From a87ac255cf7ef0672b4de865d82e6a40c93b57d8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 22 Feb 2010 13:19:34 -0800 Subject: Initial commit. lol --- .dir-locals.el | 1 + Makefile | 40 ++ ast.h | 511 ++++++++++++++++++++ ast_to_hir.cc | 1172 ++++++++++++++++++++++++++++++++++++++++++++ builtin_types.sh | 328 +++++++++++++ glsl_lexer.l | 273 +++++++++++ glsl_parser.y | 1228 +++++++++++++++++++++++++++++++++++++++++++++++ glsl_parser_extras.cc | 771 +++++++++++++++++++++++++++++ glsl_parser_extras.h | 68 +++ glsl_types.c | 159 ++++++ glsl_types.h | 141 ++++++ hash_table.c | 159 ++++++ hash_table.h | 117 +++++ hir_field_selection.cc | 187 ++++++++ hir_function.c | 41 ++ ir.cc | 116 +++++ ir.h | 302 ++++++++++++ main/imports.h | 6 + main/simple_list.h | 235 +++++++++ symbol_table.c | 377 +++++++++++++++ symbol_table.h | 63 +++ tests/parameters-01.txt | 9 + tests/parameters-02.txt | 9 + tests/parameters-03.txt | 9 + tests/swiz-01.glsl | 10 + tests/swiz-02.glsl | 10 + 26 files changed, 6342 insertions(+) create mode 100644 .dir-locals.el create mode 100644 Makefile create mode 100644 ast.h create mode 100644 ast_to_hir.cc create mode 100755 builtin_types.sh create mode 100644 glsl_lexer.l create mode 100644 glsl_parser.y create mode 100644 glsl_parser_extras.cc create mode 100644 glsl_parser_extras.h create mode 100644 glsl_types.c create mode 100644 glsl_types.h create mode 100644 hash_table.c create mode 100644 hash_table.h create mode 100644 hir_field_selection.cc create mode 100644 hir_function.c create mode 100644 ir.cc create mode 100644 ir.h create mode 100644 main/imports.h create mode 100644 main/simple_list.h create mode 100644 symbol_table.c create mode 100644 symbol_table.h create mode 100644 tests/parameters-01.txt create mode 100644 tests/parameters-02.txt create mode 100644 tests/parameters-03.txt create mode 100644 tests/swiz-01.glsl create mode 100644 tests/swiz-02.glsl diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 00000000000..148e4ca61f0 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1 @@ +((c-mode . ((c-basic-offset . 3)))) diff --git a/Makefile b/Makefile new file mode 100644 index 00000000000..2f2142ed131 --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +CSRCS = symbol_table.c hash_table.c glsl_types.c +CCSRCS = glsl_parser.tab.cc glsl_lexer.cc glsl_parser_extras.cc +# ast_to_hir.cc ir.cc hir_field_selection.cc +OBJS = $(CSRCS:.c=.o) $(CCSRCS:.cc=.o) + +CC = gcc +CXX = g++ +WARN = -Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector \ + -Wunreachable-code +CPPFLAGS = -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE +CFLAGS = -O0 -ggdb3 -fstack-protector $(CPPFLAGS) $(WARN) -std=c89 -ansi -pedantic +CXXFLAGS = -O0 -ggdb3 -fstack-protector $(CPPFLAGS) $(WARN) +LDLAGS = -ggdb3 + +glsl: $(OBJS) + $(CXX) $(LDLAGS) $(OBJS) -o glsl + +glsl_parser.tab.cc glsl_parser.tab.h: glsl_parser.y + bison --report-file=glsl_parser.output -v -d \ + --output=glsl_parser.tab.cc \ + --name-prefix=_mesa_glsl_ $< && \ + mv glsl_parser.tab.hh glsl_parser.tab.h + +glsl_lexer.cc: glsl_lexer.l + flex --outfile="glsl_lexer.cc" $< + +glsl_parser_tab.o: glsl_parser.tab.cc +glsl_types.o: glsl_types.c glsl_types.h builtin_types.h +glsl_lexer.o: glsl_lexer.cc glsl_parser.tab.h glsl_parser_extras.h ast.h +glsl_parser.o: glsl_parser_extras.h ast.h +ast_to_hir.o: ast_to_hir.cc symbol_table.h glsl_parser_extras.h ast.h glsl_types.h ir.h + +builtin_types.h: builtin_types.sh + ./builtin_types.sh > builtin_types.h + +clean: + rm -f $(OBJS) glsl + rm -f glsl_lexer.cc glsl_parser.tab.{cc,h,hh} glsl_parser.output + rm -f builtin_types.h + rm -f *~ \ No newline at end of file diff --git a/ast.h b/ast.h new file mode 100644 index 00000000000..591655d06cc --- /dev/null +++ b/ast.h @@ -0,0 +1,511 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef AST_H +#define AST_H + +#include "main/simple_list.h" +#include "glsl_parser_extras.h" + +struct ir_instruction; +struct _mesa_glsl_parse_state; + +struct YYLTYPE; + +#define _mesa_ast_print(n) \ + ((ast_node *) n)->print() + +#define _mesa_ast_to_hir(n, instr, s) \ + ((struct ast_node *) n)->vtbl->to_hir((struct ast_node *) n, instr, s) + +#define _mesa_ast_function_call_to_hir(n, p, s) \ + ((struct ast_node *) n)->vtbl->function_call_to_hir( \ + (struct ast_node *) n, \ + (struct ast_node *) p, \ + s) + +class ast_node : public simple_node { +public: + virtual ~ast_node(); + virtual void print(void) const; + + /** + * Retrieve the source location of an AST node + * + * This function is primarily used to get the source position of an AST node + * into a form that can be passed to \c _mesa_glsl_error. + * + * \sa _mesa_glsl_error, ast_node::set_location + */ + struct YYLTYPE get_location(void) const + { + struct YYLTYPE locp; + + locp.source = this->location.source; + locp.first_line = this->location.line; + locp.first_column = this->location.column; + locp.last_line = locp.first_line; + locp.last_column = locp.first_column; + + return locp; + } + + /** + * Set the source location of an AST node from a parser location + * + * \sa ast_node::get_location + */ + void set_location(const struct YYLTYPE *locp) + { + this->location.source = locp->source; + this->location.line = locp->first_line; + this->location.column = locp->first_column; + } + + + int type; + + struct { + unsigned source; + unsigned line; + unsigned column; + } location; + +protected: + ast_node(void); +}; + + +enum ast_operators { + ast_assign, + ast_plus, /**< Unary + operator. */ + ast_neg, + ast_add, + ast_sub, + ast_mul, + ast_div, + ast_mod, + ast_lshift, + ast_rshift, + ast_less, + ast_greater, + ast_lequal, + ast_gequal, + ast_equal, + ast_nequal, + ast_bit_and, + ast_bit_xor, + ast_bit_or, + ast_bit_not, + ast_logic_and, + ast_logic_xor, + ast_logic_or, + ast_logic_not, + + ast_mul_assign, + ast_div_assign, + ast_mod_assign, + ast_add_assign, + ast_sub_assign, + ast_ls_assign, + ast_rs_assign, + ast_and_assign, + ast_xor_assign, + ast_or_assign, + + ast_conditional, + + ast_pre_inc, + ast_pre_dec, + ast_post_inc, + ast_post_dec, + ast_field_selection, + ast_array_index, + + ast_function_call, + + ast_identifier, + ast_int_constant, + ast_uint_constant, + ast_float_constant, + ast_bool_constant, + + ast_sequence +}; + +class ast_expression : public ast_node { +public: + ast_expression(int oper, ast_expression *, + ast_expression *, ast_expression *); + + virtual void print(void) const; + + enum ast_operators oper; + + ast_expression *subexpressions[3]; + + union { + char *identifier; + int int_constant; + float float_constant; + unsigned uint_constant; + int bool_constant; + } primary_expression; + + + /** + * List of expressions for an \c ast_sequence. + */ + struct simple_node expressions; +}; + +/** + * Number of possible operators for an ast_expression + * + * This is done as a define instead of as an additional value in the enum so + * that the compiler won't generate spurious messages like "warning: + * enumeration value ‘ast_num_operators’ not handled in switch" + */ +#define AST_NUM_OPERATORS (ast_sequence + 1) + + +class ast_compound_statement : public ast_node { +public: + ast_compound_statement(int new_scope, ast_node *statements); + virtual void print(void) const; + + int new_scope; + struct simple_node statements; +}; + +class ast_declaration : public ast_node { +public: + ast_declaration(char *identifier, int is_array, ast_expression *array_size, + ast_expression *initializer); + virtual void print(void) const; + + char *identifier; + + int is_array; + ast_expression *array_size; + + ast_expression *initializer; +}; + + +enum { + ast_precision_high = 0, /**< Default precision. */ + ast_precision_medium, + ast_precision_low +}; + +struct ast_type_qualifier { + unsigned invariant:1; + unsigned constant:1; + unsigned attribute:1; + unsigned varying:1; + unsigned in:1; + unsigned out:1; + unsigned centroid:1; + unsigned uniform:1; + unsigned smooth:1; + unsigned flat:1; + unsigned noperspective:1; +}; + +class ast_struct_specifier : public ast_node { +public: + ast_struct_specifier(char *identifier, ast_node *declarator_list); + virtual void print(void) const; + + char *name; + struct simple_node declarations; +}; + + +enum ast_types { + ast_void, + ast_float, + ast_int, + ast_uint, + ast_bool, + ast_vec2, + ast_vec3, + ast_vec4, + ast_bvec2, + ast_bvec3, + ast_bvec4, + ast_ivec2, + ast_ivec3, + ast_ivec4, + ast_uvec2, + ast_uvec3, + ast_uvec4, + ast_mat2, + ast_mat2x3, + ast_mat2x4, + ast_mat3x2, + ast_mat3, + ast_mat3x4, + ast_mat4x2, + ast_mat4x3, + ast_mat4, + ast_sampler1d, + ast_sampler2d, + ast_sampler3d, + ast_samplercube, + ast_sampler1dshadow, + ast_sampler2dshadow, + ast_samplercubeshadow, + ast_sampler1darray, + ast_sampler2darray, + ast_sampler1darrayshadow, + ast_sampler2darrayshadow, + ast_isampler1d, + ast_isampler2d, + ast_isampler3d, + ast_isamplercube, + ast_isampler1darray, + ast_isampler2darray, + ast_usampler1d, + ast_usampler2d, + ast_usampler3d, + ast_usamplercube, + ast_usampler1darray, + ast_usampler2darray, + + ast_struct, + ast_type_name +}; + + +class ast_type_specifier : public ast_node { +public: + ast_type_specifier(int specifier); + + virtual void print(void) const; + + enum ast_types type_specifier; + + char *type_name; + ast_struct_specifier *structure; + + int is_array; + ast_expression *array_size; + + unsigned precision:2; +}; + + +class ast_fully_specified_type : public ast_node { +public: + virtual void print(void) const; + + ast_type_qualifier qualifier; + ast_type_specifier *specifier; +}; + + +class ast_declarator_list : public ast_node { +public: + ast_declarator_list(ast_fully_specified_type *); + virtual void print(void) const; + + ast_fully_specified_type *type; + struct simple_node declarations; + + /** + * Special flag for vertex shader "invariant" declarations. + * + * Vertex shaders can contain "invariant" variable redeclarations that do + * not include a type. For example, "invariant gl_Position;". This flag + * is used to note these cases when no type is specified. + */ + int invariant; +}; + + +class ast_parameter_declarator : public ast_node { +public: + virtual void print(void) const; + + ast_fully_specified_type *type; + char *identifier; + int is_array; + ast_expression *array_size; +}; + + +class ast_function : public ast_node { +public: + ast_function(void); + + virtual void print(void) const; + + ast_fully_specified_type *return_type; + char *identifier; + + struct simple_node parameters; +}; + + +class ast_declaration_statement : public ast_node { +public: + ast_declaration_statement(void); + + enum { + ast_function, + ast_declaration, + ast_precision + } mode; + + union { + class ast_function *function; + ast_declarator_list *declarator; + ast_type_specifier *type; + ast_node *node; + } declaration; +}; + + +class ast_expression_statement : public ast_node { +public: + ast_expression_statement(ast_expression *); + virtual void print(void) const; + + ast_expression *expression; +}; + + +class ast_case_label : public ast_node { +public: + + /** + * An expression of NULL means 'default'. + */ + ast_expression *expression; +}; + +class ast_selection_statement : public ast_node { +public: + ast_selection_statement(ast_expression *condition, + ast_node *then_statement, + ast_node *else_statement); + virtual void print(void) const; + + ast_expression *condition; + ast_node *then_statement; + ast_node *else_statement; +}; + + +class ast_switch_statement : public ast_node { +public: + ast_expression *expression; + struct simple_node statements; +}; + +class ast_iteration_statement : public ast_node { +public: + ast_iteration_statement(int mode, ast_node *init, ast_node *condition, + ast_expression *rest_expression, ast_node *body); + + virtual void print(void) const; + + enum ast_iteration_modes { + ast_for, + ast_while, + ast_do_while + } mode; + + + ast_node *init_statement; + ast_node *condition; + ast_expression *rest_expression; + + ast_node *body; +}; + + +class ast_jump_statement : public ast_node { +public: + ast_jump_statement(int mode, ast_expression *return_value); + virtual void print(void) const; + + enum ast_jump_modes { + ast_continue, + ast_break, + ast_return, + ast_discard + } mode; + + ast_expression *opt_return_value; +}; + + +class ast_function_definition : public ast_node { +public: + virtual void print(void) const; + + ast_function *prototype; + ast_compound_statement *body; +}; + + +extern struct ir_instruction * +ast_expression_to_hir(const ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + +extern struct ir_instruction * +ast_expression_statement_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + +extern struct ir_instruction * +ast_compound_statement_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + +extern struct ir_instruction * +ast_function_definition_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + +extern struct ir_instruction * +ast_declarator_list_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + +extern struct ir_instruction * +ast_parameter_declarator_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + +extern struct ir_instruction * +_mesa_ast_field_selection_to_hir(const struct ast_expression *expr, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + +#endif /* AST_H */ diff --git a/ast_to_hir.cc b/ast_to_hir.cc new file mode 100644 index 00000000000..8474a461ce2 --- /dev/null +++ b/ast_to_hir.cc @@ -0,0 +1,1172 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ast_to_hir.c + * Convert abstract syntax to to high-level intermediate reprensentation (HIR). + * + * During the conversion to HIR, the majority of the symantic checking is + * preformed on the program. This includes: + * + * * Symbol table management + * * Type checking + * * Function binding + * + * The majority of this work could be done during parsing, and the parser could + * probably generate HIR directly. However, this results in frequent changes + * to the parser code. Since we do not assume that every system this complier + * is built on will have Flex and Bison installed, we have to store the code + * generated by these tools in our version control system. In other parts of + * the system we've seen problems where a parser was changed but the generated + * code was not committed, merge conflicts where created because two developers + * had slightly different versions of Bison installed, etc. + * + * I have also noticed that running Bison generated parsers in GDB is very + * irritating. When you get a segfault on '$$ = $1->foo', you can't very + * well 'print $1' in GDB. + * + * As a result, my preference is to put as little C code as possible in the + * parser (and lexer) sources. + */ +#include +#include "main/imports.h" +#include "symbol_table.h" +#include "glsl_parser_extras.h" +#include "ast.h" +#include "glsl_types.h" +#include "ir.h" + +void +_mesa_generate_hir_from_ast(struct _mesa_glsl_parse_state *state) +{ + struct simple_node *ptr; + + foreach (ptr, & state->translation_unit) { + if (1) { + } + } +} + + +static const struct glsl_type * +arithmetic_result_type(const struct glsl_type *type_a, + const struct glsl_type *type_b, + bool multiply, + struct _mesa_glsl_parse_state *state) +{ + /* From GLSL 1.50 spec, page 56: + * + * "The arithmetic binary operators add (+), subtract (-), + * multiply (*), and divide (/) operate on integer and + * floating-point scalars, vectors, and matrices." + */ + if (! is_numeric_base_type(type_a->base_type) + || ! is_numeric_base_type(type_b->base_type)) { + return glsl_error_type; + } + + + /* "If one operand is floating-point based and the other is + * not, then the conversions from Section 4.1.10 "Implicit + * Conversions" are applied to the non-floating-point-based operand." + * + * This conversion was added in GLSL 1.20. If the compilation mode is + * GLSL 1.10, the conversion is skipped. + */ + if (state->language_version >= 120) { + if ((type_a->base_type == GLSL_TYPE_FLOAT) + && (type_b->base_type != GLSL_TYPE_FLOAT)) { + } else if ((type_a->base_type != GLSL_TYPE_FLOAT) + && (type_b->base_type == GLSL_TYPE_FLOAT)) { + } + } + + /* "If the operands are integer types, they must both be signed or + * both be unsigned." + * + * From this rule and the preceeding conversion it can be inferred that + * both types must be GLSL_TYPE_FLOAT, or GLSL_TYPE_UINT, or GLSL_TYPE_INT. + * The is_numeric_base_type check above already filtered out the case + * where either type is not one of these, so now the base types need only + * be tested for equality. + */ + if (type_a->base_type != type_b->base_type) { + return glsl_error_type; + } + + /* "All arithmetic binary operators result in the same fundamental type + * (signed integer, unsigned integer, or floating-point) as the + * operands they operate on, after operand type conversion. After + * conversion, the following cases are valid + * + * * The two operands are scalars. In this case the operation is + * applied, resulting in a scalar." + */ + if (is_glsl_type_scalar(type_a) && is_glsl_type_scalar(type_b)) + return type_a; + + /* "* One operand is a scalar, and the other is a vector or matrix. + * In this case, the scalar operation is applied independently to each + * component of the vector or matrix, resulting in the same size + * vector or matrix." + */ + if (is_glsl_type_scalar(type_a)) { + if (!is_glsl_type_scalar(type_b)) + return type_b; + } else if (is_glsl_type_scalar(type_b)) { + return type_a; + } + + /* All of the combinations of , , + * , , and have been + * handled. + */ + assert(type_a->vector_elements > 1); + assert(type_b->vector_elements > 1); + + /* "* The two operands are vectors of the same size. In this case, the + * operation is done component-wise resulting in the same size + * vector." + */ + if (is_glsl_type_vector(type_a) && is_glsl_type_vector(type_b)) { + if (type_a->vector_elements == type_b->vector_elements) + return type_a; + else + return glsl_error_type; + } + + /* All of the combinations of , , + * , , , and + * have been handled. At least one of the operands must + * be matrix. Further, since there are no integer matrix types, the base + * type of both operands must be float. + */ + assert((type_a->matrix_rows > 1) || (type_b->matrix_rows > 1)); + assert(type_a->base_type == GLSL_TYPE_FLOAT); + assert(type_b->base_type == GLSL_TYPE_FLOAT); + + /* "* The operator is add (+), subtract (-), or divide (/), and the + * operands are matrices with the same number of rows and the same + * number of columns. In this case, the operation is done component- + * wise resulting in the same size matrix." + * * The operator is multiply (*), where both operands are matrices or + * one operand is a vector and the other a matrix. A right vector + * operand is treated as a column vector and a left vector operand as a + * row vector. In all these cases, it is required that the number of + * columns of the left operand is equal to the number of rows of the + * right operand. Then, the multiply (*) operation does a linear + * algebraic multiply, yielding an object that has the same number of + * rows as the left operand and the same number of columns as the right + * operand. Section 5.10 "Vector and Matrix Operations" explains in + * more detail how vectors and matrices are operated on." + */ + if (! multiply) { + if (is_glsl_type_matrix(type_a) && is_glsl_type_matrix(type_b) + && (type_a->vector_elements == type_b->vector_elements) + && (type_a->matrix_rows == type_b->matrix_rows)) + return type_a; + else + return glsl_error_type; + } else { + if (is_glsl_type_matrix(type_a) && is_glsl_type_matrix(type_b)) { + if (type_a->vector_elements == type_b->matrix_rows) { + char type_name[7]; + const struct glsl_type *t; + + type_name[0] = 'm'; + type_name[1] = 'a'; + type_name[2] = 't'; + + if (type_a->matrix_rows == type_b->vector_elements) { + type_name[3] = '0' + type_a->matrix_rows; + type_name[4] = '\0'; + } else { + type_name[3] = '0' + type_a->matrix_rows; + type_name[4] = 'x'; + type_name[5] = '0' + type_b->vector_elements; + type_name[6] = '\0'; + } + + t = _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); + return (t != NULL) ? t : glsl_error_type; + } + } else if (is_glsl_type_matrix(type_a)) { + /* A is a matrix and B is a column vector. Columns of A must match + * rows of B. + */ + if (type_a->vector_elements == type_b->vector_elements) + return type_b; + } else { + assert(is_glsl_type_matrix(type_b)); + + /* A is a row vector and B is a matrix. Columns of A must match + * rows of B. + */ + if (type_a->vector_elements == type_b->matrix_rows) + return type_a; + } + } + + + /* "All other cases are illegal." + */ + return glsl_error_type; +} + + +static const struct glsl_type * +unary_arithmetic_result_type(const struct glsl_type *type) +{ + /* From GLSL 1.50 spec, page 57: + * + * "The arithmetic unary operators negate (-), post- and pre-increment + * and decrement (-- and ++) operate on integer or floating-point + * values (including vectors and matrices). All unary operators work + * component-wise on their operands. These result with the same type + * they operated on." + */ + if (!is_numeric_base_type(type->base_type)) + return glsl_error_type; + + return type; +} + + +static const struct glsl_type * +modulus_result_type(const struct glsl_type *type_a, + const struct glsl_type *type_b) +{ + /* From GLSL 1.50 spec, page 56: + * "The operator modulus (%) operates on signed or unsigned integers or + * integer vectors. The operand types must both be signed or both be + * unsigned." + */ + if (! is_integer_base_type(type_a->base_type) + || ! is_integer_base_type(type_b->base_type) + || (type_a->base_type != type_b->base_type)) { + return glsl_error_type; + } + + /* "The operands cannot be vectors of differing size. If one operand is + * a scalar and the other vector, then the scalar is applied component- + * wise to the vector, resulting in the same type as the vector. If both + * are vectors of the same size, the result is computed component-wise." + */ + if (is_glsl_type_vector(type_a)) { + if (!is_glsl_type_vector(type_b) + || (type_a->vector_elements == type_b->vector_elements)) + return type_a; + } else + return type_b; + + /* "The operator modulus (%) is not defined for any other data types + * (non-integer types)." + */ + return glsl_error_type; +} + + +static const struct glsl_type * +relational_result_type(const struct glsl_type *type_a, + const struct glsl_type *type_b, + struct _mesa_glsl_parse_state *state) +{ + /* From GLSL 1.50 spec, page 56: + * "The relational operators greater than (>), less than (<), greater + * than or equal (>=), and less than or equal (<=) operate only on + * scalar integer and scalar floating-point expressions." + */ + if (! is_numeric_base_type(type_a->base_type) + || ! is_numeric_base_type(type_b->base_type) + || ! is_glsl_type_scalar(type_a) + || ! is_glsl_type_scalar(type_b)) + return glsl_error_type; + + /* "Either the operands' types must match, or the conversions from + * Section 4.1.10 "Implicit Conversions" will be applied to the integer + * operand, after which the types must match." + * + * This conversion was added in GLSL 1.20. If the compilation mode is + * GLSL 1.10, the conversion is skipped. + */ + if (state->language_version >= 120) { + if ((type_a->base_type == GLSL_TYPE_FLOAT) + && (type_b->base_type != GLSL_TYPE_FLOAT)) { + /* FINISHME: Generate the implicit type conversion. */ + } else if ((type_a->base_type != GLSL_TYPE_FLOAT) + && (type_b->base_type == GLSL_TYPE_FLOAT)) { + /* FINISHME: Generate the implicit type conversion. */ + } + } + + if (type_a->base_type != type_b->base_type) + return glsl_error_type; + + /* "The result is scalar Boolean." + */ + return glsl_bool_type; +} + + +struct ir_instruction * +ast_expression_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_expression *expr = + (struct ast_expression *) ast; + static const int operations[AST_NUM_OPERATORS] = { + -1, /* ast_assign doesn't convert to ir_expression. */ + -1, /* ast_plus doesn't convert to ir_expression. */ + ir_unop_neg, + ir_binop_add, + ir_binop_sub, + ir_binop_mul, + ir_binop_div, + ir_binop_mod, + ir_binop_lshift, + ir_binop_rshift, + ir_binop_less, + ir_binop_greater, + ir_binop_lequal, + ir_binop_gequal, + ir_binop_equal, + ir_binop_nequal, + ir_binop_bit_and, + ir_binop_bit_xor, + ir_binop_bit_or, + ir_unop_bit_not, + ir_binop_logic_and, + ir_binop_logic_xor, + ir_binop_logic_or, + ir_unop_logic_not, + + /* Note: The following block of expression types actually convert + * to multiple IR instructions. + */ + ir_binop_mul, /* ast_mul_assign */ + ir_binop_div, /* ast_div_assign */ + ir_binop_mod, /* ast_mod_assign */ + ir_binop_add, /* ast_add_assign */ + ir_binop_sub, /* ast_sub_assign */ + ir_binop_lshift, /* ast_ls_assign */ + ir_binop_rshift, /* ast_rs_assign */ + ir_binop_bit_and, /* ast_and_assign */ + ir_binop_bit_xor, /* ast_xor_assign */ + ir_binop_bit_or, /* ast_or_assign */ + + -1, /* ast_conditional doesn't convert to ir_expression. */ + -1, /* ast_pre_inc doesn't convert to ir_expression. */ + -1, /* ast_pre_dec doesn't convert to ir_expression. */ + -1, /* ast_post_inc doesn't convert to ir_expression. */ + -1, /* ast_post_dec doesn't convert to ir_expression. */ + -1, /* ast_field_selection doesn't conv to ir_expression. */ + -1, /* ast_array_index doesn't convert to ir_expression. */ + -1, /* ast_function_call doesn't conv to ir_expression. */ + -1, /* ast_identifier doesn't convert to ir_expression. */ + -1, /* ast_int_constant doesn't convert to ir_expression. */ + -1, /* ast_uint_constant doesn't conv to ir_expression. */ + -1, /* ast_float_constant doesn't conv to ir_expression. */ + -1, /* ast_bool_constant doesn't conv to ir_expression. */ + -1, /* ast_sequence doesn't convert to ir_expression. */ + }; + struct ir_instruction *result = NULL; + struct ir_instruction *op[2]; + struct simple_node op_list; + const struct glsl_type *type = glsl_error_type; + bool error_emitted = false; + YYLTYPE loc; + + loc = ast->get_location(); + make_empty_list(& op_list); + + switch (expr->oper) { + case ast_assign: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + + error_emitted = ((op[0]->type == glsl_error_type) + || (op[1]->type == glsl_error_type)); + + type = op[0]->type; + if (!error_emitted) { + YYLTYPE loc; + + /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ + loc = expr->subexpressions[0]->get_location(); + if (op[0]->mode != ir_op_dereference) { + _mesa_glsl_error(& loc, state, "invalid lvalue in assignment"); + error_emitted = true; + + type = glsl_error_type; + } else { + const struct ir_dereference *const ref = + (struct ir_dereference *) op[0]; + const struct ir_variable *const var = + (struct ir_variable *) ref->var; + + if ((var != NULL) + && (var->mode == ir_op_var_decl) + && (var->read_only)) { + _mesa_glsl_error(& loc, state, "cannot assign to read-only " + "variable `%s'", var->name); + error_emitted = true; + + type = glsl_error_type; + } + } + } + + /* FINISHME: Check that the LHS and RHS have matching types. */ + /* FINISHME: For GLSL 1.10, check that the types are not arrays. */ + + result = new ir_assignment(op[0], op[1], NULL); + break; + + case ast_plus: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + + error_emitted = (op[0]->type == glsl_error_type); + if (type == glsl_error_type) + op[0]->type = type; + + result = op[0]; + break; + + case ast_neg: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + + type = unary_arithmetic_result_type(op[0]->type); + + error_emitted = (op[0]->type == glsl_error_type); + + result = new ir_expression(operations[expr->oper], type, + op[0], NULL); + break; + + case ast_add: + case ast_sub: + case ast_mul: + case ast_div: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + + type = arithmetic_result_type(op[0]->type, op[1]->type, + (expr->operr == ast_mul), + state); + + result = new ir_expression(operations[expr->oper], type, + op[0], op[1]); + break; + + case ast_mod: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + + error_emitted = ((op[0]->type == glsl_error_type) + || (op[1]->type == glsl_error_type)); + + type = modulus_result_type(op[0]->type, op[1]->type); + + assert(operations[expr->oper] == ir_binop_mod); + + result = new ir_expression(operations[expr->oper], type, + op[0], op[1]); + break; + + case ast_lshift: + case ast_rshift: + /* FINISHME: Implement bit-shift operators. */ + break; + + case ast_less: + case ast_greater: + case ast_lequal: + case ast_gequal: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + + error_emitted = ((op[0]->type == glsl_error_type) + || (op[1]->type == glsl_error_type)); + + type = relational_result_type(op[0]->type, op[1]->type, state); + + /* The relational operators must either generate an error or result + * in a scalar boolean. See page 57 of the GLSL 1.50 spec. + */ + assert((type == glsl_error_type) + || ((type->base_type == GLSL_TYPE_BOOL) + && is_glsl_type_scalar(type))); + + result = new ir_expression(operations[expr->oper], type, + op[0], op[1]); + break; + + case ast_nequal: + case ast_equal: + /* FINISHME: Implement equality operators. */ + break; + + case ast_bit_and: + case ast_bit_xor: + case ast_bit_or: + case ast_bit_not: + /* FINISHME: Implement bit-wise operators. */ + break; + + case ast_logic_and: + case ast_logic_xor: + case ast_logic_or: + case ast_logic_not: + /* FINISHME: Implement logical operators. */ + break; + + case ast_mul_assign: + case ast_div_assign: + case ast_add_assign: + case ast_sub_assign: { + struct ir_instruction *temp_rhs; + + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + + error_emitted = ((op[0]->type == glsl_error_type) + || (op[1]->type == glsl_error_type)); + + type = arithmetic_result_type(op[0]->type, op[1]->type, + (expr->oper == ast_mul_assign), + state); + + temp_rhs = new ir_expression(operations[expr->oper], type, + op[0], op[1]); + + /* FINISHME: Check that the LHS is assignable. */ + + /* We still have to test that the LHS and RHS have matching type. For + * example, the following GLSL code should generate a type error: + * + * mat4 m; vec4 v; m *= v; + * + * The type of (m*v) is a vec4, but the type of m is a mat4. + * + * FINISHME: Is multiplication between a matrix and a vector the only + * FINISHME: case that resuls in mismatched types? + */ + /* FINISHME: Check that the LHS and RHS have matching types. */ + + /* GLSL 1.10 does not allow array assignment. However, we don't have to + * explicitly test for this because none of the binary expression + * operators allow array operands either. + */ + + /* FINISHME: This is wrong. The operation should assign to a new + * FINISHME: temporary. This assignment should then be added to the + * FINISHME: instruction list. Another assignment to the real + * FINISHME: destination should be generated. The temporary should then + * FINISHME: be returned as the r-value. + */ + result = new ir_assignment(op[0], temp_rhs, NULL); + break; + } + + case ast_mod_assign: + + case ast_ls_assign: + case ast_rs_assign: + + case ast_and_assign: + case ast_xor_assign: + case ast_or_assign: + + case ast_conditional: + + case ast_pre_inc: + case ast_pre_dec: + + case ast_post_inc: + case ast_post_dec: + break; + + case ast_field_selection: + result = _mesa_ast_field_selection_to_hir(expr, instructions, state); + type = result->type; + break; + + case ast_array_index: + break; + + case ast_function_call: + /* There are three sorts of function calls. + * + * 1. contstructors - The first subexpression is an ast_type_specifier. + * 2. methods - Only the .length() method of array types. + * 3. functions - Calls to regular old functions. + * + * Method calls are actually detected when the ast_field_selection + * expression is handled. + */ + result = _mesa_ast_function_call_to_hir(expr->subexpressions[0], + expr->subexpressions[1], + state); + type = result->type; + break; + + case ast_identifier: { + /* ast_identifier can appear several places in a full abstract syntax + * tree. This particular use must be at location specified in the grammar + * as 'variable_identifier'. + */ + struct ir_variable *var = + _mesa_symbol_table_find_symbol(state->symbols, 0, + expr->primary_expression.identifier); + + result = new ir_dereference(var); + + if (var != NULL) { + type = result->type; + } else { + _mesa_glsl_error(& loc, NULL, "`%s' undeclared", + expr->primary_expression.identifier); + + error_emitted = true; + } + break; + } + + case ast_int_constant: + type = glsl_int_type; + result = new ir_constant(type, & expr->primary_expression); + break; + + case ast_uint_constant: + type = glsl_uint_type; + result = new ir_constant(type, & expr->primary_expression); + break; + + case ast_float_constant: + type = glsl_float_type; + result = new ir_constant(type, & expr->primary_expression); + break; + + case ast_bool_constant: + type = glsl_bool_type; + result = new ir_constant(type, & expr->primary_expression); + break; + + case ast_sequence: { + struct simple_node *ptr; + + /* It should not be possible to generate a sequence in the AST without + * any expressions in it. + */ + assert(!is_empty_list(&expr->expressions)); + + /* The r-value of a sequence is the last expression in the sequence. If + * the other expressions in the sequence do not have side-effects (and + * therefore add instructions to the instruction list), they get dropped + * on the floor. + */ + foreach (ptr, &expr->expressions) + result = _mesa_ast_to_hir(ptr, instructions, state); + + type = result->type; + + /* Any errors should have already been emitted in the loop above. + */ + error_emitted = true; + break; + } + } + + if (is_error_type(type) && !error_emitted) + _mesa_glsl_error(& loc, NULL, "type mismatch"); + + return result; +} + + +struct ir_instruction * +ast_expression_statement_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_expression_statement *stmt = + (struct ast_expression_statement *) ast; + + /* It is possible to have expression statements that don't have an + * expression. This is the solitary semicolon: + * + * for (i = 0; i < 5; i++) + * ; + * + * In this case the expression will be NULL. Test for NULL and don't do + * anything in that case. + */ + if (stmt->expression != NULL) + _mesa_ast_to_hir(stmt->expression, instructions, state); + + /* Statements do not have r-values. + */ + return NULL; +} + + +struct ir_instruction * +ast_compound_statement_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_compound_statement *stmt = + (struct ast_compound_statement *) ast; + struct simple_node *ptr; + + + if (stmt->new_scope) + _mesa_symbol_table_push_scope(state->symbols); + + foreach (ptr, &stmt->statements) + _mesa_ast_to_hir(ptr, instructions, state); + + if (stmt->new_scope) + _mesa_symbol_table_pop_scope(state->symbols); + + /* Compound statements do not have r-values. + */ + return NULL; +} + + +static const struct glsl_type * +type_specifier_to_glsl_type(const struct ast_type_specifier *spec, + const char **name, + struct _mesa_glsl_parse_state *state) +{ + static const char *const type_names[] = { + "void", + "float", + "int", + "uint", + "bool", + "vec2", + "vec3", + "vec4", + "bvec2", + "bvec3", + "bvec4", + "ivec2", + "ivec3", + "ivec4", + "uvec2", + "uvec3", + "uvec4", + "mat2", + "mat2x3", + "mat2x4", + "mat3x2", + "mat3", + "mat3x4", + "mat4x2", + "mat4x3", + "mat4", + "sampler1D", + "sampler2D", + "sampler3D", + "samplerCube", + "sampler1DShadow", + "sampler2DShadow", + "samplerCubeShadow", + "sampler1DArray", + "sampler2DArray", + "sampler1DArrayShadow", + "sampler2DArrayShadow", + "isampler1D", + "isampler2D", + "isampler3D", + "isamplerCube", + "isampler1DArray", + "isampler2DArray", + "usampler1D", + "usampler2D", + "usampler3D", + "usamplerCube", + "usampler1DArray", + "usampler2DArray", + + NULL, /* ast_struct */ + NULL /* ast_type_name */ + }; + struct glsl_type *type; + const char *type_name = NULL; + + if (spec->type_specifier == ast_struct) { + /* FINISHME: Handle annonymous structures. */ + type = NULL; + } else { + type_name = (spec->type_specifier == ast_type_name) + ? spec->type_name : type_names[spec->type_specifier]; + + type = _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); + *name = type_name; + + /* FINISHME: Handle array declarations. Note that this requires complete + * FINSIHME: handling of constant expressions. + */ + } + + return type; +} + + +static void +apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, + struct ir_variable *var, + struct _mesa_glsl_parse_state *state) +{ + if (qual->invariant) + var->invariant = 1; + + /* FINISHME: Mark 'in' variables at global scope as read-only. */ + if (qual->constant || qual->attribute || qual->uniform + || (qual->varying && (state->target == fragment_shader))) + var->read_only = 1; + + if (qual->centroid) + var->centroid = 1; + + if (qual->in && qual->out) + var->mode = ir_var_inout; + else if (qual->attribute || qual->in + || (qual->varying && (state->target == fragment_shader))) + var->mode = ir_var_in; + else if (qual->out) + var->mode = ir_var_out; + else if (qual->uniform) + var->mode = ir_var_uniform; + else + var->mode = ir_var_auto; + + if (qual->flat) + var->interpolation = ir_var_flat; + else if (qual->noperspective) + var->interpolation = ir_var_noperspective; + else + var->interpolation = ir_var_smooth; +} + + +struct ir_instruction * +ast_declarator_list_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_declarator_list *dlist = (struct ast_declarator_list *) ast; + struct simple_node *ptr; + const struct glsl_type *decl_type; + const char *type_name = NULL; + + + /* FINISHME: Handle vertex shader "invariant" declarations that do not + * FINISHME: include a type. These re-declare built-in variables to be + * FINISHME: invariant. + */ + + decl_type = type_specifier_to_glsl_type(dlist->type->specifier, + & type_name, state); + + foreach (ptr, &dlist->declarations) { + struct ast_declaration *const decl = (struct ast_declaration * )ptr; + const struct glsl_type *var_type; + struct ir_variable *var; + + + /* FINISHME: Emit a warning if a variable declaration shadows a + * FINISHME: declaration at a higher scope. + */ + + if (decl_type == NULL) { + YYLTYPE loc; + + loc = ast->get_location(); + if (type_name != NULL) { + _mesa_glsl_error(& loc, state, + "invalid type `%s' in declaration of `%s'", + type_name, decl->identifier); + } else { + _mesa_glsl_error(& loc, state, + "invalid type in declaration of `%s'", + decl->identifier); + } + continue; + } + + if (decl->is_array) { + /* FINISHME: Handle array declarations. Note that this requires + * FINISHME: complete handling of constant expressions. + */ + + /* FINISHME: Reject delcarations of multidimensional arrays. */ + } else { + var_type = decl_type; + } + + var = new ir_variable(var_type, decl->identifier); + + /* FINSIHME: Variables that are attribute, uniform, varying, in, or + * FINISHME: out varibles must be declared either at global scope or + * FINISHME: in a parameter list (in and out only). + */ + + apply_type_qualifier_to_variable(& dlist->type->qualifier, var, state); + + /* Attempt to add the variable to the symbol table. If this fails, it + * means the variable has already been declared at this scope. + */ + if (_mesa_symbol_table_add_symbol(state->symbols, 0, decl->identifier, + var) != 0) { + YYLTYPE loc = ast->get_location(); + + _mesa_glsl_error(& loc, state, "`%s' redeclared", + decl->identifier); + continue; + } + + insert_at_tail(instructions, (struct simple_node *) var); + + /* FINISHME: Process the declaration initializer. */ + } + + /* Variable declarations do not have r-values. + */ + return NULL; +} + + +struct ir_instruction * +ast_parameter_declarator_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_parameter_declarator *decl = + (struct ast_parameter_declarator *) ast; + struct ir_variable *var; + const struct glsl_type *type; + const char *name = NULL; + + + type = type_specifier_to_glsl_type(decl->type->specifier, & name, state); + + if (type == NULL) { + YYLTYPE loc = ast->get_location(); + if (name != NULL) { + _mesa_glsl_error(& loc, state, + "invalid type `%s' in declaration of `%s'", + name, decl->identifier); + } else { + _mesa_glsl_error(& loc, state, + "invalid type in declaration of `%s'", + decl->identifier); + } + + type = glsl_error_type; + } + + var = new ir_variable(type, decl->identifier); + + /* FINISHME: Handle array declarations. Note that this requires + * FINISHME: complete handling of constant expressions. + */ + + apply_type_qualifier_to_variable(& decl->type->qualifier, var, state); + + insert_at_tail(instructions, var); + + /* Parameter declarations do not have r-values. + */ + return NULL; +} + + +static void +ast_function_parameters_to_hir(struct simple_node *ast_parameters, + struct simple_node *ir_parameters, + struct _mesa_glsl_parse_state *state) +{ + struct simple_node *ptr; + + foreach (ptr, ast_parameters) { + _mesa_ast_to_hir(ptr, ir_parameters, state); + } +} + + +static bool +parameter_lists_match(struct simple_node *list_a, struct simple_node *list_b) +{ + struct simple_node *node_a; + struct simple_node *node_b; + + node_b = first_elem(list_b); + foreach (node_a, list_a) { + /* If all of the parameters from the other parameter list have been + * exhausted, the lists have different length and, by definition, + * do not match. + */ + if (at_end(list_b, node_b)) + return false; + + /* If the types of the parameters do not match, the parameters lists + * are different. + */ + /* FINISHME */ + + + node_b = next_elem(node_b); + } + + return true; +} + + +struct ir_instruction * +ast_function_definition_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_function_definition *func = + (struct ast_function_definition *) ast; + struct ir_label *label; + struct simple_node *ptr; + struct simple_node *tmp; + struct ir_function_signature *signature = NULL; + struct ir_function *f = NULL; + struct simple_node parameters; + + + /* Convert the list of function parameters to HIR now so that they can be + * used below to compare this function's signature with previously seen + * signatures for functions with the same name. + */ + make_empty_list(& parameters); + ast_function_parameters_to_hir(& func->prototype->parameters, & parameters, + state); + + + /* Verify that this function's signature either doesn't match a previously + * seen signature for a function with the same name, or, if a match is found, + * that the previously seen signature does not have an associated definition. + */ + f = _mesa_symbol_table_find_symbol(state->symbols, 0, + func->prototype->identifier); + if (f != NULL) { + foreach (ptr, & f->signatures) { + signature = (struct ir_function_signature *) ptr; + + /* Compare the parameter list of the function being defined to the + * existing function. If the parameter lists match, then the return + * type must also match and the existing function must not have a + * definition. + */ + if (parameter_lists_match(& parameters, & signature->parameters)) { + /* FINISHME: Compare return types. */ + + if (signature->definition != NULL) { + YYLTYPE loc = ast->get_location(); + + _mesa_glsl_error(& loc, state, "function `%s' redefined", + func->prototype->identifier); + signature = NULL; + break; + } + } + + signature = NULL; + } + + } else { + f = new ir_function(); + f->name = func->prototype->identifier; + + _mesa_symbol_table_add_symbol(state->symbols, 0, f->name, f); + } + + + /* Finish storing the information about this new function in its signature. + */ + if (signature == NULL) { + signature = new ir_function_signature(); + insert_at_tail(& f->signatures, (struct simple_node *) signature); + } else { + /* Destroy all of the previous parameter information. The previous + * parameter information comes from the function prototype, and it can + * either include invalid parameter names or may not have names at all. + */ + foreach_s(ptr, tmp, & signature->parameters) { + assert(((struct ir_instruction *)ptr)->mode == ir_op_var_decl); + + remove_from_list(ptr); + free(ptr); + } + } + + + ast_function_parameters_to_hir(& func->prototype->parameters, + & signature->parameters, + state); + /* FINISHME: Set signature->return_type */ + + label = new ir_label(func->prototype->identifier); + if (signature->definition == NULL) { + signature->definition = label; + } + insert_at_tail(instructions, label); + + /* Add the function parameters to the symbol table. During this step the + * parameter declarations are also moved from the temporary "parameters" list + * to the instruction list. There are other more efficient ways to do this, + * but they involve ugly linked-list gymnastics. + */ + _mesa_symbol_table_push_scope(state->symbols); + foreach_s(ptr, tmp, & parameters) { + struct ir_variable *const var = (struct ir_variable *) ptr; + + assert(var->mode == ir_op_var_decl); + + remove_from_list(ptr); + insert_at_tail(instructions, ptr); + + _mesa_symbol_table_add_symbol(state->symbols, 0, var->name, var); + } + + /* Convert the body of the function to HIR, and append the resulting + * instructions to the list that currently consists of the function label + * and the function parameters. + */ + _mesa_ast_to_hir(func->body, instructions, state); + + _mesa_symbol_table_pop_scope(state->symbols); + + + /* Function definitions do not have r-values. + */ + return NULL; +} diff --git a/builtin_types.sh b/builtin_types.sh new file mode 100755 index 00000000000..19dcbaf124e --- /dev/null +++ b/builtin_types.sh @@ -0,0 +1,328 @@ +#!/bin/sh +# +# Copyright © 2009 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +# gen_integral_type +function gen_integral_type +{ + printf ' { %17s, 0, 0, 0, 0, %u, %u, "%s", 0, {NULL} },\n' $2 $3 $4 $1 + index=$((index + 1)) +} + +# gen_struct_type +function gen_struct_type +{ + elements=$(printf "%s_fields" $1) + printf ' {\n GLSL_TYPE_STRUCT, 0, 0, 0, 0, 0, 0, "%s",\n Elements(%s),\n {(void *) %s}\n },\n' \ + $1 $elements $elements +} + +# gen_sampler_type +function gen_sampler_type +{ + name=$(printf "sampler%s" $1) + + if [ $4 -eq 1 ]; then + name=$(printf "%sArray" $name) + fi + + if [ $3 -eq 1 ]; then + name=$(printf "%sShadow" $name) + fi + + if [ $5 == GLSL_TYPE_INT ]; then + name=$(printf "i%s" $name) + elif [ $5 == GLSL_TYPE_UINT ]; then + name=$(printf "u%s" $name) + fi + + printf ' { GLSL_TYPE_SAMPLER, %21s, %u, %u, %15s, 0, 0,\n "%s", 0, {NULL} },\n' \ + $2 $3 $4 $5 $name +} + +function gen_header +{ + if [ x$1 == x ]; then + name="builtin_types" + else + name="builtin_${1}_types" + fi + + printf "\nstatic const struct glsl_type %s[] = {\n" $name +} + +function gen_footer +{ + printf "};\n" +} + +function gen_struct_field_header +{ + printf "\nstatic const struct glsl_struct_field %s_fields[] = {\n" $1 +} + +function gen_struct_field_footer +{ + printf "};\n" +} + +function gen_struct_field +{ + printf ' { & %s[%2u], "%s" },\n' $1 $2 "$3" +} + +cat <source = 0; \ + yylloc->first_column = yycolumn + 1; \ + yylloc->first_line = yylineno + 1; \ + yycolumn += yyleng; \ + } while(0); + +%} + +%option bison-bridge bison-locations reentrant noyywrap +%option never-interactive +%option prefix="_mesa_glsl_" +%option extra-type="struct _mesa_glsl_parse_state *" +%option stack + +%x PP COMMENT + +%% + +"/*" { yy_push_state(COMMENT, yyscanner); } +[^*\n]* +[^*\n]*\n { yylineno++; yycolumn = 0; } +"*"+[^*/\n]* +"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; } +"*"+"/" { yy_pop_state(yyscanner); } + +\/\/.*\n { yylineno++; yycolumn = 0; } +[ \r\t]+ ; + + /* Preprocessor tokens. */ +^[ \t]*#[ \t]*$ ; +^[ \t]*#[ \t]*version { BEGIN PP; return VERSION; } +^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; } +^[ \t]*#[ \t]*line { BEGIN PP; return LINE; } +^[ \t]*#[ \t]*pragma { BEGIN PP; return PRAGMA; } +: return COLON; +[_a-zA-Z][_a-zA-Z0-9]* { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } +[1-9][0-9]* { + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } +\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } + +\n { yylineno++; yycolumn = 0; } + +attribute return ATTRIBUTE; +const return CONST; +bool return BOOL; +float return FLOAT; +int return INT; + +break return BREAK; +continue return CONTINUE; +do return DO; +while return WHILE; +else return ELSE; +for return FOR; +if return IF; +discard return DISCARD; +return return RETURN; + +bvec2 return BVEC2; +bvec3 return BVEC3; +bvec4 return BVEC4; +ivec2 return IVEC2; +ivec3 return IVEC3; +ivec4 return IVEC4; +vec2 return VEC2; +vec3 return VEC3; +vec4 return VEC4; +mat2 return MAT2; +mat3 return MAT3; +mat4 return MAT4; +mat2x2 return MAT2X2; +mat2x3 return MAT2X3; +mat2x4 return MAT2X4; +mat3x2 return MAT3X2; +mat3x3 return MAT3X3; +mat3x4 return MAT3X4; +mat4x2 return MAT4X2; +mat4x3 return MAT4X3; +mat4x4 return MAT4X4; + +in return IN; +out return OUT; +inout return INOUT; +uniform return UNIFORM; +varying return VARYING; +centroid return CENTROID; +invariant return INVARIANT; + +sampler1D return SAMPLER1D; +sampler2D return SAMPLER2D; +sampler3D return SAMPLER3D; +samplerCube return SAMPLERCUBE; +sampler1DShadow return SAMPLER1DSHADOW; +sampler2DShadow return SAMPLER2DSHADOW; + +struct return STRUCT; +void return VOID; + +\+\+ return INC_OP; +-- return DEC_OP; +\<= return LE_OP; +>= return GE_OP; +== return EQ_OP; +!= return NE_OP; +&& return AND_OP; +\|\| return OR_OP; +"^^" return XOR_OP; + +\*= return MUL_ASSIGN; +\/= return DIV_ASSIGN; +\+= return ADD_ASSIGN; +\%= return MOD_ASSIGN; +\<\<= return LEFT_ASSIGN; +>>= return RIGHT_ASSIGN; +&= return AND_ASSIGN; +^= return XOR_ASSIGN; +\|= return OR_ASSIGN; +-= return SUB_ASSIGN; + +[1-9][0-9]* { + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } +0[xX][0-9a-fA-F]+ { + yylval->n = strtol(yytext + 2, NULL, 16); + return INTCONSTANT; + } +0[0-7]* { + yylval->n = strtol(yytext + 2, NULL, 8); + return INTCONSTANT; + } + +[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } +\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } +[0-9]+\.([eE][+-]?[0-9]+)?[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } +[0-9]+[eE][+-]?[0-9]+[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } + +true { + yylval->n = 1; + return BOOLCONSTANT; + } +false { + yylval->n = 0; + return BOOLCONSTANT; + } + + + /* Reserved words in GLSL 1.10. */ +asm return ASM; +class return CLASS; +union return UNION; +enum return ENUM; +typedef return TYPEDEF; +template return TEMPLATE; +this return THIS; +packed return PACKED; +goto return GOTO; +switch return SWITCH; +default return DEFAULT; +inline return INLINE; +noinline return NOINLINE; +volatile return VOLATILE; +public return PUBLIC; +static return STATIC; +extern return EXTERN; +external return EXTERNAL; +interface return INTERFACE; +long return LONG; +short return SHORT; +double return DOUBLE; +half return HALF; +fixed return FIXED; +unsigned return UNSIGNED; +input return INPUT; +output return OUTPUT; +hvec2 return HVEC2; +hvec3 return HVEC3; +hvec4 return HVEC4; +dvec2 return DVEC2; +dvec3 return DVEC3; +dvec4 return DVEC4; +fvec2 return FVEC2; +fvec3 return FVEC3; +fvec4 return FVEC4; +sampler2DRect return SAMPLER2DRECT; +sampler3DRect return SAMPLER3DRECT; +sampler2DRectShadow return SAMPLER2DRECTSHADOW; +sizeof return SIZEOF; +cast return CAST; +namespace return NAMESPACE; +using return USING; + + /* Additional reserved words in GLSL 1.20. */ +lowp return LOWP; +mediump return MEDIUMP; +highp return HIGHP; +precision return PRECISION; + +[_a-zA-Z][_a-zA-Z0-9]* { + yylval->identifier = strdup(yytext); + + if (_mesa_symbol_table_find_symbol(yyextra->symbols, + 0, + yylval->identifier)) + return TYPE_NAME; + else + return IDENTIFIER; + } + +. { return yytext[0]; } + +%% + +void +_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, + const char *string, size_t len) +{ + yylex_init_extra(state, & state->scanner); + yy_scan_bytes(string, len, state->scanner); +} + +void +_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) +{ + yylex_destroy(state->scanner); +} diff --git a/glsl_parser.y b/glsl_parser.y new file mode 100644 index 00000000000..f9bfb0bc812 --- /dev/null +++ b/glsl_parser.y @@ -0,0 +1,1228 @@ +%{ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "symbol_table.h" +#include "glsl_types.h" + +#define YYLEX_PARAM state->scanner + +%} + +%pure-parser +%locations +%error-verbose + +%lex-param {void *scanner} +%parse-param {struct _mesa_glsl_parse_state *state} + +%union { + int n; + float real; + char *identifier; + + union { + struct ast_type_qualifier q; + unsigned i; + } type_qualifier; + + struct ast_node *node; + struct ast_type_specifier *type_specifier; + struct ast_fully_specified_type *fully_specified_type; + struct ast_function *function; + struct ast_parameter_declarator *parameter_declarator; + struct ast_function_definition *function_definition; + struct ast_compound_statement *compound_statement; + struct ast_expression *expression; + struct ast_declarator_list *declarator_list; + struct ast_struct_specifier *struct_specifier; + struct ast_declaration *declaration; + + struct { + struct ast_node *cond; + struct ast_expression *rest; + } for_rest_statement; +} + +%token ATTRIBUTE CONST BOOL FLOAT INT UINT +%token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT +%token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 +%token MAT2 MAT3 MAT4 CENTROID IN OUT INOUT UNIFORM VARYING +%token NOPERSPECTIVE FLAT SMOOTH +%token MAT2X2 MAT2X3 MAT2X4 +%token MAT3X2 MAT3X3 MAT3X4 +%token MAT4X2 MAT4X3 MAT4X4 +%token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW +%token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW +%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE +%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D +%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY +%token STRUCT VOID WHILE +%token IDENTIFIER TYPE_NAME +%token FLOATCONSTANT +%token INTCONSTANT UINTCONSTANT BOOLCONSTANT +%token FIELD_SELECTION +%token LEFT_OP RIGHT_OP +%token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP +%token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN +%token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN +%token SUB_ASSIGN +%token INVARIANT +%token HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION + +%token VERSION EXTENSION LINE PRAGMA COLON EOL INTERFACE OUTPUT + + /* Reserved words that are not actually used in the grammar. + */ +%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED GOTO +%token INLINE NOINLINE VOLATILE PUBLIC STATIC EXTERN EXTERNAL +%token LONG SHORT DOUBLE HALF FIXED UNSIGNED INPUT OUPTUT +%token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 +%token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW +%token SIZEOF CAST NAMESPACE USING LOWP MEDIUMP HIGHP + +%type variable_identifier +%type statement +%type statement_list +%type simple_statement +%type statement_matched +%type statement_unmatched +%type precision_qualifier +%type type_qualifier +%type storage_qualifier +%type interpolation_qualifier +%type type_specifier +%type type_specifier_no_prec +%type type_specifier_nonarray +%type basic_type_specifier_nonarray +%type fully_specified_type +%type function_prototype +%type function_header +%type function_header_with_parameters +%type function_declarator +%type parameter_declarator +%type parameter_declaration +%type parameter_qualifier +%type parameter_type_qualifier +%type parameter_type_specifier +%type function_definition +%type compound_statement_no_new_scope +%type compound_statement +%type statement_no_new_scope +%type expression_statement +%type expression +%type primary_expression +%type assignment_expression +%type conditional_expression +%type logical_or_expression +%type logical_xor_expression +%type logical_and_expression +%type inclusive_or_expression +%type exclusive_or_expression +%type and_expression +%type equality_expression +%type relational_expression +%type shift_expression +%type additive_expression +%type multiplicative_expression +%type unary_expression +%type constant_expression +%type integer_expression +%type postfix_expression +%type function_call_header_with_parameters +%type function_call_header_no_parameters +%type function_call_header +%type function_call_generic +%type function_call_or_method +%type function_call +%type assignment_operator +%type unary_operator +%type function_identifier +%type external_declaration +%type init_declarator_list +%type single_declaration +%type initializer +%type declaration +%type declaration_statement +%type jump_statement +%type struct_specifier +%type struct_declaration_list +%type struct_declaration +%type struct_declarator +%type struct_declarator_list +%type selection_statement_matched +%type selection_statement_unmatched +%type iteration_statement +%type condition +%type conditionopt +%type for_init_statement +%type for_rest_statement +%% + +translation_unit: + version_statement + { + _mesa_glsl_initialize_types(state); + } + external_declaration_list + | + { + state->language_version = 110; + _mesa_glsl_initialize_types(state); + } + external_declaration_list + ; + +version_statement: + VERSION INTCONSTANT EOL + { + switch ($2) { + case 110: + case 120: + case 130: + /* FINISHME: Check against implementation support versions. */ + state->language_version = $2; + break; + default: + _mesa_glsl_error(& @2, state, "Shading language version" + "%u is not supported\n", $2); + break; + } + } + ; + +external_declaration_list: + external_declaration + { + insert_at_tail(& state->translation_unit, + (struct simple_node *) $1); + } + | external_declaration_list external_declaration + { + insert_at_tail(& state->translation_unit, + (struct simple_node *) $2); + } + ; + +variable_identifier: + IDENTIFIER + ; + +primary_expression: + variable_identifier + { + $$ = new ast_expression(ast_identifier, NULL, NULL, NULL); + $$->primary_expression.identifier = $1; + } + | INTCONSTANT + { + $$ = new ast_expression(ast_int_constant, NULL, NULL, NULL); + $$->primary_expression.int_constant = $1; + } + | UINTCONSTANT + { + $$ = new ast_expression(ast_uint_constant, NULL, NULL, NULL); + $$->primary_expression.uint_constant = $1; + } + | FLOATCONSTANT + { + $$ = new ast_expression(ast_float_constant, NULL, NULL, NULL); + $$->primary_expression.float_constant = $1; + } + | BOOLCONSTANT + { + $$ = new ast_expression(ast_bool_constant, NULL, NULL, NULL); + $$->primary_expression.bool_constant = $1; + } + | '(' expression ')' + { + $$ = $2; + } + ; + +postfix_expression: + primary_expression + | postfix_expression '[' integer_expression ']' + { + $$ = new ast_expression(ast_array_index, $1, $3, NULL); + } + | function_call + { + $$ = $1; + } + | postfix_expression '.' IDENTIFIER + { + $$ = new ast_expression(ast_field_selection, $1, NULL, NULL); + $$->primary_expression.identifier = $3; + } + | postfix_expression INC_OP + { + $$ = new ast_expression(ast_post_inc, $1, NULL, NULL); + } + | postfix_expression DEC_OP + { + $$ = new ast_expression(ast_post_dec, $1, NULL, NULL); + } + ; + +integer_expression: + expression + ; + +function_call: + function_call_or_method + ; + +function_call_or_method: + function_call_generic + | postfix_expression '.' function_call_generic + { + $$ = new ast_expression(ast_field_selection, $1, $3, NULL); + } + ; + +function_call_generic: + function_call_header_with_parameters ')' + | function_call_header_no_parameters ')' + ; + +function_call_header_no_parameters: + function_call_header VOID + | function_call_header + ; + +function_call_header_with_parameters: + function_call_header assignment_expression + { + $$ = $1; + $$->subexpressions[1] = $2; + } + | function_call_header_with_parameters ',' assignment_expression + { + $$ = $1; + insert_at_tail((struct simple_node *) $$->subexpressions[1], + (struct simple_node *) $3); + } + ; + + // Grammar Note: Constructors look like functions, but lexical + // analysis recognized most of them as keywords. They are now + // recognized through "type_specifier". +function_call_header: + function_identifier '(' + { + $$ = new ast_expression(ast_function_call, + (struct ast_expression *) $1, + NULL, NULL); + } + ; + +function_identifier: + type_specifier + { + $$ = (struct ast_node *) $1; + } + | IDENTIFIER + { + ast_expression *expr = + new ast_expression(ast_identifier, NULL, NULL, NULL); + expr->primary_expression.identifier = $1; + + $$ = (struct ast_node *) expr; + } + | FIELD_SELECTION + { + ast_expression *expr = + new ast_expression(ast_identifier, NULL, NULL, NULL); + expr->primary_expression.identifier = $1; + + $$ = (struct ast_node *) expr; + } + ; + + // Grammar Note: No traditional style type casts. +unary_expression: + postfix_expression + | INC_OP unary_expression + { + $$ = new ast_expression(ast_pre_inc, $2, NULL, NULL); + } + | DEC_OP unary_expression + { + $$ = new ast_expression(ast_pre_dec, $2, NULL, NULL); + } + | unary_operator unary_expression + { + $$ = new ast_expression($1, $2, NULL, NULL); + } + ; + + // Grammar Note: No '*' or '&' unary ops. Pointers are not supported. +unary_operator: + '+' { $$ = ast_plus; } + | '-' { $$ = ast_neg; } + | '!' { $$ = ast_logic_not; } + | '~' { $$ = ast_bit_not; } + ; + +multiplicative_expression: + unary_expression + | multiplicative_expression '*' unary_expression + { + $$ = new ast_expression(ast_mul, $1, $3, NULL); + } + | multiplicative_expression '/' unary_expression + { + $$ = new ast_expression(ast_div, $1, $3, NULL); + } + | multiplicative_expression '%' unary_expression + { + $$ = new ast_expression(ast_mod, $1, $3, NULL); + } + ; + +additive_expression: + multiplicative_expression + | additive_expression '+' multiplicative_expression + { + $$ = new ast_expression(ast_add, $1, $3, NULL); + } + | additive_expression '-' multiplicative_expression + { + $$ = new ast_expression(ast_sub, $1, $3, NULL); + } + ; + +shift_expression: + additive_expression + | shift_expression LEFT_OP additive_expression + { + $$ = new ast_expression(ast_lshift, $1, $3, NULL); + } + | shift_expression RIGHT_OP additive_expression + { + $$ = new ast_expression(ast_rshift, $1, $3, NULL); + } + ; + +relational_expression: + shift_expression + | relational_expression '<' shift_expression + { + $$ = new ast_expression(ast_less, $1, $3, NULL); + } + | relational_expression '>' shift_expression + { + $$ = new ast_expression(ast_greater, $1, $3, NULL); + } + | relational_expression LE_OP shift_expression + { + $$ = new ast_expression(ast_lequal, $1, $3, NULL); + } + | relational_expression GE_OP shift_expression + { + $$ = new ast_expression(ast_gequal, $1, $3, NULL); + } + ; + +equality_expression: + relational_expression + | equality_expression EQ_OP relational_expression + { + $$ = new ast_expression(ast_equal, $1, $3, NULL); + } + | equality_expression NE_OP relational_expression + { + $$ = new ast_expression(ast_nequal, $1, $3, NULL); + } + ; + +and_expression: + equality_expression + | and_expression '&' equality_expression + { + $$ = new ast_expression(ast_bit_or, $1, $3, NULL); + } + ; + +exclusive_or_expression: + and_expression + | exclusive_or_expression '^' and_expression + { + $$ = new ast_expression(ast_bit_xor, $1, $3, NULL); + } + ; + +inclusive_or_expression: + exclusive_or_expression + | inclusive_or_expression '|' exclusive_or_expression + { + $$ = new ast_expression(ast_bit_or, $1, $3, NULL); + } + ; + +logical_and_expression: + inclusive_or_expression + | logical_and_expression AND_OP inclusive_or_expression + { + $$ = new ast_expression(ast_logic_and, $1, $3, NULL); + } + ; + +logical_xor_expression: + logical_and_expression + | logical_xor_expression XOR_OP logical_and_expression + { + $$ = new ast_expression(ast_logic_xor, $1, $3, NULL); + } + ; + +logical_or_expression: + logical_xor_expression + | logical_or_expression OR_OP logical_xor_expression + { + $$ = new ast_expression(ast_logic_or, $1, $3, NULL); + } + ; + +conditional_expression: + logical_or_expression + | logical_or_expression '?' expression ':' assignment_expression + { + $$ = new ast_expression(ast_conditional, $1, $3, $5); + } + ; + +assignment_expression: + conditional_expression + | unary_expression assignment_operator assignment_expression + { + $$ = new ast_expression($2, $1, $3, NULL); + } + ; + +assignment_operator: + '=' { $$ = ast_assign; } + | MUL_ASSIGN { $$ = ast_mul_assign; } + | DIV_ASSIGN { $$ = ast_div_assign; } + | MOD_ASSIGN { $$ = ast_mod_assign; } + | ADD_ASSIGN { $$ = ast_add_assign; } + | SUB_ASSIGN { $$ = ast_sub_assign; } + | LEFT_ASSIGN { $$ = ast_ls_assign; } + | RIGHT_ASSIGN { $$ = ast_rs_assign; } + | AND_ASSIGN { $$ = ast_and_assign; } + | XOR_ASSIGN { $$ = ast_xor_assign; } + | OR_ASSIGN { $$ = ast_or_assign; } + ; + +expression: + assignment_expression + { + $$ = $1; + } + | expression ',' assignment_expression + { + if ($1->oper != ast_sequence) { + $$ = new ast_expression(ast_sequence, NULL, NULL, NULL); + insert_at_tail(& $$->expressions, $1); + } else { + $$ = $1; + } + + insert_at_tail(& $$->expressions, $3); + } + ; + +constant_expression: + conditional_expression + ; + +declaration: + function_prototype ';' + { + $$ = $1; + } + | init_declarator_list ';' + { + $$ = $1; + } + | PRECISION precision_qualifier type_specifier_no_prec ';' + { + $$ = NULL; /* FINISHME */ + } + ; + +function_prototype: + function_declarator ')' + ; + +function_declarator: + function_header + | function_header_with_parameters + ; + +function_header_with_parameters: + function_header parameter_declaration + { + $$ = $1; + insert_at_head(& $$->parameters, + (struct simple_node *) $2); + } + | function_header_with_parameters ',' parameter_declaration + { + $$ = $1; + insert_at_head(& $$->parameters, + (struct simple_node *) $3); + } + ; + +function_header: + fully_specified_type IDENTIFIER '(' + { + $$ = new ast_function(); + $$->return_type = $1; + $$->identifier = $2; + } + ; + +parameter_declarator: + type_specifier IDENTIFIER + { + $$ = new ast_parameter_declarator(); + $$->type = new ast_fully_specified_type(); + $$->type->specifier = $1; + $$->identifier = $2; + } + | type_specifier IDENTIFIER '[' constant_expression ']' + { + $$ = new ast_parameter_declarator(); + $$->type = new ast_fully_specified_type(); + $$->type->specifier = $1; + $$->identifier = $2; + $$->is_array = true; + $$->array_size = $4; + } + ; + +parameter_declaration: + parameter_type_qualifier parameter_qualifier parameter_declarator + { + $1.i |= $2.i; + + $$ = $3; + $$->type->qualifier = $1.q; + } + | parameter_qualifier parameter_declarator + { + $$ = $2; + $$->type->qualifier = $1.q; + } + | parameter_type_qualifier parameter_qualifier parameter_type_specifier + { + $1.i |= $2.i; + + $$ = new ast_parameter_declarator(); + $$->type = new ast_fully_specified_type(); + $$->type->qualifier = $1.q; + $$->type->specifier = $3; + } + | parameter_qualifier parameter_type_specifier + { + $$ = new ast_parameter_declarator(); + $$->type = new ast_fully_specified_type(); + $$->type->qualifier = $1.q; + $$->type->specifier = $2; + } + ; + +parameter_qualifier: + /* empty */ { $$.i = 0; } + | IN { $$.i = 0; $$.q.in = 1; } + | OUT { $$.i = 0; $$.q.out = 1; } + | INOUT { $$.i = 0; $$.q.in = 1; $$.q.out = 1; } + ; + +parameter_type_specifier: + type_specifier + ; + +init_declarator_list: + single_declaration + | init_declarator_list ',' IDENTIFIER + { + ast_declaration *decl = new ast_declaration($3, false, NULL, NULL); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | init_declarator_list ',' IDENTIFIER '[' ']' + { + ast_declaration *decl = new ast_declaration($3, true, NULL, NULL); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' + { + ast_declaration *decl = new ast_declaration($3, true, $5, NULL); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer + { + ast_declaration *decl = new ast_declaration($3, true, NULL, $7); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer + { + ast_declaration *decl = new ast_declaration($3, true, $5, $8); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | init_declarator_list ',' IDENTIFIER '=' initializer + { + ast_declaration *decl = new ast_declaration($3, false, NULL, $5); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + ; + + // Grammar Note: No 'enum', or 'typedef'. +single_declaration: + fully_specified_type + { + $$ = new ast_declarator_list($1); + } + | fully_specified_type IDENTIFIER + { + ast_declaration *decl = new ast_declaration($2, false, NULL, NULL); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | fully_specified_type IDENTIFIER '[' ']' + { + ast_declaration *decl = new ast_declaration($2, true, NULL, NULL); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | fully_specified_type IDENTIFIER '[' constant_expression ']' + { + ast_declaration *decl = new ast_declaration($2, true, $4, NULL); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | fully_specified_type IDENTIFIER '[' ']' '=' initializer + { + ast_declaration *decl = new ast_declaration($2, true, NULL, $6); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer + { + ast_declaration *decl = new ast_declaration($2, true, $4, $7); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | fully_specified_type IDENTIFIER '=' initializer + { + ast_declaration *decl = new ast_declaration($2, false, NULL, $4); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | INVARIANT IDENTIFIER // Vertex only. + { + ast_declaration *decl = new ast_declaration($2, false, NULL, NULL); + + $$ = new ast_declarator_list(NULL); + $$->invariant = true; + + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + ; + +fully_specified_type: + type_specifier + { + $$ = new ast_fully_specified_type(); + $$->specifier = $1; + } + | type_qualifier type_specifier + { + $$ = new ast_fully_specified_type(); + $$->qualifier = $1.q; + $$->specifier = $2; + } + ; + +interpolation_qualifier: + SMOOTH { $$.i = 0; $$.q.smooth = 1; } + | FLAT { $$.i = 0; $$.q.flat = 1; } + | NOPERSPECTIVE { $$.i = 0; $$.q.noperspective = 1; } + ; + +parameter_type_qualifier: + CONST { $$.i = 0; $$.q.constant = 1; } + ; + +type_qualifier: + storage_qualifier + | interpolation_qualifier type_qualifier + { + $$.i = $1.i | $2.i; + } + | INVARIANT type_qualifier + { + $$ = $2; + $$.q.invariant = 1; + } + ; + +storage_qualifier: + CONST { $$.i = 0; $$.q.constant = 1; } + | ATTRIBUTE { $$.i = 0; $$.q.attribute = 1; } + | VARYING { $$.i = 0; $$.q.varying = 1; } + | CENTROID VARYING { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; } + | IN { $$.i = 0; $$.q.in = 1; } + | OUT { $$.i = 0; $$.q.out = 1; } + | CENTROID IN { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; } + | CENTROID OUT { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; } + | UNIFORM { $$.i = 0; $$.q.uniform = 1; } + ; + +type_specifier: + type_specifier_no_prec + | precision_qualifier type_specifier_no_prec + { + $$ = $2; + $$->precision = $1; + } + ; + +type_specifier_no_prec: + type_specifier_nonarray + | type_specifier_nonarray '[' ']' + { + $$ = $1; + $$->is_array = true; + $$->array_size = NULL; + } + | type_specifier_nonarray '[' constant_expression ']' + { + $$ = $1; + $$->is_array = true; + $$->array_size = $3; + } + ; + +type_specifier_nonarray: + basic_type_specifier_nonarray + { + $$ = new ast_type_specifier($1); + } + | struct_specifier + { + $$ = new ast_type_specifier(ast_struct); + $$->structure = $1; + } + | TYPE_NAME + { + $$ = new ast_type_specifier(ast_type_name); + $$->type_name = $1; + } + ; + +basic_type_specifier_nonarray: + VOID { $$ = ast_void; } + | FLOAT { $$ = ast_float; } + | INT { $$ = ast_int; } + | UINT { $$ = ast_uint; } + | BOOL { $$ = ast_bool; } + | VEC2 { $$ = ast_vec2; } + | VEC3 { $$ = ast_vec3; } + | VEC4 { $$ = ast_vec4; } + | BVEC2 { $$ = ast_bvec2; } + | BVEC3 { $$ = ast_bvec3; } + | BVEC4 { $$ = ast_bvec4; } + | IVEC2 { $$ = ast_ivec2; } + | IVEC3 { $$ = ast_ivec3; } + | IVEC4 { $$ = ast_ivec4; } + | UVEC2 { $$ = ast_uvec2; } + | UVEC3 { $$ = ast_uvec3; } + | UVEC4 { $$ = ast_uvec4; } + | MAT2 { $$ = ast_mat2; } + | MAT3 { $$ = ast_mat3; } + | MAT4 { $$ = ast_mat4; } + | MAT2X2 { $$ = ast_mat2; } + | MAT2X3 { $$ = ast_mat2x3; } + | MAT2X4 { $$ = ast_mat2x4; } + | MAT3X2 { $$ = ast_mat3x2; } + | MAT3X3 { $$ = ast_mat3; } + | MAT3X4 { $$ = ast_mat3x4; } + | MAT4X2 { $$ = ast_mat4x2; } + | MAT4X3 { $$ = ast_mat4x3; } + | MAT4X4 { $$ = ast_mat4; } + | SAMPLER1D { $$ = ast_sampler1d; } + | SAMPLER2D { $$ = ast_sampler2d; } + | SAMPLER3D { $$ = ast_sampler3d; } + | SAMPLERCUBE { $$ = ast_samplercube; } + | SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; } + | SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; } + | SAMPLERCUBESHADOW { $$ = ast_samplercubeshadow; } + | SAMPLER1DARRAY { $$ = ast_sampler1darray; } + | SAMPLER2DARRAY { $$ = ast_sampler2darray; } + | SAMPLER1DARRAYSHADOW { $$ = ast_sampler1darrayshadow; } + | SAMPLER2DARRAYSHADOW { $$ = ast_sampler2darrayshadow; } + | ISAMPLER1D { $$ = ast_isampler1d; } + | ISAMPLER2D { $$ = ast_isampler2d; } + | ISAMPLER3D { $$ = ast_isampler3d; } + | ISAMPLERCUBE { $$ = ast_isamplercube; } + | ISAMPLER1DARRAY { $$ = ast_isampler1darray; } + | ISAMPLER2DARRAY { $$ = ast_isampler2darray; } + | USAMPLER1D { $$ = ast_usampler1d; } + | USAMPLER2D { $$ = ast_usampler2d; } + | USAMPLER3D { $$ = ast_usampler3d; } + | USAMPLERCUBE { $$ = ast_usamplercube; } + | USAMPLER1DARRAY { $$ = ast_usampler1darray; } + | USAMPLER2DARRAY { $$ = ast_usampler2darray; } + ; + +precision_qualifier: + HIGH_PRECISION { $$ = ast_precision_high; } + | MEDIUM_PRECISION { $$ = ast_precision_medium; } + | LOW_PRECISION { $$ = ast_precision_low; } + ; + +struct_specifier: + STRUCT IDENTIFIER '{' struct_declaration_list '}' + { + $$ = new ast_struct_specifier($2, $4); + + _mesa_symbol_table_add_symbol(state->symbols, 0, $2, $$); + } + | STRUCT '{' struct_declaration_list '}' + { + $$ = new ast_struct_specifier(NULL, $3); + } + ; + +struct_declaration_list: + struct_declaration + { + $$ = (struct ast_node *) $1; + } + | struct_declaration_list struct_declaration + { + $$ = (struct ast_node *) $1; + insert_at_tail((struct simple_node *) $$, + (struct simple_node *) $2); + } + ; + +struct_declaration: + type_specifier struct_declarator_list ';' + { + ast_fully_specified_type *type = new ast_fully_specified_type(); + + type->specifier = $1; + $$ = new ast_declarator_list(type); + + insert_at_tail((struct simple_node *) $2, + & $$->declarations); + } + ; + +struct_declarator_list: + struct_declarator + | struct_declarator_list ',' struct_declarator + { + $$ = $1; + insert_at_tail((struct simple_node *) $$, + (struct simple_node *) $3); + } + ; + +struct_declarator: + IDENTIFIER + { + $$ = new ast_declaration($1, false, NULL, NULL); + } + | IDENTIFIER '[' constant_expression ']' + { + $$ = new ast_declaration($1, true, $3, NULL); + } + ; + +initializer: + assignment_expression + ; + +declaration_statement: + declaration + ; + + // Grammar Note: labeled statements for SWITCH only; 'goto' is not + // supported. +statement: + statement_matched + | statement_unmatched + ; + +statement_matched: + compound_statement { $$ = (struct ast_node *) $1; } + | simple_statement + ; + +statement_unmatched: + selection_statement_unmatched + ; + +simple_statement: + declaration_statement + | expression_statement + | selection_statement_matched + | switch_statement { $$ = NULL; } + | case_label { $$ = NULL; } + | iteration_statement + | jump_statement + ; + +compound_statement: + '{' '}' + { + $$ = new ast_compound_statement(true, NULL); + } + | '{' statement_list '}' + { + $$ = new ast_compound_statement(true, $2); + } + ; + +statement_no_new_scope: + compound_statement_no_new_scope { $$ = (struct ast_node *) $1; } + | simple_statement + ; + +compound_statement_no_new_scope: + '{' '}' + { + $$ = new ast_compound_statement(false, NULL); + } + | '{' statement_list '}' + { + $$ = new ast_compound_statement(false, $2); + } + ; + +statement_list: + statement + { + if ($1 == NULL) { + _mesa_glsl_error(& @1, state, " statement\n"); + assert($1 != NULL); + } + + $$ = $1; + make_empty_list((struct simple_node *) $$); + } + | statement_list statement + { + if ($2 == NULL) { + _mesa_glsl_error(& @2, state, " statement\n"); + assert($2 != NULL); + } + $$ = $1; + insert_at_tail((struct simple_node *) $$, + (struct simple_node *) $2); + } + ; + +expression_statement: + ';' + { + $$ = new ast_expression_statement(NULL); + } + | expression ';' + { + $$ = new ast_expression_statement($1); + } + ; + +selection_statement_matched: + IF '(' expression ')' statement_matched ELSE statement_matched + { + $$ = new ast_selection_statement($3, $5, $7); + } + ; + +selection_statement_unmatched: + IF '(' expression ')' statement_matched + { + $$ = new ast_selection_statement($3, $5, NULL); + } + | IF '(' expression ')' statement_unmatched + { + $$ = new ast_selection_statement($3, $5, NULL); + } + | IF '(' expression ')' statement_matched ELSE statement_unmatched + { + $$ = new ast_selection_statement($3, $5, $7); + } + ; + +condition: + expression + { + $$ = (struct ast_node *) $1; + } + | fully_specified_type IDENTIFIER '=' initializer + { + ast_declaration *decl = new ast_declaration($2, false, NULL, $4); + ast_declarator_list *declarator = new ast_declarator_list($1); + + insert_at_tail(& declarator->declarations, + (struct simple_node *) decl); + + $$ = declarator; + } + ; + +switch_statement: + SWITCH '(' expression ')' compound_statement + ; + +case_label: + CASE expression ':' + | DEFAULT ':' + ; + +iteration_statement: + WHILE '(' condition ')' statement_no_new_scope + { + $$ = new ast_iteration_statement(ast_iteration_statement::ast_while, + NULL, $3, NULL, $5); + } + | DO statement WHILE '(' expression ')' ';' + { + $$ = new ast_iteration_statement(ast_iteration_statement::ast_do_while, + NULL, $5, NULL, $2); + } + | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope + { + $$ = new ast_iteration_statement(ast_iteration_statement::ast_for, + $3, $4.cond, $4.rest, $6); + } + ; + +for_init_statement: + expression_statement + | declaration_statement + ; + +conditionopt: + condition + | /* empty */ + { + $$ = NULL; + } + ; + +for_rest_statement: + conditionopt ';' + { + $$.cond = $1; + $$.rest = NULL; + } + | conditionopt ';' expression + { + $$.cond = $1; + $$.rest = $3; + } + ; + + // Grammar Note: No 'goto'. Gotos are not supported. +jump_statement: + CONTINUE ';' + { + $$ = new ast_jump_statement(ast_jump_statement::ast_continue, NULL); + } + | BREAK ';' + { + $$ = new ast_jump_statement(ast_jump_statement::ast_break, NULL); + } + | RETURN ';' + { + $$ = new ast_jump_statement(ast_jump_statement::ast_return, NULL); + } + | RETURN expression ';' + { + $$ = new ast_jump_statement(ast_jump_statement::ast_return, $2); + } + | DISCARD ';' // Fragment shader only. + { + $$ = new ast_jump_statement(ast_jump_statement::ast_discard, NULL); + } + ; + +external_declaration: + function_definition { $$ = $1; } + | declaration { $$ = $1; } + ; + +function_definition: + function_prototype compound_statement_no_new_scope + { + $$ = new ast_function_definition(); + $$->prototype = $1; + $$->body = $2; + } + ; diff --git a/glsl_parser_extras.cc b/glsl_parser_extras.cc new file mode 100644 index 00000000000..679b600fb3c --- /dev/null +++ b/glsl_parser_extras.cc @@ -0,0 +1,771 @@ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.tab.h" +#include "symbol_table.h" + +void +_mesa_glsl_error(YYLTYPE *locp, void *state, const char *fmt, ...) +{ + char buf[1024]; + int len; + va_list ap; + + (void) state; + len = snprintf(buf, sizeof(buf), "%u:%u(%u): error: ", + locp->source, locp->first_line, locp->first_column); + + va_start(ap, fmt); + vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); + va_end(ap); + + printf("%s\n", buf); +} + + +ast_node::~ast_node() +{ + /* empty */ +} + + +void +_mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q) +{ + if (q->constant) + printf("const "); + + if (q->invariant) + printf("invariant "); + + if (q->attribute) + printf("attribute "); + + if (q->varying) + printf("varying "); + + if (q->in && q->out) + printf("inout "); + else { + if (q->in) + printf("in "); + + if (q->out) + printf("out "); + } + + if (q->centroid) + printf("centroid "); + if (q->uniform) + printf("uniform "); + if (q->smooth) + printf("smooth "); + if (q->flat) + printf("flat "); + if (q->noperspective) + printf("noperspective "); +} + + +void +ast_node::print(void) const +{ + printf("node_%d ", type); +} + + +ast_node::ast_node(void) +{ +// make_empty_list(& ast->node); +} + +void +ast_type_specifier::print(void) const +{ + switch (type_specifier) { + case ast_void: printf("void "); break; + case ast_float: printf("float "); break; + case ast_int: printf("int "); break; + case ast_uint: printf("uint "); break; + case ast_bool: printf("bool "); break; + case ast_vec2: printf("vec2 "); break; + case ast_vec3: printf("vec3 "); break; + case ast_vec4: printf("vec4 "); break; + case ast_bvec2: printf("bvec2 "); break; + case ast_bvec3: printf("bvec3 "); break; + case ast_bvec4: printf("bvec4 "); break; + case ast_ivec2: printf("ivec2 "); break; + case ast_ivec3: printf("ivec3 "); break; + case ast_ivec4: printf("ivec4 "); break; + case ast_uvec2: printf("uvec2 "); break; + case ast_uvec3: printf("uvec3 "); break; + case ast_uvec4: printf("uvec4 "); break; + case ast_mat2: printf("mat2 "); break; + case ast_mat2x3: printf("mat2x3 "); break; + case ast_mat2x4: printf("mat2x4 "); break; + case ast_mat3x2: printf("mat3x2 "); break; + case ast_mat3: printf("mat3 "); break; + case ast_mat3x4: printf("mat3x4 "); break; + case ast_mat4x2: printf("mat4x2 "); break; + case ast_mat4x3: printf("mat4x3 "); break; + case ast_mat4: printf("mat4 "); break; + case ast_sampler1d: printf("sampler1d "); break; + case ast_sampler2d: printf("sampler2d "); break; + case ast_sampler3d: printf("sampler3d "); break; + case ast_samplercube: printf("samplercube "); break; + case ast_sampler1dshadow: printf("sampler1dshadow "); break; + case ast_sampler2dshadow: printf("sampler2dshadow "); break; + case ast_samplercubeshadow: printf("samplercubeshadow "); break; + case ast_sampler1darray: printf("sampler1darray "); break; + case ast_sampler2darray: printf("sampler2darray "); break; + case ast_sampler1darrayshadow: printf("sampler1darrayshadow "); break; + case ast_sampler2darrayshadow: printf("sampler2darrayshadow "); break; + case ast_isampler1d: printf("isampler1d "); break; + case ast_isampler2d: printf("isampler2d "); break; + case ast_isampler3d: printf("isampler3d "); break; + case ast_isamplercube: printf("isamplercube "); break; + case ast_isampler1darray: printf("isampler1darray "); break; + case ast_isampler2darray: printf("isampler2darray "); break; + case ast_usampler1d: printf("usampler1d "); break; + case ast_usampler2d: printf("usampler2d "); break; + case ast_usampler3d: printf("usampler3d "); break; + case ast_usamplercube: printf("usamplercube "); break; + case ast_usampler1darray: printf("usampler1darray "); break; + case ast_usampler2darray: printf("usampler2darray "); break; + + case ast_struct: + structure->print(); + break; + + case ast_type_name: printf("%s ", type_name); break; + } + + if (is_array) { + printf("[ "); + + if (array_size) { + array_size->print(); + } + + printf("] "); + } +} + +static void +ast_opt_array_size_print(bool is_array, const ast_expression *array_size) +{ + if (is_array) { + printf("[ "); + + if (array_size) + array_size->print(); + + printf("] "); + } +} + + +ast_type_specifier::ast_type_specifier(int specifier) +{ + type_specifier = ast_types(specifier); +} + + +void +ast_compound_statement::print(void) const +{ + const struct simple_node *ptr; + + printf("{\n"); + + foreach(ptr, & statements) { + _mesa_ast_print(ptr); + } + + printf("}\n"); +} + + +ast_compound_statement::ast_compound_statement(int new_scope, + ast_node *statements) +{ + this->new_scope = new_scope; + make_empty_list(& this->statements); + + if (statements != NULL) { + /* This seems odd, but it works. The simple_list is, + * basically, a circular list. insert_at_tail adds + * the specified node to the list before the current + * head. + */ + insert_at_tail((struct simple_node *) statements, + & this->statements); + } +} + + +void +ast_expression::print(void) const +{ + static const char *const operators[] = { + "=", + "+", + "-", + "+", + "-", + "*", + "/", + "%", + "<<", + ">>", + "<", + ">", + "<=", + ">=", + "==", + "!=", + "&", + "^", + "|", + "~", + "&&", + "^^", + "!", + + "*=", + "/=", + "%=", + "+=", + "-=", + "<<=", + ">>=", + "&=", + "^=", + "|=", + + "?:", + "++", + "--", + "++", + "--", + ".", + }; + + + switch (oper) { + case ast_assign: + case ast_add: + case ast_sub: + case ast_mul: + case ast_div: + case ast_mod: + case ast_lshift: + case ast_rshift: + case ast_less: + case ast_greater: + case ast_lequal: + case ast_gequal: + case ast_equal: + case ast_nequal: + case ast_bit_and: + case ast_bit_xor: + case ast_bit_or: + case ast_logic_and: + case ast_logic_xor: + case ast_logic_or: + case ast_mul_assign: + case ast_div_assign: + case ast_mod_assign: + case ast_add_assign: + case ast_sub_assign: + case ast_ls_assign: + case ast_rs_assign: + case ast_and_assign: + case ast_xor_assign: + case ast_or_assign: + subexpressions[0]->print(); + printf("%s ", operators[oper]); + subexpressions[1]->print(); + break; + + case ast_field_selection: + subexpressions[0]->print(); + printf(". %s ", primary_expression.identifier); + break; + + case ast_plus: + case ast_neg: + case ast_bit_not: + case ast_logic_not: + case ast_pre_inc: + case ast_pre_dec: + printf("%s ", operators[oper]); + subexpressions[0]->print(); + break; + + case ast_post_inc: + case ast_post_dec: + subexpressions[0]->print(); + printf("%s ", operators[oper]); + break; + + case ast_conditional: + subexpressions[0]->print(); + printf("? "); + subexpressions[1]->print(); + printf(": "); + subexpressions[1]->print(); + break; + + case ast_array_index: + subexpressions[0]->print(); + printf("[ "); + subexpressions[1]->print(); + printf("] "); + break; + + case ast_function_call: { + ast_expression *parameters = subexpressions[1]; + + subexpressions[0]->print(); + printf("( "); + + if (parameters != NULL) { + struct simple_node *ptr; + + parameters->print(); + foreach (ptr, (struct simple_node *) parameters) { + printf(", "); + _mesa_ast_print(ptr); + } + } + + printf(") "); + break; + } + + case ast_identifier: + printf("%s ", primary_expression.identifier); + break; + + case ast_int_constant: + printf("%d ", primary_expression.int_constant); + break; + + case ast_uint_constant: + printf("%u ", primary_expression.uint_constant); + break; + + case ast_float_constant: + printf("%f ", primary_expression.float_constant); + break; + + case ast_bool_constant: + printf("%s ", + primary_expression.bool_constant + ? "true" : "false"); + break; + + case ast_sequence: { + struct simple_node *ptr; + struct simple_node *const head = first_elem(& expressions); + + printf("( "); + foreach (ptr, & expressions) { + if (ptr != head) + printf(", "); + + _mesa_ast_print(ptr); + } + printf(") "); + break; + } + } +} + +ast_expression::ast_expression(int oper, + ast_expression *ex0, + ast_expression *ex1, + ast_expression *ex2) +{ + this->oper = ast_operators(oper); + this->subexpressions[0] = ex0; + this->subexpressions[1] = ex1; + this->subexpressions[2] = ex2; + make_empty_list(& expressions); +} + + +void +ast_expression_statement::print(void) const +{ + if (expression) + expression->print(); + + printf("; "); +} + + +ast_expression_statement::ast_expression_statement(ast_expression *ex) : + expression(ex) +{ + /* empty */ +} + + +void +ast_function::print(void) const +{ + struct simple_node *ptr; + + return_type->print(); + printf(" %s (", identifier); + + foreach(ptr, & parameters) { + _mesa_ast_print(ptr); + } + + printf(")"); +} + + +ast_function::ast_function(void) +{ + make_empty_list(& parameters); +} + + +void +ast_fully_specified_type::print(void) const +{ + _mesa_ast_type_qualifier_print(& qualifier); + specifier->print(); +} + + +void +ast_parameter_declarator::print(void) const +{ + type->print(); + if (identifier) + printf("%s ", identifier); + ast_opt_array_size_print(is_array, array_size); +} + + +void +ast_function_definition::print(void) const +{ + prototype->print(); + body->print(); +} + + +void +ast_declaration::print(void) const +{ + printf("%s ", identifier); + ast_opt_array_size_print(is_array, array_size); + + if (initializer) { + printf("= "); + initializer->print(); + } +} + + +ast_declaration::ast_declaration(char *identifier, int is_array, + ast_expression *array_size, + ast_expression *initializer) +{ + this->identifier = identifier; + this->is_array = is_array; + this->array_size = array_size; + this->initializer = initializer; +} + + +void +ast_declarator_list::print(void) const +{ + struct simple_node *head; + struct simple_node *ptr; + + assert(type || invariant); + + if (type) + type->print(); + else + printf("invariant "); + + head = first_elem(& declarations); + foreach (ptr, & declarations) { + if (ptr != head) + printf(", "); + + _mesa_ast_print(ptr); + } + + printf("; "); +} + + +ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type) +{ + this->type = type; + make_empty_list(& this->declarations); +} + +void +ast_jump_statement::print(void) const +{ + switch (mode) { + case ast_continue: + printf("continue; "); + break; + case ast_break: + printf("break; "); + break; + case ast_return: + printf("return "); + if (opt_return_value) + opt_return_value->print(); + + printf("; "); + break; + case ast_discard: + printf("discard; "); + break; + } +} + + +ast_jump_statement::ast_jump_statement(int mode, ast_expression *return_value) +{ + this->mode = ast_jump_modes(mode); + + if (mode == ast_return) + opt_return_value = return_value; +} + + +void +ast_selection_statement::print(void) const +{ + printf("if ( "); + condition->print(); + printf(") "); + + then_statement->print(); + + if (else_statement) { + printf("else "); + else_statement->print(); + } + +} + + +ast_selection_statement::ast_selection_statement(ast_expression *condition, + ast_node *then_statement, + ast_node *else_statement) +{ + this->condition = condition; + this->then_statement = then_statement; + this->else_statement = else_statement; +} + + +void +ast_iteration_statement::print(void) const +{ + switch (mode) { + case ast_for: + printf("for( "); + if (init_statement) + init_statement->print(); + printf("; "); + + if (condition) + condition->print(); + printf("; "); + + if (rest_expression) + rest_expression->print(); + printf(") "); + + body->print(); + break; + + case ast_while: + printf("while ( "); + if (condition) + condition->print(); + printf(") "); + body->print(); + break; + + case ast_do_while: + printf("do "); + body->print(); + printf("while ( "); + if (condition) + condition->print(); + printf("); "); + break; + } +} + + +ast_iteration_statement::ast_iteration_statement(int mode, + ast_node *init, + ast_node *condition, + ast_expression *rest_expression, + ast_node *body) +{ + this->mode = ast_iteration_modes(mode); + this->init_statement = init; + this->condition = condition; + this->rest_expression = rest_expression; + this->body = body; +} + + +void +ast_struct_specifier::print(void) const +{ + struct simple_node *ptr; + + printf("struct %s { ", name); + foreach (ptr, & declarations) { + _mesa_ast_print(ptr); + } + printf("} "); +} + + +ast_struct_specifier::ast_struct_specifier(char *identifier, + ast_node *declarator_list) +{ + name = identifier; + + /* This seems odd, but it works. The simple_list is, + * basically, a circular list. insert_at_tail adds + * the specified node to the list before the current + * head. + */ + insert_at_tail((struct simple_node *) declarator_list, + & declarations); +} + + +static char * +load_text_file(const char *file_name, size_t *size) +{ + char *text = NULL; + struct stat st; + ssize_t total_read = 0; + int fd = open(file_name, O_RDONLY); + + *size = 0; + if (fd < 0) { + return NULL; + } + + if (fstat(fd, & st) == 0) { + text = (char *) malloc(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'; + *size = total_read; + } + } + + close(fd); + + return text; +} + + +int +main(int argc, char **argv) +{ + struct _mesa_glsl_parse_state state; + char *shader; + size_t shader_len; + struct simple_node *ptr; + struct simple_node instructions; + + (void) argc; + shader = load_text_file(argv[1], & shader_len); + + state.scanner = NULL; + make_empty_list(& state.translation_unit); + state.symbols = _mesa_symbol_table_ctor(); + + _mesa_glsl_lexer_ctor(& state, shader, shader_len); + _mesa_glsl_parse(& state); + _mesa_glsl_lexer_dtor(& state); + + foreach (ptr, & state.translation_unit) { + _mesa_ast_print(ptr); + } + +#if 0 + make_empty_list(& instructions); + foreach (ptr, & state.translation_unit) { + _mesa_ast_to_hir(ptr, &instructions, &state); + } +#endif + + _mesa_symbol_table_dtor(state.symbols); + + return 0; +} diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h new file mode 100644 index 00000000000..932c12d8410 --- /dev/null +++ b/glsl_parser_extras.h @@ -0,0 +1,68 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_PARSER_EXTRAS_H +#define GLSL_PARSER_EXTRAS_H + +#include "main/simple_list.h" + +enum _mesa_glsl_parser_targets { + vertex_shader, + geometry_shader, + fragment_shader +}; + +struct _mesa_glsl_parse_state { + void *scanner; + struct simple_node translation_unit; + struct _mesa_symbol_table *symbols; + + unsigned language_version; + enum _mesa_glsl_parser_targets target; +}; + +typedef struct YYLTYPE { + int first_line; + int first_column; + int last_line; + int last_column; + unsigned source; +} YYLTYPE; +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 + +extern void _mesa_glsl_error(YYLTYPE *locp, void *state, const char *fmt, ...); + +extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, + const char *string, size_t len); + +extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state); + +union YYSTYPE; +extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc, + void *scanner); + +extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *); + +#endif /* GLSL_PARSER_EXTRAS_H */ diff --git a/glsl_types.c b/glsl_types.c new file mode 100644 index 00000000000..89732180175 --- /dev/null +++ b/glsl_types.c @@ -0,0 +1,159 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "symbol_table.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" +#include "builtin_types.h" + + +struct glsl_type * +_mesa_glsl_array_type_ctor(struct glsl_type *base, unsigned length, + const char *name) +{ + struct glsl_type *type = calloc(1, sizeof(*type)); + + type->base_type = GLSL_TYPE_ARRAY; + type->name = name; + type->length = length; + type->fields.array = base; + + return type; +} + + +static void +add_types_to_symbol_table(struct _mesa_symbol_table *symtab, + const struct glsl_type *types, + unsigned num_types) +{ + unsigned i; + + for (i = 0; i < num_types; i++) { + _mesa_symbol_table_add_symbol(symtab, 0, types[i].name, + (void *) & types[i]); + } +} + + +static void +generate_110_types(struct _mesa_symbol_table *symtab) +{ + add_types_to_symbol_table(symtab, builtin_core_types, + Elements(builtin_core_types)); + add_types_to_symbol_table(symtab, builtin_structure_types, + Elements(builtin_structure_types)); + add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types, + Elements(builtin_110_deprecated_structure_types)); +} + + +static void +generate_120_types(struct _mesa_symbol_table *symtab) +{ + generate_110_types(symtab); + + add_types_to_symbol_table(symtab, builtin_120_types, + Elements(builtin_120_types)); +} + + +static void +generate_130_types(struct _mesa_symbol_table *symtab) +{ + generate_120_types(symtab); + + add_types_to_symbol_table(symtab, builtin_130_types, + Elements(builtin_130_types)); +} + + +void +_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) +{ + switch (state->language_version) { + case 110: + generate_110_types(state->symbols); + break; + case 120: + generate_120_types(state->symbols); + break; + case 130: + generate_130_types(state->symbols); + break; + default: + /* error */ + break; + } +} + + +const struct glsl_type * +_mesa_glsl_get_vector_type(unsigned base_type, unsigned vector_length) +{ + switch (base_type) { + case GLSL_TYPE_UINT: + switch (vector_length) { + case 1: + case 2: + case 3: + case 4: + return glsl_uint_type + (vector_length - 1); + default: + return glsl_error_type; + } + case GLSL_TYPE_INT: + switch (vector_length) { + case 1: + case 2: + case 3: + case 4: + return glsl_int_type + (vector_length - 1); + default: + return glsl_error_type; + } + case GLSL_TYPE_FLOAT: + switch (vector_length) { + case 1: + case 2: + case 3: + case 4: + return glsl_float_type + (vector_length - 1); + default: + return glsl_error_type; + } + case GLSL_TYPE_BOOL: + switch (vector_length) { + case 1: + case 2: + case 3: + case 4: + return glsl_bool_type + (vector_length - 1); + default: + return glsl_error_type; + } + default: + return glsl_error_type; + } +} diff --git a/glsl_types.h b/glsl_types.h new file mode 100644 index 00000000000..c69da956224 --- /dev/null +++ b/glsl_types.h @@ -0,0 +1,141 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_TYPES_H +#define GLSL_TYPES_H + +#define GLSL_TYPE_UINT 0 +#define GLSL_TYPE_INT 1 +#define GLSL_TYPE_FLOAT 2 +#define GLSL_TYPE_BOOL 3 +#define GLSL_TYPE_SAMPLER 4 +#define GLSL_TYPE_STRUCT 5 +#define GLSL_TYPE_ARRAY 6 +#define GLSL_TYPE_FUNCTION 7 +#define GLSL_TYPE_VOID 8 +#define GLSL_TYPE_ERROR 9 + +#define is_numeric_base_type(b) \ + (((b) >= GLSL_TYPE_UINT) && ((b) <= GLSL_TYPE_FLOAT)) + +#define is_integer_base_type(b) \ + (((b) == GLSL_TYPE_UINT) || ((b) == GLSL_TYPE_INT)) + +#define is_error_type(t) ((t)->base_type == GLSL_TYPE_ERROR) + +#define GLSL_SAMPLER_DIM_1D 0 +#define GLSL_SAMPLER_DIM_2D 1 +#define GLSL_SAMPLER_DIM_3D 2 +#define GLSL_SAMPLER_DIM_CUBE 3 +#define GLSL_SAMPLER_DIM_RECT 4 +#define GLSL_SAMPLER_DIM_BUF 5 + + +struct glsl_type { + unsigned base_type:4; + + unsigned sampler_dimensionality:3; + unsigned sampler_shadow:1; + unsigned sampler_array:1; + unsigned sampler_type:2; /**< Type of data returned using this sampler. + * only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT, + * and \c GLSL_TYPE_UINT are valid. + */ + + unsigned vector_elements:3; /**< 0, 2, 3, or 4 vector elements. */ + unsigned matrix_rows:3; /**< 0, 2, 3, or 4 matrix rows. */ + + /** + * Name of the data type + * + * This may be \c NULL for anonymous structures, for arrays, or for + * function types. + */ + const char *name; + + /** + * For \c GLSL_TYPE_ARRAY, this is the length of the array. For + * \c GLSL_TYPE_STRUCT, it is the number of elements in the structure and + * the number of values pointed to by \c fields.structure (below). + * + * For \c GLSL_TYPE_FUNCTION, it is the number of parameters to the + * function. The return value from a function is implicitly the first + * parameter. The types of the parameters are stored in + * \c fields.parameters (below). + */ + unsigned length; + + /** + * Subtype of composite data types. + */ + union { + const struct glsl_type *array; /**< Type of array elements. */ + const struct glsl_type *parameters; /**< Parameters to function. */ + const struct glsl_struct_field *structure;/**< List of struct fields. */ + } fields; +}; + +#define is_glsl_type_scalar(t) \ + (((t)->vector_elements == 0) \ + && ((t)->base_type >= GLSL_TYPE_UINT) \ + && ((t)->base_type <= GLSL_TYPE_BOOL)) + +#define is_glsl_type_vector(t) \ + (((t)->vector_elements > 0) \ + && ((t)->matrix_rows == 0) \ + && ((t)->base_type >= GLSL_TYPE_UINT) \ + && ((t)->base_type <= GLSL_TYPE_BOOL)) + +#define is_glsl_type_matrix(t) \ + (((t)->matrix_rows > 0) \ + && ((t)->base_type == GLSL_TYPE_FLOAT)) /* GLSL only has float matrices. */ + +struct glsl_struct_field { + const struct glsl_type *type; + const char *name; +}; + +struct _mesa_glsl_parse_state; + +#ifdef __cplusplus +extern "C" { +#endif + +extern void +_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); + +extern const struct glsl_type * +_mesa_glsl_get_vector_type(unsigned base_type, unsigned vector_length); + +extern const struct glsl_type *const glsl_error_type; +extern const struct glsl_type *const glsl_int_type; +extern const struct glsl_type *const glsl_uint_type; +extern const struct glsl_type *const glsl_float_type; +extern const struct glsl_type *const glsl_bool_type; + +#ifdef __cplusplus +} +#endif + +#endif /* GLSL_TYPES_H */ diff --git a/hash_table.c b/hash_table.c new file mode 100644 index 00000000000..e89a2564d76 --- /dev/null +++ b/hash_table.c @@ -0,0 +1,159 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file hash_table.c + * \brief Implementation of a generic, opaque hash table data type. + * + * \author Ian Romanick + */ + +#include "main/imports.h" +#include "main/simple_list.h" +#include "hash_table.h" + +struct node { + struct node *next; + struct node *prev; +}; + +struct hash_table { + hash_func_t hash; + hash_compare_func_t compare; + + unsigned num_buckets; + struct node buckets[1]; +}; + + +struct hash_node { + struct node link; + const void *key; + void *data; +}; + + +struct hash_table * +hash_table_ctor(unsigned num_buckets, hash_func_t hash, + hash_compare_func_t compare) +{ + struct hash_table *ht; + unsigned i; + + + if (num_buckets < 16) { + num_buckets = 16; + } + + ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1) + * sizeof(ht->buckets[0]))); + if (ht != NULL) { + ht->hash = hash; + ht->compare = compare; + ht->num_buckets = num_buckets; + + for (i = 0; i < num_buckets; i++) { + make_empty_list(& ht->buckets[i]); + } + } + + return ht; +} + + +void +hash_table_dtor(struct hash_table *ht) +{ + hash_table_clear(ht); + _mesa_free(ht); +} + + +void +hash_table_clear(struct hash_table *ht) +{ + struct node *node; + struct node *temp; + unsigned i; + + + for (i = 0; i < ht->num_buckets; i++) { + foreach_s(node, temp, & ht->buckets[i]) { + remove_from_list(node); + _mesa_free(node); + } + + assert(is_empty_list(& ht->buckets[i])); + } +} + + +void * +hash_table_find(struct hash_table *ht, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct node *node; + + foreach(node, & ht->buckets[bucket]) { + struct hash_node *hn = (struct hash_node *) node; + + if ((*ht->compare)(hn->key, key) == 0) { + return hn->data; + } + } + + return NULL; +} + + +void +hash_table_insert(struct hash_table *ht, void *data, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct hash_node *node; + + node = _mesa_calloc(sizeof(*node)); + + node->data = data; + node->key = key; + + insert_at_head(& ht->buckets[bucket], & node->link); +} + + +unsigned +hash_table_string_hash(const void *key) +{ + const char *str = (const char *) key; + unsigned hash = 5381; + + + while (*str != '\0') { + hash = (hash * 33) + *str; + str++; + } + + return hash; +} diff --git a/hash_table.h b/hash_table.h new file mode 100644 index 00000000000..7b302f5dbee --- /dev/null +++ b/hash_table.h @@ -0,0 +1,117 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file hash_table.h + * \brief Implementation of a generic, opaque hash table data type. + * + * \author Ian Romanick + */ + +#ifndef HASH_TABLE_H +#define HASH_TABLE_H + +#include + +struct hash_table; + +typedef unsigned (*hash_func_t)(const void *key); +typedef int (*hash_compare_func_t)(const void *key1, const void *key2); + +/** + * Hash table constructor + * + * Creates a hash table with the specified number of buckets. The supplied + * \c hash and \c compare routines are used when adding elements to the table + * and when searching for elements in the table. + * + * \param num_buckets Number of buckets (bins) in the hash table. + * \param hash Function used to compute hash value of input keys. + * \param compare Function used to compare keys. + */ +extern struct hash_table *hash_table_ctor(unsigned num_buckets, + hash_func_t hash, hash_compare_func_t compare); + + +/** + * Release all memory associated with a hash table + * + * \warning + * This function cannot release memory occupied either by keys or data. + */ +extern void hash_table_dtor(struct hash_table *ht); + + +/** + * Flush all entries from a hash table + * + * \param ht Table to be cleared of its entries. + */ +extern void hash_table_clear(struct hash_table *ht); + + +/** + * Search a hash table for a specific element + * + * \param ht Table to be searched + * \param key Key of the desired element + * + * \return + * The \c data value supplied to \c hash_table_insert when the element with + * the matching key was added. If no matching key exists in the table, + * \c NULL is returned. + */ +extern void *hash_table_find(struct hash_table *ht, const void *key); + + +/** + * Add an element to a hash table + */ +extern void hash_table_insert(struct hash_table *ht, void *data, + const void *key); + + +/** + * Compute hash value of a string + * + * Computes the hash value of a string using the DJB2 algorithm developed by + * Professor Daniel J. Bernstein. It was published on comp.lang.c once upon + * a time. I was unable to find the original posting in the archives. + * + * \param key Pointer to a NUL terminated string to be hashed. + * + * \sa hash_table_string_compare + */ +extern unsigned hash_table_string_hash(const void *key); + + +/** + * Compare two strings used as keys + * + * This is just a macro wrapper around \c strcmp. + * + * \sa hash_table_string_hash + */ +#define hash_table_string_compare ((hash_compare_func_t) strcmp) + +#endif /* HASH_TABLE_H */ diff --git a/hir_field_selection.cc b/hir_field_selection.cc new file mode 100644 index 00000000000..295cbaf8949 --- /dev/null +++ b/hir_field_selection.cc @@ -0,0 +1,187 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "main/imports.h" +#include "symbol_table.h" +#include "glsl_parser_extras.h" +#include "ast.h" +#include "glsl_types.h" +#include "ir.h" + +#define X 1 +#define R 5 +#define S 9 +#define I 13 + +static bool +generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, + unsigned vector_length) +{ + /* For each possible swizzle character, this table encodes the value in + * \c idx_map that represents the 0th element of the vector. For invalid + * swizzle characters (e.g., 'k'), a special value is used that will allow + * detection of errors. + */ + unsigned char base_idx[26] = { + /* a b c d e f g h i j k l m */ + R, R, I, I, I, I, R, I, I, I, I, I, I, + /* n o p q r s t u v w x y z */ + I, I, S, S, R, S, S, I, I, X, X, X, X + }; + + /* Each valid swizzle character has an entry in the previous table. This + * table encodes the base index encoded in the previous table plus the actual + * index of the swizzle character. When processing swizzles, the first + * character in the string is indexed in the previous table. Each character + * in the string is indexed in this table, and the value found there has the + * value form the first table subtracted. The result must be on the range + * [0,3]. + * + * For example, the string "wzyx" will get X from the first table. Each of + * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After + * subtraction, the swizzle values are { 3, 2, 1, 0 }. + * + * The string "wzrg" will get X from the first table. Each of the characters + * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the + * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range + * [0,3], the error is detected. + */ + unsigned char idx_map[26] = { + /* a b c d e f g h i j k l m */ + R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, + /* n o p q r s t u v w x y z */ + 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2 + }; + + int swiz_idx[4] = { 0, 0, 0, 0 }; + unsigned base; + unsigned dup_mask = 0; + unsigned seen_mask = 0; + unsigned i; + + + /* Validate the first character in the swizzle string and look up the base + * index value as described above. + */ + if ((str[0] < 'a') || (str[0] > 'z')) + return FALSE; + + base = base_idx[str[0] - 'a']; + + + for (i = 0; (i < 4) && (str[i] != '\0'); i++) { + unsigned bit; + + /* Validate the next character, and, as described above, convert it to a + * swizzle index. + */ + if ((str[i] < 'a') || (str[i] > 'z')) + return FALSE; + + swiz_idx[i] = idx_map[str[0] - 'a'] - base; + if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) + return FALSE; + + + /* Track a bit-mask of the swizzle index values that have been seen. If + * a value is seen more than once, set the "duplicate" flag. + */ + bit = (1U << swiz_idx[i]); + dup_mask |= seen_mask & bit; + seen_mask |= bit; + } + + if (str[i] != '\0') + return FALSE; + + swiz->x = swiz_idx[0]; + swiz->y = swiz_idx[1]; + swiz->z = swiz_idx[2]; + swiz->w = swiz_idx[3]; + swiz->num_components = i; + swiz->has_duplicates = (dup_mask != 0); + + return TRUE; +} + + +struct ir_instruction * +_mesa_ast_field_selection_to_hir(const ast_expression *expr, + simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + ir_instruction *op; + ir_dereference *deref; + YYLTYPE loc; + + + op = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + deref = new ir_dereference(op); + + /* Initially assume that the resulting type of the field selection is an + * error. This make the error paths below a bit easier to follow. + */ + deref->type = glsl_error_type; + + /* If processing the thing being dereferenced generated an error, bail out + * now. Doing so prevents spurious error messages from being logged below. + */ + if (is_error_type(op->type)) + return (struct ir_instruction *) deref; + + /* There are two kinds of field selection. There is the selection of a + * specific field from a structure, and there is the selection of a + * swizzle / mask from a vector. Which is which is determined entirely + * by the base type of the thing to which the field selection operator is + * being applied. + */ + _mesa_ast_get_location(expr, & loc); + if (is_glsl_type_vector(op->type)) { + if (generate_swizzle(expr->primary_expression.identifier, + & deref->selector.swizzle, + op->type->vector_elements)) { + /* Based on the number of elements in the swizzle and the base type + * (i.e., float, int, unsigned, or bool) of the vector being swizzled, + * generate the type of the resulting value. + */ + deref->type = + _mesa_glsl_get_vector_type(op->type->base_type, + deref->selector.swizzle.num_components); + } else { + /* FINISHME: Logging of error messages should be moved into + * FINISHME: generate_swizzle. This allows the generation of more + * FINISHME: specific error messages. + */ + _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'", + expr->primary_expression.identifier); + } + } else if (op->type->base_type == GLSL_TYPE_STRUCT) { + /* FINISHME: Handle field selection from structures. */ + } else { + _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " + "non-structure / non-vector.", + expr->primary_expression.identifier); + } + + return (struct ir_instruction *) deref; +} diff --git a/hir_function.c b/hir_function.c new file mode 100644 index 00000000000..eac2b59a611 --- /dev/null +++ b/hir_function.c @@ -0,0 +1,41 @@ +struct ir_instruction * +_mesa_ast_constructor_to_hir(const struct ast_node *n, + const struct ast_node *parameters, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_type_specifier *type = (struct ast_type_specifier *) n; + + + /* There are effectively three kinds of constructors. Each has its own set + * of rules. + * + * * Built-in scalar, vector, and matrix types: For each of these the only + * matching requirement is that the number of values supplied is + * sufficient to initialize all of the fields of the type. + * * Array types: The number of initializers must match the size of the + * array, if a size is specified. Each of the initializers must + * exactly match the base type of the array. + * * Structure types: These initializers must exactly match the fields of + * the structure in order. This is the most restrictive type. + * + * In all cases the built-in promotions from integer to floating-point types + * are applied. + */ + + if (type->is_array) { + /* FINISHME */ + } else if ((type->type_specifier == ast_struct) + || (type->type_specifier == ast_type_name)) { + /* FINISHME */ + } else { + const struct glsl_type *ctor_type; + + /* Look-up the type, by name, in the symbol table. + */ + + + /* Generate a series of assignments of constructor parameters to fields + * of the object being initialized. + */ + } +} diff --git a/ir.cc b/ir.cc new file mode 100644 index 00000000000..7bd7854ccb8 --- /dev/null +++ b/ir.cc @@ -0,0 +1,116 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "main/imports.h" +#include "main/simple_list.h" +#include "ir.h" +#include "glsl_types.h" + +ir_instruction::ir_instruction(int mode) +{ + this->mode = mode; + make_empty_list(this); +} + + +ir_assignment::ir_assignment(ir_instruction *lhs, ir_instruction *rhs, + ir_expression *condition) + : ir_instruction(ir_op_assign) +{ + this->lhs = (ir_dereference *) lhs; + this->rhs = rhs; + this->condition = condition; +} + + +ir_expression::ir_expression(int op, const struct glsl_type *type, + ir_instruction *op0, ir_instruction *op1) + : ir_instruction(ir_op_expression) +{ + this->type = type; + this->operation = ir_expression_operation(op); + this->operands[0] = op0; + this->operands[1] = op1; +} + + +ir_label::ir_label(const char *label) + : ir_instruction(ir_op_label), label(label) +{ + /* empty */ +} + + +ir_constant::ir_constant(const struct glsl_type *type, const void *data) + : ir_instruction(ir_op_constant) +{ + const unsigned elements = + ((type->vector_elements == 0) ? 1 : type->vector_elements) + * ((type->matrix_rows == 0) ? 1 : type->matrix_rows); + unsigned size = 0; + + this->type = type; + switch (type->base_type) { + case GLSL_TYPE_UINT: size = sizeof(this->value.u[0]); break; + case GLSL_TYPE_INT: size = sizeof(this->value.i[0]); break; + case GLSL_TYPE_FLOAT: size = sizeof(this->value.f[0]); break; + case GLSL_TYPE_BOOL: size = sizeof(this->value.b[0]); break; + default: + /* FINISHME: What to do? Exceptions are not the answer. + */ + break; + } + + memcpy(& this->value, data, size * elements); +} + + +ir_dereference::ir_dereference(ir_instruction *var) + : ir_instruction(ir_op_dereference) +{ + this->mode = ir_reference_variable; + this->var = var; + this->type = (var != NULL) ? var->type : glsl_error_type; +} + + +ir_variable::ir_variable(const struct glsl_type *type, const char *name) + : ir_instruction(ir_op_var_decl) +{ + this->type = type; + this->name = name; +} + + +ir_function_signature::ir_function_signature(void) + : ir_instruction(ir_op_func_sig) +{ + make_empty_list(& parameters); +} + + +ir_function::ir_function(void) + : ir_instruction(ir_op_func) +{ + make_empty_list(& signatures); +} diff --git a/ir.h b/ir.h new file mode 100644 index 00000000000..304f1dccfe0 --- /dev/null +++ b/ir.h @@ -0,0 +1,302 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +struct ir_program { + void *bong_hits; +}; + + +enum ir_opcodes { + ir_op_var_decl, + ir_op_assign, + ir_op_expression, + ir_op_dereference, + ir_op_jump, + ir_op_label, + ir_op_constant, + ir_op_func_sig, + ir_op_func +}; + +/** + * Base class of all IR instructions + */ +class ir_instruction : public simple_node { +public: + unsigned mode; + const struct glsl_type *type; + +protected: + ir_instruction(int mode); + +private: + /** + * Dummy constructor to catch bad constructors in derived classes. + * + * Every derived must use the constructor that sets the instructions + * mode. Having the \c void constructor private prevents derived classes + * from accidentally doing the wrong thing. + */ + ir_instruction(void); +}; + + +enum ir_variable_mode { + ir_var_auto = 0, + ir_var_uniform, + ir_var_in, + ir_var_out, + ir_var_inout +}; + +enum ir_varaible_interpolation { + ir_var_smooth = 0, + ir_var_flat, + ir_var_noperspective +}; + +class ir_variable : public ir_instruction { +public: + ir_variable(const struct glsl_type *, const char *); + + const char *name; + + unsigned read_only:1; + unsigned centroid:1; + unsigned invariant:1; + + unsigned mode:3; + unsigned interpolation:2; +}; + + +class ir_label : public ir_instruction { +public: + ir_label(const char *label); + + const char *label; +}; + + +/*@{*/ +class ir_function_signature : public ir_instruction { +public: + ir_function_signature(void); + + /** + * Function return type. + * + * \note This discards the optional precision qualifier. + */ + const struct glsl_type *return_type; + + /** + * List of function parameters stored as ir_variable objects. + */ + struct simple_node parameters; + + /** + * Pointer to the label that begins the function definition. + */ + ir_label *definition; +}; + + +/** + * Header for tracking functions in the symbol table + */ +class ir_function : public ir_instruction { +public: + ir_function(void); + + /** + * Name of the function. + */ + const char *name; + + struct simple_node signatures; +}; +/*@}*/ + +class ir_expression; +class ir_dereference; + +class ir_assignment : public ir_instruction { +public: + ir_assignment(ir_instruction *lhs, ir_instruction *rhs, + ir_expression *condition); + + /** + * Left-hand side of the assignment. + */ + ir_dereference *lhs; + + /** + * Value being assigned + * + * This should be either \c ir_op_expression or \c ir_op_deference. + */ + ir_instruction *rhs; + + /** + * Optional condition for the assignment. + */ + ir_expression *condition; +}; + + +enum ir_expression_operation { + ir_unop_bit_not, + ir_unop_logic_not, + ir_unop_neg, + ir_unop_abs, + ir_unop_rcp, + ir_unop_rsq, + ir_unop_exp, + ir_unop_log, + ir_unop_f2i, /**< Float-to-integer conversion. */ + ir_unop_i2f, /**< Integer-to-float conversion. */ + + /** + * \name Unary floating-point rounding operations. + */ + /*@{*/ + ir_unop_trunc, + ir_unop_ceil, + ir_unop_floor, + /*@}*/ + + ir_binop_add, + ir_binop_sub, + ir_binop_mul, + ir_binop_div, + ir_binop_mod, + + /** + * \name Binary comparison operators + */ + /*@{*/ + ir_binop_less, + ir_binop_greater, + ir_binop_lequal, + ir_binop_gequal, + ir_binop_equal, + ir_binop_nequal, + /*@}*/ + + /** + * \name Bit-wise binary operations. + */ + /*@{*/ + ir_binop_lshift, + ir_binop_rshift, + ir_binop_bit_and, + ir_binop_bit_xor, + ir_binop_bit_or, + /*@}*/ + + ir_binop_logic_and, + ir_binop_logic_xor, + ir_binop_logic_or, + ir_binop_logic_not, + + ir_binop_dot, + ir_binop_min, + ir_binop_max, + + ir_binop_pow +}; + +class ir_expression : public ir_instruction { +public: + ir_expression(int op, const struct glsl_type *type, + ir_instruction *, ir_instruction *); + + ir_expression_operation operation; + ir_instruction *operands[2]; +}; + + +struct ir_swizzle_mask { + unsigned x:2; + unsigned y:2; + unsigned z:2; + unsigned w:2; + + /** + * Number of components in the swizzle. + */ + unsigned num_components:2; + + /** + * Does the swizzle contain duplicate components? + * + * L-value swizzles cannot contain duplicate components. + */ + unsigned has_duplicates:1; +}; + +class ir_dereference : public ir_instruction { +public: + ir_dereference(struct ir_instruction *); + + enum { + ir_reference_variable, + ir_reference_array, + ir_reference_record + } mode; + + /** + * Object being dereferenced. + * + * Must be either an \c ir_variable or an \c ir_deference. + */ + ir_instruction *var; + + union { + ir_expression *array_index; + const char *field; + struct ir_swizzle_mask swizzle; + } selector; +}; + + +class ir_constant : public ir_instruction { +public: + ir_constant(const struct glsl_type *type, const void *data); + + /** + * Value of the constant. + * + * The field used to back the values supplied by the constant is determined + * by the type associated with the \c ir_instruction. Constants may be + * scalars, vectors, or matrices. + */ + union { + unsigned u[16]; + int i[16]; + float f[16]; + bool b[16]; + } value; +}; + diff --git a/main/imports.h b/main/imports.h new file mode 100644 index 00000000000..d2197342c04 --- /dev/null +++ b/main/imports.h @@ -0,0 +1,6 @@ +#include +#include + +#define _mesa_malloc(x) malloc(x) +#define _mesa_free(x) free(x) +#define _mesa_calloc(x) calloc(1,x) diff --git a/main/simple_list.h b/main/simple_list.h new file mode 100644 index 00000000000..5ef39e14cc6 --- /dev/null +++ b/main/simple_list.h @@ -0,0 +1,235 @@ +/** + * \file simple_list.h + * Simple macros for type-safe, intrusive lists. + * + * Intended to work with a list sentinal which is created as an empty + * list. Insert & delete are O(1). + * + * \author + * (C) 1997, Keith Whitwell + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _SIMPLE_LIST_H +#define _SIMPLE_LIST_H + +struct simple_node { + struct simple_node *next; + struct simple_node *prev; +}; + +/** + * Remove an element from list. + * + * \param elem element to remove. + */ +#define remove_from_list(elem) \ +do { \ + (elem)->next->prev = (elem)->prev; \ + (elem)->prev->next = (elem)->next; \ +} while (0) + +/** + * Insert an element to the list head. + * + * \param list list. + * \param elem element to insert. + */ +#define insert_at_head(list, elem) \ +do { \ + (elem)->prev = list; \ + (elem)->next = (list)->next; \ + (list)->next->prev = elem; \ + (list)->next = elem; \ +} while(0) + +/** + * Insert an element to the list tail. + * + * \param list list. + * \param elem element to insert. + */ +#define insert_at_tail(list, elem) \ +do { \ + (elem)->next = list; \ + (elem)->prev = (list)->prev; \ + (list)->prev->next = elem; \ + (list)->prev = elem; \ +} while(0) + +/** + * Move an element to the list head. + * + * \param list list. + * \param elem element to move. + */ +#define move_to_head(list, elem) \ +do { \ + remove_from_list(elem); \ + insert_at_head(list, elem); \ +} while (0) + +/** + * Move an element to the list tail. + * + * \param list list. + * \param elem element to move. + */ +#define move_to_tail(list, elem) \ +do { \ + remove_from_list(elem); \ + insert_at_tail(list, elem); \ +} while (0) + +/** + * Consatinate a cyclic list to a list + * + * Appends the sequence of nodes starting with \c tail to the list \c head. + * A "cyclic list" is a list that does not have a sentinal node. This means + * that the data pointed to by \c tail is an actual node, not a dataless + * sentinal. Note that if \c tail constist of a single node, this macro + * behaves identically to \c insert_at_tail + * + * \param head Head of the list to be appended to. This may or may not + * be a cyclic list. + * \param tail Head of the cyclic list to be appended to \c head. + * \param temp Temporary \c simple_list used by the macro + * + * \sa insert_at_tail + */ +#define concat_list_and_cycle(head, tail, temp) \ +do { \ + (head)->prev->next = (tail); \ + (tail)->prev->next = (head); \ + (temp) = (head)->prev; \ + (head)->prev = (tail)->prev; \ + (tail)->prev = (temp); \ +} while (0) + +#define concat_list(head, next_list) \ +do { \ + (next_list)->next->prev = (head)->prev; \ + (next_list)->prev->next = (head); \ + (head)->prev->next = (next_list)->next; \ + (head)->prev = (next_list)->prev; \ +} while (0) + +/** + * Make a empty list empty. + * + * \param sentinal list (sentinal element). + */ +#define make_empty_list(sentinal) \ +do { \ + (sentinal)->next = sentinal; \ + (sentinal)->prev = sentinal; \ +} while (0) + +/** + * Get list first element. + * + * \param list list. + * + * \return pointer to first element. + */ +#define first_elem(list) ((list)->next) + +/** + * Get list last element. + * + * \param list list. + * + * \return pointer to last element. + */ +#define last_elem(list) ((list)->prev) + +/** + * Get next element. + * + * \param elem element. + * + * \return pointer to next element. + */ +#define next_elem(elem) ((elem)->next) + +/** + * Get previous element. + * + * \param elem element. + * + * \return pointer to previous element. + */ +#define prev_elem(elem) ((elem)->prev) + +/** + * Test whether element is at end of the list. + * + * \param list list. + * \param elem element. + * + * \return non-zero if element is at end of list, or zero otherwise. + */ +#define at_end(list, elem) ((elem) == (list)) + +/** + * Test if a list is empty. + * + * \param list list. + * + * \return non-zero if list empty, or zero otherwise. + */ +#define is_empty_list(list) ((list)->next == (list)) + +/** + * Walk through the elements of a list. + * + * \param ptr pointer to the current element. + * \param list list. + * + * \note It should be followed by a { } block or a single statement, as in a \c + * for loop. + */ +#define foreach(ptr, list) \ + for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) + +/** + * Walk through the elements of a list. + * + * Same as #foreach but lets you unlink the current value during a list + * traversal. Useful for freeing a list, element by element. + * + * \param ptr pointer to the current element. + * \param t temporary pointer. + * \param list list. + * + * \note It should be followed by a { } block or a single statement, as in a \c + * for loop. + */ +#define foreach_s(ptr, t, list) \ + for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) + +#endif diff --git a/symbol_table.c b/symbol_table.c new file mode 100644 index 00000000000..4e043d17336 --- /dev/null +++ b/symbol_table.c @@ -0,0 +1,377 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "main/imports.h" +#include "symbol_table.h" +#include "hash_table.h" + +struct symbol { + /** + * Link to the next symbol in the table with the same name + * + * The linked list of symbols with the same name is ordered by scope + * from inner-most to outer-most. + */ + struct symbol *next_with_same_name; + + + /** + * Link to the next symbol in the table with the same scope + * + * The linked list of symbols with the same scope is unordered. Symbols + * in this list my have unique names. + */ + struct symbol *next_with_same_scope; + + + /** + * Header information for the list of symbols with the same name. + */ + struct symbol_header *hdr; + + + /** + * Name space of the symbol + * + * Name space are arbitrary user assigned integers. No two symbols can + * exist in the same name space at the same scope level. + */ + int name_space; + + + /** + * Arbitrary user supplied data. + */ + void *data; + + /** Scope depth where this symbol was defined. */ + unsigned depth; +}; + + +/** + */ +struct symbol_header { + /** Linkage in list of all headers in a given symbol table. */ + struct symbol_header *next; + + /** Symbol name. */ + const char *name; + + /** Linked list of symbols with the same name. */ + struct symbol *symbols; +}; + + +/** + * Element of the scope stack. + */ +struct scope_level { + /** Link to next (inner) scope level. */ + struct scope_level *next; + + /** Linked list of symbols with the same scope. */ + struct symbol *symbols; +}; + + +/** + * + */ +struct _mesa_symbol_table { + /** Hash table containing all symbols in the symbol table. */ + struct hash_table *ht; + + /** Top of scope stack. */ + struct scope_level *current_scope; + + /** List of all symbol headers in the table. */ + struct symbol_header *hdr; + + /** Current scope depth. */ + unsigned depth; +}; + + +struct _mesa_symbol_table_iterator { + /** + * Name space of symbols returned by this iterator. + */ + int name_space; + + + /** + * Currently iterated symbol + * + * The next call to \c _mesa_symbol_table_iterator_get will return this + * value. It will also update this value to the value that should be + * returned by the next call. + */ + struct symbol *curr; +}; + + +static void +check_symbol_table(struct _mesa_symbol_table *table) +{ +#if 1 + struct scope_level *scope; + + for (scope = table->current_scope; scope != NULL; scope = scope->next) { + struct symbol *sym; + + for (sym = scope->symbols + ; sym != NULL + ; sym = sym->next_with_same_name) { + const struct symbol_header *const hdr = sym->hdr; + struct symbol *sym2; + + for (sym2 = hdr->symbols + ; sym2 != NULL + ; sym2 = sym2->next_with_same_name) { + assert(sym2->hdr == hdr); + } + } + } +#endif +} + +void +_mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table) +{ + struct scope_level *const scope = table->current_scope; + struct symbol *sym = scope->symbols; + + table->current_scope = scope->next; + table->depth--; + + free(scope); + + while (sym != NULL) { + struct symbol *const next = sym->next_with_same_scope; + struct symbol_header *const hdr = sym->hdr; + + assert(hdr->symbols == sym); + + hdr->symbols = sym->next_with_same_name; + + free(sym); + + sym = next; + } + + check_symbol_table(table); +} + + +void +_mesa_symbol_table_push_scope(struct _mesa_symbol_table *table) +{ + struct scope_level *const scope = calloc(1, sizeof(*scope)); + + scope->next = table->current_scope; + table->current_scope = scope; + table->depth++; +} + + +static struct symbol_header * +find_symbol(struct _mesa_symbol_table *table, const char *name) +{ + return (struct symbol_header *) hash_table_find(table->ht, name); +} + + +struct _mesa_symbol_table_iterator * +_mesa_symbol_table_iterator_ctor(struct _mesa_symbol_table *table, + int name_space, const char *name) +{ + struct _mesa_symbol_table_iterator *iter = calloc(1, sizeof(*iter)); + struct symbol_header *const hdr = find_symbol(table, name); + + iter->name_space = name_space; + + if (hdr != NULL) { + struct symbol *sym; + + for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { + assert(sym->hdr == hdr); + + if ((name_space == -1) || (sym->name_space == name_space)) { + iter->curr = sym; + break; + } + } + } + + return iter; +} + + +void +_mesa_symbol_table_iterator_dtor(struct _mesa_symbol_table_iterator *iter) +{ + free(iter); +} + + +void * +_mesa_symbol_table_iterator_get(struct _mesa_symbol_table_iterator *iter) +{ + return (iter->curr == NULL) ? NULL : iter->curr->data; +} + + +int +_mesa_symbol_table_iterator_next(struct _mesa_symbol_table_iterator *iter) +{ + struct symbol_header *hdr; + + if (iter->curr == NULL) { + return 0; + } + + hdr = iter->curr->hdr; + iter->curr = iter->curr->next_with_same_name; + + while (iter->curr != NULL) { + assert(iter->curr->hdr == hdr); + + if ((iter->name_space == -1) + || (iter->curr->name_space == iter->name_space)) { + return 1; + } + + iter->curr = iter->curr->next_with_same_name; + } + + return 0; +} + + +void * +_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table, + int name_space, const char *name) +{ + struct symbol_header *const hdr = find_symbol(table, name); + + if (hdr != NULL) { + struct symbol *sym; + + + for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { + assert(sym->hdr == hdr); + + if ((name_space == -1) || (sym->name_space == name_space)) { + return sym->data; + } + } + } + + return NULL; +} + + +int +_mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, + int name_space, const char *name, + void *declaration) +{ + struct symbol_header *hdr; + struct symbol *sym; + + check_symbol_table(table); + + hdr = find_symbol(table, name); + + check_symbol_table(table); + + if (hdr == NULL) { + hdr = calloc(1, sizeof(*hdr)); + hdr->name = name; + + hash_table_insert(table->ht, hdr, name); + hdr->next = table->hdr; + table->hdr = hdr; + } + + check_symbol_table(table); + + /* If the symbol already exists at this scope, it cannot be added to the + * table. + */ + if (hdr->symbols && (hdr->symbols->depth == table->depth)) + return -1; + + sym = calloc(1, sizeof(*sym)); + sym->next_with_same_name = hdr->symbols; + sym->next_with_same_scope = table->current_scope->symbols; + sym->hdr = hdr; + sym->name_space = name_space; + sym->data = declaration; + sym->depth = table->depth; + + assert(sym->hdr == hdr); + + hdr->symbols = sym; + table->current_scope->symbols = sym; + + check_symbol_table(table); + return 0; +} + + +struct _mesa_symbol_table * +_mesa_symbol_table_ctor(void) +{ + struct _mesa_symbol_table *table = calloc(1, sizeof(*table)); + + if (table != NULL) { + table->ht = hash_table_ctor(32, hash_table_string_hash, + hash_table_string_compare); + + _mesa_symbol_table_push_scope(table); + } + + return table; +} + + +void +_mesa_symbol_table_dtor(struct _mesa_symbol_table *table) +{ + struct symbol_header *hdr; + struct symbol_header *next; + + while (table->current_scope != NULL) { + _mesa_symbol_table_pop_scope(table); + } + + for (hdr = table->hdr; hdr != NULL; hdr = next) { + next = hdr->next; + _mesa_free(hdr); + } + + hash_table_dtor(table->ht); + free(table); +} diff --git a/symbol_table.h b/symbol_table.h new file mode 100644 index 00000000000..d3f65e30a92 --- /dev/null +++ b/symbol_table.h @@ -0,0 +1,63 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#ifndef MESA_SYMBOL_TABLE_H +#define MESA_SYMBOL_TABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct _mesa_symbol_table; +struct _mesa_symbol_table_iterator; + +extern void _mesa_symbol_table_push_scope(struct _mesa_symbol_table *table); + +extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table); + +extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, + int name_space, const char *name, void *declaration); + +extern void *_mesa_symbol_table_find_symbol( + struct _mesa_symbol_table *symtab, int name_space, const char *name); + +extern struct _mesa_symbol_table *_mesa_symbol_table_ctor(void); + +extern void _mesa_symbol_table_dtor(struct _mesa_symbol_table *); + +extern struct _mesa_symbol_table_iterator *_mesa_symbol_table_iterator_ctor( + struct _mesa_symbol_table *table, int name_space, const char *name); + +extern void _mesa_symbol_table_iterator_dtor( + struct _mesa_symbol_table_iterator *); + +extern void *_mesa_symbol_table_iterator_get( + struct _mesa_symbol_table_iterator *iter); + +extern int _mesa_symbol_table_iterator_next( + struct _mesa_symbol_table_iterator *iter); + +#ifdef __cplusplus +} +#endif + +#endif /* MESA_SYMBOL_TABLE_H */ diff --git a/tests/parameters-01.txt b/tests/parameters-01.txt new file mode 100644 index 00000000000..f0beb6c35d1 --- /dev/null +++ b/tests/parameters-01.txt @@ -0,0 +1,9 @@ +void a() +{ + ; +} + +void a() +{ + ; +} diff --git a/tests/parameters-02.txt b/tests/parameters-02.txt new file mode 100644 index 00000000000..58f44e532e1 --- /dev/null +++ b/tests/parameters-02.txt @@ -0,0 +1,9 @@ +void a() +{ + ; +} + +void a(float x) +{ + ; +} diff --git a/tests/parameters-03.txt b/tests/parameters-03.txt new file mode 100644 index 00000000000..7ec30f80cc6 --- /dev/null +++ b/tests/parameters-03.txt @@ -0,0 +1,9 @@ +/* FAIL - x is redeclared in the function body at the same scope as the + * parameter + */ +void a(float x, float y) +{ + float x; + + x = y; +} diff --git a/tests/swiz-01.glsl b/tests/swiz-01.glsl new file mode 100644 index 00000000000..a72af37c677 --- /dev/null +++ b/tests/swiz-01.glsl @@ -0,0 +1,10 @@ +#version 120 + +void main() +{ + float a; + vec4 b; + + b.x = 6.0; + a = b.x; +} diff --git a/tests/swiz-02.glsl b/tests/swiz-02.glsl new file mode 100644 index 00000000000..5e2acd1a25a --- /dev/null +++ b/tests/swiz-02.glsl @@ -0,0 +1,10 @@ +#version 120 + +void main() +{ + float a; + vec4 b; + + b.x = 6.0; + a = b.xy; +} -- cgit v1.2.3 From 53d2774ee397fc35fc0458d994d39dd3f27a5eb1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 22 Feb 2010 13:22:10 -0800 Subject: Initialize the node structure embedded in the ast_node --- glsl_parser_extras.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glsl_parser_extras.cc b/glsl_parser_extras.cc index 679b600fb3c..36a6ca8264b 100644 --- a/glsl_parser_extras.cc +++ b/glsl_parser_extras.cc @@ -108,7 +108,7 @@ ast_node::print(void) const ast_node::ast_node(void) { -// make_empty_list(& ast->node); + make_empty_list(this); } void -- cgit v1.2.3 From d5f4f09e76504876e62d9a3510fbd1480716035d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 22 Feb 2010 18:43:08 -0800 Subject: Rename .cc files to .cpp --- Makefile | 24 +- ast_to_hir.cc | 1172 ----------------------------------------------- ast_to_hir.cpp | 1172 +++++++++++++++++++++++++++++++++++++++++++++++ glsl_parser_extras.cc | 771 ------------------------------- glsl_parser_extras.cpp | 771 +++++++++++++++++++++++++++++++ hir_field_selection.cc | 187 -------- hir_field_selection.cpp | 187 ++++++++ ir.cc | 116 ----- ir.cpp | 116 +++++ 9 files changed, 2258 insertions(+), 2258 deletions(-) delete mode 100644 ast_to_hir.cc create mode 100644 ast_to_hir.cpp delete mode 100644 glsl_parser_extras.cc create mode 100644 glsl_parser_extras.cpp delete mode 100644 hir_field_selection.cc create mode 100644 hir_field_selection.cpp delete mode 100644 ir.cc create mode 100644 ir.cpp diff --git a/Makefile b/Makefile index 2f2142ed131..0d9017c3069 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CSRCS = symbol_table.c hash_table.c glsl_types.c -CCSRCS = glsl_parser.tab.cc glsl_lexer.cc glsl_parser_extras.cc -# ast_to_hir.cc ir.cc hir_field_selection.cc -OBJS = $(CSRCS:.c=.o) $(CCSRCS:.cc=.o) +CCSRCS = glsl_parser.tab.cpp glsl_lexer.cpp glsl_parser_extras.cpp +# ast_to_hir.cpp ir.cpp hir_field_selection.cpp +OBJS = $(CSRCS:.c=.o) $(CCSRCS:.cpp=.o) CC = gcc CXX = g++ @@ -15,26 +15,26 @@ LDLAGS = -ggdb3 glsl: $(OBJS) $(CXX) $(LDLAGS) $(OBJS) -o glsl -glsl_parser.tab.cc glsl_parser.tab.h: glsl_parser.y +glsl_parser.tab.cpp glsl_parser.tab.h: glsl_parser.y bison --report-file=glsl_parser.output -v -d \ - --output=glsl_parser.tab.cc \ + --output=glsl_parser.tab.cpp \ --name-prefix=_mesa_glsl_ $< && \ - mv glsl_parser.tab.hh glsl_parser.tab.h + mv glsl_parser.tab.hpp glsl_parser.tab.h -glsl_lexer.cc: glsl_lexer.l - flex --outfile="glsl_lexer.cc" $< +glsl_lexer.cpp: glsl_lexer.l + flex --outfile="glsl_lexer.cpp" $< -glsl_parser_tab.o: glsl_parser.tab.cc +glsl_parser_tab.o: glsl_parser.tab.cpp glsl_types.o: glsl_types.c glsl_types.h builtin_types.h -glsl_lexer.o: glsl_lexer.cc glsl_parser.tab.h glsl_parser_extras.h ast.h +glsl_lexer.o: glsl_lexer.cpp glsl_parser.tab.h glsl_parser_extras.h ast.h glsl_parser.o: glsl_parser_extras.h ast.h -ast_to_hir.o: ast_to_hir.cc symbol_table.h glsl_parser_extras.h ast.h glsl_types.h ir.h +ast_to_hir.o: ast_to_hir.cpp symbol_table.h glsl_parser_extras.h ast.h glsl_types.h ir.h builtin_types.h: builtin_types.sh ./builtin_types.sh > builtin_types.h clean: rm -f $(OBJS) glsl - rm -f glsl_lexer.cc glsl_parser.tab.{cc,h,hh} glsl_parser.output + rm -f glsl_lexer.cpp glsl_parser.tab.{cpp,h,hpp} glsl_parser.output rm -f builtin_types.h rm -f *~ \ No newline at end of file diff --git a/ast_to_hir.cc b/ast_to_hir.cc deleted file mode 100644 index 8474a461ce2..00000000000 --- a/ast_to_hir.cc +++ /dev/null @@ -1,1172 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ast_to_hir.c - * Convert abstract syntax to to high-level intermediate reprensentation (HIR). - * - * During the conversion to HIR, the majority of the symantic checking is - * preformed on the program. This includes: - * - * * Symbol table management - * * Type checking - * * Function binding - * - * The majority of this work could be done during parsing, and the parser could - * probably generate HIR directly. However, this results in frequent changes - * to the parser code. Since we do not assume that every system this complier - * is built on will have Flex and Bison installed, we have to store the code - * generated by these tools in our version control system. In other parts of - * the system we've seen problems where a parser was changed but the generated - * code was not committed, merge conflicts where created because two developers - * had slightly different versions of Bison installed, etc. - * - * I have also noticed that running Bison generated parsers in GDB is very - * irritating. When you get a segfault on '$$ = $1->foo', you can't very - * well 'print $1' in GDB. - * - * As a result, my preference is to put as little C code as possible in the - * parser (and lexer) sources. - */ -#include -#include "main/imports.h" -#include "symbol_table.h" -#include "glsl_parser_extras.h" -#include "ast.h" -#include "glsl_types.h" -#include "ir.h" - -void -_mesa_generate_hir_from_ast(struct _mesa_glsl_parse_state *state) -{ - struct simple_node *ptr; - - foreach (ptr, & state->translation_unit) { - if (1) { - } - } -} - - -static const struct glsl_type * -arithmetic_result_type(const struct glsl_type *type_a, - const struct glsl_type *type_b, - bool multiply, - struct _mesa_glsl_parse_state *state) -{ - /* From GLSL 1.50 spec, page 56: - * - * "The arithmetic binary operators add (+), subtract (-), - * multiply (*), and divide (/) operate on integer and - * floating-point scalars, vectors, and matrices." - */ - if (! is_numeric_base_type(type_a->base_type) - || ! is_numeric_base_type(type_b->base_type)) { - return glsl_error_type; - } - - - /* "If one operand is floating-point based and the other is - * not, then the conversions from Section 4.1.10 "Implicit - * Conversions" are applied to the non-floating-point-based operand." - * - * This conversion was added in GLSL 1.20. If the compilation mode is - * GLSL 1.10, the conversion is skipped. - */ - if (state->language_version >= 120) { - if ((type_a->base_type == GLSL_TYPE_FLOAT) - && (type_b->base_type != GLSL_TYPE_FLOAT)) { - } else if ((type_a->base_type != GLSL_TYPE_FLOAT) - && (type_b->base_type == GLSL_TYPE_FLOAT)) { - } - } - - /* "If the operands are integer types, they must both be signed or - * both be unsigned." - * - * From this rule and the preceeding conversion it can be inferred that - * both types must be GLSL_TYPE_FLOAT, or GLSL_TYPE_UINT, or GLSL_TYPE_INT. - * The is_numeric_base_type check above already filtered out the case - * where either type is not one of these, so now the base types need only - * be tested for equality. - */ - if (type_a->base_type != type_b->base_type) { - return glsl_error_type; - } - - /* "All arithmetic binary operators result in the same fundamental type - * (signed integer, unsigned integer, or floating-point) as the - * operands they operate on, after operand type conversion. After - * conversion, the following cases are valid - * - * * The two operands are scalars. In this case the operation is - * applied, resulting in a scalar." - */ - if (is_glsl_type_scalar(type_a) && is_glsl_type_scalar(type_b)) - return type_a; - - /* "* One operand is a scalar, and the other is a vector or matrix. - * In this case, the scalar operation is applied independently to each - * component of the vector or matrix, resulting in the same size - * vector or matrix." - */ - if (is_glsl_type_scalar(type_a)) { - if (!is_glsl_type_scalar(type_b)) - return type_b; - } else if (is_glsl_type_scalar(type_b)) { - return type_a; - } - - /* All of the combinations of , , - * , , and have been - * handled. - */ - assert(type_a->vector_elements > 1); - assert(type_b->vector_elements > 1); - - /* "* The two operands are vectors of the same size. In this case, the - * operation is done component-wise resulting in the same size - * vector." - */ - if (is_glsl_type_vector(type_a) && is_glsl_type_vector(type_b)) { - if (type_a->vector_elements == type_b->vector_elements) - return type_a; - else - return glsl_error_type; - } - - /* All of the combinations of , , - * , , , and - * have been handled. At least one of the operands must - * be matrix. Further, since there are no integer matrix types, the base - * type of both operands must be float. - */ - assert((type_a->matrix_rows > 1) || (type_b->matrix_rows > 1)); - assert(type_a->base_type == GLSL_TYPE_FLOAT); - assert(type_b->base_type == GLSL_TYPE_FLOAT); - - /* "* The operator is add (+), subtract (-), or divide (/), and the - * operands are matrices with the same number of rows and the same - * number of columns. In this case, the operation is done component- - * wise resulting in the same size matrix." - * * The operator is multiply (*), where both operands are matrices or - * one operand is a vector and the other a matrix. A right vector - * operand is treated as a column vector and a left vector operand as a - * row vector. In all these cases, it is required that the number of - * columns of the left operand is equal to the number of rows of the - * right operand. Then, the multiply (*) operation does a linear - * algebraic multiply, yielding an object that has the same number of - * rows as the left operand and the same number of columns as the right - * operand. Section 5.10 "Vector and Matrix Operations" explains in - * more detail how vectors and matrices are operated on." - */ - if (! multiply) { - if (is_glsl_type_matrix(type_a) && is_glsl_type_matrix(type_b) - && (type_a->vector_elements == type_b->vector_elements) - && (type_a->matrix_rows == type_b->matrix_rows)) - return type_a; - else - return glsl_error_type; - } else { - if (is_glsl_type_matrix(type_a) && is_glsl_type_matrix(type_b)) { - if (type_a->vector_elements == type_b->matrix_rows) { - char type_name[7]; - const struct glsl_type *t; - - type_name[0] = 'm'; - type_name[1] = 'a'; - type_name[2] = 't'; - - if (type_a->matrix_rows == type_b->vector_elements) { - type_name[3] = '0' + type_a->matrix_rows; - type_name[4] = '\0'; - } else { - type_name[3] = '0' + type_a->matrix_rows; - type_name[4] = 'x'; - type_name[5] = '0' + type_b->vector_elements; - type_name[6] = '\0'; - } - - t = _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); - return (t != NULL) ? t : glsl_error_type; - } - } else if (is_glsl_type_matrix(type_a)) { - /* A is a matrix and B is a column vector. Columns of A must match - * rows of B. - */ - if (type_a->vector_elements == type_b->vector_elements) - return type_b; - } else { - assert(is_glsl_type_matrix(type_b)); - - /* A is a row vector and B is a matrix. Columns of A must match - * rows of B. - */ - if (type_a->vector_elements == type_b->matrix_rows) - return type_a; - } - } - - - /* "All other cases are illegal." - */ - return glsl_error_type; -} - - -static const struct glsl_type * -unary_arithmetic_result_type(const struct glsl_type *type) -{ - /* From GLSL 1.50 spec, page 57: - * - * "The arithmetic unary operators negate (-), post- and pre-increment - * and decrement (-- and ++) operate on integer or floating-point - * values (including vectors and matrices). All unary operators work - * component-wise on their operands. These result with the same type - * they operated on." - */ - if (!is_numeric_base_type(type->base_type)) - return glsl_error_type; - - return type; -} - - -static const struct glsl_type * -modulus_result_type(const struct glsl_type *type_a, - const struct glsl_type *type_b) -{ - /* From GLSL 1.50 spec, page 56: - * "The operator modulus (%) operates on signed or unsigned integers or - * integer vectors. The operand types must both be signed or both be - * unsigned." - */ - if (! is_integer_base_type(type_a->base_type) - || ! is_integer_base_type(type_b->base_type) - || (type_a->base_type != type_b->base_type)) { - return glsl_error_type; - } - - /* "The operands cannot be vectors of differing size. If one operand is - * a scalar and the other vector, then the scalar is applied component- - * wise to the vector, resulting in the same type as the vector. If both - * are vectors of the same size, the result is computed component-wise." - */ - if (is_glsl_type_vector(type_a)) { - if (!is_glsl_type_vector(type_b) - || (type_a->vector_elements == type_b->vector_elements)) - return type_a; - } else - return type_b; - - /* "The operator modulus (%) is not defined for any other data types - * (non-integer types)." - */ - return glsl_error_type; -} - - -static const struct glsl_type * -relational_result_type(const struct glsl_type *type_a, - const struct glsl_type *type_b, - struct _mesa_glsl_parse_state *state) -{ - /* From GLSL 1.50 spec, page 56: - * "The relational operators greater than (>), less than (<), greater - * than or equal (>=), and less than or equal (<=) operate only on - * scalar integer and scalar floating-point expressions." - */ - if (! is_numeric_base_type(type_a->base_type) - || ! is_numeric_base_type(type_b->base_type) - || ! is_glsl_type_scalar(type_a) - || ! is_glsl_type_scalar(type_b)) - return glsl_error_type; - - /* "Either the operands' types must match, or the conversions from - * Section 4.1.10 "Implicit Conversions" will be applied to the integer - * operand, after which the types must match." - * - * This conversion was added in GLSL 1.20. If the compilation mode is - * GLSL 1.10, the conversion is skipped. - */ - if (state->language_version >= 120) { - if ((type_a->base_type == GLSL_TYPE_FLOAT) - && (type_b->base_type != GLSL_TYPE_FLOAT)) { - /* FINISHME: Generate the implicit type conversion. */ - } else if ((type_a->base_type != GLSL_TYPE_FLOAT) - && (type_b->base_type == GLSL_TYPE_FLOAT)) { - /* FINISHME: Generate the implicit type conversion. */ - } - } - - if (type_a->base_type != type_b->base_type) - return glsl_error_type; - - /* "The result is scalar Boolean." - */ - return glsl_bool_type; -} - - -struct ir_instruction * -ast_expression_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) -{ - const struct ast_expression *expr = - (struct ast_expression *) ast; - static const int operations[AST_NUM_OPERATORS] = { - -1, /* ast_assign doesn't convert to ir_expression. */ - -1, /* ast_plus doesn't convert to ir_expression. */ - ir_unop_neg, - ir_binop_add, - ir_binop_sub, - ir_binop_mul, - ir_binop_div, - ir_binop_mod, - ir_binop_lshift, - ir_binop_rshift, - ir_binop_less, - ir_binop_greater, - ir_binop_lequal, - ir_binop_gequal, - ir_binop_equal, - ir_binop_nequal, - ir_binop_bit_and, - ir_binop_bit_xor, - ir_binop_bit_or, - ir_unop_bit_not, - ir_binop_logic_and, - ir_binop_logic_xor, - ir_binop_logic_or, - ir_unop_logic_not, - - /* Note: The following block of expression types actually convert - * to multiple IR instructions. - */ - ir_binop_mul, /* ast_mul_assign */ - ir_binop_div, /* ast_div_assign */ - ir_binop_mod, /* ast_mod_assign */ - ir_binop_add, /* ast_add_assign */ - ir_binop_sub, /* ast_sub_assign */ - ir_binop_lshift, /* ast_ls_assign */ - ir_binop_rshift, /* ast_rs_assign */ - ir_binop_bit_and, /* ast_and_assign */ - ir_binop_bit_xor, /* ast_xor_assign */ - ir_binop_bit_or, /* ast_or_assign */ - - -1, /* ast_conditional doesn't convert to ir_expression. */ - -1, /* ast_pre_inc doesn't convert to ir_expression. */ - -1, /* ast_pre_dec doesn't convert to ir_expression. */ - -1, /* ast_post_inc doesn't convert to ir_expression. */ - -1, /* ast_post_dec doesn't convert to ir_expression. */ - -1, /* ast_field_selection doesn't conv to ir_expression. */ - -1, /* ast_array_index doesn't convert to ir_expression. */ - -1, /* ast_function_call doesn't conv to ir_expression. */ - -1, /* ast_identifier doesn't convert to ir_expression. */ - -1, /* ast_int_constant doesn't convert to ir_expression. */ - -1, /* ast_uint_constant doesn't conv to ir_expression. */ - -1, /* ast_float_constant doesn't conv to ir_expression. */ - -1, /* ast_bool_constant doesn't conv to ir_expression. */ - -1, /* ast_sequence doesn't convert to ir_expression. */ - }; - struct ir_instruction *result = NULL; - struct ir_instruction *op[2]; - struct simple_node op_list; - const struct glsl_type *type = glsl_error_type; - bool error_emitted = false; - YYLTYPE loc; - - loc = ast->get_location(); - make_empty_list(& op_list); - - switch (expr->oper) { - case ast_assign: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); - - error_emitted = ((op[0]->type == glsl_error_type) - || (op[1]->type == glsl_error_type)); - - type = op[0]->type; - if (!error_emitted) { - YYLTYPE loc; - - /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ - loc = expr->subexpressions[0]->get_location(); - if (op[0]->mode != ir_op_dereference) { - _mesa_glsl_error(& loc, state, "invalid lvalue in assignment"); - error_emitted = true; - - type = glsl_error_type; - } else { - const struct ir_dereference *const ref = - (struct ir_dereference *) op[0]; - const struct ir_variable *const var = - (struct ir_variable *) ref->var; - - if ((var != NULL) - && (var->mode == ir_op_var_decl) - && (var->read_only)) { - _mesa_glsl_error(& loc, state, "cannot assign to read-only " - "variable `%s'", var->name); - error_emitted = true; - - type = glsl_error_type; - } - } - } - - /* FINISHME: Check that the LHS and RHS have matching types. */ - /* FINISHME: For GLSL 1.10, check that the types are not arrays. */ - - result = new ir_assignment(op[0], op[1], NULL); - break; - - case ast_plus: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - - error_emitted = (op[0]->type == glsl_error_type); - if (type == glsl_error_type) - op[0]->type = type; - - result = op[0]; - break; - - case ast_neg: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - - type = unary_arithmetic_result_type(op[0]->type); - - error_emitted = (op[0]->type == glsl_error_type); - - result = new ir_expression(operations[expr->oper], type, - op[0], NULL); - break; - - case ast_add: - case ast_sub: - case ast_mul: - case ast_div: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); - - type = arithmetic_result_type(op[0]->type, op[1]->type, - (expr->operr == ast_mul), - state); - - result = new ir_expression(operations[expr->oper], type, - op[0], op[1]); - break; - - case ast_mod: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); - - error_emitted = ((op[0]->type == glsl_error_type) - || (op[1]->type == glsl_error_type)); - - type = modulus_result_type(op[0]->type, op[1]->type); - - assert(operations[expr->oper] == ir_binop_mod); - - result = new ir_expression(operations[expr->oper], type, - op[0], op[1]); - break; - - case ast_lshift: - case ast_rshift: - /* FINISHME: Implement bit-shift operators. */ - break; - - case ast_less: - case ast_greater: - case ast_lequal: - case ast_gequal: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); - - error_emitted = ((op[0]->type == glsl_error_type) - || (op[1]->type == glsl_error_type)); - - type = relational_result_type(op[0]->type, op[1]->type, state); - - /* The relational operators must either generate an error or result - * in a scalar boolean. See page 57 of the GLSL 1.50 spec. - */ - assert((type == glsl_error_type) - || ((type->base_type == GLSL_TYPE_BOOL) - && is_glsl_type_scalar(type))); - - result = new ir_expression(operations[expr->oper], type, - op[0], op[1]); - break; - - case ast_nequal: - case ast_equal: - /* FINISHME: Implement equality operators. */ - break; - - case ast_bit_and: - case ast_bit_xor: - case ast_bit_or: - case ast_bit_not: - /* FINISHME: Implement bit-wise operators. */ - break; - - case ast_logic_and: - case ast_logic_xor: - case ast_logic_or: - case ast_logic_not: - /* FINISHME: Implement logical operators. */ - break; - - case ast_mul_assign: - case ast_div_assign: - case ast_add_assign: - case ast_sub_assign: { - struct ir_instruction *temp_rhs; - - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); - - error_emitted = ((op[0]->type == glsl_error_type) - || (op[1]->type == glsl_error_type)); - - type = arithmetic_result_type(op[0]->type, op[1]->type, - (expr->oper == ast_mul_assign), - state); - - temp_rhs = new ir_expression(operations[expr->oper], type, - op[0], op[1]); - - /* FINISHME: Check that the LHS is assignable. */ - - /* We still have to test that the LHS and RHS have matching type. For - * example, the following GLSL code should generate a type error: - * - * mat4 m; vec4 v; m *= v; - * - * The type of (m*v) is a vec4, but the type of m is a mat4. - * - * FINISHME: Is multiplication between a matrix and a vector the only - * FINISHME: case that resuls in mismatched types? - */ - /* FINISHME: Check that the LHS and RHS have matching types. */ - - /* GLSL 1.10 does not allow array assignment. However, we don't have to - * explicitly test for this because none of the binary expression - * operators allow array operands either. - */ - - /* FINISHME: This is wrong. The operation should assign to a new - * FINISHME: temporary. This assignment should then be added to the - * FINISHME: instruction list. Another assignment to the real - * FINISHME: destination should be generated. The temporary should then - * FINISHME: be returned as the r-value. - */ - result = new ir_assignment(op[0], temp_rhs, NULL); - break; - } - - case ast_mod_assign: - - case ast_ls_assign: - case ast_rs_assign: - - case ast_and_assign: - case ast_xor_assign: - case ast_or_assign: - - case ast_conditional: - - case ast_pre_inc: - case ast_pre_dec: - - case ast_post_inc: - case ast_post_dec: - break; - - case ast_field_selection: - result = _mesa_ast_field_selection_to_hir(expr, instructions, state); - type = result->type; - break; - - case ast_array_index: - break; - - case ast_function_call: - /* There are three sorts of function calls. - * - * 1. contstructors - The first subexpression is an ast_type_specifier. - * 2. methods - Only the .length() method of array types. - * 3. functions - Calls to regular old functions. - * - * Method calls are actually detected when the ast_field_selection - * expression is handled. - */ - result = _mesa_ast_function_call_to_hir(expr->subexpressions[0], - expr->subexpressions[1], - state); - type = result->type; - break; - - case ast_identifier: { - /* ast_identifier can appear several places in a full abstract syntax - * tree. This particular use must be at location specified in the grammar - * as 'variable_identifier'. - */ - struct ir_variable *var = - _mesa_symbol_table_find_symbol(state->symbols, 0, - expr->primary_expression.identifier); - - result = new ir_dereference(var); - - if (var != NULL) { - type = result->type; - } else { - _mesa_glsl_error(& loc, NULL, "`%s' undeclared", - expr->primary_expression.identifier); - - error_emitted = true; - } - break; - } - - case ast_int_constant: - type = glsl_int_type; - result = new ir_constant(type, & expr->primary_expression); - break; - - case ast_uint_constant: - type = glsl_uint_type; - result = new ir_constant(type, & expr->primary_expression); - break; - - case ast_float_constant: - type = glsl_float_type; - result = new ir_constant(type, & expr->primary_expression); - break; - - case ast_bool_constant: - type = glsl_bool_type; - result = new ir_constant(type, & expr->primary_expression); - break; - - case ast_sequence: { - struct simple_node *ptr; - - /* It should not be possible to generate a sequence in the AST without - * any expressions in it. - */ - assert(!is_empty_list(&expr->expressions)); - - /* The r-value of a sequence is the last expression in the sequence. If - * the other expressions in the sequence do not have side-effects (and - * therefore add instructions to the instruction list), they get dropped - * on the floor. - */ - foreach (ptr, &expr->expressions) - result = _mesa_ast_to_hir(ptr, instructions, state); - - type = result->type; - - /* Any errors should have already been emitted in the loop above. - */ - error_emitted = true; - break; - } - } - - if (is_error_type(type) && !error_emitted) - _mesa_glsl_error(& loc, NULL, "type mismatch"); - - return result; -} - - -struct ir_instruction * -ast_expression_statement_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) -{ - const struct ast_expression_statement *stmt = - (struct ast_expression_statement *) ast; - - /* It is possible to have expression statements that don't have an - * expression. This is the solitary semicolon: - * - * for (i = 0; i < 5; i++) - * ; - * - * In this case the expression will be NULL. Test for NULL and don't do - * anything in that case. - */ - if (stmt->expression != NULL) - _mesa_ast_to_hir(stmt->expression, instructions, state); - - /* Statements do not have r-values. - */ - return NULL; -} - - -struct ir_instruction * -ast_compound_statement_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) -{ - const struct ast_compound_statement *stmt = - (struct ast_compound_statement *) ast; - struct simple_node *ptr; - - - if (stmt->new_scope) - _mesa_symbol_table_push_scope(state->symbols); - - foreach (ptr, &stmt->statements) - _mesa_ast_to_hir(ptr, instructions, state); - - if (stmt->new_scope) - _mesa_symbol_table_pop_scope(state->symbols); - - /* Compound statements do not have r-values. - */ - return NULL; -} - - -static const struct glsl_type * -type_specifier_to_glsl_type(const struct ast_type_specifier *spec, - const char **name, - struct _mesa_glsl_parse_state *state) -{ - static const char *const type_names[] = { - "void", - "float", - "int", - "uint", - "bool", - "vec2", - "vec3", - "vec4", - "bvec2", - "bvec3", - "bvec4", - "ivec2", - "ivec3", - "ivec4", - "uvec2", - "uvec3", - "uvec4", - "mat2", - "mat2x3", - "mat2x4", - "mat3x2", - "mat3", - "mat3x4", - "mat4x2", - "mat4x3", - "mat4", - "sampler1D", - "sampler2D", - "sampler3D", - "samplerCube", - "sampler1DShadow", - "sampler2DShadow", - "samplerCubeShadow", - "sampler1DArray", - "sampler2DArray", - "sampler1DArrayShadow", - "sampler2DArrayShadow", - "isampler1D", - "isampler2D", - "isampler3D", - "isamplerCube", - "isampler1DArray", - "isampler2DArray", - "usampler1D", - "usampler2D", - "usampler3D", - "usamplerCube", - "usampler1DArray", - "usampler2DArray", - - NULL, /* ast_struct */ - NULL /* ast_type_name */ - }; - struct glsl_type *type; - const char *type_name = NULL; - - if (spec->type_specifier == ast_struct) { - /* FINISHME: Handle annonymous structures. */ - type = NULL; - } else { - type_name = (spec->type_specifier == ast_type_name) - ? spec->type_name : type_names[spec->type_specifier]; - - type = _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); - *name = type_name; - - /* FINISHME: Handle array declarations. Note that this requires complete - * FINSIHME: handling of constant expressions. - */ - } - - return type; -} - - -static void -apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, - struct ir_variable *var, - struct _mesa_glsl_parse_state *state) -{ - if (qual->invariant) - var->invariant = 1; - - /* FINISHME: Mark 'in' variables at global scope as read-only. */ - if (qual->constant || qual->attribute || qual->uniform - || (qual->varying && (state->target == fragment_shader))) - var->read_only = 1; - - if (qual->centroid) - var->centroid = 1; - - if (qual->in && qual->out) - var->mode = ir_var_inout; - else if (qual->attribute || qual->in - || (qual->varying && (state->target == fragment_shader))) - var->mode = ir_var_in; - else if (qual->out) - var->mode = ir_var_out; - else if (qual->uniform) - var->mode = ir_var_uniform; - else - var->mode = ir_var_auto; - - if (qual->flat) - var->interpolation = ir_var_flat; - else if (qual->noperspective) - var->interpolation = ir_var_noperspective; - else - var->interpolation = ir_var_smooth; -} - - -struct ir_instruction * -ast_declarator_list_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) -{ - const struct ast_declarator_list *dlist = (struct ast_declarator_list *) ast; - struct simple_node *ptr; - const struct glsl_type *decl_type; - const char *type_name = NULL; - - - /* FINISHME: Handle vertex shader "invariant" declarations that do not - * FINISHME: include a type. These re-declare built-in variables to be - * FINISHME: invariant. - */ - - decl_type = type_specifier_to_glsl_type(dlist->type->specifier, - & type_name, state); - - foreach (ptr, &dlist->declarations) { - struct ast_declaration *const decl = (struct ast_declaration * )ptr; - const struct glsl_type *var_type; - struct ir_variable *var; - - - /* FINISHME: Emit a warning if a variable declaration shadows a - * FINISHME: declaration at a higher scope. - */ - - if (decl_type == NULL) { - YYLTYPE loc; - - loc = ast->get_location(); - if (type_name != NULL) { - _mesa_glsl_error(& loc, state, - "invalid type `%s' in declaration of `%s'", - type_name, decl->identifier); - } else { - _mesa_glsl_error(& loc, state, - "invalid type in declaration of `%s'", - decl->identifier); - } - continue; - } - - if (decl->is_array) { - /* FINISHME: Handle array declarations. Note that this requires - * FINISHME: complete handling of constant expressions. - */ - - /* FINISHME: Reject delcarations of multidimensional arrays. */ - } else { - var_type = decl_type; - } - - var = new ir_variable(var_type, decl->identifier); - - /* FINSIHME: Variables that are attribute, uniform, varying, in, or - * FINISHME: out varibles must be declared either at global scope or - * FINISHME: in a parameter list (in and out only). - */ - - apply_type_qualifier_to_variable(& dlist->type->qualifier, var, state); - - /* Attempt to add the variable to the symbol table. If this fails, it - * means the variable has already been declared at this scope. - */ - if (_mesa_symbol_table_add_symbol(state->symbols, 0, decl->identifier, - var) != 0) { - YYLTYPE loc = ast->get_location(); - - _mesa_glsl_error(& loc, state, "`%s' redeclared", - decl->identifier); - continue; - } - - insert_at_tail(instructions, (struct simple_node *) var); - - /* FINISHME: Process the declaration initializer. */ - } - - /* Variable declarations do not have r-values. - */ - return NULL; -} - - -struct ir_instruction * -ast_parameter_declarator_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) -{ - const struct ast_parameter_declarator *decl = - (struct ast_parameter_declarator *) ast; - struct ir_variable *var; - const struct glsl_type *type; - const char *name = NULL; - - - type = type_specifier_to_glsl_type(decl->type->specifier, & name, state); - - if (type == NULL) { - YYLTYPE loc = ast->get_location(); - if (name != NULL) { - _mesa_glsl_error(& loc, state, - "invalid type `%s' in declaration of `%s'", - name, decl->identifier); - } else { - _mesa_glsl_error(& loc, state, - "invalid type in declaration of `%s'", - decl->identifier); - } - - type = glsl_error_type; - } - - var = new ir_variable(type, decl->identifier); - - /* FINISHME: Handle array declarations. Note that this requires - * FINISHME: complete handling of constant expressions. - */ - - apply_type_qualifier_to_variable(& decl->type->qualifier, var, state); - - insert_at_tail(instructions, var); - - /* Parameter declarations do not have r-values. - */ - return NULL; -} - - -static void -ast_function_parameters_to_hir(struct simple_node *ast_parameters, - struct simple_node *ir_parameters, - struct _mesa_glsl_parse_state *state) -{ - struct simple_node *ptr; - - foreach (ptr, ast_parameters) { - _mesa_ast_to_hir(ptr, ir_parameters, state); - } -} - - -static bool -parameter_lists_match(struct simple_node *list_a, struct simple_node *list_b) -{ - struct simple_node *node_a; - struct simple_node *node_b; - - node_b = first_elem(list_b); - foreach (node_a, list_a) { - /* If all of the parameters from the other parameter list have been - * exhausted, the lists have different length and, by definition, - * do not match. - */ - if (at_end(list_b, node_b)) - return false; - - /* If the types of the parameters do not match, the parameters lists - * are different. - */ - /* FINISHME */ - - - node_b = next_elem(node_b); - } - - return true; -} - - -struct ir_instruction * -ast_function_definition_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) -{ - const struct ast_function_definition *func = - (struct ast_function_definition *) ast; - struct ir_label *label; - struct simple_node *ptr; - struct simple_node *tmp; - struct ir_function_signature *signature = NULL; - struct ir_function *f = NULL; - struct simple_node parameters; - - - /* Convert the list of function parameters to HIR now so that they can be - * used below to compare this function's signature with previously seen - * signatures for functions with the same name. - */ - make_empty_list(& parameters); - ast_function_parameters_to_hir(& func->prototype->parameters, & parameters, - state); - - - /* Verify that this function's signature either doesn't match a previously - * seen signature for a function with the same name, or, if a match is found, - * that the previously seen signature does not have an associated definition. - */ - f = _mesa_symbol_table_find_symbol(state->symbols, 0, - func->prototype->identifier); - if (f != NULL) { - foreach (ptr, & f->signatures) { - signature = (struct ir_function_signature *) ptr; - - /* Compare the parameter list of the function being defined to the - * existing function. If the parameter lists match, then the return - * type must also match and the existing function must not have a - * definition. - */ - if (parameter_lists_match(& parameters, & signature->parameters)) { - /* FINISHME: Compare return types. */ - - if (signature->definition != NULL) { - YYLTYPE loc = ast->get_location(); - - _mesa_glsl_error(& loc, state, "function `%s' redefined", - func->prototype->identifier); - signature = NULL; - break; - } - } - - signature = NULL; - } - - } else { - f = new ir_function(); - f->name = func->prototype->identifier; - - _mesa_symbol_table_add_symbol(state->symbols, 0, f->name, f); - } - - - /* Finish storing the information about this new function in its signature. - */ - if (signature == NULL) { - signature = new ir_function_signature(); - insert_at_tail(& f->signatures, (struct simple_node *) signature); - } else { - /* Destroy all of the previous parameter information. The previous - * parameter information comes from the function prototype, and it can - * either include invalid parameter names or may not have names at all. - */ - foreach_s(ptr, tmp, & signature->parameters) { - assert(((struct ir_instruction *)ptr)->mode == ir_op_var_decl); - - remove_from_list(ptr); - free(ptr); - } - } - - - ast_function_parameters_to_hir(& func->prototype->parameters, - & signature->parameters, - state); - /* FINISHME: Set signature->return_type */ - - label = new ir_label(func->prototype->identifier); - if (signature->definition == NULL) { - signature->definition = label; - } - insert_at_tail(instructions, label); - - /* Add the function parameters to the symbol table. During this step the - * parameter declarations are also moved from the temporary "parameters" list - * to the instruction list. There are other more efficient ways to do this, - * but they involve ugly linked-list gymnastics. - */ - _mesa_symbol_table_push_scope(state->symbols); - foreach_s(ptr, tmp, & parameters) { - struct ir_variable *const var = (struct ir_variable *) ptr; - - assert(var->mode == ir_op_var_decl); - - remove_from_list(ptr); - insert_at_tail(instructions, ptr); - - _mesa_symbol_table_add_symbol(state->symbols, 0, var->name, var); - } - - /* Convert the body of the function to HIR, and append the resulting - * instructions to the list that currently consists of the function label - * and the function parameters. - */ - _mesa_ast_to_hir(func->body, instructions, state); - - _mesa_symbol_table_pop_scope(state->symbols); - - - /* Function definitions do not have r-values. - */ - return NULL; -} diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp new file mode 100644 index 00000000000..8474a461ce2 --- /dev/null +++ b/ast_to_hir.cpp @@ -0,0 +1,1172 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ast_to_hir.c + * Convert abstract syntax to to high-level intermediate reprensentation (HIR). + * + * During the conversion to HIR, the majority of the symantic checking is + * preformed on the program. This includes: + * + * * Symbol table management + * * Type checking + * * Function binding + * + * The majority of this work could be done during parsing, and the parser could + * probably generate HIR directly. However, this results in frequent changes + * to the parser code. Since we do not assume that every system this complier + * is built on will have Flex and Bison installed, we have to store the code + * generated by these tools in our version control system. In other parts of + * the system we've seen problems where a parser was changed but the generated + * code was not committed, merge conflicts where created because two developers + * had slightly different versions of Bison installed, etc. + * + * I have also noticed that running Bison generated parsers in GDB is very + * irritating. When you get a segfault on '$$ = $1->foo', you can't very + * well 'print $1' in GDB. + * + * As a result, my preference is to put as little C code as possible in the + * parser (and lexer) sources. + */ +#include +#include "main/imports.h" +#include "symbol_table.h" +#include "glsl_parser_extras.h" +#include "ast.h" +#include "glsl_types.h" +#include "ir.h" + +void +_mesa_generate_hir_from_ast(struct _mesa_glsl_parse_state *state) +{ + struct simple_node *ptr; + + foreach (ptr, & state->translation_unit) { + if (1) { + } + } +} + + +static const struct glsl_type * +arithmetic_result_type(const struct glsl_type *type_a, + const struct glsl_type *type_b, + bool multiply, + struct _mesa_glsl_parse_state *state) +{ + /* From GLSL 1.50 spec, page 56: + * + * "The arithmetic binary operators add (+), subtract (-), + * multiply (*), and divide (/) operate on integer and + * floating-point scalars, vectors, and matrices." + */ + if (! is_numeric_base_type(type_a->base_type) + || ! is_numeric_base_type(type_b->base_type)) { + return glsl_error_type; + } + + + /* "If one operand is floating-point based and the other is + * not, then the conversions from Section 4.1.10 "Implicit + * Conversions" are applied to the non-floating-point-based operand." + * + * This conversion was added in GLSL 1.20. If the compilation mode is + * GLSL 1.10, the conversion is skipped. + */ + if (state->language_version >= 120) { + if ((type_a->base_type == GLSL_TYPE_FLOAT) + && (type_b->base_type != GLSL_TYPE_FLOAT)) { + } else if ((type_a->base_type != GLSL_TYPE_FLOAT) + && (type_b->base_type == GLSL_TYPE_FLOAT)) { + } + } + + /* "If the operands are integer types, they must both be signed or + * both be unsigned." + * + * From this rule and the preceeding conversion it can be inferred that + * both types must be GLSL_TYPE_FLOAT, or GLSL_TYPE_UINT, or GLSL_TYPE_INT. + * The is_numeric_base_type check above already filtered out the case + * where either type is not one of these, so now the base types need only + * be tested for equality. + */ + if (type_a->base_type != type_b->base_type) { + return glsl_error_type; + } + + /* "All arithmetic binary operators result in the same fundamental type + * (signed integer, unsigned integer, or floating-point) as the + * operands they operate on, after operand type conversion. After + * conversion, the following cases are valid + * + * * The two operands are scalars. In this case the operation is + * applied, resulting in a scalar." + */ + if (is_glsl_type_scalar(type_a) && is_glsl_type_scalar(type_b)) + return type_a; + + /* "* One operand is a scalar, and the other is a vector or matrix. + * In this case, the scalar operation is applied independently to each + * component of the vector or matrix, resulting in the same size + * vector or matrix." + */ + if (is_glsl_type_scalar(type_a)) { + if (!is_glsl_type_scalar(type_b)) + return type_b; + } else if (is_glsl_type_scalar(type_b)) { + return type_a; + } + + /* All of the combinations of , , + * , , and have been + * handled. + */ + assert(type_a->vector_elements > 1); + assert(type_b->vector_elements > 1); + + /* "* The two operands are vectors of the same size. In this case, the + * operation is done component-wise resulting in the same size + * vector." + */ + if (is_glsl_type_vector(type_a) && is_glsl_type_vector(type_b)) { + if (type_a->vector_elements == type_b->vector_elements) + return type_a; + else + return glsl_error_type; + } + + /* All of the combinations of , , + * , , , and + * have been handled. At least one of the operands must + * be matrix. Further, since there are no integer matrix types, the base + * type of both operands must be float. + */ + assert((type_a->matrix_rows > 1) || (type_b->matrix_rows > 1)); + assert(type_a->base_type == GLSL_TYPE_FLOAT); + assert(type_b->base_type == GLSL_TYPE_FLOAT); + + /* "* The operator is add (+), subtract (-), or divide (/), and the + * operands are matrices with the same number of rows and the same + * number of columns. In this case, the operation is done component- + * wise resulting in the same size matrix." + * * The operator is multiply (*), where both operands are matrices or + * one operand is a vector and the other a matrix. A right vector + * operand is treated as a column vector and a left vector operand as a + * row vector. In all these cases, it is required that the number of + * columns of the left operand is equal to the number of rows of the + * right operand. Then, the multiply (*) operation does a linear + * algebraic multiply, yielding an object that has the same number of + * rows as the left operand and the same number of columns as the right + * operand. Section 5.10 "Vector and Matrix Operations" explains in + * more detail how vectors and matrices are operated on." + */ + if (! multiply) { + if (is_glsl_type_matrix(type_a) && is_glsl_type_matrix(type_b) + && (type_a->vector_elements == type_b->vector_elements) + && (type_a->matrix_rows == type_b->matrix_rows)) + return type_a; + else + return glsl_error_type; + } else { + if (is_glsl_type_matrix(type_a) && is_glsl_type_matrix(type_b)) { + if (type_a->vector_elements == type_b->matrix_rows) { + char type_name[7]; + const struct glsl_type *t; + + type_name[0] = 'm'; + type_name[1] = 'a'; + type_name[2] = 't'; + + if (type_a->matrix_rows == type_b->vector_elements) { + type_name[3] = '0' + type_a->matrix_rows; + type_name[4] = '\0'; + } else { + type_name[3] = '0' + type_a->matrix_rows; + type_name[4] = 'x'; + type_name[5] = '0' + type_b->vector_elements; + type_name[6] = '\0'; + } + + t = _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); + return (t != NULL) ? t : glsl_error_type; + } + } else if (is_glsl_type_matrix(type_a)) { + /* A is a matrix and B is a column vector. Columns of A must match + * rows of B. + */ + if (type_a->vector_elements == type_b->vector_elements) + return type_b; + } else { + assert(is_glsl_type_matrix(type_b)); + + /* A is a row vector and B is a matrix. Columns of A must match + * rows of B. + */ + if (type_a->vector_elements == type_b->matrix_rows) + return type_a; + } + } + + + /* "All other cases are illegal." + */ + return glsl_error_type; +} + + +static const struct glsl_type * +unary_arithmetic_result_type(const struct glsl_type *type) +{ + /* From GLSL 1.50 spec, page 57: + * + * "The arithmetic unary operators negate (-), post- and pre-increment + * and decrement (-- and ++) operate on integer or floating-point + * values (including vectors and matrices). All unary operators work + * component-wise on their operands. These result with the same type + * they operated on." + */ + if (!is_numeric_base_type(type->base_type)) + return glsl_error_type; + + return type; +} + + +static const struct glsl_type * +modulus_result_type(const struct glsl_type *type_a, + const struct glsl_type *type_b) +{ + /* From GLSL 1.50 spec, page 56: + * "The operator modulus (%) operates on signed or unsigned integers or + * integer vectors. The operand types must both be signed or both be + * unsigned." + */ + if (! is_integer_base_type(type_a->base_type) + || ! is_integer_base_type(type_b->base_type) + || (type_a->base_type != type_b->base_type)) { + return glsl_error_type; + } + + /* "The operands cannot be vectors of differing size. If one operand is + * a scalar and the other vector, then the scalar is applied component- + * wise to the vector, resulting in the same type as the vector. If both + * are vectors of the same size, the result is computed component-wise." + */ + if (is_glsl_type_vector(type_a)) { + if (!is_glsl_type_vector(type_b) + || (type_a->vector_elements == type_b->vector_elements)) + return type_a; + } else + return type_b; + + /* "The operator modulus (%) is not defined for any other data types + * (non-integer types)." + */ + return glsl_error_type; +} + + +static const struct glsl_type * +relational_result_type(const struct glsl_type *type_a, + const struct glsl_type *type_b, + struct _mesa_glsl_parse_state *state) +{ + /* From GLSL 1.50 spec, page 56: + * "The relational operators greater than (>), less than (<), greater + * than or equal (>=), and less than or equal (<=) operate only on + * scalar integer and scalar floating-point expressions." + */ + if (! is_numeric_base_type(type_a->base_type) + || ! is_numeric_base_type(type_b->base_type) + || ! is_glsl_type_scalar(type_a) + || ! is_glsl_type_scalar(type_b)) + return glsl_error_type; + + /* "Either the operands' types must match, or the conversions from + * Section 4.1.10 "Implicit Conversions" will be applied to the integer + * operand, after which the types must match." + * + * This conversion was added in GLSL 1.20. If the compilation mode is + * GLSL 1.10, the conversion is skipped. + */ + if (state->language_version >= 120) { + if ((type_a->base_type == GLSL_TYPE_FLOAT) + && (type_b->base_type != GLSL_TYPE_FLOAT)) { + /* FINISHME: Generate the implicit type conversion. */ + } else if ((type_a->base_type != GLSL_TYPE_FLOAT) + && (type_b->base_type == GLSL_TYPE_FLOAT)) { + /* FINISHME: Generate the implicit type conversion. */ + } + } + + if (type_a->base_type != type_b->base_type) + return glsl_error_type; + + /* "The result is scalar Boolean." + */ + return glsl_bool_type; +} + + +struct ir_instruction * +ast_expression_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_expression *expr = + (struct ast_expression *) ast; + static const int operations[AST_NUM_OPERATORS] = { + -1, /* ast_assign doesn't convert to ir_expression. */ + -1, /* ast_plus doesn't convert to ir_expression. */ + ir_unop_neg, + ir_binop_add, + ir_binop_sub, + ir_binop_mul, + ir_binop_div, + ir_binop_mod, + ir_binop_lshift, + ir_binop_rshift, + ir_binop_less, + ir_binop_greater, + ir_binop_lequal, + ir_binop_gequal, + ir_binop_equal, + ir_binop_nequal, + ir_binop_bit_and, + ir_binop_bit_xor, + ir_binop_bit_or, + ir_unop_bit_not, + ir_binop_logic_and, + ir_binop_logic_xor, + ir_binop_logic_or, + ir_unop_logic_not, + + /* Note: The following block of expression types actually convert + * to multiple IR instructions. + */ + ir_binop_mul, /* ast_mul_assign */ + ir_binop_div, /* ast_div_assign */ + ir_binop_mod, /* ast_mod_assign */ + ir_binop_add, /* ast_add_assign */ + ir_binop_sub, /* ast_sub_assign */ + ir_binop_lshift, /* ast_ls_assign */ + ir_binop_rshift, /* ast_rs_assign */ + ir_binop_bit_and, /* ast_and_assign */ + ir_binop_bit_xor, /* ast_xor_assign */ + ir_binop_bit_or, /* ast_or_assign */ + + -1, /* ast_conditional doesn't convert to ir_expression. */ + -1, /* ast_pre_inc doesn't convert to ir_expression. */ + -1, /* ast_pre_dec doesn't convert to ir_expression. */ + -1, /* ast_post_inc doesn't convert to ir_expression. */ + -1, /* ast_post_dec doesn't convert to ir_expression. */ + -1, /* ast_field_selection doesn't conv to ir_expression. */ + -1, /* ast_array_index doesn't convert to ir_expression. */ + -1, /* ast_function_call doesn't conv to ir_expression. */ + -1, /* ast_identifier doesn't convert to ir_expression. */ + -1, /* ast_int_constant doesn't convert to ir_expression. */ + -1, /* ast_uint_constant doesn't conv to ir_expression. */ + -1, /* ast_float_constant doesn't conv to ir_expression. */ + -1, /* ast_bool_constant doesn't conv to ir_expression. */ + -1, /* ast_sequence doesn't convert to ir_expression. */ + }; + struct ir_instruction *result = NULL; + struct ir_instruction *op[2]; + struct simple_node op_list; + const struct glsl_type *type = glsl_error_type; + bool error_emitted = false; + YYLTYPE loc; + + loc = ast->get_location(); + make_empty_list(& op_list); + + switch (expr->oper) { + case ast_assign: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + + error_emitted = ((op[0]->type == glsl_error_type) + || (op[1]->type == glsl_error_type)); + + type = op[0]->type; + if (!error_emitted) { + YYLTYPE loc; + + /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ + loc = expr->subexpressions[0]->get_location(); + if (op[0]->mode != ir_op_dereference) { + _mesa_glsl_error(& loc, state, "invalid lvalue in assignment"); + error_emitted = true; + + type = glsl_error_type; + } else { + const struct ir_dereference *const ref = + (struct ir_dereference *) op[0]; + const struct ir_variable *const var = + (struct ir_variable *) ref->var; + + if ((var != NULL) + && (var->mode == ir_op_var_decl) + && (var->read_only)) { + _mesa_glsl_error(& loc, state, "cannot assign to read-only " + "variable `%s'", var->name); + error_emitted = true; + + type = glsl_error_type; + } + } + } + + /* FINISHME: Check that the LHS and RHS have matching types. */ + /* FINISHME: For GLSL 1.10, check that the types are not arrays. */ + + result = new ir_assignment(op[0], op[1], NULL); + break; + + case ast_plus: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + + error_emitted = (op[0]->type == glsl_error_type); + if (type == glsl_error_type) + op[0]->type = type; + + result = op[0]; + break; + + case ast_neg: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + + type = unary_arithmetic_result_type(op[0]->type); + + error_emitted = (op[0]->type == glsl_error_type); + + result = new ir_expression(operations[expr->oper], type, + op[0], NULL); + break; + + case ast_add: + case ast_sub: + case ast_mul: + case ast_div: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + + type = arithmetic_result_type(op[0]->type, op[1]->type, + (expr->operr == ast_mul), + state); + + result = new ir_expression(operations[expr->oper], type, + op[0], op[1]); + break; + + case ast_mod: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + + error_emitted = ((op[0]->type == glsl_error_type) + || (op[1]->type == glsl_error_type)); + + type = modulus_result_type(op[0]->type, op[1]->type); + + assert(operations[expr->oper] == ir_binop_mod); + + result = new ir_expression(operations[expr->oper], type, + op[0], op[1]); + break; + + case ast_lshift: + case ast_rshift: + /* FINISHME: Implement bit-shift operators. */ + break; + + case ast_less: + case ast_greater: + case ast_lequal: + case ast_gequal: + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + + error_emitted = ((op[0]->type == glsl_error_type) + || (op[1]->type == glsl_error_type)); + + type = relational_result_type(op[0]->type, op[1]->type, state); + + /* The relational operators must either generate an error or result + * in a scalar boolean. See page 57 of the GLSL 1.50 spec. + */ + assert((type == glsl_error_type) + || ((type->base_type == GLSL_TYPE_BOOL) + && is_glsl_type_scalar(type))); + + result = new ir_expression(operations[expr->oper], type, + op[0], op[1]); + break; + + case ast_nequal: + case ast_equal: + /* FINISHME: Implement equality operators. */ + break; + + case ast_bit_and: + case ast_bit_xor: + case ast_bit_or: + case ast_bit_not: + /* FINISHME: Implement bit-wise operators. */ + break; + + case ast_logic_and: + case ast_logic_xor: + case ast_logic_or: + case ast_logic_not: + /* FINISHME: Implement logical operators. */ + break; + + case ast_mul_assign: + case ast_div_assign: + case ast_add_assign: + case ast_sub_assign: { + struct ir_instruction *temp_rhs; + + op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + + error_emitted = ((op[0]->type == glsl_error_type) + || (op[1]->type == glsl_error_type)); + + type = arithmetic_result_type(op[0]->type, op[1]->type, + (expr->oper == ast_mul_assign), + state); + + temp_rhs = new ir_expression(operations[expr->oper], type, + op[0], op[1]); + + /* FINISHME: Check that the LHS is assignable. */ + + /* We still have to test that the LHS and RHS have matching type. For + * example, the following GLSL code should generate a type error: + * + * mat4 m; vec4 v; m *= v; + * + * The type of (m*v) is a vec4, but the type of m is a mat4. + * + * FINISHME: Is multiplication between a matrix and a vector the only + * FINISHME: case that resuls in mismatched types? + */ + /* FINISHME: Check that the LHS and RHS have matching types. */ + + /* GLSL 1.10 does not allow array assignment. However, we don't have to + * explicitly test for this because none of the binary expression + * operators allow array operands either. + */ + + /* FINISHME: This is wrong. The operation should assign to a new + * FINISHME: temporary. This assignment should then be added to the + * FINISHME: instruction list. Another assignment to the real + * FINISHME: destination should be generated. The temporary should then + * FINISHME: be returned as the r-value. + */ + result = new ir_assignment(op[0], temp_rhs, NULL); + break; + } + + case ast_mod_assign: + + case ast_ls_assign: + case ast_rs_assign: + + case ast_and_assign: + case ast_xor_assign: + case ast_or_assign: + + case ast_conditional: + + case ast_pre_inc: + case ast_pre_dec: + + case ast_post_inc: + case ast_post_dec: + break; + + case ast_field_selection: + result = _mesa_ast_field_selection_to_hir(expr, instructions, state); + type = result->type; + break; + + case ast_array_index: + break; + + case ast_function_call: + /* There are three sorts of function calls. + * + * 1. contstructors - The first subexpression is an ast_type_specifier. + * 2. methods - Only the .length() method of array types. + * 3. functions - Calls to regular old functions. + * + * Method calls are actually detected when the ast_field_selection + * expression is handled. + */ + result = _mesa_ast_function_call_to_hir(expr->subexpressions[0], + expr->subexpressions[1], + state); + type = result->type; + break; + + case ast_identifier: { + /* ast_identifier can appear several places in a full abstract syntax + * tree. This particular use must be at location specified in the grammar + * as 'variable_identifier'. + */ + struct ir_variable *var = + _mesa_symbol_table_find_symbol(state->symbols, 0, + expr->primary_expression.identifier); + + result = new ir_dereference(var); + + if (var != NULL) { + type = result->type; + } else { + _mesa_glsl_error(& loc, NULL, "`%s' undeclared", + expr->primary_expression.identifier); + + error_emitted = true; + } + break; + } + + case ast_int_constant: + type = glsl_int_type; + result = new ir_constant(type, & expr->primary_expression); + break; + + case ast_uint_constant: + type = glsl_uint_type; + result = new ir_constant(type, & expr->primary_expression); + break; + + case ast_float_constant: + type = glsl_float_type; + result = new ir_constant(type, & expr->primary_expression); + break; + + case ast_bool_constant: + type = glsl_bool_type; + result = new ir_constant(type, & expr->primary_expression); + break; + + case ast_sequence: { + struct simple_node *ptr; + + /* It should not be possible to generate a sequence in the AST without + * any expressions in it. + */ + assert(!is_empty_list(&expr->expressions)); + + /* The r-value of a sequence is the last expression in the sequence. If + * the other expressions in the sequence do not have side-effects (and + * therefore add instructions to the instruction list), they get dropped + * on the floor. + */ + foreach (ptr, &expr->expressions) + result = _mesa_ast_to_hir(ptr, instructions, state); + + type = result->type; + + /* Any errors should have already been emitted in the loop above. + */ + error_emitted = true; + break; + } + } + + if (is_error_type(type) && !error_emitted) + _mesa_glsl_error(& loc, NULL, "type mismatch"); + + return result; +} + + +struct ir_instruction * +ast_expression_statement_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_expression_statement *stmt = + (struct ast_expression_statement *) ast; + + /* It is possible to have expression statements that don't have an + * expression. This is the solitary semicolon: + * + * for (i = 0; i < 5; i++) + * ; + * + * In this case the expression will be NULL. Test for NULL and don't do + * anything in that case. + */ + if (stmt->expression != NULL) + _mesa_ast_to_hir(stmt->expression, instructions, state); + + /* Statements do not have r-values. + */ + return NULL; +} + + +struct ir_instruction * +ast_compound_statement_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_compound_statement *stmt = + (struct ast_compound_statement *) ast; + struct simple_node *ptr; + + + if (stmt->new_scope) + _mesa_symbol_table_push_scope(state->symbols); + + foreach (ptr, &stmt->statements) + _mesa_ast_to_hir(ptr, instructions, state); + + if (stmt->new_scope) + _mesa_symbol_table_pop_scope(state->symbols); + + /* Compound statements do not have r-values. + */ + return NULL; +} + + +static const struct glsl_type * +type_specifier_to_glsl_type(const struct ast_type_specifier *spec, + const char **name, + struct _mesa_glsl_parse_state *state) +{ + static const char *const type_names[] = { + "void", + "float", + "int", + "uint", + "bool", + "vec2", + "vec3", + "vec4", + "bvec2", + "bvec3", + "bvec4", + "ivec2", + "ivec3", + "ivec4", + "uvec2", + "uvec3", + "uvec4", + "mat2", + "mat2x3", + "mat2x4", + "mat3x2", + "mat3", + "mat3x4", + "mat4x2", + "mat4x3", + "mat4", + "sampler1D", + "sampler2D", + "sampler3D", + "samplerCube", + "sampler1DShadow", + "sampler2DShadow", + "samplerCubeShadow", + "sampler1DArray", + "sampler2DArray", + "sampler1DArrayShadow", + "sampler2DArrayShadow", + "isampler1D", + "isampler2D", + "isampler3D", + "isamplerCube", + "isampler1DArray", + "isampler2DArray", + "usampler1D", + "usampler2D", + "usampler3D", + "usamplerCube", + "usampler1DArray", + "usampler2DArray", + + NULL, /* ast_struct */ + NULL /* ast_type_name */ + }; + struct glsl_type *type; + const char *type_name = NULL; + + if (spec->type_specifier == ast_struct) { + /* FINISHME: Handle annonymous structures. */ + type = NULL; + } else { + type_name = (spec->type_specifier == ast_type_name) + ? spec->type_name : type_names[spec->type_specifier]; + + type = _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); + *name = type_name; + + /* FINISHME: Handle array declarations. Note that this requires complete + * FINSIHME: handling of constant expressions. + */ + } + + return type; +} + + +static void +apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, + struct ir_variable *var, + struct _mesa_glsl_parse_state *state) +{ + if (qual->invariant) + var->invariant = 1; + + /* FINISHME: Mark 'in' variables at global scope as read-only. */ + if (qual->constant || qual->attribute || qual->uniform + || (qual->varying && (state->target == fragment_shader))) + var->read_only = 1; + + if (qual->centroid) + var->centroid = 1; + + if (qual->in && qual->out) + var->mode = ir_var_inout; + else if (qual->attribute || qual->in + || (qual->varying && (state->target == fragment_shader))) + var->mode = ir_var_in; + else if (qual->out) + var->mode = ir_var_out; + else if (qual->uniform) + var->mode = ir_var_uniform; + else + var->mode = ir_var_auto; + + if (qual->flat) + var->interpolation = ir_var_flat; + else if (qual->noperspective) + var->interpolation = ir_var_noperspective; + else + var->interpolation = ir_var_smooth; +} + + +struct ir_instruction * +ast_declarator_list_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_declarator_list *dlist = (struct ast_declarator_list *) ast; + struct simple_node *ptr; + const struct glsl_type *decl_type; + const char *type_name = NULL; + + + /* FINISHME: Handle vertex shader "invariant" declarations that do not + * FINISHME: include a type. These re-declare built-in variables to be + * FINISHME: invariant. + */ + + decl_type = type_specifier_to_glsl_type(dlist->type->specifier, + & type_name, state); + + foreach (ptr, &dlist->declarations) { + struct ast_declaration *const decl = (struct ast_declaration * )ptr; + const struct glsl_type *var_type; + struct ir_variable *var; + + + /* FINISHME: Emit a warning if a variable declaration shadows a + * FINISHME: declaration at a higher scope. + */ + + if (decl_type == NULL) { + YYLTYPE loc; + + loc = ast->get_location(); + if (type_name != NULL) { + _mesa_glsl_error(& loc, state, + "invalid type `%s' in declaration of `%s'", + type_name, decl->identifier); + } else { + _mesa_glsl_error(& loc, state, + "invalid type in declaration of `%s'", + decl->identifier); + } + continue; + } + + if (decl->is_array) { + /* FINISHME: Handle array declarations. Note that this requires + * FINISHME: complete handling of constant expressions. + */ + + /* FINISHME: Reject delcarations of multidimensional arrays. */ + } else { + var_type = decl_type; + } + + var = new ir_variable(var_type, decl->identifier); + + /* FINSIHME: Variables that are attribute, uniform, varying, in, or + * FINISHME: out varibles must be declared either at global scope or + * FINISHME: in a parameter list (in and out only). + */ + + apply_type_qualifier_to_variable(& dlist->type->qualifier, var, state); + + /* Attempt to add the variable to the symbol table. If this fails, it + * means the variable has already been declared at this scope. + */ + if (_mesa_symbol_table_add_symbol(state->symbols, 0, decl->identifier, + var) != 0) { + YYLTYPE loc = ast->get_location(); + + _mesa_glsl_error(& loc, state, "`%s' redeclared", + decl->identifier); + continue; + } + + insert_at_tail(instructions, (struct simple_node *) var); + + /* FINISHME: Process the declaration initializer. */ + } + + /* Variable declarations do not have r-values. + */ + return NULL; +} + + +struct ir_instruction * +ast_parameter_declarator_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_parameter_declarator *decl = + (struct ast_parameter_declarator *) ast; + struct ir_variable *var; + const struct glsl_type *type; + const char *name = NULL; + + + type = type_specifier_to_glsl_type(decl->type->specifier, & name, state); + + if (type == NULL) { + YYLTYPE loc = ast->get_location(); + if (name != NULL) { + _mesa_glsl_error(& loc, state, + "invalid type `%s' in declaration of `%s'", + name, decl->identifier); + } else { + _mesa_glsl_error(& loc, state, + "invalid type in declaration of `%s'", + decl->identifier); + } + + type = glsl_error_type; + } + + var = new ir_variable(type, decl->identifier); + + /* FINISHME: Handle array declarations. Note that this requires + * FINISHME: complete handling of constant expressions. + */ + + apply_type_qualifier_to_variable(& decl->type->qualifier, var, state); + + insert_at_tail(instructions, var); + + /* Parameter declarations do not have r-values. + */ + return NULL; +} + + +static void +ast_function_parameters_to_hir(struct simple_node *ast_parameters, + struct simple_node *ir_parameters, + struct _mesa_glsl_parse_state *state) +{ + struct simple_node *ptr; + + foreach (ptr, ast_parameters) { + _mesa_ast_to_hir(ptr, ir_parameters, state); + } +} + + +static bool +parameter_lists_match(struct simple_node *list_a, struct simple_node *list_b) +{ + struct simple_node *node_a; + struct simple_node *node_b; + + node_b = first_elem(list_b); + foreach (node_a, list_a) { + /* If all of the parameters from the other parameter list have been + * exhausted, the lists have different length and, by definition, + * do not match. + */ + if (at_end(list_b, node_b)) + return false; + + /* If the types of the parameters do not match, the parameters lists + * are different. + */ + /* FINISHME */ + + + node_b = next_elem(node_b); + } + + return true; +} + + +struct ir_instruction * +ast_function_definition_to_hir(const struct ast_node *ast, + struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + const struct ast_function_definition *func = + (struct ast_function_definition *) ast; + struct ir_label *label; + struct simple_node *ptr; + struct simple_node *tmp; + struct ir_function_signature *signature = NULL; + struct ir_function *f = NULL; + struct simple_node parameters; + + + /* Convert the list of function parameters to HIR now so that they can be + * used below to compare this function's signature with previously seen + * signatures for functions with the same name. + */ + make_empty_list(& parameters); + ast_function_parameters_to_hir(& func->prototype->parameters, & parameters, + state); + + + /* Verify that this function's signature either doesn't match a previously + * seen signature for a function with the same name, or, if a match is found, + * that the previously seen signature does not have an associated definition. + */ + f = _mesa_symbol_table_find_symbol(state->symbols, 0, + func->prototype->identifier); + if (f != NULL) { + foreach (ptr, & f->signatures) { + signature = (struct ir_function_signature *) ptr; + + /* Compare the parameter list of the function being defined to the + * existing function. If the parameter lists match, then the return + * type must also match and the existing function must not have a + * definition. + */ + if (parameter_lists_match(& parameters, & signature->parameters)) { + /* FINISHME: Compare return types. */ + + if (signature->definition != NULL) { + YYLTYPE loc = ast->get_location(); + + _mesa_glsl_error(& loc, state, "function `%s' redefined", + func->prototype->identifier); + signature = NULL; + break; + } + } + + signature = NULL; + } + + } else { + f = new ir_function(); + f->name = func->prototype->identifier; + + _mesa_symbol_table_add_symbol(state->symbols, 0, f->name, f); + } + + + /* Finish storing the information about this new function in its signature. + */ + if (signature == NULL) { + signature = new ir_function_signature(); + insert_at_tail(& f->signatures, (struct simple_node *) signature); + } else { + /* Destroy all of the previous parameter information. The previous + * parameter information comes from the function prototype, and it can + * either include invalid parameter names or may not have names at all. + */ + foreach_s(ptr, tmp, & signature->parameters) { + assert(((struct ir_instruction *)ptr)->mode == ir_op_var_decl); + + remove_from_list(ptr); + free(ptr); + } + } + + + ast_function_parameters_to_hir(& func->prototype->parameters, + & signature->parameters, + state); + /* FINISHME: Set signature->return_type */ + + label = new ir_label(func->prototype->identifier); + if (signature->definition == NULL) { + signature->definition = label; + } + insert_at_tail(instructions, label); + + /* Add the function parameters to the symbol table. During this step the + * parameter declarations are also moved from the temporary "parameters" list + * to the instruction list. There are other more efficient ways to do this, + * but they involve ugly linked-list gymnastics. + */ + _mesa_symbol_table_push_scope(state->symbols); + foreach_s(ptr, tmp, & parameters) { + struct ir_variable *const var = (struct ir_variable *) ptr; + + assert(var->mode == ir_op_var_decl); + + remove_from_list(ptr); + insert_at_tail(instructions, ptr); + + _mesa_symbol_table_add_symbol(state->symbols, 0, var->name, var); + } + + /* Convert the body of the function to HIR, and append the resulting + * instructions to the list that currently consists of the function label + * and the function parameters. + */ + _mesa_ast_to_hir(func->body, instructions, state); + + _mesa_symbol_table_pop_scope(state->symbols); + + + /* Function definitions do not have r-values. + */ + return NULL; +} diff --git a/glsl_parser_extras.cc b/glsl_parser_extras.cc deleted file mode 100644 index 36a6ca8264b..00000000000 --- a/glsl_parser_extras.cc +++ /dev/null @@ -1,771 +0,0 @@ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_parser.tab.h" -#include "symbol_table.h" - -void -_mesa_glsl_error(YYLTYPE *locp, void *state, const char *fmt, ...) -{ - char buf[1024]; - int len; - va_list ap; - - (void) state; - len = snprintf(buf, sizeof(buf), "%u:%u(%u): error: ", - locp->source, locp->first_line, locp->first_column); - - va_start(ap, fmt); - vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); - va_end(ap); - - printf("%s\n", buf); -} - - -ast_node::~ast_node() -{ - /* empty */ -} - - -void -_mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q) -{ - if (q->constant) - printf("const "); - - if (q->invariant) - printf("invariant "); - - if (q->attribute) - printf("attribute "); - - if (q->varying) - printf("varying "); - - if (q->in && q->out) - printf("inout "); - else { - if (q->in) - printf("in "); - - if (q->out) - printf("out "); - } - - if (q->centroid) - printf("centroid "); - if (q->uniform) - printf("uniform "); - if (q->smooth) - printf("smooth "); - if (q->flat) - printf("flat "); - if (q->noperspective) - printf("noperspective "); -} - - -void -ast_node::print(void) const -{ - printf("node_%d ", type); -} - - -ast_node::ast_node(void) -{ - make_empty_list(this); -} - -void -ast_type_specifier::print(void) const -{ - switch (type_specifier) { - case ast_void: printf("void "); break; - case ast_float: printf("float "); break; - case ast_int: printf("int "); break; - case ast_uint: printf("uint "); break; - case ast_bool: printf("bool "); break; - case ast_vec2: printf("vec2 "); break; - case ast_vec3: printf("vec3 "); break; - case ast_vec4: printf("vec4 "); break; - case ast_bvec2: printf("bvec2 "); break; - case ast_bvec3: printf("bvec3 "); break; - case ast_bvec4: printf("bvec4 "); break; - case ast_ivec2: printf("ivec2 "); break; - case ast_ivec3: printf("ivec3 "); break; - case ast_ivec4: printf("ivec4 "); break; - case ast_uvec2: printf("uvec2 "); break; - case ast_uvec3: printf("uvec3 "); break; - case ast_uvec4: printf("uvec4 "); break; - case ast_mat2: printf("mat2 "); break; - case ast_mat2x3: printf("mat2x3 "); break; - case ast_mat2x4: printf("mat2x4 "); break; - case ast_mat3x2: printf("mat3x2 "); break; - case ast_mat3: printf("mat3 "); break; - case ast_mat3x4: printf("mat3x4 "); break; - case ast_mat4x2: printf("mat4x2 "); break; - case ast_mat4x3: printf("mat4x3 "); break; - case ast_mat4: printf("mat4 "); break; - case ast_sampler1d: printf("sampler1d "); break; - case ast_sampler2d: printf("sampler2d "); break; - case ast_sampler3d: printf("sampler3d "); break; - case ast_samplercube: printf("samplercube "); break; - case ast_sampler1dshadow: printf("sampler1dshadow "); break; - case ast_sampler2dshadow: printf("sampler2dshadow "); break; - case ast_samplercubeshadow: printf("samplercubeshadow "); break; - case ast_sampler1darray: printf("sampler1darray "); break; - case ast_sampler2darray: printf("sampler2darray "); break; - case ast_sampler1darrayshadow: printf("sampler1darrayshadow "); break; - case ast_sampler2darrayshadow: printf("sampler2darrayshadow "); break; - case ast_isampler1d: printf("isampler1d "); break; - case ast_isampler2d: printf("isampler2d "); break; - case ast_isampler3d: printf("isampler3d "); break; - case ast_isamplercube: printf("isamplercube "); break; - case ast_isampler1darray: printf("isampler1darray "); break; - case ast_isampler2darray: printf("isampler2darray "); break; - case ast_usampler1d: printf("usampler1d "); break; - case ast_usampler2d: printf("usampler2d "); break; - case ast_usampler3d: printf("usampler3d "); break; - case ast_usamplercube: printf("usamplercube "); break; - case ast_usampler1darray: printf("usampler1darray "); break; - case ast_usampler2darray: printf("usampler2darray "); break; - - case ast_struct: - structure->print(); - break; - - case ast_type_name: printf("%s ", type_name); break; - } - - if (is_array) { - printf("[ "); - - if (array_size) { - array_size->print(); - } - - printf("] "); - } -} - -static void -ast_opt_array_size_print(bool is_array, const ast_expression *array_size) -{ - if (is_array) { - printf("[ "); - - if (array_size) - array_size->print(); - - printf("] "); - } -} - - -ast_type_specifier::ast_type_specifier(int specifier) -{ - type_specifier = ast_types(specifier); -} - - -void -ast_compound_statement::print(void) const -{ - const struct simple_node *ptr; - - printf("{\n"); - - foreach(ptr, & statements) { - _mesa_ast_print(ptr); - } - - printf("}\n"); -} - - -ast_compound_statement::ast_compound_statement(int new_scope, - ast_node *statements) -{ - this->new_scope = new_scope; - make_empty_list(& this->statements); - - if (statements != NULL) { - /* This seems odd, but it works. The simple_list is, - * basically, a circular list. insert_at_tail adds - * the specified node to the list before the current - * head. - */ - insert_at_tail((struct simple_node *) statements, - & this->statements); - } -} - - -void -ast_expression::print(void) const -{ - static const char *const operators[] = { - "=", - "+", - "-", - "+", - "-", - "*", - "/", - "%", - "<<", - ">>", - "<", - ">", - "<=", - ">=", - "==", - "!=", - "&", - "^", - "|", - "~", - "&&", - "^^", - "!", - - "*=", - "/=", - "%=", - "+=", - "-=", - "<<=", - ">>=", - "&=", - "^=", - "|=", - - "?:", - "++", - "--", - "++", - "--", - ".", - }; - - - switch (oper) { - case ast_assign: - case ast_add: - case ast_sub: - case ast_mul: - case ast_div: - case ast_mod: - case ast_lshift: - case ast_rshift: - case ast_less: - case ast_greater: - case ast_lequal: - case ast_gequal: - case ast_equal: - case ast_nequal: - case ast_bit_and: - case ast_bit_xor: - case ast_bit_or: - case ast_logic_and: - case ast_logic_xor: - case ast_logic_or: - case ast_mul_assign: - case ast_div_assign: - case ast_mod_assign: - case ast_add_assign: - case ast_sub_assign: - case ast_ls_assign: - case ast_rs_assign: - case ast_and_assign: - case ast_xor_assign: - case ast_or_assign: - subexpressions[0]->print(); - printf("%s ", operators[oper]); - subexpressions[1]->print(); - break; - - case ast_field_selection: - subexpressions[0]->print(); - printf(". %s ", primary_expression.identifier); - break; - - case ast_plus: - case ast_neg: - case ast_bit_not: - case ast_logic_not: - case ast_pre_inc: - case ast_pre_dec: - printf("%s ", operators[oper]); - subexpressions[0]->print(); - break; - - case ast_post_inc: - case ast_post_dec: - subexpressions[0]->print(); - printf("%s ", operators[oper]); - break; - - case ast_conditional: - subexpressions[0]->print(); - printf("? "); - subexpressions[1]->print(); - printf(": "); - subexpressions[1]->print(); - break; - - case ast_array_index: - subexpressions[0]->print(); - printf("[ "); - subexpressions[1]->print(); - printf("] "); - break; - - case ast_function_call: { - ast_expression *parameters = subexpressions[1]; - - subexpressions[0]->print(); - printf("( "); - - if (parameters != NULL) { - struct simple_node *ptr; - - parameters->print(); - foreach (ptr, (struct simple_node *) parameters) { - printf(", "); - _mesa_ast_print(ptr); - } - } - - printf(") "); - break; - } - - case ast_identifier: - printf("%s ", primary_expression.identifier); - break; - - case ast_int_constant: - printf("%d ", primary_expression.int_constant); - break; - - case ast_uint_constant: - printf("%u ", primary_expression.uint_constant); - break; - - case ast_float_constant: - printf("%f ", primary_expression.float_constant); - break; - - case ast_bool_constant: - printf("%s ", - primary_expression.bool_constant - ? "true" : "false"); - break; - - case ast_sequence: { - struct simple_node *ptr; - struct simple_node *const head = first_elem(& expressions); - - printf("( "); - foreach (ptr, & expressions) { - if (ptr != head) - printf(", "); - - _mesa_ast_print(ptr); - } - printf(") "); - break; - } - } -} - -ast_expression::ast_expression(int oper, - ast_expression *ex0, - ast_expression *ex1, - ast_expression *ex2) -{ - this->oper = ast_operators(oper); - this->subexpressions[0] = ex0; - this->subexpressions[1] = ex1; - this->subexpressions[2] = ex2; - make_empty_list(& expressions); -} - - -void -ast_expression_statement::print(void) const -{ - if (expression) - expression->print(); - - printf("; "); -} - - -ast_expression_statement::ast_expression_statement(ast_expression *ex) : - expression(ex) -{ - /* empty */ -} - - -void -ast_function::print(void) const -{ - struct simple_node *ptr; - - return_type->print(); - printf(" %s (", identifier); - - foreach(ptr, & parameters) { - _mesa_ast_print(ptr); - } - - printf(")"); -} - - -ast_function::ast_function(void) -{ - make_empty_list(& parameters); -} - - -void -ast_fully_specified_type::print(void) const -{ - _mesa_ast_type_qualifier_print(& qualifier); - specifier->print(); -} - - -void -ast_parameter_declarator::print(void) const -{ - type->print(); - if (identifier) - printf("%s ", identifier); - ast_opt_array_size_print(is_array, array_size); -} - - -void -ast_function_definition::print(void) const -{ - prototype->print(); - body->print(); -} - - -void -ast_declaration::print(void) const -{ - printf("%s ", identifier); - ast_opt_array_size_print(is_array, array_size); - - if (initializer) { - printf("= "); - initializer->print(); - } -} - - -ast_declaration::ast_declaration(char *identifier, int is_array, - ast_expression *array_size, - ast_expression *initializer) -{ - this->identifier = identifier; - this->is_array = is_array; - this->array_size = array_size; - this->initializer = initializer; -} - - -void -ast_declarator_list::print(void) const -{ - struct simple_node *head; - struct simple_node *ptr; - - assert(type || invariant); - - if (type) - type->print(); - else - printf("invariant "); - - head = first_elem(& declarations); - foreach (ptr, & declarations) { - if (ptr != head) - printf(", "); - - _mesa_ast_print(ptr); - } - - printf("; "); -} - - -ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type) -{ - this->type = type; - make_empty_list(& this->declarations); -} - -void -ast_jump_statement::print(void) const -{ - switch (mode) { - case ast_continue: - printf("continue; "); - break; - case ast_break: - printf("break; "); - break; - case ast_return: - printf("return "); - if (opt_return_value) - opt_return_value->print(); - - printf("; "); - break; - case ast_discard: - printf("discard; "); - break; - } -} - - -ast_jump_statement::ast_jump_statement(int mode, ast_expression *return_value) -{ - this->mode = ast_jump_modes(mode); - - if (mode == ast_return) - opt_return_value = return_value; -} - - -void -ast_selection_statement::print(void) const -{ - printf("if ( "); - condition->print(); - printf(") "); - - then_statement->print(); - - if (else_statement) { - printf("else "); - else_statement->print(); - } - -} - - -ast_selection_statement::ast_selection_statement(ast_expression *condition, - ast_node *then_statement, - ast_node *else_statement) -{ - this->condition = condition; - this->then_statement = then_statement; - this->else_statement = else_statement; -} - - -void -ast_iteration_statement::print(void) const -{ - switch (mode) { - case ast_for: - printf("for( "); - if (init_statement) - init_statement->print(); - printf("; "); - - if (condition) - condition->print(); - printf("; "); - - if (rest_expression) - rest_expression->print(); - printf(") "); - - body->print(); - break; - - case ast_while: - printf("while ( "); - if (condition) - condition->print(); - printf(") "); - body->print(); - break; - - case ast_do_while: - printf("do "); - body->print(); - printf("while ( "); - if (condition) - condition->print(); - printf("); "); - break; - } -} - - -ast_iteration_statement::ast_iteration_statement(int mode, - ast_node *init, - ast_node *condition, - ast_expression *rest_expression, - ast_node *body) -{ - this->mode = ast_iteration_modes(mode); - this->init_statement = init; - this->condition = condition; - this->rest_expression = rest_expression; - this->body = body; -} - - -void -ast_struct_specifier::print(void) const -{ - struct simple_node *ptr; - - printf("struct %s { ", name); - foreach (ptr, & declarations) { - _mesa_ast_print(ptr); - } - printf("} "); -} - - -ast_struct_specifier::ast_struct_specifier(char *identifier, - ast_node *declarator_list) -{ - name = identifier; - - /* This seems odd, but it works. The simple_list is, - * basically, a circular list. insert_at_tail adds - * the specified node to the list before the current - * head. - */ - insert_at_tail((struct simple_node *) declarator_list, - & declarations); -} - - -static char * -load_text_file(const char *file_name, size_t *size) -{ - char *text = NULL; - struct stat st; - ssize_t total_read = 0; - int fd = open(file_name, O_RDONLY); - - *size = 0; - if (fd < 0) { - return NULL; - } - - if (fstat(fd, & st) == 0) { - text = (char *) malloc(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'; - *size = total_read; - } - } - - close(fd); - - return text; -} - - -int -main(int argc, char **argv) -{ - struct _mesa_glsl_parse_state state; - char *shader; - size_t shader_len; - struct simple_node *ptr; - struct simple_node instructions; - - (void) argc; - shader = load_text_file(argv[1], & shader_len); - - state.scanner = NULL; - make_empty_list(& state.translation_unit); - state.symbols = _mesa_symbol_table_ctor(); - - _mesa_glsl_lexer_ctor(& state, shader, shader_len); - _mesa_glsl_parse(& state); - _mesa_glsl_lexer_dtor(& state); - - foreach (ptr, & state.translation_unit) { - _mesa_ast_print(ptr); - } - -#if 0 - make_empty_list(& instructions); - foreach (ptr, & state.translation_unit) { - _mesa_ast_to_hir(ptr, &instructions, &state); - } -#endif - - _mesa_symbol_table_dtor(state.symbols); - - return 0; -} diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp new file mode 100644 index 00000000000..36a6ca8264b --- /dev/null +++ b/glsl_parser_extras.cpp @@ -0,0 +1,771 @@ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.tab.h" +#include "symbol_table.h" + +void +_mesa_glsl_error(YYLTYPE *locp, void *state, const char *fmt, ...) +{ + char buf[1024]; + int len; + va_list ap; + + (void) state; + len = snprintf(buf, sizeof(buf), "%u:%u(%u): error: ", + locp->source, locp->first_line, locp->first_column); + + va_start(ap, fmt); + vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); + va_end(ap); + + printf("%s\n", buf); +} + + +ast_node::~ast_node() +{ + /* empty */ +} + + +void +_mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q) +{ + if (q->constant) + printf("const "); + + if (q->invariant) + printf("invariant "); + + if (q->attribute) + printf("attribute "); + + if (q->varying) + printf("varying "); + + if (q->in && q->out) + printf("inout "); + else { + if (q->in) + printf("in "); + + if (q->out) + printf("out "); + } + + if (q->centroid) + printf("centroid "); + if (q->uniform) + printf("uniform "); + if (q->smooth) + printf("smooth "); + if (q->flat) + printf("flat "); + if (q->noperspective) + printf("noperspective "); +} + + +void +ast_node::print(void) const +{ + printf("node_%d ", type); +} + + +ast_node::ast_node(void) +{ + make_empty_list(this); +} + +void +ast_type_specifier::print(void) const +{ + switch (type_specifier) { + case ast_void: printf("void "); break; + case ast_float: printf("float "); break; + case ast_int: printf("int "); break; + case ast_uint: printf("uint "); break; + case ast_bool: printf("bool "); break; + case ast_vec2: printf("vec2 "); break; + case ast_vec3: printf("vec3 "); break; + case ast_vec4: printf("vec4 "); break; + case ast_bvec2: printf("bvec2 "); break; + case ast_bvec3: printf("bvec3 "); break; + case ast_bvec4: printf("bvec4 "); break; + case ast_ivec2: printf("ivec2 "); break; + case ast_ivec3: printf("ivec3 "); break; + case ast_ivec4: printf("ivec4 "); break; + case ast_uvec2: printf("uvec2 "); break; + case ast_uvec3: printf("uvec3 "); break; + case ast_uvec4: printf("uvec4 "); break; + case ast_mat2: printf("mat2 "); break; + case ast_mat2x3: printf("mat2x3 "); break; + case ast_mat2x4: printf("mat2x4 "); break; + case ast_mat3x2: printf("mat3x2 "); break; + case ast_mat3: printf("mat3 "); break; + case ast_mat3x4: printf("mat3x4 "); break; + case ast_mat4x2: printf("mat4x2 "); break; + case ast_mat4x3: printf("mat4x3 "); break; + case ast_mat4: printf("mat4 "); break; + case ast_sampler1d: printf("sampler1d "); break; + case ast_sampler2d: printf("sampler2d "); break; + case ast_sampler3d: printf("sampler3d "); break; + case ast_samplercube: printf("samplercube "); break; + case ast_sampler1dshadow: printf("sampler1dshadow "); break; + case ast_sampler2dshadow: printf("sampler2dshadow "); break; + case ast_samplercubeshadow: printf("samplercubeshadow "); break; + case ast_sampler1darray: printf("sampler1darray "); break; + case ast_sampler2darray: printf("sampler2darray "); break; + case ast_sampler1darrayshadow: printf("sampler1darrayshadow "); break; + case ast_sampler2darrayshadow: printf("sampler2darrayshadow "); break; + case ast_isampler1d: printf("isampler1d "); break; + case ast_isampler2d: printf("isampler2d "); break; + case ast_isampler3d: printf("isampler3d "); break; + case ast_isamplercube: printf("isamplercube "); break; + case ast_isampler1darray: printf("isampler1darray "); break; + case ast_isampler2darray: printf("isampler2darray "); break; + case ast_usampler1d: printf("usampler1d "); break; + case ast_usampler2d: printf("usampler2d "); break; + case ast_usampler3d: printf("usampler3d "); break; + case ast_usamplercube: printf("usamplercube "); break; + case ast_usampler1darray: printf("usampler1darray "); break; + case ast_usampler2darray: printf("usampler2darray "); break; + + case ast_struct: + structure->print(); + break; + + case ast_type_name: printf("%s ", type_name); break; + } + + if (is_array) { + printf("[ "); + + if (array_size) { + array_size->print(); + } + + printf("] "); + } +} + +static void +ast_opt_array_size_print(bool is_array, const ast_expression *array_size) +{ + if (is_array) { + printf("[ "); + + if (array_size) + array_size->print(); + + printf("] "); + } +} + + +ast_type_specifier::ast_type_specifier(int specifier) +{ + type_specifier = ast_types(specifier); +} + + +void +ast_compound_statement::print(void) const +{ + const struct simple_node *ptr; + + printf("{\n"); + + foreach(ptr, & statements) { + _mesa_ast_print(ptr); + } + + printf("}\n"); +} + + +ast_compound_statement::ast_compound_statement(int new_scope, + ast_node *statements) +{ + this->new_scope = new_scope; + make_empty_list(& this->statements); + + if (statements != NULL) { + /* This seems odd, but it works. The simple_list is, + * basically, a circular list. insert_at_tail adds + * the specified node to the list before the current + * head. + */ + insert_at_tail((struct simple_node *) statements, + & this->statements); + } +} + + +void +ast_expression::print(void) const +{ + static const char *const operators[] = { + "=", + "+", + "-", + "+", + "-", + "*", + "/", + "%", + "<<", + ">>", + "<", + ">", + "<=", + ">=", + "==", + "!=", + "&", + "^", + "|", + "~", + "&&", + "^^", + "!", + + "*=", + "/=", + "%=", + "+=", + "-=", + "<<=", + ">>=", + "&=", + "^=", + "|=", + + "?:", + "++", + "--", + "++", + "--", + ".", + }; + + + switch (oper) { + case ast_assign: + case ast_add: + case ast_sub: + case ast_mul: + case ast_div: + case ast_mod: + case ast_lshift: + case ast_rshift: + case ast_less: + case ast_greater: + case ast_lequal: + case ast_gequal: + case ast_equal: + case ast_nequal: + case ast_bit_and: + case ast_bit_xor: + case ast_bit_or: + case ast_logic_and: + case ast_logic_xor: + case ast_logic_or: + case ast_mul_assign: + case ast_div_assign: + case ast_mod_assign: + case ast_add_assign: + case ast_sub_assign: + case ast_ls_assign: + case ast_rs_assign: + case ast_and_assign: + case ast_xor_assign: + case ast_or_assign: + subexpressions[0]->print(); + printf("%s ", operators[oper]); + subexpressions[1]->print(); + break; + + case ast_field_selection: + subexpressions[0]->print(); + printf(". %s ", primary_expression.identifier); + break; + + case ast_plus: + case ast_neg: + case ast_bit_not: + case ast_logic_not: + case ast_pre_inc: + case ast_pre_dec: + printf("%s ", operators[oper]); + subexpressions[0]->print(); + break; + + case ast_post_inc: + case ast_post_dec: + subexpressions[0]->print(); + printf("%s ", operators[oper]); + break; + + case ast_conditional: + subexpressions[0]->print(); + printf("? "); + subexpressions[1]->print(); + printf(": "); + subexpressions[1]->print(); + break; + + case ast_array_index: + subexpressions[0]->print(); + printf("[ "); + subexpressions[1]->print(); + printf("] "); + break; + + case ast_function_call: { + ast_expression *parameters = subexpressions[1]; + + subexpressions[0]->print(); + printf("( "); + + if (parameters != NULL) { + struct simple_node *ptr; + + parameters->print(); + foreach (ptr, (struct simple_node *) parameters) { + printf(", "); + _mesa_ast_print(ptr); + } + } + + printf(") "); + break; + } + + case ast_identifier: + printf("%s ", primary_expression.identifier); + break; + + case ast_int_constant: + printf("%d ", primary_expression.int_constant); + break; + + case ast_uint_constant: + printf("%u ", primary_expression.uint_constant); + break; + + case ast_float_constant: + printf("%f ", primary_expression.float_constant); + break; + + case ast_bool_constant: + printf("%s ", + primary_expression.bool_constant + ? "true" : "false"); + break; + + case ast_sequence: { + struct simple_node *ptr; + struct simple_node *const head = first_elem(& expressions); + + printf("( "); + foreach (ptr, & expressions) { + if (ptr != head) + printf(", "); + + _mesa_ast_print(ptr); + } + printf(") "); + break; + } + } +} + +ast_expression::ast_expression(int oper, + ast_expression *ex0, + ast_expression *ex1, + ast_expression *ex2) +{ + this->oper = ast_operators(oper); + this->subexpressions[0] = ex0; + this->subexpressions[1] = ex1; + this->subexpressions[2] = ex2; + make_empty_list(& expressions); +} + + +void +ast_expression_statement::print(void) const +{ + if (expression) + expression->print(); + + printf("; "); +} + + +ast_expression_statement::ast_expression_statement(ast_expression *ex) : + expression(ex) +{ + /* empty */ +} + + +void +ast_function::print(void) const +{ + struct simple_node *ptr; + + return_type->print(); + printf(" %s (", identifier); + + foreach(ptr, & parameters) { + _mesa_ast_print(ptr); + } + + printf(")"); +} + + +ast_function::ast_function(void) +{ + make_empty_list(& parameters); +} + + +void +ast_fully_specified_type::print(void) const +{ + _mesa_ast_type_qualifier_print(& qualifier); + specifier->print(); +} + + +void +ast_parameter_declarator::print(void) const +{ + type->print(); + if (identifier) + printf("%s ", identifier); + ast_opt_array_size_print(is_array, array_size); +} + + +void +ast_function_definition::print(void) const +{ + prototype->print(); + body->print(); +} + + +void +ast_declaration::print(void) const +{ + printf("%s ", identifier); + ast_opt_array_size_print(is_array, array_size); + + if (initializer) { + printf("= "); + initializer->print(); + } +} + + +ast_declaration::ast_declaration(char *identifier, int is_array, + ast_expression *array_size, + ast_expression *initializer) +{ + this->identifier = identifier; + this->is_array = is_array; + this->array_size = array_size; + this->initializer = initializer; +} + + +void +ast_declarator_list::print(void) const +{ + struct simple_node *head; + struct simple_node *ptr; + + assert(type || invariant); + + if (type) + type->print(); + else + printf("invariant "); + + head = first_elem(& declarations); + foreach (ptr, & declarations) { + if (ptr != head) + printf(", "); + + _mesa_ast_print(ptr); + } + + printf("; "); +} + + +ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type) +{ + this->type = type; + make_empty_list(& this->declarations); +} + +void +ast_jump_statement::print(void) const +{ + switch (mode) { + case ast_continue: + printf("continue; "); + break; + case ast_break: + printf("break; "); + break; + case ast_return: + printf("return "); + if (opt_return_value) + opt_return_value->print(); + + printf("; "); + break; + case ast_discard: + printf("discard; "); + break; + } +} + + +ast_jump_statement::ast_jump_statement(int mode, ast_expression *return_value) +{ + this->mode = ast_jump_modes(mode); + + if (mode == ast_return) + opt_return_value = return_value; +} + + +void +ast_selection_statement::print(void) const +{ + printf("if ( "); + condition->print(); + printf(") "); + + then_statement->print(); + + if (else_statement) { + printf("else "); + else_statement->print(); + } + +} + + +ast_selection_statement::ast_selection_statement(ast_expression *condition, + ast_node *then_statement, + ast_node *else_statement) +{ + this->condition = condition; + this->then_statement = then_statement; + this->else_statement = else_statement; +} + + +void +ast_iteration_statement::print(void) const +{ + switch (mode) { + case ast_for: + printf("for( "); + if (init_statement) + init_statement->print(); + printf("; "); + + if (condition) + condition->print(); + printf("; "); + + if (rest_expression) + rest_expression->print(); + printf(") "); + + body->print(); + break; + + case ast_while: + printf("while ( "); + if (condition) + condition->print(); + printf(") "); + body->print(); + break; + + case ast_do_while: + printf("do "); + body->print(); + printf("while ( "); + if (condition) + condition->print(); + printf("); "); + break; + } +} + + +ast_iteration_statement::ast_iteration_statement(int mode, + ast_node *init, + ast_node *condition, + ast_expression *rest_expression, + ast_node *body) +{ + this->mode = ast_iteration_modes(mode); + this->init_statement = init; + this->condition = condition; + this->rest_expression = rest_expression; + this->body = body; +} + + +void +ast_struct_specifier::print(void) const +{ + struct simple_node *ptr; + + printf("struct %s { ", name); + foreach (ptr, & declarations) { + _mesa_ast_print(ptr); + } + printf("} "); +} + + +ast_struct_specifier::ast_struct_specifier(char *identifier, + ast_node *declarator_list) +{ + name = identifier; + + /* This seems odd, but it works. The simple_list is, + * basically, a circular list. insert_at_tail adds + * the specified node to the list before the current + * head. + */ + insert_at_tail((struct simple_node *) declarator_list, + & declarations); +} + + +static char * +load_text_file(const char *file_name, size_t *size) +{ + char *text = NULL; + struct stat st; + ssize_t total_read = 0; + int fd = open(file_name, O_RDONLY); + + *size = 0; + if (fd < 0) { + return NULL; + } + + if (fstat(fd, & st) == 0) { + text = (char *) malloc(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'; + *size = total_read; + } + } + + close(fd); + + return text; +} + + +int +main(int argc, char **argv) +{ + struct _mesa_glsl_parse_state state; + char *shader; + size_t shader_len; + struct simple_node *ptr; + struct simple_node instructions; + + (void) argc; + shader = load_text_file(argv[1], & shader_len); + + state.scanner = NULL; + make_empty_list(& state.translation_unit); + state.symbols = _mesa_symbol_table_ctor(); + + _mesa_glsl_lexer_ctor(& state, shader, shader_len); + _mesa_glsl_parse(& state); + _mesa_glsl_lexer_dtor(& state); + + foreach (ptr, & state.translation_unit) { + _mesa_ast_print(ptr); + } + +#if 0 + make_empty_list(& instructions); + foreach (ptr, & state.translation_unit) { + _mesa_ast_to_hir(ptr, &instructions, &state); + } +#endif + + _mesa_symbol_table_dtor(state.symbols); + + return 0; +} diff --git a/hir_field_selection.cc b/hir_field_selection.cc deleted file mode 100644 index 295cbaf8949..00000000000 --- a/hir_field_selection.cc +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include "main/imports.h" -#include "symbol_table.h" -#include "glsl_parser_extras.h" -#include "ast.h" -#include "glsl_types.h" -#include "ir.h" - -#define X 1 -#define R 5 -#define S 9 -#define I 13 - -static bool -generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, - unsigned vector_length) -{ - /* For each possible swizzle character, this table encodes the value in - * \c idx_map that represents the 0th element of the vector. For invalid - * swizzle characters (e.g., 'k'), a special value is used that will allow - * detection of errors. - */ - unsigned char base_idx[26] = { - /* a b c d e f g h i j k l m */ - R, R, I, I, I, I, R, I, I, I, I, I, I, - /* n o p q r s t u v w x y z */ - I, I, S, S, R, S, S, I, I, X, X, X, X - }; - - /* Each valid swizzle character has an entry in the previous table. This - * table encodes the base index encoded in the previous table plus the actual - * index of the swizzle character. When processing swizzles, the first - * character in the string is indexed in the previous table. Each character - * in the string is indexed in this table, and the value found there has the - * value form the first table subtracted. The result must be on the range - * [0,3]. - * - * For example, the string "wzyx" will get X from the first table. Each of - * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After - * subtraction, the swizzle values are { 3, 2, 1, 0 }. - * - * The string "wzrg" will get X from the first table. Each of the characters - * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the - * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range - * [0,3], the error is detected. - */ - unsigned char idx_map[26] = { - /* a b c d e f g h i j k l m */ - R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, - /* n o p q r s t u v w x y z */ - 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2 - }; - - int swiz_idx[4] = { 0, 0, 0, 0 }; - unsigned base; - unsigned dup_mask = 0; - unsigned seen_mask = 0; - unsigned i; - - - /* Validate the first character in the swizzle string and look up the base - * index value as described above. - */ - if ((str[0] < 'a') || (str[0] > 'z')) - return FALSE; - - base = base_idx[str[0] - 'a']; - - - for (i = 0; (i < 4) && (str[i] != '\0'); i++) { - unsigned bit; - - /* Validate the next character, and, as described above, convert it to a - * swizzle index. - */ - if ((str[i] < 'a') || (str[i] > 'z')) - return FALSE; - - swiz_idx[i] = idx_map[str[0] - 'a'] - base; - if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) - return FALSE; - - - /* Track a bit-mask of the swizzle index values that have been seen. If - * a value is seen more than once, set the "duplicate" flag. - */ - bit = (1U << swiz_idx[i]); - dup_mask |= seen_mask & bit; - seen_mask |= bit; - } - - if (str[i] != '\0') - return FALSE; - - swiz->x = swiz_idx[0]; - swiz->y = swiz_idx[1]; - swiz->z = swiz_idx[2]; - swiz->w = swiz_idx[3]; - swiz->num_components = i; - swiz->has_duplicates = (dup_mask != 0); - - return TRUE; -} - - -struct ir_instruction * -_mesa_ast_field_selection_to_hir(const ast_expression *expr, - simple_node *instructions, - struct _mesa_glsl_parse_state *state) -{ - ir_instruction *op; - ir_dereference *deref; - YYLTYPE loc; - - - op = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - deref = new ir_dereference(op); - - /* Initially assume that the resulting type of the field selection is an - * error. This make the error paths below a bit easier to follow. - */ - deref->type = glsl_error_type; - - /* If processing the thing being dereferenced generated an error, bail out - * now. Doing so prevents spurious error messages from being logged below. - */ - if (is_error_type(op->type)) - return (struct ir_instruction *) deref; - - /* There are two kinds of field selection. There is the selection of a - * specific field from a structure, and there is the selection of a - * swizzle / mask from a vector. Which is which is determined entirely - * by the base type of the thing to which the field selection operator is - * being applied. - */ - _mesa_ast_get_location(expr, & loc); - if (is_glsl_type_vector(op->type)) { - if (generate_swizzle(expr->primary_expression.identifier, - & deref->selector.swizzle, - op->type->vector_elements)) { - /* Based on the number of elements in the swizzle and the base type - * (i.e., float, int, unsigned, or bool) of the vector being swizzled, - * generate the type of the resulting value. - */ - deref->type = - _mesa_glsl_get_vector_type(op->type->base_type, - deref->selector.swizzle.num_components); - } else { - /* FINISHME: Logging of error messages should be moved into - * FINISHME: generate_swizzle. This allows the generation of more - * FINISHME: specific error messages. - */ - _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'", - expr->primary_expression.identifier); - } - } else if (op->type->base_type == GLSL_TYPE_STRUCT) { - /* FINISHME: Handle field selection from structures. */ - } else { - _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " - "non-structure / non-vector.", - expr->primary_expression.identifier); - } - - return (struct ir_instruction *) deref; -} diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp new file mode 100644 index 00000000000..295cbaf8949 --- /dev/null +++ b/hir_field_selection.cpp @@ -0,0 +1,187 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "main/imports.h" +#include "symbol_table.h" +#include "glsl_parser_extras.h" +#include "ast.h" +#include "glsl_types.h" +#include "ir.h" + +#define X 1 +#define R 5 +#define S 9 +#define I 13 + +static bool +generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, + unsigned vector_length) +{ + /* For each possible swizzle character, this table encodes the value in + * \c idx_map that represents the 0th element of the vector. For invalid + * swizzle characters (e.g., 'k'), a special value is used that will allow + * detection of errors. + */ + unsigned char base_idx[26] = { + /* a b c d e f g h i j k l m */ + R, R, I, I, I, I, R, I, I, I, I, I, I, + /* n o p q r s t u v w x y z */ + I, I, S, S, R, S, S, I, I, X, X, X, X + }; + + /* Each valid swizzle character has an entry in the previous table. This + * table encodes the base index encoded in the previous table plus the actual + * index of the swizzle character. When processing swizzles, the first + * character in the string is indexed in the previous table. Each character + * in the string is indexed in this table, and the value found there has the + * value form the first table subtracted. The result must be on the range + * [0,3]. + * + * For example, the string "wzyx" will get X from the first table. Each of + * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After + * subtraction, the swizzle values are { 3, 2, 1, 0 }. + * + * The string "wzrg" will get X from the first table. Each of the characters + * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the + * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range + * [0,3], the error is detected. + */ + unsigned char idx_map[26] = { + /* a b c d e f g h i j k l m */ + R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, + /* n o p q r s t u v w x y z */ + 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2 + }; + + int swiz_idx[4] = { 0, 0, 0, 0 }; + unsigned base; + unsigned dup_mask = 0; + unsigned seen_mask = 0; + unsigned i; + + + /* Validate the first character in the swizzle string and look up the base + * index value as described above. + */ + if ((str[0] < 'a') || (str[0] > 'z')) + return FALSE; + + base = base_idx[str[0] - 'a']; + + + for (i = 0; (i < 4) && (str[i] != '\0'); i++) { + unsigned bit; + + /* Validate the next character, and, as described above, convert it to a + * swizzle index. + */ + if ((str[i] < 'a') || (str[i] > 'z')) + return FALSE; + + swiz_idx[i] = idx_map[str[0] - 'a'] - base; + if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) + return FALSE; + + + /* Track a bit-mask of the swizzle index values that have been seen. If + * a value is seen more than once, set the "duplicate" flag. + */ + bit = (1U << swiz_idx[i]); + dup_mask |= seen_mask & bit; + seen_mask |= bit; + } + + if (str[i] != '\0') + return FALSE; + + swiz->x = swiz_idx[0]; + swiz->y = swiz_idx[1]; + swiz->z = swiz_idx[2]; + swiz->w = swiz_idx[3]; + swiz->num_components = i; + swiz->has_duplicates = (dup_mask != 0); + + return TRUE; +} + + +struct ir_instruction * +_mesa_ast_field_selection_to_hir(const ast_expression *expr, + simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + ir_instruction *op; + ir_dereference *deref; + YYLTYPE loc; + + + op = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + deref = new ir_dereference(op); + + /* Initially assume that the resulting type of the field selection is an + * error. This make the error paths below a bit easier to follow. + */ + deref->type = glsl_error_type; + + /* If processing the thing being dereferenced generated an error, bail out + * now. Doing so prevents spurious error messages from being logged below. + */ + if (is_error_type(op->type)) + return (struct ir_instruction *) deref; + + /* There are two kinds of field selection. There is the selection of a + * specific field from a structure, and there is the selection of a + * swizzle / mask from a vector. Which is which is determined entirely + * by the base type of the thing to which the field selection operator is + * being applied. + */ + _mesa_ast_get_location(expr, & loc); + if (is_glsl_type_vector(op->type)) { + if (generate_swizzle(expr->primary_expression.identifier, + & deref->selector.swizzle, + op->type->vector_elements)) { + /* Based on the number of elements in the swizzle and the base type + * (i.e., float, int, unsigned, or bool) of the vector being swizzled, + * generate the type of the resulting value. + */ + deref->type = + _mesa_glsl_get_vector_type(op->type->base_type, + deref->selector.swizzle.num_components); + } else { + /* FINISHME: Logging of error messages should be moved into + * FINISHME: generate_swizzle. This allows the generation of more + * FINISHME: specific error messages. + */ + _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'", + expr->primary_expression.identifier); + } + } else if (op->type->base_type == GLSL_TYPE_STRUCT) { + /* FINISHME: Handle field selection from structures. */ + } else { + _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " + "non-structure / non-vector.", + expr->primary_expression.identifier); + } + + return (struct ir_instruction *) deref; +} diff --git a/ir.cc b/ir.cc deleted file mode 100644 index 7bd7854ccb8..00000000000 --- a/ir.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include "main/imports.h" -#include "main/simple_list.h" -#include "ir.h" -#include "glsl_types.h" - -ir_instruction::ir_instruction(int mode) -{ - this->mode = mode; - make_empty_list(this); -} - - -ir_assignment::ir_assignment(ir_instruction *lhs, ir_instruction *rhs, - ir_expression *condition) - : ir_instruction(ir_op_assign) -{ - this->lhs = (ir_dereference *) lhs; - this->rhs = rhs; - this->condition = condition; -} - - -ir_expression::ir_expression(int op, const struct glsl_type *type, - ir_instruction *op0, ir_instruction *op1) - : ir_instruction(ir_op_expression) -{ - this->type = type; - this->operation = ir_expression_operation(op); - this->operands[0] = op0; - this->operands[1] = op1; -} - - -ir_label::ir_label(const char *label) - : ir_instruction(ir_op_label), label(label) -{ - /* empty */ -} - - -ir_constant::ir_constant(const struct glsl_type *type, const void *data) - : ir_instruction(ir_op_constant) -{ - const unsigned elements = - ((type->vector_elements == 0) ? 1 : type->vector_elements) - * ((type->matrix_rows == 0) ? 1 : type->matrix_rows); - unsigned size = 0; - - this->type = type; - switch (type->base_type) { - case GLSL_TYPE_UINT: size = sizeof(this->value.u[0]); break; - case GLSL_TYPE_INT: size = sizeof(this->value.i[0]); break; - case GLSL_TYPE_FLOAT: size = sizeof(this->value.f[0]); break; - case GLSL_TYPE_BOOL: size = sizeof(this->value.b[0]); break; - default: - /* FINISHME: What to do? Exceptions are not the answer. - */ - break; - } - - memcpy(& this->value, data, size * elements); -} - - -ir_dereference::ir_dereference(ir_instruction *var) - : ir_instruction(ir_op_dereference) -{ - this->mode = ir_reference_variable; - this->var = var; - this->type = (var != NULL) ? var->type : glsl_error_type; -} - - -ir_variable::ir_variable(const struct glsl_type *type, const char *name) - : ir_instruction(ir_op_var_decl) -{ - this->type = type; - this->name = name; -} - - -ir_function_signature::ir_function_signature(void) - : ir_instruction(ir_op_func_sig) -{ - make_empty_list(& parameters); -} - - -ir_function::ir_function(void) - : ir_instruction(ir_op_func) -{ - make_empty_list(& signatures); -} diff --git a/ir.cpp b/ir.cpp new file mode 100644 index 00000000000..7bd7854ccb8 --- /dev/null +++ b/ir.cpp @@ -0,0 +1,116 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "main/imports.h" +#include "main/simple_list.h" +#include "ir.h" +#include "glsl_types.h" + +ir_instruction::ir_instruction(int mode) +{ + this->mode = mode; + make_empty_list(this); +} + + +ir_assignment::ir_assignment(ir_instruction *lhs, ir_instruction *rhs, + ir_expression *condition) + : ir_instruction(ir_op_assign) +{ + this->lhs = (ir_dereference *) lhs; + this->rhs = rhs; + this->condition = condition; +} + + +ir_expression::ir_expression(int op, const struct glsl_type *type, + ir_instruction *op0, ir_instruction *op1) + : ir_instruction(ir_op_expression) +{ + this->type = type; + this->operation = ir_expression_operation(op); + this->operands[0] = op0; + this->operands[1] = op1; +} + + +ir_label::ir_label(const char *label) + : ir_instruction(ir_op_label), label(label) +{ + /* empty */ +} + + +ir_constant::ir_constant(const struct glsl_type *type, const void *data) + : ir_instruction(ir_op_constant) +{ + const unsigned elements = + ((type->vector_elements == 0) ? 1 : type->vector_elements) + * ((type->matrix_rows == 0) ? 1 : type->matrix_rows); + unsigned size = 0; + + this->type = type; + switch (type->base_type) { + case GLSL_TYPE_UINT: size = sizeof(this->value.u[0]); break; + case GLSL_TYPE_INT: size = sizeof(this->value.i[0]); break; + case GLSL_TYPE_FLOAT: size = sizeof(this->value.f[0]); break; + case GLSL_TYPE_BOOL: size = sizeof(this->value.b[0]); break; + default: + /* FINISHME: What to do? Exceptions are not the answer. + */ + break; + } + + memcpy(& this->value, data, size * elements); +} + + +ir_dereference::ir_dereference(ir_instruction *var) + : ir_instruction(ir_op_dereference) +{ + this->mode = ir_reference_variable; + this->var = var; + this->type = (var != NULL) ? var->type : glsl_error_type; +} + + +ir_variable::ir_variable(const struct glsl_type *type, const char *name) + : ir_instruction(ir_op_var_decl) +{ + this->type = type; + this->name = name; +} + + +ir_function_signature::ir_function_signature(void) + : ir_instruction(ir_op_func_sig) +{ + make_empty_list(& parameters); +} + + +ir_function::ir_function(void) + : ir_instruction(ir_op_func) +{ + make_empty_list(& signatures); +} -- cgit v1.2.3 From 89227f6ce40aa34d77fb61edbd32e522afc6e493 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 22 Feb 2010 19:09:45 -0800 Subject: Ignore all build products --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..4c678686229 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.o +*~ +builtin_types.h +glsl_lexer.cpp +glsl_parser.output +glsl_parser.tab.cpp +glsl_parser.tab.h +glsl_parser.tab.hpp +glsl -- cgit v1.2.3 From 88349b22caa0ab0b44188dbb9e002549aadb0590 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 22 Feb 2010 19:10:25 -0800 Subject: Add ast_expression_bin subclass of ast_expression The ast_expression_bin subclass is used for all binary expressions such as addition, subtraction, and comparisons. Several other subclasses are soon to follow. --- Makefile | 3 +- ast.h | 10 ++++++ ast_expr.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ glsl_parser.y | 38 ++++++++++----------- glsl_parser_extras.cpp | 74 ++++------------------------------------ 5 files changed, 130 insertions(+), 87 deletions(-) create mode 100644 ast_expr.cpp diff --git a/Makefile b/Makefile index 0d9017c3069..7b1f3f1f93f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ CSRCS = symbol_table.c hash_table.c glsl_types.c -CCSRCS = glsl_parser.tab.cpp glsl_lexer.cpp glsl_parser_extras.cpp +CCSRCS = glsl_parser.tab.cpp glsl_lexer.cpp glsl_parser_extras.cpp \ + ast_expr.cpp # ast_to_hir.cpp ir.cpp hir_field_selection.cpp OBJS = $(CSRCS:.c=.o) $(CCSRCS:.cpp=.o) diff --git a/ast.h b/ast.h index 591655d06cc..1f659933e98 100644 --- a/ast.h +++ b/ast.h @@ -159,6 +159,8 @@ public: ast_expression(int oper, ast_expression *, ast_expression *, ast_expression *); + static const char *operator_string(enum ast_operators op); + virtual void print(void) const; enum ast_operators oper; @@ -180,6 +182,14 @@ public: struct simple_node expressions; }; +class ast_expression_bin : public ast_expression { +public: + ast_expression_bin(int oper, ast_expression *, ast_expression *); + + virtual void print(void) const; +}; + + /** * Number of possible operators for an ast_expression * diff --git a/ast_expr.cpp b/ast_expr.cpp new file mode 100644 index 00000000000..ad29cdc68d7 --- /dev/null +++ b/ast_expr.cpp @@ -0,0 +1,92 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include "ast.h" + +const char * +ast_expression::operator_string(enum ast_operators op) +{ + static const char *const operators[] = { + "=", + "+", + "-", + "+", + "-", + "*", + "/", + "%", + "<<", + ">>", + "<", + ">", + "<=", + ">=", + "==", + "!=", + "&", + "^", + "|", + "~", + "&&", + "^^", + "!", + + "*=", + "/=", + "%=", + "+=", + "-=", + "<<=", + ">>=", + "&=", + "^=", + "|=", + + "?:", + "++", + "--", + "++", + "--", + ".", + }; + + return operators[op]; +} + + +ast_expression_bin::ast_expression_bin(int oper, ast_expression *ex0, + ast_expression *ex1) : + ast_expression(oper, ex0, ex1, NULL) +{ + assert((oper >= ast_plus) && (oper <= ast_logic_not)); +} + + +void +ast_expression_bin::print(void) const +{ + subexpressions[0]->print(); + printf("%s ", operator_string(oper)); + subexpressions[1]->print(); +} diff --git a/glsl_parser.y b/glsl_parser.y index f9bfb0bc812..f4105652b8e 100644 --- a/glsl_parser.y +++ b/glsl_parser.y @@ -395,15 +395,15 @@ multiplicative_expression: unary_expression | multiplicative_expression '*' unary_expression { - $$ = new ast_expression(ast_mul, $1, $3, NULL); + $$ = new ast_expression_bin(ast_mul, $1, $3); } | multiplicative_expression '/' unary_expression { - $$ = new ast_expression(ast_div, $1, $3, NULL); + $$ = new ast_expression_bin(ast_div, $1, $3); } | multiplicative_expression '%' unary_expression { - $$ = new ast_expression(ast_mod, $1, $3, NULL); + $$ = new ast_expression_bin(ast_mod, $1, $3); } ; @@ -411,11 +411,11 @@ additive_expression: multiplicative_expression | additive_expression '+' multiplicative_expression { - $$ = new ast_expression(ast_add, $1, $3, NULL); + $$ = new ast_expression_bin(ast_add, $1, $3); } | additive_expression '-' multiplicative_expression { - $$ = new ast_expression(ast_sub, $1, $3, NULL); + $$ = new ast_expression_bin(ast_sub, $1, $3); } ; @@ -423,11 +423,11 @@ shift_expression: additive_expression | shift_expression LEFT_OP additive_expression { - $$ = new ast_expression(ast_lshift, $1, $3, NULL); + $$ = new ast_expression_bin(ast_lshift, $1, $3); } | shift_expression RIGHT_OP additive_expression { - $$ = new ast_expression(ast_rshift, $1, $3, NULL); + $$ = new ast_expression_bin(ast_rshift, $1, $3); } ; @@ -435,19 +435,19 @@ relational_expression: shift_expression | relational_expression '<' shift_expression { - $$ = new ast_expression(ast_less, $1, $3, NULL); + $$ = new ast_expression_bin(ast_less, $1, $3); } | relational_expression '>' shift_expression { - $$ = new ast_expression(ast_greater, $1, $3, NULL); + $$ = new ast_expression_bin(ast_greater, $1, $3); } | relational_expression LE_OP shift_expression { - $$ = new ast_expression(ast_lequal, $1, $3, NULL); + $$ = new ast_expression_bin(ast_lequal, $1, $3); } | relational_expression GE_OP shift_expression { - $$ = new ast_expression(ast_gequal, $1, $3, NULL); + $$ = new ast_expression_bin(ast_gequal, $1, $3); } ; @@ -455,11 +455,11 @@ equality_expression: relational_expression | equality_expression EQ_OP relational_expression { - $$ = new ast_expression(ast_equal, $1, $3, NULL); + $$ = new ast_expression_bin(ast_equal, $1, $3); } | equality_expression NE_OP relational_expression { - $$ = new ast_expression(ast_nequal, $1, $3, NULL); + $$ = new ast_expression_bin(ast_nequal, $1, $3); } ; @@ -467,7 +467,7 @@ and_expression: equality_expression | and_expression '&' equality_expression { - $$ = new ast_expression(ast_bit_or, $1, $3, NULL); + $$ = new ast_expression_bin(ast_bit_or, $1, $3); } ; @@ -475,7 +475,7 @@ exclusive_or_expression: and_expression | exclusive_or_expression '^' and_expression { - $$ = new ast_expression(ast_bit_xor, $1, $3, NULL); + $$ = new ast_expression_bin(ast_bit_xor, $1, $3); } ; @@ -483,7 +483,7 @@ inclusive_or_expression: exclusive_or_expression | inclusive_or_expression '|' exclusive_or_expression { - $$ = new ast_expression(ast_bit_or, $1, $3, NULL); + $$ = new ast_expression_bin(ast_bit_or, $1, $3); } ; @@ -491,7 +491,7 @@ logical_and_expression: inclusive_or_expression | logical_and_expression AND_OP inclusive_or_expression { - $$ = new ast_expression(ast_logic_and, $1, $3, NULL); + $$ = new ast_expression_bin(ast_logic_and, $1, $3); } ; @@ -499,7 +499,7 @@ logical_xor_expression: logical_and_expression | logical_xor_expression XOR_OP logical_and_expression { - $$ = new ast_expression(ast_logic_xor, $1, $3, NULL); + $$ = new ast_expression_bin(ast_logic_xor, $1, $3); } ; @@ -507,7 +507,7 @@ logical_or_expression: logical_xor_expression | logical_or_expression OR_OP logical_xor_expression { - $$ = new ast_expression(ast_logic_or, $1, $3, NULL); + $$ = new ast_expression_bin(ast_logic_or, $1, $3); } ; diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 36a6ca8264b..a0fad52d62a 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -239,72 +239,8 @@ ast_compound_statement::ast_compound_statement(int new_scope, void ast_expression::print(void) const { - static const char *const operators[] = { - "=", - "+", - "-", - "+", - "-", - "*", - "/", - "%", - "<<", - ">>", - "<", - ">", - "<=", - ">=", - "==", - "!=", - "&", - "^", - "|", - "~", - "&&", - "^^", - "!", - - "*=", - "/=", - "%=", - "+=", - "-=", - "<<=", - ">>=", - "&=", - "^=", - "|=", - - "?:", - "++", - "--", - "++", - "--", - ".", - }; - - switch (oper) { case ast_assign: - case ast_add: - case ast_sub: - case ast_mul: - case ast_div: - case ast_mod: - case ast_lshift: - case ast_rshift: - case ast_less: - case ast_greater: - case ast_lequal: - case ast_gequal: - case ast_equal: - case ast_nequal: - case ast_bit_and: - case ast_bit_xor: - case ast_bit_or: - case ast_logic_and: - case ast_logic_xor: - case ast_logic_or: case ast_mul_assign: case ast_div_assign: case ast_mod_assign: @@ -316,7 +252,7 @@ ast_expression::print(void) const case ast_xor_assign: case ast_or_assign: subexpressions[0]->print(); - printf("%s ", operators[oper]); + printf("%s ", operator_string(oper)); subexpressions[1]->print(); break; @@ -331,14 +267,14 @@ ast_expression::print(void) const case ast_logic_not: case ast_pre_inc: case ast_pre_dec: - printf("%s ", operators[oper]); + printf("%s ", operator_string(oper)); subexpressions[0]->print(); break; case ast_post_inc: case ast_post_dec: subexpressions[0]->print(); - printf("%s ", operators[oper]); + printf("%s ", operator_string(oper)); break; case ast_conditional: @@ -412,6 +348,10 @@ ast_expression::print(void) const printf(") "); break; } + + default: + assert(0); + break; } } -- cgit v1.2.3 From 168890ce1b8923f814e3b15ad51d66e88e5b0d70 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Feb 2010 12:24:40 -0800 Subject: Convert to new interfaces so that it will compile Convert TRUE and FALSE to true and false. Convert _mesa_ast_get_location to ast_node::get_location. --- hir_field_selection.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 295cbaf8949..3c9fb08cb3e 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -84,7 +84,7 @@ generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, * index value as described above. */ if ((str[0] < 'a') || (str[0] > 'z')) - return FALSE; + return false; base = base_idx[str[0] - 'a']; @@ -96,11 +96,11 @@ generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, * swizzle index. */ if ((str[i] < 'a') || (str[i] > 'z')) - return FALSE; + return false; swiz_idx[i] = idx_map[str[0] - 'a'] - base; if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) - return FALSE; + return false; /* Track a bit-mask of the swizzle index values that have been seen. If @@ -112,7 +112,7 @@ generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, } if (str[i] != '\0') - return FALSE; + return false; swiz->x = swiz_idx[0]; swiz->y = swiz_idx[1]; @@ -121,7 +121,7 @@ generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, swiz->num_components = i; swiz->has_duplicates = (dup_mask != 0); - return TRUE; + return true; } @@ -155,7 +155,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, * by the base type of the thing to which the field selection operator is * being applied. */ - _mesa_ast_get_location(expr, & loc); + loc = expr->get_location(); if (is_glsl_type_vector(op->type)) { if (generate_swizzle(expr->primary_expression.identifier, & deref->selector.swizzle, -- cgit v1.2.3 From e41a1cd4d534639272938210c5491077688ccd37 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Feb 2010 12:49:55 -0800 Subject: Replace tacky wrapper macros with tacky in-line type-casts --- ast.h | 12 ------------ glsl_parser_extras.cpp | 14 +++++++------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/ast.h b/ast.h index 1f659933e98..b04cf75c371 100644 --- a/ast.h +++ b/ast.h @@ -33,18 +33,6 @@ struct _mesa_glsl_parse_state; struct YYLTYPE; -#define _mesa_ast_print(n) \ - ((ast_node *) n)->print() - -#define _mesa_ast_to_hir(n, instr, s) \ - ((struct ast_node *) n)->vtbl->to_hir((struct ast_node *) n, instr, s) - -#define _mesa_ast_function_call_to_hir(n, p, s) \ - ((struct ast_node *) n)->vtbl->function_call_to_hir( \ - (struct ast_node *) n, \ - (struct ast_node *) p, \ - s) - class ast_node : public simple_node { public: virtual ~ast_node(); diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index a0fad52d62a..54d510c1a19 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -211,7 +211,7 @@ ast_compound_statement::print(void) const printf("{\n"); foreach(ptr, & statements) { - _mesa_ast_print(ptr); + ((ast_node *)ptr)->print(); } printf("}\n"); @@ -304,7 +304,7 @@ ast_expression::print(void) const parameters->print(); foreach (ptr, (struct simple_node *) parameters) { printf(", "); - _mesa_ast_print(ptr); + ((ast_node *)ptr)->print(); } } @@ -343,7 +343,7 @@ ast_expression::print(void) const if (ptr != head) printf(", "); - _mesa_ast_print(ptr); + ((ast_node *)ptr)->print(); } printf(") "); break; @@ -394,7 +394,7 @@ ast_function::print(void) const printf(" %s (", identifier); foreach(ptr, & parameters) { - _mesa_ast_print(ptr); + ((ast_node *)ptr)->print(); } printf(")"); @@ -475,7 +475,7 @@ ast_declarator_list::print(void) const if (ptr != head) printf(", "); - _mesa_ast_print(ptr); + ((ast_node *)ptr)->print(); } printf("; "); @@ -610,7 +610,7 @@ ast_struct_specifier::print(void) const printf("struct %s { ", name); foreach (ptr, & declarations) { - _mesa_ast_print(ptr); + ((ast_node *)ptr)->print(); } printf("} "); } @@ -695,7 +695,7 @@ main(int argc, char **argv) _mesa_glsl_lexer_dtor(& state); foreach (ptr, & state.translation_unit) { - _mesa_ast_print(ptr); + ((ast_node *)ptr)->print(); } #if 0 -- cgit v1.2.3 From d59673c9de9f14e6aefcdb0b06751d935385c4aa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Feb 2010 17:17:23 -0800 Subject: autoconf for the ... --- .gitignore | 19 +- Makefile | 41 -- Makefile.am | 39 ++ autogen.sh | 12 + configure.ac | 71 +++ glsl_lexer.l | 273 ----------- glsl_lexer.lpp | 273 +++++++++++ glsl_parser.y | 1228 ----------------------------------------------- glsl_parser.ypp | 1229 ++++++++++++++++++++++++++++++++++++++++++++++++ glsl_parser_extras.cpp | 2 +- 10 files changed, 1641 insertions(+), 1546 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac delete mode 100644 glsl_lexer.l create mode 100644 glsl_lexer.lpp delete mode 100644 glsl_parser.y create mode 100644 glsl_parser.ypp diff --git a/.gitignore b/.gitignore index 4c678686229..e098bdb965a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,22 @@ +.deps +COPYING +INSTALL +Makefile.in +aclocal.m4 +autom4te.cache +config.* +configure +depcomp +ylwrap +install-sh +missing +stamp-h1 +Makefile *.o *~ builtin_types.h glsl_lexer.cpp glsl_parser.output -glsl_parser.tab.cpp -glsl_parser.tab.h -glsl_parser.tab.hpp +glsl_parser.cpp +glsl_parser.h glsl diff --git a/Makefile b/Makefile deleted file mode 100644 index 7b1f3f1f93f..00000000000 --- a/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -CSRCS = symbol_table.c hash_table.c glsl_types.c -CCSRCS = glsl_parser.tab.cpp glsl_lexer.cpp glsl_parser_extras.cpp \ - ast_expr.cpp -# ast_to_hir.cpp ir.cpp hir_field_selection.cpp -OBJS = $(CSRCS:.c=.o) $(CCSRCS:.cpp=.o) - -CC = gcc -CXX = g++ -WARN = -Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector \ - -Wunreachable-code -CPPFLAGS = -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -CFLAGS = -O0 -ggdb3 -fstack-protector $(CPPFLAGS) $(WARN) -std=c89 -ansi -pedantic -CXXFLAGS = -O0 -ggdb3 -fstack-protector $(CPPFLAGS) $(WARN) -LDLAGS = -ggdb3 - -glsl: $(OBJS) - $(CXX) $(LDLAGS) $(OBJS) -o glsl - -glsl_parser.tab.cpp glsl_parser.tab.h: glsl_parser.y - bison --report-file=glsl_parser.output -v -d \ - --output=glsl_parser.tab.cpp \ - --name-prefix=_mesa_glsl_ $< && \ - mv glsl_parser.tab.hpp glsl_parser.tab.h - -glsl_lexer.cpp: glsl_lexer.l - flex --outfile="glsl_lexer.cpp" $< - -glsl_parser_tab.o: glsl_parser.tab.cpp -glsl_types.o: glsl_types.c glsl_types.h builtin_types.h -glsl_lexer.o: glsl_lexer.cpp glsl_parser.tab.h glsl_parser_extras.h ast.h -glsl_parser.o: glsl_parser_extras.h ast.h -ast_to_hir.o: ast_to_hir.cpp symbol_table.h glsl_parser_extras.h ast.h glsl_types.h ir.h - -builtin_types.h: builtin_types.sh - ./builtin_types.sh > builtin_types.h - -clean: - rm -f $(OBJS) glsl - rm -f glsl_lexer.cpp glsl_parser.tab.{cpp,h,hpp} glsl_parser.output - rm -f builtin_types.h - rm -f *~ \ No newline at end of file diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000000..28d9c3c7a1d --- /dev/null +++ b/Makefile.am @@ -0,0 +1,39 @@ +# Copyright © 2010 Intel Corporation +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +# USE OR OTHER DEALINGS IN THE SOFTWARE. + +AUTOMAKE_OPTIONS = foreign + +bin_PROGRAMS = glsl +glsl_SOURCES = symbol_table.c hash_table.c glsl_types.c \ + glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ + ast_expr.cpp +# ast_to_hir.cpp ir.cpp hir_field_selection.cpp + +BUILT_SOURCES = glsl_parser.h builtin_types.h + +glsl_parser.h: glsl_parser.ypp + +.lpp.cpp: + $(LEXCOMPILE) --outfile="$@" $< + +builtin_types.h: builtin_types.sh + sh ./builtin_types.sh > builtin_types.h diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 00000000000..904cd6746c8 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd $srcdir + +autoreconf -v --install || exit 1 +cd $ORIGDIR || exit $? + +$srcdir/configure --enable-maintainer-mode "$@" diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000000..b97feb94407 --- /dev/null +++ b/configure.ac @@ -0,0 +1,71 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT(glsl, XXXXX, idr@freedesktop.org, glsl) +AC_CONFIG_SRCDIR([Makefile.am]) +AM_CONFIG_HEADER([config.h]) + +AM_INIT_AUTOMAKE + +AM_MAINTAINER_MODE + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC +AC_PROG_MAKE_SET +AC_PROG_YACC +AC_PROG_LEX + +# Checks for libraries. + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. +AC_HEADER_STDC + + +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], + [use debug compiler flags and macros @<:@default=disabled@:>@])], + [enable_debug="$enableval"], + [enable_debug=no] +) +if test "x$enable_debug" = xyes; then + DEFINES="$DEFINES -DDEBUG" + if test "x$GCC" = xyes; then + # Remove any -g or -O flags from the command line + CFLAGS=[`echo $CFLAGS | sed 's/-g[^ \t]*[ \t]*//g;s/-O[^ \t]*[ \t]*//g'`] + CFLAGS="$CFLAGS -O0 -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2" + fi + if test "x$GXX" = xyes; then + # Remove any -g flags from the command line + CXXFLAGS=[`echo $CXXFLAGS | sed 's/-g[^ \t]*[ \t]*//g;s/-O[^ \t]*[ \t]*//g'`] + CXXFLAGS="$CXXFLAGS -O0 -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2" + fi +fi + + +if test "x$GCC" = xyes ; then + WARN="-Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector -Wunreadchable-code" +else + WARN="" +fi + +if test "x$GXX" = xyes ; then + WARN="-Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector" +else + WARN="" +fi + +if test "x$GCC" = xyes ; then + CFLAGS="$CFLAGS -std=c89 -ansi -pedantic" +fi + +CFLAGS="$CFLAGS $WARN" +CXXFLAGS="$CXXFLAGS $WARN" +YFLAGS="-d -v" + +AC_OUTPUT([Makefile]) diff --git a/glsl_lexer.l b/glsl_lexer.l deleted file mode 100644 index 201d4616834..00000000000 --- a/glsl_lexer.l +++ /dev/null @@ -1,273 +0,0 @@ -%{ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_parser.tab.h" -#include "symbol_table.h" - -#define YY_USER_ACTION \ - do { \ - yylloc->source = 0; \ - yylloc->first_column = yycolumn + 1; \ - yylloc->first_line = yylineno + 1; \ - yycolumn += yyleng; \ - } while(0); - -%} - -%option bison-bridge bison-locations reentrant noyywrap -%option never-interactive -%option prefix="_mesa_glsl_" -%option extra-type="struct _mesa_glsl_parse_state *" -%option stack - -%x PP COMMENT - -%% - -"/*" { yy_push_state(COMMENT, yyscanner); } -[^*\n]* -[^*\n]*\n { yylineno++; yycolumn = 0; } -"*"+[^*/\n]* -"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; } -"*"+"/" { yy_pop_state(yyscanner); } - -\/\/.*\n { yylineno++; yycolumn = 0; } -[ \r\t]+ ; - - /* Preprocessor tokens. */ -^[ \t]*#[ \t]*$ ; -^[ \t]*#[ \t]*version { BEGIN PP; return VERSION; } -^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; } -^[ \t]*#[ \t]*line { BEGIN PP; return LINE; } -^[ \t]*#[ \t]*pragma { BEGIN PP; return PRAGMA; } -: return COLON; -[_a-zA-Z][_a-zA-Z0-9]* { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } -[1-9][0-9]* { - yylval->n = strtol(yytext, NULL, 10); - return INTCONSTANT; - } -\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } - -\n { yylineno++; yycolumn = 0; } - -attribute return ATTRIBUTE; -const return CONST; -bool return BOOL; -float return FLOAT; -int return INT; - -break return BREAK; -continue return CONTINUE; -do return DO; -while return WHILE; -else return ELSE; -for return FOR; -if return IF; -discard return DISCARD; -return return RETURN; - -bvec2 return BVEC2; -bvec3 return BVEC3; -bvec4 return BVEC4; -ivec2 return IVEC2; -ivec3 return IVEC3; -ivec4 return IVEC4; -vec2 return VEC2; -vec3 return VEC3; -vec4 return VEC4; -mat2 return MAT2; -mat3 return MAT3; -mat4 return MAT4; -mat2x2 return MAT2X2; -mat2x3 return MAT2X3; -mat2x4 return MAT2X4; -mat3x2 return MAT3X2; -mat3x3 return MAT3X3; -mat3x4 return MAT3X4; -mat4x2 return MAT4X2; -mat4x3 return MAT4X3; -mat4x4 return MAT4X4; - -in return IN; -out return OUT; -inout return INOUT; -uniform return UNIFORM; -varying return VARYING; -centroid return CENTROID; -invariant return INVARIANT; - -sampler1D return SAMPLER1D; -sampler2D return SAMPLER2D; -sampler3D return SAMPLER3D; -samplerCube return SAMPLERCUBE; -sampler1DShadow return SAMPLER1DSHADOW; -sampler2DShadow return SAMPLER2DSHADOW; - -struct return STRUCT; -void return VOID; - -\+\+ return INC_OP; --- return DEC_OP; -\<= return LE_OP; ->= return GE_OP; -== return EQ_OP; -!= return NE_OP; -&& return AND_OP; -\|\| return OR_OP; -"^^" return XOR_OP; - -\*= return MUL_ASSIGN; -\/= return DIV_ASSIGN; -\+= return ADD_ASSIGN; -\%= return MOD_ASSIGN; -\<\<= return LEFT_ASSIGN; ->>= return RIGHT_ASSIGN; -&= return AND_ASSIGN; -^= return XOR_ASSIGN; -\|= return OR_ASSIGN; --= return SUB_ASSIGN; - -[1-9][0-9]* { - yylval->n = strtol(yytext, NULL, 10); - return INTCONSTANT; - } -0[xX][0-9a-fA-F]+ { - yylval->n = strtol(yytext + 2, NULL, 16); - return INTCONSTANT; - } -0[0-7]* { - yylval->n = strtol(yytext + 2, NULL, 8); - return INTCONSTANT; - } - -[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { - yylval->real = strtod(yytext, NULL); - return FLOATCONSTANT; - } -\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { - yylval->real = strtod(yytext, NULL); - return FLOATCONSTANT; - } -[0-9]+\.([eE][+-]?[0-9]+)?[fF]? { - yylval->real = strtod(yytext, NULL); - return FLOATCONSTANT; - } -[0-9]+[eE][+-]?[0-9]+[fF]? { - yylval->real = strtod(yytext, NULL); - return FLOATCONSTANT; - } - -true { - yylval->n = 1; - return BOOLCONSTANT; - } -false { - yylval->n = 0; - return BOOLCONSTANT; - } - - - /* Reserved words in GLSL 1.10. */ -asm return ASM; -class return CLASS; -union return UNION; -enum return ENUM; -typedef return TYPEDEF; -template return TEMPLATE; -this return THIS; -packed return PACKED; -goto return GOTO; -switch return SWITCH; -default return DEFAULT; -inline return INLINE; -noinline return NOINLINE; -volatile return VOLATILE; -public return PUBLIC; -static return STATIC; -extern return EXTERN; -external return EXTERNAL; -interface return INTERFACE; -long return LONG; -short return SHORT; -double return DOUBLE; -half return HALF; -fixed return FIXED; -unsigned return UNSIGNED; -input return INPUT; -output return OUTPUT; -hvec2 return HVEC2; -hvec3 return HVEC3; -hvec4 return HVEC4; -dvec2 return DVEC2; -dvec3 return DVEC3; -dvec4 return DVEC4; -fvec2 return FVEC2; -fvec3 return FVEC3; -fvec4 return FVEC4; -sampler2DRect return SAMPLER2DRECT; -sampler3DRect return SAMPLER3DRECT; -sampler2DRectShadow return SAMPLER2DRECTSHADOW; -sizeof return SIZEOF; -cast return CAST; -namespace return NAMESPACE; -using return USING; - - /* Additional reserved words in GLSL 1.20. */ -lowp return LOWP; -mediump return MEDIUMP; -highp return HIGHP; -precision return PRECISION; - -[_a-zA-Z][_a-zA-Z0-9]* { - yylval->identifier = strdup(yytext); - - if (_mesa_symbol_table_find_symbol(yyextra->symbols, - 0, - yylval->identifier)) - return TYPE_NAME; - else - return IDENTIFIER; - } - -. { return yytext[0]; } - -%% - -void -_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, - const char *string, size_t len) -{ - yylex_init_extra(state, & state->scanner); - yy_scan_bytes(string, len, state->scanner); -} - -void -_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) -{ - yylex_destroy(state->scanner); -} diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp new file mode 100644 index 00000000000..9c7e3064e4a --- /dev/null +++ b/glsl_lexer.lpp @@ -0,0 +1,273 @@ +%{ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" +#include "symbol_table.h" + +#define YY_USER_ACTION \ + do { \ + yylloc->source = 0; \ + yylloc->first_column = yycolumn + 1; \ + yylloc->first_line = yylineno + 1; \ + yycolumn += yyleng; \ + } while(0); + +%} + +%option bison-bridge bison-locations reentrant noyywrap +%option never-interactive +%option prefix="_mesa_glsl_" +%option extra-type="struct _mesa_glsl_parse_state *" +%option stack + +%x PP COMMENT + +%% + +"/*" { yy_push_state(COMMENT, yyscanner); } +[^*\n]* +[^*\n]*\n { yylineno++; yycolumn = 0; } +"*"+[^*/\n]* +"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; } +"*"+"/" { yy_pop_state(yyscanner); } + +\/\/.*\n { yylineno++; yycolumn = 0; } +[ \r\t]+ ; + + /* Preprocessor tokens. */ +^[ \t]*#[ \t]*$ ; +^[ \t]*#[ \t]*version { BEGIN PP; return VERSION; } +^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; } +^[ \t]*#[ \t]*line { BEGIN PP; return LINE; } +^[ \t]*#[ \t]*pragma { BEGIN PP; return PRAGMA; } +: return COLON; +[_a-zA-Z][_a-zA-Z0-9]* { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } +[1-9][0-9]* { + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } +\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } + +\n { yylineno++; yycolumn = 0; } + +attribute return ATTRIBUTE; +const return CONST; +bool return BOOL; +float return FLOAT; +int return INT; + +break return BREAK; +continue return CONTINUE; +do return DO; +while return WHILE; +else return ELSE; +for return FOR; +if return IF; +discard return DISCARD; +return return RETURN; + +bvec2 return BVEC2; +bvec3 return BVEC3; +bvec4 return BVEC4; +ivec2 return IVEC2; +ivec3 return IVEC3; +ivec4 return IVEC4; +vec2 return VEC2; +vec3 return VEC3; +vec4 return VEC4; +mat2 return MAT2; +mat3 return MAT3; +mat4 return MAT4; +mat2x2 return MAT2X2; +mat2x3 return MAT2X3; +mat2x4 return MAT2X4; +mat3x2 return MAT3X2; +mat3x3 return MAT3X3; +mat3x4 return MAT3X4; +mat4x2 return MAT4X2; +mat4x3 return MAT4X3; +mat4x4 return MAT4X4; + +in return IN; +out return OUT; +inout return INOUT; +uniform return UNIFORM; +varying return VARYING; +centroid return CENTROID; +invariant return INVARIANT; + +sampler1D return SAMPLER1D; +sampler2D return SAMPLER2D; +sampler3D return SAMPLER3D; +samplerCube return SAMPLERCUBE; +sampler1DShadow return SAMPLER1DSHADOW; +sampler2DShadow return SAMPLER2DSHADOW; + +struct return STRUCT; +void return VOID; + +\+\+ return INC_OP; +-- return DEC_OP; +\<= return LE_OP; +>= return GE_OP; +== return EQ_OP; +!= return NE_OP; +&& return AND_OP; +\|\| return OR_OP; +"^^" return XOR_OP; + +\*= return MUL_ASSIGN; +\/= return DIV_ASSIGN; +\+= return ADD_ASSIGN; +\%= return MOD_ASSIGN; +\<\<= return LEFT_ASSIGN; +>>= return RIGHT_ASSIGN; +&= return AND_ASSIGN; +^= return XOR_ASSIGN; +\|= return OR_ASSIGN; +-= return SUB_ASSIGN; + +[1-9][0-9]* { + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } +0[xX][0-9a-fA-F]+ { + yylval->n = strtol(yytext + 2, NULL, 16); + return INTCONSTANT; + } +0[0-7]* { + yylval->n = strtol(yytext + 2, NULL, 8); + return INTCONSTANT; + } + +[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } +\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } +[0-9]+\.([eE][+-]?[0-9]+)?[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } +[0-9]+[eE][+-]?[0-9]+[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } + +true { + yylval->n = 1; + return BOOLCONSTANT; + } +false { + yylval->n = 0; + return BOOLCONSTANT; + } + + + /* Reserved words in GLSL 1.10. */ +asm return ASM; +class return CLASS; +union return UNION; +enum return ENUM; +typedef return TYPEDEF; +template return TEMPLATE; +this return THIS; +packed return PACKED; +goto return GOTO; +switch return SWITCH; +default return DEFAULT; +inline return INLINE; +noinline return NOINLINE; +volatile return VOLATILE; +public return PUBLIC; +static return STATIC; +extern return EXTERN; +external return EXTERNAL; +interface return INTERFACE; +long return LONG; +short return SHORT; +double return DOUBLE; +half return HALF; +fixed return FIXED; +unsigned return UNSIGNED; +input return INPUT; +output return OUTPUT; +hvec2 return HVEC2; +hvec3 return HVEC3; +hvec4 return HVEC4; +dvec2 return DVEC2; +dvec3 return DVEC3; +dvec4 return DVEC4; +fvec2 return FVEC2; +fvec3 return FVEC3; +fvec4 return FVEC4; +sampler2DRect return SAMPLER2DRECT; +sampler3DRect return SAMPLER3DRECT; +sampler2DRectShadow return SAMPLER2DRECTSHADOW; +sizeof return SIZEOF; +cast return CAST; +namespace return NAMESPACE; +using return USING; + + /* Additional reserved words in GLSL 1.20. */ +lowp return LOWP; +mediump return MEDIUMP; +highp return HIGHP; +precision return PRECISION; + +[_a-zA-Z][_a-zA-Z0-9]* { + yylval->identifier = strdup(yytext); + + if (_mesa_symbol_table_find_symbol(yyextra->symbols, + 0, + yylval->identifier)) + return TYPE_NAME; + else + return IDENTIFIER; + } + +. { return yytext[0]; } + +%% + +void +_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, + const char *string, size_t len) +{ + yylex_init_extra(state, & state->scanner); + yy_scan_bytes(string, len, state->scanner); +} + +void +_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) +{ + yylex_destroy(state->scanner); +} diff --git a/glsl_parser.y b/glsl_parser.y deleted file mode 100644 index f4105652b8e..00000000000 --- a/glsl_parser.y +++ /dev/null @@ -1,1228 +0,0 @@ -%{ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include -#include -#include - -#include "ast.h" -#include "glsl_parser_extras.h" -#include "symbol_table.h" -#include "glsl_types.h" - -#define YYLEX_PARAM state->scanner - -%} - -%pure-parser -%locations -%error-verbose - -%lex-param {void *scanner} -%parse-param {struct _mesa_glsl_parse_state *state} - -%union { - int n; - float real; - char *identifier; - - union { - struct ast_type_qualifier q; - unsigned i; - } type_qualifier; - - struct ast_node *node; - struct ast_type_specifier *type_specifier; - struct ast_fully_specified_type *fully_specified_type; - struct ast_function *function; - struct ast_parameter_declarator *parameter_declarator; - struct ast_function_definition *function_definition; - struct ast_compound_statement *compound_statement; - struct ast_expression *expression; - struct ast_declarator_list *declarator_list; - struct ast_struct_specifier *struct_specifier; - struct ast_declaration *declaration; - - struct { - struct ast_node *cond; - struct ast_expression *rest; - } for_rest_statement; -} - -%token ATTRIBUTE CONST BOOL FLOAT INT UINT -%token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT -%token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 -%token MAT2 MAT3 MAT4 CENTROID IN OUT INOUT UNIFORM VARYING -%token NOPERSPECTIVE FLAT SMOOTH -%token MAT2X2 MAT2X3 MAT2X4 -%token MAT3X2 MAT3X3 MAT3X4 -%token MAT4X2 MAT4X3 MAT4X4 -%token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW -%token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW -%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE -%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D -%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY -%token STRUCT VOID WHILE -%token IDENTIFIER TYPE_NAME -%token FLOATCONSTANT -%token INTCONSTANT UINTCONSTANT BOOLCONSTANT -%token FIELD_SELECTION -%token LEFT_OP RIGHT_OP -%token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP -%token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN -%token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN -%token SUB_ASSIGN -%token INVARIANT -%token HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION - -%token VERSION EXTENSION LINE PRAGMA COLON EOL INTERFACE OUTPUT - - /* Reserved words that are not actually used in the grammar. - */ -%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED GOTO -%token INLINE NOINLINE VOLATILE PUBLIC STATIC EXTERN EXTERNAL -%token LONG SHORT DOUBLE HALF FIXED UNSIGNED INPUT OUPTUT -%token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 -%token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW -%token SIZEOF CAST NAMESPACE USING LOWP MEDIUMP HIGHP - -%type variable_identifier -%type statement -%type statement_list -%type simple_statement -%type statement_matched -%type statement_unmatched -%type precision_qualifier -%type type_qualifier -%type storage_qualifier -%type interpolation_qualifier -%type type_specifier -%type type_specifier_no_prec -%type type_specifier_nonarray -%type basic_type_specifier_nonarray -%type fully_specified_type -%type function_prototype -%type function_header -%type function_header_with_parameters -%type function_declarator -%type parameter_declarator -%type parameter_declaration -%type parameter_qualifier -%type parameter_type_qualifier -%type parameter_type_specifier -%type function_definition -%type compound_statement_no_new_scope -%type compound_statement -%type statement_no_new_scope -%type expression_statement -%type expression -%type primary_expression -%type assignment_expression -%type conditional_expression -%type logical_or_expression -%type logical_xor_expression -%type logical_and_expression -%type inclusive_or_expression -%type exclusive_or_expression -%type and_expression -%type equality_expression -%type relational_expression -%type shift_expression -%type additive_expression -%type multiplicative_expression -%type unary_expression -%type constant_expression -%type integer_expression -%type postfix_expression -%type function_call_header_with_parameters -%type function_call_header_no_parameters -%type function_call_header -%type function_call_generic -%type function_call_or_method -%type function_call -%type assignment_operator -%type unary_operator -%type function_identifier -%type external_declaration -%type init_declarator_list -%type single_declaration -%type initializer -%type declaration -%type declaration_statement -%type jump_statement -%type struct_specifier -%type struct_declaration_list -%type struct_declaration -%type struct_declarator -%type struct_declarator_list -%type selection_statement_matched -%type selection_statement_unmatched -%type iteration_statement -%type condition -%type conditionopt -%type for_init_statement -%type for_rest_statement -%% - -translation_unit: - version_statement - { - _mesa_glsl_initialize_types(state); - } - external_declaration_list - | - { - state->language_version = 110; - _mesa_glsl_initialize_types(state); - } - external_declaration_list - ; - -version_statement: - VERSION INTCONSTANT EOL - { - switch ($2) { - case 110: - case 120: - case 130: - /* FINISHME: Check against implementation support versions. */ - state->language_version = $2; - break; - default: - _mesa_glsl_error(& @2, state, "Shading language version" - "%u is not supported\n", $2); - break; - } - } - ; - -external_declaration_list: - external_declaration - { - insert_at_tail(& state->translation_unit, - (struct simple_node *) $1); - } - | external_declaration_list external_declaration - { - insert_at_tail(& state->translation_unit, - (struct simple_node *) $2); - } - ; - -variable_identifier: - IDENTIFIER - ; - -primary_expression: - variable_identifier - { - $$ = new ast_expression(ast_identifier, NULL, NULL, NULL); - $$->primary_expression.identifier = $1; - } - | INTCONSTANT - { - $$ = new ast_expression(ast_int_constant, NULL, NULL, NULL); - $$->primary_expression.int_constant = $1; - } - | UINTCONSTANT - { - $$ = new ast_expression(ast_uint_constant, NULL, NULL, NULL); - $$->primary_expression.uint_constant = $1; - } - | FLOATCONSTANT - { - $$ = new ast_expression(ast_float_constant, NULL, NULL, NULL); - $$->primary_expression.float_constant = $1; - } - | BOOLCONSTANT - { - $$ = new ast_expression(ast_bool_constant, NULL, NULL, NULL); - $$->primary_expression.bool_constant = $1; - } - | '(' expression ')' - { - $$ = $2; - } - ; - -postfix_expression: - primary_expression - | postfix_expression '[' integer_expression ']' - { - $$ = new ast_expression(ast_array_index, $1, $3, NULL); - } - | function_call - { - $$ = $1; - } - | postfix_expression '.' IDENTIFIER - { - $$ = new ast_expression(ast_field_selection, $1, NULL, NULL); - $$->primary_expression.identifier = $3; - } - | postfix_expression INC_OP - { - $$ = new ast_expression(ast_post_inc, $1, NULL, NULL); - } - | postfix_expression DEC_OP - { - $$ = new ast_expression(ast_post_dec, $1, NULL, NULL); - } - ; - -integer_expression: - expression - ; - -function_call: - function_call_or_method - ; - -function_call_or_method: - function_call_generic - | postfix_expression '.' function_call_generic - { - $$ = new ast_expression(ast_field_selection, $1, $3, NULL); - } - ; - -function_call_generic: - function_call_header_with_parameters ')' - | function_call_header_no_parameters ')' - ; - -function_call_header_no_parameters: - function_call_header VOID - | function_call_header - ; - -function_call_header_with_parameters: - function_call_header assignment_expression - { - $$ = $1; - $$->subexpressions[1] = $2; - } - | function_call_header_with_parameters ',' assignment_expression - { - $$ = $1; - insert_at_tail((struct simple_node *) $$->subexpressions[1], - (struct simple_node *) $3); - } - ; - - // Grammar Note: Constructors look like functions, but lexical - // analysis recognized most of them as keywords. They are now - // recognized through "type_specifier". -function_call_header: - function_identifier '(' - { - $$ = new ast_expression(ast_function_call, - (struct ast_expression *) $1, - NULL, NULL); - } - ; - -function_identifier: - type_specifier - { - $$ = (struct ast_node *) $1; - } - | IDENTIFIER - { - ast_expression *expr = - new ast_expression(ast_identifier, NULL, NULL, NULL); - expr->primary_expression.identifier = $1; - - $$ = (struct ast_node *) expr; - } - | FIELD_SELECTION - { - ast_expression *expr = - new ast_expression(ast_identifier, NULL, NULL, NULL); - expr->primary_expression.identifier = $1; - - $$ = (struct ast_node *) expr; - } - ; - - // Grammar Note: No traditional style type casts. -unary_expression: - postfix_expression - | INC_OP unary_expression - { - $$ = new ast_expression(ast_pre_inc, $2, NULL, NULL); - } - | DEC_OP unary_expression - { - $$ = new ast_expression(ast_pre_dec, $2, NULL, NULL); - } - | unary_operator unary_expression - { - $$ = new ast_expression($1, $2, NULL, NULL); - } - ; - - // Grammar Note: No '*' or '&' unary ops. Pointers are not supported. -unary_operator: - '+' { $$ = ast_plus; } - | '-' { $$ = ast_neg; } - | '!' { $$ = ast_logic_not; } - | '~' { $$ = ast_bit_not; } - ; - -multiplicative_expression: - unary_expression - | multiplicative_expression '*' unary_expression - { - $$ = new ast_expression_bin(ast_mul, $1, $3); - } - | multiplicative_expression '/' unary_expression - { - $$ = new ast_expression_bin(ast_div, $1, $3); - } - | multiplicative_expression '%' unary_expression - { - $$ = new ast_expression_bin(ast_mod, $1, $3); - } - ; - -additive_expression: - multiplicative_expression - | additive_expression '+' multiplicative_expression - { - $$ = new ast_expression_bin(ast_add, $1, $3); - } - | additive_expression '-' multiplicative_expression - { - $$ = new ast_expression_bin(ast_sub, $1, $3); - } - ; - -shift_expression: - additive_expression - | shift_expression LEFT_OP additive_expression - { - $$ = new ast_expression_bin(ast_lshift, $1, $3); - } - | shift_expression RIGHT_OP additive_expression - { - $$ = new ast_expression_bin(ast_rshift, $1, $3); - } - ; - -relational_expression: - shift_expression - | relational_expression '<' shift_expression - { - $$ = new ast_expression_bin(ast_less, $1, $3); - } - | relational_expression '>' shift_expression - { - $$ = new ast_expression_bin(ast_greater, $1, $3); - } - | relational_expression LE_OP shift_expression - { - $$ = new ast_expression_bin(ast_lequal, $1, $3); - } - | relational_expression GE_OP shift_expression - { - $$ = new ast_expression_bin(ast_gequal, $1, $3); - } - ; - -equality_expression: - relational_expression - | equality_expression EQ_OP relational_expression - { - $$ = new ast_expression_bin(ast_equal, $1, $3); - } - | equality_expression NE_OP relational_expression - { - $$ = new ast_expression_bin(ast_nequal, $1, $3); - } - ; - -and_expression: - equality_expression - | and_expression '&' equality_expression - { - $$ = new ast_expression_bin(ast_bit_or, $1, $3); - } - ; - -exclusive_or_expression: - and_expression - | exclusive_or_expression '^' and_expression - { - $$ = new ast_expression_bin(ast_bit_xor, $1, $3); - } - ; - -inclusive_or_expression: - exclusive_or_expression - | inclusive_or_expression '|' exclusive_or_expression - { - $$ = new ast_expression_bin(ast_bit_or, $1, $3); - } - ; - -logical_and_expression: - inclusive_or_expression - | logical_and_expression AND_OP inclusive_or_expression - { - $$ = new ast_expression_bin(ast_logic_and, $1, $3); - } - ; - -logical_xor_expression: - logical_and_expression - | logical_xor_expression XOR_OP logical_and_expression - { - $$ = new ast_expression_bin(ast_logic_xor, $1, $3); - } - ; - -logical_or_expression: - logical_xor_expression - | logical_or_expression OR_OP logical_xor_expression - { - $$ = new ast_expression_bin(ast_logic_or, $1, $3); - } - ; - -conditional_expression: - logical_or_expression - | logical_or_expression '?' expression ':' assignment_expression - { - $$ = new ast_expression(ast_conditional, $1, $3, $5); - } - ; - -assignment_expression: - conditional_expression - | unary_expression assignment_operator assignment_expression - { - $$ = new ast_expression($2, $1, $3, NULL); - } - ; - -assignment_operator: - '=' { $$ = ast_assign; } - | MUL_ASSIGN { $$ = ast_mul_assign; } - | DIV_ASSIGN { $$ = ast_div_assign; } - | MOD_ASSIGN { $$ = ast_mod_assign; } - | ADD_ASSIGN { $$ = ast_add_assign; } - | SUB_ASSIGN { $$ = ast_sub_assign; } - | LEFT_ASSIGN { $$ = ast_ls_assign; } - | RIGHT_ASSIGN { $$ = ast_rs_assign; } - | AND_ASSIGN { $$ = ast_and_assign; } - | XOR_ASSIGN { $$ = ast_xor_assign; } - | OR_ASSIGN { $$ = ast_or_assign; } - ; - -expression: - assignment_expression - { - $$ = $1; - } - | expression ',' assignment_expression - { - if ($1->oper != ast_sequence) { - $$ = new ast_expression(ast_sequence, NULL, NULL, NULL); - insert_at_tail(& $$->expressions, $1); - } else { - $$ = $1; - } - - insert_at_tail(& $$->expressions, $3); - } - ; - -constant_expression: - conditional_expression - ; - -declaration: - function_prototype ';' - { - $$ = $1; - } - | init_declarator_list ';' - { - $$ = $1; - } - | PRECISION precision_qualifier type_specifier_no_prec ';' - { - $$ = NULL; /* FINISHME */ - } - ; - -function_prototype: - function_declarator ')' - ; - -function_declarator: - function_header - | function_header_with_parameters - ; - -function_header_with_parameters: - function_header parameter_declaration - { - $$ = $1; - insert_at_head(& $$->parameters, - (struct simple_node *) $2); - } - | function_header_with_parameters ',' parameter_declaration - { - $$ = $1; - insert_at_head(& $$->parameters, - (struct simple_node *) $3); - } - ; - -function_header: - fully_specified_type IDENTIFIER '(' - { - $$ = new ast_function(); - $$->return_type = $1; - $$->identifier = $2; - } - ; - -parameter_declarator: - type_specifier IDENTIFIER - { - $$ = new ast_parameter_declarator(); - $$->type = new ast_fully_specified_type(); - $$->type->specifier = $1; - $$->identifier = $2; - } - | type_specifier IDENTIFIER '[' constant_expression ']' - { - $$ = new ast_parameter_declarator(); - $$->type = new ast_fully_specified_type(); - $$->type->specifier = $1; - $$->identifier = $2; - $$->is_array = true; - $$->array_size = $4; - } - ; - -parameter_declaration: - parameter_type_qualifier parameter_qualifier parameter_declarator - { - $1.i |= $2.i; - - $$ = $3; - $$->type->qualifier = $1.q; - } - | parameter_qualifier parameter_declarator - { - $$ = $2; - $$->type->qualifier = $1.q; - } - | parameter_type_qualifier parameter_qualifier parameter_type_specifier - { - $1.i |= $2.i; - - $$ = new ast_parameter_declarator(); - $$->type = new ast_fully_specified_type(); - $$->type->qualifier = $1.q; - $$->type->specifier = $3; - } - | parameter_qualifier parameter_type_specifier - { - $$ = new ast_parameter_declarator(); - $$->type = new ast_fully_specified_type(); - $$->type->qualifier = $1.q; - $$->type->specifier = $2; - } - ; - -parameter_qualifier: - /* empty */ { $$.i = 0; } - | IN { $$.i = 0; $$.q.in = 1; } - | OUT { $$.i = 0; $$.q.out = 1; } - | INOUT { $$.i = 0; $$.q.in = 1; $$.q.out = 1; } - ; - -parameter_type_specifier: - type_specifier - ; - -init_declarator_list: - single_declaration - | init_declarator_list ',' IDENTIFIER - { - ast_declaration *decl = new ast_declaration($3, false, NULL, NULL); - - $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | init_declarator_list ',' IDENTIFIER '[' ']' - { - ast_declaration *decl = new ast_declaration($3, true, NULL, NULL); - - $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' - { - ast_declaration *decl = new ast_declaration($3, true, $5, NULL); - - $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer - { - ast_declaration *decl = new ast_declaration($3, true, NULL, $7); - - $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer - { - ast_declaration *decl = new ast_declaration($3, true, $5, $8); - - $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | init_declarator_list ',' IDENTIFIER '=' initializer - { - ast_declaration *decl = new ast_declaration($3, false, NULL, $5); - - $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - ; - - // Grammar Note: No 'enum', or 'typedef'. -single_declaration: - fully_specified_type - { - $$ = new ast_declarator_list($1); - } - | fully_specified_type IDENTIFIER - { - ast_declaration *decl = new ast_declaration($2, false, NULL, NULL); - - $$ = new ast_declarator_list($1); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | fully_specified_type IDENTIFIER '[' ']' - { - ast_declaration *decl = new ast_declaration($2, true, NULL, NULL); - - $$ = new ast_declarator_list($1); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | fully_specified_type IDENTIFIER '[' constant_expression ']' - { - ast_declaration *decl = new ast_declaration($2, true, $4, NULL); - - $$ = new ast_declarator_list($1); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | fully_specified_type IDENTIFIER '[' ']' '=' initializer - { - ast_declaration *decl = new ast_declaration($2, true, NULL, $6); - - $$ = new ast_declarator_list($1); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer - { - ast_declaration *decl = new ast_declaration($2, true, $4, $7); - - $$ = new ast_declarator_list($1); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | fully_specified_type IDENTIFIER '=' initializer - { - ast_declaration *decl = new ast_declaration($2, false, NULL, $4); - - $$ = new ast_declarator_list($1); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - | INVARIANT IDENTIFIER // Vertex only. - { - ast_declaration *decl = new ast_declaration($2, false, NULL, NULL); - - $$ = new ast_declarator_list(NULL); - $$->invariant = true; - - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); - } - ; - -fully_specified_type: - type_specifier - { - $$ = new ast_fully_specified_type(); - $$->specifier = $1; - } - | type_qualifier type_specifier - { - $$ = new ast_fully_specified_type(); - $$->qualifier = $1.q; - $$->specifier = $2; - } - ; - -interpolation_qualifier: - SMOOTH { $$.i = 0; $$.q.smooth = 1; } - | FLAT { $$.i = 0; $$.q.flat = 1; } - | NOPERSPECTIVE { $$.i = 0; $$.q.noperspective = 1; } - ; - -parameter_type_qualifier: - CONST { $$.i = 0; $$.q.constant = 1; } - ; - -type_qualifier: - storage_qualifier - | interpolation_qualifier type_qualifier - { - $$.i = $1.i | $2.i; - } - | INVARIANT type_qualifier - { - $$ = $2; - $$.q.invariant = 1; - } - ; - -storage_qualifier: - CONST { $$.i = 0; $$.q.constant = 1; } - | ATTRIBUTE { $$.i = 0; $$.q.attribute = 1; } - | VARYING { $$.i = 0; $$.q.varying = 1; } - | CENTROID VARYING { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; } - | IN { $$.i = 0; $$.q.in = 1; } - | OUT { $$.i = 0; $$.q.out = 1; } - | CENTROID IN { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; } - | CENTROID OUT { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; } - | UNIFORM { $$.i = 0; $$.q.uniform = 1; } - ; - -type_specifier: - type_specifier_no_prec - | precision_qualifier type_specifier_no_prec - { - $$ = $2; - $$->precision = $1; - } - ; - -type_specifier_no_prec: - type_specifier_nonarray - | type_specifier_nonarray '[' ']' - { - $$ = $1; - $$->is_array = true; - $$->array_size = NULL; - } - | type_specifier_nonarray '[' constant_expression ']' - { - $$ = $1; - $$->is_array = true; - $$->array_size = $3; - } - ; - -type_specifier_nonarray: - basic_type_specifier_nonarray - { - $$ = new ast_type_specifier($1); - } - | struct_specifier - { - $$ = new ast_type_specifier(ast_struct); - $$->structure = $1; - } - | TYPE_NAME - { - $$ = new ast_type_specifier(ast_type_name); - $$->type_name = $1; - } - ; - -basic_type_specifier_nonarray: - VOID { $$ = ast_void; } - | FLOAT { $$ = ast_float; } - | INT { $$ = ast_int; } - | UINT { $$ = ast_uint; } - | BOOL { $$ = ast_bool; } - | VEC2 { $$ = ast_vec2; } - | VEC3 { $$ = ast_vec3; } - | VEC4 { $$ = ast_vec4; } - | BVEC2 { $$ = ast_bvec2; } - | BVEC3 { $$ = ast_bvec3; } - | BVEC4 { $$ = ast_bvec4; } - | IVEC2 { $$ = ast_ivec2; } - | IVEC3 { $$ = ast_ivec3; } - | IVEC4 { $$ = ast_ivec4; } - | UVEC2 { $$ = ast_uvec2; } - | UVEC3 { $$ = ast_uvec3; } - | UVEC4 { $$ = ast_uvec4; } - | MAT2 { $$ = ast_mat2; } - | MAT3 { $$ = ast_mat3; } - | MAT4 { $$ = ast_mat4; } - | MAT2X2 { $$ = ast_mat2; } - | MAT2X3 { $$ = ast_mat2x3; } - | MAT2X4 { $$ = ast_mat2x4; } - | MAT3X2 { $$ = ast_mat3x2; } - | MAT3X3 { $$ = ast_mat3; } - | MAT3X4 { $$ = ast_mat3x4; } - | MAT4X2 { $$ = ast_mat4x2; } - | MAT4X3 { $$ = ast_mat4x3; } - | MAT4X4 { $$ = ast_mat4; } - | SAMPLER1D { $$ = ast_sampler1d; } - | SAMPLER2D { $$ = ast_sampler2d; } - | SAMPLER3D { $$ = ast_sampler3d; } - | SAMPLERCUBE { $$ = ast_samplercube; } - | SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; } - | SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; } - | SAMPLERCUBESHADOW { $$ = ast_samplercubeshadow; } - | SAMPLER1DARRAY { $$ = ast_sampler1darray; } - | SAMPLER2DARRAY { $$ = ast_sampler2darray; } - | SAMPLER1DARRAYSHADOW { $$ = ast_sampler1darrayshadow; } - | SAMPLER2DARRAYSHADOW { $$ = ast_sampler2darrayshadow; } - | ISAMPLER1D { $$ = ast_isampler1d; } - | ISAMPLER2D { $$ = ast_isampler2d; } - | ISAMPLER3D { $$ = ast_isampler3d; } - | ISAMPLERCUBE { $$ = ast_isamplercube; } - | ISAMPLER1DARRAY { $$ = ast_isampler1darray; } - | ISAMPLER2DARRAY { $$ = ast_isampler2darray; } - | USAMPLER1D { $$ = ast_usampler1d; } - | USAMPLER2D { $$ = ast_usampler2d; } - | USAMPLER3D { $$ = ast_usampler3d; } - | USAMPLERCUBE { $$ = ast_usamplercube; } - | USAMPLER1DARRAY { $$ = ast_usampler1darray; } - | USAMPLER2DARRAY { $$ = ast_usampler2darray; } - ; - -precision_qualifier: - HIGH_PRECISION { $$ = ast_precision_high; } - | MEDIUM_PRECISION { $$ = ast_precision_medium; } - | LOW_PRECISION { $$ = ast_precision_low; } - ; - -struct_specifier: - STRUCT IDENTIFIER '{' struct_declaration_list '}' - { - $$ = new ast_struct_specifier($2, $4); - - _mesa_symbol_table_add_symbol(state->symbols, 0, $2, $$); - } - | STRUCT '{' struct_declaration_list '}' - { - $$ = new ast_struct_specifier(NULL, $3); - } - ; - -struct_declaration_list: - struct_declaration - { - $$ = (struct ast_node *) $1; - } - | struct_declaration_list struct_declaration - { - $$ = (struct ast_node *) $1; - insert_at_tail((struct simple_node *) $$, - (struct simple_node *) $2); - } - ; - -struct_declaration: - type_specifier struct_declarator_list ';' - { - ast_fully_specified_type *type = new ast_fully_specified_type(); - - type->specifier = $1; - $$ = new ast_declarator_list(type); - - insert_at_tail((struct simple_node *) $2, - & $$->declarations); - } - ; - -struct_declarator_list: - struct_declarator - | struct_declarator_list ',' struct_declarator - { - $$ = $1; - insert_at_tail((struct simple_node *) $$, - (struct simple_node *) $3); - } - ; - -struct_declarator: - IDENTIFIER - { - $$ = new ast_declaration($1, false, NULL, NULL); - } - | IDENTIFIER '[' constant_expression ']' - { - $$ = new ast_declaration($1, true, $3, NULL); - } - ; - -initializer: - assignment_expression - ; - -declaration_statement: - declaration - ; - - // Grammar Note: labeled statements for SWITCH only; 'goto' is not - // supported. -statement: - statement_matched - | statement_unmatched - ; - -statement_matched: - compound_statement { $$ = (struct ast_node *) $1; } - | simple_statement - ; - -statement_unmatched: - selection_statement_unmatched - ; - -simple_statement: - declaration_statement - | expression_statement - | selection_statement_matched - | switch_statement { $$ = NULL; } - | case_label { $$ = NULL; } - | iteration_statement - | jump_statement - ; - -compound_statement: - '{' '}' - { - $$ = new ast_compound_statement(true, NULL); - } - | '{' statement_list '}' - { - $$ = new ast_compound_statement(true, $2); - } - ; - -statement_no_new_scope: - compound_statement_no_new_scope { $$ = (struct ast_node *) $1; } - | simple_statement - ; - -compound_statement_no_new_scope: - '{' '}' - { - $$ = new ast_compound_statement(false, NULL); - } - | '{' statement_list '}' - { - $$ = new ast_compound_statement(false, $2); - } - ; - -statement_list: - statement - { - if ($1 == NULL) { - _mesa_glsl_error(& @1, state, " statement\n"); - assert($1 != NULL); - } - - $$ = $1; - make_empty_list((struct simple_node *) $$); - } - | statement_list statement - { - if ($2 == NULL) { - _mesa_glsl_error(& @2, state, " statement\n"); - assert($2 != NULL); - } - $$ = $1; - insert_at_tail((struct simple_node *) $$, - (struct simple_node *) $2); - } - ; - -expression_statement: - ';' - { - $$ = new ast_expression_statement(NULL); - } - | expression ';' - { - $$ = new ast_expression_statement($1); - } - ; - -selection_statement_matched: - IF '(' expression ')' statement_matched ELSE statement_matched - { - $$ = new ast_selection_statement($3, $5, $7); - } - ; - -selection_statement_unmatched: - IF '(' expression ')' statement_matched - { - $$ = new ast_selection_statement($3, $5, NULL); - } - | IF '(' expression ')' statement_unmatched - { - $$ = new ast_selection_statement($3, $5, NULL); - } - | IF '(' expression ')' statement_matched ELSE statement_unmatched - { - $$ = new ast_selection_statement($3, $5, $7); - } - ; - -condition: - expression - { - $$ = (struct ast_node *) $1; - } - | fully_specified_type IDENTIFIER '=' initializer - { - ast_declaration *decl = new ast_declaration($2, false, NULL, $4); - ast_declarator_list *declarator = new ast_declarator_list($1); - - insert_at_tail(& declarator->declarations, - (struct simple_node *) decl); - - $$ = declarator; - } - ; - -switch_statement: - SWITCH '(' expression ')' compound_statement - ; - -case_label: - CASE expression ':' - | DEFAULT ':' - ; - -iteration_statement: - WHILE '(' condition ')' statement_no_new_scope - { - $$ = new ast_iteration_statement(ast_iteration_statement::ast_while, - NULL, $3, NULL, $5); - } - | DO statement WHILE '(' expression ')' ';' - { - $$ = new ast_iteration_statement(ast_iteration_statement::ast_do_while, - NULL, $5, NULL, $2); - } - | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope - { - $$ = new ast_iteration_statement(ast_iteration_statement::ast_for, - $3, $4.cond, $4.rest, $6); - } - ; - -for_init_statement: - expression_statement - | declaration_statement - ; - -conditionopt: - condition - | /* empty */ - { - $$ = NULL; - } - ; - -for_rest_statement: - conditionopt ';' - { - $$.cond = $1; - $$.rest = NULL; - } - | conditionopt ';' expression - { - $$.cond = $1; - $$.rest = $3; - } - ; - - // Grammar Note: No 'goto'. Gotos are not supported. -jump_statement: - CONTINUE ';' - { - $$ = new ast_jump_statement(ast_jump_statement::ast_continue, NULL); - } - | BREAK ';' - { - $$ = new ast_jump_statement(ast_jump_statement::ast_break, NULL); - } - | RETURN ';' - { - $$ = new ast_jump_statement(ast_jump_statement::ast_return, NULL); - } - | RETURN expression ';' - { - $$ = new ast_jump_statement(ast_jump_statement::ast_return, $2); - } - | DISCARD ';' // Fragment shader only. - { - $$ = new ast_jump_statement(ast_jump_statement::ast_discard, NULL); - } - ; - -external_declaration: - function_definition { $$ = $1; } - | declaration { $$ = $1; } - ; - -function_definition: - function_prototype compound_statement_no_new_scope - { - $$ = new ast_function_definition(); - $$->prototype = $1; - $$->body = $2; - } - ; diff --git a/glsl_parser.ypp b/glsl_parser.ypp new file mode 100644 index 00000000000..c7557254581 --- /dev/null +++ b/glsl_parser.ypp @@ -0,0 +1,1229 @@ +%{ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "symbol_table.h" +#include "glsl_types.h" + +#define YYLEX_PARAM state->scanner + +%} + +%pure-parser +%locations +%error-verbose + +%lex-param {void *scanner} +%parse-param {struct _mesa_glsl_parse_state *state} +%name-prefix "_mesa_glsl_" + +%union { + int n; + float real; + char *identifier; + + union { + struct ast_type_qualifier q; + unsigned i; + } type_qualifier; + + struct ast_node *node; + struct ast_type_specifier *type_specifier; + struct ast_fully_specified_type *fully_specified_type; + struct ast_function *function; + struct ast_parameter_declarator *parameter_declarator; + struct ast_function_definition *function_definition; + struct ast_compound_statement *compound_statement; + struct ast_expression *expression; + struct ast_declarator_list *declarator_list; + struct ast_struct_specifier *struct_specifier; + struct ast_declaration *declaration; + + struct { + struct ast_node *cond; + struct ast_expression *rest; + } for_rest_statement; +} + +%token ATTRIBUTE CONST BOOL FLOAT INT UINT +%token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT +%token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 +%token MAT2 MAT3 MAT4 CENTROID IN OUT INOUT UNIFORM VARYING +%token NOPERSPECTIVE FLAT SMOOTH +%token MAT2X2 MAT2X3 MAT2X4 +%token MAT3X2 MAT3X3 MAT3X4 +%token MAT4X2 MAT4X3 MAT4X4 +%token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW +%token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW +%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE +%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D +%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY +%token STRUCT VOID WHILE +%token IDENTIFIER TYPE_NAME +%token FLOATCONSTANT +%token INTCONSTANT UINTCONSTANT BOOLCONSTANT +%token FIELD_SELECTION +%token LEFT_OP RIGHT_OP +%token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP +%token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN +%token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN +%token SUB_ASSIGN +%token INVARIANT +%token HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION + +%token VERSION EXTENSION LINE PRAGMA COLON EOL INTERFACE OUTPUT + + /* Reserved words that are not actually used in the grammar. + */ +%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED GOTO +%token INLINE NOINLINE VOLATILE PUBLIC STATIC EXTERN EXTERNAL +%token LONG SHORT DOUBLE HALF FIXED UNSIGNED INPUT OUPTUT +%token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 +%token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW +%token SIZEOF CAST NAMESPACE USING LOWP MEDIUMP HIGHP + +%type variable_identifier +%type statement +%type statement_list +%type simple_statement +%type statement_matched +%type statement_unmatched +%type precision_qualifier +%type type_qualifier +%type storage_qualifier +%type interpolation_qualifier +%type type_specifier +%type type_specifier_no_prec +%type type_specifier_nonarray +%type basic_type_specifier_nonarray +%type fully_specified_type +%type function_prototype +%type function_header +%type function_header_with_parameters +%type function_declarator +%type parameter_declarator +%type parameter_declaration +%type parameter_qualifier +%type parameter_type_qualifier +%type parameter_type_specifier +%type function_definition +%type compound_statement_no_new_scope +%type compound_statement +%type statement_no_new_scope +%type expression_statement +%type expression +%type primary_expression +%type assignment_expression +%type conditional_expression +%type logical_or_expression +%type logical_xor_expression +%type logical_and_expression +%type inclusive_or_expression +%type exclusive_or_expression +%type and_expression +%type equality_expression +%type relational_expression +%type shift_expression +%type additive_expression +%type multiplicative_expression +%type unary_expression +%type constant_expression +%type integer_expression +%type postfix_expression +%type function_call_header_with_parameters +%type function_call_header_no_parameters +%type function_call_header +%type function_call_generic +%type function_call_or_method +%type function_call +%type assignment_operator +%type unary_operator +%type function_identifier +%type external_declaration +%type init_declarator_list +%type single_declaration +%type initializer +%type declaration +%type declaration_statement +%type jump_statement +%type struct_specifier +%type struct_declaration_list +%type struct_declaration +%type struct_declarator +%type struct_declarator_list +%type selection_statement_matched +%type selection_statement_unmatched +%type iteration_statement +%type condition +%type conditionopt +%type for_init_statement +%type for_rest_statement +%% + +translation_unit: + version_statement + { + _mesa_glsl_initialize_types(state); + } + external_declaration_list + | + { + state->language_version = 110; + _mesa_glsl_initialize_types(state); + } + external_declaration_list + ; + +version_statement: + VERSION INTCONSTANT EOL + { + switch ($2) { + case 110: + case 120: + case 130: + /* FINISHME: Check against implementation support versions. */ + state->language_version = $2; + break; + default: + _mesa_glsl_error(& @2, state, "Shading language version" + "%u is not supported\n", $2); + break; + } + } + ; + +external_declaration_list: + external_declaration + { + insert_at_tail(& state->translation_unit, + (struct simple_node *) $1); + } + | external_declaration_list external_declaration + { + insert_at_tail(& state->translation_unit, + (struct simple_node *) $2); + } + ; + +variable_identifier: + IDENTIFIER + ; + +primary_expression: + variable_identifier + { + $$ = new ast_expression(ast_identifier, NULL, NULL, NULL); + $$->primary_expression.identifier = $1; + } + | INTCONSTANT + { + $$ = new ast_expression(ast_int_constant, NULL, NULL, NULL); + $$->primary_expression.int_constant = $1; + } + | UINTCONSTANT + { + $$ = new ast_expression(ast_uint_constant, NULL, NULL, NULL); + $$->primary_expression.uint_constant = $1; + } + | FLOATCONSTANT + { + $$ = new ast_expression(ast_float_constant, NULL, NULL, NULL); + $$->primary_expression.float_constant = $1; + } + | BOOLCONSTANT + { + $$ = new ast_expression(ast_bool_constant, NULL, NULL, NULL); + $$->primary_expression.bool_constant = $1; + } + | '(' expression ')' + { + $$ = $2; + } + ; + +postfix_expression: + primary_expression + | postfix_expression '[' integer_expression ']' + { + $$ = new ast_expression(ast_array_index, $1, $3, NULL); + } + | function_call + { + $$ = $1; + } + | postfix_expression '.' IDENTIFIER + { + $$ = new ast_expression(ast_field_selection, $1, NULL, NULL); + $$->primary_expression.identifier = $3; + } + | postfix_expression INC_OP + { + $$ = new ast_expression(ast_post_inc, $1, NULL, NULL); + } + | postfix_expression DEC_OP + { + $$ = new ast_expression(ast_post_dec, $1, NULL, NULL); + } + ; + +integer_expression: + expression + ; + +function_call: + function_call_or_method + ; + +function_call_or_method: + function_call_generic + | postfix_expression '.' function_call_generic + { + $$ = new ast_expression(ast_field_selection, $1, $3, NULL); + } + ; + +function_call_generic: + function_call_header_with_parameters ')' + | function_call_header_no_parameters ')' + ; + +function_call_header_no_parameters: + function_call_header VOID + | function_call_header + ; + +function_call_header_with_parameters: + function_call_header assignment_expression + { + $$ = $1; + $$->subexpressions[1] = $2; + } + | function_call_header_with_parameters ',' assignment_expression + { + $$ = $1; + insert_at_tail((struct simple_node *) $$->subexpressions[1], + (struct simple_node *) $3); + } + ; + + // Grammar Note: Constructors look like functions, but lexical + // analysis recognized most of them as keywords. They are now + // recognized through "type_specifier". +function_call_header: + function_identifier '(' + { + $$ = new ast_expression(ast_function_call, + (struct ast_expression *) $1, + NULL, NULL); + } + ; + +function_identifier: + type_specifier + { + $$ = (struct ast_node *) $1; + } + | IDENTIFIER + { + ast_expression *expr = + new ast_expression(ast_identifier, NULL, NULL, NULL); + expr->primary_expression.identifier = $1; + + $$ = (struct ast_node *) expr; + } + | FIELD_SELECTION + { + ast_expression *expr = + new ast_expression(ast_identifier, NULL, NULL, NULL); + expr->primary_expression.identifier = $1; + + $$ = (struct ast_node *) expr; + } + ; + + // Grammar Note: No traditional style type casts. +unary_expression: + postfix_expression + | INC_OP unary_expression + { + $$ = new ast_expression(ast_pre_inc, $2, NULL, NULL); + } + | DEC_OP unary_expression + { + $$ = new ast_expression(ast_pre_dec, $2, NULL, NULL); + } + | unary_operator unary_expression + { + $$ = new ast_expression($1, $2, NULL, NULL); + } + ; + + // Grammar Note: No '*' or '&' unary ops. Pointers are not supported. +unary_operator: + '+' { $$ = ast_plus; } + | '-' { $$ = ast_neg; } + | '!' { $$ = ast_logic_not; } + | '~' { $$ = ast_bit_not; } + ; + +multiplicative_expression: + unary_expression + | multiplicative_expression '*' unary_expression + { + $$ = new ast_expression_bin(ast_mul, $1, $3); + } + | multiplicative_expression '/' unary_expression + { + $$ = new ast_expression_bin(ast_div, $1, $3); + } + | multiplicative_expression '%' unary_expression + { + $$ = new ast_expression_bin(ast_mod, $1, $3); + } + ; + +additive_expression: + multiplicative_expression + | additive_expression '+' multiplicative_expression + { + $$ = new ast_expression_bin(ast_add, $1, $3); + } + | additive_expression '-' multiplicative_expression + { + $$ = new ast_expression_bin(ast_sub, $1, $3); + } + ; + +shift_expression: + additive_expression + | shift_expression LEFT_OP additive_expression + { + $$ = new ast_expression_bin(ast_lshift, $1, $3); + } + | shift_expression RIGHT_OP additive_expression + { + $$ = new ast_expression_bin(ast_rshift, $1, $3); + } + ; + +relational_expression: + shift_expression + | relational_expression '<' shift_expression + { + $$ = new ast_expression_bin(ast_less, $1, $3); + } + | relational_expression '>' shift_expression + { + $$ = new ast_expression_bin(ast_greater, $1, $3); + } + | relational_expression LE_OP shift_expression + { + $$ = new ast_expression_bin(ast_lequal, $1, $3); + } + | relational_expression GE_OP shift_expression + { + $$ = new ast_expression_bin(ast_gequal, $1, $3); + } + ; + +equality_expression: + relational_expression + | equality_expression EQ_OP relational_expression + { + $$ = new ast_expression_bin(ast_equal, $1, $3); + } + | equality_expression NE_OP relational_expression + { + $$ = new ast_expression_bin(ast_nequal, $1, $3); + } + ; + +and_expression: + equality_expression + | and_expression '&' equality_expression + { + $$ = new ast_expression_bin(ast_bit_or, $1, $3); + } + ; + +exclusive_or_expression: + and_expression + | exclusive_or_expression '^' and_expression + { + $$ = new ast_expression_bin(ast_bit_xor, $1, $3); + } + ; + +inclusive_or_expression: + exclusive_or_expression + | inclusive_or_expression '|' exclusive_or_expression + { + $$ = new ast_expression_bin(ast_bit_or, $1, $3); + } + ; + +logical_and_expression: + inclusive_or_expression + | logical_and_expression AND_OP inclusive_or_expression + { + $$ = new ast_expression_bin(ast_logic_and, $1, $3); + } + ; + +logical_xor_expression: + logical_and_expression + | logical_xor_expression XOR_OP logical_and_expression + { + $$ = new ast_expression_bin(ast_logic_xor, $1, $3); + } + ; + +logical_or_expression: + logical_xor_expression + | logical_or_expression OR_OP logical_xor_expression + { + $$ = new ast_expression_bin(ast_logic_or, $1, $3); + } + ; + +conditional_expression: + logical_or_expression + | logical_or_expression '?' expression ':' assignment_expression + { + $$ = new ast_expression(ast_conditional, $1, $3, $5); + } + ; + +assignment_expression: + conditional_expression + | unary_expression assignment_operator assignment_expression + { + $$ = new ast_expression($2, $1, $3, NULL); + } + ; + +assignment_operator: + '=' { $$ = ast_assign; } + | MUL_ASSIGN { $$ = ast_mul_assign; } + | DIV_ASSIGN { $$ = ast_div_assign; } + | MOD_ASSIGN { $$ = ast_mod_assign; } + | ADD_ASSIGN { $$ = ast_add_assign; } + | SUB_ASSIGN { $$ = ast_sub_assign; } + | LEFT_ASSIGN { $$ = ast_ls_assign; } + | RIGHT_ASSIGN { $$ = ast_rs_assign; } + | AND_ASSIGN { $$ = ast_and_assign; } + | XOR_ASSIGN { $$ = ast_xor_assign; } + | OR_ASSIGN { $$ = ast_or_assign; } + ; + +expression: + assignment_expression + { + $$ = $1; + } + | expression ',' assignment_expression + { + if ($1->oper != ast_sequence) { + $$ = new ast_expression(ast_sequence, NULL, NULL, NULL); + insert_at_tail(& $$->expressions, $1); + } else { + $$ = $1; + } + + insert_at_tail(& $$->expressions, $3); + } + ; + +constant_expression: + conditional_expression + ; + +declaration: + function_prototype ';' + { + $$ = $1; + } + | init_declarator_list ';' + { + $$ = $1; + } + | PRECISION precision_qualifier type_specifier_no_prec ';' + { + $$ = NULL; /* FINISHME */ + } + ; + +function_prototype: + function_declarator ')' + ; + +function_declarator: + function_header + | function_header_with_parameters + ; + +function_header_with_parameters: + function_header parameter_declaration + { + $$ = $1; + insert_at_head(& $$->parameters, + (struct simple_node *) $2); + } + | function_header_with_parameters ',' parameter_declaration + { + $$ = $1; + insert_at_head(& $$->parameters, + (struct simple_node *) $3); + } + ; + +function_header: + fully_specified_type IDENTIFIER '(' + { + $$ = new ast_function(); + $$->return_type = $1; + $$->identifier = $2; + } + ; + +parameter_declarator: + type_specifier IDENTIFIER + { + $$ = new ast_parameter_declarator(); + $$->type = new ast_fully_specified_type(); + $$->type->specifier = $1; + $$->identifier = $2; + } + | type_specifier IDENTIFIER '[' constant_expression ']' + { + $$ = new ast_parameter_declarator(); + $$->type = new ast_fully_specified_type(); + $$->type->specifier = $1; + $$->identifier = $2; + $$->is_array = true; + $$->array_size = $4; + } + ; + +parameter_declaration: + parameter_type_qualifier parameter_qualifier parameter_declarator + { + $1.i |= $2.i; + + $$ = $3; + $$->type->qualifier = $1.q; + } + | parameter_qualifier parameter_declarator + { + $$ = $2; + $$->type->qualifier = $1.q; + } + | parameter_type_qualifier parameter_qualifier parameter_type_specifier + { + $1.i |= $2.i; + + $$ = new ast_parameter_declarator(); + $$->type = new ast_fully_specified_type(); + $$->type->qualifier = $1.q; + $$->type->specifier = $3; + } + | parameter_qualifier parameter_type_specifier + { + $$ = new ast_parameter_declarator(); + $$->type = new ast_fully_specified_type(); + $$->type->qualifier = $1.q; + $$->type->specifier = $2; + } + ; + +parameter_qualifier: + /* empty */ { $$.i = 0; } + | IN { $$.i = 0; $$.q.in = 1; } + | OUT { $$.i = 0; $$.q.out = 1; } + | INOUT { $$.i = 0; $$.q.in = 1; $$.q.out = 1; } + ; + +parameter_type_specifier: + type_specifier + ; + +init_declarator_list: + single_declaration + | init_declarator_list ',' IDENTIFIER + { + ast_declaration *decl = new ast_declaration($3, false, NULL, NULL); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | init_declarator_list ',' IDENTIFIER '[' ']' + { + ast_declaration *decl = new ast_declaration($3, true, NULL, NULL); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' + { + ast_declaration *decl = new ast_declaration($3, true, $5, NULL); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer + { + ast_declaration *decl = new ast_declaration($3, true, NULL, $7); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer + { + ast_declaration *decl = new ast_declaration($3, true, $5, $8); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | init_declarator_list ',' IDENTIFIER '=' initializer + { + ast_declaration *decl = new ast_declaration($3, false, NULL, $5); + + $$ = $1; + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + ; + + // Grammar Note: No 'enum', or 'typedef'. +single_declaration: + fully_specified_type + { + $$ = new ast_declarator_list($1); + } + | fully_specified_type IDENTIFIER + { + ast_declaration *decl = new ast_declaration($2, false, NULL, NULL); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | fully_specified_type IDENTIFIER '[' ']' + { + ast_declaration *decl = new ast_declaration($2, true, NULL, NULL); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | fully_specified_type IDENTIFIER '[' constant_expression ']' + { + ast_declaration *decl = new ast_declaration($2, true, $4, NULL); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | fully_specified_type IDENTIFIER '[' ']' '=' initializer + { + ast_declaration *decl = new ast_declaration($2, true, NULL, $6); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer + { + ast_declaration *decl = new ast_declaration($2, true, $4, $7); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | fully_specified_type IDENTIFIER '=' initializer + { + ast_declaration *decl = new ast_declaration($2, false, NULL, $4); + + $$ = new ast_declarator_list($1); + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + | INVARIANT IDENTIFIER // Vertex only. + { + ast_declaration *decl = new ast_declaration($2, false, NULL, NULL); + + $$ = new ast_declarator_list(NULL); + $$->invariant = true; + + insert_at_tail(& $$->declarations, + (struct simple_node *) decl); + } + ; + +fully_specified_type: + type_specifier + { + $$ = new ast_fully_specified_type(); + $$->specifier = $1; + } + | type_qualifier type_specifier + { + $$ = new ast_fully_specified_type(); + $$->qualifier = $1.q; + $$->specifier = $2; + } + ; + +interpolation_qualifier: + SMOOTH { $$.i = 0; $$.q.smooth = 1; } + | FLAT { $$.i = 0; $$.q.flat = 1; } + | NOPERSPECTIVE { $$.i = 0; $$.q.noperspective = 1; } + ; + +parameter_type_qualifier: + CONST { $$.i = 0; $$.q.constant = 1; } + ; + +type_qualifier: + storage_qualifier + | interpolation_qualifier type_qualifier + { + $$.i = $1.i | $2.i; + } + | INVARIANT type_qualifier + { + $$ = $2; + $$.q.invariant = 1; + } + ; + +storage_qualifier: + CONST { $$.i = 0; $$.q.constant = 1; } + | ATTRIBUTE { $$.i = 0; $$.q.attribute = 1; } + | VARYING { $$.i = 0; $$.q.varying = 1; } + | CENTROID VARYING { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; } + | IN { $$.i = 0; $$.q.in = 1; } + | OUT { $$.i = 0; $$.q.out = 1; } + | CENTROID IN { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; } + | CENTROID OUT { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; } + | UNIFORM { $$.i = 0; $$.q.uniform = 1; } + ; + +type_specifier: + type_specifier_no_prec + | precision_qualifier type_specifier_no_prec + { + $$ = $2; + $$->precision = $1; + } + ; + +type_specifier_no_prec: + type_specifier_nonarray + | type_specifier_nonarray '[' ']' + { + $$ = $1; + $$->is_array = true; + $$->array_size = NULL; + } + | type_specifier_nonarray '[' constant_expression ']' + { + $$ = $1; + $$->is_array = true; + $$->array_size = $3; + } + ; + +type_specifier_nonarray: + basic_type_specifier_nonarray + { + $$ = new ast_type_specifier($1); + } + | struct_specifier + { + $$ = new ast_type_specifier(ast_struct); + $$->structure = $1; + } + | TYPE_NAME + { + $$ = new ast_type_specifier(ast_type_name); + $$->type_name = $1; + } + ; + +basic_type_specifier_nonarray: + VOID { $$ = ast_void; } + | FLOAT { $$ = ast_float; } + | INT { $$ = ast_int; } + | UINT { $$ = ast_uint; } + | BOOL { $$ = ast_bool; } + | VEC2 { $$ = ast_vec2; } + | VEC3 { $$ = ast_vec3; } + | VEC4 { $$ = ast_vec4; } + | BVEC2 { $$ = ast_bvec2; } + | BVEC3 { $$ = ast_bvec3; } + | BVEC4 { $$ = ast_bvec4; } + | IVEC2 { $$ = ast_ivec2; } + | IVEC3 { $$ = ast_ivec3; } + | IVEC4 { $$ = ast_ivec4; } + | UVEC2 { $$ = ast_uvec2; } + | UVEC3 { $$ = ast_uvec3; } + | UVEC4 { $$ = ast_uvec4; } + | MAT2 { $$ = ast_mat2; } + | MAT3 { $$ = ast_mat3; } + | MAT4 { $$ = ast_mat4; } + | MAT2X2 { $$ = ast_mat2; } + | MAT2X3 { $$ = ast_mat2x3; } + | MAT2X4 { $$ = ast_mat2x4; } + | MAT3X2 { $$ = ast_mat3x2; } + | MAT3X3 { $$ = ast_mat3; } + | MAT3X4 { $$ = ast_mat3x4; } + | MAT4X2 { $$ = ast_mat4x2; } + | MAT4X3 { $$ = ast_mat4x3; } + | MAT4X4 { $$ = ast_mat4; } + | SAMPLER1D { $$ = ast_sampler1d; } + | SAMPLER2D { $$ = ast_sampler2d; } + | SAMPLER3D { $$ = ast_sampler3d; } + | SAMPLERCUBE { $$ = ast_samplercube; } + | SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; } + | SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; } + | SAMPLERCUBESHADOW { $$ = ast_samplercubeshadow; } + | SAMPLER1DARRAY { $$ = ast_sampler1darray; } + | SAMPLER2DARRAY { $$ = ast_sampler2darray; } + | SAMPLER1DARRAYSHADOW { $$ = ast_sampler1darrayshadow; } + | SAMPLER2DARRAYSHADOW { $$ = ast_sampler2darrayshadow; } + | ISAMPLER1D { $$ = ast_isampler1d; } + | ISAMPLER2D { $$ = ast_isampler2d; } + | ISAMPLER3D { $$ = ast_isampler3d; } + | ISAMPLERCUBE { $$ = ast_isamplercube; } + | ISAMPLER1DARRAY { $$ = ast_isampler1darray; } + | ISAMPLER2DARRAY { $$ = ast_isampler2darray; } + | USAMPLER1D { $$ = ast_usampler1d; } + | USAMPLER2D { $$ = ast_usampler2d; } + | USAMPLER3D { $$ = ast_usampler3d; } + | USAMPLERCUBE { $$ = ast_usamplercube; } + | USAMPLER1DARRAY { $$ = ast_usampler1darray; } + | USAMPLER2DARRAY { $$ = ast_usampler2darray; } + ; + +precision_qualifier: + HIGH_PRECISION { $$ = ast_precision_high; } + | MEDIUM_PRECISION { $$ = ast_precision_medium; } + | LOW_PRECISION { $$ = ast_precision_low; } + ; + +struct_specifier: + STRUCT IDENTIFIER '{' struct_declaration_list '}' + { + $$ = new ast_struct_specifier($2, $4); + + _mesa_symbol_table_add_symbol(state->symbols, 0, $2, $$); + } + | STRUCT '{' struct_declaration_list '}' + { + $$ = new ast_struct_specifier(NULL, $3); + } + ; + +struct_declaration_list: + struct_declaration + { + $$ = (struct ast_node *) $1; + } + | struct_declaration_list struct_declaration + { + $$ = (struct ast_node *) $1; + insert_at_tail((struct simple_node *) $$, + (struct simple_node *) $2); + } + ; + +struct_declaration: + type_specifier struct_declarator_list ';' + { + ast_fully_specified_type *type = new ast_fully_specified_type(); + + type->specifier = $1; + $$ = new ast_declarator_list(type); + + insert_at_tail((struct simple_node *) $2, + & $$->declarations); + } + ; + +struct_declarator_list: + struct_declarator + | struct_declarator_list ',' struct_declarator + { + $$ = $1; + insert_at_tail((struct simple_node *) $$, + (struct simple_node *) $3); + } + ; + +struct_declarator: + IDENTIFIER + { + $$ = new ast_declaration($1, false, NULL, NULL); + } + | IDENTIFIER '[' constant_expression ']' + { + $$ = new ast_declaration($1, true, $3, NULL); + } + ; + +initializer: + assignment_expression + ; + +declaration_statement: + declaration + ; + + // Grammar Note: labeled statements for SWITCH only; 'goto' is not + // supported. +statement: + statement_matched + | statement_unmatched + ; + +statement_matched: + compound_statement { $$ = (struct ast_node *) $1; } + | simple_statement + ; + +statement_unmatched: + selection_statement_unmatched + ; + +simple_statement: + declaration_statement + | expression_statement + | selection_statement_matched + | switch_statement { $$ = NULL; } + | case_label { $$ = NULL; } + | iteration_statement + | jump_statement + ; + +compound_statement: + '{' '}' + { + $$ = new ast_compound_statement(true, NULL); + } + | '{' statement_list '}' + { + $$ = new ast_compound_statement(true, $2); + } + ; + +statement_no_new_scope: + compound_statement_no_new_scope { $$ = (struct ast_node *) $1; } + | simple_statement + ; + +compound_statement_no_new_scope: + '{' '}' + { + $$ = new ast_compound_statement(false, NULL); + } + | '{' statement_list '}' + { + $$ = new ast_compound_statement(false, $2); + } + ; + +statement_list: + statement + { + if ($1 == NULL) { + _mesa_glsl_error(& @1, state, " statement\n"); + assert($1 != NULL); + } + + $$ = $1; + make_empty_list((struct simple_node *) $$); + } + | statement_list statement + { + if ($2 == NULL) { + _mesa_glsl_error(& @2, state, " statement\n"); + assert($2 != NULL); + } + $$ = $1; + insert_at_tail((struct simple_node *) $$, + (struct simple_node *) $2); + } + ; + +expression_statement: + ';' + { + $$ = new ast_expression_statement(NULL); + } + | expression ';' + { + $$ = new ast_expression_statement($1); + } + ; + +selection_statement_matched: + IF '(' expression ')' statement_matched ELSE statement_matched + { + $$ = new ast_selection_statement($3, $5, $7); + } + ; + +selection_statement_unmatched: + IF '(' expression ')' statement_matched + { + $$ = new ast_selection_statement($3, $5, NULL); + } + | IF '(' expression ')' statement_unmatched + { + $$ = new ast_selection_statement($3, $5, NULL); + } + | IF '(' expression ')' statement_matched ELSE statement_unmatched + { + $$ = new ast_selection_statement($3, $5, $7); + } + ; + +condition: + expression + { + $$ = (struct ast_node *) $1; + } + | fully_specified_type IDENTIFIER '=' initializer + { + ast_declaration *decl = new ast_declaration($2, false, NULL, $4); + ast_declarator_list *declarator = new ast_declarator_list($1); + + insert_at_tail(& declarator->declarations, + (struct simple_node *) decl); + + $$ = declarator; + } + ; + +switch_statement: + SWITCH '(' expression ')' compound_statement + ; + +case_label: + CASE expression ':' + | DEFAULT ':' + ; + +iteration_statement: + WHILE '(' condition ')' statement_no_new_scope + { + $$ = new ast_iteration_statement(ast_iteration_statement::ast_while, + NULL, $3, NULL, $5); + } + | DO statement WHILE '(' expression ')' ';' + { + $$ = new ast_iteration_statement(ast_iteration_statement::ast_do_while, + NULL, $5, NULL, $2); + } + | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope + { + $$ = new ast_iteration_statement(ast_iteration_statement::ast_for, + $3, $4.cond, $4.rest, $6); + } + ; + +for_init_statement: + expression_statement + | declaration_statement + ; + +conditionopt: + condition + | /* empty */ + { + $$ = NULL; + } + ; + +for_rest_statement: + conditionopt ';' + { + $$.cond = $1; + $$.rest = NULL; + } + | conditionopt ';' expression + { + $$.cond = $1; + $$.rest = $3; + } + ; + + // Grammar Note: No 'goto'. Gotos are not supported. +jump_statement: + CONTINUE ';' + { + $$ = new ast_jump_statement(ast_jump_statement::ast_continue, NULL); + } + | BREAK ';' + { + $$ = new ast_jump_statement(ast_jump_statement::ast_break, NULL); + } + | RETURN ';' + { + $$ = new ast_jump_statement(ast_jump_statement::ast_return, NULL); + } + | RETURN expression ';' + { + $$ = new ast_jump_statement(ast_jump_statement::ast_return, $2); + } + | DISCARD ';' // Fragment shader only. + { + $$ = new ast_jump_statement(ast_jump_statement::ast_discard, NULL); + } + ; + +external_declaration: + function_definition { $$ = $1; } + | declaration { $$ = $1; } + ; + +function_definition: + function_prototype compound_statement_no_new_scope + { + $$ = new ast_function_definition(); + $$->prototype = $1; + $$->body = $2; + } + ; diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 54d510c1a19..f30b7d8eb6c 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -33,7 +33,7 @@ #include "ast.h" #include "glsl_parser_extras.h" -#include "glsl_parser.tab.h" +#include "glsl_parser.h" #include "symbol_table.h" void -- cgit v1.2.3 From 18238de6c34a1a32c452f1006ed13d8adc1bc9d7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 1 Mar 2010 13:49:10 -0800 Subject: Make AST->HIR conversion a method of ast_node, re-enable --- Makefile.am | 3 +- ast.h | 20 +++++ ast_to_hir.cpp | 211 ++++++++++++++++++++++++------------------------ glsl_parser_extras.cpp | 4 +- hir_field_selection.cpp | 2 +- 5 files changed, 127 insertions(+), 113 deletions(-) diff --git a/Makefile.am b/Makefile.am index 28d9c3c7a1d..1fc8aa97a27 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,8 +25,7 @@ AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = glsl glsl_SOURCES = symbol_table.c hash_table.c glsl_types.c \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ - ast_expr.cpp -# ast_to_hir.cpp ir.cpp hir_field_selection.cpp + ast_expr.cpp ast_to_hir.cpp ir.cpp hir_field_selection.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h diff --git a/ast.h b/ast.h index b04cf75c371..59bc4fb0b5e 100644 --- a/ast.h +++ b/ast.h @@ -37,6 +37,8 @@ class ast_node : public simple_node { public: virtual ~ast_node(); virtual void print(void) const; + virtual ir_instruction *hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); /** * Retrieve the source location of an AST node @@ -149,6 +151,9 @@ public: static const char *operator_string(enum ast_operators op); + virtual ir_instruction *hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + virtual void print(void) const; enum ast_operators oper; @@ -193,6 +198,9 @@ public: ast_compound_statement(int new_scope, ast_node *statements); virtual void print(void) const; + virtual ir_instruction *hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + int new_scope; struct simple_node statements; }; @@ -330,6 +338,9 @@ public: ast_declarator_list(ast_fully_specified_type *); virtual void print(void) const; + virtual ir_instruction *hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + ast_fully_specified_type *type; struct simple_node declarations; @@ -348,6 +359,9 @@ class ast_parameter_declarator : public ast_node { public: virtual void print(void) const; + virtual ir_instruction *hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + ast_fully_specified_type *type; char *identifier; int is_array; @@ -392,6 +406,9 @@ public: ast_expression_statement(ast_expression *); virtual void print(void) const; + virtual ir_instruction *hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + ast_expression *expression; }; @@ -466,6 +483,9 @@ class ast_function_definition : public ast_node { public: virtual void print(void) const; + virtual ir_instruction *hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state); + ast_function *prototype; ast_compound_statement *body; }; diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 8474a461ce2..e7f21ee2524 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -207,7 +207,8 @@ arithmetic_result_type(const struct glsl_type *type_a, type_name[6] = '\0'; } - t = _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); + t = (glsl_type *) + _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); return (t != NULL) ? t : glsl_error_type; } } else if (is_glsl_type_matrix(type_a)) { @@ -328,13 +329,21 @@ relational_result_type(const struct glsl_type *type_a, } -struct ir_instruction * -ast_expression_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) +ir_instruction * +ast_node::hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) +{ + (void) instructions; + (void) state; + + return NULL; +} + + +ir_instruction * +ast_expression::hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) { - const struct ast_expression *expr = - (struct ast_expression *) ast; static const int operations[AST_NUM_OPERATORS] = { -1, /* ast_assign doesn't convert to ir_expression. */ -1, /* ast_plus doesn't convert to ir_expression. */ @@ -390,20 +399,20 @@ ast_expression_to_hir(const struct ast_node *ast, -1, /* ast_bool_constant doesn't conv to ir_expression. */ -1, /* ast_sequence doesn't convert to ir_expression. */ }; - struct ir_instruction *result = NULL; - struct ir_instruction *op[2]; + ir_instruction *result = NULL; + ir_instruction *op[2]; struct simple_node op_list; const struct glsl_type *type = glsl_error_type; bool error_emitted = false; YYLTYPE loc; - loc = ast->get_location(); + loc = this->get_location(); make_empty_list(& op_list); - switch (expr->oper) { + switch (this->oper) { case ast_assign: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); error_emitted = ((op[0]->type == glsl_error_type) || (op[1]->type == glsl_error_type)); @@ -413,7 +422,7 @@ ast_expression_to_hir(const struct ast_node *ast, YYLTYPE loc; /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ - loc = expr->subexpressions[0]->get_location(); + loc = this->subexpressions[0]->get_location(); if (op[0]->mode != ir_op_dereference) { _mesa_glsl_error(& loc, state, "invalid lvalue in assignment"); error_emitted = true; @@ -444,7 +453,7 @@ ast_expression_to_hir(const struct ast_node *ast, break; case ast_plus: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[0] = this->subexpressions[0]->hir(instructions, state); error_emitted = (op[0]->type == glsl_error_type); if (type == glsl_error_type) @@ -454,13 +463,13 @@ ast_expression_to_hir(const struct ast_node *ast, break; case ast_neg: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op[0] = this->subexpressions[0]->hir(instructions, state); type = unary_arithmetic_result_type(op[0]->type); error_emitted = (op[0]->type == glsl_error_type); - result = new ir_expression(operations[expr->oper], type, + result = new ir_expression(operations[this->oper], type, op[0], NULL); break; @@ -468,29 +477,29 @@ ast_expression_to_hir(const struct ast_node *ast, case ast_sub: case ast_mul: case ast_div: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); type = arithmetic_result_type(op[0]->type, op[1]->type, - (expr->operr == ast_mul), + (this->oper == ast_mul), state); - result = new ir_expression(operations[expr->oper], type, + result = new ir_expression(operations[this->oper], type, op[0], op[1]); break; case ast_mod: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); error_emitted = ((op[0]->type == glsl_error_type) || (op[1]->type == glsl_error_type)); type = modulus_result_type(op[0]->type, op[1]->type); - assert(operations[expr->oper] == ir_binop_mod); + assert(operations[this->oper] == ir_binop_mod); - result = new ir_expression(operations[expr->oper], type, + result = new ir_expression(operations[this->oper], type, op[0], op[1]); break; @@ -503,8 +512,8 @@ ast_expression_to_hir(const struct ast_node *ast, case ast_greater: case ast_lequal: case ast_gequal: - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); error_emitted = ((op[0]->type == glsl_error_type) || (op[1]->type == glsl_error_type)); @@ -518,7 +527,7 @@ ast_expression_to_hir(const struct ast_node *ast, || ((type->base_type == GLSL_TYPE_BOOL) && is_glsl_type_scalar(type))); - result = new ir_expression(operations[expr->oper], type, + result = new ir_expression(operations[this->oper], type, op[0], op[1]); break; @@ -547,17 +556,17 @@ ast_expression_to_hir(const struct ast_node *ast, case ast_sub_assign: { struct ir_instruction *temp_rhs; - op[0] = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); - op[1] = _mesa_ast_to_hir(expr->subexpressions[1], instructions, state); + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); error_emitted = ((op[0]->type == glsl_error_type) || (op[1]->type == glsl_error_type)); type = arithmetic_result_type(op[0]->type, op[1]->type, - (expr->oper == ast_mul_assign), + (this->oper == ast_mul_assign), state); - temp_rhs = new ir_expression(operations[expr->oper], type, + temp_rhs = new ir_expression(operations[this->oper], type, op[0], op[1]); /* FINISHME: Check that the LHS is assignable. */ @@ -608,7 +617,7 @@ ast_expression_to_hir(const struct ast_node *ast, break; case ast_field_selection: - result = _mesa_ast_field_selection_to_hir(expr, instructions, state); + result = _mesa_ast_field_selection_to_hir(this, instructions, state); type = result->type; break; @@ -625,10 +634,12 @@ ast_expression_to_hir(const struct ast_node *ast, * Method calls are actually detected when the ast_field_selection * expression is handled. */ - result = _mesa_ast_function_call_to_hir(expr->subexpressions[0], - expr->subexpressions[1], +#if 0 + result = _mesa_ast_function_call_to_hir(this->subexpressions[0], + this->subexpressions[1], state); type = result->type; +#endif break; case ast_identifier: { @@ -636,9 +647,9 @@ ast_expression_to_hir(const struct ast_node *ast, * tree. This particular use must be at location specified in the grammar * as 'variable_identifier'. */ - struct ir_variable *var = + ir_variable *var = (ir_variable *) _mesa_symbol_table_find_symbol(state->symbols, 0, - expr->primary_expression.identifier); + this->primary_expression.identifier); result = new ir_dereference(var); @@ -646,7 +657,7 @@ ast_expression_to_hir(const struct ast_node *ast, type = result->type; } else { _mesa_glsl_error(& loc, NULL, "`%s' undeclared", - expr->primary_expression.identifier); + this->primary_expression.identifier); error_emitted = true; } @@ -655,22 +666,22 @@ ast_expression_to_hir(const struct ast_node *ast, case ast_int_constant: type = glsl_int_type; - result = new ir_constant(type, & expr->primary_expression); + result = new ir_constant(type, & this->primary_expression); break; case ast_uint_constant: type = glsl_uint_type; - result = new ir_constant(type, & expr->primary_expression); + result = new ir_constant(type, & this->primary_expression); break; case ast_float_constant: type = glsl_float_type; - result = new ir_constant(type, & expr->primary_expression); + result = new ir_constant(type, & this->primary_expression); break; case ast_bool_constant: type = glsl_bool_type; - result = new ir_constant(type, & expr->primary_expression); + result = new ir_constant(type, & this->primary_expression); break; case ast_sequence: { @@ -679,15 +690,15 @@ ast_expression_to_hir(const struct ast_node *ast, /* It should not be possible to generate a sequence in the AST without * any expressions in it. */ - assert(!is_empty_list(&expr->expressions)); + assert(!is_empty_list(&this->expressions)); /* The r-value of a sequence is the last expression in the sequence. If * the other expressions in the sequence do not have side-effects (and * therefore add instructions to the instruction list), they get dropped * on the floor. */ - foreach (ptr, &expr->expressions) - result = _mesa_ast_to_hir(ptr, instructions, state); + foreach (ptr, &this->expressions) + result = ((ast_node *)ptr)->hir(instructions, state); type = result->type; @@ -705,14 +716,10 @@ ast_expression_to_hir(const struct ast_node *ast, } -struct ir_instruction * -ast_expression_statement_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) +ir_instruction * +ast_expression_statement::hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) { - const struct ast_expression_statement *stmt = - (struct ast_expression_statement *) ast; - /* It is possible to have expression statements that don't have an * expression. This is the solitary semicolon: * @@ -722,8 +729,8 @@ ast_expression_statement_to_hir(const struct ast_node *ast, * In this case the expression will be NULL. Test for NULL and don't do * anything in that case. */ - if (stmt->expression != NULL) - _mesa_ast_to_hir(stmt->expression, instructions, state); + if (expression != NULL) + expression->hir(instructions, state); /* Statements do not have r-values. */ @@ -731,23 +738,20 @@ ast_expression_statement_to_hir(const struct ast_node *ast, } -struct ir_instruction * -ast_compound_statement_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) +ir_instruction * +ast_compound_statement::hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) { - const struct ast_compound_statement *stmt = - (struct ast_compound_statement *) ast; struct simple_node *ptr; - if (stmt->new_scope) + if (new_scope) _mesa_symbol_table_push_scope(state->symbols); - foreach (ptr, &stmt->statements) - _mesa_ast_to_hir(ptr, instructions, state); + foreach (ptr, &statements) + ((ast_node *)ptr)->hir(instructions, state); - if (stmt->new_scope) + if (new_scope) _mesa_symbol_table_pop_scope(state->symbols); /* Compound statements do not have r-values. @@ -825,7 +829,8 @@ type_specifier_to_glsl_type(const struct ast_type_specifier *spec, type_name = (spec->type_specifier == ast_type_name) ? spec->type_name : type_names[spec->type_specifier]; - type = _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); + type = (glsl_type *) + _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); *name = type_name; /* FINISHME: Handle array declarations. Note that this requires complete @@ -874,12 +879,10 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, } -struct ir_instruction * -ast_declarator_list_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) +ir_instruction * +ast_declarator_list::hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) { - const struct ast_declarator_list *dlist = (struct ast_declarator_list *) ast; struct simple_node *ptr; const struct glsl_type *decl_type; const char *type_name = NULL; @@ -890,10 +893,10 @@ ast_declarator_list_to_hir(const struct ast_node *ast, * FINISHME: invariant. */ - decl_type = type_specifier_to_glsl_type(dlist->type->specifier, + decl_type = type_specifier_to_glsl_type(this->type->specifier, & type_name, state); - foreach (ptr, &dlist->declarations) { + foreach (ptr, &this->declarations) { struct ast_declaration *const decl = (struct ast_declaration * )ptr; const struct glsl_type *var_type; struct ir_variable *var; @@ -906,7 +909,7 @@ ast_declarator_list_to_hir(const struct ast_node *ast, if (decl_type == NULL) { YYLTYPE loc; - loc = ast->get_location(); + loc = this->get_location(); if (type_name != NULL) { _mesa_glsl_error(& loc, state, "invalid type `%s' in declaration of `%s'", @@ -936,14 +939,14 @@ ast_declarator_list_to_hir(const struct ast_node *ast, * FINISHME: in a parameter list (in and out only). */ - apply_type_qualifier_to_variable(& dlist->type->qualifier, var, state); + apply_type_qualifier_to_variable(& this->type->qualifier, var, state); /* Attempt to add the variable to the symbol table. If this fails, it * means the variable has already been declared at this scope. */ if (_mesa_symbol_table_add_symbol(state->symbols, 0, decl->identifier, var) != 0) { - YYLTYPE loc = ast->get_location(); + YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "`%s' redeclared", decl->identifier); @@ -961,42 +964,38 @@ ast_declarator_list_to_hir(const struct ast_node *ast, } -struct ir_instruction * -ast_parameter_declarator_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) +ir_instruction * +ast_parameter_declarator::hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) { - const struct ast_parameter_declarator *decl = - (struct ast_parameter_declarator *) ast; - struct ir_variable *var; const struct glsl_type *type; const char *name = NULL; - type = type_specifier_to_glsl_type(decl->type->specifier, & name, state); + type = type_specifier_to_glsl_type(this->type->specifier, & name, state); if (type == NULL) { - YYLTYPE loc = ast->get_location(); + YYLTYPE loc = this->get_location(); if (name != NULL) { _mesa_glsl_error(& loc, state, "invalid type `%s' in declaration of `%s'", - name, decl->identifier); + name, this->identifier); } else { _mesa_glsl_error(& loc, state, "invalid type in declaration of `%s'", - decl->identifier); + this->identifier); } type = glsl_error_type; } - var = new ir_variable(type, decl->identifier); + ir_variable *var = new ir_variable(type, this->identifier); /* FINISHME: Handle array declarations. Note that this requires * FINISHME: complete handling of constant expressions. */ - apply_type_qualifier_to_variable(& decl->type->qualifier, var, state); + apply_type_qualifier_to_variable(& this->type->qualifier, var, state); insert_at_tail(instructions, var); @@ -1014,7 +1013,7 @@ ast_function_parameters_to_hir(struct simple_node *ast_parameters, struct simple_node *ptr; foreach (ptr, ast_parameters) { - _mesa_ast_to_hir(ptr, ir_parameters, state); + ((ast_node *)ptr)->hir(ir_parameters, state); } } @@ -1047,18 +1046,15 @@ parameter_lists_match(struct simple_node *list_a, struct simple_node *list_b) } -struct ir_instruction * -ast_function_definition_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state) +ir_instruction * +ast_function_definition::hir(struct simple_node *instructions, + struct _mesa_glsl_parse_state *state) { - const struct ast_function_definition *func = - (struct ast_function_definition *) ast; - struct ir_label *label; + ir_label *label; struct simple_node *ptr; struct simple_node *tmp; - struct ir_function_signature *signature = NULL; - struct ir_function *f = NULL; + ir_function_signature *signature = NULL; + ir_function *f = NULL; struct simple_node parameters; @@ -1067,7 +1063,7 @@ ast_function_definition_to_hir(const struct ast_node *ast, * signatures for functions with the same name. */ make_empty_list(& parameters); - ast_function_parameters_to_hir(& func->prototype->parameters, & parameters, + ast_function_parameters_to_hir(& this->prototype->parameters, & parameters, state); @@ -1075,8 +1071,9 @@ ast_function_definition_to_hir(const struct ast_node *ast, * seen signature for a function with the same name, or, if a match is found, * that the previously seen signature does not have an associated definition. */ - f = _mesa_symbol_table_find_symbol(state->symbols, 0, - func->prototype->identifier); + f = (ir_function *) + _mesa_symbol_table_find_symbol(state->symbols, 0, + this->prototype->identifier); if (f != NULL) { foreach (ptr, & f->signatures) { signature = (struct ir_function_signature *) ptr; @@ -1090,10 +1087,10 @@ ast_function_definition_to_hir(const struct ast_node *ast, /* FINISHME: Compare return types. */ if (signature->definition != NULL) { - YYLTYPE loc = ast->get_location(); + YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "function `%s' redefined", - func->prototype->identifier); + this->prototype->identifier); signature = NULL; break; } @@ -1104,7 +1101,7 @@ ast_function_definition_to_hir(const struct ast_node *ast, } else { f = new ir_function(); - f->name = func->prototype->identifier; + f->name = this->prototype->identifier; _mesa_symbol_table_add_symbol(state->symbols, 0, f->name, f); } @@ -1129,12 +1126,12 @@ ast_function_definition_to_hir(const struct ast_node *ast, } - ast_function_parameters_to_hir(& func->prototype->parameters, + ast_function_parameters_to_hir(& this->prototype->parameters, & signature->parameters, state); /* FINISHME: Set signature->return_type */ - label = new ir_label(func->prototype->identifier); + label = new ir_label(this->prototype->identifier); if (signature->definition == NULL) { signature->definition = label; } @@ -1161,7 +1158,7 @@ ast_function_definition_to_hir(const struct ast_node *ast, * instructions to the list that currently consists of the function label * and the function parameters. */ - _mesa_ast_to_hir(func->body, instructions, state); + this->body->hir(instructions, state); _mesa_symbol_table_pop_scope(state->symbols); diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index f30b7d8eb6c..602f2cc5b21 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -698,12 +698,10 @@ main(int argc, char **argv) ((ast_node *)ptr)->print(); } -#if 0 make_empty_list(& instructions); foreach (ptr, & state.translation_unit) { - _mesa_ast_to_hir(ptr, &instructions, &state); + ((ast_node *)ptr)->hir(&instructions, &state); } -#endif _mesa_symbol_table_dtor(state.symbols); diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 3c9fb08cb3e..1dd81264407 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -135,7 +135,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, YYLTYPE loc; - op = _mesa_ast_to_hir(expr->subexpressions[0], instructions, state); + op = expr->subexpressions[0]->hir(instructions, state); deref = new ir_dereference(op); /* Initially assume that the resulting type of the field selection is an -- cgit v1.2.3 From 1e2e58c1f6aec7dd0704fbcc46ac12ab3e59a922 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 8 Mar 2010 13:02:58 -0800 Subject: Set C++ indent too. --- .dir-locals.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.dir-locals.el b/.dir-locals.el index 148e4ca61f0..be19e29a5ab 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1 +1,3 @@ -((c-mode . ((c-basic-offset . 3)))) +((c-mode . ((c-basic-offset . 3))) + (c++-mode . ((c-basic-offset . 3))) +) -- cgit v1.2.3 From 61484ba188ed14bbd989010708e4520e5852ea32 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 8 Mar 2010 23:06:48 -0800 Subject: Remove prototypes for *_to_hir functions that no longer exist --- ast.h | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/ast.h b/ast.h index 59bc4fb0b5e..96f2e3bb039 100644 --- a/ast.h +++ b/ast.h @@ -491,36 +491,6 @@ public: }; -extern struct ir_instruction * -ast_expression_to_hir(const ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state); - -extern struct ir_instruction * -ast_expression_statement_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state); - -extern struct ir_instruction * -ast_compound_statement_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state); - -extern struct ir_instruction * -ast_function_definition_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state); - -extern struct ir_instruction * -ast_declarator_list_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state); - -extern struct ir_instruction * -ast_parameter_declarator_to_hir(const struct ast_node *ast, - struct simple_node *instructions, - struct _mesa_glsl_parse_state *state); - extern struct ir_instruction * _mesa_ast_field_selection_to_hir(const struct ast_expression *expr, struct simple_node *instructions, -- cgit v1.2.3 From 7e4ce719238e910043325567e941e4ea9a953264 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 8 Mar 2010 23:42:45 -0800 Subject: Add yet-another linked list type The use of macros to access existing linked list type makes it unsuitable for its current use as a base class. Since this type and the accompanying macros are used all over the place in Mesa, we can't really change them. --- list.h | 298 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 list.h diff --git a/list.h b/list.h new file mode 100644 index 00000000000..d122369f13b --- /dev/null +++ b/list.h @@ -0,0 +1,298 @@ +/* + * Copyright © 2008, 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file list.h + * \brief Doubly-linked list abstract container type. + * + * Each doubly-linked list has a sentinal head and tail node. These nodes + * contain no data. The head sentinal can be identified by its \c prev + * pointer being \c NULL. The tail sentinal can be identified by its + * \c next pointer being \c NULL. + * + * A list is empty if either the head sentinal's \c next pointer points to the + * tail sentinal or the tail sentinal's \c prev poiner points to the head + * sentinal. + * + * Instead of tracking two separate \c node structures and a \c list structure + * that points to them, the sentinal nodes are in a single structure. Noting + * that each sentinal node always has one \c NULL pointer, the \c NULL + * pointers occupy the same memory location. In the \c list structure + * contains a the following: + * + * - A \c head pointer that represents the \c next pointer of the + * head sentinal node. + * - A \c tail pointer that represents the \c prev pointer of the head + * sentinal node and the \c next pointer of the tail sentinal node. This + * pointer is \b always \c NULL. + * - A \c tail_prev pointer that represents the \c prev pointer of the + * tail sentinal node. + * + * Therefore, if \c head->next is \c NULL or \c tail_prev->prev is \c NULL, + * the list is empty. + * + * To anyone familiar with "exec lists" on the Amiga, this structure should + * be immediately recognizable. See the following link for the original Amiga + * operating system documentation on the subject. + * + * http://www.natami.net/dev/Libraries_Manual_guide/node02D7.html + * + * \author Ian Romanick + */ + +#pragma once +#ifndef LIST_CONTAINER_H +#define LIST_CONTAINER_H + +#include + +struct exec_node { + struct exec_node *next; + struct exec_node *prev; + +#ifdef __cplusplus + exec_node() : next(NULL), prev(NULL) + { + /* empty */ + } + + const exec_node *get_next() const + { + return next; + } + + exec_node *get_next() + { + return next; + } + + const exec_node *get_prev() const + { + return prev; + } + + exec_node *get_prev() + { + return prev; + } + + void remove() + { + next->prev = prev; + prev->next = next; + next = NULL; + prev = NULL; + } + + /** + * Link a node with itself + * + * This creates a sort of degenerate list that is occasionally useful. + */ + void self_link() + { + next = this; + prev = this; + } + + /** + * Insert a node in the list after the current node + */ + void insert_after(exec_node *after) + { + after->next = this->next; + after->prev = this; + + this->next->prev = after; + this->next = after; + } +#endif +}; + +#ifdef __cplusplus +struct exec_node; + +class iterator { +public: + void next() + { + } + + void *get() + { + return NULL; + } + + bool has_next() const + { + return false; + } +}; + +class exec_list_iterator : public iterator { +public: + exec_list_iterator(exec_node *n) : node(n), _next(n->next) + { + /* empty */ + } + + void next() + { + node = _next; + _next = node->next; + } + + void remove() + { + node->remove(); + } + + exec_node *get() + { + return node; + } + + bool has_next() const + { + return _next != NULL; + } + +private: + exec_node *node; + exec_node *_next; +}; + +#define foreach_iter(iter_type, iter, container) \ + for (iter_type iter = container . iterator(); iter.has_next(); iter.next()) +#endif + + +struct exec_list { + struct exec_node *head; + struct exec_node *tail; + struct exec_node *tail_pred; + +#ifdef __cplusplus + exec_list() + { + make_empty(); + } + + void make_empty() + { + head = (exec_node *) & tail; + tail = NULL; + tail_pred = (exec_node *) & head; + } + + bool is_empty() const + { + /* There are three ways to test whether a list is empty or not. + * + * - Check to see if the \c head points to the \c tail. + * - Check to see if the \c tail_pred points to the \c head. + * - Check to see if the \c head is the sentinal node by test whether its + * \c next pointer is \c NULL. + * + * The first two methods tend to generate better code on modern systems + * because they save a pointer dereference. + */ + return head == (exec_node *) &tail; + } + + const exec_node *get_head() const + { + return !is_empty() ? head : NULL; + } + + exec_node *get_head() + { + return !is_empty() ? head : NULL; + } + + const exec_node *get_tail() const + { + return !is_empty() ? tail_pred : NULL; + } + + exec_node *get_tail() + { + return !is_empty() ? tail_pred : NULL; + } + + void push_head(exec_node *n) + { + n->next = head; + n->prev = (exec_node *) &head; + + n->next->prev = n; + head = n; + } + + void push_tail(exec_node *n) + { + n->next = (exec_node *) &tail; + n->prev = tail_pred; + + n->prev->next = n; + tail_pred = n; + } + + void push_degenerate_list_at_head(exec_node *n) + { + assert(n->prev->next == n); + + n->prev->next = head; + head->prev = n->prev; + n->prev = (exec_node *) &head; + head = n; + } + + /** + * Move all of the nodes from this list to the target list + */ + void move_nodes_to(exec_list *target) + { + target->head = head; + target->tail = NULL; + target->tail_pred = tail_pred; + + target->head->prev = (exec_node *) &target->head; + target->tail_pred->next = (exec_node *) &target->tail; + + make_empty(); + } + + exec_list_iterator iterator() + { + return exec_list_iterator(head); + } + + exec_list_iterator iterator() const + { + return exec_list_iterator((exec_node *) head); + } +#endif +}; + +#endif /* LIST_CONTAINER_H */ -- cgit v1.2.3 From 0044e7edcea22d2456c051a1c4b744a26960ad27 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 8 Mar 2010 23:44:00 -0800 Subject: Conver IR structures to use exec_list instead of simple_node --- ast.h | 17 ++++++------- ast_to_hir.cpp | 63 +++++++++++++++++++++++-------------------------- glsl_parser_extras.cpp | 3 +-- hir_field_selection.cpp | 2 +- ir.cpp | 4 ++-- ir.h | 8 ++++--- 6 files changed, 48 insertions(+), 49 deletions(-) diff --git a/ast.h b/ast.h index 96f2e3bb039..fa84a915749 100644 --- a/ast.h +++ b/ast.h @@ -26,6 +26,7 @@ #define AST_H #include "main/simple_list.h" +#include "list.h" #include "glsl_parser_extras.h" struct ir_instruction; @@ -37,7 +38,7 @@ class ast_node : public simple_node { public: virtual ~ast_node(); virtual void print(void) const; - virtual ir_instruction *hir(struct simple_node *instructions, + virtual ir_instruction *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); /** @@ -151,7 +152,7 @@ public: static const char *operator_string(enum ast_operators op); - virtual ir_instruction *hir(struct simple_node *instructions, + virtual ir_instruction *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); virtual void print(void) const; @@ -198,7 +199,7 @@ public: ast_compound_statement(int new_scope, ast_node *statements); virtual void print(void) const; - virtual ir_instruction *hir(struct simple_node *instructions, + virtual ir_instruction *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); int new_scope; @@ -338,7 +339,7 @@ public: ast_declarator_list(ast_fully_specified_type *); virtual void print(void) const; - virtual ir_instruction *hir(struct simple_node *instructions, + virtual ir_instruction *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_fully_specified_type *type; @@ -359,7 +360,7 @@ class ast_parameter_declarator : public ast_node { public: virtual void print(void) const; - virtual ir_instruction *hir(struct simple_node *instructions, + virtual ir_instruction *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_fully_specified_type *type; @@ -406,7 +407,7 @@ public: ast_expression_statement(ast_expression *); virtual void print(void) const; - virtual ir_instruction *hir(struct simple_node *instructions, + virtual ir_instruction *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_expression *expression; @@ -483,7 +484,7 @@ class ast_function_definition : public ast_node { public: virtual void print(void) const; - virtual ir_instruction *hir(struct simple_node *instructions, + virtual ir_instruction *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_function *prototype; @@ -493,7 +494,7 @@ public: extern struct ir_instruction * _mesa_ast_field_selection_to_hir(const struct ast_expression *expr, - struct simple_node *instructions, + exec_list *instructions, struct _mesa_glsl_parse_state *state); #endif /* AST_H */ diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index e7f21ee2524..3342eae8c30 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -330,7 +330,7 @@ relational_result_type(const struct glsl_type *type_a, ir_instruction * -ast_node::hir(struct simple_node *instructions, +ast_node::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { (void) instructions; @@ -341,7 +341,7 @@ ast_node::hir(struct simple_node *instructions, ir_instruction * -ast_expression::hir(struct simple_node *instructions, +ast_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { static const int operations[AST_NUM_OPERATORS] = { @@ -717,7 +717,7 @@ ast_expression::hir(struct simple_node *instructions, ir_instruction * -ast_expression_statement::hir(struct simple_node *instructions, +ast_expression_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { /* It is possible to have expression statements that don't have an @@ -739,7 +739,7 @@ ast_expression_statement::hir(struct simple_node *instructions, ir_instruction * -ast_compound_statement::hir(struct simple_node *instructions, +ast_compound_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { struct simple_node *ptr; @@ -880,7 +880,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, ir_instruction * -ast_declarator_list::hir(struct simple_node *instructions, +ast_declarator_list::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { struct simple_node *ptr; @@ -953,7 +953,7 @@ ast_declarator_list::hir(struct simple_node *instructions, continue; } - insert_at_tail(instructions, (struct simple_node *) var); + instructions->push_tail(var); /* FINISHME: Process the declaration initializer. */ } @@ -965,7 +965,7 @@ ast_declarator_list::hir(struct simple_node *instructions, ir_instruction * -ast_parameter_declarator::hir(struct simple_node *instructions, +ast_parameter_declarator::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { const struct glsl_type *type; @@ -997,7 +997,7 @@ ast_parameter_declarator::hir(struct simple_node *instructions, apply_type_qualifier_to_variable(& this->type->qualifier, var, state); - insert_at_tail(instructions, var); + instructions->push_tail(var); /* Parameter declarations do not have r-values. */ @@ -1007,7 +1007,7 @@ ast_parameter_declarator::hir(struct simple_node *instructions, static void ast_function_parameters_to_hir(struct simple_node *ast_parameters, - struct simple_node *ir_parameters, + exec_list *ir_parameters, struct _mesa_glsl_parse_state *state) { struct simple_node *ptr; @@ -1019,18 +1019,17 @@ ast_function_parameters_to_hir(struct simple_node *ast_parameters, static bool -parameter_lists_match(struct simple_node *list_a, struct simple_node *list_b) +parameter_lists_match(exec_list *list_a, exec_list *list_b) { - struct simple_node *node_a; - struct simple_node *node_b; + exec_list_iterator iter_a = list_a->iterator(); + exec_list_iterator iter_b = list_b->iterator(); - node_b = first_elem(list_b); - foreach (node_a, list_a) { + while (iter_a.has_next()) { /* If all of the parameters from the other parameter list have been * exhausted, the lists have different length and, by definition, * do not match. */ - if (at_end(list_b, node_b)) + if (!iter_b.has_next()) return false; /* If the types of the parameters do not match, the parameters lists @@ -1039,7 +1038,8 @@ parameter_lists_match(struct simple_node *list_a, struct simple_node *list_b) /* FINISHME */ - node_b = next_elem(node_b); + iter_a.next(); + iter_b.next(); } return true; @@ -1047,22 +1047,19 @@ parameter_lists_match(struct simple_node *list_a, struct simple_node *list_b) ir_instruction * -ast_function_definition::hir(struct simple_node *instructions, +ast_function_definition::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { ir_label *label; - struct simple_node *ptr; - struct simple_node *tmp; ir_function_signature *signature = NULL; ir_function *f = NULL; - struct simple_node parameters; + exec_list parameters; /* Convert the list of function parameters to HIR now so that they can be * used below to compare this function's signature with previously seen * signatures for functions with the same name. */ - make_empty_list(& parameters); ast_function_parameters_to_hir(& this->prototype->parameters, & parameters, state); @@ -1075,8 +1072,8 @@ ast_function_definition::hir(struct simple_node *instructions, _mesa_symbol_table_find_symbol(state->symbols, 0, this->prototype->identifier); if (f != NULL) { - foreach (ptr, & f->signatures) { - signature = (struct ir_function_signature *) ptr; + foreach_iter(exec_list_iterator, iter, f->signatures) { + signature = (struct ir_function_signature *) iter.get(); /* Compare the parameter list of the function being defined to the * existing function. If the parameter lists match, then the return @@ -1111,17 +1108,17 @@ ast_function_definition::hir(struct simple_node *instructions, */ if (signature == NULL) { signature = new ir_function_signature(); - insert_at_tail(& f->signatures, (struct simple_node *) signature); + f->signatures.push_tail(signature); } else { /* Destroy all of the previous parameter information. The previous * parameter information comes from the function prototype, and it can * either include invalid parameter names or may not have names at all. */ - foreach_s(ptr, tmp, & signature->parameters) { - assert(((struct ir_instruction *)ptr)->mode == ir_op_var_decl); + foreach_iter(exec_list_iterator, iter, signature->parameters) { + assert(((struct ir_instruction *)iter.get())->mode == ir_op_var_decl); - remove_from_list(ptr); - free(ptr); + iter.remove(); + delete iter.get(); } } @@ -1135,7 +1132,7 @@ ast_function_definition::hir(struct simple_node *instructions, if (signature->definition == NULL) { signature->definition = label; } - insert_at_tail(instructions, label); + instructions->push_tail(label); /* Add the function parameters to the symbol table. During this step the * parameter declarations are also moved from the temporary "parameters" list @@ -1143,13 +1140,13 @@ ast_function_definition::hir(struct simple_node *instructions, * but they involve ugly linked-list gymnastics. */ _mesa_symbol_table_push_scope(state->symbols); - foreach_s(ptr, tmp, & parameters) { - struct ir_variable *const var = (struct ir_variable *) ptr; + foreach_iter(exec_list_iterator, iter, parameters) { + ir_variable *const var = (ir_variable *) iter.get(); assert(var->mode == ir_op_var_decl); - remove_from_list(ptr); - insert_at_tail(instructions, ptr); + iter.remove(); + instructions->push_tail(var); _mesa_symbol_table_add_symbol(state->symbols, 0, var->name, var); } diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 602f2cc5b21..a166fbcd09f 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -681,7 +681,7 @@ main(int argc, char **argv) char *shader; size_t shader_len; struct simple_node *ptr; - struct simple_node instructions; + exec_list instructions; (void) argc; shader = load_text_file(argv[1], & shader_len); @@ -698,7 +698,6 @@ main(int argc, char **argv) ((ast_node *)ptr)->print(); } - make_empty_list(& instructions); foreach (ptr, & state.translation_unit) { ((ast_node *)ptr)->hir(&instructions, &state); } diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 1dd81264407..326a10543fe 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -127,7 +127,7 @@ generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, struct ir_instruction * _mesa_ast_field_selection_to_hir(const ast_expression *expr, - simple_node *instructions, + exec_list *instructions, struct _mesa_glsl_parse_state *state) { ir_instruction *op; diff --git a/ir.cpp b/ir.cpp index 7bd7854ccb8..2eac2c90cd1 100644 --- a/ir.cpp +++ b/ir.cpp @@ -105,12 +105,12 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) ir_function_signature::ir_function_signature(void) : ir_instruction(ir_op_func_sig) { - make_empty_list(& parameters); + /* empty */ } ir_function::ir_function(void) : ir_instruction(ir_op_func) { - make_empty_list(& signatures); + /* empty */ } diff --git a/ir.h b/ir.h index 304f1dccfe0..b728631d785 100644 --- a/ir.h +++ b/ir.h @@ -21,6 +21,8 @@ * DEALINGS IN THE SOFTWARE. */ +#include "list.h" + struct ir_program { void *bong_hits; }; @@ -41,7 +43,7 @@ enum ir_opcodes { /** * Base class of all IR instructions */ -class ir_instruction : public simple_node { +class ir_instruction : public exec_node { public: unsigned mode; const struct glsl_type *type; @@ -113,7 +115,7 @@ public: /** * List of function parameters stored as ir_variable objects. */ - struct simple_node parameters; + struct exec_list parameters; /** * Pointer to the label that begins the function definition. @@ -134,7 +136,7 @@ public: */ const char *name; - struct simple_node signatures; + struct exec_list signatures; }; /*@}*/ -- cgit v1.2.3 From 3a9e989628e37a0122ff72c8ef52e82dcb5ff41a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 8 Mar 2010 23:44:24 -0800 Subject: Remove unused function --- ast_to_hir.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 3342eae8c30..b63b28b11a5 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -56,18 +56,6 @@ #include "glsl_types.h" #include "ir.h" -void -_mesa_generate_hir_from_ast(struct _mesa_glsl_parse_state *state) -{ - struct simple_node *ptr; - - foreach (ptr, & state->translation_unit) { - if (1) { - } - } -} - - static const struct glsl_type * arithmetic_result_type(const struct glsl_type *type_a, const struct glsl_type *type_b, -- cgit v1.2.3 From eccf0bf5f2e261b315b2a473667f71cae50c6001 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 9 Mar 2010 15:17:37 -0800 Subject: Make glsl_type a class Among other benefits, this cleans up a the hackery invovled in initializing the union field in builtin_types.h. --- Makefile.am | 2 +- builtin_types.sh | 13 +++-- glsl_types.c | 159 ------------------------------------------------------- glsl_types.cpp | 144 +++++++++++++++++++++++++++++++++++++++++++++++++ glsl_types.h | 53 ++++++++++++++++--- 5 files changed, 198 insertions(+), 173 deletions(-) delete mode 100644 glsl_types.c create mode 100644 glsl_types.cpp diff --git a/Makefile.am b/Makefile.am index 1fc8aa97a27..77b401357a2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,7 +23,7 @@ AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = glsl -glsl_SOURCES = symbol_table.c hash_table.c glsl_types.c \ +glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ ast_expr.cpp ast_to_hir.cpp ir.cpp hir_field_selection.cpp diff --git a/builtin_types.sh b/builtin_types.sh index 19dcbaf124e..3c8fd879e32 100755 --- a/builtin_types.sh +++ b/builtin_types.sh @@ -24,7 +24,7 @@ # gen_integral_type function gen_integral_type { - printf ' { %17s, 0, 0, 0, 0, %u, %u, "%s", 0, {NULL} },\n' $2 $3 $4 $1 + printf ' glsl_type( %17s, %u, %u, "%s"),\n' $2 $3 $4 $1 index=$((index + 1)) } @@ -32,8 +32,8 @@ function gen_integral_type function gen_struct_type { elements=$(printf "%s_fields" $1) - printf ' {\n GLSL_TYPE_STRUCT, 0, 0, 0, 0, 0, 0, "%s",\n Elements(%s),\n {(void *) %s}\n },\n' \ - $1 $elements $elements + printf ' glsl_type(%s,\n Elements(%s),\n "%s"),\n' \ + $elements $elements $1 } # gen_sampler_type @@ -55,7 +55,7 @@ function gen_sampler_type name=$(printf "u%s" $name) fi - printf ' { GLSL_TYPE_SAMPLER, %21s, %u, %u, %15s, 0, 0,\n "%s", 0, {NULL} },\n' \ + printf ' glsl_type(%21s, %u, %u, %15s, "%s"),\n' \ $2 $3 $4 $5 $name } @@ -119,9 +119,8 @@ cat < -#include "symbol_table.h" -#include "glsl_parser_extras.h" -#include "glsl_types.h" -#include "builtin_types.h" - - -struct glsl_type * -_mesa_glsl_array_type_ctor(struct glsl_type *base, unsigned length, - const char *name) -{ - struct glsl_type *type = calloc(1, sizeof(*type)); - - type->base_type = GLSL_TYPE_ARRAY; - type->name = name; - type->length = length; - type->fields.array = base; - - return type; -} - - -static void -add_types_to_symbol_table(struct _mesa_symbol_table *symtab, - const struct glsl_type *types, - unsigned num_types) -{ - unsigned i; - - for (i = 0; i < num_types; i++) { - _mesa_symbol_table_add_symbol(symtab, 0, types[i].name, - (void *) & types[i]); - } -} - - -static void -generate_110_types(struct _mesa_symbol_table *symtab) -{ - add_types_to_symbol_table(symtab, builtin_core_types, - Elements(builtin_core_types)); - add_types_to_symbol_table(symtab, builtin_structure_types, - Elements(builtin_structure_types)); - add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types, - Elements(builtin_110_deprecated_structure_types)); -} - - -static void -generate_120_types(struct _mesa_symbol_table *symtab) -{ - generate_110_types(symtab); - - add_types_to_symbol_table(symtab, builtin_120_types, - Elements(builtin_120_types)); -} - - -static void -generate_130_types(struct _mesa_symbol_table *symtab) -{ - generate_120_types(symtab); - - add_types_to_symbol_table(symtab, builtin_130_types, - Elements(builtin_130_types)); -} - - -void -_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) -{ - switch (state->language_version) { - case 110: - generate_110_types(state->symbols); - break; - case 120: - generate_120_types(state->symbols); - break; - case 130: - generate_130_types(state->symbols); - break; - default: - /* error */ - break; - } -} - - -const struct glsl_type * -_mesa_glsl_get_vector_type(unsigned base_type, unsigned vector_length) -{ - switch (base_type) { - case GLSL_TYPE_UINT: - switch (vector_length) { - case 1: - case 2: - case 3: - case 4: - return glsl_uint_type + (vector_length - 1); - default: - return glsl_error_type; - } - case GLSL_TYPE_INT: - switch (vector_length) { - case 1: - case 2: - case 3: - case 4: - return glsl_int_type + (vector_length - 1); - default: - return glsl_error_type; - } - case GLSL_TYPE_FLOAT: - switch (vector_length) { - case 1: - case 2: - case 3: - case 4: - return glsl_float_type + (vector_length - 1); - default: - return glsl_error_type; - } - case GLSL_TYPE_BOOL: - switch (vector_length) { - case 1: - case 2: - case 3: - case 4: - return glsl_bool_type + (vector_length - 1); - default: - return glsl_error_type; - } - default: - return glsl_error_type; - } -} diff --git a/glsl_types.cpp b/glsl_types.cpp new file mode 100644 index 00000000000..cd473625f2e --- /dev/null +++ b/glsl_types.cpp @@ -0,0 +1,144 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "symbol_table.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" +#include "builtin_types.h" + + +static void +add_types_to_symbol_table(struct _mesa_symbol_table *symtab, + const struct glsl_type *types, + unsigned num_types) +{ + unsigned i; + + for (i = 0; i < num_types; i++) { + _mesa_symbol_table_add_symbol(symtab, 0, types[i].name, + (void *) & types[i]); + } +} + + +static void +generate_110_types(struct _mesa_symbol_table *symtab) +{ + add_types_to_symbol_table(symtab, builtin_core_types, + Elements(builtin_core_types)); + add_types_to_symbol_table(symtab, builtin_structure_types, + Elements(builtin_structure_types)); + add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types, + Elements(builtin_110_deprecated_structure_types)); +} + + +static void +generate_120_types(struct _mesa_symbol_table *symtab) +{ + generate_110_types(symtab); + + add_types_to_symbol_table(symtab, builtin_120_types, + Elements(builtin_120_types)); +} + + +static void +generate_130_types(struct _mesa_symbol_table *symtab) +{ + generate_120_types(symtab); + + add_types_to_symbol_table(symtab, builtin_130_types, + Elements(builtin_130_types)); +} + + +void +_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) +{ + switch (state->language_version) { + case 110: + generate_110_types(state->symbols); + break; + case 120: + generate_120_types(state->symbols); + break; + case 130: + generate_130_types(state->symbols); + break; + default: + /* error */ + break; + } +} + + +const struct glsl_type * +_mesa_glsl_get_vector_type(unsigned base_type, unsigned vector_length) +{ + switch (base_type) { + case GLSL_TYPE_UINT: + switch (vector_length) { + case 1: + case 2: + case 3: + case 4: + return glsl_uint_type + (vector_length - 1); + default: + return glsl_error_type; + } + case GLSL_TYPE_INT: + switch (vector_length) { + case 1: + case 2: + case 3: + case 4: + return glsl_int_type + (vector_length - 1); + default: + return glsl_error_type; + } + case GLSL_TYPE_FLOAT: + switch (vector_length) { + case 1: + case 2: + case 3: + case 4: + return glsl_float_type + (vector_length - 1); + default: + return glsl_error_type; + } + case GLSL_TYPE_BOOL: + switch (vector_length) { + case 1: + case 2: + case 3: + case 4: + return glsl_bool_type + (vector_length - 1); + default: + return glsl_error_type; + } + default: + return glsl_error_type; + } +} diff --git a/glsl_types.h b/glsl_types.h index c69da956224..9a70b8bfd4d 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -25,6 +25,8 @@ #ifndef GLSL_TYPES_H #define GLSL_TYPES_H +#include + #define GLSL_TYPE_UINT 0 #define GLSL_TYPE_INT 1 #define GLSL_TYPE_FLOAT 2 @@ -44,12 +46,14 @@ #define is_error_type(t) ((t)->base_type == GLSL_TYPE_ERROR) -#define GLSL_SAMPLER_DIM_1D 0 -#define GLSL_SAMPLER_DIM_2D 1 -#define GLSL_SAMPLER_DIM_3D 2 -#define GLSL_SAMPLER_DIM_CUBE 3 -#define GLSL_SAMPLER_DIM_RECT 4 -#define GLSL_SAMPLER_DIM_BUF 5 +enum glsl_sampler_dim { + GLSL_SAMPLER_DIM_1D = 0, + GLSL_SAMPLER_DIM_2D, + GLSL_SAMPLER_DIM_3D, + GLSL_SAMPLER_DIM_CUBE, + GLSL_SAMPLER_DIM_RECT, + GLSL_SAMPLER_DIM_BUF +}; struct glsl_type { @@ -94,6 +98,43 @@ struct glsl_type { const struct glsl_type *parameters; /**< Parameters to function. */ const struct glsl_struct_field *structure;/**< List of struct fields. */ } fields; + + + glsl_type(unsigned base_type, unsigned vector_elements, + unsigned matrix_rows, const char *name) : + base_type(base_type), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(vector_elements), matrix_rows(matrix_rows), + name(name), + length(0) + { + memset(& fields, 0, sizeof(fields)); + } + + glsl_type(enum glsl_sampler_dim dim, bool shadow, bool array, + unsigned type, const char *name) : + base_type(GLSL_TYPE_SAMPLER), + sampler_dimensionality(dim), sampler_shadow(shadow), + sampler_array(array), sampler_type(type), + vector_elements(0), matrix_rows(0), + name(name), + length(0) + { + memset(& fields, 0, sizeof(fields)); + } + + glsl_type(const glsl_struct_field *fields, unsigned num_fields, + const char *name) : + base_type(GLSL_TYPE_STRUCT), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(0), matrix_rows(0), + name(name), + length(num_fields) + { + this->fields.structure = fields; + } }; #define is_glsl_type_scalar(t) \ -- cgit v1.2.3 From cb36f8aaeeb09660843316270a781948f773d90b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 9 Mar 2010 15:51:22 -0800 Subject: Convert is_glsl_type_scalar to glsl_type::is_scalar --- ast_to_hir.cpp | 14 +++++++------- glsl_types.h | 15 ++++++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index b63b28b11a5..8feeab62673 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -110,7 +110,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * * The two operands are scalars. In this case the operation is * applied, resulting in a scalar." */ - if (is_glsl_type_scalar(type_a) && is_glsl_type_scalar(type_b)) + if (type_a->is_scalar() && type_b->is_scalar()) return type_a; /* "* One operand is a scalar, and the other is a vector or matrix. @@ -118,10 +118,10 @@ arithmetic_result_type(const struct glsl_type *type_a, * component of the vector or matrix, resulting in the same size * vector or matrix." */ - if (is_glsl_type_scalar(type_a)) { - if (!is_glsl_type_scalar(type_b)) + if (type_a->is_scalar()) { + if (!type_b->is_scalar()) return type_b; - } else if (is_glsl_type_scalar(type_b)) { + } else if (type_b->is_scalar()) { return type_a; } @@ -287,8 +287,8 @@ relational_result_type(const struct glsl_type *type_a, */ if (! is_numeric_base_type(type_a->base_type) || ! is_numeric_base_type(type_b->base_type) - || ! is_glsl_type_scalar(type_a) - || ! is_glsl_type_scalar(type_b)) + || !type_a->is_scalar() + || !type_b->is_scalar()) return glsl_error_type; /* "Either the operands' types must match, or the conversions from @@ -513,7 +513,7 @@ ast_expression::hir(exec_list *instructions, */ assert((type == glsl_error_type) || ((type->base_type == GLSL_TYPE_BOOL) - && is_glsl_type_scalar(type))); + && type->is_scalar())); result = new ir_expression(operations[this->oper], type, op[0], op[1]); diff --git a/glsl_types.h b/glsl_types.h index 9a70b8bfd4d..0375934de9c 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -135,12 +135,17 @@ struct glsl_type { { this->fields.structure = fields; } -}; -#define is_glsl_type_scalar(t) \ - (((t)->vector_elements == 0) \ - && ((t)->base_type >= GLSL_TYPE_UINT) \ - && ((t)->base_type <= GLSL_TYPE_BOOL)) + /** + * Query whether or not a type is a scalar (non-vector and non-matrix). + */ + bool is_scalar() const + { + return (vector_elements == 0) + && (base_type >= GLSL_TYPE_UINT) + && (base_type <= GLSL_TYPE_BOOL); + } +}; #define is_glsl_type_vector(t) \ (((t)->vector_elements > 0) \ -- cgit v1.2.3 From a2dd22fb194bdffa14a2466ae5667f3be63430d3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 9 Mar 2010 15:55:16 -0800 Subject: Convert is_glsl_type_vector to glsl_type::is_vector --- ast_to_hir.cpp | 6 +++--- glsl_types.h | 17 +++++++++++------ hir_field_selection.cpp | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 8feeab62673..1de58245913 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -136,7 +136,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * operation is done component-wise resulting in the same size * vector." */ - if (is_glsl_type_vector(type_a) && is_glsl_type_vector(type_b)) { + if (type_a->is_vector() && type_b->is_vector()) { if (type_a->vector_elements == type_b->vector_elements) return type_a; else @@ -261,8 +261,8 @@ modulus_result_type(const struct glsl_type *type_a, * wise to the vector, resulting in the same type as the vector. If both * are vectors of the same size, the result is computed component-wise." */ - if (is_glsl_type_vector(type_a)) { - if (!is_glsl_type_vector(type_b) + if (type_a->is_vector()) { + if (!type_b->is_vector() || (type_a->vector_elements == type_b->vector_elements)) return type_a; } else diff --git a/glsl_types.h b/glsl_types.h index 0375934de9c..2b660168bdd 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -145,13 +145,18 @@ struct glsl_type { && (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_BOOL); } -}; -#define is_glsl_type_vector(t) \ - (((t)->vector_elements > 0) \ - && ((t)->matrix_rows == 0) \ - && ((t)->base_type >= GLSL_TYPE_UINT) \ - && ((t)->base_type <= GLSL_TYPE_BOOL)) + /** + * Query whether or not a type is a vector + */ + bool is_vector() const + { + return (vector_elements > 0) + && (matrix_rows == 0) + && (base_type >= GLSL_TYPE_UINT) + && (base_type <= GLSL_TYPE_BOOL); + } +}; #define is_glsl_type_matrix(t) \ (((t)->matrix_rows > 0) \ diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 326a10543fe..8bef094c60f 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -156,7 +156,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, * being applied. */ loc = expr->get_location(); - if (is_glsl_type_vector(op->type)) { + if (op->type->is_vector()) { if (generate_swizzle(expr->primary_expression.identifier, & deref->selector.swizzle, op->type->vector_elements)) { -- cgit v1.2.3 From fce1150156edc8b51f5cf077679c0fdb5d582aba Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 9 Mar 2010 15:58:52 -0800 Subject: Convert is_glsl_type_matrix to glsl_type::is_matrix --- ast_to_hir.cpp | 8 ++++---- glsl_types.h | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1de58245913..5811d73586a 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -169,14 +169,14 @@ arithmetic_result_type(const struct glsl_type *type_a, * more detail how vectors and matrices are operated on." */ if (! multiply) { - if (is_glsl_type_matrix(type_a) && is_glsl_type_matrix(type_b) + if (type_a->is_matrix() && type_b->is_matrix() && (type_a->vector_elements == type_b->vector_elements) && (type_a->matrix_rows == type_b->matrix_rows)) return type_a; else return glsl_error_type; } else { - if (is_glsl_type_matrix(type_a) && is_glsl_type_matrix(type_b)) { + if (type_a->is_matrix() && type_b->is_matrix()) { if (type_a->vector_elements == type_b->matrix_rows) { char type_name[7]; const struct glsl_type *t; @@ -199,14 +199,14 @@ arithmetic_result_type(const struct glsl_type *type_a, _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); return (t != NULL) ? t : glsl_error_type; } - } else if (is_glsl_type_matrix(type_a)) { + } else if (type_a->is_matrix()) { /* A is a matrix and B is a column vector. Columns of A must match * rows of B. */ if (type_a->vector_elements == type_b->vector_elements) return type_b; } else { - assert(is_glsl_type_matrix(type_b)); + assert(type_b->is_matrix()); /* A is a row vector and B is a matrix. Columns of A must match * rows of B. diff --git a/glsl_types.h b/glsl_types.h index 2b660168bdd..f26dcd6b538 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -156,11 +156,16 @@ struct glsl_type { && (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_BOOL); } -}; -#define is_glsl_type_matrix(t) \ - (((t)->matrix_rows > 0) \ - && ((t)->base_type == GLSL_TYPE_FLOAT)) /* GLSL only has float matrices. */ + /** + * Query whether or not a type is a matrix + */ + bool is_matrix() const + { + /* GLSL only has float matrices. */ + return (matrix_rows > 0) && (base_type == GLSL_TYPE_FLOAT); + } +}; struct glsl_struct_field { const struct glsl_type *type; -- cgit v1.2.3 From 78b51b0fdd61b58940f9043ef9046217552f2c70 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 9 Mar 2010 16:23:37 -0800 Subject: IR visitor: Add initial version of ir_visitor classes The ir_visitor class is the abstract base class for all visitors. ir_print_visitor contains the beginnings of a concrete visitor class that will print out an IR sequence in a Lisp / Scheme-like syntax. --- Makefile.am | 3 +- ir.h | 43 +++++++++++++++++++++++++ ir_print_visitor.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ir_print_visitor.h | 65 ++++++++++++++++++++++++++++++++++++++ ir_visitor.h | 57 +++++++++++++++++++++++++++++++++ 5 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 ir_print_visitor.cpp create mode 100644 ir_print_visitor.h create mode 100644 ir_visitor.h diff --git a/Makefile.am b/Makefile.am index 77b401357a2..60317f8b4d3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,8 @@ AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = glsl glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ - ast_expr.cpp ast_to_hir.cpp ir.cpp hir_field_selection.cpp + ast_expr.cpp ast_to_hir.cpp ir.cpp hir_field_selection.cpp \ + ir_print_visitor.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h diff --git a/ir.h b/ir.h index b728631d785..8d59d21dcb3 100644 --- a/ir.h +++ b/ir.h @@ -22,6 +22,7 @@ */ #include "list.h" +#include "ir_visitor.h" struct ir_program { void *bong_hits; @@ -48,6 +49,8 @@ public: unsigned mode; const struct glsl_type *type; + virtual void accept(ir_visitor *) = 0; + protected: ir_instruction(int mode); @@ -81,6 +84,11 @@ class ir_variable : public ir_instruction { public: ir_variable(const struct glsl_type *, const char *); + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + const char *name; unsigned read_only:1; @@ -96,6 +104,11 @@ class ir_label : public ir_instruction { public: ir_label(const char *label); + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + const char *label; }; @@ -105,6 +118,11 @@ class ir_function_signature : public ir_instruction { public: ir_function_signature(void); + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + /** * Function return type. * @@ -131,6 +149,11 @@ class ir_function : public ir_instruction { public: ir_function(void); + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + /** * Name of the function. */ @@ -148,6 +171,11 @@ public: ir_assignment(ir_instruction *lhs, ir_instruction *rhs, ir_expression *condition); + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + /** * Left-hand side of the assignment. */ @@ -234,6 +262,11 @@ public: ir_expression(int op, const struct glsl_type *type, ir_instruction *, ir_instruction *); + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + ir_expression_operation operation; ir_instruction *operands[2]; }; @@ -262,6 +295,11 @@ class ir_dereference : public ir_instruction { public: ir_dereference(struct ir_instruction *); + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + enum { ir_reference_variable, ir_reference_array, @@ -287,6 +325,11 @@ class ir_constant : public ir_instruction { public: ir_constant(const struct glsl_type *type, const void *data); + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + /** * Value of the constant. * diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp new file mode 100644 index 00000000000..8c4271e466a --- /dev/null +++ b/ir_print_visitor.cpp @@ -0,0 +1,89 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "ir_print_visitor.h" + +void ir_print_visitor::visit(ir_variable *ir) +{ + printf("(declare \n"); + + const char *const cent = (ir->centroid) ? "centroid " : ""; + const char *const inv = (ir->invariant) ? "invariant " : ""; + const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " }; + const char *const interp[] = { "", "flat", "noperspective" }; + + printf(" (%s%s%s%s)\n", + cent, inv, mode[ir->mode], interp[ir->interpolation]); + + printf(" (FINISHME: type goes here)\n"); + printf(" (%s)\n", ir->name); + printf(")\n"); +} + + +void ir_print_visitor::visit(ir_label *ir) +{ + printf("(label %s)\n", ir->label); +} + + +void ir_print_visitor::visit(ir_function_signature *ir) +{ + printf("%s:%d:\n", __func__, __LINE__); + (void) ir; +} + + +void ir_print_visitor::visit(ir_function *ir) +{ + printf("(function %s\n", ir->name); + printf(")\n"); +} + + +void ir_print_visitor::visit(ir_expression *ir) +{ + printf("%s:%d:\n", __func__, __LINE__); + (void) ir; +} + + +void ir_print_visitor::visit(ir_dereference *ir) +{ + printf("%s:%d:\n", __func__, __LINE__); + (void) ir; +} + + +void ir_print_visitor::visit(ir_assignment *ir) +{ + printf("%s:%d:\n", __func__, __LINE__); + (void) ir; +} + + +void ir_print_visitor::visit(ir_constant *ir) +{ + printf("%s:%d:\n", __func__, __LINE__); + (void) ir; +} diff --git a/ir_print_visitor.h b/ir_print_visitor.h new file mode 100644 index 00000000000..a2004e43b2f --- /dev/null +++ b/ir_print_visitor.h @@ -0,0 +1,65 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_PRINT_VISITOR_H +#define IR_PRINT_VISITOR_H + +#include "ir.h" +#include "ir_visitor.h" + +/** + * Abstract base class of visitors of IR instruction trees + */ +class ir_print_visitor : public ir_visitor { +public: + ir_print_visitor() + { + /* empty */ + } + + virtual ~ir_print_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_label *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + /*@}*/ +}; + +#endif /* IR_PRINT_VISITOR_H */ diff --git a/ir_visitor.h b/ir_visitor.h new file mode 100644 index 00000000000..4494074eca4 --- /dev/null +++ b/ir_visitor.h @@ -0,0 +1,57 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_VISITOR_H +#define IR_VISITOR_H + +/** + * Abstract base class of visitors of IR instruction trees + */ +class ir_visitor { +public: + virtual ~ir_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(class ir_variable *) = 0; + virtual void visit(class ir_label *) = 0; + virtual void visit(class ir_function_signature *) = 0; + virtual void visit(class ir_function *) = 0; + virtual void visit(class ir_expression *) = 0; + virtual void visit(class ir_dereference *) = 0; + virtual void visit(class ir_assignment *) = 0; + virtual void visit(class ir_constant *) = 0; + /*@}*/ +}; + +#endif /* IR_VISITOR_H */ -- cgit v1.2.3 From 6652af36fe8994b1621d882fcc230d320908a2a3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 9 Mar 2010 16:38:02 -0800 Subject: Add assignment side-effect to the instruction stream The actual assignment is a side-effect of the assignment expression. Add it to the instruction stream and return the LHS of the assignment as its rvalue. --- ast_to_hir.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 5811d73586a..faa13abd599 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -398,7 +398,7 @@ ast_expression::hir(exec_list *instructions, make_empty_list(& op_list); switch (this->oper) { - case ast_assign: + case ast_assign: { op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); @@ -437,8 +437,12 @@ ast_expression::hir(exec_list *instructions, /* FINISHME: Check that the LHS and RHS have matching types. */ /* FINISHME: For GLSL 1.10, check that the types are not arrays. */ - result = new ir_assignment(op[0], op[1], NULL); + ir_instruction *tmp = new ir_assignment(op[0], op[1], NULL); + instructions->push_tail(tmp); + + result = op[0]; break; + } case ast_plus: op[0] = this->subexpressions[0]->hir(instructions, state); -- cgit v1.2.3 From 6044ae79a013ba6067ffd968cee97c0d29b728c2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 9 Mar 2010 16:40:45 -0800 Subject: IR print visitor: Print assignments --- ir_print_visitor.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 8c4271e466a..365ff5933e3 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -77,8 +77,22 @@ void ir_print_visitor::visit(ir_dereference *ir) void ir_print_visitor::visit(ir_assignment *ir) { - printf("%s:%d:\n", __func__, __LINE__); - (void) ir; + printf("(assign\n"); + + printf(" ("); + if (ir->condition) + ir->condition->accept(this); + else + printf("true"); + printf(")\n"); + + printf(" ("); + ir->lhs->accept(this); + printf(")\n"); + + printf(" ("); + ir->rhs->accept(this); + printf(")\n"); } -- cgit v1.2.3 From fe10250355682bcfb87d1688151b93b08d0a4e3c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 9 Mar 2010 21:44:34 -0800 Subject: IR print visitor: Add some support for printing types and constants --- ir_print_visitor.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 365ff5933e3..c09de83ffd6 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -22,6 +22,28 @@ */ #include #include "ir_print_visitor.h" +#include "glsl_types.h" + +static void +print_type(const glsl_type *t) +{ + if (t->base_type == GLSL_TYPE_ARRAY) { + printf("array\n"); + printf(" ("); + print_type(t->fields.array); + printf(")\n"); + + printf(" (%u)\n", t->length); + printf(")"); + } else if (t->base_type == GLSL_TYPE_STRUCT) { + printf("struct (%s %u\n", t->name ? t->name : "@", t->length); + printf(" (FINISHME: structure fields go here)\n"); + printf(")"); + } else { + printf("%s", t->name); + } +} + void ir_print_visitor::visit(ir_variable *ir) { @@ -35,7 +57,10 @@ void ir_print_visitor::visit(ir_variable *ir) printf(" (%s%s%s%s)\n", cent, inv, mode[ir->mode], interp[ir->interpolation]); - printf(" (FINISHME: type goes here)\n"); + printf(" ("); + print_type(ir->type); + printf(")\n"); + printf(" (%s)\n", ir->name); printf(")\n"); } @@ -98,6 +123,12 @@ void ir_print_visitor::visit(ir_assignment *ir) void ir_print_visitor::visit(ir_constant *ir) { - printf("%s:%d:\n", __func__, __LINE__); (void) ir; + + printf("(constant\n"); + printf(" ("); + print_type(ir->type); + printf(")\n"); + printf(" (FINISHME: value goes here)\n"); + printf(")\n"); } -- cgit v1.2.3 From 654c05725704fdb589ebe3bff7c88d695675a2d9 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 00:21:27 -0800 Subject: ir_variable: Initialize all attribute bits to reasonable defaults This prevents variables from randomly having their 'invariant' or 'read_only' bits set, for example. --- ir.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ir.cpp b/ir.cpp index 2eac2c90cd1..ad93310bc90 100644 --- a/ir.cpp +++ b/ir.cpp @@ -95,7 +95,8 @@ ir_dereference::ir_dereference(ir_instruction *var) ir_variable::ir_variable(const struct glsl_type *type, const char *name) - : ir_instruction(ir_op_var_decl) + : ir_instruction(ir_op_var_decl), read_only(false), centroid(false), + invariant(false), mode(ir_var_auto), interpolation(ir_var_smooth) { this->type = type; this->name = name; -- cgit v1.2.3 From 0b678234625fac67a89285ad2871dedc891fb1b1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 00:28:59 -0800 Subject: AST to IR: Mark 'varying' in a vertex shader as 'out' --- ast_to_hir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index faa13abd599..becc8327fb6 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -855,7 +855,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, else if (qual->attribute || qual->in || (qual->varying && (state->target == fragment_shader))) var->mode = ir_var_in; - else if (qual->out) + else if (qual->out || (qual->varying && (state->target == vertex_shader))) var->mode = ir_var_out; else if (qual->uniform) var->mode = ir_var_uniform; -- cgit v1.2.3 From 02ae68f496e2dee1c65df4f6194806785c84d67f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 00:52:39 -0800 Subject: Fix typeo in gl_FogParameters.scale (was scalre) --- builtin_types.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin_types.sh b/builtin_types.sh index 3c8fd879e32..b7baa59b23c 100755 --- a/builtin_types.sh +++ b/builtin_types.sh @@ -245,7 +245,7 @@ gen_struct_field builtin_core_types 11 "color" gen_struct_field builtin_core_types 8 "density" gen_struct_field builtin_core_types 8 "start" gen_struct_field builtin_core_types 8 "end" -gen_struct_field builtin_core_types 8 "scalre" +gen_struct_field builtin_core_types 8 "scale" gen_struct_field_footer gen_header "110_deprecated_structure" -- cgit v1.2.3 From 1c4156ffac393a1379ea1674d363e64f0da4a40b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 09:27:03 -0800 Subject: Use ir_print_visitor to dump IR tree --- glsl_parser_extras.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index a166fbcd09f..caa221f9212 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -35,6 +35,7 @@ #include "glsl_parser_extras.h" #include "glsl_parser.h" #include "symbol_table.h" +#include "ir_print_visitor.h" void _mesa_glsl_error(YYLTYPE *locp, void *state, const char *fmt, ...) @@ -702,6 +703,13 @@ main(int argc, char **argv) ((ast_node *)ptr)->hir(&instructions, &state); } + printf("\n\n"); + foreach_iter(exec_list_iterator, iter, instructions) { + ir_print_visitor v; + + ((ir_instruction *)iter.get())->accept(& v); + } + _mesa_symbol_table_dtor(state.symbols); return 0; -- cgit v1.2.3 From 8e6cd3bf54132d64a1f39df05c9392b46eece2a1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 09:31:30 -0800 Subject: Require the shader target be specified to the driver program --- glsl_parser_extras.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index caa221f9212..222f06b5263 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -684,8 +684,27 @@ main(int argc, char **argv) struct simple_node *ptr; exec_list instructions; - (void) argc; - shader = load_text_file(argv[1], & shader_len); + if (argc < 3) { + printf("Usage: %s [v|g|f] \n", argv[0]); + return EXIT_FAILURE; + } + + switch (argv[1][0]) { + case 'v': + state.target = vertex_shader; + break; + case 'g': + state.target = geometry_shader; + break; + case 'f': + state.target = fragment_shader; + break; + default: + printf("Usage: %s [v|g|f] \n", argv[0]); + return EXIT_FAILURE; + } + + shader = load_text_file(argv[2], & shader_len); state.scanner = NULL; make_empty_list(& state.translation_unit); -- cgit v1.2.3 From d949a9afb0a01e9678a4343f66b056b41a2e48a9 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 09:55:22 -0800 Subject: Move top-level AST to HIR conversion to _mesa_ast_to_hir --- ast.h | 3 +++ ast_to_hir.cpp | 11 +++++++++++ glsl_parser_extras.cpp | 4 +--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ast.h b/ast.h index fa84a915749..36316920926 100644 --- a/ast.h +++ b/ast.h @@ -492,6 +492,9 @@ public: }; +extern void +_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); + extern struct ir_instruction * _mesa_ast_field_selection_to_hir(const struct ast_expression *expr, exec_list *instructions, diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index becc8327fb6..e371007ef8b 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -56,6 +56,17 @@ #include "glsl_types.h" #include "ir.h" +void +_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) +{ + struct simple_node *ptr; + + foreach (ptr, & state->translation_unit) { + ((ast_node *)ptr)->hir(instructions, state); + } +} + + static const struct glsl_type * arithmetic_result_type(const struct glsl_type *type_a, const struct glsl_type *type_b, diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 222f06b5263..d066ca3cd08 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -718,9 +718,7 @@ main(int argc, char **argv) ((ast_node *)ptr)->print(); } - foreach (ptr, & state.translation_unit) { - ((ast_node *)ptr)->hir(&instructions, &state); - } + _mesa_ast_to_hir(&instructions, &state); printf("\n\n"); foreach_iter(exec_list_iterator, iter, instructions) { -- cgit v1.2.3 From f52888fac0b8a6c395a7eb684731852d9b46441f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 10:42:37 -0800 Subject: Include cstdlib to be sure size_t is available --- glsl_parser_extras.h | 1 + 1 file changed, 1 insertion(+) diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 932c12d8410..1c972623c20 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -25,6 +25,7 @@ #ifndef GLSL_PARSER_EXTRAS_H #define GLSL_PARSER_EXTRAS_H +#include #include "main/simple_list.h" enum _mesa_glsl_parser_targets { -- cgit v1.2.3 From adfb0cd7401251bef0c854ac945fce78f0ed11db Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 10:43:16 -0800 Subject: IR variable: Initial work to support GLSL built-in variables --- Makefile.am | 2 +- ast_to_hir.cpp | 2 + builtin_variables.h | 59 +++++++++++++++++++++ ir.h | 4 ++ ir_variable.cpp | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 builtin_variables.h create mode 100644 ir_variable.cpp diff --git a/Makefile.am b/Makefile.am index 60317f8b4d3..fd0d4f69469 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,7 @@ bin_PROGRAMS = glsl glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ ast_expr.cpp ast_to_hir.cpp ir.cpp hir_field_selection.cpp \ - ir_print_visitor.cpp + ir_print_visitor.cpp ir_variable.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index e371007ef8b..1379ec98013 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -61,6 +61,8 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { struct simple_node *ptr; + _mesa_glsl_initialize_variables(instructions, state); + foreach (ptr, & state->translation_unit) { ((ast_node *)ptr)->hir(instructions, state); } diff --git a/builtin_variables.h b/builtin_variables.h new file mode 100644 index 00000000000..9693217e990 --- /dev/null +++ b/builtin_variables.h @@ -0,0 +1,59 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +struct builtin_variable { + enum ir_variable_mode mode; + const char *type; + const char *name; +}; + +static const builtin_variable builtin_core_vs_variables[] = { + { ir_var_out, "vec4", "gl_Position" }, + { ir_var_out, "float", "gl_PointSize" }, +}; + +static const builtin_variable builtin_110_deprecated_vs_variables[] = { + { ir_var_in, "vec4", "gl_Vertex" }, + { ir_var_in, "vec4", "gl_Normal" }, + { ir_var_in, "vec4", "gl_Color" }, + { ir_var_in, "vec4", "gl_SecondaryColor" }, + { ir_var_in, "vec4", "gl_MultiTexCoord0" }, + { ir_var_in, "vec4", "gl_MultiTexCoord1" }, + { ir_var_in, "vec4", "gl_MultiTexCoord2" }, + { ir_var_in, "vec4", "gl_MultiTexCoord3" }, + { ir_var_in, "vec4", "gl_MultiTexCoord4" }, + { ir_var_in, "vec4", "gl_MultiTexCoord5" }, + { ir_var_in, "vec4", "gl_MultiTexCoord6" }, + { ir_var_in, "vec4", "gl_MultiTexCoord7" }, + { ir_var_in, "float", "gl_FogCoord" }, + { ir_var_out, "vec4", "gl_ClipVertex" }, + { ir_var_out, "vec4", "gl_FrontColor" }, + { ir_var_out, "vec4", "gl_BackColor" }, + { ir_var_out, "vec4", "gl_FrontSecondaryColor" }, + { ir_var_out, "vec4", "gl_BackSecondaryColor" }, + { ir_var_out, "vec4", "gl_FogFragCoord" }, +}; + +static const builtin_variable builtin_130_vs_variables[] = { + { ir_var_in, "int", "gl_VertexID" }, +}; diff --git a/ir.h b/ir.h index 8d59d21dcb3..5087e4560e4 100644 --- a/ir.h +++ b/ir.h @@ -345,3 +345,7 @@ public: } value; }; + +extern void +_mesa_glsl_initialize_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state); diff --git a/ir_variable.cpp b/ir_variable.cpp new file mode 100644 index 00000000000..e7cb43f9269 --- /dev/null +++ b/ir_variable.cpp @@ -0,0 +1,144 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "glsl_parser_extras.h" +#include "symbol_table.h" +#include "ir.h" +#include "builtin_variables.h" + +#ifndef Elements +#define Elements(x) (sizeof(x)/sizeof(*(x))) +#endif + +static void +add_builtin_variable(const builtin_variable *proto, exec_list *instructions, + struct _mesa_symbol_table *symtab) +{ + /* Create a new variable declaration from the description supplied by + * the caller. + */ + const glsl_type *const type = (glsl_type *) + _mesa_symbol_table_find_symbol(symtab, 0, proto->type); + + assert(type != NULL); + + ir_variable *var = new ir_variable(type, proto->name); + + var->mode = proto->mode; + if (var->mode != ir_var_out) + var->read_only = true; + + + /* Once the variable is created an initialized, add it to the symbol table + * and add the declaration to the IR stream. + */ + instructions->push_tail(var); + + _mesa_symbol_table_add_symbol(symtab, 0, var->name, var); +} + + +static void +generate_110_vs_variables(exec_list *instructions, + struct _mesa_symbol_table *symtab) +{ + for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { + add_builtin_variable(& builtin_core_vs_variables[i], + instructions, symtab); + } + + for (unsigned i = 0 + ; i < Elements(builtin_110_deprecated_vs_variables) + ; i++) { + add_builtin_variable(& builtin_110_deprecated_vs_variables[i], + instructions, symtab); + } + + /* FINISHME: Add support fo gl_TexCoord. The size of this array is + * FINISHME: implementation dependent based on the value of + * FINISHME: GL_MAX_TEXTURE_COORDS. + */ +} + + +static void +generate_120_vs_variables(exec_list *instructions, + struct _mesa_symbol_table *symtab) +{ + /* GLSL version 1.20 did not add any built-in variables in the vertex + * shader. + */ + generate_110_vs_variables(instructions, symtab); +} + + +static void +generate_130_vs_variables(exec_list *instructions, + struct _mesa_symbol_table *symtab) +{ + generate_120_vs_variables(instructions, symtab); + + for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { + add_builtin_variable(& builtin_130_vs_variables[i], + instructions, symtab); + } + + /* FINISHME: Add support fo gl_ClipDistance. The size of this array is + * FINISHME: implementation dependent based on the value of + * FINISHME: GL_MAX_CLIP_DISTANCES. + */ +} + + +static void +initialize_vs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + + switch (state->language_version) { + case 110: + generate_110_vs_variables(instructions, state->symbols); + break; + case 120: + generate_120_vs_variables(instructions, state->symbols); + break; + case 130: + generate_130_vs_variables(instructions, state->symbols); + break; + } +} + + +void +_mesa_glsl_initialize_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + switch (state->target) { + case vertex_shader: + initialize_vs_variables(instructions, state); + break; + case geometry_shader: + case fragment_shader: + break; + } +} -- cgit v1.2.3 From d10fe19495191072d39689337700b69e62252bf1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 13:25:56 -0800 Subject: Simplified constructor for identifier expressions --- ast.h | 9 +++++++++ glsl_parser.ypp | 12 ++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ast.h b/ast.h index 36316920926..3eb8e5f20fd 100644 --- a/ast.h +++ b/ast.h @@ -150,6 +150,15 @@ public: ast_expression(int oper, ast_expression *, ast_expression *, ast_expression *); + ast_expression(const char *identifier) : + oper(ast_identifier) + { + subexpressions[0] = NULL; + subexpressions[1] = NULL; + subexpressions[2] = NULL; + primary_expression.identifier = (char *) identifier; + } + static const char *operator_string(enum ast_operators op); virtual ir_instruction *hir(exec_list *instructions, diff --git a/glsl_parser.ypp b/glsl_parser.ypp index c7557254581..debbcea9366 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -351,19 +351,11 @@ function_identifier: } | IDENTIFIER { - ast_expression *expr = - new ast_expression(ast_identifier, NULL, NULL, NULL); - expr->primary_expression.identifier = $1; - - $$ = (struct ast_node *) expr; + $$ = new ast_expression($1); } | FIELD_SELECTION { - ast_expression *expr = - new ast_expression(ast_identifier, NULL, NULL, NULL); - expr->primary_expression.identifier = $1; - - $$ = (struct ast_node *) expr; + $$ = new ast_expression($1); } ; -- cgit v1.2.3 From 7cfddf19413ef61fcf1450bd61e9ece4cf1735a4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 13:26:52 -0800 Subject: Make ast_function_expression subclass of ast_expression --- ast.h | 17 +++++++++++++++++ ast_to_hir.cpp | 35 +++++++++++++++++++++-------------- glsl_parser.ypp | 4 +--- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/ast.h b/ast.h index 3eb8e5f20fd..cd5bf6b3f5f 100644 --- a/ast.h +++ b/ast.h @@ -192,6 +192,23 @@ public: virtual void print(void) const; }; +/** + * Subclass of expressions for function calls + */ +class ast_function_expression : public ast_expression { +public: + ast_function_expression(ast_node *callee) + : ast_expression(ast_function_call, (ast_expression *) callee, + NULL, NULL) + { + /* empty */ + } + + + virtual ir_instruction *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); +}; + /** * Number of possible operators for an ast_expression diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1379ec98013..3c4b69fdc24 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -630,21 +630,10 @@ ast_expression::hir(exec_list *instructions, break; case ast_function_call: - /* There are three sorts of function calls. - * - * 1. contstructors - The first subexpression is an ast_type_specifier. - * 2. methods - Only the .length() method of array types. - * 3. functions - Calls to regular old functions. - * - * Method calls are actually detected when the ast_field_selection - * expression is handled. + /* Should *NEVER* get here. ast_function_call should always be handled + * by ast_function_expression::hir. */ -#if 0 - result = _mesa_ast_function_call_to_hir(this->subexpressions[0], - this->subexpressions[1], - state); - type = result->type; -#endif + assert(0); break; case ast_identifier: { @@ -721,6 +710,24 @@ ast_expression::hir(exec_list *instructions, } +ir_instruction * +ast_function_expression::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + /* There are three sorts of function calls. + * + * 1. contstructors - The first subexpression is an ast_type_specifier. + * 2. methods - Only the .length() method of array types. + * 3. functions - Calls to regular old functions. + * + * Method calls are actually detected when the ast_field_selection + * expression is handled. + */ + (void) instructions; + (void) state; + return NULL; +} + ir_instruction * ast_expression_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) diff --git a/glsl_parser.ypp b/glsl_parser.ypp index debbcea9366..2f337b127c5 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -338,9 +338,7 @@ function_call_header_with_parameters: function_call_header: function_identifier '(' { - $$ = new ast_expression(ast_function_call, - (struct ast_expression *) $1, - NULL, NULL); + $$ = new ast_function_expression($1); } ; -- cgit v1.2.3 From 986b8f798272d3ae2898617c8fb089156a5941c0 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 13:58:12 -0800 Subject: Tell emacs that C++ .h files are C++ --- ast.h | 1 + glsl_types.h | 1 + ir.h | 1 + ir_print_visitor.h | 1 + ir_visitor.h | 1 + 5 files changed, 5 insertions(+) diff --git a/ast.h b/ast.h index cd5bf6b3f5f..ad614e98fe6 100644 --- a/ast.h +++ b/ast.h @@ -1,3 +1,4 @@ +/* -*- c++ -*- */ /* * Copyright © 2009 Intel Corporation * diff --git a/glsl_types.h b/glsl_types.h index f26dcd6b538..45037b37869 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -1,3 +1,4 @@ +/* -*- c++ -*- */ /* * Copyright © 2009 Intel Corporation * diff --git a/ir.h b/ir.h index 5087e4560e4..a4cc1d8b94f 100644 --- a/ir.h +++ b/ir.h @@ -1,3 +1,4 @@ +/* -*- c++ -*- */ /* * Copyright © 2010 Intel Corporation * diff --git a/ir_print_visitor.h b/ir_print_visitor.h index a2004e43b2f..778d4ee00df 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -1,3 +1,4 @@ +/* -*- c++ -*- */ /* * Copyright © 2010 Intel Corporation * diff --git a/ir_visitor.h b/ir_visitor.h index 4494074eca4..43246d1058d 100644 --- a/ir_visitor.h +++ b/ir_visitor.h @@ -1,3 +1,4 @@ +/* -*- c++ -*- */ /* * Copyright © 2010 Intel Corporation * -- cgit v1.2.3 From 3821761e45c455374c9fdb4cd02104f420373360 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 14:12:22 -0800 Subject: Differentiate in ast_function_expression between constructors and func. calls --- ast.h | 25 ++++++++++++++++++++++--- glsl_parser.ypp | 11 +++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ast.h b/ast.h index ad614e98fe6..d82325747c2 100644 --- a/ast.h +++ b/ast.h @@ -198,16 +198,35 @@ public: */ class ast_function_expression : public ast_expression { public: - ast_function_expression(ast_node *callee) - : ast_expression(ast_function_call, (ast_expression *) callee, - NULL, NULL) + ast_function_expression(ast_expression *callee) + : ast_expression(ast_function_call, callee, + NULL, NULL), + cons(false) { /* empty */ } + ast_function_expression(class ast_type_specifier *type) + : ast_expression(ast_function_call, (ast_expression *) type, + NULL, NULL), + cons(true) + { + /* empty */ + } + + bool is_constructor() const + { + return cons; + } virtual ir_instruction *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); + +private: + /** + * Is this function call actually a constructor? + */ + bool cons; }; diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 2f337b127c5..058a03231da 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -337,23 +337,22 @@ function_call_header_with_parameters: // recognized through "type_specifier". function_call_header: function_identifier '(' - { - $$ = new ast_function_expression($1); - } ; function_identifier: type_specifier { - $$ = (struct ast_node *) $1; + $$ = new ast_function_expression($1); } | IDENTIFIER { - $$ = new ast_expression($1); + ast_expression *callee = new ast_expression($1); + $$ = new ast_function_expression(callee); } | FIELD_SELECTION { - $$ = new ast_expression($1); + ast_expression *callee = new ast_expression($1); + $$ = new ast_function_expression(callee); } ; -- cgit v1.2.3 From 1f585180597290c7891c43dc0da3c9c06d7cebb1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 11 Mar 2010 14:08:33 -0800 Subject: Track generation of errors and halt compilation appropriately --- glsl_parser_extras.cpp | 17 ++++++++++++----- glsl_parser_extras.h | 6 +++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index d066ca3cd08..52ae79918a2 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -38,13 +38,16 @@ #include "ir_print_visitor.h" void -_mesa_glsl_error(YYLTYPE *locp, void *state, const char *fmt, ...) +_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, + const char *fmt, ...) { char buf[1024]; int len; va_list ap; - (void) state; + if (state) + state->error = true; + len = snprintf(buf, sizeof(buf), "%u:%u(%u): error: ", locp->source, locp->first_line, locp->first_column); @@ -709,6 +712,7 @@ main(int argc, char **argv) state.scanner = NULL; make_empty_list(& state.translation_unit); state.symbols = _mesa_symbol_table_ctor(); + state.error = false; _mesa_glsl_lexer_ctor(& state, shader, shader_len); _mesa_glsl_parse(& state); @@ -721,10 +725,13 @@ main(int argc, char **argv) _mesa_ast_to_hir(&instructions, &state); printf("\n\n"); - foreach_iter(exec_list_iterator, iter, instructions) { - ir_print_visitor v; - ((ir_instruction *)iter.get())->accept(& v); + if (!state.error) { + foreach_iter(exec_list_iterator, iter, instructions) { + ir_print_visitor v; + + ((ir_instruction *)iter.get())->accept(& v); + } } _mesa_symbol_table_dtor(state.symbols); diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 1c972623c20..c7cd68c181c 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -41,6 +41,9 @@ struct _mesa_glsl_parse_state { unsigned language_version; enum _mesa_glsl_parser_targets target; + + /** Was there an error during compilation? */ + bool error; }; typedef struct YYLTYPE { @@ -53,7 +56,8 @@ typedef struct YYLTYPE { # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 -extern void _mesa_glsl_error(YYLTYPE *locp, void *state, const char *fmt, ...); +extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, + const char *fmt, ...); extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string, size_t len); -- cgit v1.2.3 From d27ec2461bca2625d09a3592ec8cc4137d4347f3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 11 Mar 2010 14:23:41 -0800 Subject: Fix broken constructor of ir_instruction base class Make the constructor inline-able, and don't try to initialize it as a simple_node. It hasn't been derived from simple_node in a long time. --- ir.cpp | 7 ------- ir.h | 6 +++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ir.cpp b/ir.cpp index ad93310bc90..3166cdc9eff 100644 --- a/ir.cpp +++ b/ir.cpp @@ -26,13 +26,6 @@ #include "ir.h" #include "glsl_types.h" -ir_instruction::ir_instruction(int mode) -{ - this->mode = mode; - make_empty_list(this); -} - - ir_assignment::ir_assignment(ir_instruction *lhs, ir_instruction *rhs, ir_expression *condition) : ir_instruction(ir_op_assign) diff --git a/ir.h b/ir.h index a4cc1d8b94f..7de7c385323 100644 --- a/ir.h +++ b/ir.h @@ -53,7 +53,11 @@ public: virtual void accept(ir_visitor *) = 0; protected: - ir_instruction(int mode); + ir_instruction(int mode) + : mode(mode) + { + /* empty */ + } private: /** -- cgit v1.2.3 From ed45ec6a515f3529f12fc23d51621e435d3b6cdf Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 11 Mar 2010 14:34:27 -0800 Subject: Add ir_call call to represent function calls. --- ast_to_hir.cpp | 2 +- ir.cpp | 10 ++++++++++ ir.h | 30 +++++++++++++++++++++++++++++- ir_print_visitor.cpp | 10 ++++++++++ ir_print_visitor.h | 1 + ir_visitor.h | 1 + 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 3c4b69fdc24..1fea7299dbd 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -725,7 +725,7 @@ ast_function_expression::hir(exec_list *instructions, */ (void) instructions; (void) state; - return NULL; + return ir_call::get_error_instruction(); } ir_instruction * diff --git a/ir.cpp b/ir.cpp index 3166cdc9eff..5aec70bfce8 100644 --- a/ir.cpp +++ b/ir.cpp @@ -108,3 +108,13 @@ ir_function::ir_function(void) { /* empty */ } + + +ir_call * +ir_call::get_error_instruction() +{ + ir_call *call = new ir_call; + + call->type = glsl_error_type; + return call; +} diff --git a/ir.h b/ir.h index 7de7c385323..136b45b72be 100644 --- a/ir.h +++ b/ir.h @@ -39,7 +39,8 @@ enum ir_opcodes { ir_op_label, ir_op_constant, ir_op_func_sig, - ir_op_func + ir_op_func, + ir_op_call, }; /** @@ -277,6 +278,33 @@ public: }; +/** + * IR instruction representing a function call + */ +class ir_call : public ir_instruction { +public: + ir_call() + : ir_instruction(ir_op_call), callee(NULL) + { + /* empty */ + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + /** + * Get a generic ir_call object when an error occurs + */ + static ir_call *get_error_instruction(); + +private: + ir_function_signature *callee; + exec_list actual_parameters; +}; + + struct ir_swizzle_mask { unsigned x:2; unsigned y:2; diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index c09de83ffd6..b1c718d99ea 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -132,3 +132,13 @@ void ir_print_visitor::visit(ir_constant *ir) printf(" (FINISHME: value goes here)\n"); printf(")\n"); } + + +void +ir_print_visitor::visit(ir_call *ir) +{ + (void) ir; + + printf("(call FINISHME: function name here\n"); + printf(" (FINISHME: function paramaters here))\n"); +} diff --git a/ir_print_visitor.h b/ir_print_visitor.h index 778d4ee00df..b76de504617 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -60,6 +60,7 @@ public: virtual void visit(ir_dereference *); virtual void visit(ir_assignment *); virtual void visit(ir_constant *); + virtual void visit(ir_call *); /*@}*/ }; diff --git a/ir_visitor.h b/ir_visitor.h index 43246d1058d..a2b2dd678b4 100644 --- a/ir_visitor.h +++ b/ir_visitor.h @@ -52,6 +52,7 @@ public: virtual void visit(class ir_dereference *) = 0; virtual void visit(class ir_assignment *) = 0; virtual void visit(class ir_constant *) = 0; + virtual void visit(class ir_call *) = 0; /*@}*/ }; -- cgit v1.2.3 From 7e3ed40200ac87c50b84f73409ca0df48fc6a25d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 11 Mar 2010 14:46:19 -0800 Subject: Add a handful of simple tests for function calls in constructors --- tests/constructor-01.glsl | 4 ++++ tests/function-01.glsl | 16 ++++++++++++++++ tests/function-02.glsl | 16 ++++++++++++++++ tests/function-03.glsl | 16 ++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 tests/constructor-01.glsl create mode 100644 tests/function-01.glsl create mode 100644 tests/function-02.glsl create mode 100644 tests/function-03.glsl diff --git a/tests/constructor-01.glsl b/tests/constructor-01.glsl new file mode 100644 index 00000000000..f7af569c683 --- /dev/null +++ b/tests/constructor-01.glsl @@ -0,0 +1,4 @@ +void main() +{ + gl_Position = vec4(1.0, 1.0, 1.0, 0.0);; +} diff --git a/tests/function-01.glsl b/tests/function-01.glsl new file mode 100644 index 00000000000..0eaa2397ab6 --- /dev/null +++ b/tests/function-01.glsl @@ -0,0 +1,16 @@ +/* FAIL - no function named 'foo' exists */ + +vec4 bar(float x, float y, float z, float w) +{ + vec4 v; + v.x = x; + v.y = y; + v.z = z; + v.w = w; + return v; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0, 0.0); +} diff --git a/tests/function-02.glsl b/tests/function-02.glsl new file mode 100644 index 00000000000..941fcc1ef7b --- /dev/null +++ b/tests/function-02.glsl @@ -0,0 +1,16 @@ +/* FAIL - no version of 'foo' matches the call to 'foo' */ + +vec4 foo(float x, float y, float z, float w) +{ + vec4 v; + v.x = x; + v.y = y; + v.z = z; + v.w = w; + return v; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0); +} diff --git a/tests/function-03.glsl b/tests/function-03.glsl new file mode 100644 index 00000000000..6f6562ea858 --- /dev/null +++ b/tests/function-03.glsl @@ -0,0 +1,16 @@ +/* PASS */ + +vec4 foo(float x, float y, float z, float w) +{ + vec4 v; + v.x = x; + v.y = y; + v.z = z; + v.w = w; + return v; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0, 0.0); +} -- cgit v1.2.3 From cdb8d54b6808b13092cb85e44cf02e4e91c3a669 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 11 Mar 2010 14:48:51 -0800 Subject: Default function parameters to 'in' instead of auto --- ast_to_hir.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1fea7299dbd..c791aec3e24 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1007,7 +1007,12 @@ ast_parameter_declarator::hir(exec_list *instructions, * FINISHME: complete handling of constant expressions. */ + /* Apply any specified qualifiers to the parameter declaration. Note that + * for function parameters the default mode is 'in'. + */ apply_type_qualifier_to_variable(& this->type->qualifier, var, state); + if (var->mode == ir_var_auto) + var->mode = ir_var_in; instructions->push_tail(var); @@ -1155,7 +1160,7 @@ ast_function_definition::hir(exec_list *instructions, foreach_iter(exec_list_iterator, iter, parameters) { ir_variable *const var = (ir_variable *) iter.get(); - assert(var->mode == ir_op_var_decl); + assert(((ir_instruction *)var)->mode == ir_op_var_decl); iter.remove(); instructions->push_tail(var); -- cgit v1.2.3 From 471471f83471481db0445e73f8c89e6a9149838e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 11 Mar 2010 14:50:30 -0800 Subject: Initial pass at resolving function calls The code is still really rough and *REALLY* incomplete. This at least passes the first few trivially simple test cases. --- Makefile.am | 2 +- ast_to_hir.cpp | 67 +++++++++++++++++++- ir.h | 22 +++++-- ir_function.cpp | 185 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 269 insertions(+), 7 deletions(-) create mode 100644 ir_function.cpp diff --git a/Makefile.am b/Makefile.am index fd0d4f69469..ff4886a9e52 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,7 @@ bin_PROGRAMS = glsl glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ ast_expr.cpp ast_to_hir.cpp ir.cpp hir_field_selection.cpp \ - ir_print_visitor.cpp ir_variable.cpp + ir_print_visitor.cpp ir_variable.cpp ir_function.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index c791aec3e24..d24dc159f21 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -720,11 +720,74 @@ ast_function_expression::hir(exec_list *instructions, * 2. methods - Only the .length() method of array types. * 3. functions - Calls to regular old functions. * + * There are two kinds of constructor call. Constructors for built-in + * language types, such as mat4 and vec2, are free form. The only + * requirement is that the parameters must provide enough values of the + * correct scalar type. Constructors for arrays and structures must have + * the exact number of parameters with matching types in the correct order. + * These constructors follow essentially the same type matching rules as + * functions. + * * Method calls are actually detected when the ast_field_selection * expression is handled. */ - (void) instructions; - (void) state; + if (is_constructor()) { + return ir_call::get_error_instruction(); + } else { + const ast_expression *id = subexpressions[0]; + + ir_function *f = (ir_function *) + _mesa_symbol_table_find_symbol(state->symbols, 0, + id->primary_expression.identifier); + + if (f == NULL) { + YYLTYPE loc = id->get_location(); + + _mesa_glsl_error(& loc, state, "function `%s' undeclared", + id->primary_expression.identifier); + return ir_call::get_error_instruction(); + } + + /* Once we've determined that the function being called might exist, + * process the parameters. + */ + exec_list actual_parameters; + simple_node *const first = subexpressions[1]; + if (first != NULL) { + simple_node *ptr = first; + do { + ir_instruction *const result = + ((ast_node *) ptr)->hir(instructions, state); + ptr = ptr->next; + + actual_parameters.push_tail(result); + } while (ptr != first); + } + + /* After processing the function's actual parameters, try to find an + * overload of the function that matches. + */ + const ir_function_signature *sig = + f->matching_signature(& actual_parameters); + if (sig != NULL) { + /* FINISHME: The list of actual parameters needs to be modified to + * FINISHME: include any necessary conversions. + */ + return new ir_call(sig, & actual_parameters); + } else { + YYLTYPE loc = id->get_location(); + + /* FINISHME: Log a better error message here. G++ will show the types + * FINISHME: of the actual parameters and the set of candidate + * FINISHME: functions. A different error should also be logged when + * FINISHME: multiple functions match. + */ + _mesa_glsl_error(& loc, state, "no matching function for call to `%s'", + id->primary_expression.identifier); + return ir_call::get_error_instruction(); + } + } + return ir_call::get_error_instruction(); } diff --git a/ir.h b/ir.h index 136b45b72be..5acf611e746 100644 --- a/ir.h +++ b/ir.h @@ -160,11 +160,19 @@ public: v->visit(this); } + /** + * Find a signature that matches a set of actual parameters. + */ + const ir_function_signature *matching_signature(exec_list *actual_param); + /** * Name of the function. */ const char *name; + /** + * Set of overloaded functions with this name. + */ struct exec_list signatures; }; /*@}*/ @@ -283,10 +291,10 @@ public: */ class ir_call : public ir_instruction { public: - ir_call() - : ir_instruction(ir_op_call), callee(NULL) + ir_call(const ir_function_signature *callee, exec_list *actual_parameters) + : ir_instruction(ir_op_call), callee(callee) { - /* empty */ + actual_parameters->move_nodes_to(& this->actual_parameters); } virtual void accept(ir_visitor *v) @@ -300,7 +308,13 @@ public: static ir_call *get_error_instruction(); private: - ir_function_signature *callee; + ir_call() + : ir_instruction(ir_op_call), callee(NULL) + { + /* empty */ + } + + const ir_function_signature *callee; exec_list actual_parameters; }; diff --git a/ir_function.cpp b/ir_function.cpp new file mode 100644 index 00000000000..a14b546bc6e --- /dev/null +++ b/ir_function.cpp @@ -0,0 +1,185 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "glsl_types.h" +#include "ir.h" + +int +type_compare(const glsl_type *a, const glsl_type *b) +{ + switch (a->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + if ((a->vector_elements != b->vector_elements) + || (a->matrix_rows != b->matrix_rows)) + return -1; + + if (a->base_type == b->base_type) + return 0; + + /* There is no implicit conversion to or from bool. + */ + if ((a->base_type == GLSL_TYPE_BOOL) + || (b->base_type == GLSL_TYPE_BOOL)) + return -1; + + return 1; + + case GLSL_TYPE_SAMPLER: + return ((a->sampler_dimensionality == b->sampler_dimensionality) + && (a->sampler_shadow == b->sampler_shadow) + && (a->sampler_array == b->sampler_array) + && (a->sampler_type == b->sampler_type)) + ? 0 : -1; + + case GLSL_TYPE_STRUCT: + return (strcmp(a->name, b->name) == 0) ? 0 : -1; + + case GLSL_TYPE_ARRAY: + if ((b->base_type != GLSL_TYPE_ARRAY) + || (a->length != b->length)) + return -1; + + /* From GLSL 1.50 spec, page 27 (page 33 of the PDF): + * "There are no implicit array or structure conversions." + * + * If the comparison of the array element types detects that a conversion + * would be required, the array types do not match. + */ + return (type_compare(a->fields.array, b->fields.array) == 0) ? 0 : -1; + + case GLSL_TYPE_FUNCTION: + case GLSL_TYPE_VOID: + case GLSL_TYPE_ERROR: + default: + /* These are all error conditions. It is invalid for a parameter to + * a function to be declared as error, void, or a function. + */ + return -1; + } + + /* This point should be unreachable. + */ + assert(0); +} + + +static int +parameter_lists_match(exec_list *list_a, exec_list *list_b) +{ + exec_list_iterator iter_a = list_a->iterator(); + exec_list_iterator iter_b = list_b->iterator(); + int total_score = 0; + + for (/* empty */ ; iter_a.has_next(); iter_a.next(), iter_b.next()) { + /* If all of the parameters from the other parameter list have been + * exhausted, the lists have different length and, by definition, + * do not match. + */ + if (!iter_b.has_next()) + return -1; + + + const ir_variable *const param = (ir_variable *) iter_a.get(); + const ir_instruction *const actual = (ir_instruction *) iter_b.get(); + + /* Determine whether or not the types match. If the types are an + * exact match, the match score is zero. If the types don't match + * but the actual parameter can be coerced to the type of the declared + * parameter, the match score is one. + */ + int score; + switch ((enum ir_variable_mode)(param->mode)) { + case ir_var_auto: + case ir_var_uniform: + /* These are all error conditions. It is invalid for a parameter to + * a function to be declared as auto (not in, out, or inout) or + * as uniform. + */ + assert(0); + return -1; + + case ir_var_in: + score = type_compare(param->type, actual->type); + break; + + case ir_var_out: + /* FINISHME: Make sure that actual is a valid lvalue. */ + score = type_compare(actual->type, param->type); + break; + + case ir_var_inout: + /* FINISHME: Make sure that actual is a valid lvalue. */ + + /* Since there are no bi-directional automatic conversions (e.g., + * there is int -> float but no float -> int), inout parameters must + * be exact matches. + */ + score = (type_compare(actual->type, param->type) == 0) ? 0 : -1; + break; + } + + if (score < 0) + return -1; + + total_score += score; + } + + /* If all of the parameters from the other parameter list have been + * exhausted, the lists have different length and, by definition, do not + * match. + */ + if (iter_b.has_next()) + return -1; + + return total_score; +} + + +const ir_function_signature * +ir_function::matching_signature(exec_list *actual_parameters) +{ + ir_function_signature *match = NULL; + + foreach_iter(exec_list_iterator, iter, signatures) { + ir_function_signature *const sig = + (ir_function_signature *) iter.get(); + + const int score = parameter_lists_match(& sig->parameters, + actual_parameters); + + if (score == 0) + return sig; + + if (score > 0) { + if (match != NULL) + return NULL; + + match = sig; + } + } + + return match; +} -- cgit v1.2.3 From 44eb13d0b589e27038dffc10cec0f0a303e124fe Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 11 Mar 2010 16:11:07 -0800 Subject: Add parameters to function declarations in the correct order --- glsl_parser.ypp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 058a03231da..cc9e11676a3 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -581,13 +581,13 @@ function_header_with_parameters: function_header parameter_declaration { $$ = $1; - insert_at_head(& $$->parameters, + insert_at_tail(& $$->parameters, (struct simple_node *) $2); } | function_header_with_parameters ',' parameter_declaration { $$ = $1; - insert_at_head(& $$->parameters, + insert_at_tail(& $$->parameters, (struct simple_node *) $3); } ; -- cgit v1.2.3 From f13d4295f941f09908af99e2e81a0e47e31d5639 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 11 Mar 2010 16:12:25 -0800 Subject: Change type of function_identifier to silence bison warning When the implementation of function_call_header and function_identifier were changed a few commits ago, the types of the production changed. This just updates the types specified for the productions to match reality. --- glsl_parser.ypp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glsl_parser.ypp b/glsl_parser.ypp index cc9e11676a3..3645e96f721 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -164,7 +164,7 @@ %type function_call %type assignment_operator %type unary_operator -%type function_identifier +%type function_identifier %type external_declaration %type init_declarator_list %type single_declaration -- cgit v1.2.3 From 728330e3b27e56206422d61a4ece87cdfb563817 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 15 Mar 2010 13:02:08 -0700 Subject: Remove DOA hir_function.c file --- hir_function.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 hir_function.c diff --git a/hir_function.c b/hir_function.c deleted file mode 100644 index eac2b59a611..00000000000 --- a/hir_function.c +++ /dev/null @@ -1,41 +0,0 @@ -struct ir_instruction * -_mesa_ast_constructor_to_hir(const struct ast_node *n, - const struct ast_node *parameters, - struct _mesa_glsl_parse_state *state) -{ - const struct ast_type_specifier *type = (struct ast_type_specifier *) n; - - - /* There are effectively three kinds of constructors. Each has its own set - * of rules. - * - * * Built-in scalar, vector, and matrix types: For each of these the only - * matching requirement is that the number of values supplied is - * sufficient to initialize all of the fields of the type. - * * Array types: The number of initializers must match the size of the - * array, if a size is specified. Each of the initializers must - * exactly match the base type of the array. - * * Structure types: These initializers must exactly match the fields of - * the structure in order. This is the most restrictive type. - * - * In all cases the built-in promotions from integer to floating-point types - * are applied. - */ - - if (type->is_array) { - /* FINISHME */ - } else if ((type->type_specifier == ast_struct) - || (type->type_specifier == ast_type_name)) { - /* FINISHME */ - } else { - const struct glsl_type *ctor_type; - - /* Look-up the type, by name, in the symbol table. - */ - - - /* Generate a series of assignments of constructor parameters to fields - * of the object being initialized. - */ - } -} -- cgit v1.2.3 From 548fa293a37db8f01bd35d2dc878720e75886aa4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 15 Mar 2010 13:04:13 -0700 Subject: Move ast_function_expression::hir to ast_function.cpp --- Makefile.am | 3 +- ast_function.cpp | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ast_to_hir.cpp | 81 ----------------------------------------- 3 files changed, 111 insertions(+), 82 deletions(-) create mode 100644 ast_function.cpp diff --git a/Makefile.am b/Makefile.am index ff4886a9e52..b2c49b018bb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,8 @@ AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = glsl glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ - ast_expr.cpp ast_to_hir.cpp ir.cpp hir_field_selection.cpp \ + ast_expr.cpp ast_to_hir.cpp ast_function.cpp \ + ir.cpp hir_field_selection.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h diff --git a/ast_function.cpp b/ast_function.cpp new file mode 100644 index 00000000000..2e0cbe9e132 --- /dev/null +++ b/ast_function.cpp @@ -0,0 +1,109 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "symbol_table.h" +#include "ast.h" +#include "glsl_types.h" +#include "ir.h" + +ir_instruction * +ast_function_expression::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + /* There are three sorts of function calls. + * + * 1. contstructors - The first subexpression is an ast_type_specifier. + * 2. methods - Only the .length() method of array types. + * 3. functions - Calls to regular old functions. + * + * There are two kinds of constructor call. Constructors for built-in + * language types, such as mat4 and vec2, are free form. The only + * requirement is that the parameters must provide enough values of the + * correct scalar type. Constructors for arrays and structures must have + * the exact number of parameters with matching types in the correct order. + * These constructors follow essentially the same type matching rules as + * functions. + * + * Method calls are actually detected when the ast_field_selection + * expression is handled. + */ + if (is_constructor()) { + return ir_call::get_error_instruction(); + } else { + const ast_expression *id = subexpressions[0]; + + ir_function *f = (ir_function *) + _mesa_symbol_table_find_symbol(state->symbols, 0, + id->primary_expression.identifier); + + if (f == NULL) { + YYLTYPE loc = id->get_location(); + + _mesa_glsl_error(& loc, state, "function `%s' undeclared", + id->primary_expression.identifier); + return ir_call::get_error_instruction(); + } + + /* Once we've determined that the function being called might exist, + * process the parameters. + */ + exec_list actual_parameters; + simple_node *const first = subexpressions[1]; + if (first != NULL) { + simple_node *ptr = first; + do { + ir_instruction *const result = + ((ast_node *) ptr)->hir(instructions, state); + ptr = ptr->next; + + actual_parameters.push_tail(result); + } while (ptr != first); + } + + /* After processing the function's actual parameters, try to find an + * overload of the function that matches. + */ + const ir_function_signature *sig = + f->matching_signature(& actual_parameters); + if (sig != NULL) { + /* FINISHME: The list of actual parameters needs to be modified to + * FINISHME: include any necessary conversions. + */ + return new ir_call(sig, & actual_parameters); + } else { + YYLTYPE loc = id->get_location(); + + /* FINISHME: Log a better error message here. G++ will show the types + * FINISHME: of the actual parameters and the set of candidate + * FINISHME: functions. A different error should also be logged when + * FINISHME: multiple functions match. + */ + _mesa_glsl_error(& loc, state, "no matching function for call to `%s'", + id->primary_expression.identifier); + return ir_call::get_error_instruction(); + } + } + + return ir_call::get_error_instruction(); +} diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index d24dc159f21..1de64795ad6 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -710,87 +710,6 @@ ast_expression::hir(exec_list *instructions, } -ir_instruction * -ast_function_expression::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - /* There are three sorts of function calls. - * - * 1. contstructors - The first subexpression is an ast_type_specifier. - * 2. methods - Only the .length() method of array types. - * 3. functions - Calls to regular old functions. - * - * There are two kinds of constructor call. Constructors for built-in - * language types, such as mat4 and vec2, are free form. The only - * requirement is that the parameters must provide enough values of the - * correct scalar type. Constructors for arrays and structures must have - * the exact number of parameters with matching types in the correct order. - * These constructors follow essentially the same type matching rules as - * functions. - * - * Method calls are actually detected when the ast_field_selection - * expression is handled. - */ - if (is_constructor()) { - return ir_call::get_error_instruction(); - } else { - const ast_expression *id = subexpressions[0]; - - ir_function *f = (ir_function *) - _mesa_symbol_table_find_symbol(state->symbols, 0, - id->primary_expression.identifier); - - if (f == NULL) { - YYLTYPE loc = id->get_location(); - - _mesa_glsl_error(& loc, state, "function `%s' undeclared", - id->primary_expression.identifier); - return ir_call::get_error_instruction(); - } - - /* Once we've determined that the function being called might exist, - * process the parameters. - */ - exec_list actual_parameters; - simple_node *const first = subexpressions[1]; - if (first != NULL) { - simple_node *ptr = first; - do { - ir_instruction *const result = - ((ast_node *) ptr)->hir(instructions, state); - ptr = ptr->next; - - actual_parameters.push_tail(result); - } while (ptr != first); - } - - /* After processing the function's actual parameters, try to find an - * overload of the function that matches. - */ - const ir_function_signature *sig = - f->matching_signature(& actual_parameters); - if (sig != NULL) { - /* FINISHME: The list of actual parameters needs to be modified to - * FINISHME: include any necessary conversions. - */ - return new ir_call(sig, & actual_parameters); - } else { - YYLTYPE loc = id->get_location(); - - /* FINISHME: Log a better error message here. G++ will show the types - * FINISHME: of the actual parameters and the set of candidate - * FINISHME: functions. A different error should also be logged when - * FINISHME: multiple functions match. - */ - _mesa_glsl_error(& loc, state, "no matching function for call to `%s'", - id->primary_expression.identifier); - return ir_call::get_error_instruction(); - } - } - - return ir_call::get_error_instruction(); -} - ir_instruction * ast_expression_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) -- cgit v1.2.3 From f4749610ed800c2a93f0a21f94c0f8b4212c38de Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 15 Mar 2010 13:26:02 -0700 Subject: Factor guts of function matching code out to match_function_by_name This function will be used for matching some types of constructors as well. --- ast_function.cpp | 106 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 2e0cbe9e132..5cf271e2eda 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -27,6 +27,58 @@ #include "glsl_types.h" #include "ir.h" +static ir_instruction * +match_function_by_name(exec_list *instructions, const char *name, + YYLTYPE *loc, simple_node *parameters, + struct _mesa_glsl_parse_state *state) +{ + ir_function *f = (ir_function *) + _mesa_symbol_table_find_symbol(state->symbols, 0, name); + + if (f == NULL) { + _mesa_glsl_error(loc, state, "function `%s' undeclared", name); + return ir_call::get_error_instruction(); + } + + /* Once we've determined that the function being called might exist, + * process the parameters. + */ + exec_list actual_parameters; + simple_node *const first = parameters; + if (first != NULL) { + simple_node *ptr = first; + do { + ir_instruction *const result = + ((ast_node *) ptr)->hir(instructions, state); + ptr = ptr->next; + + actual_parameters.push_tail(result); + } while (ptr != first); + } + + /* After processing the function's actual parameters, try to find an + * overload of the function that matches. + */ + const ir_function_signature *sig = + f->matching_signature(& actual_parameters); + if (sig != NULL) { + /* FINISHME: The list of actual parameters needs to be modified to + * FINISHME: include any necessary conversions. + */ + return new ir_call(sig, & actual_parameters); + } else { + /* FINISHME: Log a better error message here. G++ will show the types + * FINISHME: of the actual parameters and the set of candidate + * FINISHME: functions. A different error should also be logged when + * FINISHME: multiple functions match. + */ + _mesa_glsl_error(loc, state, "no matching function for call to `%s'", + name); + return ir_call::get_error_instruction(); + } +} + + ir_instruction * ast_function_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -52,57 +104,11 @@ ast_function_expression::hir(exec_list *instructions, return ir_call::get_error_instruction(); } else { const ast_expression *id = subexpressions[0]; + YYLTYPE loc = id->get_location(); - ir_function *f = (ir_function *) - _mesa_symbol_table_find_symbol(state->symbols, 0, - id->primary_expression.identifier); - - if (f == NULL) { - YYLTYPE loc = id->get_location(); - - _mesa_glsl_error(& loc, state, "function `%s' undeclared", - id->primary_expression.identifier); - return ir_call::get_error_instruction(); - } - - /* Once we've determined that the function being called might exist, - * process the parameters. - */ - exec_list actual_parameters; - simple_node *const first = subexpressions[1]; - if (first != NULL) { - simple_node *ptr = first; - do { - ir_instruction *const result = - ((ast_node *) ptr)->hir(instructions, state); - ptr = ptr->next; - - actual_parameters.push_tail(result); - } while (ptr != first); - } - - /* After processing the function's actual parameters, try to find an - * overload of the function that matches. - */ - const ir_function_signature *sig = - f->matching_signature(& actual_parameters); - if (sig != NULL) { - /* FINISHME: The list of actual parameters needs to be modified to - * FINISHME: include any necessary conversions. - */ - return new ir_call(sig, & actual_parameters); - } else { - YYLTYPE loc = id->get_location(); - - /* FINISHME: Log a better error message here. G++ will show the types - * FINISHME: of the actual parameters and the set of candidate - * FINISHME: functions. A different error should also be logged when - * FINISHME: multiple functions match. - */ - _mesa_glsl_error(& loc, state, "no matching function for call to `%s'", - id->primary_expression.identifier); - return ir_call::get_error_instruction(); - } + return match_function_by_name(instructions, + id->primary_expression.identifier, & loc, + subexpressions[1], state); } return ir_call::get_error_instruction(); -- cgit v1.2.3 From bbddcb3092dbb80081d9d4d183cd7b6f3804b1d8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 15 Mar 2010 14:09:23 -0700 Subject: Factor ast_type_specifier code out to ast_type.cpp --- Makefile.am | 2 +- ast_type.cpp | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ glsl_parser_extras.cpp | 77 ------------------------------------ 3 files changed, 104 insertions(+), 78 deletions(-) create mode 100644 ast_type.cpp diff --git a/Makefile.am b/Makefile.am index b2c49b018bb..0865977329d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,7 @@ AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = glsl glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ - ast_expr.cpp ast_to_hir.cpp ast_function.cpp \ + ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \ ir.cpp hir_field_selection.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp diff --git a/ast_type.cpp b/ast_type.cpp new file mode 100644 index 00000000000..d2e047e2c43 --- /dev/null +++ b/ast_type.cpp @@ -0,0 +1,103 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "ast.h" +#include "symbol_table.h" + +void +ast_type_specifier::print(void) const +{ + switch (type_specifier) { + case ast_void: printf("void "); break; + case ast_float: printf("float "); break; + case ast_int: printf("int "); break; + case ast_uint: printf("uint "); break; + case ast_bool: printf("bool "); break; + case ast_vec2: printf("vec2 "); break; + case ast_vec3: printf("vec3 "); break; + case ast_vec4: printf("vec4 "); break; + case ast_bvec2: printf("bvec2 "); break; + case ast_bvec3: printf("bvec3 "); break; + case ast_bvec4: printf("bvec4 "); break; + case ast_ivec2: printf("ivec2 "); break; + case ast_ivec3: printf("ivec3 "); break; + case ast_ivec4: printf("ivec4 "); break; + case ast_uvec2: printf("uvec2 "); break; + case ast_uvec3: printf("uvec3 "); break; + case ast_uvec4: printf("uvec4 "); break; + case ast_mat2: printf("mat2 "); break; + case ast_mat2x3: printf("mat2x3 "); break; + case ast_mat2x4: printf("mat2x4 "); break; + case ast_mat3x2: printf("mat3x2 "); break; + case ast_mat3: printf("mat3 "); break; + case ast_mat3x4: printf("mat3x4 "); break; + case ast_mat4x2: printf("mat4x2 "); break; + case ast_mat4x3: printf("mat4x3 "); break; + case ast_mat4: printf("mat4 "); break; + case ast_sampler1d: printf("sampler1d "); break; + case ast_sampler2d: printf("sampler2d "); break; + case ast_sampler3d: printf("sampler3d "); break; + case ast_samplercube: printf("samplercube "); break; + case ast_sampler1dshadow: printf("sampler1dshadow "); break; + case ast_sampler2dshadow: printf("sampler2dshadow "); break; + case ast_samplercubeshadow: printf("samplercubeshadow "); break; + case ast_sampler1darray: printf("sampler1darray "); break; + case ast_sampler2darray: printf("sampler2darray "); break; + case ast_sampler1darrayshadow: printf("sampler1darrayshadow "); break; + case ast_sampler2darrayshadow: printf("sampler2darrayshadow "); break; + case ast_isampler1d: printf("isampler1d "); break; + case ast_isampler2d: printf("isampler2d "); break; + case ast_isampler3d: printf("isampler3d "); break; + case ast_isamplercube: printf("isamplercube "); break; + case ast_isampler1darray: printf("isampler1darray "); break; + case ast_isampler2darray: printf("isampler2darray "); break; + case ast_usampler1d: printf("usampler1d "); break; + case ast_usampler2d: printf("usampler2d "); break; + case ast_usampler3d: printf("usampler3d "); break; + case ast_usamplercube: printf("usamplercube "); break; + case ast_usampler1darray: printf("usampler1darray "); break; + case ast_usampler2darray: printf("usampler2darray "); break; + + case ast_struct: + structure->print(); + break; + + case ast_type_name: printf("%s ", type_name); break; + } + + if (is_array) { + printf("[ "); + + if (array_size) { + array_size->print(); + } + + printf("] "); + } +} + +ast_type_specifier::ast_type_specifier(int specifier) +{ + type_specifier = ast_types(specifier); +} diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 52ae79918a2..e7f34864d53 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -115,77 +115,6 @@ ast_node::ast_node(void) make_empty_list(this); } -void -ast_type_specifier::print(void) const -{ - switch (type_specifier) { - case ast_void: printf("void "); break; - case ast_float: printf("float "); break; - case ast_int: printf("int "); break; - case ast_uint: printf("uint "); break; - case ast_bool: printf("bool "); break; - case ast_vec2: printf("vec2 "); break; - case ast_vec3: printf("vec3 "); break; - case ast_vec4: printf("vec4 "); break; - case ast_bvec2: printf("bvec2 "); break; - case ast_bvec3: printf("bvec3 "); break; - case ast_bvec4: printf("bvec4 "); break; - case ast_ivec2: printf("ivec2 "); break; - case ast_ivec3: printf("ivec3 "); break; - case ast_ivec4: printf("ivec4 "); break; - case ast_uvec2: printf("uvec2 "); break; - case ast_uvec3: printf("uvec3 "); break; - case ast_uvec4: printf("uvec4 "); break; - case ast_mat2: printf("mat2 "); break; - case ast_mat2x3: printf("mat2x3 "); break; - case ast_mat2x4: printf("mat2x4 "); break; - case ast_mat3x2: printf("mat3x2 "); break; - case ast_mat3: printf("mat3 "); break; - case ast_mat3x4: printf("mat3x4 "); break; - case ast_mat4x2: printf("mat4x2 "); break; - case ast_mat4x3: printf("mat4x3 "); break; - case ast_mat4: printf("mat4 "); break; - case ast_sampler1d: printf("sampler1d "); break; - case ast_sampler2d: printf("sampler2d "); break; - case ast_sampler3d: printf("sampler3d "); break; - case ast_samplercube: printf("samplercube "); break; - case ast_sampler1dshadow: printf("sampler1dshadow "); break; - case ast_sampler2dshadow: printf("sampler2dshadow "); break; - case ast_samplercubeshadow: printf("samplercubeshadow "); break; - case ast_sampler1darray: printf("sampler1darray "); break; - case ast_sampler2darray: printf("sampler2darray "); break; - case ast_sampler1darrayshadow: printf("sampler1darrayshadow "); break; - case ast_sampler2darrayshadow: printf("sampler2darrayshadow "); break; - case ast_isampler1d: printf("isampler1d "); break; - case ast_isampler2d: printf("isampler2d "); break; - case ast_isampler3d: printf("isampler3d "); break; - case ast_isamplercube: printf("isamplercube "); break; - case ast_isampler1darray: printf("isampler1darray "); break; - case ast_isampler2darray: printf("isampler2darray "); break; - case ast_usampler1d: printf("usampler1d "); break; - case ast_usampler2d: printf("usampler2d "); break; - case ast_usampler3d: printf("usampler3d "); break; - case ast_usamplercube: printf("usamplercube "); break; - case ast_usampler1darray: printf("usampler1darray "); break; - case ast_usampler2darray: printf("usampler2darray "); break; - - case ast_struct: - structure->print(); - break; - - case ast_type_name: printf("%s ", type_name); break; - } - - if (is_array) { - printf("[ "); - - if (array_size) { - array_size->print(); - } - - printf("] "); - } -} static void ast_opt_array_size_print(bool is_array, const ast_expression *array_size) @@ -201,12 +130,6 @@ ast_opt_array_size_print(bool is_array, const ast_expression *array_size) } -ast_type_specifier::ast_type_specifier(int specifier) -{ - type_specifier = ast_types(specifier); -} - - void ast_compound_statement::print(void) const { -- cgit v1.2.3 From 7f9d30974317a4050fb8990ce1a3eebbb190483a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 15 Mar 2010 14:15:15 -0700 Subject: Ensure that ast_type always has type_name set For built-in types, type_name would be NULL. This ensures that type_name is set even for the built-in types. This simplifies code in a few places and centralizes the name setting code. --- ast.h | 2 +- ast_to_hir.cpp | 62 +------------------------------ ast_type.cpp | 114 +++++++++++++++++++++++++++++---------------------------- 3 files changed, 62 insertions(+), 116 deletions(-) diff --git a/ast.h b/ast.h index d82325747c2..32cd5b6b4f5 100644 --- a/ast.h +++ b/ast.h @@ -361,7 +361,7 @@ public: enum ast_types type_specifier; - char *type_name; + const char *type_name; ast_struct_specifier *structure; int is_array; diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1de64795ad6..9f580d28cb0 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -759,73 +759,15 @@ type_specifier_to_glsl_type(const struct ast_type_specifier *spec, const char **name, struct _mesa_glsl_parse_state *state) { - static const char *const type_names[] = { - "void", - "float", - "int", - "uint", - "bool", - "vec2", - "vec3", - "vec4", - "bvec2", - "bvec3", - "bvec4", - "ivec2", - "ivec3", - "ivec4", - "uvec2", - "uvec3", - "uvec4", - "mat2", - "mat2x3", - "mat2x4", - "mat3x2", - "mat3", - "mat3x4", - "mat4x2", - "mat4x3", - "mat4", - "sampler1D", - "sampler2D", - "sampler3D", - "samplerCube", - "sampler1DShadow", - "sampler2DShadow", - "samplerCubeShadow", - "sampler1DArray", - "sampler2DArray", - "sampler1DArrayShadow", - "sampler2DArrayShadow", - "isampler1D", - "isampler2D", - "isampler3D", - "isamplerCube", - "isampler1DArray", - "isampler2DArray", - "usampler1D", - "usampler2D", - "usampler3D", - "usamplerCube", - "usampler1DArray", - "usampler2DArray", - - NULL, /* ast_struct */ - NULL /* ast_type_name */ - }; struct glsl_type *type; - const char *type_name = NULL; if (spec->type_specifier == ast_struct) { /* FINISHME: Handle annonymous structures. */ type = NULL; } else { - type_name = (spec->type_specifier == ast_type_name) - ? spec->type_name : type_names[spec->type_specifier]; - type = (glsl_type *) - _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); - *name = type_name; + _mesa_symbol_table_find_symbol(state->symbols, 0, spec->type_name); + *name = spec->type_name; /* FINISHME: Handle array declarations. Note that this requires complete * FINSIHME: handling of constant expressions. diff --git a/ast_type.cpp b/ast_type.cpp index d2e047e2c43..25f28b13e2a 100644 --- a/ast_type.cpp +++ b/ast_type.cpp @@ -28,62 +28,10 @@ void ast_type_specifier::print(void) const { - switch (type_specifier) { - case ast_void: printf("void "); break; - case ast_float: printf("float "); break; - case ast_int: printf("int "); break; - case ast_uint: printf("uint "); break; - case ast_bool: printf("bool "); break; - case ast_vec2: printf("vec2 "); break; - case ast_vec3: printf("vec3 "); break; - case ast_vec4: printf("vec4 "); break; - case ast_bvec2: printf("bvec2 "); break; - case ast_bvec3: printf("bvec3 "); break; - case ast_bvec4: printf("bvec4 "); break; - case ast_ivec2: printf("ivec2 "); break; - case ast_ivec3: printf("ivec3 "); break; - case ast_ivec4: printf("ivec4 "); break; - case ast_uvec2: printf("uvec2 "); break; - case ast_uvec3: printf("uvec3 "); break; - case ast_uvec4: printf("uvec4 "); break; - case ast_mat2: printf("mat2 "); break; - case ast_mat2x3: printf("mat2x3 "); break; - case ast_mat2x4: printf("mat2x4 "); break; - case ast_mat3x2: printf("mat3x2 "); break; - case ast_mat3: printf("mat3 "); break; - case ast_mat3x4: printf("mat3x4 "); break; - case ast_mat4x2: printf("mat4x2 "); break; - case ast_mat4x3: printf("mat4x3 "); break; - case ast_mat4: printf("mat4 "); break; - case ast_sampler1d: printf("sampler1d "); break; - case ast_sampler2d: printf("sampler2d "); break; - case ast_sampler3d: printf("sampler3d "); break; - case ast_samplercube: printf("samplercube "); break; - case ast_sampler1dshadow: printf("sampler1dshadow "); break; - case ast_sampler2dshadow: printf("sampler2dshadow "); break; - case ast_samplercubeshadow: printf("samplercubeshadow "); break; - case ast_sampler1darray: printf("sampler1darray "); break; - case ast_sampler2darray: printf("sampler2darray "); break; - case ast_sampler1darrayshadow: printf("sampler1darrayshadow "); break; - case ast_sampler2darrayshadow: printf("sampler2darrayshadow "); break; - case ast_isampler1d: printf("isampler1d "); break; - case ast_isampler2d: printf("isampler2d "); break; - case ast_isampler3d: printf("isampler3d "); break; - case ast_isamplercube: printf("isamplercube "); break; - case ast_isampler1darray: printf("isampler1darray "); break; - case ast_isampler2darray: printf("isampler2darray "); break; - case ast_usampler1d: printf("usampler1d "); break; - case ast_usampler2d: printf("usampler2d "); break; - case ast_usampler3d: printf("usampler3d "); break; - case ast_usamplercube: printf("usamplercube "); break; - case ast_usampler1darray: printf("usampler1darray "); break; - case ast_usampler2darray: printf("usampler2darray "); break; - - case ast_struct: + if (type_specifier == ast_struct) { structure->print(); - break; - - case ast_type_name: printf("%s ", type_name); break; + } else { + printf("%s ", type_name); } if (is_array) { @@ -99,5 +47,61 @@ ast_type_specifier::print(void) const ast_type_specifier::ast_type_specifier(int specifier) { + static const char *const names[] = { + "void", + "float", + "int", + "uint", + "bool", + "vec2", + "vec3", + "vec4", + "bvec2", + "bvec3", + "bvec4", + "ivec2", + "ivec3", + "ivec4", + "uvec2", + "uvec3", + "uvec4", + "mat2", + "mat2x3", + "mat2x4", + "mat3x2", + "mat3", + "mat3x4", + "mat4x2", + "mat4x3", + "mat4", + "sampler1D", + "sampler2D", + "sampler3D", + "samplerCube", + "sampler1DShadow", + "sampler2DShadow", + "samplerCubeShadow", + "sampler1DArray", + "sampler2DArray", + "sampler1DArrayShadow", + "sampler2DArrayShadow", + "isampler1D", + "isampler2D", + "isampler3D", + "isamplerCube", + "isampler1DArray", + "isampler2DArray", + "usampler1D", + "usampler2D", + "usampler3D", + "usamplerCube", + "usampler1DArray", + "usampler2DArray", + + NULL, /* ast_struct */ + NULL /* ast_type_name */ + }; + type_specifier = ast_types(specifier); + type_name = names[specifier]; } -- cgit v1.2.3 From ed85a5dd4b36f4a583fc321b6d8d49a050d48678 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 15 Mar 2010 14:28:17 -0700 Subject: Add new constructors for ast_type_specifier Add a constructor that uses an ast_struct_specifier and one that uses a type name. This saves a (trivial) bit of code, but it also ensures some of the class invariants (i.e., type_name != NULL) are met. --- ast.h | 16 ++++++++++++++++ glsl_parser.ypp | 6 ++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ast.h b/ast.h index 32cd5b6b4f5..1bc38d355cb 100644 --- a/ast.h +++ b/ast.h @@ -357,6 +357,22 @@ class ast_type_specifier : public ast_node { public: ast_type_specifier(int specifier); + /** Construct a type specifier from a type name */ + ast_type_specifier(const char *name) + : type_specifier(ast_type_name), type_name(name), structure(NULL), + is_array(false), array_size(NULL), precision(ast_precision_high) + { + /* empty */ + } + + /** Construct a type specifier from a structure definition */ + ast_type_specifier(ast_struct_specifier *s) + : type_specifier(ast_struct), type_name(s->name), structure(s), + is_array(false), array_size(NULL), precision(ast_precision_high) + { + /* empty */ + } + virtual void print(void) const; enum ast_types type_specifier; diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 3645e96f721..2bc5cb06e6c 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -861,13 +861,11 @@ type_specifier_nonarray: } | struct_specifier { - $$ = new ast_type_specifier(ast_struct); - $$->structure = $1; + $$ = new ast_type_specifier($1); } | TYPE_NAME { - $$ = new ast_type_specifier(ast_type_name); - $$->type_name = $1; + $$ = new ast_type_specifier($1); } ; -- cgit v1.2.3 From 5c2bd09888394190e30f89ccd39177caaf0e3353 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 15 Mar 2010 14:31:48 -0700 Subject: Trivial clean-ups to ast_type_specifier(int) constructor --- ast_type.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ast_type.cpp b/ast_type.cpp index 25f28b13e2a..3bfbc647a1e 100644 --- a/ast_type.cpp +++ b/ast_type.cpp @@ -46,6 +46,8 @@ ast_type_specifier::print(void) const } ast_type_specifier::ast_type_specifier(int specifier) + : type_specifier(ast_types(specifier)), type_name(NULL), structure(NULL), + is_array(false), array_size(NULL), precision(ast_precision_high) { static const char *const names[] = { "void", @@ -102,6 +104,5 @@ ast_type_specifier::ast_type_specifier(int specifier) NULL /* ast_type_name */ }; - type_specifier = ast_types(specifier); type_name = names[specifier]; } -- cgit v1.2.3 From e309a6051d1a04ee581f0a47c6c585918fba1096 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 15 Mar 2010 15:20:15 -0700 Subject: Add multiple include protection to ir.h --- ir.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ir.h b/ir.h index 5acf611e746..c7fd981200f 100644 --- a/ir.h +++ b/ir.h @@ -22,6 +22,10 @@ * DEALINGS IN THE SOFTWARE. */ +#pragma once +#ifndef IR_H +#define IR_H + #include "list.h" #include "ir_visitor.h" @@ -396,3 +400,5 @@ public: extern void _mesa_glsl_initialize_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state); + +#endif /* IR_H */ -- cgit v1.2.3 From b0bb781e1dae3d98b861c1f6cae7fb99efefe2e1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 11:12:33 -0700 Subject: Don't track new type names during pass-1 parsing This implementation was wrong anyway because it did not respect scoping rules. This will need to be revisited soon. The most likely result is that the grammar is going to need some significant re-work to be able to use a IDENTIFIER in all the places where a TYPE_NAME is currently used. --- glsl_lexer.lpp | 9 +-------- glsl_parser.ypp | 3 --- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index 9c7e3064e4a..8f3f1211d5d 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -24,7 +24,6 @@ #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" -#include "symbol_table.h" #define YY_USER_ACTION \ do { \ @@ -245,13 +244,7 @@ precision return PRECISION; [_a-zA-Z][_a-zA-Z0-9]* { yylval->identifier = strdup(yytext); - - if (_mesa_symbol_table_find_symbol(yyextra->symbols, - 0, - yylval->identifier)) - return TYPE_NAME; - else - return IDENTIFIER; + return IDENTIFIER; } . { return yytext[0]; } diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 2bc5cb06e6c..7af93dd9447 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -28,7 +28,6 @@ #include "ast.h" #include "glsl_parser_extras.h" -#include "symbol_table.h" #include "glsl_types.h" #define YYLEX_PARAM state->scanner @@ -934,8 +933,6 @@ struct_specifier: STRUCT IDENTIFIER '{' struct_declaration_list '}' { $$ = new ast_struct_specifier($2, $4); - - _mesa_symbol_table_add_symbol(state->symbols, 0, $2, $$); } | STRUCT '{' struct_declaration_list '}' { -- cgit v1.2.3 From 82de85e264383553dc3c3f827c3b3259355b1006 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 11:42:45 -0700 Subject: Add a GLSL-specific facade to _mesa_symbol_table This adds some type saftey and will enable elimination of a bunch of type casts and other ugly crap in the code. --- glsl_symbol_table.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 glsl_symbol_table.h diff --git a/glsl_symbol_table.h b/glsl_symbol_table.h new file mode 100644 index 00000000000..482507cf671 --- /dev/null +++ b/glsl_symbol_table.h @@ -0,0 +1,109 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_SYMBOL_TABLE +#define GLSL_SYMBOL_TABLE + +#include "symbol_table.h" +#include "ir.h" +#include "glsl_types.h" + +/** + * Facade class for _mesa_symbol_table + * + * Wraps the existing \c _mesa_symbol_table data structure to enforce some + * type safe and some symbol table invariants. + */ +class glsl_symbol_table { +public: + glsl_symbol_table() + { + table = _mesa_symbol_table_ctor(); + } + + ~glsl_symbol_table() + { + _mesa_symbol_table_dtor(table); + } + + void push_scope() + { + _mesa_symbol_table_push_scope(table); + } + + void pop_scope() + { + _mesa_symbol_table_pop_scope(table); + } + + /** + * \name Methods to add symbols to the table + * + * There is some temptation to rename all these functions to \c add_symbol + * or similar. However, this breaks symmetry with the getter functions and + * reduces the clarity of the intention of code that uses these methods. + */ + /*@{*/ + bool add_variable(const char *name, ir_variable *v) + { + return _mesa_symbol_table_add_symbol(table, 0, name, v) == 0; + } + + bool add_type(const char *name, const glsl_type *t) + { + return _mesa_symbol_table_add_symbol(table, 0, name, (void *) t) == 0; + } + + bool add_function(const char *name, ir_function *f) + { + return _mesa_symbol_table_add_symbol(table, 0, name, f) == 0; + } + /*@}*/ + + /** + * \name Methods to get symbols from the table + */ + /*@{*/ + ir_variable *get_variable(const char *name) + { + return (ir_variable *) _mesa_symbol_table_find_symbol(table, 0, name); + } + + glsl_type *get_type(const char *name) + { + return (glsl_type *) _mesa_symbol_table_find_symbol(table, 0, name); + } + + ir_function *get_function(const char *name) + { + return (ir_function *) _mesa_symbol_table_find_symbol(table, 0, name); + } + /*@}*/ + +private: + struct _mesa_symbol_table *table; +}; + +#endif /* GLSL_SYMBOL_TABLE */ -- cgit v1.2.3 From 8bde4cec6b189564b1f2d58514bd7e7a4b40f714 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 11:57:24 -0700 Subject: Use glsl_symbol_table instead of using _mesa_symbol_table directly --- ast_function.cpp | 5 ++--- ast_to_hir.cpp | 32 +++++++++++++------------------- glsl_parser_extras.cpp | 5 ++--- glsl_parser_extras.h | 3 ++- glsl_types.cpp | 13 ++++++------- ir_variable.cpp | 15 +++++++-------- 6 files changed, 32 insertions(+), 41 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 5cf271e2eda..a120eb8dd63 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -22,7 +22,7 @@ */ #include -#include "symbol_table.h" +#include "glsl_symbol_table.h" #include "ast.h" #include "glsl_types.h" #include "ir.h" @@ -32,8 +32,7 @@ match_function_by_name(exec_list *instructions, const char *name, YYLTYPE *loc, simple_node *parameters, struct _mesa_glsl_parse_state *state) { - ir_function *f = (ir_function *) - _mesa_symbol_table_find_symbol(state->symbols, 0, name); + ir_function *f = state->symbols->get_function(name); if (f == NULL) { _mesa_glsl_error(loc, state, "function `%s' undeclared", name); diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 9f580d28cb0..5c87107cb5a 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -50,7 +50,7 @@ */ #include #include "main/imports.h" -#include "symbol_table.h" +#include "glsl_symbol_table.h" #include "glsl_parser_extras.h" #include "ast.h" #include "glsl_types.h" @@ -208,8 +208,7 @@ arithmetic_result_type(const struct glsl_type *type_a, type_name[6] = '\0'; } - t = (glsl_type *) - _mesa_symbol_table_find_symbol(state->symbols, 0, type_name); + t = state->symbols->get_type(type_name); return (t != NULL) ? t : glsl_error_type; } } else if (type_a->is_matrix()) { @@ -641,9 +640,8 @@ ast_expression::hir(exec_list *instructions, * tree. This particular use must be at location specified in the grammar * as 'variable_identifier'. */ - ir_variable *var = (ir_variable *) - _mesa_symbol_table_find_symbol(state->symbols, 0, - this->primary_expression.identifier); + ir_variable *var = + state->symbols->get_variable(this->primary_expression.identifier); result = new ir_dereference(var); @@ -740,13 +738,13 @@ ast_compound_statement::hir(exec_list *instructions, if (new_scope) - _mesa_symbol_table_push_scope(state->symbols); + state->symbols->push_scope(); foreach (ptr, &statements) ((ast_node *)ptr)->hir(instructions, state); if (new_scope) - _mesa_symbol_table_pop_scope(state->symbols); + state->symbols->pop_scope(); /* Compound statements do not have r-values. */ @@ -765,8 +763,7 @@ type_specifier_to_glsl_type(const struct ast_type_specifier *spec, /* FINISHME: Handle annonymous structures. */ type = NULL; } else { - type = (glsl_type *) - _mesa_symbol_table_find_symbol(state->symbols, 0, spec->type_name); + type = state->symbols->get_type(spec->type_name); *name = spec->type_name; /* FINISHME: Handle array declarations. Note that this requires complete @@ -880,8 +877,7 @@ ast_declarator_list::hir(exec_list *instructions, /* Attempt to add the variable to the symbol table. If this fails, it * means the variable has already been declared at this scope. */ - if (_mesa_symbol_table_add_symbol(state->symbols, 0, decl->identifier, - var) != 0) { + if (!state->symbols->add_variable(decl->identifier, var)) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "`%s' redeclared", @@ -1009,9 +1005,7 @@ ast_function_definition::hir(exec_list *instructions, * seen signature for a function with the same name, or, if a match is found, * that the previously seen signature does not have an associated definition. */ - f = (ir_function *) - _mesa_symbol_table_find_symbol(state->symbols, 0, - this->prototype->identifier); + f = state->symbols->get_function(this->prototype->identifier); if (f != NULL) { foreach_iter(exec_list_iterator, iter, f->signatures) { signature = (struct ir_function_signature *) iter.get(); @@ -1041,7 +1035,7 @@ ast_function_definition::hir(exec_list *instructions, f = new ir_function(); f->name = this->prototype->identifier; - _mesa_symbol_table_add_symbol(state->symbols, 0, f->name, f); + state->symbols->add_function(f->name, f); } @@ -1080,7 +1074,7 @@ ast_function_definition::hir(exec_list *instructions, * to the instruction list. There are other more efficient ways to do this, * but they involve ugly linked-list gymnastics. */ - _mesa_symbol_table_push_scope(state->symbols); + state->symbols->push_scope(); foreach_iter(exec_list_iterator, iter, parameters) { ir_variable *const var = (ir_variable *) iter.get(); @@ -1089,7 +1083,7 @@ ast_function_definition::hir(exec_list *instructions, iter.remove(); instructions->push_tail(var); - _mesa_symbol_table_add_symbol(state->symbols, 0, var->name, var); + state->symbols->add_variable(var->name, var); } /* Convert the body of the function to HIR, and append the resulting @@ -1098,7 +1092,7 @@ ast_function_definition::hir(exec_list *instructions, */ this->body->hir(instructions, state); - _mesa_symbol_table_pop_scope(state->symbols); + state->symbols->pop_scope(); /* Function definitions do not have r-values. diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index e7f34864d53..3a2038a1532 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -34,7 +34,6 @@ #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" -#include "symbol_table.h" #include "ir_print_visitor.h" void @@ -634,7 +633,7 @@ main(int argc, char **argv) state.scanner = NULL; make_empty_list(& state.translation_unit); - state.symbols = _mesa_symbol_table_ctor(); + state.symbols = new glsl_symbol_table; state.error = false; _mesa_glsl_lexer_ctor(& state, shader, shader_len); @@ -657,7 +656,7 @@ main(int argc, char **argv) } } - _mesa_symbol_table_dtor(state.symbols); + delete state.symbols; return 0; } diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index c7cd68c181c..b3b3f868b16 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -27,6 +27,7 @@ #include #include "main/simple_list.h" +#include "glsl_symbol_table.h" enum _mesa_glsl_parser_targets { vertex_shader, @@ -37,7 +38,7 @@ enum _mesa_glsl_parser_targets { struct _mesa_glsl_parse_state { void *scanner; struct simple_node translation_unit; - struct _mesa_symbol_table *symbols; + glsl_symbol_table *symbols; unsigned language_version; enum _mesa_glsl_parser_targets target; diff --git a/glsl_types.cpp b/glsl_types.cpp index cd473625f2e..5a087216ea6 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -22,28 +22,27 @@ */ #include -#include "symbol_table.h" +#include "glsl_symbol_table.h" #include "glsl_parser_extras.h" #include "glsl_types.h" #include "builtin_types.h" static void -add_types_to_symbol_table(struct _mesa_symbol_table *symtab, +add_types_to_symbol_table(glsl_symbol_table *symtab, const struct glsl_type *types, unsigned num_types) { unsigned i; for (i = 0; i < num_types; i++) { - _mesa_symbol_table_add_symbol(symtab, 0, types[i].name, - (void *) & types[i]); + symtab->add_type(types[i].name, & types[i]); } } static void -generate_110_types(struct _mesa_symbol_table *symtab) +generate_110_types(glsl_symbol_table *symtab) { add_types_to_symbol_table(symtab, builtin_core_types, Elements(builtin_core_types)); @@ -55,7 +54,7 @@ generate_110_types(struct _mesa_symbol_table *symtab) static void -generate_120_types(struct _mesa_symbol_table *symtab) +generate_120_types(glsl_symbol_table *symtab) { generate_110_types(symtab); @@ -65,7 +64,7 @@ generate_120_types(struct _mesa_symbol_table *symtab) static void -generate_130_types(struct _mesa_symbol_table *symtab) +generate_130_types(glsl_symbol_table *symtab) { generate_120_types(symtab); diff --git a/ir_variable.cpp b/ir_variable.cpp index e7cb43f9269..283842c54e0 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -22,7 +22,7 @@ */ #include "glsl_parser_extras.h" -#include "symbol_table.h" +#include "glsl_symbol_table.h" #include "ir.h" #include "builtin_variables.h" @@ -32,13 +32,12 @@ static void add_builtin_variable(const builtin_variable *proto, exec_list *instructions, - struct _mesa_symbol_table *symtab) + glsl_symbol_table *symtab) { /* Create a new variable declaration from the description supplied by * the caller. */ - const glsl_type *const type = (glsl_type *) - _mesa_symbol_table_find_symbol(symtab, 0, proto->type); + const glsl_type *const type = symtab->get_type(proto->type); assert(type != NULL); @@ -54,13 +53,13 @@ add_builtin_variable(const builtin_variable *proto, exec_list *instructions, */ instructions->push_tail(var); - _mesa_symbol_table_add_symbol(symtab, 0, var->name, var); + symtab->add_variable(var->name, var); } static void generate_110_vs_variables(exec_list *instructions, - struct _mesa_symbol_table *symtab) + glsl_symbol_table *symtab) { for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { add_builtin_variable(& builtin_core_vs_variables[i], @@ -83,7 +82,7 @@ generate_110_vs_variables(exec_list *instructions, static void generate_120_vs_variables(exec_list *instructions, - struct _mesa_symbol_table *symtab) + glsl_symbol_table *symtab) { /* GLSL version 1.20 did not add any built-in variables in the vertex * shader. @@ -94,7 +93,7 @@ generate_120_vs_variables(exec_list *instructions, static void generate_130_vs_variables(exec_list *instructions, - struct _mesa_symbol_table *symtab) + glsl_symbol_table *symtab) { generate_120_vs_variables(instructions, symtab); -- cgit v1.2.3 From 95517faf6931765408c697e3d60e4469616ad1d3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 15:32:57 -0700 Subject: Add function to determine the scope where a variable is declared --- symbol_table.c | 30 ++++++++++++++++++++++++++++++ symbol_table.h | 3 +++ 2 files changed, 33 insertions(+) diff --git a/symbol_table.c b/symbol_table.c index 4e043d17336..5d748f45c7c 100644 --- a/symbol_table.c +++ b/symbol_table.c @@ -269,6 +269,36 @@ _mesa_symbol_table_iterator_next(struct _mesa_symbol_table_iterator *iter) } +/** + * Determine the scope "distance" of a symbol from the current scope + * + * \return + * A non-negative number for the number of scopes between the current scope + * and the scope where a symbol was defined. A value of zero means the current + * scope. A negative number if the symbol does not exist. + */ +int +_mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, + int name_space, const char *name) +{ + struct symbol_header *const hdr = find_symbol(table, name); + struct symbol *sym; + + if (hdr != NULL) { + for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { + assert(sym->hdr == hdr); + + if ((name_space == -1) || (sym->name_space == name_space)) { + assert(sym->depth <= table->depth); + return sym->depth - table->depth; + } + } + } + + return -1; +} + + void * _mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table, int name_space, const char *name) diff --git a/symbol_table.h b/symbol_table.h index d3f65e30a92..3a9994c1ac9 100644 --- a/symbol_table.h +++ b/symbol_table.h @@ -37,6 +37,9 @@ extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table); extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, int name_space, const char *name, void *declaration); +extern int _mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, + int name_space, const char *name); + extern void *_mesa_symbol_table_find_symbol( struct _mesa_symbol_table *symtab, int name_space, const char *name); -- cgit v1.2.3 From 38395c1aad82abdeecbd66bca8daaa6f431c920c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 15:34:13 -0700 Subject: Use separate namespaces for types, variables, and functions This will allow types and their constructors to be easily stored in the same symbol table. This does add a potential problem that a shader could declare a variable and a function with the same name. This appears to be forbidden by the GLSL spec. --- glsl_symbol_table.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/glsl_symbol_table.h b/glsl_symbol_table.h index 482507cf671..ad3ccf06efe 100644 --- a/glsl_symbol_table.h +++ b/glsl_symbol_table.h @@ -37,6 +37,13 @@ * type safe and some symbol table invariants. */ class glsl_symbol_table { +private: + enum glsl_symbol_name_space { + glsl_variable_name_space = 0, + glsl_type_name_space = 1, + glsl_function_name_space = 2 + }; + public: glsl_symbol_table() { @@ -68,17 +75,20 @@ public: /*@{*/ bool add_variable(const char *name, ir_variable *v) { - return _mesa_symbol_table_add_symbol(table, 0, name, v) == 0; + return _mesa_symbol_table_add_symbol(table, glsl_variable_name_space, + name, v) == 0; } bool add_type(const char *name, const glsl_type *t) { - return _mesa_symbol_table_add_symbol(table, 0, name, (void *) t) == 0; + return _mesa_symbol_table_add_symbol(table, glsl_type_name_space, + name, (void *) t) == 0; } bool add_function(const char *name, ir_function *f) { - return _mesa_symbol_table_add_symbol(table, 0, name, f) == 0; + return _mesa_symbol_table_add_symbol(table, glsl_function_name_space, + name, f) == 0; } /*@}*/ @@ -88,17 +98,20 @@ public: /*@{*/ ir_variable *get_variable(const char *name) { - return (ir_variable *) _mesa_symbol_table_find_symbol(table, 0, name); + return (ir_variable *) + _mesa_symbol_table_find_symbol(table, glsl_variable_name_space, name); } glsl_type *get_type(const char *name) { - return (glsl_type *) _mesa_symbol_table_find_symbol(table, 0, name); + return (glsl_type *) + _mesa_symbol_table_find_symbol(table, glsl_type_name_space, name); } ir_function *get_function(const char *name) { - return (ir_function *) _mesa_symbol_table_find_symbol(table, 0, name); + return (ir_function *) + _mesa_symbol_table_find_symbol(table, glsl_function_name_space, name); } /*@}*/ -- cgit v1.2.3 From ac4fdc255ba82b96cc867f084f6b781d6e95136b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 15:37:01 -0700 Subject: Add query to determine whether a name was declared at this scope This will be used to prevent a variable and a function with the same name from being declared. As a side effect, the calls to add_{type,name,function} should never fail. --- glsl_symbol_table.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glsl_symbol_table.h b/glsl_symbol_table.h index ad3ccf06efe..26b90fdb7c6 100644 --- a/glsl_symbol_table.h +++ b/glsl_symbol_table.h @@ -65,6 +65,14 @@ public: _mesa_symbol_table_pop_scope(table); } + /** + * Determine whether a name was declared at the current scope + */ + bool name_declared_this_scope(const char *name) + { + return _mesa_symbol_table_symbol_scope(table, -1, name) == 0; + } + /** * \name Methods to add symbols to the table * -- cgit v1.2.3 From 3359e58eac19dd7771a78310c8a0e3d3ded55063 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 15:38:52 -0700 Subject: Use glsl_symbol_table::name_declared_this_scope Prevent most illegal name reuse. --- ast_to_hir.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 5c87107cb5a..63f0c82d3d6 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -877,7 +877,7 @@ ast_declarator_list::hir(exec_list *instructions, /* Attempt to add the variable to the symbol table. If this fails, it * means the variable has already been declared at this scope. */ - if (!state->symbols->add_variable(decl->identifier, var)) { + if (state->symbols->name_declared_this_scope(decl->identifier)) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "`%s' redeclared", @@ -885,6 +885,10 @@ ast_declarator_list::hir(exec_list *instructions, continue; } + const bool added_variable = + state->symbols->add_variable(decl->identifier, var); + assert(added_variable); + instructions->push_tail(var); /* FINISHME: Process the declaration initializer. */ @@ -1005,7 +1009,8 @@ ast_function_definition::hir(exec_list *instructions, * seen signature for a function with the same name, or, if a match is found, * that the previously seen signature does not have an associated definition. */ - f = state->symbols->get_function(this->prototype->identifier); + const char *const name = this->prototype->identifier; + f = state->symbols->get_function(name); if (f != NULL) { foreach_iter(exec_list_iterator, iter, f->signatures) { signature = (struct ir_function_signature *) iter.get(); @@ -1021,8 +1026,7 @@ ast_function_definition::hir(exec_list *instructions, if (signature->definition != NULL) { YYLTYPE loc = this->get_location(); - _mesa_glsl_error(& loc, state, "function `%s' redefined", - this->prototype->identifier); + _mesa_glsl_error(& loc, state, "function `%s' redefined", name); signature = NULL; break; } @@ -1031,9 +1035,17 @@ ast_function_definition::hir(exec_list *instructions, signature = NULL; } + } else if (state->symbols->name_declared_this_scope(name)) { + /* This function name shadows a non-function use of the same name. + */ + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "function name `%s' conflicts with " + "non-function", name); + signature = NULL; } else { f = new ir_function(); - f->name = this->prototype->identifier; + f->name = name; state->symbols->add_function(f->name, f); } @@ -1063,7 +1075,7 @@ ast_function_definition::hir(exec_list *instructions, state); /* FINISHME: Set signature->return_type */ - label = new ir_label(this->prototype->identifier); + label = new ir_label(name); if (signature->definition == NULL) { signature->definition = label; } @@ -1083,7 +1095,16 @@ ast_function_definition::hir(exec_list *instructions, iter.remove(); instructions->push_tail(var); - state->symbols->add_variable(var->name, var); + /* The only way a parameter would "exist" is if two parameters have + * the same name. + */ + if (state->symbols->name_declared_this_scope(var->name)) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "parameter `%s' redeclared", var->name); + } else { + state->symbols->add_variable(var->name, var); + } } /* Convert the body of the function to HIR, and append the resulting -- cgit v1.2.3 From 9578c87ce23a98472d52f15b0a7063f4df036c4d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 16:44:52 -0700 Subject: Implement IR return instructions --- ir.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ ir_print_visitor.cpp | 15 +++++++++++++++ ir_print_visitor.h | 1 + ir_visitor.h | 1 + 4 files changed, 62 insertions(+) diff --git a/ir.h b/ir.h index c7fd981200f..ab598ee0b08 100644 --- a/ir.h +++ b/ir.h @@ -323,6 +323,51 @@ private: }; +/** + * \name Jump-like IR instructions. + * + * These include \c break, \c continue, \c return, and \c discard. + */ +/*@{*/ +class ir_jump : public ir_instruction { +protected: + ir_jump() + : ir_instruction(ir_op_jump) + { + /* empty */ + } +}; + +class ir_return : public ir_jump { +public: + ir_return() + : value(NULL) + { + /* empty */ + } + + ir_return(ir_expression *value) + : value(value) + { + /* empty */ + } + + ir_expression *get_value() const + { + return value; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + +private: + ir_expression *value; +}; +/*@}*/ + + struct ir_swizzle_mask { unsigned x:2; unsigned y:2; diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index b1c718d99ea..f9f3d3f17d8 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -142,3 +142,18 @@ ir_print_visitor::visit(ir_call *ir) printf("(call FINISHME: function name here\n"); printf(" (FINISHME: function paramaters here))\n"); } + + +void +ir_print_visitor::visit(ir_return *ir) +{ + printf("(return"); + + ir_expression *const value = ir->get_value(); + if (value) { + printf(" "); + value->accept(this); + } + + printf(")\n"); +} diff --git a/ir_print_visitor.h b/ir_print_visitor.h index b76de504617..121b7e8bb68 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -61,6 +61,7 @@ public: virtual void visit(ir_assignment *); virtual void visit(ir_constant *); virtual void visit(ir_call *); + virtual void visit(ir_return *); /*@}*/ }; diff --git a/ir_visitor.h b/ir_visitor.h index a2b2dd678b4..8ea416eb9f2 100644 --- a/ir_visitor.h +++ b/ir_visitor.h @@ -53,6 +53,7 @@ public: virtual void visit(class ir_assignment *) = 0; virtual void visit(class ir_constant *) = 0; virtual void visit(class ir_call *) = 0; + virtual void visit(class ir_return *) = 0; /*@}*/ }; -- cgit v1.2.3 From 16a246c049fa3c8d7841f87c8defdd0f26f302ee Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 16:45:19 -0700 Subject: Initial bits for converting AST return nodes to IR return instructions --- ast.h | 3 +++ ast_to_hir.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/ast.h b/ast.h index 1bc38d355cb..5fd69695c1a 100644 --- a/ast.h +++ b/ast.h @@ -531,6 +531,9 @@ public: ast_jump_statement(int mode, ast_expression *return_value); virtual void print(void) const; + virtual ir_instruction *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + enum ast_jump_modes { ast_continue, ast_break, diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 63f0c82d3d6..79d32165a19 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1120,3 +1120,40 @@ ast_function_definition::hir(exec_list *instructions, */ return NULL; } + + +ir_instruction * +ast_jump_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + + if (mode == ast_return) { + ir_return *inst; + + if (opt_return_value) { + /* FINISHME: Make sure the enclosing function has a non-void return + * FINISHME: type. + */ + + ir_expression *const ret = (ir_expression *) + opt_return_value->hir(instructions, state); + assert(ret != NULL); + + /* FINISHME: Make sure the type of the return value matches the return + * FINISHME: type of the enclosing function. + */ + + inst = new ir_return(ret); + } else { + /* FINISHME: Make sure the enclosing function has a void return type. + */ + inst = new ir_return; + } + + instructions->push_tail(inst); + } + + /* Jump instructions do not have r-values. + */ + return NULL; +} -- cgit v1.2.3 From 41ec6a47ab81620bab9182f987e4bc4780e3a6ab Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 17:08:05 -0700 Subject: Track the function that is currently being defined Later this will allow type checking for return statements. --- ast_to_hir.cpp | 7 +++++++ glsl_parser_extras.h | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 79d32165a19..be1a8deb938 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -63,6 +63,8 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) _mesa_glsl_initialize_variables(instructions, state); + state->current_function = NULL; + foreach (ptr, & state->translation_unit) { ((ast_node *)ptr)->hir(instructions, state); } @@ -1070,6 +1072,9 @@ ast_function_definition::hir(exec_list *instructions, } + assert(state->current_function == NULL); + state->current_function = signature; + ast_function_parameters_to_hir(& this->prototype->parameters, & signature->parameters, state); @@ -1115,6 +1120,8 @@ ast_function_definition::hir(exec_list *instructions, state->symbols->pop_scope(); + assert(state->current_function == signature); + state->current_function = NULL; /* Function definitions do not have r-values. */ diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index b3b3f868b16..dbe7c17302a 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -43,6 +43,14 @@ struct _mesa_glsl_parse_state { unsigned language_version; enum _mesa_glsl_parser_targets target; + /** + * During AST to IR conversion, pointer to current IR function + * + * Will be \c NULL whenever the AST to IR conversion is not inside a + * function definition. + */ + class ir_function_signature *current_function; + /** Was there an error during compilation? */ bool error; }; -- cgit v1.2.3 From f8f1085e5ed21f63a7ab5af02ca9a8249bf1f6a2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 11:54:03 -0700 Subject: Add test for declaring variables of type void. --- tests/void-01.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/void-01.txt diff --git a/tests/void-01.txt b/tests/void-01.txt new file mode 100644 index 00000000000..5719edc0b6c --- /dev/null +++ b/tests/void-01.txt @@ -0,0 +1,2 @@ +/* FAIL - cannot declare a variable as having type `void' */ +void foo; -- cgit v1.2.3 From 693bb11b5f817b6a299f03acaf50fc3264c853d0 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 11:57:24 -0700 Subject: Rename test GLSL sources from .txt to .glsl --- tests/parameters-01.glsl | 9 +++++++++ tests/parameters-01.txt | 9 --------- tests/parameters-02.glsl | 9 +++++++++ tests/parameters-02.txt | 9 --------- tests/parameters-03.glsl | 9 +++++++++ tests/parameters-03.txt | 9 --------- tests/void-01.glsl | 2 ++ tests/void-01.txt | 2 -- 8 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 tests/parameters-01.glsl delete mode 100644 tests/parameters-01.txt create mode 100644 tests/parameters-02.glsl delete mode 100644 tests/parameters-02.txt create mode 100644 tests/parameters-03.glsl delete mode 100644 tests/parameters-03.txt create mode 100644 tests/void-01.glsl delete mode 100644 tests/void-01.txt diff --git a/tests/parameters-01.glsl b/tests/parameters-01.glsl new file mode 100644 index 00000000000..f0beb6c35d1 --- /dev/null +++ b/tests/parameters-01.glsl @@ -0,0 +1,9 @@ +void a() +{ + ; +} + +void a() +{ + ; +} diff --git a/tests/parameters-01.txt b/tests/parameters-01.txt deleted file mode 100644 index f0beb6c35d1..00000000000 --- a/tests/parameters-01.txt +++ /dev/null @@ -1,9 +0,0 @@ -void a() -{ - ; -} - -void a() -{ - ; -} diff --git a/tests/parameters-02.glsl b/tests/parameters-02.glsl new file mode 100644 index 00000000000..58f44e532e1 --- /dev/null +++ b/tests/parameters-02.glsl @@ -0,0 +1,9 @@ +void a() +{ + ; +} + +void a(float x) +{ + ; +} diff --git a/tests/parameters-02.txt b/tests/parameters-02.txt deleted file mode 100644 index 58f44e532e1..00000000000 --- a/tests/parameters-02.txt +++ /dev/null @@ -1,9 +0,0 @@ -void a() -{ - ; -} - -void a(float x) -{ - ; -} diff --git a/tests/parameters-03.glsl b/tests/parameters-03.glsl new file mode 100644 index 00000000000..7ec30f80cc6 --- /dev/null +++ b/tests/parameters-03.glsl @@ -0,0 +1,9 @@ +/* FAIL - x is redeclared in the function body at the same scope as the + * parameter + */ +void a(float x, float y) +{ + float x; + + x = y; +} diff --git a/tests/parameters-03.txt b/tests/parameters-03.txt deleted file mode 100644 index 7ec30f80cc6..00000000000 --- a/tests/parameters-03.txt +++ /dev/null @@ -1,9 +0,0 @@ -/* FAIL - x is redeclared in the function body at the same scope as the - * parameter - */ -void a(float x, float y) -{ - float x; - - x = y; -} diff --git a/tests/void-01.glsl b/tests/void-01.glsl new file mode 100644 index 00000000000..5719edc0b6c --- /dev/null +++ b/tests/void-01.glsl @@ -0,0 +1,2 @@ +/* FAIL - cannot declare a variable as having type `void' */ +void foo; diff --git a/tests/void-01.txt b/tests/void-01.txt deleted file mode 100644 index 5719edc0b6c..00000000000 --- a/tests/void-01.txt +++ /dev/null @@ -1,2 +0,0 @@ -/* FAIL - cannot declare a variable as having type `void' */ -void foo; -- cgit v1.2.3 From 7563b50075975a3a6b32de64ecb240398d421a55 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 12:11:50 -0700 Subject: Add `void' type to table of available types This will make void-01.glsl test fail, so I may regret this later. However, this will make supporting functions that return void or functions that have a void parameter list easier to handle. --- builtin_types.sh | 3 +++ glsl_types.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/builtin_types.sh b/builtin_types.sh index b7baa59b23c..e09b8309b4a 100755 --- a/builtin_types.sh +++ b/builtin_types.sh @@ -122,6 +122,9 @@ cat < Date: Tue, 23 Mar 2010 12:19:13 -0700 Subject: Set, and require, a return type for function signatures --- ast_to_hir.cpp | 9 ++++++++- ir.cpp | 4 ++-- ir.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index be1a8deb938..feeb0d925dd 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1006,6 +1006,13 @@ ast_function_definition::hir(exec_list *instructions, ast_function_parameters_to_hir(& this->prototype->parameters, & parameters, state); + const char *return_type_name; + const glsl_type *return_type = + type_specifier_to_glsl_type(this->prototype->return_type->specifier, + & return_type_name, state); + + assert(return_type != NULL); + /* Verify that this function's signature either doesn't match a previously * seen signature for a function with the same name, or, if a match is found, @@ -1056,7 +1063,7 @@ ast_function_definition::hir(exec_list *instructions, /* Finish storing the information about this new function in its signature. */ if (signature == NULL) { - signature = new ir_function_signature(); + signature = new ir_function_signature(return_type); f->signatures.push_tail(signature); } else { /* Destroy all of the previous parameter information. The previous diff --git a/ir.cpp b/ir.cpp index 5aec70bfce8..4f7ea1bf1af 100644 --- a/ir.cpp +++ b/ir.cpp @@ -96,8 +96,8 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) } -ir_function_signature::ir_function_signature(void) - : ir_instruction(ir_op_func_sig) +ir_function_signature::ir_function_signature(const glsl_type *return_type) + : ir_instruction(ir_op_func_sig), return_type(return_type), definition(NULL) { /* empty */ } diff --git a/ir.h b/ir.h index ab598ee0b08..618f2a655af 100644 --- a/ir.h +++ b/ir.h @@ -126,7 +126,7 @@ public: /*@{*/ class ir_function_signature : public ir_instruction { public: - ir_function_signature(void); + ir_function_signature(const glsl_type *return_type); virtual void accept(ir_visitor *v) { -- cgit v1.2.3 From 9e7c34b865309c65ea5a763900e2d0eae4b58ce5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 12:21:18 -0700 Subject: Set the type of a function call to be the return type of the callee --- ir.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ir.h b/ir.h index 618f2a655af..997a37c0795 100644 --- a/ir.h +++ b/ir.h @@ -298,6 +298,8 @@ public: ir_call(const ir_function_signature *callee, exec_list *actual_parameters) : ir_instruction(ir_op_call), callee(callee) { + assert(callee->return_type != NULL); + type = callee->return_type; actual_parameters->move_nodes_to(& this->actual_parameters); } -- cgit v1.2.3 From 8400bc4d35fe7aa0ce605e4f4bb837227dfcacf9 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 12:28:28 -0700 Subject: Add is_error and is_void type queries --- glsl_types.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/glsl_types.h b/glsl_types.h index 45037b37869..57f339a9a6f 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -166,6 +166,22 @@ struct glsl_type { /* GLSL only has float matrices. */ return (matrix_rows > 0) && (base_type == GLSL_TYPE_FLOAT); } + + /** + * Query whether or not a type is the void type singleton. + */ + bool is_void() const + { + return base_type == GLSL_TYPE_VOID; + } + + /** + * Query whether or not a type is the error type singleton. + */ + bool is_error() const + { + return base_type == GLSL_TYPE_ERROR; + } }; struct glsl_struct_field { -- cgit v1.2.3 From cec65a6b76290ee4da91691bd3ef01c3fb8a0c37 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 12:28:44 -0700 Subject: Generate an error for variables declared with type void --- ast_to_hir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index feeb0d925dd..62f2068b3a2 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -841,7 +841,7 @@ ast_declarator_list::hir(exec_list *instructions, * FINISHME: declaration at a higher scope. */ - if (decl_type == NULL) { + if ((decl_type == NULL) || decl_type->is_void()) { YYLTYPE loc; loc = this->get_location(); -- cgit v1.2.3 From 6985a43832fa170d62ef08f831210248b4a4b03e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 23 Mar 2010 20:24:11 -0700 Subject: Clean the built sources with make clean. --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 0865977329d..03aae628f1f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,7 @@ glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h +CLEANFILES = $(BUILT_SOURCES) glsl_parser.h: glsl_parser.ypp -- cgit v1.2.3 From e5ba18083b20da540ea0dc216e744a4c3e550833 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 23 Mar 2010 20:24:33 -0700 Subject: Use bash for the built file generation since builtin_types.sh requires it. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 03aae628f1f..f299c3fc4f9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,4 +38,4 @@ glsl_parser.h: glsl_parser.ypp $(LEXCOMPILE) --outfile="$@" $< builtin_types.h: builtin_types.sh - sh ./builtin_types.sh > builtin_types.h + bash ./builtin_types.sh > builtin_types.h -- cgit v1.2.3 From f41fc537280d048bca2a3b23abd17d8bb3eff907 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 23 Mar 2010 20:43:10 -0700 Subject: Include other generated sources in BUILT_SOURCES. Otherwise, having cleaned glsl_parser.h, we'd never regenerate it because glsl_parser.cpp was already right where it needed to be. --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index f299c3fc4f9..48b4b3921c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,10 +29,10 @@ glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ ir.cpp hir_field_selection.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp -BUILT_SOURCES = glsl_parser.h builtin_types.h +BUILT_SOURCES = glsl_parser.h builtin_types.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) -glsl_parser.h: glsl_parser.ypp +glsl_parser.h: glsl_parser.cpp .lpp.cpp: $(LEXCOMPILE) --outfile="$@" $< -- cgit v1.2.3 From f3f111eac45162e9634208cd7305981d8393328d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 13:04:19 -0700 Subject: Fix typographical errors of "FINISHME" --- ast_to_hir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 62f2068b3a2..b4a3d054eb5 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -769,7 +769,7 @@ type_specifier_to_glsl_type(const struct ast_type_specifier *spec, *name = spec->type_name; /* FINISHME: Handle array declarations. Note that this requires complete - * FINSIHME: handling of constant expressions. + * FINISHME: handling of constant expressions. */ } @@ -869,7 +869,7 @@ ast_declarator_list::hir(exec_list *instructions, var = new ir_variable(var_type, decl->identifier); - /* FINSIHME: Variables that are attribute, uniform, varying, in, or + /* FINISHME: Variables that are attribute, uniform, varying, in, or * FINISHME: out varibles must be declared either at global scope or * FINISHME: in a parameter list (in and out only). */ -- cgit v1.2.3 From 71d0bbfcb2853f37b580ec7b705e55bb0eb426fa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 13:21:19 -0700 Subject: Disallow passing NULL for state to _mesa_glsl_error The two places that were still passing NULL had a state pointer to pass. Not passing it in these places prevented termination of compilation of erroneous programs. --- ast_to_hir.cpp | 4 ++-- glsl_parser_extras.cpp | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index b4a3d054eb5..563cb92122a 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -650,7 +650,7 @@ ast_expression::hir(exec_list *instructions, if (var != NULL) { type = result->type; } else { - _mesa_glsl_error(& loc, NULL, "`%s' undeclared", + _mesa_glsl_error(& loc, state, "`%s' undeclared", this->primary_expression.identifier); error_emitted = true; @@ -704,7 +704,7 @@ ast_expression::hir(exec_list *instructions, } if (is_error_type(type) && !error_emitted) - _mesa_glsl_error(& loc, NULL, "type mismatch"); + _mesa_glsl_error(& loc, state, "type mismatch"); return result; } diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 3a2038a1532..b774d8b5f4e 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -44,8 +44,7 @@ _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, int len; va_list ap; - if (state) - state->error = true; + state->error = true; len = snprintf(buf, sizeof(buf), "%u:%u(%u): error: ", locp->source, locp->first_line, locp->first_column); -- cgit v1.2.3 From 0bb1c3c1539fcadaa90d592a296c2ff1de3787a4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 13:23:31 -0700 Subject: Add *some* type checking for assignments --- ast_to_hir.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 563cb92122a..ace80718d59 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -331,6 +331,45 @@ relational_result_type(const struct glsl_type *type_a, } +/** + * Validates that a value can be assigned to a location with a specified type + * + * Validates that \c rhs can be assigned to some location. If the types are + * not an exact match but an automatic conversion is possible, \c rhs will be + * converted. + * + * \return + * \c NULL if \c rhs cannot be assigned to a location with type \c lhs_type. + * Otherwise the actual RHS to be assigned will be returned. This may be + * \c rhs, or it may be \c rhs after some type conversion. + * + * \note + * In addition to being used for assignments, this function is used to + * type-check return values. + */ +ir_instruction * +validate_assignment(const glsl_type *lhs_type, ir_instruction *rhs) +{ + const glsl_type *const rhs_type = rhs->type; + + /* If there is already some error in the RHS, just return it. Anything + * else will lead to an avalanche of error message back to the user. + */ + if (rhs_type->is_error()) + return rhs; + + /* FINISHME: For GLSL 1.10, check that the types are not arrays. */ + + /* If the types are identical, the assignment can trivially proceed. + */ + if (rhs_type == lhs_type) + return rhs; + + /* FINISHME: Check for and apply automatic conversions. */ + return NULL; +} + + ir_instruction * ast_node::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -448,8 +487,11 @@ ast_expression::hir(exec_list *instructions, } } - /* FINISHME: Check that the LHS and RHS have matching types. */ - /* FINISHME: For GLSL 1.10, check that the types are not arrays. */ + ir_instruction *rhs = validate_assignment(op[0]->type, op[1]); + if (rhs == NULL) { + type = glsl_error_type; + rhs = op[1]; + } ir_instruction *tmp = new ir_assignment(op[0], op[1], NULL); instructions->push_tail(tmp); -- cgit v1.2.3 From 1e5cd2b05b2354006f8e33d20c3535ac2219b573 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 13:23:53 -0700 Subject: Add test for invalid assignment of function return value --- tests/function-04.glsl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/function-04.glsl diff --git a/tests/function-04.glsl b/tests/function-04.glsl new file mode 100644 index 00000000000..dfc0d2b7a6c --- /dev/null +++ b/tests/function-04.glsl @@ -0,0 +1,15 @@ +/* FAIL - type mismatch in assignment */ + +vec3 foo(float x, float y, float z) +{ + vec3 v; + v.x = x; + v.y = y; + v.z = z; + return v; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0); +} -- cgit v1.2.3 From cb7d066967b85c52fe15590b56529254516261e7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 15:03:46 -0700 Subject: Add query to determine whether a type is a sampler --- glsl_types.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glsl_types.h b/glsl_types.h index 57f339a9a6f..b1cd9a9d637 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -167,6 +167,14 @@ struct glsl_type { return (matrix_rows > 0) && (base_type == GLSL_TYPE_FLOAT); } + /** + * Query whether or not a type is a sampler + */ + bool is_sampler() const + { + return base_type == GLSL_TYPE_SAMPLER; + } + /** * Query whether or not a type is the void type singleton. */ -- cgit v1.2.3 From abef9557642f77d406452f3c32e5e49ced212571 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 15:08:30 -0700 Subject: Begin processing constructors Right now, reject constructors for samplers because the are illegal. --- ast_function.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index a120eb8dd63..7082ed3c140 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -88,18 +88,35 @@ ast_function_expression::hir(exec_list *instructions, * 2. methods - Only the .length() method of array types. * 3. functions - Calls to regular old functions. * - * There are two kinds of constructor call. Constructors for built-in - * language types, such as mat4 and vec2, are free form. The only - * requirement is that the parameters must provide enough values of the - * correct scalar type. Constructors for arrays and structures must have - * the exact number of parameters with matching types in the correct order. - * These constructors follow essentially the same type matching rules as - * functions. - * * Method calls are actually detected when the ast_field_selection * expression is handled. */ if (is_constructor()) { + const ast_type_specifier *type = (ast_type_specifier *) subexpressions[0]; + YYLTYPE loc = type->get_location(); + + const glsl_type *const constructor_type = + state->symbols->get_type(type->type_name); + + + /* Constructors for samplers are illegal. + */ + if (constructor_type->is_sampler()) { + _mesa_glsl_error(& loc, state, "cannot construct sampler type `%s'", + constructor_type->name); + return ir_call::get_error_instruction(); + } + + + /* There are two kinds of constructor call. Constructors for built-in + * language types, such as mat4 and vec2, are free form. The only + * requirement is that the parameters must provide enough values of the + * correct scalar type. Constructors for arrays and structures must + * have the exact number of parameters with matching types in the + * correct order. These constructors follow essentially the same type + * matching rules as functions. + */ + return ir_call::get_error_instruction(); } else { const ast_expression *id = subexpressions[0]; -- cgit v1.2.3 From 7aeb6abda7da155d81fc4bda5c0c03ff28e5ed0c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 17:31:03 -0700 Subject: Add glsl_type::is_numeric and glsl_type::is_boolean queries --- glsl_types.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/glsl_types.h b/glsl_types.h index b1cd9a9d637..7c48e792eb5 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -167,6 +167,22 @@ struct glsl_type { return (matrix_rows > 0) && (base_type == GLSL_TYPE_FLOAT); } + /** + * Query whether or not a type is a non-array numeric type + */ + bool is_numeric() const + { + return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_FLOAT); + } + + /** + * Query whether or not a type is a non-array boolean type + */ + bool is_boolean() const + { + return base_type == GLSL_TYPE_BOOL; + } + /** * Query whether or not a type is a sampler */ -- cgit v1.2.3 From bb7e00a1cd63f3012226253bb0121922419a5f23 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 17:31:39 -0700 Subject: Add glsl_type::get_base_type query Retreives the glsl_type that corresponds to the base type of a numeric scalar / vector / matrix type. So vec4 returns float, etc. --- glsl_types.cpp | 17 +++++++++++++++++ glsl_types.h | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/glsl_types.cpp b/glsl_types.cpp index af6a40800b0..2b06a335538 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -142,3 +142,20 @@ _mesa_glsl_get_vector_type(unsigned base_type, unsigned vector_length) return glsl_error_type; } } + + +const glsl_type *glsl_type::get_base_type() const +{ + switch (base_type) { + case GLSL_TYPE_UINT: + return glsl_uint_type; + case GLSL_TYPE_INT: + return glsl_int_type; + case GLSL_TYPE_FLOAT: + return glsl_float_type; + case GLSL_TYPE_BOOL: + return glsl_bool_type; + default: + return glsl_error_type; + } +} diff --git a/glsl_types.h b/glsl_types.h index 7c48e792eb5..97d8390e600 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -137,6 +137,16 @@ struct glsl_type { this->fields.structure = fields; } + /** + * For numeric and boolean derrived types returns the basic scalar type + * + * If the type is a numeric or boolean scalar, vector, or matrix type, + * this function gets the scalar type of the individual components. For + * all other types, including arrays of numeric or boolean types, the + * error type is returned. + */ + const glsl_type *get_base_type() const; + /** * Query whether or not a type is a scalar (non-vector and non-matrix). */ -- cgit v1.2.3 From 882dad75408fc4071a9dd700309f9e54f6ad2650 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 23 Mar 2010 17:42:04 -0700 Subject: ir_function constructor now takes the function name as a parameter --- ast_to_hir.cpp | 4 +--- ir.cpp | 4 ++-- ir.h | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index ace80718d59..f7c82fab4bf 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1095,9 +1095,7 @@ ast_function_definition::hir(exec_list *instructions, "non-function", name); signature = NULL; } else { - f = new ir_function(); - f->name = name; - + f = new ir_function(name); state->symbols->add_function(f->name, f); } diff --git a/ir.cpp b/ir.cpp index 4f7ea1bf1af..26e73943053 100644 --- a/ir.cpp +++ b/ir.cpp @@ -103,8 +103,8 @@ ir_function_signature::ir_function_signature(const glsl_type *return_type) } -ir_function::ir_function(void) - : ir_instruction(ir_op_func) +ir_function::ir_function(const char *name) + : ir_instruction(ir_op_func), name(name) { /* empty */ } diff --git a/ir.h b/ir.h index 997a37c0795..7db617d65b8 100644 --- a/ir.h +++ b/ir.h @@ -157,7 +157,7 @@ public: */ class ir_function : public ir_instruction { public: - ir_function(void); + ir_function(const char *name); virtual void accept(ir_visitor *v) { -- cgit v1.2.3 From 7d9bce35517f1a512943cf5e1165ff9e0db44e5f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 12:08:46 -0700 Subject: Add (negative) test for constructing samplers --- tests/constructor-02.glsl | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/constructor-02.glsl diff --git a/tests/constructor-02.glsl b/tests/constructor-02.glsl new file mode 100644 index 00000000000..47acbe9db14 --- /dev/null +++ b/tests/constructor-02.glsl @@ -0,0 +1,7 @@ +/* FAIL - cannot construct samplers */ +void main() +{ + int i; + + i = sampler2D(0); +} -- cgit v1.2.3 From 44bb1a62f9fa55a2f4febc87abcfb78386283c0e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 14:56:36 -0700 Subject: Allow duplicate symbols at the same scope that are in different name spaces --- symbol_table.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/symbol_table.c b/symbol_table.c index 5d748f45c7c..0f0df7a261b 100644 --- a/symbol_table.c +++ b/symbol_table.c @@ -347,10 +347,16 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, check_symbol_table(table); - /* If the symbol already exists at this scope, it cannot be added to the - * table. + /* If the symbol already exists in this namespace at this scope, it cannot + * be added to the table. */ - if (hdr->symbols && (hdr->symbols->depth == table->depth)) + for (sym = hdr->symbols + ; (sym != NULL) && (sym->name_space != name_space) + ; sym = sym->next_with_same_name) { + /* empty */ + } + + if (sym && (sym->depth == table->depth)) return -1; sym = calloc(1, sizeof(*sym)); -- cgit v1.2.3 From 2f4240fb0276bd18b86adadd41664ca0c9f10da6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 15:12:21 -0700 Subject: Add method to set the swizzle of an ir_dereference --- ir.cpp | 26 ++++++++++++++++++++++++++ ir.h | 7 +++++++ 2 files changed, 33 insertions(+) diff --git a/ir.cpp b/ir.cpp index 26e73943053..49df75425e6 100644 --- a/ir.cpp +++ b/ir.cpp @@ -87,6 +87,32 @@ ir_dereference::ir_dereference(ir_instruction *var) } +void +ir_dereference::set_swizzle(unsigned x, unsigned y, unsigned z, unsigned w, + unsigned count) +{ + assert((count >= 1) && (count <= 4)); + + const unsigned dup_mask = 0 + | ((count > 1) ? ((1U << y) & ((1U << x) )) : 0) + | ((count > 2) ? ((1U << z) & ((1U << x) | (1U << y) )) : 0) + | ((count > 3) ? ((1U << w) & ((1U << x) | (1U << y) | (1U << z))) : 0); + + assert(x <= 3); + assert(y <= 3); + assert(z <= 3); + assert(w <= 3); + + selector.swizzle.x = x; + selector.swizzle.y = y; + selector.swizzle.z = z; + selector.swizzle.w = w; + selector.swizzle.num_components = count; + selector.swizzle.has_duplicates = dup_mask != 0; +} + + + ir_variable::ir_variable(const struct glsl_type *type, const char *name) : ir_instruction(ir_op_var_decl), read_only(false), centroid(false), invariant(false), mode(ir_var_auto), interpolation(ir_var_smooth) diff --git a/ir.h b/ir.h index 7db617d65b8..bbf53540dbe 100644 --- a/ir.h +++ b/ir.h @@ -398,6 +398,13 @@ public: v->visit(this); } + /** + * Setting the swizzle of a derefernce + */ + void set_swizzle(unsigned x, unsigned y, unsigned z, unsigned w, + unsigned count); + + enum { ir_reference_variable, ir_reference_array, -- cgit v1.2.3 From afbe26fd61abb3c28c1b0165427b77fd2fed355d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 15:25:23 -0700 Subject: Use ir_dereference::set_swizzle --- hir_field_selection.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 8bef094c60f..554fdd30d53 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -34,7 +34,7 @@ #define I 13 static bool -generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, +generate_swizzle(const char *str, ir_dereference *deref, unsigned vector_length) { /* For each possible swizzle character, this table encodes the value in @@ -75,8 +75,6 @@ generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, int swiz_idx[4] = { 0, 0, 0, 0 }; unsigned base; - unsigned dup_mask = 0; - unsigned seen_mask = 0; unsigned i; @@ -90,8 +88,6 @@ generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, for (i = 0; (i < 4) && (str[i] != '\0'); i++) { - unsigned bit; - /* Validate the next character, and, as described above, convert it to a * swizzle index. */ @@ -101,26 +97,12 @@ generate_swizzle(const char *str, struct ir_swizzle_mask *swiz, swiz_idx[i] = idx_map[str[0] - 'a'] - base; if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) return false; - - - /* Track a bit-mask of the swizzle index values that have been seen. If - * a value is seen more than once, set the "duplicate" flag. - */ - bit = (1U << swiz_idx[i]); - dup_mask |= seen_mask & bit; - seen_mask |= bit; } if (str[i] != '\0') return false; - swiz->x = swiz_idx[0]; - swiz->y = swiz_idx[1]; - swiz->z = swiz_idx[2]; - swiz->w = swiz_idx[3]; - swiz->num_components = i; - swiz->has_duplicates = (dup_mask != 0); - + deref->set_swizzle(swiz_idx[0], swiz_idx[1], swiz_idx[2], swiz_idx[3], i); return true; } @@ -158,8 +140,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, loc = expr->get_location(); if (op->type->is_vector()) { if (generate_swizzle(expr->primary_expression.identifier, - & deref->selector.swizzle, - op->type->vector_elements)) { + deref, op->type->vector_elements)) { /* Based on the number of elements in the swizzle and the base type * (i.e., float, int, unsigned, or bool) of the vector being swizzled, * generate the type of the resulting value. -- cgit v1.2.3 From 9e97ffb7547f25cbec96f1fb2c60f3ab9b0f0488 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 15:27:04 -0700 Subject: Trivial cleanups in generate_swizzle Add 'const' and 'static const' in a couple of places. --- hir_field_selection.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 554fdd30d53..9928b7b0bfa 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -42,7 +42,7 @@ generate_swizzle(const char *str, ir_dereference *deref, * swizzle characters (e.g., 'k'), a special value is used that will allow * detection of errors. */ - unsigned char base_idx[26] = { + static const unsigned char base_idx[26] = { /* a b c d e f g h i j k l m */ R, R, I, I, I, I, R, I, I, I, I, I, I, /* n o p q r s t u v w x y z */ @@ -66,7 +66,7 @@ generate_swizzle(const char *str, ir_dereference *deref, * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range * [0,3], the error is detected. */ - unsigned char idx_map[26] = { + static const unsigned char idx_map[26] = { /* a b c d e f g h i j k l m */ R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, /* n o p q r s t u v w x y z */ @@ -74,7 +74,6 @@ generate_swizzle(const char *str, ir_dereference *deref, }; int swiz_idx[4] = { 0, 0, 0, 0 }; - unsigned base; unsigned i; @@ -84,7 +83,7 @@ generate_swizzle(const char *str, ir_dereference *deref, if ((str[0] < 'a') || (str[0] > 'z')) return false; - base = base_idx[str[0] - 'a']; + const unsigned base = base_idx[str[0] - 'a']; for (i = 0; (i < 4) && (str[i] != '\0'); i++) { -- cgit v1.2.3 From 4d184a1d02edef1720bb8093a91596831f7c017d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 15:27:50 -0700 Subject: Fix typo in swizzle processing loop One of the accesses to str in the loop used str[0] instead of str[i]. Reported-by: Kenneth Graunke --- hir_field_selection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 9928b7b0bfa..aa53120dbdb 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -93,7 +93,7 @@ generate_swizzle(const char *str, ir_dereference *deref, if ((str[i] < 'a') || (str[i] > 'z')) return false; - swiz_idx[i] = idx_map[str[0] - 'a'] - base; + swiz_idx[i] = idx_map[str[i] - 'a'] - base; if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) return false; } -- cgit v1.2.3 From 9ff8f3777e7388eda2b935e74aafa7a9429a3d72 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 17:05:09 -0700 Subject: Add class-private handles to matrix types in glsl_type --- builtin_types.sh | 20 +++++++++++++++----- glsl_types.h | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/builtin_types.sh b/builtin_types.sh index e09b8309b4a..6dd0ea7403b 100755 --- a/builtin_types.sh +++ b/builtin_types.sh @@ -155,6 +155,7 @@ for i in 2 3 4; do gen_integral_type "vec$i" "GLSL_TYPE_FLOAT" $i 0 done +matX_index=$index for i in 2 3 4; do gen_integral_type "mat$i" "GLSL_TYPE_FLOAT" $i $i done @@ -175,6 +176,9 @@ echo echo 'const struct glsl_type *const glsl_bool_type = & builtin_core_types['$bool_index'];' echo 'const struct glsl_type *const glsl_int_type = & builtin_core_types['$int_index'];' echo 'const struct glsl_type *const glsl_float_type = & builtin_core_types['$float_index'];' +echo 'const glsl_type *const glsl_type::mat2_type = & builtin_core_types['$(($matX_index + 0))'];' +echo 'const glsl_type *const glsl_type::mat3_type = & builtin_core_types['$(($matX_index + 1))'];' +echo 'const glsl_type *const glsl_type::mat4_type = & builtin_core_types['$(($matX_index + 2))'];' echo '/*@}*/' echo @@ -268,16 +272,22 @@ echo '/** \name Types added in GLSL 1.20' echo ' */' echo '/*@{*/' gen_header "120" -for i in 2 3 4; do - for j in 2 3 4; do - if [ $i -ne $j ]; then - gen_integral_type "mat${i}x${j}" "GLSL_TYPE_FLOAT" $i $j +for c in 2 3 4; do + for r in 2 3 4; do + if [ $c -ne $r ]; then + gen_integral_type "mat${c}x${r}" "GLSL_TYPE_FLOAT" $c $r fi done done gen_footer -echo '/*@}*/' +echo 'const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0];' +echo 'const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1];' +echo 'const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2];' +echo 'const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3];' +echo 'const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4];' +echo 'const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5];' +echo '/*@}*/' echo echo '/** \name Types added in GLSL 1.30' echo ' */' diff --git a/glsl_types.h b/glsl_types.h index 97d8390e600..4a92712b211 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -216,6 +216,22 @@ struct glsl_type { { return base_type == GLSL_TYPE_ERROR; } + +private: + /** + * \name Pointers to various type singletons + */ + /*@{*/ + static const glsl_type *const mat2_type; + static const glsl_type *const mat2x3_type; + static const glsl_type *const mat2x4_type; + static const glsl_type *const mat3x2_type; + static const glsl_type *const mat3_type; + static const glsl_type *const mat3x4_type; + static const glsl_type *const mat4x2_type; + static const glsl_type *const mat4x3_type; + static const glsl_type *const mat4_type; + /*@}*/ }; struct glsl_struct_field { -- cgit v1.2.3 From 60b54d977a7b3df9612eb9232f6b5d6c3f393e2f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 17:08:13 -0700 Subject: Replace accesses to glsl_type data with query functions In these particular cases, using the query functions makes it more obvious what is happening. --- ast_to_hir.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index f7c82fab4bf..1d9df36143e 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -83,8 +83,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * multiply (*), and divide (/) operate on integer and * floating-point scalars, vectors, and matrices." */ - if (! is_numeric_base_type(type_a->base_type) - || ! is_numeric_base_type(type_b->base_type)) { + if (!type_a->is_numeric() || !type_b->is_numeric()) { return glsl_error_type; } @@ -109,9 +108,9 @@ arithmetic_result_type(const struct glsl_type *type_a, * * From this rule and the preceeding conversion it can be inferred that * both types must be GLSL_TYPE_FLOAT, or GLSL_TYPE_UINT, or GLSL_TYPE_INT. - * The is_numeric_base_type check above already filtered out the case - * where either type is not one of these, so now the base types need only - * be tested for equality. + * The is_numeric check above already filtered out the case where either + * type is not one of these, so now the base types need only be tested for + * equality. */ if (type_a->base_type != type_b->base_type) { return glsl_error_type; @@ -144,8 +143,8 @@ arithmetic_result_type(const struct glsl_type *type_a, * , , and have been * handled. */ - assert(type_a->vector_elements > 1); - assert(type_b->vector_elements > 1); + assert(!type_a->is_scalar()); + assert(!type_b->is_scalar()); /* "* The two operands are vectors of the same size. In this case, the * operation is done component-wise resulting in the same size @@ -164,7 +163,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * be matrix. Further, since there are no integer matrix types, the base * type of both operands must be float. */ - assert((type_a->matrix_rows > 1) || (type_b->matrix_rows > 1)); + assert(type_a->is_matrix() || type_b->is_matrix()); assert(type_a->base_type == GLSL_TYPE_FLOAT); assert(type_b->base_type == GLSL_TYPE_FLOAT); -- cgit v1.2.3 From 3209c4e3692eaa9468aadcd21ce402e6b0d5b7dd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 17:11:30 -0700 Subject: Add glsl_type::get_instance method Gets the singleton corresponding to a particular scalar, vector, or matrix type. --- glsl_types.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ glsl_types.h | 6 ++++++ 2 files changed, 62 insertions(+) diff --git a/glsl_types.cpp b/glsl_types.cpp index 2b06a335538..6dcbba8e8cd 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -159,3 +159,59 @@ const glsl_type *glsl_type::get_base_type() const return glsl_error_type; } } + + +const glsl_type * +glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) +{ + if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4)) + return glsl_error_type; + + + /* Treat GLSL vectors as Nx1 matrices. + */ + if (columns == 1) { + switch (base_type) { + case GLSL_TYPE_UINT: + return glsl_uint_type + (rows - 1); + case GLSL_TYPE_INT: + return glsl_int_type + (rows - 1); + case GLSL_TYPE_FLOAT: + return glsl_float_type + (rows - 1); + case GLSL_TYPE_BOOL: + return glsl_bool_type + (rows - 1); + default: + return glsl_error_type; + } + } else { + if ((base_type != GLSL_TYPE_FLOAT) || (rows == 1)) + return glsl_error_type; + + /* GLSL matrix types are named mat{COLUMNS}x{ROWS}. Only the following + * combinations are valid: + * + * 1 2 3 4 + * 1 + * 2 x x x + * 3 x x x + * 4 x x x + */ +#define IDX(c,r) (((c-1)*3) + (r-1)) + + switch (IDX(columns, rows)) { + case IDX(2,2): return mat2_type; + case IDX(2,3): return mat2x3_type; + case IDX(2,4): return mat2x4_type; + case IDX(3,2): return mat3x2_type; + case IDX(3,3): return mat3_type; + case IDX(3,4): return mat3x4_type; + case IDX(4,2): return mat4x2_type; + case IDX(4,3): return mat4x3_type; + case IDX(4,4): return mat4_type; + default: return glsl_error_type; + } + } + + assert(!"Should not get here."); + return glsl_error_type; +} diff --git a/glsl_types.h b/glsl_types.h index 4a92712b211..a7897719fb4 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -147,6 +147,12 @@ struct glsl_type { */ const glsl_type *get_base_type() const; + /** + * Get the instance of a built-in scalar, vector, or matrix type + */ + static const glsl_type *get_instance(unsigned base_type, unsigned rows, + unsigned columns); + /** * Query whether or not a type is a scalar (non-vector and non-matrix). */ -- cgit v1.2.3 From e4fca97afd27f72d056e245aaa5761579ee78850 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 17:42:59 -0700 Subject: Add some matrix math tests --- tests/matrix-01.glsl | 6 ++++++ tests/matrix-02.glsl | 6 ++++++ tests/matrix-03.glsl | 6 ++++++ tests/matrix-04.glsl | 6 ++++++ tests/matrix-05.glsl | 6 ++++++ tests/matrix-06.glsl | 6 ++++++ tests/matrix-07.glsl | 27 +++++++++++++++++++++++++++ tests/matrix-08.glsl | 19 +++++++++++++++++++ 8 files changed, 82 insertions(+) create mode 100644 tests/matrix-01.glsl create mode 100644 tests/matrix-02.glsl create mode 100644 tests/matrix-03.glsl create mode 100644 tests/matrix-04.glsl create mode 100644 tests/matrix-05.glsl create mode 100644 tests/matrix-06.glsl create mode 100644 tests/matrix-07.glsl create mode 100644 tests/matrix-08.glsl diff --git a/tests/matrix-01.glsl b/tests/matrix-01.glsl new file mode 100644 index 00000000000..f46416c8f67 --- /dev/null +++ b/tests/matrix-01.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat2x3 m; +} diff --git a/tests/matrix-02.glsl b/tests/matrix-02.glsl new file mode 100644 index 00000000000..0630722b795 --- /dev/null +++ b/tests/matrix-02.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat2x4 m; +} diff --git a/tests/matrix-03.glsl b/tests/matrix-03.glsl new file mode 100644 index 00000000000..925dc806258 --- /dev/null +++ b/tests/matrix-03.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat3x2 m; +} diff --git a/tests/matrix-04.glsl b/tests/matrix-04.glsl new file mode 100644 index 00000000000..5275619b319 --- /dev/null +++ b/tests/matrix-04.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat3x4 m; +} diff --git a/tests/matrix-05.glsl b/tests/matrix-05.glsl new file mode 100644 index 00000000000..74e1fd25148 --- /dev/null +++ b/tests/matrix-05.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat4x2 m; +} diff --git a/tests/matrix-06.glsl b/tests/matrix-06.glsl new file mode 100644 index 00000000000..0a512b85234 --- /dev/null +++ b/tests/matrix-06.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat4x3 m; +} diff --git a/tests/matrix-07.glsl b/tests/matrix-07.glsl new file mode 100644 index 00000000000..0b59aa69d50 --- /dev/null +++ b/tests/matrix-07.glsl @@ -0,0 +1,27 @@ +/* PASS */ + +uniform mat2 a; +uniform mat2 b; +uniform mat2 c; +uniform mat2 d; +uniform mat3 e; +uniform mat3 f; +uniform mat3 g; +uniform mat3 h; +uniform mat4 i; +uniform mat4 j; +uniform mat4 k; +uniform mat4 l; + +void main() +{ + mat2 x; + mat3 y; + mat4 z; + + x = a * b + c / d; + y = e * f + g / h; + z = i * j + k / l; + + gl_Position = gl_Vertex; +} diff --git a/tests/matrix-08.glsl b/tests/matrix-08.glsl new file mode 100644 index 00000000000..38138d22de4 --- /dev/null +++ b/tests/matrix-08.glsl @@ -0,0 +1,19 @@ +#version 120 +/* PASS */ + +uniform mat2x3 a; +uniform mat3x2 b; +uniform mat3x3 c; +uniform mat3x3 d; + +void main() +{ + mat3x3 x; + + /* Multiplying a 2 column, 3 row matrix with a 3 column, 2 row matrix + * results in a 3 column, 3 row matrix. + */ + x = (a * b) + c / d; + + gl_Position = gl_Vertex; +} -- cgit v1.2.3 From d2b6bc651a23cf45e36c39efd34532ec78d51928 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 17:45:14 -0700 Subject: Use glsl_type::get_instance instead of symbol table look-up --- ast_to_hir.cpp | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1d9df36143e..5fe44ec4697 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -192,25 +192,9 @@ arithmetic_result_type(const struct glsl_type *type_a, } else { if (type_a->is_matrix() && type_b->is_matrix()) { if (type_a->vector_elements == type_b->matrix_rows) { - char type_name[7]; - const struct glsl_type *t; - - type_name[0] = 'm'; - type_name[1] = 'a'; - type_name[2] = 't'; - - if (type_a->matrix_rows == type_b->vector_elements) { - type_name[3] = '0' + type_a->matrix_rows; - type_name[4] = '\0'; - } else { - type_name[3] = '0' + type_a->matrix_rows; - type_name[4] = 'x'; - type_name[5] = '0' + type_b->vector_elements; - type_name[6] = '\0'; - } - - t = state->symbols->get_type(type_name); - return (t != NULL) ? t : glsl_error_type; + return glsl_type::get_instance(type_a->base_type, + type_b->matrix_rows, + type_a->vector_elements); } } else if (type_a->is_matrix()) { /* A is a matrix and B is a column vector. Columns of A must match -- cgit v1.2.3 From c4e2627045af3d12aa2a2aceb809e5e436aca133 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 17:46:39 -0700 Subject: Use glsl_type::get_instance instead of _mesa_glsl_get_vector_type --- hir_field_selection.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index aa53120dbdb..5f548bfa0f8 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -145,8 +145,9 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, * generate the type of the resulting value. */ deref->type = - _mesa_glsl_get_vector_type(op->type->base_type, - deref->selector.swizzle.num_components); + glsl_type::get_instance(op->type->base_type, + deref->selector.swizzle.num_components, + 1); } else { /* FINISHME: Logging of error messages should be moved into * FINISHME: generate_swizzle. This allows the generation of more -- cgit v1.2.3 From 532edd9bc49ce3430e5084957e2ecf453d1c3d24 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 17:47:20 -0700 Subject: Remove unused _mesa_glsl_get_vector_type This function has been completely replaced by glsl_type::get_instance. --- glsl_types.cpp | 50 -------------------------------------------------- glsl_types.h | 3 --- 2 files changed, 53 deletions(-) diff --git a/glsl_types.cpp b/glsl_types.cpp index 6dcbba8e8cd..b2631efef9b 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -94,56 +94,6 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) } -const struct glsl_type * -_mesa_glsl_get_vector_type(unsigned base_type, unsigned vector_length) -{ - switch (base_type) { - case GLSL_TYPE_UINT: - switch (vector_length) { - case 1: - case 2: - case 3: - case 4: - return glsl_uint_type + (vector_length - 1); - default: - return glsl_error_type; - } - case GLSL_TYPE_INT: - switch (vector_length) { - case 1: - case 2: - case 3: - case 4: - return glsl_int_type + (vector_length - 1); - default: - return glsl_error_type; - } - case GLSL_TYPE_FLOAT: - switch (vector_length) { - case 1: - case 2: - case 3: - case 4: - return glsl_float_type + (vector_length - 1); - default: - return glsl_error_type; - } - case GLSL_TYPE_BOOL: - switch (vector_length) { - case 1: - case 2: - case 3: - case 4: - return glsl_bool_type + (vector_length - 1); - default: - return glsl_error_type; - } - default: - return glsl_error_type; - } -} - - const glsl_type *glsl_type::get_base_type() const { switch (base_type) { diff --git a/glsl_types.h b/glsl_types.h index a7897719fb4..04a9ccf4146 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -254,9 +254,6 @@ extern "C" { extern void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); -extern const struct glsl_type * -_mesa_glsl_get_vector_type(unsigned base_type, unsigned vector_length); - extern const struct glsl_type *const glsl_error_type; extern const struct glsl_type *const glsl_int_type; extern const struct glsl_type *const glsl_uint_type; -- cgit v1.2.3 From 664da2510aa11c5319acad3bd6e96a9504a0b3fc Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Mar 2010 17:53:53 -0700 Subject: Replace several field comparisons with a single pointer comparison The only way the specified type fields can match is if the types are the same. Previous tests (and assertions) have filtered away all other possible cases. --- ast_to_hir.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 5fe44ec4697..cb746ed59a9 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -151,10 +151,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * vector." */ if (type_a->is_vector() && type_b->is_vector()) { - if (type_a->vector_elements == type_b->vector_elements) - return type_a; - else - return glsl_error_type; + return (type_a == type_b) ? type_a : glsl_error_type; } /* All of the combinations of , , @@ -183,12 +180,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * more detail how vectors and matrices are operated on." */ if (! multiply) { - if (type_a->is_matrix() && type_b->is_matrix() - && (type_a->vector_elements == type_b->vector_elements) - && (type_a->matrix_rows == type_b->matrix_rows)) - return type_a; - else - return glsl_error_type; + return (type_a == type_b) ? type_a : glsl_error_type; } else { if (type_a->is_matrix() && type_b->is_matrix()) { if (type_a->vector_elements == type_b->matrix_rows) { -- cgit v1.2.3 From 904872372e9822a06fdebd9248b8bd50198cf4b4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 23 Mar 2010 15:17:49 -0700 Subject: Typo fixes: de/re/ference. --- ir.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ir.h b/ir.h index bbf53540dbe..b0c2f14e129 100644 --- a/ir.h +++ b/ir.h @@ -202,7 +202,7 @@ public: /** * Value being assigned * - * This should be either \c ir_op_expression or \c ir_op_deference. + * This should be either \c ir_op_expression or \c ir_op_dereference. */ ir_instruction *rhs; @@ -414,7 +414,7 @@ public: /** * Object being dereferenced. * - * Must be either an \c ir_variable or an \c ir_deference. + * Must be either an \c ir_variable or an \c ir_dereference. */ ir_instruction *var; -- cgit v1.2.3 From f25a5ad93961c335b56d4f0508cc5c00b77ee519 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 25 Mar 2010 11:22:42 -0700 Subject: Widen num_components to handle vec4 correctly. --- ir.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir.h b/ir.h index b0c2f14e129..530c7326a35 100644 --- a/ir.h +++ b/ir.h @@ -379,7 +379,7 @@ struct ir_swizzle_mask { /** * Number of components in the swizzle. */ - unsigned num_components:2; + unsigned num_components:3; /** * Does the swizzle contain duplicate components? -- cgit v1.2.3 From 252127c379404f0c0c23a5f0e2e4175816f7e903 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 11:42:45 -0700 Subject: Add queries to get the glsl_type of a row or column of a matrix --- glsl_types.h | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/glsl_types.h b/glsl_types.h index 04a9ccf4146..e1768d520b3 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -39,6 +39,12 @@ #define GLSL_TYPE_VOID 8 #define GLSL_TYPE_ERROR 9 +extern const struct glsl_type *const glsl_error_type; +extern const struct glsl_type *const glsl_int_type; +extern const struct glsl_type *const glsl_uint_type; +extern const struct glsl_type *const glsl_float_type; +extern const struct glsl_type *const glsl_bool_type; + #define is_numeric_base_type(b) \ (((b) >= GLSL_TYPE_UINT) && ((b) <= GLSL_TYPE_FLOAT)) @@ -223,6 +229,34 @@ struct glsl_type { return base_type == GLSL_TYPE_ERROR; } + /** + * Query the full type of a matrix row + * + * \return + * If the type is not a matrix, \c glsl_error_type is returned. Otherwise + * a type matching the rows of the matrix is returned. + */ + const glsl_type *row_type() const + { + return is_matrix() + ? get_instance(base_type, matrix_rows, 1) + : glsl_error_type; + } + + /** + * Query the full type of a matrix column + * + * \return + * If the type is not a matrix, \c glsl_error_type is returned. Otherwise + * a type matching the columns of the matrix is returned. + */ + const glsl_type *column_type() const + { + return is_matrix() + ? get_instance(base_type, vector_elements, 1) + : glsl_error_type; + } + private: /** * \name Pointers to various type singletons @@ -254,12 +288,6 @@ extern "C" { extern void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); -extern const struct glsl_type *const glsl_error_type; -extern const struct glsl_type *const glsl_int_type; -extern const struct glsl_type *const glsl_uint_type; -extern const struct glsl_type *const glsl_float_type; -extern const struct glsl_type *const glsl_bool_type; - #ifdef __cplusplus } #endif -- cgit v1.2.3 From 80b5ed6e63481237f5e0355b6b096d43a9332fb2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 13:05:43 -0700 Subject: Replace several glsl_type field comparisons with a single pointer comparison This simplifies the process of matching function parameter types. More simplifications are probably possible here, but arrays and structures need to be implemented first. --- ir_function.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ir_function.cpp b/ir_function.cpp index a14b546bc6e..1ff5b203ccf 100644 --- a/ir_function.cpp +++ b/ir_function.cpp @@ -27,6 +27,11 @@ int type_compare(const glsl_type *a, const glsl_type *b) { + /* If the types are the same, they trivially match. + */ + if (a == b) + return 0; + switch (a->base_type) { case GLSL_TYPE_UINT: case GLSL_TYPE_INT: @@ -36,9 +41,6 @@ type_compare(const glsl_type *a, const glsl_type *b) || (a->matrix_rows != b->matrix_rows)) return -1; - if (a->base_type == b->base_type) - return 0; - /* There is no implicit conversion to or from bool. */ if ((a->base_type == GLSL_TYPE_BOOL) @@ -48,14 +50,10 @@ type_compare(const glsl_type *a, const glsl_type *b) return 1; case GLSL_TYPE_SAMPLER: - return ((a->sampler_dimensionality == b->sampler_dimensionality) - && (a->sampler_shadow == b->sampler_shadow) - && (a->sampler_array == b->sampler_array) - && (a->sampler_type == b->sampler_type)) - ? 0 : -1; - case GLSL_TYPE_STRUCT: - return (strcmp(a->name, b->name) == 0) ? 0 : -1; + /* Samplers and structures must match exactly. + */ + return -1; case GLSL_TYPE_ARRAY: if ((b->base_type != GLSL_TYPE_ARRAY) -- cgit v1.2.3 From c1bd3a1a61364d8450629a935b4611184eb99654 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 13:06:58 -0700 Subject: Use glsl_type::row_type and glsl_type::column type in arithmetic_result_type This substantially clarifies the code for matching matrix types. It also eliminates some uses of glsl_type member data. --- ast_to_hir.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index cb746ed59a9..740adb9f43c 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -183,24 +183,39 @@ arithmetic_result_type(const struct glsl_type *type_a, return (type_a == type_b) ? type_a : glsl_error_type; } else { if (type_a->is_matrix() && type_b->is_matrix()) { - if (type_a->vector_elements == type_b->matrix_rows) { - return glsl_type::get_instance(type_a->base_type, - type_b->matrix_rows, - type_a->vector_elements); + /* Matrix multiply. The columns of A must match the rows of B. Given + * the other previously tested constraints, this means the vector type + * of a row from A must be the same as the vector type of a column from + * B. + */ + if (type_a->row_type() == type_b->column_type()) { + /* The resulting matrix has the number of columns of matrix B and + * the number of rows of matrix A. We get the row count of A by + * looking at the size of a vector that makes up a column. The + * transpose (size of a row) is done for B. + */ + return + glsl_type::get_instance(type_a->base_type, + type_a->column_type()->vector_elements, + type_b->row_type()->vector_elements); } } else if (type_a->is_matrix()) { /* A is a matrix and B is a column vector. Columns of A must match - * rows of B. + * rows of B. Given the other previously tested constraints, this + * means the vector type of a row from A must be the same as the + * vector the type of B. */ - if (type_a->vector_elements == type_b->vector_elements) + if (type_a->row_type() == type_b) return type_b; } else { assert(type_b->is_matrix()); - /* A is a row vector and B is a matrix. Columns of A must match - * rows of B. + /* A is a row vector and B is a matrix. Columns of A must match rows + * of B. Given the other previously tested constraints, this means + * the type of A must be the same as the vector type of a column from + * B. */ - if (type_a->vector_elements == type_b->matrix_rows) + if (type_a == type_b->column_type()) return type_a; } } -- cgit v1.2.3 From 1b4f04124ab1cf1c9df94277f9da69956991d9e8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 13:19:13 -0700 Subject: Fix matrix dimensioning Newb GL mistake: matrices in GL are column-major. This means that vector_elements is the number of rows. Making these changes causes matrix-08.glsl to pass. --- builtin_types.sh | 2 +- glsl_types.h | 16 ++++++++-------- ir.cpp | 2 +- ir_function.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/builtin_types.sh b/builtin_types.sh index 6dd0ea7403b..299a4cef415 100755 --- a/builtin_types.sh +++ b/builtin_types.sh @@ -275,7 +275,7 @@ gen_header "120" for c in 2 3 4; do for r in 2 3 4; do if [ $c -ne $r ]; then - gen_integral_type "mat${c}x${r}" "GLSL_TYPE_FLOAT" $c $r + gen_integral_type "mat${c}x${r}" "GLSL_TYPE_FLOAT" $r $c fi done done diff --git a/glsl_types.h b/glsl_types.h index e1768d520b3..96c9a1b2a48 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -75,7 +75,7 @@ struct glsl_type { */ unsigned vector_elements:3; /**< 0, 2, 3, or 4 vector elements. */ - unsigned matrix_rows:3; /**< 0, 2, 3, or 4 matrix rows. */ + unsigned matrix_columns:3; /**< 0, 2, 3, or 4 matrix columns. */ /** * Name of the data type @@ -108,11 +108,11 @@ struct glsl_type { glsl_type(unsigned base_type, unsigned vector_elements, - unsigned matrix_rows, const char *name) : + unsigned matrix_columns, const char *name) : base_type(base_type), sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), sampler_type(0), - vector_elements(vector_elements), matrix_rows(matrix_rows), + vector_elements(vector_elements), matrix_columns(matrix_columns), name(name), length(0) { @@ -124,7 +124,7 @@ struct glsl_type { base_type(GLSL_TYPE_SAMPLER), sampler_dimensionality(dim), sampler_shadow(shadow), sampler_array(array), sampler_type(type), - vector_elements(0), matrix_rows(0), + vector_elements(0), matrix_columns(0), name(name), length(0) { @@ -136,7 +136,7 @@ struct glsl_type { base_type(GLSL_TYPE_STRUCT), sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), sampler_type(0), - vector_elements(0), matrix_rows(0), + vector_elements(0), matrix_columns(0), name(name), length(num_fields) { @@ -175,7 +175,7 @@ struct glsl_type { bool is_vector() const { return (vector_elements > 0) - && (matrix_rows == 0) + && (matrix_columns == 0) && (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_BOOL); } @@ -186,7 +186,7 @@ struct glsl_type { bool is_matrix() const { /* GLSL only has float matrices. */ - return (matrix_rows > 0) && (base_type == GLSL_TYPE_FLOAT); + return (matrix_columns > 0) && (base_type == GLSL_TYPE_FLOAT); } /** @@ -239,7 +239,7 @@ struct glsl_type { const glsl_type *row_type() const { return is_matrix() - ? get_instance(base_type, matrix_rows, 1) + ? get_instance(base_type, matrix_columns, 1) : glsl_error_type; } diff --git a/ir.cpp b/ir.cpp index 49df75425e6..ad75cdad73c 100644 --- a/ir.cpp +++ b/ir.cpp @@ -59,7 +59,7 @@ ir_constant::ir_constant(const struct glsl_type *type, const void *data) { const unsigned elements = ((type->vector_elements == 0) ? 1 : type->vector_elements) - * ((type->matrix_rows == 0) ? 1 : type->matrix_rows); + * ((type->matrix_columns == 0) ? 1 : type->matrix_columns); unsigned size = 0; this->type = type; diff --git a/ir_function.cpp b/ir_function.cpp index 1ff5b203ccf..b6139c4a9fe 100644 --- a/ir_function.cpp +++ b/ir_function.cpp @@ -38,7 +38,7 @@ type_compare(const glsl_type *a, const glsl_type *b) case GLSL_TYPE_FLOAT: case GLSL_TYPE_BOOL: if ((a->vector_elements != b->vector_elements) - || (a->matrix_rows != b->matrix_rows)) + || (a->matrix_columns != b->matrix_columns)) return -1; /* There is no implicit conversion to or from bool. -- cgit v1.2.3 From 68507eceead4e4cd6bb67ae219a333ab35f56bea Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 13:41:32 -0700 Subject: More matrix compilation tests --- tests/matrix-09.glsl | 11 +++++++++++ tests/matrix-10.glsl | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/matrix-09.glsl create mode 100644 tests/matrix-10.glsl diff --git a/tests/matrix-09.glsl b/tests/matrix-09.glsl new file mode 100644 index 00000000000..18afbcacea7 --- /dev/null +++ b/tests/matrix-09.glsl @@ -0,0 +1,11 @@ +/* FAIL - matrix-to-matrix constructors are not available in GLSL 1.10 */ + +uniform mat3 a; + +void main() +{ + mat2 m; + + m = mat2(a); + gl_Position = gl_Vertex; +} diff --git a/tests/matrix-10.glsl b/tests/matrix-10.glsl new file mode 100644 index 00000000000..20b55180cbb --- /dev/null +++ b/tests/matrix-10.glsl @@ -0,0 +1,12 @@ +#version 120 +/* PASS */ + +uniform mat3 a; + +void main() +{ + mat2 m; + + m = mat2(a); + gl_Position = gl_Vertex; +} -- cgit v1.2.3 From 7c15bb2465b2c22a7de810b399b4aa7bfa1467c0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 25 Mar 2010 14:37:25 -0700 Subject: Make the standalone parser return an exit code so we can automate testing. --- glsl_parser_extras.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index b774d8b5f4e..a02865887fc 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -657,5 +657,5 @@ main(int argc, char **argv) delete state.symbols; - return 0; + return state.error != 0; } -- cgit v1.2.3 From b3f743ab0badc0ca7cba16d7989ec7ba368f6b36 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 25 Mar 2010 14:48:25 -0700 Subject: Set up fragment shader builtin variables. --- builtin_variables.h | 7 +++++++ ir_variable.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/builtin_variables.h b/builtin_variables.h index 9693217e990..5b18446a0da 100644 --- a/builtin_variables.h +++ b/builtin_variables.h @@ -32,6 +32,13 @@ static const builtin_variable builtin_core_vs_variables[] = { { ir_var_out, "float", "gl_PointSize" }, }; +static const builtin_variable builtin_core_fs_variables[] = { + { ir_var_out, "vec4", "gl_FragCoord" }, + { ir_var_out, "bool", "gl_FrontFacing" }, + { ir_var_out, "vec4", "gl_FragColor" }, + { ir_var_out, "float", "gl_FragDepth" }, +}; + static const builtin_variable builtin_110_deprecated_vs_variables[] = { { ir_var_in, "vec4", "gl_Vertex" }, { ir_var_in, "vec4", "gl_Normal" }, diff --git a/ir_variable.cpp b/ir_variable.cpp index 283842c54e0..9344170613d 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -127,6 +127,57 @@ initialize_vs_variables(exec_list *instructions, } } +static void +generate_110_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { + add_builtin_variable(& builtin_core_fs_variables[i], + instructions, symtab); + } + + /* FINISHME: Add support for gl_FragData[GL_MAX_DRAW_BUFFERS]. */ +} + +static void +generate_120_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + /* GLSL version 1.20 did not add any built-in variables in the fragment + * shader. + */ + generate_110_fs_variables(instructions, symtab); +} + +static void +generate_130_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + generate_120_fs_variables(instructions, symtab); + + /* FINISHME: Add support fo gl_ClipDistance. The size of this array is + * FINISHME: implementation dependent based on the value of + * FINISHME: GL_MAX_CLIP_DISTANCES. + */ +} + +static void +initialize_fs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + + switch (state->language_version) { + case 110: + generate_110_fs_variables(instructions, state->symbols); + break; + case 120: + generate_120_fs_variables(instructions, state->symbols); + break; + case 130: + generate_130_fs_variables(instructions, state->symbols); + break; + } +} void _mesa_glsl_initialize_variables(exec_list *instructions, @@ -137,7 +188,9 @@ _mesa_glsl_initialize_variables(exec_list *instructions, initialize_vs_variables(instructions, state); break; case geometry_shader: + break; case fragment_shader: + initialize_fs_variables(instructions, state); break; } } -- cgit v1.2.3 From 2f9ca7dce2adea10d7947e98690b729cce947938 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 25 Mar 2010 16:47:49 -0700 Subject: Fix up the operator printing for the logic or and beyond, check array bounds. --- ast_expr.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ast_expr.cpp b/ast_expr.cpp index ad29cdc68d7..4e83decb924 100644 --- a/ast_expr.cpp +++ b/ast_expr.cpp @@ -50,6 +50,7 @@ ast_expression::operator_string(enum ast_operators op) "~", "&&", "^^", + "||", "!", "*=", @@ -64,6 +65,7 @@ ast_expression::operator_string(enum ast_operators op) "|=", "?:", + "++", "--", "++", @@ -71,6 +73,8 @@ ast_expression::operator_string(enum ast_operators op) ".", }; + assert((unsigned int)op < sizeof(operators) / sizeof(operators[0])); + return operators[op]; } -- cgit v1.2.3 From 720c88eab902923123b0625f133e9ef5912f0e3f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 16:58:45 -0700 Subject: Add functions to generate constructors for built-in types. Currently only vector and matrix types are supported. Structure types will be added later. --- glsl_types.cpp | 370 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ glsl_types.h | 4 + 2 files changed, 374 insertions(+) diff --git a/glsl_types.cpp b/glsl_types.cpp index b2631efef9b..f7ef4a302b9 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -111,6 +111,376 @@ const glsl_type *glsl_type::get_base_type() const } +/** + * Generate the function intro for a constructor + * + * \param type Data type to be constructed + * \param count Number of parameters to this concrete constructor. Most + * types have at least two constructors. One will take a + * single scalar parameter and the other will take "N" + * scalar parameters. + * \param parameters Storage for the list of parameters. These are + * typically stored in an \c ir_function_signature. + * \param instructions Storage for the preamble and body of the function. + * \param declarations Pointers to the variable declarations for the function + * parameters. These are used later to avoid having to use + * the symbol table. + */ +static void +generate_constructor_intro(const glsl_type *type, unsigned parameter_count, + exec_list *parameters, exec_list *instructions, + ir_variable **declarations) +{ + /* Names of parameters used in vector and matrix constructors + */ + static const char *const names[] = { + "a", "b", "c", "d", "e", "f", "g", "h", + "i", "j", "k", "l", "m", "n", "o", "p", + }; + + assert(parameter_count <= Elements(names)); + + const glsl_type *const parameter_type = type->get_base_type(); + + ir_label *const label = new ir_label(type->name); + instructions->push_tail(label); + + for (unsigned i = 0; i < parameter_count; i++) { + ir_variable *var = new ir_variable(parameter_type, names[i]); + + var->mode = ir_var_in; + parameters->push_tail(var); + + var = new ir_variable(parameter_type, names[i]); + + var->mode = ir_var_in; + instructions->push_tail(var); + + declarations[i] = var; + } + + ir_variable *retval = new ir_variable(type, "__retval"); + instructions->push_tail(retval); + + declarations[16] = retval; +} + + +/** + * Generate the body of a vector constructor that takes a single scalar + */ +static void +generate_vec_body_from_scalar(exec_list *instructions, + ir_variable **declarations) +{ + ir_instruction *inst; + + /* Generate a single assignment of the parameter to __retval.x and return + * __retval.xxxx for however many vector components there are. + */ + ir_dereference *const lhs = new ir_dereference(declarations[16]); + ir_dereference *const rhs = new ir_dereference(declarations[0]); + + lhs->set_swizzle(0, 0, 0, 0, 1); + + inst = new ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + + ir_dereference *const retval = new ir_dereference(declarations[16]); + + retval->set_swizzle(0, 0, 0, 0, declarations[16]->type->vector_elements); + + inst = new ir_return((ir_expression *) retval); + instructions->push_tail(inst); +} + + +/** + * Generate the body of a vector constructor that takes multiple scalars + */ +static void +generate_vec_body_from_N_scalars(exec_list *instructions, + ir_variable **declarations) +{ + ir_instruction *inst; + const glsl_type *const vec_type = declarations[16]->type; + + + /* Generate an assignment of each parameter to a single component of + * __retval.x and return __retval. + */ + for (unsigned i = 0; i < vec_type->vector_elements; i++) { + ir_dereference *const lhs = new ir_dereference(declarations[16]); + ir_dereference *const rhs = new ir_dereference(declarations[i]); + + lhs->selector.swizzle.x = i; + lhs->selector.swizzle.num_components = 1; + + inst = new ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + } + + ir_dereference *retval = new ir_dereference(declarations[16]); + + inst = new ir_return((ir_expression *) retval); + instructions->push_tail(inst); +} + + +/** + * Generate the body of a matrix constructor that takes a single scalar + */ +static void +generate_mat_body_from_scalar(exec_list *instructions, + ir_variable **declarations) +{ + ir_instruction *inst; + + /* Generate an assignment of the parameter to the X component of a + * temporary vector. Set the remaining fields of the vector to 0. The + * size of the vector is equal to the number of rows of the matrix. + * + * Set each column of the matrix to a successive "rotation" of the + * temporary vector. This fills the matrix with 0s, but writes the single + * scalar along the matrix's diagonal. + * + * For a mat4x3, this is equivalent to: + * + * vec3 tmp; + * mat4x3 __retval; + * tmp.x = a; + * tmp.y = 0.0; + * tmp.z = 0.0; + * __retval[0] = tmp.xyy; + * __retval[1] = tmp.yxy; + * __retval[2] = tmp.yyx; + * __retval[3] = tmp.yyy; + */ + const glsl_type *const column_type = declarations[16]->type->column_type(); + const glsl_type *const row_type = declarations[16]->type->row_type(); + ir_variable *const column = new ir_variable(column_type, "v"); + + instructions->push_tail(column); + + ir_dereference *const lhs = new ir_dereference(column); + ir_dereference *const rhs = new ir_dereference(declarations[0]); + + lhs->set_swizzle(0, 0, 0, 0, 1); + + inst = new ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + + const float z = 0.0f; + ir_constant *const zero = new ir_constant(glsl_float_type, &z); + + for (unsigned i = 1; i < column_type->vector_elements; i++) { + ir_dereference *const lhs = new ir_dereference(column); + + lhs->set_swizzle(i, 0, 0, 0, 1); + + inst = new ir_assignment(lhs, zero, NULL); + instructions->push_tail(inst); + } + + + for (unsigned i = 0; i < row_type->vector_elements; i++) { + static const unsigned swiz[] = { 1, 1, 1, 0, 1, 1, 1 }; + ir_dereference *const rhs = new ir_dereference(column); + + /* This will be .xyyy when i=0, .yxyy when i=1, etc. + */ + rhs->set_swizzle(swiz[3 - i], swiz[4 - i], swiz[5 - i], swiz[6 - i], + column_type->vector_elements); + + ir_constant *const idx = new ir_constant(glsl_int_type, &i); + ir_dereference *const lhs = new ir_dereference(declarations[16], idx); + + inst = new ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + } + + ir_dereference *const retval = new ir_dereference(declarations[16]); + inst = new ir_return((ir_expression *) retval); + instructions->push_tail(inst); +} + + +/** + * Generate the body of a vector constructor that takes multiple scalars + */ +static void +generate_mat_body_from_N_scalars(exec_list *instructions, + ir_variable **declarations) +{ + ir_instruction *inst; + const glsl_type *const row_type = declarations[16]->type->row_type(); + const glsl_type *const column_type = declarations[16]->type->column_type(); + + + /* Generate an assignment of each parameter to a single component of + * of a particular column of __retval and return __retval. + */ + for (unsigned i = 0; i < column_type->vector_elements; i++) { + for (unsigned j = 0; j < row_type->vector_elements; j++) { + ir_constant *row_index = new ir_constant(glsl_int_type, &i); + ir_dereference *const row_access = + new ir_dereference(declarations[16], row_index); + + ir_dereference *const component_access = + new ir_dereference(row_access); + + component_access->selector.swizzle.x = j; + component_access->selector.swizzle.num_components = 1; + + const unsigned param = (i * row_type->vector_elements) + j; + ir_dereference *const rhs = new ir_dereference(declarations[param]); + + inst = new ir_assignment(component_access, rhs, NULL); + instructions->push_tail(inst); + } + } + + ir_dereference *retval = new ir_dereference(declarations[16]); + + inst = new ir_return((ir_expression *) retval); + instructions->push_tail(inst); +} + + +/** + * Generate the constructors for a set of GLSL types + * + * Constructor implementations are added to \c instructions, and the symbols + * are added to \c symtab. + */ +static void +generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, + unsigned num_types, exec_list *instructions) +{ + ir_variable *declarations[17]; + + for (unsigned i = 0; i < num_types; i++) { + /* Only numeric and boolean vectors and matrices get constructors here. + * Structures need to be handled elsewhere. It is expected that scalar + * constructors are never actually called, so they are not generated. + */ + if (!types[i].is_numeric() && !types[i].is_boolean()) + continue; + + if (types[i].is_scalar()) + continue; + + /* Generate the function name and add it to the symbol table. + */ + ir_function *const f = new ir_function(types[i].name); + + bool added = symtab->add_function(types[i].name, f); + assert(added); + + + /* Each type has several basic constructors. The total number of forms + * depends on the derived type. + * + * Vectors: 1 scalar, N scalars + * Matrices: 1 scalar, NxM scalars + * + * Several possible types of constructors are not included in this list. + * + * Scalar constructors are not included. The expectation is that the + * IR generator won't actually generate these as constructor calls. The + * expectation is that it will just generate the necessary type + * conversion. + * + * Matrix contructors from matrices are also not included. The + * expectation is that the IR generator will generate a call to the + * appropriate from-scalars constructor. + */ + ir_function_signature *const sig = new ir_function_signature(& types[i]); + f->signatures.push_tail(sig); + + generate_constructor_intro(& types[i], 1, & sig->parameters, + instructions, declarations); + + if (types[i].is_vector()) { + generate_vec_body_from_scalar(instructions, declarations); + + ir_function_signature *const vec_sig = + new ir_function_signature(& types[i]); + f->signatures.push_tail(vec_sig); + + generate_constructor_intro(& types[i], types[i].vector_elements, + & vec_sig->parameters, instructions, + declarations); + generate_vec_body_from_N_scalars(instructions, declarations); + } else { + assert(types[i].is_matrix()); + + generate_mat_body_from_scalar(instructions, declarations); + + ir_function_signature *const mat_sig = + new ir_function_signature(& types[i]); + f->signatures.push_tail(mat_sig); + + generate_constructor_intro(& types[i], + (types[i].vector_elements + * types[i].matrix_columns), + & mat_sig->parameters, instructions, + declarations); + generate_mat_body_from_N_scalars(instructions, declarations); + } + } +} + + +void +generate_110_constructors(glsl_symbol_table *symtab, exec_list *instructions) +{ + generate_constructor(symtab, builtin_core_types, + Elements(builtin_core_types), instructions); +} + + +void +generate_120_constructors(glsl_symbol_table *symtab, exec_list *instructions) +{ + generate_110_constructors(symtab, instructions); + + generate_constructor(symtab, builtin_120_types, + Elements(builtin_120_types), instructions); +} + + +void +generate_130_constructors(glsl_symbol_table *symtab, exec_list *instructions) +{ + generate_120_constructors(symtab, instructions); + + generate_constructor(symtab, builtin_130_types, + Elements(builtin_130_types), instructions); +} + + +void +_mesa_glsl_initialize_constructors(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + switch (state->language_version) { + case 110: + generate_110_constructors(state->symbols, instructions); + break; + case 120: + generate_120_constructors(state->symbols, instructions); + break; + case 130: + generate_130_constructors(state->symbols, instructions); + break; + default: + /* error */ + break; + } +} + + const glsl_type * glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) { diff --git a/glsl_types.h b/glsl_types.h index 96c9a1b2a48..a795af2cd38 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -288,6 +288,10 @@ extern "C" { extern void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); +extern void +_mesa_glsl_initialize_constructors(struct exec_list *instructions, + struct _mesa_glsl_parse_state *state); + #ifdef __cplusplus } #endif -- cgit v1.2.3 From 954699773681842dac9f8f0d9ba4629513232196 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 17:01:15 -0700 Subject: Add dereference constructor for array element dereferences This should have gone in before the previous commit. --- ir.cpp | 10 ++++++++++ ir.h | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ir.cpp b/ir.cpp index ad75cdad73c..1b5947a4704 100644 --- a/ir.cpp +++ b/ir.cpp @@ -87,6 +87,16 @@ ir_dereference::ir_dereference(ir_instruction *var) } +ir_dereference::ir_dereference(ir_instruction *var, + ir_instruction *array_index) + : ir_instruction(ir_op_dereference), mode(ir_reference_array), + var(var) +{ + this->type = (var != NULL) ? var->type : glsl_error_type; + this->selector.array_index = array_index; +} + + void ir_dereference::set_swizzle(unsigned x, unsigned y, unsigned z, unsigned w, unsigned count) diff --git a/ir.h b/ir.h index 530c7326a35..22b46c971e8 100644 --- a/ir.h +++ b/ir.h @@ -393,6 +393,8 @@ class ir_dereference : public ir_instruction { public: ir_dereference(struct ir_instruction *); + ir_dereference(ir_instruction *variable, ir_instruction *array_index); + virtual void accept(ir_visitor *v) { v->visit(this); @@ -419,7 +421,7 @@ public: ir_instruction *var; union { - ir_expression *array_index; + ir_instruction *array_index; const char *field; struct ir_swizzle_mask swizzle; } selector; -- cgit v1.2.3 From a4e92c4b26578614d76ce71b53194ea5c0f58d6c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 17:02:22 -0700 Subject: Before generating HIR for user code, generate constructors for built-in types --- ast_to_hir.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 740adb9f43c..513a948a3ce 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -62,6 +62,7 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) struct simple_node *ptr; _mesa_glsl_initialize_variables(instructions, state); + _mesa_glsl_initialize_constructors(instructions, state); state->current_function = NULL; -- cgit v1.2.3 From ece0a511600bef40a088953b8054eb1424a2bb4f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 25 Mar 2010 17:02:15 -0700 Subject: Fix assignment operators: *=, /=, +=, -=. Basically, replace everything different from operator_assign other than the creation of the rhs value from the lvalue and rvalue with the contents of operator_assign. Fixes a segfault in CorrectSwizzle1.frag, and fixes parser10.frag. --- ast_to_hir.cpp | 62 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 740adb9f43c..3d17fc9c82d 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -607,32 +607,56 @@ ast_expression::hir(exec_list *instructions, temp_rhs = new ir_expression(operations[this->oper], type, op[0], op[1]); - /* FINISHME: Check that the LHS is assignable. */ - - /* We still have to test that the LHS and RHS have matching type. For - * example, the following GLSL code should generate a type error: - * - * mat4 m; vec4 v; m *= v; - * - * The type of (m*v) is a vec4, but the type of m is a mat4. - * - * FINISHME: Is multiplication between a matrix and a vector the only - * FINISHME: case that resuls in mismatched types? + /* FINISHME: This is copied from ast_assign above. It should + * FINISHME: probably be consolidated. */ - /* FINISHME: Check that the LHS and RHS have matching types. */ + error_emitted = ((op[0]->type == glsl_error_type) + || (temp_rhs->type == glsl_error_type)); + + type = op[0]->type; + if (!error_emitted) { + YYLTYPE loc; + + /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ + loc = this->subexpressions[0]->get_location(); + if (op[0]->mode != ir_op_dereference) { + _mesa_glsl_error(& loc, state, "invalid lvalue in assignment"); + error_emitted = true; + + type = glsl_error_type; + } else { + const struct ir_dereference *const ref = + (struct ir_dereference *) op[0]; + const struct ir_variable *const var = + (struct ir_variable *) ref->var; + + if ((var != NULL) + && (var->mode == ir_op_var_decl) + && (var->read_only)) { + _mesa_glsl_error(& loc, state, "cannot assign to read-only " + "variable `%s'", var->name); + error_emitted = true; + + type = glsl_error_type; + } + } + } + + ir_instruction *rhs = validate_assignment(op[0]->type, temp_rhs); + if (rhs == NULL) { + type = glsl_error_type; + rhs = temp_rhs; + } + + ir_instruction *tmp = new ir_assignment(op[0], rhs, NULL); + instructions->push_tail(tmp); /* GLSL 1.10 does not allow array assignment. However, we don't have to * explicitly test for this because none of the binary expression * operators allow array operands either. */ - /* FINISHME: This is wrong. The operation should assign to a new - * FINISHME: temporary. This assignment should then be added to the - * FINISHME: instruction list. Another assignment to the real - * FINISHME: destination should be generated. The temporary should then - * FINISHME: be returned as the r-value. - */ - result = new ir_assignment(op[0], temp_rhs, NULL); + result = op[0]; break; } -- cgit v1.2.3 From 6e7c278e243e506dd10cc7e0ca5768c187c33b27 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 17:04:26 -0700 Subject: IR print visitor: Less newlines when printing ir_variables --- ir_print_visitor.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index f9f3d3f17d8..8fe35bfa6e9 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -47,22 +47,21 @@ print_type(const glsl_type *t) void ir_print_visitor::visit(ir_variable *ir) { - printf("(declare \n"); + printf("(declare "); const char *const cent = (ir->centroid) ? "centroid " : ""; const char *const inv = (ir->invariant) ? "invariant " : ""; const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " }; const char *const interp[] = { "", "flat", "noperspective" }; - printf(" (%s%s%s%s)\n", + printf("(%s%s%s%s) ", cent, inv, mode[ir->mode], interp[ir->interpolation]); - printf(" ("); + printf("("); print_type(ir->type); - printf(")\n"); + printf(") "); - printf(" (%s)\n", ir->name); - printf(")\n"); + printf("(%s))\n", ir->name); } -- cgit v1.2.3 From 8c70a621939e55a81a363f04dee3333772339cbe Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 17:38:13 -0700 Subject: IR print visitor: print ir_dereference instructions Also make a slight change to ir_variable. The ir_dereference tracks the number of nested dereferences. If an ir_variable is visited and the count is non-zero, just print the name of the variable. --- ir_print_visitor.cpp | 63 ++++++++++++++++++++++++++++++++++++++++------------ ir_print_visitor.h | 4 ++++ 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 8fe35bfa6e9..9e4c4412ae3 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -47,21 +47,24 @@ print_type(const glsl_type *t) void ir_print_visitor::visit(ir_variable *ir) { - printf("(declare "); - - const char *const cent = (ir->centroid) ? "centroid " : ""; - const char *const inv = (ir->invariant) ? "invariant " : ""; - const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " }; - const char *const interp[] = { "", "flat", "noperspective" }; + if (deref_depth) { + printf("(%s)", ir->name); + } else { + printf("(declare "); - printf("(%s%s%s%s) ", - cent, inv, mode[ir->mode], interp[ir->interpolation]); + const char *const cent = (ir->centroid) ? "centroid " : ""; + const char *const inv = (ir->invariant) ? "invariant " : ""; + const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " }; + const char *const interp[] = { "", "flat", "noperspective" }; - printf("("); - print_type(ir->type); - printf(") "); + printf("(%s%s%s%s) ", + cent, inv, mode[ir->mode], interp[ir->interpolation]); - printf("(%s))\n", ir->name); + printf("("); + print_type(ir->type); + printf(") "); + printf("(%s))\n", ir->name); + } } @@ -94,8 +97,40 @@ void ir_print_visitor::visit(ir_expression *ir) void ir_print_visitor::visit(ir_dereference *ir) { - printf("%s:%d:\n", __func__, __LINE__); - (void) ir; + deref_depth++; + + switch (ir->mode) { + case ir_dereference::ir_reference_variable: { + const unsigned swiz[4] = { + ir->selector.swizzle.x, + ir->selector.swizzle.y, + ir->selector.swizzle.z, + ir->selector.swizzle.w, + }; + + printf("(var_ref "); + ir->var->accept(this); + printf("("); + for (unsigned i = 0; i < ir->selector.swizzle.num_components; i++) { + printf("%c", "xyzw"[swiz[i]]); + } + printf("))\n"); + break; + } + case ir_dereference::ir_reference_array: + printf("(array_ref "); + ir->var->accept(this); + ir->selector.array_index->accept(this); + printf(")\n"); + break; + case ir_dereference::ir_reference_record: + printf("(record_ref "); + ir->var->accept(this); + printf("(%s))\n", ir->selector.field); + break; + } + + deref_depth--; } diff --git a/ir_print_visitor.h b/ir_print_visitor.h index 121b7e8bb68..a4309c4f2a4 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -35,6 +35,7 @@ class ir_print_visitor : public ir_visitor { public: ir_print_visitor() + : deref_depth(0) { /* empty */ } @@ -63,6 +64,9 @@ public: virtual void visit(ir_call *); virtual void visit(ir_return *); /*@}*/ + +private: + int deref_depth; }; #endif /* IR_PRINT_VISITOR_H */ -- cgit v1.2.3 From d7388f389dfd17e3842e5dfda1b5782c00f454e5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 18:25:37 -0700 Subject: IR print visitor: print expressions Not quite complete. The operator is not yet printed. --- ir_print_visitor.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 9e4c4412ae3..40e3d057db9 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -90,8 +90,19 @@ void ir_print_visitor::visit(ir_function *ir) void ir_print_visitor::visit(ir_expression *ir) { - printf("%s:%d:\n", __func__, __LINE__); - (void) ir; + printf("(expression "); + + printf("(FINISHME: operator) "); + + printf("("); + if (ir->operands[0]) + ir->operands[0]->accept(this); + printf(") "); + + printf("("); + if (ir->operands[1]) + ir->operands[1]->accept(this); + printf(")) "); } -- cgit v1.2.3 From d14642739e488c8cb15726de5a63cb01c6ce835c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 18:29:25 -0700 Subject: IR print visitor: Remove most of the newlines from the printed output This makes it a lot easier to read... if you have a really wide display. --- glsl_parser_extras.cpp | 1 + ir_print_visitor.cpp | 46 ++++++++++++++++++++-------------------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index a02865887fc..d57a68efb75 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -652,6 +652,7 @@ main(int argc, char **argv) ir_print_visitor v; ((ir_instruction *)iter.get())->accept(& v); + printf("\n"); } } diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 40e3d057db9..2c9debc7d72 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -28,16 +28,12 @@ static void print_type(const glsl_type *t) { if (t->base_type == GLSL_TYPE_ARRAY) { - printf("array\n"); - printf(" ("); + printf("array ("); print_type(t->fields.array); - printf(")\n"); - - printf(" (%u)\n", t->length); - printf(")"); + printf(") (%u))", t->length); } else if (t->base_type == GLSL_TYPE_STRUCT) { - printf("struct (%s %u\n", t->name ? t->name : "@", t->length); - printf(" (FINISHME: structure fields go here)\n"); + printf("struct (%s %u ", t->name ? t->name : "@", t->length); + printf("(FINISHME: structure fields go here) "); printf(")"); } else { printf("%s", t->name); @@ -63,14 +59,14 @@ void ir_print_visitor::visit(ir_variable *ir) printf("("); print_type(ir->type); printf(") "); - printf("(%s))\n", ir->name); + printf("(%s)) ", ir->name); } } void ir_print_visitor::visit(ir_label *ir) { - printf("(label %s)\n", ir->label); + printf("\n(label %s)", ir->label); } @@ -125,19 +121,19 @@ void ir_print_visitor::visit(ir_dereference *ir) for (unsigned i = 0; i < ir->selector.swizzle.num_components; i++) { printf("%c", "xyzw"[swiz[i]]); } - printf("))\n"); + printf(")) "); break; } case ir_dereference::ir_reference_array: printf("(array_ref "); ir->var->accept(this); ir->selector.array_index->accept(this); - printf(")\n"); + printf(") "); break; case ir_dereference::ir_reference_record: printf("(record_ref "); ir->var->accept(this); - printf("(%s))\n", ir->selector.field); + printf("(%s)) ", ir->selector.field); break; } @@ -147,22 +143,21 @@ void ir_print_visitor::visit(ir_dereference *ir) void ir_print_visitor::visit(ir_assignment *ir) { - printf("(assign\n"); + printf("(assign ("); - printf(" ("); if (ir->condition) ir->condition->accept(this); else printf("true"); - printf(")\n"); - printf(" ("); + printf(") ("); + ir->lhs->accept(this); - printf(")\n"); - printf(" ("); + printf(") ("); + ir->rhs->accept(this); - printf(")\n"); + printf(") "); } @@ -170,12 +165,11 @@ void ir_print_visitor::visit(ir_constant *ir) { (void) ir; - printf("(constant\n"); - printf(" ("); + printf("(constant ("); print_type(ir->type); - printf(")\n"); - printf(" (FINISHME: value goes here)\n"); - printf(")\n"); + printf(") "); + printf("(FINISHME: value goes here)"); + printf(") "); } @@ -200,5 +194,5 @@ ir_print_visitor::visit(ir_return *ir) value->accept(this); } - printf(")\n"); + printf(")"); } -- cgit v1.2.3 From 795492247369199d5e79f2503c40920ff8a9b686 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Mar 2010 18:38:28 -0700 Subject: IR print visitor: Finish printing constants --- ir_print_visitor.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 2c9debc7d72..ca9f7592520 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -163,13 +163,30 @@ void ir_print_visitor::visit(ir_assignment *ir) void ir_print_visitor::visit(ir_constant *ir) { - (void) ir; + const glsl_type *const base_type = ir->type->get_base_type(); printf("(constant ("); - print_type(ir->type); - printf(") "); - printf("(FINISHME: value goes here)"); + print_type(base_type); printf(") "); + + const unsigned num_values = 1 + * ((ir->type->vector_elements > 0) ? ir->type->vector_elements : 1) + * ((ir->type->matrix_columns > 0) ? ir->type->matrix_columns : 1); + + printf("(%d) (", num_values); + for (unsigned i = 0; i < num_values; i++) { + if (i != 0) + printf(", "); + + switch (base_type->base_type) { + case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break; + case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break; + case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break; + case GLSL_TYPE_BOOL: printf("%d", ir->value.b[i]); break; + default: assert(0); + } + } + printf(")) "); } -- cgit v1.2.3 From 44e1dfa2df4de3e2de963f0505cdadade6fe8180 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 25 Mar 2010 23:30:28 -0700 Subject: Replace "mode" type tag with virtual as_foo() downcasting functions. These should work well even in a non-flat IR hierarchy. Signed-off-by: Ian Romanick --- ast_to_hir.cpp | 32 ++++++++++++-------------------- ir.cpp | 20 ++++++++++---------- ir.h | 58 ++++++++++++++++++++++++++-------------------------------- 3 files changed, 48 insertions(+), 62 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index cdbf2c1e46b..5b577d1f56d 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -455,20 +455,16 @@ ast_expression::hir(exec_list *instructions, /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ loc = this->subexpressions[0]->get_location(); - if (op[0]->mode != ir_op_dereference) { + const ir_dereference *const ref = op[0]->as_dereference(); + if (ref == NULL) { _mesa_glsl_error(& loc, state, "invalid lvalue in assignment"); error_emitted = true; type = glsl_error_type; } else { - const struct ir_dereference *const ref = - (struct ir_dereference *) op[0]; - const struct ir_variable *const var = - (struct ir_variable *) ref->var; - - if ((var != NULL) - && (var->mode == ir_op_var_decl) - && (var->read_only)) { + const ir_variable *const var = (ir_variable *) ref->var; + + if (var != NULL && var->read_only) { _mesa_glsl_error(& loc, state, "cannot assign to read-only " "variable `%s'", var->name); error_emitted = true; @@ -620,20 +616,16 @@ ast_expression::hir(exec_list *instructions, /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ loc = this->subexpressions[0]->get_location(); - if (op[0]->mode != ir_op_dereference) { + const ir_dereference *const ref = op[0]->as_dereference(); + if (ref == NULL) { _mesa_glsl_error(& loc, state, "invalid lvalue in assignment"); error_emitted = true; type = glsl_error_type; } else { - const struct ir_dereference *const ref = - (struct ir_dereference *) op[0]; - const struct ir_variable *const var = - (struct ir_variable *) ref->var; - - if ((var != NULL) - && (var->mode == ir_op_var_decl) - && (var->read_only)) { + const ir_variable *const var = (ir_variable *) ref->var; + + if (var != NULL && var->read_only) { _mesa_glsl_error(& loc, state, "cannot assign to read-only " "variable `%s'", var->name); error_emitted = true; @@ -1126,7 +1118,7 @@ ast_function_definition::hir(exec_list *instructions, * either include invalid parameter names or may not have names at all. */ foreach_iter(exec_list_iterator, iter, signature->parameters) { - assert(((struct ir_instruction *)iter.get())->mode == ir_op_var_decl); + assert(((ir_instruction *) iter.get())->as_variable() != NULL); iter.remove(); delete iter.get(); @@ -1157,7 +1149,7 @@ ast_function_definition::hir(exec_list *instructions, foreach_iter(exec_list_iterator, iter, parameters) { ir_variable *const var = (ir_variable *) iter.get(); - assert(((ir_instruction *)var)->mode == ir_op_var_decl); + assert(((ir_instruction *) var)->as_variable() != NULL); iter.remove(); instructions->push_tail(var); diff --git a/ir.cpp b/ir.cpp index 1b5947a4704..0e98f0c8d99 100644 --- a/ir.cpp +++ b/ir.cpp @@ -28,7 +28,7 @@ ir_assignment::ir_assignment(ir_instruction *lhs, ir_instruction *rhs, ir_expression *condition) - : ir_instruction(ir_op_assign) + : ir_instruction() { this->lhs = (ir_dereference *) lhs; this->rhs = rhs; @@ -38,7 +38,7 @@ ir_assignment::ir_assignment(ir_instruction *lhs, ir_instruction *rhs, ir_expression::ir_expression(int op, const struct glsl_type *type, ir_instruction *op0, ir_instruction *op1) - : ir_instruction(ir_op_expression) + : ir_instruction() { this->type = type; this->operation = ir_expression_operation(op); @@ -48,14 +48,14 @@ ir_expression::ir_expression(int op, const struct glsl_type *type, ir_label::ir_label(const char *label) - : ir_instruction(ir_op_label), label(label) + : ir_instruction(), label(label) { /* empty */ } ir_constant::ir_constant(const struct glsl_type *type, const void *data) - : ir_instruction(ir_op_constant) + : ir_instruction() { const unsigned elements = ((type->vector_elements == 0) ? 1 : type->vector_elements) @@ -79,7 +79,7 @@ ir_constant::ir_constant(const struct glsl_type *type, const void *data) ir_dereference::ir_dereference(ir_instruction *var) - : ir_instruction(ir_op_dereference) + : ir_instruction() { this->mode = ir_reference_variable; this->var = var; @@ -89,7 +89,7 @@ ir_dereference::ir_dereference(ir_instruction *var) ir_dereference::ir_dereference(ir_instruction *var, ir_instruction *array_index) - : ir_instruction(ir_op_dereference), mode(ir_reference_array), + : ir_instruction(), mode(ir_reference_array), var(var) { this->type = (var != NULL) ? var->type : glsl_error_type; @@ -124,8 +124,8 @@ ir_dereference::set_swizzle(unsigned x, unsigned y, unsigned z, unsigned w, ir_variable::ir_variable(const struct glsl_type *type, const char *name) - : ir_instruction(ir_op_var_decl), read_only(false), centroid(false), - invariant(false), mode(ir_var_auto), interpolation(ir_var_smooth) + : ir_instruction(), read_only(false), centroid(false), invariant(false), + mode(ir_var_auto), interpolation(ir_var_smooth) { this->type = type; this->name = name; @@ -133,14 +133,14 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) ir_function_signature::ir_function_signature(const glsl_type *return_type) - : ir_instruction(ir_op_func_sig), return_type(return_type), definition(NULL) + : ir_instruction(), return_type(return_type), definition(NULL) { /* empty */ } ir_function::ir_function(const char *name) - : ir_instruction(ir_op_func), name(name) + : ir_instruction(), name(name) { /* empty */ } diff --git a/ir.h b/ir.h index 22b46c971e8..c21b26a460e 100644 --- a/ir.h +++ b/ir.h @@ -33,46 +33,32 @@ struct ir_program { void *bong_hits; }; - -enum ir_opcodes { - ir_op_var_decl, - ir_op_assign, - ir_op_expression, - ir_op_dereference, - ir_op_jump, - ir_op_label, - ir_op_constant, - ir_op_func_sig, - ir_op_func, - ir_op_call, -}; - /** * Base class of all IR instructions */ class ir_instruction : public exec_node { public: - unsigned mode; const struct glsl_type *type; virtual void accept(ir_visitor *) = 0; + /** + * \name IR instruction downcast functions + * + * These functions either cast the object to a derived class or return + * \c NULL if the object's type does not match the specified derived class. + * Additional downcast functions will be added as needed. + */ + /*@{*/ + virtual class ir_variable * as_variable() { return NULL; } + virtual class ir_dereference * as_dereference() { return NULL; } + /*@}*/ + protected: - ir_instruction(int mode) - : mode(mode) + ir_instruction() { /* empty */ } - -private: - /** - * Dummy constructor to catch bad constructors in derived classes. - * - * Every derived must use the constructor that sets the instructions - * mode. Having the \c void constructor private prevents derived classes - * from accidentally doing the wrong thing. - */ - ir_instruction(void); }; @@ -94,6 +80,11 @@ class ir_variable : public ir_instruction { public: ir_variable(const struct glsl_type *, const char *); + virtual ir_variable *as_variable() + { + return this; + } + virtual void accept(ir_visitor *v) { v->visit(this); @@ -181,8 +172,6 @@ public: }; /*@}*/ -class ir_expression; -class ir_dereference; class ir_assignment : public ir_instruction { public: @@ -296,7 +285,7 @@ public: class ir_call : public ir_instruction { public: ir_call(const ir_function_signature *callee, exec_list *actual_parameters) - : ir_instruction(ir_op_call), callee(callee) + : ir_instruction(), callee(callee) { assert(callee->return_type != NULL); type = callee->return_type; @@ -315,7 +304,7 @@ public: private: ir_call() - : ir_instruction(ir_op_call), callee(NULL) + : ir_instruction(), callee(NULL) { /* empty */ } @@ -334,7 +323,7 @@ private: class ir_jump : public ir_instruction { protected: ir_jump() - : ir_instruction(ir_op_jump) + : ir_instruction() { /* empty */ } @@ -395,6 +384,11 @@ public: ir_dereference(ir_instruction *variable, ir_instruction *array_index); + virtual ir_dereference *as_dereference() + { + return this; + } + virtual void accept(ir_visitor *v) { v->visit(this); -- cgit v1.2.3 From fb9fb5f51deca28ed1ec7b71759fb71fc26a0ab6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 26 Mar 2010 00:25:36 -0700 Subject: Add new abstract ir_rvalue class; rework accordingly. Signed-off-by: Ian Romanick --- ast.h | 38 ++++++++++++++--------------- ast_function.cpp | 4 +-- ast_to_hir.cpp | 32 ++++++++++++------------ glsl_types.cpp | 8 +++--- hir_field_selection.cpp | 8 +++--- ir.cpp | 20 +++++++-------- ir.h | 65 ++++++++++++++++++++++++++++++++----------------- ir_print_visitor.cpp | 2 +- 8 files changed, 98 insertions(+), 79 deletions(-) diff --git a/ast.h b/ast.h index 5fd69695c1a..a158910421d 100644 --- a/ast.h +++ b/ast.h @@ -39,8 +39,8 @@ class ast_node : public simple_node { public: virtual ~ast_node(); virtual void print(void) const; - virtual ir_instruction *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); /** * Retrieve the source location of an AST node @@ -162,8 +162,8 @@ public: static const char *operator_string(enum ast_operators op); - virtual ir_instruction *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); virtual void print(void) const; @@ -219,8 +219,8 @@ public: return cons; } - virtual ir_instruction *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); private: /** @@ -245,8 +245,8 @@ public: ast_compound_statement(int new_scope, ast_node *statements); virtual void print(void) const; - virtual ir_instruction *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); int new_scope; struct simple_node statements; @@ -401,8 +401,8 @@ public: ast_declarator_list(ast_fully_specified_type *); virtual void print(void) const; - virtual ir_instruction *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); ast_fully_specified_type *type; struct simple_node declarations; @@ -422,8 +422,8 @@ class ast_parameter_declarator : public ast_node { public: virtual void print(void) const; - virtual ir_instruction *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); ast_fully_specified_type *type; char *identifier; @@ -469,8 +469,8 @@ public: ast_expression_statement(ast_expression *); virtual void print(void) const; - virtual ir_instruction *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); ast_expression *expression; }; @@ -531,8 +531,8 @@ public: ast_jump_statement(int mode, ast_expression *return_value); virtual void print(void) const; - virtual ir_instruction *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); enum ast_jump_modes { ast_continue, @@ -549,8 +549,8 @@ class ast_function_definition : public ast_node { public: virtual void print(void) const; - virtual ir_instruction *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); ast_function *prototype; ast_compound_statement *body; @@ -560,7 +560,7 @@ public: extern void _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); -extern struct ir_instruction * +extern struct ir_rvalue * _mesa_ast_field_selection_to_hir(const struct ast_expression *expr, exec_list *instructions, struct _mesa_glsl_parse_state *state); diff --git a/ast_function.cpp b/ast_function.cpp index 7082ed3c140..f774a2fd776 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -27,7 +27,7 @@ #include "glsl_types.h" #include "ir.h" -static ir_instruction * +static ir_rvalue * match_function_by_name(exec_list *instructions, const char *name, YYLTYPE *loc, simple_node *parameters, struct _mesa_glsl_parse_state *state) @@ -78,7 +78,7 @@ match_function_by_name(exec_list *instructions, const char *name, } -ir_instruction * +ir_rvalue * ast_function_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 5b577d1f56d..2fd2e53fda3 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -338,8 +338,8 @@ relational_result_type(const struct glsl_type *type_a, * In addition to being used for assignments, this function is used to * type-check return values. */ -ir_instruction * -validate_assignment(const glsl_type *lhs_type, ir_instruction *rhs) +ir_rvalue * +validate_assignment(const glsl_type *lhs_type, ir_rvalue *rhs) { const glsl_type *const rhs_type = rhs->type; @@ -361,7 +361,7 @@ validate_assignment(const glsl_type *lhs_type, ir_instruction *rhs) } -ir_instruction * +ir_rvalue * ast_node::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { @@ -372,7 +372,7 @@ ast_node::hir(exec_list *instructions, } -ir_instruction * +ir_rvalue * ast_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { @@ -431,8 +431,8 @@ ast_expression::hir(exec_list *instructions, -1, /* ast_bool_constant doesn't conv to ir_expression. */ -1, /* ast_sequence doesn't convert to ir_expression. */ }; - ir_instruction *result = NULL; - ir_instruction *op[2]; + ir_rvalue *result = NULL; + ir_rvalue *op[2]; struct simple_node op_list; const struct glsl_type *type = glsl_error_type; bool error_emitted = false; @@ -589,8 +589,6 @@ ast_expression::hir(exec_list *instructions, case ast_div_assign: case ast_add_assign: case ast_sub_assign: { - struct ir_instruction *temp_rhs; - op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); @@ -601,8 +599,8 @@ ast_expression::hir(exec_list *instructions, (this->oper == ast_mul_assign), state); - temp_rhs = new ir_expression(operations[this->oper], type, - op[0], op[1]); + ir_rvalue *temp_rhs = new ir_expression(operations[this->oper], type, + op[0], op[1]); /* FINISHME: This is copied from ast_assign above. It should * FINISHME: probably be consolidated. @@ -635,7 +633,7 @@ ast_expression::hir(exec_list *instructions, } } - ir_instruction *rhs = validate_assignment(op[0]->type, temp_rhs); + ir_rvalue *rhs = validate_assignment(op[0]->type, temp_rhs); if (rhs == NULL) { type = glsl_error_type; rhs = temp_rhs; @@ -759,7 +757,7 @@ ast_expression::hir(exec_list *instructions, } -ir_instruction * +ir_rvalue * ast_expression_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { @@ -781,7 +779,7 @@ ast_expression_statement::hir(exec_list *instructions, } -ir_instruction * +ir_rvalue * ast_compound_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { @@ -863,7 +861,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, } -ir_instruction * +ir_rvalue * ast_declarator_list::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { @@ -951,7 +949,7 @@ ast_declarator_list::hir(exec_list *instructions, } -ir_instruction * +ir_rvalue * ast_parameter_declarator::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { @@ -1038,7 +1036,7 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) } -ir_instruction * +ir_rvalue * ast_function_definition::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { @@ -1183,7 +1181,7 @@ ast_function_definition::hir(exec_list *instructions, } -ir_instruction * +ir_rvalue * ast_jump_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { diff --git a/glsl_types.cpp b/glsl_types.cpp index f7ef4a302b9..846761fff67 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -190,7 +190,7 @@ generate_vec_body_from_scalar(exec_list *instructions, retval->set_swizzle(0, 0, 0, 0, declarations[16]->type->vector_elements); - inst = new ir_return((ir_expression *) retval); + inst = new ir_return(retval); instructions->push_tail(inst); } @@ -222,7 +222,7 @@ generate_vec_body_from_N_scalars(exec_list *instructions, ir_dereference *retval = new ir_dereference(declarations[16]); - inst = new ir_return((ir_expression *) retval); + inst = new ir_return(retval); instructions->push_tail(inst); } @@ -300,7 +300,7 @@ generate_mat_body_from_scalar(exec_list *instructions, } ir_dereference *const retval = new ir_dereference(declarations[16]); - inst = new ir_return((ir_expression *) retval); + inst = new ir_return(retval); instructions->push_tail(inst); } @@ -342,7 +342,7 @@ generate_mat_body_from_N_scalars(exec_list *instructions, ir_dereference *retval = new ir_dereference(declarations[16]); - inst = new ir_return((ir_expression *) retval); + inst = new ir_return(retval); instructions->push_tail(inst); } diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 5f548bfa0f8..41dbd42d3bf 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -106,12 +106,12 @@ generate_swizzle(const char *str, ir_dereference *deref, } -struct ir_instruction * +struct ir_rvalue * _mesa_ast_field_selection_to_hir(const ast_expression *expr, exec_list *instructions, struct _mesa_glsl_parse_state *state) { - ir_instruction *op; + ir_rvalue *op; ir_dereference *deref; YYLTYPE loc; @@ -128,7 +128,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, * now. Doing so prevents spurious error messages from being logged below. */ if (is_error_type(op->type)) - return (struct ir_instruction *) deref; + return deref; /* There are two kinds of field selection. There is the selection of a * specific field from a structure, and there is the selection of a @@ -164,5 +164,5 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, expr->primary_expression.identifier); } - return (struct ir_instruction *) deref; + return deref; } diff --git a/ir.cpp b/ir.cpp index 0e98f0c8d99..8051fb41330 100644 --- a/ir.cpp +++ b/ir.cpp @@ -26,19 +26,19 @@ #include "ir.h" #include "glsl_types.h" -ir_assignment::ir_assignment(ir_instruction *lhs, ir_instruction *rhs, - ir_expression *condition) - : ir_instruction() +ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, + ir_rvalue *condition) + : ir_rvalue() { - this->lhs = (ir_dereference *) lhs; + this->lhs = lhs; this->rhs = rhs; this->condition = condition; } ir_expression::ir_expression(int op, const struct glsl_type *type, - ir_instruction *op0, ir_instruction *op1) - : ir_instruction() + ir_rvalue *op0, ir_rvalue *op1) + : ir_rvalue() { this->type = type; this->operation = ir_expression_operation(op); @@ -55,7 +55,7 @@ ir_label::ir_label(const char *label) ir_constant::ir_constant(const struct glsl_type *type, const void *data) - : ir_instruction() + : ir_rvalue() { const unsigned elements = ((type->vector_elements == 0) ? 1 : type->vector_elements) @@ -79,7 +79,7 @@ ir_constant::ir_constant(const struct glsl_type *type, const void *data) ir_dereference::ir_dereference(ir_instruction *var) - : ir_instruction() + : ir_rvalue() { this->mode = ir_reference_variable; this->var = var; @@ -88,8 +88,8 @@ ir_dereference::ir_dereference(ir_instruction *var) ir_dereference::ir_dereference(ir_instruction *var, - ir_instruction *array_index) - : ir_instruction(), mode(ir_reference_array), + ir_rvalue *array_index) + : ir_rvalue(), mode(ir_reference_array), var(var) { this->type = (var != NULL) ? var->type : glsl_error_type; diff --git a/ir.h b/ir.h index c21b26a460e..29bc055dd7a 100644 --- a/ir.h +++ b/ir.h @@ -52,6 +52,7 @@ public: /*@{*/ virtual class ir_variable * as_variable() { return NULL; } virtual class ir_dereference * as_dereference() { return NULL; } + virtual class ir_rvalue * as_rvalue() { return NULL; } /*@}*/ protected: @@ -62,6 +63,23 @@ protected: }; +class ir_rvalue : public ir_instruction { +public: + virtual ir_rvalue * as_rvalue() + { + return this; + } + + virtual bool is_lvalue() + { + return false; + } + +protected: + ir_rvalue() : ir_instruction() { } +}; + + enum ir_variable_mode { ir_var_auto = 0, ir_var_uniform, @@ -76,6 +94,7 @@ enum ir_varaible_interpolation { ir_var_noperspective }; + class ir_variable : public ir_instruction { public: ir_variable(const struct glsl_type *, const char *); @@ -173,10 +192,9 @@ public: /*@}*/ -class ir_assignment : public ir_instruction { +class ir_assignment : public ir_rvalue { public: - ir_assignment(ir_instruction *lhs, ir_instruction *rhs, - ir_expression *condition); + ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); virtual void accept(ir_visitor *v) { @@ -186,19 +204,17 @@ public: /** * Left-hand side of the assignment. */ - ir_dereference *lhs; + ir_rvalue *lhs; /** * Value being assigned - * - * This should be either \c ir_op_expression or \c ir_op_dereference. */ - ir_instruction *rhs; + ir_rvalue *rhs; /** * Optional condition for the assignment. */ - ir_expression *condition; + ir_rvalue *condition; }; @@ -264,10 +280,10 @@ enum ir_expression_operation { ir_binop_pow }; -class ir_expression : public ir_instruction { +class ir_expression : public ir_rvalue { public: ir_expression(int op, const struct glsl_type *type, - ir_instruction *, ir_instruction *); + ir_rvalue *, ir_rvalue *); virtual void accept(ir_visitor *v) { @@ -275,17 +291,17 @@ public: } ir_expression_operation operation; - ir_instruction *operands[2]; + ir_rvalue *operands[2]; }; /** * IR instruction representing a function call */ -class ir_call : public ir_instruction { +class ir_call : public ir_rvalue { public: ir_call(const ir_function_signature *callee, exec_list *actual_parameters) - : ir_instruction(), callee(callee) + : ir_rvalue(), callee(callee) { assert(callee->return_type != NULL); type = callee->return_type; @@ -304,7 +320,7 @@ public: private: ir_call() - : ir_instruction(), callee(NULL) + : ir_rvalue(), callee(NULL) { /* empty */ } @@ -337,13 +353,13 @@ public: /* empty */ } - ir_return(ir_expression *value) + ir_return(ir_rvalue *value) : value(value) { /* empty */ } - ir_expression *get_value() const + ir_rvalue *get_value() const { return value; } @@ -354,7 +370,7 @@ public: } private: - ir_expression *value; + ir_rvalue *value; }; /*@}*/ @@ -378,11 +394,11 @@ struct ir_swizzle_mask { unsigned has_duplicates:1; }; -class ir_dereference : public ir_instruction { +class ir_dereference : public ir_rvalue { public: ir_dereference(struct ir_instruction *); - ir_dereference(ir_instruction *variable, ir_instruction *array_index); + ir_dereference(ir_instruction *variable, ir_rvalue *array_index); virtual ir_dereference *as_dereference() { @@ -394,6 +410,11 @@ public: v->visit(this); } + bool is_lvalue() + { + return var != NULL; + } + /** * Setting the swizzle of a derefernce */ @@ -410,19 +431,19 @@ public: /** * Object being dereferenced. * - * Must be either an \c ir_variable or an \c ir_dereference. + * Must be either an \c ir_variable or an \c ir_rvalue. */ ir_instruction *var; union { - ir_instruction *array_index; + ir_rvalue *array_index; const char *field; struct ir_swizzle_mask swizzle; } selector; }; -class ir_constant : public ir_instruction { +class ir_constant : public ir_rvalue { public: ir_constant(const struct glsl_type *type, const void *data); diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index ca9f7592520..8941d3c7b9f 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -205,7 +205,7 @@ ir_print_visitor::visit(ir_return *ir) { printf("(return"); - ir_expression *const value = ir->get_value(); + ir_rvalue *const value = ir->get_value(); if (value) { printf(" "); value->accept(this); -- cgit v1.2.3 From affc1413ac9f1f077a4ba1a1b7135f73d7a71167 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 26 Mar 2010 01:20:08 -0700 Subject: Move swizzles out of ir_dereference and into their own class. Also turn generate_swizzle into a static "create" method of the new class; we'll want to use it for the IR reader as well. Signed-off-by: Ian Romanick --- ast_to_hir.cpp | 35 ++------------ glsl_types.cpp | 35 +++++++------- hir_field_selection.cpp | 119 +++++------------------------------------------- ir.cpp | 104 ++++++++++++++++++++++++++++++++++++++---- ir.h | 33 ++++++++++---- ir_print_visitor.cpp | 32 ++++++++----- ir_print_visitor.h | 1 + ir_visitor.h | 1 + 8 files changed, 176 insertions(+), 184 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 2fd2e53fda3..c7e73b66304 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -454,23 +454,10 @@ ast_expression::hir(exec_list *instructions, YYLTYPE loc; /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ - loc = this->subexpressions[0]->get_location(); - const ir_dereference *const ref = op[0]->as_dereference(); - if (ref == NULL) { - _mesa_glsl_error(& loc, state, "invalid lvalue in assignment"); + if (!op[0]->is_lvalue()) { + _mesa_glsl_error(& loc, state, "non-lvalue in assignment"); error_emitted = true; - type = glsl_error_type; - } else { - const ir_variable *const var = (ir_variable *) ref->var; - - if (var != NULL && var->read_only) { - _mesa_glsl_error(& loc, state, "cannot assign to read-only " - "variable `%s'", var->name); - error_emitted = true; - - type = glsl_error_type; - } } } @@ -612,24 +599,10 @@ ast_expression::hir(exec_list *instructions, if (!error_emitted) { YYLTYPE loc; - /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ - loc = this->subexpressions[0]->get_location(); - const ir_dereference *const ref = op[0]->as_dereference(); - if (ref == NULL) { - _mesa_glsl_error(& loc, state, "invalid lvalue in assignment"); + if (!op[0]->is_lvalue()) { + _mesa_glsl_error(& loc, state, "non-lvalue in assignment"); error_emitted = true; - type = glsl_error_type; - } else { - const ir_variable *const var = (ir_variable *) ref->var; - - if (var != NULL && var->read_only) { - _mesa_glsl_error(& loc, state, "cannot assign to read-only " - "variable `%s'", var->name); - error_emitted = true; - - type = glsl_error_type; - } } } diff --git a/glsl_types.cpp b/glsl_types.cpp index 846761fff67..bcaa69825c0 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -178,17 +178,18 @@ generate_vec_body_from_scalar(exec_list *instructions, /* Generate a single assignment of the parameter to __retval.x and return * __retval.xxxx for however many vector components there are. */ - ir_dereference *const lhs = new ir_dereference(declarations[16]); + ir_dereference *const lhs_ref = new ir_dereference(declarations[16]); ir_dereference *const rhs = new ir_dereference(declarations[0]); - lhs->set_swizzle(0, 0, 0, 0, 1); + ir_swizzle *lhs = new ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); inst = new ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); - ir_dereference *const retval = new ir_dereference(declarations[16]); + ir_dereference *const retref = new ir_dereference(declarations[16]); - retval->set_swizzle(0, 0, 0, 0, declarations[16]->type->vector_elements); + ir_swizzle *retval = new ir_swizzle(retref, 0, 0, 0, 0, + declarations[16]->type->vector_elements); inst = new ir_return(retval); instructions->push_tail(inst); @@ -210,11 +211,10 @@ generate_vec_body_from_N_scalars(exec_list *instructions, * __retval.x and return __retval. */ for (unsigned i = 0; i < vec_type->vector_elements; i++) { - ir_dereference *const lhs = new ir_dereference(declarations[16]); + ir_dereference *const lhs_ref = new ir_dereference(declarations[16]); ir_dereference *const rhs = new ir_dereference(declarations[i]); - lhs->selector.swizzle.x = i; - lhs->selector.swizzle.num_components = 1; + ir_swizzle *lhs = new ir_swizzle(lhs_ref, 1, 0, 0, 0, 1); inst = new ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); @@ -262,10 +262,10 @@ generate_mat_body_from_scalar(exec_list *instructions, instructions->push_tail(column); - ir_dereference *const lhs = new ir_dereference(column); + ir_dereference *const lhs_ref = new ir_dereference(column); ir_dereference *const rhs = new ir_dereference(declarations[0]); - lhs->set_swizzle(0, 0, 0, 0, 1); + ir_swizzle *lhs = new ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); inst = new ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); @@ -274,9 +274,9 @@ generate_mat_body_from_scalar(exec_list *instructions, ir_constant *const zero = new ir_constant(glsl_float_type, &z); for (unsigned i = 1; i < column_type->vector_elements; i++) { - ir_dereference *const lhs = new ir_dereference(column); + ir_dereference *const lhs_ref = new ir_dereference(column); - lhs->set_swizzle(i, 0, 0, 0, 1); + ir_swizzle *lhs = new ir_swizzle(lhs_ref, i, 0, 0, 0, 1); inst = new ir_assignment(lhs, zero, NULL); instructions->push_tail(inst); @@ -285,12 +285,13 @@ generate_mat_body_from_scalar(exec_list *instructions, for (unsigned i = 0; i < row_type->vector_elements; i++) { static const unsigned swiz[] = { 1, 1, 1, 0, 1, 1, 1 }; - ir_dereference *const rhs = new ir_dereference(column); + ir_dereference *const rhs_ref = new ir_dereference(column); /* This will be .xyyy when i=0, .yxyy when i=1, etc. */ - rhs->set_swizzle(swiz[3 - i], swiz[4 - i], swiz[5 - i], swiz[6 - i], - column_type->vector_elements); + ir_swizzle *rhs = new ir_swizzle(rhs_ref, swiz[3 - i], swiz[4 - i], + swiz[5 - i], swiz[6 - i], + column_type->vector_elements); ir_constant *const idx = new ir_constant(glsl_int_type, &i); ir_dereference *const lhs = new ir_dereference(declarations[16], idx); @@ -326,11 +327,11 @@ generate_mat_body_from_N_scalars(exec_list *instructions, ir_dereference *const row_access = new ir_dereference(declarations[16], row_index); - ir_dereference *const component_access = + ir_dereference *const component_access_ref = new ir_dereference(row_access); - component_access->selector.swizzle.x = j; - component_access->selector.swizzle.num_components = 1; + ir_swizzle *component_access = new ir_swizzle(component_access_ref, + j, 0, 0, 0, 1); const unsigned param = (i * row_type->vector_elements) + j; ir_dereference *const rhs = new ir_dereference(declarations[param]); diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 41dbd42d3bf..76c48683619 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -28,107 +28,15 @@ #include "glsl_types.h" #include "ir.h" -#define X 1 -#define R 5 -#define S 9 -#define I 13 - -static bool -generate_swizzle(const char *str, ir_dereference *deref, - unsigned vector_length) -{ - /* For each possible swizzle character, this table encodes the value in - * \c idx_map that represents the 0th element of the vector. For invalid - * swizzle characters (e.g., 'k'), a special value is used that will allow - * detection of errors. - */ - static const unsigned char base_idx[26] = { - /* a b c d e f g h i j k l m */ - R, R, I, I, I, I, R, I, I, I, I, I, I, - /* n o p q r s t u v w x y z */ - I, I, S, S, R, S, S, I, I, X, X, X, X - }; - - /* Each valid swizzle character has an entry in the previous table. This - * table encodes the base index encoded in the previous table plus the actual - * index of the swizzle character. When processing swizzles, the first - * character in the string is indexed in the previous table. Each character - * in the string is indexed in this table, and the value found there has the - * value form the first table subtracted. The result must be on the range - * [0,3]. - * - * For example, the string "wzyx" will get X from the first table. Each of - * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After - * subtraction, the swizzle values are { 3, 2, 1, 0 }. - * - * The string "wzrg" will get X from the first table. Each of the characters - * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the - * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range - * [0,3], the error is detected. - */ - static const unsigned char idx_map[26] = { - /* a b c d e f g h i j k l m */ - R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, - /* n o p q r s t u v w x y z */ - 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2 - }; - - int swiz_idx[4] = { 0, 0, 0, 0 }; - unsigned i; - - - /* Validate the first character in the swizzle string and look up the base - * index value as described above. - */ - if ((str[0] < 'a') || (str[0] > 'z')) - return false; - - const unsigned base = base_idx[str[0] - 'a']; - - - for (i = 0; (i < 4) && (str[i] != '\0'); i++) { - /* Validate the next character, and, as described above, convert it to a - * swizzle index. - */ - if ((str[i] < 'a') || (str[i] > 'z')) - return false; - - swiz_idx[i] = idx_map[str[i] - 'a'] - base; - if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) - return false; - } - - if (str[i] != '\0') - return false; - - deref->set_swizzle(swiz_idx[0], swiz_idx[1], swiz_idx[2], swiz_idx[3], i); - return true; -} - - struct ir_rvalue * _mesa_ast_field_selection_to_hir(const ast_expression *expr, exec_list *instructions, struct _mesa_glsl_parse_state *state) { + ir_rvalue *result = NULL; ir_rvalue *op; - ir_dereference *deref; - YYLTYPE loc; - op = expr->subexpressions[0]->hir(instructions, state); - deref = new ir_dereference(op); - - /* Initially assume that the resulting type of the field selection is an - * error. This make the error paths below a bit easier to follow. - */ - deref->type = glsl_error_type; - - /* If processing the thing being dereferenced generated an error, bail out - * now. Doing so prevents spurious error messages from being logged below. - */ - if (is_error_type(op->type)) - return deref; /* There are two kinds of field selection. There is the selection of a * specific field from a structure, and there is the selection of a @@ -136,21 +44,18 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, * by the base type of the thing to which the field selection operator is * being applied. */ - loc = expr->get_location(); - if (op->type->is_vector()) { - if (generate_swizzle(expr->primary_expression.identifier, - deref, op->type->vector_elements)) { - /* Based on the number of elements in the swizzle and the base type - * (i.e., float, int, unsigned, or bool) of the vector being swizzled, - * generate the type of the resulting value. - */ - deref->type = - glsl_type::get_instance(op->type->base_type, - deref->selector.swizzle.num_components, - 1); + YYLTYPE loc = expr->get_location(); + if (op->type == glsl_error_type) { + /* silently propagate the error */ + } else if (op->type->is_vector()) { + ir_swizzle *swiz = ir_swizzle::create(op, + expr->primary_expression.identifier, + op->type->vector_elements); + if (swiz != NULL) { + result = swiz; } else { /* FINISHME: Logging of error messages should be moved into - * FINISHME: generate_swizzle. This allows the generation of more + * FINISHME: ir_swizzle::create. This allows the generation of more * FINISHME: specific error messages. */ _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'", @@ -164,5 +69,5 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, expr->primary_expression.identifier); } - return deref; + return result ? result : ir_call::get_error_instruction(); } diff --git a/ir.cpp b/ir.cpp index 8051fb41330..58c459ed5db 100644 --- a/ir.cpp +++ b/ir.cpp @@ -97,9 +97,9 @@ ir_dereference::ir_dereference(ir_instruction *var, } -void -ir_dereference::set_swizzle(unsigned x, unsigned y, unsigned z, unsigned w, - unsigned count) +ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, + unsigned w, unsigned count) + : val(val) { assert((count >= 1) && (count <= 4)); @@ -113,14 +113,100 @@ ir_dereference::set_swizzle(unsigned x, unsigned y, unsigned z, unsigned w, assert(z <= 3); assert(w <= 3); - selector.swizzle.x = x; - selector.swizzle.y = y; - selector.swizzle.z = z; - selector.swizzle.w = w; - selector.swizzle.num_components = count; - selector.swizzle.has_duplicates = dup_mask != 0; + mask.x = x; + mask.y = y; + mask.z = z; + mask.w = w; + mask.num_components = count; + mask.has_duplicates = dup_mask != 0; + + /* Based on the number of elements in the swizzle and the base type + * (i.e., float, int, unsigned, or bool) of the vector being swizzled, + * generate the type of the resulting value. + */ + type = glsl_type::get_instance(val->type->base_type, mask.num_components, 1); } +#define X 1 +#define R 5 +#define S 9 +#define I 13 + +ir_swizzle * +ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) +{ + /* For each possible swizzle character, this table encodes the value in + * \c idx_map that represents the 0th element of the vector. For invalid + * swizzle characters (e.g., 'k'), a special value is used that will allow + * detection of errors. + */ + static const unsigned char base_idx[26] = { + /* a b c d e f g h i j k l m */ + R, R, I, I, I, I, R, I, I, I, I, I, I, + /* n o p q r s t u v w x y z */ + I, I, S, S, R, S, S, I, I, X, X, X, X + }; + + /* Each valid swizzle character has an entry in the previous table. This + * table encodes the base index encoded in the previous table plus the actual + * index of the swizzle character. When processing swizzles, the first + * character in the string is indexed in the previous table. Each character + * in the string is indexed in this table, and the value found there has the + * value form the first table subtracted. The result must be on the range + * [0,3]. + * + * For example, the string "wzyx" will get X from the first table. Each of + * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After + * subtraction, the swizzle values are { 3, 2, 1, 0 }. + * + * The string "wzrg" will get X from the first table. Each of the characters + * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the + * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range + * [0,3], the error is detected. + */ + static const unsigned char idx_map[26] = { + /* a b c d e f g h i j k l m */ + R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, + /* n o p q r s t u v w x y z */ + 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2 + }; + + int swiz_idx[4] = { 0, 0, 0, 0 }; + unsigned i; + + + /* Validate the first character in the swizzle string and look up the base + * index value as described above. + */ + if ((str[0] < 'a') || (str[0] > 'z')) + return NULL; + + const unsigned base = base_idx[str[0] - 'a']; + + + for (i = 0; (i < 4) && (str[i] != '\0'); i++) { + /* Validate the next character, and, as described above, convert it to a + * swizzle index. + */ + if ((str[i] < 'a') || (str[i] > 'z')) + return NULL; + + swiz_idx[i] = idx_map[str[i] - 'a'] - base; + if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) + return NULL; + } + + if (str[i] != '\0') + return NULL; + + return new ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2], + swiz_idx[3], i); +} + +#undef X +#undef R +#undef S +#undef I ir_variable::ir_variable(const struct glsl_type *type, const char *name) diff --git a/ir.h b/ir.h index 29bc055dd7a..63ae0bc3b69 100644 --- a/ir.h +++ b/ir.h @@ -394,6 +394,31 @@ struct ir_swizzle_mask { unsigned has_duplicates:1; }; + +class ir_swizzle : public ir_rvalue { +public: + ir_swizzle(ir_rvalue *, unsigned x, unsigned y, unsigned z, unsigned w, + unsigned count); + /** + * Construct an ir_swizzle from the textual representation. Can fail. + */ + static ir_swizzle *create(ir_rvalue *, const char *, unsigned vector_length); + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + bool is_lvalue() + { + return val->is_lvalue(); + } + + ir_rvalue *val; + ir_swizzle_mask mask; +}; + + class ir_dereference : public ir_rvalue { public: ir_dereference(struct ir_instruction *); @@ -415,13 +440,6 @@ public: return var != NULL; } - /** - * Setting the swizzle of a derefernce - */ - void set_swizzle(unsigned x, unsigned y, unsigned z, unsigned w, - unsigned count); - - enum { ir_reference_variable, ir_reference_array, @@ -438,7 +456,6 @@ public: union { ir_rvalue *array_index; const char *field; - struct ir_swizzle_mask swizzle; } selector; }; diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 8941d3c7b9f..1696be69b55 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -102,26 +102,34 @@ void ir_print_visitor::visit(ir_expression *ir) } +void ir_print_visitor::visit(ir_swizzle *ir) +{ + const unsigned swiz[4] = { + ir->mask.x, + ir->mask.y, + ir->mask.z, + ir->mask.w, + }; + + printf("(swiz "); + for (unsigned i = 0; i < ir->mask.num_components; i++) { + printf("%c", "xyzw"[swiz[i]]); + } + printf(" "); + ir->val->accept(this); + printf(")"); +} + + void ir_print_visitor::visit(ir_dereference *ir) { deref_depth++; switch (ir->mode) { case ir_dereference::ir_reference_variable: { - const unsigned swiz[4] = { - ir->selector.swizzle.x, - ir->selector.swizzle.y, - ir->selector.swizzle.z, - ir->selector.swizzle.w, - }; - printf("(var_ref "); ir->var->accept(this); - printf("("); - for (unsigned i = 0; i < ir->selector.swizzle.num_components; i++) { - printf("%c", "xyzw"[swiz[i]]); - } - printf(")) "); + printf(") "); break; } case ir_dereference::ir_reference_array: diff --git a/ir_print_visitor.h b/ir_print_visitor.h index a4309c4f2a4..8fd684eb92a 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -58,6 +58,7 @@ public: virtual void visit(ir_function_signature *); virtual void visit(ir_function *); virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); virtual void visit(ir_dereference *); virtual void visit(ir_assignment *); virtual void visit(ir_constant *); diff --git a/ir_visitor.h b/ir_visitor.h index 8ea416eb9f2..76981f7afc1 100644 --- a/ir_visitor.h +++ b/ir_visitor.h @@ -49,6 +49,7 @@ public: virtual void visit(class ir_function_signature *) = 0; virtual void visit(class ir_function *) = 0; virtual void visit(class ir_expression *) = 0; + virtual void visit(class ir_swizzle *) = 0; virtual void visit(class ir_dereference *) = 0; virtual void visit(class ir_assignment *) = 0; virtual void visit(class ir_constant *) = 0; -- cgit v1.2.3 From a43817a483a8c4a480ef4e6dfda2cef899300eb0 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 14:27:23 -0700 Subject: Use glsl_type::is_error instead of comparison with glsl_error_type pointer --- ast_to_hir.cpp | 23 +++++++++-------------- hir_field_selection.cpp | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index c7e73b66304..884516f8b67 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -446,8 +446,7 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - error_emitted = ((op[0]->type == glsl_error_type) - || (op[1]->type == glsl_error_type)); + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); type = op[0]->type; if (!error_emitted) { @@ -477,8 +476,8 @@ ast_expression::hir(exec_list *instructions, case ast_plus: op[0] = this->subexpressions[0]->hir(instructions, state); - error_emitted = (op[0]->type == glsl_error_type); - if (type == glsl_error_type) + error_emitted = op[0]->type->is_error(); + if (type->is_error()) op[0]->type = type; result = op[0]; @@ -489,7 +488,7 @@ ast_expression::hir(exec_list *instructions, type = unary_arithmetic_result_type(op[0]->type); - error_emitted = (op[0]->type == glsl_error_type); + error_emitted = op[0]->type->is_error(); result = new ir_expression(operations[this->oper], type, op[0], NULL); @@ -514,8 +513,7 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - error_emitted = ((op[0]->type == glsl_error_type) - || (op[1]->type == glsl_error_type)); + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); type = modulus_result_type(op[0]->type, op[1]->type); @@ -537,15 +535,14 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - error_emitted = ((op[0]->type == glsl_error_type) - || (op[1]->type == glsl_error_type)); + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); type = relational_result_type(op[0]->type, op[1]->type, state); /* The relational operators must either generate an error or result * in a scalar boolean. See page 57 of the GLSL 1.50 spec. */ - assert((type == glsl_error_type) + assert(type->is_error() || ((type->base_type == GLSL_TYPE_BOOL) && type->is_scalar())); @@ -579,8 +576,7 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - error_emitted = ((op[0]->type == glsl_error_type) - || (op[1]->type == glsl_error_type)); + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); type = arithmetic_result_type(op[0]->type, op[1]->type, (this->oper == ast_mul_assign), @@ -592,8 +588,7 @@ ast_expression::hir(exec_list *instructions, /* FINISHME: This is copied from ast_assign above. It should * FINISHME: probably be consolidated. */ - error_emitted = ((op[0]->type == glsl_error_type) - || (temp_rhs->type == glsl_error_type)); + error_emitted = op[0]->type->is_error() || temp_rhs->type->is_error(); type = op[0]->type; if (!error_emitted) { diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 76c48683619..17c3f5c5ba3 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -45,7 +45,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, * being applied. */ YYLTYPE loc = expr->get_location(); - if (op->type == glsl_error_type) { + if (op->type->is_error()) { /* silently propagate the error */ } else if (op->type->is_vector()) { ir_swizzle *swiz = ir_swizzle::create(op, -- cgit v1.2.3 From 0471e8b0896e05b3bc81ccad6184e6e35fb61425 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 14:33:41 -0700 Subject: Make glsl_*_type glsl_type class static data --- ast_to_hir.cpp | 42 +++++++++++++++++++++--------------------- builtin_types.sh | 12 ++++++------ glsl_types.cpp | 34 +++++++++++++++++----------------- glsl_types.h | 32 +++++++++++++++++++------------- ir.cpp | 6 +++--- 5 files changed, 66 insertions(+), 60 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 884516f8b67..40a980f6826 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -85,7 +85,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * floating-point scalars, vectors, and matrices." */ if (!type_a->is_numeric() || !type_b->is_numeric()) { - return glsl_error_type; + return glsl_type::error_type; } @@ -114,7 +114,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * equality. */ if (type_a->base_type != type_b->base_type) { - return glsl_error_type; + return glsl_type::error_type; } /* "All arithmetic binary operators result in the same fundamental type @@ -152,7 +152,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * vector." */ if (type_a->is_vector() && type_b->is_vector()) { - return (type_a == type_b) ? type_a : glsl_error_type; + return (type_a == type_b) ? type_a : glsl_type::error_type; } /* All of the combinations of , , @@ -181,7 +181,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * more detail how vectors and matrices are operated on." */ if (! multiply) { - return (type_a == type_b) ? type_a : glsl_error_type; + return (type_a == type_b) ? type_a : glsl_type::error_type; } else { if (type_a->is_matrix() && type_b->is_matrix()) { /* Matrix multiply. The columns of A must match the rows of B. Given @@ -224,7 +224,7 @@ arithmetic_result_type(const struct glsl_type *type_a, /* "All other cases are illegal." */ - return glsl_error_type; + return glsl_type::error_type; } @@ -240,7 +240,7 @@ unary_arithmetic_result_type(const struct glsl_type *type) * they operated on." */ if (!is_numeric_base_type(type->base_type)) - return glsl_error_type; + return glsl_type::error_type; return type; } @@ -258,7 +258,7 @@ modulus_result_type(const struct glsl_type *type_a, if (! is_integer_base_type(type_a->base_type) || ! is_integer_base_type(type_b->base_type) || (type_a->base_type != type_b->base_type)) { - return glsl_error_type; + return glsl_type::error_type; } /* "The operands cannot be vectors of differing size. If one operand is @@ -276,7 +276,7 @@ modulus_result_type(const struct glsl_type *type_a, /* "The operator modulus (%) is not defined for any other data types * (non-integer types)." */ - return glsl_error_type; + return glsl_type::error_type; } @@ -294,7 +294,7 @@ relational_result_type(const struct glsl_type *type_a, || ! is_numeric_base_type(type_b->base_type) || !type_a->is_scalar() || !type_b->is_scalar()) - return glsl_error_type; + return glsl_type::error_type; /* "Either the operands' types must match, or the conversions from * Section 4.1.10 "Implicit Conversions" will be applied to the integer @@ -314,11 +314,11 @@ relational_result_type(const struct glsl_type *type_a, } if (type_a->base_type != type_b->base_type) - return glsl_error_type; + return glsl_type::error_type; /* "The result is scalar Boolean." */ - return glsl_bool_type; + return glsl_type::bool_type; } @@ -434,7 +434,7 @@ ast_expression::hir(exec_list *instructions, ir_rvalue *result = NULL; ir_rvalue *op[2]; struct simple_node op_list; - const struct glsl_type *type = glsl_error_type; + const struct glsl_type *type = glsl_type::error_type; bool error_emitted = false; YYLTYPE loc; @@ -456,13 +456,13 @@ ast_expression::hir(exec_list *instructions, if (!op[0]->is_lvalue()) { _mesa_glsl_error(& loc, state, "non-lvalue in assignment"); error_emitted = true; - type = glsl_error_type; + type = glsl_type::error_type; } } ir_instruction *rhs = validate_assignment(op[0]->type, op[1]); if (rhs == NULL) { - type = glsl_error_type; + type = glsl_type::error_type; rhs = op[1]; } @@ -597,13 +597,13 @@ ast_expression::hir(exec_list *instructions, if (!op[0]->is_lvalue()) { _mesa_glsl_error(& loc, state, "non-lvalue in assignment"); error_emitted = true; - type = glsl_error_type; + type = glsl_type::error_type; } } ir_rvalue *rhs = validate_assignment(op[0]->type, temp_rhs); if (rhs == NULL) { - type = glsl_error_type; + type = glsl_type::error_type; rhs = temp_rhs; } @@ -674,22 +674,22 @@ ast_expression::hir(exec_list *instructions, } case ast_int_constant: - type = glsl_int_type; + type = glsl_type::int_type; result = new ir_constant(type, & this->primary_expression); break; case ast_uint_constant: - type = glsl_uint_type; + type = glsl_type::uint_type; result = new ir_constant(type, & this->primary_expression); break; case ast_float_constant: - type = glsl_float_type; + type = glsl_type::float_type; result = new ir_constant(type, & this->primary_expression); break; case ast_bool_constant: - type = glsl_bool_type; + type = glsl_type::bool_type; result = new ir_constant(type, & this->primary_expression); break; @@ -939,7 +939,7 @@ ast_parameter_declarator::hir(exec_list *instructions, this->identifier); } - type = glsl_error_type; + type = glsl_type::error_type; } ir_variable *var = new ir_variable(type, this->identifier); diff --git a/builtin_types.sh b/builtin_types.sh index 299a4cef415..6658ada41a6 100755 --- a/builtin_types.sh +++ b/builtin_types.sh @@ -119,13 +119,13 @@ cat <push_tail(inst); const float z = 0.0f; - ir_constant *const zero = new ir_constant(glsl_float_type, &z); + ir_constant *const zero = new ir_constant(glsl_type::float_type, &z); for (unsigned i = 1; i < column_type->vector_elements; i++) { ir_dereference *const lhs_ref = new ir_dereference(column); @@ -293,7 +293,7 @@ generate_mat_body_from_scalar(exec_list *instructions, swiz[5 - i], swiz[6 - i], column_type->vector_elements); - ir_constant *const idx = new ir_constant(glsl_int_type, &i); + ir_constant *const idx = new ir_constant(glsl_type::int_type, &i); ir_dereference *const lhs = new ir_dereference(declarations[16], idx); inst = new ir_assignment(lhs, rhs, NULL); @@ -323,7 +323,7 @@ generate_mat_body_from_N_scalars(exec_list *instructions, */ for (unsigned i = 0; i < column_type->vector_elements; i++) { for (unsigned j = 0; j < row_type->vector_elements; j++) { - ir_constant *row_index = new ir_constant(glsl_int_type, &i); + ir_constant *row_index = new ir_constant(glsl_type::int_type, &i); ir_dereference *const row_access = new ir_dereference(declarations[16], row_index); @@ -486,7 +486,7 @@ const glsl_type * glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) { if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4)) - return glsl_error_type; + return error_type; /* Treat GLSL vectors as Nx1 matrices. @@ -494,19 +494,19 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) if (columns == 1) { switch (base_type) { case GLSL_TYPE_UINT: - return glsl_uint_type + (rows - 1); + return uint_type + (rows - 1); case GLSL_TYPE_INT: - return glsl_int_type + (rows - 1); + return int_type + (rows - 1); case GLSL_TYPE_FLOAT: - return glsl_float_type + (rows - 1); + return float_type + (rows - 1); case GLSL_TYPE_BOOL: - return glsl_bool_type + (rows - 1); + return bool_type + (rows - 1); default: - return glsl_error_type; + return error_type; } } else { if ((base_type != GLSL_TYPE_FLOAT) || (rows == 1)) - return glsl_error_type; + return error_type; /* GLSL matrix types are named mat{COLUMNS}x{ROWS}. Only the following * combinations are valid: @@ -529,10 +529,10 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) case IDX(4,2): return mat4x2_type; case IDX(4,3): return mat4x3_type; case IDX(4,4): return mat4_type; - default: return glsl_error_type; + default: return error_type; } } assert(!"Should not get here."); - return glsl_error_type; + return error_type; } diff --git a/glsl_types.h b/glsl_types.h index a795af2cd38..e05130102a5 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -39,12 +39,6 @@ #define GLSL_TYPE_VOID 8 #define GLSL_TYPE_ERROR 9 -extern const struct glsl_type *const glsl_error_type; -extern const struct glsl_type *const glsl_int_type; -extern const struct glsl_type *const glsl_uint_type; -extern const struct glsl_type *const glsl_float_type; -extern const struct glsl_type *const glsl_bool_type; - #define is_numeric_base_type(b) \ (((b) >= GLSL_TYPE_UINT) && ((b) <= GLSL_TYPE_FLOAT)) @@ -107,6 +101,18 @@ struct glsl_type { } fields; + /** + * \name Pointers to various public type singletons + */ + /*@{*/ + static const glsl_type *const error_type; + static const glsl_type *const int_type; + static const glsl_type *const uint_type; + static const glsl_type *const float_type; + static const glsl_type *const bool_type; + /*@}*/ + + glsl_type(unsigned base_type, unsigned vector_elements, unsigned matrix_columns, const char *name) : base_type(base_type), @@ -233,33 +239,33 @@ struct glsl_type { * Query the full type of a matrix row * * \return - * If the type is not a matrix, \c glsl_error_type is returned. Otherwise - * a type matching the rows of the matrix is returned. + * If the type is not a matrix, \c glsl_type::error_type is returned. + * Otherwise a type matching the rows of the matrix is returned. */ const glsl_type *row_type() const { return is_matrix() ? get_instance(base_type, matrix_columns, 1) - : glsl_error_type; + : error_type; } /** * Query the full type of a matrix column * * \return - * If the type is not a matrix, \c glsl_error_type is returned. Otherwise - * a type matching the columns of the matrix is returned. + * If the type is not a matrix, \c glsl_type::error_type is returned. + * Otherwise a type matching the columns of the matrix is returned. */ const glsl_type *column_type() const { return is_matrix() ? get_instance(base_type, vector_elements, 1) - : glsl_error_type; + : error_type; } private: /** - * \name Pointers to various type singletons + * \name Pointers to various private type singletons */ /*@{*/ static const glsl_type *const mat2_type; diff --git a/ir.cpp b/ir.cpp index 58c459ed5db..c4c7584bcfa 100644 --- a/ir.cpp +++ b/ir.cpp @@ -83,7 +83,7 @@ ir_dereference::ir_dereference(ir_instruction *var) { this->mode = ir_reference_variable; this->var = var; - this->type = (var != NULL) ? var->type : glsl_error_type; + this->type = (var != NULL) ? var->type : glsl_type::error_type; } @@ -92,7 +92,7 @@ ir_dereference::ir_dereference(ir_instruction *var, : ir_rvalue(), mode(ir_reference_array), var(var) { - this->type = (var != NULL) ? var->type : glsl_error_type; + this->type = (var != NULL) ? var->type : glsl_type::error_type; this->selector.array_index = array_index; } @@ -237,6 +237,6 @@ ir_call::get_error_instruction() { ir_call *call = new ir_call; - call->type = glsl_error_type; + call->type = glsl_type::error_type; return call; } -- cgit v1.2.3 From 40176e249f72b6090204611873b19aed3da67c71 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 14:38:37 -0700 Subject: Replace is_integer_base_type macro with glsl_type::is_integer method --- ast_to_hir.cpp | 3 +-- glsl_types.h | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 40a980f6826..890dc8e465c 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -255,8 +255,7 @@ modulus_result_type(const struct glsl_type *type_a, * integer vectors. The operand types must both be signed or both be * unsigned." */ - if (! is_integer_base_type(type_a->base_type) - || ! is_integer_base_type(type_b->base_type) + if (!type_a->is_integer() || !type_b->is_integer() || (type_a->base_type != type_b->base_type)) { return glsl_type::error_type; } diff --git a/glsl_types.h b/glsl_types.h index e05130102a5..9af8e9d3f8a 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -42,9 +42,6 @@ #define is_numeric_base_type(b) \ (((b) >= GLSL_TYPE_UINT) && ((b) <= GLSL_TYPE_FLOAT)) -#define is_integer_base_type(b) \ - (((b) == GLSL_TYPE_UINT) || ((b) == GLSL_TYPE_INT)) - #define is_error_type(t) ((t)->base_type == GLSL_TYPE_ERROR) enum glsl_sampler_dim { @@ -203,6 +200,14 @@ struct glsl_type { return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_FLOAT); } + /** + * Query whether or not a type is an integral type + */ + bool is_integer() const + { + return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT); + } + /** * Query whether or not a type is a non-array boolean type */ -- cgit v1.2.3 From a6d653dcbbee3158f9ea7b284bdeb1a8432f0fcb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 14:40:37 -0700 Subject: Replace remaining uses of is_numeric_base_type with glsl_type::is_numeric --- ast_to_hir.cpp | 6 +++--- glsl_types.h | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 890dc8e465c..a41bae68933 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -239,7 +239,7 @@ unary_arithmetic_result_type(const struct glsl_type *type) * component-wise on their operands. These result with the same type * they operated on." */ - if (!is_numeric_base_type(type->base_type)) + if (!type->is_numeric()) return glsl_type::error_type; return type; @@ -289,8 +289,8 @@ relational_result_type(const struct glsl_type *type_a, * than or equal (>=), and less than or equal (<=) operate only on * scalar integer and scalar floating-point expressions." */ - if (! is_numeric_base_type(type_a->base_type) - || ! is_numeric_base_type(type_b->base_type) + if (!type_a->is_numeric() + || !type_b->is_numeric() || !type_a->is_scalar() || !type_b->is_scalar()) return glsl_type::error_type; diff --git a/glsl_types.h b/glsl_types.h index 9af8e9d3f8a..64c6cef669e 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -39,9 +39,6 @@ #define GLSL_TYPE_VOID 8 #define GLSL_TYPE_ERROR 9 -#define is_numeric_base_type(b) \ - (((b) >= GLSL_TYPE_UINT) && ((b) <= GLSL_TYPE_FLOAT)) - #define is_error_type(t) ((t)->base_type == GLSL_TYPE_ERROR) enum glsl_sampler_dim { -- cgit v1.2.3 From cef3baecf636a30b62cd7a1e8de57c7650f7003e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 14:41:32 -0700 Subject: Replace remaining use of is_error_type with glsl_type::is_error --- ast_to_hir.cpp | 2 +- glsl_types.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index a41bae68933..2d7c92625e3 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -717,7 +717,7 @@ ast_expression::hir(exec_list *instructions, } } - if (is_error_type(type) && !error_emitted) + if (type->is_error() && !error_emitted) _mesa_glsl_error(& loc, state, "type mismatch"); return result; diff --git a/glsl_types.h b/glsl_types.h index 64c6cef669e..beaaa78f553 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -39,8 +39,6 @@ #define GLSL_TYPE_VOID 8 #define GLSL_TYPE_ERROR 9 -#define is_error_type(t) ((t)->base_type == GLSL_TYPE_ERROR) - enum glsl_sampler_dim { GLSL_SAMPLER_DIM_1D = 0, GLSL_SAMPLER_DIM_2D, -- cgit v1.2.3 From d811d47609323f99f3718a2c5fb75ce47032f380 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 11:13:43 -0700 Subject: Add glsl_type::components to query total number of components in a type --- glsl_types.h | 10 ++++++++++ ir.cpp | 5 +---- ir_print_visitor.cpp | 8 ++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/glsl_types.h b/glsl_types.h index beaaa78f553..720b05bcda3 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -157,6 +157,16 @@ struct glsl_type { static const glsl_type *get_instance(unsigned base_type, unsigned rows, unsigned columns); + /** + * Query the total number of scalars that make up a scalar, vector or matrix + */ + unsigned components() const + { + return ((vector_elements == 0) ? 1 : vector_elements) + * ((matrix_columns == 0) ? 1 : matrix_columns); + + } + /** * Query whether or not a type is a scalar (non-vector and non-matrix). */ diff --git a/ir.cpp b/ir.cpp index c4c7584bcfa..06eb19691e7 100644 --- a/ir.cpp +++ b/ir.cpp @@ -57,9 +57,6 @@ ir_label::ir_label(const char *label) ir_constant::ir_constant(const struct glsl_type *type, const void *data) : ir_rvalue() { - const unsigned elements = - ((type->vector_elements == 0) ? 1 : type->vector_elements) - * ((type->matrix_columns == 0) ? 1 : type->matrix_columns); unsigned size = 0; this->type = type; @@ -74,7 +71,7 @@ ir_constant::ir_constant(const struct glsl_type *type, const void *data) break; } - memcpy(& this->value, data, size * elements); + memcpy(& this->value, data, size * type->components()); } diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 1696be69b55..682a553249c 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -177,12 +177,8 @@ void ir_print_visitor::visit(ir_constant *ir) print_type(base_type); printf(") "); - const unsigned num_values = 1 - * ((ir->type->vector_elements > 0) ? ir->type->vector_elements : 1) - * ((ir->type->matrix_columns > 0) ? ir->type->matrix_columns : 1); - - printf("(%d) (", num_values); - for (unsigned i = 0; i < num_values; i++) { + printf("(%d) (", ir->type->components()); + for (unsigned i = 0; i < ir->type->components(); i++) { if (i != 0) printf(", "); -- cgit v1.2.3 From 738c183cc918dd613582010e54ad3a5b5336854c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 11:43:36 -0700 Subject: Slightly change the representation of numeric types For numeric types, vector_elements and matrix_columns must be at least 1. Previously matrix_columns was 0 for vectors, and both were 0 for scalars. This change simplifies things in some places. --- builtin_types.sh | 16 ++++++++-------- glsl_types.h | 28 +++++++++++++++++++--------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/builtin_types.sh b/builtin_types.sh index 6658ada41a6..609073c9e4d 100755 --- a/builtin_types.sh +++ b/builtin_types.sh @@ -138,21 +138,21 @@ gen_header "core" index=0; bool_index=$index -gen_integral_type "bool" "GLSL_TYPE_BOOL" 0 0 +gen_integral_type "bool" "GLSL_TYPE_BOOL" 1 1 for i in 2 3 4; do - gen_integral_type "bvec$i" "GLSL_TYPE_BOOL" $i 0 + gen_integral_type "bvec$i" "GLSL_TYPE_BOOL" $i 1 done int_index=$index -gen_integral_type "int" "GLSL_TYPE_INT" 0 0 +gen_integral_type "int" "GLSL_TYPE_INT" 1 1 for i in 2 3 4; do - gen_integral_type "ivec$i" "GLSL_TYPE_INT" $i 0 + gen_integral_type "ivec$i" "GLSL_TYPE_INT" $i 1 done float_index=$index -gen_integral_type "float" "GLSL_TYPE_FLOAT" 0 0 +gen_integral_type "float" "GLSL_TYPE_FLOAT" 1 1 for i in 2 3 4; do - gen_integral_type "vec$i" "GLSL_TYPE_FLOAT" $i 0 + gen_integral_type "vec$i" "GLSL_TYPE_FLOAT" $i 1 done matX_index=$index @@ -295,9 +295,9 @@ echo '/*@{*/' gen_header "130" index=0; uint_index=$index -gen_integral_type "uint" "GLSL_TYPE_UINT" 0 0 +gen_integral_type "uint" "GLSL_TYPE_UINT" 1 1 for i in 2 3 4; do - gen_integral_type "uvec$i" "GLSL_TYPE_UINT" $i 0 + gen_integral_type "uvec$i" "GLSL_TYPE_UINT" $i 1 done echo diff --git a/glsl_types.h b/glsl_types.h index 720b05bcda3..68a32efde66 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -27,6 +27,7 @@ #define GLSL_TYPES_H #include +#include #define GLSL_TYPE_UINT 0 #define GLSL_TYPE_INT 1 @@ -60,8 +61,16 @@ struct glsl_type { * and \c GLSL_TYPE_UINT are valid. */ - unsigned vector_elements:3; /**< 0, 2, 3, or 4 vector elements. */ - unsigned matrix_columns:3; /**< 0, 2, 3, or 4 matrix columns. */ + /** + * \name Vector and matrix element counts + * + * For scalars, each of these values will be 1. For non-numeric types + * these will be 0. + */ + /*@{*/ + unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */ + unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */ + /*@}*/ /** * Name of the data type @@ -114,6 +123,9 @@ struct glsl_type { name(name), length(0) { + /* Neither dimension is zero or both dimensions are zero. + */ + assert((vector_elements == 0) == (matrix_columns == 0)); memset(& fields, 0, sizeof(fields)); } @@ -162,9 +174,7 @@ struct glsl_type { */ unsigned components() const { - return ((vector_elements == 0) ? 1 : vector_elements) - * ((matrix_columns == 0) ? 1 : matrix_columns); - + return vector_elements * matrix_columns; } /** @@ -172,7 +182,7 @@ struct glsl_type { */ bool is_scalar() const { - return (vector_elements == 0) + return (vector_elements == 1) && (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_BOOL); } @@ -182,8 +192,8 @@ struct glsl_type { */ bool is_vector() const { - return (vector_elements > 0) - && (matrix_columns == 0) + return (vector_elements > 1) + && (matrix_columns == 1) && (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_BOOL); } @@ -194,7 +204,7 @@ struct glsl_type { bool is_matrix() const { /* GLSL only has float matrices. */ - return (matrix_columns > 0) && (base_type == GLSL_TYPE_FLOAT); + return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT); } /** -- cgit v1.2.3 From 6c86ea8adc095abeef7b3cd63d3321185542bf36 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 16:11:48 -0700 Subject: Add unary operator to convert unsigned integer to float --- ir.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ir.h b/ir.h index 63ae0bc3b69..04ac0b3e013 100644 --- a/ir.h +++ b/ir.h @@ -229,6 +229,7 @@ enum ir_expression_operation { ir_unop_log, ir_unop_f2i, /**< Float-to-integer conversion. */ ir_unop_i2f, /**< Integer-to-float conversion. */ + ir_unop_u2f, /**< Unsigned-to-float conversion. */ /** * \name Unary floating-point rounding operations. -- cgit v1.2.3 From 8343550b42d3a1de59fa15b86053d576382c11fd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 16:41:43 -0700 Subject: Add some simple constructor tests --- tests/constructor-03.glsl | 12 ++++++++++++ tests/constructor-04.glsl | 14 ++++++++++++++ tests/constructor-05.glsl | 13 +++++++++++++ tests/constructor-06.glsl | 13 +++++++++++++ tests/constructor-07.glsl | 13 +++++++++++++ tests/constructor-08.glsl | 13 +++++++++++++ tests/constructor-09.glsl | 26 ++++++++++++++++++++++++++ 7 files changed, 104 insertions(+) create mode 100644 tests/constructor-03.glsl create mode 100644 tests/constructor-04.glsl create mode 100644 tests/constructor-05.glsl create mode 100644 tests/constructor-06.glsl create mode 100644 tests/constructor-07.glsl create mode 100644 tests/constructor-08.glsl create mode 100644 tests/constructor-09.glsl diff --git a/tests/constructor-03.glsl b/tests/constructor-03.glsl new file mode 100644 index 00000000000..07ec225633a --- /dev/null +++ b/tests/constructor-03.glsl @@ -0,0 +1,12 @@ +/* FAIL - cannot construct a matrix from a matrix in GLSL 1.10 */ + +uniform mat2 a; + +void main() +{ + mat2 b; + + b = mat2(a); + + gl_Position = gl_Vertex; +} diff --git a/tests/constructor-04.glsl b/tests/constructor-04.glsl new file mode 100644 index 00000000000..19d5e011dea --- /dev/null +++ b/tests/constructor-04.glsl @@ -0,0 +1,14 @@ +#version 120 +/* FAIL - matrix must be only parameter to matrix constructor */ + +uniform mat2 a; +uniform float x; + +void main() +{ + mat2 b; + + b = mat2(a, x); + + gl_Position = gl_Vertex; +} diff --git a/tests/constructor-05.glsl b/tests/constructor-05.glsl new file mode 100644 index 00000000000..9c74f75a404 --- /dev/null +++ b/tests/constructor-05.glsl @@ -0,0 +1,13 @@ +/* FAIL - too few components supplied to constructor */ + +uniform vec2 a; +uniform float x; + +void main() +{ + mat2 b; + + b = mat2(a, x); + + gl_Position = gl_Vertex; +} diff --git a/tests/constructor-06.glsl b/tests/constructor-06.glsl new file mode 100644 index 00000000000..d77a5f9e892 --- /dev/null +++ b/tests/constructor-06.glsl @@ -0,0 +1,13 @@ +#version 120 +/* PASS */ + +uniform mat2 a; + +void main() +{ + mat2 b; + + b = mat2(a); + + gl_Position = gl_Vertex; +} diff --git a/tests/constructor-07.glsl b/tests/constructor-07.glsl new file mode 100644 index 00000000000..92322506ed1 --- /dev/null +++ b/tests/constructor-07.glsl @@ -0,0 +1,13 @@ +/* PASS */ + +uniform ivec2 a; +uniform ivec2 b; + +void main() +{ + mat2 c; + + c = mat2(a, b); + + gl_Position = gl_Vertex; +} diff --git a/tests/constructor-08.glsl b/tests/constructor-08.glsl new file mode 100644 index 00000000000..27153f0cda1 --- /dev/null +++ b/tests/constructor-08.glsl @@ -0,0 +1,13 @@ +/* PASS */ + +uniform float a; +uniform float b; + +void main() +{ + ivec2 c; + + c = ivec2(a, b); + + gl_Position = gl_Vertex; +} diff --git a/tests/constructor-09.glsl b/tests/constructor-09.glsl new file mode 100644 index 00000000000..1985699b305 --- /dev/null +++ b/tests/constructor-09.glsl @@ -0,0 +1,26 @@ +/* PASS */ + +uniform int a; +uniform float b; +uniform bool c; + +void main() +{ + float x; + int y; + bool z; + + x = float(a); + x = float(b); + x = float(c); + + y = int(a); + y = int(b); + y = int(c); + + z = bool(a); + z = bool(b); + z = bool(c); + + gl_Position = gl_Vertex; +} -- cgit v1.2.3 From 605ff69b0dbcf3206e4c9af50732083be0c908de Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 17:17:41 -0700 Subject: Add missing parenthesis in foreach_iter This allows uses like 'foreach_iter(exec_list_iterator, iter, *list_ptr)'. --- list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list.h b/list.h index d122369f13b..33b038ce8da 100644 --- a/list.h +++ b/list.h @@ -183,7 +183,7 @@ private: }; #define foreach_iter(iter_type, iter, container) \ - for (iter_type iter = container . iterator(); iter.has_next(); iter.next()) + for (iter_type iter = (container) . iterator(); iter.has_next(); iter.next()) #endif -- cgit v1.2.3 From 9878c6518f7938bd5fdae22265dd30bc72d7343c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 17:19:47 -0700 Subject: Add ir_call::iterator to iterate over actual parameters --- ir.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ir.h b/ir.h index 04ac0b3e013..98455f7c379 100644 --- a/ir.h +++ b/ir.h @@ -319,6 +319,14 @@ public: */ static ir_call *get_error_instruction(); + /** + * Get an iterator for the set of acutal parameters + */ + exec_list_iterator iterator() + { + return actual_parameters.iterator(); + } + private: ir_call() : ir_rvalue(), callee(NULL) -- cgit v1.2.3 From 9f93d24050b2cccf539a944f674784c38cee857a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 17:28:52 -0700 Subject: Be sure to set ir_function_signature::definition for constructors --- glsl_types.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/glsl_types.cpp b/glsl_types.cpp index e08307cb7f3..55d960320db 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -126,7 +126,7 @@ const glsl_type *glsl_type::get_base_type() const * parameters. These are used later to avoid having to use * the symbol table. */ -static void +static ir_label * generate_constructor_intro(const glsl_type *type, unsigned parameter_count, exec_list *parameters, exec_list *instructions, ir_variable **declarations) @@ -163,6 +163,7 @@ generate_constructor_intro(const glsl_type *type, unsigned parameter_count, instructions->push_tail(retval); declarations[16] = retval; + return label; } @@ -399,8 +400,9 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, ir_function_signature *const sig = new ir_function_signature(& types[i]); f->signatures.push_tail(sig); - generate_constructor_intro(& types[i], 1, & sig->parameters, - instructions, declarations); + sig->definition = + generate_constructor_intro(& types[i], 1, & sig->parameters, + instructions, declarations); if (types[i].is_vector()) { generate_vec_body_from_scalar(instructions, declarations); @@ -409,9 +411,10 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, new ir_function_signature(& types[i]); f->signatures.push_tail(vec_sig); - generate_constructor_intro(& types[i], types[i].vector_elements, - & vec_sig->parameters, instructions, - declarations); + vec_sig->definition = + generate_constructor_intro(& types[i], types[i].vector_elements, + & vec_sig->parameters, instructions, + declarations); generate_vec_body_from_N_scalars(instructions, declarations); } else { assert(types[i].is_matrix()); @@ -422,11 +425,12 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, new ir_function_signature(& types[i]); f->signatures.push_tail(mat_sig); - generate_constructor_intro(& types[i], - (types[i].vector_elements - * types[i].matrix_columns), - & mat_sig->parameters, instructions, - declarations); + mat_sig->definition = + generate_constructor_intro(& types[i], + (types[i].vector_elements + * types[i].matrix_columns), + & mat_sig->parameters, instructions, + declarations); generate_mat_body_from_N_scalars(instructions, declarations); } } -- cgit v1.2.3 From 93614bc4b971bb59824179057a4bfa7aac383ce3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 17:29:29 -0700 Subject: Add hack ir_call::callee_name to get the name of the called function --- ir.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ir.h b/ir.h index 98455f7c379..e6cdf29ebd6 100644 --- a/ir.h +++ b/ir.h @@ -327,6 +327,15 @@ public: return actual_parameters.iterator(); } + /** + * Get the name of the function being called. + */ + const char *callee_name() const + { + /* FINISHME: This only works for functions that have definitions. */ + return callee->definition->label; + } + private: ir_call() : ir_rvalue(), callee(NULL) -- cgit v1.2.3 From 5508129fd8beb1113ad2b64bdddb36c954a7b5ad Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 17:30:30 -0700 Subject: IR print visitor: print function calls --- ir_print_visitor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 682a553249c..0e89f10c3f3 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -197,10 +197,12 @@ void ir_print_visitor::visit(ir_constant *ir) void ir_print_visitor::visit(ir_call *ir) { - (void) ir; + printf("(call (%s) ", ir->callee_name()); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_instruction *const inst = (ir_instruction *) iter.get(); - printf("(call FINISHME: function name here\n"); - printf(" (FINISHME: function paramaters here))\n"); + inst->accept(this); + } } -- cgit v1.2.3 From 0b7dcc80eb3163b46d40c5175a27a2ea4264fcd3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 17:38:58 -0700 Subject: Initial implementation of constructor handling code All of the scalar, vector, and matrix constructors *except* "from bool" constructors should be handled. Array and structure constructors are also not yet handled. --- ast_function.cpp | 240 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) diff --git a/ast_function.cpp b/ast_function.cpp index f774a2fd776..6470057a905 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -78,6 +78,89 @@ match_function_by_name(exec_list *instructions, const char *name, } +/** + * Perform automatic type conversion of constructor parameters + */ +static ir_rvalue * +convert_component(ir_rvalue *src, const glsl_type *desired_type) +{ + const unsigned a = desired_type->base_type; + const unsigned b = src->type->base_type; + + if (src->type->is_error()) + return src; + + assert(a <= GLSL_TYPE_BOOL); + assert(b <= GLSL_TYPE_BOOL); + + if ((a == b) || (src->type->is_integer() && desired_type->is_integer())) + return src; + + switch (a) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + if (b == GLSL_TYPE_FLOAT) + return new ir_expression(ir_unop_f2i, desired_type, src, NULL); + else { + assert(b == GLSL_TYPE_BOOL); + assert(!"FINISHME: Convert bool to int / uint."); + } + case GLSL_TYPE_FLOAT: + switch (b) { + case GLSL_TYPE_UINT: + return new ir_expression(ir_unop_u2f, desired_type, src, NULL); + case GLSL_TYPE_INT: + return new ir_expression(ir_unop_i2f, desired_type, src, NULL); + case GLSL_TYPE_BOOL: + assert(!"FINISHME: Convert bool to float."); + } + break; + case GLSL_TYPE_BOOL: { + int z = 0; + ir_constant *const zero = new ir_constant(src->type, &z); + + return new ir_expression(ir_binop_nequal, desired_type, src, zero); + } + } + + assert(!"Should not get here."); + return NULL; +} + + +/** + * Dereference a specific component from a scalar, vector, or matrix + */ +static ir_rvalue * +dereference_component(ir_rvalue *src, unsigned component) +{ + assert(component < src->type->components()); + + if (src->type->is_scalar()) { + return src; + } else if (src->type->is_vector()) { + return new ir_swizzle(src, component, 0, 0, 0, 1); + } else { + assert(src->type->is_matrix()); + + /* Dereference a row of the matrix, then call this function again to get + * a specific element from that row. + */ + const int c = component / src->type->column_type()->vector_elements; + const int r = component % src->type->column_type()->vector_elements; + ir_constant *const col_index = new ir_constant(glsl_type::int_type, &c); + ir_dereference *const col = new ir_dereference(src, col_index); + + col->type = src->type->column_type(); + + return dereference_component(col, r); + } + + assert(!"Should not get here."); + return NULL; +} + + ir_rvalue * ast_function_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -116,6 +199,163 @@ ast_function_expression::hir(exec_list *instructions, * correct order. These constructors follow essentially the same type * matching rules as functions. */ + if (constructor_type->is_numeric() || constructor_type->is_boolean()) { + /* Constructing a numeric type has a couple steps. First all values + * passed to the constructor are broken into individual parameters + * and type converted to the base type of the thing being constructed. + * + * At that point we have some number of values that match the base + * type of the thing being constructed. Now the constructor can be + * treated like a function call. Each numeric type has a small set + * of constructor functions. The set of new parameters will either + * match one of those functions or the original constructor is + * invalid. + */ + const glsl_type *const base_type = constructor_type->get_base_type(); + + /* Total number of components of the type being constructed. + */ + const unsigned type_components = constructor_type->components(); + + /* Number of components from parameters that have actually been + * consumed. This is used to perform several kinds of error checking. + */ + unsigned components_used = 0; + + unsigned matrix_parameters = 0; + unsigned nonmatrix_parameters = 0; + exec_list actual_parameters; + simple_node *const first = subexpressions[1]; + + assert(first != NULL); + + if (first != NULL) { + simple_node *ptr = first; + do { + ir_rvalue *const result = + ((ast_node *) ptr)->hir(instructions, state)->as_rvalue(); + ptr = ptr->next; + + /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: + * + * "It is an error to provide extra arguments beyond this + * last used argument." + */ + if (components_used >= type_components) { + _mesa_glsl_error(& loc, state, "too many parameters to `%s' " + "constructor", + constructor_type->name); + return ir_call::get_error_instruction(); + } + + if (!result->type->is_numeric() && !result->type->is_boolean()) { + _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " + "non-numeric data type", + constructor_type->name); + return ir_call::get_error_instruction(); + } + + /* Count the number of matrix and nonmatrix parameters. This + * is used below to enforce some of the constructor rules. + */ + if (result->type->is_matrix()) + matrix_parameters++; + else + nonmatrix_parameters++; + + + /* Process each of the components of the parameter. Dereference + * each component individually, perform any type conversions, and + * add it to the parameter list for the constructor. + */ + for (unsigned i = 0; i < result->type->components(); i++) { + if (components_used >= type_components) + break; + + ir_rvalue *const component = + convert_component(dereference_component(result, i), + base_type); + + /* All cases that could result in component->type being the + * error type should have already been caught above. + */ + assert(component->type == base_type); + + /* Don't actually generate constructor calls for scalars. + * Instead, do the usual component selection and conversion, + * and return the single component. + */ + if (constructor_type->is_scalar()) + return component; + + actual_parameters.push_tail(component); + components_used++; + } + } while (ptr != first); + } + + /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: + * + * "It is an error to construct matrices from other matrices. This + * is reserved for future use." + */ + if ((state->language_version <= 110) && (matrix_parameters > 0) + && constructor_type->is_matrix()) { + _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " + "matrix in GLSL 1.10", + constructor_type->name); + return ir_call::get_error_instruction(); + } + + /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: + * + * "If a matrix argument is given to a matrix constructor, it is + * an error to have any other arguments." + */ + if ((matrix_parameters > 0) + && ((matrix_parameters + nonmatrix_parameters) > 1) + && constructor_type->is_matrix()) { + _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, " + "matrix must be only parameter", + constructor_type->name); + return ir_call::get_error_instruction(); + } + + /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: + * + * "In these cases, there must be enough components provided in the + * arguments to provide an initializer for every component in the + * constructed value." + */ + if (components_used < type_components) { + _mesa_glsl_error(& loc, state, "too few components to construct " + "`%s'", + constructor_type->name); + return ir_call::get_error_instruction(); + } + + ir_function *f = state->symbols->get_function(constructor_type->name); + if (f == NULL) { + _mesa_glsl_error(& loc, state, "no constructor for type `%s'", + constructor_type->name); + return ir_call::get_error_instruction(); + } + + const ir_function_signature *sig = + f->matching_signature(& actual_parameters); + if (sig != NULL) { + return new ir_call(sig, & actual_parameters); + } else { + /* FINISHME: Log a better error message here. G++ will show the + * FINSIHME: types of the actual parameters and the set of + * FINSIHME: candidate functions. A different error should also be + * FINSIHME: logged when multiple functions match. + */ + _mesa_glsl_error(& loc, state, "no matching constructor for `%s'", + constructor_type->name); + return ir_call::get_error_instruction(); + } + } return ir_call::get_error_instruction(); } else { -- cgit v1.2.3 From d1dfe8b994218e4b593b71fc756055a48d469527 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 17:42:10 -0700 Subject: IR print visitor: Print expressions a little better --- ir_print_visitor.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 0e89f10c3f3..6d0f797807c 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -88,9 +88,20 @@ void ir_print_visitor::visit(ir_expression *ir) { printf("(expression "); - printf("(FINISHME: operator) "); + const char *str; + char buf[256]; + + switch (ir->operation) { + case ir_unop_f2i: str = "f2i"; break; + case ir_unop_i2f: str = "i2f"; break; + case ir_unop_u2f: str = "u2f"; break; + default: + snprintf(buf, sizeof(buf), "operator %u", ir->operation); + str = buf; + break; + } - printf("("); + printf("(%s) (", str); if (ir->operands[0]) ir->operands[0]->accept(this); printf(") "); -- cgit v1.2.3 From e65e12fdbc2f51ecc3ca9265993c0c7a03e05a84 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Mar 2010 11:00:07 -0700 Subject: IR print visitor: Print out something for the operator. --- ir.h | 2 +- ir_print_visitor.cpp | 57 ++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/ir.h b/ir.h index e6cdf29ebd6..c52efe61781 100644 --- a/ir.h +++ b/ir.h @@ -217,7 +217,7 @@ public: ir_rvalue *condition; }; - +/* Update ir_print_visitor.cpp when updating this list. */ enum ir_expression_operation { ir_unop_bit_not, ir_unop_logic_not, diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 6d0f797807c..f055e8f1d8f 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -86,22 +86,53 @@ void ir_print_visitor::visit(ir_function *ir) void ir_print_visitor::visit(ir_expression *ir) { - printf("(expression "); + static const char *const operators[] = { + "~", + "!", + "-", + "abs", + "rcp", + "rsq", + "exp", + "log", + "f2i", + "i2f", + "u2f", + "trunc", + "ceil", + "floor", + "+", + "-", + "*", + "/", + "%", + "<", + ">", + "<=", + ">=", + "==", + "!=", + "<<", + ">>", + "&", + "^", + "|", + "&&", + "^^", + "||", + "!", + "dot", + "min", + "max", + }; - const char *str; - char buf[256]; + printf("(expression "); - switch (ir->operation) { - case ir_unop_f2i: str = "f2i"; break; - case ir_unop_i2f: str = "i2f"; break; - case ir_unop_u2f: str = "u2f"; break; - default: - snprintf(buf, sizeof(buf), "operator %u", ir->operation); - str = buf; - break; - } + assert((unsigned int)ir->operation < + sizeof(operators) / sizeof(operators[0])); - printf("(%s) (", str); + printf("%s", operators[ir->operation]); + printf("("); if (ir->operands[0]) ir->operands[0]->accept(this); printf(") "); -- cgit v1.2.3 From 10a685218610e737e23d2d8a243ed6ff6613becd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Mar 2010 11:53:37 -0700 Subject: Factor out assignment setup in ast_to_hir. --- ast_to_hir.cpp | 86 ++++++++++++++++++++++++---------------------------------- 1 file changed, 35 insertions(+), 51 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 2d7c92625e3..a75177dcc88 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -359,6 +359,33 @@ validate_assignment(const glsl_type *lhs_type, ir_rvalue *rhs) return NULL; } +ir_rvalue * +do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, + ir_rvalue *lhs, ir_rvalue *rhs, + YYLTYPE lhs_loc) +{ + bool error_emitted = (lhs->type->is_error() || rhs->type->is_error()); + + if (!error_emitted) { + /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ + if (!lhs->is_lvalue()) { + _mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment"); + error_emitted = true; + } + } + + ir_rvalue *new_rhs = validate_assignment(lhs->type, rhs); + if (new_rhs == NULL) { + _mesa_glsl_error(& lhs_loc, state, "type mismatch"); + } else { + rhs = new_rhs; + } + + ir_instruction *tmp = new ir_assignment(lhs, rhs, NULL); + instructions->push_tail(tmp); + + return rhs; +} ir_rvalue * ast_node::hir(exec_list *instructions, @@ -445,30 +472,10 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - - type = op[0]->type; - if (!error_emitted) { - YYLTYPE loc; - - /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ - if (!op[0]->is_lvalue()) { - _mesa_glsl_error(& loc, state, "non-lvalue in assignment"); - error_emitted = true; - type = glsl_type::error_type; - } - } - - ir_instruction *rhs = validate_assignment(op[0]->type, op[1]); - if (rhs == NULL) { - type = glsl_type::error_type; - rhs = op[1]; - } - - ir_instruction *tmp = new ir_assignment(op[0], op[1], NULL); - instructions->push_tail(tmp); - - result = op[0]; + result = do_assignment(instructions, state, op[0], op[1], + this->subexpressions[0]->get_location()); + error_emitted = result->type->is_error(); + type = result->type; break; } @@ -575,8 +582,6 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - type = arithmetic_result_type(op[0]->type, op[1]->type, (this->oper == ast_mul_assign), state); @@ -584,37 +589,16 @@ ast_expression::hir(exec_list *instructions, ir_rvalue *temp_rhs = new ir_expression(operations[this->oper], type, op[0], op[1]); - /* FINISHME: This is copied from ast_assign above. It should - * FINISHME: probably be consolidated. - */ - error_emitted = op[0]->type->is_error() || temp_rhs->type->is_error(); - - type = op[0]->type; - if (!error_emitted) { - YYLTYPE loc; - - if (!op[0]->is_lvalue()) { - _mesa_glsl_error(& loc, state, "non-lvalue in assignment"); - error_emitted = true; - type = glsl_type::error_type; - } - } - - ir_rvalue *rhs = validate_assignment(op[0]->type, temp_rhs); - if (rhs == NULL) { - type = glsl_type::error_type; - rhs = temp_rhs; - } - - ir_instruction *tmp = new ir_assignment(op[0], rhs, NULL); - instructions->push_tail(tmp); + result = do_assignment(instructions, state, op[0], temp_rhs, + this->subexpressions[0]->get_location()); + type = result->type; + error_emitted = (op[0]->type->is_error()); /* GLSL 1.10 does not allow array assignment. However, we don't have to * explicitly test for this because none of the binary expression * operators allow array operands either. */ - result = op[0]; break; } -- cgit v1.2.3 From 48a0e64b7d6a4308f9c691e5844165ec97f8282e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Mar 2010 11:57:46 -0700 Subject: Add support for %= in ast_to_hir. --- ast_to_hir.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index a75177dcc88..6fe7da646b6 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -602,7 +602,26 @@ ast_expression::hir(exec_list *instructions, break; } - case ast_mod_assign: + case ast_mod_assign: { + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + + type = modulus_result_type(op[0]->type, op[1]->type); + + assert(operations[this->oper] == ir_binop_mod); + + struct ir_rvalue *temp_rhs; + temp_rhs = new ir_expression(operations[this->oper], type, + op[0], op[1]); + + result = do_assignment(instructions, state, op[0], temp_rhs, + this->subexpressions[0]->get_location()); + type = result->type; + error_emitted = op[0]->type->is_error(); + break; + } case ast_ls_assign: case ast_rs_assign: -- cgit v1.2.3 From 3c36b2df7c854d23b2be9580e416fb04079a1bef Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Mar 2010 12:07:44 -0700 Subject: Add constructors for immediate hir constants. This will make ast_to_hir for inc/dec easier. --- ir.cpp | 28 ++++++++++++++++++++++++++++ ir.h | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/ir.cpp b/ir.cpp index 06eb19691e7..4c1f307e8af 100644 --- a/ir.cpp +++ b/ir.cpp @@ -74,6 +74,34 @@ ir_constant::ir_constant(const struct glsl_type *type, const void *data) memcpy(& this->value, data, size * type->components()); } +ir_constant::ir_constant(float f) + : ir_rvalue() +{ + this->type = glsl_type::float_type; + this->value.f[0] = f; +} + +ir_constant::ir_constant(unsigned int u) + : ir_rvalue() +{ + this->type = glsl_type::uint_type; + this->value.u[0] = u; +} + +ir_constant::ir_constant(int i) + : ir_rvalue() +{ + this->type = glsl_type::int_type; + this->value.i[0] = i; +} + +ir_constant::ir_constant(bool b) + : ir_rvalue() +{ + this->type = glsl_type::bool_type; + this->value.b[0] = b; +} + ir_dereference::ir_dereference(ir_instruction *var) : ir_rvalue() diff --git a/ir.h b/ir.h index c52efe61781..a69f932c5a8 100644 --- a/ir.h +++ b/ir.h @@ -481,6 +481,10 @@ public: class ir_constant : public ir_rvalue { public: ir_constant(const struct glsl_type *type, const void *data); + ir_constant(bool b); + ir_constant(unsigned int u); + ir_constant(int i); + ir_constant(float f); virtual void accept(ir_visitor *v) { -- cgit v1.2.3 From c4f86d3b80047ce3a8be1fa69396856af1719bc9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Mar 2010 15:51:45 -0700 Subject: Make read-only variables not be considered lvalues. This should fix tests trying to assign to builtin "in" variables, and will also be relied on for post_inc/dec handling. --- ir.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ir.h b/ir.h index a69f932c5a8..7e2f304b41d 100644 --- a/ir.h +++ b/ir.h @@ -455,7 +455,17 @@ public: bool is_lvalue() { - return var != NULL; + ir_variable *as_var; + + if (var == NULL) + return NULL; + + as_var = var->as_variable(); + + if (as_var == NULL) + return NULL; + + return !as_var->read_only; } enum { -- cgit v1.2.3 From de38f0ed53c80f87478c3899d4ff1bc3a601ea6b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Mar 2010 12:14:54 -0700 Subject: Add support for ast_to_hir of post inc/dec. --- ast_to_hir.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 6fe7da646b6..f8ca3710340 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -387,6 +387,29 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, return rhs; } +static ir_rvalue * +get_lvalue_copy(exec_list *instructions, struct _mesa_glsl_parse_state *state, + ir_rvalue *lvalue, YYLTYPE loc) +{ + ir_variable *var; + ir_rvalue *var_deref; + + /* FINISHME: Give unique names to the temporaries. */ + var = new ir_variable(lvalue->type, "_internal_tmp"); + var->mode = ir_var_auto; + + var_deref = new ir_dereference(var); + do_assignment(instructions, state, var_deref, lvalue, loc); + + /* Once we've created this temporary, mark it read only so it's no + * longer considered an lvalue. + */ + var->read_only = true; + + return var_deref; +} + + ir_rvalue * ast_node::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -443,10 +466,10 @@ ast_expression::hir(exec_list *instructions, ir_binop_bit_or, /* ast_or_assign */ -1, /* ast_conditional doesn't convert to ir_expression. */ - -1, /* ast_pre_inc doesn't convert to ir_expression. */ - -1, /* ast_pre_dec doesn't convert to ir_expression. */ - -1, /* ast_post_inc doesn't convert to ir_expression. */ - -1, /* ast_post_dec doesn't convert to ir_expression. */ + ir_binop_add, /* ast_pre_inc. */ + ir_binop_sub, /* ast_pre_dec. */ + ir_binop_add, /* ast_post_inc. */ + ir_binop_sub, /* ast_post_dec. */ -1, /* ast_field_selection doesn't conv to ir_expression. */ -1, /* ast_array_index doesn't convert to ir_expression. */ -1, /* ast_function_call doesn't conv to ir_expression. */ @@ -636,8 +659,35 @@ ast_expression::hir(exec_list *instructions, case ast_pre_dec: case ast_post_inc: - case ast_post_dec: + case ast_post_dec: { + op[0] = this->subexpressions[0]->hir(instructions, state); + if (op[0]->type->base_type == GLSL_TYPE_FLOAT) + op[1] = new ir_constant(1.0f); + else + op[1] = new ir_constant(1); + + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + + type = arithmetic_result_type(op[0]->type, op[1]->type, + false, state); + + struct ir_rvalue *temp_rhs; + temp_rhs = new ir_expression(operations[this->oper], type, + op[0], op[1]); + + /* Get a temporary of a copy of the lvalue before it's modified. + * This may get thrown away later. + */ + result = get_lvalue_copy(instructions, state, op[0], + this->subexpressions[0]->get_location()); + + (void)do_assignment(instructions, state, op[0], temp_rhs, + this->subexpressions[0]->get_location()); + + type = result->type; + error_emitted = op[0]->type->is_error(); break; + } case ast_field_selection: result = _mesa_ast_field_selection_to_hir(this, instructions, state); -- cgit v1.2.3 From 76ea56c007263ec3b79234e7b775e3a7b519a54a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Mar 2010 12:16:54 -0700 Subject: Add support for ast_to_hir of pre inc/dec. --- ast_to_hir.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index f8ca3710340..67fed4cc893 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -656,7 +656,26 @@ ast_expression::hir(exec_list *instructions, case ast_conditional: case ast_pre_inc: - case ast_pre_dec: + case ast_pre_dec: { + op[0] = this->subexpressions[0]->hir(instructions, state); + if (op[0]->type->base_type == GLSL_TYPE_FLOAT) + op[1] = new ir_constant(1.0f); + else + op[1] = new ir_constant(1); + + type = arithmetic_result_type(op[0]->type, op[1]->type, + false, state); + + struct ir_rvalue *temp_rhs; + temp_rhs = new ir_expression(operations[this->oper], type, + op[0], op[1]); + + result = do_assignment(instructions, state, op[0], temp_rhs, + this->subexpressions[0]->get_location()); + type = result->type; + error_emitted = op[0]->type->is_error(); + break; + } case ast_post_inc: case ast_post_dec: { -- cgit v1.2.3 From 8518e75d289638b10cb9350f287ccbdf1c927040 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Mar 2010 16:37:22 -0700 Subject: Set the var_type for arrays to error_type until it's implemented. "Fixes" segfaults in array tests. --- ast_to_hir.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 67fed4cc893..d7bfb307a7f 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -947,6 +947,7 @@ ast_declarator_list::hir(exec_list *instructions, /* FINISHME: Handle array declarations. Note that this requires * FINISHME: complete handling of constant expressions. */ + var_type = glsl_type::error_type; /* FINISHME: Reject delcarations of multidimensional arrays. */ } else { -- cgit v1.2.3 From 72fc47f0b0605748c9643e61c2a879b8476aa533 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Mar 2010 16:37:53 -0700 Subject: Set variables with the sampler base type to read only. Fixes increment3.frag. --- ir.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ir.cpp b/ir.cpp index 4c1f307e8af..90df67bbf1d 100644 --- a/ir.cpp +++ b/ir.cpp @@ -240,6 +240,9 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) { this->type = type; this->name = name; + + if (type && type->base_type == GLSL_TYPE_SAMPLER) + this->read_only = true; } -- cgit v1.2.3 From 19360152f5bd8cff93359dbfe5a50a90b699c118 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 26 Mar 2010 18:05:27 -0700 Subject: Reject uniform initializers in GLSL 1.10 mode Now both glslparsertest/dataType3.frag and glslparsertest/dataType2.frag pass. --- ast_to_hir.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index d7bfb307a7f..c5d60b87b82 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -980,6 +980,21 @@ ast_declarator_list::hir(exec_list *instructions, instructions->push_tail(var); + /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec: + * + * "All uniform variables are read-only and are initialized either + * directly by an application via API commands, or indirectly by + * OpenGL." + */ + if ((state->language_version <= 110) + && (var->mode == ir_var_uniform) + && (decl->initializer != NULL)) { + YYLTYPE loc = decl->initializer->get_location(); + + _mesa_glsl_error(& loc, state, "uniform initializers forbidden in " + "GLSL 1.10"); + } + /* FINISHME: Process the declaration initializer. */ } -- cgit v1.2.3 From 66faec4895b7bb59a614087a200c05157191b4ae Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sat, 27 Mar 2010 18:56:53 -0700 Subject: Initial bits to process initializers in variable declarations As a result, the following tests pass: glslparsertest/array3.frag glslparsertest/CGStandardLibrary.frag glslparsertest/ConstantConversions.frag glslparsertest/constructor1.frag glslparsertest/constructor2.frag glslparsertest/constructor3.V110.frag glslparsertest/dataType4.frag glslparsertest/dataType5.frag glslparsertest/dataType13.frag glslparsertest/dataType19.frag glslparsertest/matrix.V110.frag glslparsertest/parser7.frag glslparsertest/swizzle3.frag The following tests also pass, but it is just by dumb luck. In these cases the shader fails to compile, but it fails for the wrong reason: glslparsertest/array6.frag glslparsertest/comma2.frag glslparsertest/conditional1.frag glslparsertest/conditional2.frag glslparsertest/conditional3.frag glslparsertest/constFunc.frag glslparsertest/ParseTest3.frag glslparsertest/ParseTest4.frag glslparsertest/varying3.frag glslparsertest/parser8.frag (also segfaults) glslparsertest/parser9.frag (also segfaults) The following tests now fail. As far as I can tell, these are all cases where the shader was failing to compile, but it was failing for the wrong reason. glslparsertest/CorrectMatComma.frag glslparsertest/CorrectModule.frag glslparsertest/CorrectSwizzle2.vert glslparsertest/shaders/glsl-fs-bug25902.frag --- ast_to_hir.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index c5d60b87b82..ce64794ae2c 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -980,22 +980,33 @@ ast_declarator_list::hir(exec_list *instructions, instructions->push_tail(var); - /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec: - * - * "All uniform variables are read-only and are initialized either - * directly by an application via API commands, or indirectly by - * OpenGL." - */ - if ((state->language_version <= 110) - && (var->mode == ir_var_uniform) - && (decl->initializer != NULL)) { - YYLTYPE loc = decl->initializer->get_location(); + if (decl->initializer != NULL) { + /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec: + * + * "All uniform variables are read-only and are initialized either + * directly by an application via API commands, or indirectly by + * OpenGL." + */ + if ((state->language_version <= 110) + && (var->mode == ir_var_uniform)) { + YYLTYPE loc = decl->initializer->get_location(); - _mesa_glsl_error(& loc, state, "uniform initializers forbidden in " - "GLSL 1.10"); - } + _mesa_glsl_error(& loc, state, "uniform initializers forbidden in " + "GLSL 1.10"); + } + + ir_dereference *const lhs = new ir_dereference(var); + ir_rvalue *const rhs = decl->initializer->hir(instructions, state); - /* FINISHME: Process the declaration initializer. */ + /* FINISHME: If the declaration is either 'const' or 'uniform', the + * FINISHME: initializer (rhs) must be a constant expression. + */ + + if (!rhs->type->is_error()) { + (void) do_assignment(instructions, state, lhs, rhs, + this->get_location()); + } + } } /* Variable declarations do not have r-values. -- cgit v1.2.3 From 43de17282017bdf187d6e646de3262cc64b7f46b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sun, 28 Mar 2010 17:03:16 -0700 Subject: Generate more correctly diagnostics from some invalid initializers --- ast_to_hir.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index ce64794ae2c..d6aa3bce579 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -981,6 +981,8 @@ ast_declarator_list::hir(exec_list *instructions, instructions->push_tail(var); if (decl->initializer != NULL) { + YYLTYPE initializer_loc = decl->initializer->get_location(); + /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec: * * "All uniform variables are read-only and are initialized either @@ -989,10 +991,22 @@ ast_declarator_list::hir(exec_list *instructions, */ if ((state->language_version <= 110) && (var->mode == ir_var_uniform)) { - YYLTYPE loc = decl->initializer->get_location(); + _mesa_glsl_error(& initializer_loc, state, + "cannot initialize uniforms in GLSL 1.10"); + } + + if (var->type->is_sampler()) { + _mesa_glsl_error(& initializer_loc, state, + "cannot initialize samplers"); + } - _mesa_glsl_error(& loc, state, "uniform initializers forbidden in " - "GLSL 1.10"); + if ((var->mode == ir_var_in) && (state->current_function == NULL)) { + _mesa_glsl_error(& initializer_loc, state, + "cannot initialize %s shader input / %s", + (state->target == vertex_shader) + ? "vertex" : "fragment", + (state->target == vertex_shader) + ? "attribute" : "varying"); } ir_dereference *const lhs = new ir_dereference(var); -- cgit v1.2.3 From c22c40015db32b68b33c4944b9d94bf499135ec5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Mar 2010 18:20:30 -0700 Subject: Implement the first builtin function: exp(). --- Makefile.am | 2 +- ast_to_hir.cpp | 1 + builtin_function.cpp | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++ ir.h | 4 ++ 4 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 builtin_function.cpp diff --git a/Makefile.am b/Makefile.am index 48b4b3921c0..9f5efa9e5d4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,7 @@ bin_PROGRAMS = glsl glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \ - ir.cpp hir_field_selection.cpp \ + ir.cpp hir_field_selection.cpp builtin_function.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h glsl_parser.cpp glsl_lexer.cpp diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index d6aa3bce579..ec1562f8cb2 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -63,6 +63,7 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) _mesa_glsl_initialize_variables(instructions, state); _mesa_glsl_initialize_constructors(instructions, state); + _mesa_glsl_initialize_functions(instructions, state); state->current_function = NULL; diff --git a/builtin_function.cpp b/builtin_function.cpp new file mode 100644 index 00000000000..fb168acdc3e --- /dev/null +++ b/builtin_function.cpp @@ -0,0 +1,169 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "glsl_symbol_table.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" +#include "ir.h" + +static void +generate_exp(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const retval = new ir_dereference(declarations[16]); + ir_dereference *const arg = new ir_dereference(declarations[0]); + ir_rvalue *result; + + result = new ir_expression(ir_unop_exp, type, arg, NULL); + + ir_instruction *inst = new ir_assignment(retval, result, NULL); + instructions->push_tail(inst); +} + +void +generate_function_instance(ir_function *f, + const char *name, + exec_list *instructions, + void (*generate)(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type), + const glsl_type *type) +{ + ir_variable *declarations[17]; + + ir_function_signature *const sig = new ir_function_signature(type); + f->signatures.push_tail(sig); + + ir_label *const label = new ir_label(name); + instructions->push_tail(label); + sig->definition = label; + + ir_variable *var = new ir_variable(type, "arg"); + + var->mode = ir_var_in; + sig->parameters.push_tail(var); + + var = new ir_variable(type, "arg"); + + declarations[0] = var; + + ir_variable *retval = new ir_variable(type, "__retval"); + instructions->push_tail(retval); + + declarations[16] = retval; + + generate(instructions, declarations, type); +} + +void +make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, + const char *name, + void (*generate)(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type)) +{ + ir_function *const f = new ir_function(name); + const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); + const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); + const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); + + bool added = symtab->add_function(name, f); + assert(added); + + generate_function_instance(f, name, instructions, generate, glsl_type::float_type); + generate_function_instance(f, name, instructions, generate, vec2_type); + generate_function_instance(f, name, instructions, generate, vec3_type); + generate_function_instance(f, name, instructions, generate, vec4_type); +} + +void +generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) +{ + /* FINISHME: radians() */ + /* FINISHME: degrees() */ + /* FINISHME: sin() */ + /* FINISHME: cos() */ + /* FINISHME: tan() */ + /* FINISHME: asin() */ + /* FINISHME: acos() */ + /* FINISHME: atan(y,x) */ + /* FINISHME: atan(y/x) */ + /* FINISHME: pow() */ + make_gentype_function(symtab, instructions, "exp", generate_exp); + /* FINISHME: log() */ + /* FINISHME: exp2() */ + /* FINISHME: log2() */ + /* FINISHME: sqrt() */ + /* FINISHME: inversesqrt() */ + /* FINISHME: abs() */ + /* FINISHME: sign() */ + /* FINISHME: floor() */ + /* FINISHME: ceil() */ + /* FINISHME: fract() */ + /* FINISHME: mod(x, float y) */ + /* FINISHME: mod(x, y) */ + /* FINISHME: min() */ + /* FINISHME: max() */ + /* FINISHME: clamp() */ + /* FINISHME: clamp() */ + /* FINISHME: mix() */ + /* FINISHME: mix() */ + /* FINISHME: step() */ + /* FINISHME: step() */ + /* FINISHME: smoothstep() */ + /* FINISHME: smoothstep() */ + /* FINISHME: floor() */ + /* FINISHME: step() */ + /* FINISHME: length() */ + /* FINISHME: distance() */ + /* FINISHME: dot() */ + /* FINISHME: cross() */ + /* FINISHME: normalize() */ + /* FINISHME: ftransform() */ + /* FINISHME: faceforward() */ + /* FINISHME: reflect() */ + /* FINISHME: refract() */ + /* FINISHME: matrixCompMult() */ + /* FINISHME: lessThan() */ + /* FINISHME: lessThanEqual() */ + /* FINISHME: greaterThan() */ + /* FINISHME: greaterThanEqual() */ + /* FINISHME: equal() */ + /* FINISHME: notEqual() */ + /* FINISHME: any() */ + /* FINISHME: all() */ + /* FINISHME: not() */ + /* FINISHME: texture*() */ + /* FINISHME: shadow*() */ + /* FINISHME: dFd[xy]() */ + /* FINISHME: fwidth() */ +} + +void +_mesa_glsl_initialize_functions(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + generate_110_functions(state->symbols, instructions); +} diff --git a/ir.h b/ir.h index 7e2f304b41d..bad5111b5a8 100644 --- a/ir.h +++ b/ir.h @@ -521,4 +521,8 @@ extern void _mesa_glsl_initialize_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state); +extern void +_mesa_glsl_initialize_functions(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + #endif /* IR_H */ -- cgit v1.2.3 From 2eec73f7354ba4d11907f14381463fc0fa035174 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 27 Mar 2010 12:25:20 -0700 Subject: Implement additional unary gentype builtins. --- builtin_function.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index fb168acdc3e..fd34fcefb08 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -28,20 +28,69 @@ #include "ir.h" static void -generate_exp(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) +generate_unop(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type, + enum ir_expression_operation op) { ir_dereference *const retval = new ir_dereference(declarations[16]); ir_dereference *const arg = new ir_dereference(declarations[0]); ir_rvalue *result; - result = new ir_expression(ir_unop_exp, type, arg, NULL); + result = new ir_expression(op, type, arg, NULL); ir_instruction *inst = new ir_assignment(retval, result, NULL); instructions->push_tail(inst); } +static void +generate_exp(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_exp); +} + +static void +generate_log(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_log); +} + +static void +generate_rsq(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_rsq); +} + +static void +generate_abs(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_abs); +} + +static void +generate_ceil(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_ceil); +} + +static void +generate_floor(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_floor); +} + void generate_function_instance(ir_function *f, const char *name, @@ -112,15 +161,15 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: atan(y/x) */ /* FINISHME: pow() */ make_gentype_function(symtab, instructions, "exp", generate_exp); - /* FINISHME: log() */ + make_gentype_function(symtab, instructions, "log", generate_log); /* FINISHME: exp2() */ /* FINISHME: log2() */ /* FINISHME: sqrt() */ - /* FINISHME: inversesqrt() */ - /* FINISHME: abs() */ + make_gentype_function(symtab, instructions, "inversesqrt", generate_rsq); + make_gentype_function(symtab, instructions, "abs", generate_abs); /* FINISHME: sign() */ - /* FINISHME: floor() */ - /* FINISHME: ceil() */ + make_gentype_function(symtab, instructions, "floor", generate_floor); + make_gentype_function(symtab, instructions, "ceil", generate_ceil); /* FINISHME: fract() */ /* FINISHME: mod(x, float y) */ /* FINISHME: mod(x, y) */ -- cgit v1.2.3 From bfe380a72107a19563811d25480bfb400646edf0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 27 Mar 2010 12:43:13 -0700 Subject: Implement some binary gentype builtin functions. --- builtin_function.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 18 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index fd34fcefb08..e59b314a91d 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -43,6 +43,23 @@ generate_unop(exec_list *instructions, instructions->push_tail(inst); } +static void +generate_binop(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type, + enum ir_expression_operation op) +{ + ir_dereference *const retval = new ir_dereference(declarations[16]); + ir_dereference *const arg1 = new ir_dereference(declarations[0]); + ir_dereference *const arg2 = new ir_dereference(declarations[1]); + ir_rvalue *result; + + result = new ir_expression(op, type, arg1, arg2); + + ir_instruction *inst = new ir_assignment(retval, result, NULL); + instructions->push_tail(inst); +} + static void generate_exp(exec_list *instructions, ir_variable **declarations, @@ -91,10 +108,35 @@ generate_floor(exec_list *instructions, generate_unop(instructions, declarations, type, ir_unop_floor); } +static void +generate_mod(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_binop(instructions, declarations, type, ir_binop_mod); +} + +static void +generate_min(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_binop(instructions, declarations, type, ir_binop_min); +} + +static void +generate_max(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_binop(instructions, declarations, type, ir_binop_max); +} + void generate_function_instance(ir_function *f, const char *name, exec_list *instructions, + int n_args, void (*generate)(exec_list *instructions, ir_variable **declarations, const glsl_type *type), @@ -108,15 +150,22 @@ generate_function_instance(ir_function *f, ir_label *const label = new ir_label(name); instructions->push_tail(label); sig->definition = label; + static const char *arg_names[] = { + "arg0", + "arg1" + }; + int i; - ir_variable *var = new ir_variable(type, "arg"); + for (i = 0; i < n_args; i++) { + ir_variable *var = new ir_variable(type, arg_names[i]); - var->mode = ir_var_in; - sig->parameters.push_tail(var); + var->mode = ir_var_in; + sig->parameters.push_tail(var); - var = new ir_variable(type, "arg"); + var = new ir_variable(type, arg_names[i]); - declarations[0] = var; + declarations[i] = var; + } ir_variable *retval = new ir_variable(type, "__retval"); instructions->push_tail(retval); @@ -129,6 +178,7 @@ generate_function_instance(ir_function *f, void make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, const char *name, + int n_args, void (*generate)(exec_list *instructions, ir_variable **declarations, const glsl_type *type)) @@ -141,10 +191,14 @@ make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, bool added = symtab->add_function(name, f); assert(added); - generate_function_instance(f, name, instructions, generate, glsl_type::float_type); - generate_function_instance(f, name, instructions, generate, vec2_type); - generate_function_instance(f, name, instructions, generate, vec3_type); - generate_function_instance(f, name, instructions, generate, vec4_type); + generate_function_instance(f, name, instructions, n_args, generate, + glsl_type::float_type); + generate_function_instance(f, name, instructions, n_args, generate, + vec2_type); + generate_function_instance(f, name, instructions, n_args, generate, + vec3_type); + generate_function_instance(f, name, instructions, n_args, generate, + vec4_type); } void @@ -160,21 +214,23 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: atan(y,x) */ /* FINISHME: atan(y/x) */ /* FINISHME: pow() */ - make_gentype_function(symtab, instructions, "exp", generate_exp); - make_gentype_function(symtab, instructions, "log", generate_log); + make_gentype_function(symtab, instructions, "exp", 1, generate_exp); + make_gentype_function(symtab, instructions, "log", 1, generate_log); /* FINISHME: exp2() */ /* FINISHME: log2() */ /* FINISHME: sqrt() */ - make_gentype_function(symtab, instructions, "inversesqrt", generate_rsq); - make_gentype_function(symtab, instructions, "abs", generate_abs); + make_gentype_function(symtab, instructions, "inversesqrt", 1, generate_rsq); + make_gentype_function(symtab, instructions, "abs", 1, generate_abs); /* FINISHME: sign() */ - make_gentype_function(symtab, instructions, "floor", generate_floor); - make_gentype_function(symtab, instructions, "ceil", generate_ceil); + make_gentype_function(symtab, instructions, "floor", 1, generate_floor); + make_gentype_function(symtab, instructions, "ceil", 1, generate_ceil); /* FINISHME: fract() */ /* FINISHME: mod(x, float y) */ - /* FINISHME: mod(x, y) */ - /* FINISHME: min() */ - /* FINISHME: max() */ + make_gentype_function(symtab, instructions, "mod", 2, generate_mod); + make_gentype_function(symtab, instructions, "min", 2, generate_min); + /* FINISHME: min(x, float y) */ + make_gentype_function(symtab, instructions, "max", 2, generate_max); + /* FINISHME: max(x, float y) */ /* FINISHME: clamp() */ /* FINISHME: clamp() */ /* FINISHME: mix() */ -- cgit v1.2.3 From 0f09aea3bfe90378f6fdfa7b6798cf597a20cd37 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 27 Mar 2010 12:48:57 -0700 Subject: Add support for builtin deprecated fs varyings. Fixes glsl-color.frag. --- builtin_variables.h | 6 ++++++ ir_variable.cpp | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/builtin_variables.h b/builtin_variables.h index 5b18446a0da..a742a1562d2 100644 --- a/builtin_variables.h +++ b/builtin_variables.h @@ -39,6 +39,12 @@ static const builtin_variable builtin_core_fs_variables[] = { { ir_var_out, "float", "gl_FragDepth" }, }; +static const builtin_variable builtin_110_deprecated_fs_variables[] = { + { ir_var_in, "vec4", "gl_Color" }, + { ir_var_in, "vec4", "gl_SecondaryColor" }, + { ir_var_in, "vec4", "gl_FogFragCoord" }, +}; + static const builtin_variable builtin_110_deprecated_vs_variables[] = { { ir_var_in, "vec4", "gl_Vertex" }, { ir_var_in, "vec4", "gl_Normal" }, diff --git a/ir_variable.cpp b/ir_variable.cpp index 9344170613d..df8e4c3ba82 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -136,6 +136,14 @@ generate_110_fs_variables(exec_list *instructions, instructions, symtab); } + /* FINISHME: Add support for gl_TexCoord[] */ + for (unsigned i = 0 + ; i < Elements(builtin_110_deprecated_fs_variables) + ; i++) { + add_builtin_variable(& builtin_110_deprecated_fs_variables[i], + instructions, symtab); + } + /* FINISHME: Add support for gl_FragData[GL_MAX_DRAW_BUFFERS]. */ } -- cgit v1.2.3 From ddd2e83db2b6baa062f76f22bb980030144dbcad Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 27 Mar 2010 12:59:42 -0700 Subject: Add builtin pow() function. --- builtin_function.cpp | 11 ++++++++++- ir_print_visitor.cpp | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index e59b314a91d..ec1b54a2dd5 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -132,6 +132,15 @@ generate_max(exec_list *instructions, generate_binop(instructions, declarations, type, ir_binop_max); } + +static void +generate_pow(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_binop(instructions, declarations, type, ir_binop_pow); +} + void generate_function_instance(ir_function *f, const char *name, @@ -213,7 +222,7 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: acos() */ /* FINISHME: atan(y,x) */ /* FINISHME: atan(y/x) */ - /* FINISHME: pow() */ + make_gentype_function(symtab, instructions, "pow", 2, generate_pow); make_gentype_function(symtab, instructions, "exp", 1, generate_exp); make_gentype_function(symtab, instructions, "log", 1, generate_log); /* FINISHME: exp2() */ diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index f055e8f1d8f..ecfdb49c480 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -124,6 +124,7 @@ void ir_print_visitor::visit(ir_expression *ir) "dot", "min", "max", + "pow", }; printf("(expression "); -- cgit v1.2.3 From 44d68fd06ff8b53fc70a9a07c897dda9b3457ef8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 27 Mar 2010 13:01:51 -0700 Subject: Add sqrt() builtin as an IR operation. Following a discussion in #dri-devel, I think this makes more sense than implementing it as RSQ RCP CMP as Mesa did. The i965 has a hardware sqrt that should work, and AMD is suppposed to be able to implement it as RSQ RCP with an alternate floating point mode so that the 0.0 case is handled like we want. --- builtin_function.cpp | 10 +++++++++- ir.h | 1 + ir_print_visitor.cpp | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index ec1b54a2dd5..9d231e872b6 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -84,6 +84,14 @@ generate_rsq(exec_list *instructions, generate_unop(instructions, declarations, type, ir_unop_rsq); } +static void +generate_sqrt(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_sqrt); +} + static void generate_abs(exec_list *instructions, ir_variable **declarations, @@ -227,7 +235,7 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) make_gentype_function(symtab, instructions, "log", 1, generate_log); /* FINISHME: exp2() */ /* FINISHME: log2() */ - /* FINISHME: sqrt() */ + make_gentype_function(symtab, instructions, "sqrt", 1, generate_sqrt); make_gentype_function(symtab, instructions, "inversesqrt", 1, generate_rsq); make_gentype_function(symtab, instructions, "abs", 1, generate_abs); /* FINISHME: sign() */ diff --git a/ir.h b/ir.h index bad5111b5a8..45905289485 100644 --- a/ir.h +++ b/ir.h @@ -225,6 +225,7 @@ enum ir_expression_operation { ir_unop_abs, ir_unop_rcp, ir_unop_rsq, + ir_unop_sqrt, ir_unop_exp, ir_unop_log, ir_unop_f2i, /**< Float-to-integer conversion. */ diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index ecfdb49c480..8b2080f7ec5 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -93,6 +93,7 @@ void ir_print_visitor::visit(ir_expression *ir) "abs", "rcp", "rsq", + "sqrt", "exp", "log", "f2i", -- cgit v1.2.3 From 53afc3609db0afffacb1c40975ec7d87b9e3c7cd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 27 Mar 2010 13:55:04 -0700 Subject: Implement builtin length() function. --- builtin_function.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index 9d231e872b6..7cd08d772f0 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -157,6 +157,7 @@ generate_function_instance(ir_function *f, void (*generate)(exec_list *instructions, ir_variable **declarations, const glsl_type *type), + const glsl_type *ret_type, const glsl_type *type) { ir_variable *declarations[17]; @@ -184,7 +185,7 @@ generate_function_instance(ir_function *f, declarations[i] = var; } - ir_variable *retval = new ir_variable(type, "__retval"); + ir_variable *retval = new ir_variable(ret_type, "__retval"); instructions->push_tail(retval); declarations[16] = retval; @@ -201,6 +202,7 @@ make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, const glsl_type *type)) { ir_function *const f = new ir_function(name); + const glsl_type *float_type = glsl_type::float_type; const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); @@ -209,13 +211,56 @@ make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, assert(added); generate_function_instance(f, name, instructions, n_args, generate, - glsl_type::float_type); + float_type, float_type); generate_function_instance(f, name, instructions, n_args, generate, - vec2_type); + vec2_type, vec2_type); generate_function_instance(f, name, instructions, n_args, generate, - vec3_type); + vec3_type, vec3_type); generate_function_instance(f, name, instructions, n_args, generate, - vec4_type); + vec4_type, vec4_type); +} + +static void +generate_length(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const retval = new ir_dereference(declarations[16]); + ir_dereference *const arg = new ir_dereference(declarations[0]); + ir_rvalue *result, *temp; + + (void)type; + + /* FINISHME: implement the abs(arg) variant for length(float f) */ + + temp = new ir_expression(ir_binop_dot, glsl_type::float_type, arg, arg); + result = new ir_expression(ir_unop_sqrt, glsl_type::float_type, temp, NULL); + + ir_instruction *inst = new ir_assignment(retval, result, NULL); + instructions->push_tail(inst); +} + +void +generate_length_functions(glsl_symbol_table *symtab, exec_list *instructions) +{ + const char *name = "length"; + ir_function *const f = new ir_function(name); + const glsl_type *float_type = glsl_type::float_type; + const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); + const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); + const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); + + bool added = symtab->add_function(name, f); + assert(added); + + generate_function_instance(f, name, instructions, 1, generate_length, + float_type, float_type); + generate_function_instance(f, name, instructions, 1, generate_length, + float_type, vec2_type); + generate_function_instance(f, name, instructions, 1, generate_length, + float_type, vec3_type); + generate_function_instance(f, name, instructions, 1, generate_length, + float_type, vec4_type); } void @@ -258,7 +303,7 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: smoothstep() */ /* FINISHME: floor() */ /* FINISHME: step() */ - /* FINISHME: length() */ + generate_length_functions(symtab, instructions); /* FINISHME: distance() */ /* FINISHME: dot() */ /* FINISHME: cross() */ -- cgit v1.2.3 From 01665262e50162e858c45f92a8a7e12b953e56ad Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 27 Mar 2010 13:56:35 -0700 Subject: Implement exp2() and log2(), and make ir_unop_exp and ir_unop_log be base e. Making the base e functions IR operations is not a clear win. i965 doesn't support it, it doesn't look like r600 supports it, but r500 does. It should be easily supportable as a lowering pass, though. --- builtin_function.cpp | 20 ++++++++++++++++++-- ir.h | 2 ++ ir_print_visitor.cpp | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index 7cd08d772f0..ef6af2052b9 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -76,6 +76,22 @@ generate_log(exec_list *instructions, generate_unop(instructions, declarations, type, ir_unop_log); } +static void +generate_exp2(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_exp2); +} + +static void +generate_log2(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_log2); +} + static void generate_rsq(exec_list *instructions, ir_variable **declarations, @@ -278,8 +294,8 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) make_gentype_function(symtab, instructions, "pow", 2, generate_pow); make_gentype_function(symtab, instructions, "exp", 1, generate_exp); make_gentype_function(symtab, instructions, "log", 1, generate_log); - /* FINISHME: exp2() */ - /* FINISHME: log2() */ + make_gentype_function(symtab, instructions, "exp2", 1, generate_exp2); + make_gentype_function(symtab, instructions, "log2", 1, generate_log2); make_gentype_function(symtab, instructions, "sqrt", 1, generate_sqrt); make_gentype_function(symtab, instructions, "inversesqrt", 1, generate_rsq); make_gentype_function(symtab, instructions, "abs", 1, generate_abs); diff --git a/ir.h b/ir.h index 45905289485..600a2cd78de 100644 --- a/ir.h +++ b/ir.h @@ -228,6 +228,8 @@ enum ir_expression_operation { ir_unop_sqrt, ir_unop_exp, ir_unop_log, + ir_unop_exp2, + ir_unop_log2, ir_unop_f2i, /**< Float-to-integer conversion. */ ir_unop_i2f, /**< Integer-to-float conversion. */ ir_unop_u2f, /**< Unsigned-to-float conversion. */ diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 8b2080f7ec5..aeff280cdd9 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -96,6 +96,8 @@ void ir_print_visitor::visit(ir_expression *ir) "sqrt", "exp", "log", + "exp2", + "log2", "f2i", "i2f", "u2f", -- cgit v1.2.3 From 76a91e1afbd24dbbdaab1b9dde8540906376cb18 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 27 Mar 2010 14:04:43 -0700 Subject: Implement dot() builtin. --- builtin_function.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index ef6af2052b9..edb33dd8f35 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -279,6 +279,46 @@ generate_length_functions(glsl_symbol_table *symtab, exec_list *instructions) float_type, vec4_type); } +static void +generate_dot(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const retval = new ir_dereference(declarations[16]); + ir_dereference *const arg = new ir_dereference(declarations[0]); + ir_rvalue *result; + + (void)type; + + result = new ir_expression(ir_binop_dot, glsl_type::float_type, arg, arg); + + ir_instruction *inst = new ir_assignment(retval, result, NULL); + instructions->push_tail(inst); +} + +void +generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions) +{ + const char *name = "dot"; + ir_function *const f = new ir_function(name); + const glsl_type *float_type = glsl_type::float_type; + const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); + const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); + const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); + + bool added = symtab->add_function(name, f); + assert(added); + + generate_function_instance(f, name, instructions, 1, generate_dot, + float_type, float_type); + generate_function_instance(f, name, instructions, 1, generate_dot, + float_type, vec2_type); + generate_function_instance(f, name, instructions, 1, generate_dot, + float_type, vec3_type); + generate_function_instance(f, name, instructions, 1, generate_dot, + float_type, vec4_type); +} + void generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) { @@ -321,7 +361,7 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: step() */ generate_length_functions(symtab, instructions); /* FINISHME: distance() */ - /* FINISHME: dot() */ + generate_dot_functions(symtab, instructions); /* FINISHME: cross() */ /* FINISHME: normalize() */ /* FINISHME: ftransform() */ -- cgit v1.2.3 From 3cb4358f386d20c23de87b23a830f6c4ed0f08ad Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 28 Mar 2010 00:36:06 -0700 Subject: Add the instruction for the parameter variable declarations of builtin funcs. Matches constructor setup, but I'm not really sure why we make the variable twice. --- builtin_function.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index edb33dd8f35..58e3abfceb7 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -193,11 +193,13 @@ generate_function_instance(ir_function *f, for (i = 0; i < n_args; i++) { ir_variable *var = new ir_variable(type, arg_names[i]); + var = new ir_variable(type, arg_names[i]); var->mode = ir_var_in; sig->parameters.push_tail(var); var = new ir_variable(type, arg_names[i]); - + var->mode = ir_var_in; + instructions->push_tail(var); declarations[i] = var; } -- cgit v1.2.3 From 2e063f1adf9e529697483eaabc7e015b4b740267 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 28 Mar 2010 00:56:22 -0700 Subject: Reject variables marked with attribute in the fragment shader. Fixes attribute.frag. --- ast_to_hir.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index ec1562f8cb2..277e67ba389 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -867,7 +867,8 @@ type_specifier_to_glsl_type(const struct ast_type_specifier *spec, static void apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, struct ir_variable *var, - struct _mesa_glsl_parse_state *state) + struct _mesa_glsl_parse_state *state, + YYLTYPE *loc) { if (qual->invariant) var->invariant = 1; @@ -880,6 +881,13 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, if (qual->centroid) var->centroid = 1; + if (qual->attribute && state->target == fragment_shader) { + var->type = glsl_type::error_type; + _mesa_glsl_error(loc, state, + "`attribute' variables may not be declared in the " + "fragment shader"); + } + if (qual->in && qual->out) var->mode = ir_var_inout; else if (qual->attribute || qual->in @@ -922,16 +930,13 @@ ast_declarator_list::hir(exec_list *instructions, struct ast_declaration *const decl = (struct ast_declaration * )ptr; const struct glsl_type *var_type; struct ir_variable *var; - + YYLTYPE loc = this->get_location(); /* FINISHME: Emit a warning if a variable declaration shadows a * FINISHME: declaration at a higher scope. */ if ((decl_type == NULL) || decl_type->is_void()) { - YYLTYPE loc; - - loc = this->get_location(); if (type_name != NULL) { _mesa_glsl_error(& loc, state, "invalid type `%s' in declaration of `%s'", @@ -962,7 +967,8 @@ ast_declarator_list::hir(exec_list *instructions, * FINISHME: in a parameter list (in and out only). */ - apply_type_qualifier_to_variable(& this->type->qualifier, var, state); + apply_type_qualifier_to_variable(& this->type->qualifier, var, state, + & loc); /* Attempt to add the variable to the symbol table. If this fails, it * means the variable has already been declared at this scope. @@ -1036,12 +1042,11 @@ ast_parameter_declarator::hir(exec_list *instructions, { const struct glsl_type *type; const char *name = NULL; - + YYLTYPE loc = this->get_location(); type = type_specifier_to_glsl_type(this->type->specifier, & name, state); if (type == NULL) { - YYLTYPE loc = this->get_location(); if (name != NULL) { _mesa_glsl_error(& loc, state, "invalid type `%s' in declaration of `%s'", @@ -1064,7 +1069,7 @@ ast_parameter_declarator::hir(exec_list *instructions, /* Apply any specified qualifiers to the parameter declaration. Note that * for function parameters the default mode is 'in'. */ - apply_type_qualifier_to_variable(& this->type->qualifier, var, state); + apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc); if (var->mode == ir_var_auto) var->mode = ir_var_in; -- cgit v1.2.3 From ab372dab2a013e5d0c8ee57bb799a76c9a78abf2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 28 Mar 2010 01:24:55 -0700 Subject: Reject main() declarations with a non-void return value. Fixes main3.vert. --- ast_to_hir.cpp | 9 ++++++++- glsl_types.cpp | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 277e67ba389..e16f79f6f21 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1146,7 +1146,6 @@ ast_function_definition::hir(exec_list *instructions, assert(return_type != NULL); - /* Verify that this function's signature either doesn't match a previously * seen signature for a function with the same name, or, if a match is found, * that the previously seen signature does not have an associated definition. @@ -1190,6 +1189,14 @@ ast_function_definition::hir(exec_list *instructions, state->symbols->add_function(f->name, f); } + /* Verify the return type of main() */ + if (strcmp(name, "main") == 0) { + if (return_type != glsl_type::get_instance(GLSL_TYPE_VOID, 0, 0)) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "main() must return void"); + } + } /* Finish storing the information about this new function in its signature. */ diff --git a/glsl_types.cpp b/glsl_types.cpp index 55d960320db..df9667f8dce 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -489,10 +489,12 @@ _mesa_glsl_initialize_constructors(exec_list *instructions, const glsl_type * glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) { + if (base_type == GLSL_TYPE_VOID) + return &void_type; + if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4)) return error_type; - /* Treat GLSL vectors as Nx1 matrices. */ if (columns == 1) { -- cgit v1.2.3 From a9fafc6504ebccdc0fee3d2529c3fe6068cc86b8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 28 Mar 2010 01:29:18 -0700 Subject: Don't let swizzles with duplicated components be considered as lvalues. Fixes swizzle2.frag. --- ir.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir.h b/ir.h index 600a2cd78de..3ef37083697 100644 --- a/ir.h +++ b/ir.h @@ -432,7 +432,7 @@ public: bool is_lvalue() { - return val->is_lvalue(); + return val->is_lvalue() && !mask.has_duplicates; } ir_rvalue *val; -- cgit v1.2.3 From 78fe3c9150c0c5f77a20a790ee7441f8a9d1de5f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 28 Mar 2010 01:46:48 -0700 Subject: Add definitions for 1.10 built-in uniforms for ff state. --- builtin_variables.h | 18 ++++++++++++++++++ ir_variable.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/builtin_variables.h b/builtin_variables.h index a742a1562d2..902ff22e8ae 100644 --- a/builtin_variables.h +++ b/builtin_variables.h @@ -70,3 +70,21 @@ static const builtin_variable builtin_110_deprecated_vs_variables[] = { static const builtin_variable builtin_130_vs_variables[] = { { ir_var_in, "int", "gl_VertexID" }, }; + +static const builtin_variable builtin_110_deprecated_uniforms[] = { + { ir_var_uniform, "mat4", "gl_ModelViewMatrix" }, + { ir_var_uniform, "mat4", "gl_ProjectionMatrix" }, + { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrix" }, + { ir_var_uniform, "mat3", "gl_NormalMatrix" }, + { ir_var_uniform, "mat4", "gl_ModelViewMatrixInverse" }, + { ir_var_uniform, "mat4", "gl_ProjectionMatrixInverse" }, + { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrixInverse" }, + { ir_var_uniform, "mat4", "gl_ModelViewMatrixTranspose" }, + { ir_var_uniform, "mat4", "gl_ProjectionMatrixTranspose" }, + { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrixTranspose" }, + { ir_var_uniform, "mat4", "gl_ModelViewMatrixInverseTranspose" }, + { ir_var_uniform, "mat4", "gl_ProjectionMatrixInverseTranspose" }, + { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, + { ir_var_uniform, "float", "gl_NormalScale" }, +}; + diff --git a/ir_variable.cpp b/ir_variable.cpp index df8e4c3ba82..1b4b742ac4c 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -56,6 +56,37 @@ add_builtin_variable(const builtin_variable *proto, exec_list *instructions, symtab->add_variable(var->name, var); } +static void +generate_110_uniforms(exec_list *instructions, + glsl_symbol_table *symtab) +{ + for (unsigned i = 0 + ; i < Elements(builtin_110_deprecated_uniforms) + ; i++) { + add_builtin_variable(& builtin_110_deprecated_uniforms[i], + instructions, symtab); + } + + /* FINISHME: Add support for gl_TextureMatrix[]. The size of this array is + * FINISHME: implementation dependent based on the value of + * FINISHME: GL_MAX_TEXTURE_COORDS. + */ + + /* FINISHME: Add support for gl_DepthRangeParameters */ + /* FINISHME: Add support for gl_ClipPlane[] */ + /* FINISHME: Add support for gl_PointParameters */ + + /* FINISHME: Add support for gl_MaterialParameters + * FINISHME: (glFrontMaterial, glBackMaterial) + */ + + /* FINISHME: Add support for gl_LightSource[] */ + /* FINISHME: Add support for gl_LightModel */ + /* FINISHME: Add support for gl_FrontLightProduct[], gl_BackLightProduct[] */ + /* FINISHME: Add support for gl_TextureEnvColor[] */ + /* FINISHME: Add support for gl_ObjectPlane*[], gl_EyePlane*[] */ + /* FINISHME: Add support for gl_Fog */ +} static void generate_110_vs_variables(exec_list *instructions, @@ -72,6 +103,7 @@ generate_110_vs_variables(exec_list *instructions, add_builtin_variable(& builtin_110_deprecated_vs_variables[i], instructions, symtab); } + generate_110_uniforms(instructions, symtab); /* FINISHME: Add support fo gl_TexCoord. The size of this array is * FINISHME: implementation dependent based on the value of @@ -143,6 +175,7 @@ generate_110_fs_variables(exec_list *instructions, add_builtin_variable(& builtin_110_deprecated_fs_variables[i], instructions, symtab); } + generate_110_uniforms(instructions, symtab); /* FINISHME: Add support for gl_FragData[GL_MAX_DRAW_BUFFERS]. */ } -- cgit v1.2.3 From d1e31952ed282851ae29e2c15cb86bf84283ee4e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 28 Mar 2010 01:55:38 -0700 Subject: Add support for builtin radians() and degrees(). --- builtin_function.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index 58e3abfceb7..8e7e1164b8c 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -22,6 +22,7 @@ */ #include +#include #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" #include "glsl_types.h" @@ -60,6 +61,40 @@ generate_binop(exec_list *instructions, instructions->push_tail(inst); } +static void +generate_radians(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const retval = new ir_dereference(declarations[16]); + ir_dereference *const arg = new ir_dereference(declarations[0]); + ir_rvalue *result; + + result = new ir_expression(ir_binop_mul, type, + arg, + new ir_constant((float)(M_PI / 180.0))); + + ir_instruction *inst = new ir_assignment(retval, result, NULL); + instructions->push_tail(inst); +} + +static void +generate_degrees(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const retval = new ir_dereference(declarations[16]); + ir_dereference *const arg = new ir_dereference(declarations[0]); + ir_rvalue *result; + + result = new ir_expression(ir_binop_mul, type, + arg, + new ir_constant((float)(180.0 / M_PI))); + + ir_instruction *inst = new ir_assignment(retval, result, NULL); + instructions->push_tail(inst); +} + static void generate_exp(exec_list *instructions, ir_variable **declarations, @@ -324,8 +359,8 @@ generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions) void generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) { - /* FINISHME: radians() */ - /* FINISHME: degrees() */ + make_gentype_function(symtab, instructions, "radians", 1, generate_radians); + make_gentype_function(symtab, instructions, "degrees", 1, generate_degrees); /* FINISHME: sin() */ /* FINISHME: cos() */ /* FINISHME: tan() */ -- cgit v1.2.3 From 521c2983b43570ece73d9377f812baa6bcaf94d3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 12:52:00 -0700 Subject: Trivial code cleanup in ir_dereference::is_lvalue --- ir.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ir.h b/ir.h index 3ef37083697..328cd4e4ff5 100644 --- a/ir.h +++ b/ir.h @@ -458,15 +458,12 @@ public: bool is_lvalue() { - ir_variable *as_var; - if (var == NULL) - return NULL; - - as_var = var->as_variable(); + return false; + ir_variable *const as_var = var->as_variable(); if (as_var == NULL) - return NULL; + return false; return !as_var->read_only; } -- cgit v1.2.3 From 17d86f4371da413176ba365ca26a58bac172d365 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 12:59:02 -0700 Subject: Add a variable to the symbol table after processing the initializer --- ast_to_hir.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index e16f79f6f21..7b1db0c4818 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -981,10 +981,6 @@ ast_declarator_list::hir(exec_list *instructions, continue; } - const bool added_variable = - state->symbols->add_variable(decl->identifier, var); - assert(added_variable); - instructions->push_tail(var); if (decl->initializer != NULL) { @@ -1028,6 +1024,19 @@ ast_declarator_list::hir(exec_list *instructions, this->get_location()); } } + + /* Add the vairable to the symbol table after processing the initializer. + * This differs from most C-like languages, but it follows the GLSL + * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 + * spec: + * + * "Within a declaration, the scope of a name starts immediately + * after the initializer if present or immediately after the name + * being declared if not." + */ + const bool added_variable = + state->symbols->add_variable(decl->identifier, var); + assert(added_variable); } /* Variable declarations do not have r-values. -- cgit v1.2.3 From 721efc04da96451297ca1defe703fe755c212baa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 14:11:10 -0700 Subject: Add several simple if-statement tests --- tests/if-01.glsl | 11 +++++++++++ tests/if-02.glsl | 11 +++++++++++ tests/if-03.glsl | 11 +++++++++++ tests/if-04.glsl | 11 +++++++++++ 4 files changed, 44 insertions(+) create mode 100644 tests/if-01.glsl create mode 100644 tests/if-02.glsl create mode 100644 tests/if-03.glsl create mode 100644 tests/if-04.glsl diff --git a/tests/if-01.glsl b/tests/if-01.glsl new file mode 100644 index 00000000000..ca9abd54f75 --- /dev/null +++ b/tests/if-01.glsl @@ -0,0 +1,11 @@ +/* FAIL - if-statement condition is not bool scalar */ + +uniform bvec4 a; + +void main() +{ + if (a) + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); + else + gl_Position = vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/tests/if-02.glsl b/tests/if-02.glsl new file mode 100644 index 00000000000..7adccea0432 --- /dev/null +++ b/tests/if-02.glsl @@ -0,0 +1,11 @@ +/* FAIL - if-statement condition is not bool scalar */ + +uniform float a; + +void main() +{ + if (a) + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); + else + gl_Position = vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/tests/if-03.glsl b/tests/if-03.glsl new file mode 100644 index 00000000000..179618c716e --- /dev/null +++ b/tests/if-03.glsl @@ -0,0 +1,11 @@ +/* PASS */ + +uniform bool a; + +void main() +{ + if (a) + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); + else + gl_Position = vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/tests/if-04.glsl b/tests/if-04.glsl new file mode 100644 index 00000000000..7b711fb7edf --- /dev/null +++ b/tests/if-04.glsl @@ -0,0 +1,11 @@ +/* PASS */ + +uniform bvec4 a; + +void main() +{ + if (a.x) + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); + else + gl_Position = vec4(0.0, 1.0, 0.0, 1.0); +} -- cgit v1.2.3 From 3c6fea3048a0d9add2fec621d30c32f3519d8868 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 14:11:25 -0700 Subject: Implement ir_if (for if-statments) and conversion from AST The following tests now pass: glslparsertest/shaders/if1.frag glslparsertest/shaders/if2.frag The following tests that used to pass now fail. It appears that most of these fail because ast_nequal and ast_equal are not converted to HIR. shaders/glsl-unused-varying.frag shaders/glsl-fs-sqrt-branch.frag --- ast.h | 3 +++ ast_to_hir.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ ir.h | 22 ++++++++++++++++++++++ ir_print_visitor.cpp | 24 ++++++++++++++++++++++++ ir_print_visitor.h | 1 + ir_visitor.h | 1 + 6 files changed, 100 insertions(+) diff --git a/ast.h b/ast.h index a158910421d..53b0e4a2b41 100644 --- a/ast.h +++ b/ast.h @@ -492,6 +492,9 @@ public: ast_node *else_statement); virtual void print(void) const; + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + ast_expression *condition; ast_node *then_statement; ast_node *else_statement; diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 7b1db0c4818..0a505bf4146 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1318,3 +1318,52 @@ ast_jump_statement::hir(exec_list *instructions, */ return NULL; } + + +ir_rvalue * +ast_selection_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + ir_rvalue *const condition = this->condition->hir(instructions, state); + struct simple_node *ptr; + + /* From page 66 (page 72 of the PDF) of the GLSL 1.50 spec: + * + * "Any expression whose type evaluates to a Boolean can be used as the + * conditional expression bool-expression. Vector types are not accepted + * as the expression to if." + * + * The checks are separated so that higher quality diagnostics can be + * generated for cases where both rules are violated. + */ + if (!condition->type->is_boolean() || !condition->type->is_scalar()) { + YYLTYPE loc = this->condition->get_location(); + + _mesa_glsl_error(& loc, state, "if-statement condition must be scalar " + "boolean"); + } + + ir_if *const stmt = new ir_if(condition); + + if (then_statement != NULL) { + ast_node *node = (ast_node *) then_statement; + do { + node->hir(& stmt->then_instructions, state); + node = (ast_node *) node->next; + } while (node != then_statement); + } + + if (else_statement != NULL) { + ast_node *node = (ast_node *) else_statement; + do { + node->hir(& stmt->else_instructions, state); + node = (ast_node *) node->next; + } while (node != else_statement); + } + + instructions->push_tail(stmt); + + /* if-statements do not have r-values. + */ + return NULL; +} diff --git a/ir.h b/ir.h index 328cd4e4ff5..83e4f95b0cc 100644 --- a/ir.h +++ b/ir.h @@ -192,6 +192,28 @@ public: /*@}*/ +/** + * IR instruction representing high-level if-statements + */ +class ir_if : public ir_instruction { +public: + ir_if(ir_rvalue *condition) + : condition(condition) + { + /* empty */ + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + ir_rvalue *condition; + exec_list then_instructions; + exec_list else_instructions; +}; + + class ir_assignment : public ir_rvalue { public: ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index aeff280cdd9..e6b24d2d5bc 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -265,3 +265,27 @@ ir_print_visitor::visit(ir_return *ir) printf(")"); } + + +void +ir_print_visitor::visit(ir_if *ir) +{ + printf("(if "); + ir->condition->accept(this); + + printf("(\n"); + foreach_iter(exec_list_iterator, iter, ir->then_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + inst->accept(this); + } + printf(")\n"); + + printf("(\n"); + foreach_iter(exec_list_iterator, iter, ir->else_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + inst->accept(this); + } + printf("))\n"); +} diff --git a/ir_print_visitor.h b/ir_print_visitor.h index 8fd684eb92a..76d812e19c1 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -64,6 +64,7 @@ public: virtual void visit(ir_constant *); virtual void visit(ir_call *); virtual void visit(ir_return *); + virtual void visit(ir_if *); /*@}*/ private: diff --git a/ir_visitor.h b/ir_visitor.h index 76981f7afc1..521b1c3d805 100644 --- a/ir_visitor.h +++ b/ir_visitor.h @@ -55,6 +55,7 @@ public: virtual void visit(class ir_constant *) = 0; virtual void visit(class ir_call *) = 0; virtual void visit(class ir_return *) = 0; + virtual void visit(class ir_if *) = 0; /*@}*/ }; -- cgit v1.2.3 From 251eb753187fee83e6413f44f8b3cf0be1b4f4cb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 14:15:05 -0700 Subject: Add missing break-statements in ast_expression::hir The ast_conditional case was flowing right into ast_pre_inc. --- ast_to_hir.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 0a505bf4146..8d34adf8ef4 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -649,12 +649,15 @@ ast_expression::hir(exec_list *instructions, case ast_ls_assign: case ast_rs_assign: + break; case ast_and_assign: case ast_xor_assign: case ast_or_assign: + break; case ast_conditional: + break; case ast_pre_inc: case ast_pre_dec: { -- cgit v1.2.3 From 6e659caaa946339a2de3890a8bed091ccb65102a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 15:11:05 -0700 Subject: Implement HIR conversion for ast_nequal and ast_equal The following tests now pass: shaders/glsl-unused-varying.frag shaders/glsl-fs-sqrt-branch.frag --- ast_to_hir.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 8d34adf8ef4..4674cfcdd52 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -582,7 +582,30 @@ ast_expression::hir(exec_list *instructions, case ast_nequal: case ast_equal: - /* FINISHME: Implement equality operators. */ + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + /* From page 58 (page 64 of the PDF) of the GLSL 1.50 spec: + * + * "The equality operators equal (==), and not equal (!=) + * operate on all types. They result in a scalar Boolean. If + * the operand types do not match, then there must be a + * conversion from Section 4.1.10 "Implicit Conversions" + * applied to one operand that can make them match, in which + * case this conversion is done." + */ + /* FINISHME: Apply implicit conversions */ + if (op[0]->type != op[1]->type) { + _mesa_glsl_error(& loc, state, "operands of `%s' must have the same " + "type", (this->oper == ast_equal) ? "==" : "!="); + error_emitted = true; + } + + result = new ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], op[1]); + type = glsl_type::bool_type; + + assert(result->type == glsl_type::bool_type); break; case ast_bit_and: -- cgit v1.2.3 From 5185a5f7d5654c9202c226015c4daeee43d9b897 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 15:20:42 -0700 Subject: Add generate_temporary to generate an anonymous temporary --- ast_to_hir.cpp | 20 ++++++++++++++++++++ glsl_parser_extras.cpp | 1 + glsl_parser_extras.h | 3 +++ 3 files changed, 24 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 4674cfcdd52..80489d37198 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -388,6 +388,26 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, return rhs; } + +/** + * Generate a new temporary and add its declaration to the instruction stream + */ +static ir_variable * +generate_temporary(const glsl_type *type, exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + char *name = (char *) malloc(sizeof(char) * 13); + + snprintf(name, 13, "tmp_%08X", state->temp_index); + state->temp_index++; + + ir_variable *const var = new ir_variable(type, name); + instructions->push_tail(var); + + return var; +} + + static ir_rvalue * get_lvalue_copy(exec_list *instructions, struct _mesa_glsl_parse_state *state, ir_rvalue *lvalue, YYLTYPE loc) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index d57a68efb75..1ddc2ee9ddd 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -634,6 +634,7 @@ main(int argc, char **argv) make_empty_list(& state.translation_unit); state.symbols = new glsl_symbol_table; state.error = false; + state.temp_index = 0; _mesa_glsl_lexer_ctor(& state, shader, shader_len); _mesa_glsl_parse(& state); diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index dbe7c17302a..96c975ba117 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -53,6 +53,9 @@ struct _mesa_glsl_parse_state { /** Was there an error during compilation? */ bool error; + + /** Index of last generated anonymous temporary. */ + unsigned temp_index; }; typedef struct YYLTYPE { -- cgit v1.2.3 From 96f9cea11606bb1bd8e07edc17032447424b8bff Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 15:33:54 -0700 Subject: Implement HIR conversion for ?: operator --- ast_to_hir.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 80489d37198..661dd704dc2 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -699,8 +699,70 @@ ast_expression::hir(exec_list *instructions, case ast_or_assign: break; - case ast_conditional: + case ast_conditional: { + op[0] = this->subexpressions[0]->hir(instructions, state); + + /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: + * + * "The ternary selection operator (?:). It operates on three + * expressions (exp1 ? exp2 : exp3). This operator evaluates the + * first expression, which must result in a scalar Boolean." + */ + if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[0]->get_location(); + + _mesa_glsl_error(& loc, state, "?: condition must be scalar boolean"); + error_emitted = true; + } + + /* The :? operator is implemented by generating an anonymous temporary + * followed by an if-statement. The last instruction in each branch of + * the if-statement assigns a value to the anonymous temporary. This + * temporary is the r-value of the expression. + */ + ir_variable *const tmp = generate_temporary(glsl_type::error_type, + instructions, state); + + ir_if *const stmt = new ir_if(op[0]); + instructions->push_tail(stmt); + + op[1] = this->subexpressions[1]->hir(& stmt->then_instructions, state); + ir_dereference *const then_deref = new ir_dereference(tmp); + ir_assignment *const then_assign = + new ir_assignment(then_deref, op[1], NULL); + stmt->then_instructions.push_tail(then_assign); + + op[2] = this->subexpressions[2]->hir(& stmt->else_instructions, state); + ir_dereference *const else_deref = new ir_dereference(tmp); + ir_assignment *const else_assign = + new ir_assignment(else_deref, op[2], NULL); + stmt->else_instructions.push_tail(else_assign); + + /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: + * + * "The second and third expressions can be any type, as + * long their types match, or there is a conversion in + * Section 4.1.10 "Implicit Conversions" that can be applied + * to one of the expressions to make their types match. This + * resulting matching type is the type of the entire + * expression." + */ + /* FINISHME: Apply implicit conversions */ + if (op[1]->type == op[2]->type) { + tmp->type = op[1]->type; + } else { + YYLTYPE loc = this->subexpressions[1]->get_location(); + + _mesa_glsl_error(& loc, state, "Second and third operands of ?: " + "operator must have matching types."); + error_emitted = true; + } + + + result = new ir_dereference(tmp); + type = tmp->type; break; + } case ast_pre_inc: case ast_pre_dec: { -- cgit v1.2.3 From 32a494586fa8cb01a4ff4c5fa270d29e15c09aa8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 15:34:21 -0700 Subject: Add tests for :? operator --- tests/condition-01.glsl | 8 ++++++++ tests/condition-02.glsl | 8 ++++++++ tests/condition-03.glsl | 8 ++++++++ tests/condition-04.glsl | 8 ++++++++ tests/condition-05.glsl | 13 +++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 tests/condition-01.glsl create mode 100644 tests/condition-02.glsl create mode 100644 tests/condition-03.glsl create mode 100644 tests/condition-04.glsl create mode 100644 tests/condition-05.glsl diff --git a/tests/condition-01.glsl b/tests/condition-01.glsl new file mode 100644 index 00000000000..d89c313117e --- /dev/null +++ b/tests/condition-01.glsl @@ -0,0 +1,8 @@ +/* FAIL - :? condition is not bool scalar */ + +uniform bvec4 a; + +void main() +{ + gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/tests/condition-02.glsl b/tests/condition-02.glsl new file mode 100644 index 00000000000..cbd0e18d9a8 --- /dev/null +++ b/tests/condition-02.glsl @@ -0,0 +1,8 @@ +/* FAIL - :? condition is not bool scalar */ + +uniform float a; + +void main() +{ + gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/tests/condition-03.glsl b/tests/condition-03.glsl new file mode 100644 index 00000000000..9af5d7aa470 --- /dev/null +++ b/tests/condition-03.glsl @@ -0,0 +1,8 @@ +/* PASS */ + +uniform bool a; + +void main() +{ + gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/tests/condition-04.glsl b/tests/condition-04.glsl new file mode 100644 index 00000000000..f440b7e9955 --- /dev/null +++ b/tests/condition-04.glsl @@ -0,0 +1,8 @@ +/* FAIL - type of second two operands must match */ + +uniform bool a; + +void main() +{ + gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0); +} diff --git a/tests/condition-05.glsl b/tests/condition-05.glsl new file mode 100644 index 00000000000..3dff18f519d --- /dev/null +++ b/tests/condition-05.glsl @@ -0,0 +1,13 @@ +#version 120 +/* PASS */ + +uniform bool a; +uniform int b; + +void main() +{ + float x; + + x = (a) ? 2.0 : b; + gl_Position = vec4(x); +} -- cgit v1.2.3 From 8a24cd5ceaf74a9be5954b5f7426b1612ce8ecd3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 15:36:02 -0700 Subject: Allow single-component constructors This causes the following tests to pass: glslparsertest/shaders/CorrectVersion.V110.frag shaders/glsl-vs-sqrt-zero.frag shaders/glsl-vs-sqrt-zero.vert This causes the following tests to fail. These shaders were previously failing to compile, but they were all failing for the wrong reasons. glslparsertest/shaders/attribute1.vert glslparsertest/shaders/attribute2.vert glslparsertest/shaders/main2.vert --- ast_function.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ast_function.cpp b/ast_function.cpp index 6470057a905..36bf0c9cc2d 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -327,7 +327,7 @@ ast_function_expression::hir(exec_list *instructions, * arguments to provide an initializer for every component in the * constructed value." */ - if (components_used < type_components) { + if ((components_used < type_components) && (components_used != 1)) { _mesa_glsl_error(& loc, state, "too few components to construct " "`%s'", constructor_type->name); -- cgit v1.2.3 From 70348543ac8f2c4d3d25996869461c53ea82b6a8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 16:17:15 -0700 Subject: Add glsl_type::is_array and glsl_type::is_float queries --- glsl_types.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/glsl_types.h b/glsl_types.h index 68a32efde66..bb2d6f697b6 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -223,6 +223,14 @@ struct glsl_type { return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT); } + /** + * Query whether or not a type is a float type + */ + bool is_float() const + { + return base_type == GLSL_TYPE_FLOAT; + } + /** * Query whether or not a type is a non-array boolean type */ @@ -239,6 +247,14 @@ struct glsl_type { return base_type == GLSL_TYPE_SAMPLER; } + /** + * Query whether or not a type is an array + */ + bool is_array() const + { + return base_type == GLSL_TYPE_ARRAY; + } + /** * Query whether or not a type is the void type singleton. */ -- cgit v1.2.3 From 0104536568ed031654c1c3c957b0216bbca4a1d6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 16:17:56 -0700 Subject: Apply implicit conversions to arithmetic operators --- ast_to_hir.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 17 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 661dd704dc2..34762df18d4 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -73,12 +73,70 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) } +/** + * If a conversion is available, convert one operand to a different type + * + * The \c from \c ir_rvalue is converted "in place". + * + * \param to Type that the operand it to be converted to + * \param from Operand that is being converted + * \param state GLSL compiler state + * + * \return + * If a conversion is possible (or unnecessary), \c true is returned. + * Otherwise \c false is returned. + */ +static bool +apply_implicit_conversion(const glsl_type *to, ir_rvalue **from, + struct _mesa_glsl_parse_state *state) +{ + if (to->base_type == (*from)->type->base_type) + return true; + + /* This conversion was added in GLSL 1.20. If the compilation mode is + * GLSL 1.10, the conversion is skipped. + */ + if (state->language_version < 120) + return false; + + /* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec: + * + * "There are no implicit array or structure conversions. For + * example, an array of int cannot be implicitly converted to an + * array of float. There are no implicit conversions between + * signed and unsigned integers." + */ + /* FINISHME: The above comment is partially a lie. There is int/uint + * FINISHME: conversion for immediate constants. + */ + if (!to->is_float() || !(*from)->type->is_numeric()) + return false; + + switch (((*from))->type->base_type) { + case GLSL_TYPE_INT: + (*from) = new ir_expression(ir_unop_i2f, to, (*from), NULL); + break; + case GLSL_TYPE_UINT: + (*from) = new ir_expression(ir_unop_u2f, to, (*from), NULL); + break; + case GLSL_TYPE_BOOL: + assert(!"FINISHME: Convert bool to float."); + default: + assert(0); + } + + return true; +} + + static const struct glsl_type * -arithmetic_result_type(const struct glsl_type *type_a, - const struct glsl_type *type_b, +arithmetic_result_type(ir_rvalue **value_a, ir_rvalue **value_b, bool multiply, struct _mesa_glsl_parse_state *state) { + const glsl_type *const type_a = (*value_a)->type; + const glsl_type *const type_b = (*value_b)->type; + /* From GLSL 1.50 spec, page 56: * * "The arithmetic binary operators add (+), subtract (-), @@ -93,16 +151,10 @@ arithmetic_result_type(const struct glsl_type *type_a, /* "If one operand is floating-point based and the other is * not, then the conversions from Section 4.1.10 "Implicit * Conversions" are applied to the non-floating-point-based operand." - * - * This conversion was added in GLSL 1.20. If the compilation mode is - * GLSL 1.10, the conversion is skipped. */ - if (state->language_version >= 120) { - if ((type_a->base_type == GLSL_TYPE_FLOAT) - && (type_b->base_type != GLSL_TYPE_FLOAT)) { - } else if ((type_a->base_type != GLSL_TYPE_FLOAT) - && (type_b->base_type == GLSL_TYPE_FLOAT)) { - } + if (!apply_implicit_conversion(type_a, value_b, state) + && !apply_implicit_conversion(type_b, value_a, state)) { + return glsl_type::error_type; } /* "If the operands are integer types, they must both be signed or @@ -551,7 +603,7 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - type = arithmetic_result_type(op[0]->type, op[1]->type, + type = arithmetic_result_type(& op[0], & op[1], (this->oper == ast_mul), state); @@ -649,7 +701,7 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - type = arithmetic_result_type(op[0]->type, op[1]->type, + type = arithmetic_result_type(& op[0], & op[1], (this->oper == ast_mul_assign), state); @@ -772,8 +824,7 @@ ast_expression::hir(exec_list *instructions, else op[1] = new ir_constant(1); - type = arithmetic_result_type(op[0]->type, op[1]->type, - false, state); + type = arithmetic_result_type(& op[0], & op[1], false, state); struct ir_rvalue *temp_rhs; temp_rhs = new ir_expression(operations[this->oper], type, @@ -796,8 +847,7 @@ ast_expression::hir(exec_list *instructions, error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - type = arithmetic_result_type(op[0]->type, op[1]->type, - false, state); + type = arithmetic_result_type(& op[0], & op[1], false, state); struct ir_rvalue *temp_rhs; temp_rhs = new ir_expression(operations[this->oper], type, -- cgit v1.2.3 From 0150f5f20edaef96520af5d1bbed0e62e24918e5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 16:20:07 -0700 Subject: Apply implicit conversions to relational operators --- ast_to_hir.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 34762df18d4..31cd01eda89 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -333,10 +333,12 @@ modulus_result_type(const struct glsl_type *type_a, static const struct glsl_type * -relational_result_type(const struct glsl_type *type_a, - const struct glsl_type *type_b, +relational_result_type(ir_rvalue **value_a, ir_rvalue **value_b, struct _mesa_glsl_parse_state *state) { + const glsl_type *const type_a = (*value_a)->type; + const glsl_type *const type_b = (*value_b)->type; + /* From GLSL 1.50 spec, page 56: * "The relational operators greater than (>), less than (<), greater * than or equal (>=), and less than or equal (<=) operate only on @@ -351,18 +353,10 @@ relational_result_type(const struct glsl_type *type_a, /* "Either the operands' types must match, or the conversions from * Section 4.1.10 "Implicit Conversions" will be applied to the integer * operand, after which the types must match." - * - * This conversion was added in GLSL 1.20. If the compilation mode is - * GLSL 1.10, the conversion is skipped. */ - if (state->language_version >= 120) { - if ((type_a->base_type == GLSL_TYPE_FLOAT) - && (type_b->base_type != GLSL_TYPE_FLOAT)) { - /* FINISHME: Generate the implicit type conversion. */ - } else if ((type_a->base_type != GLSL_TYPE_FLOAT) - && (type_b->base_type == GLSL_TYPE_FLOAT)) { - /* FINISHME: Generate the implicit type conversion. */ - } + if (!apply_implicit_conversion(type_a, value_b, state) + && !apply_implicit_conversion(type_b, value_a, state)) { + return glsl_type::error_type; } if (type_a->base_type != type_b->base_type) @@ -639,7 +633,7 @@ ast_expression::hir(exec_list *instructions, error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - type = relational_result_type(op[0]->type, op[1]->type, state); + type = relational_result_type(& op[0], & op[1], state); /* The relational operators must either generate an error or result * in a scalar boolean. See page 57 of the GLSL 1.50 spec. -- cgit v1.2.3 From 212b0327b47033442842a7be3d7fb10e08e2bf66 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 16:22:38 -0700 Subject: Apply implicit conversions to equality operators --- ast_to_hir.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 31cd01eda89..3450d3889c3 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -660,8 +660,9 @@ ast_expression::hir(exec_list *instructions, * applied to one operand that can make them match, in which * case this conversion is done." */ - /* FINISHME: Apply implicit conversions */ - if (op[0]->type != op[1]->type) { + if ((!apply_implicit_conversion(op[0]->type, & op[1], state) + && !apply_implicit_conversion(op[1]->type, & op[0], state)) + || (op[0]->type != op[1]->type)) { _mesa_glsl_error(& loc, state, "operands of `%s' must have the same " "type", (this->oper == ast_equal) ? "==" : "!="); error_emitted = true; -- cgit v1.2.3 From db9be2e7aa3a56e43b725ad7725fe6b424e4933e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 16:25:56 -0700 Subject: Apply implicit conversions to ?: operator --- ast_to_hir.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 3450d3889c3..dfb2e40ea3d 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -794,18 +794,18 @@ ast_expression::hir(exec_list *instructions, * resulting matching type is the type of the entire * expression." */ - /* FINISHME: Apply implicit conversions */ - if (op[1]->type == op[2]->type) { - tmp->type = op[1]->type; - } else { + if ((!apply_implicit_conversion(op[1]->type, & op[2], state) + && !apply_implicit_conversion(op[2]->type, & op[1], state)) + || (op[1]->type != op[2]->type)) { YYLTYPE loc = this->subexpressions[1]->get_location(); _mesa_glsl_error(& loc, state, "Second and third operands of ?: " "operator must have matching types."); error_emitted = true; + } else { + tmp->type = op[1]->type; } - result = new ir_dereference(tmp); type = tmp->type; break; -- cgit v1.2.3 From bfb09c2a94414c1b40108c9c41eb0844d932e459 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 16:32:55 -0700 Subject: Use call-by-reference for apply_implicit_conversion I'm not sure if this is a win or not. It makes the code in apply_implicit_conversion more clear, but it obscures the fact that it may change the pointers. --- ast_to_hir.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index dfb2e40ea3d..b03735ecb6c 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -87,10 +87,10 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) * Otherwise \c false is returned. */ static bool -apply_implicit_conversion(const glsl_type *to, ir_rvalue **from, +apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, struct _mesa_glsl_parse_state *state) { - if (to->base_type == (*from)->type->base_type) + if (to->base_type == from->type->base_type) return true; /* This conversion was added in GLSL 1.20. If the compilation mode is @@ -109,15 +109,15 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue **from, /* FINISHME: The above comment is partially a lie. There is int/uint * FINISHME: conversion for immediate constants. */ - if (!to->is_float() || !(*from)->type->is_numeric()) + if (!to->is_float() || !from->type->is_numeric()) return false; - switch (((*from))->type->base_type) { + switch (from->type->base_type) { case GLSL_TYPE_INT: - (*from) = new ir_expression(ir_unop_i2f, to, (*from), NULL); + from = new ir_expression(ir_unop_i2f, to, from, NULL); break; case GLSL_TYPE_UINT: - (*from) = new ir_expression(ir_unop_u2f, to, (*from), NULL); + from = new ir_expression(ir_unop_u2f, to, from, NULL); break; case GLSL_TYPE_BOOL: assert(!"FINISHME: Convert bool to float."); @@ -130,12 +130,12 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue **from, static const struct glsl_type * -arithmetic_result_type(ir_rvalue **value_a, ir_rvalue **value_b, +arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, bool multiply, struct _mesa_glsl_parse_state *state) { - const glsl_type *const type_a = (*value_a)->type; - const glsl_type *const type_b = (*value_b)->type; + const glsl_type *const type_a = value_a->type; + const glsl_type *const type_b = value_b->type; /* From GLSL 1.50 spec, page 56: * @@ -333,11 +333,11 @@ modulus_result_type(const struct glsl_type *type_a, static const struct glsl_type * -relational_result_type(ir_rvalue **value_a, ir_rvalue **value_b, +relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, struct _mesa_glsl_parse_state *state) { - const glsl_type *const type_a = (*value_a)->type; - const glsl_type *const type_b = (*value_b)->type; + const glsl_type *const type_a = value_a->type; + const glsl_type *const type_b = value_b->type; /* From GLSL 1.50 spec, page 56: * "The relational operators greater than (>), less than (<), greater @@ -597,7 +597,7 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - type = arithmetic_result_type(& op[0], & op[1], + type = arithmetic_result_type(op[0], op[1], (this->oper == ast_mul), state); @@ -633,7 +633,7 @@ ast_expression::hir(exec_list *instructions, error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - type = relational_result_type(& op[0], & op[1], state); + type = relational_result_type(op[0], op[1], state); /* The relational operators must either generate an error or result * in a scalar boolean. See page 57 of the GLSL 1.50 spec. @@ -660,8 +660,8 @@ ast_expression::hir(exec_list *instructions, * applied to one operand that can make them match, in which * case this conversion is done." */ - if ((!apply_implicit_conversion(op[0]->type, & op[1], state) - && !apply_implicit_conversion(op[1]->type, & op[0], state)) + if ((!apply_implicit_conversion(op[0]->type, op[1], state) + && !apply_implicit_conversion(op[1]->type, op[0], state)) || (op[0]->type != op[1]->type)) { _mesa_glsl_error(& loc, state, "operands of `%s' must have the same " "type", (this->oper == ast_equal) ? "==" : "!="); @@ -696,7 +696,7 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - type = arithmetic_result_type(& op[0], & op[1], + type = arithmetic_result_type(op[0], op[1], (this->oper == ast_mul_assign), state); @@ -794,8 +794,8 @@ ast_expression::hir(exec_list *instructions, * resulting matching type is the type of the entire * expression." */ - if ((!apply_implicit_conversion(op[1]->type, & op[2], state) - && !apply_implicit_conversion(op[2]->type, & op[1], state)) + if ((!apply_implicit_conversion(op[1]->type, op[2], state) + && !apply_implicit_conversion(op[2]->type, op[1], state)) || (op[1]->type != op[2]->type)) { YYLTYPE loc = this->subexpressions[1]->get_location(); @@ -819,7 +819,7 @@ ast_expression::hir(exec_list *instructions, else op[1] = new ir_constant(1); - type = arithmetic_result_type(& op[0], & op[1], false, state); + type = arithmetic_result_type(op[0], op[1], false, state); struct ir_rvalue *temp_rhs; temp_rhs = new ir_expression(operations[this->oper], type, @@ -842,7 +842,7 @@ ast_expression::hir(exec_list *instructions, error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - type = arithmetic_result_type(& op[0], & op[1], false, state); + type = arithmetic_result_type(op[0], op[1], false, state); struct ir_rvalue *temp_rhs; temp_rhs = new ir_expression(operations[this->oper], type, -- cgit v1.2.3 From 06e5308e29e42d22a72247abfdd260bc9ba145b8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 16:44:29 -0700 Subject: Add parser support for texture rectangle types --- ast.h | 2 ++ ast_type.cpp | 2 ++ glsl_parser.ypp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/ast.h b/ast.h index 53b0e4a2b41..8e904bccc97 100644 --- a/ast.h +++ b/ast.h @@ -326,10 +326,12 @@ enum ast_types { ast_mat4, ast_sampler1d, ast_sampler2d, + ast_sampler2drect, ast_sampler3d, ast_samplercube, ast_sampler1dshadow, ast_sampler2dshadow, + ast_sampler2drectshadow, ast_samplercubeshadow, ast_sampler1darray, ast_sampler2darray, diff --git a/ast_type.cpp b/ast_type.cpp index 3bfbc647a1e..cb0852bb773 100644 --- a/ast_type.cpp +++ b/ast_type.cpp @@ -78,10 +78,12 @@ ast_type_specifier::ast_type_specifier(int specifier) "mat4", "sampler1D", "sampler2D", + "sampler2DRect", "sampler3D", "samplerCube", "sampler1DShadow", "sampler2DShadow", + "sampler2DRectShadow", "samplerCubeShadow", "sampler1DArray", "sampler2DArray", diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 7af93dd9447..4a58666d763 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -900,10 +900,12 @@ basic_type_specifier_nonarray: | MAT4X4 { $$ = ast_mat4; } | SAMPLER1D { $$ = ast_sampler1d; } | SAMPLER2D { $$ = ast_sampler2d; } + | SAMPLER2DRECT { $$ = ast_sampler2drect; } | SAMPLER3D { $$ = ast_sampler3d; } | SAMPLERCUBE { $$ = ast_samplercube; } | SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; } | SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; } + | SAMPLER2DRECTSHADOW { $$ = ast_sampler2drectshadow; } | SAMPLERCUBESHADOW { $$ = ast_samplercubeshadow; } | SAMPLER1DARRAY { $$ = ast_sampler1darray; } | SAMPLER2DARRAY { $$ = ast_sampler2darray; } -- cgit v1.2.3 From fb9f5b0675bd714fd6d6325479f62435aaabc2ee Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 17:16:35 -0700 Subject: Add some checking for vertex shader inputs / attributes This causes the following tests to pass: glslparsertest/shaders/attribute.vert glslparsertest/shaders/attribute1.vert glslparsertest/shaders/attribute2.vert --- ast_to_hir.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index b03735ecb6c..dd024836a0e 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1136,6 +1136,61 @@ ast_declarator_list::hir(exec_list *instructions, instructions->push_tail(var); + if (this->type->qualifier.attribute + && (state->current_function != NULL)) { + _mesa_glsl_error(& loc, state, + "attribute variable `%s' must be declared at global " + "scope", + var->name); + } + + if ((var->mode == ir_var_in) && (state->current_function == NULL)) { + if (state->target == vertex_shader) { + bool error_emitted = false; + + /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: + * + * "Vertex shader inputs can only be float, floating-point + * vectors, matrices, signed and unsigned integers and integer + * vectors. Vertex shader inputs can also form arrays of these + * types, but not structures." + * + * From page 23 (page 29 of the PDF) of the GLSL 1.20 spec: + * + * "The attribute qualifier can be used only with float, + * floating-point vectors, and matrices. Attribute variables + * cannot be declared as arrays or structures." + */ + const glsl_type *check_type = var->type->is_array() + ? var->type->fields.array : var->type; + + switch (check_type->base_type) { + case GLSL_TYPE_FLOAT: + break; + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + if (state->language_version > 120) + break; + /* FALLTHROUGH */ + default: + _mesa_glsl_error(& loc, state, + "vertex shader input / attribute cannot have " + "type %s`%s'", + var->type->is_array() ? "array of " : "", + check_type->name); + error_emitted = true; + } + + if (!error_emitted && (state->language_version <= 120) + && var->type->is_array()) { + _mesa_glsl_error(& loc, state, + "vertex shader input / attribute cannot have " + "array type"); + error_emitted = true; + } + } + } + if (decl->initializer != NULL) { YYLTYPE initializer_loc = decl->initializer->get_location(); -- cgit v1.2.3 From 8901eeefc94e4211c87ff13e951113749fc495de Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 17:19:13 -0700 Subject: Add several tests for vertex shader attributes --- tests/attribute-01.glsl | 7 +++++++ tests/attribute-02.glsl | 7 +++++++ tests/attribute-03.glsl | 7 +++++++ tests/attribute-04.glsl | 7 +++++++ tests/attribute-05.glsl | 7 +++++++ tests/attribute-06.glsl | 7 +++++++ tests/attribute-07.glsl | 7 +++++++ tests/attribute-08.glsl | 7 +++++++ tests/attribute-09.glsl | 7 +++++++ tests/attribute-10.glsl | 8 ++++++++ tests/attribute-11.glsl | 8 ++++++++ 11 files changed, 79 insertions(+) create mode 100644 tests/attribute-01.glsl create mode 100644 tests/attribute-02.glsl create mode 100644 tests/attribute-03.glsl create mode 100644 tests/attribute-04.glsl create mode 100644 tests/attribute-05.glsl create mode 100644 tests/attribute-06.glsl create mode 100644 tests/attribute-07.glsl create mode 100644 tests/attribute-08.glsl create mode 100644 tests/attribute-09.glsl create mode 100644 tests/attribute-10.glsl create mode 100644 tests/attribute-11.glsl diff --git a/tests/attribute-01.glsl b/tests/attribute-01.glsl new file mode 100644 index 00000000000..18e9e4468aa --- /dev/null +++ b/tests/attribute-01.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type int */ +attribute int i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/tests/attribute-02.glsl b/tests/attribute-02.glsl new file mode 100644 index 00000000000..6b6df74d252 --- /dev/null +++ b/tests/attribute-02.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type ivec2 */ +attribute ivec2 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/tests/attribute-03.glsl b/tests/attribute-03.glsl new file mode 100644 index 00000000000..870de9e8148 --- /dev/null +++ b/tests/attribute-03.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type ivec3 */ +attribute ivec3 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/tests/attribute-04.glsl b/tests/attribute-04.glsl new file mode 100644 index 00000000000..14af2fcaadd --- /dev/null +++ b/tests/attribute-04.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type ivec4 */ +attribute ivec4 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/tests/attribute-05.glsl b/tests/attribute-05.glsl new file mode 100644 index 00000000000..18822c78541 --- /dev/null +++ b/tests/attribute-05.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type bool */ +attribute bool i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/tests/attribute-06.glsl b/tests/attribute-06.glsl new file mode 100644 index 00000000000..f18027b81af --- /dev/null +++ b/tests/attribute-06.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type bvec2 */ +attribute bvec2 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/tests/attribute-07.glsl b/tests/attribute-07.glsl new file mode 100644 index 00000000000..0af13ba84bf --- /dev/null +++ b/tests/attribute-07.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type bvec3 */ +attribute bvec3 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/tests/attribute-08.glsl b/tests/attribute-08.glsl new file mode 100644 index 00000000000..b069c04d1b4 --- /dev/null +++ b/tests/attribute-08.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type bvec4 */ +attribute bvec4 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/tests/attribute-09.glsl b/tests/attribute-09.glsl new file mode 100644 index 00000000000..6a607244b9a --- /dev/null +++ b/tests/attribute-09.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have array type in GLSL 1.10 */ +attribute vec4 i[10]; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/tests/attribute-10.glsl b/tests/attribute-10.glsl new file mode 100644 index 00000000000..6f5ef63a015 --- /dev/null +++ b/tests/attribute-10.glsl @@ -0,0 +1,8 @@ +#version 120 +/* FAIL - attribute cannot have array type in GLSL 1.20 */ +attribute vec4 i[10]; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/tests/attribute-11.glsl b/tests/attribute-11.glsl new file mode 100644 index 00000000000..c1e69014314 --- /dev/null +++ b/tests/attribute-11.glsl @@ -0,0 +1,8 @@ +#version 130 +/* PASS */ +attribute vec4 i[10]; + +void main() +{ + gl_Position = vec4(1.0); +} -- cgit v1.2.3 From 2d816204c875ace0fc363d3eeada2255a5009d5c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 17:40:11 -0700 Subject: Arrays are not allowed as vertex shader inputs in GLSL 1.30 either --- ast_to_hir.cpp | 8 +++++++- tests/attribute-11.glsl | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index dd024836a0e..a5fa5e112f6 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1155,6 +1155,12 @@ ast_declarator_list::hir(exec_list *instructions, * vectors. Vertex shader inputs can also form arrays of these * types, but not structures." * + * From page 31 (page 27 of the PDF) of the GLSL 1.30 spec: + * + * "Vertex shader inputs can only be float, floating-point + * vectors, matrices, signed and unsigned integers and integer + * vectors. They cannot be arrays or structures." + * * From page 23 (page 29 of the PDF) of the GLSL 1.20 spec: * * "The attribute qualifier can be used only with float, @@ -1181,7 +1187,7 @@ ast_declarator_list::hir(exec_list *instructions, error_emitted = true; } - if (!error_emitted && (state->language_version <= 120) + if (!error_emitted && (state->language_version <= 130) && var->type->is_array()) { _mesa_glsl_error(& loc, state, "vertex shader input / attribute cannot have " diff --git a/tests/attribute-11.glsl b/tests/attribute-11.glsl index c1e69014314..47cb5a05833 100644 --- a/tests/attribute-11.glsl +++ b/tests/attribute-11.glsl @@ -1,5 +1,5 @@ #version 130 -/* PASS */ +/* FAIL - attribute cannot have array type in GLSL 1.30 */ attribute vec4 i[10]; void main() -- cgit v1.2.3 From 84960f01cb0edb79ec86d120b7dab7f254373940 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 30 Mar 2010 16:56:22 -0700 Subject: Add some array declaration tests --- tests/array-01.glsl | 3 +++ tests/array-02.glsl | 3 +++ tests/array-03.glsl | 3 +++ tests/array-04.glsl | 2 ++ tests/array-05.glsl | 2 ++ tests/array-06.glsl | 2 ++ tests/array-07.glsl | 2 ++ tests/array-08.glsl | 2 ++ 8 files changed, 19 insertions(+) create mode 100644 tests/array-01.glsl create mode 100644 tests/array-02.glsl create mode 100644 tests/array-03.glsl create mode 100644 tests/array-04.glsl create mode 100644 tests/array-05.glsl create mode 100644 tests/array-06.glsl create mode 100644 tests/array-07.glsl create mode 100644 tests/array-08.glsl diff --git a/tests/array-01.glsl b/tests/array-01.glsl new file mode 100644 index 00000000000..d14135fb3a8 --- /dev/null +++ b/tests/array-01.glsl @@ -0,0 +1,3 @@ +#version 120 +/* FAIL - array size type must be int */ +uniform vec4 [3.2] a; diff --git a/tests/array-02.glsl b/tests/array-02.glsl new file mode 100644 index 00000000000..d743617158d --- /dev/null +++ b/tests/array-02.glsl @@ -0,0 +1,3 @@ +#version 120 +/* FAIL - array size type must be scalar */ +uniform vec4 [ivec4(3)] a; diff --git a/tests/array-03.glsl b/tests/array-03.glsl new file mode 100644 index 00000000000..0026913f019 --- /dev/null +++ b/tests/array-03.glsl @@ -0,0 +1,3 @@ +#version 120 +/* PASS */ +uniform vec4 [3] a; diff --git a/tests/array-04.glsl b/tests/array-04.glsl new file mode 100644 index 00000000000..70f434d8ab6 --- /dev/null +++ b/tests/array-04.glsl @@ -0,0 +1,2 @@ +/* FAIL - array size type must be int */ +uniform vec4 a[3.2]; diff --git a/tests/array-05.glsl b/tests/array-05.glsl new file mode 100644 index 00000000000..168704096b0 --- /dev/null +++ b/tests/array-05.glsl @@ -0,0 +1,2 @@ +/* FAIL - array size type must be scalar */ +uniform vec4 a[ivec4(3)]; diff --git a/tests/array-06.glsl b/tests/array-06.glsl new file mode 100644 index 00000000000..46b43795be1 --- /dev/null +++ b/tests/array-06.glsl @@ -0,0 +1,2 @@ +/* PASS */ +uniform vec4 a[3]; diff --git a/tests/array-07.glsl b/tests/array-07.glsl new file mode 100644 index 00000000000..161ffbf2f2e --- /dev/null +++ b/tests/array-07.glsl @@ -0,0 +1,2 @@ +/* FAIL - array size must be > 0 */ +uniform vec4 a[0]; diff --git a/tests/array-08.glsl b/tests/array-08.glsl new file mode 100644 index 00000000000..4bf0c6bd513 --- /dev/null +++ b/tests/array-08.glsl @@ -0,0 +1,2 @@ +/* FAIL - array size must be > 0 */ +uniform vec4 a[-1]; -- cgit v1.2.3 From 1cf43a4331dfe62aaa834e5bc6319b43eac98445 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 30 Mar 2010 16:56:50 -0700 Subject: Initial bits of constant expression evaluator Currently only works for constants. The rest will be added later. --- Makefile.am | 3 +- ir.h | 1 + ir_constant_expression.cpp | 191 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 ir_constant_expression.cpp diff --git a/Makefile.am b/Makefile.am index 9f5efa9e5d4..c1c96ba2b90 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,7 +27,8 @@ glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \ ir.cpp hir_field_selection.cpp builtin_function.cpp \ - ir_print_visitor.cpp ir_variable.cpp ir_function.cpp + ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \ + ir_constant_expression.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/ir.h b/ir.h index 83e4f95b0cc..aa3e03a2111 100644 --- a/ir.h +++ b/ir.h @@ -40,6 +40,7 @@ class ir_instruction : public exec_node { public: const struct glsl_type *type; + class ir_constant *constant_expression_value(); virtual void accept(ir_visitor *) = 0; /** diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp new file mode 100644 index 00000000000..b8a9031fba1 --- /dev/null +++ b/ir_constant_expression.cpp @@ -0,0 +1,191 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_constant_expression.cpp + * Evaluate and process constant valued expressions + * + * In GLSL, constant valued expressions are used in several places. These + * must be processed and evaluated very early in the compilation process. + * + * * Sizes of arrays + * * Initializers for uniforms + * * Initializers for \c const variables + */ + +#define NULL 0 +#include "ir.h" +#include "ir_visitor.h" + +/** + * Visitor class for evaluating constant expressions + */ +class ir_constant_visitor : public ir_visitor { +public: + ir_constant_visitor() + : value(NULL) + { + /* empty */ + } + + virtual ~ir_constant_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_label *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ + + /** + * Value of the constant expression. + * + * \note + * This field will be \c NULL if the expression is not constant valued. + */ + /* FINIHSME: This cannot hold values for constant arrays or structures. */ + ir_constant *value; +}; + + +ir_constant * +ir_instruction::constant_expression_value() +{ + ir_constant_visitor visitor; + + this->accept(& visitor); + return visitor.value; +} + + +void +ir_constant_visitor::visit(ir_variable *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_label *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_function_signature *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_function *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_expression *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_swizzle *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_dereference *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_assignment *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_constant *ir) +{ + value = ir; +} + + +void +ir_constant_visitor::visit(ir_call *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_return *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_if *ir) +{ + (void) ir; + value = NULL; +} -- cgit v1.2.3 From 066304679cdd8bad6bca7fb815087559cda75aaf Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 30 Mar 2010 16:57:29 -0700 Subject: Add proper wrappers so that C++ code can use hash_table type --- hash_table.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hash_table.h b/hash_table.h index 7b302f5dbee..b9dd343dee9 100644 --- a/hash_table.h +++ b/hash_table.h @@ -31,6 +31,10 @@ #ifndef HASH_TABLE_H #define HASH_TABLE_H +#ifdef __cplusplus +extern "C" { +#endif + #include struct hash_table; @@ -114,4 +118,8 @@ extern unsigned hash_table_string_hash(const void *key); */ #define hash_table_string_compare ((hash_compare_func_t) strcmp) +#ifdef __cplusplus +}; +#endif + #endif /* HASH_TABLE_H */ -- cgit v1.2.3 From 548a1b5ab7304037a7cac8e6d647fb6b5ccbaf5d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 30 Mar 2010 16:58:19 -0700 Subject: Implement array type handling Since all glsl_type objects are flyweights, support is added to track all known array types. This accounts for most of the changes. --- glsl_types.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ glsl_types.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/glsl_types.cpp b/glsl_types.cpp index df9667f8dce..8d11196e93d 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -26,8 +26,11 @@ #include "glsl_parser_extras.h" #include "glsl_types.h" #include "builtin_types.h" +#include "hash_table.h" +hash_table *glsl_type::array_types = NULL; + static void add_types_to_symbol_table(glsl_symbol_table *symtab, const struct glsl_type *types, @@ -542,3 +545,49 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) assert(!"Should not get here."); return error_type; } + + +int +glsl_type::array_key_compare(const void *a, const void *b) +{ + const array_hash_key *const key1 = (array_hash_key *) a; + const array_hash_key *const key2 = (array_hash_key *) b; + + return ((key1->type == key2->type) && (key1->size == key2->size)) ? 0 : 1; +} + + +unsigned +glsl_type::array_key_hash(const void *a) +{ + char buf[sizeof(array_hash_key) + 1]; + + memcpy(buf, a, sizeof(array_hash_key)); + buf[sizeof(array_hash_key)] = '\0'; + + return hash_table_string_hash(buf); +} + + +const glsl_type * +glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) +{ + array_hash_key key = { base, array_size }; + + if (array_types == NULL) { + array_types = hash_table_ctor(64, array_key_hash, array_key_compare); + } + + const glsl_type *t = (glsl_type *) hash_table_find(array_types, & key); + if (t == NULL) { + t = new glsl_type(base, array_size); + + hash_table_insert(array_types, (void *) t, & key); + } + + assert(t->base_type == GLSL_TYPE_ARRAY); + assert(t->length == array_size); + assert(t->fields.array == base); + + return t; +} diff --git a/glsl_types.h b/glsl_types.h index bb2d6f697b6..6f3b512f288 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -169,6 +169,12 @@ struct glsl_type { static const glsl_type *get_instance(unsigned base_type, unsigned rows, unsigned columns); + /** + * Get the instance of an array type + */ + static const glsl_type *get_array_instance(const glsl_type *base, + unsigned elements); + /** * Query the total number of scalars that make up a scalar, vector or matrix */ @@ -300,6 +306,20 @@ struct glsl_type { } private: + /** + * Constructor for array types + */ + glsl_type(const glsl_type *array, unsigned length) : + base_type(GLSL_TYPE_ARRAY), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(0), matrix_columns(0), + name(NULL), length(length) + { + this->fields.array = array; + this->name = ""; + } + /** * \name Pointers to various private type singletons */ @@ -314,6 +334,18 @@ private: static const glsl_type *const mat4x3_type; static const glsl_type *const mat4_type; /*@}*/ + + /** Hash table containing the known array types. */ + static struct hash_table *array_types; + + /** Structure defining the key type used for array_types hash table. */ + struct array_hash_key { + const glsl_type *type; + unsigned size; + }; + + static int array_key_compare(const void *a, const void *b); + static unsigned array_key_hash(const void *key); }; struct glsl_struct_field { -- cgit v1.2.3 From 28009cd75cd3328774bd80a5b87a255ac881a710 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 30 Mar 2010 16:59:27 -0700 Subject: Begin handling array declarations This causes the following tests to pass: glslparsertest/shaders/array4.frag glslparsertest/shaders/array5.frag This causes the following tests to fail. These shaders were previously failing to compile, but they were all failing for the wrong reasons. glslparsertest/shaders/array3.frag --- ast_to_hir.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index a5fa5e112f6..23021bf04cf 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -994,12 +994,55 @@ ast_compound_statement::hir(exec_list *instructions, } +static const glsl_type * +process_array_type(const glsl_type *base, ast_node *array_size, + struct _mesa_glsl_parse_state *state) +{ + unsigned length = 0; + + /* FINISHME: Reject delcarations of multidimensional arrays. */ + + if (array_size != NULL) { + exec_list dummy_instructions; + ir_rvalue *const ir = array_size->hir(& dummy_instructions, state); + YYLTYPE loc = array_size->get_location(); + + /* FINISHME: Verify that the grammar forbids side-effects in array + * FINISHME: sizes. i.e., 'vec4 [x = 12] data' + */ + assert(dummy_instructions.is_empty()); + + if (ir != NULL) { + if (!ir->type->is_integer()) { + _mesa_glsl_error(& loc, state, "array size must be integer type"); + } else if (!ir->type->is_scalar()) { + _mesa_glsl_error(& loc, state, "array size must be scalar type"); + } else { + ir_constant *const size = ir->constant_expression_value(); + + if (size == NULL) { + _mesa_glsl_error(& loc, state, "array size must be a " + "constant valued expression"); + } else if (size->value.i[0] <= 0) { + _mesa_glsl_error(& loc, state, "array size must be > 0"); + } else { + assert(size->type == ir->type); + length = size->value.u[0]; + } + } + } + } + + return glsl_type::get_array_instance(base, length); +} + + static const struct glsl_type * type_specifier_to_glsl_type(const struct ast_type_specifier *spec, const char **name, struct _mesa_glsl_parse_state *state) { - struct glsl_type *type; + const glsl_type *type; if (spec->type_specifier == ast_struct) { /* FINISHME: Handle annonymous structures. */ @@ -1008,9 +1051,9 @@ type_specifier_to_glsl_type(const struct ast_type_specifier *spec, type = state->symbols->get_type(spec->type_name); *name = spec->type_name; - /* FINISHME: Handle array declarations. Note that this requires complete - * FINISHME: handling of constant expressions. - */ + if (spec->is_array) { + type = process_array_type(type, spec->array_size, state); + } } return type; @@ -1103,12 +1146,7 @@ ast_declarator_list::hir(exec_list *instructions, } if (decl->is_array) { - /* FINISHME: Handle array declarations. Note that this requires - * FINISHME: complete handling of constant expressions. - */ - var_type = glsl_type::error_type; - - /* FINISHME: Reject delcarations of multidimensional arrays. */ + var_type = process_array_type(decl_type, decl->array_size, state); } else { var_type = decl_type; } -- cgit v1.2.3 From a80cbd6d82f6ec4c1d16129581d5fa893a6ba94f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 30 Mar 2010 17:04:48 -0700 Subject: Forbid array comparisons in GLSL 1.10 This causes the following tests to pass: glslparsertest/shaders/array3.frag --- ast_to_hir.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 23021bf04cf..e037af7137b 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -666,6 +666,11 @@ ast_expression::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "operands of `%s' must have the same " "type", (this->oper == ast_equal) ? "==" : "!="); error_emitted = true; + } else if ((state->language_version <= 110) + && (op[0]->type->is_array() || op[1]->type->is_array())) { + _mesa_glsl_error(& loc, state, "array comparisons forbidden in " + "GLSL 1.10"); + error_emitted = true; } result = new ir_expression(operations[this->oper], glsl_type::bool_type, -- cgit v1.2.3 From 794ea61006142b794ccd277af9ac044aa63d6fcb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 30 Mar 2010 18:31:32 -1000 Subject: Fix unused variable warning. --- ast_to_hir.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index e037af7137b..5162acea4ed 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1582,7 +1582,6 @@ ast_selection_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { ir_rvalue *const condition = this->condition->hir(instructions, state); - struct simple_node *ptr; /* From page 66 (page 72 of the PDF) of the GLSL 1.50 spec: * -- cgit v1.2.3 From ab79d4ec6e7c5639084f71f93857f39239e8b848 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 30 Mar 2010 23:23:16 -1000 Subject: Test that a void function doesn't return a value. Fixes function1.frag. --- ast_to_hir.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 5162acea4ed..fbadd403188 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1549,9 +1549,16 @@ ast_jump_statement::hir(exec_list *instructions, ir_return *inst; if (opt_return_value) { - /* FINISHME: Make sure the enclosing function has a non-void return - * FINISHME: type. - */ + assert(state->current_function); + if (state->current_function->return_type->base_type == + GLSL_TYPE_VOID) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`return` with a value, in function `%s' " + "returning void", + state->current_function->definition->label); + } ir_expression *const ret = (ir_expression *) opt_return_value->hir(instructions, state); -- cgit v1.2.3 From aad7c7793788f34e98fb7264dc2219fc73002877 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 30 Mar 2010 23:28:20 -1000 Subject: Test that a non-void function returns a value. --- ast_to_hir.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index fbadd403188..1f81a943279 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1547,9 +1547,9 @@ ast_jump_statement::hir(exec_list *instructions, if (mode == ast_return) { ir_return *inst; + assert(state->current_function); if (opt_return_value) { - assert(state->current_function); if (state->current_function->return_type->base_type == GLSL_TYPE_VOID) { YYLTYPE loc = this->get_location(); @@ -1570,8 +1570,15 @@ ast_jump_statement::hir(exec_list *instructions, inst = new ir_return(ret); } else { - /* FINISHME: Make sure the enclosing function has a void return type. - */ + if (state->current_function->return_type->base_type != + GLSL_TYPE_VOID) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`return' with no value, in function %s returning " + "non-void", + state->current_function->definition->label); + } inst = new ir_return; } -- cgit v1.2.3 From 174cc03edcd6861ba416cc1afb19d4d43933ac84 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 30 Mar 2010 23:37:51 -1000 Subject: Test that main doesn't take any parameters. Fixes main2.vert. --- ast_to_hir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1f81a943279..a0fe37b5485 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1462,6 +1462,12 @@ ast_function_definition::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "main() must return void"); } + + if (!parameters.is_empty()) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "main() must not take any parameters"); + } } /* Finish storing the information about this new function in its signature. -- cgit v1.2.3 From b98020770730bd4a7e9bd5c2e4ab2ae8c1eb0376 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 30 Mar 2010 23:40:14 -1000 Subject: Test that discard only appears in the fragment shader. Fixes fragmentOnly4.vert. --- ast_to_hir.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index a0fe37b5485..f66c0298085 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1591,6 +1591,16 @@ ast_jump_statement::hir(exec_list *instructions, instructions->push_tail(inst); } + if (mode == ast_discard) { + /* FINISHME: discard support */ + if (state->target != fragment_shader) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`discard' may only appear in a fragment shader"); + } + } + /* Jump instructions do not have r-values. */ return NULL; -- cgit v1.2.3 From b97ee2e260efb68849ee13402072b7d7185746d5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 08:20:58 -1000 Subject: Test that variable names don't use the reserved gl_ prefix. Fixes identifier2.frag. --- ast_to_hir.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index f66c0298085..708656a6fce 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1177,6 +1177,21 @@ ast_declarator_list::hir(exec_list *instructions, continue; } + /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec, + * + * "Identifiers starting with "gl_" are reserved for use by + * OpenGL, and may not be declared in a shader as either a + * variable or a function." + */ + if (strncmp(decl->identifier, "gl_", 3) == 0) { + /* FINISHME: This should only trigger if we're not redefining + * FINISHME: a builtin (to add a qualifier, for example). + */ + _mesa_glsl_error(& loc, state, + "identifier `%s' uses reserved `gl_' prefix", + decl->identifier); + } + instructions->push_tail(var); if (this->type->qualifier.attribute -- cgit v1.2.3 From b82c0c31aea2d02721f162b94b9f591242d9364e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 09:11:39 -1000 Subject: Implement logical operators. Fixes parser9.frag. --- ast_to_hir.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 708656a6fce..1ebcf45e701 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -691,7 +691,25 @@ ast_expression::hir(exec_list *instructions, case ast_logic_xor: case ast_logic_or: case ast_logic_not: - /* FINISHME: Implement logical operators. */ + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[0]->get_location(); + + _mesa_glsl_error(& loc, state, "LHS of `%s' must be scalar boolean", + operator_string(this->oper)); + } + + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[1]->get_location(); + + _mesa_glsl_error(& loc, state, "RHS of `%s' must be scalar boolean", + operator_string(this->oper)); + } + + result = new ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], op[1]); break; case ast_mul_assign: -- cgit v1.2.3 From e1c1a3f3bd139da47a1184a8c69af6239973a90c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 12:26:03 -0700 Subject: Slightly refector checks for declarations that must be at global scope --- ast_to_hir.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1ebcf45e701..7525461272d 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1176,11 +1176,6 @@ ast_declarator_list::hir(exec_list *instructions, var = new ir_variable(var_type, decl->identifier); - /* FINISHME: Variables that are attribute, uniform, varying, in, or - * FINISHME: out varibles must be declared either at global scope or - * FINISHME: in a parameter list (in and out only). - */ - apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc); @@ -1212,15 +1207,18 @@ ast_declarator_list::hir(exec_list *instructions, instructions->push_tail(var); - if (this->type->qualifier.attribute - && (state->current_function != NULL)) { - _mesa_glsl_error(& loc, state, - "attribute variable `%s' must be declared at global " - "scope", - var->name); - } - - if ((var->mode == ir_var_in) && (state->current_function == NULL)) { + if (state->current_function != NULL) { + /* FINISHME: Variables that are uniform, varying, in, or + * FINISHME: out varibles must be declared either at global scope or + * FINISHME: in a parameter list (in and out only). + */ + if (this->type->qualifier.attribute) { + _mesa_glsl_error(& loc, state, + "attribute variable `%s' must be declared at " + "global scope", + var->name); + } + } else if (var->mode == ir_var_in) { if (state->target == vertex_shader) { bool error_emitted = false; -- cgit v1.2.3 From b168e53452592ce7364a3ce46a6d30c5b746fc3b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 12:31:18 -0700 Subject: Require that 'uniform' and 'varying' variables be declared at global scope This causes the following tests to pass: glslparsertest/shaders/uniform.frag glslparsertest/shaders/varying.frag --- ast_to_hir.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 7525461272d..874c11a0a8b 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1208,13 +1208,22 @@ ast_declarator_list::hir(exec_list *instructions, instructions->push_tail(var); if (state->current_function != NULL) { - /* FINISHME: Variables that are uniform, varying, in, or - * FINISHME: out varibles must be declared either at global scope or - * FINISHME: in a parameter list (in and out only). + const char *mode = NULL; + + /* FINISHME: Variables that are in or out must be declared either at + * FINISHME: global scope or FINISHME: in a parameter list. */ if (this->type->qualifier.attribute) { + mode = "attribute"; + } else if (this->type->qualifier.uniform) { + mode = "uniform"; + } else if (this->type->qualifier.varying) { + mode = "varying"; + } + + if (mode) { _mesa_glsl_error(& loc, state, - "attribute variable `%s' must be declared at " + "%s variable `%s' must be declared at " "global scope", var->name); } -- cgit v1.2.3 From d8065d86e8416c207b9a574ee45bf89b7d7b8eb2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 13:03:56 -0700 Subject: Fix comment bug and printf bug in previous commit --- ast_to_hir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 874c11a0a8b..06d7d6273cf 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1211,7 +1211,7 @@ ast_declarator_list::hir(exec_list *instructions, const char *mode = NULL; /* FINISHME: Variables that are in or out must be declared either at - * FINISHME: global scope or FINISHME: in a parameter list. + * FINISHME: global scope or in a parameter list. */ if (this->type->qualifier.attribute) { mode = "attribute"; @@ -1225,7 +1225,7 @@ ast_declarator_list::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "%s variable `%s' must be declared at " "global scope", - var->name); + mode, var->name); } } else if (var->mode == ir_var_in) { if (state->target == vertex_shader) { -- cgit v1.2.3 From d8a2133887576daf7bc87fe05efdf31e7b5dca28 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 13:13:12 -0700 Subject: Add some variable declaration qualifier tests --- tests/qualifier-01.glsl | 3 +++ tests/qualifier-02.glsl | 2 ++ tests/qualifier-03.glsl | 2 ++ tests/qualifier-04.glsl | 3 +++ tests/qualifier-05.glsl | 3 +++ tests/qualifier-06.glsl | 7 +++++++ tests/qualifier-07.glsl | 7 +++++++ 7 files changed, 27 insertions(+) create mode 100644 tests/qualifier-01.glsl create mode 100644 tests/qualifier-02.glsl create mode 100644 tests/qualifier-03.glsl create mode 100644 tests/qualifier-04.glsl create mode 100644 tests/qualifier-05.glsl create mode 100644 tests/qualifier-06.glsl create mode 100644 tests/qualifier-07.glsl diff --git a/tests/qualifier-01.glsl b/tests/qualifier-01.glsl new file mode 100644 index 00000000000..54ec3572a24 --- /dev/null +++ b/tests/qualifier-01.glsl @@ -0,0 +1,3 @@ +#version 130 +/* FAIL - inout only allowed in parameter list */ +inout vec4 foo; diff --git a/tests/qualifier-02.glsl b/tests/qualifier-02.glsl new file mode 100644 index 00000000000..b635d52aa2a --- /dev/null +++ b/tests/qualifier-02.glsl @@ -0,0 +1,2 @@ +/* FAIL - in only allowed in parameter list in GLSL 1.10 */ +in foo; diff --git a/tests/qualifier-03.glsl b/tests/qualifier-03.glsl new file mode 100644 index 00000000000..7e448034a7c --- /dev/null +++ b/tests/qualifier-03.glsl @@ -0,0 +1,2 @@ +/* FAIL - out only allowed in parameter list in GLSL 1.10 */ +out vec4 foo; diff --git a/tests/qualifier-04.glsl b/tests/qualifier-04.glsl new file mode 100644 index 00000000000..d03cafc1db2 --- /dev/null +++ b/tests/qualifier-04.glsl @@ -0,0 +1,3 @@ +#version 130 +/* PASS */ +in vec4 foo; diff --git a/tests/qualifier-05.glsl b/tests/qualifier-05.glsl new file mode 100644 index 00000000000..15281f33840 --- /dev/null +++ b/tests/qualifier-05.glsl @@ -0,0 +1,3 @@ +#version 130 +/* PASS */ +out vec4 foo; diff --git a/tests/qualifier-06.glsl b/tests/qualifier-06.glsl new file mode 100644 index 00000000000..1907a087c8e --- /dev/null +++ b/tests/qualifier-06.glsl @@ -0,0 +1,7 @@ +/* FAIL - in only allowed in parameter list in GLSL 1.10 */ +void main() +{ + in vec4 foo; + + gl_Position = gl_Vertex; +} diff --git a/tests/qualifier-07.glsl b/tests/qualifier-07.glsl new file mode 100644 index 00000000000..12568a57dbc --- /dev/null +++ b/tests/qualifier-07.glsl @@ -0,0 +1,7 @@ +/* FAIL - out only allowed in parameter list in GLSL 1.10 */ +void main() +{ + out vec4 foo; + + gl_Position = gl_Vertex; +} -- cgit v1.2.3 From a705d65ccd1e204cc0b667df2678cc6921cbd9f5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 13:14:37 -0700 Subject: Add 'in' to some parameters of the function This goes along with the qualifier-?? tests. --- tests/function-03.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/function-03.glsl b/tests/function-03.glsl index 6f6562ea858..b0da42f8e96 100644 --- a/tests/function-03.glsl +++ b/tests/function-03.glsl @@ -1,6 +1,6 @@ /* PASS */ -vec4 foo(float x, float y, float z, float w) +vec4 foo(in float x, in float y, float z, float w) { vec4 v; v.x = x; -- cgit v1.2.3 From e0800062daf237a9e4f893bc3db473da8f7472c0 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 13:15:23 -0700 Subject: Reject declarations with 'in' or 'out' qualifiers 'in' and 'out' can only be used in function parameter lists or at global scope (1.30 and later). This change enforces this. --- ast_to_hir.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 06d7d6273cf..375955d0332 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1209,9 +1209,10 @@ ast_declarator_list::hir(exec_list *instructions, if (state->current_function != NULL) { const char *mode = NULL; + const char *extra = ""; - /* FINISHME: Variables that are in or out must be declared either at - * FINISHME: global scope or in a parameter list. + /* There is no need to check for 'inout' here because the parser will + * only allow that in function parameter lists. */ if (this->type->qualifier.attribute) { mode = "attribute"; @@ -1219,13 +1220,19 @@ ast_declarator_list::hir(exec_list *instructions, mode = "uniform"; } else if (this->type->qualifier.varying) { mode = "varying"; + } else if (this->type->qualifier.in) { + mode = "in"; + extra = " or in function parameter list"; + } else if (this->type->qualifier.out) { + mode = "out"; + extra = " or in function parameter list"; } if (mode) { _mesa_glsl_error(& loc, state, "%s variable `%s' must be declared at " - "global scope", - mode, var->name); + "global scope%s", + mode, var->name, extra); } } else if (var->mode == ir_var_in) { if (state->target == vertex_shader) { -- cgit v1.2.3 From 0ed61257253fc0df1dde9042cb0e7fe22d58077a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 09:29:33 -1000 Subject: Test that const declarations include initializers. Fixes dataType6.frag, and also array2.frag for an unexpected but valid reason. --- ast_to_hir.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 375955d0332..c9aa91e7f0f 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1329,6 +1329,17 @@ ast_declarator_list::hir(exec_list *instructions, } } + /* From page 23 (page 29 of the PDF) of the GLSL 1.10 spec: + * + * "It is an error to write to a const variable outside of + * its declaration, so they must be initialized when + * declared." + */ + if (this->type->qualifier.constant && decl->initializer == NULL) { + _mesa_glsl_error(& loc, state, + "const declaration of `%s' must be initialized"); + } + /* Add the vairable to the symbol table after processing the initializer. * This differs from most C-like languages, but it follows the GLSL * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 -- cgit v1.2.3 From 0bf381016524ac58f5961877ea0e8651c4922ca3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 14:37:42 -0700 Subject: glsl_type array constructor generate a real name for the type --- glsl_types.cpp | 26 ++++++++++++++++++++++++++ glsl_types.h | 12 ++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/glsl_types.cpp b/glsl_types.cpp index 8d11196e93d..eb9ab820b16 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -21,6 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ +#include #include #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" @@ -489,6 +490,31 @@ _mesa_glsl_initialize_constructors(exec_list *instructions, } +glsl_type::glsl_type(const glsl_type *array, unsigned length) : + base_type(GLSL_TYPE_ARRAY), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(0), matrix_columns(0), + name(NULL), length(length) +{ + this->fields.array = array; + + /* Allow a maximum of 10 characters for the array size. This is enough + * for 32-bits of ~0. The extra 3 are for the '[', ']', and terminating + * NUL. + */ + const unsigned name_length = strlen(array->name) + 10 + 3; + char *const n = (char *) malloc(name_length); + + if (length == 0) + snprintf(n, name_length, "%s[]", array->name); + else + snprintf(n, name_length, "%s[%u]", array->name, length); + + this->name = n; +} + + const glsl_type * glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) { diff --git a/glsl_types.h b/glsl_types.h index 6f3b512f288..23a04fbe9d0 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -309,16 +309,8 @@ private: /** * Constructor for array types */ - glsl_type(const glsl_type *array, unsigned length) : - base_type(GLSL_TYPE_ARRAY), - sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), - sampler_type(0), - vector_elements(0), matrix_columns(0), - name(NULL), length(length) - { - this->fields.array = array; - this->name = ""; - } + glsl_type(const glsl_type *array, unsigned length); + /** * \name Pointers to various private type singletons -- cgit v1.2.3 From 299ed08a68d4f603bb72b7635bfa5c6f95776b22 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:13:38 -0700 Subject: Fix big dumbness in glsl_type::get_array_instance hash_table_insert needs to keep the key so that it compare keys on a following hash_table_find call. Since key was allocated on the stack, it disappeared out from under the hash table. --- glsl_types.cpp | 31 +++++++++++++++++++++---------- glsl_types.h | 6 ------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/glsl_types.cpp b/glsl_types.cpp index eb9ab820b16..7b8b3e90142 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -576,29 +576,40 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) int glsl_type::array_key_compare(const void *a, const void *b) { - const array_hash_key *const key1 = (array_hash_key *) a; - const array_hash_key *const key2 = (array_hash_key *) b; + const glsl_type *const key1 = (glsl_type *) a; + const glsl_type *const key2 = (glsl_type *) b; - return ((key1->type == key2->type) && (key1->size == key2->size)) ? 0 : 1; + /* Return zero is the types match (there is zero difference) or non-zero + * otherwise. + */ + return ((key1->fields.array == key2->fields.array) + && (key1->length == key2->length)) ? 0 : 1; } unsigned glsl_type::array_key_hash(const void *a) { - char buf[sizeof(array_hash_key) + 1]; - - memcpy(buf, a, sizeof(array_hash_key)); - buf[sizeof(array_hash_key)] = '\0'; + const glsl_type *const key = (glsl_type *) a; + + const struct { + const glsl_type *t; + unsigned l; + char nul; + } hash_key = { + key->fields.array, + key->length, + '\0' + }; - return hash_table_string_hash(buf); + return hash_table_string_hash(& hash_key); } const glsl_type * glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) { - array_hash_key key = { base, array_size }; + const glsl_type key(base, array_size); if (array_types == NULL) { array_types = hash_table_ctor(64, array_key_hash, array_key_compare); @@ -608,7 +619,7 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) if (t == NULL) { t = new glsl_type(base, array_size); - hash_table_insert(array_types, (void *) t, & key); + hash_table_insert(array_types, (void *) t, t); } assert(t->base_type == GLSL_TYPE_ARRAY); diff --git a/glsl_types.h b/glsl_types.h index 23a04fbe9d0..32035f5a443 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -330,12 +330,6 @@ private: /** Hash table containing the known array types. */ static struct hash_table *array_types; - /** Structure defining the key type used for array_types hash table. */ - struct array_hash_key { - const glsl_type *type; - unsigned size; - }; - static int array_key_compare(const void *a, const void *b); static unsigned array_key_hash(const void *key); }; -- cgit v1.2.3 From 615adcda8a27783bac52f25fac9850a75d792c84 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:16:54 -0700 Subject: More array declaration tests --- tests/array-09.glsl | 9 +++++++++ tests/array-10.glsl | 11 +++++++++++ tests/array-11.glsl | 9 +++++++++ tests/array-12.glsl | 11 +++++++++++ tests/array-13.glsl | 11 +++++++++++ 5 files changed, 51 insertions(+) create mode 100644 tests/array-09.glsl create mode 100644 tests/array-10.glsl create mode 100644 tests/array-11.glsl create mode 100644 tests/array-12.glsl create mode 100644 tests/array-13.glsl diff --git a/tests/array-09.glsl b/tests/array-09.glsl new file mode 100644 index 00000000000..cad6d0e54ec --- /dev/null +++ b/tests/array-09.glsl @@ -0,0 +1,9 @@ +#version 120 +/* PASS */ + +void main() +{ + vec4 a[2] = vec4 [2] (vec4(1.0), vec4(2.0)); + + gl_Position = gl_Vertex; +} diff --git a/tests/array-10.glsl b/tests/array-10.glsl new file mode 100644 index 00000000000..019aa21150f --- /dev/null +++ b/tests/array-10.glsl @@ -0,0 +1,11 @@ +/* FAIL - array constructors forbidden in GLSL 1.10 + * + * This can also generate an error because the 'vec4[]' style syntax is + * illegal in GLSL 1.10. + */ +void main() +{ + vec4 a[2] = vec4 [2] (vec4(1.0), vec4(2.0)); + + gl_Position = gl_Vertex; +} diff --git a/tests/array-11.glsl b/tests/array-11.glsl new file mode 100644 index 00000000000..51d94e94773 --- /dev/null +++ b/tests/array-11.glsl @@ -0,0 +1,9 @@ +#version 120 +/* PASS */ + +void main() +{ + vec4 a[] = vec4 [] (vec4(1.0), vec4(2.0)); + + gl_Position = gl_Vertex; +} diff --git a/tests/array-12.glsl b/tests/array-12.glsl new file mode 100644 index 00000000000..7fc9579452f --- /dev/null +++ b/tests/array-12.glsl @@ -0,0 +1,11 @@ +#version 120 +/* FAIL - array must have an implicit or explicit size */ + +void main() +{ + vec4 a[]; + + a = vec4 [2] (vec4(1.0), vec4(2.0)); + + gl_Position = gl_Vertex; +} diff --git a/tests/array-13.glsl b/tests/array-13.glsl new file mode 100644 index 00000000000..cc7e29a5f76 --- /dev/null +++ b/tests/array-13.glsl @@ -0,0 +1,11 @@ +#version 120 +/* PASS */ + +void main() +{ + vec4 a[2]; + + a = vec4 [] (vec4(1.0), vec4(2.0)); + + gl_Position = gl_Vertex; +} -- cgit v1.2.3 From d612a127ccf12c11204f7f72a332de12f58f85a2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:22:06 -0700 Subject: Move type_specifier_to_glsl_type to ast_type_specifier::glsl_type This make is easily accessible from other modules. --- ast.h | 4 ++++ ast_to_hir.cpp | 28 +++++++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ast.h b/ast.h index 8e904bccc97..d21be7e7a09 100644 --- a/ast.h +++ b/ast.h @@ -375,6 +375,10 @@ public: /* empty */ } + const struct glsl_type *glsl_type(const char **name, + struct _mesa_glsl_parse_state *state) + const; + virtual void print(void) const; enum ast_types type_specifier; diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index c9aa91e7f0f..5341dd59ce2 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1060,22 +1060,21 @@ process_array_type(const glsl_type *base, ast_node *array_size, } -static const struct glsl_type * -type_specifier_to_glsl_type(const struct ast_type_specifier *spec, - const char **name, - struct _mesa_glsl_parse_state *state) +const glsl_type * +ast_type_specifier::glsl_type(const char **name, + struct _mesa_glsl_parse_state *state) const { - const glsl_type *type; + const struct glsl_type *type; - if (spec->type_specifier == ast_struct) { + if (this->type_specifier == ast_struct) { /* FINISHME: Handle annonymous structures. */ type = NULL; } else { - type = state->symbols->get_type(spec->type_name); - *name = spec->type_name; + type = state->symbols->get_type(this->type_name); + *name = this->type_name; - if (spec->is_array) { - type = process_array_type(type, spec->array_size, state); + if (this->is_array) { + type = process_array_type(type, this->array_size, state); } } @@ -1142,8 +1141,7 @@ ast_declarator_list::hir(exec_list *instructions, * FINISHME: invariant. */ - decl_type = type_specifier_to_glsl_type(this->type->specifier, - & type_name, state); + decl_type = this->type->specifier->glsl_type(& type_name, state); foreach (ptr, &this->declarations) { struct ast_declaration *const decl = (struct ast_declaration * )ptr; @@ -1368,7 +1366,7 @@ ast_parameter_declarator::hir(exec_list *instructions, const char *name = NULL; YYLTYPE loc = this->get_location(); - type = type_specifier_to_glsl_type(this->type->specifier, & name, state); + type = this->type->specifier->glsl_type(& name, state); if (type == NULL) { if (name != NULL) { @@ -1465,8 +1463,8 @@ ast_function_definition::hir(exec_list *instructions, const char *return_type_name; const glsl_type *return_type = - type_specifier_to_glsl_type(this->prototype->return_type->specifier, - & return_type_name, state); + this->prototype->return_type->specifier->glsl_type(& return_type_name, + state); assert(return_type != NULL); -- cgit v1.2.3 From 3e0ef5f81b08a1496d952d3673b614497be9c75a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:22:56 -0700 Subject: Use ast_type_specifier::glsl_type to get the type of a constructor This is the first baby step towards getting array constructors working. --- ast_function.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 36bf0c9cc2d..f8c2b6eaa27 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -177,9 +177,9 @@ ast_function_expression::hir(exec_list *instructions, if (is_constructor()) { const ast_type_specifier *type = (ast_type_specifier *) subexpressions[0]; YYLTYPE loc = type->get_location(); + const char *name; - const glsl_type *const constructor_type = - state->symbols->get_type(type->type_name); + const glsl_type *const constructor_type = type->glsl_type(& name, state); /* Constructors for samplers are illegal. -- cgit v1.2.3 From b6326abb859550963446affe9123085fd57f9525 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:25:21 -0700 Subject: Reject array constructor calls in GLSL 1.10 --- ast_function.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ast_function.cpp b/ast_function.cpp index f8c2b6eaa27..74ae5d8962b 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -190,6 +190,15 @@ ast_function_expression::hir(exec_list *instructions, return ir_call::get_error_instruction(); } + if (constructor_type->is_array()) { + if (state->language_version <= 110) { + _mesa_glsl_error(& loc, state, + "array constructors forbidden in GLSL 1.10"); + return ir_call::get_error_instruction(); + } + + return ir_call::get_error_instruction(); + } /* There are two kinds of constructor call. Constructors for built-in * language types, such as mat4 and vec2, are free form. The only -- cgit v1.2.3 From 68515ee6c2a41cf5c0476b3309fcb050ef37b0d2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:28:51 -0700 Subject: Refactor parts of match_function_by_name into process_parameters and process_call These will be used in the functions that implement calls to array constructors. --- ast_function.cpp | 71 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 74ae5d8962b..340873ae418 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -27,23 +27,14 @@ #include "glsl_types.h" #include "ir.h" -static ir_rvalue * -match_function_by_name(exec_list *instructions, const char *name, - YYLTYPE *loc, simple_node *parameters, - struct _mesa_glsl_parse_state *state) +static unsigned +process_parameters(exec_list *instructions, exec_list *actual_parameters, + simple_node *parameters, + struct _mesa_glsl_parse_state *state) { - ir_function *f = state->symbols->get_function(name); - - if (f == NULL) { - _mesa_glsl_error(loc, state, "function `%s' undeclared", name); - return ir_call::get_error_instruction(); - } - - /* Once we've determined that the function being called might exist, - * process the parameters. - */ - exec_list actual_parameters; simple_node *const first = parameters; + unsigned count = 0; + if (first != NULL) { simple_node *ptr = first; do { @@ -51,20 +42,31 @@ match_function_by_name(exec_list *instructions, const char *name, ((ast_node *) ptr)->hir(instructions, state); ptr = ptr->next; - actual_parameters.push_tail(result); + actual_parameters->push_tail(result); + count++; } while (ptr != first); } - /* After processing the function's actual parameters, try to find an - * overload of the function that matches. - */ + return count; +} + + +static ir_rvalue * +process_call(exec_list *instructions, ir_function *f, + YYLTYPE *loc, exec_list *actual_parameters, + struct _mesa_glsl_parse_state *state) +{ const ir_function_signature *sig = - f->matching_signature(& actual_parameters); + f->matching_signature(actual_parameters); + + /* The instructions param will be used when the FINISHMEs below are done */ + (void) instructions; + if (sig != NULL) { /* FINISHME: The list of actual parameters needs to be modified to * FINISHME: include any necessary conversions. */ - return new ir_call(sig, & actual_parameters); + return new ir_call(sig, actual_parameters); } else { /* FINISHME: Log a better error message here. G++ will show the types * FINISHME: of the actual parameters and the set of candidate @@ -72,9 +74,34 @@ match_function_by_name(exec_list *instructions, const char *name, * FINISHME: multiple functions match. */ _mesa_glsl_error(loc, state, "no matching function for call to `%s'", - name); + f->name); + return ir_call::get_error_instruction(); + } +} + + +static ir_rvalue * +match_function_by_name(exec_list *instructions, const char *name, + YYLTYPE *loc, simple_node *parameters, + struct _mesa_glsl_parse_state *state) +{ + ir_function *f = state->symbols->get_function(name); + + if (f == NULL) { + _mesa_glsl_error(loc, state, "function `%s' undeclared", name); return ir_call::get_error_instruction(); } + + /* Once we've determined that the function being called might exist, + * process the parameters. + */ + exec_list actual_parameters; + process_parameters(instructions, &actual_parameters, parameters, state); + + /* After processing the function's actual parameters, try to find an + * overload of the function that matches. + */ + return process_call(instructions, f, loc, &actual_parameters, state); } -- cgit v1.2.3 From 4ef183e51de2b625b51cdd6c925760429801595e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:30:56 -0700 Subject: Add glsl_type::generate_constructor_prototype Generates a symbol table entry and the IR approximation of a prototype for a type's constructor. Currently only arrays are supported. --- glsl_types.cpp | 31 +++++++++++++++++++++++++++++++ glsl_types.h | 3 +++ 2 files changed, 34 insertions(+) diff --git a/glsl_types.cpp b/glsl_types.cpp index 7b8b3e90142..a38750e9bb1 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -115,6 +115,37 @@ const glsl_type *glsl_type::get_base_type() const } +ir_function * +glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const +{ + /* FINISHME: Add support for non-array types. */ + assert(base_type == GLSL_TYPE_ARRAY); + + /* Generate the function name and add it to the symbol table. + */ + ir_function *const f = new ir_function(name); + + bool added = symtab->add_function(name, f); + assert(added); + + ir_function_signature *const sig = new ir_function_signature(this); + f->signatures.push_tail(sig); + + for (unsigned i = 0; i < length; i++) { + char *const param_name = (char *) malloc(10); + + snprintf(param_name, 10, "p%08X", i); + + ir_variable *var = new ir_variable(fields.array, param_name); + + var->mode = ir_var_in; + sig->parameters.push_tail(var); + } + + return f; +} + + /** * Generate the function intro for a constructor * diff --git a/glsl_types.h b/glsl_types.h index 32035f5a443..6c9444cbe16 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -175,6 +175,9 @@ struct glsl_type { static const glsl_type *get_array_instance(const glsl_type *base, unsigned elements); + class ir_function *generate_constructor_prototype(class glsl_symbol_table *) + const; + /** * Query the total number of scalars that make up a scalar, vector or matrix */ -- cgit v1.2.3 From 6a15d5b514b703ff8dd024f96ffbcb68484a954e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:37:10 -0700 Subject: Use ir_function::add_signature to create link between function and signature ir_function_signature now has a pointer back to the ir_function that owns it. --- ast_to_hir.cpp | 2 +- builtin_function.cpp | 2 +- glsl_types.cpp | 8 ++++---- ir.h | 12 ++++++++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 5341dd59ce2..78c92822e30 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1530,7 +1530,7 @@ ast_function_definition::hir(exec_list *instructions, */ if (signature == NULL) { signature = new ir_function_signature(return_type); - f->signatures.push_tail(signature); + f->add_signature(signature); } else { /* Destroy all of the previous parameter information. The previous * parameter information comes from the function prototype, and it can diff --git a/builtin_function.cpp b/builtin_function.cpp index 8e7e1164b8c..684a10c8893 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -214,7 +214,7 @@ generate_function_instance(ir_function *f, ir_variable *declarations[17]; ir_function_signature *const sig = new ir_function_signature(type); - f->signatures.push_tail(sig); + f->add_signature(sig); ir_label *const label = new ir_label(name); instructions->push_tail(label); diff --git a/glsl_types.cpp b/glsl_types.cpp index a38750e9bb1..ba4f0297d81 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -129,7 +129,7 @@ glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const assert(added); ir_function_signature *const sig = new ir_function_signature(this); - f->signatures.push_tail(sig); + f->add_signature(sig); for (unsigned i = 0; i < length; i++) { char *const param_name = (char *) malloc(10); @@ -433,7 +433,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, * appropriate from-scalars constructor. */ ir_function_signature *const sig = new ir_function_signature(& types[i]); - f->signatures.push_tail(sig); + f->add_signature(sig); sig->definition = generate_constructor_intro(& types[i], 1, & sig->parameters, @@ -444,7 +444,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, ir_function_signature *const vec_sig = new ir_function_signature(& types[i]); - f->signatures.push_tail(vec_sig); + f->add_signature(vec_sig); vec_sig->definition = generate_constructor_intro(& types[i], types[i].vector_elements, @@ -458,7 +458,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, ir_function_signature *const mat_sig = new ir_function_signature(& types[i]); - f->signatures.push_tail(mat_sig); + f->add_signature(mat_sig); mat_sig->definition = generate_constructor_intro(& types[i], diff --git a/ir.h b/ir.h index aa3e03a2111..2d2da1df763 100644 --- a/ir.h +++ b/ir.h @@ -160,6 +160,12 @@ public: * Pointer to the label that begins the function definition. */ ir_label *definition; + +private: + /** Function of which this signature is one overload. */ + class ir_function *function; + + friend class ir_function; }; @@ -175,6 +181,12 @@ public: v->visit(this); } + void add_signature(ir_function_signature *sig) + { + sig->function = this; + signatures.push_tail(sig); + } + /** * Find a signature that matches a set of actual parameters. */ -- cgit v1.2.3 From 95cd6cc195f4652378d7ecf614c6e1c568311a04 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:40:26 -0700 Subject: Add ir_function::iterator to iterate over function signatures --- ast_to_hir.cpp | 2 +- ir.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 78c92822e30..e6031ae0046 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1475,7 +1475,7 @@ ast_function_definition::hir(exec_list *instructions, const char *const name = this->prototype->identifier; f = state->symbols->get_function(name); if (f != NULL) { - foreach_iter(exec_list_iterator, iter, f->signatures) { + foreach_iter(exec_list_iterator, iter, *f) { signature = (struct ir_function_signature *) iter.get(); /* Compare the parameter list of the function being defined to the diff --git a/ir.h b/ir.h index 2d2da1df763..3322ea96404 100644 --- a/ir.h +++ b/ir.h @@ -187,6 +187,14 @@ public: signatures.push_tail(sig); } + /** + * Get an iterator for the set of function signatures + */ + exec_list_iterator iterator() + { + return signatures.iterator(); + } + /** * Find a signature that matches a set of actual parameters. */ -- cgit v1.2.3 From a4775823b09f0ff77a46e8f35fba32234791a64c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:40:58 -0700 Subject: Make ir_function::signatures private --- ir.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ir.h b/ir.h index 3322ea96404..261d1924027 100644 --- a/ir.h +++ b/ir.h @@ -205,6 +205,7 @@ public: */ const char *name; +private: /** * Set of overloaded functions with this name. */ -- cgit v1.2.3 From 0f0ea5826454cf25d6e76ac848a317e673ff1032 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:44:12 -0700 Subject: Add ir_function_signature::function_name --- ir.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ir.h b/ir.h index 261d1924027..c3c5369bfc0 100644 --- a/ir.h +++ b/ir.h @@ -144,6 +144,11 @@ public: v->visit(this); } + /** + * Get the name of the function for which this is a signature + */ + const char *function_name() const; + /** * Function return type. * @@ -211,6 +216,11 @@ private: */ struct exec_list signatures; }; + +inline const char *ir_function_signature::function_name() const +{ + return function->name; +} /*@}*/ @@ -379,8 +389,7 @@ public: */ const char *callee_name() const { - /* FINISHME: This only works for functions that have definitions. */ - return callee->definition->label; + return callee->function_name(); } private: -- cgit v1.2.3 From 00aa173c9cbc1d6c50bcb5caf569558759ce26d8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 16:48:48 -0700 Subject: Generate array constructor calls --- ast_function.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/ast_function.cpp b/ast_function.cpp index 340873ae418..91d4f15a3b7 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -188,6 +188,77 @@ dereference_component(ir_rvalue *src, unsigned component) } +static ir_rvalue * +process_array_constructor(exec_list *instructions, + const glsl_type *constructor_type, + YYLTYPE *loc, simple_node *parameters, + struct _mesa_glsl_parse_state *state) +{ + /* Array constructors come in two forms: sized and unsized. Sized array + * constructors look like 'vec4[2](a, b)', where 'a' and 'b' are vec4 + * variables. In this case the number of parameters must exactly match the + * specified size of the array. + * + * Unsized array constructors look like 'vec4[](a, b)', where 'a' and 'b' + * are vec4 variables. In this case the size of the array being constructed + * is determined by the number of parameters. + * + * From page 52 (page 58 of the PDF) of the GLSL 1.50 spec: + * + * "There must be exactly the same number of arguments as the size of + * the array being constructed. If no size is present in the + * constructor, then the array is explicitly sized to the number of + * arguments provided. The arguments are assigned in order, starting at + * element 0, to the elements of the constructed array. Each argument + * must be the same type as the element type of the array, or be a type + * that can be converted to the element type of the array according to + * Section 4.1.10 "Implicit Conversions."" + */ + exec_list actual_parameters; + const unsigned parameter_count = + process_parameters(instructions, &actual_parameters, parameters, state); + + if ((parameter_count == 0) + || ((constructor_type->length != 0) + && (constructor_type->length != parameter_count))) { + const unsigned min_param = (constructor_type->length == 0) + ? 1 : constructor_type->length; + + _mesa_glsl_error(loc, state, "array constructor must have %s %u " + "parameter%s", + (constructor_type->length != 0) ? "at least" : "exactly", + min_param, (min_param <= 1) ? "" : "s"); + return ir_call::get_error_instruction(); + } + + if (constructor_type->length == 0) { + constructor_type = + glsl_type::get_array_instance(constructor_type->get_base_type(), + parameter_count); + assert(constructor_type != NULL); + assert(constructor_type->length == parameter_count); + } + + ir_function *f = state->symbols->get_function(constructor_type->name); + + /* If the constructor for this type of array does not exist, generate the + * prototype and add it to the symbol table. The code will be generated + * later. + */ + if (f == NULL) { + f = constructor_type->generate_constructor_prototype(state->symbols); + } + + ir_rvalue *const r = + process_call(instructions, f, loc, &actual_parameters, state); + + assert(r != NULL); + assert(r->type->is_error() || (r->type == constructor_type)); + + return r; +} + + ir_rvalue * ast_function_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -224,7 +295,8 @@ ast_function_expression::hir(exec_list *instructions, return ir_call::get_error_instruction(); } - return ir_call::get_error_instruction(); + return process_array_constructor(instructions, constructor_type, + & loc, subexpressions[1], state); } /* There are two kinds of constructor call. Constructors for built-in -- cgit v1.2.3 From 25711a85c22bed305c9b52b89feb9c600d1892df Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 17:39:10 -0700 Subject: Minor cleanups in ast_function_definition::hir --- ast_to_hir.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index e6031ae0046..627d9321821 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1513,7 +1513,7 @@ ast_function_definition::hir(exec_list *instructions, /* Verify the return type of main() */ if (strcmp(name, "main") == 0) { - if (return_type != glsl_type::get_instance(GLSL_TYPE_VOID, 0, 0)) { + if (! return_type->is_void()) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "main() must return void"); @@ -1551,7 +1551,6 @@ ast_function_definition::hir(exec_list *instructions, ast_function_parameters_to_hir(& this->prototype->parameters, & signature->parameters, state); - /* FINISHME: Set signature->return_type */ label = new ir_label(name); if (signature->definition == NULL) { @@ -1566,9 +1565,9 @@ ast_function_definition::hir(exec_list *instructions, */ state->symbols->push_scope(); foreach_iter(exec_list_iterator, iter, parameters) { - ir_variable *const var = (ir_variable *) iter.get(); + ir_variable *const var = ((ir_instruction *) iter.get())->as_variable(); - assert(((ir_instruction *) var)->as_variable() != NULL); + assert(var != NULL); iter.remove(); instructions->push_tail(var); -- cgit v1.2.3 From 2d394d4877794d19756c3760d711524dca89f772 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 17:52:44 -0700 Subject: Add ir_variable::clone --- ir.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ir.h b/ir.h index c3c5369bfc0..de6f09318ad 100644 --- a/ir.h +++ b/ir.h @@ -110,6 +110,26 @@ public: v->visit(this); } + /** + * Duplicate an IR variable + * + * \note + * This will probably be made \c virtual and moved to the base class + * eventually. + */ + ir_variable *clone() const + { + ir_variable *var = new ir_variable(type, name); + + var->read_only = this->read_only; + var->centroid = this->centroid; + var->invariant = this->invariant; + var->mode = this->mode; + var->interpolation = this->interpolation; + + return var; + } + const char *name; unsigned read_only:1; -- cgit v1.2.3 From e29a5859891eb9e1587396dea0e8010f7d88f68c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 17:54:26 -0700 Subject: Use ir_variable::clone to copy parameters to the function body Several other code movements were also done. This partitions this function into two halves. The first half processes the prototype part, and the second have processes the actual function definition. The coming patch series will parition ast_function_definition::hir into (at least) two separate functions. --- ast_to_hir.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 627d9321821..6d78383a46c 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1544,32 +1544,29 @@ ast_function_definition::hir(exec_list *instructions, } } + parameters.move_nodes_to(& signature->parameters); + assert(state->current_function == NULL); state->current_function = signature; - ast_function_parameters_to_hir(& this->prototype->parameters, - & signature->parameters, - state); - label = new ir_label(name); if (signature->definition == NULL) { signature->definition = label; } instructions->push_tail(label); - /* Add the function parameters to the symbol table. During this step the - * parameter declarations are also moved from the temporary "parameters" list - * to the instruction list. There are other more efficient ways to do this, - * but they involve ugly linked-list gymnastics. + /* Duplicate parameters declared in the prototype as concrete variables. + * Add these to the symbol table. */ state->symbols->push_scope(); - foreach_iter(exec_list_iterator, iter, parameters) { - ir_variable *const var = ((ir_instruction *) iter.get())->as_variable(); + foreach_iter(exec_list_iterator, iter, signature->parameters) { + ir_variable *const proto = ((ir_instruction *) iter.get())->as_variable(); + + assert(proto != NULL); - assert(var != NULL); + ir_variable *const var = proto->clone(); - iter.remove(); instructions->push_tail(var); /* The only way a parameter would "exist" is if two parameters have -- cgit v1.2.3 From acce380a3f6df56d44460c0b066b4791cc0f9732 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 18:15:50 -0700 Subject: Fix exec_list::move_nodes_to when the source list is empty --- list.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/list.h b/list.h index 33b038ce8da..054be7ed435 100644 --- a/list.h +++ b/list.h @@ -273,14 +273,18 @@ struct exec_list { */ void move_nodes_to(exec_list *target) { - target->head = head; - target->tail = NULL; - target->tail_pred = tail_pred; - - target->head->prev = (exec_node *) &target->head; - target->tail_pred->next = (exec_node *) &target->tail; - - make_empty(); + if (is_empty()) { + target->make_empty(); + } else { + target->head = head; + target->tail = NULL; + target->tail_pred = tail_pred; + + target->head->prev = (exec_node *) &target->head; + target->tail_pred->next = (exec_node *) &target->tail; + + make_empty(); + } } exec_list_iterator iterator() -- cgit v1.2.3 From 92318a947958892497722772b03c643ebc943294 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 31 Mar 2010 18:23:21 -0700 Subject: Add ast_function::hir ast_function::hir consists of bits pulled out of ast_function_definition::hir. In fact, the later uses the former to do a lot of its processing. Several class private data fields were added to ast_function to facilitate communicate between the two. This causes the following tests to pass: glslparsertest/shaders/CorrectModule.frag This causes the following tests to fail. These shaders were previously failing to compile, but they were all failing for the wrong reasons. glslparsertest/shaders/function9.frag glslparsertest/shaders/function10.frag --- ast.h | 26 ++++++++++++++++++++ ast_to_hir.cpp | 65 +++++++++++++++++++++++++++++++------------------- glsl_parser_extras.cpp | 1 + 3 files changed, 68 insertions(+), 24 deletions(-) diff --git a/ast.h b/ast.h index d21be7e7a09..80352590080 100644 --- a/ast.h +++ b/ast.h @@ -444,10 +444,36 @@ public: virtual void print(void) const; + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + ast_fully_specified_type *return_type; char *identifier; struct simple_node parameters; + +private: + /** + * Is this prototype part of the function definition? + * + * Used by ast_function_definition::hir to process the parameters, etc. + * of the function. + * + * \sa ::hir + */ + bool is_definition; + + /** + * Function signature corresponding to this function prototype instance + * + * Used by ast_function_definition::hir to process the parameters, etc. + * of the function. + * + * \sa ::hir + */ + class ir_function_signature *signature; + + friend class ast_function_definition; }; diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 6d78383a46c..2eecc9f3ec9 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1445,26 +1445,28 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) ir_rvalue * -ast_function_definition::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) +ast_function::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) { - ir_label *label; - ir_function_signature *signature = NULL; ir_function *f = NULL; - exec_list parameters; + ir_function_signature *sig = NULL; + exec_list hir_parameters; + /* The prototype part of a function does not generate anything in the IR + * instruction stream. + */ + (void) instructions; + /* Convert the list of function parameters to HIR now so that they can be * used below to compare this function's signature with previously seen * signatures for functions with the same name. */ - ast_function_parameters_to_hir(& this->prototype->parameters, & parameters, - state); + ast_function_parameters_to_hir(& this->parameters, & hir_parameters, state); const char *return_type_name; const glsl_type *return_type = - this->prototype->return_type->specifier->glsl_type(& return_type_name, - state); + this->return_type->specifier->glsl_type(& return_type_name, state); assert(return_type != NULL); @@ -1472,30 +1474,30 @@ ast_function_definition::hir(exec_list *instructions, * seen signature for a function with the same name, or, if a match is found, * that the previously seen signature does not have an associated definition. */ - const char *const name = this->prototype->identifier; + const char *const name = identifier; f = state->symbols->get_function(name); if (f != NULL) { foreach_iter(exec_list_iterator, iter, *f) { - signature = (struct ir_function_signature *) iter.get(); + sig = (struct ir_function_signature *) iter.get(); /* Compare the parameter list of the function being defined to the * existing function. If the parameter lists match, then the return * type must also match and the existing function must not have a * definition. */ - if (parameter_lists_match(& parameters, & signature->parameters)) { + if (parameter_lists_match(& hir_parameters, & sig->parameters)) { /* FINISHME: Compare return types. */ - if (signature->definition != NULL) { + if (is_definition && (sig->definition != NULL)) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "function `%s' redefined", name); - signature = NULL; + sig = NULL; break; } } - signature = NULL; + sig = NULL; } } else if (state->symbols->name_declared_this_scope(name)) { @@ -1505,7 +1507,7 @@ ast_function_definition::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "function name `%s' conflicts with " "non-function", name); - signature = NULL; + sig = NULL; } else { f = new ir_function(name); state->symbols->add_function(f->name, f); @@ -1519,7 +1521,7 @@ ast_function_definition::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "main() must return void"); } - if (!parameters.is_empty()) { + if (!hir_parameters.is_empty()) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "main() must not take any parameters"); @@ -1528,15 +1530,15 @@ ast_function_definition::hir(exec_list *instructions, /* Finish storing the information about this new function in its signature. */ - if (signature == NULL) { - signature = new ir_function_signature(return_type); - f->add_signature(signature); - } else { + if (sig == NULL) { + sig = new ir_function_signature(return_type); + f->add_signature(sig); + } else if (is_definition) { /* Destroy all of the previous parameter information. The previous * parameter information comes from the function prototype, and it can * either include invalid parameter names or may not have names at all. */ - foreach_iter(exec_list_iterator, iter, signature->parameters) { + foreach_iter(exec_list_iterator, iter, sig->parameters) { assert(((ir_instruction *) iter.get())->as_variable() != NULL); iter.remove(); @@ -1544,13 +1546,28 @@ ast_function_definition::hir(exec_list *instructions, } } - parameters.move_nodes_to(& signature->parameters); + hir_parameters.move_nodes_to(& sig->parameters); + signature = sig; + + /* Function declarations (prototypes) do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_function_definition::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + prototype->is_definition = true; + prototype->hir(instructions, state); + ir_function_signature *signature = prototype->signature; assert(state->current_function == NULL); state->current_function = signature; - label = new ir_label(name); + ir_label *label = new ir_label(signature->function_name()); if (signature->definition == NULL) { signature->definition = label; } diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 1ddc2ee9ddd..265782ebdab 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -327,6 +327,7 @@ ast_function::print(void) const ast_function::ast_function(void) + : is_definition(false), signature(NULL) { make_empty_list(& parameters); } -- cgit v1.2.3 From ebfdef7a83966341c27f44c83366419d4a2f7a60 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 31 Mar 2010 17:12:34 -0700 Subject: Set source locations on AST nodes so error messages print locations. I haven't verified that these are all correct, but it's still a lot better than not having anything. Signed-off-by: Kenneth Graunke --- ast.h | 8 ++--- glsl_parser.ypp | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 4 deletions(-) diff --git a/ast.h b/ast.h index 80352590080..f7cdf96d099 100644 --- a/ast.h +++ b/ast.h @@ -68,11 +68,11 @@ public: * * \sa ast_node::get_location */ - void set_location(const struct YYLTYPE *locp) + void set_location(const struct YYLTYPE &locp) { - this->location.source = locp->source; - this->location.line = locp->first_line; - this->location.column = locp->first_column; + this->location.source = locp.source; + this->location.line = locp.first_line; + this->location.column = locp.first_column; } diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 4a58666d763..b8c01b508d0 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -238,26 +238,31 @@ primary_expression: variable_identifier { $$ = new ast_expression(ast_identifier, NULL, NULL, NULL); + $$->set_location(yylloc); $$->primary_expression.identifier = $1; } | INTCONSTANT { $$ = new ast_expression(ast_int_constant, NULL, NULL, NULL); + $$->set_location(yylloc); $$->primary_expression.int_constant = $1; } | UINTCONSTANT { $$ = new ast_expression(ast_uint_constant, NULL, NULL, NULL); + $$->set_location(yylloc); $$->primary_expression.uint_constant = $1; } | FLOATCONSTANT { $$ = new ast_expression(ast_float_constant, NULL, NULL, NULL); + $$->set_location(yylloc); $$->primary_expression.float_constant = $1; } | BOOLCONSTANT { $$ = new ast_expression(ast_bool_constant, NULL, NULL, NULL); + $$->set_location(yylloc); $$->primary_expression.bool_constant = $1; } | '(' expression ')' @@ -271,6 +276,7 @@ postfix_expression: | postfix_expression '[' integer_expression ']' { $$ = new ast_expression(ast_array_index, $1, $3, NULL); + $$->set_location(yylloc); } | function_call { @@ -279,15 +285,18 @@ postfix_expression: | postfix_expression '.' IDENTIFIER { $$ = new ast_expression(ast_field_selection, $1, NULL, NULL); + $$->set_location(yylloc); $$->primary_expression.identifier = $3; } | postfix_expression INC_OP { $$ = new ast_expression(ast_post_inc, $1, NULL, NULL); + $$->set_location(yylloc); } | postfix_expression DEC_OP { $$ = new ast_expression(ast_post_dec, $1, NULL, NULL); + $$->set_location(yylloc); } ; @@ -304,6 +313,7 @@ function_call_or_method: | postfix_expression '.' function_call_generic { $$ = new ast_expression(ast_field_selection, $1, $3, NULL); + $$->set_location(yylloc); } ; @@ -321,11 +331,13 @@ function_call_header_with_parameters: function_call_header assignment_expression { $$ = $1; + $$->set_location(yylloc); $$->subexpressions[1] = $2; } | function_call_header_with_parameters ',' assignment_expression { $$ = $1; + $$->set_location(yylloc); insert_at_tail((struct simple_node *) $$->subexpressions[1], (struct simple_node *) $3); } @@ -342,16 +354,19 @@ function_identifier: type_specifier { $$ = new ast_function_expression($1); + $$->set_location(yylloc); } | IDENTIFIER { ast_expression *callee = new ast_expression($1); $$ = new ast_function_expression(callee); + $$->set_location(yylloc); } | FIELD_SELECTION { ast_expression *callee = new ast_expression($1); $$ = new ast_function_expression(callee); + $$->set_location(yylloc); } ; @@ -361,14 +376,17 @@ unary_expression: | INC_OP unary_expression { $$ = new ast_expression(ast_pre_inc, $2, NULL, NULL); + $$->set_location(yylloc); } | DEC_OP unary_expression { $$ = new ast_expression(ast_pre_dec, $2, NULL, NULL); + $$->set_location(yylloc); } | unary_operator unary_expression { $$ = new ast_expression($1, $2, NULL, NULL); + $$->set_location(yylloc); } ; @@ -385,14 +403,17 @@ multiplicative_expression: | multiplicative_expression '*' unary_expression { $$ = new ast_expression_bin(ast_mul, $1, $3); + $$->set_location(yylloc); } | multiplicative_expression '/' unary_expression { $$ = new ast_expression_bin(ast_div, $1, $3); + $$->set_location(yylloc); } | multiplicative_expression '%' unary_expression { $$ = new ast_expression_bin(ast_mod, $1, $3); + $$->set_location(yylloc); } ; @@ -401,10 +422,12 @@ additive_expression: | additive_expression '+' multiplicative_expression { $$ = new ast_expression_bin(ast_add, $1, $3); + $$->set_location(yylloc); } | additive_expression '-' multiplicative_expression { $$ = new ast_expression_bin(ast_sub, $1, $3); + $$->set_location(yylloc); } ; @@ -413,10 +436,12 @@ shift_expression: | shift_expression LEFT_OP additive_expression { $$ = new ast_expression_bin(ast_lshift, $1, $3); + $$->set_location(yylloc); } | shift_expression RIGHT_OP additive_expression { $$ = new ast_expression_bin(ast_rshift, $1, $3); + $$->set_location(yylloc); } ; @@ -425,18 +450,22 @@ relational_expression: | relational_expression '<' shift_expression { $$ = new ast_expression_bin(ast_less, $1, $3); + $$->set_location(yylloc); } | relational_expression '>' shift_expression { $$ = new ast_expression_bin(ast_greater, $1, $3); + $$->set_location(yylloc); } | relational_expression LE_OP shift_expression { $$ = new ast_expression_bin(ast_lequal, $1, $3); + $$->set_location(yylloc); } | relational_expression GE_OP shift_expression { $$ = new ast_expression_bin(ast_gequal, $1, $3); + $$->set_location(yylloc); } ; @@ -445,10 +474,12 @@ equality_expression: | equality_expression EQ_OP relational_expression { $$ = new ast_expression_bin(ast_equal, $1, $3); + $$->set_location(yylloc); } | equality_expression NE_OP relational_expression { $$ = new ast_expression_bin(ast_nequal, $1, $3); + $$->set_location(yylloc); } ; @@ -457,6 +488,7 @@ and_expression: | and_expression '&' equality_expression { $$ = new ast_expression_bin(ast_bit_or, $1, $3); + $$->set_location(yylloc); } ; @@ -465,6 +497,7 @@ exclusive_or_expression: | exclusive_or_expression '^' and_expression { $$ = new ast_expression_bin(ast_bit_xor, $1, $3); + $$->set_location(yylloc); } ; @@ -473,6 +506,7 @@ inclusive_or_expression: | inclusive_or_expression '|' exclusive_or_expression { $$ = new ast_expression_bin(ast_bit_or, $1, $3); + $$->set_location(yylloc); } ; @@ -481,6 +515,7 @@ logical_and_expression: | logical_and_expression AND_OP inclusive_or_expression { $$ = new ast_expression_bin(ast_logic_and, $1, $3); + $$->set_location(yylloc); } ; @@ -489,6 +524,7 @@ logical_xor_expression: | logical_xor_expression XOR_OP logical_and_expression { $$ = new ast_expression_bin(ast_logic_xor, $1, $3); + $$->set_location(yylloc); } ; @@ -497,6 +533,7 @@ logical_or_expression: | logical_or_expression OR_OP logical_xor_expression { $$ = new ast_expression_bin(ast_logic_or, $1, $3); + $$->set_location(yylloc); } ; @@ -505,6 +542,7 @@ conditional_expression: | logical_or_expression '?' expression ':' assignment_expression { $$ = new ast_expression(ast_conditional, $1, $3, $5); + $$->set_location(yylloc); } ; @@ -513,6 +551,7 @@ assignment_expression: | unary_expression assignment_operator assignment_expression { $$ = new ast_expression($2, $1, $3, NULL); + $$->set_location(yylloc); } ; @@ -539,6 +578,7 @@ expression: { if ($1->oper != ast_sequence) { $$ = new ast_expression(ast_sequence, NULL, NULL, NULL); + $$->set_location(yylloc); insert_at_tail(& $$->expressions, $1); } else { $$ = $1; @@ -595,6 +635,7 @@ function_header: fully_specified_type IDENTIFIER '(' { $$ = new ast_function(); + $$->set_location(yylloc); $$->return_type = $1; $$->identifier = $2; } @@ -604,14 +645,18 @@ parameter_declarator: type_specifier IDENTIFIER { $$ = new ast_parameter_declarator(); + $$->set_location(yylloc); $$->type = new ast_fully_specified_type(); + $$->type->set_location(yylloc); $$->type->specifier = $1; $$->identifier = $2; } | type_specifier IDENTIFIER '[' constant_expression ']' { $$ = new ast_parameter_declarator(); + $$->set_location(yylloc); $$->type = new ast_fully_specified_type(); + $$->type->set_location(yylloc); $$->type->specifier = $1; $$->identifier = $2; $$->is_array = true; @@ -637,6 +682,7 @@ parameter_declaration: $1.i |= $2.i; $$ = new ast_parameter_declarator(); + $$->set_location(yylloc); $$->type = new ast_fully_specified_type(); $$->type->qualifier = $1.q; $$->type->specifier = $3; @@ -644,6 +690,7 @@ parameter_declaration: | parameter_qualifier parameter_type_specifier { $$ = new ast_parameter_declarator(); + $$->set_location(yylloc); $$->type = new ast_fully_specified_type(); $$->type->qualifier = $1.q; $$->type->specifier = $2; @@ -666,6 +713,7 @@ init_declarator_list: | init_declarator_list ',' IDENTIFIER { ast_declaration *decl = new ast_declaration($3, false, NULL, NULL); + decl->set_location(yylloc); $$ = $1; insert_at_tail(& $$->declarations, @@ -674,6 +722,7 @@ init_declarator_list: | init_declarator_list ',' IDENTIFIER '[' ']' { ast_declaration *decl = new ast_declaration($3, true, NULL, NULL); + decl->set_location(yylloc); $$ = $1; insert_at_tail(& $$->declarations, @@ -682,6 +731,7 @@ init_declarator_list: | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' { ast_declaration *decl = new ast_declaration($3, true, $5, NULL); + decl->set_location(yylloc); $$ = $1; insert_at_tail(& $$->declarations, @@ -690,6 +740,7 @@ init_declarator_list: | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer { ast_declaration *decl = new ast_declaration($3, true, NULL, $7); + decl->set_location(yylloc); $$ = $1; insert_at_tail(& $$->declarations, @@ -698,6 +749,7 @@ init_declarator_list: | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer { ast_declaration *decl = new ast_declaration($3, true, $5, $8); + decl->set_location(yylloc); $$ = $1; insert_at_tail(& $$->declarations, @@ -706,6 +758,7 @@ init_declarator_list: | init_declarator_list ',' IDENTIFIER '=' initializer { ast_declaration *decl = new ast_declaration($3, false, NULL, $5); + decl->set_location(yylloc); $$ = $1; insert_at_tail(& $$->declarations, @@ -718,12 +771,14 @@ single_declaration: fully_specified_type { $$ = new ast_declarator_list($1); + $$->set_location(yylloc); } | fully_specified_type IDENTIFIER { ast_declaration *decl = new ast_declaration($2, false, NULL, NULL); $$ = new ast_declarator_list($1); + $$->set_location(yylloc); insert_at_tail(& $$->declarations, (struct simple_node *) decl); } @@ -732,6 +787,7 @@ single_declaration: ast_declaration *decl = new ast_declaration($2, true, NULL, NULL); $$ = new ast_declarator_list($1); + $$->set_location(yylloc); insert_at_tail(& $$->declarations, (struct simple_node *) decl); } @@ -740,6 +796,7 @@ single_declaration: ast_declaration *decl = new ast_declaration($2, true, $4, NULL); $$ = new ast_declarator_list($1); + $$->set_location(yylloc); insert_at_tail(& $$->declarations, (struct simple_node *) decl); } @@ -748,6 +805,7 @@ single_declaration: ast_declaration *decl = new ast_declaration($2, true, NULL, $6); $$ = new ast_declarator_list($1); + $$->set_location(yylloc); insert_at_tail(& $$->declarations, (struct simple_node *) decl); } @@ -756,6 +814,7 @@ single_declaration: ast_declaration *decl = new ast_declaration($2, true, $4, $7); $$ = new ast_declarator_list($1); + $$->set_location(yylloc); insert_at_tail(& $$->declarations, (struct simple_node *) decl); } @@ -764,6 +823,7 @@ single_declaration: ast_declaration *decl = new ast_declaration($2, false, NULL, $4); $$ = new ast_declarator_list($1); + $$->set_location(yylloc); insert_at_tail(& $$->declarations, (struct simple_node *) decl); } @@ -772,6 +832,7 @@ single_declaration: ast_declaration *decl = new ast_declaration($2, false, NULL, NULL); $$ = new ast_declarator_list(NULL); + $$->set_location(yylloc); $$->invariant = true; insert_at_tail(& $$->declarations, @@ -783,11 +844,13 @@ fully_specified_type: type_specifier { $$ = new ast_fully_specified_type(); + $$->set_location(yylloc); $$->specifier = $1; } | type_qualifier type_specifier { $$ = new ast_fully_specified_type(); + $$->set_location(yylloc); $$->qualifier = $1.q; $$->specifier = $2; } @@ -857,14 +920,17 @@ type_specifier_nonarray: basic_type_specifier_nonarray { $$ = new ast_type_specifier($1); + $$->set_location(yylloc); } | struct_specifier { $$ = new ast_type_specifier($1); + $$->set_location(yylloc); } | TYPE_NAME { $$ = new ast_type_specifier($1); + $$->set_location(yylloc); } ; @@ -935,10 +1001,12 @@ struct_specifier: STRUCT IDENTIFIER '{' struct_declaration_list '}' { $$ = new ast_struct_specifier($2, $4); + $$->set_location(yylloc); } | STRUCT '{' struct_declaration_list '}' { $$ = new ast_struct_specifier(NULL, $3); + $$->set_location(yylloc); } ; @@ -959,9 +1027,11 @@ struct_declaration: type_specifier struct_declarator_list ';' { ast_fully_specified_type *type = new ast_fully_specified_type(); + type->set_location(yylloc); type->specifier = $1; $$ = new ast_declarator_list(type); + $$->set_location(yylloc); insert_at_tail((struct simple_node *) $2, & $$->declarations); @@ -982,10 +1052,12 @@ struct_declarator: IDENTIFIER { $$ = new ast_declaration($1, false, NULL, NULL); + $$->set_location(yylloc); } | IDENTIFIER '[' constant_expression ']' { $$ = new ast_declaration($1, true, $3, NULL); + $$->set_location(yylloc); } ; @@ -1027,10 +1099,12 @@ compound_statement: '{' '}' { $$ = new ast_compound_statement(true, NULL); + $$->set_location(yylloc); } | '{' statement_list '}' { $$ = new ast_compound_statement(true, $2); + $$->set_location(yylloc); } ; @@ -1043,10 +1117,12 @@ compound_statement_no_new_scope: '{' '}' { $$ = new ast_compound_statement(false, NULL); + $$->set_location(yylloc); } | '{' statement_list '}' { $$ = new ast_compound_statement(false, $2); + $$->set_location(yylloc); } ; @@ -1077,10 +1153,12 @@ expression_statement: ';' { $$ = new ast_expression_statement(NULL); + $$->set_location(yylloc); } | expression ';' { $$ = new ast_expression_statement($1); + $$->set_location(yylloc); } ; @@ -1088,6 +1166,7 @@ selection_statement_matched: IF '(' expression ')' statement_matched ELSE statement_matched { $$ = new ast_selection_statement($3, $5, $7); + $$->set_location(yylloc); } ; @@ -1095,14 +1174,17 @@ selection_statement_unmatched: IF '(' expression ')' statement_matched { $$ = new ast_selection_statement($3, $5, NULL); + $$->set_location(yylloc); } | IF '(' expression ')' statement_unmatched { $$ = new ast_selection_statement($3, $5, NULL); + $$->set_location(yylloc); } | IF '(' expression ')' statement_matched ELSE statement_unmatched { $$ = new ast_selection_statement($3, $5, $7); + $$->set_location(yylloc); } ; @@ -1115,6 +1197,8 @@ condition: { ast_declaration *decl = new ast_declaration($2, false, NULL, $4); ast_declarator_list *declarator = new ast_declarator_list($1); + decl->set_location(yylloc); + declarator->set_location(yylloc); insert_at_tail(& declarator->declarations, (struct simple_node *) decl); @@ -1137,16 +1221,19 @@ iteration_statement: { $$ = new ast_iteration_statement(ast_iteration_statement::ast_while, NULL, $3, NULL, $5); + $$->set_location(yylloc); } | DO statement WHILE '(' expression ')' ';' { $$ = new ast_iteration_statement(ast_iteration_statement::ast_do_while, NULL, $5, NULL, $2); + $$->set_location(yylloc); } | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope { $$ = new ast_iteration_statement(ast_iteration_statement::ast_for, $3, $4.cond, $4.rest, $6); + $$->set_location(yylloc); } ; @@ -1181,22 +1268,27 @@ jump_statement: CONTINUE ';' { $$ = new ast_jump_statement(ast_jump_statement::ast_continue, NULL); + $$->set_location(yylloc); } | BREAK ';' { $$ = new ast_jump_statement(ast_jump_statement::ast_break, NULL); + $$->set_location(yylloc); } | RETURN ';' { $$ = new ast_jump_statement(ast_jump_statement::ast_return, NULL); + $$->set_location(yylloc); } | RETURN expression ';' { $$ = new ast_jump_statement(ast_jump_statement::ast_return, $2); + $$->set_location(yylloc); } | DISCARD ';' // Fragment shader only. { $$ = new ast_jump_statement(ast_jump_statement::ast_discard, NULL); + $$->set_location(yylloc); } ; @@ -1209,6 +1301,7 @@ function_definition: function_prototype compound_statement_no_new_scope { $$ = new ast_function_definition(); + $$->set_location(yylloc); $$->prototype = $1; $$->body = $2; } -- cgit v1.2.3 From 00e517616b722d6a1f62748d8c84004eeb814756 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Apr 2010 17:17:34 -0700 Subject: Add glsl_type::element_type and glsl_type::array_size queries The former gets the type of elements in an array, and the later gets the declared size, if any, of the array. --- glsl_types.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/glsl_types.h b/glsl_types.h index 6c9444cbe16..33b1c98158d 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -163,6 +163,18 @@ struct glsl_type { */ const glsl_type *get_base_type() const; + /** + * Query the type of elements in an array + * + * \return + * Pointer to the type of elements in the array for array types, or \c NULL + * for non-array types. + */ + const glsl_type *element_type() const + { + return is_array() ? fields.array : NULL; + } + /** * Get the instance of a built-in scalar, vector, or matrix type */ @@ -308,6 +320,19 @@ struct glsl_type { : error_type; } + /** + * Query the number of elements in an array type + * + * \return + * The number of elements in the array for array types or -1 for non-array + * types. If the number of elements in the array has not yet been declared, + * zero is returned. + */ + int array_size() const + { + return is_array() ? length : -1; + } + private: /** * Constructor for array types -- cgit v1.2.3 From a4f308f0663208eec07cc320ff4a67589d4b5a7f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Apr 2010 17:25:11 -0700 Subject: Allow unsized arrays to be redeclared with a size Test glslparsertest/shaders/array11.frag now passes for the right reason. --- ast_to_hir.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 2eecc9f3ec9..3c4b05ee796 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1178,13 +1178,40 @@ ast_declarator_list::hir(exec_list *instructions, & loc); /* Attempt to add the variable to the symbol table. If this fails, it - * means the variable has already been declared at this scope. + * means the variable has already been declared at this scope. Arrays + * fudge this rule a little bit. + * + * From page 24 (page 30 of the PDF) of the GLSL 1.50 spec, + * + * "It is legal to declare an array without a size and then + * later re-declare the same name as an array of the same + * type and specify a size." */ if (state->symbols->name_declared_this_scope(decl->identifier)) { - YYLTYPE loc = this->get_location(); + ir_variable *const earlier = + state->symbols->get_variable(decl->identifier); + + if ((earlier != NULL) + && (earlier->type->array_size() == 0) + && var->type->is_array() + && (var->type->element_type() == earlier->type->element_type())) { + /* FINISHME: This doesn't match the qualifiers on the two + * FINISHME: declarations. It's not 100% clear whether this is + * FINISHME: required or not. + */ + /* FINISHME: Check that the array hasn't already been accessed + * FINISHME: beyond the newly defined bounds. + */ + earlier->type = var->type; + delete var; + var = NULL; + } else { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "`%s' redeclared", + decl->identifier); + } - _mesa_glsl_error(& loc, state, "`%s' redeclared", - decl->identifier); continue; } -- cgit v1.2.3 From 63af4b0e99420efd5ad6ecb638f39dc2c5c5e3cf Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Apr 2010 18:02:48 -0700 Subject: Fix type handling in ir_dereference array dereference constructor --- ir.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ir.cpp b/ir.cpp index 90df67bbf1d..60f34ca9bea 100644 --- a/ir.cpp +++ b/ir.cpp @@ -117,7 +117,18 @@ ir_dereference::ir_dereference(ir_instruction *var, : ir_rvalue(), mode(ir_reference_array), var(var) { - this->type = (var != NULL) ? var->type : glsl_type::error_type; + type = glsl_type::error_type; + + if (var != NULL) { + const glsl_type *const vt = var->type; + + if (vt->is_array()) { + type = vt->element_type(); + } else if (vt->is_matrix() || vt->is_vector()) { + type = vt->get_base_type(); + } + } + this->selector.array_index = array_index; } -- cgit v1.2.3 From 27e3cf8c0d8812f9be55ca6ceb52cf8232742d99 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Apr 2010 18:03:59 -0700 Subject: Begin processing ast_array_index nodes This causes the following tests to pass: glslparsertest/shaders/parser3.frag glslparsertest/shaders/varying3.frag (also generates spurious error) --- ast_to_hir.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 3c4b05ee796..ff9cbb09d97 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -890,8 +890,74 @@ ast_expression::hir(exec_list *instructions, type = result->type; break; - case ast_array_index: + case ast_array_index: { + YYLTYPE index_loc = subexpressions[1]->get_location(); + + op[0] = subexpressions[0]->hir(instructions, state); + op[1] = subexpressions[1]->hir(instructions, state); + + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + + result = new ir_dereference(op[0], op[1]); + + if (error_emitted) + break; + + /* FINISHME: Handle vectors and matrices accessed with []. */ + if (!op[0]->type->is_array()) { + _mesa_glsl_error(& index_loc, state, + "cannot dereference non-array"); + error_emitted = true; + } + + if (!op[1]->type->is_integer()) { + _mesa_glsl_error(& index_loc, state, + "array index must be integer type"); + error_emitted = true; + } else if (!op[1]->type->is_scalar()) { + _mesa_glsl_error(& index_loc, state, + "array index must be scalar"); + error_emitted = true; + } + + /* If the array index is a constant expression and the array has a + * declared size, ensure that the access is in-bounds. If the array + * index is not a constant expression, ensure that the array has a + * declared size. + */ + ir_constant *const const_index = op[1]->constant_expression_value(); + if (const_index != NULL) { + const int idx = const_index->value.i[0]; + + /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec: + * + * "It is illegal to declare an array with a size, and then + * later (in the same shader) index the same array with an + * integral constant expression greater than or equal to the + * declared size. It is also illegal to index an array with a + * negative constant expression." + */ + if ((op[0]->type->array_size() > 0) + && (op[0]->type->array_size() <= idx)) { + _mesa_glsl_error(& loc, state, + "array index must be < %u", + op[0]->type->array_size()); + error_emitted = true; + } + + if (idx < 0) { + _mesa_glsl_error(& loc, state, + "array index must be >= 0"); + error_emitted = true; + } + } + + if (error_emitted) + result->type = glsl_type::error_type; + + type = result->type; break; + } case ast_function_call: /* Should *NEVER* get here. ast_function_call should always be handled -- cgit v1.2.3 From b8a21cc6df7e9da15a24ed3dbf60cd4aeb8effaa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Apr 2010 18:31:11 -0700 Subject: Track max accessed array element, reject additional out-of-bounds accesses For unsized arrays, we can't flag out-of-bounds accesses until the array is redeclared with a size. Track the maximum accessed element and generate an error if the declaration specifies a size that would cause that access to be out-of-bounds. This causes the following tests to pass: glslparsertest/shaders/array10.frag --- ast_to_hir.cpp | 42 ++++++++++++++++++++++++++++++++++-------- ir.cpp | 2 +- ir.h | 8 ++++++++ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index ff9cbb09d97..ca3c869dd80 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -898,13 +898,29 @@ ast_expression::hir(exec_list *instructions, error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - result = new ir_dereference(op[0], op[1]); + ir_dereference *const lhs = op[0]->as_dereference(); + ir_instruction *array; + if ((lhs != NULL) + && (lhs->mode == ir_dereference::ir_reference_variable)) { + result = new ir_dereference(lhs->var, op[1]); + + delete op[0]; + array = lhs->var; + } else { + result = new ir_dereference(op[0], op[1]); + array = op[0]; + } + + /* Do not use op[0] after this point. Use array. + */ + op[0] = NULL; + if (error_emitted) break; /* FINISHME: Handle vectors and matrices accessed with []. */ - if (!op[0]->type->is_array()) { + if (!array->type->is_array()) { _mesa_glsl_error(& index_loc, state, "cannot dereference non-array"); error_emitted = true; @@ -937,11 +953,11 @@ ast_expression::hir(exec_list *instructions, * declared size. It is also illegal to index an array with a * negative constant expression." */ - if ((op[0]->type->array_size() > 0) - && (op[0]->type->array_size() <= idx)) { + if ((array->type->array_size() > 0) + && (array->type->array_size() <= idx)) { _mesa_glsl_error(& loc, state, "array index must be < %u", - op[0]->type->array_size()); + array->type->array_size()); error_emitted = true; } @@ -950,6 +966,10 @@ ast_expression::hir(exec_list *instructions, "array index must be >= 0"); error_emitted = true; } + + ir_variable *const v = array->as_variable(); + if ((v != NULL) && (unsigned(idx) > v->max_array_access)) + v->max_array_access = idx; } if (error_emitted) @@ -1265,9 +1285,15 @@ ast_declarator_list::hir(exec_list *instructions, * FINISHME: declarations. It's not 100% clear whether this is * FINISHME: required or not. */ - /* FINISHME: Check that the array hasn't already been accessed - * FINISHME: beyond the newly defined bounds. - */ + + if (var->type->array_size() <= earlier->max_array_access) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "array size must be > %u due to " + "previous access", + earlier->max_array_access); + } + earlier->type = var->type; delete var; var = NULL; diff --git a/ir.cpp b/ir.cpp index 60f34ca9bea..3939e5a7b55 100644 --- a/ir.cpp +++ b/ir.cpp @@ -246,7 +246,7 @@ ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) ir_variable::ir_variable(const struct glsl_type *type, const char *name) - : ir_instruction(), read_only(false), centroid(false), invariant(false), + : max_array_access(0), read_only(false), centroid(false), invariant(false), mode(ir_var_auto), interpolation(ir_var_smooth) { this->type = type; diff --git a/ir.h b/ir.h index de6f09318ad..8892f1dc1bd 100644 --- a/ir.h +++ b/ir.h @@ -121,6 +121,7 @@ public: { ir_variable *var = new ir_variable(type, name); + var->max_array_access = this->max_array_access; var->read_only = this->read_only; var->centroid = this->centroid; var->invariant = this->invariant; @@ -132,6 +133,13 @@ public: const char *name; + /** + * Highest element accessed with a constant expression array index + * + * Not used for non-array variables. + */ + unsigned max_array_access; + unsigned read_only:1; unsigned centroid:1; unsigned invariant:1; -- cgit v1.2.3 From 03d3f3ab71ba280071f54cb60505212be6710f8e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Apr 2010 11:03:47 -0700 Subject: Remove ast_node::type It isn't a type (is was enum specifying the kind of node), it was unused, and it was easily confused with actual type fields. Kill with fire. --- ast.h | 3 --- glsl_parser_extras.cpp | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ast.h b/ast.h index f7cdf96d099..0dfd02a9cd1 100644 --- a/ast.h +++ b/ast.h @@ -75,9 +75,6 @@ public: this->location.column = locp.first_column; } - - int type; - struct { unsigned source; unsigned line; diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 265782ebdab..eb19ed7b91b 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -104,7 +104,7 @@ _mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q) void ast_node::print(void) const { - printf("node_%d ", type); + printf("unhandled node "); } -- cgit v1.2.3 From 068c80cfe0a280490353b6b007165d717c672eed Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 09:56:36 -1000 Subject: Don't create a parameter declaration for a (void) parameter. Fixes segfaults in a shader consisting of just: void main(void) { } Signed-off-by: Ian Romanick --- ast_to_hir.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index ca3c869dd80..137abdaaa6c 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1501,6 +1501,21 @@ ast_parameter_declarator::hir(exec_list *instructions, type = glsl_type::error_type; } + /* From page 62 (page 68 of the PDF) of the GLSL 1.50 spec: + * + * "Functions that accept no input arguments need not use void in the + * argument list because prototypes (or definitions) are required and + * therefore there is no ambiguity when an empty argument list "( )" is + * declared. The idiom "(void)" as a parameter list is provided for + * convenience." + * + * Placing this check here prevents a void parameter being set up + * for a function, which avoids tripping up checks for main taking + * parameters and lookups of an unnamed symbol. + */ + if (type->is_void() && (this->identifier == NULL)) + return NULL; + ir_variable *var = new ir_variable(type, this->identifier); /* FINISHME: Handle array declarations. Note that this requires @@ -1530,7 +1545,9 @@ ast_function_parameters_to_hir(struct simple_node *ast_parameters, struct simple_node *ptr; foreach (ptr, ast_parameters) { - ((ast_node *)ptr)->hir(ir_parameters, state); + ast_node *param = (ast_node *)ptr; + param->hir(ir_parameters, state); + } } -- cgit v1.2.3 From ac3af37d27c49704dd3b2d303b4497b08f8b47fd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 15:44:38 -1000 Subject: Allow initializers of constant values to succeed. This regresses constFunc.frag, but that's just unexpectedly passing because of the FINISHME just above. --- ast_to_hir.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 137abdaaa6c..11000a81346 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1441,8 +1441,12 @@ ast_declarator_list::hir(exec_list *instructions, */ if (!rhs->type->is_error()) { + bool temp = var->read_only; + if (this->type->qualifier.constant) + var->read_only = false; (void) do_assignment(instructions, state, lhs, rhs, this->get_location()); + var->read_only = temp; } } -- cgit v1.2.3 From 307c71bf24a3c99409ccf4b8b10f161e4b032cba Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 15:53:26 -1000 Subject: Compute the constant value of a constant initializer. Fixes constFunc.frag. --- ast_to_hir.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 11000a81346..aa7e165ee76 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1434,13 +1434,22 @@ ast_declarator_list::hir(exec_list *instructions, } ir_dereference *const lhs = new ir_dereference(var); - ir_rvalue *const rhs = decl->initializer->hir(instructions, state); + ir_rvalue *rhs = decl->initializer->hir(instructions, state); - /* FINISHME: If the declaration is either 'const' or 'uniform', the - * FINISHME: initializer (rhs) must be a constant expression. + /* Calculate the constant value if this is a const + * declaration. */ + if (this->type->qualifier.constant) { + rhs = rhs->constant_expression_value(); + if (!rhs) { + _mesa_glsl_error(& initializer_loc, state, + "initializer of const variable `%s' must be a " + "constant expression", + decl->identifier); + } + } - if (!rhs->type->is_error()) { + if (rhs && !rhs->type->is_error()) { bool temp = var->read_only; if (this->type->qualifier.constant) var->read_only = false; -- cgit v1.2.3 From a576f9d84c35ecc8a797fea6e5e26e5320f7ac0c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 16:25:12 -1000 Subject: Start trying to fill in a few bits of ir_constant_expression.cpp This makes a little progress on CorrectParse2.frag. --- ir_constant_expression.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index b8a9031fba1..942bd8097e1 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -36,6 +36,7 @@ #define NULL 0 #include "ir.h" #include "ir_visitor.h" +#include "glsl_types.h" /** * Visitor class for evaluating constant expressions @@ -127,12 +128,42 @@ ir_constant_visitor::visit(ir_function *ir) value = NULL; } - void ir_constant_visitor::visit(ir_expression *ir) { - (void) ir; value = NULL; + ir_constant *op[2]; + + switch (ir->operation) { + case ir_binop_mul: + op[0] = ir->operands[0]->constant_expression_value(); + op[1] = ir->operands[1]->constant_expression_value(); + if (op[0] && op[1] && ir->operands[0]->type == ir->operands[1]->type) { + if (ir->operands[1]->type == glsl_type::float_type) { + value = new ir_constant(op[0]->value.f[0] * op[1]->value.f[0]); + value->type = glsl_type::float_type; + } + } + break; + case ir_binop_logic_and: + op[0] = ir->operands[0]->constant_expression_value(); + op[1] = ir->operands[1]->constant_expression_value(); + if (op[0] && op[1]) { + value = new ir_constant(op[0]->value.b[0] && op[1]->value.b[0]); + value->type = glsl_type::bool_type; + } + break; + case ir_binop_logic_or: + op[0] = ir->operands[0]->constant_expression_value(); + op[1] = ir->operands[1]->constant_expression_value(); + if (op[0] && op[1]) { + value = new ir_constant(op[0]->value.b[0] || op[1]->value.b[0]); + value->type = glsl_type::bool_type; + } + break; + default: + break; + } } -- cgit v1.2.3 From a13bb1490c57ea958f2d1853d71c55d03263e9e4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 16:38:11 -1000 Subject: Emit errors from failure in arithmetic_result_type. Signed-off-by: Ian Romanick --- ast_to_hir.cpp | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index aa7e165ee76..d3bba44c8c3 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -132,7 +132,7 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, static const struct glsl_type * arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, bool multiply, - struct _mesa_glsl_parse_state *state) + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) { const glsl_type *const type_a = value_a->type; const glsl_type *const type_b = value_b->type; @@ -144,6 +144,8 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, * floating-point scalars, vectors, and matrices." */ if (!type_a->is_numeric() || !type_b->is_numeric()) { + _mesa_glsl_error(loc, state, + "Operands to arithmetic operators must be numeric"); return glsl_type::error_type; } @@ -154,6 +156,9 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, */ if (!apply_implicit_conversion(type_a, value_b, state) && !apply_implicit_conversion(type_b, value_a, state)) { + _mesa_glsl_error(loc, state, + "Could not implicitly convert operands to " + "arithmetic operator"); return glsl_type::error_type; } @@ -167,6 +172,8 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, * equality. */ if (type_a->base_type != type_b->base_type) { + _mesa_glsl_error(loc, state, + "base type mismatch for arithmetic operator"); return glsl_type::error_type; } @@ -205,7 +212,13 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, * vector." */ if (type_a->is_vector() && type_b->is_vector()) { - return (type_a == type_b) ? type_a : glsl_type::error_type; + if (type_a == type_b) { + return type_a; + } else { + _mesa_glsl_error(loc, state, + "vector size mismatch for arithmetic operator"); + return glsl_type::error_type; + } } /* All of the combinations of , , @@ -234,7 +247,8 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, * more detail how vectors and matrices are operated on." */ if (! multiply) { - return (type_a == type_b) ? type_a : glsl_type::error_type; + if (type_a == type_b) + return type_a; } else { if (type_a->is_matrix() && type_b->is_matrix()) { /* Matrix multiply. The columns of A must match the rows of B. Given @@ -248,10 +262,13 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, * looking at the size of a vector that makes up a column. The * transpose (size of a row) is done for B. */ - return + const glsl_type *const type = glsl_type::get_instance(type_a->base_type, type_a->column_type()->vector_elements, type_b->row_type()->vector_elements); + assert(type != glsl_type::error_type); + + return type; } } else if (type_a->is_matrix()) { /* A is a matrix and B is a column vector. Columns of A must match @@ -272,11 +289,15 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, if (type_a == type_b->column_type()) return type_a; } + + _mesa_glsl_error(loc, state, "size mismatch for matrix multiplication"); + return glsl_type::error_type; } /* "All other cases are illegal." */ + _mesa_glsl_error(loc, state, "type mismatch"); return glsl_type::error_type; } @@ -599,7 +620,8 @@ ast_expression::hir(exec_list *instructions, type = arithmetic_result_type(op[0], op[1], (this->oper == ast_mul), - state); + state, & loc); + error_emitted = type->is_error(); result = new ir_expression(operations[this->oper], type, op[0], op[1]); @@ -721,7 +743,7 @@ ast_expression::hir(exec_list *instructions, type = arithmetic_result_type(op[0], op[1], (this->oper == ast_mul_assign), - state); + state, & loc); ir_rvalue *temp_rhs = new ir_expression(operations[this->oper], type, op[0], op[1]); @@ -842,7 +864,7 @@ ast_expression::hir(exec_list *instructions, else op[1] = new ir_constant(1); - type = arithmetic_result_type(op[0], op[1], false, state); + type = arithmetic_result_type(op[0], op[1], false, state, & loc); struct ir_rvalue *temp_rhs; temp_rhs = new ir_expression(operations[this->oper], type, @@ -865,7 +887,7 @@ ast_expression::hir(exec_list *instructions, error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - type = arithmetic_result_type(op[0], op[1], false, state); + type = arithmetic_result_type(op[0], op[1], false, state, & loc); struct ir_rvalue *temp_rhs; temp_rhs = new ir_expression(operations[this->oper], type, -- cgit v1.2.3 From 65e1a7ac6a6735e135851ddb87e48361d4677000 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 16:45:20 -1000 Subject: Add errors for type results of other expressions. --- ast_to_hir.cpp | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index d3bba44c8c3..ca5ae866456 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -303,7 +303,8 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, static const struct glsl_type * -unary_arithmetic_result_type(const struct glsl_type *type) +unary_arithmetic_result_type(const struct glsl_type *type, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) { /* From GLSL 1.50 spec, page 57: * @@ -313,8 +314,11 @@ unary_arithmetic_result_type(const struct glsl_type *type) * component-wise on their operands. These result with the same type * they operated on." */ - if (!type->is_numeric()) + if (!type->is_numeric()) { + _mesa_glsl_error(loc, state, + "Operands to arithmetic operators must be numeric"); return glsl_type::error_type; + } return type; } @@ -322,7 +326,8 @@ unary_arithmetic_result_type(const struct glsl_type *type) static const struct glsl_type * modulus_result_type(const struct glsl_type *type_a, - const struct glsl_type *type_b) + const struct glsl_type *type_b, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) { /* From GLSL 1.50 spec, page 56: * "The operator modulus (%) operates on signed or unsigned integers or @@ -331,6 +336,7 @@ modulus_result_type(const struct glsl_type *type_a, */ if (!type_a->is_integer() || !type_b->is_integer() || (type_a->base_type != type_b->base_type)) { + _mesa_glsl_error(loc, state, "type mismatch"); return glsl_type::error_type; } @@ -349,13 +355,14 @@ modulus_result_type(const struct glsl_type *type_a, /* "The operator modulus (%) is not defined for any other data types * (non-integer types)." */ + _mesa_glsl_error(loc, state, "type mismatch"); return glsl_type::error_type; } static const struct glsl_type * relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, - struct _mesa_glsl_parse_state *state) + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) { const glsl_type *const type_a = value_a->type; const glsl_type *const type_b = value_b->type; @@ -368,8 +375,12 @@ relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, if (!type_a->is_numeric() || !type_b->is_numeric() || !type_a->is_scalar() - || !type_b->is_scalar()) + || !type_b->is_scalar()) { + _mesa_glsl_error(loc, state, + "Operands to relational operators must be scalar and " + "numeric"); return glsl_type::error_type; + } /* "Either the operands' types must match, or the conversions from * Section 4.1.10 "Implicit Conversions" will be applied to the integer @@ -377,11 +388,16 @@ relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, */ if (!apply_implicit_conversion(type_a, value_b, state) && !apply_implicit_conversion(type_b, value_a, state)) { + _mesa_glsl_error(loc, state, + "Could not implicitly convert operands to " + "relational operator"); return glsl_type::error_type; } - if (type_a->base_type != type_b->base_type) + if (type_a->base_type != type_b->base_type) { + _mesa_glsl_error(loc, state, "base type mismatch"); return glsl_type::error_type; + } /* "The result is scalar Boolean." */ @@ -603,9 +619,9 @@ ast_expression::hir(exec_list *instructions, case ast_neg: op[0] = this->subexpressions[0]->hir(instructions, state); - type = unary_arithmetic_result_type(op[0]->type); + type = unary_arithmetic_result_type(op[0]->type, state, & loc); - error_emitted = op[0]->type->is_error(); + error_emitted = type->is_error(); result = new ir_expression(operations[this->oper], type, op[0], NULL); @@ -631,14 +647,13 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - - type = modulus_result_type(op[0]->type, op[1]->type); + type = modulus_result_type(op[0]->type, op[1]->type, state, & loc); assert(operations[this->oper] == ir_binop_mod); result = new ir_expression(operations[this->oper], type, op[0], op[1]); + error_emitted = type->is_error(); break; case ast_lshift: @@ -653,9 +668,7 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - - type = relational_result_type(op[0], op[1], state); + type = relational_result_type(op[0], op[1], state, & loc); /* The relational operators must either generate an error or result * in a scalar boolean. See page 57 of the GLSL 1.50 spec. @@ -666,6 +679,7 @@ ast_expression::hir(exec_list *instructions, result = new ir_expression(operations[this->oper], type, op[0], op[1]); + error_emitted = type->is_error(); break; case ast_nequal: @@ -765,9 +779,7 @@ ast_expression::hir(exec_list *instructions, op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - - type = modulus_result_type(op[0]->type, op[1]->type); + type = modulus_result_type(op[0]->type, op[1]->type, state, & loc); assert(operations[this->oper] == ir_binop_mod); @@ -778,7 +790,7 @@ ast_expression::hir(exec_list *instructions, result = do_assignment(instructions, state, op[0], temp_rhs, this->subexpressions[0]->get_location()); type = result->type; - error_emitted = op[0]->type->is_error(); + error_emitted = type->is_error(); break; } -- cgit v1.2.3 From a5827fe8d06a1161ef3b4e2b3296431a55d4ba2e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 16:50:55 -1000 Subject: Fix ast_logic_not handling to be unary, not binary. --- ast_to_hir.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index ca5ae866456..3166a75cf5b 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -726,7 +726,6 @@ ast_expression::hir(exec_list *instructions, case ast_logic_and: case ast_logic_xor: case ast_logic_or: - case ast_logic_not: op[0] = this->subexpressions[0]->hir(instructions, state); op[1] = this->subexpressions[1]->hir(instructions, state); @@ -748,6 +747,20 @@ ast_expression::hir(exec_list *instructions, op[0], op[1]); break; + case ast_logic_not: + op[0] = this->subexpressions[0]->hir(instructions, state); + + if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[0]->get_location(); + + _mesa_glsl_error(& loc, state, + "operand of `!' must be scalar boolean"); + } + + result = new ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], NULL); + break; + case ast_mul_assign: case ast_div_assign: case ast_add_assign: -- cgit v1.2.3 From 183d8c63947fcfab45c9f2a8a8a6fc311e8b1552 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 16:53:47 -1000 Subject: Emit errors for unfinished ast_to_hir expression operations. --- ast_to_hir.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 3166a75cf5b..5d7c073ca90 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -658,7 +658,8 @@ ast_expression::hir(exec_list *instructions, case ast_lshift: case ast_rshift: - /* FINISHME: Implement bit-shift operators. */ + _mesa_glsl_error(& loc, state, "FINISHME: implement bit-shift operators"); + error_emitted = true; break; case ast_less: @@ -720,7 +721,8 @@ ast_expression::hir(exec_list *instructions, case ast_bit_xor: case ast_bit_or: case ast_bit_not: - /* FINISHME: Implement bit-wise operators. */ + _mesa_glsl_error(& loc, state, "FINISHME: implement bit-wise operators"); + error_emitted = true; break; case ast_logic_and: @@ -809,11 +811,17 @@ ast_expression::hir(exec_list *instructions, case ast_ls_assign: case ast_rs_assign: + _mesa_glsl_error(& loc, state, + "FINISHME: implement bit-shift assignment operators"); + error_emitted = true; break; case ast_and_assign: case ast_xor_assign: case ast_or_assign: + _mesa_glsl_error(& loc, state, + "FINISHME: implement logic assignment operators"); + error_emitted = true; break; case ast_conditional: { -- cgit v1.2.3 From ebbf14b9801d577adf40dcb0b63df2d3b8da934e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 17:05:32 -1000 Subject: Fix error handling of logic operators. They were always throwing a type error because type wasn't being set. --- ast_to_hir.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 5d7c073ca90..79e04ee7960 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -736,6 +736,7 @@ ast_expression::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "LHS of `%s' must be scalar boolean", operator_string(this->oper)); + error_emitted = true; } if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { @@ -743,10 +744,12 @@ ast_expression::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "RHS of `%s' must be scalar boolean", operator_string(this->oper)); + error_emitted = true; } result = new ir_expression(operations[this->oper], glsl_type::bool_type, op[0], op[1]); + type = glsl_type::bool_type; break; case ast_logic_not: @@ -757,10 +760,12 @@ ast_expression::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "operand of `!' must be scalar boolean"); + error_emitted = true; } result = new ir_expression(operations[this->oper], glsl_type::bool_type, op[0], NULL); + type = glsl_type::bool_type; break; case ast_mul_assign: -- cgit v1.2.3 From 528bb853599f514611e8e49adc758662219dacf7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 21:09:02 -1000 Subject: Handle logic not in constant expression evaluation. --- ir_constant_expression.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 942bd8097e1..c7c4d7b2449 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -135,6 +135,13 @@ ir_constant_visitor::visit(ir_expression *ir) ir_constant *op[2]; switch (ir->operation) { + case ir_unop_logic_not: + op[0] = ir->operands[0]->constant_expression_value(); + if (op[0]) { + value = new ir_constant(!op[0]->value.b[0]); + value->type = glsl_type::bool_type; + } + break; case ir_binop_mul: op[0] = ir->operands[0]->constant_expression_value(); op[1] = ir->operands[1]->constant_expression_value(); -- cgit v1.2.3 From aeab105342df8f59af1f1c65078e38dda4d7e521 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 21:12:12 -1000 Subject: Remove fake ir_binop_logic_not. I think you meant ir_unop_logic_not. --- ir.h | 1 - ir_print_visitor.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/ir.h b/ir.h index 8892f1dc1bd..559f9844788 100644 --- a/ir.h +++ b/ir.h @@ -357,7 +357,6 @@ enum ir_expression_operation { ir_binop_logic_and, ir_binop_logic_xor, ir_binop_logic_or, - ir_binop_logic_not, ir_binop_dot, ir_binop_min, diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index e6b24d2d5bc..b207262044d 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -123,7 +123,6 @@ void ir_print_visitor::visit(ir_expression *ir) "&&", "^^", "||", - "!", "dot", "min", "max", -- cgit v1.2.3 From 90b7825b0e92375dbe721d2dca1a4a3f1093f4ab Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Mar 2010 21:21:20 -1000 Subject: Reject non-float varyings. Fixes varying2.frag. --- ast_to_hir.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 79e04ee7960..456271d3002 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1252,6 +1252,18 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, "fragment shader"); } + /* From page 25 (page 31 of the PDF) of the GLSL 1.10 spec: + * + * "The varying qualifier can be used only with the data types + * float, vec2, vec3, vec4, mat2, mat3, and mat4, or arrays of + * these." + */ + if (qual->varying && var->type->base_type != GLSL_TYPE_FLOAT) { + var->type = glsl_type::error_type; + _mesa_glsl_error(loc, state, + "varying variables must be of base type float"); + } + if (qual->in && qual->out) var->mode = ir_var_inout; else if (qual->attribute || qual->in -- cgit v1.2.3 From 160d092507c1ca341b7c5c88e5ba94b4cf5fb7d0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Apr 2010 18:07:08 -1000 Subject: Simplify ir_constant_expression.cpp by factoring operand computation out. --- ir.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++ ir.h | 6 ++++- ir_constant_expression.cpp | 36 +++++++++++++--------------- 3 files changed, 79 insertions(+), 21 deletions(-) diff --git a/ir.cpp b/ir.cpp index 3939e5a7b55..35fecf75608 100644 --- a/ir.cpp +++ b/ir.cpp @@ -46,6 +46,64 @@ ir_expression::ir_expression(int op, const struct glsl_type *type, this->operands[1] = op1; } +unsigned int +ir_expression::get_num_operands(void) +{ +/* Update ir_print_visitor.cpp when updating this list. */ + const int num_operands[] = { + 1, /* ir_unop_bit_not */ + 1, /* ir_unop_logic_not */ + 1, /* ir_unop_neg */ + 1, /* ir_unop_abs */ + 1, /* ir_unop_rcp */ + 1, /* ir_unop_rsq */ + 1, /* ir_unop_sqrt */ + 1, /* ir_unop_exp */ + 1, /* ir_unop_log */ + 1, /* ir_unop_exp2 */ + 1, /* ir_unop_log2 */ + 1, /* ir_unop_f2i */ + 1, /* ir_unop_i2f */ + 1, /* ir_unop_u2f */ + + 1, /* ir_unop_trunc */ + 1, /* ir_unop_ceil */ + 1, /* ir_unop_floor */ + + 2, /* ir_binop_add */ + 2, /* ir_binop_sub */ + 2, /* ir_binop_mul */ + 2, /* ir_binop_div */ + 2, /* ir_binop_mod */ + + 2, /* ir_binop_less */ + 2, /* ir_binop_greater */ + 2, /* ir_binop_lequal */ + 2, /* ir_binop_gequal */ + 2, /* ir_binop_equal */ + 2, /* ir_binop_nequal */ + + 2, /* ir_binop_lshift */ + 2, /* ir_binop_rshift */ + 2, /* ir_binop_bit_and */ + 2, /* ir_binop_bit_xor */ + 2, /* ir_binop_bit_or */ + + 2, /* ir_binop_logic_and */ + 2, /* ir_binop_logic_xor */ + 2, /* ir_binop_logic_or */ + + 2, /* ir_binop_dot */ + 2, /* ir_binop_min */ + 2, /* ir_binop_max */ + + 2, /* ir_binop_pow */ + }; + + assert(sizeof(num_operands) / sizeof(num_operands[0]) == ir_binop_pow + 1); + + return num_operands[this->operation]; +} ir_label::ir_label(const char *label) : ir_instruction(), label(label) diff --git a/ir.h b/ir.h index 559f9844788..381af357b81 100644 --- a/ir.h +++ b/ir.h @@ -299,7 +299,9 @@ public: ir_rvalue *condition; }; -/* Update ir_print_visitor.cpp when updating this list. */ +/* Update ir_expression::num_operands() and ir_print_visitor.cpp when + * updating this list. +*/ enum ir_expression_operation { ir_unop_bit_not, ir_unop_logic_not, @@ -370,6 +372,8 @@ public: ir_expression(int op, const struct glsl_type *type, ir_rvalue *, ir_rvalue *); + unsigned int get_num_operands(void); + virtual void accept(ir_visitor *v) { v->visit(this); diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index c7c4d7b2449..476afe8b87d 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -133,40 +133,36 @@ ir_constant_visitor::visit(ir_expression *ir) { value = NULL; ir_constant *op[2]; + unsigned int i; + + for (i = 0; i < ir->get_num_operands(); i++) { + op[i] = ir->operands[i]->constant_expression_value(); + if (!op[i]) + return; + } switch (ir->operation) { case ir_unop_logic_not: - op[0] = ir->operands[0]->constant_expression_value(); - if (op[0]) { - value = new ir_constant(!op[0]->value.b[0]); - value->type = glsl_type::bool_type; - } + value = new ir_constant(!op[0]->value.b[0]); + value->type = glsl_type::bool_type; break; case ir_binop_mul: - op[0] = ir->operands[0]->constant_expression_value(); - op[1] = ir->operands[1]->constant_expression_value(); - if (op[0] && op[1] && ir->operands[0]->type == ir->operands[1]->type) { + if (ir->operands[0]->type == ir->operands[1]->type) { if (ir->operands[1]->type == glsl_type::float_type) { value = new ir_constant(op[0]->value.f[0] * op[1]->value.f[0]); value->type = glsl_type::float_type; } } + if (value) + value->type = ir->operands[1]->type; break; case ir_binop_logic_and: - op[0] = ir->operands[0]->constant_expression_value(); - op[1] = ir->operands[1]->constant_expression_value(); - if (op[0] && op[1]) { - value = new ir_constant(op[0]->value.b[0] && op[1]->value.b[0]); - value->type = glsl_type::bool_type; - } + value = new ir_constant(op[0]->value.b[0] && op[1]->value.b[0]); + value->type = glsl_type::bool_type; break; case ir_binop_logic_or: - op[0] = ir->operands[0]->constant_expression_value(); - op[1] = ir->operands[1]->constant_expression_value(); - if (op[0] && op[1]) { - value = new ir_constant(op[0]->value.b[0] || op[1]->value.b[0]); - value->type = glsl_type::bool_type; - } + value = new ir_constant(op[0]->value.b[0] || op[1]->value.b[0]); + value->type = glsl_type::bool_type; break; default: break; -- cgit v1.2.3 From d98da9738ee791edae5ee6650e7a3ac08b6c26ca Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Apr 2010 18:25:11 -1000 Subject: Make ir_constant_expression.cpp support multi-component types. --- ir_constant_expression.cpp | 73 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 476afe8b87d..e8820a0f876 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -133,40 +133,79 @@ ir_constant_visitor::visit(ir_expression *ir) { value = NULL; ir_constant *op[2]; - unsigned int i; - - for (i = 0; i < ir->get_num_operands(); i++) { - op[i] = ir->operands[i]->constant_expression_value(); - if (!op[i]) + unsigned int operand, c; + unsigned u[16]; + int i[16]; + float f[16]; + bool b[16]; + const glsl_type *type = NULL; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + op[operand] = ir->operands[operand]->constant_expression_value(); + if (!op[operand]) return; } switch (ir->operation) { case ir_unop_logic_not: - value = new ir_constant(!op[0]->value.b[0]); - value->type = glsl_type::bool_type; + type = ir->operands[0]->type; + assert(type->base_type == GLSL_TYPE_BOOL); + for (c = 0; c < ir->operands[0]->type->components(); c++) + b[c] = !op[0]->value.b[c]; break; case ir_binop_mul: - if (ir->operands[0]->type == ir->operands[1]->type) { - if (ir->operands[1]->type == glsl_type::float_type) { - value = new ir_constant(op[0]->value.f[0] * op[1]->value.f[0]); - value->type = glsl_type::float_type; + if (ir->operands[0]->type == ir->operands[1]->type && + !ir->operands[0]->type->is_matrix()) { + type = ir->operands[0]->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + u[c] = op[0]->value.u[c] * op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + i[c] = op[0]->value.i[c] * op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + f[c] = op[0]->value.f[c] * op[1]->value.f[c]; + break; + default: + assert(0); + } } } - if (value) - value->type = ir->operands[1]->type; break; case ir_binop_logic_and: - value = new ir_constant(op[0]->value.b[0] && op[1]->value.b[0]); - value->type = glsl_type::bool_type; + type = ir->operands[0]->type; + assert(type->base_type == GLSL_TYPE_BOOL); + for (c = 0; c < ir->operands[0]->type->components(); c++) + b[c] = op[0]->value.b[c] && op[1]->value.b[c]; break; case ir_binop_logic_or: - value = new ir_constant(op[0]->value.b[0] || op[1]->value.b[0]); - value->type = glsl_type::bool_type; + type = ir->operands[0]->type; + assert(type->base_type == GLSL_TYPE_BOOL); + for (c = 0; c < ir->operands[0]->type->components(); c++) + b[c] = op[0]->value.b[c] || op[1]->value.b[c]; break; default: break; } + + if (type) { + switch (type->base_type) { + case GLSL_TYPE_UINT: + value = new ir_constant(type, u); + break; + case GLSL_TYPE_INT: + value = new ir_constant(type, i); + break; + case GLSL_TYPE_FLOAT: + value = new ir_constant(type, f); + break; + case GLSL_TYPE_BOOL: + value = new ir_constant(type, b); + break; + } + } } -- cgit v1.2.3 From d251b92f8d32b28a91085d5b1f557c1f4756a2f2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Apr 2010 18:35:42 -1000 Subject: Add some more operations to ir_constant_expression.cpp. --- ir_constant_expression.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index e8820a0f876..69a36130801 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -153,6 +153,46 @@ ir_constant_visitor::visit(ir_expression *ir) for (c = 0; c < ir->operands[0]->type->components(); c++) b[c] = !op[0]->value.b[c]; break; + case ir_binop_add: + if (ir->operands[0]->type == ir->operands[1]->type) { + type = ir->operands[0]->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + u[c] = op[0]->value.u[c] + op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + i[c] = op[0]->value.i[c] + op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + f[c] = op[0]->value.f[c] + op[1]->value.f[c]; + break; + default: + assert(0); + } + } + } + break; + case ir_binop_sub: + if (ir->operands[0]->type == ir->operands[1]->type) { + type = ir->operands[0]->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + u[c] = op[0]->value.u[c] - op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + i[c] = op[0]->value.i[c] - op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + f[c] = op[0]->value.f[c] - op[1]->value.f[c]; + break; + default: + assert(0); + } + } + } + break; case ir_binop_mul: if (ir->operands[0]->type == ir->operands[1]->type && !ir->operands[0]->type->is_matrix()) { @@ -174,12 +214,38 @@ ir_constant_visitor::visit(ir_expression *ir) } } break; + case ir_binop_div: + if (ir->operands[0]->type == ir->operands[1]->type) { + type = ir->operands[0]->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + u[c] = op[0]->value.u[c] / op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + i[c] = op[0]->value.i[c] / op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + f[c] = op[0]->value.f[c] / op[1]->value.f[c]; + break; + default: + assert(0); + } + } + } + break; case ir_binop_logic_and: type = ir->operands[0]->type; assert(type->base_type == GLSL_TYPE_BOOL); for (c = 0; c < ir->operands[0]->type->components(); c++) b[c] = op[0]->value.b[c] && op[1]->value.b[c]; break; + case ir_binop_logic_xor: + type = ir->operands[0]->type; + assert(type->base_type == GLSL_TYPE_BOOL); + for (c = 0; c < ir->operands[0]->type->components(); c++) + b[c] = op[0]->value.b[c] ^ op[1]->value.b[c]; + break; case ir_binop_logic_or: type = ir->operands[0]->type; assert(type->base_type == GLSL_TYPE_BOOL); -- cgit v1.2.3 From 5150c567a0bf082d93f25ba7e29d5573c9dffb8b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Apr 2010 19:00:29 -1000 Subject: Test for the type being different in parameter_lists_match. Fixes CorrectFuncOverload.frag. --- ast_to_hir.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 456271d3002..8ed56d5800b 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1644,6 +1644,9 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) exec_list_iterator iter_b = list_b->iterator(); while (iter_a.has_next()) { + ir_variable *a = (ir_variable *)iter_a.get(); + ir_variable *b = (ir_variable *)iter_b.get(); + /* If all of the parameters from the other parameter list have been * exhausted, the lists have different length and, by definition, * do not match. @@ -1654,8 +1657,8 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) /* If the types of the parameters do not match, the parameters lists * are different. */ - /* FINISHME */ - + if (a->type != b->type) + return false; iter_a.next(); iter_b.next(); -- cgit v1.2.3 From c7da28b4beb3a593f49a6c01a90b123584b421e8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Apr 2010 20:27:35 -1000 Subject: Allow array dereferences to be considered as lvalues. Fixes glsl-vs-arrays.vert and glsl-vs-mov-after-deref.vert. Regresses parser3.frag which was failing for the wrong reason. --- ir.cpp | 24 ++++++++++++++++++++++++ ir.h | 12 +----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/ir.cpp b/ir.cpp index 35fecf75608..d9faac03d46 100644 --- a/ir.cpp +++ b/ir.cpp @@ -190,6 +190,30 @@ ir_dereference::ir_dereference(ir_instruction *var, this->selector.array_index = array_index; } +bool +ir_dereference::is_lvalue() +{ + if (var == NULL) + return false; + + if (this->type->base_type == GLSL_TYPE_ARRAY || + this->type->base_type == GLSL_TYPE_STRUCT) + return false; + + if (mode == ir_reference_variable) { + ir_variable *const as_var = var->as_variable(); + if (as_var == NULL) + return false; + + return !as_var->read_only; + } else if (mode == ir_reference_array) { + /* FINISHME: Walk up the dereference chain and figure out if + * FINISHME: the variable is read-only. + */ + } + + return true; +} ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, unsigned w, unsigned count) diff --git a/ir.h b/ir.h index 381af357b81..64ed8818431 100644 --- a/ir.h +++ b/ir.h @@ -540,17 +540,7 @@ public: v->visit(this); } - bool is_lvalue() - { - if (var == NULL) - return false; - - ir_variable *const as_var = var->as_variable(); - if (as_var == NULL) - return false; - - return !as_var->read_only; - } + bool is_lvalue(); enum { ir_reference_variable, -- cgit v1.2.3 From 3f151509327629ce7d7cbfec42cae987ebf6639f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Apr 2010 01:53:57 -1000 Subject: Test that invalid quailfiers aren't used on variables in GLSL 1.10. --- ast_to_hir.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 8ed56d5800b..5e0dcaae227 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1332,6 +1332,32 @@ ast_declarator_list::hir(exec_list *instructions, var = new ir_variable(var_type, decl->identifier); + /* From page 22 (page 28 of the PDF) of the GLSL 1.10 specification; + * + * "Global variables can only use the qualifiers const, + * attribute, uni form, or varying. Only one may be + * specified. + * + * Local variables can only use the qualifier const." + * + * This is relaxed in GLSL 1.30. + */ + if (state->language_version < 120) { + if (this->type->qualifier.out) { + _mesa_glsl_error(& loc, state, + "`out' qualifier in declaration of `%s' " + "only valid for function parameters in GLSL 1.10.", + decl->identifier); + } + if (this->type->qualifier.in) { + _mesa_glsl_error(& loc, state, + "`in' qualifier in declaration of `%s' " + "only valid for function parameters in GLSL 1.10.", + decl->identifier); + } + /* FINISHME: Test for other invalid qualifiers. */ + } + apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc); -- cgit v1.2.3 From 106d122318b94188b0e00115cd5242e0e679f807 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Apr 2010 01:59:50 -1000 Subject: Add PASS / FAIL annotations to tests missing them. This tricked my import of the tests into piglit. --- tests/constructor-01.glsl | 2 ++ tests/parameters-01.glsl | 2 ++ tests/parameters-02.glsl | 2 ++ tests/swiz-01.glsl | 1 + tests/swiz-02.glsl | 1 + 5 files changed, 8 insertions(+) diff --git a/tests/constructor-01.glsl b/tests/constructor-01.glsl index f7af569c683..fdfaf898663 100644 --- a/tests/constructor-01.glsl +++ b/tests/constructor-01.glsl @@ -1,3 +1,5 @@ +/* PASS */ + void main() { gl_Position = vec4(1.0, 1.0, 1.0, 0.0);; diff --git a/tests/parameters-01.glsl b/tests/parameters-01.glsl index f0beb6c35d1..b485106e9d7 100644 --- a/tests/parameters-01.glsl +++ b/tests/parameters-01.glsl @@ -1,3 +1,5 @@ +/* FAIL: redefinition of a() */ + void a() { ; diff --git a/tests/parameters-02.glsl b/tests/parameters-02.glsl index 58f44e532e1..7ff5f59ab79 100644 --- a/tests/parameters-02.glsl +++ b/tests/parameters-02.glsl @@ -1,3 +1,5 @@ +/* PASS */ + void a() { ; diff --git a/tests/swiz-01.glsl b/tests/swiz-01.glsl index a72af37c677..3268fa178c1 100644 --- a/tests/swiz-01.glsl +++ b/tests/swiz-01.glsl @@ -1,3 +1,4 @@ +/* PASS */ #version 120 void main() diff --git a/tests/swiz-02.glsl b/tests/swiz-02.glsl index 5e2acd1a25a..e3f043c47bd 100644 --- a/tests/swiz-02.glsl +++ b/tests/swiz-02.glsl @@ -1,3 +1,4 @@ +/* FAIL: assignment of a vec2 to a float */ #version 120 void main() -- cgit v1.2.3 From dc58b3f8ccd817fdee390a3df5b8e0fb29d5397c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Apr 2010 02:13:43 -1000 Subject: Add conversion of bool to float as an IR operation to match int to float. --- ast_function.cpp | 2 +- ast_to_hir.cpp | 3 ++- ir.cpp | 2 ++ ir.h | 2 ++ ir_print_visitor.cpp | 2 ++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 91d4f15a3b7..2ca8976d508 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -139,7 +139,7 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) case GLSL_TYPE_INT: return new ir_expression(ir_unop_i2f, desired_type, src, NULL); case GLSL_TYPE_BOOL: - assert(!"FINISHME: Convert bool to float."); + return new ir_expression(ir_unop_b2f, desired_type, src, NULL); } break; case GLSL_TYPE_BOOL: { diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 5e0dcaae227..dd846740042 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -120,7 +120,8 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, from = new ir_expression(ir_unop_u2f, to, from, NULL); break; case GLSL_TYPE_BOOL: - assert(!"FINISHME: Convert bool to float."); + from = new ir_expression(ir_unop_b2f, to, from, NULL); + break; default: assert(0); } diff --git a/ir.cpp b/ir.cpp index d9faac03d46..674ba10f57e 100644 --- a/ir.cpp +++ b/ir.cpp @@ -64,6 +64,8 @@ ir_expression::get_num_operands(void) 1, /* ir_unop_log2 */ 1, /* ir_unop_f2i */ 1, /* ir_unop_i2f */ + 1, /* ir_unop_f2b */ + 1, /* ir_unop_b2f */ 1, /* ir_unop_u2f */ 1, /* ir_unop_trunc */ diff --git a/ir.h b/ir.h index 64ed8818431..58aa63123b4 100644 --- a/ir.h +++ b/ir.h @@ -316,6 +316,8 @@ enum ir_expression_operation { ir_unop_log2, ir_unop_f2i, /**< Float-to-integer conversion. */ ir_unop_i2f, /**< Integer-to-float conversion. */ + ir_unop_f2b, /**< Float-to-boolean conversion */ + ir_unop_b2f, /**< Boolean-to-float conversion */ ir_unop_u2f, /**< Unsigned-to-float conversion. */ /** diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index b207262044d..e3aeb69a1e9 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -100,6 +100,8 @@ void ir_print_visitor::visit(ir_expression *ir) "log2", "f2i", "i2f", + "f2b", + "b2f", "u2f", "trunc", "ceil", -- cgit v1.2.3 From c2cb84e17b2f7a5db146faa9c9c2a2ffac4b6c19 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Apr 2010 02:17:08 -1000 Subject: Add bool/int conversion as IR operations. Fixes constructor-09.glsl and CorrectParse2.frag. --- ast_function.cpp | 2 +- ir.cpp | 2 ++ ir.h | 2 ++ ir_print_visitor.cpp | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ast_function.cpp b/ast_function.cpp index 2ca8976d508..09b7879185b 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -130,7 +130,7 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) return new ir_expression(ir_unop_f2i, desired_type, src, NULL); else { assert(b == GLSL_TYPE_BOOL); - assert(!"FINISHME: Convert bool to int / uint."); + return new ir_expression(ir_unop_f2b, desired_type, src, NULL); } case GLSL_TYPE_FLOAT: switch (b) { diff --git a/ir.cpp b/ir.cpp index 674ba10f57e..dd426df566a 100644 --- a/ir.cpp +++ b/ir.cpp @@ -66,6 +66,8 @@ ir_expression::get_num_operands(void) 1, /* ir_unop_i2f */ 1, /* ir_unop_f2b */ 1, /* ir_unop_b2f */ + 1, /* ir_unop_i2b */ + 1, /* ir_unop_b2i */ 1, /* ir_unop_u2f */ 1, /* ir_unop_trunc */ diff --git a/ir.h b/ir.h index 58aa63123b4..3caff3624ae 100644 --- a/ir.h +++ b/ir.h @@ -318,6 +318,8 @@ enum ir_expression_operation { ir_unop_i2f, /**< Integer-to-float conversion. */ ir_unop_f2b, /**< Float-to-boolean conversion */ ir_unop_b2f, /**< Boolean-to-float conversion */ + ir_unop_i2b, /**< int-to-boolean conversion */ + ir_unop_b2i, /**< Boolean-to-int conversion */ ir_unop_u2f, /**< Unsigned-to-float conversion. */ /** diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index e3aeb69a1e9..e1fedd78a93 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -102,6 +102,8 @@ void ir_print_visitor::visit(ir_expression *ir) "i2f", "f2b", "b2f", + "i2b", + "b2i", "u2f", "trunc", "ceil", -- cgit v1.2.3 From fe1c7ff6c62ffc985035c83a1ffadf1daad4b4ff Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Apr 2010 11:45:06 -0700 Subject: Fix matching of integer function parameters This causes the following tests to pass: glslparsertest/shaders/function10.frag --- ir_function.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ir_function.cpp b/ir_function.cpp index b6139c4a9fe..4d246392ad7 100644 --- a/ir_function.cpp +++ b/ir_function.cpp @@ -35,16 +35,18 @@ type_compare(const glsl_type *a, const glsl_type *b) switch (a->base_type) { case GLSL_TYPE_UINT: case GLSL_TYPE_INT: - case GLSL_TYPE_FLOAT: case GLSL_TYPE_BOOL: - if ((a->vector_elements != b->vector_elements) - || (a->matrix_columns != b->matrix_columns)) + /* There is no implicit conversion to or from integer types or bool. + */ + if ((a->is_integer() != b->is_integer()) + || (a->is_boolean() != b->is_boolean())) return -1; - /* There is no implicit conversion to or from bool. - */ - if ((a->base_type == GLSL_TYPE_BOOL) - || (b->base_type == GLSL_TYPE_BOOL)) + /* FALLTHROUGH */ + + case GLSL_TYPE_FLOAT: + if ((a->vector_elements != b->vector_elements) + || (a->matrix_columns != b->matrix_columns)) return -1; return 1; -- cgit v1.2.3 From 3f9a73d121e7cf160b268b2c5d16e8584eea94db Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Apr 2010 11:59:57 -0700 Subject: Make built-in gl_TexCoord available in vertex and fragment shaders --- ir_variable.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/ir_variable.cpp b/ir_variable.cpp index 1b4b742ac4c..0edb19e28fb 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -31,19 +31,13 @@ #endif static void -add_builtin_variable(const builtin_variable *proto, exec_list *instructions, +add_variable(const char *name, enum ir_variable_mode mode, + const glsl_type *type, exec_list *instructions, glsl_symbol_table *symtab) { - /* Create a new variable declaration from the description supplied by - * the caller. - */ - const glsl_type *const type = symtab->get_type(proto->type); - - assert(type != NULL); - - ir_variable *var = new ir_variable(type, proto->name); + ir_variable *var = new ir_variable(type, name); - var->mode = proto->mode; + var->mode = mode; if (var->mode != ir_var_out) var->read_only = true; @@ -56,6 +50,22 @@ add_builtin_variable(const builtin_variable *proto, exec_list *instructions, symtab->add_variable(var->name, var); } + +static void +add_builtin_variable(const builtin_variable *proto, exec_list *instructions, + glsl_symbol_table *symtab) +{ + /* Create a new variable declaration from the description supplied by + * the caller. + */ + const glsl_type *const type = symtab->get_type(proto->type); + + assert(type != NULL); + + add_variable(proto->name, proto->mode, type, instructions, symtab); +} + + static void generate_110_uniforms(exec_list *instructions, glsl_symbol_table *symtab) @@ -105,10 +115,17 @@ generate_110_vs_variables(exec_list *instructions, } generate_110_uniforms(instructions, symtab); - /* FINISHME: Add support fo gl_TexCoord. The size of this array is - * FINISHME: implementation dependent based on the value of - * FINISHME: GL_MAX_TEXTURE_COORDS. + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be + * FINISHME: at least 2, so hard-code 2 for now. */ + const glsl_type *const vec4_type = + glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 0); + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(vec4_type, 2); + + add_variable("gl_TexCoord", ir_var_out, vec4_array_type, instructions, + symtab); } @@ -168,7 +185,6 @@ generate_110_fs_variables(exec_list *instructions, instructions, symtab); } - /* FINISHME: Add support for gl_TexCoord[] */ for (unsigned i = 0 ; i < Elements(builtin_110_deprecated_fs_variables) ; i++) { @@ -178,6 +194,18 @@ generate_110_fs_variables(exec_list *instructions, generate_110_uniforms(instructions, symtab); /* FINISHME: Add support for gl_FragData[GL_MAX_DRAW_BUFFERS]. */ + + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be + * FINISHME: at least 2, so hard-code 2 for now. + */ + const glsl_type *const vec4_type = + glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 0); + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(vec4_type, 2); + + add_variable("gl_TexCoord", ir_var_in, vec4_array_type, instructions, + symtab); } static void -- cgit v1.2.3 From 45d8a70c12ee6ea956baaf898324a828496382f6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Apr 2010 15:09:33 -0700 Subject: Require that function formal parameters have names --- ast.h | 8 ++++++++ ast_to_hir.cpp | 22 +++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ast.h b/ast.h index 0dfd02a9cd1..37df4a0e086 100644 --- a/ast.h +++ b/ast.h @@ -432,6 +432,14 @@ public: char *identifier; int is_array; ast_expression *array_size; + + static void parameters_to_hir(simple_node *ast_parameters, + bool formal, exec_list *ir_parameters, + struct _mesa_glsl_parse_state *state); + +private: + /** Is this parameter declaration part of a formal parameter list? */ + bool formal_parameter; }; diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index dd846740042..3fddd5f1961 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1628,6 +1628,11 @@ ast_parameter_declarator::hir(exec_list *instructions, if (type->is_void() && (this->identifier == NULL)) return NULL; + if (formal_parameter && (this->identifier == NULL)) { + _mesa_glsl_error(& loc, state, "formal parameter lacks a name"); + return NULL; + } + ir_variable *var = new ir_variable(type, this->identifier); /* FINISHME: Handle array declarations. Note that this requires @@ -1649,17 +1654,18 @@ ast_parameter_declarator::hir(exec_list *instructions, } -static void -ast_function_parameters_to_hir(struct simple_node *ast_parameters, - exec_list *ir_parameters, - struct _mesa_glsl_parse_state *state) +void +ast_parameter_declarator::parameters_to_hir(struct simple_node *ast_parameters, + bool formal, + exec_list *ir_parameters, + _mesa_glsl_parse_state *state) { struct simple_node *ptr; foreach (ptr, ast_parameters) { - ast_node *param = (ast_node *)ptr; + ast_parameter_declarator *param = (ast_parameter_declarator *)ptr; + param->formal_parameter = formal; param->hir(ir_parameters, state); - } } @@ -1713,7 +1719,9 @@ ast_function::hir(exec_list *instructions, * used below to compare this function's signature with previously seen * signatures for functions with the same name. */ - ast_function_parameters_to_hir(& this->parameters, & hir_parameters, state); + ast_parameter_declarator::parameters_to_hir(& this->parameters, + is_definition, + & hir_parameters, state); const char *return_type_name; const glsl_type *return_type = -- cgit v1.2.3 From cf37c9e8dad4349e45cb91d36957484fd76ce264 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Apr 2010 15:30:45 -0700 Subject: Additional void parameter checks If there is a void parameter it must not have a name, and it must be the only parameter. --- ast.h | 7 +++++++ ast_to_hir.cpp | 23 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ast.h b/ast.h index 37df4a0e086..f73e74906f0 100644 --- a/ast.h +++ b/ast.h @@ -440,6 +440,13 @@ public: private: /** Is this parameter declaration part of a formal parameter list? */ bool formal_parameter; + + /** + * Is this parameter 'void' type? + * + * This field is set by \c ::hir. + */ + bool is_void; }; diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 3fddd5f1961..cc985814db6 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1625,14 +1625,21 @@ ast_parameter_declarator::hir(exec_list *instructions, * for a function, which avoids tripping up checks for main taking * parameters and lookups of an unnamed symbol. */ - if (type->is_void() && (this->identifier == NULL)) + if (type->is_void()) { + if (this->identifier != NULL) + _mesa_glsl_error(& loc, state, + "named parameter cannot have type `void'"); + + is_void = true; return NULL; + } if (formal_parameter && (this->identifier == NULL)) { _mesa_glsl_error(& loc, state, "formal parameter lacks a name"); return NULL; } + is_void = false; ir_variable *var = new ir_variable(type, this->identifier); /* FINISHME: Handle array declarations. Note that this requires @@ -1661,11 +1668,25 @@ ast_parameter_declarator::parameters_to_hir(struct simple_node *ast_parameters, _mesa_glsl_parse_state *state) { struct simple_node *ptr; + ast_parameter_declarator *void_param = NULL; + unsigned count = 0; foreach (ptr, ast_parameters) { ast_parameter_declarator *param = (ast_parameter_declarator *)ptr; param->formal_parameter = formal; param->hir(ir_parameters, state); + + if (param->is_void) + void_param = param; + + count++; + } + + if ((void_param != NULL) && (count > 1)) { + YYLTYPE loc = void_param->get_location(); + + _mesa_glsl_error(& loc, state, + "`void' parameter must be only parameter"); } } -- cgit v1.2.3 From c35bb00130a3f400af1ab9c5eff555c4f9e143d2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Apr 2010 15:51:02 -0700 Subject: Ensure that 'in' and 'inout' formal parameters are valid lvalues This causes the following tests to pass: glslparsertest/shaders/function10.frag --- ast_function.cpp | 31 +++++++++++++++++++++++++++++++ ir_function.cpp | 3 --- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 09b7879185b..28698375723 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -63,6 +63,37 @@ process_call(exec_list *instructions, ir_function *f, (void) instructions; if (sig != NULL) { + /* Verify that 'out' and 'inout' actual parameters are lvalues. This + * isn't done in ir_function::matching_signature because that function + * cannot generate the necessary diagnostics. + */ + exec_list_iterator actual_iter = actual_parameters->iterator(); + exec_list_iterator formal_iter = sig->parameters.iterator(); + + while (actual_iter.has_next()) { + ir_rvalue *actual = + ((ir_instruction *) actual_iter.get())->as_rvalue(); + ir_variable *formal = + ((ir_instruction *) formal_iter.get())->as_variable(); + + assert(actual != NULL); + assert(formal != NULL); + + if ((formal->mode == ir_var_out) + || (formal->mode == ir_var_inout)) { + if (! actual->is_lvalue()) { + /* FINISHME: Log a better diagnostic here. There is no way + * FINISHME: to tell the user which parameter is invalid. + */ + _mesa_glsl_error(loc, state, "`%s' parameter is not lvalue", + (formal->mode == ir_var_out) ? "out" : "inout"); + } + } + + actual_iter.next(); + formal_iter.next(); + } + /* FINISHME: The list of actual parameters needs to be modified to * FINISHME: include any necessary conversions. */ diff --git a/ir_function.cpp b/ir_function.cpp index 4d246392ad7..a8b73f1e1aa 100644 --- a/ir_function.cpp +++ b/ir_function.cpp @@ -126,13 +126,10 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) break; case ir_var_out: - /* FINISHME: Make sure that actual is a valid lvalue. */ score = type_compare(actual->type, param->type); break; case ir_var_inout: - /* FINISHME: Make sure that actual is a valid lvalue. */ - /* Since there are no bi-directional automatic conversions (e.g., * there is int -> float but no float -> int), inout parameters must * be exact matches. -- cgit v1.2.3 From cb9cba20a0923573d61a6360e45a7daac93a982b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Apr 2010 16:08:44 -0700 Subject: Use glsl_type::element_type to get the type of array elements --- ast_function.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ast_function.cpp b/ast_function.cpp index 28698375723..cd57c32040b 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -264,7 +264,7 @@ process_array_constructor(exec_list *instructions, if (constructor_type->length == 0) { constructor_type = - glsl_type::get_array_instance(constructor_type->get_base_type(), + glsl_type::get_array_instance(constructor_type->element_type(), parameter_count); assert(constructor_type != NULL); assert(constructor_type->length == parameter_count); -- cgit v1.2.3 From 2d946634eb3761dbec5aa8806fc36ff6d65b4f9c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Apr 2010 17:05:59 -0700 Subject: Whole structures are assignable Whole arrays are assignable in GLSL 1.20 and later, but it's not clear how to handle that within the IR because the IR is supposed to be shading language version agnostic. --- ir.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ir.cpp b/ir.cpp index dd426df566a..ef93c406198 100644 --- a/ir.cpp +++ b/ir.cpp @@ -200,8 +200,11 @@ ir_dereference::is_lvalue() if (var == NULL) return false; - if (this->type->base_type == GLSL_TYPE_ARRAY || - this->type->base_type == GLSL_TYPE_STRUCT) + /* Arrays are not assignable in GLSL 1.10, but in GLSL 1.20 and later they + * are. + */ + /* FINISHME: Handle GLSL 1.10 vs 1.20 differences. */ + if (this->type->base_type == GLSL_TYPE_ARRAY) return false; if (mode == ir_reference_variable) { -- cgit v1.2.3 From 9d975377ca6dae7805804c0fbe625bb7c5f9e095 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Apr 2010 17:17:47 -0700 Subject: Track whether whole-arrays are assignable In GLSL 1.10 this was not allowed, but in GLSL 1.20 and later it is. This causes the following tests to pass: glslparsertest/glsl2/array-09.vert glslparsertest/glsl2/array-13.vert --- ast_to_hir.cpp | 4 ++++ ir.cpp | 10 +++------- ir.h | 8 ++++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index cc985814db6..c0266e9b492 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1283,6 +1283,10 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, var->interpolation = ir_var_noperspective; else var->interpolation = ir_var_smooth; + + if (var->type->is_array() && (state->language_version >= 120)) { + var->array_lvalue = true; + } } diff --git a/ir.cpp b/ir.cpp index ef93c406198..c900a285bc7 100644 --- a/ir.cpp +++ b/ir.cpp @@ -200,18 +200,14 @@ ir_dereference::is_lvalue() if (var == NULL) return false; - /* Arrays are not assignable in GLSL 1.10, but in GLSL 1.20 and later they - * are. - */ - /* FINISHME: Handle GLSL 1.10 vs 1.20 differences. */ - if (this->type->base_type == GLSL_TYPE_ARRAY) - return false; - if (mode == ir_reference_variable) { ir_variable *const as_var = var->as_variable(); if (as_var == NULL) return false; + if (as_var->type->is_array() && !as_var->array_lvalue) + return false; + return !as_var->read_only; } else if (mode == ir_reference_array) { /* FINISHME: Walk up the dereference chain and figure out if diff --git a/ir.h b/ir.h index 3caff3624ae..5267d2bc787 100644 --- a/ir.h +++ b/ir.h @@ -146,6 +146,14 @@ public: unsigned mode:3; unsigned interpolation:2; + + /** + * Flag that the whole array is assignable + * + * In GLSL 1.20 and later whole arrays are assignable (and comparable for + * equality). This flag enables this behavior. + */ + unsigned array_lvalue:1; }; -- cgit v1.2.3 From 0157f41e5e644632393edf903f3c1adb1cf782cd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Apr 2010 17:44:39 -0700 Subject: Propagate sizes when assigning a whole array to an unsized array --- ast_to_hir.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index c0266e9b492..f7a9ba883f9 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -433,13 +433,23 @@ validate_assignment(const glsl_type *lhs_type, ir_rvalue *rhs) if (rhs_type->is_error()) return rhs; - /* FINISHME: For GLSL 1.10, check that the types are not arrays. */ - /* If the types are identical, the assignment can trivially proceed. */ if (rhs_type == lhs_type) return rhs; + /* If the array element types are the same and the size of the LHS is zero, + * the assignment is okay. + * + * Note: Whole-array assignments are not permitted in GLSL 1.10, but this + * is handled by ir_dereference::is_lvalue. + */ + if (lhs_type->is_array() && rhs->type->is_array() + && (lhs_type->element_type() == rhs->type->element_type()) + && (lhs_type->array_size() == 0)) { + return rhs; + } + /* FINISHME: Check for and apply automatic conversions. */ return NULL; } @@ -464,6 +474,24 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, _mesa_glsl_error(& lhs_loc, state, "type mismatch"); } else { rhs = new_rhs; + + /* If the LHS array was not declared with a size, it takes it size from + * the RHS. If the LHS is an l-value and a whole array, it must be a + * dereference of a variable. Any other case would require that the LHS + * is either not an l-value or not a whole array. + */ + if (lhs->type->array_size() == 0) { + ir_dereference *const d = lhs->as_dereference(); + + assert(d != NULL); + + ir_variable *const var = d->var->as_variable(); + + assert(var != NULL); + + var->type = glsl_type::get_array_instance(lhs->type->element_type(), + rhs->type->array_size()); + } } ir_instruction *tmp = new ir_assignment(lhs, rhs, NULL); -- cgit v1.2.3 From b2deb19dc30eb12bff228149221a005d1971343e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 10:30:15 -0700 Subject: Set correct type for ir_dereference of a matrix or a vector --- ir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ir.cpp b/ir.cpp index c900a285bc7..88308ce1790 100644 --- a/ir.cpp +++ b/ir.cpp @@ -186,7 +186,9 @@ ir_dereference::ir_dereference(ir_instruction *var, if (vt->is_array()) { type = vt->element_type(); - } else if (vt->is_matrix() || vt->is_vector()) { + } else if (vt->is_matrix()) { + type = vt->column_type(); + } else if (vt->is_vector()) { type = vt->get_base_type(); } } -- cgit v1.2.3 From 63038e18ad44e4e021da9a6dbe7a075e57ff6415 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 13:16:00 -0700 Subject: Allow dereference of vectors and matrices with [] This causes the following tests to pass: glslparsertest/glsl2/matrix-11.vert glslparsertest/glsl2/matrix-12.vert glslparsertest/shaders/CorrectParse2.vert glslparsertest/shaders/CorrectSwizzle2.frag --- ast_to_hir.cpp | 55 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index f7a9ba883f9..c9f93cbcc42 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1008,10 +1008,12 @@ ast_expression::hir(exec_list *instructions, if (error_emitted) break; - /* FINISHME: Handle vectors and matrices accessed with []. */ - if (!array->type->is_array()) { + if (!array->type->is_array() + && !array->type->is_matrix() + && !array->type->is_vector()) { _mesa_glsl_error(& index_loc, state, - "cannot dereference non-array"); + "cannot dereference non-array / non-matrix / " + "non-vector"); error_emitted = true; } @@ -1033,6 +1035,16 @@ ast_expression::hir(exec_list *instructions, ir_constant *const const_index = op[1]->constant_expression_value(); if (const_index != NULL) { const int idx = const_index->value.i[0]; + const char *type_name; + unsigned bound = 0; + + if (array->type->is_matrix()) { + type_name = "matrix"; + } else if (array->type->is_vector()) { + type_name = "vector"; + } else { + type_name = "array"; + } /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec: * @@ -1042,23 +1054,36 @@ ast_expression::hir(exec_list *instructions, * declared size. It is also illegal to index an array with a * negative constant expression." */ - if ((array->type->array_size() > 0) - && (array->type->array_size() <= idx)) { - _mesa_glsl_error(& loc, state, - "array index must be < %u", - array->type->array_size()); - error_emitted = true; + if (array->type->is_matrix()) { + if (array->type->row_type()->vector_elements <= idx) { + bound = array->type->row_type()->vector_elements; + } + } else if (array->type->is_vector()) { + if (array->type->vector_elements <= idx) { + bound = array->type->vector_elements; + } + } else { + if ((array->type->array_size() > 0) + && (array->type->array_size() <= idx)) { + bound = array->type->array_size(); + } } - if (idx < 0) { - _mesa_glsl_error(& loc, state, - "array index must be >= 0"); + if (bound > 0) { + _mesa_glsl_error(& loc, state, "%s index must be < %u", + type_name, bound); + error_emitted = true; + } else if (idx < 0) { + _mesa_glsl_error(& loc, state, "%s index must be >= 0", + type_name); error_emitted = true; } - ir_variable *const v = array->as_variable(); - if ((v != NULL) && (unsigned(idx) > v->max_array_access)) - v->max_array_access = idx; + if (array->type->is_array()) { + ir_variable *const v = array->as_variable(); + if ((v != NULL) && (unsigned(idx) > v->max_array_access)) + v->max_array_access = idx; + } } if (error_emitted) -- cgit v1.2.3 From 63f394203a8be9b87f8617cd7a56a0806c0870b3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 14:35:47 -0700 Subject: Set lower bound on size implied by whole-array assignment When an unsized array is accessed with a constant extension index this sets a lower bound on the allowable sizes. When the unsized array gets a size set due to a whole-array assignment, this size must be at least as large as the implied lower bound. This causes the following tests to pass: glslparsertest/glsl2/array-16.vert --- ast_to_hir.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index c9f93cbcc42..9d067be02d7 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -489,6 +489,13 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, assert(var != NULL); + if (var->max_array_access >= unsigned(rhs->type->array_size())) { + /* FINISHME: This should actually log the location of the RHS. */ + _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due to " + "previous access", + var->max_array_access); + } + var->type = glsl_type::get_array_instance(lhs->type->element_type(), rhs->type->array_size()); } -- cgit v1.2.3 From 271e1996734c3948b71b6f28bae37e25b7ec048a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Apr 2010 23:47:06 -0700 Subject: Add definition of gl_ClipDistance[] --- ir_variable.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ir_variable.cpp b/ir_variable.cpp index 0edb19e28fb..d81e0568508 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -151,10 +151,14 @@ generate_130_vs_variables(exec_list *instructions, instructions, symtab); } - /* FINISHME: Add support fo gl_ClipDistance. The size of this array is - * FINISHME: implementation dependent based on the value of - * FINISHME: GL_MAX_CLIP_DISTANCES. + /* FINISHME: The size of this array is implementation dependent based on + * FINISHME: the value of GL_MAX_CLIP_DISTANCES. */ + const glsl_type *const clip_distance_array_type = + glsl_type::get_array_instance(glsl_type::float_type, 8); + add_variable("gl_ClipDistance", ir_var_out, clip_distance_array_type, + instructions, symtab); + } -- cgit v1.2.3 From 62735694a1dfc09a16ea32312877cd49c7982118 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 5 Apr 2010 15:24:28 -0700 Subject: Add a constant folding optimization pass. --- Makefile.am | 3 +- glsl_parser_extras.cpp | 11 ++++ ir_constant_folding.cpp | 131 ++++++++++++++++++++++++++++++++++++++++++++++++ ir_constant_folding.h | 62 +++++++++++++++++++++++ 4 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 ir_constant_folding.cpp create mode 100644 ir_constant_folding.h diff --git a/Makefile.am b/Makefile.am index c1c96ba2b90..32c804c1252 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,8 @@ glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \ ir.cpp hir_field_selection.cpp builtin_function.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \ - ir_constant_expression.cpp + ir_constant_expression.cpp \ + ir_constant_folding.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index eb19ed7b91b..84a3fd90715 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -34,6 +34,7 @@ #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" +#include "ir_constant_folding.h" #include "ir_print_visitor.h" void @@ -647,6 +648,16 @@ main(int argc, char **argv) _mesa_ast_to_hir(&instructions, &state); + /* Optimization passes */ + if (!state.error) { + /* Constant folding */ + foreach_iter(exec_list_iterator, iter, instructions) { + ir_constant_folding_visitor v; + ((ir_instruction *)iter.get())->accept(& v); + } + } + + /* Print out the resulting IR */ printf("\n\n"); if (!state.error) { diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp new file mode 100644 index 00000000000..306f211fe56 --- /dev/null +++ b/ir_constant_folding.cpp @@ -0,0 +1,131 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_constant_folding.cpp + * Replace constant-valued expressions with references to constant values. + */ + +#define NULL 0 +#include "ir.h" +#include "ir_visitor.h" +#include "ir_constant_folding.h" +#include "glsl_types.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +void +ir_constant_folding_visitor::visit(ir_variable *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_label *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_function_signature *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_function *ir) +{ + (void) ir; +} + +void +ir_constant_folding_visitor::visit(ir_expression *ir) +{ + ir_constant *op[2]; + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + op[operand] = ir->operands[operand]->constant_expression_value(); + if (op[operand]) { + ir->operands[operand] = op[operand]; + } + } +} + + +void +ir_constant_folding_visitor::visit(ir_swizzle *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_dereference *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_assignment *ir) +{ + ir_constant *const_val = ir->rhs->constant_expression_value(); + if (const_val) + ir->rhs = const_val; + else + ir->rhs->accept(this); +} + + +void +ir_constant_folding_visitor::visit(ir_constant *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_call *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_return *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_if *ir) +{ + (void) ir; +} diff --git a/ir_constant_folding.h b/ir_constant_folding.h new file mode 100644 index 00000000000..9e151ecde66 --- /dev/null +++ b/ir_constant_folding.h @@ -0,0 +1,62 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_constant_folding.h + * Replace constant-valued expressions with references to constant values. + */ + +class ir_constant_folding_visitor : public ir_visitor { +public: + ir_constant_folding_visitor() + { + /* empty */ + } + + virtual ~ir_constant_folding_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_label *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ +}; -- cgit v1.2.3 From 85171c2dd8c7050511cb7708d75e574005262bf0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Apr 2010 09:55:45 -0700 Subject: Add ir_constant_expression.cpp support for <, >, <=, >=. This results in folding one more constant expression in CorrectParse2.frag. --- ir_constant_expression.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 69a36130801..f90c69b72c8 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -252,6 +252,72 @@ ir_constant_visitor::visit(ir_expression *ir) for (c = 0; c < ir->operands[0]->type->components(); c++) b[c] = op[0]->value.b[c] || op[1]->value.b[c]; break; + + case ir_binop_less: + type = glsl_type::bool_type; + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + b[0] = op[0]->value.u[0] < op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + b[0] = op[0]->value.i[0] < op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + b[0] = op[0]->value.f[0] < op[1]->value.f[0]; + break; + default: + assert(0); + } + break; + case ir_binop_greater: + type = glsl_type::bool_type; + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + b[0] = op[0]->value.u[0] > op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + b[0] = op[0]->value.i[0] > op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + b[0] = op[0]->value.f[0] > op[1]->value.f[0]; + break; + default: + assert(0); + } + break; + case ir_binop_lequal: + type = glsl_type::bool_type; + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + b[0] = op[0]->value.u[0] <= op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + b[0] = op[0]->value.i[0] <= op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + b[0] = op[0]->value.f[0] <= op[1]->value.f[0]; + break; + default: + assert(0); + } + break; + case ir_binop_gequal: + type = glsl_type::bool_type; + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + b[0] = op[0]->value.u[0] >= op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + b[0] = op[0]->value.i[0] >= op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + b[0] = op[0]->value.f[0] >= op[1]->value.f[0]; + break; + default: + assert(0); + } + break; + default: break; } -- cgit v1.2.3 From ec1949e8041b63f59aab63440ad9eeeddd226ce3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Apr 2010 10:02:27 -0700 Subject: Add support for =, != to ir_constant_expresion.cpp This results in constant folding of one more expression in CorrectParse2.frag. --- ir_constant_expression.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index f90c69b72c8..6325df5cc73 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -318,6 +318,49 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_binop_equal: + if (ir->operands[0]->type == ir->operands[1]->type) { + type = glsl_type::bool_type; + b[0] = true; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + b[0] = b[0] && op[0]->value.u[c] == op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + b[0] = b[0] && op[0]->value.i[c] == op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + b[0] = b[0] && op[0]->value.f[c] == op[1]->value.f[c]; + break; + default: + assert(0); + } + } + } + break; + case ir_binop_nequal: + if (ir->operands[0]->type == ir->operands[1]->type) { + type = glsl_type::bool_type; + b[0] = false; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + b[0] = b[0] || op[0]->value.u[c] != op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + b[0] = b[0] || op[0]->value.i[c] != op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + b[0] = b[0] || op[0]->value.f[c] != op[1]->value.f[c]; + break; + default: + assert(0); + } + } + } + break; + default: break; } -- cgit v1.2.3 From 3fff009af169313fa22996d93ad195cf12729763 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Apr 2010 10:07:20 -0700 Subject: Fold constant expressions in if conditionals. Fixes up 3 more expressions in CorrectParse2.frag. --- ir_constant_folding.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index 306f211fe56..b9dee37edfb 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -127,5 +127,9 @@ ir_constant_folding_visitor::visit(ir_return *ir) void ir_constant_folding_visitor::visit(ir_if *ir) { - (void) ir; + ir_constant *const_val = ir->condition->constant_expression_value(); + if (const_val) + ir->condition = const_val; + else + ir->condition->accept(this); } -- cgit v1.2.3 From 326c676236e6a3c90db63e4d0c893aa4f9c21876 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Apr 2010 10:30:54 -0700 Subject: Handle constant expressions using derefs of const values. Fixes CorrectParse1.frag and makes for a ton of folding in CorrectParse2.frag. --- ast_to_hir.cpp | 7 +++++-- ir.cpp | 1 + ir.h | 5 +++++ ir_constant_expression.cpp | 9 ++++++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 9d067be02d7..ddeab8db67c 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1603,12 +1603,15 @@ ast_declarator_list::hir(exec_list *instructions, * declaration. */ if (this->type->qualifier.constant) { - rhs = rhs->constant_expression_value(); - if (!rhs) { + ir_constant *constant_value = rhs->constant_expression_value(); + if (!constant_value) { _mesa_glsl_error(& initializer_loc, state, "initializer of const variable `%s' must be a " "constant expression", decl->identifier); + } else { + rhs = constant_value; + var->constant_value = constant_value; } } diff --git a/ir.cpp b/ir.cpp index 88308ce1790..0708e492850 100644 --- a/ir.cpp +++ b/ir.cpp @@ -338,6 +338,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) { this->type = type; this->name = name; + this->constant_value = NULL; if (type && type->base_type == GLSL_TYPE_SAMPLER) this->read_only = true; diff --git a/ir.h b/ir.h index 5267d2bc787..a515d9a7d0a 100644 --- a/ir.h +++ b/ir.h @@ -154,6 +154,11 @@ public: * equality). This flag enables this behavior. */ unsigned array_lvalue:1; + + /** + * Value assigned in the initializer of a variable declared "const" + */ + ir_constant *constant_value; }; diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 6325df5cc73..9c98ceb66cf 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -395,8 +395,15 @@ ir_constant_visitor::visit(ir_swizzle *ir) void ir_constant_visitor::visit(ir_dereference *ir) { - (void) ir; value = NULL; + + if (ir->mode == ir_dereference::ir_reference_variable) { + ir_variable *var = ir->var->as_variable(); + if (var && var->constant_value) { + value = new ir_constant(ir->type, &var->constant_value->value); + } + } + /* FINISHME: Other dereference modes. */ } -- cgit v1.2.3 From af18641f0a9f717fdeab8d3e94c1df93b48c4d30 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Apr 2010 10:53:57 -0700 Subject: Add float/int conversion to ir_constant_expression.cpp. Gives CorrectParse2.frag one more constant folding. --- ir_constant_expression.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 9c98ceb66cf..e1073cde1ce 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -153,6 +153,26 @@ ir_constant_visitor::visit(ir_expression *ir) for (c = 0; c < ir->operands[0]->type->components(); c++) b[c] = !op[0]->value.b[c]; break; + + case ir_unop_f2i: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + i[c] = op[0]->value.f[c]; + } + break; + case ir_unop_i2f: + assert(op[0]->type->base_type == GLSL_TYPE_UINT || + op[0]->type->base_type == GLSL_TYPE_INT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + if (op[0]->type->base_type == GLSL_TYPE_INT) + f[c] = op[0]->value.i[c]; + else + f[c] = op[0]->value.u[c]; + } + break; + case ir_binop_add: if (ir->operands[0]->type == ir->operands[1]->type) { type = ir->operands[0]->type; -- cgit v1.2.3 From bae5be356eef9efd893e8937d11ecb1b5f3feee6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Apr 2010 11:11:05 -0700 Subject: Perform constant folding on array indices. Replaces a constant var deref with a constant value in CorrectParse1.frag. --- ir_constant_folding.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index b9dee37edfb..006eb5ffcfc 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -88,7 +88,14 @@ ir_constant_folding_visitor::visit(ir_swizzle *ir) void ir_constant_folding_visitor::visit(ir_dereference *ir) { - (void) ir; + if (ir->mode == ir_dereference::ir_reference_array) { + ir_constant *const_val = ir->selector.array_index->constant_expression_value(); + if (const_val) + ir->selector.array_index = const_val; + else + ir->selector.array_index->accept(this); + } + ir->var->accept(this); } -- cgit v1.2.3 From e5a9e70cde3dda27dca045b12c5a818215b1a449 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Apr 2010 11:42:01 -0700 Subject: Descend down the tree in more locations in constant folding. --- ir_constant_folding.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index 006eb5ffcfc..eabdc240ad3 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -73,6 +73,8 @@ ir_constant_folding_visitor::visit(ir_expression *ir) op[operand] = ir->operands[operand]->constant_expression_value(); if (op[operand]) { ir->operands[operand] = op[operand]; + } else { + ir->operands[operand]->accept(this); } } } @@ -81,7 +83,7 @@ ir_constant_folding_visitor::visit(ir_expression *ir) void ir_constant_folding_visitor::visit(ir_swizzle *ir) { - (void) ir; + ir->val->accept(this); } -- cgit v1.2.3 From 70b74928a220aff024664714877defb0caedf33f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Apr 2010 11:52:09 -0700 Subject: Make constant folding descend into if statements. --- glsl_parser_extras.cpp | 6 ++---- ir.cpp | 10 ++++++++++ ir.h | 2 ++ ir_constant_folding.cpp | 3 +++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 84a3fd90715..538d77c663c 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -651,10 +651,8 @@ main(int argc, char **argv) /* Optimization passes */ if (!state.error) { /* Constant folding */ - foreach_iter(exec_list_iterator, iter, instructions) { - ir_constant_folding_visitor v; - ((ir_instruction *)iter.get())->accept(& v); - } + ir_constant_folding_visitor constant_folding; + visit_exec_list(&instructions, &constant_folding); } /* Print out the resulting IR */ diff --git a/ir.cpp b/ir.cpp index 0708e492850..99a966e1540 100644 --- a/ir.cpp +++ b/ir.cpp @@ -24,6 +24,7 @@ #include "main/imports.h" #include "main/simple_list.h" #include "ir.h" +#include "ir_visitor.h" #include "glsl_types.h" ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, @@ -367,3 +368,12 @@ ir_call::get_error_instruction() call->type = glsl_type::error_type; return call; } + +void +visit_exec_list(exec_list *list, ir_visitor *visitor) +{ + foreach_iter(exec_list_iterator, iter, *list) { + ((ir_instruction *)iter.get())->accept(visitor); + } +} + diff --git a/ir.h b/ir.h index a515d9a7d0a..adc14055724 100644 --- a/ir.h +++ b/ir.h @@ -607,6 +607,8 @@ public: } value; }; +void +visit_exec_list(exec_list *list, ir_visitor *visitor); extern void _mesa_glsl_initialize_variables(exec_list *instructions, diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index eabdc240ad3..af6674c3f6e 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -141,4 +141,7 @@ ir_constant_folding_visitor::visit(ir_if *ir) ir->condition = const_val; else ir->condition->accept(this); + + visit_exec_list(&ir->then_instructions, this); + visit_exec_list(&ir->else_instructions, this); } -- cgit v1.2.3 From b94e402cffc1c1606d8d7375f38ab573877e1c6a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Apr 2010 12:13:02 -0700 Subject: Add some linebreaks in the ir_print_visitor of if statement bodies. --- ir_print_visitor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index e1fedd78a93..375659d5cff 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -281,6 +281,7 @@ ir_print_visitor::visit(ir_if *ir) ir_instruction *const inst = (ir_instruction *) iter.get(); inst->accept(this); + printf("\n"); } printf(")\n"); @@ -289,6 +290,7 @@ ir_print_visitor::visit(ir_if *ir) ir_instruction *const inst = (ir_instruction *) iter.get(); inst->accept(this); + printf("\n"); } printf("))\n"); } -- cgit v1.2.3 From fad607a9be59056aecda50176b4d20a8b5319747 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 16:16:07 -0700 Subject: Add ir_loop to represent loops This touches a lot of files because everything derived from ir_visitor has to be updated. This is the primary disadvantage of the visitor pattern. --- ir.h | 38 ++++++++++++++++++++++++++++++++++++++ ir_constant_expression.cpp | 9 +++++++++ ir_constant_folding.cpp | 7 +++++++ ir_constant_folding.h | 1 + ir_print_visitor.cpp | 25 +++++++++++++++++++++++++ ir_print_visitor.h | 1 + ir_visitor.h | 1 + 7 files changed, 82 insertions(+) diff --git a/ir.h b/ir.h index adc14055724..8c533c308a0 100644 --- a/ir.h +++ b/ir.h @@ -287,6 +287,44 @@ public: }; +/** + * IR instruction representing a high-level loop structure. + */ +class ir_loop : public ir_instruction { +public: + ir_loop() : from(NULL), to(NULL), increment(NULL), counter(NULL) + { + /* empty */ + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + /** + * Get an iterator for the instructions of the loop body + */ + exec_list_iterator iterator() + { + return body_instructions.iterator(); + } + + /** List of instructions that make up the body of the loop. */ + exec_list body_instructions; + + /** + * \name Loop counter and controls + */ + /*@{*/ + ir_rvalue *from; + ir_rvalue *to; + ir_rvalue *increment; + ir_variable *counter; + /*@}*/ +}; + + class ir_assignment : public ir_rvalue { public: ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index e1073cde1ce..a94b0fc9e2a 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -74,6 +74,7 @@ public: virtual void visit(ir_call *); virtual void visit(ir_return *); virtual void visit(ir_if *); + virtual void visit(ir_loop *); /*@}*/ /** @@ -464,3 +465,11 @@ ir_constant_visitor::visit(ir_if *ir) (void) ir; value = NULL; } + + +void +ir_constant_visitor::visit(ir_loop *ir) +{ + (void) ir; + value = NULL; +} diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index af6674c3f6e..d7efdecc45f 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -145,3 +145,10 @@ ir_constant_folding_visitor::visit(ir_if *ir) visit_exec_list(&ir->then_instructions, this); visit_exec_list(&ir->else_instructions, this); } + + +void +ir_constant_folding_visitor::visit(ir_loop *ir) +{ + (void) ir; +} diff --git a/ir_constant_folding.h b/ir_constant_folding.h index 9e151ecde66..382f57c7e55 100644 --- a/ir_constant_folding.h +++ b/ir_constant_folding.h @@ -58,5 +58,6 @@ public: virtual void visit(ir_call *); virtual void visit(ir_return *); virtual void visit(ir_if *); + virtual void visit(ir_loop *); /*@}*/ }; diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 375659d5cff..76524261ecd 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -294,3 +294,28 @@ ir_print_visitor::visit(ir_if *ir) } printf("))\n"); } + + +void +ir_print_visitor::visit(ir_loop *ir) +{ + printf("(loop ("); + if (ir->counter != NULL) + ir->counter->accept(this); + printf(") ("); + if (ir->from != NULL) + ir->from->accept(this); + printf(") ("); + if (ir->to != NULL) + ir->to->accept(this); + printf(") ("); + if (ir->increment != NULL) + ir->increment->accept(this); + printf(") ("); + foreach_iter(exec_list_iterator, iter, ir->body_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + inst->accept(this); + } + printf("))\n"); +} diff --git a/ir_print_visitor.h b/ir_print_visitor.h index 76d812e19c1..a6365bec7e2 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -65,6 +65,7 @@ public: virtual void visit(ir_call *); virtual void visit(ir_return *); virtual void visit(ir_if *); + virtual void visit(ir_loop *); /*@}*/ private: diff --git a/ir_visitor.h b/ir_visitor.h index 521b1c3d805..fab1a75d53f 100644 --- a/ir_visitor.h +++ b/ir_visitor.h @@ -56,6 +56,7 @@ public: virtual void visit(class ir_call *) = 0; virtual void visit(class ir_return *) = 0; virtual void visit(class ir_if *) = 0; + virtual void visit(class ir_loop *) = 0; /*@}*/ }; -- cgit v1.2.3 From f8e31e00b1078dc28187a43a1ab8949e154e7533 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 16:28:15 -0700 Subject: Add ir_loop_jump to represent 'break' and 'continue' in loops --- ir.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ ir_constant_expression.cpp | 9 +++++++++ ir_constant_folding.cpp | 7 +++++++ ir_constant_folding.h | 1 + ir_print_visitor.cpp | 7 +++++++ ir_print_visitor.h | 1 + ir_visitor.h | 1 + 7 files changed, 71 insertions(+) diff --git a/ir.h b/ir.h index 8c533c308a0..4266dbc17aa 100644 --- a/ir.h +++ b/ir.h @@ -532,6 +532,51 @@ public: private: ir_rvalue *value; }; + + +/** + * Jump instructions used inside loops + * + * These include \c break and \c continue. The \c break within a loop is + * different from the \c break within a switch-statement. + * + * \sa ir_switch_jump + */ +class ir_loop_jump : public ir_jump { +public: + enum jump_mode { + jump_break, + jump_continue + }; + + ir_loop_jump(ir_loop *loop, jump_mode mode) + : loop(loop), mode(mode) + { + /* empty */ + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + bool is_break() const + { + return mode == jump_break; + } + + bool is_continue() const + { + return mode == jump_continue; + } + +private: + /** Loop containing this break instruction. */ + ir_loop *loop; + + /** Mode selector for the jump instruction. */ + enum jump_mode mode; +}; /*@}*/ diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index a94b0fc9e2a..7e1bb030f57 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -75,6 +75,7 @@ public: virtual void visit(ir_return *); virtual void visit(ir_if *); virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); /*@}*/ /** @@ -473,3 +474,11 @@ ir_constant_visitor::visit(ir_loop *ir) (void) ir; value = NULL; } + + +void +ir_constant_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; + value = NULL; +} diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index d7efdecc45f..e43f6f0ea4c 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -152,3 +152,10 @@ ir_constant_folding_visitor::visit(ir_loop *ir) { (void) ir; } + + +void +ir_constant_folding_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; +} diff --git a/ir_constant_folding.h b/ir_constant_folding.h index 382f57c7e55..843b3ad0b77 100644 --- a/ir_constant_folding.h +++ b/ir_constant_folding.h @@ -59,5 +59,6 @@ public: virtual void visit(ir_return *); virtual void visit(ir_if *); virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); /*@}*/ }; diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 76524261ecd..996beaf2908 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -319,3 +319,10 @@ ir_print_visitor::visit(ir_loop *ir) } printf("))\n"); } + + +void +ir_print_visitor::visit(ir_loop_jump *ir) +{ + printf("%s", ir->is_break() ? "break" : "continue"); +} diff --git a/ir_print_visitor.h b/ir_print_visitor.h index a6365bec7e2..82ebbac81f0 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -66,6 +66,7 @@ public: virtual void visit(ir_return *); virtual void visit(ir_if *); virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); /*@}*/ private: diff --git a/ir_visitor.h b/ir_visitor.h index fab1a75d53f..323720e93ed 100644 --- a/ir_visitor.h +++ b/ir_visitor.h @@ -57,6 +57,7 @@ public: virtual void visit(class ir_return *) = 0; virtual void visit(class ir_if *) = 0; virtual void visit(class ir_loop *) = 0; + virtual void visit(class ir_loop_jump *) = 0; /*@}*/ }; -- cgit v1.2.3 From 9e7d010ee0ed89f1fe07a06a9d9bb22e15106ae2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 16:37:49 -0700 Subject: Process ast_iteration_statement into ir_loop This causes the following tests to pass: glslparsertest/shaders/dowhile.frag glslparsertest/shaders/while.frag glslparsertest/shaders/while1.frag glslparsertest/shaders/while2.frag --- ast.h | 2 ++ ast_to_hir.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/ast.h b/ast.h index f73e74906f0..ba500dc773a 100644 --- a/ast.h +++ b/ast.h @@ -558,6 +558,8 @@ public: virtual void print(void) const; + virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); + enum ast_iteration_modes { ast_for, ast_while, diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index ddeab8db67c..08e43a9aa69 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2069,3 +2069,66 @@ ast_selection_statement::hir(exec_list *instructions, */ return NULL; } + + +ir_rvalue * +ast_iteration_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + /* For loops start a new scope, but while and do-while loops do not. + */ + if (mode == ast_for) + state->symbols->push_scope(); + + if (init_statement != NULL) + init_statement->hir(instructions, state); + + ir_loop *const stmt = new ir_loop(); + instructions->push_tail(stmt); + + if (condition != NULL) { + ir_rvalue *const cond = + condition->hir(& stmt->body_instructions, state); + + if ((cond == NULL) + || !cond->type->is_boolean() || !cond->type->is_scalar()) { + YYLTYPE loc = condition->get_location(); + + _mesa_glsl_error(& loc, state, + "loop condition must be scalar boolean"); + } else { + /* As the first code in the loop body, generate a block that looks + * like 'if (!condition) break;' as the loop termination condition. + */ + ir_rvalue *const not_cond = + new ir_expression(ir_unop_logic_not, glsl_type::bool_type, cond, + NULL); + + ir_if *const if_stmt = new ir_if(not_cond); + + ir_jump *const break_stmt = + new ir_loop_jump(stmt, ir_loop_jump::jump_break); + + if_stmt->then_instructions.push_tail(break_stmt); + stmt->body_instructions.push_tail(if_stmt); + } + } + + if (body != NULL) { + ast_node *node = (ast_node *) body; + do { + node->hir(& stmt->body_instructions, state); + node = (ast_node *) node->next; + } while (node != body); + } + + if (rest_expression != NULL) + rest_expression->hir(& stmt->body_instructions, state); + + if (mode == ast_for) + state->symbols->pop_scope(); + + /* Loops do not have r-values. + */ + return NULL; +} -- cgit v1.2.3 From d6313d7a01d842483ae8e5bd1f5dcd20ace1b6f1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 16:38:20 -0700 Subject: Add some newlines when printing ir_loop instructions --- ir_print_visitor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 996beaf2908..20f9a5b5c50 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -311,11 +311,12 @@ ir_print_visitor::visit(ir_loop *ir) printf(") ("); if (ir->increment != NULL) ir->increment->accept(this); - printf(") ("); + printf(") (\n"); foreach_iter(exec_list_iterator, iter, ir->body_instructions) { ir_instruction *const inst = (ir_instruction *) iter.get(); inst->accept(this); + printf("\n"); } printf("))\n"); } -- cgit v1.2.3 From c0e76d8352fbe96efb0338e9d98b08494671e504 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 16:53:19 -0700 Subject: Use switch based on mode in ast_jump_statement::hir --- ast_to_hir.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 08e43a9aa69..823bab9dfa0 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1967,7 +1967,8 @@ ast_jump_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - if (mode == ast_return) { + switch (mode) { + case ast_return: { ir_return *inst; assert(state->current_function); @@ -2005,9 +2006,10 @@ ast_jump_statement::hir(exec_list *instructions, } instructions->push_tail(inst); + break; } - if (mode == ast_discard) { + case ast_discard: /* FINISHME: discard support */ if (state->target != fragment_shader) { YYLTYPE loc = this->get_location(); @@ -2015,6 +2017,11 @@ ast_jump_statement::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "`discard' may only appear in a fragment shader"); } + break; + + case ast_break: + case ast_continue: + break; } /* Jump instructions do not have r-values. -- cgit v1.2.3 From e9d0f265aabb39928d4d8a527684bf3b9eebc21c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 17:01:53 -0700 Subject: Begin tracking the nesting of loops and switch-statements --- ast_to_hir.cpp | 10 ++++++++++ glsl_parser_extras.cpp | 1 + glsl_parser_extras.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 823bab9dfa0..444cb7d54e3 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2093,6 +2093,12 @@ ast_iteration_statement::hir(exec_list *instructions, ir_loop *const stmt = new ir_loop(); instructions->push_tail(stmt); + /* Track the current loop and / or switch-statement nesting. + */ + ir_instruction *const nesting = state->loop_or_switch_nesting; + state->loop_or_switch_nesting = stmt; + + if (condition != NULL) { ir_rvalue *const cond = condition->hir(& stmt->body_instructions, state); @@ -2135,6 +2141,10 @@ ast_iteration_statement::hir(exec_list *instructions, if (mode == ast_for) state->symbols->pop_scope(); + /* Restore previous nesting before returning. + */ + state->loop_or_switch_nesting = nesting; + /* Loops do not have r-values. */ return NULL; diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 538d77c663c..877b165ad71 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -637,6 +637,7 @@ main(int argc, char **argv) state.symbols = new glsl_symbol_table; state.error = false; state.temp_index = 0; + state.loop_or_switch_nesting = NULL; _mesa_glsl_lexer_ctor(& state, shader, shader_len); _mesa_glsl_parse(& state); diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 96c975ba117..373d295bba4 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -56,6 +56,9 @@ struct _mesa_glsl_parse_state { /** Index of last generated anonymous temporary. */ unsigned temp_index; + + /** Loop or switch statement containing the current instructions. */ + class ir_instruction *loop_or_switch_nesting; }; typedef struct YYLTYPE { -- cgit v1.2.3 From 01f8de4a87157b01e8b9fe31c6766a15bbfb2788 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 17:13:14 -0700 Subject: Add dynamic cast for ir_loop --- ir.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ir.h b/ir.h index 4266dbc17aa..fee23b25829 100644 --- a/ir.h +++ b/ir.h @@ -54,6 +54,7 @@ public: virtual class ir_variable * as_variable() { return NULL; } virtual class ir_dereference * as_dereference() { return NULL; } virtual class ir_rvalue * as_rvalue() { return NULL; } + virtual class ir_loop * as_loop() { return NULL; } /*@}*/ protected: @@ -302,6 +303,11 @@ public: v->visit(this); } + virtual ir_loop *as_loop() + { + return this; + } + /** * Get an iterator for the instructions of the loop body */ -- cgit v1.2.3 From 4cf20cd37c12c6243a09d52739d3d47f030a1799 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 17:13:47 -0700 Subject: Process ast_jump_statement into ir_loop_jump Specifically, handle 'break' and 'continue' inside loops. This causes the following tests to pass: glslparsertest/shaders/break.frag glslparsertest/shaders/continue.frag --- ast_to_hir.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 444cb7d54e3..ae5a8d51f78 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2021,6 +2021,32 @@ ast_jump_statement::hir(exec_list *instructions, case ast_break: case ast_continue: + /* FINISHME: Handle switch-statements. They cannot contain 'continue', + * FINISHME: and they use a different IR instruction for 'break'. + */ + /* FINISHME: Correctly handle the nesting. If a switch-statement is + * FINISHME: inside a loop, a 'continue' is valid and will bind to the + * FINISHME: loop. + */ + if (state->loop_or_switch_nesting == NULL) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`%s' may only appear in a loop", + (mode == ast_break) ? "break" : "continue"); + } else { + ir_loop *const loop = state->loop_or_switch_nesting->as_loop(); + + if (loop != NULL) { + ir_loop_jump *const jump = + new ir_loop_jump(loop, + (mode == ast_break) + ? ir_loop_jump::jump_break + : ir_loop_jump::jump_continue); + instructions->push_tail(jump); + } + } + break; } -- cgit v1.2.3 From 8c46ed24906ee10dd2f2cfaf4cf9803eca1ba523 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 5 Apr 2010 18:07:27 -0700 Subject: Generate correct IR for do-while loops Previously the same code was generated for a while loop and a do-while loop. This pulls the code that generates the conditional break into a separate method. This method is called either at the beginning or the end depending on the loop type. Reported-by: Kenneth Graunke --- ast.h | 9 +++++++++ ast_to_hir.cpp | 51 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/ast.h b/ast.h index ba500dc773a..d899fb1d090 100644 --- a/ast.h +++ b/ast.h @@ -572,6 +572,15 @@ public: ast_expression *rest_expression; ast_node *body; + +private: + /** + * Generate IR from the condition of a loop + * + * This is factored out of ::hir because some loops have the condition + * test at the top (for and while), and others have it at the end (do-while). + */ + void condition_to_hir(class ir_loop *, struct _mesa_glsl_parse_state *); }; diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index ae5a8d51f78..6afd7eafec1 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2104,27 +2104,10 @@ ast_selection_statement::hir(exec_list *instructions, } -ir_rvalue * -ast_iteration_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) +void +ast_iteration_statement::condition_to_hir(ir_loop *stmt, + struct _mesa_glsl_parse_state *state) { - /* For loops start a new scope, but while and do-while loops do not. - */ - if (mode == ast_for) - state->symbols->push_scope(); - - if (init_statement != NULL) - init_statement->hir(instructions, state); - - ir_loop *const stmt = new ir_loop(); - instructions->push_tail(stmt); - - /* Track the current loop and / or switch-statement nesting. - */ - ir_instruction *const nesting = state->loop_or_switch_nesting; - state->loop_or_switch_nesting = stmt; - - if (condition != NULL) { ir_rvalue *const cond = condition->hir(& stmt->body_instructions, state); @@ -2152,6 +2135,31 @@ ast_iteration_statement::hir(exec_list *instructions, stmt->body_instructions.push_tail(if_stmt); } } +} + + +ir_rvalue * +ast_iteration_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + /* For loops start a new scope, but while and do-while loops do not. + */ + if (mode == ast_for) + state->symbols->push_scope(); + + if (init_statement != NULL) + init_statement->hir(instructions, state); + + ir_loop *const stmt = new ir_loop(); + instructions->push_tail(stmt); + + /* Track the current loop and / or switch-statement nesting. + */ + ir_instruction *const nesting = state->loop_or_switch_nesting; + state->loop_or_switch_nesting = stmt; + + if (mode != ast_do_while) + condition_to_hir(stmt, state); if (body != NULL) { ast_node *node = (ast_node *) body; @@ -2164,6 +2172,9 @@ ast_iteration_statement::hir(exec_list *instructions, if (rest_expression != NULL) rest_expression->hir(& stmt->body_instructions, state); + if (mode == ast_do_while) + condition_to_hir(stmt, state); + if (mode == ast_for) state->symbols->pop_scope(); -- cgit v1.2.3 From 8645a955fc5fc6a8969ceade7a67390798ed6f74 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 16:47:44 -0700 Subject: Add gl_ClipDistance in fragment shader --- ir_variable.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ir_variable.cpp b/ir_variable.cpp index d81e0568508..29f3fc5a632 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -228,10 +228,13 @@ generate_130_fs_variables(exec_list *instructions, { generate_120_fs_variables(instructions, symtab); - /* FINISHME: Add support fo gl_ClipDistance. The size of this array is - * FINISHME: implementation dependent based on the value of - * FINISHME: GL_MAX_CLIP_DISTANCES. + /* FINISHME: The size of this array is implementation dependent based on + * FINISHME: the value of GL_MAX_CLIP_DISTANCES. */ + const glsl_type *const clip_distance_array_type = + glsl_type::get_array_instance(glsl_type::float_type, 8); + add_variable("gl_ClipDistance", ir_var_in, clip_distance_array_type, + instructions, symtab); } static void -- cgit v1.2.3 From 77cce649c9063e279db60b8dfba8835da59cdf19 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 16:48:42 -0700 Subject: Add support for bool to ir_equal and ir_nequal constant handling --- ir_constant_expression.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 7e1bb030f57..e3a0d9eaa11 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -355,6 +355,9 @@ ir_constant_visitor::visit(ir_expression *ir) case GLSL_TYPE_FLOAT: b[0] = b[0] && op[0]->value.f[c] == op[1]->value.f[c]; break; + case GLSL_TYPE_BOOL: + b[0] = b[0] && op[0]->value.b[c] == op[1]->value.b[c]; + break; default: assert(0); } @@ -376,6 +379,9 @@ ir_constant_visitor::visit(ir_expression *ir) case GLSL_TYPE_FLOAT: b[0] = b[0] || op[0]->value.f[c] != op[1]->value.f[c]; break; + case GLSL_TYPE_BOOL: + b[0] = b[0] || op[0]->value.b[c] != op[1]->value.b[c]; + break; default: assert(0); } -- cgit v1.2.3 From 62f62ca3b3a206bb52de79b8fc7890ac8c62c7fc Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 13:43:52 -0700 Subject: Partially fix comment handling in preprocessor directives. Multi-line /* */ comments are still broken. I think this will wait to be fixed until we have a real preprocessor. --- glsl_lexer.lpp | 1 + 1 file changed, 1 insertion(+) diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index 8f3f1211d5d..672ff39dc61 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -61,6 +61,7 @@ ^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; } ^[ \t]*#[ \t]*line { BEGIN PP; return LINE; } ^[ \t]*#[ \t]*pragma { BEGIN PP; return PRAGMA; } +\/\/[^\n]* { } : return COLON; [_a-zA-Z][_a-zA-Z0-9]* { yylval->identifier = strdup(yytext); -- cgit v1.2.3 From b0b8fa48853cabaf493f68403dcdd29e081113a7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 14:49:59 -0700 Subject: Eat whitespace while in the PP state --- glsl_lexer.lpp | 1 + 1 file changed, 1 insertion(+) diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index 672ff39dc61..a25dbf9e2fe 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -62,6 +62,7 @@ ^[ \t]*#[ \t]*line { BEGIN PP; return LINE; } ^[ \t]*#[ \t]*pragma { BEGIN PP; return PRAGMA; } \/\/[^\n]* { } +[ \t\r]* { } : return COLON; [_a-zA-Z][_a-zA-Z0-9]* { yylval->identifier = strdup(yytext); -- cgit v1.2.3 From 1b3f47fd363d74b1378f26ca0082a75db518aa1f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 16:09:47 -0700 Subject: Call glsl_type::get_instance correctly: the number of rows must be at least 1 This causes the following tests to pass: shaders/glsl-tex-mvp.vert --- ir_variable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ir_variable.cpp b/ir_variable.cpp index 29f3fc5a632..41359b56162 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -120,7 +120,7 @@ generate_110_vs_variables(exec_list *instructions, * FINISHME: at least 2, so hard-code 2 for now. */ const glsl_type *const vec4_type = - glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 0); + glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); const glsl_type *const vec4_array_type = glsl_type::get_array_instance(vec4_type, 2); @@ -204,7 +204,7 @@ generate_110_fs_variables(exec_list *instructions, * FINISHME: at least 2, so hard-code 2 for now. */ const glsl_type *const vec4_type = - glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 0); + glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); const glsl_type *const vec4_array_type = glsl_type::get_array_instance(vec4_type, 2); -- cgit v1.2.3 From 5bfe30a02be67f2b0e757921295a89adfd368e3f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 16:44:30 -0700 Subject: Add utility function to get the name of a shader target --- glsl_parser_extras.cpp | 13 +++++++++++++ glsl_parser_extras.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 877b165ad71..335a058b965 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -37,6 +37,19 @@ #include "ir_constant_folding.h" #include "ir_print_visitor.h" +const char * +_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) +{ + switch (target) { + case vertex_shader: return "vertex"; + case fragment_shader: return "fragment"; + case geometry_shader: return "geometry"; + } + + assert(!"Should not get here."); +} + + void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, const char *fmt, ...) diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 373d295bba4..2f33bea0534 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -85,4 +85,10 @@ extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc, extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *); +/** + * Get the textual name of the specified shader target + */ +extern const char * +_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target); + #endif /* GLSL_PARSER_EXTRAS_H */ -- cgit v1.2.3 From ae4c4c07959f059e557ea44e98552ced1fec9f47 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 16:41:40 -0700 Subject: Use _mesa_glsl_shader_target_name --- ast_to_hir.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 6afd7eafec1..07d40e27d24 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1306,11 +1306,12 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, if (qual->centroid) var->centroid = 1; - if (qual->attribute && state->target == fragment_shader) { + if (qual->attribute && state->target != vertex_shader) { var->type = glsl_type::error_type; _mesa_glsl_error(loc, state, "`attribute' variables may not be declared in the " - "fragment shader"); + "%s shader", + _mesa_glsl_shader_target_name(state->target)); } /* From page 25 (page 31 of the PDF) of the GLSL 1.10 spec: @@ -1590,8 +1591,7 @@ ast_declarator_list::hir(exec_list *instructions, if ((var->mode == ir_var_in) && (state->current_function == NULL)) { _mesa_glsl_error(& initializer_loc, state, "cannot initialize %s shader input / %s", - (state->target == vertex_shader) - ? "vertex" : "fragment", + _mesa_glsl_shader_target_name(state->target), (state->target == vertex_shader) ? "attribute" : "varying"); } -- cgit v1.2.3 From e701761cc84a136c2e1b3cf341bc0edb90492278 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 16:46:25 -0700 Subject: Begin processing #extension directive Nowhere near complete. It just parses correctly at this point. --- glsl_parser.ypp | 18 ++++++++++++++++-- glsl_parser_extras.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ glsl_parser_extras.h | 12 ++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/glsl_parser.ypp b/glsl_parser.ypp index b8c01b508d0..250c51c7ee3 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -190,13 +190,13 @@ translation_unit: { _mesa_glsl_initialize_types(state); } - external_declaration_list + extension_statement_list external_declaration_list | { state->language_version = 110; _mesa_glsl_initialize_types(state); } - external_declaration_list + extension_statement_list external_declaration_list ; version_statement: @@ -217,6 +217,20 @@ version_statement: } ; +extension_statement_list: + + | extension_statement_list extension_statement + ; + +extension_statement: + EXTENSION IDENTIFIER COLON IDENTIFIER EOL + { + if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) { + YYERROR; + } + } + ; + external_declaration_list: external_declaration { diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 335a058b965..1eac1890afe 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -71,6 +71,53 @@ _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, } +bool +_mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, + const char *behavior, YYLTYPE *behavior_locp, + _mesa_glsl_parse_state *state) +{ + enum { + extension_disable, + extension_enable, + extension_require, + extension_warn + } ext_mode; + bool error = false; + + if (strcmp(behavior, "warn") == 0) { + ext_mode = extension_warn; + } else if (strcmp(behavior, "require") == 0) { + ext_mode = extension_require; + } else if (strcmp(behavior, "enable") == 0) { + ext_mode = extension_enable; + } else if (strcmp(behavior, "disable") == 0) { + ext_mode = extension_disable; + } else { + _mesa_glsl_error(behavior_locp, state, + "Unknown extension behavior `%s'", + behavior); + return false; + } + + if (strcmp(name, "all") == 0) { + if ((ext_mode == extension_enable) || (ext_mode == extension_require)) { + _mesa_glsl_error(name_locp, state, "Cannot %s all extensions", + (ext_mode == extension_enable) + ? "enable" : "require"); + return false; + } + } else { + if (ext_mode == extension_require) { + _mesa_glsl_error(name_locp, state, "Unknown extension `%s'", + name); + return false; + } + } + + return true; +} + + ast_node::~ast_node() { /* empty */ diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 2f33bea0534..15667ebb689 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -85,6 +85,18 @@ extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc, extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *); +/** + * Process elements of the #extension directive + * + * \return + * If \c name and \c behavior are valid, \c true is returned. Otherwise + * \c false is returned. + */ +extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, + const char *behavior, + YYLTYPE *behavior_locp, + _mesa_glsl_parse_state *state); + /** * Get the textual name of the specified shader target */ -- cgit v1.2.3 From 56b8b214107a0320c7277cd832480998057f8413 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 14:47:46 -0700 Subject: Add _mesa_glsl_warning to emit warnings to the shader log --- glsl_parser_extras.cpp | 19 +++++++++++++++++++ glsl_parser_extras.h | 9 +++++++++ 2 files changed, 28 insertions(+) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 1eac1890afe..de67e849dfa 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -71,6 +71,25 @@ _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, } +void +_mesa_glsl_warning(const YYLTYPE *locp, const _mesa_glsl_parse_state *state, + const char *fmt, ...) +{ + char buf[1024]; + int len; + va_list ap; + + len = snprintf(buf, sizeof(buf), "%u:%u(%u): warning: ", + locp->source, locp->first_line, locp->first_column); + + va_start(ap, fmt); + vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); + va_end(ap); + + printf("%s\n", buf); +} + + bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, const char *behavior, YYLTYPE *behavior_locp, diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 15667ebb689..7759eda535f 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -74,6 +74,15 @@ typedef struct YYLTYPE { extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, const char *fmt, ...); +/** + * Emit a warning to the shader log + * + * \sa _mesa_glsl_error + */ +extern void _mesa_glsl_warning(const YYLTYPE *locp, + const _mesa_glsl_parse_state *state, + const char *fmt, ...); + extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string, size_t len); -- cgit v1.2.3 From 1799a0cd41e1a72673b4b469075e7abfcce8ec71 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 14:50:36 -0700 Subject: Emit a warning when an unknown extension is used with #extension --- glsl_parser_extras.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index de67e849dfa..8beea55573a 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -130,6 +130,9 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, _mesa_glsl_error(name_locp, state, "Unknown extension `%s'", name); return false; + } else { + _mesa_glsl_warning(name_locp, state, "Unknown extension `%s'", + name); } } -- cgit v1.2.3 From c178c74c27ab292651dcf7da02a7d035366cae04 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 16:53:54 -0700 Subject: Add tracking for extension based warnings Using '#extension foo: warn' instructs the compiler to generate a warning when some feature of the extension 'foo' is used. This patch adds some infrastructure needed to support that for variables. Similar changes will be needed for types and built-in functions. --- ir.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ir.h b/ir.h index fee23b25829..13d07155a42 100644 --- a/ir.h +++ b/ir.h @@ -156,6 +156,11 @@ public: */ unsigned array_lvalue:1; + /** + * Emit a warning if this variable is accessed. + */ + const char *warn_extension; + /** * Value assigned in the initializer of a variable declared "const" */ -- cgit v1.2.3 From 887a8b07deffa578b7d6540257a0c5f8c4d5d97c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 16:57:56 -0700 Subject: Clean up error reporting in _mesa_glsl_process_extension --- glsl_parser_extras.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 8beea55573a..6cd69c8b882 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -101,7 +101,6 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, extension_require, extension_warn } ext_mode; - bool error = false; if (strcmp(behavior, "warn") == 0) { ext_mode = extension_warn; @@ -118,6 +117,8 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, return false; } + bool unsupported = false; + if (strcmp(name, "all") == 0) { if ((ext_mode == extension_enable) || (ext_mode == extension_require)) { _mesa_glsl_error(name_locp, state, "Cannot %s all extensions", @@ -126,13 +127,19 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, return false; } } else { + unsupported = true; + } + + if (unsupported) { + static const char *const fmt = "extension `%s' unsupported in %s shader"; + if (ext_mode == extension_require) { - _mesa_glsl_error(name_locp, state, "Unknown extension `%s'", - name); + _mesa_glsl_error(name_locp, state, fmt, + name, _mesa_glsl_shader_target_name(state->target)); return false; } else { - _mesa_glsl_warning(name_locp, state, "Unknown extension `%s'", - name); + _mesa_glsl_warning(name_locp, state, fmt, + name, _mesa_glsl_shader_target_name(state->target)); } } -- cgit v1.2.3 From c77b257094b15e7c53b62cb50bfbcd7c5003f2a8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 16:59:46 -0700 Subject: Add support for GL_ARB_draw_buffers extension --- glsl_parser_extras.cpp | 9 +++++++++ glsl_parser_extras.h | 8 ++++++++ ir_variable.cpp | 43 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 6cd69c8b882..553cd675a7a 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -126,6 +126,15 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, ? "enable" : "require"); return false; } + } if (strcmp(name, "GL_ARB_draw_buffers") == 0) { + /* This extension is only supported in fragment shaders. + */ + if (state->target != fragment_shader) { + unsupported = true; + } else { + state->ARB_draw_buffers_enable = (ext_mode != extension_disable); + state->ARB_draw_buffers_warn = (ext_mode == extension_warn); + } } else { unsupported = true; } diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 7759eda535f..51e4eb89ccf 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -59,6 +59,14 @@ struct _mesa_glsl_parse_state { /** Loop or switch statement containing the current instructions. */ class ir_instruction *loop_or_switch_nesting; + + /** + * \name Enable bits for GLSL extensions + */ + /*@{*/ + unsigned ARB_draw_buffers_enable:1; + unsigned ARB_draw_buffers_warn:1; + /*@}*/ }; typedef struct YYLTYPE { diff --git a/ir_variable.cpp b/ir_variable.cpp index 41359b56162..76a528ca2be 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -30,7 +30,7 @@ #define Elements(x) (sizeof(x)/sizeof(*(x))) #endif -static void +static ir_variable * add_variable(const char *name, enum ir_variable_mode mode, const glsl_type *type, exec_list *instructions, glsl_symbol_table *symtab) @@ -48,6 +48,7 @@ add_variable(const char *name, enum ir_variable_mode mode, instructions->push_tail(var); symtab->add_variable(var->name, var); + return var; } @@ -197,8 +198,6 @@ generate_110_fs_variables(exec_list *instructions, } generate_110_uniforms(instructions, symtab); - /* FINISHME: Add support for gl_FragData[GL_MAX_DRAW_BUFFERS]. */ - /* FINISHME: The size of this array is implementation dependent based on the * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be * FINISHME: at least 2, so hard-code 2 for now. @@ -212,14 +211,35 @@ generate_110_fs_variables(exec_list *instructions, symtab); } + +static void +generate_ARB_draw_buffers_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab, bool warn) +{ + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_DRAW_BUFFERS. GL_MAX_DRAW_BUFFERS must be + * FINISHME: at least 1, so hard-code 1 for now. + */ + const glsl_type *const vec4_type = + glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(vec4_type, 1); + + ir_variable *const fd = + add_variable("gl_FragData", ir_var_out, vec4_array_type, instructions, + symtab); + + if (warn) + fd->warn_extension = "GL_ARB_draw_buffers"; +} + + static void generate_120_fs_variables(exec_list *instructions, glsl_symbol_table *symtab) { - /* GLSL version 1.20 did not add any built-in variables in the fragment - * shader. - */ generate_110_fs_variables(instructions, symtab); + generate_ARB_draw_buffers_fs_variables(instructions, symtab, false); } static void @@ -253,6 +273,17 @@ initialize_fs_variables(exec_list *instructions, generate_130_fs_variables(instructions, state->symbols); break; } + + + /* Since GL_ARB_draw_buffers is included in GLSL 1.20 and later, we + * can basically ignore any extension settings for it. + */ + if (state->language_version < 120) { + if (state->ARB_draw_buffers_enable) { + generate_ARB_draw_buffers_fs_variables(instructions, state->symbols, + state->ARB_draw_buffers_warn); + } + } } void -- cgit v1.2.3 From 0c824653952a67722c242616bb34a4796b42f660 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 17:13:44 -0700 Subject: Treat texture rectangles as an extension that is enabled be default --- builtin_types.sh | 12 ++++++++++-- glsl_parser_extras.cpp | 4 ++++ glsl_parser_extras.h | 2 ++ glsl_types.cpp | 35 ++++++++++++++++++++++++++--------- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/builtin_types.sh b/builtin_types.sh index 609073c9e4d..4e6f0878ce5 100755 --- a/builtin_types.sh +++ b/builtin_types.sh @@ -167,8 +167,6 @@ done gen_sampler_type "3D" "GLSL_SAMPLER_DIM_3D" 0 0 "GLSL_TYPE_FLOAT" gen_sampler_type "Cube" "GLSL_SAMPLER_DIM_CUBE" 0 0 "GLSL_TYPE_FLOAT" -gen_sampler_type "2DRect" "GLSL_SAMPLER_DIM_RECT" 0 0 "GLSL_TYPE_FLOAT" -gen_sampler_type "2DRect" "GLSL_SAMPLER_DIM_RECT" 1 0 "GLSL_TYPE_FLOAT" gen_footer @@ -328,6 +326,16 @@ echo '' echo 'const glsl_type *const glsl_type::uint_type = & builtin_130_types['$uint_index'];' echo '/*@}*/' +echo +echo '/** \name Sampler types added by GL_ARB_texture_rectangle' +echo ' */' +echo '/*@{*/' +gen_header "ARB_texture_rectangle" +gen_sampler_type "2DRect" "GLSL_SAMPLER_DIM_RECT" 0 0 "GLSL_TYPE_FLOAT" +gen_sampler_type "2DRect" "GLSL_SAMPLER_DIM_RECT" 1 0 "GLSL_TYPE_FLOAT" +gen_footer +echo '/*@}*/' + echo echo '/** \name Sampler types added by GL_EXT_texture_buffer_object' echo ' */' diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 553cd675a7a..fd44e966024 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -135,6 +135,9 @@ _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); } + } if (strcmp(name, "GL_ARB_texture_rectangle") == 0) { + state->ARB_texture_rectangle_enable = (ext_mode != extension_disable); + state->ARB_texture_rectangle_warn = (ext_mode == extension_warn); } else { unsupported = true; } @@ -736,6 +739,7 @@ main(int argc, char **argv) state.error = false; state.temp_index = 0; state.loop_or_switch_nesting = NULL; + state.ARB_texture_rectangle_enable = true; _mesa_glsl_lexer_ctor(& state, shader, shader_len); _mesa_glsl_parse(& state); diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 51e4eb89ccf..a79dc75d482 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -66,6 +66,8 @@ struct _mesa_glsl_parse_state { /*@{*/ unsigned ARB_draw_buffers_enable:1; unsigned ARB_draw_buffers_warn:1; + unsigned ARB_texture_rectangle_enable:1; + unsigned ARB_texture_rectangle_warn:1; /*@}*/ }; diff --git a/glsl_types.cpp b/glsl_types.cpp index ba4f0297d81..24b3e3f59f9 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -35,11 +35,11 @@ hash_table *glsl_type::array_types = NULL; static void add_types_to_symbol_table(glsl_symbol_table *symtab, const struct glsl_type *types, - unsigned num_types) + unsigned num_types, bool warn) { - unsigned i; + (void) warn; - for (i = 0; i < num_types; i++) { + for (unsigned i = 0; i < num_types; i++) { symtab->add_type(types[i].name, & types[i]); } } @@ -49,12 +49,15 @@ static void generate_110_types(glsl_symbol_table *symtab) { add_types_to_symbol_table(symtab, builtin_core_types, - Elements(builtin_core_types)); + Elements(builtin_core_types), + false); add_types_to_symbol_table(symtab, builtin_structure_types, - Elements(builtin_structure_types)); + Elements(builtin_structure_types), + false); add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types, - Elements(builtin_110_deprecated_structure_types)); - add_types_to_symbol_table(symtab, & void_type, 1); + Elements(builtin_110_deprecated_structure_types), + false); + add_types_to_symbol_table(symtab, & void_type, 1, false); } @@ -64,7 +67,7 @@ generate_120_types(glsl_symbol_table *symtab) generate_110_types(symtab); add_types_to_symbol_table(symtab, builtin_120_types, - Elements(builtin_120_types)); + Elements(builtin_120_types), false); } @@ -74,7 +77,16 @@ generate_130_types(glsl_symbol_table *symtab) generate_120_types(symtab); add_types_to_symbol_table(symtab, builtin_130_types, - Elements(builtin_130_types)); + Elements(builtin_130_types), false); +} + + +static void +generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, bool warn) +{ + add_types_to_symbol_table(symtab, builtin_ARB_texture_rectangle_types, + Elements(builtin_ARB_texture_rectangle_types), + warn); } @@ -95,6 +107,11 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) /* error */ break; } + + if (state->ARB_texture_rectangle_enable) { + generate_ARB_texture_rectangle_types(state->symbols, + state->ARB_texture_rectangle_warn); + } } -- cgit v1.2.3 From f1ddca9f2143e377d2a70941dcedbb1f5c699e07 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Apr 2010 12:35:34 -0700 Subject: Clarify the types of various exec_list in ir.h --- ast_function.cpp | 8 +++----- ir.h | 13 ++++++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index cd57c32040b..3472b397cc1 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -38,7 +38,7 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters, if (first != NULL) { simple_node *ptr = first; do { - ir_instruction *const result = + ir_rvalue *const result = ((ast_node *) ptr)->hir(instructions, state); ptr = ptr->next; @@ -71,10 +71,8 @@ process_call(exec_list *instructions, ir_function *f, exec_list_iterator formal_iter = sig->parameters.iterator(); while (actual_iter.has_next()) { - ir_rvalue *actual = - ((ir_instruction *) actual_iter.get())->as_rvalue(); - ir_variable *formal = - ((ir_instruction *) formal_iter.get())->as_variable(); + ir_rvalue *actual = (ir_rvalue *) actual_iter.get(); + ir_variable *formal = (ir_variable *) formal_iter.get(); assert(actual != NULL); assert(formal != NULL); diff --git a/ir.h b/ir.h index 13d07155a42..7ae5e3b952a 100644 --- a/ir.h +++ b/ir.h @@ -204,7 +204,10 @@ public: const struct glsl_type *return_type; /** - * List of function parameters stored as ir_variable objects. + * List of ir_variable of function parameters. + * + * This represents the storage. The paramaters passed in a particular + * call will be in ir_call::actual_paramaters. */ struct exec_list parameters; @@ -259,7 +262,7 @@ public: private: /** - * Set of overloaded functions with this name. + * List of ir_function_signature for each overloaded function with this name. */ struct exec_list signatures; }; @@ -288,7 +291,9 @@ public: } ir_rvalue *condition; + /** List of ir_instruction for the body of the then branch */ exec_list then_instructions; + /** List of ir_instruction for the body of the else branch */ exec_list else_instructions; }; @@ -321,7 +326,7 @@ public: return body_instructions.iterator(); } - /** List of instructions that make up the body of the loop. */ + /** List of ir_instruction that make up the body of the loop. */ exec_list body_instructions; /** @@ -497,6 +502,8 @@ private: } const ir_function_signature *callee; + + /* List of ir_rvalue of paramaters passed in this call. */ exec_list actual_parameters; }; -- cgit v1.2.3 From 894ea972a4defdaafeaa3a248c113b06c7ae0c7e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Apr 2010 13:19:11 -0700 Subject: Put function bodies under function signatures, instead of flat in the parent. This will let us know the length of function bodies for the purpose of inlining (among other uses). --- ast_to_hir.cpp | 8 ++++---- builtin_function.cpp | 8 ++++---- glsl_types.cpp | 23 ++++++++++++----------- ir.cpp | 4 ++-- ir.h | 10 +++++++++- ir_constant_folding.cpp | 4 ++-- ir_print_visitor.cpp | 12 +++++++++--- 7 files changed, 42 insertions(+), 27 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 07d40e27d24..d74e54c602e 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1450,7 +1450,7 @@ ast_declarator_list::hir(exec_list *instructions, * FINISHME: required or not. */ - if (var->type->array_size() <= earlier->max_array_access) { + if (var->type->array_size() <= (int)earlier->max_array_access) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "array size must be > %u due to " @@ -1914,7 +1914,7 @@ ast_function_definition::hir(exec_list *instructions, assert(state->current_function == NULL); state->current_function = signature; - ir_label *label = new ir_label(signature->function_name()); + ir_label *label = new ir_label(signature->function_name(), signature); if (signature->definition == NULL) { signature->definition = label; } @@ -1931,7 +1931,7 @@ ast_function_definition::hir(exec_list *instructions, ir_variable *const var = proto->clone(); - instructions->push_tail(var); + signature->body.push_tail(var); /* The only way a parameter would "exist" is if two parameters have * the same name. @@ -1949,7 +1949,7 @@ ast_function_definition::hir(exec_list *instructions, * instructions to the list that currently consists of the function label * and the function parameters. */ - this->body->hir(instructions, state); + this->body->hir(&signature->body, state); state->symbols->pop_scope(); diff --git a/builtin_function.cpp b/builtin_function.cpp index 684a10c8893..f8ec38c90b5 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -216,7 +216,7 @@ generate_function_instance(ir_function *f, ir_function_signature *const sig = new ir_function_signature(type); f->add_signature(sig); - ir_label *const label = new ir_label(name); + ir_label *const label = new ir_label(name, sig); instructions->push_tail(label); sig->definition = label; static const char *arg_names[] = { @@ -234,16 +234,16 @@ generate_function_instance(ir_function *f, var = new ir_variable(type, arg_names[i]); var->mode = ir_var_in; - instructions->push_tail(var); + sig->body.push_tail(var); declarations[i] = var; } ir_variable *retval = new ir_variable(ret_type, "__retval"); - instructions->push_tail(retval); + sig->body.push_tail(retval); declarations[16] = retval; - generate(instructions, declarations, type); + generate(&sig->body, declarations, type); } void diff --git a/glsl_types.cpp b/glsl_types.cpp index 24b3e3f59f9..b7abdaef2ce 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -180,7 +180,8 @@ glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const */ static ir_label * generate_constructor_intro(const glsl_type *type, unsigned parameter_count, - exec_list *parameters, exec_list *instructions, + ir_function_signature *const signature, + exec_list *instructions, ir_variable **declarations) { /* Names of parameters used in vector and matrix constructors @@ -194,25 +195,25 @@ generate_constructor_intro(const glsl_type *type, unsigned parameter_count, const glsl_type *const parameter_type = type->get_base_type(); - ir_label *const label = new ir_label(type->name); + ir_label *const label = new ir_label(type->name, signature); instructions->push_tail(label); for (unsigned i = 0; i < parameter_count; i++) { ir_variable *var = new ir_variable(parameter_type, names[i]); var->mode = ir_var_in; - parameters->push_tail(var); + signature->parameters.push_tail(var); var = new ir_variable(parameter_type, names[i]); var->mode = ir_var_in; - instructions->push_tail(var); + signature->body.push_tail(var); declarations[i] = var; } ir_variable *retval = new ir_variable(type, "__retval"); - instructions->push_tail(retval); + signature->body.push_tail(retval); declarations[16] = retval; return label; @@ -453,11 +454,11 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, f->add_signature(sig); sig->definition = - generate_constructor_intro(& types[i], 1, & sig->parameters, + generate_constructor_intro(& types[i], 1, sig, instructions, declarations); if (types[i].is_vector()) { - generate_vec_body_from_scalar(instructions, declarations); + generate_vec_body_from_scalar(&sig->body, declarations); ir_function_signature *const vec_sig = new ir_function_signature(& types[i]); @@ -465,13 +466,13 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, vec_sig->definition = generate_constructor_intro(& types[i], types[i].vector_elements, - & vec_sig->parameters, instructions, + vec_sig, instructions, declarations); - generate_vec_body_from_N_scalars(instructions, declarations); + generate_vec_body_from_N_scalars(&sig->body, declarations); } else { assert(types[i].is_matrix()); - generate_mat_body_from_scalar(instructions, declarations); + generate_mat_body_from_scalar(&sig->body, declarations); ir_function_signature *const mat_sig = new ir_function_signature(& types[i]); @@ -481,7 +482,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, generate_constructor_intro(& types[i], (types[i].vector_elements * types[i].matrix_columns), - & mat_sig->parameters, instructions, + mat_sig, instructions, declarations); generate_mat_body_from_N_scalars(instructions, declarations); } diff --git a/ir.cpp b/ir.cpp index 99a966e1540..ed0658a18f4 100644 --- a/ir.cpp +++ b/ir.cpp @@ -110,8 +110,8 @@ ir_expression::get_num_operands(void) return num_operands[this->operation]; } -ir_label::ir_label(const char *label) - : ir_instruction(), label(label) +ir_label::ir_label(const char *label, ir_function_signature *signature) + : ir_instruction(), label(label), signature(signature) { /* empty */ } diff --git a/ir.h b/ir.h index 7ae5e3b952a..95991c013fa 100644 --- a/ir.h +++ b/ir.h @@ -170,7 +170,7 @@ public: class ir_label : public ir_instruction { public: - ir_label(const char *label); + ir_label(const char *label, ir_function_signature *signature); virtual void accept(ir_visitor *v) { @@ -178,11 +178,16 @@ public: } const char *label; + + ir_function_signature *signature; }; /*@{*/ class ir_function_signature : public ir_instruction { + /* An ir_function_signature will be part of the list of signatures in + * an ir_function. + */ public: ir_function_signature(const glsl_type *return_type); @@ -216,6 +221,9 @@ public: */ ir_label *definition; + /** Body of instructions in the function. */ + struct exec_list body; + private: /** Function of which this signature is one overload. */ class ir_function *function; diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index e43f6f0ea4c..294f2c2409f 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -46,14 +46,14 @@ ir_constant_folding_visitor::visit(ir_variable *ir) void ir_constant_folding_visitor::visit(ir_label *ir) { - (void) ir; + ir->signature->accept(this); } void ir_constant_folding_visitor::visit(ir_function_signature *ir) { - (void) ir; + visit_exec_list(&ir->body, this); } diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 20f9a5b5c50..8396973f6c5 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -66,14 +66,20 @@ void ir_print_visitor::visit(ir_variable *ir) void ir_print_visitor::visit(ir_label *ir) { - printf("\n(label %s)", ir->label); + printf("\n(label %s\n", ir->label); + ir->signature->accept(this); + printf(")"); } void ir_print_visitor::visit(ir_function_signature *ir) { - printf("%s:%d:\n", __func__, __LINE__); - (void) ir; + foreach_iter(exec_list_iterator, iter, ir->body) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + inst->accept(this); + printf("\n"); + } } -- cgit v1.2.3 From 7e78e07ddb8a1e2abd3786aeb4740addd301d67c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Apr 2010 13:34:15 -0700 Subject: Fix the returns of builtin functions to actually return. --- builtin_function.cpp | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index f8ec38c90b5..ec6fd1b11a3 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -34,13 +34,12 @@ generate_unop(exec_list *instructions, const glsl_type *type, enum ir_expression_operation op) { - ir_dereference *const retval = new ir_dereference(declarations[16]); ir_dereference *const arg = new ir_dereference(declarations[0]); ir_rvalue *result; result = new ir_expression(op, type, arg, NULL); - ir_instruction *inst = new ir_assignment(retval, result, NULL); + ir_instruction *inst = new ir_return(result); instructions->push_tail(inst); } @@ -50,14 +49,13 @@ generate_binop(exec_list *instructions, const glsl_type *type, enum ir_expression_operation op) { - ir_dereference *const retval = new ir_dereference(declarations[16]); ir_dereference *const arg1 = new ir_dereference(declarations[0]); ir_dereference *const arg2 = new ir_dereference(declarations[1]); ir_rvalue *result; result = new ir_expression(op, type, arg1, arg2); - ir_instruction *inst = new ir_assignment(retval, result, NULL); + ir_instruction *inst = new ir_return(result); instructions->push_tail(inst); } @@ -66,7 +64,6 @@ generate_radians(exec_list *instructions, ir_variable **declarations, const glsl_type *type) { - ir_dereference *const retval = new ir_dereference(declarations[16]); ir_dereference *const arg = new ir_dereference(declarations[0]); ir_rvalue *result; @@ -74,7 +71,7 @@ generate_radians(exec_list *instructions, arg, new ir_constant((float)(M_PI / 180.0))); - ir_instruction *inst = new ir_assignment(retval, result, NULL); + ir_instruction *inst = new ir_return(result); instructions->push_tail(inst); } @@ -83,7 +80,6 @@ generate_degrees(exec_list *instructions, ir_variable **declarations, const glsl_type *type) { - ir_dereference *const retval = new ir_dereference(declarations[16]); ir_dereference *const arg = new ir_dereference(declarations[0]); ir_rvalue *result; @@ -91,7 +87,7 @@ generate_degrees(exec_list *instructions, arg, new ir_constant((float)(180.0 / M_PI))); - ir_instruction *inst = new ir_assignment(retval, result, NULL); + ir_instruction *inst = new ir_return(result); instructions->push_tail(inst); } @@ -211,9 +207,9 @@ generate_function_instance(ir_function *f, const glsl_type *ret_type, const glsl_type *type) { - ir_variable *declarations[17]; + ir_variable *declarations[16]; - ir_function_signature *const sig = new ir_function_signature(type); + ir_function_signature *const sig = new ir_function_signature(ret_type); f->add_signature(sig); ir_label *const label = new ir_label(name, sig); @@ -238,11 +234,6 @@ generate_function_instance(ir_function *f, declarations[i] = var; } - ir_variable *retval = new ir_variable(ret_type, "__retval"); - sig->body.push_tail(retval); - - declarations[16] = retval; - generate(&sig->body, declarations, type); } @@ -278,7 +269,6 @@ generate_length(exec_list *instructions, ir_variable **declarations, const glsl_type *type) { - ir_dereference *const retval = new ir_dereference(declarations[16]); ir_dereference *const arg = new ir_dereference(declarations[0]); ir_rvalue *result, *temp; @@ -289,7 +279,7 @@ generate_length(exec_list *instructions, temp = new ir_expression(ir_binop_dot, glsl_type::float_type, arg, arg); result = new ir_expression(ir_unop_sqrt, glsl_type::float_type, temp, NULL); - ir_instruction *inst = new ir_assignment(retval, result, NULL); + ir_instruction *inst = new ir_return(result); instructions->push_tail(inst); } @@ -321,7 +311,6 @@ generate_dot(exec_list *instructions, ir_variable **declarations, const glsl_type *type) { - ir_dereference *const retval = new ir_dereference(declarations[16]); ir_dereference *const arg = new ir_dereference(declarations[0]); ir_rvalue *result; @@ -329,7 +318,7 @@ generate_dot(exec_list *instructions, result = new ir_expression(ir_binop_dot, glsl_type::float_type, arg, arg); - ir_instruction *inst = new ir_assignment(retval, result, NULL); + ir_instruction *inst = new ir_return(result); instructions->push_tail(inst); } -- cgit v1.2.3 From 6173312d84daabaf6dbe8fa15558cba4c9cb9f5e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Apr 2010 15:18:37 -0700 Subject: Make dot() take the right number of args. --- builtin_function.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index ec6fd1b11a3..9cefbd4ae5f 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -311,12 +311,13 @@ generate_dot(exec_list *instructions, ir_variable **declarations, const glsl_type *type) { - ir_dereference *const arg = new ir_dereference(declarations[0]); + ir_dereference *const arg0 = new ir_dereference(declarations[0]); + ir_dereference *const arg1 = new ir_dereference(declarations[1]); ir_rvalue *result; (void)type; - result = new ir_expression(ir_binop_dot, glsl_type::float_type, arg, arg); + result = new ir_expression(ir_binop_dot, glsl_type::float_type, arg0, arg1); ir_instruction *inst = new ir_return(result); instructions->push_tail(inst); @@ -335,13 +336,13 @@ generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions) bool added = symtab->add_function(name, f); assert(added); - generate_function_instance(f, name, instructions, 1, generate_dot, + generate_function_instance(f, name, instructions, 2, generate_dot, float_type, float_type); - generate_function_instance(f, name, instructions, 1, generate_dot, + generate_function_instance(f, name, instructions, 2, generate_dot, float_type, vec2_type); - generate_function_instance(f, name, instructions, 1, generate_dot, + generate_function_instance(f, name, instructions, 2, generate_dot, float_type, vec3_type); - generate_function_instance(f, name, instructions, 1, generate_dot, + generate_function_instance(f, name, instructions, 2, generate_dot, float_type, vec4_type); } -- cgit v1.2.3 From fbc7c0b8f2e161bce1c048c63d2d5cfcdeb096f1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Apr 2010 14:32:53 -0700 Subject: Make function bodies rely on the parameter variable declarations. Previously, generating inlined function bodies was going to be difficult, as there was no mapping between the body's declaration of variables where parameter values were supposed to live and the parameter variables that a caller would use in paramater setup. Presumably this also have been a problem for actual codegen. --- ast_to_hir.cpp | 8 ++------ builtin_function.cpp | 4 ---- glsl_types.cpp | 5 ----- ir_print_visitor.cpp | 10 ++++++++++ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index d74e54c602e..aa9a3a1a04d 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1925,13 +1925,9 @@ ast_function_definition::hir(exec_list *instructions, */ state->symbols->push_scope(); foreach_iter(exec_list_iterator, iter, signature->parameters) { - ir_variable *const proto = ((ir_instruction *) iter.get())->as_variable(); + ir_variable *const var = ((ir_instruction *) iter.get())->as_variable(); - assert(proto != NULL); - - ir_variable *const var = proto->clone(); - - signature->body.push_tail(var); + assert(var != NULL); /* The only way a parameter would "exist" is if two parameters have * the same name. diff --git a/builtin_function.cpp b/builtin_function.cpp index 9cefbd4ae5f..e537141e3f0 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -224,13 +224,9 @@ generate_function_instance(ir_function *f, for (i = 0; i < n_args; i++) { ir_variable *var = new ir_variable(type, arg_names[i]); - var = new ir_variable(type, arg_names[i]); var->mode = ir_var_in; sig->parameters.push_tail(var); - var = new ir_variable(type, arg_names[i]); - var->mode = ir_var_in; - sig->body.push_tail(var); declarations[i] = var; } diff --git a/glsl_types.cpp b/glsl_types.cpp index b7abdaef2ce..c8d18b9ee7a 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -204,11 +204,6 @@ generate_constructor_intro(const glsl_type *type, unsigned parameter_count, var->mode = ir_var_in; signature->parameters.push_tail(var); - var = new ir_variable(parameter_type, names[i]); - - var->mode = ir_var_in; - signature->body.push_tail(var); - declarations[i] = var; } diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 8396973f6c5..908f1c3ad8d 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -67,6 +67,7 @@ void ir_print_visitor::visit(ir_variable *ir) void ir_print_visitor::visit(ir_label *ir) { printf("\n(label %s\n", ir->label); + ir->signature->accept(this); printf(")"); } @@ -74,6 +75,15 @@ void ir_print_visitor::visit(ir_label *ir) void ir_print_visitor::visit(ir_function_signature *ir) { + printf("(paramaters\n"); + foreach_iter(exec_list_iterator, iter, ir->parameters) { + ir_variable *const inst = (ir_variable *) iter.get(); + + inst->accept(this); + printf("\n"); + } + printf(")\n"); + foreach_iter(exec_list_iterator, iter, ir->body) { ir_instruction *const inst = (ir_instruction *) iter.get(); -- cgit v1.2.3 From b427c917ce47675b102fac3ddace883629ff6be8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 18:03:50 -0700 Subject: Remove extraneous base-class constructor calls --- ir.cpp | 17 ++++------------- ir.h | 10 ++++++---- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/ir.cpp b/ir.cpp index ed0658a18f4..a68d01cca96 100644 --- a/ir.cpp +++ b/ir.cpp @@ -29,7 +29,6 @@ ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition) - : ir_rvalue() { this->lhs = lhs; this->rhs = rhs; @@ -39,7 +38,6 @@ ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_expression::ir_expression(int op, const struct glsl_type *type, ir_rvalue *op0, ir_rvalue *op1) - : ir_rvalue() { this->type = type; this->operation = ir_expression_operation(op); @@ -111,14 +109,13 @@ ir_expression::get_num_operands(void) } ir_label::ir_label(const char *label, ir_function_signature *signature) - : ir_instruction(), label(label), signature(signature) + : label(label), signature(signature) { /* empty */ } ir_constant::ir_constant(const struct glsl_type *type, const void *data) - : ir_rvalue() { unsigned size = 0; @@ -138,28 +135,24 @@ ir_constant::ir_constant(const struct glsl_type *type, const void *data) } ir_constant::ir_constant(float f) - : ir_rvalue() { this->type = glsl_type::float_type; this->value.f[0] = f; } ir_constant::ir_constant(unsigned int u) - : ir_rvalue() { this->type = glsl_type::uint_type; this->value.u[0] = u; } ir_constant::ir_constant(int i) - : ir_rvalue() { this->type = glsl_type::int_type; this->value.i[0] = i; } ir_constant::ir_constant(bool b) - : ir_rvalue() { this->type = glsl_type::bool_type; this->value.b[0] = b; @@ -167,7 +160,6 @@ ir_constant::ir_constant(bool b) ir_dereference::ir_dereference(ir_instruction *var) - : ir_rvalue() { this->mode = ir_reference_variable; this->var = var; @@ -177,8 +169,7 @@ ir_dereference::ir_dereference(ir_instruction *var) ir_dereference::ir_dereference(ir_instruction *var, ir_rvalue *array_index) - : ir_rvalue(), mode(ir_reference_array), - var(var) + : mode(ir_reference_array), var(var) { type = glsl_type::error_type; @@ -347,14 +338,14 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) ir_function_signature::ir_function_signature(const glsl_type *return_type) - : ir_instruction(), return_type(return_type), definition(NULL) + : return_type(return_type), definition(NULL) { /* empty */ } ir_function::ir_function(const char *name) - : ir_instruction(), name(name) + : name(name) { /* empty */ } diff --git a/ir.h b/ir.h index 95991c013fa..34e285813c6 100644 --- a/ir.h +++ b/ir.h @@ -78,7 +78,10 @@ public: } protected: - ir_rvalue() : ir_instruction() { } + ir_rvalue() + { + /* empty */ + } }; @@ -469,7 +472,7 @@ public: class ir_call : public ir_rvalue { public: ir_call(const ir_function_signature *callee, exec_list *actual_parameters) - : ir_rvalue(), callee(callee) + : callee(callee) { assert(callee->return_type != NULL); type = callee->return_type; @@ -504,7 +507,7 @@ public: private: ir_call() - : ir_rvalue(), callee(NULL) + : callee(NULL) { /* empty */ } @@ -525,7 +528,6 @@ private: class ir_jump : public ir_instruction { protected: ir_jump() - : ir_instruction() { /* empty */ } -- cgit v1.2.3 From cad9766118d269725ef33b4e9588d674d5225010 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Apr 2010 11:46:26 -0700 Subject: Inline functions consisting of a return of an expression. --- Makefile.am | 3 +- glsl_parser_extras.cpp | 3 + ir.h | 47 +++++ ir_function_inlining.cpp | 522 +++++++++++++++++++++++++++++++++++++++++++++++ ir_function_inlining.h | 67 ++++++ list.h | 11 + 6 files changed, 652 insertions(+), 1 deletion(-) create mode 100644 ir_function_inlining.cpp create mode 100644 ir_function_inlining.h diff --git a/Makefile.am b/Makefile.am index 32c804c1252..6fac0a8c4c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,7 +29,8 @@ glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ ir.cpp hir_field_selection.cpp builtin_function.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \ ir_constant_expression.cpp \ - ir_constant_folding.cpp + ir_constant_folding.cpp \ + ir_function_inlining.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index fd44e966024..a4a67c88bcb 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -35,6 +35,7 @@ #include "glsl_parser_extras.h" #include "glsl_parser.h" #include "ir_constant_folding.h" +#include "ir_function_inlining.h" #include "ir_print_visitor.h" const char * @@ -753,6 +754,8 @@ main(int argc, char **argv) /* Optimization passes */ if (!state.error) { + do_function_inlining(&instructions); + /* Constant folding */ ir_constant_folding_visitor constant_folding; visit_exec_list(&instructions, &constant_folding); diff --git a/ir.h b/ir.h index 34e285813c6..2d3a8cdb0b0 100644 --- a/ir.h +++ b/ir.h @@ -55,6 +55,9 @@ public: virtual class ir_dereference * as_dereference() { return NULL; } virtual class ir_rvalue * as_rvalue() { return NULL; } virtual class ir_loop * as_loop() { return NULL; } + virtual class ir_assignment * as_assignment() { return NULL; } + virtual class ir_call * as_call() { return NULL; } + virtual class ir_return * as_return() { return NULL; } /*@}*/ protected: @@ -361,6 +364,11 @@ public: v->visit(this); } + virtual ir_assignment * as_assignment() + { + return this; + } + /** * Left-hand side of the assignment. */ @@ -461,6 +469,8 @@ public: v->visit(this); } + ir_expression *clone(); + ir_expression_operation operation; ir_rvalue *operands[2]; }; @@ -479,6 +489,11 @@ public: actual_parameters->move_nodes_to(& this->actual_parameters); } + virtual ir_call *as_call() + { + return this; + } + virtual void accept(ir_visitor *v) { v->visit(this); @@ -505,6 +520,17 @@ public: return callee->function_name(); } + const ir_function_signature *get_callee() + { + return callee; + } + + /** + * Generates an inline version of the function before @ir, + * returning the return value of the function. + */ + ir_rvalue *generate_inline(ir_instruction *ir); + private: ir_call() : callee(NULL) @@ -547,6 +573,11 @@ public: /* empty */ } + virtual ir_return *as_return() + { + return this; + } + ir_rvalue *get_value() const { return value; @@ -632,6 +663,17 @@ class ir_swizzle : public ir_rvalue { public: ir_swizzle(ir_rvalue *, unsigned x, unsigned y, unsigned z, unsigned w, unsigned count); + ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) + : val(val), mask(mask) + { + /* empty */ + } + + ir_swizzle *clone() + { + return new ir_swizzle(this->val, this->mask); + } + /** * Construct an ir_swizzle from the textual representation. Can fail. */ @@ -703,6 +745,11 @@ public: v->visit(this); } + ir_constant *clone() + { + return new ir_constant(this->type, &this->value); + } + /** * Value of the constant. * diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp new file mode 100644 index 00000000000..b6434b80544 --- /dev/null +++ b/ir_function_inlining.cpp @@ -0,0 +1,522 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_inlining.cpp + * + * Replaces calls to functions with the body of the function. + */ + +#define NULL 0 +#include "ir.h" +#include "ir_visitor.h" +#include "ir_function_inlining.h" +#include "glsl_types.h" + +class variable_remap : public exec_node { +public: + variable_remap(const ir_variable *old_var, ir_variable *new_var) + : old_var(old_var), new_var(new_var) + { + /* empty */ + } + const ir_variable *old_var; + ir_variable *new_var; +}; + +class ir_function_cloning_visitor : public ir_visitor { +public: + ir_function_cloning_visitor(ir_variable *retval) + : retval(retval) + { + /* empty */ + } + + virtual ~ir_function_cloning_visitor() + { + /* empty */ + } + + void remap_variable(const ir_variable *old_var, ir_variable *new_var) { + variable_remap *remap = new variable_remap(old_var, new_var); + this->remap_list.push_tail(remap); + } + + ir_variable *get_remapped_variable(ir_variable *var) { + foreach_iter(exec_list_iterator, iter, this->remap_list) { + variable_remap *remap = (variable_remap *)iter.get(); + + if (var == remap->old_var) + return remap->new_var; + } + + /* Not a reapped variable, so a global scoped reference, for example. */ + return var; + } + + /* List of variable_remap for mapping from original function body variables + * to inlined function body variables. + */ + exec_list remap_list; + + /* Return value for the inlined function. */ + ir_variable *retval; + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_label *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ + + ir_instruction *result; +}; + +void +ir_function_cloning_visitor::visit(ir_variable *ir) +{ + ir_variable *new_var = ir->clone(); + + this->result = new_var; + + this->remap_variable(ir, new_var); +} + +void +ir_function_cloning_visitor::visit(ir_label *ir) +{ + (void)ir; + this->result = NULL; +} + +void +ir_function_cloning_visitor::visit(ir_loop *ir) +{ + (void)ir; + this->result = NULL; +} + +void +ir_function_cloning_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; + this->result = NULL; +} + + +void +ir_function_cloning_visitor::visit(ir_function_signature *ir) +{ + (void)ir; + this->result = NULL; +} + + +void +ir_function_cloning_visitor::visit(ir_function *ir) +{ + (void) ir; + this->result = NULL; +} + +void +ir_function_cloning_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + ir_rvalue *op[2] = {NULL, NULL}; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + ir->operands[operand]->accept(this); + op[operand] = this->result->as_rvalue(); + assert(op[operand]); + } + + this->result = new ir_expression(ir->operation, ir->type, op[0], op[1]); +} + + +void +ir_function_cloning_visitor::visit(ir_swizzle *ir) +{ + ir->val->accept(this); + + this->result = new ir_swizzle(this->result->as_rvalue(), ir->mask); +} + +void +ir_function_cloning_visitor::visit(ir_dereference *ir) +{ + if (ir->mode == ir_dereference::ir_reference_variable) { + ir_variable *old_var = ir->var->as_variable(); + + /* If it's a deref of a real variable, then we need to remap it if + * it was local to the function. + */ + if (old_var) { + ir_variable *new_var; + + new_var = this->get_remapped_variable(old_var); + + this->result = new ir_dereference(new_var); + } else { + ir->var->accept(this); + + this->result = new ir_dereference(this->result); + } + } else { + this->result = NULL; + } +} + +void +ir_function_cloning_visitor::visit(ir_assignment *ir) +{ + ir_rvalue *lhs, *rhs, *condition; + + ir->lhs->accept(this); + lhs = this->result->as_rvalue(); + + ir->rhs->accept(this); + rhs = this->result->as_rvalue(); + + ir->condition->accept(this); + condition = this->result->as_rvalue(); + + this->result = new ir_assignment(lhs, rhs, condition); +} + + +void +ir_function_cloning_visitor::visit(ir_constant *ir) +{ + this->result = ir->clone(); +} + + +void +ir_function_cloning_visitor::visit(ir_call *ir) +{ + exec_list parameters; + + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + + param->accept(this); + parameters.push_tail(this->result); + } + + this->result = new ir_call(ir->get_callee(), ¶meters); +} + + +void +ir_function_cloning_visitor::visit(ir_return *ir) +{ + ir_rvalue *rval; + + assert(this->retval); + + rval = ir->get_value(); + rval->accept(this); + rval = this->result->as_rvalue(); + assert(rval); + + result = new ir_assignment(new ir_dereference(this->retval), + ir->get_value(), NULL); +} + + +void +ir_function_cloning_visitor::visit(ir_if *ir) +{ + (void) ir; + result = NULL; +} + +bool +can_inline(ir_call *call) +{ + bool found_return = false; + + /* FINISHME: Right now we only allow a single statement that is a return. + */ + foreach_iter(exec_list_iterator, iter, call->get_callee()->body) { + ir_instruction *ir = (ir_instruction *)iter.get(); + if (ir->get_next()->get_next() != NULL) + return false; + + if (!ir->as_return()) + return false; + + found_return = true; + } + + return found_return; +} + +bool +do_function_inlining(exec_list *instructions) +{ + bool progress; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_assignment *assign = ir->as_assignment(); + ir_call *call; + + if (assign) { + call = assign->rhs->as_call(); + if (!call || !can_inline(call)) + continue; + + /* generates the parameter setup, function body, and returns the return + * value of the function + */ + ir_rvalue *rhs = call->generate_inline(ir); + assert(rhs); + + assign->rhs = rhs; + progress = true; + } else if ((call = ir->as_call()) && can_inline(call)) { + (void)call->generate_inline(ir); + ir->remove(); + progress = true; + } else { + ir_function_inlining_visitor v; + ir->accept(&v); + } + } + + return progress; +} + +ir_rvalue * +ir_call::generate_inline(ir_instruction *next_ir) +{ + ir_variable **parameters; + int num_parameters; + int i; + ir_variable *retval = NULL; + + num_parameters = 0; + foreach_iter(exec_list_iterator, iter_sig, this->callee->parameters) + num_parameters++; + + parameters = new ir_variable *[num_parameters]; + + /* Generate storage for the return value. */ + if (this->callee->return_type) { + retval = new ir_variable(this->callee->return_type, "__retval"); + next_ir->insert_before(retval); + } + + ir_function_cloning_visitor v = ir_function_cloning_visitor(retval); + + /* Generate the declarations for the parameters to our inlined code, + * and set up the mapping of real function body variables to ours. + */ + i = 0; + exec_list_iterator sig_param_iter = this->callee->parameters.iterator(); + exec_list_iterator param_iter = this->actual_parameters.iterator(); + for (i = 0; i < num_parameters; i++) { + const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get(); + ir_rvalue *param = (ir_rvalue *) param_iter.get(); + + /* Generate a new variable for the parameter. */ + parameters[i] = sig_param->clone(); + next_ir->insert_before(parameters[i]); + + v.remap_variable(sig_param, parameters[i]); + + /* Move the actual param into our param variable if it's an 'in' type. */ + if (parameters[i]->mode == ir_var_in || + parameters[i]->mode == ir_var_inout) { + ir_assignment *assign; + + assign = new ir_assignment(new ir_dereference(parameters[i]), + param, NULL); + next_ir->insert_before(assign); + } + + sig_param_iter.next(); + param_iter.next(); + } + + /* Generate the inlined body of the function. */ + foreach_iter(exec_list_iterator, iter, callee->body) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + ir->accept(&v); + assert(v.result); + next_ir->insert_before(v.result); + } + + /* Generate the declarations for the parameters to our inlined code, + * and set up the mapping of real function body variables to ours. + */ + i = 0; + param_iter = this->actual_parameters.iterator(); + for (i = 0; i < num_parameters; i++) { + ir_instruction *const param = (ir_instruction *) param_iter.get(); + + /* Move the actual param into our param variable if it's an 'in' type. */ + if (parameters[i]->mode == ir_var_out || + parameters[i]->mode == ir_var_inout) { + ir_assignment *assign; + + assign = new ir_assignment(param->as_rvalue(), + new ir_dereference(parameters[i]), + NULL); + next_ir->insert_before(assign); + } + + param_iter.next(); + } + + delete(parameters); + + if (retval) + return new ir_dereference(retval); + else + return NULL; +} + +void +ir_function_inlining_visitor::visit(ir_variable *ir) +{ + (void) ir; +} + + +void +ir_function_inlining_visitor::visit(ir_label *ir) +{ + ir->signature->accept(this); +} + +void +ir_function_inlining_visitor::visit(ir_loop *ir) +{ + do_function_inlining(&ir->body_instructions); +} + +void +ir_function_inlining_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; +} + + +void +ir_function_inlining_visitor::visit(ir_function_signature *ir) +{ + do_function_inlining(&ir->body); +} + + +void +ir_function_inlining_visitor::visit(ir_function *ir) +{ + (void) ir; +} + +void +ir_function_inlining_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + ir->operands[operand]->accept(this); + } +} + + +void +ir_function_inlining_visitor::visit(ir_swizzle *ir) +{ + ir->val->accept(this); +} + + +void +ir_function_inlining_visitor::visit(ir_dereference *ir) +{ + if (ir->mode == ir_dereference::ir_reference_array) { + ir->selector.array_index->accept(this); + } + ir->var->accept(this); +} + +void +ir_function_inlining_visitor::visit(ir_assignment *ir) +{ + ir->rhs->accept(this); +} + + +void +ir_function_inlining_visitor::visit(ir_constant *ir) +{ + (void) ir; +} + + +void +ir_function_inlining_visitor::visit(ir_call *ir) +{ + (void) ir; +} + + +void +ir_function_inlining_visitor::visit(ir_return *ir) +{ + (void) ir; +} + + +void +ir_function_inlining_visitor::visit(ir_if *ir) +{ + ir->condition->accept(this); + + do_function_inlining(&ir->then_instructions); + do_function_inlining(&ir->else_instructions); +} diff --git a/ir_function_inlining.h b/ir_function_inlining.h new file mode 100644 index 00000000000..60c80a6dfbf --- /dev/null +++ b/ir_function_inlining.h @@ -0,0 +1,67 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_inlining.h + * + * Replaces calls to functions with the body of the function. + */ + +class ir_function_inlining_visitor : public ir_visitor { +public: + ir_function_inlining_visitor() + { + /* empty */ + } + + virtual ~ir_function_inlining_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_label *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ +}; + +bool do_function_inlining(exec_list *instructions); diff --git a/list.h b/list.h index 054be7ed435..afa32f1ed97 100644 --- a/list.h +++ b/list.h @@ -126,6 +126,17 @@ struct exec_node { this->next->prev = after; this->next = after; } + /** + * Insert a node in the list before the current node + */ + void insert_before(exec_node *before) + { + before->next = this; + before->prev = this->prev; + + this->prev->next = before; + this->prev = before; + } #endif }; -- cgit v1.2.3 From 6192434ac3bf621d600515589552100c8f5b8418 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 8 Apr 2010 13:40:52 -0700 Subject: Add inlining support for array dereferences. --- ir_function_inlining.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index b6434b80544..40f82513095 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -200,8 +200,21 @@ ir_function_cloning_visitor::visit(ir_dereference *ir) this->result = new ir_dereference(this->result); } + } else if (ir->mode == ir_dereference::ir_reference_array) { + ir_instruction *variable; + ir_rvalue *index; + + ir->var->accept(this); + variable = this->result; + + ir->selector.array_index->accept(this); + index = this->result->as_rvalue(); + + this->result = new ir_dereference(variable, index); } else { - this->result = NULL; + assert(ir->mode == ir_dereference::ir_reference_record); + /* FINISHME: inlining of structure references */ + assert(0); } } -- cgit v1.2.3 From 2a7b2b22f47661029a1e8eea3d3765bd782412b3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 8 Apr 2010 13:42:48 -0700 Subject: Repeat the optimization passes until we stop making progress. --- glsl_parser_extras.cpp | 13 +++++++++---- ir_function_inlining.cpp | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index a4a67c88bcb..38dee95c359 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -754,11 +754,16 @@ main(int argc, char **argv) /* Optimization passes */ if (!state.error) { - do_function_inlining(&instructions); + bool progress; + do { + progress = false; - /* Constant folding */ - ir_constant_folding_visitor constant_folding; - visit_exec_list(&instructions, &constant_folding); + progress = do_function_inlining(&instructions) || progress; + + /* Constant folding */ + ir_constant_folding_visitor constant_folding; + visit_exec_list(&instructions, &constant_folding); + } while (progress); } /* Print out the resulting IR */ diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 40f82513095..e03673e632d 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -307,7 +307,7 @@ can_inline(ir_call *call) bool do_function_inlining(exec_list *instructions) { - bool progress; + bool progress = false; foreach_iter(exec_list_iterator, iter, *instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); -- cgit v1.2.3 From 925759283a6396faeefb8b33761dd1c681d1593d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 8 Apr 2010 14:34:38 -0700 Subject: Add builtin normalize() functions. Fixes CorrectSqizzle2.vert. --- builtin_function.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/builtin_function.cpp b/builtin_function.cpp index e537141e3f0..1fdf8829360 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -188,6 +188,24 @@ generate_max(exec_list *instructions, } +static void +generate_normalize(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const arg = new ir_dereference(declarations[0]); + ir_rvalue *temp; + ir_rvalue *result; + + temp = new ir_expression(ir_binop_dot, glsl_type::float_type, arg, arg); + temp = new ir_expression(ir_unop_rsq, glsl_type::float_type, temp, NULL); + result = new ir_expression(ir_binop_mul, type, arg, temp); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + + static void generate_pow(exec_list *instructions, ir_variable **declarations, @@ -386,6 +404,8 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: distance() */ generate_dot_functions(symtab, instructions); /* FINISHME: cross() */ + make_gentype_function(symtab, instructions, "normalize", 1, + generate_normalize); /* FINISHME: normalize() */ /* FINISHME: ftransform() */ /* FINISHME: faceforward() */ -- cgit v1.2.3 From feeb43b829f25aef19bd71bf6d88e08dabf59aad Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 8 Apr 2010 15:02:59 -0700 Subject: Add buitlin functions for any(), all(), not(). --- builtin_function.cpp | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 203 insertions(+), 3 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index 1fdf8829360..9869f70597e 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -360,6 +360,206 @@ generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions) float_type, vec4_type); } +static void +generate_any_bvec2(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const arg0 = new ir_dereference(declarations[0]); + ir_rvalue *result; + + (void)type; + + result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, + new ir_swizzle(arg0, 0, 0, 0, 0, 1), + new ir_swizzle(arg0, 1, 0, 0, 0, 1)); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + +static void +generate_any_bvec3(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const arg0 = new ir_dereference(declarations[0]); + ir_rvalue *result; + + (void)type; + + result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, + new ir_swizzle(arg0, 0, 0, 0, 0, 1), + new ir_swizzle(arg0, 1, 0, 0, 0, 1)); + result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, + result, + new ir_swizzle(arg0, 2, 0, 0, 0, 1)); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + +static void +generate_any_bvec4(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const arg0 = new ir_dereference(declarations[0]); + ir_rvalue *result; + + (void)type; + + result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, + new ir_swizzle(arg0, 0, 0, 0, 0, 1), + new ir_swizzle(arg0, 1, 0, 0, 0, 1)); + result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, + result, + new ir_swizzle(arg0, 2, 0, 0, 0, 1)); + result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, + result, + new ir_swizzle(arg0, 3, 0, 0, 0, 1)); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + +static void +generate_all_bvec2(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const arg0 = new ir_dereference(declarations[0]); + ir_rvalue *result; + + (void)type; + + result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, + new ir_swizzle(arg0, 0, 0, 0, 0, 1), + new ir_swizzle(arg0, 1, 0, 0, 0, 1)); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + +static void +generate_all_bvec3(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const arg0 = new ir_dereference(declarations[0]); + ir_rvalue *result; + + (void)type; + + result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, + new ir_swizzle(arg0, 0, 0, 0, 0, 1), + new ir_swizzle(arg0, 1, 0, 0, 0, 1)); + result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, + result, + new ir_swizzle(arg0, 2, 0, 0, 0, 1)); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + +static void +generate_all_bvec4(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const arg0 = new ir_dereference(declarations[0]); + ir_rvalue *result; + + (void)type; + + result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, + new ir_swizzle(arg0, 0, 0, 0, 0, 1), + new ir_swizzle(arg0, 1, 0, 0, 0, 1)); + result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, + result, + new ir_swizzle(arg0, 2, 0, 0, 0, 1)); + result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, + result, + new ir_swizzle(arg0, 3, 0, 0, 0, 1)); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + +static void +generate_not(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const arg0 = new ir_dereference(declarations[0]); + ir_rvalue *result; + + result = new ir_expression(ir_unop_logic_not, type, arg0, NULL); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + +void +generate_any_functions(glsl_symbol_table *symtab, exec_list *instructions) +{ + const char *name = "any"; + ir_function *const f = new ir_function(name); + const glsl_type *bvec2_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1); + const glsl_type *bvec3_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 3, 1); + const glsl_type *bvec4_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1); + + bool added = symtab->add_function(name, f); + assert(added); + + generate_function_instance(f, name, instructions, 1, generate_any_bvec2, + glsl_type::bool_type, bvec2_type); + generate_function_instance(f, name, instructions, 1, generate_any_bvec3, + glsl_type::bool_type, bvec3_type); + generate_function_instance(f, name, instructions, 1, generate_any_bvec4, + glsl_type::bool_type, bvec4_type); +} + +void +generate_all_functions(glsl_symbol_table *symtab, exec_list *instructions) +{ + const char *name = "all"; + ir_function *const f = new ir_function(name); + const glsl_type *bvec2_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1); + const glsl_type *bvec3_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 3, 1); + const glsl_type *bvec4_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1); + + bool added = symtab->add_function(name, f); + assert(added); + + generate_function_instance(f, name, instructions, 1, generate_all_bvec2, + glsl_type::bool_type, bvec2_type); + generate_function_instance(f, name, instructions, 1, generate_all_bvec3, + glsl_type::bool_type, bvec3_type); + generate_function_instance(f, name, instructions, 1, generate_all_bvec4, + glsl_type::bool_type, bvec4_type); +} + +void +generate_not_functions(glsl_symbol_table *symtab, exec_list *instructions) +{ + const char *name = "not"; + ir_function *const f = new ir_function(name); + const glsl_type *bvec2_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1); + const glsl_type *bvec3_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 3, 1); + const glsl_type *bvec4_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1); + + bool added = symtab->add_function(name, f); + assert(added); + + generate_function_instance(f, name, instructions, 1, generate_not, + bvec2_type, bvec2_type); + generate_function_instance(f, name, instructions, 1, generate_not, + bvec3_type, bvec3_type); + generate_function_instance(f, name, instructions, 1, generate_not, + bvec4_type, bvec4_type); +} + void generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) { @@ -418,9 +618,9 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: greaterThanEqual() */ /* FINISHME: equal() */ /* FINISHME: notEqual() */ - /* FINISHME: any() */ - /* FINISHME: all() */ - /* FINISHME: not() */ + generate_any_functions(symtab, instructions); + generate_all_functions(symtab, instructions); + generate_not_functions(symtab, instructions); /* FINISHME: texture*() */ /* FINISHME: shadow*() */ /* FINISHME: dFd[xy]() */ -- cgit v1.2.3 From cc49cea9eab0dc46ee04d109f42814c4a0581c04 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 8 Apr 2010 15:10:37 -0700 Subject: Add support for builtin gentype mix(gentype a, gentype b) Fixes glsl-fs-mix.frag, glsl-fs-mix-constant.frag. --- builtin_function.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index 9869f70597e..c83bdd0a2c5 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -187,6 +187,26 @@ generate_max(exec_list *instructions, generate_binop(instructions, declarations, type, ir_binop_max); } +static void +generate_mix_vec(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const x = new ir_dereference(declarations[0]); + ir_dereference *const y = new ir_dereference(declarations[1]); + ir_dereference *const a = new ir_dereference(declarations[2]); + ir_rvalue *result, *temp; + + temp = new ir_expression(ir_binop_sub, type, new ir_constant(1.0f), a); + result = new ir_expression(ir_binop_mul, type, x, temp); + + temp = new ir_expression(ir_binop_mul, type, y, a); + result = new ir_expression(ir_binop_add, type, result, temp); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + static void generate_normalize(exec_list *instructions, @@ -235,7 +255,8 @@ generate_function_instance(ir_function *f, sig->definition = label; static const char *arg_names[] = { "arg0", - "arg1" + "arg1", + "arg2" }; int i; @@ -592,7 +613,7 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: max(x, float y) */ /* FINISHME: clamp() */ /* FINISHME: clamp() */ - /* FINISHME: mix() */ + make_gentype_function(symtab, instructions, "mix", 3, generate_mix_vec); /* FINISHME: mix() */ /* FINISHME: step() */ /* FINISHME: step() */ -- cgit v1.2.3 From cc4ef154e6f342266330858563e322dcb640f1f2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 8 Apr 2010 15:35:34 -0700 Subject: Add builtin implementations of vector comparison functions. Fixes CorrectFunction1.vert, glsl-fs-notequal.frag. --- builtin_function.cpp | 159 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 153 insertions(+), 6 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index c83bdd0a2c5..c404b3c4e86 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -299,6 +299,145 @@ make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, vec4_type, vec4_type); } +static void +generate_vec_compare(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type, + enum ir_expression_operation op) +{ + ir_dereference *const x = new ir_dereference(declarations[0]); + ir_dereference *const y = new ir_dereference(declarations[1]); + ir_variable *temp; + const glsl_type *return_type; + int i; + + return_type = glsl_type::get_instance(GLSL_TYPE_BOOL, + type->vector_elements, 1); + temp = new ir_variable(return_type, "temp"); + + for (i = 0; i < type->vector_elements; i++) { + ir_assignment *assign; + ir_expression *compare; + + compare = new ir_expression(op, + glsl_type::get_instance(type->base_type, + 1, 1), + new ir_swizzle(x, i, 0, 0, 0, 1), + new ir_swizzle(y, i, 0, 0, 0, 1)); + assign = new ir_assignment(new ir_swizzle(new ir_dereference(temp), + i, 0, 0, 0, 1), + compare, NULL); + instructions->push_tail(assign); + } + ir_instruction *inst = new ir_return(new ir_dereference(temp)); + instructions->push_tail(inst); +} + +static void +generate_lessThan(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_vec_compare(instructions, declarations, type, ir_binop_less); +} + +static void +generate_lessThanEqual(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_vec_compare(instructions, declarations, type, ir_binop_lequal); +} + +static void +generate_greaterThan(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_vec_compare(instructions, declarations, type, ir_binop_greater); +} + +static void +generate_greaterThanEqual(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_vec_compare(instructions, declarations, type, ir_binop_gequal); +} + +static void +generate_equal(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_vec_compare(instructions, declarations, type, ir_binop_equal); +} + +static void +generate_notEqual(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_vec_compare(instructions, declarations, type, ir_binop_nequal); +} + +static void +generate_vec_compare_function(glsl_symbol_table *symtab, + exec_list *instructions, + const char *name, + void (*generate)(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type), + bool do_bool) +{ + ir_function *const f = new ir_function(name); + const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); + const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); + const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); + const glsl_type *ivec2_type = glsl_type::get_instance(GLSL_TYPE_INT, 2, 1); + const glsl_type *ivec3_type = glsl_type::get_instance(GLSL_TYPE_INT, 3, 1); + const glsl_type *ivec4_type = glsl_type::get_instance(GLSL_TYPE_INT, 4, 1); + const glsl_type *uvec2_type = glsl_type::get_instance(GLSL_TYPE_UINT, 2, 1); + const glsl_type *uvec3_type = glsl_type::get_instance(GLSL_TYPE_UINT, 3, 1); + const glsl_type *uvec4_type = glsl_type::get_instance(GLSL_TYPE_UINT, 4, 1); + const glsl_type *bvec2_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1); + const glsl_type *bvec3_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 3, 1); + const glsl_type *bvec4_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1); + + bool added = symtab->add_function(name, f); + assert(added); + + generate_function_instance(f, name, instructions, 2, generate, + bvec2_type, vec2_type); + generate_function_instance(f, name, instructions, 2, generate, + bvec3_type, vec3_type); + generate_function_instance(f, name, instructions, 2, generate, + bvec4_type, vec4_type); + + generate_function_instance(f, name, instructions, 2, generate, + bvec2_type, ivec2_type); + generate_function_instance(f, name, instructions, 2, generate, + bvec3_type, ivec3_type); + generate_function_instance(f, name, instructions, 2, generate, + bvec4_type, ivec4_type); + + generate_function_instance(f, name, instructions, 2, generate, + bvec2_type, uvec2_type); + generate_function_instance(f, name, instructions, 2, generate, + bvec3_type, uvec3_type); + generate_function_instance(f, name, instructions, 2, generate, + bvec4_type, uvec4_type); + + if (do_bool) { + generate_function_instance(f, name, instructions, 2, generate, + bvec2_type, bvec2_type); + generate_function_instance(f, name, instructions, 2, generate, + bvec3_type, bvec3_type); + generate_function_instance(f, name, instructions, 2, generate, + bvec4_type, bvec4_type); + } +} + static void generate_length(exec_list *instructions, ir_variable **declarations, @@ -633,12 +772,20 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: reflect() */ /* FINISHME: refract() */ /* FINISHME: matrixCompMult() */ - /* FINISHME: lessThan() */ - /* FINISHME: lessThanEqual() */ - /* FINISHME: greaterThan() */ - /* FINISHME: greaterThanEqual() */ - /* FINISHME: equal() */ - /* FINISHME: notEqual() */ + generate_vec_compare_function(symtab, instructions, + "lessThan", generate_lessThan, false); + generate_vec_compare_function(symtab, instructions, + "lessThanEqual", generate_lessThanEqual, + false); + generate_vec_compare_function(symtab, instructions, + "greaterThan", generate_greaterThan, false); + generate_vec_compare_function(symtab, instructions, + "greaterThanEqual", generate_greaterThanEqual, + false); + generate_vec_compare_function(symtab, instructions, + "equal", generate_equal, false); + generate_vec_compare_function(symtab, instructions, + "notEqual", generate_notEqual, false); generate_any_functions(symtab, instructions); generate_all_functions(symtab, instructions); generate_not_functions(symtab, instructions); -- cgit v1.2.3 From a3fa3fbf7693fc76626e0504cdf315949caa4dfb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 8 Apr 2010 15:41:19 -0700 Subject: Add an implementation of gentype-only clamp(). --- builtin_function.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index c404b3c4e86..bdd745062b7 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -187,6 +187,23 @@ generate_max(exec_list *instructions, generate_binop(instructions, declarations, type, ir_binop_max); } +static void +generate_clamp(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const x = new ir_dereference(declarations[0]); + ir_dereference *const minval = new ir_dereference(declarations[1]); + ir_dereference *const maxval = new ir_dereference(declarations[2]); + ir_rvalue *result; + + result = new ir_expression(ir_binop_min, type, x, maxval); + result = new ir_expression(ir_binop_max, type, result, minval); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + static void generate_mix_vec(exec_list *instructions, ir_variable **declarations, @@ -750,7 +767,7 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: min(x, float y) */ make_gentype_function(symtab, instructions, "max", 2, generate_max); /* FINISHME: max(x, float y) */ - /* FINISHME: clamp() */ + make_gentype_function(symtab, instructions, "clamp", 3, generate_clamp); /* FINISHME: clamp() */ make_gentype_function(symtab, instructions, "mix", 3, generate_mix_vec); /* FINISHME: mix() */ -- cgit v1.2.3 From 3b8d2cd77901f7ec91d1b9d1a67536aea9aedca1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 14 Apr 2010 15:27:39 -0700 Subject: Fix the type of gl_FogFragCoord. --- builtin_variables.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin_variables.h b/builtin_variables.h index 902ff22e8ae..6c14a4a42b7 100644 --- a/builtin_variables.h +++ b/builtin_variables.h @@ -42,7 +42,7 @@ static const builtin_variable builtin_core_fs_variables[] = { static const builtin_variable builtin_110_deprecated_fs_variables[] = { { ir_var_in, "vec4", "gl_Color" }, { ir_var_in, "vec4", "gl_SecondaryColor" }, - { ir_var_in, "vec4", "gl_FogFragCoord" }, + { ir_var_in, "float", "gl_FogFragCoord" }, }; static const builtin_variable builtin_110_deprecated_vs_variables[] = { @@ -64,7 +64,7 @@ static const builtin_variable builtin_110_deprecated_vs_variables[] = { { ir_var_out, "vec4", "gl_BackColor" }, { ir_var_out, "vec4", "gl_FrontSecondaryColor" }, { ir_var_out, "vec4", "gl_BackSecondaryColor" }, - { ir_var_out, "vec4", "gl_FogFragCoord" }, + { ir_var_out, "float", "gl_FogFragCoord" }, }; static const builtin_variable builtin_130_vs_variables[] = { -- cgit v1.2.3 From 8558459512594216c5aed0bb8d2b0efcbc8b921c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 14 Apr 2010 15:38:52 -0700 Subject: Return the rvalue of a variable decl to fix while (bool b = condition) {} --- ast_to_hir.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index aa9a3a1a04d..4e1c8191771 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1358,7 +1358,7 @@ ast_declarator_list::hir(exec_list *instructions, struct simple_node *ptr; const struct glsl_type *decl_type; const char *type_name = NULL; - + ir_rvalue *result = NULL; /* FINISHME: Handle vertex shader "invariant" declarations that do not * FINISHME: include a type. These re-declare built-in variables to be @@ -1619,8 +1619,8 @@ ast_declarator_list::hir(exec_list *instructions, bool temp = var->read_only; if (this->type->qualifier.constant) var->read_only = false; - (void) do_assignment(instructions, state, lhs, rhs, - this->get_location()); + result = do_assignment(instructions, state, lhs, rhs, + this->get_location()); var->read_only = temp; } } @@ -1650,9 +1650,17 @@ ast_declarator_list::hir(exec_list *instructions, assert(added_variable); } - /* Variable declarations do not have r-values. + + /* Generally, variable declarations do not have r-values. However, + * one is used for the declaration in + * + * while (bool b = some_condition()) { + * ... + * } + * + * so we return the rvalue from the last seen declaration here. */ - return NULL; + return result; } -- cgit v1.2.3 From 1e7ec3ce128a9d30d7d9e1707a22b270eb525075 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 14 Apr 2010 16:16:20 -0700 Subject: Check that function definition parameter qualifiers match proto qualifiers. Fixes function9.frag. --- ast_to_hir.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 4e1c8191771..b150ba36908 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1841,6 +1841,29 @@ ast_function::hir(exec_list *instructions, * definition. */ if (parameter_lists_match(& hir_parameters, & sig->parameters)) { + exec_list_iterator iter_a = hir_parameters.iterator(); + exec_list_iterator iter_b = sig->parameters.iterator(); + + /* check that the qualifiers match. */ + while (iter_a.has_next()) { + ir_variable *a = (ir_variable *)iter_a.get(); + ir_variable *b = (ir_variable *)iter_b.get(); + + if (a->read_only != b->read_only || + a->interpolation != b->interpolation || + a->centroid != b->centroid) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "function `%s' parameter `%s' qualifiers " + "don't match prototype", + name, a->name); + } + + iter_a.next(); + iter_b.next(); + } + /* FINISHME: Compare return types. */ if (is_definition && (sig->definition != NULL)) { -- cgit v1.2.3 From 60be7626b829af7e1d07330b9a88468924ba350e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 14 Apr 2010 16:19:19 -0700 Subject: Check that the return type of function definition matches its prototype. Doesn't fix any testcases, but fixes a FINISHME. --- ast_to_hir.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index b150ba36908..251845acd9d 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1864,7 +1864,14 @@ ast_function::hir(exec_list *instructions, iter_b.next(); } - /* FINISHME: Compare return types. */ + if (sig->return_type != return_type) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "function `%s' return type doesn't match " + "prototype", + name); + } if (is_definition && (sig->definition != NULL)) { YYLTYPE loc = this->get_location(); -- cgit v1.2.3 From 5ba94206083fcd678febd6cac0231f35c0f1b77a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 14 Apr 2010 17:03:03 -0700 Subject: Add an ir_if simplification pass. This is relatively simple at the moment, recognizing only constant values, and not (for example) values that are restricted to a range that make the branching constant. However, it does remove 59 lines from the printout of CorrectParse2.vert. --- Makefile.am | 3 +- glsl_parser_extras.cpp | 2 + ir.h | 6 ++ ir_if_simplification.cpp | 235 +++++++++++++++++++++++++++++++++++++++++++++++ ir_if_simplification.h | 31 +++++++ 5 files changed, 276 insertions(+), 1 deletion(-) create mode 100644 ir_if_simplification.cpp create mode 100644 ir_if_simplification.h diff --git a/Makefile.am b/Makefile.am index 6fac0a8c4c0..68a1d98d33e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,8 @@ glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \ ir_constant_expression.cpp \ ir_constant_folding.cpp \ - ir_function_inlining.cpp + ir_function_inlining.cpp \ + ir_if_simplification.cpp BUILT_SOURCES = glsl_parser.h builtin_types.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 38dee95c359..455bf0c7a4a 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -36,6 +36,7 @@ #include "glsl_parser.h" #include "ir_constant_folding.h" #include "ir_function_inlining.h" +#include "ir_if_simplification.h" #include "ir_print_visitor.h" const char * @@ -759,6 +760,7 @@ main(int argc, char **argv) progress = false; progress = do_function_inlining(&instructions) || progress; + progress = do_if_simplification(&instructions) || progress; /* Constant folding */ ir_constant_folding_visitor constant_folding; diff --git a/ir.h b/ir.h index 2d3a8cdb0b0..471e19b43d5 100644 --- a/ir.h +++ b/ir.h @@ -58,6 +58,7 @@ public: virtual class ir_assignment * as_assignment() { return NULL; } virtual class ir_call * as_call() { return NULL; } virtual class ir_return * as_return() { return NULL; } + virtual class ir_if * as_if() { return NULL; } /*@}*/ protected: @@ -299,6 +300,11 @@ public: /* empty */ } + virtual ir_if *as_if() + { + return this; + } + virtual void accept(ir_visitor *v) { v->visit(this); diff --git a/ir_if_simplification.cpp b/ir_if_simplification.cpp new file mode 100644 index 00000000000..5637db510ce --- /dev/null +++ b/ir_if_simplification.cpp @@ -0,0 +1,235 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_inlining.cpp + * + * Moves constant branches of if statements out to the surrounding + * instruction stream. + */ + +#define NULL 0 +#include "ir.h" +#include "ir_visitor.h" +#include "ir_function_inlining.h" +#include "glsl_types.h" + +class ir_if_simplification_visitor : public ir_visitor { +public: + ir_if_simplification_visitor() + { + /* empty */ + } + + virtual ~ir_if_simplification_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_label *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ +}; + +bool +do_if_simplification(exec_list *instructions) +{ + bool progress = false; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_if *conditional = ir->as_if(); + + if (conditional) { + ir_constant *condition_constant; + + condition_constant = + conditional->condition->constant_expression_value(); + if (condition_constant) { + /* Move the contents of the one branch of the conditional + * that matters out. + */ + if (condition_constant->value.b[0]) { + foreach_iter(exec_list_iterator, then_iter, + conditional->then_instructions) { + ir_instruction *then_ir = (ir_instruction *)then_iter.get(); + ir->insert_before(then_ir); + } + } else { + foreach_iter(exec_list_iterator, else_iter, + conditional->else_instructions) { + ir_instruction *else_ir = (ir_instruction *)else_iter.get(); + ir->insert_before(else_ir); + } + } + ir->remove(); + progress = true; + /* It would be nice to move the iterator back up to the point + * that we just spliced in contents. + */ + } else { + ir_if_simplification_visitor v; + ir->accept(&v); + } + } else { + ir_if_simplification_visitor v; + ir->accept(&v); + } + } + + return progress; +} + +class variable_remap : public exec_node { +public: + variable_remap(const ir_variable *old_var, ir_variable *new_var) + : old_var(old_var), new_var(new_var) + { + /* empty */ + } + const ir_variable *old_var; + ir_variable *new_var; +}; + +void +ir_if_simplification_visitor::visit(ir_variable *ir) +{ + (void) ir; +} + + +void +ir_if_simplification_visitor::visit(ir_label *ir) +{ + ir->signature->accept(this); +} + +void +ir_if_simplification_visitor::visit(ir_loop *ir) +{ + do_if_simplification(&ir->body_instructions); +} + +void +ir_if_simplification_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; +} + + +void +ir_if_simplification_visitor::visit(ir_function_signature *ir) +{ + do_if_simplification(&ir->body); +} + + +void +ir_if_simplification_visitor::visit(ir_function *ir) +{ + (void) ir; +} + +void +ir_if_simplification_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + ir->operands[operand]->accept(this); + } +} + + +void +ir_if_simplification_visitor::visit(ir_swizzle *ir) +{ + ir->val->accept(this); +} + + +void +ir_if_simplification_visitor::visit(ir_dereference *ir) +{ + if (ir->mode == ir_dereference::ir_reference_array) { + ir->selector.array_index->accept(this); + } + ir->var->accept(this); +} + +void +ir_if_simplification_visitor::visit(ir_assignment *ir) +{ + ir->rhs->accept(this); +} + + +void +ir_if_simplification_visitor::visit(ir_constant *ir) +{ + (void) ir; +} + + +void +ir_if_simplification_visitor::visit(ir_call *ir) +{ + (void) ir; +} + + +void +ir_if_simplification_visitor::visit(ir_return *ir) +{ + (void) ir; +} + + +void +ir_if_simplification_visitor::visit(ir_if *ir) +{ + ir->condition->accept(this); + + do_if_simplification(&ir->then_instructions); + do_if_simplification(&ir->else_instructions); +} diff --git a/ir_if_simplification.h b/ir_if_simplification.h new file mode 100644 index 00000000000..84b09ef0fd3 --- /dev/null +++ b/ir_if_simplification.h @@ -0,0 +1,31 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_if_simplification.h + * + * Moves constant branches of if statements out to the surrounding + * instruction stream. + */ + +bool do_if_simplification(exec_list *instructions); -- cgit v1.2.3 From 4950a68bf22ede6f4f368c9783e5401816159574 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 16 Apr 2010 01:10:32 -0700 Subject: Make && and || only evaluate the RHS when the LHS requires it. --- ast_to_hir.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 251845acd9d..1f51943b4b2 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -761,11 +761,50 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; break; - case ast_logic_and: - case ast_logic_xor: - case ast_logic_or: + case ast_logic_and: { + op[0] = this->subexpressions[0]->hir(instructions, state); + + if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[0]->get_location(); + + _mesa_glsl_error(& loc, state, "LHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } + + ir_if *const stmt = new ir_if(op[0]); + instructions->push_tail(stmt); + + ir_variable *const tmp = generate_temporary(glsl_type::bool_type, + instructions, state); + + op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); + + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[1]->get_location(); + + _mesa_glsl_error(& loc, state, "RHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } + + ir_dereference *const then_deref = new ir_dereference(tmp); + ir_assignment *const then_assign = + new ir_assignment(then_deref, op[1], NULL); + stmt->then_instructions.push_tail(then_assign); + + ir_dereference *const else_deref = new ir_dereference(tmp); + ir_assignment *const else_assign = + new ir_assignment(else_deref, new ir_constant(false), NULL); + stmt->else_instructions.push_tail(else_assign); + + result = new ir_dereference(tmp); + type = tmp->type; + break; + } + + case ast_logic_or: { op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { YYLTYPE loc = this->subexpressions[0]->get_location(); @@ -775,6 +814,14 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; } + ir_if *const stmt = new ir_if(op[0]); + instructions->push_tail(stmt); + + ir_variable *const tmp = generate_temporary(glsl_type::bool_type, + instructions, state); + + op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { YYLTYPE loc = this->subexpressions[1]->get_location(); @@ -783,6 +830,26 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; } + ir_dereference *const then_deref = new ir_dereference(tmp); + ir_assignment *const then_assign = + new ir_assignment(then_deref, new ir_constant(true), NULL); + stmt->then_instructions.push_tail(then_assign); + + ir_dereference *const else_deref = new ir_dereference(tmp); + ir_assignment *const else_assign = + new ir_assignment(else_deref, op[1], NULL); + stmt->else_instructions.push_tail(else_assign); + + result = new ir_dereference(tmp); + type = tmp->type; + break; + } + + case ast_logic_xor: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + result = new ir_expression(operations[this->oper], glsl_type::bool_type, op[0], op[1]); type = glsl_type::bool_type; -- cgit v1.2.3 From 0d42321ec1aaeaf60ee2dd8b1872182065ebc057 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 16 Apr 2010 12:53:46 -0700 Subject: Add support for inlining calls done inside of expressions. --- Makefile.am | 1 + ir_expression_flattening.cpp | 216 +++++++++++++++++++++++++++++++++++++++++++ ir_expression_flattening.h | 38 ++++++++ ir_function_inlining.cpp | 14 +++ 4 files changed, 269 insertions(+) create mode 100644 ir_expression_flattening.cpp create mode 100644 ir_expression_flattening.h diff --git a/Makefile.am b/Makefile.am index 68a1d98d33e..1ef1a0266b2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,7 @@ glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \ ir_constant_expression.cpp \ ir_constant_folding.cpp \ + ir_expression_flattening.cpp \ ir_function_inlining.cpp \ ir_if_simplification.cpp diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp new file mode 100644 index 00000000000..5072940d629 --- /dev/null +++ b/ir_expression_flattening.cpp @@ -0,0 +1,216 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_expression_flattening.cpp + * + * Takes the leaves of expression trees and makes them dereferences of + * assignments of the leaves to temporaries, according to a predicate. + * + * This is used for automatic function inlining, where we want to take + * an expression containing a call and move the call out to its own + * assignment so that we can inline it at the appropriate place in the + * instruction stream. + */ + +#define NULL 0 +#include "ir.h" +#include "ir_visitor.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +class ir_expression_flattening_visitor : public ir_visitor { +public: + ir_expression_flattening_visitor(ir_instruction *base_ir, + bool (*predicate)(ir_instruction *ir)) + { + this->base_ir = base_ir; + this->predicate = predicate; + + /* empty */ + } + + virtual ~ir_expression_flattening_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_label *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ + + bool (*predicate)(ir_instruction *ir); + ir_instruction *base_ir; +}; + +void +do_expression_flattening(exec_list *instructions, + bool (*predicate)(ir_instruction *ir)) +{ + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + ir_expression_flattening_visitor v(ir, predicate); + ir->accept(&v); + } +} + +void +ir_expression_flattening_visitor::visit(ir_variable *ir) +{ + (void) ir; +} + + +void +ir_expression_flattening_visitor::visit(ir_label *ir) +{ + ir->signature->accept(this); +} + +void +ir_expression_flattening_visitor::visit(ir_loop *ir) +{ + do_expression_flattening(&ir->body_instructions, this->predicate); +} + +void +ir_expression_flattening_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; +} + + +void +ir_expression_flattening_visitor::visit(ir_function_signature *ir) +{ + do_expression_flattening(&ir->body, this->predicate); +} + +void +ir_expression_flattening_visitor::visit(ir_function *ir) +{ + (void) ir; +} + +void +ir_expression_flattening_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + ir->operands[operand]->accept(this); + + /* If the operand matches the predicate, then we'll assign its + * value to a temporary and deref the temporary as the operand. + */ + if (this->predicate(ir->operands[operand])) { + ir_variable *var; + ir_assignment *assign; + + var = new ir_variable(ir->operands[operand]->type, "flattening_tmp"); + this->base_ir->insert_before(var); + + assign = new ir_assignment(new ir_dereference(var), + ir->operands[operand], + NULL); + this->base_ir->insert_before(assign); + + ir->operands[operand] = new ir_dereference(var); + } + } +} + + +void +ir_expression_flattening_visitor::visit(ir_swizzle *ir) +{ + ir->val->accept(this); +} + + +void +ir_expression_flattening_visitor::visit(ir_dereference *ir) +{ + if (ir->mode == ir_dereference::ir_reference_array) { + ir->selector.array_index->accept(this); + } + ir->var->accept(this); +} + +void +ir_expression_flattening_visitor::visit(ir_assignment *ir) +{ + ir->rhs->accept(this); +} + + +void +ir_expression_flattening_visitor::visit(ir_constant *ir) +{ + (void) ir; +} + + +void +ir_expression_flattening_visitor::visit(ir_call *ir) +{ + (void) ir; +} + + +void +ir_expression_flattening_visitor::visit(ir_return *ir) +{ + (void) ir; +} + + +void +ir_expression_flattening_visitor::visit(ir_if *ir) +{ + ir->condition->accept(this); + + do_expression_flattening(&ir->then_instructions, this->predicate); + do_expression_flattening(&ir->else_instructions, this->predicate); +} diff --git a/ir_expression_flattening.h b/ir_expression_flattening.h new file mode 100644 index 00000000000..2eda1590001 --- /dev/null +++ b/ir_expression_flattening.h @@ -0,0 +1,38 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file ir_expression_flattening.h + * + * Takes the leaves of expression trees and makes them dereferences of + * assignments of the leaves to temporaries, according to a predicate. + * + * This is used for automatic function inlining, where we want to take + * an expression containing a call and move the call out to its own + * assignment so that we can inline it at the appropriate place in the + * instruction stream. + */ + +void do_expression_flattening(exec_list *instructions, + bool (*predicate)(ir_instruction *ir)); diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index e03673e632d..af6a477d9b4 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -31,6 +31,7 @@ #include "ir.h" #include "ir_visitor.h" #include "ir_function_inlining.h" +#include "ir_expression_flattening.h" #include "glsl_types.h" class variable_remap : public exec_node { @@ -304,11 +305,24 @@ can_inline(ir_call *call) return found_return; } +bool +automatic_inlining_predicate(ir_instruction *ir) +{ + ir_call *call = ir->as_call(); + + if (call && can_inline(call)) + return true; + + return false; +} + bool do_function_inlining(exec_list *instructions) { bool progress = false; + do_expression_flattening(instructions, automatic_inlining_predicate); + foreach_iter(exec_list_iterator, iter, *instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); ir_assignment *assign = ir->as_assignment(); -- cgit v1.2.3 From 44b694e1f621730bca1cd03eabdfe5474d818f18 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 16 Apr 2010 13:49:04 -0700 Subject: Avoid generating ir_if for &&, || short-circuiting with constant LHS. It was breaking constant expression detection for constant initializers, i.e. CorrectParse2.frag, CorrectParse2.vert. --- ast_to_hir.cpp | 125 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 42 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1f51943b4b2..e89b3ff228f 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -772,34 +772,55 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; } - ir_if *const stmt = new ir_if(op[0]); - instructions->push_tail(stmt); + ir_constant *op0_const = op[0]->constant_expression_value(); + if (op0_const) { + if (op0_const->value.b[0]) { + op[1] = this->subexpressions[1]->hir(instructions, state); - ir_variable *const tmp = generate_temporary(glsl_type::bool_type, - instructions, state); + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[1]->get_location(); - op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); + _mesa_glsl_error(& loc, state, + "RHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } + result = op[1]; + } else { + result = op0_const; + } + type = glsl_type::bool_type; + } else { + ir_if *const stmt = new ir_if(op[0]); + instructions->push_tail(stmt); - if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { - YYLTYPE loc = this->subexpressions[1]->get_location(); + op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); - _mesa_glsl_error(& loc, state, "RHS of `%s' must be scalar boolean", - operator_string(this->oper)); - error_emitted = true; - } + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[1]->get_location(); - ir_dereference *const then_deref = new ir_dereference(tmp); - ir_assignment *const then_assign = - new ir_assignment(then_deref, op[1], NULL); - stmt->then_instructions.push_tail(then_assign); + _mesa_glsl_error(& loc, state, + "RHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } - ir_dereference *const else_deref = new ir_dereference(tmp); - ir_assignment *const else_assign = - new ir_assignment(else_deref, new ir_constant(false), NULL); - stmt->else_instructions.push_tail(else_assign); + ir_variable *const tmp = generate_temporary(glsl_type::bool_type, + instructions, state); - result = new ir_dereference(tmp); - type = tmp->type; + ir_dereference *const then_deref = new ir_dereference(tmp); + ir_assignment *const then_assign = + new ir_assignment(then_deref, op[1], NULL); + stmt->then_instructions.push_tail(then_assign); + + ir_dereference *const else_deref = new ir_dereference(tmp); + ir_assignment *const else_assign = + new ir_assignment(else_deref, new ir_constant(false), NULL); + stmt->else_instructions.push_tail(else_assign); + + result = new ir_dereference(tmp); + type = tmp->type; + } break; } @@ -814,34 +835,54 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; } - ir_if *const stmt = new ir_if(op[0]); - instructions->push_tail(stmt); + ir_constant *op0_const = op[0]->constant_expression_value(); + if (op0_const) { + if (op0_const->value.b[0]) { + result = op0_const; + } else { + op[1] = this->subexpressions[1]->hir(instructions, state); - ir_variable *const tmp = generate_temporary(glsl_type::bool_type, - instructions, state); + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[1]->get_location(); - op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); + _mesa_glsl_error(& loc, state, + "RHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } + result = op[1]; + } + type = glsl_type::bool_type; + } else { + ir_if *const stmt = new ir_if(op[0]); + instructions->push_tail(stmt); - if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { - YYLTYPE loc = this->subexpressions[1]->get_location(); + ir_variable *const tmp = generate_temporary(glsl_type::bool_type, + instructions, state); - _mesa_glsl_error(& loc, state, "RHS of `%s' must be scalar boolean", - operator_string(this->oper)); - error_emitted = true; - } + op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); - ir_dereference *const then_deref = new ir_dereference(tmp); - ir_assignment *const then_assign = - new ir_assignment(then_deref, new ir_constant(true), NULL); - stmt->then_instructions.push_tail(then_assign); + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[1]->get_location(); - ir_dereference *const else_deref = new ir_dereference(tmp); - ir_assignment *const else_assign = - new ir_assignment(else_deref, op[1], NULL); - stmt->else_instructions.push_tail(else_assign); + _mesa_glsl_error(& loc, state, "RHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } - result = new ir_dereference(tmp); - type = tmp->type; + ir_dereference *const then_deref = new ir_dereference(tmp); + ir_assignment *const then_assign = + new ir_assignment(then_deref, new ir_constant(true), NULL); + stmt->then_instructions.push_tail(then_assign); + + ir_dereference *const else_deref = new ir_dereference(tmp); + ir_assignment *const else_assign = + new ir_assignment(else_deref, op[1], NULL); + stmt->else_instructions.push_tail(else_assign); + + result = new ir_dereference(tmp); + type = tmp->type; + } break; } -- cgit v1.2.3 From 484606610e36ec7598f7733e9787d888b6a63d64 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 16 Apr 2010 16:42:43 -0700 Subject: While-loops also start a new scope. --- ast_to_hir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index e89b3ff228f..83dac584b2b 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2284,9 +2284,9 @@ ir_rvalue * ast_iteration_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - /* For loops start a new scope, but while and do-while loops do not. + /* For-loops and while-loops start a new scope, but do-while loops do not. */ - if (mode == ast_for) + if (mode != ast_do_while) state->symbols->push_scope(); if (init_statement != NULL) @@ -2317,7 +2317,7 @@ ast_iteration_statement::hir(exec_list *instructions, if (mode == ast_do_while) condition_to_hir(stmt, state); - if (mode == ast_for) + if (mode != ast_do_while) state->symbols->pop_scope(); /* Restore previous nesting before returning. -- cgit v1.2.3 From 71df19f5ef6e78beb5160801f81468184b75447e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Apr 2010 11:10:37 -0700 Subject: Mark some variables as having usage beyond the shader's scope. This will be important to optimization passes. We don't want to dead-code eliminate writes to out varyings, or propagate uninitialized values of uniforms. --- ast_to_hir.cpp | 9 +++++++++ ir.h | 6 ++++++ ir_variable.cpp | 20 ++++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 83dac584b2b..316bcf7d71c 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1446,6 +1446,15 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, else var->mode = ir_var_auto; + if (qual->uniform) + var->shader_in = true; + if (qual->varying) { + if (qual->in) + var->shader_in = true; + if (qual->out) + var->shader_out = true; + } + if (qual->flat) var->interpolation = ir_var_flat; else if (qual->noperspective) diff --git a/ir.h b/ir.h index 471e19b43d5..cb153be77de 100644 --- a/ir.h +++ b/ir.h @@ -151,6 +151,12 @@ public: unsigned read_only:1; unsigned centroid:1; unsigned invariant:1; + /** If the variable is initialized outside of the scope of the shader */ + unsigned shader_in:1; + /** + * If the variable value is later used outside of the scope of the shader. + */ + unsigned shader_out:1; unsigned mode:3; unsigned interpolation:2; diff --git a/ir_variable.cpp b/ir_variable.cpp index 76a528ca2be..12992a9b812 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -38,9 +38,25 @@ add_variable(const char *name, enum ir_variable_mode mode, ir_variable *var = new ir_variable(type, name); var->mode = mode; - if (var->mode != ir_var_out) + switch (var->mode) { + case ir_var_in: + var->shader_in = true; var->read_only = true; - + break; + case ir_var_inout: + var->shader_in = true; + var->shader_out = true; + case ir_var_out: + var->shader_out = true; + break; + case ir_var_uniform: + var->shader_in = true; + var->read_only = true; + break; + default: + assert(0); + break; + } /* Once the variable is created an initialized, add it to the symbol table * and add the declaration to the IR stream. -- cgit v1.2.3 From 7d21104a8b92c139051e9a224c5d863802a8ade6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 16 Apr 2010 16:43:47 -0700 Subject: Remove dead code assignments and variable declarations. This pass only works on assignments where the variable is never referenced. There is no code flow analysis, so it can't do a better job of avoiding redundant assignments. For now, the optimizer only does do_dead_code_unlinked(), so it won't trim the builtin variable list or initializers outside of the scope of functions. This is because we don't have the visibility into other functions that might get linked in in order to eliminate work on global variables. --- Makefile.am | 1 + glsl_parser_extras.cpp | 2 + ir.h | 12 ++ ir_dead_code.cpp | 336 +++++++++++++++++++++++++++++++++++++++++++++++++ ir_dead_code.h | 32 +++++ 5 files changed, 383 insertions(+) create mode 100644 ir_dead_code.cpp create mode 100644 ir_dead_code.h diff --git a/Makefile.am b/Makefile.am index 1ef1a0266b2..80b5c2ec680 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,7 @@ glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \ ir_constant_expression.cpp \ ir_constant_folding.cpp \ + ir_dead_code.cpp \ ir_expression_flattening.cpp \ ir_function_inlining.cpp \ ir_if_simplification.cpp diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 455bf0c7a4a..f7ee891eeb6 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -35,6 +35,7 @@ #include "glsl_parser_extras.h" #include "glsl_parser.h" #include "ir_constant_folding.h" +#include "ir_dead_code.h" #include "ir_function_inlining.h" #include "ir_if_simplification.h" #include "ir_print_visitor.h" @@ -761,6 +762,7 @@ main(int argc, char **argv) progress = do_function_inlining(&instructions) || progress; progress = do_if_simplification(&instructions) || progress; + progress = do_dead_code_unlinked(&instructions) || progress; /* Constant folding */ ir_constant_folding_visitor constant_folding; diff --git a/ir.h b/ir.h index cb153be77de..504cffb2d54 100644 --- a/ir.h +++ b/ir.h @@ -54,11 +54,13 @@ public: virtual class ir_variable * as_variable() { return NULL; } virtual class ir_dereference * as_dereference() { return NULL; } virtual class ir_rvalue * as_rvalue() { return NULL; } + virtual class ir_label * as_label() { return NULL; } virtual class ir_loop * as_loop() { return NULL; } virtual class ir_assignment * as_assignment() { return NULL; } virtual class ir_call * as_call() { return NULL; } virtual class ir_return * as_return() { return NULL; } virtual class ir_if * as_if() { return NULL; } + virtual class ir_swizzle * as_swizzle() { return NULL; } /*@}*/ protected: @@ -185,6 +187,11 @@ class ir_label : public ir_instruction { public: ir_label(const char *label, ir_function_signature *signature); + virtual ir_label *as_label() + { + return this; + } + virtual void accept(ir_visitor *v) { v->visit(this); @@ -681,6 +688,11 @@ public: /* empty */ } + virtual ir_swizzle *as_swizzle() + { + return this; + } + ir_swizzle *clone() { return new ir_swizzle(this->val, this->mask); diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp new file mode 100644 index 00000000000..aae45d993ea --- /dev/null +++ b/ir_dead_code.cpp @@ -0,0 +1,336 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_dead_code.cpp + * + * Eliminates dead assignments and variable declarations from the code. + */ + +#define NULL 0 +#include "ir.h" +#include "ir_visitor.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +class variable_entry : public exec_node +{ +public: + variable_entry(ir_variable *var) + { + this->var = var; + assign = NULL; + referenced = false; + declaration = false; + } + + ir_variable *var; /* The key: the variable's pointer. */ + ir_assignment *assign; /* An assignment to the variable, if any */ + bool referenced; /* If the variable has ever been referenced. */ + bool declaration; /* If the variable had a decl in the instruction stream */ +}; + +class ir_dead_code_visitor : public ir_visitor { +public: + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_label *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ + + variable_entry *get_variable_entry(ir_variable *var); + + bool (*predicate)(ir_instruction *ir); + ir_instruction *base_ir; + + /* List of variable_entry */ + exec_list variable_list; +}; + +variable_entry * +ir_dead_code_visitor::get_variable_entry(ir_variable *var) +{ + assert(var); + foreach_iter(exec_list_iterator, iter, this->variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + if (entry->var == var) + return entry; + } + + variable_entry *entry = new variable_entry(var); + this->variable_list.push_tail(entry); + return entry; +} + +void +find_dead_code(exec_list *instructions, ir_dead_code_visitor *v) +{ + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + ir->accept(v); + } +} + +void +ir_dead_code_visitor::visit(ir_variable *ir) +{ + variable_entry *entry = this->get_variable_entry(ir); + if (entry) { + entry->declaration = true; + } +} + + +void +ir_dead_code_visitor::visit(ir_label *ir) +{ + ir->signature->accept(this); +} + +void +ir_dead_code_visitor::visit(ir_loop *ir) +{ + find_dead_code(&ir->body_instructions, this); + if (ir->from) + ir->from->accept(this); + if (ir->to) + ir->to->accept(this); + if (ir->increment) + ir->increment->accept(this); +} + +void +ir_dead_code_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; +} + + +void +ir_dead_code_visitor::visit(ir_function_signature *ir) +{ + find_dead_code(&ir->body, this); +} + +void +ir_dead_code_visitor::visit(ir_function *ir) +{ + (void) ir; +} + +void +ir_dead_code_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + ir->operands[operand]->accept(this); + } +} + + +void +ir_dead_code_visitor::visit(ir_swizzle *ir) +{ + ir->val->accept(this); +} + + +void +ir_dead_code_visitor::visit(ir_dereference *ir) +{ + ir_variable *var; + + if (ir->mode == ir_dereference::ir_reference_array) { + ir->selector.array_index->accept(this); + } + + var = ir->var->as_variable(); + if (var) { + variable_entry *entry = this->get_variable_entry(var); + entry->referenced = true; + } else { + ir->var->accept(this); + } +} + +void +ir_dead_code_visitor::visit(ir_assignment *ir) +{ + ir_instruction *lhs = ir->lhs; + + /* Walk through the LHS and mark references for variables used in + * array indices but not for the assignment dereference. + */ + while (lhs) { + if (lhs->as_variable()) + break; + + ir_dereference *deref = lhs->as_dereference(); + if (deref) { + if (deref->mode == ir_dereference::ir_reference_array) + deref->selector.array_index->accept(this); + lhs = deref->var; + } else { + ir_swizzle *swiz = lhs->as_swizzle(); + + lhs = swiz->val; + } + } + + ir->rhs->accept(this); + if (ir->condition) + ir->condition->accept(this); + + variable_entry *entry; + entry = this->get_variable_entry(lhs->as_variable()); + if (entry) { + if (entry->assign == NULL) + entry->assign = ir; + } +} + + +void +ir_dead_code_visitor::visit(ir_constant *ir) +{ + (void) ir; +} + + +void +ir_dead_code_visitor::visit(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + + /* FINISHME: handle out values. */ + param->accept(this); + } + + /* Ignore the callee. Function bodies will get handled when they're + * encountered at the top level instruction stream and spawn their + * own dead code visitor. + */ +} + + +void +ir_dead_code_visitor::visit(ir_return *ir) +{ + ir->get_value()->accept(this); +} + + +void +ir_dead_code_visitor::visit(ir_if *ir) +{ + ir->condition->accept(this); + + find_dead_code(&ir->then_instructions, this); + find_dead_code(&ir->else_instructions, this); +} + +/** + * Do a dead code pass over instructions and everything that instructions + * references. + * + * Note that this will remove assignments to globals, so it is not suitable + * for usage on an unlinked instruction stream. + */ +bool +do_dead_code(exec_list *instructions) +{ + ir_dead_code_visitor v; + bool progress = false; + + find_dead_code(instructions, &v); + + foreach_iter(exec_list_iterator, iter, v.variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + + if (entry->referenced || !entry->declaration) + continue; + + if (entry->assign) { + /* Remove a single dead assignment to the variable we found. + * Don't do so if it's a shader output, though. + */ + if (!entry->var->shader_out) { + entry->assign->remove(); + progress = true; + } + } else { + /* If there are no assignments or references to the variable left, + * then we can remove its declaration. + */ + entry->var->remove(); + progress = true; + } + } + return progress; +} + +/** + * Does a dead code pass on the functions present in the instruction stream. + * + * This is suitable for use while the program is not linked, as it will + * ignore variable declarations (and the assignments to them) for variables + * with global scope. + */ +bool +do_dead_code_unlinked(exec_list *instructions) +{ + bool progress = false; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_label *label = ir->as_label(); + if (label) { + if (do_dead_code(&label->signature->body)) + progress = true; + } + } + + return progress; +} diff --git a/ir_dead_code.h b/ir_dead_code.h new file mode 100644 index 00000000000..25bf6f6256c --- /dev/null +++ b/ir_dead_code.h @@ -0,0 +1,32 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file ir_dead_code.h + * + * Eliminates dead assignments and variable declarations from the code. + */ + +bool do_dead_code(exec_list *instructions); +bool do_dead_code_unlinked(exec_list *instructions); -- cgit v1.2.3 From ff236fa9b6a35ce261098d288f77f238c3286e15 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 21 Apr 2010 15:08:08 -0700 Subject: Add missing break statement --- ir_variable.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ir_variable.cpp b/ir_variable.cpp index 12992a9b812..a2c0803e55a 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -46,6 +46,7 @@ add_variable(const char *name, enum ir_variable_mode mode, case ir_var_inout: var->shader_in = true; var->shader_out = true; + break; case ir_var_out: var->shader_out = true; break; -- cgit v1.2.3 From 67a092ae09dbb2dd820aab5aa7742d3f884d6cd4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 11:52:05 -0700 Subject: Ensure that both parameter lists are the same length in function overloading. Fixes new test function-05.glsl, where the second function has matching parameter types, but less of them. --- ast_to_hir.cpp | 15 +++++++-------- tests/function-05.glsl | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 tests/function-05.glsl diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 316bcf7d71c..addbeefc4be 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1889,17 +1889,10 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) exec_list_iterator iter_a = list_a->iterator(); exec_list_iterator iter_b = list_b->iterator(); - while (iter_a.has_next()) { + while (iter_a.has_next() && iter_b.has_next()) { ir_variable *a = (ir_variable *)iter_a.get(); ir_variable *b = (ir_variable *)iter_b.get(); - /* If all of the parameters from the other parameter list have been - * exhausted, the lists have different length and, by definition, - * do not match. - */ - if (!iter_b.has_next()) - return false; - /* If the types of the parameters do not match, the parameters lists * are different. */ @@ -1910,6 +1903,12 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) iter_b.next(); } + /* Unless both lists are exhausted, they differ in length and, by + * definition, do not match. + */ + if (iter_a.has_next() != iter_b.has_next()) + return false; + return true; } diff --git a/tests/function-05.glsl b/tests/function-05.glsl new file mode 100644 index 00000000000..43365bf6062 --- /dev/null +++ b/tests/function-05.glsl @@ -0,0 +1,26 @@ +/* PASS */ + +vec4 foo(in float x, in float y, float z, float w) +{ + vec4 v; + v.x = x; + v.y = y; + v.z = z; + v.w = w; + return v; +} + +vec4 foo(in float x) +{ + vec4 v; + v.x = x; + v.y = x; + v.z = x; + v.w = x; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0, 0.0); + gl_Position = foo(2.0); +} -- cgit v1.2.3 From f96c52ba2e290e3ba5f14cd7f87ba5b4382a1785 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 15:17:26 -0700 Subject: Use ir_function_signature::function_name() rather than direct access. --- ast_to_hir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index addbeefc4be..94c8dcfbd81 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2130,7 +2130,7 @@ ast_jump_statement::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "`return` with a value, in function `%s' " "returning void", - state->current_function->definition->label); + state->current_function->function_name()); } ir_expression *const ret = (ir_expression *) @@ -2150,7 +2150,7 @@ ast_jump_statement::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "`return' with no value, in function %s returning " "non-void", - state->current_function->definition->label); + state->current_function->function_name()); } inst = new ir_return; } -- cgit v1.2.3 From 9fa99f3b6c84fe927ba97e6584cd919f097a6c9a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 12:30:22 -0700 Subject: Refactor IR function representation. Now, ir_function is emitted as part of the IR instructions, rather than simply existing in the symbol table. Individual ir_function_signatures are not emitted themselves, but only as part of ir_function. --- ast_to_hir.cpp | 22 ++++++---------------- builtin_function.cpp | 18 +++++++++++++++--- glsl_types.cpp | 36 ++++++++++++------------------------ ir.cpp | 2 +- ir.h | 14 +++++++++----- ir_function_inlining.cpp | 5 ++++- ir_if_simplification.cpp | 5 ++++- ir_print_visitor.cpp | 12 ++++++++++-- 8 files changed, 61 insertions(+), 53 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 94c8dcfbd81..7b4a855f576 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1922,11 +1922,6 @@ ast_function::hir(exec_list *instructions, exec_list hir_parameters; - /* The prototype part of a function does not generate anything in the IR - * instruction stream. - */ - (void) instructions; - /* Convert the list of function parameters to HIR now so that they can be * used below to compare this function's signature with previously seen * signatures for functions with the same name. @@ -1989,7 +1984,7 @@ ast_function::hir(exec_list *instructions, name); } - if (is_definition && (sig->definition != NULL)) { + if (is_definition && sig->is_defined) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "function `%s' redefined", name); @@ -2012,6 +2007,9 @@ ast_function::hir(exec_list *instructions, } else { f = new ir_function(name); state->symbols->add_function(f->name, f); + + /* Emit the new function header */ + instructions->push_tail(f); } /* Verify the return type of main() */ @@ -2068,12 +2066,6 @@ ast_function_definition::hir(exec_list *instructions, assert(state->current_function == NULL); state->current_function = signature; - ir_label *label = new ir_label(signature->function_name(), signature); - if (signature->definition == NULL) { - signature->definition = label; - } - instructions->push_tail(label); - /* Duplicate parameters declared in the prototype as concrete variables. * Add these to the symbol table. */ @@ -2095,11 +2087,9 @@ ast_function_definition::hir(exec_list *instructions, } } - /* Convert the body of the function to HIR, and append the resulting - * instructions to the list that currently consists of the function label - * and the function parameters. - */ + /* Convert the body of the function to HIR. */ this->body->hir(&signature->body, state); + signature->is_defined = true; state->symbols->pop_scope(); diff --git a/builtin_function.cpp b/builtin_function.cpp index bdd745062b7..4243340b3d7 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -267,9 +267,6 @@ generate_function_instance(ir_function *f, ir_function_signature *const sig = new ir_function_signature(ret_type); f->add_signature(sig); - ir_label *const label = new ir_label(name, sig); - instructions->push_tail(label); - sig->definition = label; static const char *arg_names[] = { "arg0", "arg1", @@ -287,6 +284,7 @@ generate_function_instance(ir_function *f, } generate(&sig->body, declarations, type); + sig->is_defined = true; } void @@ -306,6 +304,8 @@ make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, bool added = symtab->add_function(name, f); assert(added); + instructions->push_tail(f); + generate_function_instance(f, name, instructions, n_args, generate, float_type, float_type); generate_function_instance(f, name, instructions, n_args, generate, @@ -424,6 +424,8 @@ generate_vec_compare_function(glsl_symbol_table *symtab, bool added = symtab->add_function(name, f); assert(added); + instructions->push_tail(f); + generate_function_instance(f, name, instructions, 2, generate, bvec2_type, vec2_type); generate_function_instance(f, name, instructions, 2, generate, @@ -487,6 +489,8 @@ generate_length_functions(glsl_symbol_table *symtab, exec_list *instructions) bool added = symtab->add_function(name, f); assert(added); + instructions->push_tail(f); + generate_function_instance(f, name, instructions, 1, generate_length, float_type, float_type); generate_function_instance(f, name, instructions, 1, generate_length, @@ -527,6 +531,8 @@ generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions) bool added = symtab->add_function(name, f); assert(added); + instructions->push_tail(f); + generate_function_instance(f, name, instructions, 2, generate_dot, float_type, float_type); generate_function_instance(f, name, instructions, 2, generate_dot, @@ -689,6 +695,8 @@ generate_any_functions(glsl_symbol_table *symtab, exec_list *instructions) bool added = symtab->add_function(name, f); assert(added); + instructions->push_tail(f); + generate_function_instance(f, name, instructions, 1, generate_any_bvec2, glsl_type::bool_type, bvec2_type); generate_function_instance(f, name, instructions, 1, generate_any_bvec3, @@ -709,6 +717,8 @@ generate_all_functions(glsl_symbol_table *symtab, exec_list *instructions) bool added = symtab->add_function(name, f); assert(added); + instructions->push_tail(f); + generate_function_instance(f, name, instructions, 1, generate_all_bvec2, glsl_type::bool_type, bvec2_type); generate_function_instance(f, name, instructions, 1, generate_all_bvec3, @@ -729,6 +739,8 @@ generate_not_functions(glsl_symbol_table *symtab, exec_list *instructions) bool added = symtab->add_function(name, f); assert(added); + instructions->push_tail(f); + generate_function_instance(f, name, instructions, 1, generate_not, bvec2_type, bvec2_type); generate_function_instance(f, name, instructions, 1, generate_not, diff --git a/glsl_types.cpp b/glsl_types.cpp index c8d18b9ee7a..e72a8fc39d4 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -173,15 +173,12 @@ glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const * scalar parameters. * \param parameters Storage for the list of parameters. These are * typically stored in an \c ir_function_signature. - * \param instructions Storage for the preamble and body of the function. * \param declarations Pointers to the variable declarations for the function * parameters. These are used later to avoid having to use * the symbol table. */ -static ir_label * +static ir_function_signature * generate_constructor_intro(const glsl_type *type, unsigned parameter_count, - ir_function_signature *const signature, - exec_list *instructions, ir_variable **declarations) { /* Names of parameters used in vector and matrix constructors @@ -195,8 +192,7 @@ generate_constructor_intro(const glsl_type *type, unsigned parameter_count, const glsl_type *const parameter_type = type->get_base_type(); - ir_label *const label = new ir_label(type->name, signature); - instructions->push_tail(label); + ir_function_signature *const signature = new ir_function_signature(type); for (unsigned i = 0; i < parameter_count; i++) { ir_variable *var = new ir_variable(parameter_type, names[i]); @@ -211,7 +207,7 @@ generate_constructor_intro(const glsl_type *type, unsigned parameter_count, signature->body.push_tail(retval); declarations[16] = retval; - return label; + return signature; } @@ -420,13 +416,14 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, if (types[i].is_scalar()) continue; - /* Generate the function name and add it to the symbol table. + /* Generate the function block, add it to the symbol table, and emit it. */ ir_function *const f = new ir_function(types[i].name); bool added = symtab->add_function(types[i].name, f); assert(added); + instructions->push_tail(f); /* Each type has several basic constructors. The total number of forms * depends on the derived type. @@ -445,24 +442,18 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, * expectation is that the IR generator will generate a call to the * appropriate from-scalars constructor. */ - ir_function_signature *const sig = new ir_function_signature(& types[i]); + ir_function_signature *const sig = + generate_constructor_intro(&types[i], 1, declarations); f->add_signature(sig); - sig->definition = - generate_constructor_intro(& types[i], 1, sig, - instructions, declarations); - if (types[i].is_vector()) { generate_vec_body_from_scalar(&sig->body, declarations); ir_function_signature *const vec_sig = - new ir_function_signature(& types[i]); + generate_constructor_intro(&types[i], types[i].vector_elements, + declarations); f->add_signature(vec_sig); - vec_sig->definition = - generate_constructor_intro(& types[i], types[i].vector_elements, - vec_sig, instructions, - declarations); generate_vec_body_from_N_scalars(&sig->body, declarations); } else { assert(types[i].is_matrix()); @@ -470,15 +461,12 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, generate_mat_body_from_scalar(&sig->body, declarations); ir_function_signature *const mat_sig = - new ir_function_signature(& types[i]); - f->add_signature(mat_sig); - - mat_sig->definition = - generate_constructor_intro(& types[i], + generate_constructor_intro(&types[i], (types[i].vector_elements * types[i].matrix_columns), - mat_sig, instructions, declarations); + f->add_signature(mat_sig); + generate_mat_body_from_N_scalars(instructions, declarations); } } diff --git a/ir.cpp b/ir.cpp index a68d01cca96..ad016ddbce8 100644 --- a/ir.cpp +++ b/ir.cpp @@ -338,7 +338,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) ir_function_signature::ir_function_signature(const glsl_type *return_type) - : return_type(return_type), definition(NULL) + : return_type(return_type), is_defined(false) { /* empty */ } diff --git a/ir.h b/ir.h index 504cffb2d54..0d5b2e4d710 100644 --- a/ir.h +++ b/ir.h @@ -204,6 +204,10 @@ public: /*@{*/ +/** + * The representation of a function instance; may be the full definition or + * simply a prototype. + */ class ir_function_signature : public ir_instruction { /* An ir_function_signature will be part of the list of signatures in * an ir_function. @@ -236,10 +240,8 @@ public: */ struct exec_list parameters; - /** - * Pointer to the label that begins the function definition. - */ - ir_label *definition; + /** Whether or not this function has a body (which may be empty). */ + unsigned is_defined:1; /** Body of instructions in the function. */ struct exec_list body; @@ -253,7 +255,9 @@ private: /** - * Header for tracking functions in the symbol table + * Header for tracking multiple overloaded functions with the same name. + * Contains a list of ir_function_signatures representing each of the + * actual functions. */ class ir_function : public ir_instruction { public: diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index af6a477d9b4..117b460ae5c 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -481,7 +481,10 @@ ir_function_inlining_visitor::visit(ir_function_signature *ir) void ir_function_inlining_visitor::visit(ir_function *ir) { - (void) ir; + foreach_iter(exec_list_iterator, iter, *ir) { + ir_function_signature *const sig = (ir_function_signature *) iter.get(); + sig->accept(this); + } } void diff --git a/ir_if_simplification.cpp b/ir_if_simplification.cpp index 5637db510ce..bc5663f4734 100644 --- a/ir_if_simplification.cpp +++ b/ir_if_simplification.cpp @@ -167,7 +167,10 @@ ir_if_simplification_visitor::visit(ir_function_signature *ir) void ir_if_simplification_visitor::visit(ir_function *ir) { - (void) ir; + foreach_iter(exec_list_iterator, iter, *ir) { + ir_function_signature *const sig = (ir_function_signature *) iter.get(); + sig->accept(this); + } } void diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 908f1c3ad8d..5d98937c9c2 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -75,14 +75,14 @@ void ir_print_visitor::visit(ir_label *ir) void ir_print_visitor::visit(ir_function_signature *ir) { - printf("(paramaters\n"); + printf("(signature\n (parameters\n"); foreach_iter(exec_list_iterator, iter, ir->parameters) { ir_variable *const inst = (ir_variable *) iter.get(); inst->accept(this); printf("\n"); } - printf(")\n"); + printf(" )\n("); foreach_iter(exec_list_iterator, iter, ir->body) { ir_instruction *const inst = (ir_instruction *) iter.get(); @@ -90,12 +90,20 @@ void ir_print_visitor::visit(ir_function_signature *ir) inst->accept(this); printf("\n"); } + printf("))\n"); } void ir_print_visitor::visit(ir_function *ir) { printf("(function %s\n", ir->name); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_function_signature *const sig = (ir_function_signature *) iter.get(); + + sig->accept(this); + printf("\n"); + } + printf(")\n"); } -- cgit v1.2.3 From 32898866886e218fee4dab741ba8dfcef2c2aa5c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 15:14:02 -0700 Subject: Remove ir_label since it is no longer used. --- ir.cpp | 6 ------ ir.h | 20 -------------------- ir_constant_expression.cpp | 9 --------- ir_constant_folding.cpp | 7 ------- ir_constant_folding.h | 1 - ir_expression_flattening.cpp | 8 -------- ir_function_inlining.cpp | 14 -------------- ir_function_inlining.h | 1 - ir_if_simplification.cpp | 7 ------- ir_print_visitor.cpp | 9 --------- ir_print_visitor.h | 1 - ir_visitor.h | 1 - 12 files changed, 84 deletions(-) diff --git a/ir.cpp b/ir.cpp index ad016ddbce8..1ae7dd6f0e5 100644 --- a/ir.cpp +++ b/ir.cpp @@ -108,12 +108,6 @@ ir_expression::get_num_operands(void) return num_operands[this->operation]; } -ir_label::ir_label(const char *label, ir_function_signature *signature) - : label(label), signature(signature) -{ - /* empty */ -} - ir_constant::ir_constant(const struct glsl_type *type, const void *data) { diff --git a/ir.h b/ir.h index 0d5b2e4d710..fa9a1321e32 100644 --- a/ir.h +++ b/ir.h @@ -183,26 +183,6 @@ public: }; -class ir_label : public ir_instruction { -public: - ir_label(const char *label, ir_function_signature *signature); - - virtual ir_label *as_label() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - const char *label; - - ir_function_signature *signature; -}; - - /*@{*/ /** * The representation of a function instance; may be the full definition or diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index e3a0d9eaa11..e5626c53117 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -63,7 +63,6 @@ public: */ /*@{*/ virtual void visit(ir_variable *); - virtual void visit(ir_label *); virtual void visit(ir_function_signature *); virtual void visit(ir_function *); virtual void visit(ir_expression *); @@ -107,14 +106,6 @@ ir_constant_visitor::visit(ir_variable *ir) } -void -ir_constant_visitor::visit(ir_label *ir) -{ - (void) ir; - value = NULL; -} - - void ir_constant_visitor::visit(ir_function_signature *ir) { diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index 294f2c2409f..1b53440669f 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -43,13 +43,6 @@ ir_constant_folding_visitor::visit(ir_variable *ir) } -void -ir_constant_folding_visitor::visit(ir_label *ir) -{ - ir->signature->accept(this); -} - - void ir_constant_folding_visitor::visit(ir_function_signature *ir) { diff --git a/ir_constant_folding.h b/ir_constant_folding.h index 843b3ad0b77..44bdbd01755 100644 --- a/ir_constant_folding.h +++ b/ir_constant_folding.h @@ -47,7 +47,6 @@ public: */ /*@{*/ virtual void visit(ir_variable *); - virtual void visit(ir_label *); virtual void visit(ir_function_signature *); virtual void visit(ir_function *); virtual void visit(ir_expression *); diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp index 5072940d629..28c96a787de 100644 --- a/ir_expression_flattening.cpp +++ b/ir_expression_flattening.cpp @@ -64,7 +64,6 @@ public: */ /*@{*/ virtual void visit(ir_variable *); - virtual void visit(ir_label *); virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); virtual void visit(ir_function_signature *); @@ -101,13 +100,6 @@ ir_expression_flattening_visitor::visit(ir_variable *ir) (void) ir; } - -void -ir_expression_flattening_visitor::visit(ir_label *ir) -{ - ir->signature->accept(this); -} - void ir_expression_flattening_visitor::visit(ir_loop *ir) { diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 117b460ae5c..c0e77b42730 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -92,7 +92,6 @@ public: */ /*@{*/ virtual void visit(ir_variable *); - virtual void visit(ir_label *); virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); virtual void visit(ir_function_signature *); @@ -120,13 +119,6 @@ ir_function_cloning_visitor::visit(ir_variable *ir) this->remap_variable(ir, new_var); } -void -ir_function_cloning_visitor::visit(ir_label *ir) -{ - (void)ir; - this->result = NULL; -} - void ir_function_cloning_visitor::visit(ir_loop *ir) { @@ -452,12 +444,6 @@ ir_function_inlining_visitor::visit(ir_variable *ir) } -void -ir_function_inlining_visitor::visit(ir_label *ir) -{ - ir->signature->accept(this); -} - void ir_function_inlining_visitor::visit(ir_loop *ir) { diff --git a/ir_function_inlining.h b/ir_function_inlining.h index 60c80a6dfbf..0e5123b2970 100644 --- a/ir_function_inlining.h +++ b/ir_function_inlining.h @@ -48,7 +48,6 @@ public: */ /*@{*/ virtual void visit(ir_variable *); - virtual void visit(ir_label *); virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); virtual void visit(ir_function_signature *); diff --git a/ir_if_simplification.cpp b/ir_if_simplification.cpp index bc5663f4734..1e6fd8da8c5 100644 --- a/ir_if_simplification.cpp +++ b/ir_if_simplification.cpp @@ -55,7 +55,6 @@ public: */ /*@{*/ virtual void visit(ir_variable *); - virtual void visit(ir_label *); virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); virtual void visit(ir_function_signature *); @@ -138,12 +137,6 @@ ir_if_simplification_visitor::visit(ir_variable *ir) } -void -ir_if_simplification_visitor::visit(ir_label *ir) -{ - ir->signature->accept(this); -} - void ir_if_simplification_visitor::visit(ir_loop *ir) { diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 5d98937c9c2..8f917e48b22 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -64,15 +64,6 @@ void ir_print_visitor::visit(ir_variable *ir) } -void ir_print_visitor::visit(ir_label *ir) -{ - printf("\n(label %s\n", ir->label); - - ir->signature->accept(this); - printf(")"); -} - - void ir_print_visitor::visit(ir_function_signature *ir) { printf("(signature\n (parameters\n"); diff --git a/ir_print_visitor.h b/ir_print_visitor.h index 82ebbac81f0..b241f92e040 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -54,7 +54,6 @@ public: */ /*@{*/ virtual void visit(ir_variable *); - virtual void visit(ir_label *); virtual void visit(ir_function_signature *); virtual void visit(ir_function *); virtual void visit(ir_expression *); diff --git a/ir_visitor.h b/ir_visitor.h index 323720e93ed..579eee701d7 100644 --- a/ir_visitor.h +++ b/ir_visitor.h @@ -45,7 +45,6 @@ public: */ /*@{*/ virtual void visit(class ir_variable *) = 0; - virtual void visit(class ir_label *) = 0; virtual void visit(class ir_function_signature *) = 0; virtual void visit(class ir_function *) = 0; virtual void visit(class ir_expression *) = 0; -- cgit v1.2.3 From 7bcd5bedcc16ad1be989cef7a05e6aa7711213e9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 15:00:29 -0700 Subject: Emit body for constructors in the right place. Previously, the body of some vector constructors were added to the wrong function signature, and the body of matrix constructors were just being dumped in the main instruction stream. --- glsl_types.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glsl_types.cpp b/glsl_types.cpp index e72a8fc39d4..508a75703d1 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -454,7 +454,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, declarations); f->add_signature(vec_sig); - generate_vec_body_from_N_scalars(&sig->body, declarations); + generate_vec_body_from_N_scalars(&vec_sig->body, declarations); } else { assert(types[i].is_matrix()); @@ -467,7 +467,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, declarations); f->add_signature(mat_sig); - generate_mat_body_from_N_scalars(instructions, declarations); + generate_mat_body_from_N_scalars(&mat_sig->body, declarations); } } } -- cgit v1.2.3 From 6202cbfe3614141e330501959a7322522b35f4e4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 16:02:15 -0700 Subject: Fix ir_dead_code for function refactoring. --- ir.h | 6 ++++++ ir_dead_code.cpp | 19 ++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ir.h b/ir.h index fa9a1321e32..c93c043f5e5 100644 --- a/ir.h +++ b/ir.h @@ -52,6 +52,7 @@ public: */ /*@{*/ virtual class ir_variable * as_variable() { return NULL; } + virtual class ir_function * as_function() { return NULL; } virtual class ir_dereference * as_dereference() { return NULL; } virtual class ir_rvalue * as_rvalue() { return NULL; } virtual class ir_label * as_label() { return NULL; } @@ -243,6 +244,11 @@ class ir_function : public ir_instruction { public: ir_function(const char *name); + virtual ir_function *as_function() + { + return this; + } + virtual void accept(ir_visitor *v) { v->visit(this); diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp index aae45d993ea..81fbeba3213 100644 --- a/ir_dead_code.cpp +++ b/ir_dead_code.cpp @@ -62,7 +62,6 @@ public: */ /*@{*/ virtual void visit(ir_variable *); - virtual void visit(ir_label *); virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); virtual void visit(ir_function_signature *); @@ -121,12 +120,6 @@ ir_dead_code_visitor::visit(ir_variable *ir) } -void -ir_dead_code_visitor::visit(ir_label *ir) -{ - ir->signature->accept(this); -} - void ir_dead_code_visitor::visit(ir_loop *ir) { @@ -325,10 +318,14 @@ do_dead_code_unlinked(exec_list *instructions) foreach_iter(exec_list_iterator, iter, *instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); - ir_label *label = ir->as_label(); - if (label) { - if (do_dead_code(&label->signature->body)) - progress = true; + ir_function *f = ir->as_function(); + if (f) { + foreach_iter(exec_list_iterator, sigiter, *f) { + ir_function_signature *sig = + (ir_function_signature *) sigiter.get(); + if (do_dead_code(&sig->body)) + progress = true; + } } } -- cgit v1.2.3 From 67029b13b7e47a5e8368f7cb216cb332439cfd90 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 23:58:13 -0700 Subject: Actually emit temp declaration in vector comparison builtins. --- builtin_function.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin_function.cpp b/builtin_function.cpp index 4243340b3d7..a6e1d370365 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -331,6 +331,7 @@ generate_vec_compare(exec_list *instructions, return_type = glsl_type::get_instance(GLSL_TYPE_BOOL, type->vector_elements, 1); temp = new ir_variable(return_type, "temp"); + instructions->push_tail(temp); for (i = 0; i < type->vector_elements; i++) { ir_assignment *assign; -- cgit v1.2.3 From 25851a8d873a3cb4f6ab3252364eb46a87e1a959 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Apr 2010 00:25:55 -0700 Subject: Fix illegal (var_ref (array_ref ...)) in matrix constructors. --- glsl_types.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/glsl_types.cpp b/glsl_types.cpp index 508a75703d1..4cd0f46aab2 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -372,10 +372,7 @@ generate_mat_body_from_N_scalars(exec_list *instructions, ir_dereference *const row_access = new ir_dereference(declarations[16], row_index); - ir_dereference *const component_access_ref = - new ir_dereference(row_access); - - ir_swizzle *component_access = new ir_swizzle(component_access_ref, + ir_swizzle *component_access = new ir_swizzle(row_access, j, 0, 0, 0, 1); const unsigned param = (i * row_type->vector_elements) + j; -- cgit v1.2.3 From eb56cea3b3011f46453d4bb7d06de2e9f6b12232 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 23 Apr 2010 13:32:23 -0700 Subject: Add missing 'else's to fix extension processing The missing else-statements caused all of the extensions execpt GL_ARB_texture_rectangle to be unsupported. This causes the following tests to pass: glslparsertest/glsl2/draw_buffers-04.frag --- glsl_parser_extras.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index f7ee891eeb6..1f74cbb39dc 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -129,7 +129,7 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, ? "enable" : "require"); return false; } - } if (strcmp(name, "GL_ARB_draw_buffers") == 0) { + } else if (strcmp(name, "GL_ARB_draw_buffers") == 0) { /* This extension is only supported in fragment shaders. */ if (state->target != fragment_shader) { @@ -138,7 +138,7 @@ _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); } - } if (strcmp(name, "GL_ARB_texture_rectangle") == 0) { + } else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) { state->ARB_texture_rectangle_enable = (ext_mode != extension_disable); state->ARB_texture_rectangle_warn = (ext_mode == extension_warn); } else { -- cgit v1.2.3 From 6aeada79662aa8a0c613158667dad66a6deb02a4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 23 Apr 2010 13:37:47 -0700 Subject: Zero-out the entire parser state structure at initialization Among other things, this ensures that all of the extension flags are initially disabled. This causes the following tests to pass: glslparsertest/glsl2/draw_buffers-02.frag --- glsl_parser_extras.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 1f74cbb39dc..c808052ee78 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -719,6 +719,8 @@ main(int argc, char **argv) return EXIT_FAILURE; } + memset(& state, 0, sizeof(state)); + switch (argv[1][0]) { case 'v': state.target = vertex_shader; -- cgit v1.2.3 From 22147be898fd5a1737efd677244c2c5618644e7e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Apr 2010 18:41:32 -0700 Subject: ir_function_inlining: Avoid NULL dereference on assignment conditions. --- ir_function_inlining.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index c0e77b42730..025124ae2b2 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -214,7 +214,7 @@ ir_function_cloning_visitor::visit(ir_dereference *ir) void ir_function_cloning_visitor::visit(ir_assignment *ir) { - ir_rvalue *lhs, *rhs, *condition; + ir_rvalue *lhs, *rhs, *condition = NULL; ir->lhs->accept(this); lhs = this->result->as_rvalue(); @@ -222,8 +222,10 @@ ir_function_cloning_visitor::visit(ir_assignment *ir) ir->rhs->accept(this); rhs = this->result->as_rvalue(); - ir->condition->accept(this); - condition = this->result->as_rvalue(); + if (ir->condition) { + ir->condition->accept(this); + condition = this->result->as_rvalue(); + } this->result = new ir_assignment(lhs, rhs, condition); } -- cgit v1.2.3 From 82ad90f8cf0860a4065f3a4ece6dc66b1e408c12 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Apr 2010 18:48:20 -0700 Subject: Fix the swizzling of vector constructors from scalars. A refactor turned 'i' into '1', meaning everything writemasked into the y component. --- glsl_types.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glsl_types.cpp b/glsl_types.cpp index 4cd0f46aab2..b4abfdd7b68 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -259,7 +259,7 @@ generate_vec_body_from_N_scalars(exec_list *instructions, ir_dereference *const lhs_ref = new ir_dereference(declarations[16]); ir_dereference *const rhs = new ir_dereference(declarations[i]); - ir_swizzle *lhs = new ir_swizzle(lhs_ref, 1, 0, 0, 0, 1); + ir_swizzle *lhs = new ir_swizzle(lhs_ref, i, 0, 0, 0, 1); inst = new ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); -- cgit v1.2.3 From 8d3e59f1f399d7c1f7604779f1d62e876c609d9e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 23 Apr 2010 13:24:20 -0700 Subject: Replace builtin_types.h generation with the generated output. The script to generate it was longer and more obfuscated than the output. --- .gitignore | 1 - Makefile.am | 9 +- builtin_types.h | 251 +++++++++++++++++++++++++++++++++++++++ builtin_types.sh | 348 ------------------------------------------------------- 4 files changed, 255 insertions(+), 354 deletions(-) create mode 100644 builtin_types.h delete mode 100755 builtin_types.sh diff --git a/.gitignore b/.gitignore index e098bdb965a..9edd6daf71c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ stamp-h1 Makefile *.o *~ -builtin_types.h glsl_lexer.cpp glsl_parser.output glsl_parser.cpp diff --git a/Makefile.am b/Makefile.am index 80b5c2ec680..8fb74dcee85 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,7 +23,9 @@ AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = glsl -glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ +glsl_SOURCES = \ + builtin_types.h \ + symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \ ir.cpp hir_field_selection.cpp builtin_function.cpp \ @@ -35,13 +37,10 @@ glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ ir_function_inlining.cpp \ ir_if_simplification.cpp -BUILT_SOURCES = glsl_parser.h builtin_types.h glsl_parser.cpp glsl_lexer.cpp +BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) glsl_parser.h: glsl_parser.cpp .lpp.cpp: $(LEXCOMPILE) --outfile="$@" $< - -builtin_types.h: builtin_types.sh - bash ./builtin_types.sh > builtin_types.h diff --git a/builtin_types.h b/builtin_types.h new file mode 100644 index 00000000000..73910fd4af0 --- /dev/null +++ b/builtin_types.h @@ -0,0 +1,251 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef Elements +#define Elements(x) (sizeof(x)/sizeof(*(x))) +#endif + +static const struct glsl_type _error_type = + glsl_type(GLSL_TYPE_ERROR, 0, 0, ""); + +static const struct glsl_type void_type = + glsl_type(GLSL_TYPE_VOID, 0, 0, "void"); + +const glsl_type *const glsl_type::error_type = & _error_type; + +/** \name Core built-in types + * + * These types exist in all versions of GLSL. + */ +/*@{*/ + +static const struct glsl_type builtin_core_types[] = { + glsl_type( GLSL_TYPE_BOOL, 1, 1, "bool"), + glsl_type( GLSL_TYPE_BOOL, 2, 1, "bvec2"), + glsl_type( GLSL_TYPE_BOOL, 3, 1, "bvec3"), + glsl_type( GLSL_TYPE_BOOL, 4, 1, "bvec4"), + glsl_type( GLSL_TYPE_INT, 1, 1, "int"), + glsl_type( GLSL_TYPE_INT, 2, 1, "ivec2"), + glsl_type( GLSL_TYPE_INT, 3, 1, "ivec3"), + glsl_type( GLSL_TYPE_INT, 4, 1, "ivec4"), + glsl_type( GLSL_TYPE_FLOAT, 1, 1, "float"), + glsl_type( GLSL_TYPE_FLOAT, 2, 1, "vec2"), + glsl_type( GLSL_TYPE_FLOAT, 3, 1, "vec3"), + glsl_type( GLSL_TYPE_FLOAT, 4, 1, "vec4"), + glsl_type( GLSL_TYPE_FLOAT, 2, 2, "mat2"), + glsl_type( GLSL_TYPE_FLOAT, 3, 3, "mat3"), + glsl_type( GLSL_TYPE_FLOAT, 4, 4, "mat4"), + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT, "sampler1D"), + glsl_type( GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT, "sampler1DShadow"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT, "sampler2D"), + glsl_type( GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT, "sampler2DShadow"), + glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT, "sampler3D"), + glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT, "samplerCube"), +}; + +const glsl_type *const glsl_type::bool_type = & builtin_core_types[0]; +const glsl_type *const glsl_type::int_type = & builtin_core_types[4]; +const glsl_type *const glsl_type::float_type = & builtin_core_types[8]; +const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12]; +const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13]; +const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14]; +/*@}*/ + +/** \name GLSL structures that have not been deprecated. + */ +/*@{*/ + +static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = { + { & builtin_core_types[ 8], "near" }, + { & builtin_core_types[ 8], "far" }, + { & builtin_core_types[ 8], "diff" }, +}; + +static const struct glsl_type builtin_structure_types[] = { + glsl_type(gl_DepthRangeParameters_fields, + Elements(gl_DepthRangeParameters_fields), + "gl_DepthRangeParameters"), +}; +/*@}*/ + +/** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30 + */ +/*@{*/ + +static const struct glsl_struct_field gl_PointParameters_fields[] = { + { & builtin_core_types[ 8], "size" }, + { & builtin_core_types[ 8], "sizeMin" }, + { & builtin_core_types[ 8], "sizeMax" }, + { & builtin_core_types[ 8], "fadeThresholdSize" }, + { & builtin_core_types[ 8], "distanceConstantAttenuation" }, + { & builtin_core_types[ 8], "distanceLinearAttenuation" }, + { & builtin_core_types[ 8], "distanceQuadraticAttenuation" }, +}; + +static const struct glsl_struct_field gl_MaterialParameters_fields[] = { + { & builtin_core_types[11], "emission" }, + { & builtin_core_types[11], "ambient" }, + { & builtin_core_types[11], "diffuse" }, + { & builtin_core_types[11], "specular" }, + { & builtin_core_types[ 8], "shininess" }, +}; + +static const struct glsl_struct_field gl_LightSourceParameters_fields[] = { + { & builtin_core_types[11], "ambient" }, + { & builtin_core_types[11], "diffuse" }, + { & builtin_core_types[11], "specular" }, + { & builtin_core_types[11], "position" }, + { & builtin_core_types[11], "halfVector" }, + { & builtin_core_types[10], "spotDirection" }, + { & builtin_core_types[ 8], "spotExponent" }, + { & builtin_core_types[ 8], "spotCutoff" }, + { & builtin_core_types[ 8], "spotCosCutoff" }, + { & builtin_core_types[ 8], "constantAttenuation" }, + { & builtin_core_types[ 8], "linearAttenuation" }, + { & builtin_core_types[ 8], "quadraticAttenuation" }, +}; + +static const struct glsl_struct_field gl_LightModelParameters_fields[] = { + { & builtin_core_types[11], "ambient" }, +}; + +static const struct glsl_struct_field gl_LightModelProducts_fields[] = { + { & builtin_core_types[11], "sceneColor" }, +}; + +static const struct glsl_struct_field gl_LightProducts_fields[] = { + { & builtin_core_types[11], "ambient" }, + { & builtin_core_types[11], "diffuse" }, + { & builtin_core_types[11], "specular" }, +}; + +static const struct glsl_struct_field gl_FogParameters_fields[] = { + { & builtin_core_types[11], "color" }, + { & builtin_core_types[ 8], "density" }, + { & builtin_core_types[ 8], "start" }, + { & builtin_core_types[ 8], "end" }, + { & builtin_core_types[ 8], "scale" }, +}; + +static const struct glsl_type builtin_110_deprecated_structure_types[] = { + glsl_type(gl_PointParameters_fields, + Elements(gl_PointParameters_fields), + "gl_PointParameters"), + glsl_type(gl_MaterialParameters_fields, + Elements(gl_MaterialParameters_fields), + "gl_MaterialParameters"), + glsl_type(gl_LightSourceParameters_fields, + Elements(gl_LightSourceParameters_fields), + "gl_LightSourceParameters"), + glsl_type(gl_LightModelParameters_fields, + Elements(gl_LightModelParameters_fields), + "gl_LightModelParameters"), + glsl_type(gl_LightModelProducts_fields, + Elements(gl_LightModelProducts_fields), + "gl_LightModelProducts"), + glsl_type(gl_LightProducts_fields, + Elements(gl_LightProducts_fields), + "gl_LightProducts"), + glsl_type(gl_FogParameters_fields, + Elements(gl_FogParameters_fields), + "gl_FogParameters"), +}; +/*@}*/ + +/** \name Types added in GLSL 1.20 + */ +/*@{*/ + +static const struct glsl_type builtin_120_types[] = { + glsl_type( GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), + glsl_type( GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), + glsl_type( GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), + glsl_type( GLSL_TYPE_FLOAT, 4, 3, "mat3x4"), + glsl_type( GLSL_TYPE_FLOAT, 2, 4, "mat4x2"), + glsl_type( GLSL_TYPE_FLOAT, 3, 4, "mat4x3"), +}; +const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0]; +const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1]; +const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2]; +const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3]; +const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4]; +const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5]; +/*@}*/ + +/** \name Types added in GLSL 1.30 + */ +/*@{*/ + +static const struct glsl_type builtin_130_types[] = { + glsl_type( GLSL_TYPE_UINT, 1, 1, "uint"), + glsl_type( GLSL_TYPE_UINT, 2, 1, "uvec2"), + glsl_type( GLSL_TYPE_UINT, 3, 1, "uvec3"), + glsl_type( GLSL_TYPE_UINT, 4, 1, "uvec4"), + + /* 1D and 2D texture arrays */ + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"), + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"), + glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"), + glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), + + /* cube shadow samplers */ + glsl_type(GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"), + + /* signed and unsigned integer samplers */ + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"), + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"), + glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"), + glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"), + glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"), + glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"), +}; + +const glsl_type *const glsl_type::uint_type = & builtin_130_types[0]; +/*@}*/ + +/** \name Sampler types added by GL_ARB_texture_rectangle + */ +/*@{*/ + +static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { + glsl_type(GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"), + glsl_type(GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"), +}; +/*@}*/ + +/** \name Sampler types added by GL_EXT_texture_buffer_object + */ +/*@{*/ + +static const struct glsl_type builtin_EXT_texture_buffer_object_types[] = { + glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"), + glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"), + glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"), +}; +/*@}*/ diff --git a/builtin_types.sh b/builtin_types.sh deleted file mode 100755 index 4e6f0878ce5..00000000000 --- a/builtin_types.sh +++ /dev/null @@ -1,348 +0,0 @@ -#!/bin/sh -# -# Copyright © 2009 Intel Corporation -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. - -# gen_integral_type -function gen_integral_type -{ - printf ' glsl_type( %17s, %u, %u, "%s"),\n' $2 $3 $4 $1 - index=$((index + 1)) -} - -# gen_struct_type -function gen_struct_type -{ - elements=$(printf "%s_fields" $1) - printf ' glsl_type(%s,\n Elements(%s),\n "%s"),\n' \ - $elements $elements $1 -} - -# gen_sampler_type -function gen_sampler_type -{ - name=$(printf "sampler%s" $1) - - if [ $4 -eq 1 ]; then - name=$(printf "%sArray" $name) - fi - - if [ $3 -eq 1 ]; then - name=$(printf "%sShadow" $name) - fi - - if [ $5 == GLSL_TYPE_INT ]; then - name=$(printf "i%s" $name) - elif [ $5 == GLSL_TYPE_UINT ]; then - name=$(printf "u%s" $name) - fi - - printf ' glsl_type(%21s, %u, %u, %15s, "%s"),\n' \ - $2 $3 $4 $5 $name -} - -function gen_header -{ - if [ x$1 == x ]; then - name="builtin_types" - else - name="builtin_${1}_types" - fi - - printf "\nstatic const struct glsl_type %s[] = {\n" $name -} - -function gen_footer -{ - printf "};\n" -} - -function gen_struct_field_header -{ - printf "\nstatic const struct glsl_struct_field %s_fields[] = {\n" $1 -} - -function gen_struct_field_footer -{ - printf "};\n" -} - -function gen_struct_field -{ - printf ' { & %s[%2u], "%s" },\n' $1 $2 "$3" -} - -cat < Date: Thu, 22 Apr 2010 09:47:27 -0700 Subject: Put static pointers to vec[234]_types along with the static float_type. Otherwise you have to type a lot of get_instance. --- builtin_function.cpp | 45 +++++++++++++++------------------------------ builtin_types.h | 3 +++ glsl_types.h | 3 +++ ir_variable.cpp | 12 +++--------- 4 files changed, 24 insertions(+), 39 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index a6e1d370365..c9383e17cc9 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -296,10 +296,6 @@ make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, const glsl_type *type)) { ir_function *const f = new ir_function(name); - const glsl_type *float_type = glsl_type::float_type; - const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); - const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); - const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); bool added = symtab->add_function(name, f); assert(added); @@ -307,13 +303,13 @@ make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, instructions->push_tail(f); generate_function_instance(f, name, instructions, n_args, generate, - float_type, float_type); + glsl_type::float_type, glsl_type::float_type); generate_function_instance(f, name, instructions, n_args, generate, - vec2_type, vec2_type); + glsl_type::vec2_type, glsl_type::vec2_type); generate_function_instance(f, name, instructions, n_args, generate, - vec3_type, vec3_type); + glsl_type::vec3_type, glsl_type::vec3_type); generate_function_instance(f, name, instructions, n_args, generate, - vec4_type, vec4_type); + glsl_type::vec4_type, glsl_type::vec4_type); } static void @@ -409,9 +405,6 @@ generate_vec_compare_function(glsl_symbol_table *symtab, bool do_bool) { ir_function *const f = new ir_function(name); - const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); - const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); - const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); const glsl_type *ivec2_type = glsl_type::get_instance(GLSL_TYPE_INT, 2, 1); const glsl_type *ivec3_type = glsl_type::get_instance(GLSL_TYPE_INT, 3, 1); const glsl_type *ivec4_type = glsl_type::get_instance(GLSL_TYPE_INT, 4, 1); @@ -428,11 +421,11 @@ generate_vec_compare_function(glsl_symbol_table *symtab, instructions->push_tail(f); generate_function_instance(f, name, instructions, 2, generate, - bvec2_type, vec2_type); + bvec2_type, glsl_type::vec2_type); generate_function_instance(f, name, instructions, 2, generate, - bvec3_type, vec3_type); + bvec3_type, glsl_type::vec3_type); generate_function_instance(f, name, instructions, 2, generate, - bvec4_type, vec4_type); + bvec4_type, glsl_type::vec4_type); generate_function_instance(f, name, instructions, 2, generate, bvec2_type, ivec2_type); @@ -482,10 +475,6 @@ generate_length_functions(glsl_symbol_table *symtab, exec_list *instructions) { const char *name = "length"; ir_function *const f = new ir_function(name); - const glsl_type *float_type = glsl_type::float_type; - const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); - const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); - const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); bool added = symtab->add_function(name, f); assert(added); @@ -493,13 +482,13 @@ generate_length_functions(glsl_symbol_table *symtab, exec_list *instructions) instructions->push_tail(f); generate_function_instance(f, name, instructions, 1, generate_length, - float_type, float_type); + glsl_type::float_type, glsl_type::float_type); generate_function_instance(f, name, instructions, 1, generate_length, - float_type, vec2_type); + glsl_type::float_type, glsl_type::vec2_type); generate_function_instance(f, name, instructions, 1, generate_length, - float_type, vec3_type); + glsl_type::float_type, glsl_type::vec3_type); generate_function_instance(f, name, instructions, 1, generate_length, - float_type, vec4_type); + glsl_type::float_type, glsl_type::vec4_type); } static void @@ -524,10 +513,6 @@ generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions) { const char *name = "dot"; ir_function *const f = new ir_function(name); - const glsl_type *float_type = glsl_type::float_type; - const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); - const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); - const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); bool added = symtab->add_function(name, f); assert(added); @@ -535,13 +520,13 @@ generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions) instructions->push_tail(f); generate_function_instance(f, name, instructions, 2, generate_dot, - float_type, float_type); + glsl_type::float_type, glsl_type::float_type); generate_function_instance(f, name, instructions, 2, generate_dot, - float_type, vec2_type); + glsl_type::float_type, glsl_type::vec2_type); generate_function_instance(f, name, instructions, 2, generate_dot, - float_type, vec3_type); + glsl_type::float_type, glsl_type::vec3_type); generate_function_instance(f, name, instructions, 2, generate_dot, - float_type, vec4_type); + glsl_type::float_type, glsl_type::vec4_type); } static void diff --git a/builtin_types.h b/builtin_types.h index 73910fd4af0..7f97d6fa86d 100644 --- a/builtin_types.h +++ b/builtin_types.h @@ -66,6 +66,9 @@ static const struct glsl_type builtin_core_types[] = { const glsl_type *const glsl_type::bool_type = & builtin_core_types[0]; const glsl_type *const glsl_type::int_type = & builtin_core_types[4]; const glsl_type *const glsl_type::float_type = & builtin_core_types[8]; +const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9]; +const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10]; +const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11]; const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12]; const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13]; const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14]; diff --git a/glsl_types.h b/glsl_types.h index 33b1c98158d..c6288683013 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -110,6 +110,9 @@ struct glsl_type { static const glsl_type *const int_type; static const glsl_type *const uint_type; static const glsl_type *const float_type; + static const glsl_type *const vec2_type; + static const glsl_type *const vec3_type; + static const glsl_type *const vec4_type; static const glsl_type *const bool_type; /*@}*/ diff --git a/ir_variable.cpp b/ir_variable.cpp index a2c0803e55a..ba91d566dfc 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -137,10 +137,8 @@ generate_110_vs_variables(exec_list *instructions, * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be * FINISHME: at least 2, so hard-code 2 for now. */ - const glsl_type *const vec4_type = - glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(vec4_type, 2); + glsl_type::get_array_instance(glsl_type::vec4_type, 2); add_variable("gl_TexCoord", ir_var_out, vec4_array_type, instructions, symtab); @@ -219,10 +217,8 @@ generate_110_fs_variables(exec_list *instructions, * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be * FINISHME: at least 2, so hard-code 2 for now. */ - const glsl_type *const vec4_type = - glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(vec4_type, 2); + glsl_type::get_array_instance(glsl_type::vec4_type, 2); add_variable("gl_TexCoord", ir_var_in, vec4_array_type, instructions, symtab); @@ -237,10 +233,8 @@ generate_ARB_draw_buffers_fs_variables(exec_list *instructions, * FINISHME: value of GL_MAX_DRAW_BUFFERS. GL_MAX_DRAW_BUFFERS must be * FINISHME: at least 1, so hard-code 1 for now. */ - const glsl_type *const vec4_type = - glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(vec4_type, 1); + glsl_type::get_array_instance(glsl_type::vec4_type, 1); ir_variable *const fd = add_variable("gl_FragData", ir_var_out, vec4_array_type, instructions, -- cgit v1.2.3 From e8e97487223aa71ced5d519c15ca0d21e8d28da5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Apr 2010 17:52:59 -0700 Subject: ir_function_inlining: Implement inlining in many more cases. We still don't inline for control flow in the inlined function, and we don't have any limits on what we will inline. --- Makefile.am | 1 + ir_function_can_inline.cpp | 227 +++++++++++++++++++++++++++++++++++++++++++++ ir_function_inlining.cpp | 32 +++---- ir_function_inlining.h | 1 + 4 files changed, 240 insertions(+), 21 deletions(-) create mode 100644 ir_function_can_inline.cpp diff --git a/Makefile.am b/Makefile.am index 8fb74dcee85..b43dee3037e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,6 +34,7 @@ glsl_SOURCES = \ ir_constant_folding.cpp \ ir_dead_code.cpp \ ir_expression_flattening.cpp \ + ir_function_can_inline.cpp \ ir_function_inlining.cpp \ ir_if_simplification.cpp diff --git a/ir_function_can_inline.cpp b/ir_function_can_inline.cpp new file mode 100644 index 00000000000..6c96a206a68 --- /dev/null +++ b/ir_function_can_inline.cpp @@ -0,0 +1,227 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_can_inline.cpp + * + * Determines if we can inline a function call using ir_function_inlining.cpp. + * + * The primary restriction is that we can't return from the function + * other than as the last instruction. We could potentially work + * around this for some constructs by flattening control flow and + * moving the return to the end, or by using breaks from a do {} while + * (0) loop surrounding the function body. + */ + +#define NULL 0 +#include "ir.h" +#include "ir_visitor.h" +#include "ir_function_inlining.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +class ir_function_can_inline_visitor : public ir_visitor { +public: + ir_function_can_inline_visitor() + { + this->can_inline = true; + this->num_returns = 0; + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_label *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ + + bool can_inline; + int num_returns; +}; + +void +ir_function_can_inline_visitor::visit(ir_variable *ir) +{ + (void)ir; +} + +void +ir_function_can_inline_visitor::visit(ir_label *ir) +{ + (void)ir; +} + +void +ir_function_can_inline_visitor::visit(ir_loop *ir) +{ + /* FINISHME: Implement loop cloning in ir_function_inlining.cpp */ + this->can_inline = false; + + if (ir->from) + ir->from->accept(this); + if (ir->to) + ir->to->accept(this); + if (ir->increment) + ir->increment->accept(this); + + foreach_iter(exec_list_iterator, iter, ir->body_instructions) { + ir_instruction *inner_ir = (ir_instruction *)iter.get(); + inner_ir->accept(this); + } +} + +void +ir_function_can_inline_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; +} + + +void +ir_function_can_inline_visitor::visit(ir_function_signature *ir) +{ + (void)ir; +} + + +void +ir_function_can_inline_visitor::visit(ir_function *ir) +{ + (void) ir; +} + +void +ir_function_can_inline_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + ir->operands[operand]->accept(this); + } +} + + +void +ir_function_can_inline_visitor::visit(ir_swizzle *ir) +{ + ir->val->accept(this); +} + +void +ir_function_can_inline_visitor::visit(ir_dereference *ir) +{ + ir->var->accept(this); + if (ir->mode == ir_dereference::ir_reference_array) + ir->selector.array_index->accept(this); +} + +void +ir_function_can_inline_visitor::visit(ir_assignment *ir) +{ + ir->lhs->accept(this); + ir->rhs->accept(this); + if (ir->condition) + ir->condition->accept(this); +} + + +void +ir_function_can_inline_visitor::visit(ir_constant *ir) +{ + (void)ir; +} + + +void +ir_function_can_inline_visitor::visit(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + + param->accept(this); + } +} + + +void +ir_function_can_inline_visitor::visit(ir_return *ir) +{ + ir->get_value()->accept(this); + + this->num_returns++; +} + + +void +ir_function_can_inline_visitor::visit(ir_if *ir) +{ + /* FINISHME: Implement if cloning in ir_function_inlining.cpp. */ + this->can_inline = false; + + ir->condition->accept(this); + + foreach_iter(exec_list_iterator, iter, ir->then_instructions) { + ir_instruction *inner_ir = (ir_instruction *)iter.get(); + inner_ir->accept(this); + } + + foreach_iter(exec_list_iterator, iter, ir->else_instructions) { + ir_instruction *inner_ir = (ir_instruction *)iter.get(); + inner_ir->accept(this); + } +} + +bool +can_inline(ir_call *call) +{ + ir_function_can_inline_visitor v; + const ir_function_signature *callee = call->get_callee(); + + foreach_iter(exec_list_iterator, iter, callee->body) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir->accept(&v); + } + + ir_instruction *last = (ir_instruction *)callee->body.get_tail(); + if (last && !last->as_return()) + v.num_returns++; + + return v.can_inline && v.num_returns == 1; +} diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 025124ae2b2..ba556a84992 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -122,6 +122,9 @@ ir_function_cloning_visitor::visit(ir_variable *ir) void ir_function_cloning_visitor::visit(ir_loop *ir) { + /* FINISHME: Implement loop cloning. */ + assert(0); + (void)ir; this->result = NULL; } @@ -129,6 +132,9 @@ ir_function_cloning_visitor::visit(ir_loop *ir) void ir_function_cloning_visitor::visit(ir_loop_jump *ir) { + /* FINISHME: Implement loop cloning. */ + assert(0); + (void) ir; this->result = NULL; } @@ -137,6 +143,7 @@ ir_function_cloning_visitor::visit(ir_loop_jump *ir) void ir_function_cloning_visitor::visit(ir_function_signature *ir) { + assert(0); (void)ir; this->result = NULL; } @@ -145,6 +152,7 @@ ir_function_cloning_visitor::visit(ir_function_signature *ir) void ir_function_cloning_visitor::visit(ir_function *ir) { + assert(0); (void) ir; this->result = NULL; } @@ -274,31 +282,13 @@ ir_function_cloning_visitor::visit(ir_return *ir) void ir_function_cloning_visitor::visit(ir_if *ir) { + /* FINISHME: Implement if cloning. */ + assert(0); + (void) ir; result = NULL; } -bool -can_inline(ir_call *call) -{ - bool found_return = false; - - /* FINISHME: Right now we only allow a single statement that is a return. - */ - foreach_iter(exec_list_iterator, iter, call->get_callee()->body) { - ir_instruction *ir = (ir_instruction *)iter.get(); - if (ir->get_next()->get_next() != NULL) - return false; - - if (!ir->as_return()) - return false; - - found_return = true; - } - - return found_return; -} - bool automatic_inlining_predicate(ir_instruction *ir) { diff --git a/ir_function_inlining.h b/ir_function_inlining.h index 0e5123b2970..b68a55a1a96 100644 --- a/ir_function_inlining.h +++ b/ir_function_inlining.h @@ -64,3 +64,4 @@ public: }; bool do_function_inlining(exec_list *instructions); +bool can_inline(ir_call *call); -- cgit v1.2.3 From d7f6f346be88ce560fe71479d9264d3919b15162 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 23 Apr 2010 13:28:21 -0700 Subject: De-obfuscate some of builtin_types.h. --- builtin_types.h | 74 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/builtin_types.h b/builtin_types.h index 7f97d6fa86d..148917e0dcf 100644 --- a/builtin_types.h +++ b/builtin_types.h @@ -79,9 +79,9 @@ const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14]; /*@{*/ static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = { - { & builtin_core_types[ 8], "near" }, - { & builtin_core_types[ 8], "far" }, - { & builtin_core_types[ 8], "diff" }, + { glsl_type::float_type, "near" }, + { glsl_type::float_type, "far" }, + { glsl_type::float_type, "diff" }, }; static const struct glsl_type builtin_structure_types[] = { @@ -96,58 +96,58 @@ static const struct glsl_type builtin_structure_types[] = { /*@{*/ static const struct glsl_struct_field gl_PointParameters_fields[] = { - { & builtin_core_types[ 8], "size" }, - { & builtin_core_types[ 8], "sizeMin" }, - { & builtin_core_types[ 8], "sizeMax" }, - { & builtin_core_types[ 8], "fadeThresholdSize" }, - { & builtin_core_types[ 8], "distanceConstantAttenuation" }, - { & builtin_core_types[ 8], "distanceLinearAttenuation" }, - { & builtin_core_types[ 8], "distanceQuadraticAttenuation" }, + { glsl_type::float_type, "size" }, + { glsl_type::float_type, "sizeMin" }, + { glsl_type::float_type, "sizeMax" }, + { glsl_type::float_type, "fadeThresholdSize" }, + { glsl_type::float_type, "distanceConstantAttenuation" }, + { glsl_type::float_type, "distanceLinearAttenuation" }, + { glsl_type::float_type, "distanceQuadraticAttenuation" }, }; static const struct glsl_struct_field gl_MaterialParameters_fields[] = { - { & builtin_core_types[11], "emission" }, - { & builtin_core_types[11], "ambient" }, - { & builtin_core_types[11], "diffuse" }, - { & builtin_core_types[11], "specular" }, - { & builtin_core_types[ 8], "shininess" }, + { glsl_type::vec4_type, "emission" }, + { glsl_type::vec4_type, "ambient" }, + { glsl_type::vec4_type, "diffuse" }, + { glsl_type::vec4_type, "specular" }, + { glsl_type::float_type, "shininess" }, }; static const struct glsl_struct_field gl_LightSourceParameters_fields[] = { - { & builtin_core_types[11], "ambient" }, - { & builtin_core_types[11], "diffuse" }, - { & builtin_core_types[11], "specular" }, - { & builtin_core_types[11], "position" }, - { & builtin_core_types[11], "halfVector" }, - { & builtin_core_types[10], "spotDirection" }, - { & builtin_core_types[ 8], "spotExponent" }, - { & builtin_core_types[ 8], "spotCutoff" }, - { & builtin_core_types[ 8], "spotCosCutoff" }, - { & builtin_core_types[ 8], "constantAttenuation" }, - { & builtin_core_types[ 8], "linearAttenuation" }, - { & builtin_core_types[ 8], "quadraticAttenuation" }, + { glsl_type::vec4_type, "ambient" }, + { glsl_type::vec4_type, "diffuse" }, + { glsl_type::vec4_type, "specular" }, + { glsl_type::vec4_type, "position" }, + { glsl_type::vec4_type, "halfVector" }, + { glsl_type::vec3_type, "spotDirection" }, + { glsl_type::float_type, "spotExponent" }, + { glsl_type::float_type, "spotCutoff" }, + { glsl_type::float_type, "spotCosCutoff" }, + { glsl_type::float_type, "constantAttenuation" }, + { glsl_type::float_type, "linearAttenuation" }, + { glsl_type::float_type, "quadraticAttenuation" }, }; static const struct glsl_struct_field gl_LightModelParameters_fields[] = { - { & builtin_core_types[11], "ambient" }, + { glsl_type::vec4_type, "ambient" }, }; static const struct glsl_struct_field gl_LightModelProducts_fields[] = { - { & builtin_core_types[11], "sceneColor" }, + { glsl_type::vec4_type, "sceneColor" }, }; static const struct glsl_struct_field gl_LightProducts_fields[] = { - { & builtin_core_types[11], "ambient" }, - { & builtin_core_types[11], "diffuse" }, - { & builtin_core_types[11], "specular" }, + { glsl_type::vec4_type, "ambient" }, + { glsl_type::vec4_type, "diffuse" }, + { glsl_type::vec4_type, "specular" }, }; static const struct glsl_struct_field gl_FogParameters_fields[] = { - { & builtin_core_types[11], "color" }, - { & builtin_core_types[ 8], "density" }, - { & builtin_core_types[ 8], "start" }, - { & builtin_core_types[ 8], "end" }, - { & builtin_core_types[ 8], "scale" }, + { glsl_type::vec4_type, "color" }, + { glsl_type::float_type, "density" }, + { glsl_type::float_type, "start" }, + { glsl_type::float_type, "end" }, + { glsl_type::float_type, "scale" }, }; static const struct glsl_type builtin_110_deprecated_structure_types[] = { -- cgit v1.2.3 From 25ebc0459f9e15ebff051fe39e131eca88ea55a0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 23 Apr 2010 13:37:48 -0700 Subject: builtin_functions: Clean up compiler warning about unused name, instructions. --- builtin_function.cpp | 68 +++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index c9383e17cc9..ff731c21625 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -253,8 +253,6 @@ generate_pow(exec_list *instructions, void generate_function_instance(ir_function *f, - const char *name, - exec_list *instructions, int n_args, void (*generate)(exec_list *instructions, ir_variable **declarations, @@ -302,13 +300,13 @@ make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, instructions->push_tail(f); - generate_function_instance(f, name, instructions, n_args, generate, + generate_function_instance(f, n_args, generate, glsl_type::float_type, glsl_type::float_type); - generate_function_instance(f, name, instructions, n_args, generate, + generate_function_instance(f, n_args, generate, glsl_type::vec2_type, glsl_type::vec2_type); - generate_function_instance(f, name, instructions, n_args, generate, + generate_function_instance(f, n_args, generate, glsl_type::vec3_type, glsl_type::vec3_type); - generate_function_instance(f, name, instructions, n_args, generate, + generate_function_instance(f, n_args, generate, glsl_type::vec4_type, glsl_type::vec4_type); } @@ -420,33 +418,33 @@ generate_vec_compare_function(glsl_symbol_table *symtab, instructions->push_tail(f); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec2_type, glsl_type::vec2_type); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec3_type, glsl_type::vec3_type); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec4_type, glsl_type::vec4_type); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec2_type, ivec2_type); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec3_type, ivec3_type); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec4_type, ivec4_type); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec2_type, uvec2_type); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec3_type, uvec3_type); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec4_type, uvec4_type); if (do_bool) { - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec2_type, bvec2_type); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec3_type, bvec3_type); - generate_function_instance(f, name, instructions, 2, generate, + generate_function_instance(f, 2, generate, bvec4_type, bvec4_type); } } @@ -481,13 +479,13 @@ generate_length_functions(glsl_symbol_table *symtab, exec_list *instructions) instructions->push_tail(f); - generate_function_instance(f, name, instructions, 1, generate_length, + generate_function_instance(f, 1, generate_length, glsl_type::float_type, glsl_type::float_type); - generate_function_instance(f, name, instructions, 1, generate_length, + generate_function_instance(f, 1, generate_length, glsl_type::float_type, glsl_type::vec2_type); - generate_function_instance(f, name, instructions, 1, generate_length, + generate_function_instance(f, 1, generate_length, glsl_type::float_type, glsl_type::vec3_type); - generate_function_instance(f, name, instructions, 1, generate_length, + generate_function_instance(f, 1, generate_length, glsl_type::float_type, glsl_type::vec4_type); } @@ -519,13 +517,13 @@ generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions) instructions->push_tail(f); - generate_function_instance(f, name, instructions, 2, generate_dot, + generate_function_instance(f, 2, generate_dot, glsl_type::float_type, glsl_type::float_type); - generate_function_instance(f, name, instructions, 2, generate_dot, + generate_function_instance(f, 2, generate_dot, glsl_type::float_type, glsl_type::vec2_type); - generate_function_instance(f, name, instructions, 2, generate_dot, + generate_function_instance(f, 2, generate_dot, glsl_type::float_type, glsl_type::vec3_type); - generate_function_instance(f, name, instructions, 2, generate_dot, + generate_function_instance(f, 2, generate_dot, glsl_type::float_type, glsl_type::vec4_type); } @@ -683,11 +681,11 @@ generate_any_functions(glsl_symbol_table *symtab, exec_list *instructions) instructions->push_tail(f); - generate_function_instance(f, name, instructions, 1, generate_any_bvec2, + generate_function_instance(f, 1, generate_any_bvec2, glsl_type::bool_type, bvec2_type); - generate_function_instance(f, name, instructions, 1, generate_any_bvec3, + generate_function_instance(f, 1, generate_any_bvec3, glsl_type::bool_type, bvec3_type); - generate_function_instance(f, name, instructions, 1, generate_any_bvec4, + generate_function_instance(f, 1, generate_any_bvec4, glsl_type::bool_type, bvec4_type); } @@ -705,11 +703,11 @@ generate_all_functions(glsl_symbol_table *symtab, exec_list *instructions) instructions->push_tail(f); - generate_function_instance(f, name, instructions, 1, generate_all_bvec2, + generate_function_instance(f, 1, generate_all_bvec2, glsl_type::bool_type, bvec2_type); - generate_function_instance(f, name, instructions, 1, generate_all_bvec3, + generate_function_instance(f, 1, generate_all_bvec3, glsl_type::bool_type, bvec3_type); - generate_function_instance(f, name, instructions, 1, generate_all_bvec4, + generate_function_instance(f, 1, generate_all_bvec4, glsl_type::bool_type, bvec4_type); } @@ -727,11 +725,11 @@ generate_not_functions(glsl_symbol_table *symtab, exec_list *instructions) instructions->push_tail(f); - generate_function_instance(f, name, instructions, 1, generate_not, + generate_function_instance(f, 1, generate_not, bvec2_type, bvec2_type); - generate_function_instance(f, name, instructions, 1, generate_not, + generate_function_instance(f, 1, generate_not, bvec3_type, bvec3_type); - generate_function_instance(f, name, instructions, 1, generate_not, + generate_function_instance(f, 1, generate_not, bvec4_type, bvec4_type); } -- cgit v1.2.3 From c11f1a4fb07f09a6b804c5d0e4bb12cd5137fafa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 26 Apr 2010 14:19:49 -0700 Subject: Initial implementation of #line Does not handle comments in #line or line continuation characters, but it should be good enough for now. --- glsl_lexer.lpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index a25dbf9e2fe..06214a8eccf 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -21,6 +21,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ +#include #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" @@ -43,6 +44,13 @@ %x PP COMMENT +DEC_INT [1-9][0-9]* +HEX_INT 0[xX][0-9a-fA-F]+ +OCT_INT 0[0-7]* +INT ({DEC_INT}|{HEX_INT}|{OCT_INT}) +SPC [ \t]* +SPCP [ \t]+ +HASH ^{SPC}#{SPC} %% "/*" { yy_push_state(COMMENT, yyscanner); } @@ -59,7 +67,35 @@ ^[ \t]*#[ \t]*$ ; ^[ \t]*#[ \t]*version { BEGIN PP; return VERSION; } ^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; } -^[ \t]*#[ \t]*line { BEGIN PP; return LINE; } +{HASH}line{SPCP}{INT}{SPCP}{INT}{SPC}$ { + /* Eat characters until the first digit is + * encountered + */ + char *ptr = yytext; + while (!isdigit(*ptr)) + ptr++; + + /* Subtract one from the line number because + * yylineno is zero-based instead of + * one-based. + */ + yylineno = strtol(ptr, &ptr, 0) - 1; + yylloc->source = strtol(ptr, NULL, 0); + } +{HASH}line{SPCP}{INT}{SPC}$ { + /* Eat characters until the first digit is + * encountered + */ + char *ptr = yytext; + while (!isdigit(*ptr)) + ptr++; + + /* Subtract one from the line number because + * yylineno is zero-based instead of + * one-based. + */ + yylineno = strtol(ptr, &ptr, 0) - 1; + } ^[ \t]*#[ \t]*pragma { BEGIN PP; return PRAGMA; } \/\/[^\n]* { } [ \t\r]* { } -- cgit v1.2.3 From 230ade93a6efeb7a1cbbae1d2226a91f08890ae8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 26 Apr 2010 14:59:16 -0700 Subject: Make private glsl_type singletons public --- glsl_types.h | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/glsl_types.h b/glsl_types.h index c6288683013..2bdfeb8cb60 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -114,6 +114,15 @@ struct glsl_type { static const glsl_type *const vec3_type; static const glsl_type *const vec4_type; static const glsl_type *const bool_type; + static const glsl_type *const mat2_type; + static const glsl_type *const mat2x3_type; + static const glsl_type *const mat2x4_type; + static const glsl_type *const mat3x2_type; + static const glsl_type *const mat3_type; + static const glsl_type *const mat3x4_type; + static const glsl_type *const mat4x2_type; + static const glsl_type *const mat4x3_type; + static const glsl_type *const mat4_type; /*@}*/ @@ -342,22 +351,6 @@ private: */ glsl_type(const glsl_type *array, unsigned length); - - /** - * \name Pointers to various private type singletons - */ - /*@{*/ - static const glsl_type *const mat2_type; - static const glsl_type *const mat2x3_type; - static const glsl_type *const mat2x4_type; - static const glsl_type *const mat3x2_type; - static const glsl_type *const mat3_type; - static const glsl_type *const mat3x4_type; - static const glsl_type *const mat4x2_type; - static const glsl_type *const mat4x3_type; - static const glsl_type *const mat4_type; - /*@}*/ - /** Hash table containing the known array types. */ static struct hash_table *array_types; -- cgit v1.2.3 From 3eba593f35a966949ee7c5990f3e9f519ea0191a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 26 Apr 2010 14:59:32 -0700 Subject: Implement gl_TextureMatrix built-in uniform --- ir_variable.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ir_variable.cpp b/ir_variable.cpp index ba91d566dfc..b5e7d6e9339 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -95,10 +95,15 @@ generate_110_uniforms(exec_list *instructions, instructions, symtab); } - /* FINISHME: Add support for gl_TextureMatrix[]. The size of this array is - * FINISHME: implementation dependent based on the value of - * FINISHME: GL_MAX_TEXTURE_COORDS. + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be + * FINISHME: at least 2, so hard-code 2 for now. */ + const glsl_type *const mat4_array_type = + glsl_type::get_array_instance(glsl_type::mat4_type, 2); + + add_variable("gl_TextureMatrix", ir_var_uniform, mat4_array_type, + instructions, symtab); /* FINISHME: Add support for gl_DepthRangeParameters */ /* FINISHME: Add support for gl_ClipPlane[] */ -- cgit v1.2.3 From 1f0cb24f8bd0f2dba23c95331b04d0a1f89d2af4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Apr 2010 14:40:44 -0700 Subject: Print full type for ir_constant instead of base and component count. vec4 and mat2x2 have the same base type and number of components; printing the full type allows us to distinguish the two. --- ir_print_visitor.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 8f917e48b22..99dbacca112 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -238,10 +238,9 @@ void ir_print_visitor::visit(ir_constant *ir) const glsl_type *const base_type = ir->type->get_base_type(); printf("(constant ("); - print_type(base_type); - printf(") "); + print_type(ir->type); + printf(") ("); - printf("(%d) (", ir->type->components()); for (unsigned i = 0; i < ir->type->components(); i++) { if (i != 0) printf(", "); -- cgit v1.2.3 From 295bb7ff8d3c508320a6af60a69901999196f05f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Apr 2010 14:41:13 -0700 Subject: ir_print_visitor: Remove unnecessary parenthesis around type names. Parenthesis should only be present for compound types (i.e. arrays or structures). For atomic types, simply print the symbol. --- ir_print_visitor.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 99dbacca112..cbe7d976ce7 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -28,11 +28,11 @@ static void print_type(const glsl_type *t) { if (t->base_type == GLSL_TYPE_ARRAY) { - printf("array ("); + printf("(array "); print_type(t->fields.array); - printf(") (%u))", t->length); + printf(" (%u))", t->length); } else if (t->base_type == GLSL_TYPE_STRUCT) { - printf("struct (%s %u ", t->name ? t->name : "@", t->length); + printf("(struct (%s %u ", t->name ? t->name : "@", t->length); printf("(FINISHME: structure fields go here) "); printf(")"); } else { @@ -56,9 +56,7 @@ void ir_print_visitor::visit(ir_variable *ir) printf("(%s%s%s%s) ", cent, inv, mode[ir->mode], interp[ir->interpolation]); - printf("("); print_type(ir->type); - printf(") "); printf("(%s)) ", ir->name); } } @@ -237,9 +235,9 @@ void ir_print_visitor::visit(ir_constant *ir) { const glsl_type *const base_type = ir->type->get_base_type(); - printf("(constant ("); + printf("(constant "); print_type(ir->type); - printf(") ("); + printf(" ("); for (unsigned i = 0; i < ir->type->components(); i++) { if (i != 0) -- cgit v1.2.3 From 1a3a096bf51e86ddc63402def7dff39b41b7cd63 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Apr 2010 16:36:32 -0700 Subject: ir_print_visitor: print the type of expressions. This can be useful for debugging - it allows us to see that the inferred type is what we think it should be. Furthermore, it will allow the IR reader to avoid complex, operator-specific type inference. --- ir_print_visitor.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index cbe7d976ce7..6eb9a1dc415 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -148,10 +148,13 @@ void ir_print_visitor::visit(ir_expression *ir) printf("(expression "); + print_type(ir->type); + assert((unsigned int)ir->operation < sizeof(operators) / sizeof(operators[0])); - printf("%s", operators[ir->operation]); + printf(" %s ", operators[ir->operation]); + printf("("); if (ir->operands[0]) ir->operands[0]->accept(this); -- cgit v1.2.3 From 7dd6adbe2e791b22de97175a8715ef1217619c99 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Apr 2010 16:56:57 -0700 Subject: Refactor ir_expression::get_num_operands. A new static version takes an ir_expression_operation enum, and the original non-static version now uses it. This will make it easier to read operations (where the ir_expression doesn't yet exist). --- ir.cpp | 4 ++-- ir.h | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ir.cpp b/ir.cpp index 1ae7dd6f0e5..b4b2ca4d916 100644 --- a/ir.cpp +++ b/ir.cpp @@ -46,7 +46,7 @@ ir_expression::ir_expression(int op, const struct glsl_type *type, } unsigned int -ir_expression::get_num_operands(void) +ir_expression::get_num_operands(ir_expression_operation op) { /* Update ir_print_visitor.cpp when updating this list. */ const int num_operands[] = { @@ -105,7 +105,7 @@ ir_expression::get_num_operands(void) assert(sizeof(num_operands) / sizeof(num_operands[0]) == ir_binop_pow + 1); - return num_operands[this->operation]; + return num_operands[op]; } diff --git a/ir.h b/ir.h index c93c043f5e5..892455e1dee 100644 --- a/ir.h +++ b/ir.h @@ -471,7 +471,11 @@ public: ir_expression(int op, const struct glsl_type *type, ir_rvalue *, ir_rvalue *); - unsigned int get_num_operands(void); + static unsigned int get_num_operands(ir_expression_operation); + unsigned int get_num_operands() + { + return get_num_operands(operation); + } virtual void accept(ir_visitor *v) { -- cgit v1.2.3 From 1168d95109094f171cf05457385381d053a8581e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Apr 2010 16:34:21 -0700 Subject: ir_print_visitor: Remove unnecessary parenthesis around variable names. --- ir_print_visitor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 6eb9a1dc415..75fc109e133 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -44,7 +44,7 @@ print_type(const glsl_type *t) void ir_print_visitor::visit(ir_variable *ir) { if (deref_depth) { - printf("(%s)", ir->name); + printf("%s", ir->name); } else { printf("(declare "); @@ -57,7 +57,7 @@ void ir_print_visitor::visit(ir_variable *ir) cent, inv, mode[ir->mode], interp[ir->interpolation]); print_type(ir->type); - printf("(%s)) ", ir->name); + printf(" %s)", ir->name); } } -- cgit v1.2.3 From a02c5afce8b43b1871b6631f37b64e8c84606056 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Apr 2010 17:28:47 -0700 Subject: Add parens around printed IR so it's an official list of instructions. --- glsl_parser_extras.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index c808052ee78..121104f9386 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -776,12 +776,14 @@ main(int argc, char **argv) printf("\n\n"); if (!state.error) { + printf("(\n"); foreach_iter(exec_list_iterator, iter, instructions) { ir_print_visitor v; ((ir_instruction *)iter.get())->accept(& v); printf("\n"); } + printf("\n)"); } delete state.symbols; -- cgit v1.2.3 From c84f636c9726ef38a6ae5e007327438f8492dbba Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Apr 2010 17:29:47 -0700 Subject: ir_print_visitor: Fix unclosed parenthesis in (assign ... Also remove useless parens around subexpressions. --- ir_print_visitor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 75fc109e133..bd35bd7966b 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -216,18 +216,18 @@ void ir_print_visitor::visit(ir_dereference *ir) void ir_print_visitor::visit(ir_assignment *ir) { - printf("(assign ("); + printf("(assign "); if (ir->condition) ir->condition->accept(this); else printf("true"); - printf(") ("); + printf(" "); ir->lhs->accept(this); - printf(") ("); + printf(" "); ir->rhs->accept(this); printf(") "); -- cgit v1.2.3 From aecdefa8c03553883b675a212ce217758def08cc Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Apr 2010 17:32:14 -0700 Subject: ir_print_visitor: Fix unclosed parenthesis in (call... --- ir_print_visitor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index bd35bd7966b..de3df8874cc 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -267,6 +267,7 @@ ir_print_visitor::visit(ir_call *ir) inst->accept(this); } + printf(")\n"); } -- cgit v1.2.3 From 668d0a992a33fc2caeda070c34b3c98b5b628d2f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Apr 2010 17:59:51 -0700 Subject: ir_print_visitor: Remove unnecessary parens around array size in types. --- ir_print_visitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index de3df8874cc..9a8eaf599da 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -30,7 +30,7 @@ print_type(const glsl_type *t) if (t->base_type == GLSL_TYPE_ARRAY) { printf("(array "); print_type(t->fields.array); - printf(" (%u))", t->length); + printf(" %u)", t->length); } else if (t->base_type == GLSL_TYPE_STRUCT) { printf("(struct (%s %u ", t->name ? t->name : "@", t->length); printf("(FINISHME: structure fields go here) "); -- cgit v1.2.3 From 2bc582d26548a83fb64cdd6485d039b891dd4c37 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 12 Apr 2010 14:52:37 -0700 Subject: ir_print_visitor: Remove unnecessary parens around expression operands. --- ir_print_visitor.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 9a8eaf599da..faeb784e922 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -155,15 +155,12 @@ void ir_print_visitor::visit(ir_expression *ir) printf(" %s ", operators[ir->operation]); - printf("("); if (ir->operands[0]) ir->operands[0]->accept(this); - printf(") "); - printf("("); if (ir->operands[1]) ir->operands[1]->accept(this); - printf(")) "); + printf(") "); } -- cgit v1.2.3 From 405e122a477a62e7b331c7c4431b628a39d29919 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 12 Apr 2010 15:46:10 -0700 Subject: ir_print_visitor: Print (constant bool (1)) instead of "true" It might be better to simply handle "true" in the reader, but since booleans normally aren't printed as "true" or "false", we may as well go for consistency. --- ir_print_visitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index faeb784e922..ec20e0c0edd 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -218,7 +218,7 @@ void ir_print_visitor::visit(ir_assignment *ir) if (ir->condition) ir->condition->accept(this); else - printf("true"); + printf("(constant bool (1))"); printf(" "); -- cgit v1.2.3 From dde96781628f29cd362182864456130a4614f787 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 17:28:46 -0700 Subject: ir_print_visitor: Print return type of ir_function_signatures. --- ir_print_visitor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index ec20e0c0edd..6a340a25d49 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -64,7 +64,9 @@ void ir_print_visitor::visit(ir_variable *ir) void ir_print_visitor::visit(ir_function_signature *ir) { - printf("(signature\n (parameters\n"); + printf("(signature "); + print_type(ir->return_type); + printf("\n (parameters\n"); foreach_iter(exec_list_iterator, iter, ir->parameters) { ir_variable *const inst = (ir_variable *) iter.get(); -- cgit v1.2.3 From 0e385196f65d0f8dc3238e7eedb6f2d6c0a79a5d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Apr 2010 00:44:12 -0700 Subject: ir_print_visitor: Re-parenthesize ir_call output. --- ir_print_visitor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 6a340a25d49..56048fe40f2 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -260,13 +260,13 @@ void ir_print_visitor::visit(ir_constant *ir) void ir_print_visitor::visit(ir_call *ir) { - printf("(call (%s) ", ir->callee_name()); + printf("(call %s (", ir->callee_name()); foreach_iter(exec_list_iterator, iter, *ir) { ir_instruction *const inst = (ir_instruction *) iter.get(); inst->accept(this); } - printf(")\n"); + printf("))\n"); } -- cgit v1.2.3 From abd40b15210c17b2a3ba8fcffc868fda203efa01 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 11:49:12 -0700 Subject: Factor out qualifier checking code for later reuse. --- ast_to_hir.cpp | 28 +++++++--------------------- ir.cpp | 26 ++++++++++++++++++++++++++ ir.h | 7 +++++++ 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 7b4a855f576..0e7ab1ab3a3 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1952,27 +1952,13 @@ ast_function::hir(exec_list *instructions, * definition. */ if (parameter_lists_match(& hir_parameters, & sig->parameters)) { - exec_list_iterator iter_a = hir_parameters.iterator(); - exec_list_iterator iter_b = sig->parameters.iterator(); - - /* check that the qualifiers match. */ - while (iter_a.has_next()) { - ir_variable *a = (ir_variable *)iter_a.get(); - ir_variable *b = (ir_variable *)iter_b.get(); - - if (a->read_only != b->read_only || - a->interpolation != b->interpolation || - a->centroid != b->centroid) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "function `%s' parameter `%s' qualifiers " - "don't match prototype", - name, a->name); - } - - iter_a.next(); - iter_b.next(); + const char *mismatch = sig->qualifiers_match(&hir_parameters); + if (mismatch != NULL) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(&loc, state, "function `%s' parameter `%s' " + "qualifiers don't match prototype", + name, mismatch); } if (sig->return_type != return_type) { diff --git a/ir.cpp b/ir.cpp index b4b2ca4d916..8912c00e827 100644 --- a/ir.cpp +++ b/ir.cpp @@ -338,6 +338,32 @@ ir_function_signature::ir_function_signature(const glsl_type *return_type) } +const char * +ir_function_signature::qualifiers_match(exec_list *params) +{ + exec_list_iterator iter_a = parameters.iterator(); + exec_list_iterator iter_b = params->iterator(); + + /* check that the qualifiers match. */ + while (iter_a.has_next()) { + ir_variable *a = (ir_variable *)iter_a.get(); + ir_variable *b = (ir_variable *)iter_b.get(); + + if (a->read_only != b->read_only || + a->interpolation != b->interpolation || + a->centroid != b->centroid) { + + /* parameter a's qualifiers don't match */ + return a->name; + } + + iter_a.next(); + iter_b.next(); + } + return NULL; +} + + ir_function::ir_function(const char *name) : name(name) { diff --git a/ir.h b/ir.h index 892455e1dee..b9ab25b6453 100644 --- a/ir.h +++ b/ir.h @@ -206,6 +206,13 @@ public: */ const char *function_name() const; + /** + * Check whether the qualifiers match between this signature's parameters + * and the supplied parameter list. If not, returns the name of the first + * parameter with mismatched qualifiers (for use in error messages). + */ + const char *qualifiers_match(exec_list *params); + /** * Function return type. * -- cgit v1.2.3 From 0d605cb97c9cd2f9a170e3aa15bdf4021a75fc14 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 12:04:23 -0700 Subject: Factor out parameter list matching from ast_function::hir for later reuse. Unfortunately, we still have two kinds of matching - one, with implicit conversions (for use in calls) and another without them (for finding a prototype to overwrite when processing a function body). This commit does not attempt to coalesce the two. --- ast_to_hir.cpp | 79 +++++++++++++-------------------------------------------- ir.h | 9 ++++++- ir_function.cpp | 43 +++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 63 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 0e7ab1ab3a3..52e372c7e49 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1883,36 +1883,6 @@ ast_parameter_declarator::parameters_to_hir(struct simple_node *ast_parameters, } -static bool -parameter_lists_match(exec_list *list_a, exec_list *list_b) -{ - exec_list_iterator iter_a = list_a->iterator(); - exec_list_iterator iter_b = list_b->iterator(); - - while (iter_a.has_next() && iter_b.has_next()) { - ir_variable *a = (ir_variable *)iter_a.get(); - ir_variable *b = (ir_variable *)iter_b.get(); - - /* If the types of the parameters do not match, the parameters lists - * are different. - */ - if (a->type != b->type) - return false; - - iter_a.next(); - iter_b.next(); - } - - /* Unless both lists are exhausted, they differ in length and, by - * definition, do not match. - */ - if (iter_a.has_next() != iter_b.has_next()) - return false; - - return true; -} - - ir_rvalue * ast_function::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -1943,45 +1913,30 @@ ast_function::hir(exec_list *instructions, const char *const name = identifier; f = state->symbols->get_function(name); if (f != NULL) { - foreach_iter(exec_list_iterator, iter, *f) { - sig = (struct ir_function_signature *) iter.get(); - - /* Compare the parameter list of the function being defined to the - * existing function. If the parameter lists match, then the return - * type must also match and the existing function must not have a - * definition. - */ - if (parameter_lists_match(& hir_parameters, & sig->parameters)) { - const char *mismatch = sig->qualifiers_match(&hir_parameters); - if (mismatch != NULL) { - YYLTYPE loc = this->get_location(); + ir_function_signature *sig = f->exact_matching_signature(&hir_parameters); + if (sig != NULL) { + const char *badvar = sig->qualifiers_match(&hir_parameters); + if (badvar != NULL) { + YYLTYPE loc = this->get_location(); - _mesa_glsl_error(&loc, state, "function `%s' parameter `%s' " - "qualifiers don't match prototype", - name, mismatch); - } + _mesa_glsl_error(&loc, state, "function `%s' parameter `%s' " + "qualifiers don't match prototype", name, badvar); + } - if (sig->return_type != return_type) { - YYLTYPE loc = this->get_location(); + if (sig->return_type != return_type) { + YYLTYPE loc = this->get_location(); - _mesa_glsl_error(& loc, state, - "function `%s' return type doesn't match " - "prototype", - name); - } + _mesa_glsl_error(&loc, state, "function `%s' return type doesn't " + "match prototype", name); + } - if (is_definition && sig->is_defined) { - YYLTYPE loc = this->get_location(); + if (is_definition && sig->is_defined) { + YYLTYPE loc = this->get_location(); - _mesa_glsl_error(& loc, state, "function `%s' redefined", name); - sig = NULL; - break; - } + _mesa_glsl_error(& loc, state, "function `%s' redefined", name); + sig = NULL; } - - sig = NULL; } - } else if (state->symbols->name_declared_this_scope(name)) { /* This function name shadows a non-function use of the same name. */ diff --git a/ir.h b/ir.h index b9ab25b6453..118d97ffa3c 100644 --- a/ir.h +++ b/ir.h @@ -276,10 +276,17 @@ public: } /** - * Find a signature that matches a set of actual parameters. + * Find a signature that matches a set of actual parameters, taking implicit + * conversions into account. */ const ir_function_signature *matching_signature(exec_list *actual_param); + /** + * Find a signature that exactly matches a set of actual parameters without + * any implicit type conversions. + */ + ir_function_signature *exact_matching_signature(exec_list *actual_ps); + /** * Name of the function. */ diff --git a/ir_function.cpp b/ir_function.cpp index a8b73f1e1aa..5db93f67fb8 100644 --- a/ir_function.cpp +++ b/ir_function.cpp @@ -180,3 +180,46 @@ ir_function::matching_signature(exec_list *actual_parameters) return match; } + + +static bool +parameter_lists_match_exact(exec_list *list_a, exec_list *list_b) +{ + exec_list_iterator iter_a = list_a->iterator(); + exec_list_iterator iter_b = list_b->iterator(); + + while (iter_a.has_next() && iter_b.has_next()) { + ir_variable *a = (ir_variable *)iter_a.get(); + ir_variable *b = (ir_variable *)iter_b.get(); + + /* If the types of the parameters do not match, the parameters lists + * are different. + */ + if (a->type != b->type) + return false; + + iter_a.next(); + iter_b.next(); + } + + /* Unless both lists are exhausted, they differ in length and, by + * definition, do not match. + */ + if (iter_a.has_next() != iter_b.has_next()) + return false; + + return true; +} + +ir_function_signature * +ir_function::exact_matching_signature(exec_list *actual_parameters) +{ + foreach_iter(exec_list_iterator, iter, signatures) { + ir_function_signature *const sig = + (ir_function_signature *) iter.get(); + + if (parameter_lists_match_exact(&sig->parameters, actual_parameters)) + return sig; + } + return NULL; +} -- cgit v1.2.3 From bff6013d469b3d4e54cdc5731801c56994a523ec Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 12:44:24 -0700 Subject: Factor out parameter list replacement for later reuse. --- ast_to_hir.cpp | 13 +------------ ir.cpp | 18 ++++++++++++++++++ ir.h | 7 +++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 52e372c7e49..1dc4ea25b21 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1973,20 +1973,9 @@ ast_function::hir(exec_list *instructions, if (sig == NULL) { sig = new ir_function_signature(return_type); f->add_signature(sig); - } else if (is_definition) { - /* Destroy all of the previous parameter information. The previous - * parameter information comes from the function prototype, and it can - * either include invalid parameter names or may not have names at all. - */ - foreach_iter(exec_list_iterator, iter, sig->parameters) { - assert(((ir_instruction *) iter.get())->as_variable() != NULL); - - iter.remove(); - delete iter.get(); - } } - hir_parameters.move_nodes_to(& sig->parameters); + sig->replace_parameters(&hir_parameters); signature = sig; /* Function declarations (prototypes) do not have r-values. diff --git a/ir.cpp b/ir.cpp index 8912c00e827..e7e5dee00cb 100644 --- a/ir.cpp +++ b/ir.cpp @@ -364,6 +364,24 @@ ir_function_signature::qualifiers_match(exec_list *params) } +void +ir_function_signature::replace_parameters(exec_list *new_params) +{ + /* Destroy all of the previous parameter information. If the previous + * parameter information comes from the function prototype, it may either + * specify incorrect parameter names or not have names at all. + */ + foreach_iter(exec_list_iterator, iter, parameters) { + assert(((ir_instruction *) iter.get())->as_variable() != NULL); + + iter.remove(); + delete (ir_instruction*) iter.get(); + } + + new_params->move_nodes_to(¶meters); +} + + ir_function::ir_function(const char *name) : name(name) { diff --git a/ir.h b/ir.h index 118d97ffa3c..df64e488235 100644 --- a/ir.h +++ b/ir.h @@ -213,6 +213,13 @@ public: */ const char *qualifiers_match(exec_list *params); + /** + * Replace the current parameter list with the given one. This is useful + * if the current information came from a prototype, and either has invalid + * or missing parameter names. + */ + void replace_parameters(exec_list *new_params); + /** * Function return type. * -- cgit v1.2.3 From 3b96996b7eb6e3603a5f138177867c3e856e0dfa Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Apr 2010 17:18:29 -0700 Subject: Move array of operator strings out of ir_print_visitor.cpp. Also implement a reverse-lookup function for use in the IR reader. --- ir.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ir.h | 14 ++++++++++-- ir_print_visitor.cpp | 52 +----------------------------------------- 3 files changed, 77 insertions(+), 53 deletions(-) diff --git a/ir.cpp b/ir.cpp index e7e5dee00cb..3f4c40d0c99 100644 --- a/ir.cpp +++ b/ir.cpp @@ -108,6 +108,70 @@ ir_expression::get_num_operands(ir_expression_operation op) return num_operands[op]; } +static const char *const operator_strs[] = { + "~", + "!", + "-", + "abs", + "rcp", + "rsq", + "sqrt", + "exp", + "log", + "exp2", + "log2", + "f2i", + "i2f", + "f2b", + "b2f", + "i2b", + "b2i", + "u2f", + "trunc", + "ceil", + "floor", + "+", + "-", + "*", + "/", + "%", + "<", + ">", + "<=", + ">=", + "==", + "!=", + "<<", + ">>", + "&", + "^", + "|", + "&&", + "^^", + "||", + "dot", + "min", + "max", + "pow", +}; + +const char *ir_expression::operator_string() +{ + assert((unsigned int) operation <= + sizeof(operator_strs) / sizeof(operator_strs[0])); + return operator_strs[operation]; +} + +ir_expression_operation +ir_expression::get_operator(const char *str) +{ + const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]); + for (int op = 0; op < operator_count; op++) { + if (strcmp(str, operator_strs[op]) == 0) + return (ir_expression_operation) op; + } + return (ir_expression_operation) -1; +} ir_constant::ir_constant(const struct glsl_type *type, const void *data) { diff --git a/ir.h b/ir.h index df64e488235..42e8264d41d 100644 --- a/ir.h +++ b/ir.h @@ -415,9 +415,9 @@ public: ir_rvalue *condition; }; -/* Update ir_expression::num_operands() and ir_print_visitor.cpp when +/* Update ir_expression::num_operands() and operator_strs when * updating this list. -*/ + */ enum ir_expression_operation { ir_unop_bit_not, ir_unop_logic_not, @@ -498,6 +498,16 @@ public: return get_num_operands(operation); } + /** + * Return a string representing this expression's operator. + */ + const char *operator_string(); + + /** + * Do a reverse-lookup to translate the given string into an operator. + */ + static ir_expression_operation get_operator(const char *); + virtual void accept(ir_visitor *v) { v->visit(this); diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 56048fe40f2..778a5c16460 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -101,61 +101,11 @@ void ir_print_visitor::visit(ir_function *ir) void ir_print_visitor::visit(ir_expression *ir) { - static const char *const operators[] = { - "~", - "!", - "-", - "abs", - "rcp", - "rsq", - "sqrt", - "exp", - "log", - "exp2", - "log2", - "f2i", - "i2f", - "f2b", - "b2f", - "i2b", - "b2i", - "u2f", - "trunc", - "ceil", - "floor", - "+", - "-", - "*", - "/", - "%", - "<", - ">", - "<=", - ">=", - "==", - "!=", - "<<", - ">>", - "&", - "^", - "|", - "&&", - "^^", - "||", - "dot", - "min", - "max", - "pow", - }; - printf("(expression "); print_type(ir->type); - assert((unsigned int)ir->operation < - sizeof(operators) / sizeof(operators[0])); - - printf(" %s ", operators[ir->operation]); + printf(" %s ", ir->operator_string()); if (ir->operands[0]) ir->operands[0]->accept(this); -- cgit v1.2.3 From 9d290d786d702cfc5eb7b6aefd6cb5b2c946ab88 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 23:47:07 -0700 Subject: Use "neg" when printing/reading unary negation rather than "-". "-" is now only used for binary subtraction. --- ir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir.cpp b/ir.cpp index 3f4c40d0c99..63135e35533 100644 --- a/ir.cpp +++ b/ir.cpp @@ -111,7 +111,7 @@ ir_expression::get_num_operands(ir_expression_operation op) static const char *const operator_strs[] = { "~", "!", - "-", + "neg", "abs", "rcp", "rsq", -- cgit v1.2.3 From 1bfe1c3fdde39235ccbd8fc3da84a1603e919bc3 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Apr 2010 13:39:34 -0700 Subject: Add a simple S-Expression reader and printer. --- Makefile.am | 3 +- s_expression.cpp | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ s_expression.h | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 296 insertions(+), 1 deletion(-) create mode 100644 s_expression.cpp create mode 100644 s_expression.h diff --git a/Makefile.am b/Makefile.am index b43dee3037e..4312d41980e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,7 +36,8 @@ glsl_SOURCES = \ ir_expression_flattening.cpp \ ir_function_can_inline.cpp \ ir_function_inlining.cpp \ - ir_if_simplification.cpp + ir_if_simplification.cpp \ + s_expression.cpp BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/s_expression.cpp b/s_expression.cpp new file mode 100644 index 00000000000..4022dfab7a7 --- /dev/null +++ b/s_expression.cpp @@ -0,0 +1,146 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include "s_expression.h" + +s_symbol::s_symbol(const char *tmp) +{ + this->str = new char [strlen(tmp) + 1]; + strcpy(this->str, tmp); +} + +s_symbol::~s_symbol() +{ + delete [] this->str; + this->str = NULL; +} + +s_list::s_list() +{ +} + +s_list::~s_list() +{ + exec_list_iterator it(this->subexpressions.iterator()); + while (it.has_next()) + it.remove(); + + assert(this->subexpressions.is_empty()); +} + +unsigned +s_list::length() const +{ + unsigned i = 0; + foreach_iter(exec_list_iterator, it, this->subexpressions) { + i++; + } + return i; +} + +static s_expression * +read_atom(const char *& src) +{ + char buf[101]; + int n; + if (sscanf(src, " %100[^( \v\t\r\n)]%n", buf, &n) != 1) + return NULL; // no atom + src += n; + + // Check if the atom is a number. + char *float_end = NULL; + double f = strtod(buf, &float_end); + if (float_end != buf) { + char *int_end = NULL; + int i = strtol(buf, &int_end, 10); + // If strtod matched more characters, it must have a decimal part + if (float_end > int_end) + return new s_float(f); + + return new s_int(i); + } + // Not a number; return a symbol. + return new s_symbol(buf); +} + +s_expression * +s_expression::read_expression(const char *&src) +{ + assert(src != NULL); + + s_expression *atom = read_atom(src); + if (atom != NULL) + return atom; + + char c; + int n; + if (sscanf(src, " %c%n", &c, &n) == 1 && c == '(') { + src += n; + + s_list *list = new s_list; + s_expression *expr; + + while ((expr = read_expression(src)) != NULL) { + list->subexpressions.push_tail(expr); + } + if (sscanf(src, " %c%n", &c, &n) != 1 || c != ')') { + printf("Unclosed expression (check your parenthesis).\n"); + return NULL; + } + src += n; + return list; + } + return NULL; +} + +void s_int::print() +{ + printf("%d", this->val); +} + +void s_float::print() +{ + printf("%f", this->val); +} + +void s_symbol::print() +{ + printf("%s", this->str); +} + +void s_list::print() +{ + printf("("); + foreach_iter(exec_list_iterator, it, this->subexpressions) { + s_expression *expr = (s_expression*) it.get(); + expr->print(); + printf(" "); + } + printf(")"); +} + diff --git a/s_expression.h b/s_expression.h new file mode 100644 index 00000000000..d5e52c16e83 --- /dev/null +++ b/s_expression.h @@ -0,0 +1,148 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef S_EXPRESSION_H +#define S_EXPRESSION_H + +#include "list.h" + +#define SX_AS_(t,x) ((x) && ((s_expression*) x)->is_##t()) ? ((s_##t*) (x)) \ + : NULL +#define SX_AS_LIST(x) SX_AS_(list, x) +#define SX_AS_SYMBOL(x) SX_AS_(symbol, x) +#define SX_AS_NUMBER(x) SX_AS_(number, x) +#define SX_AS_INT(x) SX_AS_(int, x) + +/* For our purposes, S-Expressions are: + * - + * - + * - symbol + * - (expr1 expr2 ... exprN) where exprN is an S-Expression + * + * Unlike LISP/Scheme, we do not support (foo . bar) pairs. + */ +class s_expression : public exec_node +{ +public: + virtual ~s_expression() { } + + /** + * Read an S-Expression from the given string. + * Advances the supplied pointer to just after the expression read. + */ + static s_expression *read_expression(const char *&src); + + /** + * Print out an S-Expression. Useful for debugging. + */ + virtual void print() = 0; + + virtual bool is_list() const { return false; } + virtual bool is_symbol() const { return false; } + virtual bool is_number() const { return false; } + virtual bool is_int() const { return false; } + +protected: + s_expression() { } +}; + +/* Atoms */ + +class s_number : public s_expression +{ +public: + virtual ~s_number() { } + + bool is_number() const { return true; } + + virtual float fvalue() = 0; + +protected: + s_number() { } +}; + +class s_int : public s_number +{ +public: + s_int(int x) : val(x) { } + virtual ~s_int() { } + + bool is_int() const { return true; } + + float fvalue() { return float(this->val); } + int value() { return this->val; } + + void print(); + +private: + int val; +}; + +class s_float : public s_number +{ +public: + s_float(float x) : val(x) { } + virtual ~s_float() { } + + float fvalue() { return this->val; } + + void print(); + +private: + float val; +}; + +class s_symbol : public s_expression +{ +public: + s_symbol(const char *); + virtual ~s_symbol(); + + bool is_symbol() const { return true; } + + const char *value() { return this->str; } + + void print(); + +private: + char *str; +}; + +/* Lists of expressions: (expr1 ... exprN) */ +class s_list : public s_expression +{ +public: + s_list(); + virtual ~s_list(); + + virtual bool is_list() const { return true; } + unsigned length() const; + + void print(); + + exec_list subexpressions; +}; + +#endif /* S_EXPRESSION_H */ -- cgit v1.2.3 From 34350be2cdb0cb769657d5ce82bc37d906eb3eb5 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Apr 2010 14:38:03 -0700 Subject: Add stub ir_reader and new 'i' mode for reading IR rather than GLSL. --- Makefile.am | 2 +- glsl_parser_extras.cpp | 26 +++++++++++++++++--------- glsl_parser_extras.h | 3 ++- ir_reader.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ ir_reader.h | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 ir_reader.cpp create mode 100644 ir_reader.h diff --git a/Makefile.am b/Makefile.am index 4312d41980e..4044cc076d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,7 @@ glsl_SOURCES = \ ir_function_can_inline.cpp \ ir_function_inlining.cpp \ ir_if_simplification.cpp \ - s_expression.cpp + ir_reader.cpp s_expression.cpp BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 121104f9386..88889d59b0e 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -39,6 +39,7 @@ #include "ir_function_inlining.h" #include "ir_if_simplification.h" #include "ir_print_visitor.h" +#include "ir_reader.h" const char * _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) @@ -715,7 +716,7 @@ main(int argc, char **argv) exec_list instructions; if (argc < 3) { - printf("Usage: %s [v|g|f] \n", argv[0]); + printf("Usage: %s [v|g|f|i] \n", argv[0]); return EXIT_FAILURE; } @@ -731,8 +732,11 @@ main(int argc, char **argv) case 'f': state.target = fragment_shader; break; + case 'i': + state.target = ir_shader; + break; default: - printf("Usage: %s [v|g|f] \n", argv[0]); + printf("Usage: %s [v|g|f|i] \n", argv[0]); return EXIT_FAILURE; } @@ -746,15 +750,19 @@ main(int argc, char **argv) state.loop_or_switch_nesting = NULL; state.ARB_texture_rectangle_enable = true; - _mesa_glsl_lexer_ctor(& state, shader, shader_len); - _mesa_glsl_parse(& state); - _mesa_glsl_lexer_dtor(& state); + if (state.target != ir_shader) { + _mesa_glsl_lexer_ctor(& state, shader, shader_len); + _mesa_glsl_parse(& state); + _mesa_glsl_lexer_dtor(& state); - foreach (ptr, & state.translation_unit) { - ((ast_node *)ptr)->print(); - } + foreach (ptr, & state.translation_unit) { + ((ast_node *)ptr)->print(); + } - _mesa_ast_to_hir(&instructions, &state); + _mesa_ast_to_hir(&instructions, &state); + } else { + _mesa_glsl_read_ir(&state, &instructions, shader); + } /* Optimization passes */ if (!state.error) { diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index a79dc75d482..55bcc72e940 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -32,7 +32,8 @@ enum _mesa_glsl_parser_targets { vertex_shader, geometry_shader, - fragment_shader + fragment_shader, + ir_shader }; struct _mesa_glsl_parse_state { diff --git a/ir_reader.cpp b/ir_reader.cpp new file mode 100644 index 00000000000..d6f3f3c117c --- /dev/null +++ b/ir_reader.cpp @@ -0,0 +1,47 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include "ir_reader.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" +#include "s_expression.h" + +void +_mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, + const char *src) +{ + s_expression *expr = s_expression::read_expression(src); + if (expr == NULL) { + printf("couldn't parse S-Expression."); + state->error = true; + return; + } + printf("S-Expression:\n"); + expr->print(); + printf("\n"); + + // FINISHME: actually read the IR. + state->error = true; +} + diff --git a/ir_reader.h b/ir_reader.h new file mode 100644 index 00000000000..b6afdc81ab1 --- /dev/null +++ b/ir_reader.h @@ -0,0 +1,34 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_READER_H +#define IR_READER_H + +#include "ir.h" + +void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, + const char *src); + +#endif /* IR_READER_H */ -- cgit v1.2.3 From e8b399270da7a1201bd544df5bd902ca21cdcbc9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Apr 2010 15:16:20 -0700 Subject: Set language_version to 130 (the max currently supported) when reading IR. This is necessary so _mesa_glsl_initialize_types can create appropriate glsl_types and add them to the symbol table. In the future, we'll want to set it to the max GLSL version supported by the current driver. --- glsl_parser_extras.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 88889d59b0e..efcb125dfc5 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -761,6 +761,11 @@ main(int argc, char **argv) _mesa_ast_to_hir(&instructions, &state); } else { + /* FINISHME: We should initialize this to the max GLSL version supported + * FINISHME: by the driver. At the moment, we don't know what that is. + */ + state.language_version = 130; + _mesa_glsl_read_ir(&state, &instructions, shader); } -- cgit v1.2.3 From f955649af3f23367d5e70f33a2bf958b11c2e127 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Apr 2010 17:24:44 -0700 Subject: Partial IR reader. Currently reads assignments, constants, expressions, and swizzles. --- ir_reader.cpp | 318 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 314 insertions(+), 4 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index d6f3f3c117c..4890cf8da9e 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -27,21 +27,331 @@ #include "glsl_types.h" #include "s_expression.h" +static void ir_read_error(s_expression *expr, const char *fmt, ...); +static glsl_type *read_type(_mesa_glsl_parse_state *, s_expression *); +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_swizzle *read_swizzle(_mesa_glsl_parse_state *, s_list *); +static ir_constant *read_constant(_mesa_glsl_parse_state *, s_list *); + void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, const char *src) { s_expression *expr = s_expression::read_expression(src); if (expr == NULL) { - printf("couldn't parse S-Expression."); + ir_read_error(NULL, "couldn't parse S-Expression."); state->error = true; return; } printf("S-Expression:\n"); expr->print(); - printf("\n"); + printf("\n-------------\n"); - // FINISHME: actually read the IR. - state->error = true; + _mesa_glsl_initialize_types(state); + _mesa_glsl_initialize_variables(instructions, state); + _mesa_glsl_initialize_constructors(instructions, state); + _mesa_glsl_initialize_functions(instructions, state); + + // FINISHME: Only reading rvalues...for testing. + ir_instruction *ir = read_rvalue(state, SX_AS_LIST(expr)); + if (ir == NULL) { + ir_read_error(NULL, "No IR\n"); + state->error = true; + return; + } + instructions->push_tail(ir); } +static void +ir_read_error(s_expression *expr, const char *fmt, ...) +{ + char buf[1024]; + int len; + va_list ap; + + // FIXME: state->error = true; + + len = snprintf(buf, sizeof(buf), "error: "); + + va_start(ap, fmt); + vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); + va_end(ap); + + printf("%s\n", buf); +} + +static glsl_type * +read_type(_mesa_glsl_parse_state *st, 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(expr, "expected type (array (...)) or (struct (...))"); + return NULL; + } + if (strcmp(type_sym->value(), "array") == 0) + assert(false); // FINISHME + if (strcmp(type_sym->value(), "struct") == 0) + assert(false); // FINISHME + } + + s_symbol *type_sym = SX_AS_SYMBOL(expr); + if (type_sym == NULL) { + ir_read_error(expr, "expected (symbol or list)"); + return NULL; + } + + glsl_type *type = st->symbols->get_type(type_sym->value()); + if (type == NULL) + ir_read_error(expr, "invalid type: %s", type_sym->value()); + + return type; +} + +static ir_rvalue * +read_rvalue(_mesa_glsl_parse_state *st, 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.get_head()); + if (tag == NULL) { + ir_read_error(expr, "expected rvalue tag"); + return NULL; + } + + ir_rvalue *rvalue = NULL; + if (strcmp(tag->value(), "swiz") == 0) + rvalue = read_swizzle(st, list); + else if (strcmp(tag->value(), "assign") == 0) + rvalue = read_assignment(st, list); + else if (strcmp(tag->value(), "expression") == 0) + rvalue = read_expression(st, list); + // FINISHME: ir_call + // FINISHME: dereference + else if (strcmp(tag->value(), "constant") == 0) + rvalue = read_constant(st, list); + else + 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) +{ + if (list->length() != 4) { + ir_read_error(list, "expected (assign )"); + return NULL; + } + + s_expression *cond_expr = (s_expression*) list->subexpressions.head->next; + s_expression *lhs_expr = (s_expression*) cond_expr->next; + s_expression *rhs_expr = (s_expression*) lhs_expr->next; + + // FINISHME: Deal with "true" condition + ir_rvalue *condition = read_rvalue(st, cond_expr); + if (condition == NULL) { + ir_read_error(list, "when reading condition of assignment"); + return NULL; + } + + ir_rvalue *lhs = read_rvalue(st, lhs_expr); + if (lhs == NULL) { + ir_read_error(list, "when reading left-hand side of assignment"); + return NULL; + } + + ir_rvalue *rhs = read_rvalue(st, rhs_expr); + if (rhs == NULL) { + ir_read_error(list, "when reading right-hand side of assignment"); + return NULL; + } + + return new ir_assignment(lhs, rhs, condition); +} + + +static ir_expression * +read_expression(_mesa_glsl_parse_state *st, s_list *list) +{ + const unsigned list_length = list->length(); + if (list_length < 4) { + ir_read_error(list, "expected (expression " + "[])"); + return NULL; + } + + s_expression *type_expr = (s_expression*) list->subexpressions.head->next; + glsl_type *type = read_type(st, type_expr); + 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(list, "expected operator, found non-symbol"); + return NULL; + } + + ir_expression_operation op = ir_expression::get_operator(op_sym->value()); + if (op == (ir_expression_operation) -1) { + ir_read_error(list, "invalid operator: %s", op_sym->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(list, "expected (expression %s )", + op_sym->value()); + return NULL; + } + } else { + if (list_length != 4) { + ir_read_error(list, "expected (expression %s )", + op_sym->value()); + return NULL; + } + } + + s_expression *exp1 = (s_expression*) (op_sym->next); + ir_rvalue *arg1 = read_rvalue(st, exp1); + if (arg1 == NULL) { + ir_read_error(list, "when reading first operand of %s", op_sym->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 (arg2 == NULL) { + ir_read_error(list, "when reading second operand of %s", + op_sym->value()); + return NULL; + } + } + + return new ir_expression(op, type, arg1, arg2); +} + +static ir_swizzle * +read_swizzle(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 3) { + ir_read_error(list, "expected (swiz )"); + return NULL; + } + + s_symbol *swiz = SX_AS_SYMBOL(list->subexpressions.head->next); + if (swiz == NULL) { + ir_read_error(list, "expected a valid swizzle; found non-symbol"); + return NULL; + } + + unsigned num_components = strlen(swiz->value()); + if (num_components > 4) { + ir_read_error(list, "expected a valid swizzle; found %s", swiz->value()); + return NULL; + } + + s_expression *sub = (s_expression*) swiz->next; + if (sub == NULL) { + ir_read_error(list, "expected rvalue: (swizzle %s )", swiz->value()); + return NULL; + } + + ir_rvalue *rvalue = read_rvalue(st, sub); + if (rvalue == NULL) + return NULL; + + return ir_swizzle::create(rvalue, swiz->value(), num_components); +} + +static ir_constant * +read_constant(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 3) { + ir_read_error(list, "expected (constant ( ... ))"); + return NULL; + } + + s_expression *type_expr = (s_expression*) list->subexpressions.head->next; + glsl_type *type = read_type(st, type_expr); + if (type == NULL) + return NULL; + + s_list *values = SX_AS_LIST(type_expr->next); + if (values == NULL) { + ir_read_error(list, "expected (constant ( ... ))"); + return NULL; + } + + const glsl_type *const base_type = type->get_base_type(); + + unsigned u[16]; + int i[16]; + float f[16]; + bool b[16]; + + // Read in list of values (at most 16). + int k = 0; + foreach_iter(exec_list_iterator, it, values->subexpressions) { + if (k >= 16) { + ir_read_error(values, "expected at most 16 numbers"); + return NULL; + } + + s_expression *expr = (s_expression*) it.get(); + + if (base_type->base_type == GLSL_TYPE_FLOAT) { + s_number *value = SX_AS_NUMBER(expr); + if (value == NULL) { + ir_read_error(values, "expected numbers"); + return NULL; + } + f[k] = value->fvalue(); + } else { + s_int *value = SX_AS_INT(expr); + if (value == NULL) { + ir_read_error(values, "expected integers"); + return NULL; + } + + switch (base_type->base_type) { + case GLSL_TYPE_UINT: { + u[k] = value->value(); + break; + } + case GLSL_TYPE_INT: { + i[k] = value->value(); + break; + } + case GLSL_TYPE_BOOL: { + b[k] = value->value(); + break; + } + default: + ir_read_error(values, "unsupported constant type"); + return NULL; + } + } + ++k; + } + switch (base_type->base_type) { + case GLSL_TYPE_UINT: + return new ir_constant(type, u); + case GLSL_TYPE_INT: + return new ir_constant(type, i); + case GLSL_TYPE_BOOL: + return new ir_constant(type, b); + case GLSL_TYPE_FLOAT: + return new ir_constant(type, f); + } + return NULL; // should not be reached +} -- cgit v1.2.3 From d1d2ada3c6bdf5a99c07147c157da75f07100847 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Apr 2010 17:40:51 -0700 Subject: ir_reader: Add support for reading variable declarations. It also now reads a list of instructions, as it should, rather than a single rvalue. --- ir_reader.cpp | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 114 insertions(+), 5 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 4890cf8da9e..00fcc9475cc 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -29,6 +29,11 @@ static void ir_read_error(s_expression *expr, const char *fmt, ...); static glsl_type *read_type(_mesa_glsl_parse_state *, s_expression *); + +static ir_instruction *read_instruction(_mesa_glsl_parse_state *, + s_expression *); +static ir_variable *read_declaration(_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 *); @@ -54,14 +59,24 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, _mesa_glsl_initialize_constructors(instructions, state); _mesa_glsl_initialize_functions(instructions, state); - // FINISHME: Only reading rvalues...for testing. - ir_instruction *ir = read_rvalue(state, SX_AS_LIST(expr)); - if (ir == NULL) { - ir_read_error(NULL, "No IR\n"); + // Read in a list of instructions + s_list *list = SX_AS_LIST(expr); + if (list == NULL) { + ir_read_error(expr, "Expected ( ...); found an atom."); state->error = true; return; } - instructions->push_tail(ir); + + foreach_iter(exec_list_iterator, it, list->subexpressions) { + s_expression *sub = (s_expression*) it.get(); + ir_instruction *ir = read_instruction(state, sub); + if (ir == NULL) { + ir_read_error(sub, "Invalid instruction.\n"); + state->error = true; + return; + } + instructions->push_tail(ir); + } } static void @@ -111,6 +126,100 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) return type; } + +static ir_instruction * +read_instruction(_mesa_glsl_parse_state *st, 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.get_head()); + if (tag == NULL) { + ir_read_error(expr, "expected instruction tag"); + return NULL; + } + + ir_instruction *inst = NULL; + if (strcmp(tag->value(), "declare") == 0) + inst = read_declaration(st, list); + else + ir_read_error(expr, "unrecognized instruction tag: %s", tag->value()); + + return inst; +} + + +static ir_variable * +read_declaration(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 4) { + ir_read_error(list, "expected (declare () )"); + return NULL; + } + + s_list *quals = SX_AS_LIST(list->subexpressions.head->next); + if (quals == NULL) { + ir_read_error(list, "expected a list of variable qualifiers"); + return NULL; + } + + s_expression *type_expr = (s_expression*) quals->next; + glsl_type *type = read_type(st, type_expr); + if (type == NULL) + return NULL; + + s_symbol *var_name = SX_AS_SYMBOL(type_expr->next); + if (var_name == NULL) { + ir_read_error(list, "expected variable name, found non-symbol"); + return NULL; + } + + ir_variable *var = new ir_variable(type, var_name->value()); + + foreach_iter(exec_list_iterator, it, quals->subexpressions) { + s_symbol *qualifier = SX_AS_SYMBOL(it.get()); + if (qualifier == NULL) { + ir_read_error(list, "qualifier list must contain only symbols"); + delete var; + return NULL; + } + + // FINISHME: Check for duplicate/conflicting qualifiers. + if (strcmp(qualifier->value(), "centroid") == 0) { + var->centroid = 1; + } else if (strcmp(qualifier->value(), "invariant") == 0) { + var->invariant = 1; + } else if (strcmp(qualifier->value(), "uniform") == 0) { + var->mode = ir_var_uniform; + } else if (strcmp(qualifier->value(), "auto") == 0) { + var->mode = ir_var_auto; + } else if (strcmp(qualifier->value(), "in") == 0) { + var->mode = ir_var_in; + } else if (strcmp(qualifier->value(), "out") == 0) { + var->mode = ir_var_out; + } else if (strcmp(qualifier->value(), "inout") == 0) { + var->mode = ir_var_inout; + } else if (strcmp(qualifier->value(), "smooth") == 0) { + var->interpolation = ir_var_smooth; + } else if (strcmp(qualifier->value(), "flat") == 0) { + var->interpolation = ir_var_flat; + } else if (strcmp(qualifier->value(), "noperspective") == 0) { + var->interpolation = ir_var_noperspective; + } else { + ir_read_error(list, "unknown qualifier: %s", qualifier->value()); + delete var; + return NULL; + } + } + + // Add the variable to the symbol table + st->symbols->add_variable(var_name->value(), var); + + return var; +} + + static ir_rvalue * read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) { -- cgit v1.2.3 From 9d2ff7617a08fa1dc26c7661e813b0d6cb8acc2b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Apr 2010 17:56:22 -0700 Subject: ir_reader: Add support for reading (return ...) --- ir_reader.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ir_reader.cpp b/ir_reader.cpp index 00fcc9475cc..2289095dfde 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -33,6 +33,7 @@ static glsl_type *read_type(_mesa_glsl_parse_state *, s_expression *); static ir_instruction *read_instruction(_mesa_glsl_parse_state *, s_expression *); static ir_variable *read_declaration(_mesa_glsl_parse_state *, s_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 *); @@ -143,6 +144,8 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr) ir_instruction *inst = NULL; if (strcmp(tag->value(), "declare") == 0) inst = read_declaration(st, list); + else if (strcmp(tag->value(), "return") == 0) + inst = read_return(st, list); else ir_read_error(expr, "unrecognized instruction tag: %s", tag->value()); @@ -220,6 +223,26 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) } +static ir_return * +read_return(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 2) { + ir_read_error(list, "expected (return )"); + return NULL; + } + + s_expression *expr = (s_expression*) list->subexpressions.head->next; + + ir_rvalue *retval = read_rvalue(st, expr); + if (retval == NULL) { + ir_read_error(list, "when reading return value"); + return NULL; + } + + return new ir_return(retval); +} + + static ir_rvalue * read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) { -- cgit v1.2.3 From 57944975427769b08e00f274ff4d9a3e9849a5a2 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 10 Apr 2010 01:06:44 -0700 Subject: ir_reader: Add support for reading array types. Also, constify glsl_type pointers; this was necessary to use glsl_type::get_array_instance. --- ir_reader.cpp | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 2289095dfde..d0c7c7080f8 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -28,7 +28,7 @@ #include "s_expression.h" static void ir_read_error(s_expression *expr, const char *fmt, ...); -static glsl_type *read_type(_mesa_glsl_parse_state *, s_expression *); +static const glsl_type *read_type(_mesa_glsl_parse_state *, s_expression *); static ir_instruction *read_instruction(_mesa_glsl_parse_state *, s_expression *); @@ -98,20 +98,44 @@ ir_read_error(s_expression *expr, const char *fmt, ...) printf("%s\n", buf); } -static glsl_type * +static const glsl_type * read_type(_mesa_glsl_parse_state *st, 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(expr, "expected type (array (...)) or (struct (...))"); + ir_read_error(expr, "expected type (array ...) or (struct ...)"); return NULL; } - if (strcmp(type_sym->value(), "array") == 0) - assert(false); // FINISHME - if (strcmp(type_sym->value(), "struct") == 0) + if (strcmp(type_sym->value(), "array") == 0) { + if (list->length() != 3) { + ir_read_error(expr, "expected type (array )"); + 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(expr, "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(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(expr, "expected (array ...) or (struct ...); found (%s ...)", type_sym->value()); + return NULL; + } } s_symbol *type_sym = SX_AS_SYMBOL(expr); @@ -120,7 +144,7 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) return NULL; } - glsl_type *type = st->symbols->get_type(type_sym->value()); + const glsl_type *type = st->symbols->get_type(type_sym->value()); if (type == NULL) ir_read_error(expr, "invalid type: %s", type_sym->value()); @@ -168,7 +192,7 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) } s_expression *type_expr = (s_expression*) quals->next; - glsl_type *type = read_type(st, type_expr); + const glsl_type *type = read_type(st, type_expr); if (type == NULL) return NULL; @@ -319,7 +343,7 @@ read_expression(_mesa_glsl_parse_state *st, s_list *list) } s_expression *type_expr = (s_expression*) list->subexpressions.head->next; - glsl_type *type = read_type(st, type_expr); + const glsl_type *type = read_type(st, type_expr); if (type == NULL) return NULL; @@ -414,7 +438,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) } s_expression *type_expr = (s_expression*) list->subexpressions.head->next; - glsl_type *type = read_type(st, type_expr); + const glsl_type *type = read_type(st, type_expr); if (type == NULL) return NULL; -- cgit v1.2.3 From 3ea0582803ea3070a1856455137daef9ddd86cb9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 10 Apr 2010 01:45:08 -0700 Subject: ir_reader: Add support for reading conditionals: (if ...) --- ir_reader.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 18 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index d0c7c7080f8..0c41fb17621 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -30,9 +30,12 @@ static void ir_read_error(s_expression *expr, const char *fmt, ...); static const glsl_type *read_type(_mesa_glsl_parse_state *, s_expression *); +static void read_instructions(_mesa_glsl_parse_state *, exec_list *, + s_expression *); static ir_instruction *read_instruction(_mesa_glsl_parse_state *, s_expression *); static ir_variable *read_declaration(_mesa_glsl_parse_state *, s_list *); +static ir_if *read_if(_mesa_glsl_parse_state *, s_list *); static ir_return *read_return(_mesa_glsl_parse_state *, s_list *); static ir_rvalue *read_rvalue(_mesa_glsl_parse_state *, s_expression *); @@ -60,24 +63,7 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, _mesa_glsl_initialize_constructors(instructions, state); _mesa_glsl_initialize_functions(instructions, state); - // Read in a list of instructions - s_list *list = SX_AS_LIST(expr); - if (list == NULL) { - ir_read_error(expr, "Expected ( ...); found an atom."); - state->error = true; - return; - } - - foreach_iter(exec_list_iterator, it, list->subexpressions) { - s_expression *sub = (s_expression*) it.get(); - ir_instruction *ir = read_instruction(state, sub); - if (ir == NULL) { - ir_read_error(sub, "Invalid instruction.\n"); - state->error = true; - return; - } - instructions->push_tail(ir); - } + read_instructions(state, instructions, expr); } static void @@ -152,6 +138,31 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) } +static void +read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions, + s_expression *expr) +{ + // Read in a list of instructions + s_list *list = SX_AS_LIST(expr); + if (list == NULL) { + ir_read_error(expr, "Expected ( ...); found an atom."); + st->error = true; + return; + } + + foreach_iter(exec_list_iterator, it, list->subexpressions) { + s_expression *sub = (s_expression*) it.get(); + ir_instruction *ir = read_instruction(st, sub); + if (ir == NULL) { + ir_read_error(sub, "Invalid instruction.\n"); + st->error = true; + return; + } + instructions->push_tail(ir); + } +} + + static ir_instruction * read_instruction(_mesa_glsl_parse_state *st, s_expression *expr) { @@ -168,6 +179,8 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr) ir_instruction *inst = NULL; if (strcmp(tag->value(), "declare") == 0) inst = read_declaration(st, list); + else if (strcmp(tag->value(), "if") == 0) + inst = read_if(st, list); else if (strcmp(tag->value(), "return") == 0) inst = read_return(st, list); else @@ -247,6 +260,37 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) } +static ir_if * +read_if(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 4) { + ir_read_error(list, "expected (if ( ...) " + "( ...))"); + return NULL; + } + + s_expression *cond_expr = (s_expression*) list->subexpressions.head->next; + ir_rvalue *condition = read_rvalue(st, cond_expr); + if (condition == NULL) { + ir_read_error(list, "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 ir_if(condition); + + read_instructions(st, &iff->then_instructions, then_expr); + read_instructions(st, &iff->else_instructions, else_expr); + if (st->error) { + delete iff; + iff = NULL; + } + return iff; +} + + static ir_return * read_return(_mesa_glsl_parse_state *st, s_list *list) { -- cgit v1.2.3 From 46ef8f19d76b33446c2ce6e7f1379bd348fe7fe4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 12 Apr 2010 14:25:41 -0700 Subject: ir_reader: rvalues are instructions too! --- ir_reader.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 0c41fb17621..9eadce21195 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -177,15 +177,17 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr) } ir_instruction *inst = NULL; - if (strcmp(tag->value(), "declare") == 0) + if (strcmp(tag->value(), "declare") == 0) { inst = read_declaration(st, list); - else if (strcmp(tag->value(), "if") == 0) + } else if (strcmp(tag->value(), "if") == 0) { inst = read_if(st, list); - else if (strcmp(tag->value(), "return") == 0) + } else if (strcmp(tag->value(), "return") == 0) { inst = read_return(st, list); - else - ir_read_error(expr, "unrecognized instruction tag: %s", tag->value()); - + } else { + inst = read_rvalue(st, list); + if (inst == NULL) + ir_read_error(list, "when reading instruction"); + } return inst; } -- cgit v1.2.3 From 451381c220f145ac27a177c955dde30a9618fd00 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 12 Apr 2010 14:27:39 -0700 Subject: ir_reader: Add support for reading (var_ref ...) and (array_ref ...) --- ir_reader.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 6 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 9eadce21195..ee849a8c919 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -43,6 +43,9 @@ static ir_assignment *read_assignment(_mesa_glsl_parse_state *, s_list *); static ir_expression *read_expression(_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_dereference *read_var_ref(_mesa_glsl_parse_state *, s_list *); +static ir_dereference *read_array_ref(_mesa_glsl_parse_state *, s_list *); +static ir_dereference *read_record_ref(_mesa_glsl_parse_state *, s_list *); void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, @@ -327,18 +330,24 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) } ir_rvalue *rvalue = NULL; - if (strcmp(tag->value(), "swiz") == 0) + if (strcmp(tag->value(), "swiz") == 0) { rvalue = read_swizzle(st, list); - else if (strcmp(tag->value(), "assign") == 0) + } else if (strcmp(tag->value(), "assign") == 0) { rvalue = read_assignment(st, list); - else if (strcmp(tag->value(), "expression") == 0) + } else if (strcmp(tag->value(), "expression") == 0) { rvalue = read_expression(st, list); // FINISHME: ir_call - // FINISHME: dereference - else if (strcmp(tag->value(), "constant") == 0) + } else if (strcmp(tag->value(), "constant") == 0) { rvalue = read_constant(st, list); - else + } else if (strcmp(tag->value(), "var_ref") == 0) { + rvalue = read_var_ref(st, list); + } else if (strcmp(tag->value(), "array_ref") == 0) { + rvalue = read_array_ref(st, list); + } else if (strcmp(tag->value(), "record_ref") == 0) { + rvalue = read_record_ref(st, list); + } else { ir_read_error(expr, "unrecognized rvalue tag: %s", tag->value()); + } return rvalue; } @@ -557,3 +566,67 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) } return NULL; // should not be reached } + +static ir_instruction * +read_dereferencable(_mesa_glsl_parse_state *st, s_expression *expr) +{ + // Read the subject of a dereference - either a variable name or a swizzle + s_symbol *var_name = SX_AS_SYMBOL(expr); + if (var_name != NULL) { + ir_variable *var = st->symbols->get_variable(var_name->value()); + if (var == NULL) { + ir_read_error(expr, "undeclared variable: %s", var_name->value()); + } + return var; + } else { + // Hopefully a (swiz ...) + s_list *list = SX_AS_LIST(expr); + if (list != NULL && !list->subexpressions.is_empty()) { + s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head); + if (tag != NULL && strcmp(tag->value(), "swiz") == 0) + return read_swizzle(st, list); + } + } + ir_read_error(expr, "expected variable name or (swiz ...)"); + return NULL; +} + +static ir_dereference * +read_var_ref(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 2) { + ir_read_error(list, "expected (var_ref )"); + return NULL; + } + s_expression *subj_expr = (s_expression*) list->subexpressions.head->next; + ir_instruction *subject = read_dereferencable(st, subj_expr); + if (subject == NULL) + return NULL; + return new ir_dereference(subject); +} + +static ir_dereference * +read_array_ref(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 3) { + ir_read_error(list, "expected (array_ref " + ")"); + return NULL; + } + + s_expression *subj_expr = (s_expression*) list->subexpressions.head->next; + ir_instruction *subject = read_dereferencable(st, subj_expr); + if (subject == NULL) + return NULL; + + s_expression *idx_expr = (s_expression*) subj_expr->next; + ir_rvalue *idx = read_rvalue(st, idx_expr); + return new ir_dereference(subject, idx); +} + +static ir_dereference * +read_record_ref(_mesa_glsl_parse_state *st, s_list *list) +{ + ir_read_error(list, "FINISHME: record refs not yet supported."); + return NULL; +} -- cgit v1.2.3 From 32b305207cca7d8a084473f82f340e4b2fe188fa Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 12 Apr 2010 15:48:27 -0700 Subject: ir_reader: Add initial loop support; doesn't yet support break/continue. --- ir_reader.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ir_reader.cpp b/ir_reader.cpp index ee849a8c919..f7662700a6c 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -36,6 +36,7 @@ static ir_instruction *read_instruction(_mesa_glsl_parse_state *, s_expression *); static ir_variable *read_declaration(_mesa_glsl_parse_state *, s_list *); static ir_if *read_if(_mesa_glsl_parse_state *, s_list *); +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 *); @@ -184,6 +185,8 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr) inst = read_declaration(st, list); } else if (strcmp(tag->value(), "if") == 0) { inst = read_if(st, list); + } else if (strcmp(tag->value(), "loop") == 0) { + inst = read_loop(st, list); } else if (strcmp(tag->value(), "return") == 0) { inst = read_return(st, list); } else { @@ -296,6 +299,33 @@ read_if(_mesa_glsl_parse_state *st, s_list *list) } +static ir_loop * +read_loop(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 6) { + ir_read_error(list, "expected (loop " + ")"); + 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 ir_loop; + read_instructions(st, &loop->body_instructions, body_expr); + if (st->error) { + delete loop; + loop = NULL; + } + return loop; +} + + static ir_return * read_return(_mesa_glsl_parse_state *st, s_list *list) { -- cgit v1.2.3 From 396fa9eba65a764a475a1ff186a94f1a4038af8a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 12 Apr 2010 16:02:48 -0700 Subject: ir_reader: Add support for "break" and "continue" in loops. Includes threading the ir_loop * context through various functions. --- ir_reader.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index f7662700a6c..f723c0aa8c8 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -31,11 +31,11 @@ static void ir_read_error(s_expression *expr, const char *fmt, ...); static const glsl_type *read_type(_mesa_glsl_parse_state *, s_expression *); static void read_instructions(_mesa_glsl_parse_state *, exec_list *, - s_expression *); + s_expression *, ir_loop *); static ir_instruction *read_instruction(_mesa_glsl_parse_state *, - s_expression *); + 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 *); +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 *); @@ -67,7 +67,7 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, _mesa_glsl_initialize_constructors(instructions, state); _mesa_glsl_initialize_functions(instructions, state); - read_instructions(state, instructions, expr); + read_instructions(state, instructions, expr, NULL); } static void @@ -144,7 +144,7 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) static void read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions, - s_expression *expr) + s_expression *expr, ir_loop *loop_ctx) { // Read in a list of instructions s_list *list = SX_AS_LIST(expr); @@ -156,7 +156,7 @@ read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions, foreach_iter(exec_list_iterator, it, list->subexpressions) { s_expression *sub = (s_expression*) it.get(); - ir_instruction *ir = read_instruction(st, sub); + ir_instruction *ir = read_instruction(st, sub, loop_ctx); if (ir == NULL) { ir_read_error(sub, "Invalid instruction.\n"); st->error = true; @@ -168,8 +168,17 @@ read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions, static ir_instruction * -read_instruction(_mesa_glsl_parse_state *st, s_expression *expr) +read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, + ir_loop *loop_ctx) { + s_symbol *symbol = SX_AS_SYMBOL(expr); + if (symbol != NULL) { + if (strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL) + return new ir_loop_jump(loop_ctx, ir_loop_jump::jump_break); + if (strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL) + return new ir_loop_jump(loop_ctx, ir_loop_jump::jump_continue); + } + s_list *list = SX_AS_LIST(expr); if (list == NULL || list->subexpressions.is_empty()) return NULL; @@ -184,7 +193,7 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr) if (strcmp(tag->value(), "declare") == 0) { inst = read_declaration(st, list); } else if (strcmp(tag->value(), "if") == 0) { - inst = read_if(st, list); + inst = read_if(st, list, loop_ctx); } else if (strcmp(tag->value(), "loop") == 0) { inst = read_loop(st, list); } else if (strcmp(tag->value(), "return") == 0) { @@ -269,7 +278,7 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) static ir_if * -read_if(_mesa_glsl_parse_state *st, s_list *list) +read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx) { if (list->length() != 4) { ir_read_error(list, "expected (if ( ...) " @@ -289,8 +298,8 @@ read_if(_mesa_glsl_parse_state *st, s_list *list) ir_if *iff = new ir_if(condition); - read_instructions(st, &iff->then_instructions, then_expr); - read_instructions(st, &iff->else_instructions, else_expr); + read_instructions(st, &iff->then_instructions, then_expr, loop_ctx); + read_instructions(st, &iff->else_instructions, else_expr, loop_ctx); if (st->error) { delete iff; iff = NULL; @@ -317,7 +326,7 @@ read_loop(_mesa_glsl_parse_state *st, s_list *list) // FINISHME: actually read the count/from/to fields. ir_loop *loop = new ir_loop; - read_instructions(st, &loop->body_instructions, body_expr); + read_instructions(st, &loop->body_instructions, body_expr, loop); if (st->error) { delete loop; loop = NULL; -- cgit v1.2.3 From 4ec982fb86ae2476508d2027464241489243a170 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 15:47:34 -0700 Subject: Make ir_read_error set state->error. --- ir_reader.cpp | 120 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 58 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index f723c0aa8c8..8e470e95d26 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -27,7 +27,8 @@ #include "glsl_types.h" #include "s_expression.h" -static void ir_read_error(s_expression *expr, const char *fmt, ...); +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 read_instructions(_mesa_glsl_parse_state *, exec_list *, @@ -54,8 +55,7 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, { s_expression *expr = s_expression::read_expression(src); if (expr == NULL) { - ir_read_error(NULL, "couldn't parse S-Expression."); - state->error = true; + ir_read_error(state, NULL, "couldn't parse S-Expression."); return; } printf("S-Expression:\n"); @@ -71,13 +71,14 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, } static void -ir_read_error(s_expression *expr, const char *fmt, ...) +ir_read_error(_mesa_glsl_parse_state *state, s_expression *expr, + const char *fmt, ...) { char buf[1024]; int len; va_list ap; - // FIXME: state->error = true; + state->error = true; len = snprintf(buf, sizeof(buf), "error: "); @@ -95,12 +96,12 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) if (list != NULL) { s_symbol *type_sym = SX_AS_SYMBOL(list->subexpressions.get_head()); if (type_sym == NULL) { - ir_read_error(expr, "expected type (array ...) or (struct ...)"); + ir_read_error(st, expr, "expected type (array ...) or (struct ...)"); return NULL; } if (strcmp(type_sym->value(), "array") == 0) { if (list->length() != 3) { - ir_read_error(expr, "expected type (array )"); + ir_read_error(st, expr, "expected type (array )"); return NULL; } @@ -108,14 +109,14 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) 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(expr, "when reading base type of array"); + ir_read_error(st, expr, "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(expr, "found non-integer array size"); + ir_read_error(st, expr, "found non-integer array size"); return NULL; } @@ -123,20 +124,21 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) } else if (strcmp(type_sym->value(), "struct") == 0) { assert(false); // FINISHME } else { - ir_read_error(expr, "expected (array ...) or (struct ...); found (%s ...)", type_sym->value()); + ir_read_error(st, expr, "expected (array ...) or (struct ...); " + "found (%s ...)", type_sym->value()); return NULL; } } s_symbol *type_sym = SX_AS_SYMBOL(expr); if (type_sym == NULL) { - ir_read_error(expr, "expected (symbol or list)"); + ir_read_error(st, expr, "expected (symbol or list)"); return NULL; } const glsl_type *type = st->symbols->get_type(type_sym->value()); if (type == NULL) - ir_read_error(expr, "invalid type: %s", type_sym->value()); + ir_read_error(st, expr, "invalid type: %s", type_sym->value()); return type; } @@ -149,8 +151,7 @@ read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions, // Read in a list of instructions s_list *list = SX_AS_LIST(expr); if (list == NULL) { - ir_read_error(expr, "Expected ( ...); found an atom."); - st->error = true; + ir_read_error(st, expr, "Expected ( ...); found an atom."); return; } @@ -158,8 +159,7 @@ read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions, s_expression *sub = (s_expression*) it.get(); ir_instruction *ir = read_instruction(st, sub, loop_ctx); if (ir == NULL) { - ir_read_error(sub, "Invalid instruction.\n"); - st->error = true; + ir_read_error(st, sub, "Invalid instruction.\n"); return; } instructions->push_tail(ir); @@ -185,7 +185,7 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head()); if (tag == NULL) { - ir_read_error(expr, "expected instruction tag"); + ir_read_error(st, expr, "expected instruction tag"); return NULL; } @@ -201,7 +201,7 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, } else { inst = read_rvalue(st, list); if (inst == NULL) - ir_read_error(list, "when reading instruction"); + ir_read_error(st, list, "when reading instruction"); } return inst; } @@ -211,13 +211,14 @@ static ir_variable * read_declaration(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 4) { - ir_read_error(list, "expected (declare () )"); + ir_read_error(st, list, "expected (declare () " + ")"); return NULL; } s_list *quals = SX_AS_LIST(list->subexpressions.head->next); if (quals == NULL) { - ir_read_error(list, "expected a list of variable qualifiers"); + ir_read_error(st, list, "expected a list of variable qualifiers"); return NULL; } @@ -228,7 +229,7 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) s_symbol *var_name = SX_AS_SYMBOL(type_expr->next); if (var_name == NULL) { - ir_read_error(list, "expected variable name, found non-symbol"); + ir_read_error(st, list, "expected variable name, found non-symbol"); return NULL; } @@ -237,7 +238,7 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) foreach_iter(exec_list_iterator, it, quals->subexpressions) { s_symbol *qualifier = SX_AS_SYMBOL(it.get()); if (qualifier == NULL) { - ir_read_error(list, "qualifier list must contain only symbols"); + ir_read_error(st, list, "qualifier list must contain only symbols"); delete var; return NULL; } @@ -264,7 +265,7 @@ 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(list, "unknown qualifier: %s", qualifier->value()); + ir_read_error(st, list, "unknown qualifier: %s", qualifier->value()); delete var; return NULL; } @@ -281,7 +282,7 @@ static ir_if * read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx) { if (list->length() != 4) { - ir_read_error(list, "expected (if ( ...) " + ir_read_error(st, list, "expected (if ( ...) " "( ...))"); return NULL; } @@ -289,7 +290,7 @@ read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx) s_expression *cond_expr = (s_expression*) list->subexpressions.head->next; ir_rvalue *condition = read_rvalue(st, cond_expr); if (condition == NULL) { - ir_read_error(list, "when reading condition of (if ...)"); + ir_read_error(st, list, "when reading condition of (if ...)"); return NULL; } @@ -312,8 +313,8 @@ static ir_loop * read_loop(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 6) { - ir_read_error(list, "expected (loop " - ")"); + ir_read_error(st, list, "expected (loop " + " )"); return NULL; } @@ -339,7 +340,7 @@ static ir_return * read_return(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 2) { - ir_read_error(list, "expected (return )"); + ir_read_error(st, list, "expected (return )"); return NULL; } @@ -347,7 +348,7 @@ read_return(_mesa_glsl_parse_state *st, s_list *list) ir_rvalue *retval = read_rvalue(st, expr); if (retval == NULL) { - ir_read_error(list, "when reading return value"); + ir_read_error(st, list, "when reading return value"); return NULL; } @@ -364,7 +365,7 @@ 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(expr, "expected rvalue tag"); + ir_read_error(st, expr, "expected rvalue tag"); return NULL; } @@ -385,7 +386,7 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) } else if (strcmp(tag->value(), "record_ref") == 0) { rvalue = read_record_ref(st, list); } else { - ir_read_error(expr, "unrecognized rvalue tag: %s", tag->value()); + ir_read_error(st, expr, "unrecognized rvalue tag: %s", tag->value()); } return rvalue; @@ -395,7 +396,7 @@ static ir_assignment * read_assignment(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 4) { - ir_read_error(list, "expected (assign )"); + ir_read_error(st, list, "expected (assign )"); return NULL; } @@ -406,19 +407,19 @@ read_assignment(_mesa_glsl_parse_state *st, s_list *list) // FINISHME: Deal with "true" condition ir_rvalue *condition = read_rvalue(st, cond_expr); if (condition == NULL) { - ir_read_error(list, "when reading condition of assignment"); + ir_read_error(st, list, "when reading condition of assignment"); return NULL; } ir_rvalue *lhs = read_rvalue(st, lhs_expr); if (lhs == NULL) { - ir_read_error(list, "when reading left-hand side of assignment"); + ir_read_error(st, list, "when reading left-hand side of assignment"); return NULL; } ir_rvalue *rhs = read_rvalue(st, rhs_expr); if (rhs == NULL) { - ir_read_error(list, "when reading right-hand side of assignment"); + ir_read_error(st, list, "when reading right-hand side of assignment"); return NULL; } @@ -431,8 +432,8 @@ read_expression(_mesa_glsl_parse_state *st, s_list *list) { const unsigned list_length = list->length(); if (list_length < 4) { - ir_read_error(list, "expected (expression " - "[])"); + ir_read_error(st, list, "expected (expression " + " [])"); return NULL; } @@ -444,26 +445,26 @@ read_expression(_mesa_glsl_parse_state *st, s_list *list) /* Read the operator */ s_symbol *op_sym = SX_AS_SYMBOL(type_expr->next); if (op_sym == NULL) { - ir_read_error(list, "expected operator, found non-symbol"); + ir_read_error(st, list, "expected operator, found non-symbol"); return NULL; } ir_expression_operation op = ir_expression::get_operator(op_sym->value()); if (op == (ir_expression_operation) -1) { - ir_read_error(list, "invalid operator: %s", op_sym->value()); + ir_read_error(st, list, "invalid operator: %s", op_sym->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(list, "expected (expression %s )", + ir_read_error(st, list, "expected (expression %s )", op_sym->value()); return NULL; } } else { if (list_length != 4) { - ir_read_error(list, "expected (expression %s )", + ir_read_error(st, list, "expected (expression %s )", op_sym->value()); return NULL; } @@ -472,7 +473,8 @@ read_expression(_mesa_glsl_parse_state *st, s_list *list) s_expression *exp1 = (s_expression*) (op_sym->next); ir_rvalue *arg1 = read_rvalue(st, exp1); if (arg1 == NULL) { - ir_read_error(list, "when reading first operand of %s", op_sym->value()); + ir_read_error(st, list, "when reading first operand of %s", + op_sym->value()); return NULL; } @@ -481,7 +483,7 @@ read_expression(_mesa_glsl_parse_state *st, s_list *list) s_expression *exp2 = (s_expression*) (exp1->next); arg2 = read_rvalue(st, exp2); if (arg2 == NULL) { - ir_read_error(list, "when reading second operand of %s", + ir_read_error(st, list, "when reading second operand of %s", op_sym->value()); return NULL; } @@ -494,25 +496,27 @@ static ir_swizzle * read_swizzle(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 3) { - ir_read_error(list, "expected (swiz )"); + ir_read_error(st, list, "expected (swiz )"); return NULL; } s_symbol *swiz = SX_AS_SYMBOL(list->subexpressions.head->next); if (swiz == NULL) { - ir_read_error(list, "expected a valid swizzle; found non-symbol"); + ir_read_error(st, list, "expected a valid swizzle; found non-symbol"); return NULL; } unsigned num_components = strlen(swiz->value()); if (num_components > 4) { - ir_read_error(list, "expected a valid swizzle; found %s", swiz->value()); + ir_read_error(st, list, "expected a valid swizzle; found %s", + swiz->value()); return NULL; } s_expression *sub = (s_expression*) swiz->next; if (sub == NULL) { - ir_read_error(list, "expected rvalue: (swizzle %s )", swiz->value()); + ir_read_error(st, list, "expected rvalue: (swizzle %s )", + swiz->value()); return NULL; } @@ -527,7 +531,7 @@ static ir_constant * read_constant(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 3) { - ir_read_error(list, "expected (constant ( ... ))"); + ir_read_error(st, list, "expected (constant ( ... ))"); return NULL; } @@ -538,7 +542,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) s_list *values = SX_AS_LIST(type_expr->next); if (values == NULL) { - ir_read_error(list, "expected (constant ( ... ))"); + ir_read_error(st, list, "expected (constant ( ... ))"); return NULL; } @@ -553,7 +557,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(values, "expected at most 16 numbers"); + ir_read_error(st, values, "expected at most 16 numbers"); return NULL; } @@ -562,14 +566,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(values, "expected numbers"); + ir_read_error(st, values, "expected numbers"); return NULL; } f[k] = value->fvalue(); } else { s_int *value = SX_AS_INT(expr); if (value == NULL) { - ir_read_error(values, "expected integers"); + ir_read_error(st, values, "expected integers"); return NULL; } @@ -587,7 +591,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) break; } default: - ir_read_error(values, "unsupported constant type"); + ir_read_error(st, values, "unsupported constant type"); return NULL; } } @@ -614,7 +618,7 @@ read_dereferencable(_mesa_glsl_parse_state *st, s_expression *expr) if (var_name != NULL) { ir_variable *var = st->symbols->get_variable(var_name->value()); if (var == NULL) { - ir_read_error(expr, "undeclared variable: %s", var_name->value()); + ir_read_error(st, expr, "undeclared variable: %s", var_name->value()); } return var; } else { @@ -626,7 +630,7 @@ read_dereferencable(_mesa_glsl_parse_state *st, s_expression *expr) return read_swizzle(st, list); } } - ir_read_error(expr, "expected variable name or (swiz ...)"); + ir_read_error(st, expr, "expected variable name or (swiz ...)"); return NULL; } @@ -634,7 +638,7 @@ static ir_dereference * read_var_ref(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 2) { - ir_read_error(list, "expected (var_ref )"); + ir_read_error(st, list, "expected (var_ref )"); return NULL; } s_expression *subj_expr = (s_expression*) list->subexpressions.head->next; @@ -648,7 +652,7 @@ static ir_dereference * read_array_ref(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 3) { - ir_read_error(list, "expected (array_ref " + ir_read_error(st, list, "expected (array_ref " ")"); return NULL; } @@ -666,6 +670,6 @@ read_array_ref(_mesa_glsl_parse_state *st, s_list *list) static ir_dereference * read_record_ref(_mesa_glsl_parse_state *st, s_list *list) { - ir_read_error(list, "FINISHME: record refs not yet supported."); + ir_read_error(st, list, "FINISHME: record refs not yet supported."); return NULL; } -- cgit v1.2.3 From ddf5a011e2c4c9fd65d5d08aaaa284759fcd2f6e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 17:50:16 -0700 Subject: ir_reader: Don't initialize globals, builtins, or constructors. All of these are currently emitted as part of the IR, so by initializing them, we actually end up with two copies. For constructors, we may eventually wish to avoid emitting them as part of the IR output. --- ir_reader.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 8e470e95d26..eb7b7fcb6b3 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -63,9 +63,11 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, printf("\n-------------\n"); _mesa_glsl_initialize_types(state); - _mesa_glsl_initialize_variables(instructions, state); - _mesa_glsl_initialize_constructors(instructions, state); - _mesa_glsl_initialize_functions(instructions, state); + + /* FINISHME: Constructors probably shouldn't be emitted as part of the IR. + * FINISHME: Once they're not, remake them by calling: + * FINISHME: _mesa_glsl_initialize_constructors(instructions, state); + */ read_instructions(state, instructions, expr, NULL); } -- cgit v1.2.3 From 09cad1339d8e6eebe5b13d95a9e1d2a1da2fce29 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 17:52:36 -0700 Subject: ir_reader: Perform a preliminary pass to scan for function prototypes. --- ir_reader.cpp | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/ir_reader.cpp b/ir_reader.cpp index eb7b7fcb6b3..e14f5c85796 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -31,6 +31,12 @@ 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 void read_prototypes(_mesa_glsl_parse_state *, exec_list *, s_list *); +static ir_function_signature *read_prototype(_mesa_glsl_parse_state *, + s_list *); + static void read_instructions(_mesa_glsl_parse_state *, exec_list *, s_expression *, ir_loop *); static ir_instruction *read_instruction(_mesa_glsl_parse_state *, @@ -69,6 +75,10 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, * FINISHME: _mesa_glsl_initialize_constructors(instructions, state); */ + scan_for_prototypes(state, instructions, expr); + if (state->error) + return; + read_instructions(state, instructions, expr, NULL); } @@ -146,6 +156,122 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) } +static void +scan_for_prototypes(_mesa_glsl_parse_state *st, exec_list *instructions, + s_expression *expr) +{ + s_list *list = SX_AS_LIST(expr); + if (list == NULL) { + ir_read_error(st, expr, "Expected ( ...); found an atom."); + return; + } + + foreach_iter(exec_list_iterator, it, list->subexpressions) { + s_list *sub = SX_AS_LIST(it.get()); + if (sub == NULL) + continue; // not a (function ...); ignore it. + + s_symbol *tag = SX_AS_SYMBOL(sub->subexpressions.get_head()); + if (tag == NULL || strcmp(tag->value(), "function") != 0) + continue; // not a (function ...); ignore it. + + read_prototypes(st, instructions, sub); + if (st->error) + return; + } +} + +static void +read_prototypes(_mesa_glsl_parse_state *st, exec_list *instructions, + s_list *list) +{ + if (list->length() < 3) { + ir_read_error(st, list, "Expected (function (signature ...) ...)"); + return; + } + + s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next); + if (name == NULL) { + ir_read_error(st, list, "Expected (function ...)"); + return; + } + + ir_function *f = new ir_function(name->value()); + bool added = st->symbols->add_function(name->value(), f); + if (!added) { + ir_read_error(st, list, "Function %s already exists.", name->value()); + return; + } + + instructions->push_tail(f); + + exec_list_iterator it = list->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; + } + + 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; + } + + ir_function_signature *sig = read_prototype(st, siglist); + if (sig == NULL) + return; + + f->add_signature(sig); + } +} + +static ir_function_signature * +read_prototype(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 4) { + ir_read_error(st, list, "Expected (signature (parameters ...) " + "( ...))"); + return NULL; + } + + s_expression *type_expr = (s_expression*) list->subexpressions.head->next; + const glsl_type *return_type = read_type(st, type_expr); + if (return_type == NULL) + return NULL; + + s_list *paramlist = SX_AS_LIST(type_expr->next); + if (paramlist == NULL) { + ir_read_error(st, list, "Expected (signature %s (parameters ...) ...)", + return_type->name); + return NULL; + } + 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 ...)"); + return NULL; + } + + ir_function_signature *sig = new ir_function_signature(return_type); + + 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); + if (var == NULL) { + delete sig; + return NULL; + } + + sig->parameters.push_tail(var); + } + + return sig; +} + static void read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions, s_expression *expr, ir_loop *loop_ctx) -- cgit v1.2.3 From 8df335d7f9ab8b3699c312f2b4b42be2e8eeba27 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 18:14:06 -0700 Subject: ir_reader: Preliminary work toward reading functions. --- ir_reader.cpp | 61 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index e14f5c85796..44fbb33a5d4 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -33,9 +33,10 @@ 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 void read_prototypes(_mesa_glsl_parse_state *, exec_list *, s_list *); -static ir_function_signature *read_prototype(_mesa_glsl_parse_state *, - s_list *); +static ir_function *read_function(_mesa_glsl_parse_state *, s_list *, + bool skip_body); +static ir_function_signature *read_function_sig(_mesa_glsl_parse_state *, + s_list *, bool skip_body); static void read_instructions(_mesa_glsl_parse_state *, exec_list *, s_expression *, ir_loop *); @@ -175,36 +176,34 @@ 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. - read_prototypes(st, instructions, sub); - if (st->error) + ir_function *f = read_function(st, sub, true); + if (f == NULL) return; + instructions->push_tail(f); } } -static void -read_prototypes(_mesa_glsl_parse_state *st, exec_list *instructions, - s_list *list) +static ir_function * +read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) { if (list->length() < 3) { ir_read_error(st, list, "Expected (function (signature ...) ...)"); - return; + return NULL; } s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next); if (name == NULL) { ir_read_error(st, list, "Expected (function ...)"); - return; + return NULL; } - ir_function *f = new ir_function(name->value()); - bool added = st->symbols->add_function(name->value(), f); - if (!added) { - ir_read_error(st, list, "Function %s already exists.", name->value()); - return; + ir_function *f = st->symbols->get_function(name->value()); + if (f == NULL) { + f = new ir_function(name->value()); + bool added = st->symbols->add_function(name->value(), f); + assert(added); } - instructions->push_tail(f); - exec_list_iterator it = list->subexpressions.iterator(); it.next(); // skip "function" tag it.next(); // skip function name @@ -212,25 +211,26 @@ read_prototypes(_mesa_glsl_parse_state *st, exec_list *instructions, s_list *siglist = SX_AS_LIST(it.get()); if (siglist == NULL) { ir_read_error(st, list, "Expected (function (signature ...) ...)"); - return; + 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; + return NULL; } - ir_function_signature *sig = read_prototype(st, siglist); + ir_function_signature *sig = read_function_sig(st, siglist, skip_body); if (sig == NULL) - return; + return NULL; f->add_signature(sig); } + return f; } static ir_function_signature * -read_prototype(_mesa_glsl_parse_state *st, s_list *list) +read_function_sig(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) { if (list->length() != 4) { ir_read_error(st, list, "Expected (signature (parameters ...) " @@ -244,9 +244,10 @@ read_prototype(_mesa_glsl_parse_state *st, s_list *list) return NULL; s_list *paramlist = SX_AS_LIST(type_expr->next); - if (paramlist == NULL) { - ir_read_error(st, list, "Expected (signature %s (parameters ...) ...)", - return_type->name); + s_list *body_list = SX_AS_LIST(paramlist->next); + if (paramlist == NULL || body_list == NULL) { + ir_read_error(st, list, "Expected (signature (parameters ...) " + "( ...))"); return NULL; } s_symbol *paramtag = SX_AS_SYMBOL(paramlist->subexpressions.get_head()); @@ -255,8 +256,11 @@ read_prototype(_mesa_glsl_parse_state *st, s_list *list) return NULL; } + // FINISHME: Don't create a new one! Look for the existing prototype first ir_function_signature *sig = new ir_function_signature(return_type); + st->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()); @@ -269,6 +273,11 @@ read_prototype(_mesa_glsl_parse_state *st, s_list *list) sig->parameters.push_tail(var); } + if (!skip_body) + read_instructions(st, &sig->body, body_list, NULL); + + st->symbols->pop_scope(); + return sig; } @@ -326,6 +335,8 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, inst = read_loop(st, list); } else if (strcmp(tag->value(), "return") == 0) { inst = read_return(st, list); + } else if (strcmp(tag->value(), "function") == 0) { + inst = read_function(st, list, false); } else { inst = read_rvalue(st, list); if (inst == NULL) -- cgit v1.2.3 From 951632253f4f37ce058e2466bca5b96bb43ccfbf Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 23:15:08 -0700 Subject: ir_reader: Fix for swizzles. --- ir_reader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 44fbb33a5d4..976af2ab128 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -645,8 +645,7 @@ read_swizzle(_mesa_glsl_parse_state *st, s_list *list) return NULL; } - unsigned num_components = strlen(swiz->value()); - if (num_components > 4) { + if (strlen(swiz->value()) > 4) { ir_read_error(st, list, "expected a valid swizzle; found %s", swiz->value()); return NULL; @@ -663,7 +662,8 @@ read_swizzle(_mesa_glsl_parse_state *st, s_list *list) if (rvalue == NULL) return NULL; - return ir_swizzle::create(rvalue, swiz->value(), num_components); + return ir_swizzle::create(rvalue, swiz->value(), + rvalue->type->vector_elements); } static ir_constant * -- cgit v1.2.3 From 46a223224c55eaed7bf634d901f733098e674457 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 23:23:23 -0700 Subject: Make ir_read_error print out the given S-Expression, for context. --- ir_reader.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 976af2ab128..74fe5faaf67 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -87,19 +87,22 @@ static void ir_read_error(_mesa_glsl_parse_state *state, s_expression *expr, const char *fmt, ...) { - char buf[1024]; - int len; va_list ap; state->error = true; - len = snprintf(buf, sizeof(buf), "error: "); + printf("error: "); va_start(ap, fmt); - vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); + vprintf(fmt, ap); va_end(ap); + printf("\n"); - printf("%s\n", buf); + if (expr != NULL) { + printf("...in this context:\n "); + expr->print(); + printf("\n\n"); + } } static const glsl_type * @@ -122,7 +125,7 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) 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, expr, "when reading base type of array"); + ir_read_error(st, NULL, "when reading base type of array"); return NULL; } @@ -340,7 +343,7 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, } else { inst = read_rvalue(st, list); if (inst == NULL) - ir_read_error(st, list, "when reading instruction"); + ir_read_error(st, NULL, "when reading instruction"); } return inst; } @@ -429,7 +432,7 @@ read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx) s_expression *cond_expr = (s_expression*) list->subexpressions.head->next; ir_rvalue *condition = read_rvalue(st, cond_expr); if (condition == NULL) { - ir_read_error(st, list, "when reading condition of (if ...)"); + ir_read_error(st, NULL, "when reading condition of (if ...)"); return NULL; } @@ -487,7 +490,7 @@ read_return(_mesa_glsl_parse_state *st, s_list *list) ir_rvalue *retval = read_rvalue(st, expr); if (retval == NULL) { - ir_read_error(st, list, "when reading return value"); + ir_read_error(st, NULL, "when reading return value"); return NULL; } @@ -546,19 +549,19 @@ read_assignment(_mesa_glsl_parse_state *st, s_list *list) // FINISHME: Deal with "true" condition ir_rvalue *condition = read_rvalue(st, cond_expr); if (condition == NULL) { - ir_read_error(st, list, "when reading condition of assignment"); + ir_read_error(st, NULL, "when reading condition of assignment"); return NULL; } ir_rvalue *lhs = read_rvalue(st, lhs_expr); if (lhs == NULL) { - ir_read_error(st, list, "when reading left-hand side of assignment"); + ir_read_error(st, NULL, "when reading left-hand side of assignment"); return NULL; } ir_rvalue *rhs = read_rvalue(st, rhs_expr); if (rhs == NULL) { - ir_read_error(st, list, "when reading right-hand side of assignment"); + ir_read_error(st, NULL, "when reading right-hand side of assignment"); return NULL; } @@ -612,7 +615,7 @@ read_expression(_mesa_glsl_parse_state *st, s_list *list) s_expression *exp1 = (s_expression*) (op_sym->next); ir_rvalue *arg1 = read_rvalue(st, exp1); if (arg1 == NULL) { - ir_read_error(st, list, "when reading first operand of %s", + ir_read_error(st, NULL, "when reading first operand of %s", op_sym->value()); return NULL; } @@ -622,7 +625,7 @@ read_expression(_mesa_glsl_parse_state *st, s_list *list) s_expression *exp2 = (s_expression*) (exp1->next); arg2 = read_rvalue(st, exp2); if (arg2 == NULL) { - ir_read_error(st, list, "when reading second operand of %s", + ir_read_error(st, NULL, "when reading second operand of %s", op_sym->value()); return NULL; } -- cgit v1.2.3 From 21128c23c69d7dc0b46455591899e4850b2029d8 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 23:46:22 -0700 Subject: ir_reader: Fix incorrect error message for expressions. --- ir_reader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 74fe5faaf67..dc1c84fcac1 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -600,13 +600,13 @@ read_expression(_mesa_glsl_parse_state *st, s_list *list) /* 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 %s )", - op_sym->value()); + ir_read_error(st, list, "expected (expression %s " + " )", op_sym->value()); return NULL; } } else { if (list_length != 4) { - ir_read_error(st, list, "expected (expression %s )", + ir_read_error(st, list, "expected (expression %s )", op_sym->value()); return NULL; } -- cgit v1.2.3 From b142aeeb20f1b1d5f3752b973ecb0da61e7a574e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 12:45:18 -0700 Subject: ir_reader: Replace function prototypes with the definition. Previously, we just created a new one, which was wrong. --- ir_reader.cpp | 64 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index dc1c84fcac1..7818147a807 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -35,8 +35,8 @@ 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 ir_function_signature *read_function_sig(_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 *); @@ -223,65 +223,83 @@ read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) return NULL; } - ir_function_signature *sig = read_function_sig(st, siglist, skip_body); - if (sig == NULL) - return NULL; - - f->add_signature(sig); + read_function_sig(st, f, siglist, skip_body); } return f; } -static ir_function_signature * -read_function_sig(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) +static void +read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list, + bool skip_body) { if (list->length() != 4) { ir_read_error(st, list, "Expected (signature (parameters ...) " "( ...))"); - return NULL; + return; } s_expression *type_expr = (s_expression*) list->subexpressions.head->next; const glsl_type *return_type = read_type(st, type_expr); if (return_type == NULL) - return NULL; + return; s_list *paramlist = SX_AS_LIST(type_expr->next); s_list *body_list = SX_AS_LIST(paramlist->next); if (paramlist == NULL || body_list == NULL) { ir_read_error(st, list, "Expected (signature (parameters ...) " "( ...))"); - return NULL; + 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 ...)"); - return NULL; + return; } - // FINISHME: Don't create a new one! Look for the existing prototype first - ir_function_signature *sig = new ir_function_signature(return_type); - + // Read the parameters list into a temporary place. + exec_list hir_parameters; st->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); - if (var == NULL) { - delete sig; - return NULL; + if (var == NULL) + return; + + hir_parameters.push_tail(var); + } + + ir_function_signature *sig = f->exact_matching_signature(&hir_parameters); + if (sig != NULL) { + const char *badvar = sig->qualifiers_match(&hir_parameters); + if (badvar != NULL) { + ir_read_error(st, list, "function `%s' parameter `%s' qualifiers " + "don't match prototype", f->name, badvar); + return; } - sig->parameters.push_tail(var); + if (sig->return_type != return_type) { + ir_read_error(st, list, "function `%s' return type doesn't " + "match prototype", f->name); + return; + } + } else { + sig = new ir_function_signature(return_type); + f->add_signature(sig); } - if (!skip_body) + sig->replace_parameters(&hir_parameters); + + if (!skip_body) { + if (sig->is_defined) { + ir_read_error(st, list, "function %s redefined", f->name); + return; + } read_instructions(st, &sig->body, body_list, NULL); + } st->symbols->pop_scope(); - - return sig; } static void -- cgit v1.2.3 From b51557fbe2b3543cb2e2ed5a3a3637964ca81e17 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 12:54:21 -0700 Subject: ir_reader: Read function calls. --- ir_reader.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 7818147a807..64e7fd1333a 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -50,6 +50,7 @@ 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_dereference *read_var_ref(_mesa_glsl_parse_state *, s_list *); @@ -536,7 +537,8 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) rvalue = read_assignment(st, list); } else if (strcmp(tag->value(), "expression") == 0) { rvalue = read_expression(st, list); - // FINISHME: ir_call + } else if (strcmp(tag->value(), "call") == 0) { + rvalue = read_call(st, list); } else if (strcmp(tag->value(), "constant") == 0) { rvalue = read_constant(st, list); } else if (strcmp(tag->value(), "var_ref") == 0) { @@ -586,6 +588,49 @@ read_assignment(_mesa_glsl_parse_state *st, s_list *list) return new ir_assignment(lhs, rhs, condition); } +static ir_call * +read_call(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 3) { + ir_read_error(st, list, "expected (call ( ...))"); + return NULL; + } + + s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next); + s_list *params = SX_AS_LIST(name->next); + if (name == NULL || params == NULL) { + ir_read_error(st, list, "expected (call ( ...))"); + return NULL; + } + + exec_list parameters; + + foreach_iter(exec_list_iterator, it, params->subexpressions) { + s_expression *expr = (s_expression*) it.get(); + ir_rvalue *param = read_rvalue(st, expr); + if (param == NULL) { + ir_read_error(st, list, "when reading parameter to function call"); + return NULL; + } + parameters.push_tail(param); + } + + ir_function *f = st->symbols->get_function(name->value()); + if (f == NULL) { + ir_read_error(st, list, "found call to undefined function %s", + name->value()); + return NULL; + } + + const ir_function_signature *callee = f->matching_signature(¶meters); + if (callee == NULL) { + ir_read_error(st, list, "couldn't find matching signature for function " + "%s", name->value()); + return NULL; + } + + return new ir_call(callee, ¶meters); +} static ir_expression * read_expression(_mesa_glsl_parse_state *st, s_list *list) -- cgit v1.2.3 From 92eb64cd33555e6bb960aa90d7d84cc9b4d332f8 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 12:58:31 -0700 Subject: ir_reader: Don't print out the S-Expression. It's no longer useful for debugging. --- ir_reader.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 64e7fd1333a..e7625736776 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -66,9 +66,6 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, ir_read_error(state, NULL, "couldn't parse S-Expression."); return; } - printf("S-Expression:\n"); - expr->print(); - printf("\n-------------\n"); _mesa_glsl_initialize_types(state); -- cgit v1.2.3 From bf783ecea69c6b4a3fb5f616e91707cf6d806040 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 13:16:31 -0700 Subject: ir_reader: Slightly better error message when failing to read swizzles. --- ir_reader.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index e7625736776..2c942914aef 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -725,8 +725,12 @@ read_swizzle(_mesa_glsl_parse_state *st, s_list *list) if (rvalue == NULL) return NULL; - return ir_swizzle::create(rvalue, swiz->value(), - rvalue->type->vector_elements); + ir_swizzle *ir = ir_swizzle::create(rvalue, swiz->value(), + rvalue->type->vector_elements); + if (ir == NULL) + ir_read_error(st, list, "invalid swizzle"); + + return ir; } static ir_constant * -- cgit v1.2.3 From 1f959ab4d68ce7c963f9d5f3edc64b457565c291 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 19 Apr 2010 15:11:31 -0700 Subject: Use IDENTIFIER instead of TYPE_NAME for structure names Since there is no track of which names are structure names during parsing, TYPE_NAME cannot be produced by the lexer. Use IDENTIFIER and let the AST processor sort it out. --- glsl_parser.ypp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 250c51c7ee3..131f23d8c1e 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -84,7 +84,7 @@ %token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D %token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY %token STRUCT VOID WHILE -%token IDENTIFIER TYPE_NAME +%token IDENTIFIER %token FLOATCONSTANT %token INTCONSTANT UINTCONSTANT BOOLCONSTANT %token FIELD_SELECTION @@ -941,7 +941,7 @@ type_specifier_nonarray: $$ = new ast_type_specifier($1); $$->set_location(yylloc); } - | TYPE_NAME + | IDENTIFIER { $$ = new ast_type_specifier($1); $$->set_location(yylloc); -- cgit v1.2.3 From 3455ce614424a5a23a23037e23d0454e476bceea Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 19 Apr 2010 15:13:15 -0700 Subject: Begin converting structure definitions to IR --- ast.h | 5 ++++ ast_to_hir.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/ast.h b/ast.h index d899fb1d090..41787f5c1c3 100644 --- a/ast.h +++ b/ast.h @@ -289,6 +289,9 @@ public: ast_struct_specifier(char *identifier, ast_node *declarator_list); virtual void print(void) const; + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + char *name; struct simple_node declarations; }; @@ -378,6 +381,8 @@ public: virtual void print(void) const; + ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); + enum ast_types type_specifier; const char *type_name; diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1dc4ea25b21..2f83dd6597e 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1381,7 +1381,7 @@ ast_type_specifier::glsl_type(const char **name, { const struct glsl_type *type; - if (this->type_specifier == ast_struct) { + if ((this->type_specifier == ast_struct) && (this->type_name == NULL)) { /* FINISHME: Handle annonymous structures. */ type = NULL; } else { @@ -1477,6 +1477,11 @@ ast_declarator_list::hir(exec_list *instructions, const char *type_name = NULL; ir_rvalue *result = NULL; + /* The type specifier may contain a structure definition. Process that + * before any of the variable declarations. + */ + (void) this->type->specifier->hir(instructions, state); + /* FINISHME: Handle vertex shader "invariant" declarations that do not * FINISHME: include a type. These re-declare built-in variables to be * FINISHME: invariant. @@ -2256,3 +2261,78 @@ ast_iteration_statement::hir(exec_list *instructions, */ return NULL; } + + +ir_rvalue * +ast_type_specifier::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + if (this->structure != NULL) + return this->structure->hir(instructions, state); +} + + +ir_rvalue * +ast_struct_specifier::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + simple_node *ptr; + unsigned decl_count = 0; + + /* Make an initial pass over the list of structure fields to determine how + * many there are. Each element in this list is an ast_declarator_list. + * This means that we actually need to count the number of elements in the + * 'declarations' list in each of the elements. + */ + foreach (ptr, & this->declarations) { + ast_declarator_list *decl_list = (ast_declarator_list *) ptr; + simple_node *decl_ptr; + + foreach (decl_ptr, & decl_list->declarations) { + decl_count++; + } + } + + + /* Allocate storage for the structure fields and process the field + * declarations. As the declarations are processed, try to also convert + * the types to HIR. This ensures that structure definitions embedded in + * other structure definitions are processed. + */ + glsl_struct_field *const fields = (glsl_struct_field *) + malloc(sizeof(*fields) * decl_count); + + unsigned i = 0; + foreach (ptr, & this->declarations) { + ast_declarator_list *decl_list = (ast_declarator_list *) ptr; + simple_node *decl_ptr; + const char *type_name; + + decl_list->type->specifier->hir(instructions, state); + + const glsl_type *decl_type = + decl_list->type->specifier->glsl_type(& type_name, state); + + foreach (decl_ptr, & decl_list->declarations) { + ast_declaration *const decl = (ast_declaration *) decl_ptr; + const struct glsl_type *const field_type = + (decl->is_array) + ? process_array_type(decl_type, decl->array_size, state) + : decl_type; + + fields[i].type = field_type; + fields[i].name = decl->identifier; + i++; + } + } + + assert(i == decl_count); + + glsl_type *t = new glsl_type(fields, decl_count, this->name); + + state->symbols->add_type(this->name, t); + + /* Structure type definitions do not have r-values. + */ + return NULL; +} -- cgit v1.2.3 From 8f755dcb67848966c350883ad6fbb50547d9ec24 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 19 Apr 2010 15:40:01 -0700 Subject: Add glsl_type::field_type Query the type of a structure field --- glsl_types.cpp | 15 +++++++++++++++ glsl_types.h | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/glsl_types.cpp b/glsl_types.cpp index b4abfdd7b68..71d7dd36f84 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -657,3 +657,18 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) return t; } + + +const glsl_type * +glsl_type::field_type(const char *name) const +{ + if (this->base_type != GLSL_TYPE_STRUCT) + return error_type; + + for (unsigned i = 0; i < this->length; i++) { + if (strcmp(name, this->fields.structure[i].name) == 0) + return this->fields.structure[i].type; + } + + return error_type; +} diff --git a/glsl_types.h b/glsl_types.h index 2bdfeb8cb60..1f8559aa6a4 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -332,6 +332,17 @@ struct glsl_type { : error_type; } + + /** + * Get the type of a structure field + * + * \return + * Pointer to the type of the named field. If the type is not a structure + * or the named field does not exist, \c glsl_type::error_type is returned. + */ + const glsl_type *field_type(const char *name) const; + + /** * Query the number of elements in an array type * -- cgit v1.2.3 From 7ee79fb6b78012abd0ae8e874a7c64550b1cb707 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 19 Apr 2010 15:40:49 -0700 Subject: Add ir_dereference constructor for structure field dereferences --- ir.cpp | 8 ++++++++ ir.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/ir.cpp b/ir.cpp index 63135e35533..7ada145d53b 100644 --- a/ir.cpp +++ b/ir.cpp @@ -246,6 +246,14 @@ ir_dereference::ir_dereference(ir_instruction *var, this->selector.array_index = array_index; } +ir_dereference::ir_dereference(ir_instruction *variable, const char *field) + : mode(ir_reference_record), var(variable) +{ + this->selector.field = field; + this->type = (var != NULL) + ? var->type->field_type(field) : glsl_type::error_type; +} + bool ir_dereference::is_lvalue() { diff --git a/ir.h b/ir.h index 42e8264d41d..b3fb06d2c7b 100644 --- a/ir.h +++ b/ir.h @@ -749,6 +749,8 @@ public: ir_dereference(ir_instruction *variable, ir_rvalue *array_index); + ir_dereference(ir_instruction *variable, const char *field); + virtual ir_dereference *as_dereference() { return this; -- cgit v1.2.3 From 6efaeeea4489941f4916fda3041c2bf4e22b482e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 19 Apr 2010 15:41:23 -0700 Subject: Convert structure field dereferences to HIR --- hir_field_selection.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 17c3f5c5ba3..685cf75dcf0 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -62,7 +62,13 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, expr->primary_expression.identifier); } } else if (op->type->base_type == GLSL_TYPE_STRUCT) { - /* FINISHME: Handle field selection from structures. */ + result = new ir_dereference(op, expr->primary_expression.identifier); + + if (result->type->is_error()) { + _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " + "structure", + expr->primary_expression.identifier); + } } else { _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " "non-structure / non-vector.", -- cgit v1.2.3 From 1d28b617ba66cfcb1641c9f516146d51aa82b118 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 20 Apr 2010 16:48:24 -0700 Subject: Ensure that anonymous structures have non-NULL names --- ast_to_hir.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 2f83dd6597e..a29a49d98dd 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2328,9 +2328,22 @@ ast_struct_specifier::hir(exec_list *instructions, assert(i == decl_count); - glsl_type *t = new glsl_type(fields, decl_count, this->name); + const char *name; + if (this->name == NULL) { + static unsigned anon_count = 1; + char buf[32]; - state->symbols->add_type(this->name, t); + snprintf(buf, sizeof(buf), "#anon_struct_%04x", anon_count); + anon_count++; + + name = strdup(buf); + } else { + name = this->name; + } + + glsl_type *t = new glsl_type(fields, decl_count, name); + + state->symbols->add_type(name, t); /* Structure type definitions do not have r-values. */ -- cgit v1.2.3 From 73986a7a262807ab2cfd6d46ae17cfc7a30cdfec Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 20 Apr 2010 16:49:03 -0700 Subject: Ensure that structure fields have non-NULL types --- ast_to_hir.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index a29a49d98dd..9b39d1f05b9 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2320,7 +2320,8 @@ ast_struct_specifier::hir(exec_list *instructions, ? process_array_type(decl_type, decl->array_size, state) : decl_type; - fields[i].type = field_type; + fields[i].type = (field_type != NULL) + ? field_type : glsl_type::error_type; fields[i].name = decl->identifier; i++; } -- cgit v1.2.3 From ae000fcb2e47a88d507a616709ae42d4aefae7a0 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 21 Apr 2010 11:54:02 -0700 Subject: Implement structures and arrays in ir_dereference::is_lvalue --- ir.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ir.cpp b/ir.cpp index 7ada145d53b..6778997ac83 100644 --- a/ir.cpp +++ b/ir.cpp @@ -260,22 +260,21 @@ ir_dereference::is_lvalue() if (var == NULL) return false; + ir_variable *const as_var = var->as_variable(); if (mode == ir_reference_variable) { - ir_variable *const as_var = var->as_variable(); if (as_var == NULL) return false; if (as_var->type->is_array() && !as_var->array_lvalue) return false; + } + if (as_var != NULL) return !as_var->read_only; - } else if (mode == ir_reference_array) { - /* FINISHME: Walk up the dereference chain and figure out if - * FINISHME: the variable is read-only. - */ - } - return true; + /* Walk up the dereference chain and figure out if the variable is read-only. + */ + return this->var->as_rvalue()->is_lvalue(); } ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, -- cgit v1.2.3 From 8bec5e92e09c56e893cea33a44b0fb5a2ba1b283 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 21 Apr 2010 12:13:48 -0700 Subject: Support structures in glsl_type::generate_constructor_prototype --- glsl_types.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/glsl_types.cpp b/glsl_types.cpp index 71d7dd36f84..720dce79a1d 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -135,9 +135,6 @@ const glsl_type *glsl_type::get_base_type() const ir_function * glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const { - /* FINISHME: Add support for non-array types. */ - assert(base_type == GLSL_TYPE_ARRAY); - /* Generate the function name and add it to the symbol table. */ ir_function *const f = new ir_function(name); @@ -153,7 +150,9 @@ glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const snprintf(param_name, 10, "p%08X", i); - ir_variable *var = new ir_variable(fields.array, param_name); + ir_variable *var = (this->base_type == GLSL_TYPE_ARRAY) + ? new ir_variable(fields.array, param_name) + : new ir_variable(fields.structure[i].type, param_name); var->mode = ir_var_in; sig->parameters.push_tail(var); -- cgit v1.2.3 From 85ba37b97df8edd18b757bc475b12b66f4b117ed Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 21 Apr 2010 14:33:34 -0700 Subject: Always return a value from ast_type_specifier::hir --- ast_to_hir.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 9b39d1f05b9..704f2745a74 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2269,6 +2269,8 @@ ast_type_specifier::hir(exec_list *instructions, { if (this->structure != NULL) return this->structure->hir(instructions, state); + + return NULL; } -- cgit v1.2.3 From 82baaf428308e83ad28ca0914c13af59e8a28374 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 23 Apr 2010 13:21:22 -0700 Subject: glsl_type::generate_constructor_prototype now generates the function too Also, change the name of the method to generate_constructor. --- ast_function.cpp | 5 ++--- glsl_types.cpp | 30 +++++++++++++++++++++++++++++- glsl_types.h | 6 ++++-- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 3472b397cc1..cc8e9a8039b 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -271,11 +271,10 @@ process_array_constructor(exec_list *instructions, ir_function *f = state->symbols->get_function(constructor_type->name); /* If the constructor for this type of array does not exist, generate the - * prototype and add it to the symbol table. The code will be generated - * later. + * prototype and add it to the symbol table. */ if (f == NULL) { - f = constructor_type->generate_constructor_prototype(state->symbols); + f = constructor_type->generate_constructor(state->symbols); } ir_rvalue *const r = diff --git a/glsl_types.cpp b/glsl_types.cpp index 720dce79a1d..a293ce72860 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -133,7 +133,7 @@ const glsl_type *glsl_type::get_base_type() const ir_function * -glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const +glsl_type::generate_constructor(glsl_symbol_table *symtab) const { /* Generate the function name and add it to the symbol table. */ @@ -145,6 +145,8 @@ glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const ir_function_signature *const sig = new ir_function_signature(this); f->add_signature(sig); + ir_variable **declarations = + (ir_variable **) malloc(sizeof(ir_variable *) * this->length); for (unsigned i = 0; i < length; i++) { char *const param_name = (char *) malloc(10); @@ -155,9 +157,35 @@ glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const : new ir_variable(fields.structure[i].type, param_name); var->mode = ir_var_in; + declarations[i] = var; sig->parameters.push_tail(var); } + /* Generate the body of the constructor. The body assigns each of the + * parameters to a portion of a local variable called __retval that has + * the same type as the constructor. After initializing __retval, + * __retval is returned. + */ + ir_variable *retval = new ir_variable(this, "__retval"); + sig->body.push_tail(retval); + + for (unsigned i = 0; i < length; i++) { + ir_dereference *const lhs = (this->base_type == GLSL_TYPE_ARRAY) + ? new ir_dereference(retval, new ir_constant(i)) + : new ir_dereference(retval, fields.structure[i].name); + + ir_dereference *const rhs = new ir_dereference(declarations[i]); + ir_instruction *const assign = new ir_assignment(lhs, rhs, NULL); + + sig->body.push_tail(assign); + } + + free(declarations); + + ir_dereference *const retref = new ir_dereference(retval); + ir_instruction *const inst = new ir_return(retref); + sig->body.push_tail(inst); + return f; } diff --git a/glsl_types.h b/glsl_types.h index 1f8559aa6a4..96e4c74d5b5 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -199,8 +199,10 @@ struct glsl_type { static const glsl_type *get_array_instance(const glsl_type *base, unsigned elements); - class ir_function *generate_constructor_prototype(class glsl_symbol_table *) - const; + /** + * Generate the constructor for this type and add it to the symbol table + */ + class ir_function *generate_constructor(class glsl_symbol_table *) const; /** * Query the total number of scalars that make up a scalar, vector or matrix -- cgit v1.2.3 From ab89927a91a0ea6ffdb56e5e75044472f7277f4a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 23 Apr 2010 13:24:08 -0700 Subject: Reject conflicting struct declarations, generate struct constructor --- ast_to_hir.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 704f2745a74..a32805b38f0 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2346,7 +2346,20 @@ ast_struct_specifier::hir(exec_list *instructions, glsl_type *t = new glsl_type(fields, decl_count, name); - state->symbols->add_type(name, t); + YYLTYPE loc = this->get_location(); + if (!state->symbols->add_type(name, t)) { + _mesa_glsl_error(& loc, state, "struct `%s' previously defined", name); + } else { + /* This logic is a bit tricky. It is an error to declare a structure at + * global scope if there is also a function with the same name. + */ + if ((state->current_function == NULL) + && (state->symbols->get_function(name) != NULL)) { + _mesa_glsl_error(& loc, state, "name `%s' previously defined", name); + } else { + t->generate_constructor(state->symbols); + } + } /* Structure type definitions do not have r-values. */ -- cgit v1.2.3 From c824e35dd092a9cc0dbfd36d90fcdf1488c8942d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 23 Apr 2010 15:55:19 -0700 Subject: Begin handling some varieties of invalid declarations --- ast_to_hir.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index a32805b38f0..e0913dd9729 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1476,6 +1476,7 @@ ast_declarator_list::hir(exec_list *instructions, const struct glsl_type *decl_type; const char *type_name = NULL; ir_rvalue *result = NULL; + YYLTYPE loc = this->get_location(); /* The type specifier may contain a structure definition. Process that * before any of the variable declarations. @@ -1488,12 +1489,27 @@ ast_declarator_list::hir(exec_list *instructions, */ decl_type = this->type->specifier->glsl_type(& type_name, state); + if (is_empty_list(&this->declarations)) { + /* There are only two valid cases where the declaration list can be + * empty. + * + * 1. The declaration is setting the default precision of a built-in + * type (e.g., 'precision highp vec4;'). + * + * 2. Adding 'invariant' to an existing vertex shader output. + */ + + if (this->type->qualifier.invariant) { + } else if (decl_type != NULL) { + } else { + _mesa_glsl_error(& loc, state, "incomplete declaration"); + } + } foreach (ptr, &this->declarations) { struct ast_declaration *const decl = (struct ast_declaration * )ptr; const struct glsl_type *var_type; struct ir_variable *var; - YYLTYPE loc = this->get_location(); /* FINISHME: Emit a warning if a variable declaration shadows a * FINISHME: declaration at a higher scope. -- cgit v1.2.3 From c0bfe8723e1329d7734ab8ad7d97210d8050d365 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Apr 2010 15:01:50 -0700 Subject: Correctly handle remapping of array dereferences if ->var is a variable. --- ir_function_inlining.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index ba556a84992..5b1b3cb8b0b 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -184,34 +184,25 @@ ir_function_cloning_visitor::visit(ir_swizzle *ir) void ir_function_cloning_visitor::visit(ir_dereference *ir) { - if (ir->mode == ir_dereference::ir_reference_variable) { - ir_variable *old_var = ir->var->as_variable(); - - /* If it's a deref of a real variable, then we need to remap it if - * it was local to the function. - */ - if (old_var) { - ir_variable *new_var; - - new_var = this->get_remapped_variable(old_var); + ir_variable *old_var = ir->var->as_variable(); + ir_instruction *var; - this->result = new ir_dereference(new_var); - } else { - ir->var->accept(this); + if (old_var) + var = this->get_remapped_variable(old_var); + else { + ir->var->accept(this); + var = this->result; + } - this->result = new ir_dereference(this->result); - } + if (ir->mode == ir_dereference::ir_reference_variable) { + this->result = new ir_dereference(var); } else if (ir->mode == ir_dereference::ir_reference_array) { - ir_instruction *variable; ir_rvalue *index; - ir->var->accept(this); - variable = this->result; - ir->selector.array_index->accept(this); index = this->result->as_rvalue(); - this->result = new ir_dereference(variable, index); + this->result = new ir_dereference(var, index); } else { assert(ir->mode == ir_dereference::ir_reference_record); /* FINISHME: inlining of structure references */ -- cgit v1.2.3 From 35e8e461ca0f3027e650a52d5d2c69583a9ddef9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Apr 2010 15:02:40 -0700 Subject: ir_function_inlining: Handle inlining of structure dereferences. --- ir_function_inlining.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 5b1b3cb8b0b..385ce9ef6d7 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -205,8 +205,7 @@ ir_function_cloning_visitor::visit(ir_dereference *ir) this->result = new ir_dereference(var, index); } else { assert(ir->mode == ir_dereference::ir_reference_record); - /* FINISHME: inlining of structure references */ - assert(0); + this->result = new ir_dereference(var, strdup(ir->selector.field)); } } -- cgit v1.2.3 From 7d82c765a8ac7bdbad4cb445b1d2fd216a6e744d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 28 Apr 2010 12:01:40 -0700 Subject: IR print visitor: Just print the name of structures Treat structure types like other non-array types. We'll have to print the structure defintion elsewhere. --- ir_print_visitor.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 778a5c16460..f1108c6fe41 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -31,10 +31,6 @@ print_type(const glsl_type *t) printf("(array "); print_type(t->fields.array); printf(" %u)", t->length); - } else if (t->base_type == GLSL_TYPE_STRUCT) { - printf("(struct (%s %u ", t->name ? t->name : "@", t->length); - printf("(FINISHME: structure fields go here) "); - printf(")"); } else { printf("%s", t->name); } -- cgit v1.2.3 From 36d8a64a95354d09685e65c5e721038ff81b6d1f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 28 Apr 2010 13:04:15 -0700 Subject: IR print visitor: Move logic for printing the whole program to _mesa_print_ir --- glsl_parser_extras.cpp | 9 +-------- ir_print_visitor.cpp | 16 ++++++++++++++++ ir_print_visitor.h | 3 +++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index efcb125dfc5..4255d2d66e7 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -789,14 +789,7 @@ main(int argc, char **argv) printf("\n\n"); if (!state.error) { - printf("(\n"); - foreach_iter(exec_list_iterator, iter, instructions) { - ir_print_visitor v; - - ((ir_instruction *)iter.get())->accept(& v); - printf("\n"); - } - printf("\n)"); + _mesa_print_ir(&instructions, &state); } delete state.symbols; diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index f1108c6fe41..272e892a1ec 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -24,6 +24,22 @@ #include "ir_print_visitor.h" #include "glsl_types.h" +void +_mesa_print_ir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + (void) state; + + printf("(\n"); + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_print_visitor v; + + ((ir_instruction *)iter.get())->accept(& v); + printf("\n"); + } + printf("\n)"); +} + static void print_type(const glsl_type *t) { diff --git a/ir_print_visitor.h b/ir_print_visitor.h index b241f92e040..aeee538df29 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -29,6 +29,9 @@ #include "ir.h" #include "ir_visitor.h" +extern void _mesa_print_ir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + /** * Abstract base class of visitors of IR instruction trees */ -- cgit v1.2.3 From a2c6df556655e3619f5a0cd82b0d11aac37c5692 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 28 Apr 2010 13:14:53 -0700 Subject: Track and print user defined structure types --- ast_to_hir.cpp | 10 ++++++++++ glsl_parser_extras.h | 4 ++++ ir_print_visitor.cpp | 22 +++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index e0913dd9729..357683f0c3d 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2375,6 +2375,16 @@ ast_struct_specifier::hir(exec_list *instructions, } else { t->generate_constructor(state->symbols); } + + const glsl_type **s = (const glsl_type **) + realloc(state->user_structures, + sizeof(state->user_structures[0]) * + (state->num_user_structures + 1)); + if (s != NULL) { + s[state->num_user_structures] = t; + state->user_structures = s; + state->num_user_structures++; + } } /* Structure type definitions do not have r-values. diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 55bcc72e940..125c675a921 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -61,6 +61,10 @@ struct _mesa_glsl_parse_state { /** Loop or switch statement containing the current instructions. */ class ir_instruction *loop_or_switch_nesting; + /** List of structures defined in user code. */ + const glsl_type **user_structures; + unsigned num_user_structures; + /** * \name Enable bits for GLSL extensions */ diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 272e892a1ec..9edb6803853 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -23,12 +23,29 @@ #include #include "ir_print_visitor.h" #include "glsl_types.h" +#include "glsl_parser_extras.h" + +static void print_type(const glsl_type *t); void _mesa_print_ir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - (void) state; + for (unsigned i = 0; i < state->num_user_structures; i++) { + const glsl_type *const s = state->user_structures[i]; + + printf("(structure (%s) (%s@%08x) (%u) (\n", + s->name, s->name, (unsigned) s, s->length + ); + + for (unsigned j = 0; j < s->length; j++) { + printf("\t(("); + print_type(s->fields.structure[j].type); + printf(")(%s))\n", s->fields.structure[j].name); + } + + printf(")\n"); + } printf("(\n"); foreach_iter(exec_list_iterator, iter, *instructions) { @@ -47,6 +64,9 @@ print_type(const glsl_type *t) printf("(array "); print_type(t->fields.array); printf(" %u)", t->length); + } else if ((t->base_type == GLSL_TYPE_STRUCT) + && (strncmp("gl_", t->name, 3) != 0)) { + printf("%s@%08x", t->name, (unsigned) t); } else { printf("%s", t->name); } -- cgit v1.2.3 From 438f38c55afc8a31d01af357de95a56044ea7055 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Apr 2010 13:54:19 -0700 Subject: ir_dead_code: Fix segfault on handling a return statement with no value. --- ir_dead_code.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp index 81fbeba3213..a73e9ed9bbb 100644 --- a/ir_dead_code.cpp +++ b/ir_dead_code.cpp @@ -251,7 +251,10 @@ ir_dead_code_visitor::visit(ir_call *ir) void ir_dead_code_visitor::visit(ir_return *ir) { - ir->get_value()->accept(this); + ir_rvalue *val = ir->get_value(); + + if (val) + val->accept(this); } -- cgit v1.2.3 From c07fdae33f083f6337a2810c36d6dcb2dbeacff2 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 30 Apr 2010 23:38:50 -0700 Subject: Fix incorrect comments in function inliner. --- ir_function_inlining.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 385ce9ef6d7..c623cd010b6 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -389,15 +389,15 @@ ir_call::generate_inline(ir_instruction *next_ir) next_ir->insert_before(v.result); } - /* Generate the declarations for the parameters to our inlined code, - * and set up the mapping of real function body variables to ours. + /* Copy back the value of any 'out' parameters from the function body + * variables to our own. */ i = 0; param_iter = this->actual_parameters.iterator(); for (i = 0; i < num_parameters; i++) { ir_instruction *const param = (ir_instruction *) param_iter.get(); - /* Move the actual param into our param variable if it's an 'in' type. */ + /* Move our param variable into the actual param if it's an 'out' type. */ if (parameters[i]->mode == ir_var_out || parameters[i]->mode == ir_var_inout) { ir_assignment *assign; -- cgit v1.2.3 From 05ddebac0a45bf07fa60b04b22f29234ca26a4a4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 1 May 2010 00:31:35 -0700 Subject: Fix ir_return cloning to actually use the cloned subexpression. This caused a nasty bug where the function inliner would create new variables for each of the formal parameters, but the body would still reference the old copies. This was highly visible since the dead code eliminator (rightly) removed the new declarations, leading to printed IR that referenced non-existent variable names. --- ir_function_inlining.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index c623cd010b6..0d072c1b764 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -264,8 +264,7 @@ ir_function_cloning_visitor::visit(ir_return *ir) rval = this->result->as_rvalue(); assert(rval); - result = new ir_assignment(new ir_dereference(this->retval), - ir->get_value(), NULL); + result = new ir_assignment(new ir_dereference(this->retval), rval, NULL); } -- cgit v1.2.3 From b0e0da5f07b5072d588ab33b121933c705f3b8a1 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 23:18:25 -0700 Subject: Use %p rather than %08x when printing pointers to fix compile. --- ir_print_visitor.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 9edb6803853..ee7aa311758 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -34,9 +34,8 @@ _mesa_print_ir(exec_list *instructions, for (unsigned i = 0; i < state->num_user_structures; i++) { const glsl_type *const s = state->user_structures[i]; - printf("(structure (%s) (%s@%08x) (%u) (\n", - s->name, s->name, (unsigned) s, s->length - ); + printf("(structure (%s) (%s@%p) (%u) (\n", + s->name, s->name, s, s->length); for (unsigned j = 0; j < s->length; j++) { printf("\t(("); @@ -66,7 +65,7 @@ print_type(const glsl_type *t) printf(" %u)", t->length); } else if ((t->base_type == GLSL_TYPE_STRUCT) && (strncmp("gl_", t->name, 3) != 0)) { - printf("%s@%08x", t->name, (unsigned) t); + printf("%s@%p", t->name, t); } else { printf("%s", t->name); } -- cgit v1.2.3 From a35e62d97a714c1fe77d4eaf3dbdd659d83449b1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Apr 2010 17:53:26 -0700 Subject: glsl_lexer: Quiet warning about unused unput(). --- glsl_lexer.lpp | 1 + 1 file changed, 1 insertion(+) diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index 06214a8eccf..34ca229de8d 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -37,6 +37,7 @@ %} %option bison-bridge bison-locations reentrant noyywrap +%option nounput noyy_top_state %option never-interactive %option prefix="_mesa_glsl_" %option extra-type="struct _mesa_glsl_parse_state *" -- cgit v1.2.3 From 7f436a837c2f265cfd790ff20ac51377d7207c40 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Apr 2010 17:54:52 -0700 Subject: Use the AM_SILENT_RULES when available. --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index b97feb94407..f0a4301076d 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,8 @@ AC_PROG_MAKE_SET AC_PROG_YACC AC_PROG_LEX +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + # Checks for libraries. # Checks for header files. -- cgit v1.2.3 From 81f49a774eec3990b0a6ffeca75119e6a3ef827d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Apr 2010 17:57:28 -0700 Subject: Quiet warnings about ir_shader not being handled in places it's not needed. --- glsl_parser_extras.cpp | 1 + ir_variable.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 4255d2d66e7..4183d138566 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -48,6 +48,7 @@ _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) case vertex_shader: return "vertex"; case fragment_shader: return "fragment"; case geometry_shader: return "geometry"; + case ir_shader: break; } assert(!"Should not get here."); diff --git a/ir_variable.cpp b/ir_variable.cpp index b5e7d6e9339..2c2b57a7114 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -21,6 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ +#include #include "glsl_parser_extras.h" #include "glsl_symbol_table.h" #include "ir.h" @@ -315,5 +316,9 @@ _mesa_glsl_initialize_variables(exec_list *instructions, case fragment_shader: initialize_fs_variables(instructions, state); break; + case ir_shader: + fprintf(stderr, "ir reader has no builtin variables"); + exit(1); + break; } } -- cgit v1.2.3 From 3623df68fa9f4db88c436425524bc27c7f59a051 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Apr 2010 18:00:33 -0700 Subject: Store warnings and errors in a parser state infolog. Cleans up compile warning about unused state in _mesa_glsl_warning. We would want infolog handling roughly like this anyway. --- glsl_parser_extras.cpp | 10 +++++++++- glsl_parser_extras.h | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 4183d138566..88767af2049 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -73,11 +73,15 @@ _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, va_end(ap); printf("%s\n", buf); + + if (state->info_log) + free(state->info_log); + state->info_log = strdup(buf); } void -_mesa_glsl_warning(const YYLTYPE *locp, const _mesa_glsl_parse_state *state, +_mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, const char *fmt, ...) { char buf[1024]; @@ -92,6 +96,10 @@ _mesa_glsl_warning(const YYLTYPE *locp, const _mesa_glsl_parse_state *state, va_end(ap); printf("%s\n", buf); + + if (!state->info_log) { + state->info_log = strdup(buf); + } } diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 125c675a921..b06b3fe920c 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -65,6 +65,8 @@ struct _mesa_glsl_parse_state { const glsl_type **user_structures; unsigned num_user_structures; + char *info_log; + /** * \name Enable bits for GLSL extensions */ @@ -95,7 +97,7 @@ extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, * \sa _mesa_glsl_error */ extern void _mesa_glsl_warning(const YYLTYPE *locp, - const _mesa_glsl_parse_state *state, + _mesa_glsl_parse_state *state, const char *fmt, ...); extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, -- cgit v1.2.3 From 3bc8b68436ad387cc395d6c0843bbf185d1739d0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 3 May 2010 11:41:00 -0700 Subject: Remove the pedantic C junk. Mesa doesn't use pedantic ANSI C89, so I have no idea why we would. --- configure.ac | 4 ---- 1 file changed, 4 deletions(-) diff --git a/configure.ac b/configure.ac index f0a4301076d..37f3283a887 100644 --- a/configure.ac +++ b/configure.ac @@ -62,10 +62,6 @@ else WARN="" fi -if test "x$GCC" = xyes ; then - CFLAGS="$CFLAGS -std=c89 -ansi -pedantic" -fi - CFLAGS="$CFLAGS $WARN" CXXFLAGS="$CXXFLAGS $WARN" YFLAGS="-d -v" -- cgit v1.2.3 From 05a4e59c2410292f595cfe0cc552a86ae69b20d2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 3 May 2010 17:08:01 -0700 Subject: ir_to_mesa.cpp: Fix missing types on some ir_swizzles. Debugging this took forever as I only looked at constructors in ir.cpp to find who wasn't setting up ->type. I dislike hiding code (as opposed to prototypes and definitions) in C++ header files, but in this case I have only myself to blame. --- ir.cpp | 8 ++++++++ ir.h | 6 +----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ir.cpp b/ir.cpp index 6778997ac83..d2d8b4015b7 100644 --- a/ir.cpp +++ b/ir.cpp @@ -307,6 +307,14 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, type = glsl_type::get_instance(val->type->base_type, mask.num_components, 1); } +ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) +{ + this->val = val; + this->mask = mask; + this->type = glsl_type::get_instance(val->type->base_type, + mask.num_components, 1); +} + #define X 1 #define R 5 #define S 9 diff --git a/ir.h b/ir.h index b3fb06d2c7b..ce924206f8a 100644 --- a/ir.h +++ b/ir.h @@ -707,11 +707,7 @@ class ir_swizzle : public ir_rvalue { public: ir_swizzle(ir_rvalue *, unsigned x, unsigned y, unsigned z, unsigned w, unsigned count); - ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) - : val(val), mask(mask) - { - /* empty */ - } + ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask); virtual ir_swizzle *as_swizzle() { -- cgit v1.2.3 From 5c89f0ecb9581cbe83442ab3f41f2f3701fffab0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 4 May 2010 13:04:40 -0700 Subject: ir_copy_propagation: New pass to rewrite dereferences to avoid copies. This is pretty basic. Right now it only handles pure assignments -- same type on each side, no swizzling, and only within basic blocks. --- Makefile.am | 8 +- glsl_parser_extras.cpp | 2 + ir.h | 6 + ir_basic_block.cpp | 136 +++++++++++++++++++++ ir_basic_block.h | 26 ++++ ir_copy_propagation.cpp | 313 ++++++++++++++++++++++++++++++++++++++++++++++++ ir_copy_propagation.h | 24 ++++ ir_visit_tree.cpp | 207 ++++++++++++++++++++++++++++++++ ir_visit_tree.h | 27 +++++ 9 files changed, 748 insertions(+), 1 deletion(-) create mode 100644 ir_basic_block.cpp create mode 100644 ir_basic_block.h create mode 100644 ir_copy_propagation.cpp create mode 100644 ir_copy_propagation.h create mode 100644 ir_visit_tree.cpp create mode 100644 ir_visit_tree.h diff --git a/Makefile.am b/Makefile.am index 4044cc076d7..49c3f4d7b27 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,14 +30,20 @@ glsl_SOURCES = \ ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \ ir.cpp hir_field_selection.cpp builtin_function.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \ + ir_basic_block.cpp \ + ir_basic_block.h \ ir_constant_expression.cpp \ ir_constant_folding.cpp \ + ir_copy_propagation.cpp \ + ir_copy_propagation.h \ ir_dead_code.cpp \ ir_expression_flattening.cpp \ ir_function_can_inline.cpp \ ir_function_inlining.cpp \ ir_if_simplification.cpp \ - ir_reader.cpp s_expression.cpp + ir_reader.cpp s_expression.cpp \ + ir_visit_tree.cpp \ + ir_visit_tree.h BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 88767af2049..31fa5e6c7d0 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -35,6 +35,7 @@ #include "glsl_parser_extras.h" #include "glsl_parser.h" #include "ir_constant_folding.h" +#include "ir_copy_propagation.h" #include "ir_dead_code.h" #include "ir_function_inlining.h" #include "ir_if_simplification.h" @@ -786,6 +787,7 @@ main(int argc, char **argv) progress = do_function_inlining(&instructions) || progress; progress = do_if_simplification(&instructions) || progress; + progress = do_copy_propagation(&instructions) || progress; progress = do_dead_code_unlinked(&instructions) || progress; /* Constant folding */ diff --git a/ir.h b/ir.h index ce924206f8a..d8568a8dae7 100644 --- a/ir.h +++ b/ir.h @@ -62,6 +62,7 @@ public: virtual class ir_return * as_return() { return NULL; } virtual class ir_if * as_if() { return NULL; } virtual class ir_swizzle * as_swizzle() { return NULL; } + virtual class ir_constant * as_constant() { return NULL; } /*@}*/ protected: @@ -787,6 +788,11 @@ public: ir_constant(int i); ir_constant(float f); + virtual ir_constant *as_constant() + { + return this; + } + virtual void accept(ir_visitor *v) { v->visit(this); diff --git a/ir_basic_block.cpp b/ir_basic_block.cpp new file mode 100644 index 00000000000..b10a25c5353 --- /dev/null +++ b/ir_basic_block.cpp @@ -0,0 +1,136 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_basic_block.cpp + * + * Basic block analysis of instruction streams. + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "ir_visit_tree.h" +#include "ir_basic_block.h" +#include "glsl_types.h" + +static void +has_call_callback(ir_instruction *ir, void *data) +{ + bool *has_call = (bool *)data; + + *has_call = *has_call || ir->as_call(); +} + +/** + * Calls a user function for every basic block in the instruction stream. + * + * Basic block analysis is pretty easy in our IR thanks to the lack of + * unstructured control flow. We've got: + * + * ir_loop (for () {}, while () {}, do {} while ()) + * ir_loop_jump ( + * ir_if () {} + * ir_return + * ir_call() + * + * Note that the basic blocks returned by this don't encompass all + * operations performed by the program -- for example, if conditions + * don't get returned, nor do the assignments that will be generated + * for ir_call parameters. + */ +void call_for_basic_blocks(exec_list *instructions, + void (*callback)(ir_instruction *first, + ir_instruction *last)) +{ + ir_instruction *leader = NULL; + ir_instruction *last = NULL; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_if *ir_if; + ir_loop *ir_loop; + ir_function *ir_function; + + if (!leader) + leader = ir; + + if ((ir_if = ir->as_if())) { + callback(leader, ir); + leader = NULL; + + call_for_basic_blocks(&ir_if->then_instructions, callback); + call_for_basic_blocks(&ir_if->else_instructions, callback); + } else if ((ir_loop = ir->as_loop())) { + callback(leader, ir); + leader = NULL; + call_for_basic_blocks(&ir_loop->body_instructions, callback); + } else if (ir->as_return() || ir->as_call()) { + callback(leader, ir); + leader = NULL; + } else if ((ir_function = ir->as_function())) { + /* A function definition doesn't interrupt our basic block + * since execution doesn't go into it. We should process the + * bodies of its signatures for BBs, though. + * + * Note that we miss an opportunity for producing more + * maximal BBs between the instructions that precede main() + * and the body of main(). Perhaps those instructions ought + * to live inside of main(). + */ + foreach_iter(exec_list_iterator, fun_iter, *ir_function) { + ir_function_signature *ir_sig; + + ir_sig = (ir_function_signature *)fun_iter.get(); + + call_for_basic_blocks(&ir_sig->body, callback); + } + } else if (ir->as_assignment()) { + bool has_call = false; + + /* If there's a call in the expression tree being assigned, + * then that ends the BB too. + * + * The assumption is that any consumer of the basic block + * walker is fine with the fact that the call is somewhere in + * the tree even if portions of the tree may be evaluated + * after the call. + * + * A consumer that has an issue with this could not process + * the last instruction of the basic block. If doing so, + * expression flattener may be useful before using the basic + * block finder to get more maximal basic blocks out. + */ + ir_visit_tree(ir, has_call_callback, &has_call); + + if (has_call) { + callback(leader, ir); + leader = NULL; + } + } + last = ir; + } + if (leader) { + callback(leader, last); + } +} diff --git a/ir_basic_block.h b/ir_basic_block.h new file mode 100644 index 00000000000..e7993b3b04a --- /dev/null +++ b/ir_basic_block.h @@ -0,0 +1,26 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +void call_for_basic_blocks(exec_list *instructions, + void (*callback)(ir_instruction *first, + ir_instruction *last)); diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp new file mode 100644 index 00000000000..8eb1ebde38c --- /dev/null +++ b/ir_copy_propagation.cpp @@ -0,0 +1,313 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_dead_code.cpp + * + * Eliminates dead assignments and variable declarations from the code. + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "ir_basic_block.h" +#include "ir_copy_propagation.h" +#include "glsl_types.h" + +class acp_entry : public exec_node +{ +public: + acp_entry(ir_variable *lhs, ir_variable *rhs) + { + assert(lhs); + assert(rhs); + this->lhs = lhs; + this->rhs = rhs; + } + + ir_variable *lhs; + ir_variable *rhs; +}; + +class ir_copy_propagation_visitor : public ir_visitor { +public: + ir_copy_propagation_visitor(exec_list *acp) + { + progress = false; + this->acp = acp; + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ + + /** List of acp_entry */ + exec_list *acp; + bool progress; +}; + + +void +ir_copy_propagation_visitor::visit(ir_variable *ir) +{ + (void)ir; +} + + +void +ir_copy_propagation_visitor::visit(ir_loop *ir) +{ + (void)ir; +} + +void +ir_copy_propagation_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; +} + + +void +ir_copy_propagation_visitor::visit(ir_function_signature *ir) +{ + (void)ir; +} + +void +ir_copy_propagation_visitor::visit(ir_function *ir) +{ + (void) ir; +} + +void +ir_copy_propagation_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + ir->operands[operand]->accept(this); + } +} + + +void +ir_copy_propagation_visitor::visit(ir_swizzle *ir) +{ + ir->val->accept(this); +} + +/** + * Replaces dereferences of ACP RHS variables with ACP LHS variables. + * + * This is where the actual copy propagation occurs. Note that the + * rewriting of ir_dereference means that the ir_dereference instance + * must not be shared by multiple IR operations! + */ +void +ir_copy_propagation_visitor::visit(ir_dereference *ir) +{ + ir_variable *var; + + if (ir->mode == ir_dereference::ir_reference_array) { + ir->selector.array_index->accept(this); + } + + var = ir->var->as_variable(); + if (var) { + foreach_iter(exec_list_iterator, iter, *this->acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (var == entry->lhs) { + ir->var = entry->rhs; + this->progress = true; + break; + } + } + } else { + ir->var->accept(this); + } +} + +void +ir_copy_propagation_visitor::visit(ir_assignment *ir) +{ + if (ir->condition) + ir->condition->accept(this); + + /* Ignores the LHS. Don't want to rewrite the LHS to point at some + * other storage! + */ + + ir->rhs->accept(this); +} + + +void +ir_copy_propagation_visitor::visit(ir_constant *ir) +{ + (void) ir; +} + + +void +ir_copy_propagation_visitor::visit(ir_call *ir) +{ + (void)ir; + + /* Note, if we were to do copy propagation to parameters of calls, we'd + * have to be careful about out params. + */ +} + + +void +ir_copy_propagation_visitor::visit(ir_return *ir) +{ + ir_rvalue *val = ir->get_value(); + + if (val) + val->accept(this); +} + + +void +ir_copy_propagation_visitor::visit(ir_if *ir) +{ + ir->condition->accept(this); +} + +static void +propagate_copies(ir_instruction *ir, exec_list *acp) +{ + ir_copy_propagation_visitor v(acp); + + ir->accept(&v); +} + +static void +kill_invalidated_copies(ir_assignment *ir, exec_list *acp) +{ + ir_dereference *lhs_deref = ir->lhs->as_dereference(); + + /* Only handle simple dereferences for now. */ + if (lhs_deref && + lhs_deref->mode == ir_dereference::ir_reference_variable) { + ir_variable *var = lhs_deref->var->as_variable(); + + foreach_iter(exec_list_iterator, iter, *acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (entry->lhs == var || entry->rhs == var) { + entry->remove(); + } + } + } else { + /* FINISHME: Only clear out the entries we overwrote here. */ + acp->make_empty(); + } +} + +/** + * Adds an entry to the available copy list if it's a plain assignment + * of a variable to a variable. + */ +static void +add_copy(ir_assignment *ir, exec_list *acp) +{ + acp_entry *entry; + + if (ir->condition) { + ir_constant *condition = ir->condition->as_constant(); + if (!condition || !condition->value.b[0]) + return; + } + + ir_dereference *lhs_deref = ir->lhs->as_dereference(); + if (!lhs_deref || lhs_deref->mode != ir_dereference::ir_reference_variable) + return; + ir_variable *lhs_var = lhs_deref->var->as_variable(); + + ir_dereference *rhs_deref = ir->rhs->as_dereference(); + if (!rhs_deref || rhs_deref->mode != ir_dereference::ir_reference_variable) + return; + ir_variable *rhs_var = rhs_deref->var->as_variable(); + + entry = new acp_entry(lhs_var, rhs_var); + acp->push_tail(entry); +} + +static void +copy_propagation_basic_block(ir_instruction *first, + ir_instruction *last) +{ + ir_instruction *ir; + /* List of avaialble_copy */ + exec_list acp; + + for (ir = first;; ir = (ir_instruction *)ir->next) { + ir_assignment *ir_assign = ir->as_assignment(); + + propagate_copies(ir, &acp); + + if (ir_assign) { + kill_invalidated_copies(ir_assign, &acp); + + add_copy(ir_assign, &acp); + } + if (ir == last) + break; + } +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_copy_propagation(exec_list *instructions) +{ + bool progress = false; + + call_for_basic_blocks(instructions, copy_propagation_basic_block); + + /* FINISHME: Return a legit progress value. */ + return progress; +} diff --git a/ir_copy_propagation.h b/ir_copy_propagation.h new file mode 100644 index 00000000000..cfb0f63250a --- /dev/null +++ b/ir_copy_propagation.h @@ -0,0 +1,24 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +bool do_copy_propagation(exec_list *instructions); diff --git a/ir_visit_tree.cpp b/ir_visit_tree.cpp new file mode 100644 index 00000000000..89def6a9205 --- /dev/null +++ b/ir_visit_tree.cpp @@ -0,0 +1,207 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_dead_code.cpp + * + * Eliminates dead assignments and variable declarations from the code. + */ + +#define NULL 0 +#include "ir.h" +#include "ir_visitor.h" +#include "ir_visit_tree.h" + +class ir_tree_visitor : public ir_visitor { +public: + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ + + void (*callback)(ir_instruction *ir, void *data); + void *data; +}; + +void +ir_tree_visitor::visit(ir_variable *ir) +{ + this->callback(ir, this->data); +} + + +void +ir_tree_visitor::visit(ir_loop *ir) +{ + this->callback(ir, this->data); + + visit_exec_list(&ir->body_instructions, this); + if (ir->from) + ir->from->accept(this); + if (ir->to) + ir->to->accept(this); + if (ir->increment) + ir->increment->accept(this); +} + +void +ir_tree_visitor::visit(ir_loop_jump *ir) +{ + this->callback(ir, this->data); +} + + +void +ir_tree_visitor::visit(ir_function_signature *ir) +{ + this->callback(ir, this->data); + + visit_exec_list(&ir->body, this); +} + +void +ir_tree_visitor::visit(ir_function *ir) +{ + this->callback(ir, this->data); + + /* FINISHME: Do we want to walk into functions? */ +} + +void +ir_tree_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + + this->callback(ir, this->data); + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + ir->operands[operand]->accept(this); + } +} + + +void +ir_tree_visitor::visit(ir_swizzle *ir) +{ + this->callback(ir, this->data); + + ir->val->accept(this); +} + + +void +ir_tree_visitor::visit(ir_dereference *ir) +{ + this->callback(ir, this->data); + + if (ir->mode == ir_dereference::ir_reference_array) { + ir->selector.array_index->accept(this); + } +} + +void +ir_tree_visitor::visit(ir_assignment *ir) +{ + this->callback(ir, this->data); + + ir->lhs->accept(this); + ir->rhs->accept(this); + if (ir->condition) + ir->condition->accept(this); +} + + +void +ir_tree_visitor::visit(ir_constant *ir) +{ + this->callback(ir, this->data); +} + + +void +ir_tree_visitor::visit(ir_call *ir) +{ + this->callback(ir, this->data); + + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + + param->accept(this); + } +} + + +void +ir_tree_visitor::visit(ir_return *ir) +{ + ir_rvalue *val = ir->get_value(); + + this->callback(ir, this->data); + + if (val) + val->accept(this); +} + + +void +ir_tree_visitor::visit(ir_if *ir) +{ + this->callback(ir, this->data); + + ir->condition->accept(this); + + visit_exec_list(&ir->then_instructions, this); + visit_exec_list(&ir->else_instructions, this); +} + +void ir_visit_tree(ir_instruction *ir, + void (*callback)(ir_instruction *ir, + void *data), + void *data) +{ + ir_tree_visitor v; + v.callback = callback; + v.data = data; + + ir->accept(&v); +} + diff --git a/ir_visit_tree.h b/ir_visit_tree.h new file mode 100644 index 00000000000..24672783ef7 --- /dev/null +++ b/ir_visit_tree.h @@ -0,0 +1,27 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +void ir_visit_tree(ir_instruction *ir, + void (*callback)(ir_instruction *ir, + void *data), + void *data); -- cgit v1.2.3 From 4e2c0b99d932577d082b95d54e4ed1ba1d5d686b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 5 May 2010 09:26:46 -0700 Subject: ir_copy_propagation: Handle swizzles and array derefs on LHS of assign. This improves the ACP to not get cleared when more complicated assignments occur, cleaning up more redundant copies in programs. --- ir_copy_propagation.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index 8eb1ebde38c..526ff96e623 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -30,6 +30,7 @@ #include #include "ir.h" #include "ir_visitor.h" +#include "ir_print_visitor.h" #include "ir_basic_block.h" #include "ir_copy_propagation.h" #include "glsl_types.h" @@ -226,23 +227,33 @@ propagate_copies(ir_instruction *ir, exec_list *acp) static void kill_invalidated_copies(ir_assignment *ir, exec_list *acp) { - ir_dereference *lhs_deref = ir->lhs->as_dereference(); - - /* Only handle simple dereferences for now. */ - if (lhs_deref && - lhs_deref->mode == ir_dereference::ir_reference_variable) { - ir_variable *var = lhs_deref->var->as_variable(); - - foreach_iter(exec_list_iterator, iter, *acp) { - acp_entry *entry = (acp_entry *)iter.get(); + ir_instruction *current = ir->lhs; - if (entry->lhs == var || entry->rhs == var) { - entry->remove(); + /* Walk down the dereference chain to find the variable at the end + * of it that we're actually modifying. + */ + while (current != NULL) { + ir_swizzle *swiz; + ir_dereference *deref; + + if ((swiz = current->as_swizzle())) { + current = swiz->val; + } else if ((deref = current->as_dereference())) { + current = deref->var; + } else { + ir_variable *var = current->as_variable(); + assert(var); + + foreach_iter(exec_list_iterator, iter, *acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (entry->lhs == var || entry->rhs == var) { + entry->remove(); + } } + current = NULL; + break; } - } else { - /* FINISHME: Only clear out the entries we overwrote here. */ - acp->make_empty(); } } -- cgit v1.2.3 From 8e75de31649f877f24f460bc887c827227968403 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 5 May 2010 09:31:53 -0700 Subject: ir_copy_propagation: Return true if we optimized out any assignments. This may trigger other optimization phases to make more progress themselves. --- ir_basic_block.cpp | 22 ++++++++++++---------- ir_basic_block.h | 4 +++- ir_copy_propagation.cpp | 15 ++++++++++----- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ir_basic_block.cpp b/ir_basic_block.cpp index b10a25c5353..455398e499c 100644 --- a/ir_basic_block.cpp +++ b/ir_basic_block.cpp @@ -61,7 +61,9 @@ has_call_callback(ir_instruction *ir, void *data) */ void call_for_basic_blocks(exec_list *instructions, void (*callback)(ir_instruction *first, - ir_instruction *last)) + ir_instruction *last, + void *data), + void *data) { ir_instruction *leader = NULL; ir_instruction *last = NULL; @@ -76,17 +78,17 @@ void call_for_basic_blocks(exec_list *instructions, leader = ir; if ((ir_if = ir->as_if())) { - callback(leader, ir); + callback(leader, ir, data); leader = NULL; - call_for_basic_blocks(&ir_if->then_instructions, callback); - call_for_basic_blocks(&ir_if->else_instructions, callback); + call_for_basic_blocks(&ir_if->then_instructions, callback, data); + call_for_basic_blocks(&ir_if->else_instructions, callback, data); } else if ((ir_loop = ir->as_loop())) { - callback(leader, ir); + callback(leader, ir, data); leader = NULL; - call_for_basic_blocks(&ir_loop->body_instructions, callback); + call_for_basic_blocks(&ir_loop->body_instructions, callback, data); } else if (ir->as_return() || ir->as_call()) { - callback(leader, ir); + callback(leader, ir, data); leader = NULL; } else if ((ir_function = ir->as_function())) { /* A function definition doesn't interrupt our basic block @@ -103,7 +105,7 @@ void call_for_basic_blocks(exec_list *instructions, ir_sig = (ir_function_signature *)fun_iter.get(); - call_for_basic_blocks(&ir_sig->body, callback); + call_for_basic_blocks(&ir_sig->body, callback, data); } } else if (ir->as_assignment()) { bool has_call = false; @@ -124,13 +126,13 @@ void call_for_basic_blocks(exec_list *instructions, ir_visit_tree(ir, has_call_callback, &has_call); if (has_call) { - callback(leader, ir); + callback(leader, ir, data); leader = NULL; } } last = ir; } if (leader) { - callback(leader, last); + callback(leader, last, data); } } diff --git a/ir_basic_block.h b/ir_basic_block.h index e7993b3b04a..dbd678b5c4f 100644 --- a/ir_basic_block.h +++ b/ir_basic_block.h @@ -23,4 +23,6 @@ void call_for_basic_blocks(exec_list *instructions, void (*callback)(ir_instruction *first, - ir_instruction *last)); + ir_instruction *last, + void *data), + void *data); diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index 526ff96e623..1f8c3590c20 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -216,12 +216,14 @@ ir_copy_propagation_visitor::visit(ir_if *ir) ir->condition->accept(this); } -static void +static bool propagate_copies(ir_instruction *ir, exec_list *acp) { ir_copy_propagation_visitor v(acp); ir->accept(&v); + + return v.progress; } static void @@ -288,16 +290,19 @@ add_copy(ir_assignment *ir, exec_list *acp) static void copy_propagation_basic_block(ir_instruction *first, - ir_instruction *last) + ir_instruction *last, + void *data) { ir_instruction *ir; /* List of avaialble_copy */ exec_list acp; + bool *out_progress = (bool *)data; + bool progress = false; for (ir = first;; ir = (ir_instruction *)ir->next) { ir_assignment *ir_assign = ir->as_assignment(); - propagate_copies(ir, &acp); + progress = propagate_copies(ir, &acp) || progress; if (ir_assign) { kill_invalidated_copies(ir_assign, &acp); @@ -307,6 +312,7 @@ copy_propagation_basic_block(ir_instruction *first, if (ir == last) break; } + *out_progress = progress; } /** @@ -317,8 +323,7 @@ do_copy_propagation(exec_list *instructions) { bool progress = false; - call_for_basic_blocks(instructions, copy_propagation_basic_block); + call_for_basic_blocks(instructions, copy_propagation_basic_block, &progress); - /* FINISHME: Return a legit progress value. */ return progress; } -- cgit v1.2.3 From aef0aaee675093ce2f494a139054b1bca94e9a43 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 5 May 2010 09:38:09 -0700 Subject: ir_copy_propagation: Fix up the doxygen about the file. --- ir_copy_propagation.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index 1f8c3590c20..018a30d77cf 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -22,9 +22,14 @@ */ /** - * \file ir_dead_code.cpp + * \file ir_copy_propagation.cpp * - * Eliminates dead assignments and variable declarations from the code. + * Moves usage of recently-copied variables to the previous copy of + * the variable within basic blocks. + * + * This should reduce the number of MOV instructions in the generated + * programs unless copy propagation is also done on the LIR, and may + * help anyway by triggering other optimizations that live in the HIR. */ #include -- cgit v1.2.3 From dc1dbd65e1099d98a05302e4ee67bc84c59a1386 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 5 May 2010 11:07:21 -0700 Subject: ir_visit_tree: Make sure we visit dereference targets, too. Found this with the local dead code pass, which never saw variable dereferences occurring. --- ir_visit_tree.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ir_visit_tree.cpp b/ir_visit_tree.cpp index 89def6a9205..b94c1b02087 100644 --- a/ir_visit_tree.cpp +++ b/ir_visit_tree.cpp @@ -136,6 +136,7 @@ ir_tree_visitor::visit(ir_dereference *ir) if (ir->mode == ir_dereference::ir_reference_array) { ir->selector.array_index->accept(this); } + ir->var->accept(this); } void -- cgit v1.2.3 From 6255a1f4c6425aa311c90e9dc7fca41c34e8dc2b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 5 May 2010 10:37:25 -0700 Subject: ir_dead_code_local: Remove redundant assignments within basic blocks. This cleans up a bunch of junk code in some of the GLSL parser tests, and could potentially help real-world too (particularly after copy propagation has happened). --- Makefile.am | 3 + glsl_parser_extras.cpp | 2 + ir_dead_code_local.cpp | 222 +++++++++++++++++++++++++++++++++++++++++++++++++ ir_optimization.h | 31 +++++++ 4 files changed, 258 insertions(+) create mode 100644 ir_dead_code_local.cpp create mode 100644 ir_optimization.h diff --git a/Makefile.am b/Makefile.am index 49c3f4d7b27..8f2f3fa632e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,10 +37,13 @@ glsl_SOURCES = \ ir_copy_propagation.cpp \ ir_copy_propagation.h \ ir_dead_code.cpp \ + ir_dead_code.h \ + ir_dead_code_local.cpp \ ir_expression_flattening.cpp \ ir_function_can_inline.cpp \ ir_function_inlining.cpp \ ir_if_simplification.cpp \ + ir_optimization.h \ ir_reader.cpp s_expression.cpp \ ir_visit_tree.cpp \ ir_visit_tree.h diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 31fa5e6c7d0..58656c70ae2 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -39,6 +39,7 @@ #include "ir_dead_code.h" #include "ir_function_inlining.h" #include "ir_if_simplification.h" +#include "ir_optimization.h" #include "ir_print_visitor.h" #include "ir_reader.h" @@ -788,6 +789,7 @@ main(int argc, char **argv) progress = do_function_inlining(&instructions) || progress; progress = do_if_simplification(&instructions) || progress; progress = do_copy_propagation(&instructions) || progress; + progress = do_dead_code_local(&instructions) || progress; progress = do_dead_code_unlinked(&instructions) || progress; /* Constant folding */ diff --git a/ir_dead_code_local.cpp b/ir_dead_code_local.cpp new file mode 100644 index 00000000000..de6a4f5e5d9 --- /dev/null +++ b/ir_dead_code_local.cpp @@ -0,0 +1,222 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_dead_code_local.cpp + * + * Eliminates local dead assignments from the code. + * + * This operates on basic blocks, tracking assignments and finding if + * they're used before the variable is completely reassigned. + * + * Compare this to ir_dead_code.cpp, which operates globally looking + * for assignments to variables that are never read. + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "ir_print_visitor.h" +#include "ir_basic_block.h" +#include "ir_visit_tree.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +static bool debug = false; + +class assignment_entry : public exec_node +{ +public: + assignment_entry(ir_variable *lhs, ir_instruction *ir) + { + assert(lhs); + assert(ir); + this->lhs = lhs; + this->ir = ir; + } + + ir_variable *lhs; + ir_instruction *ir; +}; + +static void +ir_kill_for_derefs_callback(ir_instruction *ir, void *data) +{ + exec_list *assignments = (exec_list *)data; + ir_variable *var = ir->as_variable(); + + if (!var) + return; + + foreach_iter(exec_list_iterator, iter, *assignments) { + assignment_entry *entry = (assignment_entry *)iter.get(); + + if (entry->lhs == var) { + if (debug) + printf("kill %s\n", entry->lhs->name); + entry->remove(); + } + } +} + +static void +kill_for_derefs(ir_instruction *ir, exec_list *assignments) +{ + ir_visit_tree(ir, ir_kill_for_derefs_callback, assignments); +} + +/** + * Adds an entry to the available copy list if it's a plain assignment + * of a variable to a variable. + */ +static bool +process_assignment(ir_assignment *ir, exec_list *assignments) +{ + ir_variable *var = NULL; + bool progress = false; + ir_instruction *current; + + /* Kill assignment entries for things used to produce this assignment. */ + kill_for_derefs(ir->rhs, assignments); + if (ir->condition) { + kill_for_derefs(ir->condition, assignments); + } + + /* Walk down the dereference chain to find the variable at the end + * of it that we're actually modifying. Kill assignment enties used as + * array indices, too. + */ + for (current = ir->lhs; current != NULL;) { + ir_swizzle *swiz; + ir_dereference *deref; + + if ((swiz = current->as_swizzle())) { + current = swiz->val; + } else if ((deref = current->as_dereference())) { + if (deref->mode == ir_dereference::ir_reference_array) + kill_for_derefs(deref->selector.array_index, assignments); + current = deref->var; + } else { + var = current->as_variable(); + + current = NULL; + break; + } + } + + assert(var); + + bool always_assign = true; + if (ir->condition) { + ir_constant *condition = ir->condition->as_constant(); + if (!condition || !condition->value.b[0]) + always_assign = false; + } + + /* Now, check if we did a whole-variable assignment. */ + ir_dereference *lhs_deref = ir->lhs->as_dereference(); + if (always_assign && + lhs_deref && + lhs_deref->mode == ir_dereference::ir_reference_variable) { + /* We did a whole-variable assignment. So, any instruction in + * the assignment list with the same LHS is dead. + */ + if (debug) + printf("looking for %s to remove\n", var->name); + foreach_iter(exec_list_iterator, iter, *assignments) { + assignment_entry *entry = (assignment_entry *)iter.get(); + + if (entry->lhs == var) { + if (debug) + printf("removing %s\n", var->name); + entry->ir->remove(); + entry->remove(); + progress = true; + } + } + } + + /* Add this instruction to the assignment list. */ + assignment_entry *entry = new assignment_entry(var, ir); + assignments->push_tail(entry); + + if (debug) { + printf("add %s\n", var->name); + + printf("current entries\n"); + foreach_iter(exec_list_iterator, iter, *assignments) { + assignment_entry *entry = (assignment_entry *)iter.get(); + + printf(" %s\n", entry->lhs->name); + } + } + + return progress; +} + +static void +dead_code_local_basic_block(ir_instruction *first, + ir_instruction *last, + void *data) +{ + ir_instruction *ir, *ir_next; + /* List of avaialble_copy */ + exec_list assignments; + bool *out_progress = (bool *)data; + bool progress = false; + + /* Safe looping, since process_assignment */ + for (ir = first, ir_next = (ir_instruction *)first->next;; + ir = ir_next, ir_next = (ir_instruction *)ir->next) { + ir_assignment *ir_assign = ir->as_assignment(); + + if (debug) { + ir_print_visitor v; + ir->accept(&v); + printf("\n"); + } + + if (ir_assign) { + progress = process_assignment(ir_assign, &assignments) || progress; + } else { + kill_for_derefs(ir, &assignments); + } + + if (ir == last) + break; + } + *out_progress = progress; +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_dead_code_local(exec_list *instructions) +{ + bool progress = false; + + call_for_basic_blocks(instructions, dead_code_local_basic_block, &progress); + + return progress; +} diff --git a/ir_optimization.h b/ir_optimization.h new file mode 100644 index 00000000000..22ce75e10ff --- /dev/null +++ b/ir_optimization.h @@ -0,0 +1,31 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file ir_dead_code.h + * + * Prototypes for optimization passes to be called by the compiler and drivers. + */ + +bool do_dead_code_local(exec_list *instructions); -- cgit v1.2.3 From bdd9b1f3ffa2a195d983816adfeca20480256119 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 5 May 2010 11:45:30 -0700 Subject: Move optimization pass prototypes to a single header. --- glsl_parser_extras.cpp | 10 +------- ir_constant_folding.cpp | 49 ++++++++++++++++++++++++++++++++++++- ir_constant_folding.h | 63 ------------------------------------------------ ir_copy_propagation.cpp | 2 +- ir_copy_propagation.h | 24 ------------------ ir_dead_code.h | 32 ------------------------ ir_function_inlining.cpp | 36 +++++++++++++++++++++++++++ ir_function_inlining.h | 37 ---------------------------- ir_if_simplification.h | 31 ------------------------ ir_optimization.h | 6 +++++ 10 files changed, 92 insertions(+), 198 deletions(-) delete mode 100644 ir_constant_folding.h delete mode 100644 ir_copy_propagation.h delete mode 100644 ir_dead_code.h delete mode 100644 ir_if_simplification.h diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 58656c70ae2..18280e0301c 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -34,11 +34,6 @@ #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" -#include "ir_constant_folding.h" -#include "ir_copy_propagation.h" -#include "ir_dead_code.h" -#include "ir_function_inlining.h" -#include "ir_if_simplification.h" #include "ir_optimization.h" #include "ir_print_visitor.h" #include "ir_reader.h" @@ -791,10 +786,7 @@ main(int argc, char **argv) progress = do_copy_propagation(&instructions) || progress; progress = do_dead_code_local(&instructions) || progress; progress = do_dead_code_unlinked(&instructions) || progress; - - /* Constant folding */ - ir_constant_folding_visitor constant_folding; - visit_exec_list(&instructions, &constant_folding); + progress = do_constant_folding(&instructions) || progress; } while (progress); } diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index 1b53440669f..913d42f0d9a 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -29,13 +29,49 @@ #define NULL 0 #include "ir.h" #include "ir_visitor.h" -#include "ir_constant_folding.h" +#include "ir_optimization.h" #include "glsl_types.h" /** * Visitor class for replacing expressions with ir_constant values. */ +class ir_constant_folding_visitor : public ir_visitor { +public: + ir_constant_folding_visitor() + { + /* empty */ + } + + virtual ~ir_constant_folding_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + /*@}*/ +}; + void ir_constant_folding_visitor::visit(ir_variable *ir) { @@ -152,3 +188,14 @@ ir_constant_folding_visitor::visit(ir_loop_jump *ir) { (void) ir; } + +bool +do_constant_folding(exec_list *instructions) +{ + ir_constant_folding_visitor constant_folding; + + visit_exec_list(instructions, &constant_folding); + + /* FINISHME: Return real progress. */ + return false; +} diff --git a/ir_constant_folding.h b/ir_constant_folding.h deleted file mode 100644 index 44bdbd01755..00000000000 --- a/ir_constant_folding.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_constant_folding.h - * Replace constant-valued expressions with references to constant values. - */ - -class ir_constant_folding_visitor : public ir_visitor { -public: - ir_constant_folding_visitor() - { - /* empty */ - } - - virtual ~ir_constant_folding_visitor() - { - /* empty */ - } - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - /*@}*/ -}; diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index 018a30d77cf..6c346521126 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -37,7 +37,7 @@ #include "ir_visitor.h" #include "ir_print_visitor.h" #include "ir_basic_block.h" -#include "ir_copy_propagation.h" +#include "ir_optimization.h" #include "glsl_types.h" class acp_entry : public exec_node diff --git a/ir_copy_propagation.h b/ir_copy_propagation.h deleted file mode 100644 index cfb0f63250a..00000000000 --- a/ir_copy_propagation.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -bool do_copy_propagation(exec_list *instructions); diff --git a/ir_dead_code.h b/ir_dead_code.h deleted file mode 100644 index 25bf6f6256c..00000000000 --- a/ir_dead_code.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file ir_dead_code.h - * - * Eliminates dead assignments and variable declarations from the code. - */ - -bool do_dead_code(exec_list *instructions); -bool do_dead_code_unlinked(exec_list *instructions); diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 0d072c1b764..09604c04df9 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -34,6 +34,42 @@ #include "ir_expression_flattening.h" #include "glsl_types.h" +class ir_function_inlining_visitor : public ir_visitor { +public: + ir_function_inlining_visitor() + { + /* empty */ + } + + virtual ~ir_function_inlining_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ +}; + class variable_remap : public exec_node { public: variable_remap(const ir_variable *old_var, ir_variable *new_var) diff --git a/ir_function_inlining.h b/ir_function_inlining.h index b68a55a1a96..6db011bbcae 100644 --- a/ir_function_inlining.h +++ b/ir_function_inlining.h @@ -27,41 +27,4 @@ * Replaces calls to functions with the body of the function. */ -class ir_function_inlining_visitor : public ir_visitor { -public: - ir_function_inlining_visitor() - { - /* empty */ - } - - virtual ~ir_function_inlining_visitor() - { - /* empty */ - } - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - /*@}*/ -}; - -bool do_function_inlining(exec_list *instructions); bool can_inline(ir_call *call); diff --git a/ir_if_simplification.h b/ir_if_simplification.h deleted file mode 100644 index 84b09ef0fd3..00000000000 --- a/ir_if_simplification.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_if_simplification.h - * - * Moves constant branches of if statements out to the surrounding - * instruction stream. - */ - -bool do_if_simplification(exec_list *instructions); diff --git a/ir_optimization.h b/ir_optimization.h index 22ce75e10ff..d9e30ce08ce 100644 --- a/ir_optimization.h +++ b/ir_optimization.h @@ -28,4 +28,10 @@ * Prototypes for optimization passes to be called by the compiler and drivers. */ +bool do_constant_folding(exec_list *instructions); +bool do_copy_propagation(exec_list *instructions); +bool do_dead_code(exec_list *instructions); bool do_dead_code_local(exec_list *instructions); +bool do_dead_code_unlinked(exec_list *instructions); +bool do_function_inlining(exec_list *instructions); +bool do_if_simplification(exec_list *instructions); -- cgit v1.2.3 From 3521f0bdd52d226031a3b60e2cd89b4629147690 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 10 May 2010 10:47:14 -0700 Subject: Store AST function call parameters in expressions Previously the list of function call parameters was stored as a circular list in ast_expression::subexpressions[1]. They are now stored as a regular list in ast_expression::expressions. --- ast.h | 3 +- ast_function.cpp | 138 +++++++++++++++++++++++-------------------------- glsl_parser.ypp | 11 ++-- glsl_parser_extras.cpp | 14 ++--- 4 files changed, 79 insertions(+), 87 deletions(-) diff --git a/ast.h b/ast.h index 41787f5c1c3..9fa651878e9 100644 --- a/ast.h +++ b/ast.h @@ -178,7 +178,8 @@ public: /** - * List of expressions for an \c ast_sequence. + * List of expressions for an \c ast_sequence or parameters for an + * \c ast_function_call */ struct simple_node expressions; }; diff --git a/ast_function.cpp b/ast_function.cpp index cc8e9a8039b..35ffcdbb8bc 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -32,19 +32,15 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters, simple_node *parameters, struct _mesa_glsl_parse_state *state) { - simple_node *const first = parameters; + simple_node *ptr; unsigned count = 0; - if (first != NULL) { - simple_node *ptr = first; - do { - ir_rvalue *const result = - ((ast_node *) ptr)->hir(instructions, state); - ptr = ptr->next; + foreach (ptr, parameters) { + ir_rvalue *const result = + ((ast_node *) ptr)->hir(instructions, state); - actual_parameters->push_tail(result); - count++; - } while (ptr != first); + actual_parameters->push_tail(result); + count++; } return count; @@ -324,7 +320,7 @@ ast_function_expression::hir(exec_list *instructions, } return process_array_constructor(instructions, constructor_type, - & loc, subexpressions[1], state); + & loc, &this->expressions, state); } /* There are two kinds of constructor call. Constructors for built-in @@ -361,73 +357,69 @@ ast_function_expression::hir(exec_list *instructions, unsigned matrix_parameters = 0; unsigned nonmatrix_parameters = 0; exec_list actual_parameters; - simple_node *const first = subexpressions[1]; - assert(first != NULL); + assert(!is_empty_list(&this->expressions)); - if (first != NULL) { - simple_node *ptr = first; - do { - ir_rvalue *const result = - ((ast_node *) ptr)->hir(instructions, state)->as_rvalue(); - ptr = ptr->next; + simple_node *ptr; + foreach (ptr, &this->expressions) { + ir_rvalue *const result = + ((ast_node *) ptr)->hir(instructions, state)->as_rvalue(); - /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: - * - * "It is an error to provide extra arguments beyond this - * last used argument." - */ - if (components_used >= type_components) { - _mesa_glsl_error(& loc, state, "too many parameters to `%s' " - "constructor", - constructor_type->name); - return ir_call::get_error_instruction(); - } - - if (!result->type->is_numeric() && !result->type->is_boolean()) { - _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " - "non-numeric data type", - constructor_type->name); - return ir_call::get_error_instruction(); - } - - /* Count the number of matrix and nonmatrix parameters. This - * is used below to enforce some of the constructor rules. - */ - if (result->type->is_matrix()) - matrix_parameters++; - else - nonmatrix_parameters++; + /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: + * + * "It is an error to provide extra arguments beyond this + * last used argument." + */ + if (components_used >= type_components) { + _mesa_glsl_error(& loc, state, "too many parameters to `%s' " + "constructor", + constructor_type->name); + return ir_call::get_error_instruction(); + } + + if (!result->type->is_numeric() && !result->type->is_boolean()) { + _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " + "non-numeric data type", + constructor_type->name); + return ir_call::get_error_instruction(); + } + + /* Count the number of matrix and nonmatrix parameters. This + * is used below to enforce some of the constructor rules. + */ + if (result->type->is_matrix()) + matrix_parameters++; + else + nonmatrix_parameters++; - /* Process each of the components of the parameter. Dereference - * each component individually, perform any type conversions, and - * add it to the parameter list for the constructor. + /* Process each of the components of the parameter. Dereference + * each component individually, perform any type conversions, and + * add it to the parameter list for the constructor. + */ + for (unsigned i = 0; i < result->type->components(); i++) { + if (components_used >= type_components) + break; + + ir_rvalue *const component = + convert_component(dereference_component(result, i), + base_type); + + /* All cases that could result in component->type being the + * error type should have already been caught above. */ - for (unsigned i = 0; i < result->type->components(); i++) { - if (components_used >= type_components) - break; - - ir_rvalue *const component = - convert_component(dereference_component(result, i), - base_type); - - /* All cases that could result in component->type being the - * error type should have already been caught above. - */ - assert(component->type == base_type); - - /* Don't actually generate constructor calls for scalars. - * Instead, do the usual component selection and conversion, - * and return the single component. - */ - if (constructor_type->is_scalar()) - return component; - - actual_parameters.push_tail(component); - components_used++; - } - } while (ptr != first); + assert(component->type == base_type); + + /* Don't actually generate constructor calls for scalars. + * Instead, do the usual component selection and conversion, + * and return the single component. + */ + if (constructor_type->is_scalar()) + return component; + + actual_parameters.push_tail(component); + components_used++; + } } /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: @@ -500,7 +492,7 @@ ast_function_expression::hir(exec_list *instructions, return match_function_by_name(instructions, id->primary_expression.identifier, & loc, - subexpressions[1], state); + &this->expressions, state); } return ir_call::get_error_instruction(); diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 131f23d8c1e..fb3b3450728 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -294,6 +294,12 @@ postfix_expression: } | function_call { + /* Function call parameters used to be stored as a circular list in + * subexpressions[1]. They are now stored as a regular list in + * expressions. This assertion validates that the old code was + * correctly converted. It can eventually be removed. + */ + assert($1->subexpressions[1] == NULL); $$ = $1; } | postfix_expression '.' IDENTIFIER @@ -346,14 +352,13 @@ function_call_header_with_parameters: { $$ = $1; $$->set_location(yylloc); - $$->subexpressions[1] = $2; + insert_at_tail(& $$->expressions, (struct simple_node *) $2); } | function_call_header_with_parameters ',' assignment_expression { $$ = $1; $$->set_location(yylloc); - insert_at_tail((struct simple_node *) $$->subexpressions[1], - (struct simple_node *) $3); + insert_at_tail(& $$->expressions, (struct simple_node *) $3); } ; diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 18280e0301c..201b685189f 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -330,19 +330,13 @@ ast_expression::print(void) const break; case ast_function_call: { - ast_expression *parameters = subexpressions[1]; - subexpressions[0]->print(); printf("( "); - if (parameters != NULL) { - struct simple_node *ptr; - - parameters->print(); - foreach (ptr, (struct simple_node *) parameters) { - printf(", "); - ((ast_node *)ptr)->print(); - } + struct simple_node *ptr; + foreach (ptr, &this->expressions) { + printf(", "); + ((ast_node *)ptr)->print(); } printf(") "); -- cgit v1.2.3 From f4e06981cc85e28a61a1d94681989fb8e45dc310 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 10 May 2010 10:56:03 -0700 Subject: Remove unnecessary include of simple_list.h --- ir.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ir.cpp b/ir.cpp index d2d8b4015b7..76f5bab7311 100644 --- a/ir.cpp +++ b/ir.cpp @@ -22,7 +22,6 @@ */ #include #include "main/imports.h" -#include "main/simple_list.h" #include "ir.h" #include "ir_visitor.h" #include "glsl_types.h" -- cgit v1.2.3 From 4f9d72fa9e2a4ff1a2aca6de8ee4fa93639c75f1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 10 May 2010 11:10:26 -0700 Subject: Loop bodies, then-statements, and else-statements are not lists The statement making up a loop body, a then-statement, or an else-statement are single nodes. If the statement is a block, the single node will be an ast_compound_statement. There is no need to loop at the top level when processing these statements. --- ast_to_hir.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 357683f0c3d..427158cf10e 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2171,21 +2171,11 @@ ast_selection_statement::hir(exec_list *instructions, ir_if *const stmt = new ir_if(condition); - if (then_statement != NULL) { - ast_node *node = (ast_node *) then_statement; - do { - node->hir(& stmt->then_instructions, state); - node = (ast_node *) node->next; - } while (node != then_statement); - } + if (then_statement != NULL) + then_statement->hir(& stmt->then_instructions, state); - if (else_statement != NULL) { - ast_node *node = (ast_node *) else_statement; - do { - node->hir(& stmt->else_instructions, state); - node = (ast_node *) node->next; - } while (node != else_statement); - } + if (else_statement != NULL) + else_statement->hir(& stmt->else_instructions, state); instructions->push_tail(stmt); @@ -2252,13 +2242,8 @@ ast_iteration_statement::hir(exec_list *instructions, if (mode != ast_do_while) condition_to_hir(stmt, state); - if (body != NULL) { - ast_node *node = (ast_node *) body; - do { - node->hir(& stmt->body_instructions, state); - node = (ast_node *) node->next; - } while (node != body); - } + if (body != NULL) + body->hir(& stmt->body_instructions, state); if (rest_expression != NULL) rest_expression->hir(& stmt->body_instructions, state); -- cgit v1.2.3 From 43bfc2b6b5477b24d831f49a6ab2123ce95ba747 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 10 May 2010 11:16:24 -0700 Subject: exec_list: Add macros to get ptr to structure containing a node This has some ugly hackery to work-around C++ fail. I have emperically determined that it works in all the cases that matter. --- list.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/list.h b/list.h index afa32f1ed97..26941746b45 100644 --- a/list.h +++ b/list.h @@ -64,6 +64,9 @@ #ifndef LIST_CONTAINER_H #define LIST_CONTAINER_H +#ifndef __cplusplus +#include +#endif #include struct exec_node { @@ -140,6 +143,30 @@ struct exec_node { #endif }; + +#ifdef __cplusplus +/* This macro will not work correctly if `t' uses virtual inheritance. If you + * are using virtual inheritance, you deserve a slow and painful death. Enjoy! + */ +#define exec_list_offsetof(t, f, p) \ + (((char *) &((t *) p)->f) - ((char *) p)) +#else +#define exec_list_offsetof(t, f, p) offsetof(t, f) +#endif + +/** + * Get a pointer to the structure containing an exec_node + * + * Given a pointer to an \c exec_node embedded in a structure, get a pointer to + * the containing structure. + * + * \param type Base type of the structure containing the node + * \param node Pointer to the \c exec_node + * \param field Name of the field in \c type that is the embedded \c exec_node + */ +#define exec_node_data(type, node, field) \ + ((type *) (((char *) node) - exec_list_offsetof(type, field, node))) + #ifdef __cplusplus struct exec_node; -- cgit v1.2.3 From 752c905b8ca694df1e863d500653b386653c35e7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 10 May 2010 11:17:23 -0700 Subject: exec_list: Add simpler exec_list for-each macros --- list.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/list.h b/list.h index 26941746b45..3bfdf55e2a2 100644 --- a/list.h +++ b/list.h @@ -337,4 +337,14 @@ struct exec_list { #endif }; +#define foreach_list(__node, __list) \ + for (exec_node * __node = (__list)->head \ + ; (__node)->next != NULL \ + ; (__node) = (__node)->next) + +#define foreach_list_const(__node, __list) \ + for (const exec_node * __node = (__list)->head \ + ; (__node)->next != NULL \ + ; (__node) = (__node)->next) + #endif /* LIST_CONTAINER_H */ -- cgit v1.2.3 From 304ea90233baeac6801a98e981658cb7a2d2501c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 10 May 2010 11:17:53 -0700 Subject: Convert ast_node use of simple_node to exec_list and exec_node --- ast.h | 19 ++++++------ ast_function.cpp | 21 ++++++------- ast_to_hir.cpp | 63 ++++++++++++++++++-------------------- glsl_parser.ypp | 82 ++++++++++++++++++++------------------------------ glsl_parser_extras.cpp | 81 ++++++++++++++++++------------------------------- glsl_parser_extras.h | 3 +- 6 files changed, 111 insertions(+), 158 deletions(-) diff --git a/ast.h b/ast.h index 9fa651878e9..1cf80af9144 100644 --- a/ast.h +++ b/ast.h @@ -26,7 +26,6 @@ #ifndef AST_H #define AST_H -#include "main/simple_list.h" #include "list.h" #include "glsl_parser_extras.h" @@ -35,7 +34,7 @@ struct _mesa_glsl_parse_state; struct YYLTYPE; -class ast_node : public simple_node { +class ast_node { public: virtual ~ast_node(); virtual void print(void) const; @@ -81,6 +80,8 @@ public: unsigned column; } location; + exec_node link; + protected: ast_node(void); }; @@ -181,7 +182,7 @@ public: * List of expressions for an \c ast_sequence or parameters for an * \c ast_function_call */ - struct simple_node expressions; + exec_list expressions; }; class ast_expression_bin : public ast_expression { @@ -247,7 +248,7 @@ public: struct _mesa_glsl_parse_state *state); int new_scope; - struct simple_node statements; + exec_list statements; }; class ast_declaration : public ast_node { @@ -294,7 +295,7 @@ public: struct _mesa_glsl_parse_state *state); char *name; - struct simple_node declarations; + exec_list declarations; }; @@ -414,7 +415,7 @@ public: struct _mesa_glsl_parse_state *state); ast_fully_specified_type *type; - struct simple_node declarations; + exec_list declarations; /** * Special flag for vertex shader "invariant" declarations. @@ -439,7 +440,7 @@ public: int is_array; ast_expression *array_size; - static void parameters_to_hir(simple_node *ast_parameters, + static void parameters_to_hir(exec_list *ast_parameters, bool formal, exec_list *ir_parameters, struct _mesa_glsl_parse_state *state); @@ -468,7 +469,7 @@ public: ast_fully_specified_type *return_type; char *identifier; - struct simple_node parameters; + exec_list parameters; private: /** @@ -554,7 +555,7 @@ public: class ast_switch_statement : public ast_node { public: ast_expression *expression; - struct simple_node statements; + exec_list statements; }; class ast_iteration_statement : public ast_node { diff --git a/ast_function.cpp b/ast_function.cpp index 35ffcdbb8bc..7931633c5a1 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -29,15 +29,14 @@ static unsigned process_parameters(exec_list *instructions, exec_list *actual_parameters, - simple_node *parameters, + exec_list *parameters, struct _mesa_glsl_parse_state *state) { - simple_node *ptr; unsigned count = 0; - foreach (ptr, parameters) { - ir_rvalue *const result = - ((ast_node *) ptr)->hir(instructions, state); + foreach_list (n, parameters) { + ast_node *const ast = exec_node_data(ast_node, n, link); + ir_rvalue *const result = ast->hir(instructions, state); actual_parameters->push_tail(result); count++; @@ -107,7 +106,7 @@ process_call(exec_list *instructions, ir_function *f, static ir_rvalue * match_function_by_name(exec_list *instructions, const char *name, - YYLTYPE *loc, simple_node *parameters, + YYLTYPE *loc, exec_list *parameters, struct _mesa_glsl_parse_state *state) { ir_function *f = state->symbols->get_function(name); @@ -216,7 +215,7 @@ dereference_component(ir_rvalue *src, unsigned component) static ir_rvalue * process_array_constructor(exec_list *instructions, const glsl_type *constructor_type, - YYLTYPE *loc, simple_node *parameters, + YYLTYPE *loc, exec_list *parameters, struct _mesa_glsl_parse_state *state) { /* Array constructors come in two forms: sized and unsized. Sized array @@ -358,12 +357,12 @@ ast_function_expression::hir(exec_list *instructions, unsigned nonmatrix_parameters = 0; exec_list actual_parameters; - assert(!is_empty_list(&this->expressions)); + assert(!this->expressions.is_empty()); - simple_node *ptr; - foreach (ptr, &this->expressions) { + foreach_list (n, &this->expressions) { + ast_node *ast = exec_node_data(ast_node, n, link); ir_rvalue *const result = - ((ast_node *) ptr)->hir(instructions, state)->as_rvalue(); + ast->hir(instructions, state)->as_rvalue(); /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: * diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 427158cf10e..0e6cb4f7271 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -59,16 +59,15 @@ void _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - struct simple_node *ptr; - _mesa_glsl_initialize_variables(instructions, state); _mesa_glsl_initialize_constructors(instructions, state); _mesa_glsl_initialize_functions(instructions, state); state->current_function = NULL; - foreach (ptr, & state->translation_unit) { - ((ast_node *)ptr)->hir(instructions, state); + foreach_list (n, & state->translation_unit) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->hir(instructions, state); } } @@ -622,13 +621,11 @@ ast_expression::hir(exec_list *instructions, }; ir_rvalue *result = NULL; ir_rvalue *op[2]; - struct simple_node op_list; const struct glsl_type *type = glsl_type::error_type; bool error_emitted = false; YYLTYPE loc; loc = this->get_location(); - make_empty_list(& op_list); switch (this->oper) { case ast_assign: { @@ -1257,20 +1254,20 @@ ast_expression::hir(exec_list *instructions, break; case ast_sequence: { - struct simple_node *ptr; - /* It should not be possible to generate a sequence in the AST without * any expressions in it. */ - assert(!is_empty_list(&this->expressions)); + assert(!this->expressions.is_empty()); /* The r-value of a sequence is the last expression in the sequence. If * the other expressions in the sequence do not have side-effects (and * therefore add instructions to the instruction list), they get dropped * on the floor. */ - foreach (ptr, &this->expressions) - result = ((ast_node *)ptr)->hir(instructions, state); + foreach_list (n, &this->expressions) { + ast_node *ast = exec_node_data(ast_node, n, link); + result = ast->hir(instructions, state); + } type = result->type; @@ -1314,14 +1311,13 @@ ir_rvalue * ast_compound_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - struct simple_node *ptr; - - if (new_scope) state->symbols->push_scope(); - foreach (ptr, &statements) - ((ast_node *)ptr)->hir(instructions, state); + foreach_list (n, &this->statements) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->hir(instructions, state); + } if (new_scope) state->symbols->pop_scope(); @@ -1472,7 +1468,6 @@ ir_rvalue * ast_declarator_list::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - struct simple_node *ptr; const struct glsl_type *decl_type; const char *type_name = NULL; ir_rvalue *result = NULL; @@ -1489,7 +1484,7 @@ ast_declarator_list::hir(exec_list *instructions, */ decl_type = this->type->specifier->glsl_type(& type_name, state); - if (is_empty_list(&this->declarations)) { + if (this->declarations.is_empty()) { /* There are only two valid cases where the declaration list can be * empty. * @@ -1506,8 +1501,8 @@ ast_declarator_list::hir(exec_list *instructions, } } - foreach (ptr, &this->declarations) { - struct ast_declaration *const decl = (struct ast_declaration * )ptr; + foreach_list (n, &this->declarations) { + ast_declaration *const decl = exec_node_data(ast_declaration, n, link); const struct glsl_type *var_type; struct ir_variable *var; @@ -1875,17 +1870,17 @@ ast_parameter_declarator::hir(exec_list *instructions, void -ast_parameter_declarator::parameters_to_hir(struct simple_node *ast_parameters, +ast_parameter_declarator::parameters_to_hir(exec_list *ast_parameters, bool formal, exec_list *ir_parameters, _mesa_glsl_parse_state *state) { - struct simple_node *ptr; ast_parameter_declarator *void_param = NULL; unsigned count = 0; - foreach (ptr, ast_parameters) { - ast_parameter_declarator *param = (ast_parameter_declarator *)ptr; + foreach_list (n, ast_parameters) { + ast_parameter_declarator *param = + exec_node_data(ast_parameter_declarator, n, link); param->formal_parameter = formal; param->hir(ir_parameters, state); @@ -2279,7 +2274,6 @@ ir_rvalue * ast_struct_specifier::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - simple_node *ptr; unsigned decl_count = 0; /* Make an initial pass over the list of structure fields to determine how @@ -2287,11 +2281,11 @@ ast_struct_specifier::hir(exec_list *instructions, * This means that we actually need to count the number of elements in the * 'declarations' list in each of the elements. */ - foreach (ptr, & this->declarations) { - ast_declarator_list *decl_list = (ast_declarator_list *) ptr; - simple_node *decl_ptr; + foreach_list (n, & this->declarations) { + ast_declarator_list *decl_list = + exec_node_data(ast_declarator_list, n, link); - foreach (decl_ptr, & decl_list->declarations) { + foreach_list_const (decl_ptr, & decl_list->declarations) { decl_count++; } } @@ -2306,9 +2300,9 @@ ast_struct_specifier::hir(exec_list *instructions, malloc(sizeof(*fields) * decl_count); unsigned i = 0; - foreach (ptr, & this->declarations) { - ast_declarator_list *decl_list = (ast_declarator_list *) ptr; - simple_node *decl_ptr; + foreach_list (n, & this->declarations) { + ast_declarator_list *decl_list = + exec_node_data(ast_declarator_list, n, link); const char *type_name; decl_list->type->specifier->hir(instructions, state); @@ -2316,8 +2310,9 @@ ast_struct_specifier::hir(exec_list *instructions, const glsl_type *decl_type = decl_list->type->specifier->glsl_type(& type_name, state); - foreach (decl_ptr, & decl_list->declarations) { - ast_declaration *const decl = (ast_declaration *) decl_ptr; + foreach_list (decl_node, & decl_list->declarations) { + ast_declaration *const decl = + exec_node_data(ast_declaration, decl_node, link); const struct glsl_type *const field_type = (decl->is_array) ? process_array_type(decl_type, decl->array_size, state) diff --git a/glsl_parser.ypp b/glsl_parser.ypp index fb3b3450728..86ec6f58424 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -234,13 +234,11 @@ extension_statement: external_declaration_list: external_declaration { - insert_at_tail(& state->translation_unit, - (struct simple_node *) $1); + state->translation_unit.push_tail(& $1->link); } | external_declaration_list external_declaration { - insert_at_tail(& state->translation_unit, - (struct simple_node *) $2); + state->translation_unit.push_tail(& $2->link); } ; @@ -352,13 +350,13 @@ function_call_header_with_parameters: { $$ = $1; $$->set_location(yylloc); - insert_at_tail(& $$->expressions, (struct simple_node *) $2); + $$->expressions.push_tail(& $2->link); } | function_call_header_with_parameters ',' assignment_expression { $$ = $1; $$->set_location(yylloc); - insert_at_tail(& $$->expressions, (struct simple_node *) $3); + $$->expressions.push_tail(& $3->link); } ; @@ -598,12 +596,12 @@ expression: if ($1->oper != ast_sequence) { $$ = new ast_expression(ast_sequence, NULL, NULL, NULL); $$->set_location(yylloc); - insert_at_tail(& $$->expressions, $1); + $$->expressions.push_tail(& $1->link); } else { $$ = $1; } - insert_at_tail(& $$->expressions, $3); + $$->expressions.push_tail(& $3->link); } ; @@ -639,14 +637,12 @@ function_header_with_parameters: function_header parameter_declaration { $$ = $1; - insert_at_tail(& $$->parameters, - (struct simple_node *) $2); + $$->parameters.push_tail(& $2->link); } | function_header_with_parameters ',' parameter_declaration { $$ = $1; - insert_at_tail(& $$->parameters, - (struct simple_node *) $3); + $$->parameters.push_tail(& $3->link); } ; @@ -735,8 +731,7 @@ init_declarator_list: decl->set_location(yylloc); $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | init_declarator_list ',' IDENTIFIER '[' ']' { @@ -744,8 +739,7 @@ init_declarator_list: decl->set_location(yylloc); $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' { @@ -753,8 +747,7 @@ init_declarator_list: decl->set_location(yylloc); $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer { @@ -762,8 +755,7 @@ init_declarator_list: decl->set_location(yylloc); $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer { @@ -771,8 +763,7 @@ init_declarator_list: decl->set_location(yylloc); $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | init_declarator_list ',' IDENTIFIER '=' initializer { @@ -780,8 +771,7 @@ init_declarator_list: decl->set_location(yylloc); $$ = $1; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } ; @@ -798,8 +788,7 @@ single_declaration: $$ = new ast_declarator_list($1); $$->set_location(yylloc); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | fully_specified_type IDENTIFIER '[' ']' { @@ -807,8 +796,7 @@ single_declaration: $$ = new ast_declarator_list($1); $$->set_location(yylloc); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | fully_specified_type IDENTIFIER '[' constant_expression ']' { @@ -816,8 +804,7 @@ single_declaration: $$ = new ast_declarator_list($1); $$->set_location(yylloc); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | fully_specified_type IDENTIFIER '[' ']' '=' initializer { @@ -825,8 +812,7 @@ single_declaration: $$ = new ast_declarator_list($1); $$->set_location(yylloc); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer { @@ -834,8 +820,7 @@ single_declaration: $$ = new ast_declarator_list($1); $$->set_location(yylloc); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | fully_specified_type IDENTIFIER '=' initializer { @@ -843,8 +828,7 @@ single_declaration: $$ = new ast_declarator_list($1); $$->set_location(yylloc); - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } | INVARIANT IDENTIFIER // Vertex only. { @@ -854,8 +838,7 @@ single_declaration: $$->set_location(yylloc); $$->invariant = true; - insert_at_tail(& $$->declarations, - (struct simple_node *) decl); + $$->declarations.push_tail(&decl->link); } ; @@ -1033,12 +1016,12 @@ struct_declaration_list: struct_declaration { $$ = (struct ast_node *) $1; + $1->link.self_link(); } | struct_declaration_list struct_declaration { $$ = (struct ast_node *) $1; - insert_at_tail((struct simple_node *) $$, - (struct simple_node *) $2); + $$->link.insert_before(& $2->link); } ; @@ -1052,18 +1035,20 @@ struct_declaration: $$ = new ast_declarator_list(type); $$->set_location(yylloc); - insert_at_tail((struct simple_node *) $2, - & $$->declarations); + $$->declarations.push_degenerate_list_at_head(& $2->link); } ; struct_declarator_list: struct_declarator + { + $$ = $1; + $1->link.self_link(); + } | struct_declarator_list ',' struct_declarator { $$ = $1; - insert_at_tail((struct simple_node *) $$, - (struct simple_node *) $3); + $$->link.insert_before(& $3->link); } ; @@ -1154,7 +1139,7 @@ statement_list: } $$ = $1; - make_empty_list((struct simple_node *) $$); + $$->link.self_link(); } | statement_list statement { @@ -1163,8 +1148,7 @@ statement_list: assert($2 != NULL); } $$ = $1; - insert_at_tail((struct simple_node *) $$, - (struct simple_node *) $2); + $$->link.insert_before(& $2->link); } ; @@ -1219,9 +1203,7 @@ condition: decl->set_location(yylloc); declarator->set_location(yylloc); - insert_at_tail(& declarator->declarations, - (struct simple_node *) decl); - + declarator->declarations.push_tail(&decl->link); $$ = declarator; } ; diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 201b685189f..985d3829e65 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -222,7 +222,7 @@ ast_node::print(void) const ast_node::ast_node(void) { - make_empty_list(this); + /* empty */ } @@ -243,12 +243,11 @@ ast_opt_array_size_print(bool is_array, const ast_expression *array_size) void ast_compound_statement::print(void) const { - const struct simple_node *ptr; - printf("{\n"); - foreach(ptr, & statements) { - ((ast_node *)ptr)->print(); + foreach_list_const(n, &this->statements) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); } printf("}\n"); @@ -259,16 +258,9 @@ ast_compound_statement::ast_compound_statement(int new_scope, ast_node *statements) { this->new_scope = new_scope; - make_empty_list(& this->statements); if (statements != NULL) { - /* This seems odd, but it works. The simple_list is, - * basically, a circular list. insert_at_tail adds - * the specified node to the list before the current - * head. - */ - insert_at_tail((struct simple_node *) statements, - & this->statements); + this->statements.push_degenerate_list_at_head(&statements->link); } } @@ -333,10 +325,11 @@ ast_expression::print(void) const subexpressions[0]->print(); printf("( "); - struct simple_node *ptr; - foreach (ptr, &this->expressions) { + foreach_list_const (n, &this->expressions) { printf(", "); - ((ast_node *)ptr)->print(); + + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); } printf(") "); @@ -366,15 +359,13 @@ ast_expression::print(void) const break; case ast_sequence: { - struct simple_node *ptr; - struct simple_node *const head = first_elem(& expressions); - printf("( "); - foreach (ptr, & expressions) { - if (ptr != head) + foreach_list_const(n, & this->expressions) { + if (n != this->expressions.get_head()) printf(", "); - ((ast_node *)ptr)->print(); + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); } printf(") "); break; @@ -395,7 +386,6 @@ ast_expression::ast_expression(int oper, this->subexpressions[0] = ex0; this->subexpressions[1] = ex1; this->subexpressions[2] = ex2; - make_empty_list(& expressions); } @@ -419,13 +409,12 @@ ast_expression_statement::ast_expression_statement(ast_expression *ex) : void ast_function::print(void) const { - struct simple_node *ptr; - return_type->print(); printf(" %s (", identifier); - foreach(ptr, & parameters) { - ((ast_node *)ptr)->print(); + foreach_list_const(n, & this->parameters) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); } printf(")"); @@ -435,7 +424,7 @@ ast_function::print(void) const ast_function::ast_function(void) : is_definition(false), signature(NULL) { - make_empty_list(& parameters); + /* empty */ } @@ -492,9 +481,6 @@ ast_declaration::ast_declaration(char *identifier, int is_array, void ast_declarator_list::print(void) const { - struct simple_node *head; - struct simple_node *ptr; - assert(type || invariant); if (type) @@ -502,12 +488,12 @@ ast_declarator_list::print(void) const else printf("invariant "); - head = first_elem(& declarations); - foreach (ptr, & declarations) { - if (ptr != head) + foreach_list_const (ptr, & this->declarations) { + if (ptr != this->declarations.get_head()) printf(", "); - ((ast_node *)ptr)->print(); + ast_node *ast = exec_node_data(ast_node, ptr, link); + ast->print(); } printf("; "); @@ -517,7 +503,6 @@ ast_declarator_list::print(void) const ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type) { this->type = type; - make_empty_list(& this->declarations); } void @@ -638,11 +623,10 @@ ast_iteration_statement::ast_iteration_statement(int mode, void ast_struct_specifier::print(void) const { - struct simple_node *ptr; - printf("struct %s { ", name); - foreach (ptr, & declarations) { - ((ast_node *)ptr)->print(); + foreach_list_const(n, &this->declarations) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); } printf("} "); } @@ -652,14 +636,7 @@ ast_struct_specifier::ast_struct_specifier(char *identifier, ast_node *declarator_list) { name = identifier; - - /* This seems odd, but it works. The simple_list is, - * basically, a circular list. insert_at_tail adds - * the specified node to the list before the current - * head. - */ - insert_at_tail((struct simple_node *) declarator_list, - & declarations); + this->declarations.push_degenerate_list_at_head(&declarator_list->link); } @@ -712,7 +689,6 @@ main(int argc, char **argv) struct _mesa_glsl_parse_state state; char *shader; size_t shader_len; - struct simple_node *ptr; exec_list instructions; if (argc < 3) { @@ -743,7 +719,7 @@ main(int argc, char **argv) shader = load_text_file(argv[2], & shader_len); state.scanner = NULL; - make_empty_list(& state.translation_unit); + state.translation_unit.make_empty(); state.symbols = new glsl_symbol_table; state.error = false; state.temp_index = 0; @@ -755,8 +731,9 @@ main(int argc, char **argv) _mesa_glsl_parse(& state); _mesa_glsl_lexer_dtor(& state); - foreach (ptr, & state.translation_unit) { - ((ast_node *)ptr)->print(); + foreach_list_const(n, &state.translation_unit) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); } _mesa_ast_to_hir(&instructions, &state); diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index b06b3fe920c..157b9861a31 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -26,7 +26,6 @@ #define GLSL_PARSER_EXTRAS_H #include -#include "main/simple_list.h" #include "glsl_symbol_table.h" enum _mesa_glsl_parser_targets { @@ -38,7 +37,7 @@ enum _mesa_glsl_parser_targets { struct _mesa_glsl_parse_state { void *scanner; - struct simple_node translation_unit; + exec_list translation_unit; glsl_symbol_table *symbols; unsigned language_version; -- cgit v1.2.3 From 3a37b8701cd3e0a86fef59910b20b2af7e4573f6 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 10 May 2010 11:44:09 -0700 Subject: Add the tiniest shell of a flex/bison-based parser. It doesn't really *do* anything yet---merlely parsing a stream of whitespace-separated tokens, (and not interpreting them at all). --- Makefile | 12 ++++++++++++ glcpp-lex.l | 41 +++++++++++++++++++++++++++++++++++++++++ glcpp-parse.y | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ glcpp.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 Makefile create mode 100644 glcpp-lex.l create mode 100644 glcpp-parse.y create mode 100644 glcpp.c diff --git a/Makefile b/Makefile new file mode 100644 index 00000000000..d8357dda0f0 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +glcpp: glcpp.o glcpp-lex.o glcpp-parse.o + +%.c %.h: %.y + bison --defines=$*.h --output=$*.c $^ + +%.c: %.l + flex --outfile=$@ $< + +glcpp-lex.c: glcpp-parse.h + +clean: + rm -f glcpp-lex.c glcpp-parse.c *.o *~ diff --git a/glcpp-lex.l b/glcpp-lex.l new file mode 100644 index 00000000000..9779f2b92e6 --- /dev/null +++ b/glcpp-lex.l @@ -0,0 +1,41 @@ +%{ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include + +#include "glcpp-parse.h" +%} + +%option noyywrap + +%% + + /* Silently eat all whitespace. */ +[[:space:]]+ + + /* Any non-whitespace is a token. */ +[^[:space:]]+ { return TOKEN; } + +%% diff --git a/glcpp-parse.y b/glcpp-parse.y new file mode 100644 index 00000000000..739b2935b3f --- /dev/null +++ b/glcpp-parse.y @@ -0,0 +1,57 @@ +%{ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include + +#define YYSTYPE int + +void +yyerror (const char *error); + +%} + +%token TOKEN + +%% + +input: /* empty */ + | tokens +; + + +tokens: token + | tokens token +; + +token: TOKEN +; + +%% + +void +yyerror (const char *error) +{ + fprintf (stderr, "Parse error: %s\n", error); +} diff --git a/glcpp.c b/glcpp.c new file mode 100644 index 00000000000..09641ceeadb --- /dev/null +++ b/glcpp.c @@ -0,0 +1,28 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +int +main (void) +{ + return yyparse (); +} -- cgit v1.2.3 From 38aa83560be3368b4e9784b3ef8f73144171ca45 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 10 May 2010 11:52:29 -0700 Subject: Make the lexer reentrant (to avoid "still reachable" memory). This allows the final program to be 100% "valgrind clean", (freeing all memory that it allocates). This will make it much easier to ensure that any allocation that parser actions perform are also cleaned up. --- glcpp-lex.l | 2 +- glcpp-parse.y | 7 +++++-- glcpp.c | 9 ++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 9779f2b92e6..276f50ddfe3 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -28,7 +28,7 @@ #include "glcpp-parse.h" %} -%option noyywrap +%option reentrant noyywrap %% diff --git a/glcpp-parse.y b/glcpp-parse.y index 739b2935b3f..9acd549b24c 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -28,10 +28,13 @@ #define YYSTYPE int void -yyerror (const char *error); +yyerror (const char *error, void *scanner); %} +%parse-param {void *scanner} +%lex-param {void *scanner} + %token TOKEN %% @@ -51,7 +54,7 @@ token: TOKEN %% void -yyerror (const char *error) +yyerror (const char *error, void *scanner) { fprintf (stderr, "Parse error: %s\n", error); } diff --git a/glcpp.c b/glcpp.c index 09641ceeadb..90a0e89cfa6 100644 --- a/glcpp.c +++ b/glcpp.c @@ -24,5 +24,12 @@ int main (void) { - return yyparse (); + int ret; + void *scanner; + + yylex_init (&scanner); + ret = yyparse (scanner); + yylex_destroy (scanner); + + return ret; } -- cgit v1.2.3 From a1e32bcff0a04dbff61f28c8e725cf2bf120bf85 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 10 May 2010 13:17:25 -0700 Subject: Add some compiler warnings and corresponding fixes. Most of the current problems were (mostly) harmless things like missing declarations, but there was at least one real error, (reversed argument order for yyerrror). --- Makefile | 2 ++ glcpp-lex.l | 1 + glcpp-parse.y | 6 ++++-- glcpp.c | 2 ++ glcpp.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 glcpp.h diff --git a/Makefile b/Makefile index d8357dda0f0..d0ca78de74c 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +override CFLAGS += -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wno-unused + glcpp: glcpp.o glcpp-lex.o glcpp-parse.o %.c %.h: %.y diff --git a/glcpp-lex.l b/glcpp-lex.l index 276f50ddfe3..747e24056f4 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -25,6 +25,7 @@ #include #include +#include "glcpp.h" #include "glcpp-parse.h" %} diff --git a/glcpp-parse.y b/glcpp-parse.y index 9acd549b24c..a2d10942538 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -25,10 +25,12 @@ #include #include +#include "glcpp.h" + #define YYSTYPE int void -yyerror (const char *error, void *scanner); +yyerror (void *scanner, const char *error); %} @@ -54,7 +56,7 @@ token: TOKEN %% void -yyerror (const char *error, void *scanner) +yyerror (void *scanner, const char *error) { fprintf (stderr, "Parse error: %s\n", error); } diff --git a/glcpp.c b/glcpp.c index 90a0e89cfa6..eefac74be9a 100644 --- a/glcpp.c +++ b/glcpp.c @@ -21,6 +21,8 @@ * DEALINGS IN THE SOFTWARE. */ +#include "glcpp.h" + int main (void) { diff --git a/glcpp.h b/glcpp.h new file mode 100644 index 00000000000..485387b8a5d --- /dev/null +++ b/glcpp.h @@ -0,0 +1,45 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef GLCPP_H +#define GLCPP_H + +/* Generated by glcpp-lex.l to glcpp-lex.c */ + +#define yyscan_t void* + +int +yylex_init (yyscan_t *scanner); + +int +yylex (yyscan_t scanner); + +int +yylex_destroy (yyscan_t scanner); + +/* Generated by glcpp-parse.y to glcpp-parse.c */ + +int +yyparse (void *scanner); + +#endif -- cgit v1.2.3 From a70e7bab2b492f64455c74f2222b363f37dc8dfa Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 10 May 2010 13:32:42 -0700 Subject: Add .gitignore file. To ignore generated source files (and glcpp binary). --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..5bbd660f22b --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +glcpp +glcpp-lex.c +glcpp-parse.c +glcpp-parse.h +*.o +*~ -- cgit v1.2.3 From 633a692225fcdad15ce84776a7a18d7d008d52b3 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 10 May 2010 13:36:26 -0700 Subject: Add hash table implementation from glsl2 project. The preprocessor here is intended to become part of the glsl2 codebase eventually anyway. --- Makefile | 2 +- hash_table.c | 159 ++++++++++++++++++++++++++++++++++++ hash_table.h | 125 ++++++++++++++++++++++++++++ main/imports.h | 6 ++ main/simple_list.h | 235 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 526 insertions(+), 1 deletion(-) create mode 100644 hash_table.c create mode 100644 hash_table.h create mode 100644 main/imports.h create mode 100644 main/simple_list.h diff --git a/Makefile b/Makefile index d0ca78de74c..0af7e05d1b2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ override CFLAGS += -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wno-unused -glcpp: glcpp.o glcpp-lex.o glcpp-parse.o +glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o %.c %.h: %.y bison --defines=$*.h --output=$*.c $^ diff --git a/hash_table.c b/hash_table.c new file mode 100644 index 00000000000..e89a2564d76 --- /dev/null +++ b/hash_table.c @@ -0,0 +1,159 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file hash_table.c + * \brief Implementation of a generic, opaque hash table data type. + * + * \author Ian Romanick + */ + +#include "main/imports.h" +#include "main/simple_list.h" +#include "hash_table.h" + +struct node { + struct node *next; + struct node *prev; +}; + +struct hash_table { + hash_func_t hash; + hash_compare_func_t compare; + + unsigned num_buckets; + struct node buckets[1]; +}; + + +struct hash_node { + struct node link; + const void *key; + void *data; +}; + + +struct hash_table * +hash_table_ctor(unsigned num_buckets, hash_func_t hash, + hash_compare_func_t compare) +{ + struct hash_table *ht; + unsigned i; + + + if (num_buckets < 16) { + num_buckets = 16; + } + + ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1) + * sizeof(ht->buckets[0]))); + if (ht != NULL) { + ht->hash = hash; + ht->compare = compare; + ht->num_buckets = num_buckets; + + for (i = 0; i < num_buckets; i++) { + make_empty_list(& ht->buckets[i]); + } + } + + return ht; +} + + +void +hash_table_dtor(struct hash_table *ht) +{ + hash_table_clear(ht); + _mesa_free(ht); +} + + +void +hash_table_clear(struct hash_table *ht) +{ + struct node *node; + struct node *temp; + unsigned i; + + + for (i = 0; i < ht->num_buckets; i++) { + foreach_s(node, temp, & ht->buckets[i]) { + remove_from_list(node); + _mesa_free(node); + } + + assert(is_empty_list(& ht->buckets[i])); + } +} + + +void * +hash_table_find(struct hash_table *ht, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct node *node; + + foreach(node, & ht->buckets[bucket]) { + struct hash_node *hn = (struct hash_node *) node; + + if ((*ht->compare)(hn->key, key) == 0) { + return hn->data; + } + } + + return NULL; +} + + +void +hash_table_insert(struct hash_table *ht, void *data, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct hash_node *node; + + node = _mesa_calloc(sizeof(*node)); + + node->data = data; + node->key = key; + + insert_at_head(& ht->buckets[bucket], & node->link); +} + + +unsigned +hash_table_string_hash(const void *key) +{ + const char *str = (const char *) key; + unsigned hash = 5381; + + + while (*str != '\0') { + hash = (hash * 33) + *str; + str++; + } + + return hash; +} diff --git a/hash_table.h b/hash_table.h new file mode 100644 index 00000000000..b9dd343dee9 --- /dev/null +++ b/hash_table.h @@ -0,0 +1,125 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file hash_table.h + * \brief Implementation of a generic, opaque hash table data type. + * + * \author Ian Romanick + */ + +#ifndef HASH_TABLE_H +#define HASH_TABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +struct hash_table; + +typedef unsigned (*hash_func_t)(const void *key); +typedef int (*hash_compare_func_t)(const void *key1, const void *key2); + +/** + * Hash table constructor + * + * Creates a hash table with the specified number of buckets. The supplied + * \c hash and \c compare routines are used when adding elements to the table + * and when searching for elements in the table. + * + * \param num_buckets Number of buckets (bins) in the hash table. + * \param hash Function used to compute hash value of input keys. + * \param compare Function used to compare keys. + */ +extern struct hash_table *hash_table_ctor(unsigned num_buckets, + hash_func_t hash, hash_compare_func_t compare); + + +/** + * Release all memory associated with a hash table + * + * \warning + * This function cannot release memory occupied either by keys or data. + */ +extern void hash_table_dtor(struct hash_table *ht); + + +/** + * Flush all entries from a hash table + * + * \param ht Table to be cleared of its entries. + */ +extern void hash_table_clear(struct hash_table *ht); + + +/** + * Search a hash table for a specific element + * + * \param ht Table to be searched + * \param key Key of the desired element + * + * \return + * The \c data value supplied to \c hash_table_insert when the element with + * the matching key was added. If no matching key exists in the table, + * \c NULL is returned. + */ +extern void *hash_table_find(struct hash_table *ht, const void *key); + + +/** + * Add an element to a hash table + */ +extern void hash_table_insert(struct hash_table *ht, void *data, + const void *key); + + +/** + * Compute hash value of a string + * + * Computes the hash value of a string using the DJB2 algorithm developed by + * Professor Daniel J. Bernstein. It was published on comp.lang.c once upon + * a time. I was unable to find the original posting in the archives. + * + * \param key Pointer to a NUL terminated string to be hashed. + * + * \sa hash_table_string_compare + */ +extern unsigned hash_table_string_hash(const void *key); + + +/** + * Compare two strings used as keys + * + * This is just a macro wrapper around \c strcmp. + * + * \sa hash_table_string_hash + */ +#define hash_table_string_compare ((hash_compare_func_t) strcmp) + +#ifdef __cplusplus +}; +#endif + +#endif /* HASH_TABLE_H */ diff --git a/main/imports.h b/main/imports.h new file mode 100644 index 00000000000..d2197342c04 --- /dev/null +++ b/main/imports.h @@ -0,0 +1,6 @@ +#include +#include + +#define _mesa_malloc(x) malloc(x) +#define _mesa_free(x) free(x) +#define _mesa_calloc(x) calloc(1,x) diff --git a/main/simple_list.h b/main/simple_list.h new file mode 100644 index 00000000000..5ef39e14cc6 --- /dev/null +++ b/main/simple_list.h @@ -0,0 +1,235 @@ +/** + * \file simple_list.h + * Simple macros for type-safe, intrusive lists. + * + * Intended to work with a list sentinal which is created as an empty + * list. Insert & delete are O(1). + * + * \author + * (C) 1997, Keith Whitwell + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _SIMPLE_LIST_H +#define _SIMPLE_LIST_H + +struct simple_node { + struct simple_node *next; + struct simple_node *prev; +}; + +/** + * Remove an element from list. + * + * \param elem element to remove. + */ +#define remove_from_list(elem) \ +do { \ + (elem)->next->prev = (elem)->prev; \ + (elem)->prev->next = (elem)->next; \ +} while (0) + +/** + * Insert an element to the list head. + * + * \param list list. + * \param elem element to insert. + */ +#define insert_at_head(list, elem) \ +do { \ + (elem)->prev = list; \ + (elem)->next = (list)->next; \ + (list)->next->prev = elem; \ + (list)->next = elem; \ +} while(0) + +/** + * Insert an element to the list tail. + * + * \param list list. + * \param elem element to insert. + */ +#define insert_at_tail(list, elem) \ +do { \ + (elem)->next = list; \ + (elem)->prev = (list)->prev; \ + (list)->prev->next = elem; \ + (list)->prev = elem; \ +} while(0) + +/** + * Move an element to the list head. + * + * \param list list. + * \param elem element to move. + */ +#define move_to_head(list, elem) \ +do { \ + remove_from_list(elem); \ + insert_at_head(list, elem); \ +} while (0) + +/** + * Move an element to the list tail. + * + * \param list list. + * \param elem element to move. + */ +#define move_to_tail(list, elem) \ +do { \ + remove_from_list(elem); \ + insert_at_tail(list, elem); \ +} while (0) + +/** + * Consatinate a cyclic list to a list + * + * Appends the sequence of nodes starting with \c tail to the list \c head. + * A "cyclic list" is a list that does not have a sentinal node. This means + * that the data pointed to by \c tail is an actual node, not a dataless + * sentinal. Note that if \c tail constist of a single node, this macro + * behaves identically to \c insert_at_tail + * + * \param head Head of the list to be appended to. This may or may not + * be a cyclic list. + * \param tail Head of the cyclic list to be appended to \c head. + * \param temp Temporary \c simple_list used by the macro + * + * \sa insert_at_tail + */ +#define concat_list_and_cycle(head, tail, temp) \ +do { \ + (head)->prev->next = (tail); \ + (tail)->prev->next = (head); \ + (temp) = (head)->prev; \ + (head)->prev = (tail)->prev; \ + (tail)->prev = (temp); \ +} while (0) + +#define concat_list(head, next_list) \ +do { \ + (next_list)->next->prev = (head)->prev; \ + (next_list)->prev->next = (head); \ + (head)->prev->next = (next_list)->next; \ + (head)->prev = (next_list)->prev; \ +} while (0) + +/** + * Make a empty list empty. + * + * \param sentinal list (sentinal element). + */ +#define make_empty_list(sentinal) \ +do { \ + (sentinal)->next = sentinal; \ + (sentinal)->prev = sentinal; \ +} while (0) + +/** + * Get list first element. + * + * \param list list. + * + * \return pointer to first element. + */ +#define first_elem(list) ((list)->next) + +/** + * Get list last element. + * + * \param list list. + * + * \return pointer to last element. + */ +#define last_elem(list) ((list)->prev) + +/** + * Get next element. + * + * \param elem element. + * + * \return pointer to next element. + */ +#define next_elem(elem) ((elem)->next) + +/** + * Get previous element. + * + * \param elem element. + * + * \return pointer to previous element. + */ +#define prev_elem(elem) ((elem)->prev) + +/** + * Test whether element is at end of the list. + * + * \param list list. + * \param elem element. + * + * \return non-zero if element is at end of list, or zero otherwise. + */ +#define at_end(list, elem) ((elem) == (list)) + +/** + * Test if a list is empty. + * + * \param list list. + * + * \return non-zero if list empty, or zero otherwise. + */ +#define is_empty_list(list) ((list)->next == (list)) + +/** + * Walk through the elements of a list. + * + * \param ptr pointer to the current element. + * \param list list. + * + * \note It should be followed by a { } block or a single statement, as in a \c + * for loop. + */ +#define foreach(ptr, list) \ + for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) + +/** + * Walk through the elements of a list. + * + * Same as #foreach but lets you unlink the current value during a list + * traversal. Useful for freeing a list, element by element. + * + * \param ptr pointer to the current element. + * \param t temporary pointer. + * \param list list. + * + * \note It should be followed by a { } block or a single statement, as in a \c + * for loop. + */ +#define foreach_s(ptr, t, list) \ + for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) + +#endif -- cgit v1.2.3 From 725c17a9266c1141508da623c8781412853b70e4 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 10 May 2010 16:14:59 -0700 Subject: Makefile: Enable debugging of parser. This compiles the debugging code for teh parser. It's not active unless the yydebug variable is set to a non-zero value. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0af7e05d1b2..d37e9233ec0 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ override CFLAGS += -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wno-unused glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o %.c %.h: %.y - bison --defines=$*.h --output=$*.c $^ + bison --debug --defines=$*.h --output=$*.c $^ %.c: %.l flex --outfile=$@ $< -- cgit v1.2.3 From 0b27b5f05191f07ed31e65ff07e5233672f3c33a Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 10 May 2010 16:16:06 -0700 Subject: Implment #define By using the recently-imported hash_table implementation. --- glcpp-lex.l | 23 +++++++++++++++++++---- glcpp-parse.y | 49 +++++++++++++++++++++++++++++++++++++++++++------ glcpp.c | 10 ++++++---- glcpp.h | 21 +++++++++++++++++++-- 4 files changed, 87 insertions(+), 16 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 747e24056f4..a220fef76bf 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -31,12 +31,27 @@ %option reentrant noyywrap +%x ST_DEFINE +%x ST_DEFVAL + +SPACE [[:space:]] +NONSPACE [^[:space:]] +NOTNEWLINE [^\n] +HSPACE [ \t] +HASH ^{HSPACE}*# +IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* +DEFVAL {NONSPACE}{NOTNEWLINE}* %% - /* Silently eat all whitespace. */ -[[:space:]]+ +{HASH}define { BEGIN ST_DEFINE; return DEFINE; } + +{HSPACE}+ +{IDENTIFIER} { BEGIN ST_DEFVAL; yylval = strdup (yytext); return IDENTIFIER; } + +{SPACE}+ +{DEFVAL} { BEGIN INITIAL; yylval = strdup (yytext); return DEFVAL; } - /* Any non-whitespace is a token. */ -[^[:space:]]+ { return TOKEN; } + /* Anything we don't specifically recognize is a stream of tokens */ +{NONSPACE}+ { yylval = strdup (yytext); return TOKEN; } %% diff --git a/glcpp-parse.y b/glcpp-parse.y index a2d10942538..89dc46497f5 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -27,30 +27,46 @@ #include "glcpp.h" -#define YYSTYPE int +#define YYLEX_PARAM parser->scanner void yyerror (void *scanner, const char *error); %} -%parse-param {void *scanner} +%parse-param {glcpp_parser_t *parser} %lex-param {void *scanner} +%token DEFINE +%token DEFVAL +%token IDENTIFIER %token TOKEN %% input: /* empty */ - | tokens + | content ; +content: token + | directive + | content token + | content directive +; -tokens: token - | tokens token +directive: DEFINE IDENTIFIER DEFVAL { + hash_table_insert (parser->defines, $3, $2); +} ; -token: TOKEN +token: TOKEN { + char *value = hash_table_find (parser->defines, $1); + if (value) + printf ("%s", value); + else + printf ("%s", $1); + free ($1); +} ; %% @@ -60,3 +76,24 @@ yyerror (void *scanner, const char *error) { fprintf (stderr, "Parse error: %s\n", error); } + +void +glcpp_parser_init (glcpp_parser_t *parser) +{ + yylex_init (&parser->scanner); + parser->defines = hash_table_ctor (32, hash_table_string_hash, + hash_table_string_compare); +} + +int +glcpp_parser_parse (glcpp_parser_t *parser) +{ + return yyparse (parser); +} + +void +glcpp_parser_fini (glcpp_parser_t *parser) +{ + yylex_destroy (parser->scanner); + hash_table_dtor (parser->defines); +} diff --git a/glcpp.c b/glcpp.c index eefac74be9a..d6c89df2f95 100644 --- a/glcpp.c +++ b/glcpp.c @@ -26,12 +26,14 @@ int main (void) { + glcpp_parser_t parser; int ret; - void *scanner; - yylex_init (&scanner); - ret = yyparse (scanner); - yylex_destroy (scanner); + glcpp_parser_init (&parser); + + ret = glcpp_parser_parse (&parser); + + glcpp_parser_fini (&parser); return ret; } diff --git a/glcpp.h b/glcpp.h index 485387b8a5d..5278e1b971b 100644 --- a/glcpp.h +++ b/glcpp.h @@ -24,10 +24,27 @@ #ifndef GLCPP_H #define GLCPP_H -/* Generated by glcpp-lex.l to glcpp-lex.c */ +#include "hash_table.h" +#define YYSTYPE char * #define yyscan_t void* +typedef struct { + yyscan_t scanner; + struct hash_table *defines; +} glcpp_parser_t; + +void +glcpp_parser_init (glcpp_parser_t *parser); + +int +glcpp_parser_parse (glcpp_parser_t *parser); + +void +glcpp_parser_fini (glcpp_parser_t *parser); + +/* Generated by glcpp-lex.l to glcpp-lex.c */ + int yylex_init (yyscan_t *scanner); @@ -40,6 +57,6 @@ yylex_destroy (yyscan_t scanner); /* Generated by glcpp-parse.y to glcpp-parse.c */ int -yyparse (void *scanner); +yyparse (glcpp_parser_t *parser); #endif -- cgit v1.2.3 From e8c790b3ceab06eb0433c3a234d3e16980f7ef19 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 10 May 2010 16:21:10 -0700 Subject: Add a very simple test for the pre-processor. Validate desired test cases by ensuring the output of glcpp matches the output of the gcc preprocessor, (ignoring any lines of the gcc output beginning with '#'). Only one test case so far with a trivial #define. --- .gitignore | 3 +++ Makefile | 4 ++++ tests/001-define.c | 2 ++ tests/glcpp-test | 9 +++++++++ 4 files changed, 18 insertions(+) create mode 100644 tests/001-define.c create mode 100755 tests/glcpp-test diff --git a/.gitignore b/.gitignore index 5bbd660f22b..d67bd38c93c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ glcpp-parse.c glcpp-parse.h *.o *~ +tests/*.expected +tests/*.gcc +tests/*.out diff --git a/Makefile b/Makefile index d37e9233ec0..38cc1f314a9 100644 --- a/Makefile +++ b/Makefile @@ -10,5 +10,9 @@ glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o glcpp-lex.c: glcpp-parse.h +test: + @(cd tests; ./glcpp-test) + clean: rm -f glcpp-lex.c glcpp-parse.c *.o *~ + rm -f tests/*.out tests/*.gcc tests/*.expected diff --git a/tests/001-define.c b/tests/001-define.c new file mode 100644 index 00000000000..cbf2fee0e75 --- /dev/null +++ b/tests/001-define.c @@ -0,0 +1,2 @@ +#define foo 1 +foo diff --git a/tests/glcpp-test b/tests/glcpp-test new file mode 100755 index 00000000000..25685eeabe5 --- /dev/null +++ b/tests/glcpp-test @@ -0,0 +1,9 @@ +#!/bin/sh + +for test in *.c; do + echo "Testing $test" + ../glcpp < $test > $test.out + gcc -E $test -o $test.gcc + grep -v '^#' < $test.gcc > $test.expected + diff -u $test.expected $test.out +done -- cgit v1.2.3 From 4cfbad9e4df4acb011676bde761af557ae58e96a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 10 May 2010 17:40:41 -0700 Subject: exec_list: Add foreach_list_typed and foreach_list_typed_const These variations are parameterized by the type of the nodes in the list. This enables skipping the explicit usage of exec_node_data in the loop body. --- list.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/list.h b/list.h index 3bfdf55e2a2..615be054378 100644 --- a/list.h +++ b/list.h @@ -347,4 +347,16 @@ struct exec_list { ; (__node)->next != NULL \ ; (__node) = (__node)->next) +#define foreach_list_typed(__type, __node, __field, __list) \ + for (__type * __node = \ + exec_node_data(__type, (__list)->head, __field); \ + (__node)->__field.next != NULL; \ + (__node) = exec_node_data(__type, (__node)->__field.next, __field)) + +#define foreach_list_typed_const(__type, __node, __field, __list) \ + for (const __type * __node = \ + exec_node_data(__type, (__list)->head, __field); \ + (__node)->__field.next != NULL; \ + (__node) = exec_node_data(__type, (__node)->__field.next, __field)) + #endif /* LIST_CONTAINER_H */ -- cgit v1.2.3 From 2b97dc657a0e762bc67216405419cd348eb948c0 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 10 May 2010 17:42:05 -0700 Subject: Replace many uses of foreach_list with foreach_list_typed --- ast_to_hir.cpp | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 0e6cb4f7271..2243d644032 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -65,10 +65,8 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) state->current_function = NULL; - foreach_list (n, & state->translation_unit) { - ast_node *ast = exec_node_data(ast_node, n, link); + foreach_list_typed (ast_node, ast, link, & state->translation_unit) ast->hir(instructions, state); - } } @@ -1264,10 +1262,8 @@ ast_expression::hir(exec_list *instructions, * therefore add instructions to the instruction list), they get dropped * on the floor. */ - foreach_list (n, &this->expressions) { - ast_node *ast = exec_node_data(ast_node, n, link); + foreach_list_typed (ast_node, ast, link, &this->expressions) result = ast->hir(instructions, state); - } type = result->type; @@ -1314,10 +1310,8 @@ ast_compound_statement::hir(exec_list *instructions, if (new_scope) state->symbols->push_scope(); - foreach_list (n, &this->statements) { - ast_node *ast = exec_node_data(ast_node, n, link); + foreach_list_typed (ast_node, ast, link, &this->statements) ast->hir(instructions, state); - } if (new_scope) state->symbols->pop_scope(); @@ -1501,8 +1495,7 @@ ast_declarator_list::hir(exec_list *instructions, } } - foreach_list (n, &this->declarations) { - ast_declaration *const decl = exec_node_data(ast_declaration, n, link); + foreach_list_typed (ast_declaration, decl, link, &this->declarations) { const struct glsl_type *var_type; struct ir_variable *var; @@ -1878,9 +1871,7 @@ ast_parameter_declarator::parameters_to_hir(exec_list *ast_parameters, ast_parameter_declarator *void_param = NULL; unsigned count = 0; - foreach_list (n, ast_parameters) { - ast_parameter_declarator *param = - exec_node_data(ast_parameter_declarator, n, link); + foreach_list_typed (ast_parameter_declarator, param, link, ast_parameters) { param->formal_parameter = formal; param->hir(ir_parameters, state); @@ -2281,10 +2272,8 @@ ast_struct_specifier::hir(exec_list *instructions, * This means that we actually need to count the number of elements in the * 'declarations' list in each of the elements. */ - foreach_list (n, & this->declarations) { - ast_declarator_list *decl_list = - exec_node_data(ast_declarator_list, n, link); - + foreach_list_typed (ast_declarator_list, decl_list, link, + &this->declarations) { foreach_list_const (decl_ptr, & decl_list->declarations) { decl_count++; } @@ -2300,9 +2289,8 @@ ast_struct_specifier::hir(exec_list *instructions, malloc(sizeof(*fields) * decl_count); unsigned i = 0; - foreach_list (n, & this->declarations) { - ast_declarator_list *decl_list = - exec_node_data(ast_declarator_list, n, link); + foreach_list_typed (ast_declarator_list, decl_list, link, + &this->declarations) { const char *type_name; decl_list->type->specifier->hir(instructions, state); @@ -2310,9 +2298,8 @@ ast_struct_specifier::hir(exec_list *instructions, const glsl_type *decl_type = decl_list->type->specifier->glsl_type(& type_name, state); - foreach_list (decl_node, & decl_list->declarations) { - ast_declaration *const decl = - exec_node_data(ast_declaration, decl_node, link); + foreach_list_typed (ast_declaration, decl, link, + &decl_list->declarations) { const struct glsl_type *const field_type = (decl->is_array) ? process_array_type(decl_type, decl->array_size, state) -- cgit v1.2.3 From beb26e8ac3152c4a7be43d7ee068b50e17b3ba18 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 11 May 2010 12:04:42 -0700 Subject: Add README file describing glcpp. Mostly this is a place for me to write down the URLs of the GLSL and C99 specifications that I need to write this code. --- README | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 00000000000..ba833a49ffb --- /dev/null +++ b/README @@ -0,0 +1,14 @@ +glcpp -- GLSL "C" preprocessor + +This is a simple preprocessor designed to provide the preprocessing +needs of the GLSL language. The requirements for this preprocessor are +specified in the GLSL 1.30 specification availble from: + +http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.30.08.pdf + +This specification is not precise on some semantics, (for example, +#define and #if), defining these merely "as is standard for C++ +preprocessors". To fill in these details, I've been using the C99 +standard (for which I had a convenient copy) as available from: + +http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf -- cgit v1.2.3 From 49206ef4c8adba5427e9d9b5e0dfc11345262890 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 11 May 2010 12:29:22 -0700 Subject: Add test for chained #define directives. Where one macro is defined in terms of another macro. The current implementation does not yet deal with this correctly. --- tests/002-define-chain.c | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/002-define-chain.c diff --git a/tests/002-define-chain.c b/tests/002-define-chain.c new file mode 100644 index 00000000000..87d75c68751 --- /dev/null +++ b/tests/002-define-chain.c @@ -0,0 +1,3 @@ +#define foo 1 +#define bar foo +bar -- cgit v1.2.3 From c6d5af335121f6027cc46ef9c5aa77aa4e5906ca Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 11 May 2010 12:30:09 -0700 Subject: Fix to handle chained #define directives. The fix is as simple as adding a loop to continue to lookup values in the hash table until one of the following termination conditions: 1. The token we look up has no definition 2. We get back the original symbol we started with This second termination condition prevents infinite iteration. --- glcpp-parse.y | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 89dc46497f5..a3a661b8bef 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -32,6 +32,9 @@ void yyerror (void *scanner, const char *error); +const char * +_resolve_token (glcpp_parser_t *parser, const char *token); + %} %parse-param {glcpp_parser_t *parser} @@ -59,14 +62,7 @@ directive: DEFINE IDENTIFIER DEFVAL { } ; -token: TOKEN { - char *value = hash_table_find (parser->defines, $1); - if (value) - printf ("%s", value); - else - printf ("%s", $1); - free ($1); -} +token: TOKEN { printf ("%s", _resolve_token (parser, $1)); free ($1); } ; %% @@ -97,3 +93,22 @@ glcpp_parser_fini (glcpp_parser_t *parser) yylex_destroy (parser->scanner); hash_table_dtor (parser->defines); } + +const char * +_resolve_token (glcpp_parser_t *parser, const char *token) +{ + const char *orig = token; + const char *replacement; + + while (1) { + replacement = hash_table_find (parser->defines, token); + if (replacement == NULL) + break; + token = replacement; + if (strcmp (token, orig) == 0) + break; + } + + return token; +} + -- cgit v1.2.3 From 34db0d332e0a1477971b7c29c18899e7264f9bce Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 11 May 2010 12:35:06 -0700 Subject: Add a couple more tests for chained #define directives. One with the chained defines in the opposite order, and one with the potential to trigger an infinite-loop bug through mutual recursion. Each of these tests pass already. --- tests/003-define-chain-reverse.c | 3 +++ tests/004-define-recursive.c | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 tests/003-define-chain-reverse.c create mode 100644 tests/004-define-recursive.c diff --git a/tests/003-define-chain-reverse.c b/tests/003-define-chain-reverse.c new file mode 100644 index 00000000000..a18b724eca0 --- /dev/null +++ b/tests/003-define-chain-reverse.c @@ -0,0 +1,3 @@ +#define bar foo +#define foo 1 +bar diff --git a/tests/004-define-recursive.c b/tests/004-define-recursive.c new file mode 100644 index 00000000000..2ac56ea3dcf --- /dev/null +++ b/tests/004-define-recursive.c @@ -0,0 +1,6 @@ +#define foo bar +#define bar baz +#define baz foo +foo +bar +baz -- cgit v1.2.3 From df2ab5b99237ab0b6760226554b133a5ccd11579 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 11 May 2010 12:39:29 -0700 Subject: Add tests defining a macro to be a literal and another macro. These 3 new tests are modeled after 3 existing tests but made slightly more complex since now instead of definining a new macro to be an existing macro, we define it to be replaced with two tokens, (one a literal, and one an existing macro). These tests all fail currently because the replacement lookup is currently happening on the basis of the entire replacement string rather than on a list of tokens. --- tests/005-define-composite-chain.c | 3 +++ tests/006-define-composite-chain-reverse.c | 3 +++ tests/007-define-composite-recursive.c | 6 ++++++ 3 files changed, 12 insertions(+) create mode 100644 tests/005-define-composite-chain.c create mode 100644 tests/006-define-composite-chain-reverse.c create mode 100644 tests/007-define-composite-recursive.c diff --git a/tests/005-define-composite-chain.c b/tests/005-define-composite-chain.c new file mode 100644 index 00000000000..f5521df968d --- /dev/null +++ b/tests/005-define-composite-chain.c @@ -0,0 +1,3 @@ +#define foo 1 +#define bar a foo +bar diff --git a/tests/006-define-composite-chain-reverse.c b/tests/006-define-composite-chain-reverse.c new file mode 100644 index 00000000000..4bb91a1221a --- /dev/null +++ b/tests/006-define-composite-chain-reverse.c @@ -0,0 +1,3 @@ +#define bar a foo +#define foo 1 +bar diff --git a/tests/007-define-composite-recursive.c b/tests/007-define-composite-recursive.c new file mode 100644 index 00000000000..5784565bdf3 --- /dev/null +++ b/tests/007-define-composite-recursive.c @@ -0,0 +1,6 @@ +#define foo a bar +#define bar b baz +#define baz c foo +foo +bar +baz -- cgit v1.2.3 From 33cc400714f379ef13e876b4aedd0de8cb5d033d Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 12 May 2010 12:17:10 -0700 Subject: Fix defines involving both literals and other defined macros. We now store a list of tokens in our hash-table rather than a single string. This lets us replace each macro in the value as necessary. This code adds a link dependency on talloc which does exactly what we want in terms of memory management for a parser. The 3 tests added in the previous commit now pass. --- Makefile | 7 +++ glcpp-lex.l | 34 ++++++++--- glcpp-parse.y | 179 +++++++++++++++++++++++++++++++++++++++++++++++----------- glcpp.c | 10 ++-- glcpp.h | 25 +++++--- 5 files changed, 202 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index 38cc1f314a9..83519328bf6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,13 @@ +# Debug symbols by default, but let the user avoid that with something +# like "make CFLAGS=-O2" +CFLAGS = -g + +# But we use 'override' here so that "make CFLAGS=-O2" will still have +# all the warnings enabled. override CFLAGS += -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wno-unused glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o + gcc -o $@ -ltalloc $^ %.c %.h: %.y bison --debug --defines=$*.h --output=$*.c $^ diff --git a/glcpp-lex.l b/glcpp-lex.l index a220fef76bf..f1a35607794 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -36,22 +36,40 @@ SPACE [[:space:]] NONSPACE [^[:space:]] -NOTNEWLINE [^\n] +NEWLINE [\n] HSPACE [ \t] HASH ^{HSPACE}*# IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* -DEFVAL {NONSPACE}{NOTNEWLINE}* +TOKEN {NONSPACE}+ + %% -{HASH}define { BEGIN ST_DEFINE; return DEFINE; } +{HASH}define{HSPACE}* { + BEGIN ST_DEFINE; + return DEFINE; +} + +{IDENTIFIER} { + yylval.str = strdup (yytext); + return IDENTIFIER; +} + +{TOKEN} { + yylval.str = strdup (yytext); + return TOKEN; +} -{HSPACE}+ -{IDENTIFIER} { BEGIN ST_DEFVAL; yylval = strdup (yytext); return IDENTIFIER; } +\n { + BEGIN INITIAL; + return NEWLINE; +} -{SPACE}+ -{DEFVAL} { BEGIN INITIAL; yylval = strdup (yytext); return DEFVAL; } +{SPACE}+ /* Anything we don't specifically recognize is a stream of tokens */ -{NONSPACE}+ { yylval = strdup (yytext); return TOKEN; } +{NONSPACE}+ { + yylval.str = strdup (yytext); + return TOKEN; +} %% diff --git a/glcpp-parse.y b/glcpp-parse.y index a3a661b8bef..eae96efb30a 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -24,61 +24,158 @@ #include #include +#include #include "glcpp.h" #define YYLEX_PARAM parser->scanner +struct glcpp_parser { + yyscan_t scanner; + struct hash_table *defines; +}; + void yyerror (void *scanner, const char *error); -const char * -_resolve_token (glcpp_parser_t *parser, const char *token); +void +_print_resolved_token (glcpp_parser_t *parser, const char *token); + +list_t * +_list_create (void *ctx); + +void +_list_append (list_t *list, const char *str); %} +%union { + char *str; + list_t *list; +} + %parse-param {glcpp_parser_t *parser} %lex-param {void *scanner} -%token DEFINE -%token DEFVAL -%token IDENTIFIER -%token TOKEN +%token DEFINE IDENTIFIER NEWLINE TOKEN +%type token IDENTIFIER TOKEN +%type replacement_list %% -input: /* empty */ - | content +input: + /* empty */ +| content ; -content: token - | directive - | content token - | content directive +content: + token { + _print_resolved_token (parser, $1); + free ($1); + } +| directive +| content token { + _print_resolved_token (parser, $2); + free ($2); + } +| content directive ; -directive: DEFINE IDENTIFIER DEFVAL { - hash_table_insert (parser->defines, $3, $2); -} +directive: + DEFINE IDENTIFIER replacement_list NEWLINE { + char *key = talloc_strdup ($3, $2); + free ($2); + hash_table_insert (parser->defines, $3, key); + printf ("\n"); + } ; -token: TOKEN { printf ("%s", _resolve_token (parser, $1)); free ($1); } +replacement_list: + /* empty */ { + $$ = _list_create (parser); + } + +| replacement_list token { + _list_append ($1, $2); + free ($2); + $$ = $1; + } +; + +token: + TOKEN { $$ = $1; } +| IDENTIFIER { $$ = $1; } ; %% +list_t * +_list_create (void *ctx) +{ + list_t *list; + + list = talloc (ctx, list_t); + if (list == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + list->head = NULL; + list->tail = NULL; + + return list; +} + +void +_list_append (list_t *list, const char *str) +{ + node_t *node; + + node = talloc (list, node_t); + if (node == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + node->str = talloc_strdup (node, str); + if (node->str == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + node->next = NULL; + + if (list->head == NULL) { + list->head = node; + } else { + list->tail->next = node; + } + + list->tail = node; +} + void yyerror (void *scanner, const char *error) { fprintf (stderr, "Parse error: %s\n", error); } -void -glcpp_parser_init (glcpp_parser_t *parser) +glcpp_parser_t * +glcpp_parser_create (void) { + glcpp_parser_t *parser; + + parser = talloc (NULL, glcpp_parser_t); + if (parser == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + yylex_init (&parser->scanner); parser->defines = hash_table_ctor (32, hash_table_string_hash, hash_table_string_compare); + + return parser; } int @@ -88,27 +185,43 @@ glcpp_parser_parse (glcpp_parser_t *parser) } void -glcpp_parser_fini (glcpp_parser_t *parser) +glcpp_parser_destroy (glcpp_parser_t *parser) { yylex_destroy (parser->scanner); hash_table_dtor (parser->defines); + talloc_free (parser); } -const char * -_resolve_token (glcpp_parser_t *parser, const char *token) +static void +_print_resolved_recursive (glcpp_parser_t *parser, + const char *token, + const char *orig, + int *first) { - const char *orig = token; - const char *replacement; - - while (1) { - replacement = hash_table_find (parser->defines, token); - if (replacement == NULL) - break; - token = replacement; - if (strcmp (token, orig) == 0) - break; + list_t *replacement; + node_t *node; + + replacement = hash_table_find (parser->defines, token); + if (replacement == NULL) { + printf ("%s%s", *first ? "" : " ", token); + *first = 0; + } else { + for (node = replacement->head ; node ; node = node->next) { + token = node->str; + if (strcmp (token, orig) == 0) { + printf ("%s%s", *first ? "" : " ", token); + *first = 0; + } else { + _print_resolved_recursive (parser, token, orig, first); + } + } } - - return token; } +void +_print_resolved_token (glcpp_parser_t *parser, const char *token) +{ + int first = 1; + + _print_resolved_recursive (parser, token, token, &first); +} diff --git a/glcpp.c b/glcpp.c index d6c89df2f95..fcdc4ed8a0f 100644 --- a/glcpp.c +++ b/glcpp.c @@ -23,17 +23,19 @@ #include "glcpp.h" +extern int yydebug; + int main (void) { - glcpp_parser_t parser; + glcpp_parser_t *parser; int ret; - glcpp_parser_init (&parser); + parser = glcpp_parser_create (); - ret = glcpp_parser_parse (&parser); + ret = glcpp_parser_parse (parser); - glcpp_parser_fini (&parser); + glcpp_parser_destroy (parser); return ret; } diff --git a/glcpp.h b/glcpp.h index 5278e1b971b..6fea9333e85 100644 --- a/glcpp.h +++ b/glcpp.h @@ -26,22 +26,31 @@ #include "hash_table.h" -#define YYSTYPE char * #define yyscan_t void* -typedef struct { - yyscan_t scanner; - struct hash_table *defines; -} glcpp_parser_t; +/* Some data types used for parser value. */ -void -glcpp_parser_init (glcpp_parser_t *parser); + +typedef struct node { + const char *str; + struct node *next; +} node_t; + +typedef struct list { + node_t *head; + node_t *tail; +} list_t; + +typedef struct glcpp_parser glcpp_parser_t; + +glcpp_parser_t * +glcpp_parser_create (void); int glcpp_parser_parse (glcpp_parser_t *parser); void -glcpp_parser_fini (glcpp_parser_t *parser); +glcpp_parser_destroy (glcpp_parser_t *parser); /* Generated by glcpp-lex.l to glcpp-lex.c */ -- cgit v1.2.3 From 5070a20cd1e65d52856bd74558f9a34f8dca114f Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 12 May 2010 12:45:33 -0700 Subject: Convert lexer to talloc and add xtalloc wrappers. The lexer was previously using strdup (expecting the parser to free), but is now more consistent, easier to use, and slightly more efficent by using talloc along with the parser. Also, we add xtalloc and xtalloc_strdup wrappers around talloc and talloc_strdup to put all of the out-of-memory-checking code in one place. --- Makefile | 2 +- glcpp-lex.l | 7 ++++--- glcpp-parse.y | 39 ++++++++++----------------------------- glcpp.h | 12 +++++++++++- xtalloc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 34 deletions(-) create mode 100644 xtalloc.c diff --git a/Makefile b/Makefile index 83519328bf6..7233150a80b 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ CFLAGS = -g # all the warnings enabled. override CFLAGS += -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wno-unused -glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o +glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o xtalloc.o gcc -o $@ -ltalloc $^ %.c %.h: %.y diff --git a/glcpp-lex.l b/glcpp-lex.l index f1a35607794..ec91538a73c 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -30,6 +30,7 @@ %} %option reentrant noyywrap +%option extra-type="glcpp_parser_t *" %x ST_DEFINE %x ST_DEFVAL @@ -50,12 +51,12 @@ TOKEN {NONSPACE}+ } {IDENTIFIER} { - yylval.str = strdup (yytext); + yylval.str = xtalloc_strdup (yyextra, yytext); return IDENTIFIER; } {TOKEN} { - yylval.str = strdup (yytext); + yylval.str = xtalloc_strdup (yyextra, yytext); return TOKEN; } @@ -68,7 +69,7 @@ TOKEN {NONSPACE}+ /* Anything we don't specifically recognize is a stream of tokens */ {NONSPACE}+ { - yylval.str = strdup (yytext); + yylval.str = xtalloc_strdup (yyextra, yytext); return TOKEN; } diff --git a/glcpp-parse.y b/glcpp-parse.y index eae96efb30a..1a7ec4970d5 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -71,21 +71,20 @@ input: content: token { _print_resolved_token (parser, $1); - free ($1); + talloc_free ($1); } | directive | content token { _print_resolved_token (parser, $2); - free ($2); + talloc_free ($2); } | content directive ; directive: DEFINE IDENTIFIER replacement_list NEWLINE { - char *key = talloc_strdup ($3, $2); - free ($2); - hash_table_insert (parser->defines, $3, key); + talloc_steal ($3, $2); + hash_table_insert (parser->defines, $3, $2); printf ("\n"); } ; @@ -97,7 +96,7 @@ replacement_list: | replacement_list token { _list_append ($1, $2); - free ($2); + talloc_free ($2); $$ = $1; } ; @@ -114,12 +113,7 @@ _list_create (void *ctx) { list_t *list; - list = talloc (ctx, list_t); - if (list == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - + list = xtalloc (ctx, list_t); list->head = NULL; list->tail = NULL; @@ -131,17 +125,8 @@ _list_append (list_t *list, const char *str) { node_t *node; - node = talloc (list, node_t); - if (node == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - node->str = talloc_strdup (node, str); - if (node->str == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } + node = xtalloc (list, node_t); + node->str = xtalloc_strdup (node, str); node->next = NULL; @@ -165,13 +150,9 @@ glcpp_parser_create (void) { glcpp_parser_t *parser; - parser = talloc (NULL, glcpp_parser_t); - if (parser == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } + parser = xtalloc (NULL, glcpp_parser_t); - yylex_init (&parser->scanner); + yylex_init_extra (parser, &parser->scanner); parser->defines = hash_table_ctor (32, hash_table_string_hash, hash_table_string_compare); diff --git a/glcpp.h b/glcpp.h index 6fea9333e85..8472570ccb6 100644 --- a/glcpp.h +++ b/glcpp.h @@ -55,7 +55,7 @@ glcpp_parser_destroy (glcpp_parser_t *parser); /* Generated by glcpp-lex.l to glcpp-lex.c */ int -yylex_init (yyscan_t *scanner); +yylex_init_extra (glcpp_parser_t *parser, yyscan_t* scanner); int yylex (yyscan_t scanner); @@ -68,4 +68,14 @@ yylex_destroy (yyscan_t scanner); int yyparse (glcpp_parser_t *parser); +/* xtalloc - wrappers around talloc to check for out-of-memory */ + +#define xtalloc(ctx, type) (type *)xtalloc_named_const(ctx, sizeof(type), #type) + +void * +xtalloc_named_const (const void *context, size_t size, const char *name); + +char * +xtalloc_strdup (const void *t, const char *p); + #endif diff --git a/xtalloc.c b/xtalloc.c new file mode 100644 index 00000000000..849e12d3491 --- /dev/null +++ b/xtalloc.c @@ -0,0 +1,52 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include + +void * +xtalloc_named_const (const void *context, size_t size, const char *name) +{ + void *ret; + + ret = talloc_named_const (context, size, name); + if (ret == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + return ret; +} + +char * +xtalloc_strdup (const void *t, const char *p) +{ + char *ret; + + ret = talloc_strdup (t, p); + if (ret == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + return ret; +} -- cgit v1.2.3 From 39cd7c2f2e2d27a93ad63191f02adb56be31c0ce Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 12 May 2010 12:49:07 -0700 Subject: Add test for an empty definition. Happily this one passes without needing any additional code. --- tests/008-define-empty.c | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/008-define-empty.c diff --git a/tests/008-define-empty.c b/tests/008-define-empty.c new file mode 100644 index 00000000000..b1bd17ec215 --- /dev/null +++ b/tests/008-define-empty.c @@ -0,0 +1,2 @@ +#define foo +foo -- cgit v1.2.3 From 7bdd1f36d9f238e6af4846d46b9dd30fffc772a5 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 12 May 2010 12:51:31 -0700 Subject: Add test for #undef. Which hasn't been implemented yet, so this test fails. --- tests/009-undef.c | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/009-undef.c diff --git a/tests/009-undef.c b/tests/009-undef.c new file mode 100644 index 00000000000..3fc1fb44243 --- /dev/null +++ b/tests/009-undef.c @@ -0,0 +1,4 @@ +#define foo 1 +foo +#undef foo +foo -- cgit v1.2.3 From cd27e6413a683d3ba1763ec68edfb1ff13193fc3 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 12 May 2010 13:11:50 -0700 Subject: Add support for the #undef macro. This isn't ideal for two reasons: 1. There's a bunch of stateful redundancy in the lexer that should be cleaned up. 2. The hash table does not provide a mechanism to delete an entry, so we waste memory to add a new NULL entry in front of the existing entry with the same key. But this does at least work, (it passes the recently added undef test case). --- glcpp-lex.l | 19 ++++++++++++++++++- glcpp-parse.y | 26 +++++++++++++++++++++----- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index ec91538a73c..9ec4deb7185 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -33,7 +33,7 @@ %option extra-type="glcpp_parser_t *" %x ST_DEFINE -%x ST_DEFVAL +%x ST_UNDEF SPACE [[:space:]] NONSPACE [^[:space:]] @@ -67,6 +67,23 @@ TOKEN {NONSPACE}+ {SPACE}+ +{HASH}undef{HSPACE}* { + BEGIN ST_UNDEF; + return UNDEF; +} + +{IDENTIFIER} { + yylval.str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; +} + +\n { + BEGIN INITIAL; + return NEWLINE; +} + +{SPACE}+ + /* Anything we don't specifically recognize is a stream of tokens */ {NONSPACE}+ { yylval.str = xtalloc_strdup (yyextra, yytext); diff --git a/glcpp-parse.y b/glcpp-parse.y index 1a7ec4970d5..29614fb1a4d 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -57,7 +57,7 @@ _list_append (list_t *list, const char *str); %parse-param {glcpp_parser_t *parser} %lex-param {void *scanner} -%token DEFINE IDENTIFIER NEWLINE TOKEN +%token DEFINE IDENTIFIER NEWLINE TOKEN UNDEF %type token IDENTIFIER TOKEN %type replacement_list @@ -73,19 +73,35 @@ content: _print_resolved_token (parser, $1); talloc_free ($1); } -| directive +| directive_with_newline | content token { _print_resolved_token (parser, $2); talloc_free ($2); } -| content directive +| content directive_with_newline +; + +directive_with_newline: + directive NEWLINE { + printf ("\n"); + } ; directive: - DEFINE IDENTIFIER replacement_list NEWLINE { + DEFINE IDENTIFIER replacement_list { talloc_steal ($3, $2); hash_table_insert (parser->defines, $3, $2); - printf ("\n"); + } +| UNDEF IDENTIFIER { + list_t *replacement = hash_table_find (parser->defines, $2); + if (replacement) { + /* XXX: Need hash table to support a real way + * to remove an element rather than prefixing + * a new node with data of NULL like this. */ + hash_table_insert (parser->defines, NULL, $2); + talloc_free (replacement); + } + talloc_free ($2); } ; -- cgit v1.2.3 From a68e668b17a00ed5714cdb1e7809b7ba4522d89d Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 12 May 2010 13:14:08 -0700 Subject: Add test case to define, undef, and then again define a macro. Happily, this is another test case that works just fine without any additional code. --- tests/010-undef-re-define.c | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/010-undef-re-define.c diff --git a/tests/010-undef-re-define.c b/tests/010-undef-re-define.c new file mode 100644 index 00000000000..32ff73798b1 --- /dev/null +++ b/tests/010-undef-re-define.c @@ -0,0 +1,6 @@ +#define foo 1 +foo +#undef foo +foo +#define foo 2 +foo -- cgit v1.2.3 From 012295f94c4b02d2683072d9aa6ab56f81409507 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 12 May 2010 13:19:23 -0700 Subject: Simplify lexer significantly (remove all stateful lexing). We are able to remove all state by simply passing NEWLINE through as a token unconditionally (as opposed to only passing newline when on a driective line as we did previously). --- glcpp-lex.l | 41 +++++++++-------------------------------- glcpp-parse.y | 6 ++++++ 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 9ec4deb7185..18d9050d715 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -32,9 +32,6 @@ %option reentrant noyywrap %option extra-type="glcpp_parser_t *" -%x ST_DEFINE -%x ST_UNDEF - SPACE [[:space:]] NONSPACE [^[:space:]] NEWLINE [\n] @@ -46,48 +43,28 @@ TOKEN {NONSPACE}+ %% {HASH}define{HSPACE}* { - BEGIN ST_DEFINE; return DEFINE; } -{IDENTIFIER} { - yylval.str = xtalloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - -{TOKEN} { - yylval.str = xtalloc_strdup (yyextra, yytext); - return TOKEN; -} - -\n { - BEGIN INITIAL; - return NEWLINE; -} - -{SPACE}+ - {HASH}undef{HSPACE}* { - BEGIN ST_UNDEF; return UNDEF; } -{IDENTIFIER} { + +{IDENTIFIER} { yylval.str = xtalloc_strdup (yyextra, yytext); return IDENTIFIER; } -\n { - BEGIN INITIAL; - return NEWLINE; -} - -{SPACE}+ - - /* Anything we don't specifically recognize is a stream of tokens */ -{NONSPACE}+ { +{TOKEN} { yylval.str = xtalloc_strdup (yyextra, yytext); return TOKEN; } +\n { + return NEWLINE; +} + +{SPACE}+ + %% diff --git a/glcpp-parse.y b/glcpp-parse.y index 29614fb1a4d..9883a6f9532 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -74,11 +74,17 @@ content: talloc_free ($1); } | directive_with_newline +| NEWLINE { + printf ("\n"); + } | content token { _print_resolved_token (parser, $2); talloc_free ($2); } | content directive_with_newline +| content NEWLINE { + printf ("\n"); + } ; directive_with_newline: -- cgit v1.2.3 From 8bcb6f1777ff8f763c67552c111ce8e637d78410 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 12 May 2010 13:21:20 -0700 Subject: Remove some redundancy in the top-level production. Previously we had two copies of all top-level actions, (once in a list context and once in a non-list context). Much simpler to instead have a single list-context production with no action and then only have the actions in their own non-list contexts. --- glcpp-parse.y | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 9883a6f9532..91fc5b98fc5 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -65,7 +65,7 @@ _list_append (list_t *list, const char *str); input: /* empty */ -| content +| input content ; content: @@ -77,14 +77,6 @@ content: | NEWLINE { printf ("\n"); } -| content token { - _print_resolved_token (parser, $2); - talloc_free ($2); - } -| content directive_with_newline -| content NEWLINE { - printf ("\n"); - } ; directive_with_newline: -- cgit v1.2.3 From 9f62a7e9e25efd79ebf46c64166876436f88f08a Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 07:38:29 -0700 Subject: Make the lexer distinguish between identifiers and defined macros. This is just a minor style improvement for now. But the same mechanism, (having the lexer peek into the table of defined macros), will be essential when we add function-like macros in addition to the current object-like macros. --- glcpp-lex.l | 5 ++++- glcpp-parse.y | 51 ++++++++++++++++++++++++++++++++++----------------- glcpp.h | 4 ++++ 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 18d9050d715..3622db939e7 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -53,7 +53,10 @@ TOKEN {NONSPACE}+ {IDENTIFIER} { yylval.str = xtalloc_strdup (yyextra, yytext); - return IDENTIFIER; + if (glcpp_parser_macro_defined (yyextra, yylval.str)) + return MACRO; + else + return IDENTIFIER; } {TOKEN} { diff --git a/glcpp-parse.y b/glcpp-parse.y index 91fc5b98fc5..4d6475497bf 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -39,7 +39,7 @@ void yyerror (void *scanner, const char *error); void -_print_resolved_token (glcpp_parser_t *parser, const char *token); +_print_expanded_macro (glcpp_parser_t *parser, const char *macro); list_t * _list_create (void *ctx); @@ -57,8 +57,8 @@ _list_append (list_t *list, const char *str); %parse-param {glcpp_parser_t *parser} %lex-param {void *scanner} -%token DEFINE IDENTIFIER NEWLINE TOKEN UNDEF -%type token IDENTIFIER TOKEN +%token DEFINE IDENTIFIER MACRO NEWLINE TOKEN UNDEF +%type IDENTIFIER MACRO TOKEN string %type replacement_list %% @@ -69,8 +69,16 @@ input: ; content: - token { - _print_resolved_token (parser, $1); + IDENTIFIER { + printf ("%s", $1); + talloc_free ($1); + } +| TOKEN { + printf ("%s", $1); + talloc_free ($1); + } +| MACRO { + _print_expanded_macro (parser, $1); talloc_free ($1); } | directive_with_newline @@ -90,7 +98,7 @@ directive: talloc_steal ($3, $2); hash_table_insert (parser->defines, $3, $2); } -| UNDEF IDENTIFIER { +| UNDEF MACRO { list_t *replacement = hash_table_find (parser->defines, $2); if (replacement) { /* XXX: Need hash table to support a real way @@ -108,16 +116,17 @@ replacement_list: $$ = _list_create (parser); } -| replacement_list token { +| replacement_list string { _list_append ($1, $2); talloc_free ($2); $$ = $1; } ; -token: - TOKEN { $$ = $1; } -| IDENTIFIER { $$ = $1; } +string: + IDENTIFIER { $$ = $1; } +| MACRO { $$ = $1; } +| TOKEN { $$ = $1; } ; %% @@ -187,11 +196,17 @@ glcpp_parser_destroy (glcpp_parser_t *parser) talloc_free (parser); } +int +glcpp_parser_macro_defined (glcpp_parser_t *parser, const char *identifier) +{ + return (hash_table_find (parser->defines, identifier) != NULL); +} + static void -_print_resolved_recursive (glcpp_parser_t *parser, - const char *token, - const char *orig, - int *first) +_print_expanded_macro_recursive (glcpp_parser_t *parser, + const char *token, + const char *orig, + int *first) { list_t *replacement; node_t *node; @@ -207,16 +222,18 @@ _print_resolved_recursive (glcpp_parser_t *parser, printf ("%s%s", *first ? "" : " ", token); *first = 0; } else { - _print_resolved_recursive (parser, token, orig, first); + _print_expanded_macro_recursive (parser, + token, orig, + first); } } } } void -_print_resolved_token (glcpp_parser_t *parser, const char *token) +_print_expanded_macro (glcpp_parser_t *parser, const char *macro) { int first = 1; - _print_resolved_recursive (parser, token, token, &first); + _print_expanded_macro_recursive (parser, macro, macro, &first); } diff --git a/glcpp.h b/glcpp.h index 8472570ccb6..39d6d5d0ebb 100644 --- a/glcpp.h +++ b/glcpp.h @@ -52,6 +52,10 @@ glcpp_parser_parse (glcpp_parser_t *parser); void glcpp_parser_destroy (glcpp_parser_t *parser); +int +glcpp_parser_macro_defined (glcpp_parser_t *parser, + const char *identifier); + /* Generated by glcpp-lex.l to glcpp-lex.c */ int -- cgit v1.2.3 From 4abc3dec720933e78a266417cffb2ea7b16d497f Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 09:34:21 -0700 Subject: Add tests for the structure of function-like macros. These test only the most basic aspect of parsing of function-like macros. Specifically, none of the definitions of these function like macros use the arguments of the function. No function-like macros are implemented yet, so all of these fail for now. --- tests/011-define-func-empty.c | 2 ++ tests/012-define-func-no-args.c | 2 ++ tests/013-define-func-1-arg-unused.c | 2 ++ tests/014-define-func-2-arg-unused.c | 2 ++ 4 files changed, 8 insertions(+) create mode 100644 tests/011-define-func-empty.c create mode 100644 tests/012-define-func-no-args.c create mode 100644 tests/013-define-func-1-arg-unused.c create mode 100644 tests/014-define-func-2-arg-unused.c diff --git a/tests/011-define-func-empty.c b/tests/011-define-func-empty.c new file mode 100644 index 00000000000..d9ce13c2284 --- /dev/null +++ b/tests/011-define-func-empty.c @@ -0,0 +1,2 @@ +#define foo() +foo() diff --git a/tests/012-define-func-no-args.c b/tests/012-define-func-no-args.c new file mode 100644 index 00000000000..c2bb730b115 --- /dev/null +++ b/tests/012-define-func-no-args.c @@ -0,0 +1,2 @@ +#define foo() bar +foo() diff --git a/tests/013-define-func-1-arg-unused.c b/tests/013-define-func-1-arg-unused.c new file mode 100644 index 00000000000..f78fb8b118a --- /dev/null +++ b/tests/013-define-func-1-arg-unused.c @@ -0,0 +1,2 @@ +#define foo(x) 1 +foo(bar) diff --git a/tests/014-define-func-2-arg-unused.c b/tests/014-define-func-2-arg-unused.c new file mode 100644 index 00000000000..11feb2624b7 --- /dev/null +++ b/tests/014-define-func-2-arg-unused.c @@ -0,0 +1,2 @@ +#define foo(x,y) 1 +foo(bar,baz) -- cgit v1.2.3 From fcbbb4688641e46270ba0cd531639df9b964f697 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 09:36:23 -0700 Subject: Add support for the structure of function-like macros. We accept the structure of arguments in both macro definition and macro invocation, but we don't yet expand those arguments. This is just enough code to pass the recently-added tests, but does not yet provide any sort of useful function-like macro. --- Makefile | 2 +- glcpp-lex.l | 20 ++++-- glcpp-parse.y | 214 +++++++++++++++++++++++++++++++++++++++++++++++++++------- glcpp.h | 12 +++- 4 files changed, 214 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index 7233150a80b..c5472a86b3c 100644 --- a/Makefile +++ b/Makefile @@ -22,4 +22,4 @@ test: clean: rm -f glcpp-lex.c glcpp-parse.c *.o *~ - rm -f tests/*.out tests/*.gcc tests/*.expected + rm -f tests/*.out tests/*.gcc tests/*.expected tests/*~ diff --git a/glcpp-lex.l b/glcpp-lex.l index 3622db939e7..c6e545aa8ed 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -38,7 +38,7 @@ NEWLINE [\n] HSPACE [ \t] HASH ^{HSPACE}*# IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* -TOKEN {NONSPACE}+ +TOKEN [^[:space:](),]+ %% @@ -53,12 +53,22 @@ TOKEN {NONSPACE}+ {IDENTIFIER} { yylval.str = xtalloc_strdup (yyextra, yytext); - if (glcpp_parser_macro_defined (yyextra, yylval.str)) - return MACRO; - else - return IDENTIFIER; + switch (glcpp_parser_macro_type (yyextra, yylval.str)) + { + case MACRO_TYPE_UNDEFINED: + return IDENTIFIER; + break; + case MACRO_TYPE_OBJECT: + return OBJ_MACRO; + break; + case MACRO_TYPE_FUNCTION: + return FUNC_MACRO; + break; + } } +[(),] { return yytext[0]; } + {TOKEN} { yylval.str = xtalloc_strdup (yyextra, yytext); return TOKEN; diff --git a/glcpp-parse.y b/glcpp-parse.y index 4d6475497bf..2e40db525b8 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -24,12 +24,19 @@ #include #include +#include #include #include "glcpp.h" #define YYLEX_PARAM parser->scanner +typedef struct { + int is_function; + list_t *parameter_list; + list_t *replacement_list; +} macro_t; + struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; @@ -39,13 +46,32 @@ void yyerror (void *scanner, const char *error); void -_print_expanded_macro (glcpp_parser_t *parser, const char *macro); +_define_object_macro (glcpp_parser_t *parser, + const char *macro, + list_t *replacement_list); + +void +_define_function_macro (glcpp_parser_t *parser, + const char *macro, + list_t *parameter_list, + list_t *replacement_list); + +void +_print_expanded_object_macro (glcpp_parser_t *parser, const char *macro); + +void +_print_expanded_function_macro (glcpp_parser_t *parser, + const char *macro, + list_t *arguments); list_t * _list_create (void *ctx); void -_list_append (list_t *list, const char *str); +_list_append_item (list_t *list, const char *str); + +void +_list_append_list (list_t *list, list_t *tail); %} @@ -57,9 +83,9 @@ _list_append (list_t *list, const char *str); %parse-param {glcpp_parser_t *parser} %lex-param {void *scanner} -%token DEFINE IDENTIFIER MACRO NEWLINE TOKEN UNDEF -%type IDENTIFIER MACRO TOKEN string -%type replacement_list +%token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO TOKEN UNDEF +%type FUNC_MACRO IDENTIFIER OBJ_MACRO TOKEN string +%type argument argument_list parameter_list replacement_list %% @@ -77,16 +103,48 @@ content: printf ("%s", $1); talloc_free ($1); } -| MACRO { - _print_expanded_macro (parser, $1); - talloc_free ($1); - } +| macro | directive_with_newline | NEWLINE { printf ("\n"); } ; +macro: + FUNC_MACRO '(' argument_list ')' { + _print_expanded_function_macro (parser, $1, $3); + } +| OBJ_MACRO { + _print_expanded_object_macro (parser, $1); + talloc_free ($1); + } +; + +argument_list: + /* empty */ { + $$ = _list_create (parser); + } +| argument { + $$ = _list_create (parser); + _list_append_list ($$, $1); + } +| argument_list ',' argument { + _list_append_list ($1, $3); + $$ = $1; + } +; + +argument: + /* empty */ { + $$ = _list_create (parser); + } +| argument string { + _list_append_item ($1, $2); + talloc_free ($2); + } +| argument '(' argument ')' +; + directive_with_newline: directive NEWLINE { printf ("\n"); @@ -95,10 +153,23 @@ directive_with_newline: directive: DEFINE IDENTIFIER replacement_list { - talloc_steal ($3, $2); - hash_table_insert (parser->defines, $3, $2); + _define_object_macro (parser, $2, $3); + } +| DEFINE IDENTIFIER '(' parameter_list ')' replacement_list { + _define_function_macro (parser, $2, $4, $6); + } +| UNDEF FUNC_MACRO { + list_t *replacement = hash_table_find (parser->defines, $2); + if (replacement) { + /* XXX: Need hash table to support a real way + * to remove an element rather than prefixing + * a new node with data of NULL like this. */ + hash_table_insert (parser->defines, NULL, $2); + talloc_free (replacement); + } + talloc_free ($2); } -| UNDEF MACRO { +| UNDEF OBJ_MACRO { list_t *replacement = hash_table_find (parser->defines, $2); if (replacement) { /* XXX: Need hash table to support a real way @@ -115,17 +186,33 @@ replacement_list: /* empty */ { $$ = _list_create (parser); } - | replacement_list string { - _list_append ($1, $2); + _list_append_item ($1, $2); talloc_free ($2); $$ = $1; } ; +parameter_list: + /* empty */ { + $$ = _list_create (parser); + } +| IDENTIFIER { + $$ = _list_create (parser); + _list_append_item ($$, $1); + talloc_free ($1); + } +| parameter_list ',' IDENTIFIER { + _list_append_item ($1, $3); + talloc_free ($3); + $$ = $1; + } +; + string: IDENTIFIER { $$ = $1; } -| MACRO { $$ = $1; } +| FUNC_MACRO { $$ = $1; } +| OBJ_MACRO { $$ = $1; } | TOKEN { $$ = $1; } ; @@ -144,7 +231,19 @@ _list_create (void *ctx) } void -_list_append (list_t *list, const char *str) +_list_append_list (list_t *list, list_t *tail) +{ + if (list->head == NULL) { + list->head = tail->head; + } else { + list->tail->next = tail->head; + } + + list->tail = tail->tail; +} + +void +_list_append_item (list_t *list, const char *str) { node_t *node; @@ -196,10 +295,20 @@ glcpp_parser_destroy (glcpp_parser_t *parser) talloc_free (parser); } -int -glcpp_parser_macro_defined (glcpp_parser_t *parser, const char *identifier) +macro_type_t +glcpp_parser_macro_type (glcpp_parser_t *parser, const char *identifier) { - return (hash_table_find (parser->defines, identifier) != NULL); + macro_t *macro; + + macro = hash_table_find (parser->defines, identifier); + + if (macro == NULL) + return MACRO_TYPE_UNDEFINED; + + if (macro->is_function) + return MACRO_TYPE_FUNCTION; + else + return MACRO_TYPE_OBJECT; } static void @@ -208,15 +317,17 @@ _print_expanded_macro_recursive (glcpp_parser_t *parser, const char *orig, int *first) { - list_t *replacement; + macro_t *macro; node_t *node; - replacement = hash_table_find (parser->defines, token); - if (replacement == NULL) { + macro = hash_table_find (parser->defines, token); + if (macro == NULL) { printf ("%s%s", *first ? "" : " ", token); *first = 0; } else { - for (node = replacement->head ; node ; node = node->next) { + list_t *replacement_list = macro->replacement_list; + + for (node = replacement_list->head ; node ; node = node->next) { token = node->str; if (strcmp (token, orig) == 0) { printf ("%s%s", *first ? "" : " ", token); @@ -231,9 +342,62 @@ _print_expanded_macro_recursive (glcpp_parser_t *parser, } void -_print_expanded_macro (glcpp_parser_t *parser, const char *macro) +_define_object_macro (glcpp_parser_t *parser, + const char *identifier, + list_t *replacement_list) +{ + macro_t *macro; + + macro = xtalloc (parser, macro_t); + + macro->is_function = 0; + macro->parameter_list = NULL; + macro->replacement_list = talloc_steal (macro, replacement_list); + + hash_table_insert (parser->defines, macro, identifier); +} + +void +_define_function_macro (glcpp_parser_t *parser, + const char *identifier, + list_t *parameter_list, + list_t *replacement_list) +{ + macro_t *macro; + + macro = xtalloc (parser, macro_t); + + macro->is_function = 1; + macro->parameter_list = talloc_steal (macro, parameter_list); + macro->replacement_list = talloc_steal (macro, replacement_list); + + hash_table_insert (parser->defines, macro, identifier); +} + +void +_print_expanded_object_macro (glcpp_parser_t *parser, const char *identifier) { int first = 1; + macro_t *macro; + + macro = hash_table_find (parser->defines, identifier); + assert (! macro->is_function); + + _print_expanded_macro_recursive (parser, identifier, identifier, &first); +} + +void +_print_expanded_function_macro (glcpp_parser_t *parser, + const char *identifier, + list_t *arguments) +{ + int first = 1; + macro_t *macro; + + macro = hash_table_find (parser->defines, identifier); + assert (macro->is_function); + + /* XXX: Need to use argument list here in the expansion. */ - _print_expanded_macro_recursive (parser, macro, macro, &first); + _print_expanded_macro_recursive (parser, identifier, identifier, &first); } diff --git a/glcpp.h b/glcpp.h index 39d6d5d0ebb..69b3b840aed 100644 --- a/glcpp.h +++ b/glcpp.h @@ -52,9 +52,15 @@ glcpp_parser_parse (glcpp_parser_t *parser); void glcpp_parser_destroy (glcpp_parser_t *parser); -int -glcpp_parser_macro_defined (glcpp_parser_t *parser, - const char *identifier); +typedef enum { + MACRO_TYPE_UNDEFINED, + MACRO_TYPE_OBJECT, + MACRO_TYPE_FUNCTION +} macro_type_t; + +macro_type_t +glcpp_parser_macro_type (glcpp_parser_t *parser, + const char *identifier); /* Generated by glcpp-lex.l to glcpp-lex.c */ -- cgit v1.2.3 From db35d557a40b9fb56483f77da2fb98f541808dd0 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 08:47:32 -0700 Subject: Eliminate a reduce/reduce conflict in the function-like macro production. Previously, an empty argument could be parsed as either an "argument_list" directly or first as an "argument" and then an "argument_list". We fix this by removing the possibility of an empty "argument_list" directly. --- glcpp-parse.y | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 2e40db525b8..66725db69ed 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -121,10 +121,7 @@ macro: ; argument_list: - /* empty */ { - $$ = _list_create (parser); - } -| argument { + argument { $$ = _list_create (parser); _list_append_list ($$, $1); } -- cgit v1.2.3 From 67c27afc168f85ce6dc66820db864aaaef67f8ed Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 10:26:58 -0700 Subject: Add test for an object-like macro with a definition beginning with '(' Our current parser sees "#define foo (" as an identifier token followed by a '(' token and parses this as a function-like macro. That would be correct for "#define foo(" but the preprocessor specification treats this whitespace as significant here so this test currently fails. --- tests/015-define-object-with-parens.c | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/015-define-object-with-parens.c diff --git a/tests/015-define-object-with-parens.c b/tests/015-define-object-with-parens.c new file mode 100644 index 00000000000..7dcadfa24fd --- /dev/null +++ b/tests/015-define-object-with-parens.c @@ -0,0 +1,2 @@ +#define foo ( ) 1 +foo() -- cgit v1.2.3 From 0a93cbbe4f00e0bdd0c61119d3598e3a98a37505 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 10:29:07 -0700 Subject: Fix parsing of object-like macro with a definition that begins with '('. Previously our parser was incorrectly treating this case as a function-like macro. We fix this by conditionally passing a SPACE token from the lexer, (but only immediately after the identifier immediately after #define). --- glcpp-lex.l | 41 ++++++++++++++++++++++++++++++++++++----- glcpp-parse.y | 32 ++++++++++++++++++++++---------- 2 files changed, 58 insertions(+), 15 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index c6e545aa8ed..3c9dda46d47 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -32,6 +32,9 @@ %option reentrant noyywrap %option extra-type="glcpp_parser_t *" +%x ST_DEFINE +%x ST_DEFVAL + SPACE [[:space:]] NONSPACE [^[:space:]] NEWLINE [\n] @@ -42,16 +45,42 @@ TOKEN [^[:space:](),]+ %% -{HASH}define{HSPACE}* { +{HASH}undef{HSPACE}* { + return UNDEF; +} + + /* We use the ST_DEFINE and ST_DEFVAL states so that we can + * pass a space token, (yes, a token for whitespace!), since + * the preprocessor specification requires distinguishing + * "#define foo()" from "#define foo ()". + */ +{HASH}define{HSPACE}* { + BEGIN ST_DEFINE; return DEFINE; } -{HASH}undef{HSPACE}* { - return UNDEF; +{IDENTIFIER} { + BEGIN ST_DEFVAL; + yylval.str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; } +\n { + BEGIN INITIAL; + return NEWLINE; +} + +{HSPACE}+ { + BEGIN INITIAL; + return SPACE; +} -{IDENTIFIER} { +"(" { + BEGIN INITIAL; + return '('; +} + +{IDENTIFIER} { yylval.str = xtalloc_strdup (yyextra, yytext); switch (glcpp_parser_macro_type (yyextra, yylval.str)) { @@ -67,7 +96,9 @@ TOKEN [^[:space:](),]+ } } -[(),] { return yytext[0]; } +[(),] { + return yytext[0]; +} {TOKEN} { yylval.str = xtalloc_strdup (yyextra, yytext); diff --git a/glcpp-parse.y b/glcpp-parse.y index 66725db69ed..dc352de55b6 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -83,8 +83,8 @@ _list_append_list (list_t *list, list_t *tail); %parse-param {glcpp_parser_t *parser} %lex-param {void *scanner} -%token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO TOKEN UNDEF -%type FUNC_MACRO IDENTIFIER OBJ_MACRO TOKEN string +%token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO SPACE TOKEN UNDEF +%type FUNC_MACRO IDENTIFIER OBJ_MACRO TOKEN word word_or_symbol %type argument argument_list parameter_list replacement_list %% @@ -105,9 +105,10 @@ content: } | macro | directive_with_newline -| NEWLINE { - printf ("\n"); - } +| NEWLINE { printf ("\n"); } +| '(' { printf ("("); } +| ')' { printf (")"); } +| ',' { printf (","); } ; macro: @@ -135,7 +136,7 @@ argument: /* empty */ { $$ = _list_create (parser); } -| argument string { +| argument word { _list_append_item ($1, $2); talloc_free ($2); } @@ -149,8 +150,12 @@ directive_with_newline: ; directive: - DEFINE IDENTIFIER replacement_list { - _define_object_macro (parser, $2, $3); + DEFINE IDENTIFIER { + list_t *list = _list_create (parser); + _define_object_macro (parser, $2, list); + } +| DEFINE IDENTIFIER SPACE replacement_list { + _define_object_macro (parser, $2, $4); } | DEFINE IDENTIFIER '(' parameter_list ')' replacement_list { _define_function_macro (parser, $2, $4, $6); @@ -183,7 +188,7 @@ replacement_list: /* empty */ { $$ = _list_create (parser); } -| replacement_list string { +| replacement_list word_or_symbol { _list_append_item ($1, $2); talloc_free ($2); $$ = $1; @@ -206,7 +211,14 @@ parameter_list: } ; -string: +word_or_symbol: + word { $$ = $1; } +| '(' { $$ = xtalloc_strdup (parser, "("); } +| ')' { $$ = xtalloc_strdup (parser, ")"); } +| ',' { $$ = xtalloc_strdup (parser, ","); } +; + +word: IDENTIFIER { $$ = $1; } | FUNC_MACRO { $$ = $1; } | OBJ_MACRO { $$ = $1; } -- cgit v1.2.3 From 27bc8930ba9ba67f2de29a03232a948316409ded Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 10:41:53 -0700 Subject: Add some whitespace variations to test 15. This shows two minor failures in our current parsing (resulting in whitespace-only changes, oso not that significant): 1. We are inserting extra whitespace between tokens not originally separated by whitespace in the replacement list of a macro definition. 2. We are swallowing whitespace separating tokens in the general content. --- tests/015-define-object-with-parens.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/015-define-object-with-parens.c b/tests/015-define-object-with-parens.c index 7dcadfa24fd..10bf7e31a34 100644 --- a/tests/015-define-object-with-parens.c +++ b/tests/015-define-object-with-parens.c @@ -1,2 +1,4 @@ #define foo ( ) 1 foo() +#define bar () 2 +bar( ) -- cgit v1.2.3 From 462cce1852c80a2d71bfec1a2ead10fe0a9e2486 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 10:45:32 -0700 Subject: Makefile: Make "make test" depend on the main program. Otherwise, running "make test" can run an old version of the code, (even when new changes are sitting in the source waiting to be compiled). --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c5472a86b3c..550945abd30 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o xtalloc.o glcpp-lex.c: glcpp-parse.h -test: +test: glcpp @(cd tests; ./glcpp-test) clean: -- cgit v1.2.3 From 48b94da0994b44e41324a2419117dcd81facce8b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 10:46:29 -0700 Subject: Make the lexer return SPACE tokens unconditionally. It seems strange to always be returning SPACE tokens, but since we were already needing to return a SPACE token in some cases, this actually simplifies our lexer. This also allows us to fix two whitespace-handling differences compared to "gcc -E" so that now the recent modification to the test suite passes once again. --- glcpp-lex.l | 29 +++-------------------------- glcpp-parse.y | 37 +++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 44 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 3c9dda46d47..21b9e3530aa 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -32,9 +32,6 @@ %option reentrant noyywrap %option extra-type="glcpp_parser_t *" -%x ST_DEFINE -%x ST_DEFVAL - SPACE [[:space:]] NONSPACE [^[:space:]] NEWLINE [\n] @@ -55,31 +52,9 @@ TOKEN [^[:space:](),]+ * "#define foo()" from "#define foo ()". */ {HASH}define{HSPACE}* { - BEGIN ST_DEFINE; return DEFINE; } -{IDENTIFIER} { - BEGIN ST_DEFVAL; - yylval.str = xtalloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - -\n { - BEGIN INITIAL; - return NEWLINE; -} - -{HSPACE}+ { - BEGIN INITIAL; - return SPACE; -} - -"(" { - BEGIN INITIAL; - return '('; -} - {IDENTIFIER} { yylval.str = xtalloc_strdup (yyextra, yytext); switch (glcpp_parser_macro_type (yyextra, yylval.str)) @@ -109,6 +84,8 @@ TOKEN [^[:space:](),]+ return NEWLINE; } -{SPACE}+ +{HSPACE}+ { + return SPACE; +} %% diff --git a/glcpp-parse.y b/glcpp-parse.y index dc352de55b6..7d1c3ab927f 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -109,6 +109,7 @@ content: | '(' { printf ("("); } | ')' { printf (")"); } | ',' { printf (","); } +| SPACE { printf (" "); } ; macro: @@ -157,8 +158,12 @@ directive: | DEFINE IDENTIFIER SPACE replacement_list { _define_object_macro (parser, $2, $4); } -| DEFINE IDENTIFIER '(' parameter_list ')' replacement_list { - _define_function_macro (parser, $2, $4, $6); +| DEFINE IDENTIFIER '(' parameter_list ')' { + list_t *list = _list_create (parser); + _define_function_macro (parser, $2, $4, list); + } +| DEFINE IDENTIFIER '(' parameter_list ')' SPACE replacement_list { + _define_function_macro (parser, $2, $4, $7); } | UNDEF FUNC_MACRO { list_t *replacement = hash_table_find (parser->defines, $2); @@ -185,8 +190,10 @@ directive: ; replacement_list: - /* empty */ { + word_or_symbol { $$ = _list_create (parser); + _list_append_item ($$, $1); + talloc_free ($1); } | replacement_list word_or_symbol { _list_append_item ($1, $2); @@ -216,6 +223,7 @@ word_or_symbol: | '(' { $$ = xtalloc_strdup (parser, "("); } | ')' { $$ = xtalloc_strdup (parser, ")"); } | ',' { $$ = xtalloc_strdup (parser, ","); } +| SPACE { $$ = xtalloc_strdup (parser, " "); } ; word: @@ -323,29 +331,24 @@ glcpp_parser_macro_type (glcpp_parser_t *parser, const char *identifier) static void _print_expanded_macro_recursive (glcpp_parser_t *parser, const char *token, - const char *orig, - int *first) + const char *orig) { macro_t *macro; node_t *node; macro = hash_table_find (parser->defines, token); if (macro == NULL) { - printf ("%s%s", *first ? "" : " ", token); - *first = 0; + printf ("%s", token); } else { list_t *replacement_list = macro->replacement_list; for (node = replacement_list->head ; node ; node = node->next) { token = node->str; - if (strcmp (token, orig) == 0) { - printf ("%s%s", *first ? "" : " ", token); - *first = 0; - } else { + if (strcmp (token, orig) == 0) + printf ("%s", token); + else _print_expanded_macro_recursive (parser, - token, orig, - first); - } + token, orig); } } } @@ -386,13 +389,12 @@ _define_function_macro (glcpp_parser_t *parser, void _print_expanded_object_macro (glcpp_parser_t *parser, const char *identifier) { - int first = 1; macro_t *macro; macro = hash_table_find (parser->defines, identifier); assert (! macro->is_function); - _print_expanded_macro_recursive (parser, identifier, identifier, &first); + _print_expanded_macro_recursive (parser, identifier, identifier); } void @@ -400,7 +402,6 @@ _print_expanded_function_macro (glcpp_parser_t *parser, const char *identifier, list_t *arguments) { - int first = 1; macro_t *macro; macro = hash_table_find (parser->defines, identifier); @@ -408,5 +409,5 @@ _print_expanded_function_macro (glcpp_parser_t *parser, /* XXX: Need to use argument list here in the expansion. */ - _print_expanded_macro_recursive (parser, identifier, identifier, &first); + _print_expanded_macro_recursive (parser, identifier, identifier); } -- cgit v1.2.3 From af71ba41bdecbe9f971752c32c514ca7b319f588 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 12:54:17 -0700 Subject: Add tests exercising substitution of arguments in function-like macros. This capability is the only thing that makes function-like macros interesting. This isn't supported yet so these tests fail for now. --- tests/016-define-func-1-arg.c | 2 ++ tests/017-define-func-2-args.c | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 tests/016-define-func-1-arg.c create mode 100644 tests/017-define-func-2-args.c diff --git a/tests/016-define-func-1-arg.c b/tests/016-define-func-1-arg.c new file mode 100644 index 00000000000..dea38d1fedd --- /dev/null +++ b/tests/016-define-func-1-arg.c @@ -0,0 +1,2 @@ +#define foo(x) ((x) + 1) +foo(bar) diff --git a/tests/017-define-func-2-args.c b/tests/017-define-func-2-args.c new file mode 100644 index 00000000000..c7253835278 --- /dev/null +++ b/tests/017-define-func-2-args.c @@ -0,0 +1,2 @@ +#define foo(x,y) ((x)*(y)) +foo(bar,baz) -- cgit v1.2.3 From dcc2ecd30d2ff68792f192c867b301a10872d86d Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 12:56:42 -0700 Subject: Implement substitution of macro arguments. Making the two recently-added tests for this functionality now pass. --- glcpp-parse.y | 169 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 141 insertions(+), 28 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 7d1c3ab927f..4b4a754f82b 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -73,6 +73,15 @@ _list_append_item (list_t *list, const char *str); void _list_append_list (list_t *list, list_t *tail); +int +_list_contains (list_t *list, const char *member, int *index); + +const char * +_list_member_at (list_t *list, int index); + +int +_list_length (list_t *list); + %} %union { @@ -277,6 +286,62 @@ _list_append_item (list_t *list, const char *str) list->tail = node; } + +int +_list_contains (list_t *list, const char *member, int *index) +{ + node_t *node; + int i; + + if (list == NULL) + return 0; + + for (i = 0, node = list->head; node; i++, node = node->next) { + if (strcmp (node->str, member) == 0) { + *index = i; + return 1; + } + } + + return 0; +} + +int +_list_length (list_t *list) +{ + int length = 0; + node_t *node; + + if (list == NULL) + return 0; + + for (node = list->head; node; node = node->next) + length++; + + return length; +} + +const char * +_list_member_at (list_t *list, int index) +{ + node_t *node; + int i; + + if (list == NULL) + return NULL; + + node = list->head; + for (i = 0; i < index; i++) { + node = node->next; + if (node == NULL) + break; + } + + if (node) + return node->str; + + return NULL; +} void yyerror (void *scanner, const char *error) @@ -328,31 +393,6 @@ glcpp_parser_macro_type (glcpp_parser_t *parser, const char *identifier) return MACRO_TYPE_OBJECT; } -static void -_print_expanded_macro_recursive (glcpp_parser_t *parser, - const char *token, - const char *orig) -{ - macro_t *macro; - node_t *node; - - macro = hash_table_find (parser->defines, token); - if (macro == NULL) { - printf ("%s", token); - } else { - list_t *replacement_list = macro->replacement_list; - - for (node = replacement_list->head ; node ; node = node->next) { - token = node->str; - if (strcmp (token, orig) == 0) - printf ("%s", token); - else - _print_expanded_macro_recursive (parser, - token, orig); - } - } -} - void _define_object_macro (glcpp_parser_t *parser, const char *identifier, @@ -386,6 +426,70 @@ _define_function_macro (glcpp_parser_t *parser, hash_table_insert (parser->defines, macro, identifier); } +static void +_print_expanded_macro_recursive (glcpp_parser_t *parser, + const char *token, + const char *orig, + list_t *parameters, + list_t *arguments); + +static void +_print_expanded_list_recursive (glcpp_parser_t *parser, + list_t *list, + const char *orig, + list_t *parameters, + list_t *arguments) +{ + const char *token; + node_t *node; + int index; + + for (node = list->head ; node ; node = node->next) { + token = node->str; + + if (strcmp (token, orig) == 0) { + printf ("%s", token); + continue; + } + + if (_list_contains (parameters, token, &index)) { + const char *argument; + + argument = _list_member_at (arguments, index); + _print_expanded_macro_recursive (parser, argument, + orig, parameters, + arguments); + } else { + _print_expanded_macro_recursive (parser, token, + orig, parameters, + arguments); + } + } +} + + +static void +_print_expanded_macro_recursive (glcpp_parser_t *parser, + const char *token, + const char *orig, + list_t *parameters, + list_t *arguments) +{ + macro_t *macro; + list_t *replacement_list; + + macro = hash_table_find (parser->defines, token); + if (macro == NULL) { + printf ("%s", token); + return; + } + + replacement_list = macro->replacement_list; + + _print_expanded_list_recursive (parser, replacement_list, + orig, parameters, arguments); +} + void _print_expanded_object_macro (glcpp_parser_t *parser, const char *identifier) { @@ -394,7 +498,8 @@ _print_expanded_object_macro (glcpp_parser_t *parser, const char *identifier) macro = hash_table_find (parser->defines, identifier); assert (! macro->is_function); - _print_expanded_macro_recursive (parser, identifier, identifier); + _print_expanded_macro_recursive (parser, identifier, identifier, + NULL, NULL); } void @@ -407,7 +512,15 @@ _print_expanded_function_macro (glcpp_parser_t *parser, macro = hash_table_find (parser->defines, identifier); assert (macro->is_function); - /* XXX: Need to use argument list here in the expansion. */ + if (_list_length (arguments) != _list_length (macro->parameter_list)) { + fprintf (stderr, + "Error: macro %s invoked with %d arguments (expected %d)\n", + identifier, + _list_length (arguments), + _list_length (macro->parameter_list)); + return; + } - _print_expanded_macro_recursive (parser, identifier, identifier); + _print_expanded_macro_recursive (parser, identifier, identifier, + macro->parameter_list, arguments); } -- cgit v1.2.3 From 30140733112b09d531d949a9bfbd9daf0cae4781 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 12:57:34 -0700 Subject: Add test where a macro formal parameter is the same as an existing macro. This is a well-defined condition, but something that currently trips up the implementation. Should be easy to fix. --- tests/018-define-func-macro-as-parameter.c | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/018-define-func-macro-as-parameter.c diff --git a/tests/018-define-func-macro-as-parameter.c b/tests/018-define-func-macro-as-parameter.c new file mode 100644 index 00000000000..668130b8f9b --- /dev/null +++ b/tests/018-define-func-macro-as-parameter.c @@ -0,0 +1,3 @@ +#define x 0 +#define foo(x) x +foo(1) -- cgit v1.2.3 From 7f9aa36bbcf457e1a221ab6447de3bec30908000 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 May 2010 12:58:49 -0700 Subject: Fix case of a macro formal parameter matching a defined macro. Simply need to allow for a macro name to appear in the parameter list. This makes the recently-added test pass. --- glcpp-parse.y | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 4b4a754f82b..1b6c939a269 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -93,7 +93,7 @@ _list_length (list_t *list); %lex-param {void *scanner} %token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO SPACE TOKEN UNDEF -%type FUNC_MACRO IDENTIFIER OBJ_MACRO TOKEN word word_or_symbol +%type FUNC_MACRO IDENTIFIER identifier_perhaps_macro OBJ_MACRO TOKEN word word_or_symbol %type argument argument_list parameter_list replacement_list %% @@ -215,18 +215,24 @@ parameter_list: /* empty */ { $$ = _list_create (parser); } -| IDENTIFIER { +| identifier_perhaps_macro { $$ = _list_create (parser); _list_append_item ($$, $1); talloc_free ($1); } -| parameter_list ',' IDENTIFIER { +| parameter_list ',' identifier_perhaps_macro { _list_append_item ($1, $3); talloc_free ($3); $$ = $1; } ; +identifier_perhaps_macro: + IDENTIFIER { $$ = $1; } +| FUNC_MACRO { $$ = $1; } +| OBJ_MACRO { $$ = $1; } +; + word_or_symbol: word { $$ = $1; } | '(' { $$ = xtalloc_strdup (parser, "("); } -- cgit v1.2.3 From 610053b2c63fe6bc1d11347dc87e63d958b04dd8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 10:05:11 -0700 Subject: Rename list_t and node_t to string_list_t and string_node_t. We'll soon be adding other types of lists, so it will be helpful to have a qualified name here. --- glcpp-parse.y | 128 +++++++++++++++++++++++++++++----------------------------- glcpp.h | 14 +++---- 2 files changed, 71 insertions(+), 71 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 1b6c939a269..3b97743085a 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -33,8 +33,8 @@ typedef struct { int is_function; - list_t *parameter_list; - list_t *replacement_list; + string_list_t *parameter_list; + string_list_t *replacement_list; } macro_t; struct glcpp_parser { @@ -48,13 +48,13 @@ yyerror (void *scanner, const char *error); void _define_object_macro (glcpp_parser_t *parser, const char *macro, - list_t *replacement_list); + string_list_t *replacement_list); void _define_function_macro (glcpp_parser_t *parser, const char *macro, - list_t *parameter_list, - list_t *replacement_list); + string_list_t *parameter_list, + string_list_t *replacement_list); void _print_expanded_object_macro (glcpp_parser_t *parser, const char *macro); @@ -62,31 +62,31 @@ _print_expanded_object_macro (glcpp_parser_t *parser, const char *macro); void _print_expanded_function_macro (glcpp_parser_t *parser, const char *macro, - list_t *arguments); + string_list_t *arguments); -list_t * -_list_create (void *ctx); +string_list_t * +_string_list_create (void *ctx); void -_list_append_item (list_t *list, const char *str); +_string_list_append_item (string_list_t *list, const char *str); void -_list_append_list (list_t *list, list_t *tail); +_string_list_append_list (string_list_t *list, string_list_t *tail); int -_list_contains (list_t *list, const char *member, int *index); +_string_list_contains (string_list_t *list, const char *member, int *index); const char * -_list_member_at (list_t *list, int index); +_string_list_member_at (string_list_t *list, int index); int -_list_length (list_t *list); +_string_list_length (string_list_t *list); %} %union { char *str; - list_t *list; + string_list_t *list; } %parse-param {glcpp_parser_t *parser} @@ -133,21 +133,21 @@ macro: argument_list: argument { - $$ = _list_create (parser); - _list_append_list ($$, $1); + $$ = _string_list_create (parser); + _string_list_append_list ($$, $1); } | argument_list ',' argument { - _list_append_list ($1, $3); + _string_list_append_list ($1, $3); $$ = $1; } ; argument: /* empty */ { - $$ = _list_create (parser); + $$ = _string_list_create (parser); } | argument word { - _list_append_item ($1, $2); + _string_list_append_item ($1, $2); talloc_free ($2); } | argument '(' argument ')' @@ -161,21 +161,21 @@ directive_with_newline: directive: DEFINE IDENTIFIER { - list_t *list = _list_create (parser); + string_list_t *list = _string_list_create (parser); _define_object_macro (parser, $2, list); } | DEFINE IDENTIFIER SPACE replacement_list { _define_object_macro (parser, $2, $4); } | DEFINE IDENTIFIER '(' parameter_list ')' { - list_t *list = _list_create (parser); + string_list_t *list = _string_list_create (parser); _define_function_macro (parser, $2, $4, list); } | DEFINE IDENTIFIER '(' parameter_list ')' SPACE replacement_list { _define_function_macro (parser, $2, $4, $7); } | UNDEF FUNC_MACRO { - list_t *replacement = hash_table_find (parser->defines, $2); + string_list_t *replacement = hash_table_find (parser->defines, $2); if (replacement) { /* XXX: Need hash table to support a real way * to remove an element rather than prefixing @@ -186,7 +186,7 @@ directive: talloc_free ($2); } | UNDEF OBJ_MACRO { - list_t *replacement = hash_table_find (parser->defines, $2); + string_list_t *replacement = hash_table_find (parser->defines, $2); if (replacement) { /* XXX: Need hash table to support a real way * to remove an element rather than prefixing @@ -200,12 +200,12 @@ directive: replacement_list: word_or_symbol { - $$ = _list_create (parser); - _list_append_item ($$, $1); + $$ = _string_list_create (parser); + _string_list_append_item ($$, $1); talloc_free ($1); } | replacement_list word_or_symbol { - _list_append_item ($1, $2); + _string_list_append_item ($1, $2); talloc_free ($2); $$ = $1; } @@ -213,15 +213,15 @@ replacement_list: parameter_list: /* empty */ { - $$ = _list_create (parser); + $$ = _string_list_create (parser); } | identifier_perhaps_macro { - $$ = _list_create (parser); - _list_append_item ($$, $1); + $$ = _string_list_create (parser); + _string_list_append_item ($$, $1); talloc_free ($1); } | parameter_list ',' identifier_perhaps_macro { - _list_append_item ($1, $3); + _string_list_append_item ($1, $3); talloc_free ($3); $$ = $1; } @@ -250,12 +250,12 @@ word: %% -list_t * -_list_create (void *ctx) +string_list_t * +_string_list_create (void *ctx) { - list_t *list; + string_list_t *list; - list = xtalloc (ctx, list_t); + list = xtalloc (ctx, string_list_t); list->head = NULL; list->tail = NULL; @@ -263,7 +263,7 @@ _list_create (void *ctx) } void -_list_append_list (list_t *list, list_t *tail) +_string_list_append_list (string_list_t *list, string_list_t *tail) { if (list->head == NULL) { list->head = tail->head; @@ -275,11 +275,11 @@ _list_append_list (list_t *list, list_t *tail) } void -_list_append_item (list_t *list, const char *str) +_string_list_append_item (string_list_t *list, const char *str) { - node_t *node; + string_node_t *node; - node = xtalloc (list, node_t); + node = xtalloc (list, string_node_t); node->str = xtalloc_strdup (node, str); node->next = NULL; @@ -294,9 +294,9 @@ _list_append_item (list_t *list, const char *str) } int -_list_contains (list_t *list, const char *member, int *index) +_string_list_contains (string_list_t *list, const char *member, int *index) { - node_t *node; + string_node_t *node; int i; if (list == NULL) @@ -313,10 +313,10 @@ _list_contains (list_t *list, const char *member, int *index) } int -_list_length (list_t *list) +_string_list_length (string_list_t *list) { int length = 0; - node_t *node; + string_node_t *node; if (list == NULL) return 0; @@ -328,9 +328,9 @@ _list_length (list_t *list) } const char * -_list_member_at (list_t *list, int index) +_string_list_member_at (string_list_t *list, int index) { - node_t *node; + string_node_t *node; int i; if (list == NULL) @@ -402,7 +402,7 @@ glcpp_parser_macro_type (glcpp_parser_t *parser, const char *identifier) void _define_object_macro (glcpp_parser_t *parser, const char *identifier, - list_t *replacement_list) + string_list_t *replacement_list) { macro_t *macro; @@ -418,8 +418,8 @@ _define_object_macro (glcpp_parser_t *parser, void _define_function_macro (glcpp_parser_t *parser, const char *identifier, - list_t *parameter_list, - list_t *replacement_list) + string_list_t *parameter_list, + string_list_t *replacement_list) { macro_t *macro; @@ -436,18 +436,18 @@ static void _print_expanded_macro_recursive (glcpp_parser_t *parser, const char *token, const char *orig, - list_t *parameters, - list_t *arguments); + string_list_t *parameters, + string_list_t *arguments); static void -_print_expanded_list_recursive (glcpp_parser_t *parser, - list_t *list, +_print_expanded_string_list_recursive (glcpp_parser_t *parser, + string_list_t *list, const char *orig, - list_t *parameters, - list_t *arguments) + string_list_t *parameters, + string_list_t *arguments) { const char *token; - node_t *node; + string_node_t *node; int index; for (node = list->head ; node ; node = node->next) { @@ -458,10 +458,10 @@ _print_expanded_list_recursive (glcpp_parser_t *parser, continue; } - if (_list_contains (parameters, token, &index)) { + if (_string_list_contains (parameters, token, &index)) { const char *argument; - argument = _list_member_at (arguments, index); + argument = _string_list_member_at (arguments, index); _print_expanded_macro_recursive (parser, argument, orig, parameters, arguments); @@ -478,11 +478,11 @@ static void _print_expanded_macro_recursive (glcpp_parser_t *parser, const char *token, const char *orig, - list_t *parameters, - list_t *arguments) + string_list_t *parameters, + string_list_t *arguments) { macro_t *macro; - list_t *replacement_list; + string_list_t *replacement_list; macro = hash_table_find (parser->defines, token); if (macro == NULL) { @@ -492,7 +492,7 @@ _print_expanded_macro_recursive (glcpp_parser_t *parser, replacement_list = macro->replacement_list; - _print_expanded_list_recursive (parser, replacement_list, + _print_expanded_string_list_recursive (parser, replacement_list, orig, parameters, arguments); } @@ -511,19 +511,19 @@ _print_expanded_object_macro (glcpp_parser_t *parser, const char *identifier) void _print_expanded_function_macro (glcpp_parser_t *parser, const char *identifier, - list_t *arguments) + string_list_t *arguments) { macro_t *macro; macro = hash_table_find (parser->defines, identifier); assert (macro->is_function); - if (_list_length (arguments) != _list_length (macro->parameter_list)) { + if (_string_list_length (arguments) != _string_list_length (macro->parameter_list)) { fprintf (stderr, "Error: macro %s invoked with %d arguments (expected %d)\n", identifier, - _list_length (arguments), - _list_length (macro->parameter_list)); + _string_list_length (arguments), + _string_list_length (macro->parameter_list)); return; } diff --git a/glcpp.h b/glcpp.h index 69b3b840aed..cee08faa983 100644 --- a/glcpp.h +++ b/glcpp.h @@ -31,15 +31,15 @@ /* Some data types used for parser value. */ -typedef struct node { +typedef struct string_node { const char *str; - struct node *next; -} node_t; + struct string_node *next; +} string_node_t; -typedef struct list { - node_t *head; - node_t *tail; -} list_t; +typedef struct string_list { + string_node_t *head; + string_node_t *tail; +} string_list_t; typedef struct glcpp_parser glcpp_parser_t; -- cgit v1.2.3 From c5e9855f130b928b480c18c913135a411ee921e7 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 10:12:21 -0700 Subject: Remove _list suffix from several identifiers. Instead of "parameter_list" and "replacement_list" just use "parameters" and "replacements". This is consistent with the existing "arguments" and keeps the line length down in the face of the now-longer "string_list_t" rather than "list_t". --- glcpp-parse.y | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 3b97743085a..4e5de8254d8 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -33,8 +33,8 @@ typedef struct { int is_function; - string_list_t *parameter_list; - string_list_t *replacement_list; + string_list_t *parameters; + string_list_t *replacements; } macro_t; struct glcpp_parser { @@ -48,13 +48,13 @@ yyerror (void *scanner, const char *error); void _define_object_macro (glcpp_parser_t *parser, const char *macro, - string_list_t *replacement_list); + string_list_t *replacements); void _define_function_macro (glcpp_parser_t *parser, const char *macro, - string_list_t *parameter_list, - string_list_t *replacement_list); + string_list_t *parameters, + string_list_t *replacements); void _print_expanded_object_macro (glcpp_parser_t *parser, const char *macro); @@ -402,15 +402,15 @@ glcpp_parser_macro_type (glcpp_parser_t *parser, const char *identifier) void _define_object_macro (glcpp_parser_t *parser, const char *identifier, - string_list_t *replacement_list) + string_list_t *replacements) { macro_t *macro; macro = xtalloc (parser, macro_t); macro->is_function = 0; - macro->parameter_list = NULL; - macro->replacement_list = talloc_steal (macro, replacement_list); + macro->parameters = NULL; + macro->replacements = talloc_steal (macro, replacements); hash_table_insert (parser->defines, macro, identifier); } @@ -418,16 +418,16 @@ _define_object_macro (glcpp_parser_t *parser, void _define_function_macro (glcpp_parser_t *parser, const char *identifier, - string_list_t *parameter_list, - string_list_t *replacement_list) + string_list_t *parameters, + string_list_t *replacements) { macro_t *macro; macro = xtalloc (parser, macro_t); macro->is_function = 1; - macro->parameter_list = talloc_steal (macro, parameter_list); - macro->replacement_list = talloc_steal (macro, replacement_list); + macro->parameters = talloc_steal (macro, parameters); + macro->replacements = talloc_steal (macro, replacements); hash_table_insert (parser->defines, macro, identifier); } @@ -482,7 +482,7 @@ _print_expanded_macro_recursive (glcpp_parser_t *parser, string_list_t *arguments) { macro_t *macro; - string_list_t *replacement_list; + string_list_t *replacements; macro = hash_table_find (parser->defines, token); if (macro == NULL) { @@ -490,10 +490,10 @@ _print_expanded_macro_recursive (glcpp_parser_t *parser, return; } - replacement_list = macro->replacement_list; + replacements = macro->replacements; - _print_expanded_string_list_recursive (parser, replacement_list, - orig, parameters, arguments); + _print_expanded_string_list_recursive (parser, replacements, + orig, parameters, arguments); } void @@ -518,15 +518,15 @@ _print_expanded_function_macro (glcpp_parser_t *parser, macro = hash_table_find (parser->defines, identifier); assert (macro->is_function); - if (_string_list_length (arguments) != _string_list_length (macro->parameter_list)) { + if (_string_list_length (arguments) != _string_list_length (macro->parameters)) { fprintf (stderr, "Error: macro %s invoked with %d arguments (expected %d)\n", identifier, _string_list_length (arguments), - _string_list_length (macro->parameter_list)); + _string_list_length (macro->parameters)); return; } _print_expanded_macro_recursive (parser, identifier, identifier, - macro->parameter_list, arguments); + macro->parameters, arguments); } -- cgit v1.2.3 From 04af13539a7a4bc72b566c111914b103d9e851a6 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 10:17:38 -0700 Subject: Move most printing to the action in the content production. Previously, printing was occurring all over the place. Here we document that it should all be happening at the top-level content production, and we move the printing of directive newlines. The printing of expanded macros is still happening in lower-level productions, but we plan to fix that soon. --- glcpp-parse.y | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 4e5de8254d8..8dc78975114 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -103,6 +103,7 @@ input: | input content ; + /* We do all printing at the content level */ content: IDENTIFIER { printf ("%s", $1); @@ -113,7 +114,7 @@ content: talloc_free ($1); } | macro -| directive_with_newline +| directive_with_newline { printf ("\n"); } | NEWLINE { printf ("\n"); } | '(' { printf ("("); } | ')' { printf (")"); } @@ -154,9 +155,7 @@ argument: ; directive_with_newline: - directive NEWLINE { - printf ("\n"); - } + directive NEWLINE ; directive: -- cgit v1.2.3 From 2be8be0f742a7abf410be8176f6fd6fc49a6b361 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 10:31:43 -0700 Subject: Make macro-expansion productions create string-list values rather than printing Then we print the final string list up at the top-level content production along with all other printing. Additionally, having macro-expansion productions that create values will make it easier to solve problems like composed function-like macro invocations in the future. --- glcpp-parse.y | 130 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 49 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 8dc78975114..d0ee78e008e 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -56,13 +56,16 @@ _define_function_macro (glcpp_parser_t *parser, string_list_t *parameters, string_list_t *replacements); -void -_print_expanded_object_macro (glcpp_parser_t *parser, const char *macro); +string_list_t * +_expand_object_macro (glcpp_parser_t *parser, const char *identifier); + +string_list_t * +_expand_function_macro (glcpp_parser_t *parser, + const char *identifier, + string_list_t *arguments); void -_print_expanded_function_macro (glcpp_parser_t *parser, - const char *macro, - string_list_t *arguments); +_print_string_list (string_list_t *list); string_list_t * _string_list_create (void *ctx); @@ -94,7 +97,7 @@ _string_list_length (string_list_t *list); %token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO SPACE TOKEN UNDEF %type FUNC_MACRO IDENTIFIER identifier_perhaps_macro OBJ_MACRO TOKEN word word_or_symbol -%type argument argument_list parameter_list replacement_list +%type argument argument_list macro parameter_list replacement_list %% @@ -113,7 +116,9 @@ content: printf ("%s", $1); talloc_free ($1); } -| macro +| macro { + _print_string_list ($1); + } | directive_with_newline { printf ("\n"); } | NEWLINE { printf ("\n"); } | '(' { printf ("("); } @@ -124,10 +129,10 @@ content: macro: FUNC_MACRO '(' argument_list ')' { - _print_expanded_function_macro (parser, $1, $3); + $$ = _expand_function_macro (parser, $1, $3); } | OBJ_MACRO { - _print_expanded_object_macro (parser, $1); + $$ = _expand_object_macro (parser, $1); talloc_free ($1); } ; @@ -326,6 +331,18 @@ _string_list_length (string_list_t *list) return length; } +void +_print_string_list (string_list_t *list) +{ + string_node_t *node; + + if (list == NULL) + return; + + for (node = list->head; node; node = node->next) + printf ("%s", node->str); +} + const char * _string_list_member_at (string_list_t *list, int index) { @@ -431,29 +448,33 @@ _define_function_macro (glcpp_parser_t *parser, hash_table_insert (parser->defines, macro, identifier); } -static void -_print_expanded_macro_recursive (glcpp_parser_t *parser, - const char *token, - const char *orig, - string_list_t *parameters, - string_list_t *arguments); - -static void -_print_expanded_string_list_recursive (glcpp_parser_t *parser, - string_list_t *list, - const char *orig, - string_list_t *parameters, - string_list_t *arguments) +static string_list_t * +_expand_macro_recursive (glcpp_parser_t *parser, + const char *token, + const char *orig, + string_list_t *parameters, + string_list_t *arguments); + +static string_list_t * +_expand_string_list_recursive (glcpp_parser_t *parser, + string_list_t *list, + const char *orig, + string_list_t *parameters, + string_list_t *arguments) { + string_list_t *result; + string_list_t *child; const char *token; string_node_t *node; int index; + result = _string_list_create (parser); + for (node = list->head ; node ; node = node->next) { token = node->str; if (strcmp (token, orig) == 0) { - printf ("%s", token); + _string_list_append_item (result, token); continue; } @@ -461,71 +482,82 @@ _print_expanded_string_list_recursive (glcpp_parser_t *parser, const char *argument; argument = _string_list_member_at (arguments, index); - _print_expanded_macro_recursive (parser, argument, - orig, parameters, - arguments); + child = _expand_macro_recursive (parser, argument, + orig, NULL, NULL); + _string_list_append_list (result, child); } else { - _print_expanded_macro_recursive (parser, token, + child = _expand_macro_recursive (parser, token, orig, parameters, arguments); + _string_list_append_list (result, child); } } + + return result; } -static void -_print_expanded_macro_recursive (glcpp_parser_t *parser, - const char *token, - const char *orig, - string_list_t *parameters, - string_list_t *arguments) +static string_list_t * +_expand_macro_recursive (glcpp_parser_t *parser, + const char *token, + const char *orig, + string_list_t *parameters, + string_list_t *arguments) { macro_t *macro; string_list_t *replacements; macro = hash_table_find (parser->defines, token); if (macro == NULL) { - printf ("%s", token); - return; + string_list_t *result; + + result = _string_list_create (parser); + _string_list_append_item (result, token); + return result; } replacements = macro->replacements; - _print_expanded_string_list_recursive (parser, replacements, - orig, parameters, arguments); + return _expand_string_list_recursive (parser, replacements, + orig, parameters, arguments); } -void -_print_expanded_object_macro (glcpp_parser_t *parser, const char *identifier) +string_list_t * +_expand_object_macro (glcpp_parser_t *parser, const char *identifier) { macro_t *macro; macro = hash_table_find (parser->defines, identifier); assert (! macro->is_function); - _print_expanded_macro_recursive (parser, identifier, identifier, - NULL, NULL); + return _expand_macro_recursive (parser, identifier, identifier, + NULL, NULL); } -void -_print_expanded_function_macro (glcpp_parser_t *parser, - const char *identifier, - string_list_t *arguments) +string_list_t * +_expand_function_macro (glcpp_parser_t *parser, + const char *identifier, + string_list_t *arguments) { + string_list_t *result; macro_t *macro; + result = _string_list_create (parser); + macro = hash_table_find (parser->defines, identifier); assert (macro->is_function); - if (_string_list_length (arguments) != _string_list_length (macro->parameters)) { + if (_string_list_length (arguments) != + _string_list_length (macro->parameters)) + { fprintf (stderr, "Error: macro %s invoked with %d arguments (expected %d)\n", identifier, _string_list_length (arguments), _string_list_length (macro->parameters)); - return; + return NULL; } - _print_expanded_macro_recursive (parser, identifier, identifier, - macro->parameters, arguments); + return _expand_macro_recursive (parser, identifier, identifier, + macro->parameters, arguments); } -- cgit v1.2.3 From db272e6e6fbfe349ea6d9877bb7715ecb2d9f0c1 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 10:00:59 -0700 Subject: Add test for function-like macro invocations with multiple-token arguments. These are not yet parsed correctly, so these tests fail. --- tests/019-define-func-1-arg-multi.c | 2 ++ tests/020-define-func-2-arg-multi.c | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 tests/019-define-func-1-arg-multi.c create mode 100644 tests/020-define-func-2-arg-multi.c diff --git a/tests/019-define-func-1-arg-multi.c b/tests/019-define-func-1-arg-multi.c new file mode 100644 index 00000000000..c4e62b25508 --- /dev/null +++ b/tests/019-define-func-1-arg-multi.c @@ -0,0 +1,2 @@ +#define foo(x) (x) +foo(this is more than one word) diff --git a/tests/020-define-func-2-arg-multi.c b/tests/020-define-func-2-arg-multi.c new file mode 100644 index 00000000000..253421139d4 --- /dev/null +++ b/tests/020-define-func-2-arg-multi.c @@ -0,0 +1,2 @@ +#define foo(x,y) x, two fish, red fish, y +foo(one fish, blue fish) -- cgit v1.2.3 From 8f6a828e4a454e1bdce359c43e1108ff0315a89c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 10:44:19 -0700 Subject: Support macro invocations with multiple tokens for a single argument. We provide for this by changing the value of the argument-list production from a list of strings (string_list_t) to a new data-structure that holds a list of lists of strings (argument_list_t). --- glcpp-parse.y | 115 ++++++++++++++++++++++++++++++++++++++++++++++------------ glcpp.h | 11 +++++- 2 files changed, 102 insertions(+), 24 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index d0ee78e008e..27b5514e928 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -62,7 +62,7 @@ _expand_object_macro (glcpp_parser_t *parser, const char *identifier); string_list_t * _expand_function_macro (glcpp_parser_t *parser, const char *identifier, - string_list_t *arguments); + argument_list_t *arguments); void _print_string_list (string_list_t *list); @@ -79,17 +79,27 @@ _string_list_append_list (string_list_t *list, string_list_t *tail); int _string_list_contains (string_list_t *list, const char *member, int *index); -const char * -_string_list_member_at (string_list_t *list, int index); - int _string_list_length (string_list_t *list); +argument_list_t * +_argument_list_create (void *ctx); + +void +_argument_list_append (argument_list_t *list, string_list_t *argument); + +int +_argument_list_length (argument_list_t *list); + +string_list_t * +_argument_list_member_at (argument_list_t *list, int index); + %} %union { char *str; - string_list_t *list; + string_list_t *string_list; + argument_list_t *argument_list; } %parse-param {glcpp_parser_t *parser} @@ -97,7 +107,8 @@ _string_list_length (string_list_t *list); %token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO SPACE TOKEN UNDEF %type FUNC_MACRO IDENTIFIER identifier_perhaps_macro OBJ_MACRO TOKEN word word_or_symbol -%type argument argument_list macro parameter_list replacement_list +%type argument macro parameter_list replacement_list +%type argument_list %% @@ -139,11 +150,15 @@ macro: argument_list: argument { - $$ = _string_list_create (parser); - _string_list_append_list ($$, $1); + $$ = _argument_list_create (parser); + _argument_list_append ($$, $1); + } +| argument_list ',' SPACE argument { + _argument_list_append ($1, $4); + $$ = $1; } | argument_list ',' argument { - _string_list_append_list ($1, $3); + _argument_list_append ($1, $3); $$ = $1; } ; @@ -156,6 +171,11 @@ argument: _string_list_append_item ($1, $2); talloc_free ($2); } +| argument SPACE word { + _string_list_append_item ($1, " "); + _string_list_append_item ($1, $3); + talloc_free ($3); + } | argument '(' argument ')' ; @@ -343,10 +363,59 @@ _print_string_list (string_list_t *list) printf ("%s", node->str); } -const char * -_string_list_member_at (string_list_t *list, int index) +argument_list_t * +_argument_list_create (void *ctx) { - string_node_t *node; + argument_list_t *list; + + list = xtalloc (ctx, argument_list_t); + list->head = NULL; + list->tail = NULL; + + return list; +} + +void +_argument_list_append (argument_list_t *list, string_list_t *argument) +{ + argument_node_t *node; + + if (argument == NULL || argument->head == NULL) + return; + + node = xtalloc (list, argument_node_t); + node->argument = argument; + + node->next = NULL; + + if (list->head == NULL) { + list->head = node; + } else { + list->tail->next = node; + } + + list->tail = node; +} + +int +_argument_list_length (argument_list_t *list) +{ + int length = 0; + argument_node_t *node; + + if (list == NULL) + return 0; + + for (node = list->head; node; node = node->next) + length++; + + return length; +} + +string_list_t * +_argument_list_member_at (argument_list_t *list, int index) +{ + argument_node_t *node; int i; if (list == NULL) @@ -360,7 +429,7 @@ _string_list_member_at (string_list_t *list, int index) } if (node) - return node->str; + return node->argument; return NULL; } @@ -453,14 +522,14 @@ _expand_macro_recursive (glcpp_parser_t *parser, const char *token, const char *orig, string_list_t *parameters, - string_list_t *arguments); + argument_list_t *arguments); static string_list_t * _expand_string_list_recursive (glcpp_parser_t *parser, string_list_t *list, const char *orig, string_list_t *parameters, - string_list_t *arguments) + argument_list_t *arguments) { string_list_t *result; string_list_t *child; @@ -479,11 +548,11 @@ _expand_string_list_recursive (glcpp_parser_t *parser, } if (_string_list_contains (parameters, token, &index)) { - const char *argument; + string_list_t *argument; - argument = _string_list_member_at (arguments, index); - child = _expand_macro_recursive (parser, argument, - orig, NULL, NULL); + argument = _argument_list_member_at (arguments, index); + child = _expand_string_list_recursive (parser, argument, + orig, NULL, NULL); _string_list_append_list (result, child); } else { child = _expand_macro_recursive (parser, token, @@ -502,7 +571,7 @@ _expand_macro_recursive (glcpp_parser_t *parser, const char *token, const char *orig, string_list_t *parameters, - string_list_t *arguments) + argument_list_t *arguments) { macro_t *macro; string_list_t *replacements; @@ -537,7 +606,7 @@ _expand_object_macro (glcpp_parser_t *parser, const char *identifier) string_list_t * _expand_function_macro (glcpp_parser_t *parser, const char *identifier, - string_list_t *arguments) + argument_list_t *arguments) { string_list_t *result; macro_t *macro; @@ -547,13 +616,13 @@ _expand_function_macro (glcpp_parser_t *parser, macro = hash_table_find (parser->defines, identifier); assert (macro->is_function); - if (_string_list_length (arguments) != + if (_argument_list_length (arguments) != _string_list_length (macro->parameters)) { fprintf (stderr, "Error: macro %s invoked with %d arguments (expected %d)\n", identifier, - _string_list_length (arguments), + _argument_list_length (arguments), _string_list_length (macro->parameters)); return NULL; } diff --git a/glcpp.h b/glcpp.h index cee08faa983..7966a2a3d21 100644 --- a/glcpp.h +++ b/glcpp.h @@ -30,7 +30,6 @@ /* Some data types used for parser value. */ - typedef struct string_node { const char *str; struct string_node *next; @@ -41,6 +40,16 @@ typedef struct string_list { string_node_t *tail; } string_list_t; +typedef struct argument_node { + string_list_t *argument; + struct argument_node *next; +} argument_node_t; + +typedef struct argument_list { + argument_node_t *head; + argument_node_t *tail; +} argument_list_t; + typedef struct glcpp_parser glcpp_parser_t; glcpp_parser_t * -- cgit v1.2.3 From ac070e8bf5005151dd702f2cd3fbfb2d1eaaf00d Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 11:33:00 -0700 Subject: Eliminate a shift/reduce conflict. By simply allowing for the argument_list production to be empty rather than the lower-level argument production to be empty. --- glcpp-parse.y | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 27b5514e928..e70b3298d8d 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -149,7 +149,10 @@ macro: ; argument_list: - argument { + /* empty */ { + $$ = _argument_list_create (parser); + } +| argument { $$ = _argument_list_create (parser); _argument_list_append ($$, $1); } @@ -164,8 +167,9 @@ argument_list: ; argument: - /* empty */ { + word { $$ = _string_list_create (parser); + _string_list_append_item ($$, $1); } | argument word { _string_list_append_item ($1, $2); -- cgit v1.2.3 From 92e7bf0f50ff673b7441b2f2be9ef99a4af8cae4 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 10:01:44 -0700 Subject: Add test for composed invocation of function-like macros. This is a case like "foo(bar(x))" where both foo and bar are defined function-like macros. This is not yet parsed correctly so this test fails. --- tests/021-define-func-compose.c | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/021-define-func-compose.c diff --git a/tests/021-define-func-compose.c b/tests/021-define-func-compose.c new file mode 100644 index 00000000000..21ddd0e65f9 --- /dev/null +++ b/tests/021-define-func-compose.c @@ -0,0 +1,3 @@ +#define bar(x) (1+(x)) +#define foo(y) (2*(y)) +foo(bar(3)) -- cgit v1.2.3 From 38bd27b444f610904320b5aa9d37e43be9164697 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 12:05:37 -0700 Subject: Fix expansion of composited macros. This is a case such as "foo(bar(x))". The recently added test for this now passes. --- glcpp-parse.y | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index e70b3298d8d..f972ec372b8 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -106,7 +106,7 @@ _argument_list_member_at (argument_list_t *list, int index); %lex-param {void *scanner} %token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO SPACE TOKEN UNDEF -%type FUNC_MACRO IDENTIFIER identifier_perhaps_macro OBJ_MACRO TOKEN word word_or_symbol +%type FUNC_MACRO IDENTIFIER identifier_perhaps_macro OBJ_MACRO replacement_word TOKEN word %type argument macro parameter_list replacement_list %type argument_list @@ -171,6 +171,9 @@ argument: $$ = _string_list_create (parser); _string_list_append_item ($$, $1); } +| macro { + $$ = $1; + } | argument word { _string_list_append_item ($1, $2); talloc_free ($2); @@ -227,18 +230,28 @@ directive: ; replacement_list: - word_or_symbol { + replacement_word { $$ = _string_list_create (parser); _string_list_append_item ($$, $1); talloc_free ($1); } -| replacement_list word_or_symbol { +| replacement_list replacement_word { _string_list_append_item ($1, $2); talloc_free ($2); $$ = $1; } ; +replacement_word: + word { $$ = $1; } +| FUNC_MACRO { $$ = $1; } +| OBJ_MACRO { $$ = $1; } +| '(' { $$ = xtalloc_strdup (parser, "("); } +| ')' { $$ = xtalloc_strdup (parser, ")"); } +| ',' { $$ = xtalloc_strdup (parser, ","); } +| SPACE { $$ = xtalloc_strdup (parser, " "); } +; + parameter_list: /* empty */ { $$ = _string_list_create (parser); @@ -261,18 +274,8 @@ identifier_perhaps_macro: | OBJ_MACRO { $$ = $1; } ; -word_or_symbol: - word { $$ = $1; } -| '(' { $$ = xtalloc_strdup (parser, "("); } -| ')' { $$ = xtalloc_strdup (parser, ")"); } -| ',' { $$ = xtalloc_strdup (parser, ","); } -| SPACE { $$ = xtalloc_strdup (parser, " "); } -; - word: IDENTIFIER { $$ = $1; } -| FUNC_MACRO { $$ = $1; } -| OBJ_MACRO { $$ = $1; } | TOKEN { $$ = $1; } ; -- cgit v1.2.3 From 2384937835c1cfbce8c6361ad0972761e17ae1a7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 16:06:41 -0700 Subject: Fix function call parameter printer to omit extraneous leading comma The output of all test cases was verified to be the same using diff. --- glsl_parser_extras.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 985d3829e65..62eeb9c8600 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -326,7 +326,8 @@ ast_expression::print(void) const printf("( "); foreach_list_const (n, &this->expressions) { - printf(", "); + if (n != this->expressions.get_head()) + printf(", "); ast_node *ast = exec_node_data(ast_node, n, link); ast->print(); -- cgit v1.2.3 From c05bc5b7cc8e9bbfcefc97cbb9159b848157cf4c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 12:57:23 -0700 Subject: FS gl_FragCoord and and gl_FrontFacing are FS ins, not outs. --- builtin_variables.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin_variables.h b/builtin_variables.h index 6c14a4a42b7..661da6cf555 100644 --- a/builtin_variables.h +++ b/builtin_variables.h @@ -33,8 +33,8 @@ static const builtin_variable builtin_core_vs_variables[] = { }; static const builtin_variable builtin_core_fs_variables[] = { - { ir_var_out, "vec4", "gl_FragCoord" }, - { ir_var_out, "bool", "gl_FrontFacing" }, + { ir_var_in, "vec4", "gl_FragCoord" }, + { ir_var_in, "bool", "gl_FrontFacing" }, { ir_var_out, "vec4", "gl_FragColor" }, { ir_var_out, "float", "gl_FragDepth" }, }; -- cgit v1.2.3 From f6c90d8b3484864cd7f3abf895746e0655929a13 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 23:17:58 -0700 Subject: ir_reader: Set function signatures as defined. --- ir_reader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ir_reader.cpp b/ir_reader.cpp index 2c942914aef..1bf5363f52a 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -295,6 +295,7 @@ read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list, return; } read_instructions(st, &sig->body, body_list, NULL); + sig->is_defined = true; } st->symbols->pop_scope(); -- cgit v1.2.3 From e4afc64290a7917fa388f4395ed7066eaba519a5 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 22:57:47 -0700 Subject: Initial commit of IR for builtins. These were all generated by Eric's existing builtin_functions.cpp; I split the uvec* signatures out of 110 into the 130 folder. --- builtins/110/abs | 21 +++++++++++++++ builtins/110/all | 16 ++++++++++++ builtins/110/any | 16 ++++++++++++ builtins/110/ceil | 21 +++++++++++++++ builtins/110/clamp | 29 ++++++++++++++++++++ builtins/110/degrees | 21 +++++++++++++++ builtins/110/dot | 25 ++++++++++++++++++ builtins/110/equal | 61 +++++++++++++++++++++++++++++++++++++++++++ builtins/110/exp | 21 +++++++++++++++ builtins/110/exp2 | 21 +++++++++++++++ builtins/110/floor | 21 +++++++++++++++ builtins/110/greaterThan | 61 +++++++++++++++++++++++++++++++++++++++++++ builtins/110/greaterThanEqual | 61 +++++++++++++++++++++++++++++++++++++++++++ builtins/110/inversesqrt | 21 +++++++++++++++ builtins/110/length | 21 +++++++++++++++ builtins/110/lessThan | 61 +++++++++++++++++++++++++++++++++++++++++++ builtins/110/lessThanEqual | 61 +++++++++++++++++++++++++++++++++++++++++++ builtins/110/log | 21 +++++++++++++++ builtins/110/log2 | 21 +++++++++++++++ builtins/110/max | 25 ++++++++++++++++++ builtins/110/min | 25 ++++++++++++++++++ builtins/110/mix | 29 ++++++++++++++++++++ builtins/110/mod | 25 ++++++++++++++++++ builtins/110/normalize | 21 +++++++++++++++ builtins/110/not | 16 ++++++++++++ builtins/110/notEqual | 61 +++++++++++++++++++++++++++++++++++++++++++ builtins/110/pow | 25 ++++++++++++++++++ builtins/110/radians | 21 +++++++++++++++ builtins/110/sqrt | 21 +++++++++++++++ builtins/130/equal | 31 ++++++++++++++++++++++ builtins/130/greaterThan | 31 ++++++++++++++++++++++ builtins/130/greaterThanEqual | 31 ++++++++++++++++++++++ builtins/130/lessThan | 31 ++++++++++++++++++++++ builtins/130/lessThanEqual | 31 ++++++++++++++++++++++ builtins/130/notEqual | 31 ++++++++++++++++++++++ 35 files changed, 1056 insertions(+) create mode 100644 builtins/110/abs create mode 100644 builtins/110/all create mode 100644 builtins/110/any create mode 100644 builtins/110/ceil create mode 100644 builtins/110/clamp create mode 100644 builtins/110/degrees create mode 100644 builtins/110/dot create mode 100644 builtins/110/equal create mode 100644 builtins/110/exp create mode 100644 builtins/110/exp2 create mode 100644 builtins/110/floor create mode 100644 builtins/110/greaterThan create mode 100644 builtins/110/greaterThanEqual create mode 100644 builtins/110/inversesqrt create mode 100644 builtins/110/length create mode 100644 builtins/110/lessThan create mode 100644 builtins/110/lessThanEqual create mode 100644 builtins/110/log create mode 100644 builtins/110/log2 create mode 100644 builtins/110/max create mode 100644 builtins/110/min create mode 100644 builtins/110/mix create mode 100644 builtins/110/mod create mode 100644 builtins/110/normalize create mode 100644 builtins/110/not create mode 100644 builtins/110/notEqual create mode 100644 builtins/110/pow create mode 100644 builtins/110/radians create mode 100644 builtins/110/sqrt create mode 100644 builtins/130/equal create mode 100644 builtins/130/greaterThan create mode 100644 builtins/130/greaterThanEqual create mode 100644 builtins/130/lessThan create mode 100644 builtins/130/lessThanEqual create mode 100644 builtins/130/notEqual diff --git a/builtins/110/abs b/builtins/110/abs new file mode 100644 index 00000000000..904845307c4 --- /dev/null +++ b/builtins/110/abs @@ -0,0 +1,21 @@ +((function abs + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float abs (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 abs (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 abs (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 abs (var_ref arg0))))) +)) diff --git a/builtins/110/all b/builtins/110/all new file mode 100644 index 00000000000..2cac0dfb684 --- /dev/null +++ b/builtins/110/all @@ -0,0 +1,16 @@ +((function all + (signature bool + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) +)) diff --git a/builtins/110/any b/builtins/110/any new file mode 100644 index 00000000000..f10e8a7b478 --- /dev/null +++ b/builtins/110/any @@ -0,0 +1,16 @@ +((function any + (signature bool + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) +)) diff --git a/builtins/110/ceil b/builtins/110/ceil new file mode 100644 index 00000000000..a26a7750493 --- /dev/null +++ b/builtins/110/ceil @@ -0,0 +1,21 @@ +((function ceil + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float ceil (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 ceil (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 ceil (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 ceil (var_ref arg0))))) +)) diff --git a/builtins/110/clamp b/builtins/110/clamp new file mode 100644 index 00000000000..1ae44db46ca --- /dev/null +++ b/builtins/110/clamp @@ -0,0 +1,29 @@ +((function clamp + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) vec2 arg2)) + ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) vec3 arg2)) + ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) vec4 arg2)) + ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) +)) diff --git a/builtins/110/degrees b/builtins/110/degrees new file mode 100644 index 00000000000..dc0d7b9e20d --- /dev/null +++ b/builtins/110/degrees @@ -0,0 +1,21 @@ +((function degrees + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (constant float (57.295780)))))) +)) diff --git a/builtins/110/dot b/builtins/110/dot new file mode 100644 index 00000000000..a91a6d2c56d --- /dev/null +++ b/builtins/110/dot @@ -0,0 +1,25 @@ +((function dot + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) +)) diff --git a/builtins/110/equal b/builtins/110/equal new file mode 100644 index 00000000000..0061cb28e4a --- /dev/null +++ b/builtins/110/equal @@ -0,0 +1,61 @@ +((function equal + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/110/exp b/builtins/110/exp new file mode 100644 index 00000000000..a73bd6a7f84 --- /dev/null +++ b/builtins/110/exp @@ -0,0 +1,21 @@ +((function exp + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float exp (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 exp (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 exp (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 exp (var_ref arg0))))) +)) diff --git a/builtins/110/exp2 b/builtins/110/exp2 new file mode 100644 index 00000000000..a842d3fe65b --- /dev/null +++ b/builtins/110/exp2 @@ -0,0 +1,21 @@ +((function exp2 + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float exp2 (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 exp2 (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 exp2 (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 exp2 (var_ref arg0))))) +)) diff --git a/builtins/110/floor b/builtins/110/floor new file mode 100644 index 00000000000..8dd8052799b --- /dev/null +++ b/builtins/110/floor @@ -0,0 +1,21 @@ +((function floor + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float floor (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 floor (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 floor (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 floor (var_ref arg0))))) +)) diff --git a/builtins/110/greaterThan b/builtins/110/greaterThan new file mode 100644 index 00000000000..8a95cc0478a --- /dev/null +++ b/builtins/110/greaterThan @@ -0,0 +1,61 @@ +((function greaterThan + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/110/greaterThanEqual b/builtins/110/greaterThanEqual new file mode 100644 index 00000000000..b6c6ab8f2bd --- /dev/null +++ b/builtins/110/greaterThanEqual @@ -0,0 +1,61 @@ +((function greaterThanEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/110/inversesqrt b/builtins/110/inversesqrt new file mode 100644 index 00000000000..5b66d2b3695 --- /dev/null +++ b/builtins/110/inversesqrt @@ -0,0 +1,21 @@ +((function inversesqrt + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float rsq (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 rsq (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 rsq (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 rsq (var_ref arg0))))) +)) diff --git a/builtins/110/length b/builtins/110/length new file mode 100644 index 00000000000..89ff7f3ef12 --- /dev/null +++ b/builtins/110/length @@ -0,0 +1,21 @@ +((function length + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec2 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec3 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec4 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) +)) diff --git a/builtins/110/lessThan b/builtins/110/lessThan new file mode 100644 index 00000000000..433acad1fe1 --- /dev/null +++ b/builtins/110/lessThan @@ -0,0 +1,61 @@ +((function lessThan + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/110/lessThanEqual b/builtins/110/lessThanEqual new file mode 100644 index 00000000000..d4f2d89efd2 --- /dev/null +++ b/builtins/110/lessThanEqual @@ -0,0 +1,61 @@ +((function lessThanEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/110/log b/builtins/110/log new file mode 100644 index 00000000000..d168abb5a73 --- /dev/null +++ b/builtins/110/log @@ -0,0 +1,21 @@ +((function log + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float log (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 log (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 log (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 log (var_ref arg0))))) +)) diff --git a/builtins/110/log2 b/builtins/110/log2 new file mode 100644 index 00000000000..b96c6276f0a --- /dev/null +++ b/builtins/110/log2 @@ -0,0 +1,21 @@ +((function log2 + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float log2 (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 log2 (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 log2 (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 log2 (var_ref arg0))))) +)) diff --git a/builtins/110/max b/builtins/110/max new file mode 100644 index 00000000000..0dc3ffb5e41 --- /dev/null +++ b/builtins/110/max @@ -0,0 +1,25 @@ +((function max + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float max (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 max (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 max (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) +)) diff --git a/builtins/110/min b/builtins/110/min new file mode 100644 index 00000000000..f9820ef8286 --- /dev/null +++ b/builtins/110/min @@ -0,0 +1,25 @@ +((function min + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float min (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 min (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 min (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) +)) diff --git a/builtins/110/mix b/builtins/110/mix new file mode 100644 index 00000000000..6bdac74f6ff --- /dev/null +++ b/builtins/110/mix @@ -0,0 +1,29 @@ +((function mix + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) vec2 arg2)) + ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) vec3 arg2)) + ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) vec4 arg2)) + ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) +)) diff --git a/builtins/110/mod b/builtins/110/mod new file mode 100644 index 00000000000..121db4fd08e --- /dev/null +++ b/builtins/110/mod @@ -0,0 +1,25 @@ +((function mod + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float % (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 % (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 % (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) +)) diff --git a/builtins/110/normalize b/builtins/110/normalize new file mode 100644 index 00000000000..be88a9830d1 --- /dev/null +++ b/builtins/110/normalize @@ -0,0 +1,21 @@ +((function normalize + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) +)) diff --git a/builtins/110/not b/builtins/110/not new file mode 100644 index 00000000000..b696b06557f --- /dev/null +++ b/builtins/110/not @@ -0,0 +1,16 @@ +((function not + (signature bvec2 + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bvec2 ! (var_ref arg0))))) + + (signature bvec3 + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bvec3 ! (var_ref arg0))))) + + (signature bvec4 + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bvec4 ! (var_ref arg0))))) +)) diff --git a/builtins/110/notEqual b/builtins/110/notEqual new file mode 100644 index 00000000000..c87efa317f7 --- /dev/null +++ b/builtins/110/notEqual @@ -0,0 +1,61 @@ +((function notEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/110/pow b/builtins/110/pow new file mode 100644 index 00000000000..a61bc4418e3 --- /dev/null +++ b/builtins/110/pow @@ -0,0 +1,25 @@ +((function pow + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float pow (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 pow (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 pow (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 pow (var_ref arg0) (var_ref arg1))))) +)) diff --git a/builtins/110/radians b/builtins/110/radians new file mode 100644 index 00000000000..6a0f5d2e219 --- /dev/null +++ b/builtins/110/radians @@ -0,0 +1,21 @@ +((function radians + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (constant float (0.017453)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (constant float (0.017453)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (constant float (0.017453)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (constant float (0.017453)))))) +)) diff --git a/builtins/110/sqrt b/builtins/110/sqrt new file mode 100644 index 00000000000..0302d164ae5 --- /dev/null +++ b/builtins/110/sqrt @@ -0,0 +1,21 @@ +((function sqrt + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float sqrt (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 sqrt (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 sqrt (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 sqrt (var_ref arg0))))) +)) diff --git a/builtins/130/equal b/builtins/130/equal new file mode 100644 index 00000000000..5060155ab34 --- /dev/null +++ b/builtins/130/equal @@ -0,0 +1,31 @@ +((function equal + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/130/greaterThan b/builtins/130/greaterThan new file mode 100644 index 00000000000..c17d4644ba8 --- /dev/null +++ b/builtins/130/greaterThan @@ -0,0 +1,31 @@ +((function greaterThan + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/130/greaterThanEqual b/builtins/130/greaterThanEqual new file mode 100644 index 00000000000..c9d0b23723c --- /dev/null +++ b/builtins/130/greaterThanEqual @@ -0,0 +1,31 @@ +((function greaterThanEqual + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/130/lessThan b/builtins/130/lessThan new file mode 100644 index 00000000000..4ed489da2bd --- /dev/null +++ b/builtins/130/lessThan @@ -0,0 +1,31 @@ +((function lessThan + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/130/lessThanEqual b/builtins/130/lessThanEqual new file mode 100644 index 00000000000..92ae2dff12a --- /dev/null +++ b/builtins/130/lessThanEqual @@ -0,0 +1,31 @@ +((function lessThanEqual + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/builtins/130/notEqual b/builtins/130/notEqual new file mode 100644 index 00000000000..d49e2cb7730 --- /dev/null +++ b/builtins/130/notEqual @@ -0,0 +1,31 @@ +((function notEqual + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) -- cgit v1.2.3 From a40e68b256c428d8dcaf8b9b1dfb79316af7c050 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 3 May 2010 02:40:10 -0700 Subject: Fix bogus expression typing in various builtins. --- builtins/110/equal | 36 ++++++++++++++++++------------------ builtins/110/greaterThan | 36 ++++++++++++++++++------------------ builtins/110/greaterThanEqual | 36 ++++++++++++++++++------------------ builtins/110/lessThan | 36 ++++++++++++++++++------------------ builtins/110/lessThanEqual | 36 ++++++++++++++++++------------------ builtins/130/equal | 18 +++++++++--------- builtins/130/greaterThan | 18 +++++++++--------- builtins/130/greaterThanEqual | 18 +++++++++--------- builtins/130/lessThan | 18 +++++++++--------- builtins/130/lessThanEqual | 18 +++++++++--------- builtins/130/notEqual | 18 +++++++++--------- 11 files changed, 144 insertions(+), 144 deletions(-) diff --git a/builtins/110/equal b/builtins/110/equal index 0061cb28e4a..ae7ddc53bdc 100644 --- a/builtins/110/equal +++ b/builtins/110/equal @@ -4,8 +4,8 @@ (declare (in) vec2 arg0) (declare (in) vec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) vec3 arg0) (declare (in) vec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,10 +23,10 @@ (declare (in) vec4 arg0) (declare (in) vec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) (signature bvec2 @@ -34,8 +34,8 @@ (declare (in) ivec2 arg0) (declare (in) ivec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -43,9 +43,9 @@ (declare (in) ivec3 arg0) (declare (in) ivec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -53,9 +53,9 @@ (declare (in) ivec4 arg0) (declare (in) ivec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) diff --git a/builtins/110/greaterThan b/builtins/110/greaterThan index 8a95cc0478a..ae03030e495 100644 --- a/builtins/110/greaterThan +++ b/builtins/110/greaterThan @@ -4,8 +4,8 @@ (declare (in) vec2 arg0) (declare (in) vec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) vec3 arg0) (declare (in) vec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,10 +23,10 @@ (declare (in) vec4 arg0) (declare (in) vec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) (signature bvec2 @@ -34,8 +34,8 @@ (declare (in) ivec2 arg0) (declare (in) ivec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -43,9 +43,9 @@ (declare (in) ivec3 arg0) (declare (in) ivec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -53,9 +53,9 @@ (declare (in) ivec4 arg0) (declare (in) ivec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) diff --git a/builtins/110/greaterThanEqual b/builtins/110/greaterThanEqual index b6c6ab8f2bd..204d5fd1439 100644 --- a/builtins/110/greaterThanEqual +++ b/builtins/110/greaterThanEqual @@ -4,8 +4,8 @@ (declare (in) vec2 arg0) (declare (in) vec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) vec3 arg0) (declare (in) vec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,10 +23,10 @@ (declare (in) vec4 arg0) (declare (in) vec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) (signature bvec2 @@ -34,8 +34,8 @@ (declare (in) ivec2 arg0) (declare (in) ivec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -43,9 +43,9 @@ (declare (in) ivec3 arg0) (declare (in) ivec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -53,9 +53,9 @@ (declare (in) ivec4 arg0) (declare (in) ivec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) diff --git a/builtins/110/lessThan b/builtins/110/lessThan index 433acad1fe1..5c4254165c7 100644 --- a/builtins/110/lessThan +++ b/builtins/110/lessThan @@ -4,8 +4,8 @@ (declare (in) vec2 arg0) (declare (in) vec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) vec3 arg0) (declare (in) vec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,10 +23,10 @@ (declare (in) vec4 arg0) (declare (in) vec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) (signature bvec2 @@ -34,8 +34,8 @@ (declare (in) ivec2 arg0) (declare (in) ivec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -43,9 +43,9 @@ (declare (in) ivec3 arg0) (declare (in) ivec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -53,9 +53,9 @@ (declare (in) ivec4 arg0) (declare (in) ivec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) diff --git a/builtins/110/lessThanEqual b/builtins/110/lessThanEqual index d4f2d89efd2..ccb955b8a76 100644 --- a/builtins/110/lessThanEqual +++ b/builtins/110/lessThanEqual @@ -4,8 +4,8 @@ (declare (in) vec2 arg0) (declare (in) vec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) vec3 arg0) (declare (in) vec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,10 +23,10 @@ (declare (in) vec4 arg0) (declare (in) vec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) (signature bvec2 @@ -34,8 +34,8 @@ (declare (in) ivec2 arg0) (declare (in) ivec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -43,9 +43,9 @@ (declare (in) ivec3 arg0) (declare (in) ivec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -53,9 +53,9 @@ (declare (in) ivec4 arg0) (declare (in) ivec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) diff --git a/builtins/130/equal b/builtins/130/equal index 5060155ab34..079c3e97fb2 100644 --- a/builtins/130/equal +++ b/builtins/130/equal @@ -4,8 +4,8 @@ (declare (in) uvec2 arg0) (declare (in) uvec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) uvec3 arg0) (declare (in) uvec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,9 +23,9 @@ (declare (in) uvec4 arg0) (declare (in) uvec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) diff --git a/builtins/130/greaterThan b/builtins/130/greaterThan index c17d4644ba8..a9fb7b3a43e 100644 --- a/builtins/130/greaterThan +++ b/builtins/130/greaterThan @@ -4,8 +4,8 @@ (declare (in) uvec2 arg0) (declare (in) uvec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) uvec3 arg0) (declare (in) uvec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,9 +23,9 @@ (declare (in) uvec4 arg0) (declare (in) uvec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) diff --git a/builtins/130/greaterThanEqual b/builtins/130/greaterThanEqual index c9d0b23723c..293c93c7cca 100644 --- a/builtins/130/greaterThanEqual +++ b/builtins/130/greaterThanEqual @@ -4,8 +4,8 @@ (declare (in) uvec2 arg0) (declare (in) uvec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) uvec3 arg0) (declare (in) uvec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,9 +23,9 @@ (declare (in) uvec4 arg0) (declare (in) uvec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) diff --git a/builtins/130/lessThan b/builtins/130/lessThan index 4ed489da2bd..d9f693fd63f 100644 --- a/builtins/130/lessThan +++ b/builtins/130/lessThan @@ -4,8 +4,8 @@ (declare (in) uvec2 arg0) (declare (in) uvec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) uvec3 arg0) (declare (in) uvec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,9 +23,9 @@ (declare (in) uvec4 arg0) (declare (in) uvec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) diff --git a/builtins/130/lessThanEqual b/builtins/130/lessThanEqual index 92ae2dff12a..494411b869a 100644 --- a/builtins/130/lessThanEqual +++ b/builtins/130/lessThanEqual @@ -4,8 +4,8 @@ (declare (in) uvec2 arg0) (declare (in) uvec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) uvec3 arg0) (declare (in) uvec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,9 +23,9 @@ (declare (in) uvec4 arg0) (declare (in) uvec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) diff --git a/builtins/130/notEqual b/builtins/130/notEqual index d49e2cb7730..81e6376bd9c 100644 --- a/builtins/130/notEqual +++ b/builtins/130/notEqual @@ -4,8 +4,8 @@ (declare (in) uvec2 arg0) (declare (in) uvec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) uvec3 arg0) (declare (in) uvec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,9 +23,9 @@ (declare (in) uvec4 arg0) (declare (in) uvec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) -- cgit v1.2.3 From 4c7367b3f99236dc664d547b7806680ffcf89d15 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 23:00:43 -0700 Subject: Add a perl script to generate builtin_function.cpp. Usage: ./builtins/tools/generate_builtins.pl > builtin_function.cpp --- builtins/tools/generate_builtins.pl | 108 ++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100755 builtins/tools/generate_builtins.pl diff --git a/builtins/tools/generate_builtins.pl b/builtins/tools/generate_builtins.pl new file mode 100755 index 00000000000..e7ec8ef56ff --- /dev/null +++ b/builtins/tools/generate_builtins.pl @@ -0,0 +1,108 @@ +#!/usr/bin/env perl + + +sub process_version { + my ($version) = @_; + my @vars; + print "/* Version $version builtins */\n\n"; + + my @files = ; + foreach $file (@files) { + push(@vars, process_file($file)); + } + + print "static const char *functions_for_$version [] = {\n"; + foreach $var (@vars) { + print " $var,\n"; + } + print "};\n\n" +} + +sub process_file { + my ($file) = @_; + + # Change from builtins/110/foo to builtins_110_foo + my $var = $file; $var =~ s!/!_!g; + + print "static const char *$var = {\n"; + open SRC, "<", "$file" or die $!; + while () { + s/\\/\\\\/g; + s/\"/\\\"/g; + s/\n/\\n/g; + print " \"$_\"\n"; + } + print "};\n\n"; + close SRC or die $!; + return $var; +} + +print << 'EOF'; +/* DO NOT MODIFY - automatically generated by generate_builtins.pl */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "glsl_parser_extras.h" +#include "ir_reader.h" + +void +read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, + const char **functions, unsigned count) +{ + if (st->error) + return; + + for (unsigned i = 0; i < count; i++) { + _mesa_glsl_read_ir(st, instructions, functions[i]); + + if (st->error) { + printf("error reading builtin: %.35s ...\n", functions[i]); + return; + } + } +} + +EOF + +@versions = sort(); +foreach $version (@versions) { + $version =~ s!builtins/!!g; + process_version($version); +} + +print << 'EOF'; +void +_mesa_glsl_initialize_functions(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ +EOF + +foreach $version (@versions) { + print " if (state->language_version >= $version)\n"; + print " read_builtins(state, instructions, functions_for_$version,\n"; + print " sizeof(functions_for_$version) / "; + print "sizeof(const char *));\n\n" +} + +print "}\n"; -- cgit v1.2.3 From b3262128fe2322854377a3af65f924ab27c5fb3b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 23:01:33 -0700 Subject: Replace old builtin_function.cpp with new autogenerated one. --- builtin_function.cpp | 2004 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 1226 insertions(+), 778 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index ff731c21625..ef3a5c8d4b9 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1,3 +1,4 @@ +/* DO NOT MODIFY - automatically generated by generate_builtins.pl */ /* * Copyright © 2010 Intel Corporation * @@ -21,796 +22,1243 @@ * DEALINGS IN THE SOFTWARE. */ -#include -#include -#include "glsl_symbol_table.h" +#include #include "glsl_parser_extras.h" -#include "glsl_types.h" -#include "ir.h" - -static void -generate_unop(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type, - enum ir_expression_operation op) -{ - ir_dereference *const arg = new ir_dereference(declarations[0]); - ir_rvalue *result; - - result = new ir_expression(op, type, arg, NULL); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_binop(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type, - enum ir_expression_operation op) -{ - ir_dereference *const arg1 = new ir_dereference(declarations[0]); - ir_dereference *const arg2 = new ir_dereference(declarations[1]); - ir_rvalue *result; - - result = new ir_expression(op, type, arg1, arg2); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_radians(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg = new ir_dereference(declarations[0]); - ir_rvalue *result; - - result = new ir_expression(ir_binop_mul, type, - arg, - new ir_constant((float)(M_PI / 180.0))); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_degrees(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg = new ir_dereference(declarations[0]); - ir_rvalue *result; - - result = new ir_expression(ir_binop_mul, type, - arg, - new ir_constant((float)(180.0 / M_PI))); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_exp(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_unop(instructions, declarations, type, ir_unop_exp); -} - -static void -generate_log(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_unop(instructions, declarations, type, ir_unop_log); -} - -static void -generate_exp2(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_unop(instructions, declarations, type, ir_unop_exp2); -} - -static void -generate_log2(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_unop(instructions, declarations, type, ir_unop_log2); -} - -static void -generate_rsq(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_unop(instructions, declarations, type, ir_unop_rsq); -} - -static void -generate_sqrt(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_unop(instructions, declarations, type, ir_unop_sqrt); -} - -static void -generate_abs(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_unop(instructions, declarations, type, ir_unop_abs); -} - -static void -generate_ceil(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_unop(instructions, declarations, type, ir_unop_ceil); -} - -static void -generate_floor(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_unop(instructions, declarations, type, ir_unop_floor); -} - -static void -generate_mod(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_binop(instructions, declarations, type, ir_binop_mod); -} - -static void -generate_min(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_binop(instructions, declarations, type, ir_binop_min); -} - -static void -generate_max(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_binop(instructions, declarations, type, ir_binop_max); -} - -static void -generate_clamp(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const x = new ir_dereference(declarations[0]); - ir_dereference *const minval = new ir_dereference(declarations[1]); - ir_dereference *const maxval = new ir_dereference(declarations[2]); - ir_rvalue *result; - - result = new ir_expression(ir_binop_min, type, x, maxval); - result = new ir_expression(ir_binop_max, type, result, minval); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_mix_vec(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const x = new ir_dereference(declarations[0]); - ir_dereference *const y = new ir_dereference(declarations[1]); - ir_dereference *const a = new ir_dereference(declarations[2]); - ir_rvalue *result, *temp; - - temp = new ir_expression(ir_binop_sub, type, new ir_constant(1.0f), a); - result = new ir_expression(ir_binop_mul, type, x, temp); - - temp = new ir_expression(ir_binop_mul, type, y, a); - result = new ir_expression(ir_binop_add, type, result, temp); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - - -static void -generate_normalize(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg = new ir_dereference(declarations[0]); - ir_rvalue *temp; - ir_rvalue *result; - - temp = new ir_expression(ir_binop_dot, glsl_type::float_type, arg, arg); - temp = new ir_expression(ir_unop_rsq, glsl_type::float_type, temp, NULL); - result = new ir_expression(ir_binop_mul, type, arg, temp); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - - -static void -generate_pow(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_binop(instructions, declarations, type, ir_binop_pow); -} +#include "ir_reader.h" void -generate_function_instance(ir_function *f, - int n_args, - void (*generate)(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type), - const glsl_type *ret_type, - const glsl_type *type) -{ - ir_variable *declarations[16]; - - ir_function_signature *const sig = new ir_function_signature(ret_type); - f->add_signature(sig); - - static const char *arg_names[] = { - "arg0", - "arg1", - "arg2" - }; - int i; - - for (i = 0; i < n_args; i++) { - ir_variable *var = new ir_variable(type, arg_names[i]); - - var->mode = ir_var_in; - sig->parameters.push_tail(var); - - declarations[i] = var; - } - - generate(&sig->body, declarations, type); - sig->is_defined = true; -} - -void -make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, - const char *name, - int n_args, - void (*generate)(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type)) -{ - ir_function *const f = new ir_function(name); - - bool added = symtab->add_function(name, f); - assert(added); - - instructions->push_tail(f); - - generate_function_instance(f, n_args, generate, - glsl_type::float_type, glsl_type::float_type); - generate_function_instance(f, n_args, generate, - glsl_type::vec2_type, glsl_type::vec2_type); - generate_function_instance(f, n_args, generate, - glsl_type::vec3_type, glsl_type::vec3_type); - generate_function_instance(f, n_args, generate, - glsl_type::vec4_type, glsl_type::vec4_type); -} - -static void -generate_vec_compare(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type, - enum ir_expression_operation op) -{ - ir_dereference *const x = new ir_dereference(declarations[0]); - ir_dereference *const y = new ir_dereference(declarations[1]); - ir_variable *temp; - const glsl_type *return_type; - int i; - - return_type = glsl_type::get_instance(GLSL_TYPE_BOOL, - type->vector_elements, 1); - temp = new ir_variable(return_type, "temp"); - instructions->push_tail(temp); - - for (i = 0; i < type->vector_elements; i++) { - ir_assignment *assign; - ir_expression *compare; - - compare = new ir_expression(op, - glsl_type::get_instance(type->base_type, - 1, 1), - new ir_swizzle(x, i, 0, 0, 0, 1), - new ir_swizzle(y, i, 0, 0, 0, 1)); - assign = new ir_assignment(new ir_swizzle(new ir_dereference(temp), - i, 0, 0, 0, 1), - compare, NULL); - instructions->push_tail(assign); - } - ir_instruction *inst = new ir_return(new ir_dereference(temp)); - instructions->push_tail(inst); -} - -static void -generate_lessThan(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_vec_compare(instructions, declarations, type, ir_binop_less); -} - -static void -generate_lessThanEqual(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) +read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, + const char **functions, unsigned count) { - generate_vec_compare(instructions, declarations, type, ir_binop_lequal); -} + if (st->error) + return; -static void -generate_greaterThan(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_vec_compare(instructions, declarations, type, ir_binop_greater); -} + for (unsigned i = 0; i < count; i++) { + _mesa_glsl_read_ir(st, instructions, functions[i]); -static void -generate_greaterThanEqual(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_vec_compare(instructions, declarations, type, ir_binop_gequal); -} - -static void -generate_equal(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_vec_compare(instructions, declarations, type, ir_binop_equal); -} - -static void -generate_notEqual(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - generate_vec_compare(instructions, declarations, type, ir_binop_nequal); -} - -static void -generate_vec_compare_function(glsl_symbol_table *symtab, - exec_list *instructions, - const char *name, - void (*generate)(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type), - bool do_bool) -{ - ir_function *const f = new ir_function(name); - const glsl_type *ivec2_type = glsl_type::get_instance(GLSL_TYPE_INT, 2, 1); - const glsl_type *ivec3_type = glsl_type::get_instance(GLSL_TYPE_INT, 3, 1); - const glsl_type *ivec4_type = glsl_type::get_instance(GLSL_TYPE_INT, 4, 1); - const glsl_type *uvec2_type = glsl_type::get_instance(GLSL_TYPE_UINT, 2, 1); - const glsl_type *uvec3_type = glsl_type::get_instance(GLSL_TYPE_UINT, 3, 1); - const glsl_type *uvec4_type = glsl_type::get_instance(GLSL_TYPE_UINT, 4, 1); - const glsl_type *bvec2_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1); - const glsl_type *bvec3_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 3, 1); - const glsl_type *bvec4_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1); - - bool added = symtab->add_function(name, f); - assert(added); - - instructions->push_tail(f); - - generate_function_instance(f, 2, generate, - bvec2_type, glsl_type::vec2_type); - generate_function_instance(f, 2, generate, - bvec3_type, glsl_type::vec3_type); - generate_function_instance(f, 2, generate, - bvec4_type, glsl_type::vec4_type); - - generate_function_instance(f, 2, generate, - bvec2_type, ivec2_type); - generate_function_instance(f, 2, generate, - bvec3_type, ivec3_type); - generate_function_instance(f, 2, generate, - bvec4_type, ivec4_type); - - generate_function_instance(f, 2, generate, - bvec2_type, uvec2_type); - generate_function_instance(f, 2, generate, - bvec3_type, uvec3_type); - generate_function_instance(f, 2, generate, - bvec4_type, uvec4_type); - - if (do_bool) { - generate_function_instance(f, 2, generate, - bvec2_type, bvec2_type); - generate_function_instance(f, 2, generate, - bvec3_type, bvec3_type); - generate_function_instance(f, 2, generate, - bvec4_type, bvec4_type); + if (st->error) { + printf("error reading builtin: %.35s ...\n", functions[i]); + return; + } } } -static void -generate_length(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg = new ir_dereference(declarations[0]); - ir_rvalue *result, *temp; - - (void)type; - - /* FINISHME: implement the abs(arg) variant for length(float f) */ - - temp = new ir_expression(ir_binop_dot, glsl_type::float_type, arg, arg); - result = new ir_expression(ir_unop_sqrt, glsl_type::float_type, temp, NULL); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -void -generate_length_functions(glsl_symbol_table *symtab, exec_list *instructions) -{ - const char *name = "length"; - ir_function *const f = new ir_function(name); - - bool added = symtab->add_function(name, f); - assert(added); - - instructions->push_tail(f); - - generate_function_instance(f, 1, generate_length, - glsl_type::float_type, glsl_type::float_type); - generate_function_instance(f, 1, generate_length, - glsl_type::float_type, glsl_type::vec2_type); - generate_function_instance(f, 1, generate_length, - glsl_type::float_type, glsl_type::vec3_type); - generate_function_instance(f, 1, generate_length, - glsl_type::float_type, glsl_type::vec4_type); -} - -static void -generate_dot(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg0 = new ir_dereference(declarations[0]); - ir_dereference *const arg1 = new ir_dereference(declarations[1]); - ir_rvalue *result; - - (void)type; - - result = new ir_expression(ir_binop_dot, glsl_type::float_type, arg0, arg1); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -void -generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions) -{ - const char *name = "dot"; - ir_function *const f = new ir_function(name); - - bool added = symtab->add_function(name, f); - assert(added); - - instructions->push_tail(f); - - generate_function_instance(f, 2, generate_dot, - glsl_type::float_type, glsl_type::float_type); - generate_function_instance(f, 2, generate_dot, - glsl_type::float_type, glsl_type::vec2_type); - generate_function_instance(f, 2, generate_dot, - glsl_type::float_type, glsl_type::vec3_type); - generate_function_instance(f, 2, generate_dot, - glsl_type::float_type, glsl_type::vec4_type); -} - -static void -generate_any_bvec2(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg0 = new ir_dereference(declarations[0]); - ir_rvalue *result; - - (void)type; - - result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, - new ir_swizzle(arg0, 0, 0, 0, 0, 1), - new ir_swizzle(arg0, 1, 0, 0, 0, 1)); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_any_bvec3(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg0 = new ir_dereference(declarations[0]); - ir_rvalue *result; - - (void)type; - - result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, - new ir_swizzle(arg0, 0, 0, 0, 0, 1), - new ir_swizzle(arg0, 1, 0, 0, 0, 1)); - result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, - result, - new ir_swizzle(arg0, 2, 0, 0, 0, 1)); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_any_bvec4(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg0 = new ir_dereference(declarations[0]); - ir_rvalue *result; - - (void)type; - - result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, - new ir_swizzle(arg0, 0, 0, 0, 0, 1), - new ir_swizzle(arg0, 1, 0, 0, 0, 1)); - result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, - result, - new ir_swizzle(arg0, 2, 0, 0, 0, 1)); - result = new ir_expression(ir_binop_logic_or, glsl_type::bool_type, - result, - new ir_swizzle(arg0, 3, 0, 0, 0, 1)); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_all_bvec2(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg0 = new ir_dereference(declarations[0]); - ir_rvalue *result; - - (void)type; - - result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, - new ir_swizzle(arg0, 0, 0, 0, 0, 1), - new ir_swizzle(arg0, 1, 0, 0, 0, 1)); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_all_bvec3(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg0 = new ir_dereference(declarations[0]); - ir_rvalue *result; - - (void)type; - - result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, - new ir_swizzle(arg0, 0, 0, 0, 0, 1), - new ir_swizzle(arg0, 1, 0, 0, 0, 1)); - result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, - result, - new ir_swizzle(arg0, 2, 0, 0, 0, 1)); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_all_bvec4(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg0 = new ir_dereference(declarations[0]); - ir_rvalue *result; - - (void)type; - - result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, - new ir_swizzle(arg0, 0, 0, 0, 0, 1), - new ir_swizzle(arg0, 1, 0, 0, 0, 1)); - result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, - result, - new ir_swizzle(arg0, 2, 0, 0, 0, 1)); - result = new ir_expression(ir_binop_logic_and, glsl_type::bool_type, - result, - new ir_swizzle(arg0, 3, 0, 0, 0, 1)); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -static void -generate_not(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) -{ - ir_dereference *const arg0 = new ir_dereference(declarations[0]); - ir_rvalue *result; - - result = new ir_expression(ir_unop_logic_not, type, arg0, NULL); - - ir_instruction *inst = new ir_return(result); - instructions->push_tail(inst); -} - -void -generate_any_functions(glsl_symbol_table *symtab, exec_list *instructions) -{ - const char *name = "any"; - ir_function *const f = new ir_function(name); - const glsl_type *bvec2_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1); - const glsl_type *bvec3_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 3, 1); - const glsl_type *bvec4_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1); - - bool added = symtab->add_function(name, f); - assert(added); - - instructions->push_tail(f); - - generate_function_instance(f, 1, generate_any_bvec2, - glsl_type::bool_type, bvec2_type); - generate_function_instance(f, 1, generate_any_bvec3, - glsl_type::bool_type, bvec3_type); - generate_function_instance(f, 1, generate_any_bvec4, - glsl_type::bool_type, bvec4_type); -} +/* Version 110 builtins */ + +static const char *builtins_110_abs = { + "((function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float abs (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 abs (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 abs (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 abs (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_all = { + "((function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n" + "))\n" +}; + +static const char *builtins_110_any = { + "((function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n" + "))\n" +}; + +static const char *builtins_110_ceil = { + "((function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float ceil (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 ceil (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 ceil (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 ceil (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_clamp = { + "((function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) vec2 arg2))\n" + " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) vec3 arg2))\n" + " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) vec4 arg2))\n" + " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "))\n" +}; + +static const char *builtins_110_degrees = { + "((function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float * (var_ref arg0) (constant float (57.295780))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 * (var_ref arg0) (constant float (57.295780))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 * (var_ref arg0) (constant float (57.295780))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 * (var_ref arg0) (constant float (57.295780))))))\n" + "))\n" +}; + +static const char *builtins_110_dot = { + "((function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "))\n" +}; + +static const char *builtins_110_equal = { + "((function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_exp = { + "((function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float exp (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 exp (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 exp (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 exp (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_exp2 = { + "((function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float exp2 (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 exp2 (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 exp2 (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 exp2 (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_floor = { + "((function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float floor (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 floor (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 floor (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 floor (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_greaterThan = { + "((function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_greaterThanEqual = { + "((function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_inversesqrt = { + "((function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float rsq (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 rsq (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 rsq (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 rsq (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_length = { + "((function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "))\n" +}; + +static const char *builtins_110_lessThan = { + "((function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_lessThanEqual = { + "((function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_log = { + "((function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float log (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 log (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 log (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 log (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_log2 = { + "((function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float log2 (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 log2 (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 log2 (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 log2 (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_max = { + "((function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" + "))\n" +}; + +static const char *builtins_110_min = { + "((function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" + "))\n" +}; + +static const char *builtins_110_mix = { + "((function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) vec2 arg2))\n" + " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) vec3 arg2))\n" + " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) vec4 arg2))\n" + " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" + "))\n" +}; + +static const char *builtins_110_mod = { + "((function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" + "))\n" +}; + +static const char *builtins_110_normalize = { + "((function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "))\n" +}; + +static const char *builtins_110_not = { + "((function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bvec2 ! (var_ref arg0)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bvec3 ! (var_ref arg0)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bvec4 ! (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_notEqual = { + "((function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_pow = { + "((function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float pow (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 pow (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 pow (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 pow (var_ref arg0) (var_ref arg1)))))\n" + "))\n" +}; + +static const char *builtins_110_radians = { + "((function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float * (var_ref arg0) (constant float (0.017453))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 * (var_ref arg0) (constant float (0.017453))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 * (var_ref arg0) (constant float (0.017453))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 * (var_ref arg0) (constant float (0.017453))))))\n" + "))\n" +}; + +static const char *builtins_110_sqrt = { + "((function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float sqrt (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 sqrt (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 sqrt (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 sqrt (var_ref arg0)))))\n" + "))\n" +}; + +static const char *functions_for_110 [] = { + builtins_110_abs, + builtins_110_all, + builtins_110_any, + builtins_110_ceil, + builtins_110_clamp, + builtins_110_degrees, + builtins_110_dot, + builtins_110_equal, + builtins_110_exp, + builtins_110_exp2, + builtins_110_floor, + builtins_110_greaterThan, + builtins_110_greaterThanEqual, + builtins_110_inversesqrt, + builtins_110_length, + builtins_110_lessThan, + builtins_110_lessThanEqual, + builtins_110_log, + builtins_110_log2, + builtins_110_max, + builtins_110_min, + builtins_110_mix, + builtins_110_mod, + builtins_110_normalize, + builtins_110_not, + builtins_110_notEqual, + builtins_110_pow, + builtins_110_radians, + builtins_110_sqrt, +}; + +/* Version 130 builtins */ + +static const char *builtins_130_equal = { + "((function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_greaterThan = { + "((function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_greaterThanEqual = { + "((function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_lessThan = { + "((function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_lessThanEqual = { + "((function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_notEqual = { + "((function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *functions_for_130 [] = { + builtins_130_equal, + builtins_130_greaterThan, + builtins_130_greaterThanEqual, + builtins_130_lessThan, + builtins_130_lessThanEqual, + builtins_130_notEqual, +}; void -generate_all_functions(glsl_symbol_table *symtab, exec_list *instructions) -{ - const char *name = "all"; - ir_function *const f = new ir_function(name); - const glsl_type *bvec2_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1); - const glsl_type *bvec3_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 3, 1); - const glsl_type *bvec4_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1); - - bool added = symtab->add_function(name, f); - assert(added); - - instructions->push_tail(f); - - generate_function_instance(f, 1, generate_all_bvec2, - glsl_type::bool_type, bvec2_type); - generate_function_instance(f, 1, generate_all_bvec3, - glsl_type::bool_type, bvec3_type); - generate_function_instance(f, 1, generate_all_bvec4, - glsl_type::bool_type, bvec4_type); -} - -void -generate_not_functions(glsl_symbol_table *symtab, exec_list *instructions) +_mesa_glsl_initialize_functions(exec_list *instructions, + struct _mesa_glsl_parse_state *state) { - const char *name = "not"; - ir_function *const f = new ir_function(name); - const glsl_type *bvec2_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1); - const glsl_type *bvec3_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 3, 1); - const glsl_type *bvec4_type = glsl_type::get_instance(GLSL_TYPE_BOOL, 4, 1); - - bool added = symtab->add_function(name, f); - assert(added); - - instructions->push_tail(f); - - generate_function_instance(f, 1, generate_not, - bvec2_type, bvec2_type); - generate_function_instance(f, 1, generate_not, - bvec3_type, bvec3_type); - generate_function_instance(f, 1, generate_not, - bvec4_type, bvec4_type); -} + if (state->language_version >= 110) + read_builtins(state, instructions, functions_for_110, + sizeof(functions_for_110) / sizeof(const char *)); -void -generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) -{ - make_gentype_function(symtab, instructions, "radians", 1, generate_radians); - make_gentype_function(symtab, instructions, "degrees", 1, generate_degrees); - /* FINISHME: sin() */ - /* FINISHME: cos() */ - /* FINISHME: tan() */ - /* FINISHME: asin() */ - /* FINISHME: acos() */ - /* FINISHME: atan(y,x) */ - /* FINISHME: atan(y/x) */ - make_gentype_function(symtab, instructions, "pow", 2, generate_pow); - make_gentype_function(symtab, instructions, "exp", 1, generate_exp); - make_gentype_function(symtab, instructions, "log", 1, generate_log); - make_gentype_function(symtab, instructions, "exp2", 1, generate_exp2); - make_gentype_function(symtab, instructions, "log2", 1, generate_log2); - make_gentype_function(symtab, instructions, "sqrt", 1, generate_sqrt); - make_gentype_function(symtab, instructions, "inversesqrt", 1, generate_rsq); - make_gentype_function(symtab, instructions, "abs", 1, generate_abs); - /* FINISHME: sign() */ - make_gentype_function(symtab, instructions, "floor", 1, generate_floor); - make_gentype_function(symtab, instructions, "ceil", 1, generate_ceil); - /* FINISHME: fract() */ - /* FINISHME: mod(x, float y) */ - make_gentype_function(symtab, instructions, "mod", 2, generate_mod); - make_gentype_function(symtab, instructions, "min", 2, generate_min); - /* FINISHME: min(x, float y) */ - make_gentype_function(symtab, instructions, "max", 2, generate_max); - /* FINISHME: max(x, float y) */ - make_gentype_function(symtab, instructions, "clamp", 3, generate_clamp); - /* FINISHME: clamp() */ - make_gentype_function(symtab, instructions, "mix", 3, generate_mix_vec); - /* FINISHME: mix() */ - /* FINISHME: step() */ - /* FINISHME: step() */ - /* FINISHME: smoothstep() */ - /* FINISHME: smoothstep() */ - /* FINISHME: floor() */ - /* FINISHME: step() */ - generate_length_functions(symtab, instructions); - /* FINISHME: distance() */ - generate_dot_functions(symtab, instructions); - /* FINISHME: cross() */ - make_gentype_function(symtab, instructions, "normalize", 1, - generate_normalize); - /* FINISHME: normalize() */ - /* FINISHME: ftransform() */ - /* FINISHME: faceforward() */ - /* FINISHME: reflect() */ - /* FINISHME: refract() */ - /* FINISHME: matrixCompMult() */ - generate_vec_compare_function(symtab, instructions, - "lessThan", generate_lessThan, false); - generate_vec_compare_function(symtab, instructions, - "lessThanEqual", generate_lessThanEqual, - false); - generate_vec_compare_function(symtab, instructions, - "greaterThan", generate_greaterThan, false); - generate_vec_compare_function(symtab, instructions, - "greaterThanEqual", generate_greaterThanEqual, - false); - generate_vec_compare_function(symtab, instructions, - "equal", generate_equal, false); - generate_vec_compare_function(symtab, instructions, - "notEqual", generate_notEqual, false); - generate_any_functions(symtab, instructions); - generate_all_functions(symtab, instructions); - generate_not_functions(symtab, instructions); - /* FINISHME: texture*() */ - /* FINISHME: shadow*() */ - /* FINISHME: dFd[xy]() */ - /* FINISHME: fwidth() */ -} + if (state->language_version >= 130) + read_builtins(state, instructions, functions_for_130, + sizeof(functions_for_130) / sizeof(const char *)); -void -_mesa_glsl_initialize_functions(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - generate_110_functions(state->symbols, instructions); } -- cgit v1.2.3 From 9287ecc3aa81ab5e79bc9aa61bcdd620a142d79d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 3 May 2010 14:39:03 -0700 Subject: Integrate generate_builtins.pl into the build process. make will now regenerate builtin_function.cpp whenever you change/add/remove files in the builtins/* folders. --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index 8f2f3fa632e..105fcc5d28f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,6 +51,8 @@ glsl_SOURCES = \ BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) +builtin_function.cpp: builtins/*/* + ./builtins/tools/generate_builtins.pl > builtin_function.cpp glsl_parser.h: glsl_parser.cpp .lpp.cpp: -- cgit v1.2.3 From a2b63d3ed1197587f2441c4c2897ff32b3228d26 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 30 Apr 2010 15:18:07 -0700 Subject: Implement "step" builtin. --- builtins/110/step | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 builtins/110/step diff --git a/builtins/110/step b/builtins/110/step new file mode 100644 index 00000000000..1cc2b51f8fb --- /dev/null +++ b/builtins/110/step @@ -0,0 +1,68 @@ +((function step + (signature float + (parameters + (declare (in) float edge) + (declare (in) float x)) + ((return (expression float b2f (expression bool < (var_ref x) (var_ref edge)))))) + + (signature vec2 + (parameters + (declare (in) float edge) + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec3 + (parameters + (declare (in) float edge) + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec4 + (parameters + (declare (in) float edge) + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec2 + (parameters + (declare (in) vec2 edge) + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz 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 + (parameters + (declare (in) vec3 edge) + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (constant bool (1)) (swiz 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 + (parameters + (declare (in) vec4 edge) + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz z (var_ref edge))))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(swiz w (var_ref edge))))) + (return (var_ref t)))) +)) + -- cgit v1.2.3 From c2de1875234565c53b8f3683b04bc7f901055882 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 3 May 2010 19:10:04 -0700 Subject: Implement "smoothstep" builtin. --- builtins/110/smoothstep | 224 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 builtins/110/smoothstep diff --git a/builtins/110/smoothstep b/builtins/110/smoothstep new file mode 100644 index 00000000000..b4255ba78f1 --- /dev/null +++ b/builtins/110/smoothstep @@ -0,0 +1,224 @@ +((function smoothstep + (signature float + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) float x)) + ((declare () float t) + + (assign (constant bool (1)) (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))) + (constant float (1.0))) + (constant float (0.0)))) + (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t)))))))) + + (signature vec2 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec2 x)) + ((declare () vec2 t) + (declare () vec2 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + (return (var_ref retval)) + )) + + (signature vec3 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec3 x)) + ((declare () vec3 t) + (declare () vec3 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) + (return (var_ref retval)) + )) + + + (signature vec4 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec4 x)) + ((declare () vec4 t) + (declare () vec4 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) + + (assign (constant bool (1)) (swiz w (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t))))))) + (return (var_ref retval)) + )) + + (signature vec2 + (parameters + (declare (in) vec2 edge0) + (declare (in) vec2 edge1) + (declare (in) vec2 x)) + ((declare () vec2 t) + (declare () vec2 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + (return (var_ref retval)) + )) + + (signature vec3 + (parameters + (declare (in) vec3 edge0) + (declare (in) vec3 edge1) + (declare (in) vec3 x)) + ((declare () vec3 t) + (declare () vec3 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) + (return (var_ref retval)) + )) + + + (signature vec4 + (parameters + (declare (in) vec4 edge0) + (declare (in) vec4 edge1) + (declare (in) vec4 x)) + ((declare () vec4 t) + (declare () vec4 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) + + (assign (constant bool (1)) (swiz w (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz w (var_ref x)) (swiz w (var_ref edge0))) (expression float - (swiz w (var_ref edge1)) (swiz w (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t))))))) + (return (var_ref retval)) + )) + +)) + -- cgit v1.2.3 From a4b7b5a654ca810e296bb0cca1b27b8847f5548a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 3 May 2010 20:05:57 -0700 Subject: Implement "sign" builtin via a new expression operator. --- builtins/110/sign | 34 ++++++++++++++++++++++++++++++++++ builtins/130/sign | 34 ++++++++++++++++++++++++++++++++++ ir.cpp | 2 ++ ir.h | 1 + 4 files changed, 71 insertions(+) create mode 100644 builtins/110/sign create mode 100644 builtins/130/sign diff --git a/builtins/110/sign b/builtins/110/sign new file mode 100644 index 00000000000..7d540de405b --- /dev/null +++ b/builtins/110/sign @@ -0,0 +1,34 @@ +((function sign + (signature float + (parameters + (declare (in) float x)) + ((return (expression float sign (var_ref x))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) + (return (var_ref t)))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x)))) + (return (var_ref t)))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x)))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression float sign (swiz w (var_ref x)))) + (return (var_ref t)))) +)) + diff --git a/builtins/130/sign b/builtins/130/sign new file mode 100644 index 00000000000..0bdc0e09d25 --- /dev/null +++ b/builtins/130/sign @@ -0,0 +1,34 @@ +((function sign + (signature int + (parameters + (declare (in) int x)) + ((return (expression int / (var_ref x) (expression int abs (var_ref x)))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 x)) + ((declare () ivec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) + (return (var_ref t)))) + + (signature ivec3 + (parameters + (declare (in) ivec3 x)) + ((declare () ivec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x)))) + (return (var_ref t)))) + + (signature ivec4 + (parameters + (declare (in) ivec4 x)) + ((declare () ivec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x)))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression int sign (swiz w (var_ref x)))) + (return (var_ref t)))) +)) + diff --git a/ir.cpp b/ir.cpp index 76f5bab7311..b927c73ccb6 100644 --- a/ir.cpp +++ b/ir.cpp @@ -53,6 +53,7 @@ ir_expression::get_num_operands(ir_expression_operation op) 1, /* ir_unop_logic_not */ 1, /* ir_unop_neg */ 1, /* ir_unop_abs */ + 1, /* ir_unop_sign */ 1, /* ir_unop_rcp */ 1, /* ir_unop_rsq */ 1, /* ir_unop_sqrt */ @@ -112,6 +113,7 @@ static const char *const operator_strs[] = { "!", "neg", "abs", + "sign", "rcp", "rsq", "sqrt", diff --git a/ir.h b/ir.h index d8568a8dae7..55a67733fe7 100644 --- a/ir.h +++ b/ir.h @@ -424,6 +424,7 @@ enum ir_expression_operation { ir_unop_logic_not, ir_unop_neg, ir_unop_abs, + ir_unop_sign, ir_unop_rcp, ir_unop_rsq, ir_unop_sqrt, -- cgit v1.2.3 From d9bda3c29d23f99598645902c8ba3b7666341c9b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 3 May 2010 20:59:09 -0700 Subject: Implement "fract" builtin. --- builtins/110/fract | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 builtins/110/fract diff --git a/builtins/110/fract b/builtins/110/fract new file mode 100644 index 00000000000..3995bfaf3f9 --- /dev/null +++ b/builtins/110/fract @@ -0,0 +1,34 @@ +((function fract + (signature float + (parameters + (declare (in) float x)) + ((return (expression float - (var_ref x) (expression float floor (var_ref x)))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) + (return (var_ref t)))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x))))) + (return (var_ref t)))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x))))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression float - (swiz w (var_ref x)) (expression float floor (swiz w (var_ref x))))) + (return (var_ref t)))) +)) + -- cgit v1.2.3 From 6a9b1e1f06c2859f0c20375189c6ff02ed769d1a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 3 May 2010 21:29:01 -0700 Subject: Implement "cross" builtin. --- builtins/110/cross | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 builtins/110/cross diff --git a/builtins/110/cross b/builtins/110/cross new file mode 100644 index 00000000000..deb2f952bfc --- /dev/null +++ b/builtins/110/cross @@ -0,0 +1,17 @@ +((function cross + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float - (expression float * (swiz y (var_ref arg0)) (swiz z (var_ref arg1))) + (expression float * (swiz y (var_ref arg1)) (swiz z (var_ref arg0))))) + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float - (expression float * (swiz z (var_ref arg0)) (swiz x (var_ref arg1))) + (expression float * (swiz z (var_ref arg1)) (swiz x (var_ref arg0))))) + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float - (expression float * (swiz x (var_ref arg0)) (swiz y (var_ref arg1))) + (expression float * (swiz x (var_ref arg1)) (swiz y (var_ref arg0))))) + (return (var_ref t)))) +)) -- cgit v1.2.3 From 57e7da173e8d38bf0c95ded535cdf1b12a00a1a2 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 3 May 2010 22:11:17 -0700 Subject: Implement "sin" and "cos" builtins via new expression operators. --- builtins/110/cos | 21 +++++++++++++++++++++ builtins/110/sin | 21 +++++++++++++++++++++ ir.cpp | 5 +++++ ir.h | 8 ++++++++ 4 files changed, 55 insertions(+) create mode 100644 builtins/110/cos create mode 100644 builtins/110/sin diff --git a/builtins/110/cos b/builtins/110/cos new file mode 100644 index 00000000000..88f266eccbe --- /dev/null +++ b/builtins/110/cos @@ -0,0 +1,21 @@ +((function cos + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float cos (var_ref angle))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 cos (var_ref angle))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 cos (var_ref angle))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 cos (var_ref angle))))) +)) diff --git a/builtins/110/sin b/builtins/110/sin new file mode 100644 index 00000000000..e6009d8ef12 --- /dev/null +++ b/builtins/110/sin @@ -0,0 +1,21 @@ +((function sin + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float sin (var_ref angle))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 sin (var_ref angle))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 sin (var_ref angle))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 sin (var_ref angle))))) +)) diff --git a/ir.cpp b/ir.cpp index b927c73ccb6..eb12b5fe77f 100644 --- a/ir.cpp +++ b/ir.cpp @@ -73,6 +73,9 @@ ir_expression::get_num_operands(ir_expression_operation op) 1, /* ir_unop_ceil */ 1, /* ir_unop_floor */ + 1, /* ir_unop_sin */ + 1, /* ir_unop_cos */ + 2, /* ir_binop_add */ 2, /* ir_binop_sub */ 2, /* ir_binop_mul */ @@ -131,6 +134,8 @@ static const char *const operator_strs[] = { "trunc", "ceil", "floor", + "sin", + "cos", "+", "-", "*", diff --git a/ir.h b/ir.h index 55a67733fe7..df9a8c4174d 100644 --- a/ir.h +++ b/ir.h @@ -449,6 +449,14 @@ enum ir_expression_operation { ir_unop_floor, /*@}*/ + /** + * \name Trigonometric operations. + */ + /*@{*/ + ir_unop_sin, + ir_unop_cos, + /*@}*/ + ir_binop_add, ir_binop_sub, ir_binop_mul, -- cgit v1.2.3 From c8de850dd5b80b42f75dc339921b3d4f28db5bf5 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 3 May 2010 22:12:35 -0700 Subject: Implement "tan" builtin. --- builtins/110/tan | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 builtins/110/tan diff --git a/builtins/110/tan b/builtins/110/tan new file mode 100644 index 00000000000..3e04892a76c --- /dev/null +++ b/builtins/110/tan @@ -0,0 +1,21 @@ +((function tan + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle)))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression float / (expression float sin (var_ref angle)) (expression vec2 cos (var_ref angle)))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression float / (expression float sin (var_ref angle)) (expression vec3 cos (var_ref angle)))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression float / (expression float sin (var_ref angle)) (expression vec4 cos (var_ref angle)))))) +)) -- cgit v1.2.3 From 67e07ad3a33192ebf8e296c1c652d29dee467ae2 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 30 Apr 2010 15:20:06 -0700 Subject: Refresh autogenerated builtin_function.cpp. --- builtin_function.cpp | 798 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 654 insertions(+), 144 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index ef3a5c8d4b9..909329c563a 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -163,6 +163,50 @@ static const char *builtins_110_clamp = { "))\n" }; +static const char *builtins_110_cos = { + "((function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ((return (expression float cos (var_ref angle)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ((return (expression vec2 cos (var_ref angle)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ((return (expression vec3 cos (var_ref angle)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ((return (expression vec4 cos (var_ref angle)))))\n" + "))\n" +}; + +static const char *builtins_110_cross = { + "((function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float - (expression float * (swiz y (var_ref arg0)) (swiz z (var_ref arg1)))\n" + " (expression float * (swiz y (var_ref arg1)) (swiz z (var_ref arg0)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float - (expression float * (swiz z (var_ref arg0)) (swiz x (var_ref arg1)))\n" + " (expression float * (swiz z (var_ref arg1)) (swiz x (var_ref arg0)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float - (expression float * (swiz x (var_ref arg0)) (swiz y (var_ref arg1)))\n" + " (expression float * (swiz x (var_ref arg1)) (swiz y (var_ref arg0)))))\n" + " (return (var_ref t))))\n" + "))\n" +}; + static const char *builtins_110_degrees = { "((function degrees\n" " (signature float\n" @@ -222,8 +266,8 @@ static const char *builtins_110_equal = { " (declare (in) vec2 arg0)\n" " (declare (in) vec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -231,9 +275,9 @@ static const char *builtins_110_equal = { " (declare (in) vec3 arg0)\n" " (declare (in) vec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -241,10 +285,10 @@ static const char *builtins_110_equal = { " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec2\n" @@ -252,8 +296,8 @@ static const char *builtins_110_equal = { " (declare (in) ivec2 arg0)\n" " (declare (in) ivec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -261,9 +305,9 @@ static const char *builtins_110_equal = { " (declare (in) ivec3 arg0)\n" " (declare (in) ivec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -271,10 +315,10 @@ static const char *builtins_110_equal = { " (declare (in) ivec4 arg0)\n" " (declare (in) ivec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; @@ -351,6 +395,43 @@ static const char *builtins_110_floor = { "))\n" }; +static const char *builtins_110_fract = { + "((function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float - (var_ref x) (expression float floor (var_ref x))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x)))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float - (swiz w (var_ref x)) (expression float floor (swiz w (var_ref x)))))\n" + " (return (var_ref t))))\n" + "))\n" + "\n" +}; + static const char *builtins_110_greaterThan = { "((function greaterThan\n" " (signature bvec2\n" @@ -358,8 +439,8 @@ static const char *builtins_110_greaterThan = { " (declare (in) vec2 arg0)\n" " (declare (in) vec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -367,9 +448,9 @@ static const char *builtins_110_greaterThan = { " (declare (in) vec3 arg0)\n" " (declare (in) vec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -377,10 +458,10 @@ static const char *builtins_110_greaterThan = { " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec2\n" @@ -388,8 +469,8 @@ static const char *builtins_110_greaterThan = { " (declare (in) ivec2 arg0)\n" " (declare (in) ivec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -397,9 +478,9 @@ static const char *builtins_110_greaterThan = { " (declare (in) ivec3 arg0)\n" " (declare (in) ivec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -407,10 +488,10 @@ static const char *builtins_110_greaterThan = { " (declare (in) ivec4 arg0)\n" " (declare (in) ivec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; @@ -422,8 +503,8 @@ static const char *builtins_110_greaterThanEqual = { " (declare (in) vec2 arg0)\n" " (declare (in) vec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -431,9 +512,9 @@ static const char *builtins_110_greaterThanEqual = { " (declare (in) vec3 arg0)\n" " (declare (in) vec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -441,10 +522,10 @@ static const char *builtins_110_greaterThanEqual = { " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec2\n" @@ -452,8 +533,8 @@ static const char *builtins_110_greaterThanEqual = { " (declare (in) ivec2 arg0)\n" " (declare (in) ivec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -461,9 +542,9 @@ static const char *builtins_110_greaterThanEqual = { " (declare (in) ivec3 arg0)\n" " (declare (in) ivec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -471,10 +552,10 @@ static const char *builtins_110_greaterThanEqual = { " (declare (in) ivec4 arg0)\n" " (declare (in) ivec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; @@ -534,8 +615,8 @@ static const char *builtins_110_lessThan = { " (declare (in) vec2 arg0)\n" " (declare (in) vec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -543,9 +624,9 @@ static const char *builtins_110_lessThan = { " (declare (in) vec3 arg0)\n" " (declare (in) vec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -553,10 +634,10 @@ static const char *builtins_110_lessThan = { " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec2\n" @@ -564,8 +645,8 @@ static const char *builtins_110_lessThan = { " (declare (in) ivec2 arg0)\n" " (declare (in) ivec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -573,9 +654,9 @@ static const char *builtins_110_lessThan = { " (declare (in) ivec3 arg0)\n" " (declare (in) ivec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -583,10 +664,10 @@ static const char *builtins_110_lessThan = { " (declare (in) ivec4 arg0)\n" " (declare (in) ivec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; @@ -598,8 +679,8 @@ static const char *builtins_110_lessThanEqual = { " (declare (in) vec2 arg0)\n" " (declare (in) vec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -607,9 +688,9 @@ static const char *builtins_110_lessThanEqual = { " (declare (in) vec3 arg0)\n" " (declare (in) vec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -617,10 +698,10 @@ static const char *builtins_110_lessThanEqual = { " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec2\n" @@ -628,8 +709,8 @@ static const char *builtins_110_lessThanEqual = { " (declare (in) ivec2 arg0)\n" " (declare (in) ivec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -637,9 +718,9 @@ static const char *builtins_110_lessThanEqual = { " (declare (in) ivec3 arg0)\n" " (declare (in) ivec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -647,10 +728,10 @@ static const char *builtins_110_lessThanEqual = { " (declare (in) ivec4 arg0)\n" " (declare (in) ivec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; @@ -978,6 +1059,294 @@ static const char *builtins_110_radians = { "))\n" }; +static const char *builtins_110_sign = { + "((function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float sign (var_ref x)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float sign (swiz w (var_ref x))))\n" + " (return (var_ref t))))\n" + "))\n" + "\n" +}; + +static const char *builtins_110_sin = { + "((function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ((return (expression float sin (var_ref angle)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ((return (expression vec2 sin (var_ref angle)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ((return (expression vec3 sin (var_ref angle)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ((return (expression vec4 sin (var_ref angle)))))\n" + "))\n" +}; + +static const char *builtins_110_smoothstep = { + "((function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) float x))\n" + " ((declare () float t)\n" + "\n" + " (assign (constant bool (1)) (var_ref t)\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (declare () vec2 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (declare () vec3 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (declare () vec4 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz w (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge0)\n" + " (declare (in) vec2 edge1)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (declare () vec2 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge0)\n" + " (declare (in) vec3 edge1)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (declare () vec3 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge0)\n" + " (declare (in) vec4 edge1)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (declare () vec4 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz w (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz w (var_ref x)) (swiz w (var_ref edge0))) (expression float - (swiz w (var_ref edge1)) (swiz w (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + "))\n" + "\n" +}; + static const char *builtins_110_sqrt = { "((function sqrt\n" " (signature float\n" @@ -1002,18 +1371,116 @@ static const char *builtins_110_sqrt = { "))\n" }; +static const char *builtins_110_step = { + "((function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) float x))\n" + " ((return (expression float b2f (expression bool < (var_ref x) (var_ref edge))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(swiz z (var_ref edge)))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz z (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(swiz w (var_ref edge)))))\n" + " (return (var_ref t))))\n" + "))\n" + "\n" +}; + +static const char *builtins_110_tan = { + "((function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ((return (expression float / (expression float sin (var_ref angle)) (expression vec2 cos (var_ref angle))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ((return (expression float / (expression float sin (var_ref angle)) (expression vec3 cos (var_ref angle))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ((return (expression float / (expression float sin (var_ref angle)) (expression vec4 cos (var_ref angle))))))\n" + "))\n" +}; + static const char *functions_for_110 [] = { builtins_110_abs, builtins_110_all, builtins_110_any, builtins_110_ceil, builtins_110_clamp, + builtins_110_cos, + builtins_110_cross, builtins_110_degrees, builtins_110_dot, builtins_110_equal, builtins_110_exp, builtins_110_exp2, builtins_110_floor, + builtins_110_fract, builtins_110_greaterThan, builtins_110_greaterThanEqual, builtins_110_inversesqrt, @@ -1031,7 +1498,12 @@ static const char *functions_for_110 [] = { builtins_110_notEqual, builtins_110_pow, builtins_110_radians, + builtins_110_sign, + builtins_110_sin, + builtins_110_smoothstep, builtins_110_sqrt, + builtins_110_step, + builtins_110_tan, }; /* Version 130 builtins */ @@ -1043,8 +1515,8 @@ static const char *builtins_130_equal = { " (declare (in) uvec2 arg0)\n" " (declare (in) uvec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -1052,9 +1524,9 @@ static const char *builtins_130_equal = { " (declare (in) uvec3 arg0)\n" " (declare (in) uvec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -1062,10 +1534,10 @@ static const char *builtins_130_equal = { " (declare (in) uvec4 arg0)\n" " (declare (in) uvec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; @@ -1077,8 +1549,8 @@ static const char *builtins_130_greaterThan = { " (declare (in) uvec2 arg0)\n" " (declare (in) uvec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -1086,9 +1558,9 @@ static const char *builtins_130_greaterThan = { " (declare (in) uvec3 arg0)\n" " (declare (in) uvec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -1096,10 +1568,10 @@ static const char *builtins_130_greaterThan = { " (declare (in) uvec4 arg0)\n" " (declare (in) uvec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; @@ -1111,8 +1583,8 @@ static const char *builtins_130_greaterThanEqual = { " (declare (in) uvec2 arg0)\n" " (declare (in) uvec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -1120,9 +1592,9 @@ static const char *builtins_130_greaterThanEqual = { " (declare (in) uvec3 arg0)\n" " (declare (in) uvec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -1130,10 +1602,10 @@ static const char *builtins_130_greaterThanEqual = { " (declare (in) uvec4 arg0)\n" " (declare (in) uvec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; @@ -1145,8 +1617,8 @@ static const char *builtins_130_lessThan = { " (declare (in) uvec2 arg0)\n" " (declare (in) uvec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -1154,9 +1626,9 @@ static const char *builtins_130_lessThan = { " (declare (in) uvec3 arg0)\n" " (declare (in) uvec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -1164,10 +1636,10 @@ static const char *builtins_130_lessThan = { " (declare (in) uvec4 arg0)\n" " (declare (in) uvec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; @@ -1179,8 +1651,8 @@ static const char *builtins_130_lessThanEqual = { " (declare (in) uvec2 arg0)\n" " (declare (in) uvec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -1188,9 +1660,9 @@ static const char *builtins_130_lessThanEqual = { " (declare (in) uvec3 arg0)\n" " (declare (in) uvec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -1198,10 +1670,10 @@ static const char *builtins_130_lessThanEqual = { " (declare (in) uvec4 arg0)\n" " (declare (in) uvec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; @@ -1213,8 +1685,8 @@ static const char *builtins_130_notEqual = { " (declare (in) uvec2 arg0)\n" " (declare (in) uvec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -1222,9 +1694,9 @@ static const char *builtins_130_notEqual = { " (declare (in) uvec3 arg0)\n" " (declare (in) uvec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -1232,14 +1704,51 @@ static const char *builtins_130_notEqual = { " (declare (in) uvec4 arg0)\n" " (declare (in) uvec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression uint != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression uint != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression uint != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression uint != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" }; +static const char *builtins_130_sign = { + "((function sign\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int x))\n" + " ((return (expression int / (var_ref x) (expression int abs (var_ref x))))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 x))\n" + " ((declare () ivec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 x))\n" + " ((declare () ivec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 x))\n" + " ((declare () ivec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression int sign (swiz w (var_ref x))))\n" + " (return (var_ref t))))\n" + "))\n" + "\n" +}; + static const char *functions_for_130 [] = { builtins_130_equal, builtins_130_greaterThan, @@ -1247,6 +1756,7 @@ static const char *functions_for_130 [] = { builtins_130_lessThan, builtins_130_lessThanEqual, builtins_130_notEqual, + builtins_130_sign, }; void -- cgit v1.2.3 From f6ae186cfd2c7006656ac55446247b569b92a721 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 16:51:54 -0700 Subject: Add test invoking a macro with an argument containing (non-macro) parentheses. The macro invocation is defined to consume all text between a set of matched parentheses. We previously tested for inner parentheses from a nested function-like macro invocation. Here we test for inner parentheses occuring on their own, (not part of another macro invocation). --- tests/022-define-func-arg-with-parens.c | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/022-define-func-arg-with-parens.c diff --git a/tests/022-define-func-arg-with-parens.c b/tests/022-define-func-arg-with-parens.c new file mode 100644 index 00000000000..c20d73a4a28 --- /dev/null +++ b/tests/022-define-func-arg-with-parens.c @@ -0,0 +1,2 @@ +#define foo(x) (x) +foo(argument(including parens)for the win) -- cgit v1.2.3 From 3596bb149e107ad12df4fee0723caf91819c0758 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 16:53:52 -0700 Subject: Provide implementation for macro arguments containing parentheses. We were correctly parsing this already, but simply not returning any value (for no good reason). Fortunately the fix is quite simple. This makes the test added in the previous commit now pass. --- Makefile | 2 +- glcpp-parse.y | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 550945abd30..3fa863c49b9 100644 --- a/Makefile +++ b/Makefile @@ -21,5 +21,5 @@ test: glcpp @(cd tests; ./glcpp-test) clean: - rm -f glcpp-lex.c glcpp-parse.c *.o *~ + rm -f glcpp glcpp-lex.c glcpp-parse.c *.o *~ rm -f tests/*.out tests/*.gcc tests/*.expected tests/*~ diff --git a/glcpp-parse.y b/glcpp-parse.y index f972ec372b8..58afd724b6a 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -177,13 +177,20 @@ argument: | argument word { _string_list_append_item ($1, $2); talloc_free ($2); + $$ = $1; } | argument SPACE word { _string_list_append_item ($1, " "); _string_list_append_item ($1, $3); talloc_free ($3); + $$ = $1; + } +| argument '(' argument ')' { + _string_list_append_item ($1, "("); + _string_list_append_list ($1, $3); + _string_list_append_item ($1, ")"); + $$ = $1; } -| argument '(' argument ')' ; directive_with_newline: -- cgit v1.2.3 From 4eb2ccf261f739ad9b91455f28c1dece573a30d6 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 16:58:00 -0700 Subject: Add test with extra whitespace in macro defintions and invocations. This whitespace is not dealt with in an elegant way yet so this test does not pass currently. --- tests/023-define-extra-whitespace.c | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/023-define-extra-whitespace.c diff --git a/tests/023-define-extra-whitespace.c b/tests/023-define-extra-whitespace.c new file mode 100644 index 00000000000..375355a17d9 --- /dev/null +++ b/tests/023-define-extra-whitespace.c @@ -0,0 +1,8 @@ +#define noargs() 1 +# define onearg(foo) foo + # define twoargs( x , y ) x y + # define threeargs( a , b , c ) a b c +noargs ( ) + onearg ( 2 ) + twoargs ( 3 , 4 ) +threeargs ( 5 , 6 , 7 ) -- cgit v1.2.3 From 81f01432bd4aad8e8b87ae273eb05297e35eff07 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 17:08:45 -0700 Subject: Don't return SPACE tokens unless strictly needed. This reverts the unconditional return of SPACE tokens from the lexer from commit 48b94da0994b44e41324a2419117dcd81facce8b . That commit seemed useful because it kept the lexer simpler, but the presence of SPACE tokens is causing lots of extra complication for the parser itself, (redundant productions other than whitespace differences, several productions buggy in the case of extra whitespace, etc.) Of course, we'd prefer to never have any whitespace token, but that's not possible with the need to distinguish between "#define foo()" and "#define foo ()". So we'll accept a little bit of pain in the lexer, (enough state to support this special-case token), in exchange for keeping most of the parser blissffully ignorant of whether tokens are separated by whitespace or not. This change does mean that our output now differs from that of "gcc -E", but only in whitespace. So we test with "diff -w now to ignore those differences. --- glcpp-lex.l | 29 ++++++++++++++++++++++++++--- glcpp-parse.y | 22 +++++++--------------- tests/glcpp-test | 2 +- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 21b9e3530aa..3c9dda46d47 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -32,6 +32,9 @@ %option reentrant noyywrap %option extra-type="glcpp_parser_t *" +%x ST_DEFINE +%x ST_DEFVAL + SPACE [[:space:]] NONSPACE [^[:space:]] NEWLINE [\n] @@ -52,9 +55,31 @@ TOKEN [^[:space:](),]+ * "#define foo()" from "#define foo ()". */ {HASH}define{HSPACE}* { + BEGIN ST_DEFINE; return DEFINE; } +{IDENTIFIER} { + BEGIN ST_DEFVAL; + yylval.str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; +} + +\n { + BEGIN INITIAL; + return NEWLINE; +} + +{HSPACE}+ { + BEGIN INITIAL; + return SPACE; +} + +"(" { + BEGIN INITIAL; + return '('; +} + {IDENTIFIER} { yylval.str = xtalloc_strdup (yyextra, yytext); switch (glcpp_parser_macro_type (yyextra, yylval.str)) @@ -84,8 +109,6 @@ TOKEN [^[:space:](),]+ return NEWLINE; } -{HSPACE}+ { - return SPACE; -} +{SPACE}+ %% diff --git a/glcpp-parse.y b/glcpp-parse.y index 58afd724b6a..71ea3e53439 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -135,7 +135,6 @@ content: | '(' { printf ("("); } | ')' { printf (")"); } | ',' { printf (","); } -| SPACE { printf (" "); } ; macro: @@ -156,10 +155,6 @@ argument_list: $$ = _argument_list_create (parser); _argument_list_append ($$, $1); } -| argument_list ',' SPACE argument { - _argument_list_append ($1, $4); - $$ = $1; - } | argument_list ',' argument { _argument_list_append ($1, $3); $$ = $1; @@ -179,12 +174,6 @@ argument: talloc_free ($2); $$ = $1; } -| argument SPACE word { - _string_list_append_item ($1, " "); - _string_list_append_item ($1, $3); - talloc_free ($3); - $$ = $1; - } | argument '(' argument ')' { _string_list_append_item ($1, "("); _string_list_append_list ($1, $3); @@ -209,8 +198,8 @@ directive: string_list_t *list = _string_list_create (parser); _define_function_macro (parser, $2, $4, list); } -| DEFINE IDENTIFIER '(' parameter_list ')' SPACE replacement_list { - _define_function_macro (parser, $2, $4, $7); +| DEFINE IDENTIFIER '(' parameter_list ')' replacement_list { + _define_function_macro (parser, $2, $4, $6); } | UNDEF FUNC_MACRO { string_list_t *replacement = hash_table_find (parser->defines, $2); @@ -256,7 +245,6 @@ replacement_word: | '(' { $$ = xtalloc_strdup (parser, "("); } | ')' { $$ = xtalloc_strdup (parser, ")"); } | ',' { $$ = xtalloc_strdup (parser, ","); } -| SPACE { $$ = xtalloc_strdup (parser, " "); } ; parameter_list: @@ -373,8 +361,11 @@ _print_string_list (string_list_t *list) if (list == NULL) return; - for (node = list->head; node; node = node->next) + for (node = list->head; node; node = node->next) { printf ("%s", node->str); + if (node->next) + printf (" "); + } } argument_list_t * @@ -623,6 +614,7 @@ _expand_function_macro (glcpp_parser_t *parser, argument_list_t *arguments) { string_list_t *result; + macro_t *macro; result = _string_list_create (parser); diff --git a/tests/glcpp-test b/tests/glcpp-test index 25685eeabe5..bd204de1e2f 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -5,5 +5,5 @@ for test in *.c; do ../glcpp < $test > $test.out gcc -E $test -o $test.gcc grep -v '^#' < $test.gcc > $test.expected - diff -u $test.expected $test.out + diff -w -u $test.expected $test.out done -- cgit v1.2.3 From e36a4d5be9a9fa3abc4fb5d0b6c3601934f7a343 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 14 May 2010 17:29:24 -0700 Subject: Fix two whitespace bugs in the lexer. The first bug was not allowing whitespace between '#' and the directive name. The second bug was swallowing a terminating newline along with any trailing whitespace on a line. With these two fixes, and the previous commit to stop emitting SPACE tokens, the recently added extra-whitespace test now passes. --- glcpp-lex.l | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 3c9dda46d47..97ff1175f1b 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -39,7 +39,7 @@ SPACE [[:space:]] NONSPACE [^[:space:]] NEWLINE [\n] HSPACE [ \t] -HASH ^{HSPACE}*# +HASH ^{HSPACE}*#{HSPACE}* IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* TOKEN [^[:space:](),]+ @@ -109,6 +109,6 @@ TOKEN [^[:space:](),]+ return NEWLINE; } -{SPACE}+ +{HSPACE}+ %% -- cgit v1.2.3 From 2b3c476fa08e33a0ee1633b173a7df31ecaca582 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 17:35:42 -0700 Subject: Add ir_rvalue::variable_referenced --- ir.cpp | 35 +++++++++++++++++++++++++++++++++++ ir.h | 18 ++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/ir.cpp b/ir.cpp index eb12b5fe77f..696feb23f6f 100644 --- a/ir.cpp +++ b/ir.cpp @@ -283,6 +283,36 @@ ir_dereference::is_lvalue() return this->var->as_rvalue()->is_lvalue(); } + +ir_variable * +ir_dereference::variable_referenced() +{ + /* Walk down the dereference chain to find the variable at the end. + * + * This could be implemented recurrsively, but it would still need to call + * as_variable and as_rvalue, so the code wouldn't be any cleaner. + */ + for (ir_instruction *current = this->var; current != NULL; /* empty */ ) { + ir_dereference *deref; + ir_variable *v; + + if ((deref = current->as_dereference())) { + current = deref->var; + } else if ((v = current->as_variable())) { + return v; + } else { + /* This is the case of, for example, an array dereference of the + * value returned by a function call. + */ + return NULL; + } + } + + assert(!"Should not get here."); + return NULL; +} + + ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, unsigned w, unsigned count) : val(val) @@ -402,6 +432,11 @@ ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) #undef S #undef I +ir_variable * +ir_swizzle::variable_referenced() +{ + return this->val->variable_referenced(); +} ir_variable::ir_variable(const struct glsl_type *type, const char *name) : max_array_access(0), read_only(false), centroid(false), invariant(false), diff --git a/ir.h b/ir.h index df9a8c4174d..a533eee960d 100644 --- a/ir.h +++ b/ir.h @@ -85,6 +85,14 @@ public: return false; } + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() + { + return NULL; + } + protected: ir_rvalue() { @@ -744,6 +752,11 @@ public: return val->is_lvalue() && !mask.has_duplicates; } + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced(); + ir_rvalue *val; ir_swizzle_mask mask; }; @@ -769,6 +782,11 @@ public: bool is_lvalue(); + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced(); + enum { ir_reference_variable, ir_reference_array, -- cgit v1.2.3 From 5d82e239f98060c6de37f31f3900d84ee43aa4e5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 17:36:00 -0700 Subject: Use ir_rvalue::variable_referenced instead of open-coding it --- ir_copy_propagation.cpp | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index 6c346521126..aac12b3da38 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -234,32 +234,14 @@ propagate_copies(ir_instruction *ir, exec_list *acp) static void kill_invalidated_copies(ir_assignment *ir, exec_list *acp) { - ir_instruction *current = ir->lhs; + ir_variable *var = ir->lhs->variable_referenced(); + assert(var != NULL); - /* Walk down the dereference chain to find the variable at the end - * of it that we're actually modifying. - */ - while (current != NULL) { - ir_swizzle *swiz; - ir_dereference *deref; - - if ((swiz = current->as_swizzle())) { - current = swiz->val; - } else if ((deref = current->as_dereference())) { - current = deref->var; - } else { - ir_variable *var = current->as_variable(); - assert(var); - - foreach_iter(exec_list_iterator, iter, *acp) { - acp_entry *entry = (acp_entry *)iter.get(); - - if (entry->lhs == var || entry->rhs == var) { - entry->remove(); - } - } - current = NULL; - break; + foreach_iter(exec_list_iterator, iter, *acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (entry->lhs == var || entry->rhs == var) { + entry->remove(); } } } -- cgit v1.2.3 From 420d05a15b90658680b87b4d83b092768590319a Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 17 May 2010 10:15:23 -0700 Subject: Add test and fix bug leading to infinite recursion. The test case here is simply "#define foo foo" and "#define bar foo" and then attempting to expand "bar". Previously, our termination condition for the recursion was overly simple---just looking for the single identifier that began the expansion. We now fix this to maintain a stack of identifiers and terminate when any one of them occurs in the replacement list. --- glcpp-parse.y | 87 ++++++++++++++++++++++++------ tests/024-define-chain-to-self-recursion.c | 3 ++ 2 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 tests/024-define-chain-to-self-recursion.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 71ea3e53439..16d2a28a007 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -76,6 +76,12 @@ _string_list_append_item (string_list_t *list, const char *str); void _string_list_append_list (string_list_t *list, string_list_t *tail); +void +_string_list_push (string_list_t *list, const char *str); + +void +_string_list_pop (string_list_t *list); + int _string_list_contains (string_list_t *list, const char *member, int *index); @@ -319,6 +325,45 @@ _string_list_append_item (string_list_t *list, const char *str) list->tail = node; } +void +_string_list_push (string_list_t *list, const char *str) +{ + string_node_t *node; + + node = xtalloc (list, string_node_t); + node->str = xtalloc_strdup (node, str); + + node->next = list->head; + + if (list->tail == NULL) { + list->tail = node; + } + + list->head = node; +} + +void +_string_list_pop (string_list_t *list) +{ + string_node_t *node; + + node = list->head; + + if (node == NULL) { + fprintf (stderr, "Internal error: _string_list_pop called on an empty list.\n"); + exit (1); + } + + list->head = node->next; + + if (list->tail == node) { + assert (node->next == NULL); + list->tail = NULL; + } + + talloc_free (node); +} + int _string_list_contains (string_list_t *list, const char *member, int *index) { @@ -330,7 +375,8 @@ _string_list_contains (string_list_t *list, const char *member, int *index) for (i = 0, node = list->head; node; i++, node = node->next) { if (strcmp (node->str, member) == 0) { - *index = i; + if (index) + *index = i; return 1; } } @@ -525,14 +571,14 @@ _define_function_macro (glcpp_parser_t *parser, static string_list_t * _expand_macro_recursive (glcpp_parser_t *parser, const char *token, - const char *orig, + string_list_t *active, string_list_t *parameters, argument_list_t *arguments); static string_list_t * _expand_string_list_recursive (glcpp_parser_t *parser, string_list_t *list, - const char *orig, + string_list_t *active, string_list_t *parameters, argument_list_t *arguments) { @@ -547,7 +593,10 @@ _expand_string_list_recursive (glcpp_parser_t *parser, for (node = list->head ; node ; node = node->next) { token = node->str; - if (strcmp (token, orig) == 0) { + /* Don't expand this macro if it's on the active + * stack, (meaning we're already in the process of + * expanding it). */ + if (_string_list_contains (active, token, NULL)) { _string_list_append_item (result, token); continue; } @@ -557,11 +606,11 @@ _expand_string_list_recursive (glcpp_parser_t *parser, argument = _argument_list_member_at (arguments, index); child = _expand_string_list_recursive (parser, argument, - orig, NULL, NULL); + active, NULL, NULL); _string_list_append_list (result, child); } else { child = _expand_macro_recursive (parser, token, - orig, parameters, + active, parameters, arguments); _string_list_append_list (result, child); } @@ -574,12 +623,18 @@ _expand_string_list_recursive (glcpp_parser_t *parser, static string_list_t * _expand_macro_recursive (glcpp_parser_t *parser, const char *token, - const char *orig, + string_list_t *active, string_list_t *parameters, argument_list_t *arguments) { macro_t *macro; string_list_t *replacements; + string_list_t *result; + + if (active == NULL) + active = _string_list_create (NULL); + + _string_list_push (active, token); macro = hash_table_find (parser->defines, token); if (macro == NULL) { @@ -592,8 +647,14 @@ _expand_macro_recursive (glcpp_parser_t *parser, replacements = macro->replacements; - return _expand_string_list_recursive (parser, replacements, - orig, parameters, arguments); + result = _expand_string_list_recursive (parser, replacements, + active, parameters, arguments); + + _string_list_pop (active); + if (_string_list_length (active) == 0) + talloc_free (active); + + return result; } string_list_t * @@ -604,7 +665,7 @@ _expand_object_macro (glcpp_parser_t *parser, const char *identifier) macro = hash_table_find (parser->defines, identifier); assert (! macro->is_function); - return _expand_macro_recursive (parser, identifier, identifier, + return _expand_macro_recursive (parser, identifier, NULL, NULL, NULL); } @@ -613,12 +674,8 @@ _expand_function_macro (glcpp_parser_t *parser, const char *identifier, argument_list_t *arguments) { - string_list_t *result; - macro_t *macro; - result = _string_list_create (parser); - macro = hash_table_find (parser->defines, identifier); assert (macro->is_function); @@ -633,6 +690,6 @@ _expand_function_macro (glcpp_parser_t *parser, return NULL; } - return _expand_macro_recursive (parser, identifier, identifier, + return _expand_macro_recursive (parser, identifier, NULL, macro->parameters, arguments); } diff --git a/tests/024-define-chain-to-self-recursion.c b/tests/024-define-chain-to-self-recursion.c new file mode 100644 index 00000000000..e788adce30c --- /dev/null +++ b/tests/024-define-chain-to-self-recursion.c @@ -0,0 +1,3 @@ +#define foo foo +#define bar foo +bar -- cgit v1.2.3 From acf87bc03411c4d9b818a346bc9dad858b0a2407 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 17 May 2010 10:34:29 -0700 Subject: Fix bug (and add test) for a function-like-macro appearing as a non-macro. That is, when a function-like macro appears in the content without parentheses it should be accepted and passed on through, (previously the parser was regarding this as a syntax error). --- glcpp-parse.y | 4 ++++ tests/025-func-macro-as-non-macro.c | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 tests/025-func-macro-as-non-macro.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 16d2a28a007..6f158d91398 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -133,6 +133,10 @@ content: printf ("%s", $1); talloc_free ($1); } +| FUNC_MACRO { + printf ("%s", $1); + talloc_free ($1); + } | macro { _print_string_list ($1); } diff --git a/tests/025-func-macro-as-non-macro.c b/tests/025-func-macro-as-non-macro.c new file mode 100644 index 00000000000..3dbe026d9dd --- /dev/null +++ b/tests/025-func-macro-as-non-macro.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo -- cgit v1.2.3 From 86790dd43f6b8253d99f5473c593031adc847230 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 10 May 2010 17:44:57 -0700 Subject: Replace find_dead_code with visit_exec_list find_dead_code appears to be an open-coded version of visit_exec_list that was implemented first. --- ir_dead_code.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp index a73e9ed9bbb..0cc8a2650f0 100644 --- a/ir_dead_code.cpp +++ b/ir_dead_code.cpp @@ -100,15 +100,6 @@ ir_dead_code_visitor::get_variable_entry(ir_variable *var) return entry; } -void -find_dead_code(exec_list *instructions, ir_dead_code_visitor *v) -{ - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - - ir->accept(v); - } -} void ir_dead_code_visitor::visit(ir_variable *ir) @@ -123,7 +114,7 @@ ir_dead_code_visitor::visit(ir_variable *ir) void ir_dead_code_visitor::visit(ir_loop *ir) { - find_dead_code(&ir->body_instructions, this); + visit_exec_list(&ir->body_instructions, this); if (ir->from) ir->from->accept(this); if (ir->to) @@ -142,7 +133,7 @@ ir_dead_code_visitor::visit(ir_loop_jump *ir) void ir_dead_code_visitor::visit(ir_function_signature *ir) { - find_dead_code(&ir->body, this); + visit_exec_list(&ir->body, this); } void @@ -263,8 +254,8 @@ ir_dead_code_visitor::visit(ir_if *ir) { ir->condition->accept(this); - find_dead_code(&ir->then_instructions, this); - find_dead_code(&ir->else_instructions, this); + visit_exec_list(&ir->then_instructions, this); + visit_exec_list(&ir->else_instructions, this); } /** @@ -280,7 +271,7 @@ do_dead_code(exec_list *instructions) ir_dead_code_visitor v; bool progress = false; - find_dead_code(instructions, &v); + visit_exec_list(instructions, &v); foreach_iter(exec_list_iterator, iter, v.variable_list) { variable_entry *entry = (variable_entry *)iter.get(); -- cgit v1.2.3 From 8895bae55ba8d9f62dd59cbd924ac37c8a7dcdb1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 12:39:23 -0700 Subject: Add ir_hierarchical_visitor base class and associated infrastructure This type of visitor should eventually replace all or almost all current uses of ir_visitor. --- Makefile.am | 5 +- ir.h | 28 +++++ ir_hierarchical_visitor.cpp | 197 ++++++++++++++++++++++++++++++++ ir_hierarchical_visitor.h | 121 ++++++++++++++++++++ ir_hv_accept.cpp | 265 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 615 insertions(+), 1 deletion(-) create mode 100644 ir_hierarchical_visitor.cpp create mode 100644 ir_hierarchical_visitor.h create mode 100644 ir_hv_accept.cpp diff --git a/Makefile.am b/Makefile.am index 105fcc5d28f..aa050217b24 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,7 +46,10 @@ glsl_SOURCES = \ ir_optimization.h \ ir_reader.cpp s_expression.cpp \ ir_visit_tree.cpp \ - ir_visit_tree.h + ir_visit_tree.h \ + ir_hv_accept.cpp \ + ir_hierarchical_visitor.h \ + ir_hierarchical_visitor.cpp BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/ir.h b/ir.h index a533eee960d..93b4c2b66ab 100644 --- a/ir.h +++ b/ir.h @@ -28,6 +28,7 @@ #include "list.h" #include "ir_visitor.h" +#include "ir_hierarchical_visitor.h" struct ir_program { void *bong_hits; @@ -42,6 +43,7 @@ public: class ir_constant *constant_expression_value(); virtual void accept(ir_visitor *) = 0; + virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0; /** * \name IR instruction downcast functions @@ -130,6 +132,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + /** * Duplicate an IR variable * @@ -210,6 +214,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + /** * Get the name of the function for which this is a signature */ @@ -277,6 +283,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + void add_signature(ir_function_signature *sig) { sig->function = this; @@ -343,6 +351,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + ir_rvalue *condition; /** List of ir_instruction for the body of the then branch */ exec_list then_instructions; @@ -366,6 +376,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + virtual ir_loop *as_loop() { return this; @@ -403,6 +415,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + virtual ir_assignment * as_assignment() { return this; @@ -531,6 +545,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + ir_expression *clone(); ir_expression_operation operation; @@ -561,6 +577,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + /** * Get a generic ir_call object when an error occurs */ @@ -650,6 +668,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + private: ir_rvalue *value; }; @@ -681,6 +701,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + bool is_break() const { return mode == jump_break; @@ -747,6 +769,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + bool is_lvalue() { return val->is_lvalue() && !mask.has_duplicates; @@ -780,6 +804,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + bool is_lvalue(); /** @@ -825,6 +851,8 @@ public: v->visit(this); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + ir_constant *clone() { return new ir_constant(this->type, &this->value); diff --git a/ir_hierarchical_visitor.cpp b/ir_hierarchical_visitor.cpp new file mode 100644 index 00000000000..4fec0d7c752 --- /dev/null +++ b/ir_hierarchical_visitor.cpp @@ -0,0 +1,197 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#define NULL 0 +#include "ir.h" +#include "ir_hierarchical_visitor.h" + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_variable *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_constant *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_loop *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_loop *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_function_signature *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_function_signature *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_function *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_function *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_expression *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_expression *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_swizzle *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_swizzle *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_dereference *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_dereference *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_assignment *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_assignment *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_call *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_call *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_return *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_return *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_if *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_if *ir) +{ + (void) ir; + return visit_continue; +} + +void +ir_hierarchical_visitor::run(exec_list *instructions) +{ + foreach_list(n, instructions) { + ir_instruction *ir = (ir_instruction *) n; + + if (ir->accept(this) != visit_continue) + break; + } +} diff --git a/ir_hierarchical_visitor.h b/ir_hierarchical_visitor.h new file mode 100644 index 00000000000..daf220906ad --- /dev/null +++ b/ir_hierarchical_visitor.h @@ -0,0 +1,121 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_HIERARCHICAL_VISITOR_H +#define IR_HIERARCHICAL_VISITOR_H + +/** + * Enumeration values returned by visit methods to guide processing + */ +enum ir_visitor_status { + visit_continue, /**< Continue visiting as normal. */ + visit_continue_with_parent, /**< Don't visit siblings, continue w/parent. */ + visit_stop /**< Stop visiting immediately. */ +}; + + +/** + * Base class of hierarchical visitors of IR instruction trees + * + * Hierarchical visitors differ from traditional visitors in a couple of + * important ways. Rather than having a single \c visit method for each + * subclass in the composite, there are three kinds of visit methods. + * Leaf-node classes have a traditional \c visit method. Internal-node + * classes have a \c visit_enter method, which is invoked just before + * processing child nodes, and a \c visit_leave method which is invoked just + * after processing child nodes. + * + * In addition, each visit method and the \c accept methods in the composite + * have a return value which guides the navigation. Any of the visit methods + * can choose to continue visiting the tree as normal (by returning \c + * visit_continue), terminate visiting any further nodes immediately (by + * returning \c visit_stop), or stop visiting sibling nodes (by returning \c + * visit_continue_with_parent). + * + * These two changes combine to allow nagivation of children to be implemented + * in the composite's \c accept method. The \c accept method for a leaf-node + * class will simply call the \c visit method, as usual, and pass its return + * value on. The \c accept method for internal-node classes will call the \c + * visit_enter method, call the \c accpet method of each child node, and, + * finally, call the \c visit_leave method. If any of these return a value + * other that \c visit_continue, the correct action must be taken. + * + * The final benefit is that the hierarchical visitor base class need not be + * abstract. Default implementations of every \c visit, \c visit_enter, and + * \c visit_leave method can be provided. By default each of these methods + * simply returns \c visit_continue. This allows a significant reduction in + * derived class code. + * + * For more information about hierarchical visitors, see: + * + * http://c2.com/cgi/wiki?HierarchicalVisitorPattern + * http://c2.com/cgi/wiki?HierarchicalVisitorDiscussion + */ + +class ir_hierarchical_visitor { +public: + /** + * \name Visit methods for leaf-node classes + */ + /*@{*/ + virtual ir_visitor_status visit(class ir_variable *); + virtual ir_visitor_status visit(class ir_constant *); + virtual ir_visitor_status visit(class ir_loop_jump *); + /*@}*/ + + /** + * \name Visit methods for internal-node classes + */ + /*@{*/ + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_leave(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_leave(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_leave(class ir_function *); + virtual ir_visitor_status visit_enter(class ir_expression *); + virtual ir_visitor_status visit_leave(class ir_expression *); + virtual ir_visitor_status visit_enter(class ir_swizzle *); + virtual ir_visitor_status visit_leave(class ir_swizzle *); + virtual ir_visitor_status visit_enter(class ir_dereference *); + virtual ir_visitor_status visit_leave(class ir_dereference *); + virtual ir_visitor_status visit_enter(class ir_assignment *); + virtual ir_visitor_status visit_leave(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_leave(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_return *); + virtual ir_visitor_status visit_leave(class ir_return *); + virtual ir_visitor_status visit_enter(class ir_if *); + virtual ir_visitor_status visit_leave(class ir_if *); + /*@}*/ + + + /** + * Utility function to process a linked list of instructions with a visitor + */ + void run(struct exec_list *instructions); +}; + +#endif /* IR_HIERARCHICAL_VISITOR_H */ diff --git a/ir_hv_accept.cpp b/ir_hv_accept.cpp new file mode 100644 index 00000000000..7249bdb49ae --- /dev/null +++ b/ir_hv_accept.cpp @@ -0,0 +1,265 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#define NULL 0 +#include "ir.h" + +/** + * \file ir_hv_accept.cpp + * Implementations of all hierarchical visitor accept methods for IR + * instructions. + */ + +/** + * Process a list of nodes using a hierarchical vistor + */ +static ir_visitor_status +visit_list_elements(ir_hierarchical_visitor *v, exec_list *l) +{ + foreach_list (n, l) { + ir_instruction *const ir = (ir_instruction *) n; + ir_visitor_status s = ir->accept(v); + + if (s != visit_continue) + return s; + } + + return visit_continue; +} + + +ir_visitor_status +ir_variable::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_loop::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->body_instructions); + if (s == visit_stop) + return s; + + if (s != visit_continue_with_parent) { + if (this->from) { + s = this->from->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + if (this->to) { + s = this->to->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + if (this->increment) { + s = this->increment->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + } + + return v->visit_leave(this); +} + + +ir_visitor_status +ir_loop_jump::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_function_signature::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->body); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_function::accept(ir_hierarchical_visitor *v) +{ + /* FINISHME: Do we want to walk into functions? */ + (void) v; + return visit_continue; +} + + +ir_visitor_status +ir_expression::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + for (unsigned i = 0; i < this->get_num_operands(); i++) { + switch (this->operands[i]->accept(v)) { + case visit_continue: + break; + + case visit_continue_with_parent: + // I wish for Java's labeled break-statement here. + goto done; + + case visit_stop: + return s; + } + } + +done: + return v->visit_leave(this); +} + + +ir_visitor_status +ir_swizzle::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->val->accept(v); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_dereference::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (this->mode == ir_reference_array) { + s = this->selector.array_index->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + + s = this->var->accept(v); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_assignment::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->lhs->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->rhs->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (this->condition) + s = this->condition->accept(v); + + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_constant::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_call::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->actual_parameters); + if (s == visit_stop) + return s; + + return v->visit_leave(this); +} + + +ir_visitor_status +ir_return::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + ir_rvalue *val = this->get_value(); + if (val) { + s = val->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + return v->visit_leave(this); +} + + +ir_visitor_status +ir_if::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->condition->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (s != visit_continue_with_parent) { + s = visit_list_elements(v, &this->then_instructions); + if (s == visit_stop) + return s; + } + + if (s != visit_continue_with_parent) { + s = visit_list_elements(v, &this->else_instructions); + if (s == visit_stop) + return s; + } + + return v->visit_leave(this); +} -- cgit v1.2.3 From b5a7cf93442c2def485dcfd05df46abcd78b5d21 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 12:41:22 -0700 Subject: Reimplement ir_dead_code_visitor using ir_hierarchical_vistor The output of all test cases was verified to be the same using diff. --- ir_dead_code.cpp | 193 ++++++++++++++++++------------------------------------- 1 file changed, 62 insertions(+), 131 deletions(-) diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp index 0cc8a2650f0..20b791e94ac 100644 --- a/ir_dead_code.cpp +++ b/ir_dead_code.cpp @@ -40,41 +40,33 @@ public: { this->var = var; assign = NULL; - referenced = false; + referenced_count = 0; + assigned_count = 0; declaration = false; } ir_variable *var; /* The key: the variable's pointer. */ ir_assignment *assign; /* An assignment to the variable, if any */ - bool referenced; /* If the variable has ever been referenced. */ + + /** Number of times the variable is referenced, including assignments. */ + unsigned referenced_count; + + /** Number of times the variable is assignmened. */ + unsigned assigned_count; + bool declaration; /* If the variable had a decl in the instruction stream */ }; -class ir_dead_code_visitor : public ir_visitor { +class ir_dead_code_visitor : public ir_hierarchical_visitor { public: + virtual ir_visitor_status visit(ir_variable *); - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - /*@}*/ + virtual ir_visitor_status visit_enter(ir_function *); + virtual ir_visitor_status visit_enter(ir_dereference *); + virtual ir_visitor_status visit_leave(ir_dereference *); + virtual ir_visitor_status visit_leave(ir_assignment *); + + ir_dead_code_visitor(void); variable_entry *get_variable_entry(ir_variable *var); @@ -83,8 +75,17 @@ public: /* List of variable_entry */ exec_list variable_list; + + /* Depth of derefernce stack. */ + int in_dereference; }; +ir_dead_code_visitor::ir_dead_code_visitor(void) +{ + this->in_dereference = 0; +} + + variable_entry * ir_dead_code_visitor::get_variable_entry(ir_variable *var) { @@ -101,85 +102,49 @@ ir_dead_code_visitor::get_variable_entry(ir_variable *var) } -void +ir_visitor_status ir_dead_code_visitor::visit(ir_variable *ir) { variable_entry *entry = this->get_variable_entry(ir); if (entry) { - entry->declaration = true; + if (this->in_dereference) + entry->referenced_count++; + else + entry->declaration = true; } -} - -void -ir_dead_code_visitor::visit(ir_loop *ir) -{ - visit_exec_list(&ir->body_instructions, this); - if (ir->from) - ir->from->accept(this); - if (ir->to) - ir->to->accept(this); - if (ir->increment) - ir->increment->accept(this); + return visit_continue; } -void -ir_dead_code_visitor::visit(ir_loop_jump *ir) + +ir_visitor_status +ir_dead_code_visitor::visit_enter(ir_function *ir) { (void) ir; + return visit_continue_with_parent; } -void -ir_dead_code_visitor::visit(ir_function_signature *ir) -{ - visit_exec_list(&ir->body, this); -} - -void -ir_dead_code_visitor::visit(ir_function *ir) +ir_visitor_status +ir_dead_code_visitor::visit_enter(ir_dereference *ir) { (void) ir; + this->in_dereference++; + return visit_continue; } -void -ir_dead_code_visitor::visit(ir_expression *ir) -{ - unsigned int operand; - for (operand = 0; operand < ir->get_num_operands(); operand++) { - ir->operands[operand]->accept(this); - } -} - - -void -ir_dead_code_visitor::visit(ir_swizzle *ir) +ir_visitor_status +ir_dead_code_visitor::visit_leave(ir_dereference *ir) { - ir->val->accept(this); + (void) ir; + this->in_dereference--; + return visit_continue; } -void -ir_dead_code_visitor::visit(ir_dereference *ir) -{ - ir_variable *var; - - if (ir->mode == ir_dereference::ir_reference_array) { - ir->selector.array_index->accept(this); - } - - var = ir->var->as_variable(); - if (var) { - variable_entry *entry = this->get_variable_entry(var); - entry->referenced = true; - } else { - ir->var->accept(this); - } -} - -void -ir_dead_code_visitor::visit(ir_assignment *ir) +ir_visitor_status +ir_dead_code_visitor::visit_leave(ir_assignment *ir) { ir_instruction *lhs = ir->lhs; @@ -192,8 +157,6 @@ ir_dead_code_visitor::visit(ir_assignment *ir) ir_dereference *deref = lhs->as_dereference(); if (deref) { - if (deref->mode == ir_dereference::ir_reference_array) - deref->selector.array_index->accept(this); lhs = deref->var; } else { ir_swizzle *swiz = lhs->as_swizzle(); @@ -202,62 +165,19 @@ ir_dead_code_visitor::visit(ir_assignment *ir) } } - ir->rhs->accept(this); - if (ir->condition) - ir->condition->accept(this); variable_entry *entry; entry = this->get_variable_entry(lhs->as_variable()); if (entry) { + entry->assigned_count++; if (entry->assign == NULL) entry->assign = ir; } -} - -void -ir_dead_code_visitor::visit(ir_constant *ir) -{ - (void) ir; + return visit_continue; } -void -ir_dead_code_visitor::visit(ir_call *ir) -{ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - - /* FINISHME: handle out values. */ - param->accept(this); - } - - /* Ignore the callee. Function bodies will get handled when they're - * encountered at the top level instruction stream and spawn their - * own dead code visitor. - */ -} - - -void -ir_dead_code_visitor::visit(ir_return *ir) -{ - ir_rvalue *val = ir->get_value(); - - if (val) - val->accept(this); -} - - -void -ir_dead_code_visitor::visit(ir_if *ir) -{ - ir->condition->accept(this); - - visit_exec_list(&ir->then_instructions, this); - visit_exec_list(&ir->else_instructions, this); -} - /** * Do a dead code pass over instructions and everything that instructions * references. @@ -271,12 +191,23 @@ do_dead_code(exec_list *instructions) ir_dead_code_visitor v; bool progress = false; - visit_exec_list(instructions, &v); + v.run(instructions); foreach_iter(exec_list_iterator, iter, v.variable_list) { variable_entry *entry = (variable_entry *)iter.get(); - if (entry->referenced || !entry->declaration) + /* Since each assignment is a reference, the refereneced count must be + * greater than or equal to the assignment count. If they are equal, + * then all of the references are assignments, and the variable is + * dead. + * + * Note that if the variable is neither assigned nor referenced, both + * counts will be zero and will be caught by the equality test. + */ + assert(entry->referenced_count >= entry->assigned_count); + + if ((entry->referenced_count > entry->assigned_count) + || !entry->declaration) continue; if (entry->assign) { -- cgit v1.2.3 From 671e4f6321ce173b97fdbb459778df0bc9625b9b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 12:53:33 -0700 Subject: Reimplement ir_function_can_inline_visitor using ir_hierarchical_vistor The output of all test cases was verified to be the same using diff. --- ir_function_can_inline.cpp | 163 +++++---------------------------------------- 1 file changed, 16 insertions(+), 147 deletions(-) diff --git a/ir_function_can_inline.cpp b/ir_function_can_inline.cpp index 6c96a206a68..3be351055dd 100644 --- a/ir_function_can_inline.cpp +++ b/ir_function_can_inline.cpp @@ -35,12 +35,8 @@ #define NULL 0 #include "ir.h" -#include "ir_visitor.h" -#include "ir_function_inlining.h" -#include "ir_expression_flattening.h" -#include "glsl_types.h" -class ir_function_can_inline_visitor : public ir_visitor { +class ir_function_can_inline_visitor : public ir_hierarchical_visitor { public: ir_function_can_inline_visitor() { @@ -48,164 +44,40 @@ public: this->num_returns = 0; } - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_label *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - /*@}*/ + virtual ir_visitor_status visit_enter(ir_loop *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_if *); bool can_inline; int num_returns; }; -void -ir_function_can_inline_visitor::visit(ir_variable *ir) -{ - (void)ir; -} - -void -ir_function_can_inline_visitor::visit(ir_label *ir) -{ - (void)ir; -} - -void -ir_function_can_inline_visitor::visit(ir_loop *ir) +ir_visitor_status +ir_function_can_inline_visitor::visit_enter(ir_loop *ir) { /* FINISHME: Implement loop cloning in ir_function_inlining.cpp */ - this->can_inline = false; - - if (ir->from) - ir->from->accept(this); - if (ir->to) - ir->to->accept(this); - if (ir->increment) - ir->increment->accept(this); - - foreach_iter(exec_list_iterator, iter, ir->body_instructions) { - ir_instruction *inner_ir = (ir_instruction *)iter.get(); - inner_ir->accept(this); - } -} - -void -ir_function_can_inline_visitor::visit(ir_loop_jump *ir) -{ (void) ir; + this->can_inline = false; + return visit_stop; } -void -ir_function_can_inline_visitor::visit(ir_function_signature *ir) -{ - (void)ir; -} - - -void -ir_function_can_inline_visitor::visit(ir_function *ir) +ir_visitor_status +ir_function_can_inline_visitor::visit_enter(ir_return *ir) { (void) ir; -} - -void -ir_function_can_inline_visitor::visit(ir_expression *ir) -{ - unsigned int operand; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - ir->operands[operand]->accept(this); - } -} - - -void -ir_function_can_inline_visitor::visit(ir_swizzle *ir) -{ - ir->val->accept(this); -} - -void -ir_function_can_inline_visitor::visit(ir_dereference *ir) -{ - ir->var->accept(this); - if (ir->mode == ir_dereference::ir_reference_array) - ir->selector.array_index->accept(this); -} - -void -ir_function_can_inline_visitor::visit(ir_assignment *ir) -{ - ir->lhs->accept(this); - ir->rhs->accept(this); - if (ir->condition) - ir->condition->accept(this); -} - - -void -ir_function_can_inline_visitor::visit(ir_constant *ir) -{ - (void)ir; -} - - -void -ir_function_can_inline_visitor::visit(ir_call *ir) -{ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - - param->accept(this); - } -} - - -void -ir_function_can_inline_visitor::visit(ir_return *ir) -{ - ir->get_value()->accept(this); - this->num_returns++; + return visit_continue; } -void -ir_function_can_inline_visitor::visit(ir_if *ir) +ir_visitor_status +ir_function_can_inline_visitor::visit_enter(ir_if *ir) { /* FINISHME: Implement if cloning in ir_function_inlining.cpp. */ + (void) ir; this->can_inline = false; - - ir->condition->accept(this); - - foreach_iter(exec_list_iterator, iter, ir->then_instructions) { - ir_instruction *inner_ir = (ir_instruction *)iter.get(); - inner_ir->accept(this); - } - - foreach_iter(exec_list_iterator, iter, ir->else_instructions) { - ir_instruction *inner_ir = (ir_instruction *)iter.get(); - inner_ir->accept(this); - } + return visit_stop; } bool @@ -214,10 +86,7 @@ can_inline(ir_call *call) ir_function_can_inline_visitor v; const ir_function_signature *callee = call->get_callee(); - foreach_iter(exec_list_iterator, iter, callee->body) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir->accept(&v); - } + v.run((exec_list *) &callee->body); ir_instruction *last = (ir_instruction *)callee->body.get_tail(); if (last && !last->as_return()) -- cgit v1.2.3 From 458d5c61ef9740cf589807c85d95e9ea4d04c03b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 13:34:43 -0700 Subject: Make visit_list_elements safe against node removals --- ir_hv_accept.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/ir_hv_accept.cpp b/ir_hv_accept.cpp index 7249bdb49ae..43422e84aae 100644 --- a/ir_hv_accept.cpp +++ b/ir_hv_accept.cpp @@ -31,11 +31,20 @@ /** * Process a list of nodes using a hierarchical vistor + * + * \warning + * This function will operate correctly if a node being processed is removed + * from list. However, if nodes are added to the list after the node being + * processed, some of the added noded may not be processed. */ static ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l) { - foreach_list (n, l) { + exec_node *next; + + for (exec_node *n = l->head; n->next != NULL; n = next) { + next = n->next; + ir_instruction *const ir = (ir_instruction *) n; ir_visitor_status s = ir->accept(v); @@ -112,9 +121,12 @@ ir_function_signature::accept(ir_hierarchical_visitor *v) ir_visitor_status ir_function::accept(ir_hierarchical_visitor *v) { - /* FINISHME: Do we want to walk into functions? */ - (void) v; - return visit_continue; + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->signatures); + return (s == visit_stop) ? s : v->visit_leave(this); } -- cgit v1.2.3 From a0b4f3d631cefa6ee3f341461e4754ef6462f89b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 13:35:27 -0700 Subject: Reimplement ir_if_simplicifation_visitor using ir_hierarchical_vistor The output of all test cases was verified to be the same using diff. --- ir_if_simplification.cpp | 210 ++++++++--------------------------------------- 1 file changed, 32 insertions(+), 178 deletions(-) diff --git a/ir_if_simplification.cpp b/ir_if_simplification.cpp index 1e6fd8da8c5..042d0b677fc 100644 --- a/ir_if_simplification.cpp +++ b/ir_if_simplification.cpp @@ -30,202 +30,56 @@ #define NULL 0 #include "ir.h" -#include "ir_visitor.h" -#include "ir_function_inlining.h" -#include "glsl_types.h" -class ir_if_simplification_visitor : public ir_visitor { +class ir_if_simplification_visitor : public ir_hierarchical_visitor { public: ir_if_simplification_visitor() { - /* empty */ + this->made_progress = false; } - virtual ~ir_if_simplification_visitor() - { - /* empty */ - } + ir_visitor_status visit_leave(ir_if *); - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - /*@}*/ + bool made_progress; }; bool do_if_simplification(exec_list *instructions) { - bool progress = false; + ir_if_simplification_visitor v; - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_if *conditional = ir->as_if(); + v.run(instructions); + return v.made_progress; +} - if (conditional) { - ir_constant *condition_constant; - condition_constant = - conditional->condition->constant_expression_value(); - if (condition_constant) { - /* Move the contents of the one branch of the conditional - * that matters out. - */ - if (condition_constant->value.b[0]) { - foreach_iter(exec_list_iterator, then_iter, - conditional->then_instructions) { - ir_instruction *then_ir = (ir_instruction *)then_iter.get(); - ir->insert_before(then_ir); - } - } else { - foreach_iter(exec_list_iterator, else_iter, - conditional->else_instructions) { - ir_instruction *else_ir = (ir_instruction *)else_iter.get(); - ir->insert_before(else_ir); - } - } - ir->remove(); - progress = true; - /* It would be nice to move the iterator back up to the point - * that we just spliced in contents. - */ - } else { - ir_if_simplification_visitor v; - ir->accept(&v); +ir_visitor_status +ir_if_simplification_visitor::visit_leave(ir_if *ir) +{ + /* FINISHME: Ideally there would be a way to note that the condition results + * FINISHME: in a constant before processing both of the other subtrees. + * FINISHME: This can probably be done with some flags, but it would take + * FINISHME: some work to get right. + */ + ir_constant *condition_constant = ir->condition->constant_expression_value(); + if (condition_constant) { + /* Move the contents of the one branch of the conditional + * that matters out. + */ + if (condition_constant->value.b[0]) { + foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { + ir_instruction *then_ir = (ir_instruction *)then_iter.get(); + ir->insert_before(then_ir); } } else { - ir_if_simplification_visitor v; - ir->accept(&v); + foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { + ir_instruction *else_ir = (ir_instruction *)else_iter.get(); + ir->insert_before(else_ir); + } } + ir->remove(); + this->made_progress = true; } - return progress; -} - -class variable_remap : public exec_node { -public: - variable_remap(const ir_variable *old_var, ir_variable *new_var) - : old_var(old_var), new_var(new_var) - { - /* empty */ - } - const ir_variable *old_var; - ir_variable *new_var; -}; - -void -ir_if_simplification_visitor::visit(ir_variable *ir) -{ - (void) ir; -} - - -void -ir_if_simplification_visitor::visit(ir_loop *ir) -{ - do_if_simplification(&ir->body_instructions); -} - -void -ir_if_simplification_visitor::visit(ir_loop_jump *ir) -{ - (void) ir; -} - - -void -ir_if_simplification_visitor::visit(ir_function_signature *ir) -{ - do_if_simplification(&ir->body); -} - - -void -ir_if_simplification_visitor::visit(ir_function *ir) -{ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_function_signature *const sig = (ir_function_signature *) iter.get(); - sig->accept(this); - } -} - -void -ir_if_simplification_visitor::visit(ir_expression *ir) -{ - unsigned int operand; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - ir->operands[operand]->accept(this); - } -} - - -void -ir_if_simplification_visitor::visit(ir_swizzle *ir) -{ - ir->val->accept(this); -} - - -void -ir_if_simplification_visitor::visit(ir_dereference *ir) -{ - if (ir->mode == ir_dereference::ir_reference_array) { - ir->selector.array_index->accept(this); - } - ir->var->accept(this); -} - -void -ir_if_simplification_visitor::visit(ir_assignment *ir) -{ - ir->rhs->accept(this); -} - - -void -ir_if_simplification_visitor::visit(ir_constant *ir) -{ - (void) ir; -} - - -void -ir_if_simplification_visitor::visit(ir_call *ir) -{ - (void) ir; -} - - -void -ir_if_simplification_visitor::visit(ir_return *ir) -{ - (void) ir; -} - - -void -ir_if_simplification_visitor::visit(ir_if *ir) -{ - ir->condition->accept(this); - - do_if_simplification(&ir->then_instructions); - do_if_simplification(&ir->else_instructions); + return visit_continue; } -- cgit v1.2.3 From 77dd4f3536905f1b3a5c33b3758dc7e230332b38 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 14:11:06 -0700 Subject: Reimplement has_call_callback using ir_hierarchical_vistor This has the added advantage that it will stop traversing the tree as soon as the first call is found. The output of all test cases was verified to be the same using diff. --- ir_basic_block.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/ir_basic_block.cpp b/ir_basic_block.cpp index 455398e499c..2cf37046059 100644 --- a/ir_basic_block.cpp +++ b/ir_basic_block.cpp @@ -30,17 +30,25 @@ #include #include "ir.h" #include "ir_visitor.h" -#include "ir_visit_tree.h" #include "ir_basic_block.h" #include "glsl_types.h" -static void -has_call_callback(ir_instruction *ir, void *data) -{ - bool *has_call = (bool *)data; +class ir_has_call_visitor : public ir_hierarchical_visitor { +public: + ir_has_call_visitor() + { + has_call = false; + } - *has_call = *has_call || ir->as_call(); -} + virtual ir_visitor_status visit_enter(ir_call *ir) + { + (void) ir; + has_call = true; + return visit_stop; + } + + bool has_call; +}; /** * Calls a user function for every basic block in the instruction stream. @@ -108,7 +116,7 @@ void call_for_basic_blocks(exec_list *instructions, call_for_basic_blocks(&ir_sig->body, callback, data); } } else if (ir->as_assignment()) { - bool has_call = false; + ir_has_call_visitor v; /* If there's a call in the expression tree being assigned, * then that ends the BB too. @@ -123,9 +131,8 @@ void call_for_basic_blocks(exec_list *instructions, * expression flattener may be useful before using the basic * block finder to get more maximal basic blocks out. */ - ir_visit_tree(ir, has_call_callback, &has_call); - - if (has_call) { + ir->accept(&v); + if (v.has_call) { callback(leader, ir, data); leader = NULL; } -- cgit v1.2.3 From 551c9c0deb6d6de6ce5ea08a4100a3b33e062ea2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 14:31:25 -0700 Subject: Reimplement kill_for_derefs using ir_hierarchical_vistor The output of all test cases was verified to be the same using diff. --- ir_dead_code_local.cpp | 52 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/ir_dead_code_local.cpp b/ir_dead_code_local.cpp index de6a4f5e5d9..f101ccb5ec3 100644 --- a/ir_dead_code_local.cpp +++ b/ir_dead_code_local.cpp @@ -35,10 +35,8 @@ #include #include "ir.h" -#include "ir_visitor.h" #include "ir_print_visitor.h" #include "ir_basic_block.h" -#include "ir_visit_tree.h" #include "ir_optimization.h" #include "glsl_types.h" @@ -59,31 +57,31 @@ public: ir_instruction *ir; }; -static void -ir_kill_for_derefs_callback(ir_instruction *ir, void *data) -{ - exec_list *assignments = (exec_list *)data; - ir_variable *var = ir->as_variable(); - - if (!var) - return; +class kill_for_derefs_visitor : public ir_hierarchical_visitor { +public: + kill_for_derefs_visitor(exec_list *assignments) + { + this->assignments = assignments; + } - foreach_iter(exec_list_iterator, iter, *assignments) { - assignment_entry *entry = (assignment_entry *)iter.get(); + virtual ir_visitor_status visit(ir_variable *var) + { + foreach_iter(exec_list_iterator, iter, *this->assignments) { + assignment_entry *entry = (assignment_entry *)iter.get(); - if (entry->lhs == var) { - if (debug) - printf("kill %s\n", entry->lhs->name); - entry->remove(); + if (entry->lhs == var) { + if (debug) + printf("kill %s\n", entry->lhs->name); + entry->remove(); + } } + + return visit_continue; } -} -static void -kill_for_derefs(ir_instruction *ir, exec_list *assignments) -{ - ir_visit_tree(ir, ir_kill_for_derefs_callback, assignments); -} +private: + exec_list *assignments; +}; /** * Adds an entry to the available copy list if it's a plain assignment @@ -95,11 +93,12 @@ process_assignment(ir_assignment *ir, exec_list *assignments) ir_variable *var = NULL; bool progress = false; ir_instruction *current; + kill_for_derefs_visitor v(assignments); /* Kill assignment entries for things used to produce this assignment. */ - kill_for_derefs(ir->rhs, assignments); + ir->rhs->accept(&v); if (ir->condition) { - kill_for_derefs(ir->condition, assignments); + ir->condition->accept(&v); } /* Walk down the dereference chain to find the variable at the end @@ -114,7 +113,7 @@ process_assignment(ir_assignment *ir, exec_list *assignments) current = swiz->val; } else if ((deref = current->as_dereference())) { if (deref->mode == ir_dereference::ir_reference_array) - kill_for_derefs(deref->selector.array_index, assignments); + deref->selector.array_index->accept(&v); current = deref->var; } else { var = current->as_variable(); @@ -199,7 +198,8 @@ dead_code_local_basic_block(ir_instruction *first, if (ir_assign) { progress = process_assignment(ir_assign, &assignments) || progress; } else { - kill_for_derefs(ir, &assignments); + kill_for_derefs_visitor kill(&assignments); + ir->accept(&kill); } if (ir == last) -- cgit v1.2.3 From c65cfef317484a8be24fddd5e65a362aebb5c382 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 14 May 2010 14:32:17 -0700 Subject: ir_visit_tree is no longer used, remove ir_visit_tree.{cpp,h} --- Makefile.am | 2 - ir_visit_tree.cpp | 208 ------------------------------------------------------ ir_visit_tree.h | 27 ------- 3 files changed, 237 deletions(-) delete mode 100644 ir_visit_tree.cpp delete mode 100644 ir_visit_tree.h diff --git a/Makefile.am b/Makefile.am index aa050217b24..42f0ae557ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,8 +45,6 @@ glsl_SOURCES = \ ir_if_simplification.cpp \ ir_optimization.h \ ir_reader.cpp s_expression.cpp \ - ir_visit_tree.cpp \ - ir_visit_tree.h \ ir_hv_accept.cpp \ ir_hierarchical_visitor.h \ ir_hierarchical_visitor.cpp diff --git a/ir_visit_tree.cpp b/ir_visit_tree.cpp deleted file mode 100644 index b94c1b02087..00000000000 --- a/ir_visit_tree.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_dead_code.cpp - * - * Eliminates dead assignments and variable declarations from the code. - */ - -#define NULL 0 -#include "ir.h" -#include "ir_visitor.h" -#include "ir_visit_tree.h" - -class ir_tree_visitor : public ir_visitor { -public: - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - /*@}*/ - - void (*callback)(ir_instruction *ir, void *data); - void *data; -}; - -void -ir_tree_visitor::visit(ir_variable *ir) -{ - this->callback(ir, this->data); -} - - -void -ir_tree_visitor::visit(ir_loop *ir) -{ - this->callback(ir, this->data); - - visit_exec_list(&ir->body_instructions, this); - if (ir->from) - ir->from->accept(this); - if (ir->to) - ir->to->accept(this); - if (ir->increment) - ir->increment->accept(this); -} - -void -ir_tree_visitor::visit(ir_loop_jump *ir) -{ - this->callback(ir, this->data); -} - - -void -ir_tree_visitor::visit(ir_function_signature *ir) -{ - this->callback(ir, this->data); - - visit_exec_list(&ir->body, this); -} - -void -ir_tree_visitor::visit(ir_function *ir) -{ - this->callback(ir, this->data); - - /* FINISHME: Do we want to walk into functions? */ -} - -void -ir_tree_visitor::visit(ir_expression *ir) -{ - unsigned int operand; - - this->callback(ir, this->data); - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - ir->operands[operand]->accept(this); - } -} - - -void -ir_tree_visitor::visit(ir_swizzle *ir) -{ - this->callback(ir, this->data); - - ir->val->accept(this); -} - - -void -ir_tree_visitor::visit(ir_dereference *ir) -{ - this->callback(ir, this->data); - - if (ir->mode == ir_dereference::ir_reference_array) { - ir->selector.array_index->accept(this); - } - ir->var->accept(this); -} - -void -ir_tree_visitor::visit(ir_assignment *ir) -{ - this->callback(ir, this->data); - - ir->lhs->accept(this); - ir->rhs->accept(this); - if (ir->condition) - ir->condition->accept(this); -} - - -void -ir_tree_visitor::visit(ir_constant *ir) -{ - this->callback(ir, this->data); -} - - -void -ir_tree_visitor::visit(ir_call *ir) -{ - this->callback(ir, this->data); - - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - - param->accept(this); - } -} - - -void -ir_tree_visitor::visit(ir_return *ir) -{ - ir_rvalue *val = ir->get_value(); - - this->callback(ir, this->data); - - if (val) - val->accept(this); -} - - -void -ir_tree_visitor::visit(ir_if *ir) -{ - this->callback(ir, this->data); - - ir->condition->accept(this); - - visit_exec_list(&ir->then_instructions, this); - visit_exec_list(&ir->else_instructions, this); -} - -void ir_visit_tree(ir_instruction *ir, - void (*callback)(ir_instruction *ir, - void *data), - void *data) -{ - ir_tree_visitor v; - v.callback = callback; - v.data = data; - - ir->accept(&v); -} - diff --git a/ir_visit_tree.h b/ir_visit_tree.h deleted file mode 100644 index 24672783ef7..00000000000 --- a/ir_visit_tree.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -void ir_visit_tree(ir_instruction *ir, - void (*callback)(ir_instruction *ir, - void *data), - void *data); -- cgit v1.2.3 From 796e1f0eadcfbbc6e4d79778b2378975204bb97c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 17 May 2010 12:45:16 -0700 Subject: Expect 1 shift/reduce conflict. The most recent fix to the parser introduced a shift/reduce conflict. We document this conflict here, and tell bison that it need not report it (since I verified that it's being resolved in the direction desired). For the record, I did write additional lexer code to eliminate this conflict, but it was quite fragile, (would not accept a newline between a function-like macro name and the left parenthesis, for example). --- glcpp-parse.y | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glcpp-parse.y b/glcpp-parse.y index 6f158d91398..959083578e7 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -116,6 +116,14 @@ _argument_list_member_at (argument_list_t *list, int index); %type argument macro parameter_list replacement_list %type argument_list +/* Hard to remove shift/reduce conflicts documented as follows: + * + * 1. '(' after FUNC_MACRO name which is correctly resolved to shift + * to form macro invocation rather than reducing directly to + * content. + */ +%expect 1 + %% input: -- cgit v1.2.3 From 1a29500e72ac338c1fb243742aff1c167e1059db Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 17 May 2010 13:19:04 -0700 Subject: Fix (and add test for) function-like macro invocation with newlines. The test has a newline before the left parenthesis, and newlines to separate the parentheses from the argument. The fix involves more state in the lexer to only return a NEWLINE token when termniating a directive. This is very similar to our previous fix with extra lexer state to only return the SPACE token when it would be significant for the parser. With this change, the exact number and positioning of newlines in the output is now different compared to "gcc -E" so we add a -B option to diff when testing to ignore that. --- glcpp-lex.l | 82 +++++++++++++++++++++++++--------- glcpp-parse.y | 1 - tests/026-define-func-extra-newlines.c | 6 +++ tests/glcpp-test | 2 +- 4 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 tests/026-define-func-extra-newlines.c diff --git a/glcpp-lex.l b/glcpp-lex.l index 97ff1175f1b..4cb73c5d715 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -27,13 +27,36 @@ #include "glcpp.h" #include "glcpp-parse.h" + +/* Yes, a macro with a return statement in it is evil. But surely no + * more evil than all the code generation happening with flex in the + * first place. */ +#define LEXIFY_IDENTIFIER do { \ + yylval.str = xtalloc_strdup (yyextra, yytext); \ + switch (glcpp_parser_macro_type (yyextra, yylval.str)) \ + { \ + case MACRO_TYPE_UNDEFINED: \ + return IDENTIFIER; \ + break; \ + case MACRO_TYPE_OBJECT: \ + return OBJ_MACRO; \ + break; \ + case MACRO_TYPE_FUNCTION: \ + return FUNC_MACRO; \ + break; \ + } \ + } while (0) + %} %option reentrant noyywrap %option extra-type="glcpp_parser_t *" %x ST_DEFINE +%x ST_DEFVAL_START %x ST_DEFVAL +%x ST_UNDEF +%x ST_UNDEF_END SPACE [[:space:]] NONSPACE [^[:space:]] @@ -46,9 +69,20 @@ TOKEN [^[:space:](),]+ %% {HASH}undef{HSPACE}* { + BEGIN ST_UNDEF; return UNDEF; } +{IDENTIFIER} { + BEGIN ST_UNDEF_END; + LEXIFY_IDENTIFIER; +} + +\n { + BEGIN INITIAL; + return NEWLINE; +} + /* We use the ST_DEFINE and ST_DEFVAL states so that we can * pass a space token, (yes, a token for whitespace!), since * the preprocessor specification requires distinguishing @@ -60,40 +94,48 @@ TOKEN [^[:space:](),]+ } {IDENTIFIER} { - BEGIN ST_DEFVAL; + BEGIN ST_DEFVAL_START; yylval.str = xtalloc_strdup (yyextra, yytext); return IDENTIFIER; } -\n { +\n { BEGIN INITIAL; return NEWLINE; } -{HSPACE}+ { - BEGIN INITIAL; +{HSPACE}+ { + BEGIN ST_DEFVAL; return SPACE; } -"(" { - BEGIN INITIAL; +"(" { + BEGIN ST_DEFVAL; return '('; } -{IDENTIFIER} { +{IDENTIFIER} { + LEXIFY_IDENTIFIER; +} + +[(),] { + return yytext[0]; +} + +{TOKEN} { yylval.str = xtalloc_strdup (yyextra, yytext); - switch (glcpp_parser_macro_type (yyextra, yylval.str)) - { - case MACRO_TYPE_UNDEFINED: - return IDENTIFIER; - break; - case MACRO_TYPE_OBJECT: - return OBJ_MACRO; - break; - case MACRO_TYPE_FUNCTION: - return FUNC_MACRO; - break; - } + return TOKEN; +} + +\n { + BEGIN INITIAL; + return NEWLINE; +} + +{HSPACE}+ + +{IDENTIFIER} { + LEXIFY_IDENTIFIER; } [(),] { @@ -106,7 +148,7 @@ TOKEN [^[:space:](),]+ } \n { - return NEWLINE; + printf ("\n"); } {HSPACE}+ diff --git a/glcpp-parse.y b/glcpp-parse.y index 959083578e7..b2eaa5ba696 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -149,7 +149,6 @@ content: _print_string_list ($1); } | directive_with_newline { printf ("\n"); } -| NEWLINE { printf ("\n"); } | '(' { printf ("("); } | ')' { printf (")"); } | ',' { printf (","); } diff --git a/tests/026-define-func-extra-newlines.c b/tests/026-define-func-extra-newlines.c new file mode 100644 index 00000000000..0d837405309 --- /dev/null +++ b/tests/026-define-func-extra-newlines.c @@ -0,0 +1,6 @@ +#define foo(a) bar + +foo +( +1 +) diff --git a/tests/glcpp-test b/tests/glcpp-test index bd204de1e2f..673a4f45e96 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -5,5 +5,5 @@ for test in *.c; do ../glcpp < $test > $test.out gcc -E $test -o $test.gcc grep -v '^#' < $test.gcc > $test.expected - diff -w -u $test.expected $test.out + diff -B -w -u $test.expected $test.out done -- cgit v1.2.3 From 461c294ac57e387aa2355cfd2aa93cefaba03baa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 18 May 2010 13:53:20 +0200 Subject: Use ir_rvalue::variable_referenced instead of open coding it --- ir_dead_code.cpp | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp index 20b791e94ac..aa8ebf8ad10 100644 --- a/ir_dead_code.cpp +++ b/ir_dead_code.cpp @@ -146,28 +146,8 @@ ir_dead_code_visitor::visit_leave(ir_dereference *ir) ir_visitor_status ir_dead_code_visitor::visit_leave(ir_assignment *ir) { - ir_instruction *lhs = ir->lhs; - - /* Walk through the LHS and mark references for variables used in - * array indices but not for the assignment dereference. - */ - while (lhs) { - if (lhs->as_variable()) - break; - - ir_dereference *deref = lhs->as_dereference(); - if (deref) { - lhs = deref->var; - } else { - ir_swizzle *swiz = lhs->as_swizzle(); - - lhs = swiz->val; - } - } - - variable_entry *entry; - entry = this->get_variable_entry(lhs->as_variable()); + entry = this->get_variable_entry(ir->lhs->variable_referenced()); if (entry) { entry->assigned_count++; if (entry->assign == NULL) -- cgit v1.2.3 From d476db38fe21f5e6061a7d93dbd5a9991b91bf59 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 17 May 2010 13:33:10 -0700 Subject: Add several tests where the defined value of a macro is (or looks like) a macro Many of these look quite similar to existing tests that are handled correctly, yet none of these work. For example, in test 30 we have a simple non-function macro "foo" that is defined as "bar(baz(success))" and obviously non-function macro expansion has been working for a long time. Similarly, if we had text of "bar(baz(success))" it would be expanded correctly as well. But when this otherwise functioning text appears as the body of a macro, things don't work at all. This is pointing out a fundamental problem with the current approach. The current code does a recursive expansion of a macro definition, but this doesn't involve the parsing machinery, so it can't actually handle things like an arbitrary nesting of parentheses. The fix will require the parser to stuff macro values back into the lexer to get at all of the existing machinery when expanding macros. --- tests/027-define-chain-obj-to-func.c | 3 +++ tests/028-define-chain-obj-to-non-func.c | 3 +++ tests/029-define-chain-obj-to-func-with-args.c | 3 +++ tests/030-define-chain-obj-to-func-compose.c | 4 ++++ tests/031-define-chain-func-to-func-compose.c | 4 ++++ 5 files changed, 17 insertions(+) create mode 100644 tests/027-define-chain-obj-to-func.c create mode 100644 tests/028-define-chain-obj-to-non-func.c create mode 100644 tests/029-define-chain-obj-to-func-with-args.c create mode 100644 tests/030-define-chain-obj-to-func-compose.c create mode 100644 tests/031-define-chain-func-to-func-compose.c diff --git a/tests/027-define-chain-obj-to-func.c b/tests/027-define-chain-obj-to-func.c new file mode 100644 index 00000000000..5ccb52caba5 --- /dev/null +++ b/tests/027-define-chain-obj-to-func.c @@ -0,0 +1,3 @@ +#define failure() success +#define foo failure() +foo diff --git a/tests/028-define-chain-obj-to-non-func.c b/tests/028-define-chain-obj-to-non-func.c new file mode 100644 index 00000000000..44962a71876 --- /dev/null +++ b/tests/028-define-chain-obj-to-non-func.c @@ -0,0 +1,3 @@ +#define success() failure +#define foo success +foo diff --git a/tests/029-define-chain-obj-to-func-with-args.c b/tests/029-define-chain-obj-to-func-with-args.c new file mode 100644 index 00000000000..261f7d28fc2 --- /dev/null +++ b/tests/029-define-chain-obj-to-func-with-args.c @@ -0,0 +1,3 @@ +#define bar(failure) failure +#define foo bar(success) +foo diff --git a/tests/030-define-chain-obj-to-func-compose.c b/tests/030-define-chain-obj-to-func-compose.c new file mode 100644 index 00000000000..e56fbefd62d --- /dev/null +++ b/tests/030-define-chain-obj-to-func-compose.c @@ -0,0 +1,4 @@ +#define baz(failure) failure +#define bar(failure) failure +#define foo bar(baz(success)) +foo diff --git a/tests/031-define-chain-func-to-func-compose.c b/tests/031-define-chain-func-to-func-compose.c new file mode 100644 index 00000000000..3f4c8744dff --- /dev/null +++ b/tests/031-define-chain-func-to-func-compose.c @@ -0,0 +1,4 @@ +#define baz(failure) failure +#define bar(failure) failure +#define foo() bar(baz(success)) +foo() -- cgit v1.2.3 From a807fb72c45888b5ff915aa08d8bd10069be4a2e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 18 May 2010 22:10:04 -0700 Subject: Rewrite macro handling to support function-like macro invocation in macro values The rewrite her discards the functions that did direct, recursive expansion of macro values. Instead, the parser now pushes the macro definition string over to a stack of buffers for the lexer. This way, macro expansion gets access to all parsing machinery. This isn't a small change, but the result is simpler than before (I think). It passes the entire test suite, including the four tests added with the previous commit that were failing before. --- glcpp-lex.l | 146 ++++++++++++++++------- glcpp-parse.y | 367 ++++++++++++++++++++++++---------------------------------- glcpp.h | 77 ++++++++++-- xtalloc.c | 14 +++ 4 files changed, 338 insertions(+), 266 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 4cb73c5d715..52be1b1ea43 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -27,34 +27,15 @@ #include "glcpp.h" #include "glcpp-parse.h" - -/* Yes, a macro with a return statement in it is evil. But surely no - * more evil than all the code generation happening with flex in the - * first place. */ -#define LEXIFY_IDENTIFIER do { \ - yylval.str = xtalloc_strdup (yyextra, yytext); \ - switch (glcpp_parser_macro_type (yyextra, yylval.str)) \ - { \ - case MACRO_TYPE_UNDEFINED: \ - return IDENTIFIER; \ - break; \ - case MACRO_TYPE_OBJECT: \ - return OBJ_MACRO; \ - break; \ - case MACRO_TYPE_FUNCTION: \ - return FUNC_MACRO; \ - break; \ - } \ - } while (0) - %} %option reentrant noyywrap %option extra-type="glcpp_parser_t *" %x ST_DEFINE -%x ST_DEFVAL_START -%x ST_DEFVAL +%x ST_DEFINE_OBJ_OR_FUNC +%x ST_DEFINE_PARAMETER +%x ST_DEFINE_VALUE %x ST_UNDEF %x ST_UNDEF_END @@ -75,12 +56,14 @@ TOKEN [^[:space:](),]+ {IDENTIFIER} { BEGIN ST_UNDEF_END; - LEXIFY_IDENTIFIER; + yylval.str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; } +{HSPACE}* + \n { BEGIN INITIAL; - return NEWLINE; } /* We use the ST_DEFINE and ST_DEFVAL states so that we can @@ -94,48 +77,73 @@ TOKEN [^[:space:](),]+ } {IDENTIFIER} { - BEGIN ST_DEFVAL_START; + BEGIN ST_DEFINE_OBJ_OR_FUNC; yylval.str = xtalloc_strdup (yyextra, yytext); return IDENTIFIER; } -\n { +\n { BEGIN INITIAL; - return NEWLINE; + yylval.str = xtalloc_strdup (yyextra, ""); + return REPLACEMENT; } -{HSPACE}+ { - BEGIN ST_DEFVAL; - return SPACE; +{HSPACE}+ { + BEGIN ST_DEFINE_VALUE; } -"(" { - BEGIN ST_DEFVAL; +"(" { + BEGIN ST_DEFINE_PARAMETER; return '('; } -{IDENTIFIER} { - LEXIFY_IDENTIFIER; +{IDENTIFIER} { + yylval.str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; } -[(),] { - return yytext[0]; +"," { + return ','; } -{TOKEN} { - yylval.str = xtalloc_strdup (yyextra, yytext); - return TOKEN; +")" { + BEGIN ST_DEFINE_VALUE; + return ')'; } -\n { +{HSPACE}+ + +.*\n { BEGIN INITIAL; - return NEWLINE; + yylval.str = xtalloc_strndup (yyextra, yytext, strlen (yytext) - 1); + return REPLACEMENT; } -{HSPACE}+ - {IDENTIFIER} { - LEXIFY_IDENTIFIER; + int parameter_index; + yylval.str = xtalloc_strdup (yyextra, yytext); + switch (glcpp_parser_classify_token (yyextra, yylval.str, + ¶meter_index)) + { + case TOKEN_CLASS_ARGUMENT: + talloc_free (yylval.str); + /* We don't return a value here since the + * current token will be replaced by new + * tokens. */ + glcpp_parser_push_expansion_argument (yyextra, + parameter_index); + break; + case TOKEN_CLASS_IDENTIFIER: + return IDENTIFIER; + break; + case TOKEN_CLASS_FUNC_MACRO: + return FUNC_MACRO; + break; + case TOKEN_CLASS_OBJ_MACRO: + return OBJ_MACRO; + break; + + } } [(),] { @@ -153,4 +161,54 @@ TOKEN [^[:space:](),]+ {HSPACE}+ +<> { + int done; + + done = glcpp_lex_stack_pop (yyextra->lex_stack); + + if (done) + yyterminate (); + + glcpp_parser_pop_expansion (yyextra); +} + %% + +void +glcpp_lex_stack_push (glcpp_lex_stack_t *stack, const char *string) +{ + struct yyguts_t *yyg = (struct yyguts_t*) stack->parser->scanner; + glcpp_lex_node_t *node; + + /* Save the current buffer on the top of the stack. */ + node = xtalloc (stack, glcpp_lex_node_t); + node->buffer = YY_CURRENT_BUFFER; + + node->next = stack->head; + stack->head = node; + + /* Then switch to a new scan buffer for string. */ + yy_scan_string (string, stack->parser->scanner); +} + +int +glcpp_lex_stack_pop (glcpp_lex_stack_t *stack) +{ + struct yyguts_t *yyg = (struct yyguts_t*) stack->parser->scanner; + glcpp_lex_node_t *node; + + node = stack->head; + + if (node == NULL) + return 1; + + stack->head = node->next; + + yy_delete_buffer (YY_CURRENT_BUFFER, stack->parser->scanner); + yy_switch_to_buffer ((YY_BUFFER_STATE) node->buffer, + stack->parser->scanner); + + talloc_free (node); + + return 0; +} diff --git a/glcpp-parse.y b/glcpp-parse.y index b2eaa5ba696..9f1075aa50a 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -25,41 +25,29 @@ #include #include #include -#include #include "glcpp.h" #define YYLEX_PARAM parser->scanner -typedef struct { - int is_function; - string_list_t *parameters; - string_list_t *replacements; -} macro_t; - -struct glcpp_parser { - yyscan_t scanner; - struct hash_table *defines; -}; - void yyerror (void *scanner, const char *error); void _define_object_macro (glcpp_parser_t *parser, const char *macro, - string_list_t *replacements); + const char *replacement); void _define_function_macro (glcpp_parser_t *parser, const char *macro, string_list_t *parameters, - string_list_t *replacements); + const char *replacement); -string_list_t * +void _expand_object_macro (glcpp_parser_t *parser, const char *identifier); -string_list_t * +void _expand_function_macro (glcpp_parser_t *parser, const char *identifier, argument_list_t *arguments); @@ -76,12 +64,6 @@ _string_list_append_item (string_list_t *list, const char *str); void _string_list_append_list (string_list_t *list, string_list_t *tail); -void -_string_list_push (string_list_t *list, const char *str); - -void -_string_list_pop (string_list_t *list); - int _string_list_contains (string_list_t *list, const char *member, int *index); @@ -111,9 +93,9 @@ _argument_list_member_at (argument_list_t *list, int index); %parse-param {glcpp_parser_t *parser} %lex-param {void *scanner} -%token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO SPACE TOKEN UNDEF -%type FUNC_MACRO IDENTIFIER identifier_perhaps_macro OBJ_MACRO replacement_word TOKEN word -%type argument macro parameter_list replacement_list +%token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO REPLACEMENT TOKEN UNDEF +%type FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN word +%type argument macro parameter_list %type argument_list /* Hard to remove shift/reduce conflicts documented as follows: @@ -145,21 +127,21 @@ content: printf ("%s", $1); talloc_free ($1); } -| macro { - _print_string_list ($1); +| directive { + printf ("\n"); } -| directive_with_newline { printf ("\n"); } | '(' { printf ("("); } | ')' { printf (")"); } | ',' { printf (","); } +| macro ; macro: FUNC_MACRO '(' argument_list ')' { - $$ = _expand_function_macro (parser, $1, $3); + _expand_function_macro (parser, $1, $3); } | OBJ_MACRO { - $$ = _expand_object_macro (parser, $1); + _expand_object_macro (parser, $1); talloc_free ($1); } ; @@ -184,7 +166,7 @@ argument: _string_list_append_item ($$, $1); } | macro { - $$ = $1; + $$ = _string_list_create (parser); } | argument word { _string_list_append_item ($1, $2); @@ -199,93 +181,42 @@ argument: } ; -directive_with_newline: - directive NEWLINE -; - directive: - DEFINE IDENTIFIER { - string_list_t *list = _string_list_create (parser); - _define_object_macro (parser, $2, list); + DEFINE IDENTIFIER REPLACEMENT { + _define_object_macro (parser, $2, $3); } -| DEFINE IDENTIFIER SPACE replacement_list { - _define_object_macro (parser, $2, $4); - } -| DEFINE IDENTIFIER '(' parameter_list ')' { - string_list_t *list = _string_list_create (parser); - _define_function_macro (parser, $2, $4, list); - } -| DEFINE IDENTIFIER '(' parameter_list ')' replacement_list { +| DEFINE IDENTIFIER '(' parameter_list ')' REPLACEMENT { _define_function_macro (parser, $2, $4, $6); } -| UNDEF FUNC_MACRO { - string_list_t *replacement = hash_table_find (parser->defines, $2); - if (replacement) { - /* XXX: Need hash table to support a real way - * to remove an element rather than prefixing - * a new node with data of NULL like this. */ - hash_table_insert (parser->defines, NULL, $2); - talloc_free (replacement); - } - talloc_free ($2); - } -| UNDEF OBJ_MACRO { - string_list_t *replacement = hash_table_find (parser->defines, $2); - if (replacement) { +| UNDEF IDENTIFIER { + string_list_t *macro = hash_table_find (parser->defines, $2); + if (macro) { /* XXX: Need hash table to support a real way * to remove an element rather than prefixing * a new node with data of NULL like this. */ hash_table_insert (parser->defines, NULL, $2); - talloc_free (replacement); + talloc_free (macro); } talloc_free ($2); } ; -replacement_list: - replacement_word { - $$ = _string_list_create (parser); - _string_list_append_item ($$, $1); - talloc_free ($1); - } -| replacement_list replacement_word { - _string_list_append_item ($1, $2); - talloc_free ($2); - $$ = $1; - } -; - -replacement_word: - word { $$ = $1; } -| FUNC_MACRO { $$ = $1; } -| OBJ_MACRO { $$ = $1; } -| '(' { $$ = xtalloc_strdup (parser, "("); } -| ')' { $$ = xtalloc_strdup (parser, ")"); } -| ',' { $$ = xtalloc_strdup (parser, ","); } -; - parameter_list: /* empty */ { $$ = _string_list_create (parser); } -| identifier_perhaps_macro { +| IDENTIFIER { $$ = _string_list_create (parser); _string_list_append_item ($$, $1); talloc_free ($1); } -| parameter_list ',' identifier_perhaps_macro { +| parameter_list ',' IDENTIFIER { _string_list_append_item ($1, $3); talloc_free ($3); $$ = $1; } ; -identifier_perhaps_macro: - IDENTIFIER { $$ = $1; } -| FUNC_MACRO { $$ = $1; } -| OBJ_MACRO { $$ = $1; } -; - word: IDENTIFIER { $$ = $1; } | TOKEN { $$ = $1; } @@ -336,45 +267,6 @@ _string_list_append_item (string_list_t *list, const char *str) list->tail = node; } -void -_string_list_push (string_list_t *list, const char *str) -{ - string_node_t *node; - - node = xtalloc (list, string_node_t); - node->str = xtalloc_strdup (node, str); - - node->next = list->head; - - if (list->tail == NULL) { - list->tail = node; - } - - list->head = node; -} - -void -_string_list_pop (string_list_t *list) -{ - string_node_t *node; - - node = list->head; - - if (node == NULL) { - fprintf (stderr, "Internal error: _string_list_pop called on an empty list.\n"); - exit (1); - } - - list->head = node->next; - - if (list->tail == node) { - assert (node->next == NULL); - list->tail = NULL; - } - - talloc_free (node); -} - int _string_list_contains (string_list_t *list, const char *member, int *index) { @@ -512,6 +404,11 @@ glcpp_parser_create (void) yylex_init_extra (parser, &parser->scanner); parser->defines = hash_table_ctor (32, hash_table_string_hash, hash_table_string_compare); + parser->expansions = NULL; + + parser->lex_stack = xtalloc (parser, glcpp_lex_stack_t); + parser->lex_stack->parser = parser; + parser->lex_stack->head = NULL; return parser; } @@ -530,26 +427,46 @@ glcpp_parser_destroy (glcpp_parser_t *parser) talloc_free (parser); } -macro_type_t -glcpp_parser_macro_type (glcpp_parser_t *parser, const char *identifier) +token_class_t +glcpp_parser_classify_token (glcpp_parser_t *parser, + const char *identifier, + int *parameter_index) { macro_t *macro; + /* First we check if we are currently expanding a + * function-like macro, and if so, whether the parameter list + * contains a parameter matching this token name. */ + if (parser->expansions && + parser->expansions->macro && + parser->expansions->macro->parameters) + { + string_list_t *list; + + list = parser->expansions->macro->parameters; + + if (_string_list_contains (list, identifier, parameter_index)) + return TOKEN_CLASS_ARGUMENT; + } + + /* If not a function-like macro parameter, we next check if + * this token is a macro itself. */ + macro = hash_table_find (parser->defines, identifier); if (macro == NULL) - return MACRO_TYPE_UNDEFINED; + return TOKEN_CLASS_IDENTIFIER; if (macro->is_function) - return MACRO_TYPE_FUNCTION; + return TOKEN_CLASS_FUNC_MACRO; else - return MACRO_TYPE_OBJECT; + return TOKEN_CLASS_OBJ_MACRO; } void _define_object_macro (glcpp_parser_t *parser, const char *identifier, - string_list_t *replacements) + const char *replacement) { macro_t *macro; @@ -557,7 +474,8 @@ _define_object_macro (glcpp_parser_t *parser, macro->is_function = 0; macro->parameters = NULL; - macro->replacements = talloc_steal (macro, replacements); + macro->identifier = talloc_strdup (macro, identifier); + macro->replacement = talloc_steal (macro, replacement); hash_table_insert (parser->defines, macro, identifier); } @@ -566,7 +484,7 @@ void _define_function_macro (glcpp_parser_t *parser, const char *identifier, string_list_t *parameters, - string_list_t *replacements) + const char *replacement) { macro_t *macro; @@ -574,101 +492,126 @@ _define_function_macro (glcpp_parser_t *parser, macro->is_function = 1; macro->parameters = talloc_steal (macro, parameters); - macro->replacements = talloc_steal (macro, replacements); + macro->identifier = talloc_strdup (macro, identifier); + macro->replacement = talloc_steal (macro, replacement); hash_table_insert (parser->defines, macro, identifier); } -static string_list_t * -_expand_macro_recursive (glcpp_parser_t *parser, - const char *token, - string_list_t *active, - string_list_t *parameters, - argument_list_t *arguments); - -static string_list_t * -_expand_string_list_recursive (glcpp_parser_t *parser, - string_list_t *list, - string_list_t *active, - string_list_t *parameters, - argument_list_t *arguments) +static void +_glcpp_parser_push_expansion_internal (glcpp_parser_t *parser, + macro_t *macro, + argument_list_t *arguments, + const char * replacement) +{ + expansion_node_t *node; + + node = xtalloc (parser, expansion_node_t); + + node->macro = macro; + node->arguments = arguments; + + node->next = parser->expansions; + parser->expansions = node; + + glcpp_lex_stack_push (parser->lex_stack, replacement); +} + +void +glcpp_parser_push_expansion_macro (glcpp_parser_t *parser, + macro_t *macro, + argument_list_t *arguments) +{ + _glcpp_parser_push_expansion_internal (parser, macro, arguments, + macro->replacement); +} + +void +glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, + int argument_index) { - string_list_t *result; - string_list_t *child; - const char *token; + argument_list_t *arguments; + string_list_t *argument; string_node_t *node; - int index; + char *argument_str, *s; + int length; - result = _string_list_create (parser); + arguments = parser->expansions->arguments; - for (node = list->head ; node ; node = node->next) { - token = node->str; + argument = _argument_list_member_at (arguments, argument_index); - /* Don't expand this macro if it's on the active - * stack, (meaning we're already in the process of - * expanding it). */ - if (_string_list_contains (active, token, NULL)) { - _string_list_append_item (result, token); - continue; - } + length = 0; + for (node = argument->head; node; node = node->next) + length += strlen (node->str) + 1; + + argument_str = xtalloc_size (parser, length); - if (_string_list_contains (parameters, token, &index)) { - string_list_t *argument; - - argument = _argument_list_member_at (arguments, index); - child = _expand_string_list_recursive (parser, argument, - active, NULL, NULL); - _string_list_append_list (result, child); - } else { - child = _expand_macro_recursive (parser, token, - active, parameters, - arguments); - _string_list_append_list (result, child); + *argument_str = '\0'; + s = argument_str; + for (node = argument->head; node; node = node->next) { + strcpy (s, node->str); + s += strlen (node->str); + if (node->next) { + *s = ' '; + s++; + *s = '\0'; } } - return result; + _glcpp_parser_push_expansion_internal (parser, NULL, NULL, + argument_str); } - -static string_list_t * -_expand_macro_recursive (glcpp_parser_t *parser, - const char *token, - string_list_t *active, - string_list_t *parameters, - argument_list_t *arguments) +/* The lexer calls this when it exhausts a string. */ +void +glcpp_parser_pop_expansion (glcpp_parser_t *parser) { - macro_t *macro; - string_list_t *replacements; - string_list_t *result; + expansion_node_t *node; + + node = parser->expansions; - if (active == NULL) - active = _string_list_create (NULL); + if (node == NULL) { + fprintf (stderr, "Internal error: _expansion_list_pop called on an empty list.\n"); + exit (1); + } - _string_list_push (active, token); + parser->expansions = node->next; - macro = hash_table_find (parser->defines, token); - if (macro == NULL) { - string_list_t *result; + talloc_free (node); +} - result = _string_list_create (parser); - _string_list_append_item (result, token); - return result; - } +int +glcpp_parser_is_expanding (glcpp_parser_t *parser, const char *member) +{ + expansion_node_t *node; - replacements = macro->replacements; + for (node = parser->expansions; node; node = node->next) { + if (node->macro && + strcmp (node->macro->identifier, member) == 0) + { + return 1; + } + } - result = _expand_string_list_recursive (parser, replacements, - active, parameters, arguments); + return 0; +} - _string_list_pop (active); - if (_string_list_length (active) == 0) - talloc_free (active); +static void +_expand_macro (glcpp_parser_t *parser, + const char *token, + macro_t *macro, + argument_list_t *arguments) +{ + /* Don't recurse if we're already actively expanding this token. */ + if (glcpp_parser_is_expanding (parser, token)) { + printf ("%s", token); + return; + } - return result; + glcpp_parser_push_expansion_macro (parser, macro, arguments); } -string_list_t * +void _expand_object_macro (glcpp_parser_t *parser, const char *identifier) { macro_t *macro; @@ -676,11 +619,10 @@ _expand_object_macro (glcpp_parser_t *parser, const char *identifier) macro = hash_table_find (parser->defines, identifier); assert (! macro->is_function); - return _expand_macro_recursive (parser, identifier, NULL, - NULL, NULL); + _expand_macro (parser, identifier, macro, NULL); } -string_list_t * +void _expand_function_macro (glcpp_parser_t *parser, const char *identifier, argument_list_t *arguments) @@ -698,9 +640,8 @@ _expand_function_macro (glcpp_parser_t *parser, identifier, _argument_list_length (arguments), _string_list_length (macro->parameters)); - return NULL; + return; } - return _expand_macro_recursive (parser, identifier, NULL, - macro->parameters, arguments); + _expand_macro (parser, identifier, macro, arguments); } diff --git a/glcpp.h b/glcpp.h index 7966a2a3d21..81f7d14c5ba 100644 --- a/glcpp.h +++ b/glcpp.h @@ -24,11 +24,13 @@ #ifndef GLCPP_H #define GLCPP_H +#include + #include "hash_table.h" #define yyscan_t void* -/* Some data types used for parser value. */ +/* Some data types used for parser values. */ typedef struct string_node { const char *str; @@ -52,6 +54,56 @@ typedef struct argument_list { typedef struct glcpp_parser glcpp_parser_t; +/* Support for temporarily lexing/parsing tokens from a string. */ + +typedef struct glcpp_lex_node { + void *buffer; + struct glcpp_lex_node *next; +} glcpp_lex_node_t; + +typedef struct { + glcpp_parser_t *parser; + glcpp_lex_node_t *head; +} glcpp_lex_stack_t; + +void +glcpp_lex_stack_push (glcpp_lex_stack_t *stack, const char *string); + +int +glcpp_lex_stack_pop (glcpp_lex_stack_t *stack); + +typedef enum { + TOKEN_CLASS_ARGUMENT, + TOKEN_CLASS_IDENTIFIER, + TOKEN_CLASS_FUNC_MACRO, + TOKEN_CLASS_OBJ_MACRO +} token_class_t; + +token_class_t +glcpp_parser_classify_token (glcpp_parser_t *parser, + const char *identifier, + int *parameter_index); + +typedef struct { + int is_function; + string_list_t *parameters; + const char *identifier; + const char *replacement; +} macro_t; + +typedef struct expansion_node { + macro_t *macro; + argument_list_t *arguments; + struct expansion_node *next; +} expansion_node_t; + +struct glcpp_parser { + yyscan_t scanner; + struct hash_table *defines; + expansion_node_t *expansions; + glcpp_lex_stack_t *lex_stack; +}; + glcpp_parser_t * glcpp_parser_create (void); @@ -61,15 +113,17 @@ glcpp_parser_parse (glcpp_parser_t *parser); void glcpp_parser_destroy (glcpp_parser_t *parser); -typedef enum { - MACRO_TYPE_UNDEFINED, - MACRO_TYPE_OBJECT, - MACRO_TYPE_FUNCTION -} macro_type_t; +void +glcpp_parser_push_expansion_macro (glcpp_parser_t *parser, + macro_t *macro, + argument_list_t *arguments); -macro_type_t -glcpp_parser_macro_type (glcpp_parser_t *parser, - const char *identifier); +void +glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, + int argument_index); + +void +glcpp_parser_pop_expansion (glcpp_parser_t *parser); /* Generated by glcpp-lex.l to glcpp-lex.c */ @@ -91,10 +145,15 @@ yyparse (glcpp_parser_t *parser); #define xtalloc(ctx, type) (type *)xtalloc_named_const(ctx, sizeof(type), #type) +#define xtalloc_size(ctx, size) xtalloc_named_const(ctx, size, __location__) + void * xtalloc_named_const (const void *context, size_t size, const char *name); char * xtalloc_strdup (const void *t, const char *p); +char * +xtalloc_strndup (const void *t, const char *p, size_t n); + #endif diff --git a/xtalloc.c b/xtalloc.c index 849e12d3491..d9893ae8893 100644 --- a/xtalloc.c +++ b/xtalloc.c @@ -50,3 +50,17 @@ xtalloc_strdup (const void *t, const char *p) return ret; } + +char * +xtalloc_strndup (const void *t, const char *p, size_t n) +{ + char *ret; + + ret = talloc_strndup (t, p, n); + if (ret == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + return ret; +} -- cgit v1.2.3 From be0e2e9b2ada51be66afb6b44330acb44e0261f2 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 07:29:22 -0700 Subject: Fix bug (and add tests) for a function-like macro defined as itself. This case worked previously, but broke in the recent rewrite of function- like macro expansion. The recursion was still terminated correctly, but any parenthesized expression after the macro name was still being swallowed even though the identifier was not being expanded as a macro. The fix is to notice earlier that the identifier is an already-expanding macro. We let the lexer know this through the classify_token function so that an already-expanding macro is lexed as an identifier, not a FUNC_MACRO. --- glcpp-parse.y | 59 ++++++++++++++++-------------------- tests/032-define-func-self-recurse.c | 2 ++ tests/033-define-func-self-compose.c | 2 ++ 3 files changed, 30 insertions(+), 33 deletions(-) create mode 100644 tests/032-define-func-self-recurse.c create mode 100644 tests/033-define-func-self-compose.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 9f1075aa50a..8dc07483c18 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -427,6 +427,22 @@ glcpp_parser_destroy (glcpp_parser_t *parser) talloc_free (parser); } +static int +glcpp_parser_is_expanding (glcpp_parser_t *parser, const char *member) +{ + expansion_node_t *node; + + for (node = parser->expansions; node; node = node->next) { + if (node->macro && + strcmp (node->macro->identifier, member) == 0) + { + return 1; + } + } + + return 0; +} + token_class_t glcpp_parser_classify_token (glcpp_parser_t *parser, const char *identifier, @@ -457,6 +473,12 @@ glcpp_parser_classify_token (glcpp_parser_t *parser, if (macro == NULL) return TOKEN_CLASS_IDENTIFIER; + /* Don't consider this a macro if we are already actively + * expanding this macro. */ + if (glcpp_parser_is_expanding (parser, identifier)) + return TOKEN_CLASS_IDENTIFIER; + + /* Definitely a macro. Just need to check if it's function-like. */ if (macro->is_function) return TOKEN_CLASS_FUNC_MACRO; else @@ -580,37 +602,6 @@ glcpp_parser_pop_expansion (glcpp_parser_t *parser) talloc_free (node); } -int -glcpp_parser_is_expanding (glcpp_parser_t *parser, const char *member) -{ - expansion_node_t *node; - - for (node = parser->expansions; node; node = node->next) { - if (node->macro && - strcmp (node->macro->identifier, member) == 0) - { - return 1; - } - } - - return 0; -} - -static void -_expand_macro (glcpp_parser_t *parser, - const char *token, - macro_t *macro, - argument_list_t *arguments) -{ - /* Don't recurse if we're already actively expanding this token. */ - if (glcpp_parser_is_expanding (parser, token)) { - printf ("%s", token); - return; - } - - glcpp_parser_push_expansion_macro (parser, macro, arguments); -} - void _expand_object_macro (glcpp_parser_t *parser, const char *identifier) { @@ -618,8 +609,9 @@ _expand_object_macro (glcpp_parser_t *parser, const char *identifier) macro = hash_table_find (parser->defines, identifier); assert (! macro->is_function); + assert (! glcpp_parser_is_expanding (parser, identifier)); - _expand_macro (parser, identifier, macro, NULL); + glcpp_parser_push_expansion_macro (parser, macro, NULL); } void @@ -631,6 +623,7 @@ _expand_function_macro (glcpp_parser_t *parser, macro = hash_table_find (parser->defines, identifier); assert (macro->is_function); + assert (! glcpp_parser_is_expanding (parser, identifier)); if (_argument_list_length (arguments) != _string_list_length (macro->parameters)) @@ -643,5 +636,5 @@ _expand_function_macro (glcpp_parser_t *parser, return; } - _expand_macro (parser, identifier, macro, arguments); + glcpp_parser_push_expansion_macro (parser, macro, arguments); } diff --git a/tests/032-define-func-self-recurse.c b/tests/032-define-func-self-recurse.c new file mode 100644 index 00000000000..60d8526c0aa --- /dev/null +++ b/tests/032-define-func-self-recurse.c @@ -0,0 +1,2 @@ +#define foo(a) foo(2 * (a)) +foo(3) diff --git a/tests/033-define-func-self-compose.c b/tests/033-define-func-self-compose.c new file mode 100644 index 00000000000..8abaaf6be95 --- /dev/null +++ b/tests/033-define-func-self-compose.c @@ -0,0 +1,2 @@ +#define foo(a) foo(2 * (a)) +foo(foo(3)) -- cgit v1.2.3 From 69f390d6096c597dbe63f20fd02b2312da211de8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 07:42:42 -0700 Subject: Fix bug (and test) for an invocation using macro name as a non-macro argument This adds a second shift/reduce conflict to our grammar. It's basically the same conflict we had previously, (deciding to shift a '(' after a FUNC_MACRO) but this time in the "argument" context rather than the "content" context. It would be nice to not have these, but I think they are unavoidable (withotu a lot of pain at least) given the preprocessor specification. --- glcpp-parse.y | 10 +++++++++- tests/034-define-func-self-compose-non-func.c | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/034-define-func-self-compose-non-func.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 8dc07483c18..ea27184c47c 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -103,8 +103,12 @@ _argument_list_member_at (argument_list_t *list, int index); * 1. '(' after FUNC_MACRO name which is correctly resolved to shift * to form macro invocation rather than reducing directly to * content. + * + * 2. Similarly, '(' after FUNC_MACRO which is correctly resolved to + * shift to form macro invocation rather than reducing directly to + * argument. */ -%expect 1 +%expect 2 %% @@ -168,6 +172,10 @@ argument: | macro { $$ = _string_list_create (parser); } +| FUNC_MACRO { + $$ = _string_list_create (parser); + _string_list_append_item ($$, $1); + } | argument word { _string_list_append_item ($1, $2); talloc_free ($2); diff --git a/tests/034-define-func-self-compose-non-func.c b/tests/034-define-func-self-compose-non-func.c new file mode 100644 index 00000000000..209a5f7e07c --- /dev/null +++ b/tests/034-define-func-self-compose-non-func.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo(foo) -- cgit v1.2.3 From 59ca98990f814926d716a13b0201c94945133824 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 07:49:47 -0700 Subject: Fix bug as in previous fix, but with multi-token argument. The previous fix added FUNC_MACRO to a production one higher in teh grammar than it should have. So it prevented a FUNC_MACRO from appearing as part of a mutli-token argument rather than just alone as an argument. Fix this (and add a test). --- glcpp-parse.y | 22 ++++++++++------------ ...nc-self-compose-non-func-multi-token-argument.c | 2 ++ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 tests/035-define-func-self-compose-non-func-multi-token-argument.c diff --git a/glcpp-parse.y b/glcpp-parse.y index ea27184c47c..400f138d17e 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -94,7 +94,7 @@ _argument_list_member_at (argument_list_t *list, int index); %lex-param {void *scanner} %token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO REPLACEMENT TOKEN UNDEF -%type FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN word +%type argument_word FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN %type argument macro parameter_list %type argument_list @@ -165,18 +165,14 @@ argument_list: ; argument: - word { + argument_word { $$ = _string_list_create (parser); _string_list_append_item ($$, $1); } | macro { $$ = _string_list_create (parser); } -| FUNC_MACRO { - $$ = _string_list_create (parser); - _string_list_append_item ($$, $1); - } -| argument word { +| argument argument_word { _string_list_append_item ($1, $2); talloc_free ($2); $$ = $1; @@ -189,6 +185,13 @@ argument: } ; +argument_word: + IDENTIFIER { $$ = $1; } +| TOKEN { $$ = $1; } +| FUNC_MACRO { $$ = $1; } +; + + directive: DEFINE IDENTIFIER REPLACEMENT { _define_object_macro (parser, $2, $3); @@ -225,11 +228,6 @@ parameter_list: } ; -word: - IDENTIFIER { $$ = $1; } -| TOKEN { $$ = $1; } -; - %% string_list_t * diff --git a/tests/035-define-func-self-compose-non-func-multi-token-argument.c b/tests/035-define-func-self-compose-non-func-multi-token-argument.c new file mode 100644 index 00000000000..9955219470c --- /dev/null +++ b/tests/035-define-func-self-compose-non-func-multi-token-argument.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo(1 + foo) -- cgit v1.2.3 From 5d2114254592e03b6d554c5e2eea4ea442c3fa05 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 07:57:03 -0700 Subject: Like previous fix, but for object-like macros (and add a test). The support for an object-like amcro within a macro-invocation argument was also implemented at one level too high in the grammar. Fortunately, this is a very simple fix. --- glcpp-parse.y | 4 +--- tests/036-define-func-non-macro-multi-token-argument.c | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 tests/036-define-func-non-macro-multi-token-argument.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 400f138d17e..647532f209d 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -169,9 +169,6 @@ argument: $$ = _string_list_create (parser); _string_list_append_item ($$, $1); } -| macro { - $$ = _string_list_create (parser); - } | argument argument_word { _string_list_append_item ($1, $2); talloc_free ($2); @@ -189,6 +186,7 @@ argument_word: IDENTIFIER { $$ = $1; } | TOKEN { $$ = $1; } | FUNC_MACRO { $$ = $1; } +| macro { $$ = xtalloc_strdup (parser, ""); } ; diff --git a/tests/036-define-func-non-macro-multi-token-argument.c b/tests/036-define-func-non-macro-multi-token-argument.c new file mode 100644 index 00000000000..b21ff336738 --- /dev/null +++ b/tests/036-define-func-non-macro-multi-token-argument.c @@ -0,0 +1,3 @@ +#define bar success +#define foo(x) x +foo(more bar) -- cgit v1.2.3 From 8f38aff9b5dd42ef963532fe5fc618e8bafa218a Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 10:01:29 -0700 Subject: Add a wrapper function around the lexer. We rename the generated lexer from yylex to glcpp_lex. Then we implement our own yylex function in glcpp-parse.y that calls glcpp_lex. This doesn't change the behavior at all yet, but gives us a place where we can do implement alternate lexing in the future. (We want this because instead of re-lexing from strings for macro expansion, we want to lex from pre-parsed token lists. We need this so that when we terminate recursion due to an already active macro expansion, we can ensure that that symbol never gets expanded again later.) --- Makefile | 2 +- glcpp-parse.y | 13 +++++++++++-- glcpp.h | 6 +++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3fa863c49b9..88116128f85 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o xtalloc.o bison --debug --defines=$*.h --output=$*.c $^ %.c: %.l - flex --outfile=$@ $< + flex --prefix=glcpp_ --outfile=$@ $< glcpp-lex.c: glcpp-parse.h diff --git a/glcpp-parse.y b/glcpp-parse.y index 647532f209d..6ef1cae0eca 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -82,6 +82,9 @@ _argument_list_length (argument_list_t *list); string_list_t * _argument_list_member_at (argument_list_t *list, int index); +static int +yylex (yyscan_t scanner); + %} %union { @@ -405,7 +408,7 @@ glcpp_parser_create (void) parser = xtalloc (NULL, glcpp_parser_t); - yylex_init_extra (parser, &parser->scanner); + glcpp_lex_init_extra (parser, &parser->scanner); parser->defines = hash_table_ctor (32, hash_table_string_hash, hash_table_string_compare); parser->expansions = NULL; @@ -426,7 +429,7 @@ glcpp_parser_parse (glcpp_parser_t *parser) void glcpp_parser_destroy (glcpp_parser_t *parser) { - yylex_destroy (parser->scanner); + glcpp_lex_destroy (parser->scanner); hash_table_dtor (parser->defines); talloc_free (parser); } @@ -642,3 +645,9 @@ _expand_function_macro (glcpp_parser_t *parser, glcpp_parser_push_expansion_macro (parser, macro, arguments); } + +static int +yylex (yyscan_t scanner) +{ + return glcpp_lex (scanner); +} diff --git a/glcpp.h b/glcpp.h index 81f7d14c5ba..6aabf6f1823 100644 --- a/glcpp.h +++ b/glcpp.h @@ -128,13 +128,13 @@ glcpp_parser_pop_expansion (glcpp_parser_t *parser); /* Generated by glcpp-lex.l to glcpp-lex.c */ int -yylex_init_extra (glcpp_parser_t *parser, yyscan_t* scanner); +glcpp_lex_init_extra (glcpp_parser_t *parser, yyscan_t* scanner); int -yylex (yyscan_t scanner); +glcpp_lex (yyscan_t scanner); int -yylex_destroy (yyscan_t scanner); +glcpp_lex_destroy (yyscan_t scanner); /* Generated by glcpp-parse.y to glcpp-parse.c */ -- cgit v1.2.3 From 0293b2e2dd81fabd3ecb71e036a99621801e1c94 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 10:05:40 -0700 Subject: Rename yylex to glcpp_parser_lex and give it a glcpp_parser_t* argument. Much cleaner this way, (and now our custom lex function has access to all the parser state which it will need). --- glcpp-parse.y | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 6ef1cae0eca..04bac00e9f9 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -82,8 +82,10 @@ _argument_list_length (argument_list_t *list); string_list_t * _argument_list_member_at (argument_list_t *list, int index); +#define yylex glcpp_parser_lex + static int -yylex (yyscan_t scanner); +glcpp_parser_lex (glcpp_parser_t *parser); %} @@ -94,7 +96,7 @@ yylex (yyscan_t scanner); } %parse-param {glcpp_parser_t *parser} -%lex-param {void *scanner} +%lex-param {glcpp_parser_t *parser} %token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO REPLACEMENT TOKEN UNDEF %type argument_word FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN @@ -647,7 +649,7 @@ _expand_function_macro (glcpp_parser_t *parser, } static int -yylex (yyscan_t scanner) +glcpp_parser_lex (glcpp_parser_t *parser) { - return glcpp_lex (scanner); + return glcpp_lex (parser->scanner); } -- cgit v1.2.3 From 66df1c262a0c816b28b21457fc499fadfcc0dbee Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 10:06:56 -0700 Subject: Remove unneeded YYLEX_PARAM define. I'm not sure where this came from, but it's clearly not needed. --- glcpp-parse.y | 2 -- 1 file changed, 2 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 04bac00e9f9..bca22cec862 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -28,8 +28,6 @@ #include "glcpp.h" -#define YYLEX_PARAM parser->scanner - void yyerror (void *scanner, const char *error); -- cgit v1.2.3 From 71c59ec66bc258be6a641b26f793060f6d9522c8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 10:07:31 -0700 Subject: Remove unused NEWLINE token. We fixed the lexer a while back to never return a NEWLINE token, but negelcted to clean up this declaration. --- glcpp-parse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index bca22cec862..bb57b300982 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -96,7 +96,7 @@ glcpp_parser_lex (glcpp_parser_t *parser); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO REPLACEMENT TOKEN UNDEF +%token DEFINE FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN UNDEF %type argument_word FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN %type argument macro parameter_list %type argument_list -- cgit v1.2.3 From aaa9acbf10b7a8e7dac061885ef95823ad27f80e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 13:28:24 -0700 Subject: Perform "re lexing" on string list values rathern than on text. Previously, we would pass original strings back to the original lexer whenever we needed to re-lex something, (such as an expanded macro or a macro argument). Now, we instead parse the macro or argument originally to a string list, and then re-lex by simply returning each string from this list in turn. We do this in the recently added glcpp_parser_lex function that sits on top of the lower-level glcpp_lex that only deals with text. This doesn't change any behavior (at least according to the existing test suite which all still passes) but it brings us much closer to being able to "finalize" an unexpanded macro as required by the specification. --- glcpp-lex.l | 71 +++++++--------------------- glcpp-parse.y | 148 ++++++++++++++++++++++++++++++++++++++++------------------ glcpp.h | 38 +++------------ 3 files changed, 124 insertions(+), 133 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 52be1b1ea43..aec967964b0 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -84,12 +84,12 @@ TOKEN [^[:space:](),]+ \n { BEGIN INITIAL; - yylval.str = xtalloc_strdup (yyextra, ""); - return REPLACEMENT; + return NEWLINE; } {HSPACE}+ { BEGIN ST_DEFINE_VALUE; + return SPACE; } "(" { @@ -113,10 +113,21 @@ TOKEN [^[:space:](),]+ {HSPACE}+ -.*\n { +{TOKEN} { + yylval.str = xtalloc_strdup (yyextra, yytext); + return TOKEN; +} + +[(),] { + yylval.str = xtalloc_strdup (yyextra, yytext); + return TOKEN; +} + +{HSPACE}+ + +\n { BEGIN INITIAL; - yylval.str = xtalloc_strndup (yyextra, yytext, strlen (yytext) - 1); - return REPLACEMENT; + return NEWLINE; } {IDENTIFIER} { @@ -161,54 +172,4 @@ TOKEN [^[:space:](),]+ {HSPACE}+ -<> { - int done; - - done = glcpp_lex_stack_pop (yyextra->lex_stack); - - if (done) - yyterminate (); - - glcpp_parser_pop_expansion (yyextra); -} - %% - -void -glcpp_lex_stack_push (glcpp_lex_stack_t *stack, const char *string) -{ - struct yyguts_t *yyg = (struct yyguts_t*) stack->parser->scanner; - glcpp_lex_node_t *node; - - /* Save the current buffer on the top of the stack. */ - node = xtalloc (stack, glcpp_lex_node_t); - node->buffer = YY_CURRENT_BUFFER; - - node->next = stack->head; - stack->head = node; - - /* Then switch to a new scan buffer for string. */ - yy_scan_string (string, stack->parser->scanner); -} - -int -glcpp_lex_stack_pop (glcpp_lex_stack_t *stack) -{ - struct yyguts_t *yyg = (struct yyguts_t*) stack->parser->scanner; - glcpp_lex_node_t *node; - - node = stack->head; - - if (node == NULL) - return 1; - - stack->head = node->next; - - yy_delete_buffer (YY_CURRENT_BUFFER, stack->parser->scanner); - yy_switch_to_buffer ((YY_BUFFER_STATE) node->buffer, - stack->parser->scanner); - - talloc_free (node); - - return 0; -} diff --git a/glcpp-parse.y b/glcpp-parse.y index bb57b300982..2383c93117f 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -34,13 +34,13 @@ yyerror (void *scanner, const char *error); void _define_object_macro (glcpp_parser_t *parser, const char *macro, - const char *replacement); + string_list_t *replacements); void _define_function_macro (glcpp_parser_t *parser, const char *macro, string_list_t *parameters, - const char *replacement); + string_list_t *replacements); void _expand_object_macro (glcpp_parser_t *parser, const char *identifier); @@ -80,6 +80,14 @@ _argument_list_length (argument_list_t *list); string_list_t * _argument_list_member_at (argument_list_t *list, int index); +static void +glcpp_parser_push_expansion_macro (glcpp_parser_t *parser, + macro_t *macro, + argument_list_t *arguments); + +static void +glcpp_parser_pop_expansion (glcpp_parser_t *parser); + #define yylex glcpp_parser_lex static int @@ -96,9 +104,9 @@ glcpp_parser_lex (glcpp_parser_t *parser); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token DEFINE FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN UNDEF -%type argument_word FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN -%type argument macro parameter_list +%token DEFINE FUNC_MACRO IDENTIFIER OBJ_MACRO NEWLINE SPACE TOKEN UNDEF +%type argument_word FUNC_MACRO IDENTIFIER OBJ_MACRO TOKEN +%type argument macro parameter_list replacement_list pp_tokens %type argument_list /* Hard to remove shift/reduce conflicts documented as follows: @@ -194,10 +202,14 @@ argument_word: directive: - DEFINE IDENTIFIER REPLACEMENT { - _define_object_macro (parser, $2, $3); + DEFINE IDENTIFIER NEWLINE { + string_list_t *list = _string_list_create (parser); + _define_object_macro (parser, $2, list); } -| DEFINE IDENTIFIER '(' parameter_list ')' REPLACEMENT { +| DEFINE IDENTIFIER SPACE replacement_list NEWLINE { + _define_object_macro (parser, $2, $4); + } +| DEFINE IDENTIFIER '(' parameter_list ')' replacement_list NEWLINE { _define_function_macro (parser, $2, $4, $6); } | UNDEF IDENTIFIER { @@ -229,6 +241,27 @@ parameter_list: } ; +replacement_list: + /* empty */ { + $$ = _string_list_create (parser); + } +| pp_tokens { + $$ = $1; + } +; + + +pp_tokens: + TOKEN { + $$ = _string_list_create (parser); + _string_list_append_item ($$, $1); + } +| pp_tokens TOKEN { + _string_list_append_item ($1, $2); + $$ = $1; + } +; + %% string_list_t * @@ -413,10 +446,6 @@ glcpp_parser_create (void) hash_table_string_compare); parser->expansions = NULL; - parser->lex_stack = xtalloc (parser, glcpp_lex_stack_t); - parser->lex_stack->parser = parser; - parser->lex_stack->head = NULL; - return parser; } @@ -495,7 +524,7 @@ glcpp_parser_classify_token (glcpp_parser_t *parser, void _define_object_macro (glcpp_parser_t *parser, const char *identifier, - const char *replacement) + string_list_t *replacements) { macro_t *macro; @@ -504,7 +533,7 @@ _define_object_macro (glcpp_parser_t *parser, macro->is_function = 0; macro->parameters = NULL; macro->identifier = talloc_strdup (macro, identifier); - macro->replacement = talloc_steal (macro, replacement); + macro->replacements = talloc_steal (macro, replacements); hash_table_insert (parser->defines, macro, identifier); } @@ -513,7 +542,7 @@ void _define_function_macro (glcpp_parser_t *parser, const char *identifier, string_list_t *parameters, - const char *replacement) + string_list_t *replacements) { macro_t *macro; @@ -522,7 +551,7 @@ _define_function_macro (glcpp_parser_t *parser, macro->is_function = 1; macro->parameters = talloc_steal (macro, parameters); macro->identifier = talloc_strdup (macro, identifier); - macro->replacement = talloc_steal (macro, replacement); + macro->replacements = talloc_steal (macro, replacements); hash_table_insert (parser->defines, macro, identifier); } @@ -531,7 +560,7 @@ static void _glcpp_parser_push_expansion_internal (glcpp_parser_t *parser, macro_t *macro, argument_list_t *arguments, - const char * replacement) + string_node_t *replacements) { expansion_node_t *node; @@ -539,20 +568,19 @@ _glcpp_parser_push_expansion_internal (glcpp_parser_t *parser, node->macro = macro; node->arguments = arguments; + node->replacements = replacements; node->next = parser->expansions; parser->expansions = node; - - glcpp_lex_stack_push (parser->lex_stack, replacement); } -void +static void glcpp_parser_push_expansion_macro (glcpp_parser_t *parser, macro_t *macro, argument_list_t *arguments) { _glcpp_parser_push_expansion_internal (parser, macro, arguments, - macro->replacement); + macro->replacements->head); } void @@ -561,38 +589,16 @@ glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, { argument_list_t *arguments; string_list_t *argument; - string_node_t *node; - char *argument_str, *s; - int length; arguments = parser->expansions->arguments; argument = _argument_list_member_at (arguments, argument_index); - length = 0; - for (node = argument->head; node; node = node->next) - length += strlen (node->str) + 1; - - argument_str = xtalloc_size (parser, length); - - *argument_str = '\0'; - s = argument_str; - for (node = argument->head; node; node = node->next) { - strcpy (s, node->str); - s += strlen (node->str); - if (node->next) { - *s = ' '; - s++; - *s = '\0'; - } - } - _glcpp_parser_push_expansion_internal (parser, NULL, NULL, - argument_str); + argument->head); } -/* The lexer calls this when it exhausts a string. */ -void +static void glcpp_parser_pop_expansion (glcpp_parser_t *parser) { expansion_node_t *node; @@ -649,5 +655,55 @@ _expand_function_macro (glcpp_parser_t *parser, static int glcpp_parser_lex (glcpp_parser_t *parser) { - return glcpp_lex (parser->scanner); + expansion_node_t *expansion; + string_node_t *replacements; + int parameter_index; + + /* Who says C can't do efficient tail recursion? */ + RECURSE: + + expansion = parser->expansions; + + if (expansion == NULL) + return glcpp_lex (parser->scanner); + + replacements = expansion->replacements; + + /* Pop expansion when replacements is exhausted. */ + if (replacements == NULL) { + glcpp_parser_pop_expansion (parser); + goto RECURSE; + } + + expansion->replacements = replacements->next; + + if (strcmp (replacements->str, "(") == 0) + return '('; + else if (strcmp (replacements->str, ")") == 0) + return ')'; + else if (strcmp (replacements->str, ",") == 0) + return ','; + + yylval.str = xtalloc_strdup (parser, replacements->str); + + switch (glcpp_parser_classify_token (parser, yylval.str, + ¶meter_index)) + { + case TOKEN_CLASS_ARGUMENT: + talloc_free (yylval.str); + glcpp_parser_push_expansion_argument (parser, + parameter_index); + goto RECURSE; + break; + case TOKEN_CLASS_IDENTIFIER: + return IDENTIFIER; + break; + case TOKEN_CLASS_FUNC_MACRO: + return FUNC_MACRO; + break; + default: + case TOKEN_CLASS_OBJ_MACRO: + return OBJ_MACRO; + break; + } } diff --git a/glcpp.h b/glcpp.h index 6aabf6f1823..ef821a7637a 100644 --- a/glcpp.h +++ b/glcpp.h @@ -54,24 +54,6 @@ typedef struct argument_list { typedef struct glcpp_parser glcpp_parser_t; -/* Support for temporarily lexing/parsing tokens from a string. */ - -typedef struct glcpp_lex_node { - void *buffer; - struct glcpp_lex_node *next; -} glcpp_lex_node_t; - -typedef struct { - glcpp_parser_t *parser; - glcpp_lex_node_t *head; -} glcpp_lex_stack_t; - -void -glcpp_lex_stack_push (glcpp_lex_stack_t *stack, const char *string); - -int -glcpp_lex_stack_pop (glcpp_lex_stack_t *stack); - typedef enum { TOKEN_CLASS_ARGUMENT, TOKEN_CLASS_IDENTIFIER, @@ -88,12 +70,13 @@ typedef struct { int is_function; string_list_t *parameters; const char *identifier; - const char *replacement; + string_list_t *replacements; } macro_t; typedef struct expansion_node { macro_t *macro; argument_list_t *arguments; + string_node_t *replacements; struct expansion_node *next; } expansion_node_t; @@ -101,9 +84,12 @@ struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; expansion_node_t *expansions; - glcpp_lex_stack_t *lex_stack; }; +void +glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, + int argument_index); + glcpp_parser_t * glcpp_parser_create (void); @@ -113,18 +99,6 @@ glcpp_parser_parse (glcpp_parser_t *parser); void glcpp_parser_destroy (glcpp_parser_t *parser); -void -glcpp_parser_push_expansion_macro (glcpp_parser_t *parser, - macro_t *macro, - argument_list_t *arguments); - -void -glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, - int argument_index); - -void -glcpp_parser_pop_expansion (glcpp_parser_t *parser); - /* Generated by glcpp-lex.l to glcpp-lex.c */ int -- cgit v1.2.3 From 472524413d004680dbdb89602617f32da8f42f56 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 19 May 2010 13:54:37 -0700 Subject: Use new token_list_t rather than string_list_t for macro values. There's not yet any change in functionality here, (at least according to the test suite). But we now have the option of specifying a type for each string in the token list. This will allow us to finalize an unexpanded macro name so that it won't be subjected to excess expansion later. --- glcpp-parse.y | 111 +++++++++++++++++++++++++++++++++++++++++++--------------- glcpp.h | 17 +++++++-- 2 files changed, 97 insertions(+), 31 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 2383c93117f..c8d1919d9c5 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -34,13 +34,13 @@ yyerror (void *scanner, const char *error); void _define_object_macro (glcpp_parser_t *parser, const char *macro, - string_list_t *replacements); + token_list_t *replacements); void _define_function_macro (glcpp_parser_t *parser, const char *macro, string_list_t *parameters, - string_list_t *replacements); + token_list_t *replacements); void _expand_object_macro (glcpp_parser_t *parser, const char *identifier); @@ -72,14 +72,23 @@ argument_list_t * _argument_list_create (void *ctx); void -_argument_list_append (argument_list_t *list, string_list_t *argument); +_argument_list_append (argument_list_t *list, token_list_t *argument); int _argument_list_length (argument_list_t *list); -string_list_t * +token_list_t * _argument_list_member_at (argument_list_t *list, int index); +token_list_t * +_token_list_create (void *ctx); + +void +_token_list_append (token_list_t *list, int type, const char *value); + +void +_token_list_append_list (token_list_t *list, token_list_t *tail); + static void glcpp_parser_push_expansion_macro (glcpp_parser_t *parser, macro_t *macro, @@ -97,8 +106,9 @@ glcpp_parser_lex (glcpp_parser_t *parser); %union { char *str; - string_list_t *string_list; argument_list_t *argument_list; + string_list_t *string_list; + token_list_t *token_list; } %parse-param {glcpp_parser_t *parser} @@ -106,8 +116,9 @@ glcpp_parser_lex (glcpp_parser_t *parser); %token DEFINE FUNC_MACRO IDENTIFIER OBJ_MACRO NEWLINE SPACE TOKEN UNDEF %type argument_word FUNC_MACRO IDENTIFIER OBJ_MACRO TOKEN -%type argument macro parameter_list replacement_list pp_tokens %type argument_list +%type macro parameter_list +%type argument replacement_list pp_tokens /* Hard to remove shift/reduce conflicts documented as follows: * @@ -177,18 +188,18 @@ argument_list: argument: argument_word { - $$ = _string_list_create (parser); - _string_list_append_item ($$, $1); + $$ = _token_list_create (parser); + _token_list_append ($$, IDENTIFIER, $1); } | argument argument_word { - _string_list_append_item ($1, $2); + _token_list_append ($1, IDENTIFIER, $2); talloc_free ($2); $$ = $1; } | argument '(' argument ')' { - _string_list_append_item ($1, "("); - _string_list_append_list ($1, $3); - _string_list_append_item ($1, ")"); + _token_list_append ($1, '(', "("); + _token_list_append_list ($1, $3); + _token_list_append ($1, ')', ")"); $$ = $1; } ; @@ -203,7 +214,7 @@ argument_word: directive: DEFINE IDENTIFIER NEWLINE { - string_list_t *list = _string_list_create (parser); + token_list_t *list = _token_list_create (parser); _define_object_macro (parser, $2, list); } | DEFINE IDENTIFIER SPACE replacement_list NEWLINE { @@ -243,7 +254,7 @@ parameter_list: replacement_list: /* empty */ { - $$ = _string_list_create (parser); + $$ = _token_list_create (parser); } | pp_tokens { $$ = $1; @@ -253,11 +264,11 @@ replacement_list: pp_tokens: TOKEN { - $$ = _string_list_create (parser); - _string_list_append_item ($$, $1); + $$ = _token_list_create (parser); + _token_list_append ($$, TOKEN, $1); } | pp_tokens TOKEN { - _string_list_append_item ($1, $2); + _token_list_append ($1, TOKEN, $2); $$ = $1; } ; @@ -370,7 +381,7 @@ _argument_list_create (void *ctx) } void -_argument_list_append (argument_list_t *list, string_list_t *argument) +_argument_list_append (argument_list_t *list, token_list_t *argument) { argument_node_t *node; @@ -406,7 +417,7 @@ _argument_list_length (argument_list_t *list) return length; } -string_list_t * +token_list_t * _argument_list_member_at (argument_list_t *list, int index) { argument_node_t *node; @@ -427,6 +438,50 @@ _argument_list_member_at (argument_list_t *list, int index) return NULL; } + +token_list_t * +_token_list_create (void *ctx) +{ + token_list_t *list; + + list = xtalloc (ctx, token_list_t); + list->head = NULL; + list->tail = NULL; + + return list; +} + +void +_token_list_append (token_list_t *list, int type, const char *value) +{ + token_node_t *node; + + node = xtalloc (list, token_node_t); + node->type = type; + node->value = xtalloc_strdup (list, value); + + node->next = NULL; + + if (list->head == NULL) { + list->head = node; + } else { + list->tail->next = node; + } + + list->tail = node; +} + +void +_token_list_append_list (token_list_t *list, token_list_t *tail) +{ + if (list->head == NULL) { + list->head = tail->head; + } else { + list->tail->next = tail->head; + } + + list->tail = tail->tail; +} void yyerror (void *scanner, const char *error) @@ -524,7 +579,7 @@ glcpp_parser_classify_token (glcpp_parser_t *parser, void _define_object_macro (glcpp_parser_t *parser, const char *identifier, - string_list_t *replacements) + token_list_t *replacements) { macro_t *macro; @@ -542,7 +597,7 @@ void _define_function_macro (glcpp_parser_t *parser, const char *identifier, string_list_t *parameters, - string_list_t *replacements) + token_list_t *replacements) { macro_t *macro; @@ -560,7 +615,7 @@ static void _glcpp_parser_push_expansion_internal (glcpp_parser_t *parser, macro_t *macro, argument_list_t *arguments, - string_node_t *replacements) + token_node_t *replacements) { expansion_node_t *node; @@ -588,7 +643,7 @@ glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, int argument_index) { argument_list_t *arguments; - string_list_t *argument; + token_list_t *argument; arguments = parser->expansions->arguments; @@ -656,7 +711,7 @@ static int glcpp_parser_lex (glcpp_parser_t *parser) { expansion_node_t *expansion; - string_node_t *replacements; + token_node_t *replacements; int parameter_index; /* Who says C can't do efficient tail recursion? */ @@ -677,14 +732,14 @@ glcpp_parser_lex (glcpp_parser_t *parser) expansion->replacements = replacements->next; - if (strcmp (replacements->str, "(") == 0) + if (strcmp (replacements->value, "(") == 0) return '('; - else if (strcmp (replacements->str, ")") == 0) + else if (strcmp (replacements->value, ")") == 0) return ')'; - else if (strcmp (replacements->str, ",") == 0) + else if (strcmp (replacements->value, ",") == 0) return ','; - yylval.str = xtalloc_strdup (parser, replacements->str); + yylval.str = xtalloc_strdup (parser, replacements->value); switch (glcpp_parser_classify_token (parser, yylval.str, ¶meter_index)) diff --git a/glcpp.h b/glcpp.h index ef821a7637a..c647e2a72e1 100644 --- a/glcpp.h +++ b/glcpp.h @@ -42,8 +42,19 @@ typedef struct string_list { string_node_t *tail; } string_list_t; +typedef struct token_node { + int type; + const char *value; + struct token_node *next; +} token_node_t; + +typedef struct token_list { + token_node_t *head; + token_node_t *tail; +} token_list_t; + typedef struct argument_node { - string_list_t *argument; + token_list_t *argument; struct argument_node *next; } argument_node_t; @@ -70,13 +81,13 @@ typedef struct { int is_function; string_list_t *parameters; const char *identifier; - string_list_t *replacements; + token_list_t *replacements; } macro_t; typedef struct expansion_node { macro_t *macro; argument_list_t *arguments; - string_node_t *replacements; + token_node_t *replacements; struct expansion_node *next; } expansion_node_t; -- cgit v1.2.3 From b569383bbdfa22ed591255f56fb93832633a95ae Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 08:01:44 -0700 Subject: Avoid re-expanding a macro name that has once been rejected from expansion. The specification of the preprocessor in C99 says that when we see a macro name that we are already expanding that we refuse to expand it now, (which we've done for a while), but also that we refuse to ever expand it later if seen in other contexts at which it would be legitimate to expand. We add a test case for that here, and fix it to work. The fix takes advantage of a new token_t value for tokens and argument words along with the recently added IDENTIFIER_FINALIZED token type which instructs the parser to not even look for another expansion. --- glcpp-lex.l | 12 ++++++++--- glcpp-parse.y | 38 ++++++++++++++++++++++++----------- glcpp.h | 6 ++++++ tests/037-finalize-unexpanded-macro.c | 3 +++ 4 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 tests/037-finalize-unexpanded-macro.c diff --git a/glcpp-lex.l b/glcpp-lex.l index aec967964b0..8e3ab661e6f 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -114,12 +114,14 @@ TOKEN [^[:space:](),]+ {HSPACE}+ {TOKEN} { - yylval.str = xtalloc_strdup (yyextra, yytext); + yylval.token.type = TOKEN; + yylval.token.value = xtalloc_strdup (yyextra, yytext); return TOKEN; } [(),] { - yylval.str = xtalloc_strdup (yyextra, yytext); + yylval.token.type = TOKEN; + yylval.token.value = xtalloc_strdup (yyextra, yytext); return TOKEN; } @@ -147,6 +149,9 @@ TOKEN [^[:space:](),]+ case TOKEN_CLASS_IDENTIFIER: return IDENTIFIER; break; + case TOKEN_CLASS_IDENTIFIER_FINALIZED: + return IDENTIFIER_FINALIZED; + break; case TOKEN_CLASS_FUNC_MACRO: return FUNC_MACRO; break; @@ -162,7 +167,8 @@ TOKEN [^[:space:](),]+ } {TOKEN} { - yylval.str = xtalloc_strdup (yyextra, yytext); + yylval.token.type = TOKEN; + yylval.token.value = xtalloc_strdup (yyextra, yytext); return TOKEN; } diff --git a/glcpp-parse.y b/glcpp-parse.y index c8d1919d9c5..28e79ebf9f7 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -108,16 +108,18 @@ glcpp_parser_lex (glcpp_parser_t *parser); char *str; argument_list_t *argument_list; string_list_t *string_list; + token_t token; token_list_t *token_list; } %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token DEFINE FUNC_MACRO IDENTIFIER OBJ_MACRO NEWLINE SPACE TOKEN UNDEF -%type argument_word FUNC_MACRO IDENTIFIER OBJ_MACRO TOKEN +%token DEFINE FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO NEWLINE SPACE TOKEN UNDEF +%type FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO %type argument_list %type macro parameter_list +%type TOKEN argument_word %type argument replacement_list pp_tokens /* Hard to remove shift/reduce conflicts documented as follows: @@ -145,10 +147,14 @@ content: printf ("%s", $1); talloc_free ($1); } -| TOKEN { +| IDENTIFIER_FINALIZED { printf ("%s", $1); talloc_free ($1); } +| TOKEN { + printf ("%s", $1.value); + talloc_free ($1.value); + } | FUNC_MACRO { printf ("%s", $1); talloc_free ($1); @@ -189,11 +195,11 @@ argument_list: argument: argument_word { $$ = _token_list_create (parser); - _token_list_append ($$, IDENTIFIER, $1); + _token_list_append ($$, $1.type, $1.value); } | argument argument_word { - _token_list_append ($1, IDENTIFIER, $2); - talloc_free ($2); + _token_list_append ($1, $2.type, $2.value); + talloc_free ($2.value); $$ = $1; } | argument '(' argument ')' { @@ -205,10 +211,11 @@ argument: ; argument_word: - IDENTIFIER { $$ = $1; } + IDENTIFIER { $$.type = IDENTIFIER; $$.value = $1; } +| IDENTIFIER_FINALIZED { $$.type = IDENTIFIER_FINALIZED; $$.value = $1; } | TOKEN { $$ = $1; } -| FUNC_MACRO { $$ = $1; } -| macro { $$ = xtalloc_strdup (parser, ""); } +| FUNC_MACRO { $$.type = FUNC_MACRO; $$.value = $1; } +| macro { $$.type = TOKEN; $$.value = xtalloc_strdup (parser, ""); } ; @@ -265,10 +272,10 @@ replacement_list: pp_tokens: TOKEN { $$ = _token_list_create (parser); - _token_list_append ($$, TOKEN, $1); + _token_list_append ($$, $1.type, $1.value); } | pp_tokens TOKEN { - _token_list_append ($1, TOKEN, $2); + _token_list_append ($1, $2.type, $2.value); $$ = $1; } ; @@ -567,7 +574,7 @@ glcpp_parser_classify_token (glcpp_parser_t *parser, /* Don't consider this a macro if we are already actively * expanding this macro. */ if (glcpp_parser_is_expanding (parser, identifier)) - return TOKEN_CLASS_IDENTIFIER; + return TOKEN_CLASS_IDENTIFIER_FINALIZED; /* Definitely a macro. Just need to check if it's function-like. */ if (macro->is_function) @@ -741,6 +748,10 @@ glcpp_parser_lex (glcpp_parser_t *parser) yylval.str = xtalloc_strdup (parser, replacements->value); + /* Carefully refuse to expand any finalized identifier. */ + if (replacements->type == IDENTIFIER_FINALIZED) + return IDENTIFIER_FINALIZED; + switch (glcpp_parser_classify_token (parser, yylval.str, ¶meter_index)) { @@ -753,6 +764,9 @@ glcpp_parser_lex (glcpp_parser_t *parser) case TOKEN_CLASS_IDENTIFIER: return IDENTIFIER; break; + case TOKEN_CLASS_IDENTIFIER_FINALIZED: + return IDENTIFIER_FINALIZED; + break; case TOKEN_CLASS_FUNC_MACRO: return FUNC_MACRO; break; diff --git a/glcpp.h b/glcpp.h index c647e2a72e1..5432a318173 100644 --- a/glcpp.h +++ b/glcpp.h @@ -42,6 +42,11 @@ typedef struct string_list { string_node_t *tail; } string_list_t; +typedef struct token { + int type; + char *value; +} token_t; + typedef struct token_node { int type; const char *value; @@ -68,6 +73,7 @@ typedef struct glcpp_parser glcpp_parser_t; typedef enum { TOKEN_CLASS_ARGUMENT, TOKEN_CLASS_IDENTIFIER, + TOKEN_CLASS_IDENTIFIER_FINALIZED, TOKEN_CLASS_FUNC_MACRO, TOKEN_CLASS_OBJ_MACRO } token_class_t; diff --git a/tests/037-finalize-unexpanded-macro.c b/tests/037-finalize-unexpanded-macro.c new file mode 100644 index 00000000000..b3a2f37f1b9 --- /dev/null +++ b/tests/037-finalize-unexpanded-macro.c @@ -0,0 +1,3 @@ +#define expand(x) expand(x once) +#define foo(x) x +foo(expand(just)) -- cgit v1.2.3 From 9f3d2c4e3dff3eb4f5820a034426056bf66b3015 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 08:42:02 -0700 Subject: Add support for commas within parenthesized groups in function arguments. The specification says that commas within a parenthesized group, (that's not a function-like macro invocation), are passed through literally and not considered argument separators in any outer macro invocation. Add support and a test for this case. This support makes a third occurrence of the same "FUNC_MACRO (" shift/reduce conflict appear, so expect that. This change does introduce a fairly large copy/paste block in the grammar which is unfortunate. Perhaps if I were more clever I'd find a way to share the common pieces between argument and argument_or_comma. --- glcpp-parse.y | 44 ++++++++++++++++++++++++++++++++++++---- tests/038-func-arg-with-commas.c | 2 ++ 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 tests/038-func-arg-with-commas.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 28e79ebf9f7..c9edc5c3040 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -119,8 +119,8 @@ glcpp_parser_lex (glcpp_parser_t *parser); %type FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO %type argument_list %type macro parameter_list -%type TOKEN argument_word -%type argument replacement_list pp_tokens +%type TOKEN argument_word argument_word_or_comma +%type argument argument_or_comma replacement_list pp_tokens /* Hard to remove shift/reduce conflicts documented as follows: * @@ -131,8 +131,10 @@ glcpp_parser_lex (glcpp_parser_t *parser); * 2. Similarly, '(' after FUNC_MACRO which is correctly resolved to * shift to form macro invocation rather than reducing directly to * argument. + * + * 3. Similarly again now that we added argument_or_comma as well. */ -%expect 2 +%expect 3 %% @@ -202,7 +204,7 @@ argument: talloc_free ($2.value); $$ = $1; } -| argument '(' argument ')' { +| argument '(' argument_or_comma ')' { _token_list_append ($1, '(', "("); _token_list_append_list ($1, $3); _token_list_append ($1, ')', ")"); @@ -218,6 +220,40 @@ argument_word: | macro { $$.type = TOKEN; $$.value = xtalloc_strdup (parser, ""); } ; + /* XXX: The body of argument_or_comma is the same as the body + * of argument, but with "argument" and "argument_word" + * changed to "argument_or_comma" and + * "argument_word_or_comma". It would be nice to have less + * redundancy here, but I'm not sure how. + * + * It would also be nice to have a less ugly grammar to have + * to implement, but such is the C preprocessor. + */ +argument_or_comma: + argument_word_or_comma { + $$ = _token_list_create (parser); + _token_list_append ($$, $1.type, $1.value); + } +| argument_or_comma argument_word_or_comma { + _token_list_append ($1, $2.type, $2.value); + $$ = $1; + } +| argument_or_comma '(' argument_or_comma ')' { + _token_list_append ($1, '(', "("); + _token_list_append_list ($1, $3); + _token_list_append ($1, ')', ")"); + $$ = $1; + } +; + +argument_word_or_comma: + IDENTIFIER { $$.type = IDENTIFIER; $$.value = $1; } +| IDENTIFIER_FINALIZED { $$.type = IDENTIFIER_FINALIZED; $$.value = $1; } +| TOKEN { $$ = $1; } +| FUNC_MACRO { $$.type = FUNC_MACRO; $$.value = $1; } +| macro { $$.type = TOKEN; $$.value = xtalloc_strdup (parser, ""); } +| ',' { $$.type = ','; $$.value = xtalloc_strdup (parser, ","); } +; directive: DEFINE IDENTIFIER NEWLINE { diff --git a/tests/038-func-arg-with-commas.c b/tests/038-func-arg-with-commas.c new file mode 100644 index 00000000000..1407c7d6e3c --- /dev/null +++ b/tests/038-func-arg-with-commas.c @@ -0,0 +1,2 @@ +#define foo(x) success +foo(argument (with,embedded , commas) -- tricky) -- cgit v1.2.3 From 805ea6afe66f52476094256914b7319b29972a16 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 12:06:33 -0700 Subject: Add test (and fix) for a function argument of a macro that expands with a comma. The fix here is quite simple (and actually only deletes code). When expanding a macro, we don't return a ',' as a unique token type, but simply let it fall through to the generic case. --- glcpp-parse.y | 2 -- tests/039-func-arg-obj-macro-with-comma.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 tests/039-func-arg-obj-macro-with-comma.c diff --git a/glcpp-parse.y b/glcpp-parse.y index c9edc5c3040..773db93e54a 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -779,8 +779,6 @@ glcpp_parser_lex (glcpp_parser_t *parser) return '('; else if (strcmp (replacements->value, ")") == 0) return ')'; - else if (strcmp (replacements->value, ",") == 0) - return ','; yylval.str = xtalloc_strdup (parser, replacements->value); diff --git a/tests/039-func-arg-obj-macro-with-comma.c b/tests/039-func-arg-obj-macro-with-comma.c new file mode 100644 index 00000000000..0f7fe632b56 --- /dev/null +++ b/tests/039-func-arg-obj-macro-with-comma.c @@ -0,0 +1,3 @@ +#define foo(a) (a) +#define bar two,words +foo(bar) -- cgit v1.2.3 From 660bda057a0f9c83625e798c0f719080d11e9431 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 14:00:28 -0700 Subject: Stop ignoring whitespace while testing. Sometime back the output of glcpp started differing from the output of "gcc -E" in the amount of whitespace in emitted. At the time, I switched the test suite to use "diff -w" to ignore this. This was a mistake since it ignores whitespace entirely. (I meant to use "diff -b" which ignores only changes in the amount of whitespace.) So bugs have since been introduced that the test suite doesn't notice. For example, glcpp is producing "twotokens" where it should be producing "two tokens". Let's stop ignoring whitespace in the test suite, which currently introduces lots of failures---some real and some spurious. --- tests/glcpp-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/glcpp-test b/tests/glcpp-test index 673a4f45e96..25685eeabe5 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -5,5 +5,5 @@ for test in *.c; do ../glcpp < $test > $test.out gcc -E $test -o $test.gcc grep -v '^#' < $test.gcc > $test.expected - diff -B -w -u $test.expected $test.out + diff -u $test.expected $test.out done -- cgit v1.2.3 From 323421db6567f3402e0ff9dcf548269e6d7b5497 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 14:05:37 -0700 Subject: Remove "unnecessary" whitespace from some tests. This whitespace was not part of anything being tested, and it introduces differences (that we don't actually care about) between the output of "gcc -E" and glcpp. Just eliminate this extra whitespace to reduce spurious test-case failures. --- tests/015-define-object-with-parens.c | 6 +++--- tests/016-define-func-1-arg.c | 2 +- tests/020-define-func-2-arg-multi.c | 2 +- tests/023-define-extra-whitespace.c | 4 ++-- tests/032-define-func-self-recurse.c | 2 +- tests/033-define-func-self-compose.c | 2 +- tests/035-define-func-self-compose-non-func-multi-token-argument.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/015-define-object-with-parens.c b/tests/015-define-object-with-parens.c index 10bf7e31a34..558da9c617b 100644 --- a/tests/015-define-object-with-parens.c +++ b/tests/015-define-object-with-parens.c @@ -1,4 +1,4 @@ -#define foo ( ) 1 +#define foo ()1 foo() -#define bar () 2 -bar( ) +#define bar ()2 +bar() diff --git a/tests/016-define-func-1-arg.c b/tests/016-define-func-1-arg.c index dea38d1fedd..a2e2404c7c1 100644 --- a/tests/016-define-func-1-arg.c +++ b/tests/016-define-func-1-arg.c @@ -1,2 +1,2 @@ -#define foo(x) ((x) + 1) +#define foo(x) ((x)+1) foo(bar) diff --git a/tests/020-define-func-2-arg-multi.c b/tests/020-define-func-2-arg-multi.c index 253421139d4..3049ad15465 100644 --- a/tests/020-define-func-2-arg-multi.c +++ b/tests/020-define-func-2-arg-multi.c @@ -1,2 +1,2 @@ -#define foo(x,y) x, two fish, red fish, y +#define foo(x,y) x,two fish,red fish,y foo(one fish, blue fish) diff --git a/tests/023-define-extra-whitespace.c b/tests/023-define-extra-whitespace.c index 375355a17d9..7ebfed6516c 100644 --- a/tests/023-define-extra-whitespace.c +++ b/tests/023-define-extra-whitespace.c @@ -3,6 +3,6 @@ # define twoargs( x , y ) x y # define threeargs( a , b , c ) a b c noargs ( ) - onearg ( 2 ) - twoargs ( 3 , 4 ) +onearg ( 2 ) +twoargs ( 3 , 4 ) threeargs ( 5 , 6 , 7 ) diff --git a/tests/032-define-func-self-recurse.c b/tests/032-define-func-self-recurse.c index 60d8526c0aa..b3ac70f499c 100644 --- a/tests/032-define-func-self-recurse.c +++ b/tests/032-define-func-self-recurse.c @@ -1,2 +1,2 @@ -#define foo(a) foo(2 * (a)) +#define foo(a) foo(2*(a)) foo(3) diff --git a/tests/033-define-func-self-compose.c b/tests/033-define-func-self-compose.c index 8abaaf6be95..f65e48286cf 100644 --- a/tests/033-define-func-self-compose.c +++ b/tests/033-define-func-self-compose.c @@ -1,2 +1,2 @@ -#define foo(a) foo(2 * (a)) +#define foo(a) foo(2*(a)) foo(foo(3)) diff --git a/tests/035-define-func-self-compose-non-func-multi-token-argument.c b/tests/035-define-func-self-compose-non-func-multi-token-argument.c index 9955219470c..c307fbe830f 100644 --- a/tests/035-define-func-self-compose-non-func-multi-token-argument.c +++ b/tests/035-define-func-self-compose-non-func-multi-token-argument.c @@ -1,2 +1,2 @@ #define foo(bar) bar -foo(1 + foo) +foo(1+foo) -- cgit v1.2.3 From ff13cfed81132eaaa8859f25f87ea5398d4864ba Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 14:08:19 -0700 Subject: Remove unused function _print_string_list The only good dead code is non-existing dead code. --- glcpp-parse.y | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 773db93e54a..79a8ec2cf2a 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -50,9 +50,6 @@ _expand_function_macro (glcpp_parser_t *parser, const char *identifier, argument_list_t *arguments); -void -_print_string_list (string_list_t *list); - string_list_t * _string_list_create (void *ctx); @@ -396,21 +393,6 @@ _string_list_length (string_list_t *list) return length; } -void -_print_string_list (string_list_t *list) -{ - string_node_t *node; - - if (list == NULL) - return; - - for (node = list->head; node; node = node->next) { - printf ("%s", node->str); - if (node->next) - printf (" "); - } -} - argument_list_t * _argument_list_create (void *ctx) { -- cgit v1.2.3 From 005b32061f77008530a290ed991980a579095002 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 14:19:57 -0700 Subject: Fix bug of consuming excess whitespace. We fix this by moving printing up to the top-level "input" action and tracking whether a space is needed between one token and the next. This fixes all actual bugs in test-suite output, but does leave some tests failing due to differences in the amount of whitespace produced, (which aren't actual bugs per se). --- glcpp-parse.y | 71 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 79a8ec2cf2a..c6d64176b2d 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -102,6 +102,7 @@ glcpp_parser_lex (glcpp_parser_t *parser); %} %union { + int ival; char *str; argument_list_t *argument_list; string_list_t *string_list; @@ -112,8 +113,9 @@ glcpp_parser_lex (glcpp_parser_t *parser); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token DEFINE FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO NEWLINE SPACE TOKEN UNDEF -%type FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO +%token DEFINE FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO NEWLINE SEPARATOR SPACE TOKEN UNDEF +%type input punctuator +%type content FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO %type argument_list %type macro parameter_list %type TOKEN argument_word argument_word_or_comma @@ -135,38 +137,71 @@ glcpp_parser_lex (glcpp_parser_t *parser); %% + /* We do all printing at the input level. + * + * The value for "input" is simply TOKEN or SEPARATOR so we + * can decide whether it's necessary to print a space + * character between any two. */ input: - /* empty */ -| input content + /* empty */ { + $$ = SEPARATOR; + } +| input content { + int is_token; + + if ($2 && strlen ($2)) { + int c = $2[0]; + int is_not_separator = ((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + (c == '_')); + + if ($1 == TOKEN && is_not_separator) + printf (" "); + printf ("%s", $2); + if (is_not_separator) + $$ = TOKEN; + else + $$ = SEPARATOR; + } else { + $$ = $1; + } + if ($2) + talloc_free ($2); + } ; - /* We do all printing at the content level */ content: IDENTIFIER { - printf ("%s", $1); - talloc_free ($1); + $$ = $1; } | IDENTIFIER_FINALIZED { - printf ("%s", $1); - talloc_free ($1); + $$ = $1; } | TOKEN { - printf ("%s", $1.value); - talloc_free ($1.value); + $$ = $1.value; } | FUNC_MACRO { - printf ("%s", $1); - talloc_free ($1); + $$ = $1; } | directive { - printf ("\n"); + $$ = talloc_strdup (parser, "\n"); + } +| punctuator { + $$ = talloc_asprintf (parser, "%c", $1); + } +| macro { + $$ = NULL; } -| '(' { printf ("("); } -| ')' { printf (")"); } -| ',' { printf (","); } -| macro ; +punctuator: + '(' { $$ = '('; } +| ')' { $$ = ')'; } +| ',' { $$ = ','; } + ; + macro: FUNC_MACRO '(' argument_list ')' { _expand_function_macro (parser, $1, $3); -- cgit v1.2.3 From 5a6b9a27fdb2ac66aaadd90b15b1889fea8f08d0 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 14:29:43 -0700 Subject: Avoid printing a space at the beginning of lines in the output. This fixes more differences compared to "gcc -E" so removes several cases of erroneously failing test cases. The implementation isn't very elegant, but it is functional. --- glcpp-lex.l | 5 +++++ glcpp-parse.y | 18 +++++++++++------- glcpp.h | 1 + 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 8e3ab661e6f..13e4d6f0ef1 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -173,7 +173,12 @@ TOKEN [^[:space:](),]+ } \n { + /* XXX: Printing here (rather than in a parser production) + * *and* frobbing a bit of the parser state here are both ugly + * things. But all my attempts to avoid this by returning a + * NEWLINE token here have led to even more ugly things. */ printf ("\n"); + yyextra->just_printed_separator = 1; } {HSPACE}+ diff --git a/glcpp-parse.y b/glcpp-parse.y index c6d64176b2d..93713a3f0ca 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -114,7 +114,7 @@ glcpp_parser_lex (glcpp_parser_t *parser); %lex-param {glcpp_parser_t *parser} %token DEFINE FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO NEWLINE SEPARATOR SPACE TOKEN UNDEF -%type input punctuator +%type punctuator %type content FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO %type argument_list %type macro parameter_list @@ -144,7 +144,7 @@ glcpp_parser_lex (glcpp_parser_t *parser); * character between any two. */ input: /* empty */ { - $$ = SEPARATOR; + parser->just_printed_separator = 1; } | input content { int is_token; @@ -157,16 +157,18 @@ input: (c >= '0' && c <= '9') || (c == '_')); - if ($1 == TOKEN && is_not_separator) + if (! parser->just_printed_separator && is_not_separator) + { printf (" "); + } printf ("%s", $2); + if (is_not_separator) - $$ = TOKEN; + parser->just_printed_separator = 0; else - $$ = SEPARATOR; - } else { - $$ = $1; + parser->just_printed_separator = 1; } + if ($2) talloc_free ($2); } @@ -561,6 +563,8 @@ glcpp_parser_create (void) hash_table_string_compare); parser->expansions = NULL; + parser->just_printed_separator = 1; + return parser; } diff --git a/glcpp.h b/glcpp.h index 5432a318173..c25e29c6883 100644 --- a/glcpp.h +++ b/glcpp.h @@ -101,6 +101,7 @@ struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; expansion_node_t *expansions; + int just_printed_separator; }; void -- cgit v1.2.3 From 876e510bdab96574c4ca5ee94c580fe6ad7f0106 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 14:38:06 -0700 Subject: Finish cleaning up whitespace differences. The last remaining thing here was that when a line ended with a macro, and the parser looked ahead to the newline token, the lexer was printing that newline before the parser printed the expansion of the macro. The fix is simple, just make the lexer tell the parser that a newline is needed, and the parser can wait until reducing a production to print that newline. With this, we now pass the entire test suite with simply "diff -u", so we no longer have any diff options hiding whitespace bugs from us. Hurrah! --- glcpp-lex.l | 7 +------ glcpp-parse.y | 9 +++++++++ glcpp.h | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 13e4d6f0ef1..114b59f0456 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -173,12 +173,7 @@ TOKEN [^[:space:](),]+ } \n { - /* XXX: Printing here (rather than in a parser production) - * *and* frobbing a bit of the parser state here are both ugly - * things. But all my attempts to avoid this by returning a - * NEWLINE token here have led to even more ugly things. */ - printf ("\n"); - yyextra->just_printed_separator = 1; + yyextra->need_newline = 1; } {HSPACE}+ diff --git a/glcpp-parse.y b/glcpp-parse.y index 93713a3f0ca..ddc2a258cd8 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -171,6 +171,12 @@ input: if ($2) talloc_free ($2); + + if (parser->need_newline) { + printf ("\n"); + parser->just_printed_separator = 1; + parser->need_newline = 0; + } } ; @@ -564,6 +570,7 @@ glcpp_parser_create (void) parser->expansions = NULL; parser->just_printed_separator = 1; + parser->need_newline = 0; return parser; } @@ -577,6 +584,8 @@ glcpp_parser_parse (glcpp_parser_t *parser) void glcpp_parser_destroy (glcpp_parser_t *parser) { + if (parser->need_newline) + printf ("\n"); glcpp_lex_destroy (parser->scanner); hash_table_dtor (parser->defines); talloc_free (parser); diff --git a/glcpp.h b/glcpp.h index c25e29c6883..2e93cb981d8 100644 --- a/glcpp.h +++ b/glcpp.h @@ -102,6 +102,7 @@ struct glcpp_parser { struct hash_table *defines; expansion_node_t *expansions; int just_printed_separator; + int need_newline; }; void -- cgit v1.2.3 From b894583fd0246060d908a0cc7b5f3ef72a5a2112 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 15:02:03 -0700 Subject: Add xtalloc_asprintf I expect this to be useful in the upcoming implementation of token pasting. --- glcpp.h | 3 +++ xtalloc.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/glcpp.h b/glcpp.h index 2e93cb981d8..048a9be76bb 100644 --- a/glcpp.h +++ b/glcpp.h @@ -149,4 +149,7 @@ xtalloc_strdup (const void *t, const char *p); char * xtalloc_strndup (const void *t, const char *p, size_t n); +char * +xtalloc_asprintf (const void *t, const char *fmt, ...); + #endif diff --git a/xtalloc.c b/xtalloc.c index d9893ae8893..e52d12ac6b2 100644 --- a/xtalloc.c +++ b/xtalloc.c @@ -64,3 +64,21 @@ xtalloc_strndup (const void *t, const char *p, size_t n) return ret; } + +char * +xtalloc_asprintf (const void *t, const char *fmt, ...) +{ + va_list ap; + char *ret; + + va_start(ap, fmt); + + ret = talloc_vasprintf(t, fmt, ap); + if (ret == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + va_end(ap); + return ret; +} -- cgit v1.2.3 From c10a51ba13272dc48407b885d8684be99bba120d Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 15:15:26 -0700 Subject: Pre-expand macro arguments at time of invocation. Previously, we were using the same lexing stack as we use for macro expansion to also expand macro arguments. Instead, we now do this earlier by simply recursing over the macro-invocations replacement list and constructing a new expanded list, (and pushing only *that* onto the stack). This is simpler, and also allows us to more easily implement token pasting in the future. --- glcpp-lex.l | 8 ------ glcpp-parse.y | 88 +++++++++++++++++++---------------------------------------- glcpp.h | 2 -- 3 files changed, 28 insertions(+), 70 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 114b59f0456..6138a9de12e 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -138,14 +138,6 @@ TOKEN [^[:space:](),]+ switch (glcpp_parser_classify_token (yyextra, yylval.str, ¶meter_index)) { - case TOKEN_CLASS_ARGUMENT: - talloc_free (yylval.str); - /* We don't return a value here since the - * current token will be replaced by new - * tokens. */ - glcpp_parser_push_expansion_argument (yyextra, - parameter_index); - break; case TOKEN_CLASS_IDENTIFIER: return IDENTIFIER; break; diff --git a/glcpp-parse.y b/glcpp-parse.y index ddc2a258cd8..0691619acf4 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -86,11 +86,6 @@ _token_list_append (token_list_t *list, int type, const char *value); void _token_list_append_list (token_list_t *list, token_list_t *tail); -static void -glcpp_parser_push_expansion_macro (glcpp_parser_t *parser, - macro_t *macro, - argument_list_t *arguments); - static void glcpp_parser_pop_expansion (glcpp_parser_t *parser); @@ -614,24 +609,7 @@ glcpp_parser_classify_token (glcpp_parser_t *parser, { macro_t *macro; - /* First we check if we are currently expanding a - * function-like macro, and if so, whether the parameter list - * contains a parameter matching this token name. */ - if (parser->expansions && - parser->expansions->macro && - parser->expansions->macro->parameters) - { - string_list_t *list; - - list = parser->expansions->macro->parameters; - - if (_string_list_contains (list, identifier, parameter_index)) - return TOKEN_CLASS_ARGUMENT; - } - - /* If not a function-like macro parameter, we next check if - * this token is a macro itself. */ - + /* Is this token a defined macro? */ macro = hash_table_find (parser->defines, identifier); if (macro == NULL) @@ -685,47 +663,21 @@ _define_function_macro (glcpp_parser_t *parser, } static void -_glcpp_parser_push_expansion_internal (glcpp_parser_t *parser, - macro_t *macro, - argument_list_t *arguments, - token_node_t *replacements) +_glcpp_parser_push_expansion (glcpp_parser_t *parser, + macro_t *macro, + token_node_t *replacements) { expansion_node_t *node; node = xtalloc (parser, expansion_node_t); node->macro = macro; - node->arguments = arguments; node->replacements = replacements; node->next = parser->expansions; parser->expansions = node; } -static void -glcpp_parser_push_expansion_macro (glcpp_parser_t *parser, - macro_t *macro, - argument_list_t *arguments) -{ - _glcpp_parser_push_expansion_internal (parser, macro, arguments, - macro->replacements->head); -} - -void -glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, - int argument_index) -{ - argument_list_t *arguments; - token_list_t *argument; - - arguments = parser->expansions->arguments; - - argument = _argument_list_member_at (arguments, argument_index); - - _glcpp_parser_push_expansion_internal (parser, NULL, NULL, - argument->head); -} - static void glcpp_parser_pop_expansion (glcpp_parser_t *parser) { @@ -752,7 +704,7 @@ _expand_object_macro (glcpp_parser_t *parser, const char *identifier) assert (! macro->is_function); assert (! glcpp_parser_is_expanding (parser, identifier)); - glcpp_parser_push_expansion_macro (parser, macro, NULL); + _glcpp_parser_push_expansion (parser, macro, macro->replacements->head); } void @@ -761,6 +713,9 @@ _expand_function_macro (glcpp_parser_t *parser, argument_list_t *arguments) { macro_t *macro; + token_list_t *expanded; + token_node_t *i, *j; + int parameter_index; macro = hash_table_find (parser->defines, identifier); assert (macro->is_function); @@ -777,7 +732,26 @@ _expand_function_macro (glcpp_parser_t *parser, return; } - glcpp_parser_push_expansion_macro (parser, macro, arguments); + expanded = _token_list_create (macro); + + for (i = macro->replacements->head; i; i = i->next) { + if (_string_list_contains (macro->parameters, i->value, + ¶meter_index)) + { + token_list_t *argument; + argument = _argument_list_member_at (arguments, + parameter_index); + for (j = argument->head; j; j = j->next) + { + _token_list_append (expanded, j->type, + j->value); + } + } else { + _token_list_append (expanded, i->type, i->value); + } + } + + _glcpp_parser_push_expansion (parser, macro, expanded->head); } static int @@ -819,12 +793,6 @@ glcpp_parser_lex (glcpp_parser_t *parser) switch (glcpp_parser_classify_token (parser, yylval.str, ¶meter_index)) { - case TOKEN_CLASS_ARGUMENT: - talloc_free (yylval.str); - glcpp_parser_push_expansion_argument (parser, - parameter_index); - goto RECURSE; - break; case TOKEN_CLASS_IDENTIFIER: return IDENTIFIER; break; diff --git a/glcpp.h b/glcpp.h index 048a9be76bb..1537109ada6 100644 --- a/glcpp.h +++ b/glcpp.h @@ -71,7 +71,6 @@ typedef struct argument_list { typedef struct glcpp_parser glcpp_parser_t; typedef enum { - TOKEN_CLASS_ARGUMENT, TOKEN_CLASS_IDENTIFIER, TOKEN_CLASS_IDENTIFIER_FINALIZED, TOKEN_CLASS_FUNC_MACRO, @@ -92,7 +91,6 @@ typedef struct { typedef struct expansion_node { macro_t *macro; - argument_list_t *arguments; token_node_t *replacements; struct expansion_node *next; } expansion_node_t; -- cgit v1.2.3 From d8327e575dd20fe696f3a44ada4bd4001b15db27 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 15:18:54 -0700 Subject: Implement (and add test) for token pasting. This is *very* easy to implement now that macro arguments are pre-expanded. --- glcpp-parse.y | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 0691619acf4..aa758f7e439 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -760,6 +760,8 @@ glcpp_parser_lex (glcpp_parser_t *parser) expansion_node_t *expansion; token_node_t *replacements; int parameter_index; + const char *token; + token_class_t class; /* Who says C can't do efficient tail recursion? */ RECURSE: @@ -779,12 +781,31 @@ glcpp_parser_lex (glcpp_parser_t *parser) expansion->replacements = replacements->next; - if (strcmp (replacements->value, "(") == 0) + token = replacements->value; + + /* Implement token pasting. */ + if (replacements->next && strcmp (replacements->next->value, "##") == 0) { + token_node_t *next_node; + + next_node = replacements->next->next; + + if (next_node == NULL) { + fprintf (stderr, "Error: '##' cannot appear at the end of a macro expansion.\n"); + exit (1); + } + + token = xtalloc_asprintf (parser, "%s%s", + token, next_node->value); + expansion->replacements = next_node->next; + } + + + if (strcmp (token, "(") == 0) return '('; - else if (strcmp (replacements->value, ")") == 0) + else if (strcmp (token, ")") == 0) return ')'; - yylval.str = xtalloc_strdup (parser, replacements->value); + yylval.str = xtalloc_strdup (parser, token); /* Carefully refuse to expand any finalized identifier. */ if (replacements->type == IDENTIFIER_FINALIZED) -- cgit v1.2.3 From b20d33c5c6fea8e392c26e9ab060efd14034f1f9 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 20 May 2010 22:27:07 -0700 Subject: Implement #if, #else, #elif, and #endif with tests. So far the only expression implemented is a single integer literal, but obviously that's easy to extend. Various things including nesting are tested here. --- glcpp-lex.l | 32 ++++++++++++++ glcpp-parse.y | 109 ++++++++++++++++++++++++++++++++++++++++++++-- glcpp.h | 12 +++++ tests/040-token-pasting.c | 2 + tests/041-if-0.c | 5 +++ tests/042-if-1.c | 5 +++ tests/043-if-0-else.c | 7 +++ tests/044-if-1-else.c | 7 +++ tests/045-if-0-elif.c | 11 +++++ tests/046-if-1-elsif.c | 11 +++++ tests/047-if-elif-else.c | 11 +++++ tests/048-if-nested.c | 11 +++++ tests/glcpp-test | 2 +- 13 files changed, 221 insertions(+), 4 deletions(-) create mode 100644 tests/040-token-pasting.c create mode 100644 tests/041-if-0.c create mode 100644 tests/042-if-1.c create mode 100644 tests/043-if-0-else.c create mode 100644 tests/044-if-1-else.c create mode 100644 tests/045-if-0-elif.c create mode 100644 tests/046-if-1-elsif.c create mode 100644 tests/047-if-elif-else.c create mode 100644 tests/048-if-nested.c diff --git a/glcpp-lex.l b/glcpp-lex.l index 6138a9de12e..825ce3d3709 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -36,6 +36,7 @@ %x ST_DEFINE_OBJ_OR_FUNC %x ST_DEFINE_PARAMETER %x ST_DEFINE_VALUE +%x ST_IF %x ST_UNDEF %x ST_UNDEF_END @@ -44,11 +45,42 @@ NONSPACE [^[:space:]] NEWLINE [\n] HSPACE [ \t] HASH ^{HSPACE}*#{HSPACE}* +INTEGER [0-9]+ IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* TOKEN [^[:space:](),]+ %% +{HASH}if{HSPACE}* { + BEGIN ST_IF; + return IF; +} + +{HASH}elif{HSPACE}* { + BEGIN ST_IF; + return ELIF; +} + +{INTEGER} { + yylval.ival = atoi (yytext); + return INTEGER; +} + +{HSPACE}+ + +\n { + BEGIN INITIAL; + return NEWLINE; +} + +{HASH}endif{HSPACE}* { + return ENDIF; +} + +{HASH}else{HSPACE}* { + return ELSE; +} + {HASH}undef{HSPACE}* { BEGIN ST_UNDEF; return UNDEF; diff --git a/glcpp-parse.y b/glcpp-parse.y index aa758f7e439..26432f20325 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -89,6 +89,16 @@ _token_list_append_list (token_list_t *list, token_list_t *tail); static void glcpp_parser_pop_expansion (glcpp_parser_t *parser); +static void +_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition); + +static void +_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, const char *type, + int condition); + +static void +_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser); + #define yylex glcpp_parser_lex static int @@ -108,8 +118,8 @@ glcpp_parser_lex (glcpp_parser_t *parser); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token DEFINE FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO NEWLINE SEPARATOR SPACE TOKEN UNDEF -%type punctuator +%token DEFINE ELIF ELSE ENDIF FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED IF IFDEF IFNDEF INTEGER OBJ_MACRO NEWLINE SEPARATOR SPACE TOKEN UNDEF +%type expression INTEGER punctuator %type content FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO %type argument_list %type macro parameter_list @@ -143,8 +153,12 @@ input: } | input content { int is_token; + int skipping = 0; + + if (parser->skip_stack && parser->skip_stack->type != SKIP_NO_SKIP) + skipping = 1; - if ($2 && strlen ($2)) { + if ($2 && strlen ($2) && ! skipping) { int c = $2[0]; int is_not_separator = ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || @@ -301,6 +315,28 @@ directive: | DEFINE IDENTIFIER '(' parameter_list ')' replacement_list NEWLINE { _define_function_macro (parser, $2, $4, $6); } +| IF expression NEWLINE { + _glcpp_parser_skip_stack_push_if (parser, $2); + } +| IFDEF IDENTIFIER NEWLINE { + string_list_t *macro = hash_table_find (parser->defines, $2); + talloc_free ($2); + _glcpp_parser_skip_stack_push_if (parser, macro != NULL); + } +| IFNDEF IDENTIFIER NEWLINE { + string_list_t *macro = hash_table_find (parser->defines, $2); + talloc_free ($2); + _glcpp_parser_skip_stack_push_if (parser, macro == NULL); + } +| ELIF expression NEWLINE { + _glcpp_parser_skip_stack_change_if (parser, "#elif", $2); + } +| ELSE { + _glcpp_parser_skip_stack_change_if (parser, "else", 1); + } +| ENDIF { + _glcpp_parser_skip_stack_pop (parser); + } | UNDEF IDENTIFIER { string_list_t *macro = hash_table_find (parser->defines, $2); if (macro) { @@ -314,6 +350,13 @@ directive: } ; +/* XXX: Need to fill out with all operators. */ +expression: + INTEGER { + $$ = $1; + } +; + parameter_list: /* empty */ { $$ = _string_list_create (parser); @@ -567,6 +610,8 @@ glcpp_parser_create (void) parser->just_printed_separator = 1; parser->need_newline = 0; + parser->skip_stack = NULL; + return parser; } @@ -581,6 +626,8 @@ glcpp_parser_destroy (glcpp_parser_t *parser) { if (parser->need_newline) printf ("\n"); + if (parser->skip_stack) + fprintf (stderr, "Error: Unterminated #if\n"); glcpp_lex_destroy (parser->scanner); hash_table_dtor (parser->defines); talloc_free (parser); @@ -829,3 +876,59 @@ glcpp_parser_lex (glcpp_parser_t *parser) break; } } + +static void +_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition) +{ + skip_type_t current = SKIP_NO_SKIP; + skip_node_t *node; + + if (parser->skip_stack) + current = parser->skip_stack->type; + + node = xtalloc (parser, skip_node_t); + + if (current == SKIP_NO_SKIP) { + if (condition) + node->type = SKIP_NO_SKIP; + else + node->type = SKIP_TO_ELSE; + } else { + node->type = SKIP_TO_ENDIF; + } + + node->next = parser->skip_stack; + parser->skip_stack = node; +} + +static void +_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, const char *type, + int condition) +{ + if (parser->skip_stack == NULL) { + fprintf (stderr, "Error: %s without #if\n", type); + exit (1); + } + + if (parser->skip_stack->type == SKIP_TO_ELSE) { + if (condition) + parser->skip_stack->type = SKIP_NO_SKIP; + } else { + parser->skip_stack->type = SKIP_TO_ENDIF; + } +} + +static void +_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser) +{ + skip_node_t *node; + + if (parser->skip_stack == NULL) { + fprintf (stderr, "Error: #endif without #if\n"); + exit (1); + } + + node = parser->skip_stack; + parser->skip_stack = node->next; + talloc_free (node); +} diff --git a/glcpp.h b/glcpp.h index 1537109ada6..33ece8f92b1 100644 --- a/glcpp.h +++ b/glcpp.h @@ -95,12 +95,24 @@ typedef struct expansion_node { struct expansion_node *next; } expansion_node_t; +typedef enum skip_type { + SKIP_NO_SKIP, + SKIP_TO_ELSE, + SKIP_TO_ENDIF +} skip_type_t; + +typedef struct skip_node { + skip_type_t type; + struct skip_node *next; +} skip_node_t; + struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; expansion_node_t *expansions; int just_printed_separator; int need_newline; + skip_node_t *skip_stack; }; void diff --git a/tests/040-token-pasting.c b/tests/040-token-pasting.c new file mode 100644 index 00000000000..caab3ba7368 --- /dev/null +++ b/tests/040-token-pasting.c @@ -0,0 +1,2 @@ +#define paste(a,b) a ## b +paste(one , token) diff --git a/tests/041-if-0.c b/tests/041-if-0.c new file mode 100644 index 00000000000..2cab677d3e8 --- /dev/null +++ b/tests/041-if-0.c @@ -0,0 +1,5 @@ +success_1 +#if 0 +failure +#endif +success_2 diff --git a/tests/042-if-1.c b/tests/042-if-1.c new file mode 100644 index 00000000000..874a25cf41b --- /dev/null +++ b/tests/042-if-1.c @@ -0,0 +1,5 @@ +success_1 +#if 1 +success_2 +#endif +success_3 diff --git a/tests/043-if-0-else.c b/tests/043-if-0-else.c new file mode 100644 index 00000000000..323351f9dbf --- /dev/null +++ b/tests/043-if-0-else.c @@ -0,0 +1,7 @@ +success_1 +#if 0 +failure +#else +success_2 +#endif +success_3 diff --git a/tests/044-if-1-else.c b/tests/044-if-1-else.c new file mode 100644 index 00000000000..28dfc25c6f0 --- /dev/null +++ b/tests/044-if-1-else.c @@ -0,0 +1,7 @@ +success_1 +#if 1 +success_2 +#else +failure +#endif +success_3 diff --git a/tests/045-if-0-elif.c b/tests/045-if-0-elif.c new file mode 100644 index 00000000000..e50f686d461 --- /dev/null +++ b/tests/045-if-0-elif.c @@ -0,0 +1,11 @@ +success_1 +#if 0 +failure_1 +#elif 0 +failure_2 +#elif 1 +success_3 +#elif 1 +failure_3 +#endif +success_4 diff --git a/tests/046-if-1-elsif.c b/tests/046-if-1-elsif.c new file mode 100644 index 00000000000..130515a01ea --- /dev/null +++ b/tests/046-if-1-elsif.c @@ -0,0 +1,11 @@ +success_1 +#if 1 +success_2 +#elif 0 +failure_1 +#elif 1 +failure_2 +#elif 0 +failure_3 +#endif +success_3 diff --git a/tests/047-if-elif-else.c b/tests/047-if-elif-else.c new file mode 100644 index 00000000000..e8f0838a9ed --- /dev/null +++ b/tests/047-if-elif-else.c @@ -0,0 +1,11 @@ +success_1 +#if 0 +failure_1 +#elif 0 +failure_2 +#elif 0 +failure_3 +#else +success_2 +#endif +success_3 diff --git a/tests/048-if-nested.c b/tests/048-if-nested.c new file mode 100644 index 00000000000..fc4679c3be4 --- /dev/null +++ b/tests/048-if-nested.c @@ -0,0 +1,11 @@ +success_1 +#if 0 +failure_1 +#if 1 +failure_2 +#else +failure_3 +#endif +failure_4 +#endif +success_2 diff --git a/tests/glcpp-test b/tests/glcpp-test index 25685eeabe5..022a2367121 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -5,5 +5,5 @@ for test in *.c; do ../glcpp < $test > $test.out gcc -E $test -o $test.gcc grep -v '^#' < $test.gcc > $test.expected - diff -u $test.expected $test.out + diff -B -u $test.expected $test.out done -- cgit v1.2.3 From bcbd587b0f5312d85307785ee2df6e5906af4f7b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 24 May 2010 10:37:38 -0700 Subject: Implement all operators specified for GLSL #if expressions (with tests). The operator coverage here is quite complete. The one big thing missing is that we are not yet doing macro expansion in #if lines. This makes the whole support fairly useless, so we plan to fix that shortcoming right away. --- glcpp-lex.l | 45 +++++++++++++++++ glcpp-parse.y | 97 +++++++++++++++++++++++++++++++++--- tests/049-if-expression-precedence.c | 6 +++ tests/050-if-defined.c | 19 +++++++ tests/051-if-relational.c | 35 +++++++++++++ 5 files changed, 195 insertions(+), 7 deletions(-) create mode 100644 tests/049-if-expression-precedence.c create mode 100644 tests/050-if-defined.c create mode 100644 tests/051-if-relational.c diff --git a/glcpp-lex.l b/glcpp-lex.l index 825ce3d3709..84166fb76fc 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -66,6 +66,51 @@ TOKEN [^[:space:](),]+ return INTEGER; } +"defined" { + return DEFINED; +} + +"<<" { + return LEFT_SHIFT; +} + +">>" { + return RIGHT_SHIFT; +} + +"<=" { + return LESS_OR_EQUAL; +} + +">=" { + return GREATER_OR_EQUAL; +} + +"==" { + return EQUAL; +} + +"!=" { + return NOT_EQUAL; +} + +"&&" { + return AND; +} + +"||" { + return OR; +} + +[-+*/%<>&^|()] { + return yytext[0]; +} + +{IDENTIFIER} { + yylval.str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; +} + {HSPACE}+ \n { diff --git a/glcpp-parse.y b/glcpp-parse.y index 26432f20325..0d3afa7af64 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -118,13 +118,24 @@ glcpp_parser_lex (glcpp_parser_t *parser); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token DEFINE ELIF ELSE ENDIF FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED IF IFDEF IFNDEF INTEGER OBJ_MACRO NEWLINE SEPARATOR SPACE TOKEN UNDEF +%token DEFINE DEFINED ELIF ELSE ENDIF FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED IF IFDEF IFNDEF INTEGER OBJ_MACRO NEWLINE SPACE TOKEN UNDEF %type expression INTEGER punctuator %type content FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO %type argument_list %type macro parameter_list %type TOKEN argument_word argument_word_or_comma %type argument argument_or_comma replacement_list pp_tokens +%left OR +%left AND +%left '|' +%left '^' +%left '&' +%left EQUAL NOT_EQUAL +%left '<' '>' LESS_OR_EQUAL GREATER_OR_EQUAL +%left LEFT_SHIFT RIGHT_SHIFT +%left '+' '-' +%left '*' '/' '%' +%right UNARY /* Hard to remove shift/reduce conflicts documented as follows: * @@ -142,11 +153,7 @@ glcpp_parser_lex (glcpp_parser_t *parser); %% - /* We do all printing at the input level. - * - * The value for "input" is simply TOKEN or SEPARATOR so we - * can decide whether it's necessary to print a space - * character between any two. */ + /* We do all printing at the input level. */ input: /* empty */ { parser->just_printed_separator = 1; @@ -350,11 +357,87 @@ directive: } ; -/* XXX: Need to fill out with all operators. */ expression: INTEGER { $$ = $1; } +| expression OR expression { + $$ = $1 || $3; + } +| expression AND expression { + $$ = $1 && $3; + } +| expression '|' expression { + $$ = $1 | $3; + } +| expression '^' expression { + $$ = $1 ^ $3; + } +| expression '&' expression { + $$ = $1 & $3; + } +| expression NOT_EQUAL expression { + $$ = $1 != $3; + } +| expression EQUAL expression { + $$ = $1 == $3; + } +| expression GREATER_OR_EQUAL expression { + $$ = $1 >= $3; + } +| expression LESS_OR_EQUAL expression { + $$ = $1 <= $3; + } +| expression '>' expression { + $$ = $1 > $3; + } +| expression '<' expression { + $$ = $1 < $3; + } +| expression RIGHT_SHIFT expression { + $$ = $1 >> $3; + } +| expression LEFT_SHIFT expression { + $$ = $1 << $3; + } +| expression '-' expression { + $$ = $1 - $3; + } +| expression '+' expression { + $$ = $1 + $3; + } +| expression '%' expression { + $$ = $1 % $3; + } +| expression '/' expression { + $$ = $1 / $3; + } +| expression '*' expression { + $$ = $1 * $3; + } +| '!' expression %prec UNARY { + $$ = ! $2; + } +| '~' expression %prec UNARY { + $$ = ~ $2; + } +| '-' expression %prec UNARY { + $$ = - $2; + } +| '+' expression %prec UNARY { + $$ = + $2; + } +| DEFINED IDENTIFIER %prec UNARY { + string_list_t *macro = hash_table_find (parser->defines, $2); + talloc_free ($2); + if (macro) + $$ = 1; + else + $$ = 0; + } +| '(' expression ')' { + $$ = $2; + } ; parameter_list: diff --git a/tests/049-if-expression-precedence.c b/tests/049-if-expression-precedence.c new file mode 100644 index 00000000000..cea935220fd --- /dev/null +++ b/tests/049-if-expression-precedence.c @@ -0,0 +1,6 @@ +#if 1 + 2 * 3 + - (25 % 17 - + 1) +failure with operator precedence +#else +success +#endif + diff --git a/tests/050-if-defined.c b/tests/050-if-defined.c new file mode 100644 index 00000000000..9838cc747d5 --- /dev/null +++ b/tests/050-if-defined.c @@ -0,0 +1,19 @@ +#if defined foo +failure_1 +#else +success_1 +#endif +#define foo +#if defined foo +success_2 +#else +failure_2 +#endif +#undef foo +#if defined foo +failure_3 +#else +success_3 +#endif + + diff --git a/tests/051-if-relational.c b/tests/051-if-relational.c new file mode 100644 index 00000000000..c3db488e0de --- /dev/null +++ b/tests/051-if-relational.c @@ -0,0 +1,35 @@ +#if 3 < 2 +failure_1 +#else +success_1 +#endif + +#if 3 >= 2 +success_2 +#else +failure_2 +#endif + +#if 2 + 3 <= 5 +success_3 +#else +failure_3 +#endif + +#if 3 - 2 == 1 +success_3 +#else +failure_3 +#endif + +#if 1 > 3 +failure_4 +#else +success_4 +#endif + +#if 1 != 5 +success_5 +#else +failure_5 +#endif -- cgit v1.2.3 From 89b933a24375a2ebed383290f24360a14edbac6b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 24 May 2010 11:26:42 -0700 Subject: Add the '~' operator to the lexer. This was simply missing before, (and unnoticed since we had no test of the '~' operator). --- glcpp-lex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 84166fb76fc..fe95508a321 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -102,7 +102,7 @@ TOKEN [^[:space:](),]+ return OR; } -[-+*/%<>&^|()] { +[-+*/%<>&^|()~] { return yytext[0]; } -- cgit v1.2.3 From 35419095f8d92f7dc5de472da3a0271d343cbcba Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 24 May 2010 11:27:23 -0700 Subject: Switch to intmax_t (rather than int) for #if expressions This is what the C99 specification demands. And the GLSL specification says that we should follow the "standard C++" rules for #if condition expressions rather than the GLSL rules, (which only support a 32-bit integer). --- glcpp-parse.y | 4 +++- glcpp.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 0d3afa7af64..2c0fe9a6af9 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -107,6 +107,7 @@ glcpp_parser_lex (glcpp_parser_t *parser); %} %union { + intmax_t imaxval; int ival; char *str; argument_list_t *argument_list; @@ -119,7 +120,8 @@ glcpp_parser_lex (glcpp_parser_t *parser); %lex-param {glcpp_parser_t *parser} %token DEFINE DEFINED ELIF ELSE ENDIF FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED IF IFDEF IFNDEF INTEGER OBJ_MACRO NEWLINE SPACE TOKEN UNDEF -%type expression INTEGER punctuator +%type punctuator +%type expression INTEGER %type content FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO %type argument_list %type macro parameter_list diff --git a/glcpp.h b/glcpp.h index 33ece8f92b1..503731b85b3 100644 --- a/glcpp.h +++ b/glcpp.h @@ -24,6 +24,8 @@ #ifndef GLCPP_H #define GLCPP_H +#include + #include #include "hash_table.h" -- cgit v1.2.3 From 03f6d5d2d4a6c42a197ee8eb4e26b87c87bbe43e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 24 May 2010 11:29:02 -0700 Subject: Add support for octal and hexadecimal integer literals. In addition to the decimal literals which we already support. Note that we use strtoll here to get the large-width integers demanded by the specification. --- glcpp-lex.l | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index fe95508a321..ee1f6e3aeea 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -45,10 +45,13 @@ NONSPACE [^[:space:]] NEWLINE [\n] HSPACE [ \t] HASH ^{HSPACE}*#{HSPACE}* -INTEGER [0-9]+ IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* TOKEN [^[:space:](),]+ +DECIMAL_INTEGER [1-9][0-9]*[uU]? +OCTAL_INTEGER 0[0-7]*[uU]? +HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? + %% {HASH}if{HSPACE}* { @@ -61,8 +64,18 @@ TOKEN [^[:space:](),]+ return ELIF; } -{INTEGER} { - yylval.ival = atoi (yytext); +{DECIMAL_INTEGER} { + yylval.ival = strtoll (yytext, NULL, 10); + return INTEGER; +} + +{OCTAL_INTEGER} { + yylval.ival = strtoll (yytext + 1, NULL, 8); + return INTEGER; +} + +{HEXADECIMAL_INTEGER} { + yylval.ival = strtoll (yytext + 2, NULL, 16); return INTEGER; } -- cgit v1.2.3 From bb9315f8047770585391c56973ef26c30f74d603 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 24 May 2010 11:30:06 -0700 Subject: Add test of bitwise operators and octal/hexadecimal literals. This new test covers several features from the last few commits. This test passes already. --- tests/052-if-bitwise.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/052-if-bitwise.c diff --git a/tests/052-if-bitwise.c b/tests/052-if-bitwise.c new file mode 100644 index 00000000000..2d8e45eb61e --- /dev/null +++ b/tests/052-if-bitwise.c @@ -0,0 +1,20 @@ +#if (0xaaaaaaaa | 0x55555555) != 4294967295 +failure_1 +#else +success_1 +#endif +#if (0x12345678 ^ 0xfdecba98) == 4023971040 +success_2 +#else +failure_2 +#endif +#if (~ 0xdeadbeef) != -3735928560 +failure_3 +#else +success_3 +#endif +#if (0667 & 0733) == 403 +success_4 +#else +failure_4 +#endif -- cgit v1.2.3 From 00f1ec421edf73516fdcfbbdb651f13eeefe8f08 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 24 May 2010 11:33:28 -0700 Subject: Add test for '/', '<<', and '>>' in #if expressions. These operators have been supported already, but were not covered in existing tests yet. So this test passes already. --- tests/053-if-divide-and-shift.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/053-if-divide-and-shift.c diff --git a/tests/053-if-divide-and-shift.c b/tests/053-if-divide-and-shift.c new file mode 100644 index 00000000000..ddc1573ab26 --- /dev/null +++ b/tests/053-if-divide-and-shift.c @@ -0,0 +1,16 @@ +#if (15 / 2) != 7 +failure_1 +#else +success_1 +#endif +#if (1 << 12) == 4096 +success_2 +#else +failure_2 +#endif +#if (31762 >> 8) != 124 +failure_3 +#else +success_3 +#endif + -- cgit v1.2.3 From 3ff81670848abb29b92e78f45080ad36cc85001c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 13:09:03 -0700 Subject: Starting over with the C99 grammar for the preprocessor. This is a fresh start with a much simpler approach for the flex/bison portions of the preprocessor. This isn't functional yet, (produces no output), but can at least read all of our test cases without any parse errors. The grammar here is based on the grammar provided for the preprocessor in the C99 specification. --- glcpp-lex.l | 197 ++++----------------------- glcpp-parse.y | 401 +++++++++---------------------------------------------- tests/glcpp-test | 5 +- 3 files changed, 98 insertions(+), 505 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index ee1f6e3aeea..f1dd11ea9bd 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -32,21 +32,14 @@ %option reentrant noyywrap %option extra-type="glcpp_parser_t *" -%x ST_DEFINE -%x ST_DEFINE_OBJ_OR_FUNC -%x ST_DEFINE_PARAMETER -%x ST_DEFINE_VALUE -%x ST_IF -%x ST_UNDEF -%x ST_UNDEF_END - SPACE [[:space:]] NONSPACE [^[:space:]] NEWLINE [\n] HSPACE [ \t] HASH ^{HSPACE}*#{HSPACE}* IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* -TOKEN [^[:space:](),]+ +PUNCTUATION [][(){}.&*~!/%<>^|;,+-] +OTHER [^][(){}.&*~!/%<>^|;,=#[:space:]+-]+ DECIMAL_INTEGER [1-9][0-9]*[uU]? OCTAL_INTEGER 0[0-7]*[uU]? @@ -54,208 +47,74 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? %% -{HASH}if{HSPACE}* { - BEGIN ST_IF; - return IF; -} - -{HASH}elif{HSPACE}* { - BEGIN ST_IF; - return ELIF; +{HASH}define{HSPACE}+/{IDENTIFIER}"(" { + return HASH_DEFINE_FUNC; } -{DECIMAL_INTEGER} { - yylval.ival = strtoll (yytext, NULL, 10); - return INTEGER; +{HASH}define { + return HASH_DEFINE_OBJ; } -{OCTAL_INTEGER} { - yylval.ival = strtoll (yytext + 1, NULL, 8); - return INTEGER; +{HASH}undef { + return HASH_UNDEF; } -{HEXADECIMAL_INTEGER} { - yylval.ival = strtoll (yytext + 2, NULL, 16); - return INTEGER; +{HASH} { + return HASH; } -"defined" { - return DEFINED; +{IDENTIFIER} { + yylval.str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; } -"<<" { +"<<" { return LEFT_SHIFT; } -">>" { +">>" { return RIGHT_SHIFT; } -"<=" { +"<=" { return LESS_OR_EQUAL; } -">=" { +">=" { return GREATER_OR_EQUAL; } -"==" { +"==" { return EQUAL; } -"!=" { +"!=" { return NOT_EQUAL; } -"&&" { +"&&" { return AND; } -"||" { +"||" { return OR; } -[-+*/%<>&^|()~] { - return yytext[0]; -} - -{IDENTIFIER} { - yylval.str = xtalloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - -{HSPACE}+ - -\n { - BEGIN INITIAL; - return NEWLINE; -} - -{HASH}endif{HSPACE}* { - return ENDIF; +"##" { + return PASTE; } -{HASH}else{HSPACE}* { - return ELSE; -} - -{HASH}undef{HSPACE}* { - BEGIN ST_UNDEF; - return UNDEF; -} - -{IDENTIFIER} { - BEGIN ST_UNDEF_END; - yylval.str = xtalloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - -{HSPACE}* - -\n { - BEGIN INITIAL; -} - - /* We use the ST_DEFINE and ST_DEFVAL states so that we can - * pass a space token, (yes, a token for whitespace!), since - * the preprocessor specification requires distinguishing - * "#define foo()" from "#define foo ()". - */ -{HASH}define{HSPACE}* { - BEGIN ST_DEFINE; - return DEFINE; -} - -{IDENTIFIER} { - BEGIN ST_DEFINE_OBJ_OR_FUNC; - yylval.str = xtalloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - -\n { - BEGIN INITIAL; - return NEWLINE; -} - -{HSPACE}+ { - BEGIN ST_DEFINE_VALUE; - return SPACE; -} - -"(" { - BEGIN ST_DEFINE_PARAMETER; - return '('; -} - -{IDENTIFIER} { - yylval.str = xtalloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - -"," { - return ','; -} - -")" { - BEGIN ST_DEFINE_VALUE; - return ')'; -} - -{HSPACE}+ - -{TOKEN} { - yylval.token.type = TOKEN; - yylval.token.value = xtalloc_strdup (yyextra, yytext); - return TOKEN; -} - -[(),] { - yylval.token.type = TOKEN; - yylval.token.value = xtalloc_strdup (yyextra, yytext); - return TOKEN; +{PUNCTUATION} { + return yytext[0]; } -{HSPACE}+ - -\n { - BEGIN INITIAL; +\n { return NEWLINE; } -{IDENTIFIER} { - int parameter_index; +{OTHER} { yylval.str = xtalloc_strdup (yyextra, yytext); - switch (glcpp_parser_classify_token (yyextra, yylval.str, - ¶meter_index)) - { - case TOKEN_CLASS_IDENTIFIER: - return IDENTIFIER; - break; - case TOKEN_CLASS_IDENTIFIER_FINALIZED: - return IDENTIFIER_FINALIZED; - break; - case TOKEN_CLASS_FUNC_MACRO: - return FUNC_MACRO; - break; - case TOKEN_CLASS_OBJ_MACRO: - return OBJ_MACRO; - break; - - } -} - -[(),] { - return yytext[0]; -} - -{TOKEN} { - yylval.token.type = TOKEN; - yylval.token.value = xtalloc_strdup (yyextra, yytext); - return TOKEN; -} - -\n { - yyextra->need_newline = 1; + return OTHER; } {HSPACE}+ diff --git a/glcpp-parse.y b/glcpp-parse.y index 2c0fe9a6af9..ebb28ed1965 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -119,366 +119,97 @@ glcpp_parser_lex (glcpp_parser_t *parser); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token DEFINE DEFINED ELIF ELSE ENDIF FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED IF IFDEF IFNDEF INTEGER OBJ_MACRO NEWLINE SPACE TOKEN UNDEF -%type punctuator -%type expression INTEGER -%type content FUNC_MACRO IDENTIFIER IDENTIFIER_FINALIZED OBJ_MACRO -%type argument_list -%type macro parameter_list -%type TOKEN argument_word argument_word_or_comma -%type argument argument_or_comma replacement_list pp_tokens -%left OR -%left AND -%left '|' -%left '^' -%left '&' -%left EQUAL NOT_EQUAL -%left '<' '>' LESS_OR_EQUAL GREATER_OR_EQUAL -%left LEFT_SHIFT RIGHT_SHIFT -%left '+' '-' -%left '*' '/' '%' -%right UNARY - -/* Hard to remove shift/reduce conflicts documented as follows: - * - * 1. '(' after FUNC_MACRO name which is correctly resolved to shift - * to form macro invocation rather than reducing directly to - * content. - * - * 2. Similarly, '(' after FUNC_MACRO which is correctly resolved to - * shift to form macro invocation rather than reducing directly to - * argument. - * - * 3. Similarly again now that we added argument_or_comma as well. - */ -%expect 3 +%token HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH IDENTIFIER NEWLINE OTHER HASH_UNDEF +%token LEFT_SHIFT RIGHT_SHIFT LESS_OR_EQUAL GREATER_OR_EQUAL EQUAL NOT_EQUAL AND OR PASTE + + /* Stale stuff just to allow code to compile. */ +%token IDENTIFIER_FINALIZED FUNC_MACRO OBJ_MACRO %% - /* We do all printing at the input level. */ input: - /* empty */ { - parser->just_printed_separator = 1; - } -| input content { - int is_token; - int skipping = 0; - - if (parser->skip_stack && parser->skip_stack->type != SKIP_NO_SKIP) - skipping = 1; - - if ($2 && strlen ($2) && ! skipping) { - int c = $2[0]; - int is_not_separator = ((c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9') || - (c == '_')); - - if (! parser->just_printed_separator && is_not_separator) - { - printf (" "); - } - printf ("%s", $2); - - if (is_not_separator) - parser->just_printed_separator = 0; - else - parser->just_printed_separator = 1; - } - - if ($2) - talloc_free ($2); - - if (parser->need_newline) { - printf ("\n"); - parser->just_printed_separator = 1; - parser->need_newline = 0; - } - } -; - -content: - IDENTIFIER { - $$ = $1; - } -| IDENTIFIER_FINALIZED { - $$ = $1; - } -| TOKEN { - $$ = $1.value; - } -| FUNC_MACRO { - $$ = $1; - } -| directive { - $$ = talloc_strdup (parser, "\n"); - } -| punctuator { - $$ = talloc_asprintf (parser, "%c", $1); - } -| macro { - $$ = NULL; - } + /* empty */ +| input line ; -punctuator: - '(' { $$ = '('; } -| ')' { $$ = ')'; } -| ',' { $$ = ','; } - ; - -macro: - FUNC_MACRO '(' argument_list ')' { - _expand_function_macro (parser, $1, $3); - } -| OBJ_MACRO { - _expand_object_macro (parser, $1); - talloc_free ($1); - } +line: + control_line +| text_line +| HASH non_directive ; -argument_list: - /* empty */ { - $$ = _argument_list_create (parser); - } -| argument { - $$ = _argument_list_create (parser); - _argument_list_append ($$, $1); - } -| argument_list ',' argument { - _argument_list_append ($1, $3); - $$ = $1; - } -; - -argument: - argument_word { - $$ = _token_list_create (parser); - _token_list_append ($$, $1.type, $1.value); - } -| argument argument_word { - _token_list_append ($1, $2.type, $2.value); - talloc_free ($2.value); - $$ = $1; - } -| argument '(' argument_or_comma ')' { - _token_list_append ($1, '(', "("); - _token_list_append_list ($1, $3); - _token_list_append ($1, ')', ")"); - $$ = $1; - } +control_line: + HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE +| HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE +| HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE +| HASH_UNDEF IDENTIFIER NEWLINE +| HASH NEWLINE ; -argument_word: - IDENTIFIER { $$.type = IDENTIFIER; $$.value = $1; } -| IDENTIFIER_FINALIZED { $$.type = IDENTIFIER_FINALIZED; $$.value = $1; } -| TOKEN { $$ = $1; } -| FUNC_MACRO { $$.type = FUNC_MACRO; $$.value = $1; } -| macro { $$.type = TOKEN; $$.value = xtalloc_strdup (parser, ""); } +identifier_list: + IDENTIFIER +| identifier_list ',' IDENTIFIER ; - /* XXX: The body of argument_or_comma is the same as the body - * of argument, but with "argument" and "argument_word" - * changed to "argument_or_comma" and - * "argument_word_or_comma". It would be nice to have less - * redundancy here, but I'm not sure how. - * - * It would also be nice to have a less ugly grammar to have - * to implement, but such is the C preprocessor. - */ -argument_or_comma: - argument_word_or_comma { - $$ = _token_list_create (parser); - _token_list_append ($$, $1.type, $1.value); - } -| argument_or_comma argument_word_or_comma { - _token_list_append ($1, $2.type, $2.value); - $$ = $1; - } -| argument_or_comma '(' argument_or_comma ')' { - _token_list_append ($1, '(', "("); - _token_list_append_list ($1, $3); - _token_list_append ($1, ')', ")"); - $$ = $1; - } +text_line: + NEWLINE +| pp_tokens NEWLINE ; -argument_word_or_comma: - IDENTIFIER { $$.type = IDENTIFIER; $$.value = $1; } -| IDENTIFIER_FINALIZED { $$.type = IDENTIFIER_FINALIZED; $$.value = $1; } -| TOKEN { $$ = $1; } -| FUNC_MACRO { $$.type = FUNC_MACRO; $$.value = $1; } -| macro { $$.type = TOKEN; $$.value = xtalloc_strdup (parser, ""); } -| ',' { $$.type = ','; $$.value = xtalloc_strdup (parser, ","); } +non_directive: + pp_tokens NEWLINE ; -directive: - DEFINE IDENTIFIER NEWLINE { - token_list_t *list = _token_list_create (parser); - _define_object_macro (parser, $2, list); - } -| DEFINE IDENTIFIER SPACE replacement_list NEWLINE { - _define_object_macro (parser, $2, $4); - } -| DEFINE IDENTIFIER '(' parameter_list ')' replacement_list NEWLINE { - _define_function_macro (parser, $2, $4, $6); - } -| IF expression NEWLINE { - _glcpp_parser_skip_stack_push_if (parser, $2); - } -| IFDEF IDENTIFIER NEWLINE { - string_list_t *macro = hash_table_find (parser->defines, $2); - talloc_free ($2); - _glcpp_parser_skip_stack_push_if (parser, macro != NULL); - } -| IFNDEF IDENTIFIER NEWLINE { - string_list_t *macro = hash_table_find (parser->defines, $2); - talloc_free ($2); - _glcpp_parser_skip_stack_push_if (parser, macro == NULL); - } -| ELIF expression NEWLINE { - _glcpp_parser_skip_stack_change_if (parser, "#elif", $2); - } -| ELSE { - _glcpp_parser_skip_stack_change_if (parser, "else", 1); - } -| ENDIF { - _glcpp_parser_skip_stack_pop (parser); - } -| UNDEF IDENTIFIER { - string_list_t *macro = hash_table_find (parser->defines, $2); - if (macro) { - /* XXX: Need hash table to support a real way - * to remove an element rather than prefixing - * a new node with data of NULL like this. */ - hash_table_insert (parser->defines, NULL, $2); - talloc_free (macro); - } - talloc_free ($2); - } +replacement_list: + /* empty */ +| pp_tokens ; -expression: - INTEGER { - $$ = $1; - } -| expression OR expression { - $$ = $1 || $3; - } -| expression AND expression { - $$ = $1 && $3; - } -| expression '|' expression { - $$ = $1 | $3; - } -| expression '^' expression { - $$ = $1 ^ $3; - } -| expression '&' expression { - $$ = $1 & $3; - } -| expression NOT_EQUAL expression { - $$ = $1 != $3; - } -| expression EQUAL expression { - $$ = $1 == $3; - } -| expression GREATER_OR_EQUAL expression { - $$ = $1 >= $3; - } -| expression LESS_OR_EQUAL expression { - $$ = $1 <= $3; - } -| expression '>' expression { - $$ = $1 > $3; - } -| expression '<' expression { - $$ = $1 < $3; - } -| expression RIGHT_SHIFT expression { - $$ = $1 >> $3; - } -| expression LEFT_SHIFT expression { - $$ = $1 << $3; - } -| expression '-' expression { - $$ = $1 - $3; - } -| expression '+' expression { - $$ = $1 + $3; - } -| expression '%' expression { - $$ = $1 % $3; - } -| expression '/' expression { - $$ = $1 / $3; - } -| expression '*' expression { - $$ = $1 * $3; - } -| '!' expression %prec UNARY { - $$ = ! $2; - } -| '~' expression %prec UNARY { - $$ = ~ $2; - } -| '-' expression %prec UNARY { - $$ = - $2; - } -| '+' expression %prec UNARY { - $$ = + $2; - } -| DEFINED IDENTIFIER %prec UNARY { - string_list_t *macro = hash_table_find (parser->defines, $2); - talloc_free ($2); - if (macro) - $$ = 1; - else - $$ = 0; - } -| '(' expression ')' { - $$ = $2; - } +pp_tokens: + preprocessing_token +| pp_tokens preprocessing_token ; -parameter_list: - /* empty */ { - $$ = _string_list_create (parser); - } -| IDENTIFIER { - $$ = _string_list_create (parser); - _string_list_append_item ($$, $1); - talloc_free ($1); - } -| parameter_list ',' IDENTIFIER { - _string_list_append_item ($1, $3); - talloc_free ($3); - $$ = $1; - } +preprocessing_token: + IDENTIFIER +| punctuator +| OTHER ; -replacement_list: - /* empty */ { - $$ = _token_list_create (parser); - } -| pp_tokens { - $$ = $1; - } +punctuator: + '[' +| ']' +| '(' +| ')' +| '{' +| '}' +| '.' +| '&' +| '*' +| '+' +| '-' +| '~' +| '!' +| '/' +| '%' +| LEFT_SHIFT +| RIGHT_SHIFT +| '<' +| '>' +| LESS_OR_EQUAL +| GREATER_OR_EQUAL +| EQUAL +| NOT_EQUAL +| '^' +| '|' +| AND +| OR +| ';' +| ',' +| PASTE ; -pp_tokens: - TOKEN { - $$ = _token_list_create (parser); - _token_list_append ($$, $1.type, $1.value); - } -| pp_tokens TOKEN { - _token_list_append ($1, $2.type, $2.value); - $$ = $1; - } -; - %% string_list_t * diff --git a/tests/glcpp-test b/tests/glcpp-test index 022a2367121..868b03cce83 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -1,9 +1,12 @@ #!/bin/sh +set -e + +echo "Caution: These results are just verifying parse-ability, not correctness!" for test in *.c; do echo "Testing $test" ../glcpp < $test > $test.out gcc -E $test -o $test.gcc grep -v '^#' < $test.gcc > $test.expected - diff -B -u $test.expected $test.out +# diff -B -u $test.expected $test.out done -- cgit v1.2.3 From 9bb796f33ac67abdf6c0bf55a06b0d8448caa3d3 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 14:40:47 -0700 Subject: Add xtalloc_reference. Yet another talloc wrapper that should come in handy. --- glcpp.h | 6 ++++++ xtalloc.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/glcpp.h b/glcpp.h index 503731b85b3..6171ce8b4a0 100644 --- a/glcpp.h +++ b/glcpp.h @@ -164,4 +164,10 @@ xtalloc_strndup (const void *t, const char *p, size_t n); char * xtalloc_asprintf (const void *t, const char *fmt, ...); +void * +_xtalloc_reference_loc (const void *context, + const void *ptr, const char *location); + +#define xtalloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_xtalloc_reference_loc((ctx),(ptr), __location__) + #endif diff --git a/xtalloc.c b/xtalloc.c index e52d12ac6b2..656ac2d6cb5 100644 --- a/xtalloc.c +++ b/xtalloc.c @@ -82,3 +82,18 @@ xtalloc_asprintf (const void *t, const char *fmt, ...) va_end(ap); return ret; } + +void * +_xtalloc_reference_loc (const void *context, + const void *ptr, const char *location) +{ + void *ret; + + ret = _talloc_reference_loc (context, ptr, location); + if (ret == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + return ret; +} -- cgit v1.2.3 From 80dc60b9c3529cf438948d50b9619e8af2fad880 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 14:42:00 -0700 Subject: Delete some trailing whitespace. This pernicious stuff managed to sneak in on us. --- glcpp-parse.y | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index ebb28ed1965..c53370a89ad 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -95,7 +95,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition); static void _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, const char *type, int condition); - + static void _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser); @@ -243,7 +243,7 @@ _string_list_append_item (string_list_t *list, const char *str) node = xtalloc (list, string_node_t); node->str = xtalloc_strdup (node, str); - + node->next = NULL; if (list->head == NULL) { @@ -404,7 +404,7 @@ _token_list_append_list (token_list_t *list, token_list_t *tail) list->tail = tail->tail; } - + void yyerror (void *scanner, const char *error) { @@ -733,7 +733,7 @@ _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, const char *type, parser->skip_stack->type = SKIP_TO_ENDIF; } } - + static void _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser) { -- cgit v1.2.3 From 808401fd79eea9fa2c965f9f235a753c0cb0d920 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 14:52:43 -0700 Subject: Store parsed tokens as token list and print all text lines. Still not doing any macro expansion just yet. But it should be fairly easy from here. --- glcpp-parse.y | 227 +++++++++++++++++++++++++++++++++++++++++-------------- glcpp.h | 27 +++++-- tests/glcpp-test | 5 +- 3 files changed, 195 insertions(+), 64 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index c53370a89ad..991b8a0b856 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -77,15 +77,29 @@ _argument_list_length (argument_list_t *list); token_list_t * _argument_list_member_at (argument_list_t *list, int index); +/* Note: This function talloc_steal()s the str pointer. */ +token_t * +_token_create_str (void *ctx, int type, char *str); + +token_t * +_token_create_ival (void *ctx, int type, int ival); + token_list_t * _token_list_create (void *ctx); +/* Note: This function add a talloc_reference() to token. + * + * You may want to talloc_unlink any current reference if you no + * longer need it. */ void -_token_list_append (token_list_t *list, int type, const char *value); +_token_list_append (token_list_t *list, token_t *token); void _token_list_append_list (token_list_t *list, token_list_t *tail); +void +_token_list_print (token_list_t *list); + static void glcpp_parser_pop_expansion (glcpp_parser_t *parser); @@ -107,12 +121,9 @@ glcpp_parser_lex (glcpp_parser_t *parser); %} %union { - intmax_t imaxval; int ival; char *str; - argument_list_t *argument_list; - string_list_t *string_list; - token_t token; + token_t *token; token_list_t *token_list; } @@ -121,6 +132,10 @@ glcpp_parser_lex (glcpp_parser_t *parser); %token HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH IDENTIFIER NEWLINE OTHER HASH_UNDEF %token LEFT_SHIFT RIGHT_SHIFT LESS_OR_EQUAL GREATER_OR_EQUAL EQUAL NOT_EQUAL AND OR PASTE +%type punctuator +%type IDENTIFIER OTHER +%type preprocessing_token +%type pp_tokens replacement_list text_line /* Stale stuff just to allow code to compile. */ %token IDENTIFIER_FINALIZED FUNC_MACRO OBJ_MACRO @@ -134,7 +149,11 @@ input: line: control_line -| text_line +| text_line { + _token_list_print ($1); + printf ("\n"); + talloc_free ($1); + } | HASH non_directive ; @@ -152,7 +171,7 @@ identifier_list: ; text_line: - NEWLINE + NEWLINE { $$ = NULL; } | pp_tokens NEWLINE ; @@ -161,55 +180,68 @@ non_directive: ; replacement_list: - /* empty */ + /* empty */ { $$ = NULL; } | pp_tokens ; pp_tokens: - preprocessing_token -| pp_tokens preprocessing_token + preprocessing_token { + $$ = _token_list_create (parser); + _token_list_append ($$, $1); + talloc_unlink (parser, $1); + } +| pp_tokens preprocessing_token { + $$ = $1; + _token_list_append ($$, $2); + talloc_unlink (parser, $2); + } ; preprocessing_token: - IDENTIFIER -| punctuator -| OTHER + IDENTIFIER { + $$ = _token_create_str (parser, IDENTIFIER, $1); + } +| punctuator { + $$ = _token_create_ival (parser, $1, $1); + } +| OTHER { + $$ = _token_create_str (parser, OTHER, $1); + } ; punctuator: - '[' -| ']' -| '(' -| ')' -| '{' -| '}' -| '.' -| '&' -| '*' -| '+' -| '-' -| '~' -| '!' -| '/' -| '%' -| LEFT_SHIFT -| RIGHT_SHIFT -| '<' -| '>' -| LESS_OR_EQUAL -| GREATER_OR_EQUAL -| EQUAL -| NOT_EQUAL -| '^' -| '|' -| AND -| OR -| ';' -| ',' -| PASTE + '[' { $$ = '['; } +| ']' { $$ = ']'; } +| '(' { $$ = '('; } +| ')' { $$ = ')'; } +| '{' { $$ = '{'; } +| '}' { $$ = '}'; } +| '.' { $$ = '.'; } +| '&' { $$ = '&'; } +| '*' { $$ = '*'; } +| '+' { $$ = '+'; } +| '-' { $$ = '-'; } +| '~' { $$ = '~'; } +| '!' { $$ = '!'; } +| '/' { $$ = '/'; } +| '%' { $$ = '%'; } +| LEFT_SHIFT { $$ = LEFT_SHIFT; } +| RIGHT_SHIFT { $$ = RIGHT_SHIFT; } +| '<' { $$ = '<'; } +| '>' { $$ = '>'; } +| LESS_OR_EQUAL { $$ = LESS_OR_EQUAL; } +| GREATER_OR_EQUAL { $$ = GREATER_OR_EQUAL; } +| EQUAL { $$ = EQUAL; } +| NOT_EQUAL { $$ = NOT_EQUAL; } +| '^' { $$ = '^'; } +| '|' { $$ = '|'; } +| AND { $$ = AND; } +| OR { $$ = OR; } +| ';' { $$ = ';'; } +| ',' { $$ = ','; } +| PASTE { $$ = PASTE; } ; - %% string_list_t * @@ -361,6 +393,77 @@ _argument_list_member_at (argument_list_t *list, int index) return NULL; } +/* Note: This function talloc_steal()s the str pointer. */ +token_t * +_token_create_str (void *ctx, int type, char *str) +{ + token_t *token; + + token = xtalloc (ctx, token_t); + token->type = type; + token->value.str = talloc_steal (token, str); + + return token; +} + +token_t * +_token_create_ival (void *ctx, int type, int ival) +{ + token_t *token; + + token = xtalloc (ctx, token_t); + token->type = type; + token->value.ival = ival; + + return token; +} + +void +_token_print (token_t *token) +{ + if (token->type < 256) { + printf ("%c", token->type); + return; + } + + switch (token->type) { + case IDENTIFIER: + case OTHER: + printf ("%s", token->value.str); + break; + case LEFT_SHIFT: + printf ("<<"); + break; + case RIGHT_SHIFT: + printf (">>"); + break; + case LESS_OR_EQUAL: + printf ("<="); + break; + case GREATER_OR_EQUAL: + printf (">="); + break; + case EQUAL: + printf ("=="); + break; + case NOT_EQUAL: + printf ("!="); + break; + case AND: + printf ("&&"); + break; + case OR: + printf ("||"); + break; + case PASTE: + printf ("##"); + break; + default: + fprintf (stderr, "Error: Don't know how to print token type %d\n", token->type); + break; + } +} + token_list_t * _token_list_create (void *ctx) { @@ -374,13 +477,12 @@ _token_list_create (void *ctx) } void -_token_list_append (token_list_t *list, int type, const char *value) +_token_list_append (token_list_t *list, token_t *token) { token_node_t *node; node = xtalloc (list, token_node_t); - node->type = type; - node->value = xtalloc_strdup (list, value); + node->token = xtalloc_reference (list, token); node->next = NULL; @@ -405,6 +507,21 @@ _token_list_append_list (token_list_t *list, token_list_t *tail) list->tail = tail->tail; } +void +_token_list_print (token_list_t *list) +{ + token_node_t *node; + + if (list == NULL) + return; + + for (node = list->head; node; node = node->next) { + _token_print (node->token); + if (node->next) + printf (" "); + } +} + void yyerror (void *scanner, const char *error) { @@ -598,7 +715,8 @@ _expand_function_macro (glcpp_parser_t *parser, expanded = _token_list_create (macro); for (i = macro->replacements->head; i; i = i->next) { - if (_string_list_contains (macro->parameters, i->value, + if (_string_list_contains (macro->parameters, + i->token->value.str, ¶meter_index)) { token_list_t *argument; @@ -606,11 +724,10 @@ _expand_function_macro (glcpp_parser_t *parser, parameter_index); for (j = argument->head; j; j = j->next) { - _token_list_append (expanded, j->type, - j->value); + _token_list_append (expanded, j->token); } } else { - _token_list_append (expanded, i->type, i->value); + _token_list_append (expanded, i->token); } } @@ -644,10 +761,10 @@ glcpp_parser_lex (glcpp_parser_t *parser) expansion->replacements = replacements->next; - token = replacements->value; + token = replacements->token->value.str; /* Implement token pasting. */ - if (replacements->next && strcmp (replacements->next->value, "##") == 0) { + if (replacements->next && strcmp (replacements->next->token->value.str, "##") == 0) { token_node_t *next_node; next_node = replacements->next->next; @@ -658,7 +775,7 @@ glcpp_parser_lex (glcpp_parser_t *parser) } token = xtalloc_asprintf (parser, "%s%s", - token, next_node->value); + token, next_node->token->value.str); expansion->replacements = next_node->next; } @@ -671,7 +788,7 @@ glcpp_parser_lex (glcpp_parser_t *parser) yylval.str = xtalloc_strdup (parser, token); /* Carefully refuse to expand any finalized identifier. */ - if (replacements->type == IDENTIFIER_FINALIZED) + if (replacements->token->type == IDENTIFIER_FINALIZED) return IDENTIFIER_FINALIZED; switch (glcpp_parser_classify_token (parser, yylval.str, diff --git a/glcpp.h b/glcpp.h index 6171ce8b4a0..261254a17c4 100644 --- a/glcpp.h +++ b/glcpp.h @@ -44,21 +44,34 @@ typedef struct string_list { string_node_t *tail; } string_list_t; -typedef struct token { +typedef struct token token_t; +typedef struct token_list token_list_t; + +typedef union YYSTYPE +{ + int ival; + char *str; + token_t *token; + token_list_t *token_list; +} YYSTYPE; + +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 + +struct token { int type; - char *value; -} token_t; + YYSTYPE value; +}; typedef struct token_node { - int type; - const char *value; + token_t *token; struct token_node *next; } token_node_t; -typedef struct token_list { +struct token_list { token_node_t *head; token_node_t *tail; -} token_list_t; +}; typedef struct argument_node { token_list_t *argument; diff --git a/tests/glcpp-test b/tests/glcpp-test index 868b03cce83..34cca883301 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -7,6 +7,7 @@ for test in *.c; do echo "Testing $test" ../glcpp < $test > $test.out gcc -E $test -o $test.gcc - grep -v '^#' < $test.gcc > $test.expected -# diff -B -u $test.expected $test.out +# grep -v '^#' < $test.gcc > $test.expected + grep -v '^[ ]*#' < $test > $test.expected + diff -w -u $test.expected $test.out done -- cgit v1.2.3 From 9fb8b7a495c9dc6f9a62cf82300fae5925af92fc Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 15:04:32 -0700 Subject: Make the lexer pass whitespace through (as OTHER tokens) for text lines. With this change, we can recreate the original text-line input exactly. Previously we were inserting a space between every pair of tokens so our output had a lot more whitespace than our input. With this change, we can drop the "-b" option to diff and match the input exactly. --- glcpp-lex.l | 72 +++++++++++++++++++++++++++++++++++++++++++++----------- glcpp-parse.y | 2 -- tests/glcpp-test | 2 +- 3 files changed, 59 insertions(+), 17 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index f1dd11ea9bd..7b5cdd57a0f 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -32,6 +32,21 @@ %option reentrant noyywrap %option extra-type="glcpp_parser_t *" + /* This lexer has two states: + * + * The CONTROL state is for control lines (directives) + * It lexes exactly as specified in the C99 specification. + * + * The INITIAL state is for input lines. In this state, we + * make the OTHER token much more broad in that it now + * includes tokens consisting entirely of whitespace. This + * allows us to pass text through verbatim. It avoids the + * "inadvertent token pasting" problem that would occur if we + * just printed tokens, while also avoiding excess whitespace + * insertion in the output.*/ + +%x CONTROL + SPACE [[:space:]] NONSPACE [^[:space:]] NEWLINE [\n] @@ -48,75 +63,104 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? %% {HASH}define{HSPACE}+/{IDENTIFIER}"(" { + BEGIN CONTROL; return HASH_DEFINE_FUNC; } {HASH}define { + BEGIN CONTROL; return HASH_DEFINE_OBJ; } {HASH}undef { + BEGIN CONTROL; return HASH_UNDEF; } {HASH} { + BEGIN CONTROL; return HASH; } -{IDENTIFIER} { +{IDENTIFIER} { yylval.str = xtalloc_strdup (yyextra, yytext); return IDENTIFIER; } -"<<" { +"<<" { return LEFT_SHIFT; } -">>" { +">>" { return RIGHT_SHIFT; } -"<=" { +"<=" { return LESS_OR_EQUAL; } -">=" { +">=" { return GREATER_OR_EQUAL; } -"==" { +"==" { return EQUAL; } -"!=" { +"!=" { return NOT_EQUAL; } -"&&" { +"&&" { return AND; } -"||" { +"||" { return OR; } -"##" { +"##" { return PASTE; } -{PUNCTUATION} { +{PUNCTUATION} { return yytext[0]; } -\n { +{OTHER} { + yylval.str = xtalloc_strdup (yyextra, yytext); + return OTHER; +} + +{HSPACE}+ + +\n { + BEGIN INITIAL; return NEWLINE; } -{OTHER} { +{IDENTIFIER} { + yylval.str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; +} + +{OTHER}+ { + yylval.str = xtalloc_strdup (yyextra, yytext); + return OTHER; +} + +{HSPACE}+ { yylval.str = xtalloc_strdup (yyextra, yytext); return OTHER; } -{HSPACE}+ +\n { + return NEWLINE; +} + +. { + yylval.str = xtalloc_strdup (yyextra, yytext); + return OTHER; +} %% diff --git a/glcpp-parse.y b/glcpp-parse.y index 991b8a0b856..957421b864e 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -517,8 +517,6 @@ _token_list_print (token_list_t *list) for (node = list->head; node; node = node->next) { _token_print (node->token); - if (node->next) - printf (" "); } } diff --git a/tests/glcpp-test b/tests/glcpp-test index 34cca883301..8074e471197 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -9,5 +9,5 @@ for test in *.c; do gcc -E $test -o $test.gcc # grep -v '^#' < $test.gcc > $test.expected grep -v '^[ ]*#' < $test > $test.expected - diff -w -u $test.expected $test.out + diff -u $test.expected $test.out done -- cgit v1.2.3 From ae6517f4a83981ae363bbbfe439ec23e8deb04b1 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 15:24:59 -0700 Subject: Implement expansion of object-like macros. For this we add an "active" string_list_t to the parser. This makes the current expansion_list_t in the parser obsolete, but we don't remove that yet. With this change we can now start passing some actual tests, so we turn on real testing in the test suite again. I expect to implement things more or less in the same order as before, so the test suite now halts on first error. With this change the first 8 tests in the suite pass, (object-like macros with chaining and recursion). --- glcpp-parse.y | 128 +++++++++++++++++++++++++++++++++++++++++++++++-------- glcpp.h | 1 + tests/glcpp-test | 5 +-- 3 files changed, 112 insertions(+), 22 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 957421b864e..b3ef177a6da 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -59,6 +59,12 @@ _string_list_append_item (string_list_t *list, const char *str); void _string_list_append_list (string_list_t *list, string_list_t *tail); +void +_string_list_push (string_list_t *list, const char *str); + +void +_string_list_pop (string_list_t *list); + int _string_list_contains (string_list_t *list, const char *member, int *index); @@ -98,7 +104,8 @@ void _token_list_append_list (token_list_t *list, token_list_t *tail); void -_token_list_print (token_list_t *list); +_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, + token_list_t *list); static void glcpp_parser_pop_expansion (glcpp_parser_t *parser); @@ -144,21 +151,24 @@ glcpp_parser_lex (glcpp_parser_t *parser); input: /* empty */ -| input line +| input line { + printf ("\n"); + } ; line: control_line | text_line { - _token_list_print ($1); - printf ("\n"); + _glcpp_parser_print_expanded_token_list (parser, $1); talloc_free ($1); } | HASH non_directive ; control_line: - HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE + HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE { + _define_object_macro (parser, $2, $3); + } | HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE | HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE | HASH_UNDEF IDENTIFIER NEWLINE @@ -287,6 +297,42 @@ _string_list_append_item (string_list_t *list, const char *str) list->tail = node; } +void +_string_list_push (string_list_t *list, const char *str) +{ + string_node_t *node; + + node = xtalloc (list, string_node_t); + node->str = xtalloc_strdup (node, str); + node->next = list->head; + + if (list->tail == NULL) { + list->tail = node; + } + list->head = node; +} + +void +_string_list_pop (string_list_t *list) +{ + string_node_t *node; + + node = list->head; + + if (node == NULL) { + fprintf (stderr, "Internal error: _string_list_pop called on an empty list.\n"); + exit (1); + } + + list->head = node->next; + if (list->tail == node) { + assert (node->next == NULL); + list->tail = NULL; + } + + talloc_free (node); +} + int _string_list_contains (string_list_t *list, const char *member, int *index) { @@ -507,19 +553,6 @@ _token_list_append_list (token_list_t *list, token_list_t *tail) list->tail = tail->tail; } -void -_token_list_print (token_list_t *list) -{ - token_node_t *node; - - if (list == NULL) - return; - - for (node = list->head; node; node = node->next) { - _token_print (node->token); - } -} - void yyerror (void *scanner, const char *error) { @@ -536,6 +569,7 @@ glcpp_parser_create (void) glcpp_lex_init_extra (parser, &parser->scanner); parser->defines = hash_table_ctor (32, hash_table_string_hash, hash_table_string_compare); + parser->active = _string_list_create (parser); parser->expansions = NULL; parser->just_printed_separator = 1; @@ -605,6 +639,64 @@ glcpp_parser_classify_token (glcpp_parser_t *parser, return TOKEN_CLASS_OBJ_MACRO; } +void +_glcpp_parser_print_expanded_token (glcpp_parser_t *parser, + token_t *token) +{ + const char *identifier; + macro_t *macro; + + /* We only expand identifiers */ + if (token->type != IDENTIFIER) { + _token_print (token); + return; + } + + /* Look up this identifier in the hash table. */ + identifier = token->value.str; + macro = hash_table_find (parser->defines, identifier); + + /* Not a macro, so just print directly. */ + if (macro == NULL) { + printf ("%s", identifier); + return; + } + + /* We're not (yet) supporting function-like macros. */ + if (macro->is_function) { + printf ("%s", identifier); + return; + } + + /* Finally, don't expand this macro if we're already actively + * expanding it, (to avoid infinite recursion). */ + if (_string_list_contains (parser->active, identifier, NULL)) { + printf ("%s", identifier); + return; + } + + _string_list_push (parser->active, identifier); + _glcpp_parser_print_expanded_token_list (parser, + macro->replacements); + _string_list_pop (parser->active); +} + +void +_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, + token_list_t *list) +{ + token_node_t *node; + + if (list == NULL) + return; + + for (node = list->head; node; node = node->next) { + _glcpp_parser_print_expanded_token (parser, node->token); + if (node->next) + printf (" "); + } +} + void _define_object_macro (glcpp_parser_t *parser, const char *identifier, diff --git a/glcpp.h b/glcpp.h index 261254a17c4..bd599d73011 100644 --- a/glcpp.h +++ b/glcpp.h @@ -124,6 +124,7 @@ typedef struct skip_node { struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; + string_list_t *active; expansion_node_t *expansions; int just_printed_separator; int need_newline; diff --git a/tests/glcpp-test b/tests/glcpp-test index 8074e471197..63041552104 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -1,13 +1,10 @@ #!/bin/sh set -e -echo "Caution: These results are just verifying parse-ability, not correctness!" - for test in *.c; do echo "Testing $test" ../glcpp < $test > $test.out gcc -E $test -o $test.gcc -# grep -v '^#' < $test.gcc > $test.expected - grep -v '^[ ]*#' < $test > $test.expected + grep -v '^#' < $test.gcc > $test.expected diff -u $test.expected $test.out done -- cgit v1.2.3 From e6fb7827c96451d4a09dfda31979a6b9cb27301e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 15:28:58 -0700 Subject: Implement #undef. Which is as simple as copying the former action back from the git history. Now all tests through test 11 pass. --- glcpp-parse.y | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index b3ef177a6da..830a6232d80 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -171,7 +171,17 @@ control_line: } | HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE | HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE -| HASH_UNDEF IDENTIFIER NEWLINE +| HASH_UNDEF IDENTIFIER NEWLINE { + string_list_t *macro = hash_table_find (parser->defines, $2); + if (macro) { + /* XXX: Need hash table to support a real way + * to remove an element rather than prefixing + * a new node with data of NULL like this. */ + hash_table_insert (parser->defines, NULL, $2); + talloc_free (macro); + } + talloc_free ($2); + } | HASH NEWLINE ; -- cgit v1.2.3 From b1854fdfb6b567fa61d544d8080e2acb4cc78dc1 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 16:28:26 -0700 Subject: Implement simplified substitution for function-like macro invocation. This supports function-like macro invocation but without any argument substitution. This now makes test 11 through 14 pass. --- glcpp-lex.l | 14 ++++- glcpp-parse.y | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++------- glcpp.h | 1 + 3 files changed, 168 insertions(+), 21 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 7b5cdd57a0f..b1980742d39 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -144,6 +144,18 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return IDENTIFIER; } +"(" { + return '('; +} + +")" { + return ')'; +} + +"," { + return ','; +} + {OTHER}+ { yylval.str = xtalloc_strdup (yyextra, yytext); return OTHER; @@ -151,7 +163,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? {HSPACE}+ { yylval.str = xtalloc_strdup (yyextra, yytext); - return OTHER; + return SPACE; } \n { diff --git a/glcpp-parse.y b/glcpp-parse.y index 830a6232d80..60b414e43a7 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -127,20 +127,14 @@ glcpp_parser_lex (glcpp_parser_t *parser); %} -%union { - int ival; - char *str; - token_t *token; - token_list_t *token_list; -} - %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH IDENTIFIER NEWLINE OTHER HASH_UNDEF +%token HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_UNDEF IDENTIFIER NEWLINE OTHER SPACE %token LEFT_SHIFT RIGHT_SHIFT LESS_OR_EQUAL GREATER_OR_EQUAL EQUAL NOT_EQUAL AND OR PASTE %type punctuator -%type IDENTIFIER OTHER +%type IDENTIFIER OTHER SPACE +%type identifier_list %type preprocessing_token %type pp_tokens replacement_list text_line @@ -169,8 +163,12 @@ control_line: HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE { _define_object_macro (parser, $2, $3); } -| HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE -| HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE +| HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE { + _define_function_macro (parser, $2, NULL, $5); + } +| HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE { + _define_function_macro (parser, $2, $4, $6); + } | HASH_UNDEF IDENTIFIER NEWLINE { string_list_t *macro = hash_table_find (parser->defines, $2); if (macro) { @@ -186,8 +184,16 @@ control_line: ; identifier_list: - IDENTIFIER -| identifier_list ',' IDENTIFIER + IDENTIFIER { + $$ = _string_list_create (parser); + _string_list_append_item ($$, $1); + talloc_steal ($$, $1); + } +| identifier_list ',' IDENTIFIER { + $$ = $1; + _string_list_append_item ($$, $3); + talloc_steal ($$, $3); + } ; text_line: @@ -227,6 +233,9 @@ preprocessing_token: | OTHER { $$ = _token_create_str (parser, OTHER, $1); } +| SPACE { + $$ = _token_create_str (parser, OTHER, $1); + } ; punctuator: @@ -649,7 +658,14 @@ glcpp_parser_classify_token (glcpp_parser_t *parser, return TOKEN_CLASS_OBJ_MACRO; } -void +/* Print a non-macro token, or the expansion of an object-like macro. + * + * Returns 0 if this token is completely printed. + * + * Returns 1 in the case that 'token' is a function-like macro that + * needs further expansion. + */ +static int _glcpp_parser_print_expanded_token (glcpp_parser_t *parser, token_t *token) { @@ -659,7 +675,7 @@ _glcpp_parser_print_expanded_token (glcpp_parser_t *parser, /* We only expand identifiers */ if (token->type != IDENTIFIER) { _token_print (token); - return; + return 0; } /* Look up this identifier in the hash table. */ @@ -669,20 +685,135 @@ _glcpp_parser_print_expanded_token (glcpp_parser_t *parser, /* Not a macro, so just print directly. */ if (macro == NULL) { printf ("%s", identifier); - return; + return 0; } - /* We're not (yet) supporting function-like macros. */ + /* For function-like macros return 1 for further processing. */ if (macro->is_function) { - printf ("%s", identifier); - return; + return 1; } /* Finally, don't expand this macro if we're already actively * expanding it, (to avoid infinite recursion). */ if (_string_list_contains (parser->active, identifier, NULL)) { + printf ("%s", identifier); + return 0; + } + + _string_list_push (parser->active, identifier); + _glcpp_parser_print_expanded_token_list (parser, + macro->replacements); + _string_list_pop (parser->active); + + return 0; +} + +typedef enum function_status +{ + FUNCTION_STATUS_SUCCESS, + FUNCTION_NOT_A_FUNCTION, + FUNCTION_UNBALANCED_PARENTHESES +} function_status_t; + +/* Find a set of function-like macro arguments by looking for a + * balanced set of parentheses. Upon return *node will be the last + * consumed node, such that further processing can continue with + * node->next. + * + * Return values: + * + * FUNCTION_STATUS_SUCCESS: + * + * Successfully parsed a set of function arguments. + * + * FUNCTION_NOT_A_FUNCTION: + * + * Macro name not followed by a '('. This is not an error, but + * simply that the macro name should be treated as a non-macro. + * + * FUNCTION_UNBLANCED_PARENTHESES + * + * Macro name is not followed by a balanced set of parentheses. + */ +static function_status_t +_find_arguments (token_node_t **node_ret, argument_list_t **arguments) +{ + token_node_t *node = *node_ret, *last; + int paren_count; + int arg_count; + + last = node; + node = node->next; + + /* Ignore whitespace before first parenthesis. */ + while (node && node->token->type == SPACE) + node = node->next; + + if (node == NULL || node->token->type != '(') + return FUNCTION_NOT_A_FUNCTION; + + paren_count = 0; + arg_count = 0; + do { + if (node->token->type == '(') + { + paren_count++; + } + else if (node->token->type == ')') + { + paren_count--; + } + else if (node->token->type == ',' && + paren_count == 1) + { + arg_count++; + } + + last = node; + node = node->next; + + } while (node && paren_count); + + if (node && paren_count) + return FUNCTION_UNBALANCED_PARENTHESES; + + *node_ret = last; + + return FUNCTION_STATUS_SUCCESS; +} + +/* Prints the expansion of *node (consuming further tokens from the + * list as necessary). Upon return *node will be the last consumed + * node, such that further processing can continue with node->next. */ +static void +_glcpp_parser_print_expanded_function (glcpp_parser_t *parser, + token_node_t **node_ret) +{ + macro_t *macro; + token_node_t *node; + const char *identifier; + argument_list_t *arguments; + function_status_t status; + + node = *node_ret; + identifier = node->token->value.str; + + macro = hash_table_find (parser->defines, identifier); + + assert (macro->is_function); + + status = _find_arguments (node_ret, &arguments); + + switch (status) { + case FUNCTION_STATUS_SUCCESS: + break; + case FUNCTION_NOT_A_FUNCTION: printf ("%s", identifier); return; + case FUNCTION_UNBALANCED_PARENTHESES: + fprintf (stderr, "Error: Macro %s call has unbalanced parentheses\n", + identifier); + exit (1); } _string_list_push (parser->active, identifier); @@ -696,12 +827,15 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, token_list_t *list) { token_node_t *node; + function_status_t function_status; if (list == NULL) return; for (node = list->head; node; node = node->next) { - _glcpp_parser_print_expanded_token (parser, node->token); + if (_glcpp_parser_print_expanded_token (parser, node->token)) + _glcpp_parser_print_expanded_function (parser, &node); + if (node->next) printf (" "); } diff --git a/glcpp.h b/glcpp.h index bd599d73011..043098b1347 100644 --- a/glcpp.h +++ b/glcpp.h @@ -51,6 +51,7 @@ typedef union YYSTYPE { int ival; char *str; + string_list_t *string_list; token_t *token; token_list_t *token_list; } YYSTYPE; -- cgit v1.2.3 From f34a0009dd07dbca4de5491744bd3618eae9458e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 16:59:02 -0700 Subject: Pass through literal space values from replacement lists. This makes test 15 pass and also dramatically simplifies the lexer. We were previously using a CONTROL state in the lexer to only emit SPACE tokens when on text lines. But that's not actually what we want. We need SPACE tokens in the replacement lists as well. Instead of a lexer state for this, we now simply set a "space_tokens" flag whenever we start constructing a pp_tokens list and clear the flag whenever we see a '#' introducing a directive. Much cleaner this way. --- glcpp-lex.l | 85 +++++++++++++---------------------------------------------- glcpp-parse.y | 10 +++---- glcpp.h | 1 + 3 files changed, 25 insertions(+), 71 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index b1980742d39..f6d0c8b7d67 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -32,21 +32,6 @@ %option reentrant noyywrap %option extra-type="glcpp_parser_t *" - /* This lexer has two states: - * - * The CONTROL state is for control lines (directives) - * It lexes exactly as specified in the C99 specification. - * - * The INITIAL state is for input lines. In this state, we - * make the OTHER token much more broad in that it now - * includes tokens consisting entirely of whitespace. This - * allows us to pass text through verbatim. It avoids the - * "inadvertent token pasting" problem that would occur if we - * just printed tokens, while also avoiding excess whitespace - * insertion in the output.*/ - -%x CONTROL - SPACE [[:space:]] NONSPACE [^[:space:]] NEWLINE [\n] @@ -63,116 +48,84 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? %% {HASH}define{HSPACE}+/{IDENTIFIER}"(" { - BEGIN CONTROL; + yyextra->space_tokens = 0; return HASH_DEFINE_FUNC; } {HASH}define { - BEGIN CONTROL; + yyextra->space_tokens = 0; return HASH_DEFINE_OBJ; } {HASH}undef { - BEGIN CONTROL; + yyextra->space_tokens = 0; return HASH_UNDEF; } {HASH} { - BEGIN CONTROL; + yyextra->space_tokens = 0; return HASH; } -{IDENTIFIER} { +{IDENTIFIER} { yylval.str = xtalloc_strdup (yyextra, yytext); return IDENTIFIER; } -"<<" { +"<<" { return LEFT_SHIFT; } -">>" { +">>" { return RIGHT_SHIFT; } -"<=" { +"<=" { return LESS_OR_EQUAL; } -">=" { +">=" { return GREATER_OR_EQUAL; } -"==" { +"==" { return EQUAL; } -"!=" { +"!=" { return NOT_EQUAL; } -"&&" { +"&&" { return AND; } -"||" { +"||" { return OR; } -"##" { +"##" { return PASTE; } -{PUNCTUATION} { +{PUNCTUATION} { return yytext[0]; } -{OTHER} { - yylval.str = xtalloc_strdup (yyextra, yytext); - return OTHER; -} - -{HSPACE}+ - -\n { - BEGIN INITIAL; - return NEWLINE; -} - -{IDENTIFIER} { - yylval.str = xtalloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - -"(" { - return '('; -} - -")" { - return ')'; -} - -"," { - return ','; -} - {OTHER}+ { yylval.str = xtalloc_strdup (yyextra, yytext); return OTHER; } {HSPACE}+ { - yylval.str = xtalloc_strdup (yyextra, yytext); - return SPACE; + if (yyextra->space_tokens) { + yylval.str = xtalloc_strdup (yyextra, yytext); + return SPACE; + } } \n { return NEWLINE; } -. { - yylval.str = xtalloc_strdup (yyextra, yytext); - return OTHER; -} - %% diff --git a/glcpp-parse.y b/glcpp-parse.y index 60b414e43a7..a1981995fd0 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -160,7 +160,7 @@ line: ; control_line: - HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE { + HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE { _define_object_macro (parser, $2, $3); } | HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE { @@ -212,6 +212,7 @@ replacement_list: pp_tokens: preprocessing_token { + parser->space_tokens = 1; $$ = _token_list_create (parser); _token_list_append ($$, $1); talloc_unlink (parser, $1); @@ -234,7 +235,7 @@ preprocessing_token: $$ = _token_create_str (parser, OTHER, $1); } | SPACE { - $$ = _token_create_str (parser, OTHER, $1); + $$ = _token_create_str (parser, SPACE, $1); } ; @@ -494,6 +495,7 @@ _token_print (token_t *token) switch (token->type) { case IDENTIFIER: case OTHER: + case SPACE: printf ("%s", token->value.str); break; case LEFT_SHIFT: @@ -589,6 +591,7 @@ glcpp_parser_create (void) parser->defines = hash_table_ctor (32, hash_table_string_hash, hash_table_string_compare); parser->active = _string_list_create (parser); + parser->space_tokens = 1; parser->expansions = NULL; parser->just_printed_separator = 1; @@ -835,9 +838,6 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, for (node = list->head; node; node = node->next) { if (_glcpp_parser_print_expanded_token (parser, node->token)) _glcpp_parser_print_expanded_function (parser, &node); - - if (node->next) - printf (" "); } } diff --git a/glcpp.h b/glcpp.h index 043098b1347..f3760fa7a41 100644 --- a/glcpp.h +++ b/glcpp.h @@ -126,6 +126,7 @@ struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; string_list_t *active; + int space_tokens; expansion_node_t *expansions; int just_printed_separator; int need_newline; -- cgit v1.2.3 From f8ec4e0be86eee05f5a661a01864247fcd1a6b30 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 17:06:17 -0700 Subject: Add a test #0 to ensure that we don't do any inadvertent token pasting. This simply ensures that spaces in input line are preserved. --- tests/000-content-with-spaces.c | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/000-content-with-spaces.c diff --git a/tests/000-content-with-spaces.c b/tests/000-content-with-spaces.c new file mode 100644 index 00000000000..a7fc918c908 --- /dev/null +++ b/tests/000-content-with-spaces.c @@ -0,0 +1 @@ +this is four tokens -- cgit v1.2.3 From e9397867ddce20a4263949f4b3a488fa99af3041 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 17:08:07 -0700 Subject: Collapse multiple spaces in input down to a single space. This is what gcc does, and it's actually less work to do this. Previously we were having to save the contents of space tokens as a string, but we don't need to do that now. We extend test #0 to exercise this feature here. --- glcpp-lex.l | 1 - glcpp-parse.y | 10 ++++++---- tests/000-content-with-spaces.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index f6d0c8b7d67..516f42dee32 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -119,7 +119,6 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? {HSPACE}+ { if (yyextra->space_tokens) { - yylval.str = xtalloc_strdup (yyextra, yytext); return SPACE; } } diff --git a/glcpp-parse.y b/glcpp-parse.y index a1981995fd0..0460f71f746 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -132,8 +132,8 @@ glcpp_parser_lex (glcpp_parser_t *parser); %token HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_UNDEF IDENTIFIER NEWLINE OTHER SPACE %token LEFT_SHIFT RIGHT_SHIFT LESS_OR_EQUAL GREATER_OR_EQUAL EQUAL NOT_EQUAL AND OR PASTE -%type punctuator -%type IDENTIFIER OTHER SPACE +%type punctuator SPACE +%type IDENTIFIER OTHER %type identifier_list %type preprocessing_token %type pp_tokens replacement_list text_line @@ -235,7 +235,7 @@ preprocessing_token: $$ = _token_create_str (parser, OTHER, $1); } | SPACE { - $$ = _token_create_str (parser, SPACE, $1); + $$ = _token_create_ival (parser, SPACE, SPACE); } ; @@ -495,9 +495,11 @@ _token_print (token_t *token) switch (token->type) { case IDENTIFIER: case OTHER: - case SPACE: printf ("%s", token->value.str); break; + case SPACE: + printf (" "); + break; case LEFT_SHIFT: printf ("<<"); break; diff --git a/tests/000-content-with-spaces.c b/tests/000-content-with-spaces.c index a7fc918c908..696cb3a74fc 100644 --- a/tests/000-content-with-spaces.c +++ b/tests/000-content-with-spaces.c @@ -1 +1 @@ -this is four tokens +this is four tokens -- cgit v1.2.3 From 9ce18cf9837bee379dfd0f52a3df005c1797e544 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 17:32:21 -0700 Subject: Implement substitution of function parameters in macro calls. This makes tests 16 - 19 pass. --- glcpp-parse.y | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 0460f71f746..eb93bad85d1 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -405,9 +405,6 @@ _argument_list_append (argument_list_t *list, token_list_t *argument) { argument_node_t *node; - if (argument == NULL || argument->head == NULL) - return; - node = xtalloc (list, argument_node_t); node->argument = argument; @@ -741,8 +738,9 @@ typedef enum function_status * Macro name is not followed by a balanced set of parentheses. */ static function_status_t -_find_arguments (token_node_t **node_ret, argument_list_t **arguments) +_arguments_parse (argument_list_t *arguments, token_node_t **node_ret) { + token_list_t *argument; token_node_t *node = *node_ret, *last; int paren_count; int arg_count; @@ -757,6 +755,8 @@ _find_arguments (token_node_t **node_ret, argument_list_t **arguments) if (node == NULL || node->token->type != '(') return FUNCTION_NOT_A_FUNCTION; + argument = NULL; + paren_count = 0; arg_count = 0; do { @@ -771,7 +771,14 @@ _find_arguments (token_node_t **node_ret, argument_list_t **arguments) else if (node->token->type == ',' && paren_count == 1) { - arg_count++; + argument = NULL; + } + else { + if (argument == NULL) { + argument = _token_list_create (arguments); + _argument_list_append (arguments, argument); + } + _token_list_append (argument, node->token); } last = node; @@ -799,6 +806,9 @@ _glcpp_parser_print_expanded_function (glcpp_parser_t *parser, const char *identifier; argument_list_t *arguments; function_status_t status; + token_list_t *expanded; + token_node_t *i, *j; + int parameter_index; node = *node_ret; identifier = node->token->value.str; @@ -807,7 +817,8 @@ _glcpp_parser_print_expanded_function (glcpp_parser_t *parser, assert (macro->is_function); - status = _find_arguments (node_ret, &arguments); + arguments = _argument_list_create (parser); + status = _arguments_parse (arguments, node_ret); switch (status) { case FUNCTION_STATUS_SUCCESS: @@ -821,10 +832,48 @@ _glcpp_parser_print_expanded_function (glcpp_parser_t *parser, exit (1); } + if (macro->replacements == NULL) { + talloc_free (arguments); + return; + } + + + if (_argument_list_length (arguments) != + _string_list_length (macro->parameters)) + { + fprintf (stderr, + "Error: macro %s invoked with %d arguments (expected %d)\n", + identifier, + _argument_list_length (arguments), + _string_list_length (macro->parameters)); + return; + } + + expanded = _token_list_create (arguments); + + for (i = macro->replacements->head; i; i = i->next) { + if (i->token->type == IDENTIFIER && + _string_list_contains (macro->parameters, + i->token->value.str, + ¶meter_index)) + { + token_list_t *argument; + argument = _argument_list_member_at (arguments, + parameter_index); + for (j = argument->head; j; j = j->next) + { + _token_list_append (expanded, j->token); + } + } else { + _token_list_append (expanded, i->token); + } + } + _string_list_push (parser->active, identifier); - _glcpp_parser_print_expanded_token_list (parser, - macro->replacements); + _glcpp_parser_print_expanded_token_list (parser, expanded); _string_list_pop (parser->active); + + talloc_free (arguments); } void -- cgit v1.2.3 From c7581c2e6e6897eddc55c537c92417b813a8b81e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 17:41:07 -0700 Subject: Ignore separating whitespace at the beginning of a macro argument. This causes test 16 to pass. Tests 17-20 are also passing now, (though they would probably have passed before this change and simply weren't being run yet). --- glcpp-parse.y | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index eb93bad85d1..ec966580fc4 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -743,7 +743,6 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) token_list_t *argument; token_node_t *node = *node_ret, *last; int paren_count; - int arg_count; last = node; node = node->next; @@ -757,9 +756,7 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) argument = NULL; - paren_count = 0; - arg_count = 0; - do { + for (paren_count = 0; node; last = node, node = node->next) { if (node->token->type == '(') { paren_count++; @@ -767,6 +764,11 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) else if (node->token->type == ')') { paren_count--; + if (paren_count == 0) { + last = node; + node = node->next; + break; + } } else if (node->token->type == ',' && paren_count == 1) @@ -775,16 +777,16 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) } else { if (argument == NULL) { + /* Don't treat initial whitespace as + * part of the arguement. */ + if (node->token->type == SPACE) + continue; argument = _token_list_create (arguments); _argument_list_append (arguments, argument); } _token_list_append (argument, node->token); } - - last = node; - node = node->next; - - } while (node && paren_count); + } if (node && paren_count) return FUNCTION_UNBALANCED_PARENTHESES; -- cgit v1.2.3 From 652fa272ea4bdb9bfe6cd7f8413b3a3b03972987 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 17:45:22 -0700 Subject: Avoid swallowing initial left parenthesis from nested macro invocation. We weren't including this left parenthesis in the argument's token list so the nested function invocation wasn not being recognized. With this fix, tests 21 and 22 now pass. --- glcpp-parse.y | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index ec966580fc4..131102fab95 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -754,9 +754,12 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) if (node == NULL || node->token->type != '(') return FUNCTION_NOT_A_FUNCTION; + last = node; + node = node->next; + argument = NULL; - for (paren_count = 0; node; last = node, node = node->next) { + for (paren_count = 1; node; last = node, node = node->next) { if (node->token->type == '(') { paren_count++; @@ -770,7 +773,8 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) break; } } - else if (node->token->type == ',' && + + if (node->token->type == ',' && paren_count == 1) { argument = NULL; -- cgit v1.2.3 From 5aa7ea08093f727761d424ad090f44b116c8f0bd Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 18:39:43 -0700 Subject: Remove a bunch of old code and give the static treatment to what's left. We're no longer using the expansion stack, so its functions can go along with most of the body of glcpp_parser_lex that was using it. --- glcpp-parse.y | 262 +++++----------------------------------------------------- glcpp.h | 7 -- 2 files changed, 21 insertions(+), 248 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 131102fab95..02286cd8e09 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -28,88 +28,77 @@ #include "glcpp.h" -void +static void yyerror (void *scanner, const char *error); -void +static void _define_object_macro (glcpp_parser_t *parser, const char *macro, token_list_t *replacements); -void +static void _define_function_macro (glcpp_parser_t *parser, const char *macro, string_list_t *parameters, token_list_t *replacements); -void -_expand_object_macro (glcpp_parser_t *parser, const char *identifier); - -void -_expand_function_macro (glcpp_parser_t *parser, - const char *identifier, - argument_list_t *arguments); - -string_list_t * +static string_list_t * _string_list_create (void *ctx); -void +static void _string_list_append_item (string_list_t *list, const char *str); -void +static void _string_list_append_list (string_list_t *list, string_list_t *tail); -void +static void _string_list_push (string_list_t *list, const char *str); -void +static void _string_list_pop (string_list_t *list); -int +static int _string_list_contains (string_list_t *list, const char *member, int *index); -int +static int _string_list_length (string_list_t *list); -argument_list_t * +static argument_list_t * _argument_list_create (void *ctx); -void +static void _argument_list_append (argument_list_t *list, token_list_t *argument); -int +static int _argument_list_length (argument_list_t *list); -token_list_t * +static token_list_t * _argument_list_member_at (argument_list_t *list, int index); /* Note: This function talloc_steal()s the str pointer. */ -token_t * +static token_t * _token_create_str (void *ctx, int type, char *str); -token_t * +static token_t * _token_create_ival (void *ctx, int type, int ival); -token_list_t * +static token_list_t * _token_list_create (void *ctx); /* Note: This function add a talloc_reference() to token. * * You may want to talloc_unlink any current reference if you no * longer need it. */ -void +static void _token_list_append (token_list_t *list, token_t *token); -void +static void _token_list_append_list (token_list_t *list, token_list_t *tail); -void +static void _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, token_list_t *list); -static void -glcpp_parser_pop_expansion (glcpp_parser_t *parser); - static void _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition); @@ -591,10 +580,6 @@ glcpp_parser_create (void) hash_table_string_compare); parser->active = _string_list_create (parser); parser->space_tokens = 1; - parser->expansions = NULL; - - parser->just_printed_separator = 1; - parser->need_newline = 0; parser->skip_stack = NULL; @@ -610,8 +595,6 @@ glcpp_parser_parse (glcpp_parser_t *parser) void glcpp_parser_destroy (glcpp_parser_t *parser) { - if (parser->need_newline) - printf ("\n"); if (parser->skip_stack) fprintf (stderr, "Error: Unterminated #if\n"); glcpp_lex_destroy (parser->scanner); @@ -619,47 +602,6 @@ glcpp_parser_destroy (glcpp_parser_t *parser) talloc_free (parser); } -static int -glcpp_parser_is_expanding (glcpp_parser_t *parser, const char *member) -{ - expansion_node_t *node; - - for (node = parser->expansions; node; node = node->next) { - if (node->macro && - strcmp (node->macro->identifier, member) == 0) - { - return 1; - } - } - - return 0; -} - -token_class_t -glcpp_parser_classify_token (glcpp_parser_t *parser, - const char *identifier, - int *parameter_index) -{ - macro_t *macro; - - /* Is this token a defined macro? */ - macro = hash_table_find (parser->defines, identifier); - - if (macro == NULL) - return TOKEN_CLASS_IDENTIFIER; - - /* Don't consider this a macro if we are already actively - * expanding this macro. */ - if (glcpp_parser_is_expanding (parser, identifier)) - return TOKEN_CLASS_IDENTIFIER_FINALIZED; - - /* Definitely a macro. Just need to check if it's function-like. */ - if (macro->is_function) - return TOKEN_CLASS_FUNC_MACRO; - else - return TOKEN_CLASS_OBJ_MACRO; -} - /* Print a non-macro token, or the expansion of an object-like macro. * * Returns 0 if this token is completely printed. @@ -933,172 +875,10 @@ _define_function_macro (glcpp_parser_t *parser, hash_table_insert (parser->defines, macro, identifier); } -static void -_glcpp_parser_push_expansion (glcpp_parser_t *parser, - macro_t *macro, - token_node_t *replacements) -{ - expansion_node_t *node; - - node = xtalloc (parser, expansion_node_t); - - node->macro = macro; - node->replacements = replacements; - - node->next = parser->expansions; - parser->expansions = node; -} - -static void -glcpp_parser_pop_expansion (glcpp_parser_t *parser) -{ - expansion_node_t *node; - - node = parser->expansions; - - if (node == NULL) { - fprintf (stderr, "Internal error: _expansion_list_pop called on an empty list.\n"); - exit (1); - } - - parser->expansions = node->next; - - talloc_free (node); -} - -void -_expand_object_macro (glcpp_parser_t *parser, const char *identifier) -{ - macro_t *macro; - - macro = hash_table_find (parser->defines, identifier); - assert (! macro->is_function); - assert (! glcpp_parser_is_expanding (parser, identifier)); - - _glcpp_parser_push_expansion (parser, macro, macro->replacements->head); -} - -void -_expand_function_macro (glcpp_parser_t *parser, - const char *identifier, - argument_list_t *arguments) -{ - macro_t *macro; - token_list_t *expanded; - token_node_t *i, *j; - int parameter_index; - - macro = hash_table_find (parser->defines, identifier); - assert (macro->is_function); - assert (! glcpp_parser_is_expanding (parser, identifier)); - - if (_argument_list_length (arguments) != - _string_list_length (macro->parameters)) - { - fprintf (stderr, - "Error: macro %s invoked with %d arguments (expected %d)\n", - identifier, - _argument_list_length (arguments), - _string_list_length (macro->parameters)); - return; - } - - expanded = _token_list_create (macro); - - for (i = macro->replacements->head; i; i = i->next) { - if (_string_list_contains (macro->parameters, - i->token->value.str, - ¶meter_index)) - { - token_list_t *argument; - argument = _argument_list_member_at (arguments, - parameter_index); - for (j = argument->head; j; j = j->next) - { - _token_list_append (expanded, j->token); - } - } else { - _token_list_append (expanded, i->token); - } - } - - _glcpp_parser_push_expansion (parser, macro, expanded->head); -} - static int glcpp_parser_lex (glcpp_parser_t *parser) { - expansion_node_t *expansion; - token_node_t *replacements; - int parameter_index; - const char *token; - token_class_t class; - - /* Who says C can't do efficient tail recursion? */ - RECURSE: - - expansion = parser->expansions; - - if (expansion == NULL) - return glcpp_lex (parser->scanner); - - replacements = expansion->replacements; - - /* Pop expansion when replacements is exhausted. */ - if (replacements == NULL) { - glcpp_parser_pop_expansion (parser); - goto RECURSE; - } - - expansion->replacements = replacements->next; - - token = replacements->token->value.str; - - /* Implement token pasting. */ - if (replacements->next && strcmp (replacements->next->token->value.str, "##") == 0) { - token_node_t *next_node; - - next_node = replacements->next->next; - - if (next_node == NULL) { - fprintf (stderr, "Error: '##' cannot appear at the end of a macro expansion.\n"); - exit (1); - } - - token = xtalloc_asprintf (parser, "%s%s", - token, next_node->token->value.str); - expansion->replacements = next_node->next; - } - - - if (strcmp (token, "(") == 0) - return '('; - else if (strcmp (token, ")") == 0) - return ')'; - - yylval.str = xtalloc_strdup (parser, token); - - /* Carefully refuse to expand any finalized identifier. */ - if (replacements->token->type == IDENTIFIER_FINALIZED) - return IDENTIFIER_FINALIZED; - - switch (glcpp_parser_classify_token (parser, yylval.str, - ¶meter_index)) - { - case TOKEN_CLASS_IDENTIFIER: - return IDENTIFIER; - break; - case TOKEN_CLASS_IDENTIFIER_FINALIZED: - return IDENTIFIER_FINALIZED; - break; - case TOKEN_CLASS_FUNC_MACRO: - return FUNC_MACRO; - break; - default: - case TOKEN_CLASS_OBJ_MACRO: - return OBJ_MACRO; - break; - } + return glcpp_lex (parser->scanner); } static void diff --git a/glcpp.h b/glcpp.h index f3760fa7a41..6bd6e66a7cc 100644 --- a/glcpp.h +++ b/glcpp.h @@ -127,16 +127,9 @@ struct glcpp_parser { struct hash_table *defines; string_list_t *active; int space_tokens; - expansion_node_t *expansions; - int just_printed_separator; - int need_newline; skip_node_t *skip_stack; }; -void -glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, - int argument_index); - glcpp_parser_t * glcpp_parser_create (void); -- cgit v1.2.3 From 10ae438399f14367dd9e03032594c1e16c428999 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 25 May 2010 20:35:01 -0700 Subject: Avoid getting extra trailing whitespace from macros. This trailing whitespace was coming from macro definitions and from macro arguments. We fix this with a little extra state in the token_list. It now remembers the last non-space token added, so that these can be trimmed off just before printing the list. With this fix test 23 now passes. Tests 24 and 25 are also passing, but they probbably would ahve before this fix---just that they weren't being run earlier. --- glcpp-parse.y | 30 ++++++++++++++++++++++++++++-- glcpp.h | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 02286cd8e09..60eaf215b8b 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -471,7 +471,7 @@ _token_create_ival (void *ctx, int type, int ival) } void -_token_print (token_t *token) +_glcpp_parser_print_token (glcpp_parser_t *parser, token_t *token) { if (token->type < 256) { printf ("%c", token->type); @@ -527,6 +527,7 @@ _token_list_create (void *ctx) list = xtalloc (ctx, token_list_t); list->head = NULL; list->tail = NULL; + list->non_space_tail = NULL; return list; } @@ -548,6 +549,8 @@ _token_list_append (token_list_t *list, token_t *token) } list->tail = node; + if (token->type != SPACE) + list->non_space_tail = node; } void @@ -560,6 +563,25 @@ _token_list_append_list (token_list_t *list, token_list_t *tail) } list->tail = tail->tail; + list->non_space_tail = tail->non_space_tail; +} + +void +_token_list_trim_trailing_space (token_list_t *list) +{ + token_node_t *tail, *next; + + if (list->non_space_tail) { + tail = list->non_space_tail->next; + list->non_space_tail->next = NULL; + list->tail = list->non_space_tail; + + while (tail) { + next = tail->next; + talloc_free (tail); + tail = next; + } + } } void @@ -618,7 +640,7 @@ _glcpp_parser_print_expanded_token (glcpp_parser_t *parser, /* We only expand identifiers */ if (token->type != IDENTIFIER) { - _token_print (token); + _glcpp_parser_print_token (parser, token); return 0; } @@ -719,6 +741,8 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) if (node->token->type == ',' && paren_count == 1) { + if (argument) + _token_list_trim_trailing_space (argument); argument = NULL; } else { @@ -834,6 +858,8 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, if (list == NULL) return; + _token_list_trim_trailing_space (list); + for (node = list->head; node; node = node->next) { if (_glcpp_parser_print_expanded_token (parser, node->token)) _glcpp_parser_print_expanded_function (parser, &node); diff --git a/glcpp.h b/glcpp.h index 6bd6e66a7cc..21db918cdce 100644 --- a/glcpp.h +++ b/glcpp.h @@ -72,6 +72,7 @@ typedef struct token_node { struct token_list { token_node_t *head; token_node_t *tail; + token_node_t *non_space_tail; }; typedef struct argument_node { -- cgit v1.2.3 From 039739b2da0ce8496f6e8d38127c0b3793607afa Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 07:58:59 -0700 Subject: Defer test 26 until much later (to test 55). Supporting embedded newlines in a macro invocation is going to be tricky with our current approach to lexing and parsing. Since this isn't really an important feature for us, we can defer this until more important things are resolved. With this test out of the way, tests 27 through 31 are passing. --- tests/026-define-func-extra-newlines.c | 6 ------ tests/055-define-func-extra-newlines.c | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 tests/026-define-func-extra-newlines.c create mode 100644 tests/055-define-func-extra-newlines.c diff --git a/tests/026-define-func-extra-newlines.c b/tests/026-define-func-extra-newlines.c deleted file mode 100644 index 0d837405309..00000000000 --- a/tests/026-define-func-extra-newlines.c +++ /dev/null @@ -1,6 +0,0 @@ -#define foo(a) bar - -foo -( -1 -) diff --git a/tests/055-define-func-extra-newlines.c b/tests/055-define-func-extra-newlines.c new file mode 100644 index 00000000000..0d837405309 --- /dev/null +++ b/tests/055-define-func-extra-newlines.c @@ -0,0 +1,6 @@ +#define foo(a) bar + +foo +( +1 +) -- cgit v1.2.3 From c0607d573e04846a23c3162901aabd7fc40ebc61 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 08:01:42 -0700 Subject: Check active expansions before expanding a function-like macro invocation. With this fix, test 32 no longer recurses infinitely, but now passes. --- glcpp-parse.y | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 60eaf215b8b..a2bff6e0ada 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -654,11 +654,6 @@ _glcpp_parser_print_expanded_token (glcpp_parser_t *parser, return 0; } - /* For function-like macros return 1 for further processing. */ - if (macro->is_function) { - return 1; - } - /* Finally, don't expand this macro if we're already actively * expanding it, (to avoid infinite recursion). */ if (_string_list_contains (parser->active, identifier, NULL)) { @@ -666,6 +661,11 @@ _glcpp_parser_print_expanded_token (glcpp_parser_t *parser, return 0; } + /* For function-like macros return 1 for further processing. */ + if (macro->is_function) { + return 1; + } + _string_list_push (parser->active, identifier); _glcpp_parser_print_expanded_token_list (parser, macro->replacements); -- cgit v1.2.3 From 0197e9b64f0e64a617537c5ad1465b4a8706fe1c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 08:05:19 -0700 Subject: Change macro expansion to append onto token lists rather than printing directly. This doesn't change any functionality here, but will allow us to make future changes that were not possible with direct printing. Specifically, we need to expand macros within macro arguments before performing argument substitution. And *that* expansion cannot result in immediate printing. --- glcpp-parse.y | 193 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 120 insertions(+), 73 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index a2bff6e0ada..e25cfa92142 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -99,6 +99,11 @@ static void _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, token_list_t *list); +static void +_glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, + token_list_t *list, + token_list_t *result); + static void _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition); @@ -470,55 +475,6 @@ _token_create_ival (void *ctx, int type, int ival) return token; } -void -_glcpp_parser_print_token (glcpp_parser_t *parser, token_t *token) -{ - if (token->type < 256) { - printf ("%c", token->type); - return; - } - - switch (token->type) { - case IDENTIFIER: - case OTHER: - printf ("%s", token->value.str); - break; - case SPACE: - printf (" "); - break; - case LEFT_SHIFT: - printf ("<<"); - break; - case RIGHT_SHIFT: - printf (">>"); - break; - case LESS_OR_EQUAL: - printf ("<="); - break; - case GREATER_OR_EQUAL: - printf (">="); - break; - case EQUAL: - printf ("=="); - break; - case NOT_EQUAL: - printf ("!="); - break; - case AND: - printf ("&&"); - break; - case OR: - printf ("||"); - break; - case PASTE: - printf ("##"); - break; - default: - fprintf (stderr, "Error: Don't know how to print token type %d\n", token->type); - break; - } -} - token_list_t * _token_list_create (void *ctx) { @@ -584,6 +540,67 @@ _token_list_trim_trailing_space (token_list_t *list) } } +static void +_token_print (token_t *token) +{ + if (token->type < 256) { + printf ("%c", token->type); + return; + } + + switch (token->type) { + case IDENTIFIER: + case OTHER: + printf ("%s", token->value.str); + break; + case SPACE: + printf (" "); + break; + case LEFT_SHIFT: + printf ("<<"); + break; + case RIGHT_SHIFT: + printf (">>"); + break; + case LESS_OR_EQUAL: + printf ("<="); + break; + case GREATER_OR_EQUAL: + printf (">="); + break; + case EQUAL: + printf ("=="); + break; + case NOT_EQUAL: + printf ("!="); + break; + case AND: + printf ("&&"); + break; + case OR: + printf ("||"); + break; + case PASTE: + printf ("##"); + break; + default: + fprintf (stderr, "Error: Don't know how to print token type %d\n", token->type); + break; + } +} + +static void +_token_list_print (token_list_t *list) +{ + token_node_t *node; + + if (list == NULL) + return; + + for (node = list->head; node; node = node->next) + _token_print (node->token); +} + void yyerror (void *scanner, const char *error) { @@ -624,23 +641,26 @@ glcpp_parser_destroy (glcpp_parser_t *parser) talloc_free (parser); } -/* Print a non-macro token, or the expansion of an object-like macro. +/* Appends onto 'expansion' a non-macro token or the expansion of an + * object-like macro. * - * Returns 0 if this token is completely printed. + * Returns 0 if this token is completely processed. * * Returns 1 in the case that 'token' is a function-like macro that * needs further expansion. */ static int -_glcpp_parser_print_expanded_token (glcpp_parser_t *parser, - token_t *token) +_glcpp_parser_expand_token_onto (glcpp_parser_t *parser, + token_t *token, + token_list_t *result) { const char *identifier; macro_t *macro; + token_list_t *expansion; /* We only expand identifiers */ if (token->type != IDENTIFIER) { - _glcpp_parser_print_token (parser, token); + _token_list_append (result, token); return 0; } @@ -648,16 +668,16 @@ _glcpp_parser_print_expanded_token (glcpp_parser_t *parser, identifier = token->value.str; macro = hash_table_find (parser->defines, identifier); - /* Not a macro, so just print directly. */ + /* Not a macro, so just append. */ if (macro == NULL) { - printf ("%s", identifier); + _token_list_append (result, token); return 0; } /* Finally, don't expand this macro if we're already actively * expanding it, (to avoid infinite recursion). */ if (_string_list_contains (parser->active, identifier, NULL)) { - printf ("%s", identifier); + _token_list_append (result, token); return 0; } @@ -667,8 +687,9 @@ _glcpp_parser_print_expanded_token (glcpp_parser_t *parser, } _string_list_push (parser->active, identifier); - _glcpp_parser_print_expanded_token_list (parser, - macro->replacements); + _glcpp_parser_expand_token_list_onto (parser, + macro->replacements, + result); _string_list_pop (parser->active); return 0; @@ -770,15 +791,16 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) * list as necessary). Upon return *node will be the last consumed * node, such that further processing can continue with node->next. */ static void -_glcpp_parser_print_expanded_function (glcpp_parser_t *parser, - token_node_t **node_ret) +_glcpp_parser_expand_function_onto (glcpp_parser_t *parser, + token_node_t **node_ret, + token_list_t *result) { macro_t *macro; token_node_t *node; const char *identifier; argument_list_t *arguments; function_status_t status; - token_list_t *expanded; + token_list_t *substituted; token_node_t *i, *j; int parameter_index; @@ -796,7 +818,7 @@ _glcpp_parser_print_expanded_function (glcpp_parser_t *parser, case FUNCTION_STATUS_SUCCESS: break; case FUNCTION_NOT_A_FUNCTION: - printf ("%s", identifier); + _token_list_append (result, node->token); return; case FUNCTION_UNBALANCED_PARENTHESES: fprintf (stderr, "Error: Macro %s call has unbalanced parentheses\n", @@ -809,7 +831,6 @@ _glcpp_parser_print_expanded_function (glcpp_parser_t *parser, return; } - if (_argument_list_length (arguments) != _string_list_length (macro->parameters)) { @@ -821,7 +842,8 @@ _glcpp_parser_print_expanded_function (glcpp_parser_t *parser, return; } - expanded = _token_list_create (arguments); + /* Perform argument substitution on the replacement list. */ + substituted = _token_list_create (arguments); for (i = macro->replacements->head; i; i = i->next) { if (i->token->type == IDENTIFIER && @@ -834,36 +856,61 @@ _glcpp_parser_print_expanded_function (glcpp_parser_t *parser, parameter_index); for (j = argument->head; j; j = j->next) { - _token_list_append (expanded, j->token); + _token_list_append (substituted, j->token); } } else { - _token_list_append (expanded, i->token); + _token_list_append (substituted, i->token); } } _string_list_push (parser->active, identifier); - _glcpp_parser_print_expanded_token_list (parser, expanded); + _glcpp_parser_expand_token_list_onto (parser, substituted, result); _string_list_pop (parser->active); talloc_free (arguments); } +static void +_glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, + token_list_t *list, + token_list_t *result) +{ + token_node_t *node; + + if (list == NULL) + return; + + for (node = list->head; node; node = node->next) + { + if (_glcpp_parser_expand_token_onto (parser, node->token, + result)) + { + _glcpp_parser_expand_function_onto (parser, &node, + result); + } + } +} + void _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, token_list_t *list) { + token_list_t *expanded; token_node_t *node; function_status_t function_status; if (list == NULL) return; - _token_list_trim_trailing_space (list); + expanded = _token_list_create (parser); - for (node = list->head; node; node = node->next) { - if (_glcpp_parser_print_expanded_token (parser, node->token)) - _glcpp_parser_print_expanded_function (parser, &node); - } + _glcpp_parser_expand_token_list_onto (parser, list, expanded); + + _token_list_trim_trailing_space (expanded); + + _token_list_print (expanded); + + talloc_free (expanded); } void -- cgit v1.2.3 From d5cd40343f4a83d3270cb87ef38e85dcb9682e8c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 08:09:29 -0700 Subject: Expand macro arguments before performing argument substitution. As required by the C99 specification of the preprocessor. With this fix, tests 33 through 36 now pass. --- glcpp-parse.y | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index e25cfa92142..3b736f8e64d 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -854,10 +854,11 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, token_list_t *argument; argument = _argument_list_member_at (arguments, parameter_index); - for (j = argument->head; j; j = j->next) - { - _token_list_append (substituted, j->token); - } + /* Before substituting, we expand the argument + * tokens. */ + _glcpp_parser_expand_token_list_onto (parser, + argument, + substituted); } else { _token_list_append (substituted, i->token); } -- cgit v1.2.3 From b1ae61a2ee1bf2ba733dca417b0268b1106d83cf Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 08:10:38 -0700 Subject: Fix a typo in a comment. Always better to use proper grammar in our grammar. --- glcpp-parse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 3b736f8e64d..5b792a976e6 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -85,7 +85,7 @@ _token_create_ival (void *ctx, int type, int ival); static token_list_t * _token_list_create (void *ctx); -/* Note: This function add a talloc_reference() to token. +/* Note: This function adds a talloc_reference() to token. * * You may want to talloc_unlink any current reference if you no * longer need it. */ -- cgit v1.2.3 From c9dcc08d4512370b6fef6370afb8bcdb0ecd9292 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 08:11:08 -0700 Subject: README: Document some known limitations. None of these are fundamental---just a few things that haven't been implemented yet. --- README | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README b/README index ba833a49ffb..f0f64c2644a 100644 --- a/README +++ b/README @@ -12,3 +12,15 @@ preprocessors". To fill in these details, I've been using the C99 standard (for which I had a convenient copy) as available from: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf + +Known limitations +----------------- +Macro invocations cannot include embedded newlines. + +The __LINE__, __FILE__, and __VERSION__ macros are not yet supported. + +The argument of the 'defined' operator cannot yet include enclosing +parentheses. + +The #error, #pragma, #extension, #version, and #line macros are not +yet supported. -- cgit v1.2.3 From ec4ada01c01338ae1deab634cf62f24344bdbd3a Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 08:15:49 -0700 Subject: Prevent unexpanded macros from being expanded again in the future. With this fix, tests 37 - 39 now pass. --- glcpp-parse.y | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 5b792a976e6..ec104330631 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -676,8 +676,17 @@ _glcpp_parser_expand_token_onto (glcpp_parser_t *parser, /* Finally, don't expand this macro if we're already actively * expanding it, (to avoid infinite recursion). */ - if (_string_list_contains (parser->active, identifier, NULL)) { - _token_list_append (result, token); + if (_string_list_contains (parser->active, identifier, NULL)) + { + /* We change the token type here from IDENTIFIER to + * OTHER to prevent any future expansion of this + * unexpanded token. */ + char *str; + token_t *new_token; + + str = xtalloc_strdup (result, token->value.str); + new_token = _token_create_str (result, OTHER, str); + _token_list_append (result, new_token); return 0; } -- cgit v1.2.3 From 63909fc19654ddb3ef339bcceed9cbf6e6a057bc Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 08:16:56 -0700 Subject: Remove some stale token types. All the code referencing these was removed some time ago. --- glcpp-parse.y | 3 --- 1 file changed, 3 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index ec104330631..04e78b1826f 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -132,9 +132,6 @@ glcpp_parser_lex (glcpp_parser_t *parser); %type preprocessing_token %type pp_tokens replacement_list text_line - /* Stale stuff just to allow code to compile. */ -%token IDENTIFIER_FINALIZED FUNC_MACRO OBJ_MACRO - %% input: -- cgit v1.2.3 From ce540f2571a449a3620bd3672bfb93b39cef71e1 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 08:25:44 -0700 Subject: Rename identifier from 'i' to 'node'. Now that we no longer have nested for loops with 'i' and 'j' we can use the 'node' that we already have. --- glcpp-parse.y | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 04e78b1826f..5f59b5b006f 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -807,7 +807,6 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, argument_list_t *arguments; function_status_t status; token_list_t *substituted; - token_node_t *i, *j; int parameter_index; node = *node_ret; @@ -851,10 +850,11 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, /* Perform argument substitution on the replacement list. */ substituted = _token_list_create (arguments); - for (i = macro->replacements->head; i; i = i->next) { - if (i->token->type == IDENTIFIER && + for (node = macro->replacements->head; node; node = node->next) + { + if (node->token->type == IDENTIFIER && _string_list_contains (macro->parameters, - i->token->value.str, + node->token->value.str, ¶meter_index)) { token_list_t *argument; @@ -866,7 +866,7 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, argument, substituted); } else { - _token_list_append (substituted, i->token); + _token_list_append (substituted, node->token); } } -- cgit v1.2.3 From ad0dee6bb0f197b9addb45f38e8843d6a504723c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 09:04:50 -0700 Subject: Implement token pasting. Which makes test 40 now pass. --- glcpp-parse.y | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/glcpp-parse.y b/glcpp-parse.y index 5f59b5b006f..330d3ab3bc4 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -586,6 +586,86 @@ _token_print (token_t *token) } } +/* Change 'token' into a new token formed by pasting 'other'. */ +static void +_token_paste (token_t *token, token_t *other) +{ + /* A very few single-character punctuators can be combined + * with another to form a multi-character punctuator. */ + switch (token->type) { + case '<': + if (other->type == '<') { + token->type = LEFT_SHIFT; + token->value.ival = LEFT_SHIFT; + return; + } else if (other->type == '=') { + token->type = LESS_OR_EQUAL; + token->value.ival = LESS_OR_EQUAL; + return; + } + break; + case '>': + if (other->type == '>') { + token->type = RIGHT_SHIFT; + token->value.ival = RIGHT_SHIFT; + return; + } else if (other->type == '=') { + token->type = GREATER_OR_EQUAL; + token->value.ival = GREATER_OR_EQUAL; + return; + } + break; + case '=': + if (other->type == '=') { + token->type = EQUAL; + token->value.ival = EQUAL; + return; + } + break; + case '!': + if (other->type == '=') { + token->type = NOT_EQUAL; + token->value.ival = NOT_EQUAL; + return; + } + break; + case '&': + if (other->type == '&') { + token->type = AND; + token->value.ival = AND; + return; + } + break; + case '|': + if (other->type == '|') { + token->type = OR; + token->value.ival = OR; + return; + } + break; + } + + /* Two string-valued tokens can usually just be mashed + * together. + * + * XXX: Since our 'OTHER' case is currently so loose, this may + * allow some things thruogh that should be treated as + * errors. */ + if ((token->type == IDENTIFIER || token->type == OTHER) && + (other->type == IDENTIFIER || other->type == OTHER)) + { + token->value.str = talloc_strdup_append (token->value.str, + other->value.str); + return; + } + + printf ("Error: Pasting \""); + _token_print (token); + printf ("\" and \""); + _token_print (other); + printf ("\" does not give a valid preprocessing token.\n"); +} + static void _token_list_print (token_list_t *list) { @@ -870,6 +950,43 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, } } + /* After argument substitution, and before further expansion + * below, implement token pasting. */ + + node = substituted->head; + while (node) + { + token_node_t *next_non_space; + + /* Look ahead for a PASTE token, skipping space. */ + next_non_space = node->next; + while (next_non_space && next_non_space->token->type == SPACE) + next_non_space = next_non_space->next; + + if (next_non_space == NULL) + break; + + if (next_non_space->token->type != PASTE) { + node = next_non_space; + continue; + } + + /* Now find the next non-space token after the PASTE. */ + next_non_space = next_non_space->next; + while (next_non_space && next_non_space->token->type == SPACE) + next_non_space = next_non_space->next; + + if (next_non_space == NULL) { + fprintf (stderr, "Error: '##' cannot appear at either end of a macro expansion\n"); + exit (1); + } + + _token_paste (node->token, next_non_space->token); + node->next = next_non_space->next; + + node = node->next; + } + _string_list_push (parser->active, identifier); _glcpp_parser_expand_token_list_onto (parser, substituted, result); _string_list_pop (parser->active); -- cgit v1.2.3 From 8fed1cddae8b024972d0c08f120bfd0292cb9cca Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 09:32:12 -0700 Subject: stash --- glcpp-lex.l | 40 +++++++++++++++++ glcpp-parse.y | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 176 insertions(+), 5 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 516f42dee32..97f01d06368 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -62,11 +62,47 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return HASH_UNDEF; } +{HASH}if { + yyextra->space_tokens = 0; + return HASH_IF; +} + +{HASH}elif { + yyextra->space_tokens = 0; + return HASH_ELIF; +} + +{HASH}else { + yyextra->space_tokens = 0; + return HASH_ELSE; +} + +{HASH}endif { + yyextra->space_tokens = 0; + return HASH_ENDIF; +} + {HASH} { yyextra->space_tokens = 0; return HASH; } +{DECIMAL_INTEGER} { + yylval.ival = strtoll (yytext, NULL, 10); + return INTEGER; +} + +{OCTAL_INTEGER} { + yylval.ival = strtoll (yytext + 1, NULL, 8); + return INTEGER; +} + +{HEXADECIMAL_INTEGER} { + yylval.ival = strtoll (yytext + 2, NULL, 16); + return INTEGER; +} + + {IDENTIFIER} { yylval.str = xtalloc_strdup (yyextra, yytext); return IDENTIFIER; @@ -108,6 +144,10 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return PASTE; } +"defined" { + return DEFINED; +} + {PUNCTUATION} { return yytext[0]; } diff --git a/glcpp-parse.y b/glcpp-parse.y index 330d3ab3bc4..58e1e655fdb 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -25,6 +25,7 @@ #include #include #include +#include #include "glcpp.h" @@ -124,27 +125,46 @@ glcpp_parser_lex (glcpp_parser_t *parser); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_UNDEF IDENTIFIER NEWLINE OTHER SPACE -%token LEFT_SHIFT RIGHT_SHIFT LESS_OR_EQUAL GREATER_OR_EQUAL EQUAL NOT_EQUAL AND OR PASTE -%type punctuator SPACE +%token DEFINED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER INTEGER NEWLINE OTHER SPACE +%token PASTE +%type expression INTEGER punctuator SPACE %type IDENTIFIER OTHER %type identifier_list %type preprocessing_token %type pp_tokens replacement_list text_line +%left OR +%left AND +%left '|' +%left '^' +%left '&' +%left EQUAL NOT_EQUAL +%left '<' '>' LESS_OR_EQUAL GREATER_OR_EQUAL +%left LEFT_SHIFT RIGHT_SHIFT +%left '+' '-' +%left '*' '/' '%' +%right UNARY %% input: /* empty */ | input line { - printf ("\n"); + if (parser->skip_stack == NULL || + parser->skip_stack->type == SKIP_NO_SKIP) + { + printf ("\n"); + } } ; line: control_line | text_line { - _glcpp_parser_print_expanded_token_list (parser, $1); + if (parser->skip_stack == NULL || + parser->skip_stack->type == SKIP_NO_SKIP) + { + _glcpp_parser_print_expanded_token_list (parser, $1); + } talloc_free ($1); } | HASH non_directive @@ -171,9 +191,114 @@ control_line: } talloc_free ($2); } +| HASH_IF expression NEWLINE { + _glcpp_parser_skip_stack_push_if (parser, $2); + } +| HASH_IFDEF IDENTIFIER NEWLINE { + string_list_t *macro = hash_table_find (parser->defines, $2); + talloc_free ($2); + _glcpp_parser_skip_stack_push_if (parser, macro != NULL); + } +| HASH_IFNDEF IDENTIFIER NEWLINE { + string_list_t *macro = hash_table_find (parser->defines, $2); + talloc_free ($2); + _glcpp_parser_skip_stack_push_if (parser, macro == NULL); + } +| HASH_ELIF expression NEWLINE { + _glcpp_parser_skip_stack_change_if (parser, "#elif", $2); + } +| HASH_ELSE NEWLINE { + _glcpp_parser_skip_stack_change_if (parser, "else", 1); + } +| HASH_ENDIF NEWLINE { + _glcpp_parser_skip_stack_pop (parser); + } | HASH NEWLINE ; +expression: + INTEGER { + $$ = $1; + } +| expression OR expression { + $$ = $1 || $3; + } +| expression AND expression { + $$ = $1 && $3; + } +| expression '|' expression { + $$ = $1 | $3; + } +| expression '^' expression { + $$ = $1 ^ $3; + } +| expression '&' expression { + $$ = $1 & $3; + } +| expression NOT_EQUAL expression { + $$ = $1 != $3; + } +| expression EQUAL expression { + $$ = $1 == $3; + } +| expression GREATER_OR_EQUAL expression { + $$ = $1 >= $3; + } +| expression LESS_OR_EQUAL expression { + $$ = $1 <= $3; + } +| expression '>' expression { + $$ = $1 > $3; + } +| expression '<' expression { + $$ = $1 < $3; + } +| expression RIGHT_SHIFT expression { + $$ = $1 >> $3; + } +| expression LEFT_SHIFT expression { + $$ = $1 << $3; + } +| expression '-' expression { + $$ = $1 - $3; + } +| expression '+' expression { + $$ = $1 + $3; + } +| expression '%' expression { + $$ = $1 % $3; + } +| expression '/' expression { + $$ = $1 / $3; + } +| expression '*' expression { + $$ = $1 * $3; + } +| '!' expression %prec UNARY { + $$ = ! $2; + } +| '~' expression %prec UNARY { + $$ = ~ $2; + } +| '-' expression %prec UNARY { + $$ = - $2; + } +| '+' expression %prec UNARY { + $$ = + $2; + } +| DEFINED IDENTIFIER %prec UNARY { + string_list_t *macro = hash_table_find (parser->defines, $2); + talloc_free ($2); + if (macro) + $$ = 1; + else + $$ = 0; + } +| '(' expression ')' { + $$ = $2; + } +; + identifier_list: IDENTIFIER { $$ = _string_list_create (parser); @@ -219,6 +344,9 @@ preprocessing_token: IDENTIFIER { $$ = _token_create_str (parser, IDENTIFIER, $1); } +| INTEGER { + $$ = _token_create_ival (parser, INTEGER, $1); + } | punctuator { $$ = _token_create_ival (parser, $1, $1); } @@ -546,6 +674,9 @@ _token_print (token_t *token) } switch (token->type) { + case INTEGER: + printf ("%" PRIxMAX, token->value.ival); + break; case IDENTIFIER: case OTHER: printf ("%s", token->value.str); -- cgit v1.2.3 From f6914fd37b2b66d7be1ba0c31450d89d1785ccce Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 09:32:57 -0700 Subject: Implement #if and friends. With this change, tests 41 through 49 all pass. (The defined operator appears to be somehow broken so that test 50 doesn't pass yet.) --- glcpp.h | 2 +- tests/049-if-expression-precedence.c | 1 - tests/050-if-defined.c | 2 -- tests/glcpp-test | 2 +- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/glcpp.h b/glcpp.h index 21db918cdce..36ab0e7ca5c 100644 --- a/glcpp.h +++ b/glcpp.h @@ -49,7 +49,7 @@ typedef struct token_list token_list_t; typedef union YYSTYPE { - int ival; + intmax_t ival; char *str; string_list_t *string_list; token_t *token; diff --git a/tests/049-if-expression-precedence.c b/tests/049-if-expression-precedence.c index cea935220fd..833ea03882a 100644 --- a/tests/049-if-expression-precedence.c +++ b/tests/049-if-expression-precedence.c @@ -3,4 +3,3 @@ failure with operator precedence #else success #endif - diff --git a/tests/050-if-defined.c b/tests/050-if-defined.c index 9838cc747d5..34f0f95140e 100644 --- a/tests/050-if-defined.c +++ b/tests/050-if-defined.c @@ -15,5 +15,3 @@ failure_3 #else success_3 #endif - - diff --git a/tests/glcpp-test b/tests/glcpp-test index 63041552104..bf88d4462e1 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -6,5 +6,5 @@ for test in *.c; do ../glcpp < $test > $test.out gcc -E $test -o $test.gcc grep -v '^#' < $test.gcc > $test.expected - diff -u $test.expected $test.out + diff -B -u $test.expected $test.out done -- cgit v1.2.3 From 16c1e980e2e3c8852ce9bea85afe094c24e420fa Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 09:35:34 -0700 Subject: Fix lexing of "defined" as an operator, not an identifier. Simply need to move the rule for IDENTIFIER to be after "defined" and everything is happy. With this change, tests 50 through 53 all pass now. --- glcpp-lex.l | 11 +++++------ tests/053-if-divide-and-shift.c | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 97f01d06368..d6b7726d36d 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -102,12 +102,6 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return INTEGER; } - -{IDENTIFIER} { - yylval.str = xtalloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - "<<" { return LEFT_SHIFT; } @@ -148,6 +142,11 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return DEFINED; } +{IDENTIFIER} { + yylval.str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; +} + {PUNCTUATION} { return yytext[0]; } diff --git a/tests/053-if-divide-and-shift.c b/tests/053-if-divide-and-shift.c index ddc1573ab26..d24c54a88d1 100644 --- a/tests/053-if-divide-and-shift.c +++ b/tests/053-if-divide-and-shift.c @@ -13,4 +13,3 @@ failure_3 #else success_3 #endif - -- cgit v1.2.3 From 8e82fcb070d5fae0ec2c763cee4cea225b459664 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 11:15:21 -0700 Subject: Implement (and test) support for macro expansion within conditional expressions. To do this we have split the existing "HASH_IF expression" into two productions: First is HASH_IF pp_tokens which simply constructs a list of tokens. Then, with that resulting token list, we first evaluate all DEFINED operator tokens, then expand all macros, and finally start lexing from the resulting token list. This brings us to the second production, IF_EXPANDED expression This final production works just like our previous "HASH_IF expression", evaluating a constant integer expression. The new test (54) added for this case now passes. --- glcpp-parse.y | 155 ++++++++++++++++++++++++++++++++++++++------- glcpp.h | 2 + tests/054-if-with-macros.c | 34 ++++++++++ 3 files changed, 169 insertions(+), 22 deletions(-) create mode 100644 tests/054-if-with-macros.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 58e1e655fdb..cce8a70156f 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -96,6 +96,10 @@ _token_list_append (token_list_t *list, token_t *token); static void _token_list_append_list (token_list_t *list, token_list_t *tail); +static void +_glcpp_parser_evaluate_defined (glcpp_parser_t *parser, + token_list_t *list); + static void _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, token_list_t *list); @@ -120,14 +124,17 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser); static int glcpp_parser_lex (glcpp_parser_t *parser); +static void +glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); + %} %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token DEFINED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER INTEGER NEWLINE OTHER SPACE +%token DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER NEWLINE OTHER SPACE %token PASTE -%type expression INTEGER punctuator SPACE +%type expression INTEGER operator SPACE %type IDENTIFIER OTHER %type identifier_list %type preprocessing_token @@ -148,28 +155,39 @@ glcpp_parser_lex (glcpp_parser_t *parser); input: /* empty */ -| input line { +| input line +; + +line: + control_line { if (parser->skip_stack == NULL || parser->skip_stack->type == SKIP_NO_SKIP) { printf ("\n"); } } -; - -line: - control_line | text_line { if (parser->skip_stack == NULL || parser->skip_stack->type == SKIP_NO_SKIP) { _glcpp_parser_print_expanded_token_list (parser, $1); + printf ("\n"); } talloc_free ($1); } +| expanded_line | HASH non_directive ; +expanded_line: + IF_EXPANDED expression NEWLINE { + _glcpp_parser_skip_stack_push_if (parser, $2); + } +| ELIF_EXPANDED expression NEWLINE { + _glcpp_parser_skip_stack_change_if (parser, "elif", $2); + } +; + control_line: HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE { _define_object_macro (parser, $2, $3); @@ -191,8 +209,17 @@ control_line: } talloc_free ($2); } -| HASH_IF expression NEWLINE { - _glcpp_parser_skip_stack_push_if (parser, $2); +| HASH_IF pp_tokens NEWLINE { + token_list_t *expanded; + token_t *token; + + expanded = _token_list_create (parser); + token = _token_create_ival (parser, IF_EXPANDED, IF_EXPANDED); + _token_list_append (expanded, token); + talloc_unlink (parser, token); + _glcpp_parser_evaluate_defined (parser, $2); + _glcpp_parser_expand_token_list_onto (parser, $2, expanded); + glcpp_parser_lex_from (parser, expanded); } | HASH_IFDEF IDENTIFIER NEWLINE { string_list_t *macro = hash_table_find (parser->defines, $2); @@ -204,8 +231,17 @@ control_line: talloc_free ($2); _glcpp_parser_skip_stack_push_if (parser, macro == NULL); } -| HASH_ELIF expression NEWLINE { - _glcpp_parser_skip_stack_change_if (parser, "#elif", $2); +| HASH_ELIF pp_tokens NEWLINE { + token_list_t *expanded; + token_t *token; + + expanded = _token_list_create (parser); + token = _token_create_ival (parser, ELIF_EXPANDED, ELIF_EXPANDED); + _token_list_append (expanded, token); + talloc_unlink (parser, token); + _glcpp_parser_evaluate_defined (parser, $2); + _glcpp_parser_expand_token_list_onto (parser, $2, expanded); + glcpp_parser_lex_from (parser, expanded); } | HASH_ELSE NEWLINE { _glcpp_parser_skip_stack_change_if (parser, "else", 1); @@ -286,14 +322,6 @@ expression: | '+' expression %prec UNARY { $$ = + $2; } -| DEFINED IDENTIFIER %prec UNARY { - string_list_t *macro = hash_table_find (parser->defines, $2); - talloc_free ($2); - if (macro) - $$ = 1; - else - $$ = 0; - } | '(' expression ')' { $$ = $2; } @@ -347,7 +375,7 @@ preprocessing_token: | INTEGER { $$ = _token_create_ival (parser, INTEGER, $1); } -| punctuator { +| operator { $$ = _token_create_ival (parser, $1, $1); } | OTHER { @@ -358,7 +386,7 @@ preprocessing_token: } ; -punctuator: +operator: '[' { $$ = '['; } | ']' { $$ = ']'; } | '(' { $$ = '('; } @@ -389,6 +417,7 @@ punctuator: | ';' { $$ = ';'; } | ',' { $$ = ','; } | PASTE { $$ = PASTE; } +| DEFINED { $$ = DEFINED; } ; %% @@ -830,6 +859,9 @@ glcpp_parser_create (void) parser->skip_stack = NULL; + parser->lex_from_list = NULL; + parser->lex_from_node = NULL; + return parser; } @@ -849,6 +881,39 @@ glcpp_parser_destroy (glcpp_parser_t *parser) talloc_free (parser); } +/* Replace any occurences of DEFINED tokens in 'list' with either a + * '0' or '1' INTEGER token depending on whether the next token in the + * list is defined or not. */ +static void +_glcpp_parser_evaluate_defined (glcpp_parser_t *parser, + token_list_t *list) +{ + token_node_t *node, *next; + string_list_t *macro; + + if (list == NULL) + return; + + for (node = list->head; node; node = node->next) { + if (node->token->type != DEFINED) + continue; + next = node->next; + while (next && next->token->type == SPACE) + next = next->next; + if (next == NULL || next->token->type != IDENTIFIER) { + fprintf (stderr, "Error: operator \"defined\" requires an identifier\n"); + exit (1); + } + macro = hash_table_find (parser->defines, + next->token->value.str); + + node->token->type = INTEGER; + node->token->value.ival = (macro != NULL); + node->next = next->next; + } +} + + /* Appends onto 'expansion' a non-macro token or the expansion of an * object-like macro. * @@ -1206,7 +1271,53 @@ _define_function_macro (glcpp_parser_t *parser, static int glcpp_parser_lex (glcpp_parser_t *parser) { - return glcpp_lex (parser->scanner); + token_node_t *node; + int ret; + + if (parser->lex_from_list == NULL) + return glcpp_lex (parser->scanner); + + node = parser->lex_from_node; + + if (node == NULL) { + talloc_free (parser->lex_from_list); + parser->lex_from_list = NULL; + return NEWLINE; + } + + yylval = node->token->value; + ret = node->token->type; + + parser->lex_from_node = node->next; + + return ret; +} + +static void +glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list) +{ + token_node_t *node; + + assert (parser->lex_from_list == NULL); + + /* Copy list, eliminating any space tokens. */ + parser->lex_from_list = _token_list_create (parser); + + for (node = list->head; node; node = node->next) { + if (node->token->type == SPACE) + continue; + _token_list_append (parser->lex_from_list, node->token); + } + + talloc_free (list); + + parser->lex_from_node = parser->lex_from_list->head; + + /* It's possible the list consisted of nothing but whitespace. */ + if (parser->lex_from_node == NULL) { + talloc_free (parser->lex_from_list); + parser->lex_from_list = NULL; + } } static void diff --git a/glcpp.h b/glcpp.h index 36ab0e7ca5c..e5be1a6cd62 100644 --- a/glcpp.h +++ b/glcpp.h @@ -129,6 +129,8 @@ struct glcpp_parser { string_list_t *active; int space_tokens; skip_node_t *skip_stack; + token_list_t *lex_from_list; + token_node_t *lex_from_node; }; glcpp_parser_t * diff --git a/tests/054-if-with-macros.c b/tests/054-if-with-macros.c new file mode 100644 index 00000000000..3da79a0d96e --- /dev/null +++ b/tests/054-if-with-macros.c @@ -0,0 +1,34 @@ +#define one 1 +#define two 2 +#define three 3 +#define five 5 +#if five < two +failure_1 +#else +success_1 +#endif +#if three >= two +success_2 +#else +failure_2 +#endif +#if two + three <= five +success_3 +#else +failure_3 +#endif +#if five - two == three +success_4 +#else +failure_4 +#endif +#if one > three +failure_5 +#else +success_5 +#endif +#if one != five +success_6 +#else +failure_6 +#endif -- cgit v1.2.3 From 70fe8b66632f4afd87ebb12a450b1e639428e88f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 19 May 2010 11:37:35 +0200 Subject: Begin refactoring ir_dereference Create separate subclasses of ir_dereference for variable, array, and record dereferences. As a side effect, array and record dereferences no longer point to ir_variable objects directly. Instead they each point to an ir_dereference_variable object. This is the first of several steps in the refactoring process. The intention is that ir_dereference will eventually become an abstract base class. --- ast_function.cpp | 2 +- ast_to_hir.cpp | 37 ++++++--------- glsl_types.cpp | 42 +++++++++-------- hir_field_selection.cpp | 3 +- ir.cpp | 107 +++++++++++++++++++++---------------------- ir.h | 67 +++++++++++++++++++++++---- ir_expression_flattening.cpp | 4 +- ir_function_inlining.cpp | 38 +++++++-------- ir_reader.cpp | 19 +++----- 9 files changed, 177 insertions(+), 142 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 7931633c5a1..300108cb73e 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -200,7 +200,7 @@ dereference_component(ir_rvalue *src, unsigned component) const int c = component / src->type->column_type()->vector_elements; const int r = component % src->type->column_type()->vector_elements; ir_constant *const col_index = new ir_constant(glsl_type::int_type, &c); - ir_dereference *const col = new ir_dereference(src, col_index); + ir_dereference *const col = new ir_dereference_array(src, col_index); col->type = src->type->column_type(); diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 2243d644032..b8128fa8a77 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -535,7 +535,7 @@ get_lvalue_copy(exec_list *instructions, struct _mesa_glsl_parse_state *state, var = new ir_variable(lvalue->type, "_internal_tmp"); var->mode = ir_var_auto; - var_deref = new ir_dereference(var); + var_deref = new ir_dereference_variable(var); do_assignment(instructions, state, var_deref, lvalue, loc); /* Once we've created this temporary, mark it read only so it's no @@ -803,17 +803,17 @@ ast_expression::hir(exec_list *instructions, ir_variable *const tmp = generate_temporary(glsl_type::bool_type, instructions, state); - ir_dereference *const then_deref = new ir_dereference(tmp); + ir_dereference *const then_deref = new ir_dereference_variable(tmp); ir_assignment *const then_assign = new ir_assignment(then_deref, op[1], NULL); stmt->then_instructions.push_tail(then_assign); - ir_dereference *const else_deref = new ir_dereference(tmp); + ir_dereference *const else_deref = new ir_dereference_variable(tmp); ir_assignment *const else_assign = new ir_assignment(else_deref, new ir_constant(false), NULL); stmt->else_instructions.push_tail(else_assign); - result = new ir_dereference(tmp); + result = new ir_dereference_variable(tmp); type = tmp->type; } break; @@ -865,17 +865,17 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; } - ir_dereference *const then_deref = new ir_dereference(tmp); + ir_dereference *const then_deref = new ir_dereference_variable(tmp); ir_assignment *const then_assign = new ir_assignment(then_deref, new ir_constant(true), NULL); stmt->then_instructions.push_tail(then_assign); - ir_dereference *const else_deref = new ir_dereference(tmp); + ir_dereference *const else_deref = new ir_dereference_variable(tmp); ir_assignment *const else_assign = new ir_assignment(else_deref, op[1], NULL); stmt->else_instructions.push_tail(else_assign); - result = new ir_dereference(tmp); + result = new ir_dereference_variable(tmp); type = tmp->type; } break; @@ -996,13 +996,13 @@ ast_expression::hir(exec_list *instructions, instructions->push_tail(stmt); op[1] = this->subexpressions[1]->hir(& stmt->then_instructions, state); - ir_dereference *const then_deref = new ir_dereference(tmp); + ir_dereference *const then_deref = new ir_dereference_variable(tmp); ir_assignment *const then_assign = new ir_assignment(then_deref, op[1], NULL); stmt->then_instructions.push_tail(then_assign); op[2] = this->subexpressions[2]->hir(& stmt->else_instructions, state); - ir_dereference *const else_deref = new ir_dereference(tmp); + ir_dereference *const else_deref = new ir_dereference_variable(tmp); ir_assignment *const else_assign = new ir_assignment(else_deref, op[2], NULL); stmt->else_instructions.push_tail(else_assign); @@ -1028,7 +1028,7 @@ ast_expression::hir(exec_list *instructions, tmp->type = op[1]->type; } - result = new ir_dereference(tmp); + result = new ir_dereference_variable(tmp); type = tmp->type; break; } @@ -1097,18 +1097,9 @@ ast_expression::hir(exec_list *instructions, error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - ir_dereference *const lhs = op[0]->as_dereference(); - ir_instruction *array; - if ((lhs != NULL) - && (lhs->mode == ir_dereference::ir_reference_variable)) { - result = new ir_dereference(lhs->var, op[1]); + ir_instruction *const array = op[0]; - delete op[0]; - array = lhs->var; - } else { - result = new ir_dereference(op[0], op[1]); - array = op[0]; - } + result = new ir_dereference_array(op[0], op[1]); /* Do not use op[0] after this point. Use array. */ @@ -1218,7 +1209,7 @@ ast_expression::hir(exec_list *instructions, ir_variable *var = state->symbols->get_variable(this->primary_expression.identifier); - result = new ir_dereference(var); + result = new ir_dereference_variable(var); if (var != NULL) { type = result->type; @@ -1722,7 +1713,7 @@ ast_declarator_list::hir(exec_list *instructions, ? "attribute" : "varying"); } - ir_dereference *const lhs = new ir_dereference(var); + ir_dereference *const lhs = new ir_dereference_variable(var); ir_rvalue *rhs = decl->initializer->hir(instructions, state); /* Calculate the constant value if this is a const diff --git a/glsl_types.cpp b/glsl_types.cpp index a293ce72860..e1beeefe891 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -171,10 +171,10 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const for (unsigned i = 0; i < length; i++) { ir_dereference *const lhs = (this->base_type == GLSL_TYPE_ARRAY) - ? new ir_dereference(retval, new ir_constant(i)) - : new ir_dereference(retval, fields.structure[i].name); + ? (ir_dereference *) new ir_dereference_array(retval, new ir_constant(i)) + : (ir_dereference *) new ir_dereference_record(retval, fields.structure[i].name); - ir_dereference *const rhs = new ir_dereference(declarations[i]); + ir_dereference *const rhs = new ir_dereference_variable(declarations[i]); ir_instruction *const assign = new ir_assignment(lhs, rhs, NULL); sig->body.push_tail(assign); @@ -182,7 +182,7 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const free(declarations); - ir_dereference *const retref = new ir_dereference(retval); + ir_dereference *const retref = new ir_dereference_variable(retval); ir_instruction *const inst = new ir_return(retref); sig->body.push_tail(inst); @@ -250,15 +250,16 @@ generate_vec_body_from_scalar(exec_list *instructions, /* Generate a single assignment of the parameter to __retval.x and return * __retval.xxxx for however many vector components there are. */ - ir_dereference *const lhs_ref = new ir_dereference(declarations[16]); - ir_dereference *const rhs = new ir_dereference(declarations[0]); + ir_dereference *const lhs_ref = + new ir_dereference_variable(declarations[16]); + ir_dereference *const rhs = new ir_dereference_variable(declarations[0]); ir_swizzle *lhs = new ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); inst = new ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); - ir_dereference *const retref = new ir_dereference(declarations[16]); + ir_dereference *const retref = new ir_dereference_variable(declarations[16]); ir_swizzle *retval = new ir_swizzle(retref, 0, 0, 0, 0, declarations[16]->type->vector_elements); @@ -283,8 +284,9 @@ generate_vec_body_from_N_scalars(exec_list *instructions, * __retval.x and return __retval. */ for (unsigned i = 0; i < vec_type->vector_elements; i++) { - ir_dereference *const lhs_ref = new ir_dereference(declarations[16]); - ir_dereference *const rhs = new ir_dereference(declarations[i]); + ir_dereference *const lhs_ref = + new ir_dereference_variable(declarations[16]); + ir_dereference *const rhs = new ir_dereference_variable(declarations[i]); ir_swizzle *lhs = new ir_swizzle(lhs_ref, i, 0, 0, 0, 1); @@ -292,7 +294,7 @@ generate_vec_body_from_N_scalars(exec_list *instructions, instructions->push_tail(inst); } - ir_dereference *retval = new ir_dereference(declarations[16]); + ir_dereference *retval = new ir_dereference_variable(declarations[16]); inst = new ir_return(retval); instructions->push_tail(inst); @@ -334,8 +336,8 @@ generate_mat_body_from_scalar(exec_list *instructions, instructions->push_tail(column); - ir_dereference *const lhs_ref = new ir_dereference(column); - ir_dereference *const rhs = new ir_dereference(declarations[0]); + ir_dereference *const lhs_ref = new ir_dereference_variable(column); + ir_dereference *const rhs = new ir_dereference_variable(declarations[0]); ir_swizzle *lhs = new ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); @@ -346,7 +348,7 @@ generate_mat_body_from_scalar(exec_list *instructions, ir_constant *const zero = new ir_constant(glsl_type::float_type, &z); for (unsigned i = 1; i < column_type->vector_elements; i++) { - ir_dereference *const lhs_ref = new ir_dereference(column); + ir_dereference *const lhs_ref = new ir_dereference_variable(column); ir_swizzle *lhs = new ir_swizzle(lhs_ref, i, 0, 0, 0, 1); @@ -357,7 +359,7 @@ generate_mat_body_from_scalar(exec_list *instructions, for (unsigned i = 0; i < row_type->vector_elements; i++) { static const unsigned swiz[] = { 1, 1, 1, 0, 1, 1, 1 }; - ir_dereference *const rhs_ref = new ir_dereference(column); + ir_dereference *const rhs_ref = new ir_dereference_variable(column); /* This will be .xyyy when i=0, .yxyy when i=1, etc. */ @@ -366,13 +368,14 @@ generate_mat_body_from_scalar(exec_list *instructions, column_type->vector_elements); ir_constant *const idx = new ir_constant(glsl_type::int_type, &i); - ir_dereference *const lhs = new ir_dereference(declarations[16], idx); + ir_dereference *const lhs = + new ir_dereference_array(declarations[16], idx); inst = new ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); } - ir_dereference *const retval = new ir_dereference(declarations[16]); + ir_dereference *const retval = new ir_dereference_variable(declarations[16]); inst = new ir_return(retval); instructions->push_tail(inst); } @@ -397,20 +400,21 @@ generate_mat_body_from_N_scalars(exec_list *instructions, for (unsigned j = 0; j < row_type->vector_elements; j++) { ir_constant *row_index = new ir_constant(glsl_type::int_type, &i); ir_dereference *const row_access = - new ir_dereference(declarations[16], row_index); + new ir_dereference_array(declarations[16], row_index); ir_swizzle *component_access = new ir_swizzle(row_access, j, 0, 0, 0, 1); const unsigned param = (i * row_type->vector_elements) + j; - ir_dereference *const rhs = new ir_dereference(declarations[param]); + ir_dereference *const rhs = + new ir_dereference_variable(declarations[param]); inst = new ir_assignment(component_access, rhs, NULL); instructions->push_tail(inst); } } - ir_dereference *retval = new ir_dereference(declarations[16]); + ir_dereference *retval = new ir_dereference_variable(declarations[16]); inst = new ir_return(retval); instructions->push_tail(inst); diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 685cf75dcf0..f0be84dab4c 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -62,7 +62,8 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, expr->primary_expression.identifier); } } else if (op->type->base_type == GLSL_TYPE_STRUCT) { - result = new ir_dereference(op, expr->primary_expression.identifier); + result = new ir_dereference_record(op, + expr->primary_expression.identifier); if (result->type->is_error()) { _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " diff --git a/ir.cpp b/ir.cpp index 696feb23f6f..f6f2558bc06 100644 --- a/ir.cpp +++ b/ir.cpp @@ -223,22 +223,40 @@ ir_constant::ir_constant(bool b) } -ir_dereference::ir_dereference(ir_instruction *var) +ir_dereference_variable::ir_dereference_variable(ir_variable *var) + : ir_dereference(ir_reference_variable) { - this->mode = ir_reference_variable; this->var = var; this->type = (var != NULL) ? var->type : glsl_type::error_type; } -ir_dereference::ir_dereference(ir_instruction *var, - ir_rvalue *array_index) - : mode(ir_reference_array), var(var) +ir_dereference_array::ir_dereference_array(ir_rvalue *value, + ir_rvalue *array_index) + : ir_dereference(ir_reference_array) { - type = glsl_type::error_type; + this->selector.array_index = array_index; + this->set_array(value); +} + + +ir_dereference_array::ir_dereference_array(ir_variable *var, + ir_rvalue *array_index) + : ir_dereference(ir_reference_array) +{ + this->selector.array_index = array_index; + this->set_array(new ir_dereference_variable(var)); +} + + +void +ir_dereference_array::set_array(ir_rvalue *value) +{ + this->var = value; + this->type = glsl_type::error_type; - if (var != NULL) { - const glsl_type *const vt = var->type; + if (this->var != NULL) { + const glsl_type *const vt = this->var->type; if (vt->is_array()) { type = vt->element_type(); @@ -248,68 +266,45 @@ ir_dereference::ir_dereference(ir_instruction *var, type = vt->get_base_type(); } } +} - this->selector.array_index = array_index; + +ir_dereference_record::ir_dereference_record(ir_rvalue *value, + const char *field) + : ir_dereference(ir_reference_record) +{ + this->var = value; + this->selector.field = field; + this->type = (this->var != NULL) + ? this->var->type->field_type(field) : glsl_type::error_type; } -ir_dereference::ir_dereference(ir_instruction *variable, const char *field) - : mode(ir_reference_record), var(variable) + +ir_dereference_record::ir_dereference_record(ir_variable *var, + const char *field) + : ir_dereference(ir_reference_record) { + this->var = new ir_dereference_variable(var); this->selector.field = field; - this->type = (var != NULL) - ? var->type->field_type(field) : glsl_type::error_type; + this->type = (this->var != NULL) + ? this->var->type->field_type(field) : glsl_type::error_type; } + bool ir_dereference::is_lvalue() { - if (var == NULL) - return false; - - ir_variable *const as_var = var->as_variable(); - if (mode == ir_reference_variable) { - if (as_var == NULL) - return false; - - if (as_var->type->is_array() && !as_var->array_lvalue) - return false; - } - - if (as_var != NULL) - return !as_var->read_only; + ir_variable *var = this->variable_referenced(); - /* Walk up the dereference chain and figure out if the variable is read-only. + /* Every l-value derference chain eventually ends in a variable. */ - return this->var->as_rvalue()->is_lvalue(); -} - + if ((var == NULL) || var->read_only) + return false; -ir_variable * -ir_dereference::variable_referenced() -{ - /* Walk down the dereference chain to find the variable at the end. - * - * This could be implemented recurrsively, but it would still need to call - * as_variable and as_rvalue, so the code wouldn't be any cleaner. - */ - for (ir_instruction *current = this->var; current != NULL; /* empty */ ) { - ir_dereference *deref; - ir_variable *v; - - if ((deref = current->as_dereference())) { - current = deref->var; - } else if ((v = current->as_variable())) { - return v; - } else { - /* This is the case of, for example, an array dereference of the - * value returned by a function call. - */ - return NULL; - } - } + if (this->type->is_array() && !var->array_lvalue) + return false; - assert(!"Should not get here."); - return NULL; + return true; } diff --git a/ir.h b/ir.h index 93b4c2b66ab..70fe9f9db6f 100644 --- a/ir.h +++ b/ir.h @@ -788,12 +788,6 @@ public: class ir_dereference : public ir_rvalue { public: - ir_dereference(struct ir_instruction *); - - ir_dereference(ir_instruction *variable, ir_rvalue *array_index); - - ir_dereference(ir_instruction *variable, const char *field); - virtual ir_dereference *as_dereference() { return this; @@ -811,9 +805,9 @@ public: /** * Get the variable that is ultimately referenced by an r-value */ - virtual ir_variable *variable_referenced(); + virtual ir_variable *variable_referenced() = 0; - enum { + enum ir_deref_mode { ir_reference_variable, ir_reference_array, ir_reference_record @@ -830,6 +824,63 @@ public: ir_rvalue *array_index; const char *field; } selector; + +protected: + ir_dereference(ir_deref_mode mode) + : mode(mode) + { + /* empty */ + } +}; + + +class ir_dereference_variable : public ir_dereference { +public: + ir_dereference_variable(ir_variable *var); + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() + { + return (ir_variable *) this->var; + } +}; + + +class ir_dereference_array : public ir_dereference { +public: + ir_dereference_array(ir_rvalue *value, ir_rvalue *array_index); + + ir_dereference_array(ir_variable *var, ir_rvalue *array_index); + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() + { + return ((ir_rvalue *) this->var)->variable_referenced(); + } + + +private: + void set_array(ir_rvalue *value); +}; + + +class ir_dereference_record : public ir_dereference { +public: + ir_dereference_record(ir_rvalue *value, const char *field); + + ir_dereference_record(ir_variable *var, const char *field); + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() + { + return ((ir_rvalue *) this->var)->variable_referenced(); + } }; diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp index 28c96a787de..9494786d4e4 100644 --- a/ir_expression_flattening.cpp +++ b/ir_expression_flattening.cpp @@ -143,12 +143,12 @@ ir_expression_flattening_visitor::visit(ir_expression *ir) var = new ir_variable(ir->operands[operand]->type, "flattening_tmp"); this->base_ir->insert_before(var); - assign = new ir_assignment(new ir_dereference(var), + assign = new ir_assignment(new ir_dereference_variable(var), ir->operands[operand], NULL); this->base_ir->insert_before(assign); - ir->operands[operand] = new ir_dereference(var); + ir->operands[operand] = new ir_dereference_variable(var); } } } diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 09604c04df9..499ce5f1dc2 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -220,28 +220,27 @@ ir_function_cloning_visitor::visit(ir_swizzle *ir) void ir_function_cloning_visitor::visit(ir_dereference *ir) { - ir_variable *old_var = ir->var->as_variable(); - ir_instruction *var; - - if (old_var) - var = this->get_remapped_variable(old_var); - else { - ir->var->accept(this); - var = this->result; - } - if (ir->mode == ir_dereference::ir_reference_variable) { - this->result = new ir_dereference(var); + ir_variable *var = this->get_remapped_variable(ir->variable_referenced()); + this->result = new ir_dereference_variable(var); } else if (ir->mode == ir_dereference::ir_reference_array) { - ir_rvalue *index; + ir->var->accept(this); + + ir_rvalue *var = this->result->as_rvalue(); ir->selector.array_index->accept(this); - index = this->result->as_rvalue(); - this->result = new ir_dereference(var, index); + ir_rvalue *index = this->result->as_rvalue(); + + this->result = new ir_dereference_array(var, index); } else { assert(ir->mode == ir_dereference::ir_reference_record); - this->result = new ir_dereference(var, strdup(ir->selector.field)); + + ir->var->accept(this); + + ir_rvalue *var = this->result->as_rvalue(); + + this->result = new ir_dereference_record(var, strdup(ir->selector.field)); } } @@ -300,7 +299,8 @@ ir_function_cloning_visitor::visit(ir_return *ir) rval = this->result->as_rvalue(); assert(rval); - result = new ir_assignment(new ir_dereference(this->retval), rval, NULL); + result = new ir_assignment(new ir_dereference_variable(this->retval), rval, + NULL); } @@ -406,7 +406,7 @@ ir_call::generate_inline(ir_instruction *next_ir) parameters[i]->mode == ir_var_inout) { ir_assignment *assign; - assign = new ir_assignment(new ir_dereference(parameters[i]), + assign = new ir_assignment(new ir_dereference_variable(parameters[i]), param, NULL); next_ir->insert_before(assign); } @@ -438,7 +438,7 @@ ir_call::generate_inline(ir_instruction *next_ir) ir_assignment *assign; assign = new ir_assignment(param->as_rvalue(), - new ir_dereference(parameters[i]), + new ir_dereference_variable(parameters[i]), NULL); next_ir->insert_before(assign); } @@ -449,7 +449,7 @@ ir_call::generate_inline(ir_instruction *next_ir) delete(parameters); if (retval) - return new ir_dereference(retval); + return new ir_dereference_variable(retval); else return NULL; } diff --git a/ir_reader.cpp b/ir_reader.cpp index 1bf5363f52a..744606d4f2c 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -817,7 +817,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) return NULL; // should not be reached } -static ir_instruction * +static ir_variable * read_dereferencable(_mesa_glsl_parse_state *st, s_expression *expr) { // Read the subject of a dereference - either a variable name or a swizzle @@ -828,15 +828,8 @@ read_dereferencable(_mesa_glsl_parse_state *st, s_expression *expr) ir_read_error(st, expr, "undeclared variable: %s", var_name->value()); } return var; - } else { - // Hopefully a (swiz ...) - s_list *list = SX_AS_LIST(expr); - if (list != NULL && !list->subexpressions.is_empty()) { - s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head); - if (tag != NULL && strcmp(tag->value(), "swiz") == 0) - return read_swizzle(st, list); - } } + ir_read_error(st, expr, "expected variable name or (swiz ...)"); return NULL; } @@ -849,10 +842,10 @@ read_var_ref(_mesa_glsl_parse_state *st, s_list *list) return NULL; } s_expression *subj_expr = (s_expression*) list->subexpressions.head->next; - ir_instruction *subject = read_dereferencable(st, subj_expr); + ir_variable *subject = read_dereferencable(st, subj_expr); if (subject == NULL) return NULL; - return new ir_dereference(subject); + return new ir_dereference_variable(subject); } static ir_dereference * @@ -865,13 +858,13 @@ read_array_ref(_mesa_glsl_parse_state *st, s_list *list) } s_expression *subj_expr = (s_expression*) list->subexpressions.head->next; - ir_instruction *subject = read_dereferencable(st, subj_expr); + ir_variable *subject = read_dereferencable(st, subj_expr); if (subject == NULL) return NULL; s_expression *idx_expr = (s_expression*) subj_expr->next; ir_rvalue *idx = read_rvalue(st, idx_expr); - return new ir_dereference(subject, idx); + return new ir_dereference_array(subject, idx); } static ir_dereference * -- cgit v1.2.3 From f3a002b503542fe2544025c6a42d552fdc4907c2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 19 May 2010 12:02:19 +0200 Subject: Refactor ir_dereference support for ir_hierarchical_visitor Move the accept method for hierarchical visitors from ir_dereference to the derived classes. This was mostly straight-forward, but I suspect that ir_dead_code_local may be broken now. --- ir.h | 7 +++++-- ir_dead_code.cpp | 40 ++++++++++------------------------------ ir_dead_code_local.cpp | 4 +++- ir_hierarchical_visitor.cpp | 25 +++++++++++++++++++++++-- ir_hierarchical_visitor.h | 22 ++++++++++++++++++++-- ir_hv_accept.cpp | 28 ++++++++++++++++++++++------ 6 files changed, 83 insertions(+), 43 deletions(-) diff --git a/ir.h b/ir.h index 70fe9f9db6f..f785ddb6373 100644 --- a/ir.h +++ b/ir.h @@ -798,8 +798,6 @@ public: v->visit(this); } - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - bool is_lvalue(); /** @@ -845,6 +843,8 @@ public: { return (ir_variable *) this->var; } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); }; @@ -862,6 +862,7 @@ public: return ((ir_rvalue *) this->var)->variable_referenced(); } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); private: void set_array(ir_rvalue *value); @@ -881,6 +882,8 @@ public: { return ((ir_rvalue *) this->var)->variable_referenced(); } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); }; diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp index aa8ebf8ad10..2ede7ff0cf4 100644 --- a/ir_dead_code.cpp +++ b/ir_dead_code.cpp @@ -60,14 +60,11 @@ public: class ir_dead_code_visitor : public ir_hierarchical_visitor { public: virtual ir_visitor_status visit(ir_variable *); + virtual ir_visitor_status visit(ir_dereference_variable *); virtual ir_visitor_status visit_enter(ir_function *); - virtual ir_visitor_status visit_enter(ir_dereference *); - virtual ir_visitor_status visit_leave(ir_dereference *); virtual ir_visitor_status visit_leave(ir_assignment *); - ir_dead_code_visitor(void); - variable_entry *get_variable_entry(ir_variable *var); bool (*predicate)(ir_instruction *ir); @@ -75,16 +72,8 @@ public: /* List of variable_entry */ exec_list variable_list; - - /* Depth of derefernce stack. */ - int in_dereference; }; -ir_dead_code_visitor::ir_dead_code_visitor(void) -{ - this->in_dereference = 0; -} - variable_entry * ir_dead_code_visitor::get_variable_entry(ir_variable *var) @@ -106,40 +95,31 @@ ir_visitor_status ir_dead_code_visitor::visit(ir_variable *ir) { variable_entry *entry = this->get_variable_entry(ir); - if (entry) { - if (this->in_dereference) - entry->referenced_count++; - else - entry->declaration = true; - } + if (entry) + entry->declaration = true; return visit_continue; } ir_visitor_status -ir_dead_code_visitor::visit_enter(ir_function *ir) +ir_dead_code_visitor::visit(ir_dereference_variable *ir) { - (void) ir; - return visit_continue_with_parent; -} + ir_variable *const var = ir->variable_referenced(); + variable_entry *entry = this->get_variable_entry(var); + if (entry) + entry->referenced_count++; -ir_visitor_status -ir_dead_code_visitor::visit_enter(ir_dereference *ir) -{ - (void) ir; - this->in_dereference++; return visit_continue; } ir_visitor_status -ir_dead_code_visitor::visit_leave(ir_dereference *ir) +ir_dead_code_visitor::visit_enter(ir_function *ir) { (void) ir; - this->in_dereference--; - return visit_continue; + return visit_continue_with_parent; } diff --git a/ir_dead_code_local.cpp b/ir_dead_code_local.cpp index f101ccb5ec3..668b6f8cd55 100644 --- a/ir_dead_code_local.cpp +++ b/ir_dead_code_local.cpp @@ -64,8 +64,10 @@ public: this->assignments = assignments; } - virtual ir_visitor_status visit(ir_variable *var) + virtual ir_visitor_status visit(ir_dereference_variable *ir) { + ir_variable *const var = ir->variable_referenced(); + foreach_iter(exec_list_iterator, iter, *this->assignments) { assignment_entry *entry = (assignment_entry *)iter.get(); diff --git a/ir_hierarchical_visitor.cpp b/ir_hierarchical_visitor.cpp index 4fec0d7c752..ad474878355 100644 --- a/ir_hierarchical_visitor.cpp +++ b/ir_hierarchical_visitor.cpp @@ -45,6 +45,13 @@ ir_hierarchical_visitor::visit(ir_loop_jump *ir) return visit_continue; } +ir_visitor_status +ir_hierarchical_visitor::visit(ir_dereference_variable *ir) +{ + (void) ir; + return visit_continue; +} + ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_loop *ir) { @@ -116,14 +123,28 @@ ir_hierarchical_visitor::visit_leave(ir_swizzle *ir) } ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_dereference *ir) +ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_dereference_array *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir) { (void) ir; return visit_continue; } ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_dereference *ir) +ir_hierarchical_visitor::visit_leave(ir_dereference_record *ir) { (void) ir; return visit_continue; diff --git a/ir_hierarchical_visitor.h b/ir_hierarchical_visitor.h index daf220906ad..d3ba508cf1c 100644 --- a/ir_hierarchical_visitor.h +++ b/ir_hierarchical_visitor.h @@ -83,6 +83,22 @@ public: virtual ir_visitor_status visit(class ir_variable *); virtual ir_visitor_status visit(class ir_constant *); virtual ir_visitor_status visit(class ir_loop_jump *); + + /** + * ir_dereference_variable isn't technically a leaf, but it is treated as a + * leaf here for a couple reasons. By not automatically visiting the one + * child ir_variable node from the ir_dereference_variable, ir_variable + * nodes can always be handled as variable declarations. Code that used + * non-hierarchical visitors had to set an "in a dereference" flag to + * determine how to handle an ir_variable. By forcing the visitor to + * handle the ir_variable within the ir_dereference_varaible visitor, this + * kludge can be avoided. + * + * In addition, I can envision no use for having separate enter and leave + * methods. Anything that could be done in the enter and leave methods + * that couldn't just be done in the visit method. + */ + virtual ir_visitor_status visit(class ir_dereference_variable *); /*@}*/ /** @@ -99,8 +115,10 @@ public: virtual ir_visitor_status visit_leave(class ir_expression *); virtual ir_visitor_status visit_enter(class ir_swizzle *); virtual ir_visitor_status visit_leave(class ir_swizzle *); - virtual ir_visitor_status visit_enter(class ir_dereference *); - virtual ir_visitor_status visit_leave(class ir_dereference *); + virtual ir_visitor_status visit_enter(class ir_dereference_array *); + virtual ir_visitor_status visit_leave(class ir_dereference_array *); + virtual ir_visitor_status visit_enter(class ir_dereference_record *); + virtual ir_visitor_status visit_leave(class ir_dereference_record *); virtual ir_visitor_status visit_enter(class ir_assignment *); virtual ir_visitor_status visit_leave(class ir_assignment *); virtual ir_visitor_status visit_enter(class ir_call *); diff --git a/ir_hv_accept.cpp b/ir_hv_accept.cpp index 43422e84aae..08f53943142 100644 --- a/ir_hv_accept.cpp +++ b/ir_hv_accept.cpp @@ -170,18 +170,34 @@ ir_swizzle::accept(ir_hierarchical_visitor *v) ir_visitor_status -ir_dereference::accept(ir_hierarchical_visitor *v) +ir_dereference_variable::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_dereference_array::accept(ir_hierarchical_visitor *v) { ir_visitor_status s = v->visit_enter(this); if (s != visit_continue) return (s == visit_continue_with_parent) ? visit_continue : s; - if (this->mode == ir_reference_array) { - s = this->selector.array_index->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } + s = this->selector.array_index->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + s = this->var->accept(v); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_dereference_record::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; s = this->var->accept(v); return (s == visit_stop) ? s : v->visit_leave(this); -- cgit v1.2.3 From c7b1046a9fa6da916f11fb9e43d61fd772470183 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 19 May 2010 13:20:12 +0200 Subject: Refactor ir_dereference support for ir_visitor Move the accept method for visitors from ir_dereference to the derived classes. --- ir.h | 20 ++++++++++---- ir_constant_expression.cpp | 30 +++++++++++++++------ ir_constant_folding.cpp | 37 +++++++++++++++++++------- ir_copy_propagation.cpp | 42 ++++++++++++++++------------- ir_expression_flattening.cpp | 22 ++++++++++++---- ir_function_inlining.cpp | 62 +++++++++++++++++++++++++++---------------- ir_print_visitor.cpp | 63 +++++++++++++++++++------------------------- ir_print_visitor.h | 4 ++- ir_visitor.h | 4 ++- 9 files changed, 178 insertions(+), 106 deletions(-) diff --git a/ir.h b/ir.h index f785ddb6373..2d641766b2e 100644 --- a/ir.h +++ b/ir.h @@ -793,11 +793,6 @@ public: return this; } - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - bool is_lvalue(); /** @@ -844,6 +839,11 @@ public: return (ir_variable *) this->var; } + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); }; @@ -862,6 +862,11 @@ public: return ((ir_rvalue *) this->var)->variable_referenced(); } + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); private: @@ -883,6 +888,11 @@ public: return ((ir_rvalue *) this->var)->variable_referenced(); } + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + virtual ir_visitor_status accept(ir_hierarchical_visitor *); }; diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index e5626c53117..076fdfda75f 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -67,7 +67,9 @@ public: virtual void visit(ir_function *); virtual void visit(ir_expression *); virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); virtual void visit(ir_assignment *); virtual void visit(ir_constant *); virtual void visit(ir_call *); @@ -412,16 +414,28 @@ ir_constant_visitor::visit(ir_swizzle *ir) void -ir_constant_visitor::visit(ir_dereference *ir) +ir_constant_visitor::visit(ir_dereference_variable *ir) { value = NULL; - if (ir->mode == ir_dereference::ir_reference_variable) { - ir_variable *var = ir->var->as_variable(); - if (var && var->constant_value) { - value = new ir_constant(ir->type, &var->constant_value->value); - } - } + ir_variable *var = ir->variable_referenced(); + if (var && var->constant_value) + value = new ir_constant(ir->type, &var->constant_value->value); +} + + +void +ir_constant_visitor::visit(ir_dereference_array *ir) +{ + value = NULL; + /* FINISHME: Other dereference modes. */ +} + + +void +ir_constant_visitor::visit(ir_dereference_record *ir) +{ + value = NULL; /* FINISHME: Other dereference modes. */ } diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index 913d42f0d9a..9a2a7f3f2e7 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -61,7 +61,9 @@ public: virtual void visit(ir_function *); virtual void visit(ir_expression *); virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); virtual void visit(ir_assignment *); virtual void visit(ir_constant *); virtual void visit(ir_call *); @@ -117,15 +119,30 @@ ir_constant_folding_visitor::visit(ir_swizzle *ir) void -ir_constant_folding_visitor::visit(ir_dereference *ir) -{ - if (ir->mode == ir_dereference::ir_reference_array) { - ir_constant *const_val = ir->selector.array_index->constant_expression_value(); - if (const_val) - ir->selector.array_index = const_val; - else - ir->selector.array_index->accept(this); - } +ir_constant_folding_visitor::visit(ir_dereference_variable *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_dereference_array *ir) +{ + ir_constant *const_val = + ir->selector.array_index->constant_expression_value(); + + if (const_val) + ir->selector.array_index = const_val; + else + ir->selector.array_index->accept(this); + + ir->var->accept(this); +} + + +void +ir_constant_folding_visitor::visit(ir_dereference_record *ir) +{ ir->var->accept(this); } diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index aac12b3da38..47f9390710c 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -78,7 +78,9 @@ public: virtual void visit(ir_function *); virtual void visit(ir_expression *); virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); virtual void visit(ir_assignment *); virtual void visit(ir_constant *); virtual void visit(ir_call *); @@ -149,30 +151,34 @@ ir_copy_propagation_visitor::visit(ir_swizzle *ir) * must not be shared by multiple IR operations! */ void -ir_copy_propagation_visitor::visit(ir_dereference *ir) +ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) { - ir_variable *var; + ir_variable *var = ir->variable_referenced(); - if (ir->mode == ir_dereference::ir_reference_array) { - ir->selector.array_index->accept(this); - } - - var = ir->var->as_variable(); - if (var) { - foreach_iter(exec_list_iterator, iter, *this->acp) { - acp_entry *entry = (acp_entry *)iter.get(); + foreach_iter(exec_list_iterator, iter, *this->acp) { + acp_entry *entry = (acp_entry *)iter.get(); - if (var == entry->lhs) { - ir->var = entry->rhs; - this->progress = true; - break; - } + if (var == entry->lhs) { + ir->var = entry->rhs; + this->progress = true; + break; } - } else { - ir->var->accept(this); } } +void +ir_copy_propagation_visitor::visit(ir_dereference_array *ir) +{ + ir->var->accept(this); + ir->selector.array_index->accept(this); +} + +void +ir_copy_propagation_visitor::visit(ir_dereference_record *ir) +{ + ir->var->accept(this); +} + void ir_copy_propagation_visitor::visit(ir_assignment *ir) { diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp index 9494786d4e4..1e0244988a2 100644 --- a/ir_expression_flattening.cpp +++ b/ir_expression_flattening.cpp @@ -70,7 +70,9 @@ public: virtual void visit(ir_function *); virtual void visit(ir_expression *); virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); virtual void visit(ir_assignment *); virtual void visit(ir_constant *); virtual void visit(ir_call *); @@ -162,11 +164,21 @@ ir_expression_flattening_visitor::visit(ir_swizzle *ir) void -ir_expression_flattening_visitor::visit(ir_dereference *ir) +ir_expression_flattening_visitor::visit(ir_dereference_variable *ir) +{ + ir->var->accept(this); +} + +void +ir_expression_flattening_visitor::visit(ir_dereference_array *ir) +{ + ir->selector.array_index->accept(this); + ir->var->accept(this); +} + +void +ir_expression_flattening_visitor::visit(ir_dereference_record *ir) { - if (ir->mode == ir_dereference::ir_reference_array) { - ir->selector.array_index->accept(this); - } ir->var->accept(this); } diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 499ce5f1dc2..38572a2057a 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -61,7 +61,9 @@ public: virtual void visit(ir_function *); virtual void visit(ir_expression *); virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); virtual void visit(ir_assignment *); virtual void visit(ir_constant *); virtual void visit(ir_call *); @@ -134,7 +136,9 @@ public: virtual void visit(ir_function *); virtual void visit(ir_expression *); virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); virtual void visit(ir_assignment *); virtual void visit(ir_constant *); virtual void visit(ir_call *); @@ -218,30 +222,34 @@ ir_function_cloning_visitor::visit(ir_swizzle *ir) } void -ir_function_cloning_visitor::visit(ir_dereference *ir) +ir_function_cloning_visitor::visit(ir_dereference_variable *ir) { - if (ir->mode == ir_dereference::ir_reference_variable) { - ir_variable *var = this->get_remapped_variable(ir->variable_referenced()); - this->result = new ir_dereference_variable(var); - } else if (ir->mode == ir_dereference::ir_reference_array) { - ir->var->accept(this); + ir_variable *var = this->get_remapped_variable(ir->variable_referenced()); + this->result = new ir_dereference_variable(var); +} - ir_rvalue *var = this->result->as_rvalue(); +void +ir_function_cloning_visitor::visit(ir_dereference_array *ir) +{ + ir->var->accept(this); - ir->selector.array_index->accept(this); + ir_rvalue *var = this->result->as_rvalue(); - ir_rvalue *index = this->result->as_rvalue(); + ir->selector.array_index->accept(this); - this->result = new ir_dereference_array(var, index); - } else { - assert(ir->mode == ir_dereference::ir_reference_record); + ir_rvalue *index = this->result->as_rvalue(); - ir->var->accept(this); + this->result = new ir_dereference_array(var, index); +} - ir_rvalue *var = this->result->as_rvalue(); +void +ir_function_cloning_visitor::visit(ir_dereference_record *ir) +{ + ir->var->accept(this); - this->result = new ir_dereference_record(var, strdup(ir->selector.field)); - } + ir_rvalue *var = this->result->as_rvalue(); + + this->result = new ir_dereference_record(var, strdup(ir->selector.field)); } void @@ -509,11 +517,21 @@ ir_function_inlining_visitor::visit(ir_swizzle *ir) void -ir_function_inlining_visitor::visit(ir_dereference *ir) +ir_function_inlining_visitor::visit(ir_dereference_variable *ir) +{ + ir->var->accept(this); +} + +void +ir_function_inlining_visitor::visit(ir_dereference_array *ir) +{ + ir->selector.array_index->accept(this); + ir->var->accept(this); +} + +void +ir_function_inlining_visitor::visit(ir_dereference_record *ir) { - if (ir->mode == ir_dereference::ir_reference_array) { - ir->selector.array_index->accept(this); - } ir->var->accept(this); } diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index ee7aa311758..7cb5eeba015 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -74,22 +74,18 @@ print_type(const glsl_type *t) void ir_print_visitor::visit(ir_variable *ir) { - if (deref_depth) { - printf("%s", ir->name); - } else { - printf("(declare "); + printf("(declare "); - const char *const cent = (ir->centroid) ? "centroid " : ""; - const char *const inv = (ir->invariant) ? "invariant " : ""; - const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " }; - const char *const interp[] = { "", "flat", "noperspective" }; + const char *const cent = (ir->centroid) ? "centroid " : ""; + const char *const inv = (ir->invariant) ? "invariant " : ""; + const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " }; + const char *const interp[] = { "", "flat", "noperspective" }; - printf("(%s%s%s%s) ", - cent, inv, mode[ir->mode], interp[ir->interpolation]); + printf("(%s%s%s%s) ", + cent, inv, mode[ir->mode], interp[ir->interpolation]); - print_type(ir->type); - printf(" %s)", ir->name); - } + print_type(ir->type); + printf(" %s)", ir->name); } @@ -166,31 +162,26 @@ void ir_print_visitor::visit(ir_swizzle *ir) } -void ir_print_visitor::visit(ir_dereference *ir) +void ir_print_visitor::visit(ir_dereference_variable *ir) { - deref_depth++; - - switch (ir->mode) { - case ir_dereference::ir_reference_variable: { - printf("(var_ref "); - ir->var->accept(this); - printf(") "); - break; - } - case ir_dereference::ir_reference_array: - printf("(array_ref "); - ir->var->accept(this); - ir->selector.array_index->accept(this); - printf(") "); - break; - case ir_dereference::ir_reference_record: - printf("(record_ref "); - ir->var->accept(this); - printf("(%s)) ", ir->selector.field); - break; - } + printf("(var_ref %s) ", ir->variable_referenced()->name); +} + - deref_depth--; +void ir_print_visitor::visit(ir_dereference_array *ir) +{ + printf("(array_ref "); + ir->var->accept(this); + ir->selector.array_index->accept(this); + printf(") "); +} + + +void ir_print_visitor::visit(ir_dereference_record *ir) +{ + printf("(record_ref "); + ir->var->accept(this); + printf("(%s)) ", ir->selector.field); } diff --git a/ir_print_visitor.h b/ir_print_visitor.h index aeee538df29..4af508794bd 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -61,7 +61,9 @@ public: virtual void visit(ir_function *); virtual void visit(ir_expression *); virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); virtual void visit(ir_assignment *); virtual void visit(ir_constant *); virtual void visit(ir_call *); diff --git a/ir_visitor.h b/ir_visitor.h index 579eee701d7..ba30858fe62 100644 --- a/ir_visitor.h +++ b/ir_visitor.h @@ -49,7 +49,9 @@ public: virtual void visit(class ir_function *) = 0; virtual void visit(class ir_expression *) = 0; virtual void visit(class ir_swizzle *) = 0; - virtual void visit(class ir_dereference *) = 0; + virtual void visit(class ir_dereference_variable *) = 0; + virtual void visit(class ir_dereference_array *) = 0; + virtual void visit(class ir_dereference_record *) = 0; virtual void visit(class ir_assignment *) = 0; virtual void visit(class ir_constant *) = 0; virtual void visit(class ir_call *) = 0; -- cgit v1.2.3 From 7fe3de6fde0cb7e73ef36d0d600f00f4793ced0d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 19 May 2010 13:47:39 +0200 Subject: Replace open coded deref navigation with hierarchical visitors --- ir_dead_code_local.cpp | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/ir_dead_code_local.cpp b/ir_dead_code_local.cpp index 668b6f8cd55..e3c0e533032 100644 --- a/ir_dead_code_local.cpp +++ b/ir_dead_code_local.cpp @@ -85,6 +85,29 @@ private: exec_list *assignments; }; +class array_index_visit : public ir_hierarchical_visitor { +public: + array_index_visit(ir_hierarchical_visitor *v) + { + this->visitor = v; + } + + virtual ir_visitor_status visit_enter(class ir_dereference_array *ir) + { + ir->selector.array_index->accept(visitor); + return visit_continue; + } + + static void run(ir_instruction *ir, ir_hierarchical_visitor *v) + { + array_index_visit top_visit(v); + ir->accept(& top_visit); + } + + ir_hierarchical_visitor *visitor; +}; + + /** * Adds an entry to the available copy list if it's a plain assignment * of a variable to a variable. @@ -94,7 +117,6 @@ process_assignment(ir_assignment *ir, exec_list *assignments) { ir_variable *var = NULL; bool progress = false; - ir_instruction *current; kill_for_derefs_visitor v(assignments); /* Kill assignment entries for things used to produce this assignment. */ @@ -103,28 +125,10 @@ process_assignment(ir_assignment *ir, exec_list *assignments) ir->condition->accept(&v); } - /* Walk down the dereference chain to find the variable at the end - * of it that we're actually modifying. Kill assignment enties used as - * array indices, too. + /* Kill assignment enties used as array indices. */ - for (current = ir->lhs; current != NULL;) { - ir_swizzle *swiz; - ir_dereference *deref; - - if ((swiz = current->as_swizzle())) { - current = swiz->val; - } else if ((deref = current->as_dereference())) { - if (deref->mode == ir_dereference::ir_reference_array) - deref->selector.array_index->accept(&v); - current = deref->var; - } else { - var = current->as_variable(); - - current = NULL; - break; - } - } - + array_index_visit::run(ir->lhs, &v); + var = ir->lhs->variable_referenced(); assert(var); bool always_assign = true; -- cgit v1.2.3 From 36ea28646c666ac2af9b43c47e65f9f53ffcc390 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 19 May 2010 13:52:29 +0200 Subject: Refactor ir_dereference data fields to subclasses --- ast_to_hir.cpp | 2 +- ir.cpp | 26 +++++++++++++------------- ir.h | 29 ++++++++++++++--------------- ir_constant_expression.cpp | 2 ++ ir_constant_folding.cpp | 10 +++++----- ir_copy_propagation.cpp | 10 +++++----- ir_dead_code_local.cpp | 2 +- ir_expression_flattening.cpp | 6 +++--- ir_function_inlining.cpp | 14 +++++++------- ir_hv_accept.cpp | 6 +++--- ir_print_visitor.cpp | 8 ++++---- 11 files changed, 58 insertions(+), 57 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index b8128fa8a77..64f8ef49681 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -482,7 +482,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, assert(d != NULL); - ir_variable *const var = d->var->as_variable(); + ir_variable *const var = d->variable_referenced(); assert(var != NULL); diff --git a/ir.cpp b/ir.cpp index f6f2558bc06..a147339b1a7 100644 --- a/ir.cpp +++ b/ir.cpp @@ -235,7 +235,7 @@ ir_dereference_array::ir_dereference_array(ir_rvalue *value, ir_rvalue *array_index) : ir_dereference(ir_reference_array) { - this->selector.array_index = array_index; + this->array_index = array_index; this->set_array(value); } @@ -244,7 +244,7 @@ ir_dereference_array::ir_dereference_array(ir_variable *var, ir_rvalue *array_index) : ir_dereference(ir_reference_array) { - this->selector.array_index = array_index; + this->array_index = array_index; this->set_array(new ir_dereference_variable(var)); } @@ -252,11 +252,11 @@ ir_dereference_array::ir_dereference_array(ir_variable *var, void ir_dereference_array::set_array(ir_rvalue *value) { - this->var = value; + this->array = value; this->type = glsl_type::error_type; - if (this->var != NULL) { - const glsl_type *const vt = this->var->type; + if (this->array != NULL) { + const glsl_type *const vt = this->array->type; if (vt->is_array()) { type = vt->element_type(); @@ -273,10 +273,10 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value, const char *field) : ir_dereference(ir_reference_record) { - this->var = value; - this->selector.field = field; - this->type = (this->var != NULL) - ? this->var->type->field_type(field) : glsl_type::error_type; + this->record = value; + this->field = field; + this->type = (this->record != NULL) + ? this->record->type->field_type(field) : glsl_type::error_type; } @@ -284,10 +284,10 @@ ir_dereference_record::ir_dereference_record(ir_variable *var, const char *field) : ir_dereference(ir_reference_record) { - this->var = new ir_dereference_variable(var); - this->selector.field = field; - this->type = (this->var != NULL) - ? this->var->type->field_type(field) : glsl_type::error_type; + this->record = new ir_dereference_variable(var); + this->field = field; + this->type = (this->record != NULL) + ? this->record->type->field_type(field) : glsl_type::error_type; } diff --git a/ir.h b/ir.h index 2d641766b2e..2e6a1943214 100644 --- a/ir.h +++ b/ir.h @@ -806,18 +806,6 @@ public: ir_reference_record } mode; - /** - * Object being dereferenced. - * - * Must be either an \c ir_variable or an \c ir_rvalue. - */ - ir_instruction *var; - - union { - ir_rvalue *array_index; - const char *field; - } selector; - protected: ir_dereference(ir_deref_mode mode) : mode(mode) @@ -836,7 +824,7 @@ public: */ virtual ir_variable *variable_referenced() { - return (ir_variable *) this->var; + return this->var; } virtual void accept(ir_visitor *v) @@ -845,6 +833,11 @@ public: } virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Object being dereferenced. + */ + ir_variable *var; }; @@ -859,7 +852,7 @@ public: */ virtual ir_variable *variable_referenced() { - return ((ir_rvalue *) this->var)->variable_referenced(); + return this->array->variable_referenced(); } virtual void accept(ir_visitor *v) @@ -869,6 +862,9 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); + ir_rvalue *array; + ir_rvalue *array_index; + private: void set_array(ir_rvalue *value); }; @@ -885,7 +881,7 @@ public: */ virtual ir_variable *variable_referenced() { - return ((ir_rvalue *) this->var)->variable_referenced(); + return this->record->variable_referenced(); } virtual void accept(ir_visitor *v) @@ -894,6 +890,9 @@ public: } virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_rvalue *record; + const char *field; }; diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 076fdfda75f..b1092de1393 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -427,6 +427,7 @@ ir_constant_visitor::visit(ir_dereference_variable *ir) void ir_constant_visitor::visit(ir_dereference_array *ir) { + (void) ir; value = NULL; /* FINISHME: Other dereference modes. */ } @@ -435,6 +436,7 @@ ir_constant_visitor::visit(ir_dereference_array *ir) void ir_constant_visitor::visit(ir_dereference_record *ir) { + (void) ir; value = NULL; /* FINISHME: Other dereference modes. */ } diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index 9a2a7f3f2e7..c7019ffc626 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -129,21 +129,21 @@ void ir_constant_folding_visitor::visit(ir_dereference_array *ir) { ir_constant *const_val = - ir->selector.array_index->constant_expression_value(); + ir->array_index->constant_expression_value(); if (const_val) - ir->selector.array_index = const_val; + ir->array_index = const_val; else - ir->selector.array_index->accept(this); + ir->array_index->accept(this); - ir->var->accept(this); + ir->array->accept(this); } void ir_constant_folding_visitor::visit(ir_dereference_record *ir) { - ir->var->accept(this); + ir->record->accept(this); } diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index 47f9390710c..e395fa9723b 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -169,14 +169,14 @@ ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) void ir_copy_propagation_visitor::visit(ir_dereference_array *ir) { - ir->var->accept(this); - ir->selector.array_index->accept(this); + ir->array->accept(this); + ir->array_index->accept(this); } void ir_copy_propagation_visitor::visit(ir_dereference_record *ir) { - ir->var->accept(this); + ir->record->accept(this); } void @@ -270,12 +270,12 @@ add_copy(ir_assignment *ir, exec_list *acp) ir_dereference *lhs_deref = ir->lhs->as_dereference(); if (!lhs_deref || lhs_deref->mode != ir_dereference::ir_reference_variable) return; - ir_variable *lhs_var = lhs_deref->var->as_variable(); + ir_variable *lhs_var = lhs_deref->variable_referenced(); ir_dereference *rhs_deref = ir->rhs->as_dereference(); if (!rhs_deref || rhs_deref->mode != ir_dereference::ir_reference_variable) return; - ir_variable *rhs_var = rhs_deref->var->as_variable(); + ir_variable *rhs_var = rhs_deref->variable_referenced(); entry = new acp_entry(lhs_var, rhs_var); acp->push_tail(entry); diff --git a/ir_dead_code_local.cpp b/ir_dead_code_local.cpp index e3c0e533032..9ac209df576 100644 --- a/ir_dead_code_local.cpp +++ b/ir_dead_code_local.cpp @@ -94,7 +94,7 @@ public: virtual ir_visitor_status visit_enter(class ir_dereference_array *ir) { - ir->selector.array_index->accept(visitor); + ir->array_index->accept(visitor); return visit_continue; } diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp index 1e0244988a2..3403389c9c4 100644 --- a/ir_expression_flattening.cpp +++ b/ir_expression_flattening.cpp @@ -172,14 +172,14 @@ ir_expression_flattening_visitor::visit(ir_dereference_variable *ir) void ir_expression_flattening_visitor::visit(ir_dereference_array *ir) { - ir->selector.array_index->accept(this); - ir->var->accept(this); + ir->array_index->accept(this); + ir->array->accept(this); } void ir_expression_flattening_visitor::visit(ir_dereference_record *ir) { - ir->var->accept(this); + ir->record->accept(this); } void diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 38572a2057a..9109ce698b2 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -231,11 +231,11 @@ ir_function_cloning_visitor::visit(ir_dereference_variable *ir) void ir_function_cloning_visitor::visit(ir_dereference_array *ir) { - ir->var->accept(this); + ir->array->accept(this); ir_rvalue *var = this->result->as_rvalue(); - ir->selector.array_index->accept(this); + ir->array_index->accept(this); ir_rvalue *index = this->result->as_rvalue(); @@ -245,11 +245,11 @@ ir_function_cloning_visitor::visit(ir_dereference_array *ir) void ir_function_cloning_visitor::visit(ir_dereference_record *ir) { - ir->var->accept(this); + ir->record->accept(this); ir_rvalue *var = this->result->as_rvalue(); - this->result = new ir_dereference_record(var, strdup(ir->selector.field)); + this->result = new ir_dereference_record(var, strdup(ir->field)); } void @@ -525,14 +525,14 @@ ir_function_inlining_visitor::visit(ir_dereference_variable *ir) void ir_function_inlining_visitor::visit(ir_dereference_array *ir) { - ir->selector.array_index->accept(this); - ir->var->accept(this); + ir->array_index->accept(this); + ir->array->accept(this); } void ir_function_inlining_visitor::visit(ir_dereference_record *ir) { - ir->var->accept(this); + ir->record->accept(this); } void diff --git a/ir_hv_accept.cpp b/ir_hv_accept.cpp index 08f53943142..8d535e24faa 100644 --- a/ir_hv_accept.cpp +++ b/ir_hv_accept.cpp @@ -183,11 +183,11 @@ ir_dereference_array::accept(ir_hierarchical_visitor *v) if (s != visit_continue) return (s == visit_continue_with_parent) ? visit_continue : s; - s = this->selector.array_index->accept(v); + s = this->array_index->accept(v); if (s != visit_continue) return (s == visit_continue_with_parent) ? visit_continue : s; - s = this->var->accept(v); + s = this->array->accept(v); return (s == visit_stop) ? s : v->visit_leave(this); } @@ -199,7 +199,7 @@ ir_dereference_record::accept(ir_hierarchical_visitor *v) if (s != visit_continue) return (s == visit_continue_with_parent) ? visit_continue : s; - s = this->var->accept(v); + s = this->record->accept(v); return (s == visit_stop) ? s : v->visit_leave(this); } diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 7cb5eeba015..e507a0ebf99 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -171,8 +171,8 @@ void ir_print_visitor::visit(ir_dereference_variable *ir) void ir_print_visitor::visit(ir_dereference_array *ir) { printf("(array_ref "); - ir->var->accept(this); - ir->selector.array_index->accept(this); + ir->array->accept(this); + ir->array_index->accept(this); printf(") "); } @@ -180,8 +180,8 @@ void ir_print_visitor::visit(ir_dereference_array *ir) void ir_print_visitor::visit(ir_dereference_record *ir) { printf("(record_ref "); - ir->var->accept(this); - printf("(%s)) ", ir->selector.field); + ir->record->accept(this); + printf("(%s)) ", ir->field); } -- cgit v1.2.3 From b067db2e253059e83249b1e4d5f3c626b0e33807 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 26 May 2010 11:32:52 -0700 Subject: Refactor whole-variable assigment checking into member function --- ir.h | 26 ++++++++++++++++++++++++++ ir_copy_propagation.cpp | 19 +++++++------------ ir_dead_code_local.cpp | 5 +---- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/ir.h b/ir.h index 2e6a1943214..306ec8c162b 100644 --- a/ir.h +++ b/ir.h @@ -95,6 +95,21 @@ public: return NULL; } + + /** + * If an r-value is a reference to a whole variable, get that variable + * + * \return + * Pointer to a variable that is completely dereferenced by the r-value. If + * the r-value is not a dereference or the dereference does not access the + * entire variable (i.e., it's just one array element, struct field), \c NULL + * is returned. + */ + virtual ir_variable *whole_variable_referenced() + { + return NULL; + } + protected: ir_rvalue() { @@ -827,6 +842,17 @@ public: return this->var; } + virtual ir_variable *whole_variable_referenced() + { + /* ir_dereference_variable objects always dereference the entire + * variable. However, if this dereference is dereferenced by anything + * else, the complete deferefernce chain is not a whole-variable + * dereference. This method should only be called on the top most + * ir_rvalue in a dereference chain. + */ + return this->var; + } + virtual void accept(ir_visitor *v) { v->visit(this); diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index e395fa9723b..82172d29b65 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -267,18 +267,13 @@ add_copy(ir_assignment *ir, exec_list *acp) return; } - ir_dereference *lhs_deref = ir->lhs->as_dereference(); - if (!lhs_deref || lhs_deref->mode != ir_dereference::ir_reference_variable) - return; - ir_variable *lhs_var = lhs_deref->variable_referenced(); - - ir_dereference *rhs_deref = ir->rhs->as_dereference(); - if (!rhs_deref || rhs_deref->mode != ir_dereference::ir_reference_variable) - return; - ir_variable *rhs_var = rhs_deref->variable_referenced(); - - entry = new acp_entry(lhs_var, rhs_var); - acp->push_tail(entry); + ir_variable *lhs_var = ir->lhs->whole_variable_referenced(); + ir_variable *rhs_var = ir->rhs->whole_variable_referenced(); + + if ((lhs_var != NULL) && (rhs_var != NULL)) { + entry = new acp_entry(lhs_var, rhs_var); + acp->push_tail(entry); + } } static void diff --git a/ir_dead_code_local.cpp b/ir_dead_code_local.cpp index 9ac209df576..e83b300390b 100644 --- a/ir_dead_code_local.cpp +++ b/ir_dead_code_local.cpp @@ -139,10 +139,7 @@ process_assignment(ir_assignment *ir, exec_list *assignments) } /* Now, check if we did a whole-variable assignment. */ - ir_dereference *lhs_deref = ir->lhs->as_dereference(); - if (always_assign && - lhs_deref && - lhs_deref->mode == ir_dereference::ir_reference_variable) { + if (always_assign && (ir->lhs->whole_variable_referenced() != NULL)) { /* We did a whole-variable assignment. So, any instruction in * the assignment list with the same LHS is dead. */ -- cgit v1.2.3 From fd55da21471fbab7e78c12a31b4eba0d33481735 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 26 May 2010 11:43:40 -0700 Subject: ir_dereference::mode is no longer used, kill with fire --- ir.cpp | 5 ----- ir.h | 13 ------------- 2 files changed, 18 deletions(-) diff --git a/ir.cpp b/ir.cpp index a147339b1a7..0810a3a0114 100644 --- a/ir.cpp +++ b/ir.cpp @@ -224,7 +224,6 @@ ir_constant::ir_constant(bool b) ir_dereference_variable::ir_dereference_variable(ir_variable *var) - : ir_dereference(ir_reference_variable) { this->var = var; this->type = (var != NULL) ? var->type : glsl_type::error_type; @@ -233,7 +232,6 @@ ir_dereference_variable::ir_dereference_variable(ir_variable *var) ir_dereference_array::ir_dereference_array(ir_rvalue *value, ir_rvalue *array_index) - : ir_dereference(ir_reference_array) { this->array_index = array_index; this->set_array(value); @@ -242,7 +240,6 @@ ir_dereference_array::ir_dereference_array(ir_rvalue *value, ir_dereference_array::ir_dereference_array(ir_variable *var, ir_rvalue *array_index) - : ir_dereference(ir_reference_array) { this->array_index = array_index; this->set_array(new ir_dereference_variable(var)); @@ -271,7 +268,6 @@ ir_dereference_array::set_array(ir_rvalue *value) ir_dereference_record::ir_dereference_record(ir_rvalue *value, const char *field) - : ir_dereference(ir_reference_record) { this->record = value; this->field = field; @@ -282,7 +278,6 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value, ir_dereference_record::ir_dereference_record(ir_variable *var, const char *field) - : ir_dereference(ir_reference_record) { this->record = new ir_dereference_variable(var); this->field = field; diff --git a/ir.h b/ir.h index 306ec8c162b..bbec6ce5bed 100644 --- a/ir.h +++ b/ir.h @@ -814,19 +814,6 @@ public: * Get the variable that is ultimately referenced by an r-value */ virtual ir_variable *variable_referenced() = 0; - - enum ir_deref_mode { - ir_reference_variable, - ir_reference_array, - ir_reference_record - } mode; - -protected: - ir_dereference(ir_deref_mode mode) - : mode(mode) - { - /* empty */ - } }; -- cgit v1.2.3 From a9159f9e87b518ba0a4ad43db8fdd58a678b3a92 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 26 May 2010 15:08:11 -0700 Subject: Fix setting the maximum accessed array element Array dereferences now point to variable dereferences instead of pointing directly to variables. This necessitated some changes to the way the variable is accessed when setting the maximum index array element. --- ast_to_hir.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 64f8ef49681..7759c36a699 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1097,7 +1097,7 @@ ast_expression::hir(exec_list *instructions, error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - ir_instruction *const array = op[0]; + ir_rvalue *const array = op[0]; result = new ir_dereference_array(op[0], op[1]); @@ -1181,7 +1181,13 @@ ast_expression::hir(exec_list *instructions, } if (array->type->is_array()) { - ir_variable *const v = array->as_variable(); + /* If the array is a variable dereference, it dereferences the + * whole array, by definition. Use this to get the variable. + * + * FINISHME: Should some methods for getting / setting / testing + * FINISHME: array access limits be added to ir_dereference? + */ + ir_variable *const v = array->whole_variable_referenced(); if ((v != NULL) && (unsigned(idx) > v->max_array_access)) v->max_array_access = idx; } -- cgit v1.2.3 From 350bd703480d4e4f8dea1813cec6ee8964bce3be Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 26 May 2010 13:03:14 -0700 Subject: ir_reader: Fix reading of array deferences and correct error messages. Previously, the syntax was (array_ref ), but the subject is now a general rvalue (not a name). In particular, it might be a (var_ref ...). Also, remove "expected ... or (swiz)" from error messages; swiz is not allowed inside a var_ref. --- ir_reader.cpp | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 744606d4f2c..072842e83b7 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -817,50 +817,42 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) return NULL; // should not be reached } -static ir_variable * -read_dereferencable(_mesa_glsl_parse_state *st, s_expression *expr) -{ - // Read the subject of a dereference - either a variable name or a swizzle - s_symbol *var_name = SX_AS_SYMBOL(expr); - if (var_name != NULL) { - ir_variable *var = st->symbols->get_variable(var_name->value()); - if (var == NULL) { - ir_read_error(st, expr, "undeclared variable: %s", var_name->value()); - } - return var; - } - - ir_read_error(st, expr, "expected variable name or (swiz ...)"); - return NULL; -} - static ir_dereference * read_var_ref(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 2) { - ir_read_error(st, list, "expected (var_ref )"); + ir_read_error(st, list, "expected (var_ref )"); return NULL; } - s_expression *subj_expr = (s_expression*) list->subexpressions.head->next; - ir_variable *subject = read_dereferencable(st, subj_expr); - if (subject == NULL) + s_symbol *var_name = SX_AS_SYMBOL(list->subexpressions.head->next); + if (var_name == NULL) { + ir_read_error(st, list, "expected (var_ref )"); + 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 ir_dereference_variable(subject); + } + + return new ir_dereference_variable(var); } static ir_dereference * read_array_ref(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 3) { - ir_read_error(st, list, "expected (array_ref " - ")"); + ir_read_error(st, list, "expected (array_ref )"); return NULL; } s_expression *subj_expr = (s_expression*) list->subexpressions.head->next; - ir_variable *subject = read_dereferencable(st, subj_expr); - if (subject == NULL) + 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); -- cgit v1.2.3 From 13e1b6b725def5a22952ecd4e2e8b1e61cb3bcfa Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 26 May 2010 15:20:59 -0700 Subject: ir_reader: Read record_refs. Also changes the print visitor to not emit extraneous parenthesis. --- ir_print_visitor.cpp | 2 +- ir_reader.cpp | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index e507a0ebf99..84edad5dfac 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -181,7 +181,7 @@ void ir_print_visitor::visit(ir_dereference_record *ir) { printf("(record_ref "); ir->record->accept(this); - printf("(%s)) ", ir->field); + printf(" %s) ", ir->field); } diff --git a/ir_reader.cpp b/ir_reader.cpp index 072842e83b7..f4b9967d449 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -862,6 +862,22 @@ read_array_ref(_mesa_glsl_parse_state *st, s_list *list) static ir_dereference * read_record_ref(_mesa_glsl_parse_state *st, s_list *list) { - ir_read_error(st, list, "FINISHME: record refs not yet supported."); - return NULL; + if (list->length() != 3) { + ir_read_error(st, list, "expected (record_ref )"); + 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 *field = SX_AS_SYMBOL(subj_expr->next); + if (field == NULL) { + ir_read_error(st, list, "expected (record_ref ... )"); + return NULL; + } + return new ir_dereference_record(subject, field->value()); } -- cgit v1.2.3 From 0324cad796b7a68634a729719f08fcbb5bbd04cc Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 15:53:05 -0700 Subject: All macro lookups should be of type macro_t, not string_list_t. This is what I get for using a non-type-safe hash-table implementation. --- glcpp-parse.y | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index cce8a70156f..a809ebf3af5 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -199,7 +199,7 @@ control_line: _define_function_macro (parser, $2, $4, $6); } | HASH_UNDEF IDENTIFIER NEWLINE { - string_list_t *macro = hash_table_find (parser->defines, $2); + macro_t *macro = hash_table_find (parser->defines, $2); if (macro) { /* XXX: Need hash table to support a real way * to remove an element rather than prefixing @@ -222,12 +222,12 @@ control_line: glcpp_parser_lex_from (parser, expanded); } | HASH_IFDEF IDENTIFIER NEWLINE { - string_list_t *macro = hash_table_find (parser->defines, $2); + macro_t *macro = hash_table_find (parser->defines, $2); talloc_free ($2); _glcpp_parser_skip_stack_push_if (parser, macro != NULL); } | HASH_IFNDEF IDENTIFIER NEWLINE { - string_list_t *macro = hash_table_find (parser->defines, $2); + macro_t *macro = hash_table_find (parser->defines, $2); talloc_free ($2); _glcpp_parser_skip_stack_push_if (parser, macro == NULL); } @@ -889,7 +889,7 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser, token_list_t *list) { token_node_t *node, *next; - string_list_t *macro; + macro_t *macro; if (list == NULL) return; -- cgit v1.2.3 From 95951ea7bb8728cf54ae4136cb59d0af9e8a06bd Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 15:57:10 -0700 Subject: Treat newlines as space when invoking a function-like macro invocation. This adds three new pieces of state to the parser, (is_control_line, newline_as_space, and paren_count), and a large amount of messy code. I'd definitely like to see a cleaner solution for this. With this fix, the "define-func-extra-newlines" now passes so we put it back to test #26 where it was originally (lately it has been known as test #55). Also, we tweak test 25 slightly. Previously this test was ending a file function-like macro name that was not actually a macro (not followed by a left parenthesis). As is, this fix was making that test fail because the text_line production expects to see a terminating NEWLINE, but that NEWLINE is now getting turned into a SPACE here. This seems unlikely to be a problem in the wild, (function macros being used in a non-macro sense seems rare enough---but more than likely they won't happen at the end of a file). Still, we document this shortcoming in the README. --- README | 4 +++ glcpp-parse.y | 61 ++++++++++++++++++++++++++++++++-- glcpp.h | 3 ++ tests/025-func-macro-as-non-macro.c | 2 +- tests/026-define-func-extra-newlines.c | 6 ++++ tests/055-define-func-extra-newlines.c | 6 ---- 6 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 tests/026-define-func-extra-newlines.c delete mode 100644 tests/055-define-func-extra-newlines.c diff --git a/README b/README index f0f64c2644a..ab42a3ffe12 100644 --- a/README +++ b/README @@ -24,3 +24,7 @@ parentheses. The #error, #pragma, #extension, #version, and #line macros are not yet supported. + +A file that ends with a function-like macro name as the last +non-whitespace token will result in a parse error, (where it should be +passed through as is). \ No newline at end of file diff --git a/glcpp-parse.y b/glcpp-parse.y index a809ebf3af5..1346b65aff6 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -856,6 +856,9 @@ glcpp_parser_create (void) hash_table_string_compare); parser->active = _string_list_create (parser); parser->space_tokens = 1; + parser->newline_as_space = 0; + parser->in_control_line = 0; + parser->paren_count = 0; parser->skip_stack = NULL; @@ -1274,8 +1277,62 @@ glcpp_parser_lex (glcpp_parser_t *parser) token_node_t *node; int ret; - if (parser->lex_from_list == NULL) - return glcpp_lex (parser->scanner); + if (parser->lex_from_list == NULL) { + ret = glcpp_lex (parser->scanner); + + /* XXX: This ugly block of code exists for the sole + * purpose of converting a NEWLINE token into a SPACE + * token, but only in the case where we have seen a + * function-like macro name, but have not yet seen its + * closing parenthesis. + * + * There's perhaps a more compact way to do this with + * mid-rule actions in the grammar. + * + * I'm definitely not pleased with the complexity of + * this code here. + */ + if (parser->newline_as_space) + { + if (ret == '(') { + parser->paren_count++; + } else if (ret == ')') { + parser->paren_count--; + if (parser->paren_count == 0) + parser->newline_as_space = 0; + } else if (ret == NEWLINE) { + ret = SPACE; + } else if (ret != SPACE) { + if (parser->paren_count == 0) + parser->newline_as_space = 0; + } + } + else if (parser->in_control_line) + { + if (ret == NEWLINE) + parser->in_control_line = 0; + } + else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC || + ret == HASH_UNDEF || ret == HASH_IF || + ret == HASH_IFDEF || ret == HASH_IFNDEF || + ret == HASH_ELIF || ret == HASH_ELSE || + ret == HASH_ENDIF || ret == HASH) + { + parser->in_control_line = 1; + } + else if (ret == IDENTIFIER) + { + macro_t *macro; + macro = hash_table_find (parser->defines, + yylval.str); + if (macro && macro->is_function) { + parser->newline_as_space = 1; + parser->paren_count = 0; + } + } + + return ret; + } node = parser->lex_from_node; diff --git a/glcpp.h b/glcpp.h index e5be1a6cd62..5c8c304a9ca 100644 --- a/glcpp.h +++ b/glcpp.h @@ -128,6 +128,9 @@ struct glcpp_parser { struct hash_table *defines; string_list_t *active; int space_tokens; + int newline_as_space; + int in_control_line; + int paren_count; skip_node_t *skip_stack; token_list_t *lex_from_list; token_node_t *lex_from_node; diff --git a/tests/025-func-macro-as-non-macro.c b/tests/025-func-macro-as-non-macro.c index 3dbe026d9dd..b433671d1bf 100644 --- a/tests/025-func-macro-as-non-macro.c +++ b/tests/025-func-macro-as-non-macro.c @@ -1,2 +1,2 @@ #define foo(bar) bar -foo +foo bar diff --git a/tests/026-define-func-extra-newlines.c b/tests/026-define-func-extra-newlines.c new file mode 100644 index 00000000000..0d837405309 --- /dev/null +++ b/tests/026-define-func-extra-newlines.c @@ -0,0 +1,6 @@ +#define foo(a) bar + +foo +( +1 +) diff --git a/tests/055-define-func-extra-newlines.c b/tests/055-define-func-extra-newlines.c deleted file mode 100644 index 0d837405309..00000000000 --- a/tests/055-define-func-extra-newlines.c +++ /dev/null @@ -1,6 +0,0 @@ -#define foo(a) bar - -foo -( -1 -) -- cgit v1.2.3 From 4b389492b9d4c28cacc1d297b3f2da1d6819edae Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 26 May 2010 16:07:49 -0700 Subject: Reimplement ir_expression_flattening_visitor using ir_hierarchical_vistor --- ir_expression_flattening.cpp | 134 ++++++------------------------------------- 1 file changed, 19 insertions(+), 115 deletions(-) diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp index 3403389c9c4..b0b1e203567 100644 --- a/ir_expression_flattening.cpp +++ b/ir_expression_flattening.cpp @@ -39,15 +39,13 @@ #include "ir_expression_flattening.h" #include "glsl_types.h" -class ir_expression_flattening_visitor : public ir_visitor { +class ir_expression_flattening_visitor : public ir_hierarchical_visitor { public: ir_expression_flattening_visitor(ir_instruction *base_ir, bool (*predicate)(ir_instruction *ir)) { this->base_ir = base_ir; this->predicate = predicate; - - /* empty */ } virtual ~ir_expression_flattening_visitor() @@ -55,30 +53,9 @@ public: /* empty */ } - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - /*@}*/ + virtual ir_visitor_status visit_enter(ir_call *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_leave(ir_expression *); bool (*predicate)(ir_instruction *ir); ir_instruction *base_ir; @@ -96,45 +73,12 @@ do_expression_flattening(exec_list *instructions, } } -void -ir_expression_flattening_visitor::visit(ir_variable *ir) -{ - (void) ir; -} - -void -ir_expression_flattening_visitor::visit(ir_loop *ir) -{ - do_expression_flattening(&ir->body_instructions, this->predicate); -} - -void -ir_expression_flattening_visitor::visit(ir_loop_jump *ir) -{ - (void) ir; -} - - -void -ir_expression_flattening_visitor::visit(ir_function_signature *ir) -{ - do_expression_flattening(&ir->body, this->predicate); -} - -void -ir_expression_flattening_visitor::visit(ir_function *ir) -{ - (void) ir; -} - -void -ir_expression_flattening_visitor::visit(ir_expression *ir) +ir_visitor_status +ir_expression_flattening_visitor::visit_leave(ir_expression *ir) { unsigned int operand; for (operand = 0; operand < ir->get_num_operands(); operand++) { - ir->operands[operand]->accept(this); - /* If the operand matches the predicate, then we'll assign its * value to a temporary and deref the temporary as the operand. */ @@ -153,68 +97,28 @@ ir_expression_flattening_visitor::visit(ir_expression *ir) ir->operands[operand] = new ir_dereference_variable(var); } } -} - - -void -ir_expression_flattening_visitor::visit(ir_swizzle *ir) -{ - ir->val->accept(this); -} - -void -ir_expression_flattening_visitor::visit(ir_dereference_variable *ir) -{ - ir->var->accept(this); + return visit_continue; } -void -ir_expression_flattening_visitor::visit(ir_dereference_array *ir) -{ - ir->array_index->accept(this); - ir->array->accept(this); -} -void -ir_expression_flattening_visitor::visit(ir_dereference_record *ir) -{ - ir->record->accept(this); -} - -void -ir_expression_flattening_visitor::visit(ir_assignment *ir) -{ - ir->rhs->accept(this); -} - - -void -ir_expression_flattening_visitor::visit(ir_constant *ir) -{ - (void) ir; -} - - -void -ir_expression_flattening_visitor::visit(ir_call *ir) +ir_visitor_status +ir_expression_flattening_visitor::visit_enter(ir_call *ir) { + /* FINISHME: Why not process the call parameters? (Same behavior as original + * FINISHME: code.) + */ (void) ir; + return visit_continue_with_parent; } -void -ir_expression_flattening_visitor::visit(ir_return *ir) +ir_visitor_status +ir_expression_flattening_visitor::visit_enter(ir_return *ir) { + /* FINISHME: Why not process the return value? (Same behavior as original + * FINISHME: code.) + */ (void) ir; -} - - -void -ir_expression_flattening_visitor::visit(ir_if *ir) -{ - ir->condition->accept(this); - - do_expression_flattening(&ir->then_instructions, this->predicate); - do_expression_flattening(&ir->else_instructions, this->predicate); + return visit_continue_with_parent; } -- cgit v1.2.3 From a8ea26d7c94526518670e54f44336f433d0ac77c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 16:18:05 -0700 Subject: Add two tests developed on the take-2 branch. The define-chain-obj-to-func-parens-in-text test passes here while the if-with-macros test fails. --- tests/054-if-with-macros.c | 34 ++++++++++++++++++++++ .../055-define-chain-obj-to-func-parens-in-text.c | 3 ++ 2 files changed, 37 insertions(+) create mode 100644 tests/054-if-with-macros.c create mode 100644 tests/055-define-chain-obj-to-func-parens-in-text.c diff --git a/tests/054-if-with-macros.c b/tests/054-if-with-macros.c new file mode 100644 index 00000000000..3da79a0d96e --- /dev/null +++ b/tests/054-if-with-macros.c @@ -0,0 +1,34 @@ +#define one 1 +#define two 2 +#define three 3 +#define five 5 +#if five < two +failure_1 +#else +success_1 +#endif +#if three >= two +success_2 +#else +failure_2 +#endif +#if two + three <= five +success_3 +#else +failure_3 +#endif +#if five - two == three +success_4 +#else +failure_4 +#endif +#if one > three +failure_5 +#else +success_5 +#endif +#if one != five +success_6 +#else +failure_6 +#endif diff --git a/tests/055-define-chain-obj-to-func-parens-in-text.c b/tests/055-define-chain-obj-to-func-parens-in-text.c new file mode 100644 index 00000000000..00f2c2346d6 --- /dev/null +++ b/tests/055-define-chain-obj-to-func-parens-in-text.c @@ -0,0 +1,3 @@ +#define failure() success +#define foo failure +foo() -- cgit v1.2.3 From 7db2402a8009772a3f10d19cfc7f30be9ee79295 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 26 May 2010 17:01:57 -0700 Subject: Add support (and test) for an object-to-function chain with the parens in the content. That is, the following case: #define foo(x) (x) #define bar bar(baz) which now works with this (ugly) commit. I definitely want to come up with something cleaner than this. --- glcpp-parse.y | 65 ++++++++++++++++------ .../055-define-chain-obj-to-func-parens-in-text.c | 3 + 2 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 tests/055-define-chain-obj-to-func-parens-in-text.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 1346b65aff6..abdcd1ed5d8 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -926,9 +926,9 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser, * needs further expansion. */ static int -_glcpp_parser_expand_token_onto (glcpp_parser_t *parser, - token_t *token, - token_list_t *result) +_expand_token_onto (glcpp_parser_t *parser, + token_t *token, + token_list_t *result) { const char *identifier; macro_t *macro; @@ -1075,10 +1075,10 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) /* Prints the expansion of *node (consuming further tokens from the * list as necessary). Upon return *node will be the last consumed * node, such that further processing can continue with node->next. */ -static void -_glcpp_parser_expand_function_onto (glcpp_parser_t *parser, - token_node_t **node_ret, - token_list_t *result) +static function_status_t +_expand_function_onto (glcpp_parser_t *parser, + token_node_t **node_ret, + token_list_t *result) { macro_t *macro; token_node_t *node; @@ -1103,7 +1103,7 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, break; case FUNCTION_NOT_A_FUNCTION: _token_list_append (result, node->token); - return; + return FUNCTION_NOT_A_FUNCTION; case FUNCTION_UNBALANCED_PARENTHESES: fprintf (stderr, "Error: Macro %s call has unbalanced parentheses\n", identifier); @@ -1112,7 +1112,7 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, if (macro->replacements == NULL) { talloc_free (arguments); - return; + return FUNCTION_STATUS_SUCCESS; } if (_argument_list_length (arguments) != @@ -1123,7 +1123,7 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, identifier, _argument_list_length (arguments), _string_list_length (macro->parameters)); - return; + exit (1); } /* Perform argument substitution on the replacement list. */ @@ -1191,6 +1191,8 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, _string_list_pop (parser->active); talloc_free (arguments); + + return FUNCTION_STATUS_SUCCESS; } static void @@ -1199,19 +1201,50 @@ _glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, token_list_t *result) { token_node_t *node; + token_list_t *intermediate, *list_orig = list; + int i, need_rescan = 0; if (list == NULL) return; - for (node = list->head; node; node = node->next) - { - if (_glcpp_parser_expand_token_onto (parser, node->token, - result)) + intermediate = _token_list_create (parser); + + /* XXX: The two-pass expansion here is really ugly. The + * problem this is solving is that we can expand a macro into + * a function-like macro name, and then we need to recognize + * that as a function-like macro, but perhaps the parentheses + * and arguments aren't on the token list yet, (since they are + * in the actual content so they are part of what we are + * expanding. + * + * This ugly hack works, but is messy, fragile, and hard to + * maintain. I think a cleaner solution would separate the + * notions of expanding and appending and avoid this problem + * altogether. + */ + + for (i = 0; i < 2; i++) { + if (i == 1) { + list = intermediate; + intermediate = _token_list_create (parser); + } + for (node = list->head; node; node = node->next) { - _glcpp_parser_expand_function_onto (parser, &node, - result); + if (_expand_token_onto (parser, node->token, + intermediate)) + { + if (_expand_function_onto (parser, &node, + intermediate)) + { + need_rescan = 1; + } + } } + if (list != list_orig) + talloc_free (list); } + + _token_list_append_list (result, intermediate); } void diff --git a/tests/055-define-chain-obj-to-func-parens-in-text.c b/tests/055-define-chain-obj-to-func-parens-in-text.c new file mode 100644 index 00000000000..00f2c2346d6 --- /dev/null +++ b/tests/055-define-chain-obj-to-func-parens-in-text.c @@ -0,0 +1,3 @@ +#define failure() success +#define foo failure +foo() -- cgit v1.2.3 From 2fd22486d4e1f19515e7f8d11f65daee371c2d95 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 26 May 2010 17:04:19 -0700 Subject: Reimplement ir_copy_propagation_visitor using ir_hierarchical_vistor --- ir_copy_propagation.cpp | 150 +++++++++++++++--------------------------------- 1 file changed, 45 insertions(+), 105 deletions(-) diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index 82172d29b65..1c5c10d6fce 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -55,92 +55,59 @@ public: ir_variable *rhs; }; -class ir_copy_propagation_visitor : public ir_visitor { +class ir_copy_propagation_visitor : public ir_hierarchical_visitor { public: ir_copy_propagation_visitor(exec_list *acp) { progress = false; + in_lhs = false; this->acp = acp; } - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - /*@}*/ + virtual ir_visitor_status visit(class ir_dereference_variable *); + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_enter(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_if *); /** List of acp_entry */ exec_list *acp; bool progress; + + /** Currently in the LHS of an assignment? */ + bool in_lhs; }; -void -ir_copy_propagation_visitor::visit(ir_variable *ir) +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_loop *ir) { (void)ir; + return visit_continue_with_parent; } - -void -ir_copy_propagation_visitor::visit(ir_loop *ir) +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir) { (void)ir; + return visit_continue_with_parent; } -void -ir_copy_propagation_visitor::visit(ir_loop_jump *ir) +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_assignment *ir) { (void) ir; + this->in_lhs = true; + return visit_continue; } - -void -ir_copy_propagation_visitor::visit(ir_function_signature *ir) -{ - (void)ir; -} - -void -ir_copy_propagation_visitor::visit(ir_function *ir) +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_function *ir) { (void) ir; -} - -void -ir_copy_propagation_visitor::visit(ir_expression *ir) -{ - unsigned int operand; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - ir->operands[operand]->accept(this); - } -} - - -void -ir_copy_propagation_visitor::visit(ir_swizzle *ir) -{ - ir->val->accept(this); + return visit_continue_with_parent; } /** @@ -150,9 +117,17 @@ ir_copy_propagation_visitor::visit(ir_swizzle *ir) * rewriting of ir_dereference means that the ir_dereference instance * must not be shared by multiple IR operations! */ -void +ir_visitor_status ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) { + /* Ignores the LHS. Don't want to rewrite the LHS to point at some + * other storage! + */ + if (this->in_lhs) { + this->in_lhs = false; + return visit_continue; + } + ir_variable *var = ir->variable_referenced(); foreach_iter(exec_list_iterator, iter, *this->acp) { @@ -164,67 +139,32 @@ ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) break; } } -} -void -ir_copy_propagation_visitor::visit(ir_dereference_array *ir) -{ - ir->array->accept(this); - ir->array_index->accept(this); -} - -void -ir_copy_propagation_visitor::visit(ir_dereference_record *ir) -{ - ir->record->accept(this); -} - -void -ir_copy_propagation_visitor::visit(ir_assignment *ir) -{ - if (ir->condition) - ir->condition->accept(this); - - /* Ignores the LHS. Don't want to rewrite the LHS to point at some - * other storage! - */ - - ir->rhs->accept(this); + return visit_continue; } -void -ir_copy_propagation_visitor::visit(ir_constant *ir) -{ - (void) ir; -} - - -void -ir_copy_propagation_visitor::visit(ir_call *ir) +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_call *ir) { (void)ir; /* Note, if we were to do copy propagation to parameters of calls, we'd * have to be careful about out params. */ + return visit_continue_with_parent; } -void -ir_copy_propagation_visitor::visit(ir_return *ir) -{ - ir_rvalue *val = ir->get_value(); - - if (val) - val->accept(this); -} - - -void -ir_copy_propagation_visitor::visit(ir_if *ir) +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_if *ir) { ir->condition->accept(this); + + /* Do not traverse into the body of the if-statement since that is a + * different basic block. + */ + return visit_continue_with_parent; } static bool -- cgit v1.2.3 From e668c2a9eeca65e5b2a7635074d9c47c93a68c6e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 26 May 2010 18:58:27 -0700 Subject: Reimplement ir_function_inlining_visitor using ir_hierarchical_vistor --- ir_function_inlining.cpp | 182 +++++++++++------------------------------------ 1 file changed, 43 insertions(+), 139 deletions(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 9109ce698b2..7ac74ca03b6 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -34,11 +34,11 @@ #include "ir_expression_flattening.h" #include "glsl_types.h" -class ir_function_inlining_visitor : public ir_visitor { +class ir_function_inlining_visitor : public ir_hierarchical_visitor { public: ir_function_inlining_visitor() { - /* empty */ + progress = false; } virtual ~ir_function_inlining_visitor() @@ -46,30 +46,13 @@ public: /* empty */ } - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - /*@}*/ + virtual ir_visitor_status visit_enter(ir_expression *); + virtual ir_visitor_status visit_enter(ir_call *); + virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_swizzle *); + + bool progress; }; class variable_remap : public exec_node { @@ -336,39 +319,13 @@ automatic_inlining_predicate(ir_instruction *ir) bool do_function_inlining(exec_list *instructions) { - bool progress = false; + ir_function_inlining_visitor v; do_expression_flattening(instructions, automatic_inlining_predicate); - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_assignment *assign = ir->as_assignment(); - ir_call *call; - - if (assign) { - call = assign->rhs->as_call(); - if (!call || !can_inline(call)) - continue; - - /* generates the parameter setup, function body, and returns the return - * value of the function - */ - ir_rvalue *rhs = call->generate_inline(ir); - assert(rhs); - - assign->rhs = rhs; - progress = true; - } else if ((call = ir->as_call()) && can_inline(call)) { - (void)call->generate_inline(ir); - ir->remove(); - progress = true; - } else { - ir_function_inlining_visitor v; - ir->accept(&v); - } - } + v.run(instructions); - return progress; + return v.progress; } ir_rvalue * @@ -462,112 +419,59 @@ ir_call::generate_inline(ir_instruction *next_ir) return NULL; } -void -ir_function_inlining_visitor::visit(ir_variable *ir) + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_expression *ir) { (void) ir; + return visit_continue_with_parent; } -void -ir_function_inlining_visitor::visit(ir_loop *ir) -{ - do_function_inlining(&ir->body_instructions); -} - -void -ir_function_inlining_visitor::visit(ir_loop_jump *ir) +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_return *ir) { (void) ir; + return visit_continue_with_parent; } -void -ir_function_inlining_visitor::visit(ir_function_signature *ir) +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_swizzle *ir) { - do_function_inlining(&ir->body); + (void) ir; + return visit_continue_with_parent; } -void -ir_function_inlining_visitor::visit(ir_function *ir) +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_call *ir) { - foreach_iter(exec_list_iterator, iter, *ir) { - ir_function_signature *const sig = (ir_function_signature *) iter.get(); - sig->accept(this); + if (can_inline(ir)) { + (void) ir->generate_inline(ir); + ir->remove(); + this->progress = true; } -} -void -ir_function_inlining_visitor::visit(ir_expression *ir) -{ - unsigned int operand; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - ir->operands[operand]->accept(this); - } -} - - -void -ir_function_inlining_visitor::visit(ir_swizzle *ir) -{ - ir->val->accept(this); -} - - -void -ir_function_inlining_visitor::visit(ir_dereference_variable *ir) -{ - ir->var->accept(this); -} - -void -ir_function_inlining_visitor::visit(ir_dereference_array *ir) -{ - ir->array_index->accept(this); - ir->array->accept(this); -} - -void -ir_function_inlining_visitor::visit(ir_dereference_record *ir) -{ - ir->record->accept(this); -} - -void -ir_function_inlining_visitor::visit(ir_assignment *ir) -{ - ir->rhs->accept(this); + return visit_continue; } -void -ir_function_inlining_visitor::visit(ir_constant *ir) +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_assignment *ir) { - (void) ir; -} - - -void -ir_function_inlining_visitor::visit(ir_call *ir) -{ - (void) ir; -} - - -void -ir_function_inlining_visitor::visit(ir_return *ir) -{ - (void) ir; -} + ir_call *call = ir->rhs->as_call(); + if (!call || !can_inline(call)) + return visit_continue; + /* generates the parameter setup, function body, and returns the return + * value of the function + */ + ir_rvalue *rhs = call->generate_inline(ir); + assert(rhs); -void -ir_function_inlining_visitor::visit(ir_if *ir) -{ - ir->condition->accept(this); + ir->rhs = rhs; + this->progress = true; - do_function_inlining(&ir->then_instructions); - do_function_inlining(&ir->else_instructions); + return visit_continue; } -- cgit v1.2.3 From dd7490093d84ce74a99922c3544b51c3f5d43345 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 27 May 2010 10:12:33 -0700 Subject: Avoid treating an expanded comma as an argument separator. That is, a function-like invocation foo(x) is valid as a single-argument invocation even if 'x' is a macro that expands into a value with a comma. Add a new COMMA_FINAL token type to handle this, and add a test for this case, (which passes). --- glcpp-parse.y | 18 ++++++++++++++++-- tests/056-macro-argument-with-comma.c | 4 ++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/056-macro-argument-with-comma.c diff --git a/glcpp-parse.y b/glcpp-parse.y index abdcd1ed5d8..b2684d06d98 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -132,7 +132,7 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER NEWLINE OTHER SPACE +%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER NEWLINE OTHER SPACE %token PASTE %type expression INTEGER operator SPACE %type IDENTIFIER OTHER @@ -740,6 +740,9 @@ _token_print (token_t *token) case PASTE: printf ("##"); break; + case COMMA_FINAL: + printf (","); + break; default: fprintf (stderr, "Error: Don't know how to print token type %d\n", token->type); break; @@ -936,7 +939,18 @@ _expand_token_onto (glcpp_parser_t *parser, /* We only expand identifiers */ if (token->type != IDENTIFIER) { - _token_list_append (result, token); + /* We change any COMMA into a COMMA_FINAL to prevent + * it being mistaken for an argument separator + * later. */ + if (token->type == ',') { + token_t *new_token; + + new_token = _token_create_ival (result, COMMA_FINAL, + COMMA_FINAL); + _token_list_append (result, new_token); + } else { + _token_list_append (result, token); + } return 0; } diff --git a/tests/056-macro-argument-with-comma.c b/tests/056-macro-argument-with-comma.c new file mode 100644 index 00000000000..58701d1f25b --- /dev/null +++ b/tests/056-macro-argument-with-comma.c @@ -0,0 +1,4 @@ +#define bar with,embedded,commas +#define function(x) success +#define foo function +foo(bar) -- cgit v1.2.3 From 602a34769a0850a98366c4011ce8b8c7d08c9276 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 27 May 2010 10:14:38 -0700 Subject: Add test 56 for a comma within the expansion of an argument. This case was tricky on the take-2 branch. It happens to be passing already here. --- tests/056-macro-argument-with-comma.c | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/056-macro-argument-with-comma.c diff --git a/tests/056-macro-argument-with-comma.c b/tests/056-macro-argument-with-comma.c new file mode 100644 index 00000000000..58701d1f25b --- /dev/null +++ b/tests/056-macro-argument-with-comma.c @@ -0,0 +1,4 @@ +#define bar with,embedded,commas +#define function(x) success +#define foo function +foo(bar) -- cgit v1.2.3 From a65cf7b1d29e98ef3bf31051df8a06cb394d131f Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 27 May 2010 11:55:36 -0700 Subject: Make two list-processing functions do nothing with an empty list. This just makes these functions easier to understand all around. In the case of _token_list_append_list this is an actual bug fix, (where append an empty list onto a non-empty list would previously scramble the tail pointer of the original list). --- glcpp-parse.y | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index b2684d06d98..ba79a611f6e 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -666,6 +666,9 @@ _token_list_append (token_list_t *list, token_t *token) void _token_list_append_list (token_list_t *list, token_list_t *tail) { + if (tail == NULL || tail->head == NULL) + return; + if (list->head == NULL) { list->head = tail->head; } else { @@ -1218,7 +1221,7 @@ _glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, token_list_t *intermediate, *list_orig = list; int i, need_rescan = 0; - if (list == NULL) + if (list == NULL || list->head == NULL) return; intermediate = _token_list_create (parser); -- cgit v1.2.3 From a19297b26e971e5a9dbe00b4254931505da4b5a9 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 27 May 2010 13:29:19 -0700 Subject: Provide support for empty arguments in macro invocations. For this we always add a new argument to the argument list as soon as possible, without waiting until we see some argument token. This does mean we need to take some extra care when comparing the number of arguments with the number of expected arguments. In addition to matching numbers, we also support one (empty) argument when zero arguments are expected. Add a test case here for this, which does pass. --- glcpp-parse.y | 20 +++++++++++--------- tests/057-empty-arguments.c | 6 ++++++ 2 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 tests/057-empty-arguments.c diff --git a/glcpp-parse.y b/glcpp-parse.y index ba79a611f6e..3e0a96528b4 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -1044,7 +1044,8 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) last = node; node = node->next; - argument = NULL; + argument = _token_list_create (arguments); + _argument_list_append (arguments, argument); for (paren_count = 1; node; last = node, node = node->next) { if (node->token->type == '(') @@ -1064,18 +1065,16 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) if (node->token->type == ',' && paren_count == 1) { - if (argument) - _token_list_trim_trailing_space (argument); - argument = NULL; + _token_list_trim_trailing_space (argument); + argument = _token_list_create (arguments); + _argument_list_append (arguments, argument); } else { - if (argument == NULL) { + if (argument->head == NULL) { /* Don't treat initial whitespace as * part of the arguement. */ if (node->token->type == SPACE) continue; - argument = _token_list_create (arguments); - _argument_list_append (arguments, argument); } _token_list_append (argument, node->token); } @@ -1132,8 +1131,11 @@ _expand_function_onto (glcpp_parser_t *parser, return FUNCTION_STATUS_SUCCESS; } - if (_argument_list_length (arguments) != - _string_list_length (macro->parameters)) + if (! ((_argument_list_length (arguments) == + _string_list_length (macro->parameters)) || + (_string_list_length (macro->parameters) == 0 && + _argument_list_length (arguments) == 1 && + arguments->head->argument->head == NULL))) { fprintf (stderr, "Error: macro %s invoked with %d arguments (expected %d)\n", diff --git a/tests/057-empty-arguments.c b/tests/057-empty-arguments.c new file mode 100644 index 00000000000..6140232865d --- /dev/null +++ b/tests/057-empty-arguments.c @@ -0,0 +1,6 @@ +#define zero() success +zero() +#define one(x) success +one() +#define two(x,y) success +two(,) -- cgit v1.2.3 From fb48fcdf9b5a5b002469ed247809fb0294d6c7a8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 27 May 2010 13:44:13 -0700 Subject: Add test for macro invocations with empty arguments. This case was recently solved on the take-2 branch. --- tests/057-empty-arguments.c | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/057-empty-arguments.c diff --git a/tests/057-empty-arguments.c b/tests/057-empty-arguments.c new file mode 100644 index 00000000000..6140232865d --- /dev/null +++ b/tests/057-empty-arguments.c @@ -0,0 +1,6 @@ +#define zero() success +zero() +#define one(x) success +one() +#define two(x,y) success +two(,) -- cgit v1.2.3 From 85b50e840d969c4d9ebcfcc3df1df7a95e07e34e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 27 May 2010 14:01:18 -0700 Subject: Add placeholder tokens to support pasting with empty arguments. Along with a passing test to verify that this works. --- glcpp-parse.y | 36 +++++++++++++++++++++++++------ tests/058-token-pasting-empty-arguments.c | 5 +++++ 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 tests/058-token-pasting-empty-arguments.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 3e0a96528b4..d587a4bf338 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -132,7 +132,7 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER NEWLINE OTHER SPACE +%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER NEWLINE OTHER PLACEHOLDER SPACE %token PASTE %type expression INTEGER operator SPACE %type IDENTIFIER OTHER @@ -746,6 +746,9 @@ _token_print (token_t *token) case COMMA_FINAL: printf (","); break; + case PLACEHOLDER: + /* Nothing to print. */ + break; default: fprintf (stderr, "Error: Don't know how to print token type %d\n", token->type); break; @@ -756,6 +759,17 @@ _token_print (token_t *token) static void _token_paste (token_t *token, token_t *other) { + /* Pasting a placeholder onto anything makes no change. */ + if (other->type == PLACEHOLDER) + return; + + /* When 'token' is a placeholder, just return contents of 'other'. */ + if (token->type == PLACEHOLDER) { + token->type = other->type; + token->value = other->value; + return; + } + /* A very few single-character punctuators can be combined * with another to form a multi-character punctuator. */ switch (token->type) { @@ -1159,10 +1173,20 @@ _expand_function_onto (glcpp_parser_t *parser, argument = _argument_list_member_at (arguments, parameter_index); /* Before substituting, we expand the argument - * tokens. */ - _glcpp_parser_expand_token_list_onto (parser, - argument, - substituted); + * tokens, or append a placeholder token for + * an empty argument. */ + if (argument->head) { + _glcpp_parser_expand_token_list_onto (parser, + argument, + substituted); + } else { + token_t *new_token; + + new_token = _token_create_ival (substituted, + PLACEHOLDER, + PLACEHOLDER); + _token_list_append (substituted, new_token); + } } else { _token_list_append (substituted, node->token); } @@ -1196,7 +1220,7 @@ _expand_function_onto (glcpp_parser_t *parser, if (next_non_space == NULL) { fprintf (stderr, "Error: '##' cannot appear at either end of a macro expansion\n"); - exit (1); + return FUNCTION_STATUS_SUCCESS; } _token_paste (node->token, next_non_space->token); diff --git a/tests/058-token-pasting-empty-arguments.c b/tests/058-token-pasting-empty-arguments.c new file mode 100644 index 00000000000..8ac260c76b6 --- /dev/null +++ b/tests/058-token-pasting-empty-arguments.c @@ -0,0 +1,5 @@ +#define paste(x,y) x ## y +paste(a,b) +paste(a,) +paste(,b) +paste(,) -- cgit v1.2.3 From 050e3ded1ea05cfe336dd0cd20212d17d7960c9e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 27 May 2010 14:36:29 -0700 Subject: Implement token pasting of integers. To do this correctly, we change the lexer to lex integers as string values, (new token type of INTEGER_STRING), and only convert to integer values when evaluating an expression value. Add a new test case for this, (which does pass now). --- Makefile | 2 +- glcpp-lex.l | 12 ++++++------ glcpp-parse.y | 32 ++++++++++++++++++++++---------- tests/059-token-pasting-integer.c | 4 ++++ 4 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 tests/059-token-pasting-integer.c diff --git a/Makefile b/Makefile index 88116128f85..0c06aa880fb 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ CFLAGS = -g override CFLAGS += -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wno-unused glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o xtalloc.o - gcc -o $@ -ltalloc $^ + gcc -o $@ -ltalloc -lm $^ %.c %.h: %.y bison --debug --defines=$*.h --output=$*.c $^ diff --git a/glcpp-lex.l b/glcpp-lex.l index d6b7726d36d..70d47d24975 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -88,18 +88,18 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } {DECIMAL_INTEGER} { - yylval.ival = strtoll (yytext, NULL, 10); - return INTEGER; + yylval.str = xtalloc_strdup (yyextra, yytext); + return INTEGER_STRING; } {OCTAL_INTEGER} { - yylval.ival = strtoll (yytext + 1, NULL, 8); - return INTEGER; + yylval.str = xtalloc_strdup (yyextra, yytext); + return INTEGER_STRING; } {HEXADECIMAL_INTEGER} { - yylval.ival = strtoll (yytext + 2, NULL, 16); - return INTEGER; + yylval.str = xtalloc_strdup (yyextra, yytext); + return INTEGER_STRING; } "<<" { diff --git a/glcpp-parse.y b/glcpp-parse.y index d587a4bf338..5b2d0d3927a 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -132,10 +132,10 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER NEWLINE OTHER PLACEHOLDER SPACE +%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING NEWLINE OTHER PLACEHOLDER SPACE %token PASTE %type expression INTEGER operator SPACE -%type IDENTIFIER OTHER +%type IDENTIFIER INTEGER_STRING OTHER %type identifier_list %type preprocessing_token %type pp_tokens replacement_list text_line @@ -253,7 +253,16 @@ control_line: ; expression: - INTEGER { + INTEGER_STRING { + if (strlen ($1) >= 3 && strncmp ($1, "0x", 2) == 0) { + $$ = strtoll ($1 + 2, NULL, 16); + } else if ($1[0] == '0') { + $$ = strtoll ($1, NULL, 8); + } else { + $$ = strtoll ($1, NULL, 10); + } + } +| INTEGER { $$ = $1; } | expression OR expression { @@ -372,8 +381,8 @@ preprocessing_token: IDENTIFIER { $$ = _token_create_str (parser, IDENTIFIER, $1); } -| INTEGER { - $$ = _token_create_ival (parser, INTEGER, $1); +| INTEGER_STRING { + $$ = _token_create_str (parser, INTEGER_STRING, $1); } | operator { $$ = _token_create_ival (parser, $1, $1); @@ -710,6 +719,7 @@ _token_print (token_t *token) printf ("%" PRIxMAX, token->value.ival); break; case IDENTIFIER: + case INTEGER_STRING: case OTHER: printf ("%s", token->value.str); break; @@ -828,11 +838,13 @@ _token_paste (token_t *token, token_t *other) /* Two string-valued tokens can usually just be mashed * together. * - * XXX: Since our 'OTHER' case is currently so loose, this may - * allow some things thruogh that should be treated as - * errors. */ - if ((token->type == IDENTIFIER || token->type == OTHER) && - (other->type == IDENTIFIER || other->type == OTHER)) + * XXX: This isn't actually legitimate. Several things here + * should result in a diagnostic since the result cannot be a + * valid, single pre-processing token. For example, pasting + * "123" and "abc" is not legal, but we don't catch that + * here. */ + if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) && + (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING)) { token->value.str = talloc_strdup_append (token->value.str, other->value.str); diff --git a/tests/059-token-pasting-integer.c b/tests/059-token-pasting-integer.c new file mode 100644 index 00000000000..37b895a4237 --- /dev/null +++ b/tests/059-token-pasting-integer.c @@ -0,0 +1,4 @@ +#define paste(x,y) x ## y +paste(1,2) +paste(1,000) +paste(identifier,2) -- cgit v1.2.3 From 886e05a35a319cdace9afed93d0cc8df2c7f33e0 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 27 May 2010 14:45:20 -0700 Subject: Add test for token-pasting of integers. This test was tricky to make pass in the take-2 branch. It ends up passing already here with no additional effort, (since we are lexing integers as string-valued token except when in the ST_IF state in the lexer anyway). --- tests/059-token-pasting-integer.c | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/059-token-pasting-integer.c diff --git a/tests/059-token-pasting-integer.c b/tests/059-token-pasting-integer.c new file mode 100644 index 00000000000..37b895a4237 --- /dev/null +++ b/tests/059-token-pasting-integer.c @@ -0,0 +1,4 @@ +#define paste(x,y) x ## y +paste(1,2) +paste(1,000) +paste(identifier,2) -- cgit v1.2.3 From baa17c87485b5e776ec142844f5df38a3df9dccc Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 27 May 2010 14:53:51 -0700 Subject: Remove blank lines from output files before comparing. Recently I'm seeing cases where "gcc -E" mysteriously omits blank lines, (even though it prints the blank lines in other very similar cases). Rather than trying to decipher and imitate this, just get rid of the blank lines. This approach with sed to kill the lines before the diff is better than "diff -B" since when there is an actual difference, the presence of blank lines won't make the diff harder to read. --- .gitignore | 1 + tests/glcpp-test | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d67bd38c93c..b88f0cc75c7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ glcpp-parse.h *~ tests/*.expected tests/*.gcc +tests/*.glcpp tests/*.out diff --git a/tests/glcpp-test b/tests/glcpp-test index bf88d4462e1..92c994979a9 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -3,8 +3,9 @@ set -e for test in *.c; do echo "Testing $test" - ../glcpp < $test > $test.out + ../glcpp < $test > $test.glcpp + grep -v '^$' < $test.glcpp > $test.out || true gcc -E $test -o $test.gcc - grep -v '^#' < $test.gcc > $test.expected - diff -B -u $test.expected $test.out + grep -v '^#' < $test.gcc | grep -v '^$' > $test.expected || true + diff -u $test.expected $test.out done -- cgit v1.2.3 From 95ec433d59be234cf2695ae091cee4ace3314d21 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 28 May 2010 08:00:43 -0700 Subject: Revert "Add support for an object-to-function chain with the parens in the content." This reverts commit 7db2402a8009772a3f10d19cfc7f30be9ee79295 It doesn't revert the new test case from that commit, just the extremely ugly second-pass implementation. --- glcpp-parse.y | 65 +++++++++++++++-------------------------------------------- 1 file changed, 16 insertions(+), 49 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 5b2d0d3927a..f4cb72a133f 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -958,9 +958,9 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser, * needs further expansion. */ static int -_expand_token_onto (glcpp_parser_t *parser, - token_t *token, - token_list_t *result) +_glcpp_parser_expand_token_onto (glcpp_parser_t *parser, + token_t *token, + token_list_t *result) { const char *identifier; macro_t *macro; @@ -1117,10 +1117,10 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) /* Prints the expansion of *node (consuming further tokens from the * list as necessary). Upon return *node will be the last consumed * node, such that further processing can continue with node->next. */ -static function_status_t -_expand_function_onto (glcpp_parser_t *parser, - token_node_t **node_ret, - token_list_t *result) +static void +_glcpp_parser_expand_function_onto (glcpp_parser_t *parser, + token_node_t **node_ret, + token_list_t *result) { macro_t *macro; token_node_t *node; @@ -1145,7 +1145,7 @@ _expand_function_onto (glcpp_parser_t *parser, break; case FUNCTION_NOT_A_FUNCTION: _token_list_append (result, node->token); - return FUNCTION_NOT_A_FUNCTION; + return; case FUNCTION_UNBALANCED_PARENTHESES: fprintf (stderr, "Error: Macro %s call has unbalanced parentheses\n", identifier); @@ -1154,7 +1154,7 @@ _expand_function_onto (glcpp_parser_t *parser, if (macro->replacements == NULL) { talloc_free (arguments); - return FUNCTION_STATUS_SUCCESS; + return; } if (! ((_argument_list_length (arguments) == @@ -1168,7 +1168,7 @@ _expand_function_onto (glcpp_parser_t *parser, identifier, _argument_list_length (arguments), _string_list_length (macro->parameters)); - exit (1); + return; } /* Perform argument substitution on the replacement list. */ @@ -1246,8 +1246,6 @@ _expand_function_onto (glcpp_parser_t *parser, _string_list_pop (parser->active); talloc_free (arguments); - - return FUNCTION_STATUS_SUCCESS; } static void @@ -1256,50 +1254,19 @@ _glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, token_list_t *result) { token_node_t *node; - token_list_t *intermediate, *list_orig = list; - int i, need_rescan = 0; if (list == NULL || list->head == NULL) return; - intermediate = _token_list_create (parser); - - /* XXX: The two-pass expansion here is really ugly. The - * problem this is solving is that we can expand a macro into - * a function-like macro name, and then we need to recognize - * that as a function-like macro, but perhaps the parentheses - * and arguments aren't on the token list yet, (since they are - * in the actual content so they are part of what we are - * expanding. - * - * This ugly hack works, but is messy, fragile, and hard to - * maintain. I think a cleaner solution would separate the - * notions of expanding and appending and avoid this problem - * altogether. - */ - - for (i = 0; i < 2; i++) { - if (i == 1) { - list = intermediate; - intermediate = _token_list_create (parser); - } - for (node = list->head; node; node = node->next) + for (node = list->head; node; node = node->next) + { + if (_glcpp_parser_expand_token_onto (parser, node->token, + result)) { - if (_expand_token_onto (parser, node->token, - intermediate)) - { - if (_expand_function_onto (parser, &node, - intermediate)) - { - need_rescan = 1; - } - } + _glcpp_parser_expand_function_onto (parser, &node, + result); } - if (list != list_orig) - talloc_free (list); } - - _token_list_append_list (result, intermediate); } void -- cgit v1.2.3 From 9b519f9c7997e0ec02c66d39edc12912aebb9eca Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 28 May 2010 08:04:13 -0700 Subject: Stop interrupting the test suite at the first failure. This behavior was useful when starting the implementation over ("take-2") where the whole test suite was failing. This made it easy to focus on one test at a time and get each working. More recently, we got the whole suite working, so we don't need this feature anymore. And in the previous commit, we regressed a couple of tests, so it's nice to be able to see all the failures with a single run of the suite. --- tests/glcpp-test | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/glcpp-test b/tests/glcpp-test index 92c994979a9..ba398af0d54 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -1,5 +1,4 @@ #!/bin/sh -set -e for test in *.c; do echo "Testing $test" -- cgit v1.2.3 From 3c93d397050bbeccb7809e53a425c860df947c45 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 28 May 2010 08:17:46 -0700 Subject: Simplify calling conventions of functions under expand_token_list_onto. We previously had a confusing thing where _expand_token_onto would return a non-zero value to indicate that the caller should then call _expand_function_onto. It's much cleaner for _expand_token_onto to just do what's needed and call the necessary function. --- glcpp-parse.y | 159 +++++++++++++++++++++++++++------------------------------- 1 file changed, 74 insertions(+), 85 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index f4cb72a133f..9f97b2a282a 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -948,81 +948,6 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser, } } - -/* Appends onto 'expansion' a non-macro token or the expansion of an - * object-like macro. - * - * Returns 0 if this token is completely processed. - * - * Returns 1 in the case that 'token' is a function-like macro that - * needs further expansion. - */ -static int -_glcpp_parser_expand_token_onto (glcpp_parser_t *parser, - token_t *token, - token_list_t *result) -{ - const char *identifier; - macro_t *macro; - token_list_t *expansion; - - /* We only expand identifiers */ - if (token->type != IDENTIFIER) { - /* We change any COMMA into a COMMA_FINAL to prevent - * it being mistaken for an argument separator - * later. */ - if (token->type == ',') { - token_t *new_token; - - new_token = _token_create_ival (result, COMMA_FINAL, - COMMA_FINAL); - _token_list_append (result, new_token); - } else { - _token_list_append (result, token); - } - return 0; - } - - /* Look up this identifier in the hash table. */ - identifier = token->value.str; - macro = hash_table_find (parser->defines, identifier); - - /* Not a macro, so just append. */ - if (macro == NULL) { - _token_list_append (result, token); - return 0; - } - - /* Finally, don't expand this macro if we're already actively - * expanding it, (to avoid infinite recursion). */ - if (_string_list_contains (parser->active, identifier, NULL)) - { - /* We change the token type here from IDENTIFIER to - * OTHER to prevent any future expansion of this - * unexpanded token. */ - char *str; - token_t *new_token; - - str = xtalloc_strdup (result, token->value.str); - new_token = _token_create_str (result, OTHER, str); - _token_list_append (result, new_token); - return 0; - } - - /* For function-like macros return 1 for further processing. */ - if (macro->is_function) { - return 1; - } - - _string_list_push (parser->active, identifier); - _glcpp_parser_expand_token_list_onto (parser, - macro->replacements, - result); - _string_list_pop (parser->active); - - return 0; -} - typedef enum function_status { FUNCTION_STATUS_SUCCESS, @@ -1114,9 +1039,10 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) return FUNCTION_STATUS_SUCCESS; } -/* Prints the expansion of *node (consuming further tokens from the - * list as necessary). Upon return *node will be the last consumed - * node, such that further processing can continue with node->next. */ +/* Appends expansion of *node (consuming further tokens from the list + * as necessary) onto result. Upon return *node will be the last + * consumed node, such that further processing can continue with + * node->next. */ static void _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, token_node_t **node_ret, @@ -1232,7 +1158,7 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, if (next_non_space == NULL) { fprintf (stderr, "Error: '##' cannot appear at either end of a macro expansion\n"); - return FUNCTION_STATUS_SUCCESS; + return; } _token_paste (node->token, next_non_space->token); @@ -1248,6 +1174,74 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, talloc_free (arguments); } + +/* Appends the expansion of the token in *node onto result. + * Upon return *node will be the last consumed node, such that further + * processing can continue with node->next. */ +static void +_glcpp_parser_expand_token_onto (glcpp_parser_t *parser, + token_node_t **node, + token_list_t *result) +{ + token_t *token = (*node)->token; + const char *identifier; + macro_t *macro; + token_list_t *expansion; + + /* We only expand identifiers */ + if (token->type != IDENTIFIER) { + /* We change any COMMA into a COMMA_FINAL to prevent + * it being mistaken for an argument separator + * later. */ + if (token->type == ',') { + token_t *new_token; + + new_token = _token_create_ival (result, COMMA_FINAL, + COMMA_FINAL); + _token_list_append (result, new_token); + } else { + _token_list_append (result, token); + } + return; + } + + /* Look up this identifier in the hash table. */ + identifier = token->value.str; + macro = hash_table_find (parser->defines, identifier); + + /* Not a macro, so just append. */ + if (macro == NULL) { + _token_list_append (result, token); + return; + } + + /* Finally, don't expand this macro if we're already actively + * expanding it, (to avoid infinite recursion). */ + if (_string_list_contains (parser->active, identifier, NULL)) + { + /* We change the token type here from IDENTIFIER to + * OTHER to prevent any future expansion of this + * unexpanded token. */ + char *str; + token_t *new_token; + + str = xtalloc_strdup (result, token->value.str); + new_token = _token_create_str (result, OTHER, str); + _token_list_append (result, new_token); + return; + } + + if (macro->is_function) { + _glcpp_parser_expand_function_onto (parser, node, result); + } else { + _string_list_push (parser->active, identifier); + _glcpp_parser_expand_token_list_onto (parser, + macro->replacements, + result); + _string_list_pop (parser->active); + } +} + static void _glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, token_list_t *list, @@ -1260,12 +1254,7 @@ _glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, for (node = list->head; node; node = node->next) { - if (_glcpp_parser_expand_token_onto (parser, node->token, - result)) - { - _glcpp_parser_expand_function_onto (parser, &node, - result); - } + _glcpp_parser_expand_token_onto (parser, &node, result); } } -- cgit v1.2.3 From 681afbc855c86df8c3521ccdfadb7f16b9729baa Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 28 May 2010 15:06:02 -0700 Subject: Perform macro by replacing tokens in original list. We take the results of macro expansion and splice them into the original token list over which we are iterating. This makes it easy for function-like macro invocations to find their arguments since they are simply subsequent tokens on the list. This fixes the recently-introduced regressions (tests 55 and 56) and also passes new tests 60 and 61 introduced to strees this feature, (with macro-argument parentheses split between a macro value and the textual input). --- glcpp-parse.y | 278 +++++++++++++-------- .../060-left-paren-in-macro-right-paren-in-text.c | 3 + tests/061-define-chain-obj-to-func-multi.c | 5 + 3 files changed, 187 insertions(+), 99 deletions(-) create mode 100644 tests/060-left-paren-in-macro-right-paren-in-text.c create mode 100644 tests/061-define-chain-obj-to-func-multi.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 9f97b2a282a..c89d7bf159c 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -101,13 +101,12 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser, token_list_t *list); static void -_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, - token_list_t *list); +_glcpp_parser_expand_token_list (glcpp_parser_t *parser, + token_list_t *list); static void -_glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, - token_list_t *list, - token_list_t *result); +_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, + token_list_t *list); static void _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition); @@ -218,7 +217,8 @@ control_line: _token_list_append (expanded, token); talloc_unlink (parser, token); _glcpp_parser_evaluate_defined (parser, $2); - _glcpp_parser_expand_token_list_onto (parser, $2, expanded); + _glcpp_parser_expand_token_list (parser, $2); + _token_list_append_list (expanded, $2); glcpp_parser_lex_from (parser, expanded); } | HASH_IFDEF IDENTIFIER NEWLINE { @@ -240,7 +240,8 @@ control_line: _token_list_append (expanded, token); talloc_unlink (parser, token); _glcpp_parser_evaluate_defined (parser, $2); - _glcpp_parser_expand_token_list_onto (parser, $2, expanded); + _glcpp_parser_expand_token_list (parser, $2); + _token_list_append_list (expanded, $2); glcpp_parser_lex_from (parser, expanded); } | HASH_ELSE NEWLINE { @@ -688,6 +689,22 @@ _token_list_append_list (token_list_t *list, token_list_t *tail) list->non_space_tail = tail->non_space_tail; } +token_list_t * +_token_list_copy (void *ctx, token_list_t *other) +{ + token_list_t *copy; + token_node_t *node; + + if (other == NULL) + return NULL; + + copy = _token_list_create (ctx); + for (node = other->head; node; node = node->next) + _token_list_append (copy, node->token); + + return copy; +} + void _token_list_trim_trailing_space (token_list_t *list) { @@ -956,9 +973,12 @@ typedef enum function_status } function_status_t; /* Find a set of function-like macro arguments by looking for a - * balanced set of parentheses. Upon return *node will be the last - * consumed node, such that further processing can continue with - * node->next. + * balanced set of parentheses. + * + * When called, 'node' should be the opening-parenthesis token, (or + * perhaps preceeding SPACE tokens). Upon successful return *last will + * be the last consumed node, (corresponding to the closing right + * parenthesis). * * Return values: * @@ -976,13 +996,13 @@ typedef enum function_status * Macro name is not followed by a balanced set of parentheses. */ static function_status_t -_arguments_parse (argument_list_t *arguments, token_node_t **node_ret) +_arguments_parse (argument_list_t *arguments, + token_node_t *node, + token_node_t **last) { token_list_t *argument; - token_node_t *node = *node_ret, *last; int paren_count; - last = node; node = node->next; /* Ignore whitespace before first parenthesis. */ @@ -992,13 +1012,12 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) if (node == NULL || node->token->type != '(') return FUNCTION_NOT_A_FUNCTION; - last = node; node = node->next; argument = _token_list_create (arguments); _argument_list_append (arguments, argument); - for (paren_count = 1; node; last = node, node = node->next) { + for (paren_count = 1; node; node = node->next) { if (node->token->type == '(') { paren_count++; @@ -1006,11 +1025,8 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) else if (node->token->type == ')') { paren_count--; - if (paren_count == 0) { - last = node; - node = node->next; + if (paren_count == 0) break; - } } if (node->token->type == ',' && @@ -1031,32 +1047,44 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) } } - if (node && paren_count) + if (paren_count) return FUNCTION_UNBALANCED_PARENTHESES; - *node_ret = last; + *last = node; return FUNCTION_STATUS_SUCCESS; } -/* Appends expansion of *node (consuming further tokens from the list - * as necessary) onto result. Upon return *node will be the last - * consumed node, such that further processing can continue with - * node->next. */ -static void -_glcpp_parser_expand_function_onto (glcpp_parser_t *parser, - token_node_t **node_ret, - token_list_t *result) +/* This is a helper function that's essentially part of the + * implementation of _glcpp_parser_expand_node. It shouldn't be called + * except for by that function. + * + * Returns NULL if node is a simple token with no expansion, (that is, + * although 'node' corresponds to an identifier defined as a + * function-like macro, it is not followed with a parenthesized + * argument list). + * + * Compute the complete expansion of node (which is a function-like + * macro) and subsequent nodes which are arguments. + * + * Returns the token list that results from the expansion and sets + * *last to the last node in the list that was consumed by the + * expansion. Specificallty, *last will be set as follows: as the + * token of the closing right parenthesis. + */ +static token_list_t * +_glcpp_parser_expand_function (glcpp_parser_t *parser, + token_node_t *node, + token_node_t **last) + { macro_t *macro; - token_node_t *node; const char *identifier; argument_list_t *arguments; function_status_t status; token_list_t *substituted; int parameter_index; - node = *node_ret; identifier = node->token->value.str; macro = hash_table_find (parser->defines, identifier); @@ -1064,23 +1092,20 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, assert (macro->is_function); arguments = _argument_list_create (parser); - status = _arguments_parse (arguments, node_ret); + status = _arguments_parse (arguments, node, last); switch (status) { case FUNCTION_STATUS_SUCCESS: break; case FUNCTION_NOT_A_FUNCTION: - _token_list_append (result, node->token); - return; + return NULL; case FUNCTION_UNBALANCED_PARENTHESES: - fprintf (stderr, "Error: Macro %s call has unbalanced parentheses\n", - identifier); - exit (1); + return NULL; } if (macro->replacements == NULL) { talloc_free (arguments); - return; + return _token_list_create (parser); } if (! ((_argument_list_length (arguments) == @@ -1094,7 +1119,7 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, identifier, _argument_list_length (arguments), _string_list_length (macro->parameters)); - return; + return NULL; } /* Perform argument substitution on the replacement list. */ @@ -1114,9 +1139,9 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, * tokens, or append a placeholder token for * an empty argument. */ if (argument->head) { - _glcpp_parser_expand_token_list_onto (parser, - argument, - substituted); + _glcpp_parser_expand_token_list (parser, + argument); + _token_list_append_list (substituted, argument); } else { token_t *new_token; @@ -1158,7 +1183,7 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, if (next_non_space == NULL) { fprintf (stderr, "Error: '##' cannot appear at either end of a macro expansion\n"); - return; + return NULL; } _token_paste (node->token, next_non_space->token); @@ -1168,22 +1193,33 @@ _glcpp_parser_expand_function_onto (glcpp_parser_t *parser, } _string_list_push (parser->active, identifier); - _glcpp_parser_expand_token_list_onto (parser, substituted, result); + _glcpp_parser_expand_token_list (parser, substituted); _string_list_pop (parser->active); - talloc_free (arguments); + return substituted; } - -/* Appends the expansion of the token in *node onto result. - * Upon return *node will be the last consumed node, such that further - * processing can continue with node->next. */ -static void -_glcpp_parser_expand_token_onto (glcpp_parser_t *parser, - token_node_t **node, - token_list_t *result) +/* Compute the complete expansion of node, (and subsequent nodes after + * 'node' in the case that 'node' is a function-like macro and + * subsequent nodes are arguments). + * + * Returns NULL if node is a simple token with no expansion. + * + * Otherwise, returns the token list that results from the expansion + * and sets *last to the last node in the list that was consumed by + * the expansion. Specificallty, *last will be set as follows: + * + * As 'node' in the case of object-like macro expansion. + * + * As the token of the closing right parenthesis in the case of + * function-like macro expansion. + */ +static token_list_t * +_glcpp_parser_expand_node (glcpp_parser_t *parser, + token_node_t *node, + token_node_t **last) { - token_t *token = (*node)->token; + token_t *token = node->token; const char *identifier; macro_t *macro; token_list_t *expansion; @@ -1194,90 +1230,134 @@ _glcpp_parser_expand_token_onto (glcpp_parser_t *parser, * it being mistaken for an argument separator * later. */ if (token->type == ',') { - token_t *new_token; - - new_token = _token_create_ival (result, COMMA_FINAL, - COMMA_FINAL); - _token_list_append (result, new_token); - } else { - _token_list_append (result, token); + token->type = COMMA_FINAL; + token->value.ival = COMMA_FINAL; } - return; + + return NULL; } /* Look up this identifier in the hash table. */ identifier = token->value.str; macro = hash_table_find (parser->defines, identifier); - /* Not a macro, so just append. */ - if (macro == NULL) { - _token_list_append (result, token); - return; - } + /* Not a macro, so no expansion needed. */ + if (macro == NULL) + return NULL; /* Finally, don't expand this macro if we're already actively * expanding it, (to avoid infinite recursion). */ - if (_string_list_contains (parser->active, identifier, NULL)) - { + if (_string_list_contains (parser->active, identifier, NULL)) { /* We change the token type here from IDENTIFIER to * OTHER to prevent any future expansion of this * unexpanded token. */ char *str; - token_t *new_token; + token_list_t *expansion; + token_t *final; - str = xtalloc_strdup (result, token->value.str); - new_token = _token_create_str (result, OTHER, str); - _token_list_append (result, new_token); - return; + str = xtalloc_strdup (parser, token->value.str); + final = _token_create_str (parser, OTHER, str); + expansion = _token_list_create (parser); + _token_list_append (expansion, final); + *last = node; + return expansion; } - if (macro->is_function) { - _glcpp_parser_expand_function_onto (parser, node, result); - } else { + if (! macro->is_function) + { + *last = node; + + if (macro->replacements == NULL) + return _token_list_create (parser); + + expansion = _token_list_copy (parser, macro->replacements); + _string_list_push (parser->active, identifier); - _glcpp_parser_expand_token_list_onto (parser, - macro->replacements, - result); + _glcpp_parser_expand_token_list (parser, expansion); _string_list_pop (parser->active); + + return expansion; } + + return _glcpp_parser_expand_function (parser, node, last); } +/* Walk over the token list replacing nodes with their expansion. + * Whenever nodes are expanded the walking will walk over the new + * nodes, continuing to expand as necessary. The results are placed in + * 'list' itself; + */ static void -_glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, - token_list_t *list, - token_list_t *result) +_glcpp_parser_expand_token_list (glcpp_parser_t *parser, + token_list_t *list) { - token_node_t *node; + token_node_t *node_prev; + token_node_t *node, *last; + token_list_t *expansion; - if (list == NULL || list->head == NULL) + if (list == NULL) return; - for (node = list->head; node; node = node->next) - { - _glcpp_parser_expand_token_onto (parser, &node, result); + _token_list_trim_trailing_space (list); + + node_prev = NULL; + node = list->head; + + while (node) { + /* Find the expansion for node, which will replace all + * nodes from node to last, inclusive. */ + expansion = _glcpp_parser_expand_node (parser, node, &last); + if (expansion) { + /* Splice expansion into list, supporting a + * simple deletion if the expansion is + * empty. */ + if (expansion->head) { + if (node_prev) + node_prev->next = expansion->head; + else + list->head = expansion->head; + expansion->tail->next = last->next; + if (last == list->tail) + list->tail = expansion->tail; + } else { + if (node_prev) + node_prev->next = last->next; + else + list->head = last->next; + if (last == list->tail) + list->tail == NULL; + } + } else { + node_prev = node; + } + node = node_prev ? node_prev->next : list->head; } + + list->non_space_tail = list->tail; +} + +static void +_glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, + token_list_t *list, + token_list_t *result) +{ + _glcpp_parser_expand_token_list (parser, list); + + _token_list_append_list (result, list); } void _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, token_list_t *list) { - token_list_t *expanded; - token_node_t *node; - function_status_t function_status; - if (list == NULL) return; - expanded = _token_list_create (parser); - - _glcpp_parser_expand_token_list_onto (parser, list, expanded); - - _token_list_trim_trailing_space (expanded); + _glcpp_parser_expand_token_list (parser, list); - _token_list_print (expanded); + _token_list_trim_trailing_space (list); - talloc_free (expanded); + _token_list_print (list); } void diff --git a/tests/060-left-paren-in-macro-right-paren-in-text.c b/tests/060-left-paren-in-macro-right-paren-in-text.c new file mode 100644 index 00000000000..ed80ea879ce --- /dev/null +++ b/tests/060-left-paren-in-macro-right-paren-in-text.c @@ -0,0 +1,3 @@ +#define double(a) a*2 +#define foo double( +foo 5) diff --git a/tests/061-define-chain-obj-to-func-multi.c b/tests/061-define-chain-obj-to-func-multi.c new file mode 100644 index 00000000000..6dbfd1f62d1 --- /dev/null +++ b/tests/061-define-chain-obj-to-func-multi.c @@ -0,0 +1,5 @@ +#define foo(x) success +#define bar foo +#define baz bar +#define joe baz +joe (failure) -- cgit v1.2.3 From c7144dc2e0175a8f4922f261d75437b984039a8c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 28 May 2010 15:12:36 -0700 Subject: Remove some blank lines from the end of some test cases. To match what we have done on the take-2 branch to these test cases. --- tests/049-if-expression-precedence.c | 1 - tests/050-if-defined.c | 2 -- tests/053-if-divide-and-shift.c | 1 - 3 files changed, 4 deletions(-) diff --git a/tests/049-if-expression-precedence.c b/tests/049-if-expression-precedence.c index cea935220fd..833ea03882a 100644 --- a/tests/049-if-expression-precedence.c +++ b/tests/049-if-expression-precedence.c @@ -3,4 +3,3 @@ failure with operator precedence #else success #endif - diff --git a/tests/050-if-defined.c b/tests/050-if-defined.c index 9838cc747d5..34f0f95140e 100644 --- a/tests/050-if-defined.c +++ b/tests/050-if-defined.c @@ -15,5 +15,3 @@ failure_3 #else success_3 #endif - - diff --git a/tests/053-if-divide-and-shift.c b/tests/053-if-divide-and-shift.c index ddc1573ab26..d24c54a88d1 100644 --- a/tests/053-if-divide-and-shift.c +++ b/tests/053-if-divide-and-shift.c @@ -13,4 +13,3 @@ failure_3 #else success_3 #endif - -- cgit v1.2.3 From 792bdcbeee770b14dc833261e7ef3c1d400e5e3f Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 28 May 2010 15:13:11 -0700 Subject: Tweak test 25 slightly, (so the non-macro doesn't end the file). This isn't a problem here, but on the take-2 branch, it was trickier at one point to make a non-macro work when the last token of the file. So we use the simpler test case here and defer the other case until later. --- tests/025-func-macro-as-non-macro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/025-func-macro-as-non-macro.c b/tests/025-func-macro-as-non-macro.c index 3dbe026d9dd..b433671d1bf 100644 --- a/tests/025-func-macro-as-non-macro.c +++ b/tests/025-func-macro-as-non-macro.c @@ -1,2 +1,2 @@ #define foo(bar) bar -foo +foo bar -- cgit v1.2.3 From b1249f69fd687441632c2d2e63618627ae9be442 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 28 May 2010 15:15:00 -0700 Subject: Add two (passing) tests from the take-2 branch. These two tests were tricky to make work on take-2, but happen to already eb working here. --- tests/000-content-with-spaces.c | 1 + tests/061-define-chain-obj-to-func-multi.c | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 tests/000-content-with-spaces.c create mode 100644 tests/061-define-chain-obj-to-func-multi.c diff --git a/tests/000-content-with-spaces.c b/tests/000-content-with-spaces.c new file mode 100644 index 00000000000..696cb3a74fc --- /dev/null +++ b/tests/000-content-with-spaces.c @@ -0,0 +1 @@ +this is four tokens diff --git a/tests/061-define-chain-obj-to-func-multi.c b/tests/061-define-chain-obj-to-func-multi.c new file mode 100644 index 00000000000..6dbfd1f62d1 --- /dev/null +++ b/tests/061-define-chain-obj-to-func-multi.c @@ -0,0 +1,5 @@ +#define foo(x) success +#define bar foo +#define baz bar +#define joe baz +joe (failure) -- cgit v1.2.3 From 614a9aece0888e7c8221ad2e8a231762442db794 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 28 May 2010 15:15:59 -0700 Subject: Add two more (failing) tests from the take-2 branch. These tests were recently fixed on the take-2 branch, but will require additional work before they will pass here. --- tests/058-token-pasting-empty-arguments.c | 5 +++++ tests/060-left-paren-in-macro-right-paren-in-text.c | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 tests/058-token-pasting-empty-arguments.c create mode 100644 tests/060-left-paren-in-macro-right-paren-in-text.c diff --git a/tests/058-token-pasting-empty-arguments.c b/tests/058-token-pasting-empty-arguments.c new file mode 100644 index 00000000000..8ac260c76b6 --- /dev/null +++ b/tests/058-token-pasting-empty-arguments.c @@ -0,0 +1,5 @@ +#define paste(x,y) x ## y +paste(a,b) +paste(a,) +paste(,b) +paste(,) diff --git a/tests/060-left-paren-in-macro-right-paren-in-text.c b/tests/060-left-paren-in-macro-right-paren-in-text.c new file mode 100644 index 00000000000..ed80ea879ce --- /dev/null +++ b/tests/060-left-paren-in-macro-right-paren-in-text.c @@ -0,0 +1,3 @@ +#define double(a) a*2 +#define foo double( +foo 5) -- cgit v1.2.3 From 631016946ca8134244c4e58bef6863d204b1119b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 29 May 2010 05:07:24 -0700 Subject: Fix pass-through of '=' and add a test for it. Previously '=' was not included in our PUNCTUATION regeular expression, but it *was* excldued from our OTHER regular expression, so we were getting the default (and hamful) lex action of just printing it. The test we add here is named "punctuator" with the idea that we can extend it as needed for other punctuator testing. --- glcpp-lex.l | 2 +- glcpp-parse.y | 1 + tests/071-punctuator.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 tests/071-punctuator.c diff --git a/glcpp-lex.l b/glcpp-lex.l index 70d47d24975..52269c6b306 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -38,7 +38,7 @@ NEWLINE [\n] HSPACE [ \t] HASH ^{HSPACE}*#{HSPACE}* IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* -PUNCTUATION [][(){}.&*~!/%<>^|;,+-] +PUNCTUATION [][(){}.&*~!/%<>^|;,=+-] OTHER [^][(){}.&*~!/%<>^|;,=#[:space:]+-]+ DECIMAL_INTEGER [1-9][0-9]*[uU]? diff --git a/glcpp-parse.y b/glcpp-parse.y index c89d7bf159c..01ca08ec740 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -426,6 +426,7 @@ operator: | OR { $$ = OR; } | ';' { $$ = ';'; } | ',' { $$ = ','; } +| '=' { $$ = '='; } | PASTE { $$ = PASTE; } | DEFINED { $$ = DEFINED; } ; diff --git a/tests/071-punctuator.c b/tests/071-punctuator.c new file mode 100644 index 00000000000..959d6825988 --- /dev/null +++ b/tests/071-punctuator.c @@ -0,0 +1 @@ +a = b -- cgit v1.2.3 From b06096e86eda1257769156523b5738044c6a2b10 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 29 May 2010 05:54:19 -0700 Subject: Add test and fix bugs with multiple token-pasting on the same line. The list replacement when token pasting was broken, (failing to properly update the list's tail pointer). Also, memory management when pasting was broken, (modifying the original token's string which would cause problems with multiple calls to a macro which pasted a literal string). We didn't catch this with previous tests because they only pasted argument values. --- glcpp-parse.y | 92 +++++++++++++++++-------------------- tests/072-token-pasting-same-line.c | 2 + 2 files changed, 43 insertions(+), 51 deletions(-) create mode 100644 tests/072-token-pasting-same-line.c diff --git a/glcpp-parse.y b/glcpp-parse.y index 01ca08ec740..f4c834e038f 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -783,73 +783,53 @@ _token_print (token_t *token) } } -/* Change 'token' into a new token formed by pasting 'other'. */ -static void +/* Return a new token (talloc()ed off of 'token') formed by pasting + * 'token' and 'other'. Note that this function may return 'token' or + * 'other' directly rather than allocating anything new. + * + * Caution: Only very cursory error-checking is performed to see if + * the final result is a valid single token. */ +static token_t * _token_paste (token_t *token, token_t *other) { /* Pasting a placeholder onto anything makes no change. */ if (other->type == PLACEHOLDER) - return; + return token; - /* When 'token' is a placeholder, just return contents of 'other'. */ - if (token->type == PLACEHOLDER) { - token->type = other->type; - token->value = other->value; - return; - } + /* When 'token' is a placeholder, just return 'other'. */ + if (token->type == PLACEHOLDER) + return other; /* A very few single-character punctuators can be combined * with another to form a multi-character punctuator. */ switch (token->type) { case '<': - if (other->type == '<') { - token->type = LEFT_SHIFT; - token->value.ival = LEFT_SHIFT; - return; - } else if (other->type == '=') { - token->type = LESS_OR_EQUAL; - token->value.ival = LESS_OR_EQUAL; - return; - } + if (other->type == '<') + return _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT); + else if (other->type == '=') + return _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL); break; case '>': - if (other->type == '>') { - token->type = RIGHT_SHIFT; - token->value.ival = RIGHT_SHIFT; - return; - } else if (other->type == '=') { - token->type = GREATER_OR_EQUAL; - token->value.ival = GREATER_OR_EQUAL; - return; - } + if (other->type == '>') + return _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT); + else if (other->type == '=') + return _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL); break; case '=': - if (other->type == '=') { - token->type = EQUAL; - token->value.ival = EQUAL; - return; - } + if (other->type == '=') + return _token_create_ival (token, EQUAL, EQUAL); break; case '!': - if (other->type == '=') { - token->type = NOT_EQUAL; - token->value.ival = NOT_EQUAL; - return; - } + if (other->type == '=') + return _token_create_ival (token, NOT_EQUAL, NOT_EQUAL); break; case '&': - if (other->type == '&') { - token->type = AND; - token->value.ival = AND; - return; - } + if (other->type == '&') + return _token_create_ival (token, AND, AND); break; case '|': - if (other->type == '|') { - token->type = OR; - token->value.ival = OR; - return; - } + if (other->type == '|') + return _token_create_ival (token, OR, OR); break; } @@ -864,9 +844,11 @@ _token_paste (token_t *token, token_t *other) if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) && (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING)) { - token->value.str = talloc_strdup_append (token->value.str, - other->value.str); - return; + char *str; + + str = xtalloc_asprintf (token, "%s%s", + token->value.str, other->value.str); + return _token_create_str (token, token->type, str); } printf ("Error: Pasting \""); @@ -874,6 +856,8 @@ _token_paste (token_t *token, token_t *other) printf ("\" and \""); _token_print (other); printf ("\" does not give a valid preprocessing token.\n"); + + return token; } static void @@ -1159,6 +1143,8 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, /* After argument substitution, and before further expansion * below, implement token pasting. */ + _token_list_trim_trailing_space (substituted); + node = substituted->head; while (node) { @@ -1187,12 +1173,16 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, return NULL; } - _token_paste (node->token, next_non_space->token); + node->token = _token_paste (node->token, next_non_space->token); node->next = next_non_space->next; + if (next_non_space == substituted->tail) + substituted->tail = node; node = node->next; } + substituted->non_space_tail = substituted->tail; + _string_list_push (parser->active, identifier); _glcpp_parser_expand_token_list (parser, substituted); _string_list_pop (parser->active); diff --git a/tests/072-token-pasting-same-line.c b/tests/072-token-pasting-same-line.c new file mode 100644 index 00000000000..e421e9d5e29 --- /dev/null +++ b/tests/072-token-pasting-same-line.c @@ -0,0 +1,2 @@ +#define paste(x) success_ ## x +paste(1) paste(2) paste(3) -- cgit v1.2.3 From 75ef1c75dd47a0b4054a767fd94f7c3cf68d2331 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 29 May 2010 05:57:22 -0700 Subject: Add killer test case from the C99 specification. Happily, this passes now, (since many of the previously added test cases were extracted from this one). --- tests/099-c99-example.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/099-c99-example.c diff --git a/tests/099-c99-example.c b/tests/099-c99-example.c new file mode 100644 index 00000000000..d1976b1f265 --- /dev/null +++ b/tests/099-c99-example.c @@ -0,0 +1,17 @@ +#define x 3 +#define f(a) f(x * (a)) +#undef x +#define x 2 +#define g f +#define z z[0] +#define h g(~ +#define m(a) a(w) +#define w 0,1 +#define t(a) a +#define p() int +#define q(x) x +#define r(x,y) x ## y +f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); +g(x +(3,4)-w) | h 5) & m + (f)^m(m); +p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,)}; -- cgit v1.2.3 From ae3fb09cd20fc189d68f0c2a63cc74dd584d7ee1 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 29 May 2010 06:01:32 -0700 Subject: Add three more tests cases recently added to the take-2 branch. The 071-punctuator test is failing only trivially (whitespace change only). And the 072-token-pasting-same-line.c test passes just fine here, (more evidence perhaps that the approach in take-2 is more trouble than it's worth?). The 099-c99-example test case is the inspiration for much of the rest of the test suite. It amazingly passes on the take-2 branch, but doesn't pass here yet. --- tests/071-punctuator.c | 1 + tests/072-token-pasting-same-line.c | 2 ++ tests/099-c99-example.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 tests/071-punctuator.c create mode 100644 tests/072-token-pasting-same-line.c create mode 100644 tests/099-c99-example.c diff --git a/tests/071-punctuator.c b/tests/071-punctuator.c new file mode 100644 index 00000000000..959d6825988 --- /dev/null +++ b/tests/071-punctuator.c @@ -0,0 +1 @@ +a = b diff --git a/tests/072-token-pasting-same-line.c b/tests/072-token-pasting-same-line.c new file mode 100644 index 00000000000..e421e9d5e29 --- /dev/null +++ b/tests/072-token-pasting-same-line.c @@ -0,0 +1,2 @@ +#define paste(x) success_ ## x +paste(1) paste(2) paste(3) diff --git a/tests/099-c99-example.c b/tests/099-c99-example.c new file mode 100644 index 00000000000..d1976b1f265 --- /dev/null +++ b/tests/099-c99-example.c @@ -0,0 +1,17 @@ +#define x 3 +#define f(a) f(x * (a)) +#undef x +#define x 2 +#define g f +#define z z[0] +#define h g(~ +#define m(a) a(w) +#define w 0,1 +#define t(a) a +#define p() int +#define q(x) x +#define r(x,y) x ## y +f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); +g(x +(3,4)-w) | h 5) & m + (f)^m(m); +p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,)}; -- cgit v1.2.3 From a771a40e2257657cbdae0eb97a7bb8733db76b91 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 1 Jun 2010 11:20:18 -0700 Subject: Fix #if-skipping to *really* skip the skipped group. Previously we were avoiding printing within a skipped group, but we were still evluating directives such as #define and #undef and still emitting diagnostics for things such as macro calls with the wrong number of arguments. Add a test for this and fix it with a high-priority rule in the lexer that consumes the skipped content. --- glcpp-lex.l | 48 ++++++++++++++++++++++++++++++------------ glcpp-parse.y | 15 ++++--------- glcpp.h | 1 + tests/062-if-0-skips-garbage.c | 5 +++++ 4 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 tests/062-if-0-skips-garbage.c diff --git a/glcpp-lex.l b/glcpp-lex.l index 52269c6b306..a51d9e185fc 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -47,39 +47,58 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? %% -{HASH}define{HSPACE}+/{IDENTIFIER}"(" { +{HASH}if/.*\n { + yyextra->lexing_if = 1; yyextra->space_tokens = 0; - return HASH_DEFINE_FUNC; + return HASH_IF; } -{HASH}define { +{HASH}elif/.*\n { + yyextra->lexing_if = 1; yyextra->space_tokens = 0; - return HASH_DEFINE_OBJ; + return HASH_ELIF; } -{HASH}undef { +{HASH}else/.*\n { yyextra->space_tokens = 0; - return HASH_UNDEF; + return HASH_ELSE; } -{HASH}if { +{HASH}endif/.*\n { yyextra->space_tokens = 0; - return HASH_IF; + return HASH_ENDIF; } -{HASH}elif { + /* When skipping (due to an #if 0 or similar) consume anything + * up to a newline. We do this less priroty than any + * #if-related directive (#if, #elif, #else, #endif), but with + * more priority than any other directive or token to avoid + * any side-effects from skipped content. + * + * We use the lexing_if flag to avoid skipping any part of an + * if conditional expression. */ +[^\n]+/\n { + if (yyextra->lexing_if || + yyextra->skip_stack == NULL || + yyextra->skip_stack->type == SKIP_NO_SKIP) + { + REJECT; + } +} + +{HASH}define{HSPACE}+/{IDENTIFIER}"(" { yyextra->space_tokens = 0; - return HASH_ELIF; + return HASH_DEFINE_FUNC; } -{HASH}else { +{HASH}define { yyextra->space_tokens = 0; - return HASH_ELSE; + return HASH_DEFINE_OBJ; } -{HASH}endif { +{HASH}undef { yyextra->space_tokens = 0; - return HASH_ENDIF; + return HASH_UNDEF; } {HASH} { @@ -163,6 +182,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } \n { + yyextra->lexing_if = 0; return NEWLINE; } diff --git a/glcpp-parse.y b/glcpp-parse.y index f4c834e038f..dd8e133f550 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -159,19 +159,11 @@ input: line: control_line { - if (parser->skip_stack == NULL || - parser->skip_stack->type == SKIP_NO_SKIP) - { - printf ("\n"); - } + printf ("\n"); } | text_line { - if (parser->skip_stack == NULL || - parser->skip_stack->type == SKIP_NO_SKIP) - { - _glcpp_parser_print_expanded_token_list (parser, $1); - printf ("\n"); - } + _glcpp_parser_print_expanded_token_list (parser, $1); + printf ("\n"); talloc_free ($1); } | expanded_line @@ -889,6 +881,7 @@ glcpp_parser_create (void) parser->defines = hash_table_ctor (32, hash_table_string_hash, hash_table_string_compare); parser->active = _string_list_create (parser); + parser->lexing_if = 0; parser->space_tokens = 1; parser->newline_as_space = 0; parser->in_control_line = 0; diff --git a/glcpp.h b/glcpp.h index 5c8c304a9ca..41fc2043d13 100644 --- a/glcpp.h +++ b/glcpp.h @@ -127,6 +127,7 @@ struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; string_list_t *active; + int lexing_if; int space_tokens; int newline_as_space; int in_control_line; diff --git a/tests/062-if-0-skips-garbage.c b/tests/062-if-0-skips-garbage.c new file mode 100644 index 00000000000..d9e439bb890 --- /dev/null +++ b/tests/062-if-0-skips-garbage.c @@ -0,0 +1,5 @@ +#define foo(a,b) +#if 0 +foo(bar) +foo( +#endif -- cgit v1.2.3 From 2571415d1a7eec72db33cd521ca48fe755c43f9c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 1 Jun 2010 12:18:43 -0700 Subject: Implement comment handling in the lexer (with test). We support both single-line (//) and multi-line (/* ... */) comments and add a test for this, (trying to stress the rules just a bit by embedding one comment delimiter into a comment delimited with the other style, etc.). To keep the test suite passing we do now discard any output lines from glcpp that consist only of spacing, (in addition to blank lines as previously). We also discard any initial whitespace from gcc output. In neither case should the absence or presence of this whitespace affect correctness. --- glcpp-lex.l | 11 +++++++++++ tests/063-comments.c | 15 +++++++++++++++ tests/glcpp-test | 4 ++-- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/063-comments.c diff --git a/glcpp-lex.l b/glcpp-lex.l index a51d9e185fc..0954ab7e83d 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -47,6 +47,17 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? %% + /* Single-line comments */ +"//"[^\n]+\n { + return NEWLINE; +} + + /* Multi-line comments */ +[/][*]([^*]*[*]+[^/])*[^*]*[*]*[/] { + if (yyextra->space_tokens) + return SPACE; +} + {HASH}if/.*\n { yyextra->lexing_if = 1; yyextra->space_tokens = 0; diff --git a/tests/063-comments.c b/tests/063-comments.c new file mode 100644 index 00000000000..4cda52236e0 --- /dev/null +++ b/tests/063-comments.c @@ -0,0 +1,15 @@ +/* this is a comment */ +// so is this +// */ +f = g/**//h; +/*//*/l(); +m = n//**/o ++ p; +/* this +comment spans +multiple lines and +contains *** stars +and slashes / *** / +and other stuff. +****/ +more code here diff --git a/tests/glcpp-test b/tests/glcpp-test index ba398af0d54..24110333a5e 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -3,8 +3,8 @@ for test in *.c; do echo "Testing $test" ../glcpp < $test > $test.glcpp - grep -v '^$' < $test.glcpp > $test.out || true + grep -v '^ *$' < $test.glcpp > $test.out || true gcc -E $test -o $test.gcc - grep -v '^#' < $test.gcc | grep -v '^$' > $test.expected || true + grep -v '^#' < $test.gcc | grep -v '^$' | sed -r -e 's/^ +/ /' > $test.expected || true diff -u $test.expected $test.out done -- cgit v1.2.3 From 459e4a286cce4fa8d52e4f6e157f4c6df46de695 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 1 Jun 2010 15:06:11 -0700 Subject: ir_expression_flattening: Fix breakage from hierarchichal visitor. Similar to other situations where the visitor pattern doesn't fit, in this case we need the pointer to the base instruction in the instruction stream for where to insert any new instructions we generate (not the instruction in the tree we're looking at). By removing the code for setting the base_ir, flattened expressions would end up, for example, before the function definition where they had appeared. --- ir_expression_flattening.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp index b0b1e203567..9c410b162fc 100644 --- a/ir_expression_flattening.cpp +++ b/ir_expression_flattening.cpp @@ -55,6 +55,9 @@ public: virtual ir_visitor_status visit_enter(ir_call *); virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_function_signature *); + virtual ir_visitor_status visit_enter(ir_if *); + virtual ir_visitor_status visit_enter(ir_loop *); virtual ir_visitor_status visit_leave(ir_expression *); bool (*predicate)(ir_instruction *ir); @@ -73,6 +76,33 @@ do_expression_flattening(exec_list *instructions, } } +ir_visitor_status +ir_expression_flattening_visitor::visit_enter(ir_function_signature *ir) +{ + do_expression_flattening(&ir->body, this->predicate); + + return visit_continue_with_parent; +} + +ir_visitor_status +ir_expression_flattening_visitor::visit_enter(ir_loop *ir) +{ + do_expression_flattening(&ir->body_instructions, this->predicate); + + return visit_continue_with_parent; +} + +ir_visitor_status +ir_expression_flattening_visitor::visit_enter(ir_if *ir) +{ + ir->condition->accept(this); + + do_expression_flattening(&ir->then_instructions, this->predicate); + do_expression_flattening(&ir->else_instructions, this->predicate); + + return visit_continue_with_parent; +} + ir_visitor_status ir_expression_flattening_visitor::visit_leave(ir_expression *ir) { -- cgit v1.2.3 From f8bb17260a6afb48534ec70dc9d5584851d7e3c2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 14:48:20 -0700 Subject: ir_expression_flattening: Handle flattening values out of swizzles, too. Fixes an uninlined normalize() in CorrectSwizzle2.vert. --- ir_expression_flattening.cpp | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp index 9c410b162fc..394a0d0432b 100644 --- a/ir_expression_flattening.cpp +++ b/ir_expression_flattening.cpp @@ -59,6 +59,7 @@ public: virtual ir_visitor_status visit_enter(ir_if *); virtual ir_visitor_status visit_enter(ir_loop *); virtual ir_visitor_status visit_leave(ir_expression *); + virtual ir_visitor_status visit_leave(ir_swizzle *); bool (*predicate)(ir_instruction *ir); ir_instruction *base_ir; @@ -76,6 +77,24 @@ do_expression_flattening(exec_list *instructions, } } + +static ir_rvalue * +operand_to_temp(ir_instruction *base_ir, ir_rvalue *ir) +{ + ir_variable *var; + ir_assignment *assign; + + var = new ir_variable(ir->type, "flattening_tmp"); + base_ir->insert_before(var); + + assign = new ir_assignment(new ir_dereference_variable(var), + ir, + NULL); + base_ir->insert_before(assign); + + return new ir_dereference_variable(var); +} + ir_visitor_status ir_expression_flattening_visitor::visit_enter(ir_function_signature *ir) { @@ -113,24 +132,23 @@ ir_expression_flattening_visitor::visit_leave(ir_expression *ir) * value to a temporary and deref the temporary as the operand. */ if (this->predicate(ir->operands[operand])) { - ir_variable *var; - ir_assignment *assign; - - var = new ir_variable(ir->operands[operand]->type, "flattening_tmp"); - this->base_ir->insert_before(var); - - assign = new ir_assignment(new ir_dereference_variable(var), - ir->operands[operand], - NULL); - this->base_ir->insert_before(assign); - - ir->operands[operand] = new ir_dereference_variable(var); + ir->operands[operand] = operand_to_temp(base_ir, + ir->operands[operand]); } } return visit_continue; } +ir_visitor_status +ir_expression_flattening_visitor::visit_leave(ir_swizzle *ir) +{ + if (this->predicate(ir->val)) { + ir->val = operand_to_temp(this->base_ir, ir->val); + } + + return visit_continue; +} ir_visitor_status ir_expression_flattening_visitor::visit_enter(ir_call *ir) -- cgit v1.2.3 From b145e903694fa932ab1e0d955e889555193ab604 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 11 May 2010 11:31:09 -0700 Subject: ir_vec_index_to_swizzle: Pass to convert indexing of vectors to swizzles. This should remove the burden of handling constant vector indexing well from backend codegen, and could help with swizzle optimizations. --- Makefile.am | 3 +- glsl_parser_extras.cpp | 1 + ir.h | 7 +- ir_optimization.h | 1 + ir_vec_index_to_swizzle.cpp | 166 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 ir_vec_index_to_swizzle.cpp diff --git a/Makefile.am b/Makefile.am index 42f0ae557ef..c31f3969a87 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,7 +47,8 @@ glsl_SOURCES = \ ir_reader.cpp s_expression.cpp \ ir_hv_accept.cpp \ ir_hierarchical_visitor.h \ - ir_hierarchical_visitor.cpp + ir_hierarchical_visitor.cpp \ + ir_vec_index_to_swizzle.cpp BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 62eeb9c8600..e778e0f8f8c 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -759,6 +759,7 @@ main(int argc, char **argv) progress = do_dead_code_local(&instructions) || progress; progress = do_dead_code_unlinked(&instructions) || progress; progress = do_constant_folding(&instructions) || progress; + progress = do_vec_index_to_swizzle(&instructions) || progress; } while (progress); } diff --git a/ir.h b/ir.h index bbec6ce5bed..784e41fcb67 100644 --- a/ir.h +++ b/ir.h @@ -56,6 +56,7 @@ public: virtual class ir_variable * as_variable() { return NULL; } virtual class ir_function * as_function() { return NULL; } virtual class ir_dereference * as_dereference() { return NULL; } + virtual class ir_dereference_array * as_dereference_array() { return NULL; } virtual class ir_rvalue * as_rvalue() { return NULL; } virtual class ir_label * as_label() { return NULL; } virtual class ir_loop * as_loop() { return NULL; } @@ -685,7 +686,6 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); -private: ir_rvalue *value; }; @@ -860,6 +860,11 @@ public: ir_dereference_array(ir_variable *var, ir_rvalue *array_index); + virtual ir_dereference_array *as_dereference_array() + { + return this; + } + /** * Get the variable that is ultimately referenced by an r-value */ diff --git a/ir_optimization.h b/ir_optimization.h index d9e30ce08ce..2916784723d 100644 --- a/ir_optimization.h +++ b/ir_optimization.h @@ -35,3 +35,4 @@ bool do_dead_code_local(exec_list *instructions); bool do_dead_code_unlinked(exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_if_simplification(exec_list *instructions); +bool do_vec_index_to_swizzle(exec_list *instructions); diff --git a/ir_vec_index_to_swizzle.cpp b/ir_vec_index_to_swizzle.cpp new file mode 100644 index 00000000000..1deb0d381ec --- /dev/null +++ b/ir_vec_index_to_swizzle.cpp @@ -0,0 +1,166 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_vec_index_to_swizzle.cpp + * + * Turns constant indexing into vector types to swizzles. This will + * let other swizzle-aware optimization passes catch these constructs, + * and codegen backends not have to worry about this case. + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "ir_print_visitor.h" +#include "glsl_types.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +class ir_vec_index_to_swizzle_visitor : public ir_hierarchical_visitor { +public: + ir_vec_index_to_swizzle_visitor() + { + progress = false; + } + + ir_rvalue *convert_vec_index_to_swizzle(ir_rvalue *val); + + virtual ir_visitor_status visit_enter(ir_expression *); + virtual ir_visitor_status visit_enter(ir_swizzle *); + virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_call *); + virtual ir_visitor_status visit_enter(ir_if *); + + bool progress; +}; + +ir_rvalue * +ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) +{ + ir_dereference_array *deref = ir->as_dereference_array(); + ir_constant *ir_constant; + ir_rvalue *deref_var; + + if (!deref) + return ir; + + if (deref->array->type->is_matrix() || deref->array->type->is_array()) + return ir; + + deref_var = deref->array->as_rvalue(); + if (!deref_var) { + ir_variable *var = deref->array->as_variable(); + assert(var); + deref_var = new ir_dereference_variable(var); + } + + assert(deref->array_index->type->base_type == GLSL_TYPE_INT); + ir_constant = deref->array_index->constant_expression_value(); + if (!ir_constant) + return ir; + + this->progress = true; + return new ir_swizzle(deref_var, ir_constant->value.i[0], 0, 0, 0, 1); +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_expression *ir) +{ + unsigned int i; + + for (i = 0; i < ir->get_num_operands(); i++) { + ir->operands[i] = convert_vec_index_to_swizzle(ir->operands[i]); + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_swizzle *ir) +{ + /* Can't be hit from normal GLSL, since you can't swizzle a scalar (which + * the result of indexing a vector is. But maybe at some point we'll end up + * using swizzling of scalars for vector construction. + */ + ir->val = convert_vec_index_to_swizzle(ir->val); + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_assignment *ir) +{ + ir->lhs = convert_vec_index_to_swizzle(ir->lhs); + ir->rhs = convert_vec_index_to_swizzle(ir->rhs); + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = convert_vec_index_to_swizzle(param); + + if (new_param != param) { + param->insert_before(new_param); + param->remove(); + } + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_return *ir) +{ + if (ir->value) { + ir->value = convert_vec_index_to_swizzle(ir->value); + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_if *ir) +{ + ir->condition = convert_vec_index_to_swizzle(ir->condition); + + return visit_continue; +} + +bool +do_vec_index_to_swizzle(exec_list *instructions) +{ + ir_vec_index_to_swizzle_visitor v; + + v.run(instructions); + + return false; +} -- cgit v1.2.3 From 49a5d5c4f5bf6e8d6ba344e8496d1d1fa0b4586d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 11 May 2010 12:34:21 -0700 Subject: ir_swizzle_swizzle: Reduce swizzle chains to a single swizzle. --- Makefile.am | 4 +++ glsl_parser_extras.cpp | 1 + ir_optimization.h | 1 + ir_swizzle_swizzle.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 ir_swizzle_swizzle.cpp diff --git a/Makefile.am b/Makefile.am index c31f3969a87..986b6fecd44 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,7 +48,11 @@ glsl_SOURCES = \ ir_hv_accept.cpp \ ir_hierarchical_visitor.h \ ir_hierarchical_visitor.cpp \ + ir_swizzle_swizzle.cpp \ ir_vec_index_to_swizzle.cpp + ir_vec_index_to_swizzle.cpp \ + ir_visit_tree.cpp \ + ir_visit_tree.h BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index e778e0f8f8c..316ac236cea 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -760,6 +760,7 @@ main(int argc, char **argv) progress = do_dead_code_unlinked(&instructions) || progress; progress = do_constant_folding(&instructions) || progress; progress = do_vec_index_to_swizzle(&instructions) || progress; + progress = do_swizzle_swizzle(&instructions) || progress; } while (progress); } diff --git a/ir_optimization.h b/ir_optimization.h index 2916784723d..0660e7297ca 100644 --- a/ir_optimization.h +++ b/ir_optimization.h @@ -35,4 +35,5 @@ bool do_dead_code_local(exec_list *instructions); bool do_dead_code_unlinked(exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_if_simplification(exec_list *instructions); +bool do_swizzle_swizzle(exec_list *instructions); bool do_vec_index_to_swizzle(exec_list *instructions); diff --git a/ir_swizzle_swizzle.cpp b/ir_swizzle_swizzle.cpp new file mode 100644 index 00000000000..8873bef8d61 --- /dev/null +++ b/ir_swizzle_swizzle.cpp @@ -0,0 +1,94 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_swizzle_swizzle.cpp + * + * Eliminates the second swizzle in a swizzle chain. + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +class ir_swizzle_swizzle_visitor : public ir_hierarchical_visitor { +public: + ir_swizzle_swizzle_visitor() + { + progress = false; + } + + virtual ir_visitor_status visit_enter(ir_swizzle *); + + bool progress; +}; + +ir_visitor_status +ir_swizzle_swizzle_visitor::visit_enter(ir_swizzle *ir) +{ + int mask2[4]; + + ir_swizzle *swiz2 = ir->val->as_swizzle(); + if (!swiz2) + return visit_continue; + + memset(&mask2, 0, sizeof(mask2)); + if (swiz2->mask.num_components >= 1) + mask2[0] = swiz2->mask.x; + if (swiz2->mask.num_components >= 2) + mask2[1] = swiz2->mask.y; + if (swiz2->mask.num_components >= 3) + mask2[2] = swiz2->mask.z; + if (swiz2->mask.num_components >= 4) + mask2[3] = swiz2->mask.w; + + if (ir->mask.num_components >= 1) + ir->mask.x = mask2[ir->mask.x]; + if (ir->mask.num_components >= 2) + ir->mask.y = mask2[ir->mask.y]; + if (ir->mask.num_components >= 3) + ir->mask.z = mask2[ir->mask.z]; + if (ir->mask.num_components >= 4) + ir->mask.w = mask2[ir->mask.w]; + + ir->val = swiz2->val; + + this->progress = true; + + return visit_continue; +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_swizzle_swizzle(exec_list *instructions) +{ + ir_swizzle_swizzle_visitor v; + + v.run(instructions); + + return v.progress; +} -- cgit v1.2.3 From f389862006dde5b0d4bcf36ba85364a1ef6d4a5d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 12 May 2010 12:15:40 -0700 Subject: ir_constant_folding: Look at instructions in functions. This was broken in the ir_label -> ir_function rework. --- ir_constant_folding.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index c7019ffc626..b3f27c80c85 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -91,7 +91,10 @@ ir_constant_folding_visitor::visit(ir_function_signature *ir) void ir_constant_folding_visitor::visit(ir_function *ir) { - (void) ir; + foreach_iter(exec_list_iterator, iter, *ir) { + ir_function_signature *const sig = (ir_function_signature *) iter.get(); + sig->accept(this); + } } void -- cgit v1.2.3 From 65122e9e8038488e8c586eb609e434a90188de27 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 12 May 2010 12:10:41 -0700 Subject: ir_constant_variable: New pass to mark constant-assigned variables constant. This removes a bunch of gratuitous moving around of constant values from constructors. Makes a shader ir I was looking at for structure handling almost readable. --- Makefile.am | 1 + glsl_parser_extras.cpp | 1 + ir_constant_variable.cpp | 165 +++++++++++++++++++++++++++++++++++++++++++++++ ir_optimization.h | 2 + linux_list.h | 93 ++++++++++++++++++++++++++ 5 files changed, 262 insertions(+) create mode 100644 ir_constant_variable.cpp create mode 100644 linux_list.h diff --git a/Makefile.am b/Makefile.am index 986b6fecd44..a62591d9ac2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,6 +34,7 @@ glsl_SOURCES = \ ir_basic_block.h \ ir_constant_expression.cpp \ ir_constant_folding.cpp \ + ir_constant_variable.cpp \ ir_copy_propagation.cpp \ ir_copy_propagation.h \ ir_dead_code.cpp \ diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 316ac236cea..afce9d9c348 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -758,6 +758,7 @@ main(int argc, char **argv) progress = do_copy_propagation(&instructions) || progress; progress = do_dead_code_local(&instructions) || progress; progress = do_dead_code_unlinked(&instructions) || progress; + progress = do_constant_variable_unlinked(&instructions) || progress; progress = do_constant_folding(&instructions) || progress; progress = do_vec_index_to_swizzle(&instructions) || progress; progress = do_swizzle_swizzle(&instructions) || progress; diff --git a/ir_constant_variable.cpp b/ir_constant_variable.cpp new file mode 100644 index 00000000000..75590dfdbfa --- /dev/null +++ b/ir_constant_variable.cpp @@ -0,0 +1,165 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_constant_variable.cpp + * + * Marks variables assigned a single constant value over the course + * of the program as constant. + * + * The goal here is to trigger further constant folding and then dead + * code elimination. This is common with vector/matrix constructors + * and calls to builtin functions. + */ + +#include +#include +#include "ir.h" +#include "ir_print_visitor.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" +#include "linux_list.h" + +struct assignment_entry { + struct list link; + int assignment_count; + ir_variable *var; + ir_constant *constval; +}; + +class ir_constant_variable_visitor : public ir_hierarchical_visitor { +public: + ir_constant_variable_visitor() + { + list_init(&list); + } + + virtual ir_visitor_status visit_enter(ir_assignment *); + + struct list list; +}; + +static struct assignment_entry * +get_assignment_entry(ir_variable *var, struct list *list) +{ + struct assignment_entry *entry; + + list_foreach_entry(entry, struct assignment_entry, list, link) { + if (entry->var == var) + return entry; + } + + entry = (struct assignment_entry *)calloc(1, sizeof(*entry)); + entry->var = var; + list_add(&entry->link, list); + return entry; +} + +ir_visitor_status +ir_constant_variable_visitor::visit_enter(ir_assignment *ir) +{ + ir_constant *constval; + struct assignment_entry *entry; + + entry = get_assignment_entry(ir->lhs->variable_referenced(), &this->list); + assert(entry); + entry->assignment_count++; + + /* If it's already constant, don't do the work. */ + if (entry->var->constant_value) + return visit_continue; + + /* OK, now find if we actually have all the right conditions for + * this to be a constant value assigned to the var. + */ + if (ir->condition) { + constval = ir->condition->constant_expression_value(); + if (!constval || !constval->value.b[0]) + return visit_continue; + } + + ir_variable *var = ir->lhs->whole_variable_referenced(); + if (!var) + return visit_continue; + + constval = ir->rhs->constant_expression_value(); + if (!constval) + return visit_continue; + + /* Mark this entry as having a constant assignment (if the + * assignment count doesn't go >1). do_constant_variable will fix + * up the variable with the constant value later. + */ + entry->constval = constval; + + return visit_continue; +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_constant_variable(exec_list *instructions) +{ + bool progress = false; + ir_constant_variable_visitor v; + + v.run(instructions); + + while (!list_is_empty(&v.list)) { + + struct assignment_entry *entry; + entry = list_entry(v.list.next, struct assignment_entry, link); + + if (entry->assignment_count == 1 && entry->constval) { + entry->var->constant_value = entry->constval; + progress = true; + } + list_del(&entry->link); + free(entry); + } + + return progress; +} + +bool +do_constant_variable_unlinked(exec_list *instructions) +{ + bool progress = false; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_function *f = ir->as_function(); + if (f) { + foreach_iter(exec_list_iterator, sigiter, *f) { + ir_function_signature *sig = + (ir_function_signature *) sigiter.get(); + if (do_constant_variable(&sig->body)) + progress = true; + } + } + } + + return progress; +} diff --git a/ir_optimization.h b/ir_optimization.h index 0660e7297ca..432a33458c2 100644 --- a/ir_optimization.h +++ b/ir_optimization.h @@ -29,6 +29,8 @@ */ bool do_constant_folding(exec_list *instructions); +bool do_constant_variable(exec_list *instructions); +bool do_constant_variable_unlinked(exec_list *instructions); bool do_copy_propagation(exec_list *instructions); bool do_dead_code(exec_list *instructions); bool do_dead_code_local(exec_list *instructions); diff --git a/linux_list.h b/linux_list.h new file mode 100644 index 00000000000..88ec6fb62af --- /dev/null +++ b/linux_list.h @@ -0,0 +1,93 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Chris Wilson + * + */ + +/* classic doubly-link circular list */ +struct list { + struct list *next, *prev; +}; + +static void +list_init(struct list *list) +{ + list->next = list->prev = list; +} + +static inline void +__list_add(struct list *entry, + struct list *prev, + struct list *next) +{ + next->prev = entry; + entry->next = next; + entry->prev = prev; + prev->next = entry; +} + +static inline void +list_add(struct list *entry, struct list *head) +{ + __list_add(entry, head, head->next); +} + +static inline void +__list_del(struct list *prev, struct list *next) +{ + next->prev = prev; + prev->next = next; +} + +static inline void +list_del(struct list *entry) +{ + __list_del(entry->prev, entry->next); + list_init(entry); +} + +static inline bool +list_is_empty(struct list *head) +{ + return head->next == head; +} + +#ifndef container_of +#define container_of(ptr, type, member) \ + (type *)((char *)(ptr) - (char *) &((type *)0)->member) +#endif + +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) + +#define list_first_entry(ptr, type, member) \ + list_entry((ptr)->next, type, member) + +#define list_foreach(pos, head) \ + for (pos = (head)->next; pos != (head); pos = pos->next) + +#define list_foreach_entry(pos, type, head, member) \ + for (pos = list_entry((head)->next, type, member);\ + &pos->member != (head); \ + pos = list_entry(pos->member.next, type, member)) -- cgit v1.2.3 From 43ad37aa885dc185679dabd605752fe2d782d542 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 12 May 2010 14:42:21 -0700 Subject: ir_constant_expression: Handle several floating point unops. Cleans up a bunch of pointless operations in a GStreamer fragment shader. --- ir_constant_expression.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index b1092de1393..361a7a1630a 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -34,6 +34,7 @@ */ #define NULL 0 +#include #include "ir.h" #include "ir_visitor.h" #include "glsl_types.h" @@ -168,6 +169,102 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_neg: + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (type->base_type) { + case GLSL_TYPE_UINT: + u[c] = -op[0]->value.u[c]; + break; + case GLSL_TYPE_INT: + i[c] = -op[0]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + f[c] = -op[0]->value.f[c]; + break; + default: + assert(0); + } + } + break; + + case ir_unop_abs: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (type->base_type) { + case GLSL_TYPE_UINT: + u[c] = op[0]->value.u[c]; + break; + case GLSL_TYPE_INT: + i[c] = op[0]->value.i[c]; + if (i[c] < 0) + i[c] = -i[c]; + break; + case GLSL_TYPE_FLOAT: + f[c] = fabs(op[0]->value.f[c]); + break; + default: + assert(0); + } + } + break; + + case ir_unop_rcp: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (type->base_type) { + case GLSL_TYPE_UINT: + if (op[0]->value.u[c] != 0.0) + u[c] = 1 / op[0]->value.u[c]; + break; + case GLSL_TYPE_INT: + if (op[0]->value.i[c] != 0.0) + i[c] = 1 / op[0]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + if (op[0]->value.f[c] != 0.0) + f[c] = 1.0 / op[0]->value.f[c]; + break; + default: + assert(0); + } + } + break; + + case ir_unop_rsq: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + f[c] = 1.0 / sqrtf(op[0]->value.f[c]); + } + break; + + case ir_unop_sqrt: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + f[c] = sqrtf(op[0]->value.f[c]); + } + break; + + case ir_unop_exp: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + f[c] = expf(op[0]->value.f[c]); + } + break; + + case ir_unop_log: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + f[c] = logf(op[0]->value.f[c]); + } + break; + case ir_binop_add: if (ir->operands[0]->type == ir->operands[1]->type) { type = ir->operands[0]->type; -- cgit v1.2.3 From 5e58e541e0419b23b958e32a22c4c7b398e414a3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 12:19:54 -0700 Subject: builtins: Add asin(). --- builtin_function.cpp | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++ builtins/110/asin | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 builtins/110/asin diff --git a/builtin_function.cpp b/builtin_function.cpp index 909329c563a..f9fdd485e4b 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -107,6 +107,98 @@ static const char *builtins_110_any = { "))\n" }; +static const char *builtins_110_asin = { + "((function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float *\n" + " (expression float -\n" + " (expression float *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression float sqrt\n" + " (expression float -\n" + " (constant float (1.0))\n" + " (expression float abs (var_ref x)))))\n" + " (expression float +\n" + " (constant float (1.5707288))\n" + " (expression float *\n" + " (expression float abs (var_ref x))\n" + " (expression float +\n" + " (constant float (-0.2121144))\n" + " (expression float *\n" + " (constant float (0.0742610))\n" + " (expression float abs (var_ref x))))))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 *\n" + " (expression vec2 -\n" + " (expression vec2 *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression vec2 sqrt\n" + " (expression vec2 -\n" + " (constant float (1.0))\n" + " (expression vec2 abs (var_ref x)))))\n" + " (expression vec2 +\n" + " (constant float (1.5707288))\n" + " (expression vec2 *\n" + " (expression vec2 abs (var_ref x))\n" + " (expression vec2 +\n" + " (constant float (-0.2121144))\n" + " (expression vec2 *\n" + " (constant float (0.0742610))\n" + " (expression vec2 abs (var_ref x))))))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 *\n" + " (expression vec3 -\n" + " (expression vec3 *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression vec3 sqrt\n" + " (expression vec3 -\n" + " (constant float (1.0))\n" + " (expression vec3 abs (var_ref x)))))\n" + " (expression vec3 +\n" + " (constant float (1.5707288))\n" + " (expression vec3 *\n" + " (expression vec3 abs (var_ref x))\n" + " (expression vec3 +\n" + " (constant float (-0.2121144))\n" + " (expression vec3 *\n" + " (constant float (0.0742610))\n" + " (expression vec3 abs (var_ref x))))))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 *\n" + " (expression vec4 -\n" + " (expression vec4 *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression vec4 sqrt\n" + " (expression vec4 -\n" + " (constant float (1.0))\n" + " (expression vec4 abs (var_ref x)))))\n" + " (expression vec4 +\n" + " (constant float (1.5707288))\n" + " (expression vec4 *\n" + " (expression vec4 abs (var_ref x))\n" + " (expression vec4 +\n" + " (constant float (-0.2121144))\n" + " (expression vec4 *\n" + " (constant float (0.0742610))\n" + " (expression vec4 abs (var_ref x))))))))))\n" + "))\n" +}; + static const char *builtins_110_ceil = { "((function ceil\n" " (signature float\n" @@ -1470,6 +1562,7 @@ static const char *functions_for_110 [] = { builtins_110_abs, builtins_110_all, builtins_110_any, + builtins_110_asin, builtins_110_ceil, builtins_110_clamp, builtins_110_cos, diff --git a/builtins/110/asin b/builtins/110/asin new file mode 100644 index 00000000000..0c913b6ae7c --- /dev/null +++ b/builtins/110/asin @@ -0,0 +1,89 @@ +((function asin + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * + (expression float - + (expression float * + (constant float (3.1415926)) + (constant float (0.5))) + (expression float sqrt + (expression float - + (constant float (1.0)) + (expression float abs (var_ref x))))) + (expression float + + (constant float (1.5707288)) + (expression float * + (expression float abs (var_ref x)) + (expression float + + (constant float (-0.2121144)) + (expression float * + (constant float (0.0742610)) + (expression float abs (var_ref x)))))))))) + + (signature float + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * + (expression vec2 - + (expression vec2 * + (constant float (3.1415926)) + (constant float (0.5))) + (expression vec2 sqrt + (expression vec2 - + (constant float (1.0)) + (expression vec2 abs (var_ref x))))) + (expression vec2 + + (constant float (1.5707288)) + (expression vec2 * + (expression vec2 abs (var_ref x)) + (expression vec2 + + (constant float (-0.2121144)) + (expression vec2 * + (constant float (0.0742610)) + (expression vec2 abs (var_ref x)))))))))) + + (signature float + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * + (expression vec3 - + (expression vec3 * + (constant float (3.1415926)) + (constant float (0.5))) + (expression vec3 sqrt + (expression vec3 - + (constant float (1.0)) + (expression vec3 abs (var_ref x))))) + (expression vec3 + + (constant float (1.5707288)) + (expression vec3 * + (expression vec3 abs (var_ref x)) + (expression vec3 + + (constant float (-0.2121144)) + (expression vec3 * + (constant float (0.0742610)) + (expression vec3 abs (var_ref x)))))))))) + + (signature float + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * + (expression vec4 - + (expression vec4 * + (constant float (3.1415926)) + (constant float (0.5))) + (expression vec4 sqrt + (expression vec4 - + (constant float (1.0)) + (expression vec4 abs (var_ref x))))) + (expression vec4 + + (constant float (1.5707288)) + (expression vec4 * + (expression vec4 abs (var_ref x)) + (expression vec4 + + (constant float (-0.2121144)) + (expression vec4 * + (constant float (0.0742610)) + (expression vec4 abs (var_ref x)))))))))) +)) -- cgit v1.2.3 From 60fa1a9458b012f39919a9c4070bfc4a0654d317 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 12:44:23 -0700 Subject: builtins: Add atan(). --- builtin_function.cpp | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++ builtins/110/atan | 154 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 312 insertions(+) create mode 100644 builtins/110/atan diff --git a/builtin_function.cpp b/builtin_function.cpp index f9fdd485e4b..1d847a65fb8 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -199,6 +199,163 @@ static const char *builtins_110_asin = { "))\n" }; +static const char *builtins_110_atan = { + "((function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (call asin ((expression float *\n" + " (var_ref x)\n" + " (expression float rsq\n" + " (expression float +\n" + " (expression float *\n" + " (var_ref x)\n" + " (var_ref x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y_over_x))\n" + " ((return (call asin ((expression vec2 *\n" + " (var_ref y_over_x)\n" + " (expression vec2 rsq\n" + " (expression vec2 +\n" + " (expression vec2 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y_over_x))\n" + " ((return (call asin ((expression vec3 *\n" + " (var_ref y_over_x)\n" + " (expression vec3 rsq\n" + " (expression vec3 +\n" + " (expression vec3 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y_over_x))\n" + " ((return (call asin ((expression vec4 *\n" + " (var_ref y_over_x)\n" + " (expression vec4 rsq\n" + " (expression vec4 +\n" + " (expression vec4 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y)\n" + " (declare (in) float x))\n" + " ((declare () float r)\n" + " (if (expression bool >\n" + " (expression float abs (var_ref x))\n" + " (constant float (.0001)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r) (call atan ((expression float /\n" + " (var_ref y)\n" + " (var_ref x)))))\n" + " (if (expression bool <\n" + " (var_ref x)\n" + " (constant float (0.0)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r)\n" + " (expression float +\n" + " (var_ref r)\n" + " (expression float *\n" + " (expression int sign (var_ref y))\n" + " (constant float (3.1415926))))))\n" + " ()))\n" + " ())\n" + " (return (var_ref r))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 r)\n" + " (if (expression bool >\n" + " (expression vec2 abs (var_ref x))\n" + " (constant float (.0001)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r) (call atan ((expression vec2 /\n" + " (var_ref y)\n" + " (var_ref x)))))\n" + " (if (expression bool <\n" + " (var_ref x)\n" + " (constant float (0.0)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r)\n" + " (expression vec2 +\n" + " (var_ref r)\n" + " (expression vec2 *\n" + " (expression int sign (var_ref y))\n" + " (constant float (3.1415926))))))\n" + " ()))\n" + " ())\n" + " (return (var_ref r))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 r)\n" + " (if (expression bool >\n" + " (expression vec3 abs (var_ref x))\n" + " (constant float (.0001)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r) (call atan ((expression vec3 /\n" + " (var_ref y)\n" + " (var_ref x)))))\n" + " (if (expression bool <\n" + " (var_ref x)\n" + " (constant float (0.0)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r)\n" + " (expression vec3 +\n" + " (var_ref r)\n" + " (expression vec3 *\n" + " (expression int sign (var_ref y))\n" + " (constant float (3.1415926))))))\n" + " ()))\n" + " ())\n" + " (return (var_ref r))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 r)\n" + " (if (expression bool >\n" + " (expression vec4 abs (var_ref x))\n" + " (constant float (.0001)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r) (call atan ((expression vec4 /\n" + " (var_ref y)\n" + " (var_ref x)))))\n" + " (if (expression bool <\n" + " (var_ref x)\n" + " (constant float (0.0)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r)\n" + " (expression vec4 +\n" + " (var_ref r)\n" + " (expression vec4 *\n" + " (expression int sign (var_ref y))\n" + " (constant float (3.1415926))))))\n" + " ()))\n" + " ())\n" + " (return (var_ref r))))\n" + "\n" + "))\n" +}; + static const char *builtins_110_ceil = { "((function ceil\n" " (signature float\n" @@ -1563,6 +1720,7 @@ static const char *functions_for_110 [] = { builtins_110_all, builtins_110_any, builtins_110_asin, + builtins_110_atan, builtins_110_ceil, builtins_110_clamp, builtins_110_cos, diff --git a/builtins/110/atan b/builtins/110/atan new file mode 100644 index 00000000000..e5542350b51 --- /dev/null +++ b/builtins/110/atan @@ -0,0 +1,154 @@ +((function atan + (signature float + (parameters + (declare (in) float x)) + ((return (call asin ((expression float * + (var_ref x) + (expression float rsq + (expression float + + (expression float * + (var_ref x) + (var_ref x)) + (constant float (1.0)))))))))) + + (signature vec2 + (parameters + (declare (in) vec2 y_over_x)) + ((return (call asin ((expression vec2 * + (var_ref y_over_x) + (expression vec2 rsq + (expression vec2 + + (expression vec2 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature vec3 + (parameters + (declare (in) vec3 y_over_x)) + ((return (call asin ((expression vec3 * + (var_ref y_over_x) + (expression vec3 rsq + (expression vec3 + + (expression vec3 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature vec4 + (parameters + (declare (in) vec4 y_over_x)) + ((return (call asin ((expression vec4 * + (var_ref y_over_x) + (expression vec4 rsq + (expression vec4 + + (expression vec4 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature float + (parameters + (declare (in) float y) + (declare (in) float x)) + ((declare () float r) + (if (expression bool > + (expression float abs (var_ref x)) + (constant float (.0001))) + ((assign (constant bool (1)) + (var_ref r) (call atan ((expression float / + (var_ref y) + (var_ref x))))) + (if (expression bool < + (var_ref x) + (constant float (0.0))) + ((assign (constant bool (1)) + (var_ref r) + (expression float + + (var_ref r) + (expression float * + (expression int sign (var_ref y)) + (constant float (3.1415926)))))) + ())) + ()) + (return (var_ref r)))) + + (signature vec2 + (parameters + (declare (in) vec2 y) + (declare (in) vec2 x)) + ((declare () vec2 r) + (if (expression bool > + (expression vec2 abs (var_ref x)) + (constant float (.0001))) + ((assign (constant bool (1)) + (var_ref r) (call atan ((expression vec2 / + (var_ref y) + (var_ref x))))) + (if (expression bool < + (var_ref x) + (constant float (0.0))) + ((assign (constant bool (1)) + (var_ref r) + (expression vec2 + + (var_ref r) + (expression vec2 * + (expression int sign (var_ref y)) + (constant float (3.1415926)))))) + ())) + ()) + (return (var_ref r)))) + + (signature vec3 + (parameters + (declare (in) vec3 y) + (declare (in) vec3 x)) + ((declare () vec3 r) + (if (expression bool > + (expression vec3 abs (var_ref x)) + (constant float (.0001))) + ((assign (constant bool (1)) + (var_ref r) (call atan ((expression vec3 / + (var_ref y) + (var_ref x))))) + (if (expression bool < + (var_ref x) + (constant float (0.0))) + ((assign (constant bool (1)) + (var_ref r) + (expression vec3 + + (var_ref r) + (expression vec3 * + (expression int sign (var_ref y)) + (constant float (3.1415926)))))) + ())) + ()) + (return (var_ref r)))) + + (signature vec4 + (parameters + (declare (in) vec4 y) + (declare (in) vec4 x)) + ((declare () vec4 r) + (if (expression bool > + (expression vec4 abs (var_ref x)) + (constant float (.0001))) + ((assign (constant bool (1)) + (var_ref r) (call atan ((expression vec4 / + (var_ref y) + (var_ref x))))) + (if (expression bool < + (var_ref x) + (constant float (0.0))) + ((assign (constant bool (1)) + (var_ref r) + (expression vec4 + + (var_ref r) + (expression vec4 * + (expression int sign (var_ref y)) + (constant float (3.1415926)))))) + ())) + ()) + (return (var_ref r)))) + +)) -- cgit v1.2.3 From 336b4ad8c76a525a0df2f4b0fc1d67e86bc5db3f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 10:38:37 -0700 Subject: Handle GLSL 1.20 implicit type conversions. We were nicely constructing a new expression for the implicit type conversion, but then checking that the previous types matched instead of the new expression's type. Fixes errors in Regnum Online shaders. --- ast_to_hir.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 7759c36a699..8945bce6ee6 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -132,8 +132,8 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, bool multiply, struct _mesa_glsl_parse_state *state, YYLTYPE *loc) { - const glsl_type *const type_a = value_a->type; - const glsl_type *const type_b = value_b->type; + const glsl_type *type_a = value_a->type; + const glsl_type *type_b = value_b->type; /* From GLSL 1.50 spec, page 56: * @@ -159,7 +159,9 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, "arithmetic operator"); return glsl_type::error_type; } - + type_a = value_a->type; + type_b = value_b->type; + /* "If the operands are integer types, they must both be signed or * both be unsigned." * @@ -362,8 +364,8 @@ static const struct glsl_type * relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, struct _mesa_glsl_parse_state *state, YYLTYPE *loc) { - const glsl_type *const type_a = value_a->type; - const glsl_type *const type_b = value_b->type; + const glsl_type *type_a = value_a->type; + const glsl_type *type_b = value_b->type; /* From GLSL 1.50 spec, page 56: * "The relational operators greater than (>), less than (<), greater @@ -391,6 +393,8 @@ relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, "relational operator"); return glsl_type::error_type; } + type_a = value_a->type; + type_b = value_b->type; if (type_a->base_type != type_b->base_type) { _mesa_glsl_error(loc, state, "base type mismatch"); @@ -420,9 +424,10 @@ relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, * type-check return values. */ ir_rvalue * -validate_assignment(const glsl_type *lhs_type, ir_rvalue *rhs) +validate_assignment(struct _mesa_glsl_parse_state *state, + const glsl_type *lhs_type, ir_rvalue *rhs) { - const glsl_type *const rhs_type = rhs->type; + const glsl_type *rhs_type = rhs->type; /* If there is already some error in the RHS, just return it. Anything * else will lead to an avalanche of error message back to the user. @@ -447,7 +452,13 @@ validate_assignment(const glsl_type *lhs_type, ir_rvalue *rhs) return rhs; } - /* FINISHME: Check for and apply automatic conversions. */ + /* Check for implicit conversion in GLSL 1.20 */ + if (apply_implicit_conversion(lhs_type, rhs, state)) { + rhs_type = rhs->type; + if (rhs_type == lhs_type) + return rhs; + } + return NULL; } @@ -466,7 +477,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, } } - ir_rvalue *new_rhs = validate_assignment(lhs->type, rhs); + ir_rvalue *new_rhs = validate_assignment(state, lhs->type, rhs); if (new_rhs == NULL) { _mesa_glsl_error(& lhs_loc, state, "type mismatch"); } else { -- cgit v1.2.3 From f03acfc7d7275b60418fec94f4a7044de486a05c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 13:05:01 -0700 Subject: builtins: Add the mix(gentype, gentype, float) variant. The broken-in-mesa Regnum Online shader now parses, except for its preprocessor usage. --- builtin_function.cpp | 21 +++++++++++++++++++++ builtins/110/mix | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/builtin_function.cpp b/builtin_function.cpp index 1d847a65fb8..b7719ab4749 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1118,6 +1118,27 @@ static const char *builtins_110_mix = { " (declare (in) vec4 arg1)\n" " (declare (in) vec4 arg2))\n" " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" "))\n" }; diff --git a/builtins/110/mix b/builtins/110/mix index 6bdac74f6ff..032f29e5fa8 100644 --- a/builtins/110/mix +++ b/builtins/110/mix @@ -26,4 +26,25 @@ (declare (in) vec4 arg1) (declare (in) vec4 arg2)) ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) float arg2)) + ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) float arg2)) + ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) float arg2)) + ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) )) -- cgit v1.2.3 From cd512b00633a8f631ad7442c5cdccc608dd432e1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 13:30:14 -0700 Subject: gl_Normal is a vec3 not a vec4. Fixes CorrectSwizzle1.vert. --- builtin_variables.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin_variables.h b/builtin_variables.h index 661da6cf555..b405b46f071 100644 --- a/builtin_variables.h +++ b/builtin_variables.h @@ -47,7 +47,7 @@ static const builtin_variable builtin_110_deprecated_fs_variables[] = { static const builtin_variable builtin_110_deprecated_vs_variables[] = { { ir_var_in, "vec4", "gl_Vertex" }, - { ir_var_in, "vec4", "gl_Normal" }, + { ir_var_in, "vec3", "gl_Normal" }, { ir_var_in, "vec4", "gl_Color" }, { ir_var_in, "vec4", "gl_SecondaryColor" }, { ir_var_in, "vec4", "gl_MultiTexCoord0" }, -- cgit v1.2.3 From 0ca171908d04732176cbcaf2625fed8208a93dc9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 13:38:15 -0700 Subject: Allow arrays of floats as varyings. The comment just above the code said arrays were OK, then it didn't handle arrays. Whoops. Partially fixes CorrectUnsizedArray.frat. --- ast_to_hir.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 8945bce6ee6..307e4483696 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1426,10 +1426,19 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, * float, vec2, vec3, vec4, mat2, mat3, and mat4, or arrays of * these." */ - if (qual->varying && var->type->base_type != GLSL_TYPE_FLOAT) { - var->type = glsl_type::error_type; - _mesa_glsl_error(loc, state, - "varying variables must be of base type float"); + if (qual->varying) { + const glsl_type *non_array_type; + + if (var->type && var->type->is_array()) + non_array_type = var->type->fields.array; + else + non_array_type = var->type; + + if (non_array_type && non_array_type->base_type != GLSL_TYPE_FLOAT) { + var->type = glsl_type::error_type; + _mesa_glsl_error(loc, state, + "varying variables must be of base type float"); + } } if (qual->in && qual->out) -- cgit v1.2.3 From da46e5f5345ed2fa9c74d135267f3d5729c04ed1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 13:57:01 -0700 Subject: builtins: Add ftransform(). Fixes glsl-orangebook-ch06-bump.vert. --- builtin_function.cpp | 20 ++++++++++++++++++++ builtins/110_vs/ftransform | 7 +++++++ builtins/tools/generate_builtins.pl | 11 +++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 builtins/110_vs/ftransform diff --git a/builtin_function.cpp b/builtin_function.cpp index b7719ab4749..4203502e45b 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1778,6 +1778,22 @@ static const char *functions_for_110 [] = { builtins_110_tan, }; +/* Version 110_vs builtins */ + +static const char *builtins_110_vs_ftransform = { + "((function ftransform\n" + " (signature vec4\n" + " (parameters)\n" + " ((return (expression vec4 *\n" + " (var_ref gl_ModelViewProjectionMatrix)\n" + " (var_ref gl_Vertex)))))\n" + "))\n" +}; + +static const char *functions_for_110_vs [] = { + builtins_110_vs_ftransform, +}; + /* Version 130 builtins */ static const char *builtins_130_equal = { @@ -2039,6 +2055,10 @@ _mesa_glsl_initialize_functions(exec_list *instructions, read_builtins(state, instructions, functions_for_110, sizeof(functions_for_110) / sizeof(const char *)); + if (state->language_version >= 110 && state->target == vertex_shader) + read_builtins(state, instructions, functions_for_110_vs, + sizeof(functions_for_110_vs) / sizeof(const char *)); + if (state->language_version >= 130) read_builtins(state, instructions, functions_for_130, sizeof(functions_for_130) / sizeof(const char *)); diff --git a/builtins/110_vs/ftransform b/builtins/110_vs/ftransform new file mode 100644 index 00000000000..3a5e8ccecfc --- /dev/null +++ b/builtins/110_vs/ftransform @@ -0,0 +1,7 @@ +((function ftransform + (signature vec4 + (parameters) + ((return (expression vec4 * + (var_ref gl_ModelViewProjectionMatrix) + (var_ref gl_Vertex))))) +)) diff --git a/builtins/tools/generate_builtins.pl b/builtins/tools/generate_builtins.pl index e7ec8ef56ff..9ce0ce3a608 100755 --- a/builtins/tools/generate_builtins.pl +++ b/builtins/tools/generate_builtins.pl @@ -85,7 +85,7 @@ read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, EOF -@versions = sort(); +@versions = sort(); foreach $version (@versions) { $version =~ s!builtins/!!g; process_version($version); @@ -99,7 +99,14 @@ _mesa_glsl_initialize_functions(exec_list *instructions, EOF foreach $version (@versions) { - print " if (state->language_version >= $version)\n"; + $version_number = $version; + if ($version =~ m/_vs/) { + $version_check = " && state->target == vertex_shader"; + $version_number =~ s/_vs//; + } else { + $version_check = ""; + } + print " if (state->language_version >= $version_number$version_check)\n"; print " read_builtins(state, instructions, functions_for_$version,\n"; print " sizeof(functions_for_$version) / "; print "sizeof(const char *));\n\n" -- cgit v1.2.3 From 5b9ac87941a11c72a220ba14c25cf0f8bc5acffa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 14:01:33 -0700 Subject: builtins: Add support for reflect(). Fixes glsl-orangebook-ch06.frag parsing. --- builtin_function.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ builtins/110/reflect | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 builtins/110/reflect diff --git a/builtin_function.cpp b/builtin_function.cpp index 4203502e45b..5bb0007e6da 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1329,6 +1329,67 @@ static const char *builtins_110_radians = { "))\n" }; +static const char *builtins_110_reflect = { + "((function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float i)\n" + " (declare (in) float n))\n" + " ((return (expression float -\n" + " (var_ref i)\n" + " (expression float *\n" + " (constant float (2.0))\n" + " (expression float *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 i)\n" + " (declare (in) vec2 n))\n" + " ((return (expression vec2 -\n" + " (var_ref i)\n" + " (expression vec2 *\n" + " (constant float (2.0))\n" + " (expression vec2 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 i)\n" + " (declare (in) vec3 n))\n" + " ((return (expression vec3 -\n" + " (var_ref i)\n" + " (expression vec3 *\n" + " (constant float (2.0))\n" + " (expression vec3 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 i)\n" + " (declare (in) vec4 n))\n" + " ((return (expression vec4 -\n" + " (var_ref i)\n" + " (expression vec4 *\n" + " (constant float (2.0))\n" + " (expression vec4 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + "))\n" +}; + static const char *builtins_110_sign = { "((function sign\n" " (signature float\n" @@ -1770,6 +1831,7 @@ static const char *functions_for_110 [] = { builtins_110_notEqual, builtins_110_pow, builtins_110_radians, + builtins_110_reflect, builtins_110_sign, builtins_110_sin, builtins_110_smoothstep, diff --git a/builtins/110/reflect b/builtins/110/reflect new file mode 100644 index 00000000000..8238fdc93fd --- /dev/null +++ b/builtins/110/reflect @@ -0,0 +1,58 @@ +((function reflect + (signature float + (parameters + (declare (in) float i) + (declare (in) float n)) + ((return (expression float - + (var_ref i) + (expression float * + (constant float (2.0)) + (expression float * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec2 + (parameters + (declare (in) vec2 i) + (declare (in) vec2 n)) + ((return (expression vec2 - + (var_ref i) + (expression vec2 * + (constant float (2.0)) + (expression vec2 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec3 + (parameters + (declare (in) vec3 i) + (declare (in) vec3 n)) + ((return (expression vec3 - + (var_ref i) + (expression vec3 * + (constant float (2.0)) + (expression vec3 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec4 + (parameters + (declare (in) vec4 i) + (declare (in) vec4 n)) + ((return (expression vec4 - + (var_ref i) + (expression vec4 * + (constant float (2.0)) + (expression vec4 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + +)) -- cgit v1.2.3 From aa5794384ffec53acd9c71882b650b3ddaff06f8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 14:09:04 -0700 Subject: Add builtin gl_LightSource[]. Fixes gst-gl-bumper.vert parsing. --- ir_variable.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ir_variable.cpp b/ir_variable.cpp index 2c2b57a7114..af8ad2c3182 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -114,7 +114,16 @@ generate_110_uniforms(exec_list *instructions, * FINISHME: (glFrontMaterial, glBackMaterial) */ - /* FINISHME: Add support for gl_LightSource[] */ + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_TEXTURE_LIGHTS. GL_MAX_TEXTURE_LIGHTS must be + * FINISHME: at least 8, so hard-code 8 for now. + */ + const glsl_type *const light_source_array_type = + glsl_type::get_array_instance(symtab->get_type("gl_LightSourceParameters"), 8); + + add_variable("gl_LightSource", ir_var_uniform, light_source_array_type, + instructions, symtab); + /* FINISHME: Add support for gl_LightModel */ /* FINISHME: Add support for gl_FrontLightProduct[], gl_BackLightProduct[] */ /* FINISHME: Add support for gl_TextureEnvColor[] */ -- cgit v1.2.3 From 4c22f4dba7a87de4736e01010e361b073a7501c8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 2 Jun 2010 10:48:47 -0700 Subject: Fix multi-line comment regular expression to handle (non) nested comments. Ken reminded me of a couple cases that I should be testing. These are the non-nestedness of things that look like nested comments as well as potentially tricky things like "/*/" and "/*/*/". The (non) nested comment case was not working in the case of the comment terminator with multiple '*' characters. We fix this by not considering a '*' as the "non-slash" to terminate a sequence of '*' characters within the comment. We also fix the final match of the terminator to use '+' rather than '*' to require the presence of a final '*' character in the comment terminator. --- glcpp-lex.l | 2 +- tests/063-comments.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 0954ab7e83d..7bc5fab76da 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -53,7 +53,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } /* Multi-line comments */ -[/][*]([^*]*[*]+[^/])*[^*]*[*]*[/] { +[/][*]([^*]*[*]+[^*/])*[^*]*[*]+[/] { if (yyextra->space_tokens) return SPACE; } diff --git a/tests/063-comments.c b/tests/063-comments.c index 4cda52236e0..e641d2f0f9e 100644 --- a/tests/063-comments.c +++ b/tests/063-comments.c @@ -13,3 +13,8 @@ and slashes / *** / and other stuff. ****/ more code here +/* Test that /* nested + comments */ +are not treated like comments. +/*/ this is a comment */ +/*/*/ -- cgit v1.2.3 From e4b2731a25c071407d90c6c593a226574e9c36f9 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 2 Jun 2010 10:59:08 -0700 Subject: Make the multi-line comment regular expression a bit easier to read. Use quoted strings for literal portions rather than a sequence of single-character character classes. --- glcpp-lex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 7bc5fab76da..2aec46a2ed1 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -53,7 +53,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } /* Multi-line comments */ -[/][*]([^*]*[*]+[^*/])*[^*]*[*]+[/] { +"/*"([^*]*[*]+[^*/])*[^*]*[*]+"/" { if (yyextra->space_tokens) return SPACE; } -- cgit v1.2.3 From 111e25bd84fb923bbab5b0ca76bbbb5d9a537a26 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 2 Jun 2010 12:54:15 -0700 Subject: Factor out common sub-expression from multi-line-comment regular expression. In two places we look for an (optional) sequence of characters other than "*" followed by a sequence of on or more "*". Using a name for this (NON_STARS_THEN_STARS) seems to make it a bit easier to understand. --- glcpp-lex.l | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glcpp-lex.l b/glcpp-lex.l index 2aec46a2ed1..0d9a75415a3 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -45,6 +45,8 @@ DECIMAL_INTEGER [1-9][0-9]*[uU]? OCTAL_INTEGER 0[0-7]*[uU]? HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? +NON_STARS_THEN_STARS [^*]*[*]+ + %% /* Single-line comments */ @@ -53,7 +55,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } /* Multi-line comments */ -"/*"([^*]*[*]+[^*/])*[^*]*[*]+"/" { +"/*"({NON_STARS_THEN_STARS}[^*/])*{NON_STARS_THEN_STARS}"/" { if (yyextra->space_tokens) return SPACE; } -- cgit v1.2.3 From c8021ee01d7ea57ada56398061ed7c03398bc965 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 2 Jun 2010 13:13:40 -0700 Subject: Remove some cruft from the Makefile This was affecting the build, but the files don't actually exist. --- Makefile.am | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index a62591d9ac2..544d446aec9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,9 +51,6 @@ glsl_SOURCES = \ ir_hierarchical_visitor.cpp \ ir_swizzle_swizzle.cpp \ ir_vec_index_to_swizzle.cpp - ir_vec_index_to_swizzle.cpp \ - ir_visit_tree.cpp \ - ir_visit_tree.h BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) -- cgit v1.2.3 From 35159b542c793e607a28bbffb12ab51e1081ca9b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 2 Jun 2010 13:39:45 -0700 Subject: There is no class ir_label, so there's no need for ir_instruction::as_label --- ir.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ir.h b/ir.h index 784e41fcb67..bf3400aa921 100644 --- a/ir.h +++ b/ir.h @@ -58,7 +58,6 @@ public: virtual class ir_dereference * as_dereference() { return NULL; } virtual class ir_dereference_array * as_dereference_array() { return NULL; } virtual class ir_rvalue * as_rvalue() { return NULL; } - virtual class ir_label * as_label() { return NULL; } virtual class ir_loop * as_loop() { return NULL; } virtual class ir_assignment * as_assignment() { return NULL; } virtual class ir_call * as_call() { return NULL; } -- cgit v1.2.3 From 384c051b8c7a53aa805836723bd43f2d496303ff Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 2 Jun 2010 13:50:27 -0700 Subject: ir_dereference_array always operates on an r-value ir_dereference_array::array is always an r-value. If the dereference is of a varaible, that r-value will be an ir_dereference_variable. This simplifies the code a bit. --- ir_vec_index_to_swizzle.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ir_vec_index_to_swizzle.cpp b/ir_vec_index_to_swizzle.cpp index 1deb0d381ec..f0900cf70d6 100644 --- a/ir_vec_index_to_swizzle.cpp +++ b/ir_vec_index_to_swizzle.cpp @@ -64,7 +64,6 @@ ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) { ir_dereference_array *deref = ir->as_dereference_array(); ir_constant *ir_constant; - ir_rvalue *deref_var; if (!deref) return ir; @@ -72,20 +71,13 @@ ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) if (deref->array->type->is_matrix() || deref->array->type->is_array()) return ir; - deref_var = deref->array->as_rvalue(); - if (!deref_var) { - ir_variable *var = deref->array->as_variable(); - assert(var); - deref_var = new ir_dereference_variable(var); - } - assert(deref->array_index->type->base_type == GLSL_TYPE_INT); ir_constant = deref->array_index->constant_expression_value(); if (!ir_constant) return ir; this->progress = true; - return new ir_swizzle(deref_var, ir_constant->value.i[0], 0, 0, 0, 1); + return new ir_swizzle(deref->array, ir_constant->value.i[0], 0, 0, 0, 1); } ir_visitor_status -- cgit v1.2.3 From c7c95fe51f0ff83d4d3e07a926f96336248f9509 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 2 Jun 2010 14:43:03 -0700 Subject: Remove dead code: _glcpp_parser_expand_token_list_onto This function simply isn't being called anymore. --- glcpp-parse.y | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index dd8e133f550..a4e6559282c 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -1320,16 +1320,6 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser, list->non_space_tail = list->tail; } -static void -_glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, - token_list_t *list, - token_list_t *result) -{ - _glcpp_parser_expand_token_list (parser, list); - - _token_list_append_list (result, list); -} - void _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, token_list_t *list) -- cgit v1.2.3 From 22b3aced03c1a243ba03fbcba5aa51f97e4f0abb Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 2 Jun 2010 15:32:03 -0700 Subject: Eliminate some recursion from children of _expand_token_list Previously, both _expand_node and _expand_function would always make mutually recursive calls into _expand_token_list. This was unnecessary since these functions can simply return unexpanded results, after which the outer iteration will next attempt expansion of the results. The only trick in doing this is to arrange so that the active list is popped at the appropriate time. To do this, we add a new token_node_t marker to the active stack. When pushing onto the active list, we set marker to last->next, and when the marker is seen by the token list iteration, we pop from the active stack. --- glcpp-parse.y | 159 +++++++++++++++++++++++++++++++++++++--------------------- glcpp.h | 8 ++- 2 files changed, 110 insertions(+), 57 deletions(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index a4e6559282c..1c7c84dac7a 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -52,12 +52,6 @@ _string_list_append_item (string_list_t *list, const char *str); static void _string_list_append_list (string_list_t *list, string_list_t *tail); -static void -_string_list_push (string_list_t *list, const char *str); - -static void -_string_list_pop (string_list_t *list); - static int _string_list_contains (string_list_t *list, const char *member, int *index); @@ -96,6 +90,20 @@ _token_list_append (token_list_t *list, token_t *token); static void _token_list_append_list (token_list_t *list, token_list_t *tail); +static int +_token_list_length (token_list_t *list); + +static active_list_t * +_active_list_push (active_list_t *list, + const char *identifier, + token_node_t *marker); + +static active_list_t * +_active_list_pop (active_list_t *list); + +int +_active_list_contains (active_list_t *list, const char *identifier); + static void _glcpp_parser_evaluate_defined (glcpp_parser_t *parser, token_list_t *list); @@ -468,42 +476,6 @@ _string_list_append_item (string_list_t *list, const char *str) list->tail = node; } -void -_string_list_push (string_list_t *list, const char *str) -{ - string_node_t *node; - - node = xtalloc (list, string_node_t); - node->str = xtalloc_strdup (node, str); - node->next = list->head; - - if (list->tail == NULL) { - list->tail = node; - } - list->head = node; -} - -void -_string_list_pop (string_list_t *list) -{ - string_node_t *node; - - node = list->head; - - if (node == NULL) { - fprintf (stderr, "Internal error: _string_list_pop called on an empty list.\n"); - exit (1); - } - - list->head = node->next; - if (list->tail == node) { - assert (node->next == NULL); - list->tail = NULL; - } - - talloc_free (node); -} - int _string_list_contains (string_list_t *list, const char *member, int *index) { @@ -716,6 +688,21 @@ _token_list_trim_trailing_space (token_list_t *list) } } +static int +_token_list_length (token_list_t *list) +{ + int length = 0; + token_node_t *node; + + if (list == NULL) + return 0; + + for (node = list->head; node; node = node->next) + length++; + + return length; +} + static void _token_print (token_t *token) { @@ -880,7 +867,7 @@ glcpp_parser_create (void) glcpp_lex_init_extra (parser, &parser->scanner); parser->defines = hash_table_ctor (32, hash_table_string_hash, hash_table_string_compare); - parser->active = _string_list_create (parser); + parser->active = NULL; parser->lexing_if = 0; parser->space_tokens = 1; parser->newline_as_space = 0; @@ -1176,10 +1163,6 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, substituted->non_space_tail = substituted->tail; - _string_list_push (parser->active, identifier); - _glcpp_parser_expand_token_list (parser, substituted); - _string_list_pop (parser->active); - return substituted; } @@ -1206,7 +1189,6 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser, token_t *token = node->token; const char *identifier; macro_t *macro; - token_list_t *expansion; /* We only expand identifiers */ if (token->type != IDENTIFIER) { @@ -1231,7 +1213,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser, /* Finally, don't expand this macro if we're already actively * expanding it, (to avoid infinite recursion). */ - if (_string_list_contains (parser->active, identifier, NULL)) { + if (_active_list_contains (parser->active, identifier)) { /* We change the token type here from IDENTIFIER to * OTHER to prevent any future expansion of this * unexpanded token. */ @@ -1254,18 +1236,63 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser, if (macro->replacements == NULL) return _token_list_create (parser); - expansion = _token_list_copy (parser, macro->replacements); - - _string_list_push (parser->active, identifier); - _glcpp_parser_expand_token_list (parser, expansion); - _string_list_pop (parser->active); - - return expansion; + return _token_list_copy (parser, macro->replacements); } return _glcpp_parser_expand_function (parser, node, last); } +/* Push a new identifier onto the active list, returning the new list. + * + * Here, 'marker' is the token node that appears in the list after the + * expansion of 'identifier'. That is, when the list iterator begins + * examinging 'marker', then it is time to pop this node from the + * active stack. + */ +active_list_t * +_active_list_push (active_list_t *list, + const char *identifier, + token_node_t *marker) +{ + active_list_t *node; + + node = xtalloc (list, active_list_t); + node->identifier = xtalloc_strdup (node, identifier); + node->marker = marker; + node->next = list; + + return node; +} + +active_list_t * +_active_list_pop (active_list_t *list) +{ + active_list_t *node = list; + + if (node == NULL) + return NULL; + + node = list->next; + talloc_free (list); + + return node; +} + +int +_active_list_contains (active_list_t *list, const char *identifier) +{ + active_list_t *node; + + if (list == NULL) + return 0; + + for (node = list; node; node = node->next) + if (strcmp (node->identifier, identifier) == 0) + return 1; + + return 0; +} + /* Walk over the token list replacing nodes with their expansion. * Whenever nodes are expanded the walking will walk over the new * nodes, continuing to expand as necessary. The results are placed in @@ -1288,10 +1315,27 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser, node = list->head; while (node) { + + while (parser->active && parser->active->marker == node) + parser->active = _active_list_pop (parser->active); + /* Find the expansion for node, which will replace all * nodes from node to last, inclusive. */ expansion = _glcpp_parser_expand_node (parser, node, &last); if (expansion) { + token_node_t *n; + + for (n = node; n != last->next; n = n->next) + while (parser->active && + parser->active->marker == n) + { + parser->active = _active_list_pop (parser->active); + } + + parser->active = _active_list_push (parser->active, + node->token->value.str, + last->next); + /* Splice expansion into list, supporting a * simple deletion if the expansion is * empty. */ @@ -1317,6 +1361,9 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser, node = node_prev ? node_prev->next : list->head; } + while (parser->active) + parser->active = _active_list_pop (parser->active); + list->non_space_tail = list->tail; } diff --git a/glcpp.h b/glcpp.h index 41fc2043d13..4459daa4f32 100644 --- a/glcpp.h +++ b/glcpp.h @@ -123,10 +123,16 @@ typedef struct skip_node { struct skip_node *next; } skip_node_t; +typedef struct active_list { + const char *identifier; + token_node_t *marker; + struct active_list *next; +} active_list_t; + struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; - string_list_t *active; + active_list_t *active; int lexing_if; int space_tokens; int newline_as_space; -- cgit v1.2.3 From 14c98a56442a076a831aee85e9b3e54d934ec360 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 2 Jun 2010 15:49:54 -0700 Subject: Restore error message for a macro with unbalanced parentheses. We had to remove this earlier because our recursive function calls caused the same nodes to be examined for expansion more than once. And in the test suite, one node would be examined before it had its closing parenthesis and then again later after the parenthesis was added. So we removed this error message to allow the test case to pass. Now that we've removed the unnecessary recursive function call we can catch this error case and report it as desired. --- glcpp-parse.y | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/glcpp-parse.y b/glcpp-parse.y index 1c7c84dac7a..b07714eebd2 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -956,7 +956,7 @@ typedef enum function_status * Macro name not followed by a '('. This is not an error, but * simply that the macro name should be treated as a non-macro. * - * FUNCTION_UNBLANCED_PARENTHESES + * FUNCTION_UNBALANCED_PARENTHESES * * Macro name is not followed by a balanced set of parentheses. */ @@ -1065,6 +1065,9 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, case FUNCTION_NOT_A_FUNCTION: return NULL; case FUNCTION_UNBALANCED_PARENTHESES: + fprintf (stderr, "Error: Macro %s call has unbalanced parentheses\n", + identifier); + exit (1); return NULL; } -- cgit v1.2.3 From 5ae88af9886b4b7bf486cbc0d10a9bab6456165f Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 2 Jun 2010 15:59:45 -0700 Subject: test suite: Add expected output for every test. Rather than using the (munged) output of "gcc -E" we now capture precisely the output we expect from every test case. This allows us to stay immune from strange output from gcc (unpredictable whitespace output---aprticularly with different gcc versions). This will also allow us to write tests that capture expected error messages from the preprocessor as well. --- .gitignore | 3 -- Makefile | 2 +- tests/000-content-with-spaces.c.expected | 1 + tests/001-define.c.expected | 2 ++ tests/002-define-chain.c.expected | 3 ++ tests/003-define-chain-reverse.c.expected | 3 ++ tests/004-define-recursive.c.expected | 6 ++++ tests/005-define-composite-chain.c.expected | 3 ++ .../006-define-composite-chain-reverse.c.expected | 3 ++ tests/007-define-composite-recursive.c.expected | 6 ++++ tests/008-define-empty.c.expected | 2 ++ tests/009-undef.c.expected | 4 +++ tests/010-undef-re-define.c.expected | 6 ++++ tests/011-define-func-empty.c.expected | 2 ++ tests/012-define-func-no-args.c.expected | 2 ++ tests/013-define-func-1-arg-unused.c.expected | 2 ++ tests/014-define-func-2-arg-unused.c.expected | 2 ++ tests/015-define-object-with-parens.c.expected | 4 +++ tests/016-define-func-1-arg.c.expected | 2 ++ tests/017-define-func-2-args.c.expected | 2 ++ .../018-define-func-macro-as-parameter.c.expected | 3 ++ tests/019-define-func-1-arg-multi.c.expected | 2 ++ tests/020-define-func-2-arg-multi.c.expected | 2 ++ tests/021-define-func-compose.c.expected | 3 ++ tests/022-define-func-arg-with-parens.c.expected | 2 ++ tests/023-define-extra-whitespace.c.expected | 8 +++++ .../024-define-chain-to-self-recursion.c.expected | 3 ++ tests/025-func-macro-as-non-macro.c.expected | 2 ++ tests/026-define-func-extra-newlines.c.expected | 3 ++ tests/027-define-chain-obj-to-func.c.expected | 3 ++ tests/028-define-chain-obj-to-non-func.c.expected | 3 ++ ...9-define-chain-obj-to-func-with-args.c.expected | 3 ++ ...030-define-chain-obj-to-func-compose.c.expected | 4 +++ ...31-define-chain-func-to-func-compose.c.expected | 4 +++ tests/032-define-func-self-recurse.c.expected | 2 ++ tests/033-define-func-self-compose.c.expected | 2 ++ ...34-define-func-self-compose-non-func.c.expected | 2 ++ ...ompose-non-func-multi-token-argument.c.expected | 2 ++ ...-func-non-macro-multi-token-argument.c.expected | 3 ++ tests/037-finalize-unexpanded-macro.c.expected | 3 ++ tests/038-func-arg-with-commas.c.expected | 2 ++ tests/039-func-arg-obj-macro-with-comma.c.expected | 3 ++ tests/040-token-pasting.c.expected | 2 ++ tests/041-if-0.c.expected | 5 ++++ tests/042-if-1.c.expected | 5 ++++ tests/043-if-0-else.c.expected | 7 +++++ tests/044-if-1-else.c.expected | 7 +++++ tests/045-if-0-elif.c.expected | 11 +++++++ tests/046-if-1-elsif.c.expected | 11 +++++++ tests/047-if-elif-else.c.expected | 11 +++++++ tests/048-if-nested.c.expected | 11 +++++++ tests/049-if-expression-precedence.c.expected | 5 ++++ tests/050-if-defined.c.expected | 17 +++++++++++ tests/051-if-relational.c.expected | 35 ++++++++++++++++++++++ tests/052-if-bitwise.c.expected | 20 +++++++++++++ tests/053-if-divide-and-shift.c.expected | 15 ++++++++++ tests/054-if-with-macros.c.expected | 34 +++++++++++++++++++++ ...ine-chain-obj-to-func-parens-in-text.c.expected | 3 ++ tests/056-macro-argument-with-comma.c.expected | 4 +++ tests/057-empty-arguments.c.expected | 6 ++++ tests/058-token-pasting-empty-arguments.c.expected | 5 ++++ tests/059-token-pasting-integer.c.expected | 4 +++ ...t-paren-in-macro-right-paren-in-text.c.expected | 3 ++ .../061-define-chain-obj-to-func-multi.c.expected | 5 ++++ tests/062-if-0-skips-garbage.c.expected | 5 ++++ tests/063-comments.c.expected | 13 ++++++++ tests/071-punctuator.c.expected | 1 + tests/072-token-pasting-same-line.c.expected | 2 ++ tests/099-c99-example.c.expected | 16 ++++++++++ tests/glcpp-test | 5 +--- 70 files changed, 384 insertions(+), 8 deletions(-) create mode 100644 tests/000-content-with-spaces.c.expected create mode 100644 tests/001-define.c.expected create mode 100644 tests/002-define-chain.c.expected create mode 100644 tests/003-define-chain-reverse.c.expected create mode 100644 tests/004-define-recursive.c.expected create mode 100644 tests/005-define-composite-chain.c.expected create mode 100644 tests/006-define-composite-chain-reverse.c.expected create mode 100644 tests/007-define-composite-recursive.c.expected create mode 100644 tests/008-define-empty.c.expected create mode 100644 tests/009-undef.c.expected create mode 100644 tests/010-undef-re-define.c.expected create mode 100644 tests/011-define-func-empty.c.expected create mode 100644 tests/012-define-func-no-args.c.expected create mode 100644 tests/013-define-func-1-arg-unused.c.expected create mode 100644 tests/014-define-func-2-arg-unused.c.expected create mode 100644 tests/015-define-object-with-parens.c.expected create mode 100644 tests/016-define-func-1-arg.c.expected create mode 100644 tests/017-define-func-2-args.c.expected create mode 100644 tests/018-define-func-macro-as-parameter.c.expected create mode 100644 tests/019-define-func-1-arg-multi.c.expected create mode 100644 tests/020-define-func-2-arg-multi.c.expected create mode 100644 tests/021-define-func-compose.c.expected create mode 100644 tests/022-define-func-arg-with-parens.c.expected create mode 100644 tests/023-define-extra-whitespace.c.expected create mode 100644 tests/024-define-chain-to-self-recursion.c.expected create mode 100644 tests/025-func-macro-as-non-macro.c.expected create mode 100644 tests/026-define-func-extra-newlines.c.expected create mode 100644 tests/027-define-chain-obj-to-func.c.expected create mode 100644 tests/028-define-chain-obj-to-non-func.c.expected create mode 100644 tests/029-define-chain-obj-to-func-with-args.c.expected create mode 100644 tests/030-define-chain-obj-to-func-compose.c.expected create mode 100644 tests/031-define-chain-func-to-func-compose.c.expected create mode 100644 tests/032-define-func-self-recurse.c.expected create mode 100644 tests/033-define-func-self-compose.c.expected create mode 100644 tests/034-define-func-self-compose-non-func.c.expected create mode 100644 tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected create mode 100644 tests/036-define-func-non-macro-multi-token-argument.c.expected create mode 100644 tests/037-finalize-unexpanded-macro.c.expected create mode 100644 tests/038-func-arg-with-commas.c.expected create mode 100644 tests/039-func-arg-obj-macro-with-comma.c.expected create mode 100644 tests/040-token-pasting.c.expected create mode 100644 tests/041-if-0.c.expected create mode 100644 tests/042-if-1.c.expected create mode 100644 tests/043-if-0-else.c.expected create mode 100644 tests/044-if-1-else.c.expected create mode 100644 tests/045-if-0-elif.c.expected create mode 100644 tests/046-if-1-elsif.c.expected create mode 100644 tests/047-if-elif-else.c.expected create mode 100644 tests/048-if-nested.c.expected create mode 100644 tests/049-if-expression-precedence.c.expected create mode 100644 tests/050-if-defined.c.expected create mode 100644 tests/051-if-relational.c.expected create mode 100644 tests/052-if-bitwise.c.expected create mode 100644 tests/053-if-divide-and-shift.c.expected create mode 100644 tests/054-if-with-macros.c.expected create mode 100644 tests/055-define-chain-obj-to-func-parens-in-text.c.expected create mode 100644 tests/056-macro-argument-with-comma.c.expected create mode 100644 tests/057-empty-arguments.c.expected create mode 100644 tests/058-token-pasting-empty-arguments.c.expected create mode 100644 tests/059-token-pasting-integer.c.expected create mode 100644 tests/060-left-paren-in-macro-right-paren-in-text.c.expected create mode 100644 tests/061-define-chain-obj-to-func-multi.c.expected create mode 100644 tests/062-if-0-skips-garbage.c.expected create mode 100644 tests/063-comments.c.expected create mode 100644 tests/071-punctuator.c.expected create mode 100644 tests/072-token-pasting-same-line.c.expected create mode 100644 tests/099-c99-example.c.expected diff --git a/.gitignore b/.gitignore index b88f0cc75c7..077db8d8e14 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,4 @@ glcpp-parse.c glcpp-parse.h *.o *~ -tests/*.expected -tests/*.gcc -tests/*.glcpp tests/*.out diff --git a/Makefile b/Makefile index 0c06aa880fb..3fb44ac3b2e 100644 --- a/Makefile +++ b/Makefile @@ -22,4 +22,4 @@ test: glcpp clean: rm -f glcpp glcpp-lex.c glcpp-parse.c *.o *~ - rm -f tests/*.out tests/*.gcc tests/*.expected tests/*~ + rm -f tests/*.out tests/*~ diff --git a/tests/000-content-with-spaces.c.expected b/tests/000-content-with-spaces.c.expected new file mode 100644 index 00000000000..a7fc918c908 --- /dev/null +++ b/tests/000-content-with-spaces.c.expected @@ -0,0 +1 @@ +this is four tokens diff --git a/tests/001-define.c.expected b/tests/001-define.c.expected new file mode 100644 index 00000000000..a464d9da742 --- /dev/null +++ b/tests/001-define.c.expected @@ -0,0 +1,2 @@ + +1 diff --git a/tests/002-define-chain.c.expected b/tests/002-define-chain.c.expected new file mode 100644 index 00000000000..c6c9ee38a9e --- /dev/null +++ b/tests/002-define-chain.c.expected @@ -0,0 +1,3 @@ + + +1 diff --git a/tests/003-define-chain-reverse.c.expected b/tests/003-define-chain-reverse.c.expected new file mode 100644 index 00000000000..c6c9ee38a9e --- /dev/null +++ b/tests/003-define-chain-reverse.c.expected @@ -0,0 +1,3 @@ + + +1 diff --git a/tests/004-define-recursive.c.expected b/tests/004-define-recursive.c.expected new file mode 100644 index 00000000000..2d07687f8ca --- /dev/null +++ b/tests/004-define-recursive.c.expected @@ -0,0 +1,6 @@ + + + +foo +bar +baz diff --git a/tests/005-define-composite-chain.c.expected b/tests/005-define-composite-chain.c.expected new file mode 100644 index 00000000000..892975c268c --- /dev/null +++ b/tests/005-define-composite-chain.c.expected @@ -0,0 +1,3 @@ + + +a 1 diff --git a/tests/006-define-composite-chain-reverse.c.expected b/tests/006-define-composite-chain-reverse.c.expected new file mode 100644 index 00000000000..892975c268c --- /dev/null +++ b/tests/006-define-composite-chain-reverse.c.expected @@ -0,0 +1,3 @@ + + +a 1 diff --git a/tests/007-define-composite-recursive.c.expected b/tests/007-define-composite-recursive.c.expected new file mode 100644 index 00000000000..0b0b477d9df --- /dev/null +++ b/tests/007-define-composite-recursive.c.expected @@ -0,0 +1,6 @@ + + + +a b c foo +b c a bar +c a b baz diff --git a/tests/008-define-empty.c.expected b/tests/008-define-empty.c.expected new file mode 100644 index 00000000000..139597f9cb0 --- /dev/null +++ b/tests/008-define-empty.c.expected @@ -0,0 +1,2 @@ + + diff --git a/tests/009-undef.c.expected b/tests/009-undef.c.expected new file mode 100644 index 00000000000..9c0b35a4518 --- /dev/null +++ b/tests/009-undef.c.expected @@ -0,0 +1,4 @@ + +1 + +foo diff --git a/tests/010-undef-re-define.c.expected b/tests/010-undef-re-define.c.expected new file mode 100644 index 00000000000..5970f49028e --- /dev/null +++ b/tests/010-undef-re-define.c.expected @@ -0,0 +1,6 @@ + +1 + +foo + +2 diff --git a/tests/011-define-func-empty.c.expected b/tests/011-define-func-empty.c.expected new file mode 100644 index 00000000000..139597f9cb0 --- /dev/null +++ b/tests/011-define-func-empty.c.expected @@ -0,0 +1,2 @@ + + diff --git a/tests/012-define-func-no-args.c.expected b/tests/012-define-func-no-args.c.expected new file mode 100644 index 00000000000..9f075f26004 --- /dev/null +++ b/tests/012-define-func-no-args.c.expected @@ -0,0 +1,2 @@ + +bar diff --git a/tests/013-define-func-1-arg-unused.c.expected b/tests/013-define-func-1-arg-unused.c.expected new file mode 100644 index 00000000000..a464d9da742 --- /dev/null +++ b/tests/013-define-func-1-arg-unused.c.expected @@ -0,0 +1,2 @@ + +1 diff --git a/tests/014-define-func-2-arg-unused.c.expected b/tests/014-define-func-2-arg-unused.c.expected new file mode 100644 index 00000000000..a464d9da742 --- /dev/null +++ b/tests/014-define-func-2-arg-unused.c.expected @@ -0,0 +1,2 @@ + +1 diff --git a/tests/015-define-object-with-parens.c.expected b/tests/015-define-object-with-parens.c.expected new file mode 100644 index 00000000000..a70321a4c51 --- /dev/null +++ b/tests/015-define-object-with-parens.c.expected @@ -0,0 +1,4 @@ + +()1() + +()2() diff --git a/tests/016-define-func-1-arg.c.expected b/tests/016-define-func-1-arg.c.expected new file mode 100644 index 00000000000..6bfe04f7381 --- /dev/null +++ b/tests/016-define-func-1-arg.c.expected @@ -0,0 +1,2 @@ + +((bar)+1) diff --git a/tests/017-define-func-2-args.c.expected b/tests/017-define-func-2-args.c.expected new file mode 100644 index 00000000000..f7a2b8c26cb --- /dev/null +++ b/tests/017-define-func-2-args.c.expected @@ -0,0 +1,2 @@ + +((bar)*(baz)) diff --git a/tests/018-define-func-macro-as-parameter.c.expected b/tests/018-define-func-macro-as-parameter.c.expected new file mode 100644 index 00000000000..c6c9ee38a9e --- /dev/null +++ b/tests/018-define-func-macro-as-parameter.c.expected @@ -0,0 +1,3 @@ + + +1 diff --git a/tests/019-define-func-1-arg-multi.c.expected b/tests/019-define-func-1-arg-multi.c.expected new file mode 100644 index 00000000000..1e89b8cfd0c --- /dev/null +++ b/tests/019-define-func-1-arg-multi.c.expected @@ -0,0 +1,2 @@ + +(this is more than one word) diff --git a/tests/020-define-func-2-arg-multi.c.expected b/tests/020-define-func-2-arg-multi.c.expected new file mode 100644 index 00000000000..19f59f5ecb7 --- /dev/null +++ b/tests/020-define-func-2-arg-multi.c.expected @@ -0,0 +1,2 @@ + +one fish,two fish,red fish,blue fish diff --git a/tests/021-define-func-compose.c.expected b/tests/021-define-func-compose.c.expected new file mode 100644 index 00000000000..87f51f0baca --- /dev/null +++ b/tests/021-define-func-compose.c.expected @@ -0,0 +1,3 @@ + + +(2*((1+(3)))) diff --git a/tests/022-define-func-arg-with-parens.c.expected b/tests/022-define-func-arg-with-parens.c.expected new file mode 100644 index 00000000000..1dfc6698bb7 --- /dev/null +++ b/tests/022-define-func-arg-with-parens.c.expected @@ -0,0 +1,2 @@ + +(argument(including parens)for the win) diff --git a/tests/023-define-extra-whitespace.c.expected b/tests/023-define-extra-whitespace.c.expected new file mode 100644 index 00000000000..9c58275d0f9 --- /dev/null +++ b/tests/023-define-extra-whitespace.c.expected @@ -0,0 +1,8 @@ + + + + +1 +2 +3 4 +5 6 7 diff --git a/tests/024-define-chain-to-self-recursion.c.expected b/tests/024-define-chain-to-self-recursion.c.expected new file mode 100644 index 00000000000..15600af546b --- /dev/null +++ b/tests/024-define-chain-to-self-recursion.c.expected @@ -0,0 +1,3 @@ + + +foo diff --git a/tests/025-func-macro-as-non-macro.c.expected b/tests/025-func-macro-as-non-macro.c.expected new file mode 100644 index 00000000000..4a59f0520e3 --- /dev/null +++ b/tests/025-func-macro-as-non-macro.c.expected @@ -0,0 +1,2 @@ + +foo bar diff --git a/tests/026-define-func-extra-newlines.c.expected b/tests/026-define-func-extra-newlines.c.expected new file mode 100644 index 00000000000..5e3c70f2cc5 --- /dev/null +++ b/tests/026-define-func-extra-newlines.c.expected @@ -0,0 +1,3 @@ + + +bar diff --git a/tests/027-define-chain-obj-to-func.c.expected b/tests/027-define-chain-obj-to-func.c.expected new file mode 100644 index 00000000000..94c15f95059 --- /dev/null +++ b/tests/027-define-chain-obj-to-func.c.expected @@ -0,0 +1,3 @@ + + +success diff --git a/tests/028-define-chain-obj-to-non-func.c.expected b/tests/028-define-chain-obj-to-non-func.c.expected new file mode 100644 index 00000000000..94c15f95059 --- /dev/null +++ b/tests/028-define-chain-obj-to-non-func.c.expected @@ -0,0 +1,3 @@ + + +success diff --git a/tests/029-define-chain-obj-to-func-with-args.c.expected b/tests/029-define-chain-obj-to-func-with-args.c.expected new file mode 100644 index 00000000000..94c15f95059 --- /dev/null +++ b/tests/029-define-chain-obj-to-func-with-args.c.expected @@ -0,0 +1,3 @@ + + +success diff --git a/tests/030-define-chain-obj-to-func-compose.c.expected b/tests/030-define-chain-obj-to-func-compose.c.expected new file mode 100644 index 00000000000..bed826e7831 --- /dev/null +++ b/tests/030-define-chain-obj-to-func-compose.c.expected @@ -0,0 +1,4 @@ + + + +success diff --git a/tests/031-define-chain-func-to-func-compose.c.expected b/tests/031-define-chain-func-to-func-compose.c.expected new file mode 100644 index 00000000000..bed826e7831 --- /dev/null +++ b/tests/031-define-chain-func-to-func-compose.c.expected @@ -0,0 +1,4 @@ + + + +success diff --git a/tests/032-define-func-self-recurse.c.expected b/tests/032-define-func-self-recurse.c.expected new file mode 100644 index 00000000000..983f9417401 --- /dev/null +++ b/tests/032-define-func-self-recurse.c.expected @@ -0,0 +1,2 @@ + +foo(2*(3)) diff --git a/tests/033-define-func-self-compose.c.expected b/tests/033-define-func-self-compose.c.expected new file mode 100644 index 00000000000..08183623643 --- /dev/null +++ b/tests/033-define-func-self-compose.c.expected @@ -0,0 +1,2 @@ + +foo(2*(foo(2*(3)))) diff --git a/tests/034-define-func-self-compose-non-func.c.expected b/tests/034-define-func-self-compose-non-func.c.expected new file mode 100644 index 00000000000..3f808fe665d --- /dev/null +++ b/tests/034-define-func-self-compose-non-func.c.expected @@ -0,0 +1,2 @@ + +foo diff --git a/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected b/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected new file mode 100644 index 00000000000..09dfdd64e9b --- /dev/null +++ b/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected @@ -0,0 +1,2 @@ + +1+foo diff --git a/tests/036-define-func-non-macro-multi-token-argument.c.expected b/tests/036-define-func-non-macro-multi-token-argument.c.expected new file mode 100644 index 00000000000..580ed9599c5 --- /dev/null +++ b/tests/036-define-func-non-macro-multi-token-argument.c.expected @@ -0,0 +1,3 @@ + + +more success diff --git a/tests/037-finalize-unexpanded-macro.c.expected b/tests/037-finalize-unexpanded-macro.c.expected new file mode 100644 index 00000000000..e804d7e4f9f --- /dev/null +++ b/tests/037-finalize-unexpanded-macro.c.expected @@ -0,0 +1,3 @@ + + +expand(just once) diff --git a/tests/038-func-arg-with-commas.c.expected b/tests/038-func-arg-with-commas.c.expected new file mode 100644 index 00000000000..6544adb3a25 --- /dev/null +++ b/tests/038-func-arg-with-commas.c.expected @@ -0,0 +1,2 @@ + +success diff --git a/tests/039-func-arg-obj-macro-with-comma.c.expected b/tests/039-func-arg-obj-macro-with-comma.c.expected new file mode 100644 index 00000000000..8a15397a033 --- /dev/null +++ b/tests/039-func-arg-obj-macro-with-comma.c.expected @@ -0,0 +1,3 @@ + + +(two,words) diff --git a/tests/040-token-pasting.c.expected b/tests/040-token-pasting.c.expected new file mode 100644 index 00000000000..48e836ec3fa --- /dev/null +++ b/tests/040-token-pasting.c.expected @@ -0,0 +1,2 @@ + +onetoken diff --git a/tests/041-if-0.c.expected b/tests/041-if-0.c.expected new file mode 100644 index 00000000000..8b506b32d55 --- /dev/null +++ b/tests/041-if-0.c.expected @@ -0,0 +1,5 @@ +success_1 + + + +success_2 diff --git a/tests/042-if-1.c.expected b/tests/042-if-1.c.expected new file mode 100644 index 00000000000..a6ae9465a97 --- /dev/null +++ b/tests/042-if-1.c.expected @@ -0,0 +1,5 @@ +success_1 + +success_2 + +success_3 diff --git a/tests/043-if-0-else.c.expected b/tests/043-if-0-else.c.expected new file mode 100644 index 00000000000..3d7e6be96c8 --- /dev/null +++ b/tests/043-if-0-else.c.expected @@ -0,0 +1,7 @@ +success_1 + + + +success_2 + +success_3 diff --git a/tests/044-if-1-else.c.expected b/tests/044-if-1-else.c.expected new file mode 100644 index 00000000000..4a31e1cfa9e --- /dev/null +++ b/tests/044-if-1-else.c.expected @@ -0,0 +1,7 @@ +success_1 + +success_2 + + + +success_3 diff --git a/tests/045-if-0-elif.c.expected b/tests/045-if-0-elif.c.expected new file mode 100644 index 00000000000..a9bb1588e4f --- /dev/null +++ b/tests/045-if-0-elif.c.expected @@ -0,0 +1,11 @@ +success_1 + + + + + +success_3 + + + +success_4 diff --git a/tests/046-if-1-elsif.c.expected b/tests/046-if-1-elsif.c.expected new file mode 100644 index 00000000000..a4995713ca5 --- /dev/null +++ b/tests/046-if-1-elsif.c.expected @@ -0,0 +1,11 @@ +success_1 + +success_2 + + + + + + + +success_3 diff --git a/tests/047-if-elif-else.c.expected b/tests/047-if-elif-else.c.expected new file mode 100644 index 00000000000..54d30861197 --- /dev/null +++ b/tests/047-if-elif-else.c.expected @@ -0,0 +1,11 @@ +success_1 + + + + + + + +success_2 + +success_3 diff --git a/tests/048-if-nested.c.expected b/tests/048-if-nested.c.expected new file mode 100644 index 00000000000..8beb9c32c37 --- /dev/null +++ b/tests/048-if-nested.c.expected @@ -0,0 +1,11 @@ +success_1 + + + + + + + + + +success_2 diff --git a/tests/049-if-expression-precedence.c.expected b/tests/049-if-expression-precedence.c.expected new file mode 100644 index 00000000000..729bdd15f80 --- /dev/null +++ b/tests/049-if-expression-precedence.c.expected @@ -0,0 +1,5 @@ + + + +success + diff --git a/tests/050-if-defined.c.expected b/tests/050-if-defined.c.expected new file mode 100644 index 00000000000..737eb8d9403 --- /dev/null +++ b/tests/050-if-defined.c.expected @@ -0,0 +1,17 @@ + + + +success_1 + + + +success_2 + + + + + + + +success_3 + diff --git a/tests/051-if-relational.c.expected b/tests/051-if-relational.c.expected new file mode 100644 index 00000000000..652fefdd43b --- /dev/null +++ b/tests/051-if-relational.c.expected @@ -0,0 +1,35 @@ + + + +success_1 + + + +success_2 + + + + + +success_3 + + + + + +success_3 + + + + + + + +success_4 + + + +success_5 + + + diff --git a/tests/052-if-bitwise.c.expected b/tests/052-if-bitwise.c.expected new file mode 100644 index 00000000000..44e52b206e5 --- /dev/null +++ b/tests/052-if-bitwise.c.expected @@ -0,0 +1,20 @@ + + + +success_1 + + +success_2 + + + + + + +success_3 + + +success_4 + + + diff --git a/tests/053-if-divide-and-shift.c.expected b/tests/053-if-divide-and-shift.c.expected new file mode 100644 index 00000000000..7e78e0454e0 --- /dev/null +++ b/tests/053-if-divide-and-shift.c.expected @@ -0,0 +1,15 @@ + + + +success_1 + + +success_2 + + + + + + +success_3 + diff --git a/tests/054-if-with-macros.c.expected b/tests/054-if-with-macros.c.expected new file mode 100644 index 00000000000..70f737c90a9 --- /dev/null +++ b/tests/054-if-with-macros.c.expected @@ -0,0 +1,34 @@ + + + + + + + +success_1 + + +success_2 + + + + +success_3 + + + + +success_4 + + + + + + +success_5 + + +success_6 + + + diff --git a/tests/055-define-chain-obj-to-func-parens-in-text.c.expected b/tests/055-define-chain-obj-to-func-parens-in-text.c.expected new file mode 100644 index 00000000000..94c15f95059 --- /dev/null +++ b/tests/055-define-chain-obj-to-func-parens-in-text.c.expected @@ -0,0 +1,3 @@ + + +success diff --git a/tests/056-macro-argument-with-comma.c.expected b/tests/056-macro-argument-with-comma.c.expected new file mode 100644 index 00000000000..bed826e7831 --- /dev/null +++ b/tests/056-macro-argument-with-comma.c.expected @@ -0,0 +1,4 @@ + + + +success diff --git a/tests/057-empty-arguments.c.expected b/tests/057-empty-arguments.c.expected new file mode 100644 index 00000000000..7d97e15e29d --- /dev/null +++ b/tests/057-empty-arguments.c.expected @@ -0,0 +1,6 @@ + +success + +success + +success diff --git a/tests/058-token-pasting-empty-arguments.c.expected b/tests/058-token-pasting-empty-arguments.c.expected new file mode 100644 index 00000000000..e0967a1b951 --- /dev/null +++ b/tests/058-token-pasting-empty-arguments.c.expected @@ -0,0 +1,5 @@ + +ab +a +b + diff --git a/tests/059-token-pasting-integer.c.expected b/tests/059-token-pasting-integer.c.expected new file mode 100644 index 00000000000..f1288aa7cb7 --- /dev/null +++ b/tests/059-token-pasting-integer.c.expected @@ -0,0 +1,4 @@ + +12 +1000 +identifier2 diff --git a/tests/060-left-paren-in-macro-right-paren-in-text.c.expected b/tests/060-left-paren-in-macro-right-paren-in-text.c.expected new file mode 100644 index 00000000000..3e5501aa6e8 --- /dev/null +++ b/tests/060-left-paren-in-macro-right-paren-in-text.c.expected @@ -0,0 +1,3 @@ + + +5*2 diff --git a/tests/061-define-chain-obj-to-func-multi.c.expected b/tests/061-define-chain-obj-to-func-multi.c.expected new file mode 100644 index 00000000000..15eb64b97f1 --- /dev/null +++ b/tests/061-define-chain-obj-to-func-multi.c.expected @@ -0,0 +1,5 @@ + + + + +success diff --git a/tests/062-if-0-skips-garbage.c.expected b/tests/062-if-0-skips-garbage.c.expected new file mode 100644 index 00000000000..3f2ff2d6cc8 --- /dev/null +++ b/tests/062-if-0-skips-garbage.c.expected @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/063-comments.c.expected b/tests/063-comments.c.expected new file mode 100644 index 00000000000..4998d76cc22 --- /dev/null +++ b/tests/063-comments.c.expected @@ -0,0 +1,13 @@ + + + +f = g /h; + l(); +m = n ++ p; + +more code here + +are not treated like comments. + + diff --git a/tests/071-punctuator.c.expected b/tests/071-punctuator.c.expected new file mode 100644 index 00000000000..959d6825988 --- /dev/null +++ b/tests/071-punctuator.c.expected @@ -0,0 +1 @@ +a = b diff --git a/tests/072-token-pasting-same-line.c.expected b/tests/072-token-pasting-same-line.c.expected new file mode 100644 index 00000000000..7b80af7e465 --- /dev/null +++ b/tests/072-token-pasting-same-line.c.expected @@ -0,0 +1,2 @@ + +success_1 success_2 success_3 diff --git a/tests/099-c99-example.c.expected b/tests/099-c99-example.c.expected new file mode 100644 index 00000000000..352bbff48f5 --- /dev/null +++ b/tests/099-c99-example.c.expected @@ -0,0 +1,16 @@ + + + + + + + + + + + + + +f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); +f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); +int i[] = { 1, 23, 4, 5, }; diff --git a/tests/glcpp-test b/tests/glcpp-test index 24110333a5e..396f6e175e8 100755 --- a/tests/glcpp-test +++ b/tests/glcpp-test @@ -2,9 +2,6 @@ for test in *.c; do echo "Testing $test" - ../glcpp < $test > $test.glcpp - grep -v '^ *$' < $test.glcpp > $test.out || true - gcc -E $test -o $test.gcc - grep -v '^#' < $test.gcc | grep -v '^$' | sed -r -e 's/^ +/ /' > $test.expected || true + ../glcpp < $test > $test.out diff -u $test.expected $test.out done -- cgit v1.2.3 From 603b8fc4b2442c93146f9ec0176a5784d9296c9d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 4 Jun 2010 12:56:15 -0700 Subject: Check variable mode when comparing qualifier lists. Fixes function-05.vert. --- ir.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ir.cpp b/ir.cpp index 0810a3a0114..2b05e9776d3 100644 --- a/ir.cpp +++ b/ir.cpp @@ -460,6 +460,7 @@ ir_function_signature::qualifiers_match(exec_list *params) ir_variable *b = (ir_variable *)iter_b.get(); if (a->read_only != b->read_only || + a->mode != b->mode || a->interpolation != b->interpolation || a->centroid != b->centroid) { -- cgit v1.2.3 From 2ab0b13dd9b281b9c68b3d3e2fb01d19564d115e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 4 Jun 2010 14:53:58 -0700 Subject: Disallow defining macros whose names start with "__" or "GL_". The GLSL specification reserves these for future use. --- glcpp-parse.y | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/glcpp-parse.y b/glcpp-parse.y index dd8e133f550..5072c48ee8d 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -1344,6 +1344,22 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, _token_list_print (list); } +void +_check_for_reserved_macro_name (const char *identifier) +{ + /* According to the GLSL specification, macro names starting with "__" + * or "GL_" are reserved for future use. So, don't allow them. + */ + if (strncmp(identifier, "__", 2) == 0) { + fprintf (stderr, "Error: Macro names starting with \"__\" are reserved.\n"); + exit(1); + } + if (strncmp(identifier, "GL_", 3) == 0) { + fprintf (stderr, "Error: Macro names starting with \"GL_\" are reserved.\n"); + exit(1); + } +} + void _define_object_macro (glcpp_parser_t *parser, const char *identifier, @@ -1351,6 +1367,8 @@ _define_object_macro (glcpp_parser_t *parser, { macro_t *macro; + _check_for_reserved_macro_name(identifier); + macro = xtalloc (parser, macro_t); macro->is_function = 0; @@ -1369,6 +1387,8 @@ _define_function_macro (glcpp_parser_t *parser, { macro_t *macro; + _check_for_reserved_macro_name(identifier); + macro = xtalloc (parser, macro_t); macro->is_function = 1; -- cgit v1.2.3 From 6cd2a5cc4b8eb1d445f2ae5311db8fda9d46b7a1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 7 Jun 2010 18:49:48 -0700 Subject: Generate an error on empty declaration lists This causes an error for code such as 'float;' --- glsl_parser.ypp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 86ec6f58424..a2ce2af877e 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -779,8 +779,13 @@ init_declarator_list: single_declaration: fully_specified_type { - $$ = new ast_declarator_list($1); - $$->set_location(yylloc); + if ($1->specifier->type_specifier != ast_struct) { + _mesa_glsl_error(& @1, state, "empty declaration list\n"); + YYERROR; + } else { + $$ = new ast_declarator_list($1); + $$->set_location(yylloc); + } } | fully_specified_type IDENTIFIER { -- cgit v1.2.3 From 15d162d7b1ebe09b0bdaf43194529f9ef995c623 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 7 Jun 2010 18:53:06 -0700 Subject: Don't process empty shaders Some valid shaders, such as 'precision highp float;', evaluate to empty sets of instructions. This causes some of the optimization stages to enter infinite loops. Instead, don't bother processing the empty ones. --- glsl_parser_extras.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index afce9d9c348..f6b30289ce3 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -737,7 +737,8 @@ main(int argc, char **argv) ast->print(); } - _mesa_ast_to_hir(&instructions, &state); + if (!state.translation_unit.is_empty()) + _mesa_ast_to_hir(&instructions, &state); } else { /* FINISHME: We should initialize this to the max GLSL version supported * FINISHME: by the driver. At the moment, we don't know what that is. @@ -748,7 +749,7 @@ main(int argc, char **argv) } /* Optimization passes */ - if (!state.error) { + if (!state.error && !instructions.is_empty()) { bool progress; do { progress = false; -- cgit v1.2.3 From 9bcb67bdc4d3f6aee9ef577266aebca85fcfb44f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 7 Jun 2010 18:55:41 -0700 Subject: Fix parsing of precision qualifiers This causes the following tests to pass: glslparsertest/glsl2/precision-02.vert glslparsertest/glsl2/precision-04.vert glslparsertest/glsl2/precision-06.vert This causes the following test to fail. This shader was previously failing to compile, but it was failing for the wrong reasons. glslparsertest/glsl2/precision-03.vert --- glsl_parser.ypp | 52 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/glsl_parser.ypp b/glsl_parser.ypp index a2ce2af877e..4de1ec9591c 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -94,7 +94,7 @@ %token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN %token SUB_ASSIGN %token INVARIANT -%token HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION +%token LOWP MEDIUMP HIGHP PRECISION %token VERSION EXTENSION LINE PRAGMA COLON EOL INTERFACE OUTPUT @@ -105,7 +105,7 @@ %token LONG SHORT DOUBLE HALF FIXED UNSIGNED INPUT OUPTUT %token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 %token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW -%token SIZEOF CAST NAMESPACE USING LOWP MEDIUMP HIGHP +%token SIZEOF CAST NAMESPACE USING %type variable_identifier %type statement @@ -234,11 +234,19 @@ extension_statement: external_declaration_list: external_declaration { - state->translation_unit.push_tail(& $1->link); + /* FINISHME: The NULL test is only required because 'precision' + * FINISHME: statements are not yet supported. + */ + if ($1 != NULL) + state->translation_unit.push_tail(& $1->link); } | external_declaration_list external_declaration { - state->translation_unit.push_tail(& $2->link); + /* FINISHME: The NULL test is only required because 'precision' + * FINISHME: statements are not yet supported. + */ + if ($2 != NULL) + state->translation_unit.push_tail(& $2->link); } ; @@ -999,9 +1007,39 @@ basic_type_specifier_nonarray: ; precision_qualifier: - HIGH_PRECISION { $$ = ast_precision_high; } - | MEDIUM_PRECISION { $$ = ast_precision_medium; } - | LOW_PRECISION { $$ = ast_precision_low; } + HIGHP { + if (state->language_version < 130) + _mesa_glsl_error(& @1, state, + "precission qualifier forbidden " + "in GLSL %d.%d (1.30 or later " + "required)\n", + state->language_version / 100, + state->language_version % 100); + + $$ = ast_precision_high; + } + | MEDIUMP { + if (state->language_version < 130) + _mesa_glsl_error(& @1, state, + "precission qualifier forbidden " + "in GLSL %d.%d (1.30 or later " + "required)\n", + state->language_version / 100, + state->language_version % 100); + + $$ = ast_precision_medium; + } + | LOWP { + if (state->language_version < 130) + _mesa_glsl_error(& @1, state, + "precission qualifier forbidden " + "in GLSL %d.%d (1.30 or later " + "required)\n", + state->language_version / 100, + state->language_version % 100); + + $$ = ast_precision_low; + } ; struct_specifier: -- cgit v1.2.3 From 19eb5896c4f47a8485a7be2d7b63c6f44dff1b42 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 7 Jun 2010 19:02:44 -0700 Subject: Only allow global precision qualifier for int and float This causes the following tests to pass: glslparsertest/glsl2/precision-03.vert --- glsl_parser.ypp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 4de1ec9591c..99c6ca132c7 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -628,6 +628,13 @@ declaration: } | PRECISION precision_qualifier type_specifier_no_prec ';' { + if (($3->type_specifier != ast_float) + && ($3->type_specifier != ast_int)) { + _mesa_glsl_error(& @3, state, "global precision qualifier can " + "only be applied to `int' or `float'\n"); + YYERROR; + } + $$ = NULL; /* FINISHME */ } ; -- cgit v1.2.3 From cfb3536f10dac343ad635be7f979b292c97eb1a3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 7 Jun 2010 19:10:33 -0700 Subject: Bump GL_MAX_TEXTURE_COORDS from 2 to 4 Every platform that supports GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 for now. This causes the following tests to pass: glslparsertest/glsl2/norsetto-bumptbn_sh_fp.vert glslparsertest/glsl2/xreal-lighting-d-omni.vert glslparsertest/glsl2/xreal-lighting-db-omni.vert glslparsertest/glsl2/xreal-lighting-dbs-omni.vert --- ir_variable.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ir_variable.cpp b/ir_variable.cpp index af8ad2c3182..0c0d1278a41 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -97,11 +97,12 @@ generate_110_uniforms(exec_list *instructions, } /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be - * FINISHME: at least 2, so hard-code 2 for now. + * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports + * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 + * FINISHME: for now. */ const glsl_type *const mat4_array_type = - glsl_type::get_array_instance(glsl_type::mat4_type, 2); + glsl_type::get_array_instance(glsl_type::mat4_type, 4); add_variable("gl_TextureMatrix", ir_var_uniform, mat4_array_type, instructions, symtab); @@ -149,11 +150,12 @@ generate_110_vs_variables(exec_list *instructions, generate_110_uniforms(instructions, symtab); /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be - * FINISHME: at least 2, so hard-code 2 for now. + * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports + * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 + * FINISHME: for now. */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, 2); + glsl_type::get_array_instance(glsl_type::vec4_type, 4); add_variable("gl_TexCoord", ir_var_out, vec4_array_type, instructions, symtab); @@ -229,11 +231,12 @@ generate_110_fs_variables(exec_list *instructions, generate_110_uniforms(instructions, symtab); /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_COORDS. GL_MAX_TEXTURE_COORDS must be - * FINISHME: at least 2, so hard-code 2 for now. + * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports + * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 + * FINISHME: for now. */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, 2); + glsl_type::get_array_instance(glsl_type::vec4_type, 4); add_variable("gl_TexCoord", ir_var_in, vec4_array_type, instructions, symtab); -- cgit v1.2.3 From 2f8b0435b0f9c4df8e19bbbd5df78729bfd25f09 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 11:00:00 -0700 Subject: Use array delete operator to delete an array This was detected by valgrind. I think GCC still does the right thing, but the C++ spec allows the compiler to do something stupid... like crash or only delete the first entry in the array. --- ir_function_inlining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 7ac74ca03b6..7cc8a325ffa 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -411,7 +411,7 @@ ir_call::generate_inline(ir_instruction *next_ir) param_iter.next(); } - delete(parameters); + delete [] parameters; if (retval) return new ir_dereference_variable(retval); -- cgit v1.2.3 From 81377c012cf5db3efe2e39885846c60b6e5c6eb8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 28 Apr 2010 18:42:36 -0700 Subject: Define IR instruction for texture look-ups --- ir.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/ir.h b/ir.h index bf3400aa921..fcb23ea0fab 100644 --- a/ir.h +++ b/ir.h @@ -737,6 +737,83 @@ private: /*@}*/ +/** + * Texture sampling opcodes used in ir_texture + */ +enum ir_texture_opcode { + ir_tex, /* Regular texture look-up */ + ir_txb, /* Texture look-up with LOD bias */ + ir_txl, /* Texture look-up with explicit LOD */ + ir_txd, /* Texture look-up with partial derivatvies */ + ir_txf /* Texel fetch with explicit LOD */ +}; + + +/** + * IR instruction to sample a texture + * + * The specific form of the IR instruction depends on the \c mode value + * selected from \c ir_texture_opcodes. In the printed IR, these will + * appear as: + * + * Texel offset + * | Projection divisor + * | | Shadow comparitor + * | | | + * v v v + * (tex (sampler) (coordinate) (0 0 0) (1) ( )) + * (txb (sampler) (coordinate) (0 0 0) (1) ( ) (bias)) + * (txl (sampler) (coordinate) (0 0 0) (1) ( ) (lod)) + * (txd (sampler) (coordinate) (0 0 0) (1) ( ) (dPdx dPdy)) + * (txf (sampler) (coordinate) (0 0 0) (lod)) + */ +class ir_texture : public ir_rvalue { +public: + ir_texture(enum ir_texture_opcode op) + : op(op) + { + /* empty */ + } + + enum ir_texture_opcode op; + + /** Sampler to use for the texture access. */ + ir_dereference *sampler; + + /** Texture coordinate to sample */ + ir_rvalue *coordinate; + + /** + * Value used for projective divide. + * + * If there is no projective divide (the common case), this will be + * \c NULL. Optimization passes should check for this to point to a constant + * of 1.0 and replace that with \c NULL. + */ + ir_rvalue *projector; + + /** + * Coordinate used for comparison on shadow look-ups. + * + * If there is no shadow comparison, this will be \c NULL. For the + * \c ir_txf opcode, this *must* be \c NULL. + */ + ir_rvalue *shadow_comparitor; + + /** Explicit texel offsets. */ + signed char offsets[3]; + + union { + ir_rvalue *lod; /**< Floating point LOD */ + ir_rvalue *bias; /**< Floating point LOD bias */ + struct { + ir_rvalue *dPdx; /**< Partial derivative of coordinate wrt X */ + ir_rvalue *dPdy; /**< Partial derivative of coordinate wrt Y */ + } grad; + } lod_info; +}; + + struct ir_swizzle_mask { unsigned x:2; unsigned y:2; -- cgit v1.2.3 From c30f6e5dea7e75983784f3539304c8dd36356d1c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 26 May 2010 16:41:47 -0700 Subject: Add mappings between ir_texture_opcode and strings. --- ir.cpp | 21 +++++++++++++++++++++ ir.h | 10 ++++++++++ 2 files changed, 31 insertions(+) diff --git a/ir.cpp b/ir.cpp index 2b05e9776d3..9a713494d3b 100644 --- a/ir.cpp +++ b/ir.cpp @@ -303,6 +303,27 @@ ir_dereference::is_lvalue() } +const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf" }; + +const char *ir_texture::opcode_string() +{ + assert((unsigned int) op <= + sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0])); + return tex_opcode_strs[op]; +} + +ir_texture_opcode +ir_texture::get_opcode(const char *str) +{ + const int count = sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]); + for (int op = 0; op < count; op++) { + if (strcmp(str, tex_opcode_strs[op]) == 0) + return (ir_texture_opcode) op; + } + return (ir_texture_opcode) -1; +} + + ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, unsigned w, unsigned count) : val(val) diff --git a/ir.h b/ir.h index fcb23ea0fab..44ffdc554ee 100644 --- a/ir.h +++ b/ir.h @@ -775,6 +775,16 @@ public: /* empty */ } + /** + * Return a string representing the ir_texture_opcode. + */ + const char *opcode_string(); + + /** + * Do a reverse-lookup to translate a string into an ir_texture_opcode. + */ + static ir_texture_opcode get_opcode(const char *); + enum ir_texture_opcode op; /** Sampler to use for the texture access. */ -- cgit v1.2.3 From be298063b501a3e0bd769209f531fd23e4e4646e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 26 May 2010 15:15:31 -0700 Subject: ir_print_visitor: Add support for ir_texture. --- ir_print_visitor.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ ir_print_visitor.h | 1 + 2 files changed, 50 insertions(+) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 84edad5dfac..18ff48c3b34 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -143,6 +143,55 @@ void ir_print_visitor::visit(ir_expression *ir) } +void ir_print_visitor::visit(ir_texture *ir) +{ + printf("(%s ", ir->opcode_string()); + + ir->sampler->accept(this); + printf(" "); + + ir->coordinate->accept(this); + + printf(" (%d %d %d) ", ir->offsets[0], ir->offsets[1], ir->offsets[2]); + + if (ir->op != ir_txf) { + if (ir->projector) + ir->projector->accept(this); + else + printf("1"); + + if (ir->shadow_comparitor) { + printf(" "); + ir->shadow_comparitor->accept(this); + } else { + printf(" ()"); + } + } + + printf(" "); + switch (ir->op) + { + case ir_tex: + break; + case ir_txb: + ir->lod_info.bias->accept(this); + break; + case ir_txl: + case ir_txf: + ir->lod_info.lod->accept(this); + break; + case ir_txd: + printf("("); + ir->lod_info.grad.dPdx->accept(this); + printf(" "); + ir->lod_info.grad.dPdy->accept(this); + printf(")"); + break; + }; + printf(")"); +} + + void ir_print_visitor::visit(ir_swizzle *ir) { const unsigned swiz[4] = { diff --git a/ir_print_visitor.h b/ir_print_visitor.h index 4af508794bd..e97b823522a 100644 --- a/ir_print_visitor.h +++ b/ir_print_visitor.h @@ -60,6 +60,7 @@ public: virtual void visit(ir_function_signature *); virtual void visit(ir_function *); virtual void visit(ir_expression *); + virtual void visit(ir_texture *); virtual void visit(ir_swizzle *); virtual void visit(ir_dereference_variable *); virtual void visit(ir_dereference_array *); -- cgit v1.2.3 From 26d74cd1d140786b8f4b1ccbaf500a16e68eec3c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 26 May 2010 17:42:03 -0700 Subject: Add stub visitor support for ir_texture. --- ir.h | 7 +++++++ ir_constant_expression.cpp | 10 ++++++++++ ir_constant_folding.cpp | 9 +++++++++ ir_function_inlining.cpp | 18 ++++++++++++++++++ ir_hierarchical_visitor.cpp | 14 ++++++++++++++ ir_hierarchical_visitor.h | 2 ++ ir_hv_accept.cpp | 6 ++++++ ir_visitor.h | 1 + 8 files changed, 67 insertions(+) diff --git a/ir.h b/ir.h index 44ffdc554ee..a286e7b9324 100644 --- a/ir.h +++ b/ir.h @@ -775,6 +775,13 @@ public: /* empty */ } + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + /** * Return a string representing the ir_texture_opcode. */ diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 361a7a1630a..e89b5bc7685 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -67,6 +67,7 @@ public: virtual void visit(ir_function_signature *); virtual void visit(ir_function *); virtual void visit(ir_expression *); + virtual void visit(ir_texture *); virtual void visit(ir_swizzle *); virtual void visit(ir_dereference_variable *); virtual void visit(ir_dereference_array *); @@ -502,6 +503,15 @@ ir_constant_visitor::visit(ir_expression *ir) } +void +ir_constant_visitor::visit(ir_texture *ir) +{ + // FINISHME: Do stuff with texture lookups + (void) ir; + value = NULL; +} + + void ir_constant_visitor::visit(ir_swizzle *ir) { diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index b3f27c80c85..5dc4a7dc654 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -60,6 +60,7 @@ public: virtual void visit(ir_function_signature *); virtual void visit(ir_function *); virtual void visit(ir_expression *); + virtual void visit(ir_texture *); virtual void visit(ir_swizzle *); virtual void visit(ir_dereference_variable *); virtual void visit(ir_dereference_array *); @@ -114,6 +115,14 @@ ir_constant_folding_visitor::visit(ir_expression *ir) } +void +ir_constant_folding_visitor::visit(ir_texture *ir) +{ + // FINISHME: Do stuff with texture lookups + (void) ir; +} + + void ir_constant_folding_visitor::visit(ir_swizzle *ir) { diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 7cc8a325ffa..d66eceedb86 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -50,6 +50,7 @@ public: virtual ir_visitor_status visit_enter(ir_call *); virtual ir_visitor_status visit_enter(ir_assignment *); virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_texture *); virtual ir_visitor_status visit_enter(ir_swizzle *); bool progress; @@ -118,6 +119,7 @@ public: virtual void visit(ir_function_signature *); virtual void visit(ir_function *); virtual void visit(ir_expression *); + virtual void visit(ir_texture *); virtual void visit(ir_swizzle *); virtual void visit(ir_dereference_variable *); virtual void visit(ir_dereference_array *); @@ -196,6 +198,14 @@ ir_function_cloning_visitor::visit(ir_expression *ir) } +void +ir_function_cloning_visitor::visit(ir_texture *ir) +{ + // FINISHME: Do stuff with texture lookups + (void) ir; +} + + void ir_function_cloning_visitor::visit(ir_swizzle *ir) { @@ -436,6 +446,14 @@ ir_function_inlining_visitor::visit_enter(ir_return *ir) } +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_texture *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + + ir_visitor_status ir_function_inlining_visitor::visit_enter(ir_swizzle *ir) { diff --git a/ir_hierarchical_visitor.cpp b/ir_hierarchical_visitor.cpp index ad474878355..fd77391973f 100644 --- a/ir_hierarchical_visitor.cpp +++ b/ir_hierarchical_visitor.cpp @@ -108,6 +108,20 @@ ir_hierarchical_visitor::visit_leave(ir_expression *ir) return visit_continue; } +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_texture *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_texture *ir) +{ + (void) ir; + return visit_continue; +} + ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_swizzle *ir) { diff --git a/ir_hierarchical_visitor.h b/ir_hierarchical_visitor.h index d3ba508cf1c..85bc5bb150b 100644 --- a/ir_hierarchical_visitor.h +++ b/ir_hierarchical_visitor.h @@ -113,6 +113,8 @@ public: virtual ir_visitor_status visit_leave(class ir_function *); virtual ir_visitor_status visit_enter(class ir_expression *); virtual ir_visitor_status visit_leave(class ir_expression *); + virtual ir_visitor_status visit_enter(class ir_texture *); + virtual ir_visitor_status visit_leave(class ir_texture *); virtual ir_visitor_status visit_enter(class ir_swizzle *); virtual ir_visitor_status visit_leave(class ir_swizzle *); virtual ir_visitor_status visit_enter(class ir_dereference_array *); diff --git a/ir_hv_accept.cpp b/ir_hv_accept.cpp index 8d535e24faa..7c1798a051a 100644 --- a/ir_hv_accept.cpp +++ b/ir_hv_accept.cpp @@ -156,6 +156,12 @@ done: return v->visit_leave(this); } +ir_visitor_status +ir_texture::accept(ir_hierarchical_visitor *v) +{ + return visit_continue_with_parent; +} + ir_visitor_status ir_swizzle::accept(ir_hierarchical_visitor *v) diff --git a/ir_visitor.h b/ir_visitor.h index ba30858fe62..a6f9d2b7ee3 100644 --- a/ir_visitor.h +++ b/ir_visitor.h @@ -48,6 +48,7 @@ public: virtual void visit(class ir_function_signature *) = 0; virtual void visit(class ir_function *) = 0; virtual void visit(class ir_expression *) = 0; + virtual void visit(class ir_texture *) = 0; virtual void visit(class ir_swizzle *) = 0; virtual void visit(class ir_dereference_variable *) = 0; virtual void visit(class ir_dereference_array *) = 0; -- cgit v1.2.3 From 3c7934bfaae5dff410cddba3ac6696a8911c0c68 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 26 May 2010 17:52:44 -0700 Subject: ir_reader: Refactor reading of dereferences for later reuse. --- ir_reader.cpp | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index f4b9967d449..019631f8080 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -53,6 +53,9 @@ 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_dereference *read_dereference(_mesa_glsl_parse_state *, + s_expression *); static ir_dereference *read_var_ref(_mesa_glsl_parse_state *, s_list *); static ir_dereference *read_array_ref(_mesa_glsl_parse_state *, s_list *); static ir_dereference *read_record_ref(_mesa_glsl_parse_state *, s_list *); @@ -528,8 +531,10 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) return NULL; } - ir_rvalue *rvalue = NULL; - if (strcmp(tag->value(), "swiz") == 0) { + ir_rvalue *rvalue = read_dereference(st, list); + if (rvalue != NULL || st->error) + return rvalue; + else if (strcmp(tag->value(), "swiz") == 0) { rvalue = read_swizzle(st, list); } else if (strcmp(tag->value(), "assign") == 0) { rvalue = read_assignment(st, list); @@ -539,12 +544,6 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) rvalue = read_call(st, list); } else if (strcmp(tag->value(), "constant") == 0) { rvalue = read_constant(st, list); - } else if (strcmp(tag->value(), "var_ref") == 0) { - rvalue = read_var_ref(st, list); - } else if (strcmp(tag->value(), "array_ref") == 0) { - rvalue = read_array_ref(st, list); - } else if (strcmp(tag->value(), "record_ref") == 0) { - rvalue = read_record_ref(st, list); } else { ir_read_error(st, expr, "unrecognized rvalue tag: %s", tag->value()); } @@ -817,6 +816,25 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) return NULL; // should not be reached } +static ir_dereference * +read_dereference(_mesa_glsl_parse_state *st, 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 * read_var_ref(_mesa_glsl_parse_state *st, s_list *list) { -- cgit v1.2.3 From dd5b4a544bd53f192cc86441f4e7e95d93707382 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 26 May 2010 17:55:10 -0700 Subject: ir_reader: Add support for reading ir_texture. --- ir_reader.cpp | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 1 deletion(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index 019631f8080..4c97cc8ebad 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -53,6 +53,7 @@ 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 *); @@ -545,7 +546,9 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) } else if (strcmp(tag->value(), "constant") == 0) { rvalue = read_constant(st, list); } else { - ir_read_error(st, expr, "unrecognized rvalue tag: %s", tag->value()); + rvalue = read_texture(st, list); + if (rvalue == NULL && !st->error) + ir_read_error(st, expr, "unrecognized rvalue tag: %s", tag->value()); } return rvalue; @@ -899,3 +902,148 @@ read_record_ref(_mesa_glsl_parse_state *st, s_list *list) } return new 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; +} + +static ir_texture * +read_texture(_mesa_glsl_parse_state *st, s_list *list) +{ + 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; + } + + ir_texture *tex = new ir_texture(op); + + // Read sampler (must be a deref) + s_expression *sampler_expr = (s_expression *) tag->next; + tex->sampler = read_dereference(st, sampler_expr); + if (tex->sampler == NULL) { + ir_read_error(st, NULL, "when reading sampler in (%s ...)", tag->value()); + return NULL; + } + + // Read coordinate (any rvalue) + s_expression *coordinate_expr = (s_expression *) sampler_expr->next; + tex->coordinate = read_rvalue(st, coordinate_expr); + if (tex->coordinate == NULL) { + ir_read_error(st, NULL, "when reading coordinate in (%s ...)", + tag->value()); + 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 ( )"); + return NULL; + } + s_int *offset_x = SX_AS_INT(offset_list->subexpressions.head); + s_int *offset_y = SX_AS_INT(offset_x->next); + s_int *offset_z = SX_AS_INT(offset_y->next); + if (offset_x == NULL || offset_y == NULL || offset_z == NULL) { + ir_read_error(st, offset_list, "expected ( )"); + 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 (proj_as_int && proj_as_int->value() == 1) { + tex->projector = NULL; + } else { + tex->projector = read_rvalue(st, proj_expr); + if (tex->projector == NULL) { + ir_read_error(st, NULL, "when reading projective divide in (%s ..)", + tag->value()); + 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; + } else { + tex->shadow_comparitor = read_rvalue(st, shadow_list); + if (tex->shadow_comparitor == NULL) { + ir_read_error(st, NULL, "when reading shadow comparitor in (%s ..)", + tag->value()); + 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; + } + default: + // tex doesn't have any extra parameters and txf was handled earlier. + break; + }; + } + return tex; +} -- cgit v1.2.3 From 56d3f6ad782e9819b40544494826954d3fcf978b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 3 Jun 2010 15:07:34 -0700 Subject: Set the type of ir_texture properly; infer it from the sampler type. --- builtin_types.h | 2 ++ glsl_types.h | 2 ++ ir.cpp | 20 ++++++++++++++++++++ ir.h | 3 +++ ir_reader.cpp | 5 +++-- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/builtin_types.h b/builtin_types.h index 148917e0dcf..41ce5d21896 100644 --- a/builtin_types.h +++ b/builtin_types.h @@ -65,6 +65,7 @@ static const struct glsl_type builtin_core_types[] = { const glsl_type *const glsl_type::bool_type = & builtin_core_types[0]; const glsl_type *const glsl_type::int_type = & builtin_core_types[4]; +const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7]; const glsl_type *const glsl_type::float_type = & builtin_core_types[8]; const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9]; const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10]; @@ -230,6 +231,7 @@ static const struct glsl_type builtin_130_types[] = { }; const glsl_type *const glsl_type::uint_type = & builtin_130_types[0]; +const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3]; /*@}*/ /** \name Sampler types added by GL_ARB_texture_rectangle diff --git a/glsl_types.h b/glsl_types.h index 96e4c74d5b5..22df13b07f0 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -108,7 +108,9 @@ struct glsl_type { /*@{*/ static const glsl_type *const error_type; static const glsl_type *const int_type; + static const glsl_type *const ivec4_type; static const glsl_type *const uint_type; + static const glsl_type *const uvec4_type; static const glsl_type *const float_type; static const glsl_type *const vec2_type; static const glsl_type *const vec3_type; diff --git a/ir.cpp b/ir.cpp index 9a713494d3b..ca34c247192 100644 --- a/ir.cpp +++ b/ir.cpp @@ -324,6 +324,26 @@ ir_texture::get_opcode(const char *str) } +void +ir_texture::set_sampler(ir_dereference *sampler) +{ + assert(sampler != NULL); + this->sampler = sampler; + + switch (sampler->type->sampler_type) { + case GLSL_TYPE_FLOAT: + this->type = glsl_type::vec4_type; + break; + case GLSL_TYPE_INT: + this->type = glsl_type::ivec4_type; + break; + case GLSL_TYPE_UINT: + this->type = glsl_type::uvec4_type; + break; + } +} + + ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, unsigned w, unsigned count) : val(val) diff --git a/ir.h b/ir.h index a286e7b9324..33ce4a04c36 100644 --- a/ir.h +++ b/ir.h @@ -787,6 +787,9 @@ public: */ const char *opcode_string(); + /** Set the sampler and infer the type. */ + void set_sampler(ir_dereference *sampler); + /** * Do a reverse-lookup to translate a string into an ir_texture_opcode. */ diff --git a/ir_reader.cpp b/ir_reader.cpp index 4c97cc8ebad..0a2d18e2e01 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -934,11 +934,12 @@ read_texture(_mesa_glsl_parse_state *st, s_list *list) // Read sampler (must be a deref) s_expression *sampler_expr = (s_expression *) tag->next; - tex->sampler = read_dereference(st, sampler_expr); - if (tex->sampler == NULL) { + ir_dereference *sampler = read_dereference(st, sampler_expr); + if (sampler == NULL) { ir_read_error(st, NULL, "when reading sampler in (%s ...)", tag->value()); return NULL; } + tex->set_sampler(sampler); // Read coordinate (any rvalue) s_expression *coordinate_expr = (s_expression *) sampler_expr->next; -- cgit v1.2.3 From 9d1fc46f0cdf63677aac05f987cdd5b18453da2f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 3 Jun 2010 14:51:40 -0700 Subject: generate_builtins.pl: Support _fs directories as well as _vs. --- builtins/tools/generate_builtins.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtins/tools/generate_builtins.pl b/builtins/tools/generate_builtins.pl index 9ce0ce3a608..71c0a4d8c00 100755 --- a/builtins/tools/generate_builtins.pl +++ b/builtins/tools/generate_builtins.pl @@ -102,10 +102,12 @@ foreach $version (@versions) { $version_number = $version; if ($version =~ m/_vs/) { $version_check = " && state->target == vertex_shader"; - $version_number =~ s/_vs//; + } elsif ($version =~ m/_fs/) { + $version_check = " && state->target == fragment_shader"; } else { $version_check = ""; } + $version_number =~ s/_[vf]s//; print " if (state->language_version >= $version_number$version_check)\n"; print " read_builtins(state, instructions, functions_for_$version,\n"; print " sizeof(functions_for_$version) / "; -- cgit v1.2.3 From 9aefbe838c34aea75ecae0c42f56f8e8fe56d47f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 4 Jun 2010 15:02:49 -0700 Subject: generate_builtins.pl: Support directiories for each extension. --- builtins/tools/generate_builtins.pl | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/builtins/tools/generate_builtins.pl b/builtins/tools/generate_builtins.pl index 71c0a4d8c00..8fdef2d9743 100755 --- a/builtins/tools/generate_builtins.pl +++ b/builtins/tools/generate_builtins.pl @@ -1,10 +1,9 @@ #!/usr/bin/env perl - sub process_version { my ($version) = @_; my @vars; - print "/* Version $version builtins */\n\n"; + print "/* $version builtins */\n\n"; my @files = ; foreach $file (@files) { @@ -85,7 +84,7 @@ read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, EOF -@versions = sort(); +@versions = sort(); foreach $version (@versions) { $version =~ s!builtins/!!g; process_version($version); @@ -99,16 +98,20 @@ _mesa_glsl_initialize_functions(exec_list *instructions, EOF foreach $version (@versions) { - $version_number = $version; - if ($version =~ m/_vs/) { - $version_check = " && state->target == vertex_shader"; - } elsif ($version =~ m/_fs/) { - $version_check = " && state->target == fragment_shader"; + if ($version =~ /^[1-9][0-9][0-9]/) { + $version_number = $version; + $version_number =~ s/_[vf]s//g; + $check = "state->language_version >= $version_number"; + if ($version =~ /_vs/) { + $check = "$check && state->target == vertex_shader"; + } elsif ($version =~ /_fs/) { + $check = "$check && state->target == fragment_shader"; + } } else { - $version_check = ""; + # Not a version...an extension name + $check = "state->${version}_enable"; } - $version_number =~ s/_[vf]s//; - print " if (state->language_version >= $version_number$version_check)\n"; + print " if ($check)\n"; print " read_builtins(state, instructions, functions_for_$version,\n"; print " sizeof(functions_for_$version) / "; print "sizeof(const char *));\n\n" -- cgit v1.2.3 From b3bcea7db6278fa1b8c66ad5253babe210462d69 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 7 Jun 2010 19:28:19 -0700 Subject: Add a python script to generate texture builtins. --- builtins/tools/texture_builtins.py | 229 +++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100755 builtins/tools/texture_builtins.py diff --git a/builtins/tools/texture_builtins.py b/builtins/tools/texture_builtins.py new file mode 100755 index 00000000000..49c620e89e2 --- /dev/null +++ b/builtins/tools/texture_builtins.py @@ -0,0 +1,229 @@ +#!/usr/bin/python + +from os import path +import sys + +def vec_type(g, size): + if size == 1: + if g == "i": + return "int" + elif g == "u": + return "unsigned" + return "float" + return g + "vec" + str(size) + +# Get the base dimension - i.e. sampler3D gives 3 +def get_coord_dim(sampler_type): + if sampler_type[0].isdigit(): + return int(sampler_type[0]) + elif sampler_type.startswith("Cube"): + return 3 + assert False ("coord_dim: invalid sampler_type: " + sampler_type) + +# Get the number of extra vector components (i.e. shadow comparitor) +def get_extra_dim(sampler_type, use_proj, unused_fields): + extra_dim = unused_fields + if sampler_type.find("Shadow") != -1: + extra_dim += 1 + if sampler_type.find("Array") != -1: + extra_dim += 1 + if use_proj: + extra_dim += 1 + return extra_dim + +def generate_sigs(g, tex_inst, sampler_type, use_proj = False, unused_fields = 0): + coord_dim = get_coord_dim(sampler_type) + extra_dim = get_extra_dim(sampler_type, use_proj, unused_fields) + + # Print parameters + print " (signature " + g + "vec4" + print " (parameters" + print " (declare (in) " + g + "sampler" + sampler_type + " sampler)" + print " (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)", + if tex_inst == "txb": + print "\n (declare (in) float bias)", + elif tex_inst == "txl": + print "\n (declare (in) float lod)", + elif tex_inst == "txf": + print "\n (declare (in) int lod)", + elif tex_inst == "txd": + grad_type = vec_type("", coord_dim) + print "\n (declare (in) " + grad_type + " dPdx)", + print "\n (declare (in) " + grad_type + " dPdy)", + + print ")\n ((return (" + tex_inst + " (var_ref sampler)", + + # Coordinate + if extra_dim > 0: + print "(swiz " + "xyzw"[:coord_dim] + " (var_ref P))", + else: + print "(var_ref P)", + + # Offset + print "(0 0 0)", + + if tex_inst != "txf": + # Projective divisor + if use_proj: + print "(swiz " + "xyzw"[coord_dim + extra_dim-1] + " (var_ref P))", + else: + print "1", + + # Shadow comparitor + if sampler_type.endswith("Shadow"): + print "(swiz z (var_ref P))", + else: + print "()", + + # Bias/explicit LOD/gradient: + if tex_inst == "txb": + print "(var_ref bias)", + elif tex_inst == "txl" or tex_inst == "txf": + print "(var_ref lod)", + elif tex_inst == "txd": + print "((var_ref dPdx) (var_ref dPdy))", + print "))))\n" + +def generate_fiu_sigs(tex_inst, sampler_type, use_proj = False, unused_fields = 0): + generate_sigs("", tex_inst, sampler_type, use_proj, unused_fields) + generate_sigs("i", tex_inst, sampler_type, use_proj, unused_fields) + generate_sigs("u", tex_inst, sampler_type, use_proj, unused_fields) + +builtins_dir = path.join(path.dirname(path.abspath(__file__)), "..") + +with open(path.join(builtins_dir, "130", "texture"), 'w') as sys.stdout: + print "((function texture" + generate_fiu_sigs("tex", "1D") + generate_fiu_sigs("tex", "2D") + generate_fiu_sigs("tex", "3D") + generate_fiu_sigs("tex", "Cube") + generate_fiu_sigs("tex", "1DArray") + generate_fiu_sigs("tex", "2DArray") + print "))" + +# txb variants are only allowed within a fragment shader (GLSL 1.30 p. 86) +with open(path.join(builtins_dir, "130_fs", "texture"), 'w') as sys.stdout: + print "((function texture" + generate_fiu_sigs("txb", "1D") + generate_fiu_sigs("txb", "2D") + generate_fiu_sigs("txb", "3D") + generate_fiu_sigs("txb", "Cube") + generate_fiu_sigs("txb", "1DArray") + generate_fiu_sigs("txb", "2DArray") + print "))" + +with open(path.join(builtins_dir, "130", "textureLod"), 'w') as sys.stdout: + print "((function textureLod" + generate_fiu_sigs("txl", "1D") + generate_fiu_sigs("txl", "2D") + generate_fiu_sigs("txl", "3D") + generate_fiu_sigs("txl", "Cube") + generate_fiu_sigs("txl", "1DArray") + generate_fiu_sigs("txl", "2DArray") + print "))" + +with open(path.join(builtins_dir, "130", "texelFetch"), 'w') as sys.stdout: + print "((function texelFetch" + generate_fiu_sigs("txf", "1D") + generate_fiu_sigs("txf", "2D") + generate_fiu_sigs("txf", "3D") + generate_fiu_sigs("txf", "1DArray") + generate_fiu_sigs("txf", "2DArray") + print "))" + +with open(path.join(builtins_dir, "130", "textureGrad"), 'w') as sys.stdout: + print "((function textureGrad" + generate_fiu_sigs("txd", "1D") + generate_fiu_sigs("txd", "2D") + generate_fiu_sigs("txd", "3D") + generate_fiu_sigs("txd", "Cube") + generate_fiu_sigs("txd", "1DArray") + generate_fiu_sigs("txd", "2DArray") + print ")\n)" + +# ARB_texture_rectangle extension +with open(path.join(builtins_dir, "ARB_texture_rectangle", "textures"), 'w') as sys.stdout: + print "((function texture2DRect" + generate_sigs("", "tex", "2DRect") + print ")\n (function shadow2DRect" + generate_sigs("", "tex", "2DRectShadow") + print "))" + +# Deprecated (110/120 style) functions with silly names: +with open(path.join(builtins_dir, "110", "textures"), 'w') as sys.stdout: + print "((function texture1D" + generate_sigs("", "tex", "1D") + print ")\n (function texture1DLod" + generate_sigs("", "txl", "1D") + print ")\n (function texture1DProj" + generate_sigs("", "tex", "1D", True) + generate_sigs("", "tex", "1D", True, 2) + print ")\n (function texture1DProjLod" + generate_sigs("", "txl", "1D", True) + generate_sigs("", "txl", "1D", True, 2) + print ")\n (function texture2D" + generate_sigs("", "tex", "2D") + print ")\n(function texture2DLod" + generate_sigs("", "txl", "2D") + print ")\n (function texture2DProj" + generate_sigs("", "tex", "2D", True) + generate_sigs("", "tex", "2D", True, 1) + print ")\n (function texture2DProjLod" + generate_sigs("", "txl", "2D", True) + generate_sigs("", "txl", "2D", True, 1) + print ")\n (function texture3D" + generate_sigs("", "tex", "3D") + print ")\n (function texture3DLod" + generate_sigs("", "txl", "3D") + print ")\n (function texture3DProj" + generate_sigs("", "tex", "3D", True) + print ")\n (function texture3DProjLod" + generate_sigs("", "txl", "3D", True) + print ")\n (function textureCube" + generate_sigs("", "tex", "Cube") + print ")\n (function textureCubeLod" + generate_sigs("", "txl", "Cube") + print ")\n (function shadow1D" + generate_sigs("", "tex", "1DShadow", False, 1) + print ")\n (function shadow1DLod" + generate_sigs("", "txl", "1DShadow", False, 1) + print ")\n (function shadow1DProj" + generate_sigs("", "tex", "1DShadow", True, 1) + print ")\n (function shadow1DProjLod" + generate_sigs("", "txl", "1DShadow", True, 1) + print ")\n (function shadow2D" + generate_sigs("", "tex", "2DShadow") + print ")\n (function shadow2DLod" + generate_sigs("", "txl", "2DShadow") + print ")\n (function shadow2DProj" + generate_sigs("", "tex", "2DShadow", True) + print ")\n (function shadow2DProjLod" + generate_sigs("", "txl", "2DShadow", True) + print "))" + +with open(path.join(builtins_dir, "110_fs", "textures"), 'w') as sys.stdout: + print "((function texture1D" + generate_sigs("", "txb", "1D") + print ")\n (function texture1DProj" + generate_sigs("", "txb", "1D", True) + generate_sigs("", "txb", "1D", True, 2) + print ")\n (function texture2D" + generate_sigs("", "txb", "2D") + print ")\n (function texture2DProj" + generate_sigs("", "txb", "2D", True) + generate_sigs("", "txb", "2D", True, 1) + print ")\n (function texture3D" + generate_sigs("", "txb", "3D") + print ")\n (function texture3DProj" + generate_sigs("", "txb", "3D", True) + print ")\n (function textureCube" + generate_sigs("", "txb", "Cube") + print ")\n (function shadow1D" + generate_sigs("", "txb", "1DShadow", False, 1) + print ")\n (function shadow1DProj" + generate_sigs("", "txb", "1DShadow", True, 1) + print ")\n (function shadow2D" + generate_sigs("", "txb", "2DShadow") + print ")\n (function shadow2DProj" + generate_sigs("", "txb", "2DShadow", True) + print "))" -- cgit v1.2.3 From 538da120920d4fce107da26bf94d30d063183deb Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 8 Jun 2010 13:44:00 -0700 Subject: texture_builtins.py: Add support for 130 Proj variants. --- builtins/tools/texture_builtins.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/builtins/tools/texture_builtins.py b/builtins/tools/texture_builtins.py index 49c620e89e2..404d7e8d415 100755 --- a/builtins/tools/texture_builtins.py +++ b/builtins/tools/texture_builtins.py @@ -112,6 +112,24 @@ with open(path.join(builtins_dir, "130_fs", "texture"), 'w') as sys.stdout: generate_fiu_sigs("txb", "2DArray") print "))" +with open(path.join(builtins_dir, "130", "textureProj"), 'w') as sys.stdout: + print "((function textureProj" + generate_fiu_sigs("tex", "1D", True) + generate_fiu_sigs("tex", "1D", True, 2) + generate_fiu_sigs("tex", "2D", True) + generate_fiu_sigs("tex", "2D", True, 1) + generate_fiu_sigs("tex", "3D", True) + print "))" + +with open(path.join(builtins_dir, "130_fs", "textureProj"), 'w') as sys.stdout: + print "((function textureProj" + generate_fiu_sigs("txb", "1D", True) + generate_fiu_sigs("txb", "1D", True, 2) + generate_fiu_sigs("txb", "2D", True) + generate_fiu_sigs("txb", "2D", True, 1) + generate_fiu_sigs("txb", "3D", True) + print "))" + with open(path.join(builtins_dir, "130", "textureLod"), 'w') as sys.stdout: print "((function textureLod" generate_fiu_sigs("txl", "1D") @@ -131,6 +149,15 @@ with open(path.join(builtins_dir, "130", "texelFetch"), 'w') as sys.stdout: generate_fiu_sigs("txf", "2DArray") print "))" +with open(path.join(builtins_dir, "130", "textureProjLod"), 'w') as sys.stdout: + print "((function textureLod" + generate_fiu_sigs("txl", "1D", True) + generate_fiu_sigs("txl", "1D", True, 2) + generate_fiu_sigs("txl", "2D", True) + generate_fiu_sigs("txl", "2D", True, 1) + generate_fiu_sigs("txl", "3D", True) + print "))" + with open(path.join(builtins_dir, "130", "textureGrad"), 'w') as sys.stdout: print "((function textureGrad" generate_fiu_sigs("txd", "1D") @@ -141,6 +168,15 @@ with open(path.join(builtins_dir, "130", "textureGrad"), 'w') as sys.stdout: generate_fiu_sigs("txd", "2DArray") print ")\n)" +with open(path.join(builtins_dir, "130", "textureProjGrad"), 'w') as sys.stdout: + print "((function textureLod" + generate_fiu_sigs("txd", "1D", True) + generate_fiu_sigs("txd", "1D", True, 2) + generate_fiu_sigs("txd", "2D", True) + generate_fiu_sigs("txd", "2D", True, 1) + generate_fiu_sigs("txd", "3D", True) + print "))" + # ARB_texture_rectangle extension with open(path.join(builtins_dir, "ARB_texture_rectangle", "textures"), 'w') as sys.stdout: print "((function texture2DRect" -- cgit v1.2.3 From c34a624c9f50edc73d8ac65e7fd1e50c30d5929e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 8 Jun 2010 15:34:37 -0700 Subject: texture_builtins.py: Fixes for Array variants. The array layer is now included as part of the texture coordinate. --- builtins/tools/texture_builtins.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/builtins/tools/texture_builtins.py b/builtins/tools/texture_builtins.py index 404d7e8d415..d4648a2aee0 100755 --- a/builtins/tools/texture_builtins.py +++ b/builtins/tools/texture_builtins.py @@ -13,20 +13,24 @@ def vec_type(g, size): return g + "vec" + str(size) # Get the base dimension - i.e. sampler3D gives 3 +# Array samplers also get +1 here since the layer is really an extra coordinate def get_coord_dim(sampler_type): if sampler_type[0].isdigit(): - return int(sampler_type[0]) + coord_dim = int(sampler_type[0]) elif sampler_type.startswith("Cube"): - return 3 - assert False ("coord_dim: invalid sampler_type: " + sampler_type) + coord_dim = 3 + else: + assert False ("coord_dim: invalid sampler_type: " + sampler_type) + + if sampler_type.find("Array") != -1: + coord_dim += 1 + return coord_dim # Get the number of extra vector components (i.e. shadow comparitor) def get_extra_dim(sampler_type, use_proj, unused_fields): extra_dim = unused_fields if sampler_type.find("Shadow") != -1: extra_dim += 1 - if sampler_type.find("Array") != -1: - extra_dim += 1 if use_proj: extra_dim += 1 return extra_dim -- cgit v1.2.3 From cc249f79e7df5fa45b119e57cdc9a4887add712b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 8 Jun 2010 16:01:41 -0700 Subject: generate_builtins.pl: Support stage-specific builtins even for extensions. --- builtins/tools/generate_builtins.pl | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/builtins/tools/generate_builtins.pl b/builtins/tools/generate_builtins.pl index 8fdef2d9743..8b640ab8ff9 100755 --- a/builtins/tools/generate_builtins.pl +++ b/builtins/tools/generate_builtins.pl @@ -97,23 +97,26 @@ _mesa_glsl_initialize_functions(exec_list *instructions, { EOF -foreach $version (@versions) { +foreach $version_xs (@versions) { + $check = ""; + if ($version_xs =~ /_vs/) { + $check = "state->target == vertex_shader && "; + } elsif ($version_xs =~ /_fs/) { + $check = "state->target == fragment_shader && "; + } + $version = $version_xs; + $version =~ s/_[vf]s//g; + if ($version =~ /^[1-9][0-9][0-9]/) { - $version_number = $version; - $version_number =~ s/_[vf]s//g; - $check = "state->language_version >= $version_number"; - if ($version =~ /_vs/) { - $check = "$check && state->target == vertex_shader"; - } elsif ($version =~ /_fs/) { - $check = "$check && state->target == fragment_shader"; - } + $check = "${check}state->language_version >= $version"; } else { # Not a version...an extension name - $check = "state->${version}_enable"; + $check = "${check}state->${version}_enable"; } print " if ($check)\n"; - print " read_builtins(state, instructions, functions_for_$version,\n"; - print " sizeof(functions_for_$version) / "; + print " read_builtins(state, instructions,\n"; + print " functions_for_$version_xs,\n"; + print " sizeof(functions_for_$version_xs) / "; print "sizeof(const char *));\n\n" } -- cgit v1.2.3 From 0d80f71867e561c541bf8832a182401297972543 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 8 Jun 2010 16:17:17 -0700 Subject: Add EXT_texture_array support. --- builtin_types.h | 12 ++++++++++++ glsl_parser_extras.h | 2 ++ glsl_types.cpp | 15 +++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/builtin_types.h b/builtin_types.h index 41ce5d21896..48202f56454 100644 --- a/builtin_types.h +++ b/builtin_types.h @@ -244,6 +244,18 @@ static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { }; /*@}*/ +/** \name Sampler types added by GL_EXT_texture_array + */ +/*@{*/ + +static const struct glsl_type builtin_EXT_texture_array_types[] = { + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), + glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), + glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), +}; +/*@}*/ + /** \name Sampler types added by GL_EXT_texture_buffer_object */ /*@{*/ diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 157b9861a31..e1585d2872a 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -74,6 +74,8 @@ struct _mesa_glsl_parse_state { unsigned ARB_draw_buffers_warn:1; unsigned ARB_texture_rectangle_enable:1; unsigned ARB_texture_rectangle_warn:1; + unsigned EXT_texture_array_enable:1; + unsigned EXT_texture_array_warn:1; /*@}*/ }; diff --git a/glsl_types.cpp b/glsl_types.cpp index e1beeefe891..9487819a447 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -90,6 +90,15 @@ generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, bool warn) } +static void +generate_EXT_texture_array_types(glsl_symbol_table *symtab, bool warn) +{ + add_types_to_symbol_table(symtab, builtin_EXT_texture_array_types, + Elements(builtin_EXT_texture_array_types), + warn); +} + + void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) { @@ -112,6 +121,12 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) generate_ARB_texture_rectangle_types(state->symbols, state->ARB_texture_rectangle_warn); } + + if (state->EXT_texture_array_enable && state->language_version < 130) { + // These are already included in 130; don't create twice. + generate_EXT_texture_array_types(state->symbols, + state->EXT_texture_array_warn); + } } -- cgit v1.2.3 From 5e65c1ccaefe8b47bb4df93251aa5a737621af75 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 8 Jun 2010 16:03:46 -0700 Subject: texture_builtins.py: Support the EXT_texture_array extension. --- builtins/tools/texture_builtins.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/builtins/tools/texture_builtins.py b/builtins/tools/texture_builtins.py index d4648a2aee0..be0bc6fc0af 100755 --- a/builtins/tools/texture_builtins.py +++ b/builtins/tools/texture_builtins.py @@ -74,7 +74,9 @@ def generate_sigs(g, tex_inst, sampler_type, use_proj = False, unused_fields = 0 print "1", # Shadow comparitor - if sampler_type.endswith("Shadow"): + if sampler_type == "2DArrayShadow": # a special case: + print "(swiz w (var_ref P))", # ...array layer is z; shadow is w + elif sampler_type.endswith("Shadow"): print "(swiz z (var_ref P))", else: print "()", @@ -189,6 +191,33 @@ with open(path.join(builtins_dir, "ARB_texture_rectangle", "textures"), 'w') as generate_sigs("", "tex", "2DRectShadow") print "))" +# EXT_texture_array extension +with open(path.join(builtins_dir, "EXT_texture_array", "textures"), 'w') as sys.stdout: + print "((function texture1DArray" + generate_sigs("", "tex", "1DArray") + print ")\n (function texture1DArrayLod" + generate_sigs("", "txl", "1DArray") + print ")\n (function texture2DArray" + generate_sigs("", "tex", "2DArray") + print ")\n (function texture2DArrayLod" + generate_sigs("", "txl", "2DArray") + print ")\n (function shadow1DArray" + generate_sigs("", "tex", "1DArrayShadow") + print ")\n (function shadow1DArrayLod" + generate_sigs("", "txl", "1DArrayShadow") + print ")\n (function shadow2DArray" + generate_sigs("", "tex", "2DArrayShadow") + print "))" + +with open(path.join(builtins_dir, "EXT_texture_array_fs", "textures"), 'w') as sys.stdout: + print "((function texture1DArray" + generate_sigs("", "txb", "1DArray") # MOVE TO _fs + print ")\n (function texture2DArray" + generate_sigs("", "txb", "2DArray") # MOVE TO _fs + print ")\n (function shadow1DArray" + generate_sigs("", "txb", "1DArrayShadow") + print "))" + # Deprecated (110/120 style) functions with silly names: with open(path.join(builtins_dir, "110", "textures"), 'w') as sys.stdout: print "((function texture1D" -- cgit v1.2.3 From 4b0029a97d564679becb4bbf243dadb8b8b87c0a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 8 Jun 2010 16:29:17 -0700 Subject: Commit output of texture_builtins.py and refresh builtin_function.cpp. --- builtin_function.cpp | 1635 ++++++++++++++++++++++++++++++- builtins/110/textures | 213 ++++ builtins/110_fs/textures | 113 +++ builtins/130/texelFetch | 107 ++ builtins/130/texture | 110 +++ builtins/130/textureGrad | 147 +++ builtins/130/textureLod | 128 +++ builtins/130/textureProj | 92 ++ builtins/130/textureProjGrad | 122 +++ builtins/130/textureProjLod | 107 ++ builtins/130_fs/texture | 128 +++ builtins/130_fs/textureProj | 107 ++ builtins/ARB_texture_rectangle/textures | 16 + builtins/EXT_texture_array/textures | 59 ++ 14 files changed, 3059 insertions(+), 25 deletions(-) create mode 100644 builtins/110/textures create mode 100644 builtins/110_fs/textures create mode 100644 builtins/130/texelFetch create mode 100644 builtins/130/texture create mode 100644 builtins/130/textureGrad create mode 100644 builtins/130/textureLod create mode 100644 builtins/130/textureProj create mode 100644 builtins/130/textureProjGrad create mode 100644 builtins/130/textureProjLod create mode 100644 builtins/130_fs/texture create mode 100644 builtins/130_fs/textureProj create mode 100644 builtins/ARB_texture_rectangle/textures create mode 100644 builtins/EXT_texture_array/textures diff --git a/builtin_function.cpp b/builtin_function.cpp index 5bb0007e6da..7a6457cc95e 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -43,7 +43,7 @@ read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, } } -/* Version 110 builtins */ +/* 110 builtins */ static const char *builtins_110_abs = { "((function abs\n" @@ -1797,6 +1797,222 @@ static const char *builtins_110_tan = { "))\n" }; +static const char *builtins_110_textures = { + "((function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function texture1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + ")\n" + " (function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + "(function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + ")\n" + " (function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + ")\n" + " (function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" + "\n" + ")\n" + " (function shadow1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + ")\n" + " (function shadow1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" + "\n" + ")\n" + " (function shadow2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + ")\n" + " (function shadow2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" +}; + static const char *functions_for_110 [] = { builtins_110_abs, builtins_110_all, @@ -1838,9 +2054,132 @@ static const char *functions_for_110 [] = { builtins_110_sqrt, builtins_110_step, builtins_110_tan, + builtins_110_textures, +}; + +/* 110_fs builtins */ + +static const char *builtins_110_fs_textures = { + "((function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + ")\n" + " (function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + ")\n" + " (function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + ")\n" + " (function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" }; -/* Version 110_vs builtins */ +static const char *functions_for_110_fs [] = { + builtins_110_fs_textures, +}; + +/* 110_vs builtins */ static const char *builtins_110_vs_ftransform = { "((function ftransform\n" @@ -1856,7 +2195,7 @@ static const char *functions_for_110_vs [] = { builtins_110_vs_ftransform, }; -/* Version 130 builtins */ +/* 130 builtins */ static const char *builtins_130_equal = { "((function equal\n" @@ -2099,30 +2438,1276 @@ static const char *builtins_130_sign = { "\n" }; -static const char *functions_for_130 [] = { - builtins_130_equal, - builtins_130_greaterThan, - builtins_130_greaterThanEqual, - builtins_130_lessThan, - builtins_130_lessThanEqual, - builtins_130_notEqual, - builtins_130_sign, +static const char *builtins_130_texelFetch = { + "((function texelFetch\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + "))\n" }; -void -_mesa_glsl_initialize_functions(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (state->language_version >= 110) - read_builtins(state, instructions, functions_for_110, - sizeof(functions_for_110) / sizeof(const char *)); - - if (state->language_version >= 110 && state->target == vertex_shader) - read_builtins(state, instructions, functions_for_110_vs, - sizeof(functions_for_110_vs) / sizeof(const char *)); +static const char *builtins_130_texture = { + "((function texture\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + "))\n" +}; - if (state->language_version >= 130) - read_builtins(state, instructions, functions_for_130, - sizeof(functions_for_130) / sizeof(const char *)); +static const char *builtins_130_textureGrad = { + "((function textureGrad\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + ")\n" + ")\n" +}; + +static const char *builtins_130_textureLod = { + "((function textureLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + "))\n" +}; + +static const char *builtins_130_textureProj = { + "((function textureProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + "))\n" +}; + +static const char *builtins_130_textureProjGrad = { + "((function textureLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" +}; + +static const char *builtins_130_textureProjLod = { + "((function textureLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_130 [] = { + builtins_130_equal, + builtins_130_greaterThan, + builtins_130_greaterThanEqual, + builtins_130_lessThan, + builtins_130_lessThanEqual, + builtins_130_notEqual, + builtins_130_sign, + builtins_130_texelFetch, + builtins_130_texture, + builtins_130_textureGrad, + builtins_130_textureLod, + builtins_130_textureProj, + builtins_130_textureProjGrad, + builtins_130_textureProjLod, +}; + +/* 130_fs builtins */ + +static const char *builtins_130_fs_texture = { + "((function texture\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + "))\n" +}; + +static const char *builtins_130_fs_textureProj = { + "((function textureProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_130_fs [] = { + builtins_130_fs_texture, + builtins_130_fs_textureProj, +}; + +/* ARB_texture_rectangle builtins */ + +static const char *builtins_ARB_texture_rectangle_textures = { + "((function texture2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function shadow2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_ARB_texture_rectangle [] = { + builtins_ARB_texture_rectangle_textures, +}; + +/* EXT_texture_array builtins */ + +static const char *builtins_EXT_texture_array_textures = { + "((function texture1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function texture1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function texture2DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" + "\n" + ")\n" + " (function shadow1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArrayShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) 1 (swiz w (var_ref P)) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_EXT_texture_array [] = { + builtins_EXT_texture_array_textures, +}; + +/* EXT_texture_array_fs builtins */ + +static const char *builtins_EXT_texture_array_fs_textures = { + "((function texture1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function shadow1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_EXT_texture_array_fs [] = { + builtins_EXT_texture_array_fs_textures, +}; + +void +_mesa_glsl_initialize_functions(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + if (state->language_version >= 110) + read_builtins(state, instructions, + functions_for_110, + sizeof(functions_for_110) / sizeof(const char *)); + + if (state->target == fragment_shader && state->language_version >= 110) + read_builtins(state, instructions, + functions_for_110_fs, + sizeof(functions_for_110_fs) / sizeof(const char *)); + + if (state->target == vertex_shader && state->language_version >= 110) + read_builtins(state, instructions, + functions_for_110_vs, + sizeof(functions_for_110_vs) / sizeof(const char *)); + + if (state->language_version >= 130) + read_builtins(state, instructions, + functions_for_130, + sizeof(functions_for_130) / sizeof(const char *)); + + if (state->target == fragment_shader && state->language_version >= 130) + read_builtins(state, instructions, + functions_for_130_fs, + sizeof(functions_for_130_fs) / sizeof(const char *)); + + if (state->ARB_texture_rectangle_enable) + read_builtins(state, instructions, + functions_for_ARB_texture_rectangle, + sizeof(functions_for_ARB_texture_rectangle) / sizeof(const char *)); + + if (state->EXT_texture_array_enable) + read_builtins(state, instructions, + functions_for_EXT_texture_array, + sizeof(functions_for_EXT_texture_array) / sizeof(const char *)); + + if (state->target == fragment_shader && state->EXT_texture_array_enable) + read_builtins(state, instructions, + functions_for_EXT_texture_array_fs, + sizeof(functions_for_EXT_texture_array_fs) / sizeof(const char *)); } diff --git a/builtins/110/textures b/builtins/110/textures new file mode 100644 index 00000000000..c81b7e8ad49 --- /dev/null +++ b/builtins/110/textures @@ -0,0 +1,213 @@ +((function texture1D + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function texture1DLod + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function texture1DProj + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + +) + (function texture1DProjLod + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + +) + (function texture2D + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) +(function texture2DLod + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function texture2DProj + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + +) + (function texture2DProjLod + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + +) + (function texture3D + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function texture3DLod + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function texture3DProj + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + +) + (function texture3DProjLod + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + +) + (function textureCube + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function textureCubeLod + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function shadow1D + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) + +) + (function shadow1DLod + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) + +) + (function shadow1DProj + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) )))) + +) + (function shadow1DProjLod + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) )))) + +) + (function shadow2D + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) + +) + (function shadow2DLod + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) + +) + (function shadow2DProj + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) )))) + +) + (function shadow2DProjLod + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) )))) + +)) diff --git a/builtins/110_fs/textures b/builtins/110_fs/textures new file mode 100644 index 00000000000..38f3787e9ef --- /dev/null +++ b/builtins/110_fs/textures @@ -0,0 +1,113 @@ +((function texture1D + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function texture1DProj + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + +) + (function texture2D + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function texture2DProj + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + +) + (function texture3D + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function texture3DProj + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + +) + (function textureCube + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function shadow1D + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) + +) + (function shadow1DProj + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) )))) + +) + (function shadow2D + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) + +) + (function shadow2DProj + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) )))) + +)) diff --git a/builtins/130/texelFetch b/builtins/130/texelFetch new file mode 100644 index 00000000000..d51ce65a897 --- /dev/null +++ b/builtins/130/texelFetch @@ -0,0 +1,107 @@ +((function texelFetch + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) int P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) int P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) int P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1DArray sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1DArray sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2DArray sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2DArray sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + +)) diff --git a/builtins/130/texture b/builtins/130/texture new file mode 100644 index 00000000000..b170b583094 --- /dev/null +++ b/builtins/130/texture @@ -0,0 +1,110 @@ +((function texture + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) float P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) float P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isamplerCube sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usamplerCube sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isampler1DArray sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usampler1DArray sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isampler2DArray sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usampler2DArray sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +)) diff --git a/builtins/130/textureGrad b/builtins/130/textureGrad new file mode 100644 index 00000000000..0ef428c224a --- /dev/null +++ b/builtins/130/textureGrad @@ -0,0 +1,147 @@ +((function textureGrad + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) float P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) float P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isamplerCube sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usamplerCube sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + +) +) diff --git a/builtins/130/textureLod b/builtins/130/textureLod new file mode 100644 index 00000000000..7d7059d848c --- /dev/null +++ b/builtins/130/textureLod @@ -0,0 +1,128 @@ +((function textureLod + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) float P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) float P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isamplerCube sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usamplerCube sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +)) diff --git a/builtins/130/textureProj b/builtins/130/textureProj new file mode 100644 index 00000000000..40ea1c2af68 --- /dev/null +++ b/builtins/130/textureProj @@ -0,0 +1,92 @@ +((function textureProj + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + +)) diff --git a/builtins/130/textureProjGrad b/builtins/130/textureProjGrad new file mode 100644 index 00000000000..a0142c5e683 --- /dev/null +++ b/builtins/130/textureProjGrad @@ -0,0 +1,122 @@ +((function textureLod + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec2 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec2 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec4 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec4 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec3 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec3 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec4 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec4 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec4 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec4 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + +)) diff --git a/builtins/130/textureProjLod b/builtins/130/textureProjLod new file mode 100644 index 00000000000..9f4ce1b493d --- /dev/null +++ b/builtins/130/textureProjLod @@ -0,0 +1,107 @@ +((function textureLod + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + +)) diff --git a/builtins/130_fs/texture b/builtins/130_fs/texture new file mode 100644 index 00000000000..0de981397f0 --- /dev/null +++ b/builtins/130_fs/texture @@ -0,0 +1,128 @@ +((function texture + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) float P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) float P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isamplerCube sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usamplerCube sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +)) diff --git a/builtins/130_fs/textureProj b/builtins/130_fs/textureProj new file mode 100644 index 00000000000..b1d8f0a2f33 --- /dev/null +++ b/builtins/130_fs/textureProj @@ -0,0 +1,107 @@ +((function textureProj + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + +)) diff --git a/builtins/ARB_texture_rectangle/textures b/builtins/ARB_texture_rectangle/textures new file mode 100644 index 00000000000..161d8c4a541 --- /dev/null +++ b/builtins/ARB_texture_rectangle/textures @@ -0,0 +1,16 @@ +((function texture2DRect + (signature vec4 + (parameters + (declare (in) sampler2DRect sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function shadow2DRect + (signature vec4 + (parameters + (declare (in) sampler2DRectShadow sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) + +)) diff --git a/builtins/EXT_texture_array/textures b/builtins/EXT_texture_array/textures new file mode 100644 index 00000000000..8a91f901401 --- /dev/null +++ b/builtins/EXT_texture_array/textures @@ -0,0 +1,59 @@ +((function texture1DArray + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function texture1DArrayLod + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function texture2DArray + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function texture2DArrayLod + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function shadow1DArray + (signature vec4 + (parameters + (declare (in) sampler1DArrayShadow sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) + +) + (function shadow1DArrayLod + (signature vec4 + (parameters + (declare (in) sampler1DArrayShadow sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) + +) + (function shadow2DArray + (signature vec4 + (parameters + (declare (in) sampler2DArrayShadow sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) 1 (swiz w (var_ref P)) )))) + +)) -- cgit v1.2.3 From 57503a22d767c146862b5e2ac0e07f8a8f5193df Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 8 Jun 2010 22:33:43 -0700 Subject: Only initialize types after #extension directives have been processed. Since _mesa_glsl_initialize_types add types for various extensions, we can't call it until after processing "#extension foo : disable" lines. Fixes tex_rect_02.frag. --- glsl_parser.ypp | 16 +++++++--------- glsl_parser_extras.cpp | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/glsl_parser.ypp b/glsl_parser.ypp index 99c6ca132c7..ae009ed20cb 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -186,21 +186,19 @@ %% translation_unit: - version_statement + version_statement extension_statement_list { _mesa_glsl_initialize_types(state); } - extension_statement_list external_declaration_list - | - { - state->language_version = 110; - _mesa_glsl_initialize_types(state); - } - extension_statement_list external_declaration_list + external_declaration_list ; version_statement: - VERSION INTCONSTANT EOL + /* blank - no #version specified */ + { + state->language_version = 110; + } + | VERSION INTCONSTANT EOL { switch ($2) { case 110: diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index f6b30289ce3..3c895946be5 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -737,7 +737,7 @@ main(int argc, char **argv) ast->print(); } - if (!state.translation_unit.is_empty()) + if (!state.error && !state.translation_unit.is_empty()) _mesa_ast_to_hir(&instructions, &state); } else { /* FINISHME: We should initialize this to the max GLSL version supported -- cgit v1.2.3 From 8331d489487268cafb3248a598e409bff6b1b123 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 8 Jun 2010 22:41:30 -0700 Subject: Don't call _mesa_glsl_initialize_types for every builtin function. This was clearly wrong; types are now only initialized once. --- glsl_parser_extras.cpp | 1 + ir_reader.cpp | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 3c895946be5..5ebbc27aca8 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -744,6 +744,7 @@ main(int argc, char **argv) * FINISHME: by the driver. At the moment, we don't know what that is. */ state.language_version = 130; + _mesa_glsl_initialize_types(&state); _mesa_glsl_read_ir(&state, &instructions, shader); } diff --git a/ir_reader.cpp b/ir_reader.cpp index 0a2d18e2e01..f05682640fd 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -71,13 +71,6 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, return; } - _mesa_glsl_initialize_types(state); - - /* FINISHME: Constructors probably shouldn't be emitted as part of the IR. - * FINISHME: Once they're not, remake them by calling: - * FINISHME: _mesa_glsl_initialize_constructors(instructions, state); - */ - scan_for_prototypes(state, instructions, expr); if (state->error) return; -- cgit v1.2.3 From b97efa5db5fce2e0d9a4c61a939c85b240c89170 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 11:07:53 -0700 Subject: ir_function_cloning_visitor: Add support for ir_texture. --- ir.h | 2 +- ir_function_inlining.cpp | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ir.h b/ir.h index 33ce4a04c36..78ea196ffbc 100644 --- a/ir.h +++ b/ir.h @@ -770,7 +770,7 @@ enum ir_texture_opcode { class ir_texture : public ir_rvalue { public: ir_texture(enum ir_texture_opcode op) - : op(op) + : op(op), projector(NULL), shadow_comparitor(NULL) { /* empty */ } diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index d66eceedb86..a501c813fb8 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -201,8 +201,28 @@ ir_function_cloning_visitor::visit(ir_expression *ir) void ir_function_cloning_visitor::visit(ir_texture *ir) { - // FINISHME: Do stuff with texture lookups - (void) ir; + ir_texture *tex = new ir_texture(ir->op); + + ir->sampler->accept(this); + tex->set_sampler(this->result->as_dereference()); + + ir->coordinate->accept(this); + tex->coordinate = this->result->as_rvalue(); + + if (ir->projector != NULL) { + ir->projector->accept(this); + tex->projector = this->result->as_rvalue(); + } + + if (ir->shadow_comparitor != NULL) { + ir->shadow_comparitor->accept(this); + tex->shadow_comparitor = this->result->as_rvalue(); + } + + for (int i = 0; i < 3; i++) + tex->offsets[i] = ir->offsets[i]; + + tex->lod_info = ir->lod_info; } -- cgit v1.2.3 From 2438f64e6332fb0a5f80926f73bf3291bb3bc3ea Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 12:58:42 -0700 Subject: Add remaining signatures for 'mod' builtin. --- builtin_function.cpp | 39 +++++++++++++++++++++++++++++++++++++++ builtins/110/mod | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/builtin_function.cpp b/builtin_function.cpp index 7a6457cc95e..865f58c7557 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1167,6 +1167,45 @@ static const char *builtins_110_mod = { " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1))\n" " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float % (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float % (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression float % (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" "))\n" }; diff --git a/builtins/110/mod b/builtins/110/mod index 121db4fd08e..9e08bbc7ef4 100644 --- a/builtins/110/mod +++ b/builtins/110/mod @@ -22,4 +22,43 @@ (declare (in) vec4 arg0) (declare (in) vec4 arg1)) ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((declare () vec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((declare () vec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float % (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((declare () vec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float % (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression float % (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) )) -- cgit v1.2.3 From 47d44c877e26c78ebdb34529d98d643a04261053 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 13:03:18 -0700 Subject: Add remaining signatures for 'min' builtin. --- builtin_function.cpp | 39 +++++++++++++++++++++++++++++++++++++++ builtins/110/min | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/builtin_function.cpp b/builtin_function.cpp index 865f58c7557..9cc70ee1a75 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1086,6 +1086,45 @@ static const char *builtins_110_min = { " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1))\n" " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression float min (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" "))\n" }; diff --git a/builtins/110/min b/builtins/110/min index f9820ef8286..31e79489405 100644 --- a/builtins/110/min +++ b/builtins/110/min @@ -22,4 +22,43 @@ (declare (in) vec4 arg0) (declare (in) vec4 arg1)) ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((declare () vec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((declare () vec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float min (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((declare () vec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float min (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression float min (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) )) -- cgit v1.2.3 From 76796ed66f2a86f3fe88d90291196c05a9ae6533 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 13:05:40 -0700 Subject: Add remaining signatures for 'max' builtin. --- builtin_function.cpp | 39 +++++++++++++++++++++++++++++++++++++++ builtins/110/max | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/builtin_function.cpp b/builtin_function.cpp index 9cc70ee1a75..d61c2bde56f 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1058,6 +1058,45 @@ static const char *builtins_110_max = { " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1))\n" " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + " \n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression float max (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" "))\n" }; diff --git a/builtins/110/max b/builtins/110/max index 0dc3ffb5e41..c05545f3d93 100644 --- a/builtins/110/max +++ b/builtins/110/max @@ -22,4 +22,43 @@ (declare (in) vec4 arg0) (declare (in) vec4 arg1)) ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((declare () vec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((declare () vec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float max (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((declare () vec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float max (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression float max (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) )) -- cgit v1.2.3 From cdf1726ffdb3fcb8f536f24ee926941cd5043268 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 13:10:00 -0700 Subject: Add remaining signatures for 'clamp' builtin. --- builtin_function.cpp | 35 ++++++++++++++++++++++++++++++++++- builtins/110/clamp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index d61c2bde56f..2bfc17115fc 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -409,6 +409,39 @@ static const char *builtins_110_clamp = { " (declare (in) vec4 arg1)\n" " (declare (in) vec4 arg2))\n" " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((declare () vec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((declare () vec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((declare () vec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result)) (expression vec4 max (expression vec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" "))\n" }; @@ -1082,7 +1115,7 @@ static const char *builtins_110_max = { " (assign (constant bool (1)) (swiz z (var_ref result))\n" " (expression float max (swiz z (var_ref arg0)) (var_ref arg1)))\n" " (return (var_ref result))))\n" - " \n" + "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 arg0)\n" diff --git a/builtins/110/clamp b/builtins/110/clamp index 1ae44db46ca..94c8e5ed168 100644 --- a/builtins/110/clamp +++ b/builtins/110/clamp @@ -26,4 +26,37 @@ (declare (in) vec4 arg1) (declare (in) vec4 arg2)) ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((declare () vec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((declare () vec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((declare () vec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) (expression vec4 max (expression vec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) )) -- cgit v1.2.3 From 29b22287fe18afe5b2c55878a59046edad544089 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 13:17:00 -0700 Subject: Implement 'distance' builtin. --- builtin_function.cpp | 37 +++++++++++++++++++++++++++++++++++++ builtins/110/distance | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 builtins/110/distance diff --git a/builtin_function.cpp b/builtin_function.cpp index 2bfc17115fc..bdcf891d851 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -513,6 +513,42 @@ static const char *builtins_110_degrees = { "))\n" }; +static const char *builtins_110_distance = { + "((function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p0)\n" + " (declare (in) float p1))\n" + " ((declare () float p)\n" + " (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 p0)\n" + " (declare (in) vec2 p1))\n" + " ((declare () vec2 p)\n" + " (assign (constant bool (1)) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 p0)\n" + " (declare (in) vec3 p1))\n" + " ((declare () vec3 p)\n" + " (assign (constant bool (1)) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 p0)\n" + " (declare (in) vec4 p1))\n" + " ((declare () vec4 p)\n" + " (assign (constant bool (1)) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "))\n" +}; + static const char *builtins_110_dot = { "((function dot\n" " (signature float\n" @@ -2174,6 +2210,7 @@ static const char *functions_for_110 [] = { builtins_110_cos, builtins_110_cross, builtins_110_degrees, + builtins_110_distance, builtins_110_dot, builtins_110_equal, builtins_110_exp, diff --git a/builtins/110/distance b/builtins/110/distance new file mode 100644 index 00000000000..a2309c484f9 --- /dev/null +++ b/builtins/110/distance @@ -0,0 +1,33 @@ +((function distance + (signature float + (parameters + (declare (in) float p0) + (declare (in) float p1)) + ((declare () float p) + (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1))) + (return (expression float sqrt (expression float dot (var_ref p) (var_ref p)))))) + + (signature float + (parameters + (declare (in) vec2 p0) + (declare (in) vec2 p1)) + ((declare () vec2 p) + (assign (constant bool (1)) (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 + (parameters + (declare (in) vec3 p0) + (declare (in) vec3 p1)) + ((declare () vec3 p) + (assign (constant bool (1)) (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 + (parameters + (declare (in) vec4 p0) + (declare (in) vec4 p1)) + ((declare () vec4 p) + (assign (constant bool (1)) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1))) + (return (expression float sqrt (expression float dot (var_ref p) (var_ref p)))))) +)) -- cgit v1.2.3 From 539f29323f16717da25502f7b0e2846289ef1399 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 13:27:16 -0700 Subject: Implement 'faceforward' builtin. --- builtin_function.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ builtins/110/faceforward | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 builtins/110/faceforward diff --git a/builtin_function.cpp b/builtin_function.cpp index bdcf891d851..754a721c7e7 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -689,6 +689,46 @@ static const char *builtins_110_exp2 = { "))\n" }; +static const char *builtins_110_faceforward = { + "((function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float N)\n" + " (declare (in) float I)\n" + " (declare (in) float Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression float neg (var_ref N)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 N)\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec2 neg (var_ref N)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 N)\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec3 neg (var_ref N)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 N)\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec4 neg (var_ref N)))))))\n" + "))\n" +}; + static const char *builtins_110_floor = { "((function floor\n" " (signature float\n" @@ -2215,6 +2255,7 @@ static const char *functions_for_110 [] = { builtins_110_equal, builtins_110_exp, builtins_110_exp2, + builtins_110_faceforward, builtins_110_floor, builtins_110_fract, builtins_110_greaterThan, diff --git a/builtins/110/faceforward b/builtins/110/faceforward new file mode 100644 index 00000000000..d1703972388 --- /dev/null +++ b/builtins/110/faceforward @@ -0,0 +1,37 @@ +((function faceforward + (signature float + (parameters + (declare (in) float N) + (declare (in) float I) + (declare (in) float Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression float neg (var_ref N))))))) + + (signature vec2 + (parameters + (declare (in) vec2 N) + (declare (in) vec2 I) + (declare (in) vec2 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec2 neg (var_ref N))))))) + + (signature vec3 + (parameters + (declare (in) vec3 N) + (declare (in) vec3 I) + (declare (in) vec3 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec3 neg (var_ref N))))))) + + (signature vec4 + (parameters + (declare (in) vec4 N) + (declare (in) vec4 I) + (declare (in) vec4 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec4 neg (var_ref N))))))) +)) -- cgit v1.2.3 From 855fcb22c1536a2c2b03c88bffa60eb7cc40ff0a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 13:52:32 -0700 Subject: Implement 'acos' builtin. This is tacked on to the end of the 'asin' file because acos calls asin, whech means asin needs to be defined first. Alphabetical order fail. --- builtin_function.cpp | 23 +++++++++++++++++++++++ builtins/110/asin | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/builtin_function.cpp b/builtin_function.cpp index 754a721c7e7..083fd314c75 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -196,6 +196,29 @@ static const char *builtins_110_asin = { " (expression vec4 *\n" " (constant float (0.0742610))\n" " (expression vec4 abs (var_ref x))))))))))\n" + ")\n" + "\n" + " (function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" "))\n" }; diff --git a/builtins/110/asin b/builtins/110/asin index 0c913b6ae7c..5e1d16719fc 100644 --- a/builtins/110/asin +++ b/builtins/110/asin @@ -86,4 +86,27 @@ (expression vec4 * (constant float (0.0742610)) (expression vec4 abs (var_ref x)))))))))) +) + + (function acos + (signature float + (parameters + (declare (in) float x)) + ((return (expression float - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) )) -- cgit v1.2.3 From c476ba8fe26c499d4cdbc686e45ffe548fe65cd8 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 14:06:56 -0700 Subject: Add a completely bogus implementation of the noise[1234] builtins. idr suggested this. Eventually we will need a real one. --- builtin_function.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ builtins/110/noise_fake | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 builtins/110/noise_fake diff --git a/builtin_function.cpp b/builtin_function.cpp index 083fd314c75..bc0409035a0 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1419,6 +1419,85 @@ static const char *builtins_110_mod = { "))\n" }; +static const char *builtins_110_noise_fake = { + "((function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (constant float (0)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (constant float (0)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant float (0)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant float (0)))))\n" + " )\n" + "\n" + " (function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (constant vec2 (0 0)))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (constant vec2 (0 0)))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant vec2 (0 0)))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant vec2 (0 0)))))\n" + " )\n" + "\n" + " (function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " )\n" + "\n" + " (function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + " )\n" + ")\n" +}; + static const char *builtins_110_normalize = { "((function normalize\n" " (signature float\n" @@ -2293,6 +2372,7 @@ static const char *functions_for_110 [] = { builtins_110_min, builtins_110_mix, builtins_110_mod, + builtins_110_noise_fake, builtins_110_normalize, builtins_110_not, builtins_110_notEqual, diff --git a/builtins/110/noise_fake b/builtins/110/noise_fake new file mode 100644 index 00000000000..bcfb17b04b8 --- /dev/null +++ b/builtins/110/noise_fake @@ -0,0 +1,76 @@ +((function noise1 + (signature float + (parameters + (declare (in) float x)) + ((return (constant float (0))))) + (signature float + (parameters + (declare (in) vec2 x)) + ((return (constant float (0))))) + (signature float + (parameters + (declare (in) vec3 x)) + ((return (constant float (0))))) + (signature float + (parameters + (declare (in) vec4 x)) + ((return (constant float (0))))) + ) + + (function noise2 + (signature vec2 + (parameters + (declare (in) float x)) + ((return (constant vec2 (0 0))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (constant vec2 (0 0))))) + (signature vec2 + (parameters + (declare (in) vec3 x)) + ((return (constant vec2 (0 0))))) + (signature vec2 + (parameters + (declare (in) vec4 x)) + ((return (constant vec2 (0 0))))) + ) + + (function noise3 + (signature vec3 + (parameters + (declare (in) float x)) + ((return (constant vec3 (0 0 0))))) + (signature vec3 + (parameters + (declare (in) vec2 x)) + ((return (constant vec3 (0 0 0))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (constant vec3 (0 0 0))))) + (signature vec3 + (parameters + (declare (in) vec4 x)) + ((return (constant vec3 (0 0 0))))) + ) + + (function noise4 + (signature vec4 + (parameters + (declare (in) float x)) + ((return (constant vec4 (0 0 0 0))))) + (signature vec4 + (parameters + (declare (in) vec2 x)) + ((return (constant vec4 (0 0 0 0))))) + (signature vec4 + (parameters + (declare (in) vec3 x)) + ((return (constant vec4 (0 0 0 0))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (constant vec4 (0 0 0 0))))) + ) +) -- cgit v1.2.3 From 3ffedf12496d17d0bcfab847293053222e996ff8 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 14:15:04 -0700 Subject: Fix some typing issues in asin. CorrectFunction.vert now passes. --- builtin_function.cpp | 14 +++++++------- builtins/110/asin | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/builtin_function.cpp b/builtin_function.cpp index bc0409035a0..c75805c782a 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -131,12 +131,12 @@ static const char *builtins_110_asin = { " (constant float (0.0742610))\n" " (expression float abs (var_ref x))))))))))\n" "\n" - " (signature float\n" + " (signature vec2\n" " (parameters\n" " (declare (in) vec2 x))\n" " ((return (expression vec2 *\n" - " (expression vec2 -\n" - " (expression vec2 *\n" + " (expression float -\n" + " (expression float *\n" " (constant float (3.1415926))\n" " (constant float (0.5)))\n" " (expression vec2 sqrt\n" @@ -153,12 +153,12 @@ static const char *builtins_110_asin = { " (constant float (0.0742610))\n" " (expression vec2 abs (var_ref x))))))))))\n" "\n" - " (signature float\n" + " (signature vec3\n" " (parameters\n" " (declare (in) vec3 x))\n" " ((return (expression vec3 *\n" " (expression vec3 -\n" - " (expression vec3 *\n" + " (expression float *\n" " (constant float (3.1415926))\n" " (constant float (0.5)))\n" " (expression vec3 sqrt\n" @@ -175,12 +175,12 @@ static const char *builtins_110_asin = { " (constant float (0.0742610))\n" " (expression vec3 abs (var_ref x))))))))))\n" "\n" - " (signature float\n" + " (signature vec4\n" " (parameters\n" " (declare (in) vec4 x))\n" " ((return (expression vec4 *\n" " (expression vec4 -\n" - " (expression vec4 *\n" + " (expression float *\n" " (constant float (3.1415926))\n" " (constant float (0.5)))\n" " (expression vec4 sqrt\n" diff --git a/builtins/110/asin b/builtins/110/asin index 5e1d16719fc..fe93337bffc 100644 --- a/builtins/110/asin +++ b/builtins/110/asin @@ -21,12 +21,12 @@ (constant float (0.0742610)) (expression float abs (var_ref x)))))))))) - (signature float + (signature vec2 (parameters (declare (in) vec2 x)) ((return (expression vec2 * - (expression vec2 - - (expression vec2 * + (expression float - + (expression float * (constant float (3.1415926)) (constant float (0.5))) (expression vec2 sqrt @@ -43,12 +43,12 @@ (constant float (0.0742610)) (expression vec2 abs (var_ref x)))))))))) - (signature float + (signature vec3 (parameters (declare (in) vec3 x)) ((return (expression vec3 * (expression vec3 - - (expression vec3 * + (expression float * (constant float (3.1415926)) (constant float (0.5))) (expression vec3 sqrt @@ -65,12 +65,12 @@ (constant float (0.0742610)) (expression vec3 abs (var_ref x)))))))))) - (signature float + (signature vec4 (parameters (declare (in) vec4 x)) ((return (expression vec4 * (expression vec4 - - (expression vec4 * + (expression float * (constant float (3.1415926)) (constant float (0.5))) (expression vec4 sqrt -- cgit v1.2.3 From cbd881da3fd2a68272988cf7fd21dfe006d47c8c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 14:30:52 -0700 Subject: Implement 'refract' builtin. --- builtin_function.cpp | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ builtins/110/refract | 102 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 builtins/110/refract diff --git a/builtin_function.cpp b/builtin_function.cpp index c75805c782a..377fd509551 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1718,6 +1718,111 @@ static const char *builtins_110_reflect = { "))\n" }; +static const char *builtins_110_refract = { + "((function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float i)\n" + " (declare (in) float n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant float (0.0))))\n" + " ((return (expression float -\n" + " (expression float * (var_ref eta) (var_ref i))\n" + " (expression float *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 i)\n" + " (declare (in) vec2 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec2 (0.0 0.0))))\n" + " ((return (expression vec2 -\n" + " (expression vec2 * (var_ref eta) (var_ref i))\n" + " (expression vec2 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 i)\n" + " (declare (in) vec3 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec3 (0.0 0.0))))\n" + " ((return (expression vec3 -\n" + " (expression vec3 * (var_ref eta) (var_ref i))\n" + " (expression vec3 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 i)\n" + " (declare (in) vec4 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec4 (0.0 0.0))))\n" + " ((return (expression vec4 -\n" + " (expression vec4 * (var_ref eta) (var_ref i))\n" + " (expression vec4 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + "))\n" +}; + static const char *builtins_110_sign = { "((function sign\n" " (signature float\n" @@ -2379,6 +2484,7 @@ static const char *functions_for_110 [] = { builtins_110_pow, builtins_110_radians, builtins_110_reflect, + builtins_110_refract, builtins_110_sign, builtins_110_sin, builtins_110_smoothstep, diff --git a/builtins/110/refract b/builtins/110/refract new file mode 100644 index 00000000000..e9b1475294a --- /dev/null +++ b/builtins/110/refract @@ -0,0 +1,102 @@ +((function refract + (signature float + (parameters + (declare (in) float i) + (declare (in) float n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant float (0.0)))) + ((return (expression float - + (expression float * (var_ref eta) (var_ref i)) + (expression float * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec2 + (parameters + (declare (in) vec2 i) + (declare (in) vec2 n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec2 (0.0 0.0)))) + ((return (expression vec2 - + (expression vec2 * (var_ref eta) (var_ref i)) + (expression vec2 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec3 + (parameters + (declare (in) vec3 i) + (declare (in) vec3 n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec3 (0.0 0.0)))) + ((return (expression vec3 - + (expression vec3 * (var_ref eta) (var_ref i)) + (expression vec3 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec4 + (parameters + (declare (in) vec4 i) + (declare (in) vec4 n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec4 (0.0 0.0)))) + ((return (expression vec4 - + (expression vec4 * (var_ref eta) (var_ref i)) + (expression vec4 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + +)) -- cgit v1.2.3 From b843c7a20c2d65494f30eb82622ae7db380f581a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 14:42:41 -0700 Subject: Implement dFdx, dFdy, and fwidth via new expression opcodes. --- builtin_function.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++ builtins/110_fs/derivatives | 73 ++++++++++++++++++++++++++++++++++++++++++ ir.cpp | 5 +++ ir.h | 8 +++++ 4 files changed, 163 insertions(+) create mode 100644 builtins/110_fs/derivatives diff --git a/builtin_function.cpp b/builtin_function.cpp index 377fd509551..4ee43df5dc2 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -2496,6 +2496,82 @@ static const char *functions_for_110 [] = { /* 110_fs builtins */ +static const char *builtins_110_fs_derivatives = { + "((function dFdx\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ((return (expression float dFdx (var_ref p)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 dFdx (var_ref p)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 dFdx (var_ref p)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 dFdx (var_ref p)))))\n" + " )\n" + "\n" + " (function dFdy\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ((return (expression float dFdy (var_ref p)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 dFdy (var_ref p)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 dFdy (var_ref p)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 dFdy (var_ref p)))))\n" + " )\n" + "\n" + " (function fwidth\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ((return (expression float +\n" + " (expression float abs (expression float dFdx (var_ref p)))\n" + " (expression float abs (expression float dFdy (var_ref p)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 +\n" + " (expression vec2 abs (expression vec2 dFdx (var_ref p)))\n" + " (expression vec2 abs (expression vec2 dFdy (var_ref p)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 +\n" + " (expression vec3 abs (expression vec3 dFdx (var_ref p)))\n" + " (expression vec3 abs (expression vec3 dFdy (var_ref p)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 +\n" + " (expression vec4 abs (expression vec4 dFdx (var_ref p)))\n" + " (expression vec4 abs (expression vec4 dFdy (var_ref p)))))))\n" + "))\n" +}; + static const char *builtins_110_fs_textures = { "((function texture1D\n" " (signature vec4\n" @@ -2613,6 +2689,7 @@ static const char *builtins_110_fs_textures = { }; static const char *functions_for_110_fs [] = { + builtins_110_fs_derivatives, builtins_110_fs_textures, }; diff --git a/builtins/110_fs/derivatives b/builtins/110_fs/derivatives new file mode 100644 index 00000000000..b79852ee1ff --- /dev/null +++ b/builtins/110_fs/derivatives @@ -0,0 +1,73 @@ +((function dFdx + (signature float + (parameters + (declare (in) float p)) + ((return (expression float dFdx (var_ref p))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 dFdx (var_ref p))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 dFdx (var_ref p))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 dFdx (var_ref p))))) + ) + + (function dFdy + (signature float + (parameters + (declare (in) float p)) + ((return (expression float dFdy (var_ref p))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 dFdy (var_ref p))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 dFdy (var_ref p))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 dFdy (var_ref p))))) + ) + + (function fwidth + (signature float + (parameters + (declare (in) float p)) + ((return (expression float + + (expression float abs (expression float dFdx (var_ref p))) + (expression float abs (expression float dFdy (var_ref p))))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 + + (expression vec2 abs (expression vec2 dFdx (var_ref p))) + (expression vec2 abs (expression vec2 dFdy (var_ref p))))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 + + (expression vec3 abs (expression vec3 dFdx (var_ref p))) + (expression vec3 abs (expression vec3 dFdy (var_ref p))))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 + + (expression vec4 abs (expression vec4 dFdx (var_ref p))) + (expression vec4 abs (expression vec4 dFdy (var_ref p))))))) +)) diff --git a/ir.cpp b/ir.cpp index ca34c247192..c5eb94d2d50 100644 --- a/ir.cpp +++ b/ir.cpp @@ -76,6 +76,9 @@ ir_expression::get_num_operands(ir_expression_operation op) 1, /* ir_unop_sin */ 1, /* ir_unop_cos */ + 1, /* ir_unop_dFdx */ + 1, /* ir_unop_dFdy */ + 2, /* ir_binop_add */ 2, /* ir_binop_sub */ 2, /* ir_binop_mul */ @@ -136,6 +139,8 @@ static const char *const operator_strs[] = { "floor", "sin", "cos", + "dFdx", + "dFdy", "+", "-", "*", diff --git a/ir.h b/ir.h index 78ea196ffbc..ea4f5494689 100644 --- a/ir.h +++ b/ir.h @@ -494,6 +494,14 @@ enum ir_expression_operation { ir_unop_cos, /*@}*/ + /** + * \name Partial derivatives. + */ + /*@{*/ + ir_unop_dFdx, + ir_unop_dFdy, + /*@}*/ + ir_binop_add, ir_binop_sub, ir_binop_mul, -- cgit v1.2.3 From d6a32d4b5450d76046428fd3f93a4feb0d14b5e6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 15:22:35 -0700 Subject: ir_constant_visitor: Add support for dFdx and dFdy operations. If the argument is a constant expression...it's not changing per pixel, so the result is simply 0. --- ir_constant_expression.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index e89b5bc7685..4055a84ff15 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -266,6 +266,15 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_dFdx: + case ir_unop_dFdy: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + f[c] = 0.0; + } + break; + case ir_binop_add: if (ir->operands[0]->type == ir->operands[1]->type) { type = ir->operands[0]->type; -- cgit v1.2.3 From 0c8ffadc8cc0b0497873a8ce46ae4e1ae03eee54 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 15:17:41 -0700 Subject: Implement matrixCompMult builtin - the last of the 110 builtins. --- builtin_function.cpp | 111 ++++++++++++++++++++++++++ builtins/110/matrixCompMult | 32 ++++++++ builtins/120/matrixCompMult | 61 ++++++++++++++ builtins/tools/generate_matrixCompMultGLSL.py | 28 +++++++ 4 files changed, 232 insertions(+) create mode 100644 builtins/110/matrixCompMult create mode 100644 builtins/120/matrixCompMult create mode 100755 builtins/tools/generate_matrixCompMultGLSL.py diff --git a/builtin_function.cpp b/builtin_function.cpp index 4ee43df5dc2..7072af25719 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1165,6 +1165,41 @@ static const char *builtins_110_log2 = { "))\n" }; +static const char *builtins_110_matrixCompMult = { + "((function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 x)\n" + " (declare (in) mat2 y))\n" + " ((declare () mat2 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 x)\n" + " (declare (in) mat3 y))\n" + " ((declare () mat3 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 x)\n" + " (declare (in) mat4 y))\n" + " ((declare () mat4 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "))\n" + "\n" +}; + static const char *builtins_110_max = { "((function max\n" " (signature float\n" @@ -2473,6 +2508,7 @@ static const char *functions_for_110 [] = { builtins_110_lessThanEqual, builtins_110_log, builtins_110_log2, + builtins_110_matrixCompMult, builtins_110_max, builtins_110_min, builtins_110_mix, @@ -2709,6 +2745,76 @@ static const char *functions_for_110_vs [] = { builtins_110_vs_ftransform, }; +/* 120 builtins */ + +static const char *builtins_120_matrixCompMult = { + "((function matrixCompMult\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) mat2x3 x)\n" + " (declare (in) mat2x3 y))\n" + " ((declare () mat2x3 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) mat3x2 x)\n" + " (declare (in) mat3x2 y))\n" + " ((declare () mat3x2 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) mat2x4 x)\n" + " (declare (in) mat2x4 y))\n" + " ((declare () mat2x4 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) mat4x2 x)\n" + " (declare (in) mat4x2 y))\n" + " ((declare () mat4x2 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) mat3x4 x)\n" + " (declare (in) mat3x4 y))\n" + " ((declare () mat3x4 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) mat4x3 x)\n" + " (declare (in) mat4x3 y))\n" + " ((declare () mat4x3 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "))\n" +}; + +static const char *functions_for_120 [] = { + builtins_120_matrixCompMult, +}; + /* 130 builtins */ static const char *builtins_130_equal = { @@ -4199,6 +4305,11 @@ _mesa_glsl_initialize_functions(exec_list *instructions, functions_for_110_vs, sizeof(functions_for_110_vs) / sizeof(const char *)); + if (state->language_version >= 120) + read_builtins(state, instructions, + functions_for_120, + sizeof(functions_for_120) / sizeof(const char *)); + if (state->language_version >= 130) read_builtins(state, instructions, functions_for_130, diff --git a/builtins/110/matrixCompMult b/builtins/110/matrixCompMult new file mode 100644 index 00000000000..cb5a2cb1f7b --- /dev/null +++ b/builtins/110/matrixCompMult @@ -0,0 +1,32 @@ +((function matrixCompMult + (signature mat2 + (parameters + (declare (in) mat2 x) + (declare (in) mat2 y)) + ((declare () mat2 z) + (assign (constant bool (1)) (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)) (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 + (parameters + (declare (in) mat3 x) + (declare (in) mat3 y)) + ((declare () mat3 z) + (assign (constant bool (1)) (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)) (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)) (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 + (parameters + (declare (in) mat4 x) + (declare (in) mat4 y)) + ((declare () mat4 z) + (assign (constant bool (1)) (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)) (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)) (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)) (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)))) +)) + diff --git a/builtins/120/matrixCompMult b/builtins/120/matrixCompMult new file mode 100644 index 00000000000..69331e26525 --- /dev/null +++ b/builtins/120/matrixCompMult @@ -0,0 +1,61 @@ +((function matrixCompMult + (signature mat2x3 + (parameters + (declare (in) mat2x3 x) + (declare (in) mat2x3 y)) + ((declare () mat2x3 z) + (assign (constant bool (1)) (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)) (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 + (parameters + (declare (in) mat3x2 x) + (declare (in) mat3x2 y)) + ((declare () mat3x2 z) + (assign (constant bool (1)) (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)) (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)) (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 + (parameters + (declare (in) mat2x4 x) + (declare (in) mat2x4 y)) + ((declare () mat2x4 z) + (assign (constant bool (1)) (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)) (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 + (parameters + (declare (in) mat4x2 x) + (declare (in) mat4x2 y)) + ((declare () mat4x2 z) + (assign (constant bool (1)) (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)) (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)) (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)) (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 + (parameters + (declare (in) mat3x4 x) + (declare (in) mat3x4 y)) + ((declare () mat3x4 z) + (assign (constant bool (1)) (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)) (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)) (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 + (parameters + (declare (in) mat4x3 x) + (declare (in) mat4x3 y)) + ((declare () mat4x3 z) + (assign (constant bool (1)) (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)) (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)) (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)) (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/builtins/tools/generate_matrixCompMultGLSL.py b/builtins/tools/generate_matrixCompMultGLSL.py new file mode 100755 index 00000000000..391ad110d37 --- /dev/null +++ b/builtins/tools/generate_matrixCompMultGLSL.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +def gen_matrix(x, y = 0): + if y == 0: + y = x + type = "mat" + str(x) + if x != y: + type = type + "x" + str(y) + print type + " matrixCompMult(" + type + " x, " + type + " y)\n{" + print " " + type + " z;" + + for i in range(x): + print " z[" + str(i) + "] = x[" + str(i) + "] * y[" + str(i) + "];" + print " return z;\n}" + +print "#version 120" +# 1.10 +gen_matrix(2) +gen_matrix(3) +gen_matrix(4) + +# 1.20 +gen_matrix(2,3) # mat2x3 means 2 columns, 3 rows +gen_matrix(3,2) +gen_matrix(2,4) +gen_matrix(4,2) +gen_matrix(3,4) +gen_matrix(4,3) -- cgit v1.2.3 From 43ff6fc4ae5f47f1537707b794253929780cafc1 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 15:47:09 -0700 Subject: Implement 1.20 'outerProduct' builtin. --- builtin_function.cpp | 96 +++++++++++++++++++++++++++++ builtins/120/outerProduct | 92 +++++++++++++++++++++++++++ builtins/tools/generate_outerProductGLSL.py | 23 +++++++ 3 files changed, 211 insertions(+) create mode 100644 builtins/120/outerProduct create mode 100755 builtins/tools/generate_outerProductGLSL.py diff --git a/builtin_function.cpp b/builtin_function.cpp index 7072af25719..dc07f85136f 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -2811,8 +2811,104 @@ static const char *builtins_120_matrixCompMult = { "))\n" }; +static const char *builtins_120_outerProduct = { + "((function outerProduct\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat2 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat2x3 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat2x4 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat3x2 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat3 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat3x4 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat4x2 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref v) (swiz w (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat4x3 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref v) (swiz w (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat4 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref v) (swiz w (var_ref u)))) \n" + "(return (var_ref m))))\n" + "))\n" + "\n" +}; + static const char *functions_for_120 [] = { builtins_120_matrixCompMult, + builtins_120_outerProduct, }; /* 130 builtins */ diff --git a/builtins/120/outerProduct b/builtins/120/outerProduct new file mode 100644 index 00000000000..b401ba02337 --- /dev/null +++ b/builtins/120/outerProduct @@ -0,0 +1,92 @@ +((function outerProduct + (signature mat2 + (parameters + (declare (in) vec2 u) + (declare (in) vec2 v)) + ((declare () mat2 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) +(return (var_ref m)))) + + (signature mat2x3 + (parameters + (declare (in) vec2 u) + (declare (in) vec3 v)) + ((declare () mat2x3 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) +(return (var_ref m)))) + + (signature mat2x4 + (parameters + (declare (in) vec2 u) + (declare (in) vec4 v)) + ((declare () mat2x4 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) +(return (var_ref m)))) + + (signature mat3x2 + (parameters + (declare (in) vec3 u) + (declare (in) vec2 v)) + ((declare () mat3x2 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) +(return (var_ref m)))) + + (signature mat3 + (parameters + (declare (in) vec3 u) + (declare (in) vec3 v)) + ((declare () mat3 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) +(return (var_ref m)))) + + (signature mat3x4 + (parameters + (declare (in) vec3 u) + (declare (in) vec4 v)) + ((declare () mat3x4 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) +(return (var_ref m)))) + + (signature mat4x2 + (parameters + (declare (in) vec4 u) + (declare (in) vec2 v)) + ((declare () mat4x2 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref v) (swiz w (var_ref u)))) +(return (var_ref m)))) + + (signature mat4x3 + (parameters + (declare (in) vec4 u) + (declare (in) vec3 v)) + ((declare () mat4x3 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref v) (swiz w (var_ref u)))) +(return (var_ref m)))) + + (signature mat4 + (parameters + (declare (in) vec4 u) + (declare (in) vec4 v)) + ((declare () mat4 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref v) (swiz w (var_ref u)))) +(return (var_ref m)))) +)) + diff --git a/builtins/tools/generate_outerProductGLSL.py b/builtins/tools/generate_outerProductGLSL.py new file mode 100755 index 00000000000..48fb72197c3 --- /dev/null +++ b/builtins/tools/generate_outerProductGLSL.py @@ -0,0 +1,23 @@ +#!/usr/bin/python + +def gen(x, y): + type = "mat" + str(x) + if x != y: + type = type + "x" + str(y) + print type + " outerProduct(vec" + str(x) + " u, vec" + str(y) + " v)\n{" + print " " + type + " m;" + + for i in range(x): + print " m[" + str(i) + "] = v * u[" + str(i) + "];" + print " return m;\n}" + +print "#version 120" +gen(2,2) +gen(2,3) # mat2x3 means 2 columns, 3 rows +gen(2,4) +gen(3,2) +gen(3,3) +gen(3,4) +gen(4,2) +gen(4,3) +gen(4,4) -- cgit v1.2.3 From 1d0e07c42007d1dbab1d582b9ae211e186fcdcdd Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 15:56:46 -0700 Subject: Implement 1.20 'transpose' builtin. --- builtin_function.cpp | 143 +++++++++++++++++++++++++++++++ builtins/120/transpose | 139 ++++++++++++++++++++++++++++++ builtins/tools/generate_transposeGLSL.py | 28 ++++++ 3 files changed, 310 insertions(+) create mode 100644 builtins/120/transpose create mode 100755 builtins/tools/generate_transposeGLSL.py diff --git a/builtin_function.cpp b/builtin_function.cpp index dc07f85136f..789e4df9c1e 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -2906,9 +2906,152 @@ static const char *builtins_120_outerProduct = { "\n" }; +static const char *builtins_120_transpose = { + "((function transpose\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 m))\n" + " ((declare () mat2 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) mat2x3 m))\n" + " ((declare () mat3x2 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) mat2x4 m))\n" + " ((declare () mat4x2 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) mat3x2 m))\n" + " ((declare () mat2x3 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 m))\n" + " ((declare () mat3 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) mat3x4 m))\n" + " ((declare () mat4x3 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) mat4x2 m))\n" + " ((declare () mat2x4 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) mat4x3 m))\n" + " ((declare () mat3x4 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 m))\n" + " ((declare () mat4 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (3))))) \n" + "(return (var_ref t))))\n" + ")\n" + "\n" + ")\n" + "\n" +}; + static const char *functions_for_120 [] = { builtins_120_matrixCompMult, builtins_120_outerProduct, + builtins_120_transpose, }; /* 130 builtins */ diff --git a/builtins/120/transpose b/builtins/120/transpose new file mode 100644 index 00000000000..416a0ee4677 --- /dev/null +++ b/builtins/120/transpose @@ -0,0 +1,139 @@ +((function transpose + (signature mat2 + (parameters + (declare (in) mat2 m)) + ((declare () mat2 t) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz 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/builtins/tools/generate_transposeGLSL.py b/builtins/tools/generate_transposeGLSL.py new file mode 100755 index 00000000000..8f669ce9839 --- /dev/null +++ b/builtins/tools/generate_transposeGLSL.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +def gen(x, y): + origtype = "mat" + str(x) + trantype = "mat" + str(y) + if x != y: + origtype = origtype + "x" + str(y) + trantype = trantype + "x" + str(x) + print trantype + " transpose(" + origtype + " m)\n{" + print " " + trantype + " t;" + + # The obvious implementation of transpose + for i in range(x): + for j in range(y): + print " t[" + str(j) + "][" + str(i) + "] =", + print "m[" + str(i) + "][" + str(j) + "];" + print " return t;\n}" + +print "#version 120" +gen(2,2) +gen(2,3) # mat2x3 means 2 columns, 3 rows +gen(2,4) +gen(3,2) +gen(3,3) +gen(3,4) +gen(4,2) +gen(4,3) +gen(4,4) -- cgit v1.2.3 From c9aabc866f1fa2b724780800cf97cf6f3c1c1cf4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 16:08:36 -0700 Subject: Implement 1.30 hyperbolic trig builtins (sinh, cosh, tanh). --- builtin_function.cpp | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++ builtins/130/cosh | 30 ++++++++++++++ builtins/130/sinh | 30 ++++++++++++++ builtins/130/tanh | 42 +++++++++++++++++++ 4 files changed, 216 insertions(+) create mode 100644 builtins/130/cosh create mode 100644 builtins/130/sinh create mode 100644 builtins/130/tanh diff --git a/builtin_function.cpp b/builtin_function.cpp index 789e4df9c1e..7f221216d8b 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -3056,6 +3056,39 @@ static const char *functions_for_120 [] = { /* 130 builtins */ +static const char *builtins_130_cosh = { + "((function cosh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float * (constant float (0.5))\n" + " (expression float +\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 * (constant vec2 (0.5))\n" + " (expression vec2 +\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 * (constant vec3 (0.5))\n" + " (expression vec3 +\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 * (constant vec4 (0.5))\n" + " (expression vec4 +\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" +}; + static const char *builtins_130_equal = { "((function equal\n" " (signature bvec2\n" @@ -3297,6 +3330,84 @@ static const char *builtins_130_sign = { "\n" }; +static const char *builtins_130_sinh = { + "((function sinh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float * (constant float (0.5))\n" + " (expression float -\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 * (constant vec2 (0.5))\n" + " (expression vec2 -\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 * (constant vec3 (0.5))\n" + " (expression vec3 -\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 * (constant vec4 (0.5))\n" + " (expression vec4 -\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" +}; + +static const char *builtins_130_tanh = { + "((function tanh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float /\n" + " (expression float -\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))\n" + " (expression float +\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 /\n" + " (expression vec2 -\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))\n" + " (expression vec2 +\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 /\n" + " (expression vec3 -\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))\n" + " (expression vec3 +\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 /\n" + " (expression vec4 -\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))\n" + " (expression vec4 +\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" +}; + static const char *builtins_130_texelFetch = { "((function texelFetch\n" " (signature vec4\n" @@ -4132,6 +4243,7 @@ static const char *builtins_130_textureProjLod = { }; static const char *functions_for_130 [] = { + builtins_130_cosh, builtins_130_equal, builtins_130_greaterThan, builtins_130_greaterThanEqual, @@ -4139,6 +4251,8 @@ static const char *functions_for_130 [] = { builtins_130_lessThanEqual, builtins_130_notEqual, builtins_130_sign, + builtins_130_sinh, + builtins_130_tanh, builtins_130_texelFetch, builtins_130_texture, builtins_130_textureGrad, diff --git a/builtins/130/cosh b/builtins/130/cosh new file mode 100644 index 00000000000..45e0ae427d6 --- /dev/null +++ b/builtins/130/cosh @@ -0,0 +1,30 @@ +((function cosh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * (constant float (0.5)) + (expression float + + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * (constant vec2 (0.5)) + (expression vec2 + + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * (constant vec3 (0.5)) + (expression vec3 + + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * (constant vec4 (0.5)) + (expression vec4 + + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/builtins/130/sinh b/builtins/130/sinh new file mode 100644 index 00000000000..7ad4f58e204 --- /dev/null +++ b/builtins/130/sinh @@ -0,0 +1,30 @@ +((function sinh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * (constant float (0.5)) + (expression float - + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * (constant vec2 (0.5)) + (expression vec2 - + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * (constant vec3 (0.5)) + (expression vec3 - + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * (constant vec4 (0.5)) + (expression vec4 - + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/builtins/130/tanh b/builtins/130/tanh new file mode 100644 index 00000000000..3b7271bf779 --- /dev/null +++ b/builtins/130/tanh @@ -0,0 +1,42 @@ +((function tanh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float / + (expression float - + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))) + (expression float + + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 / + (expression vec2 - + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))) + (expression vec2 + + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 / + (expression vec3 - + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))) + (expression vec3 + + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 / + (expression vec4 - + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))) + (expression vec4 + + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) -- cgit v1.2.3 From c3bf0cbefc32b76da0d196887c32159ba98b1e5a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 16:11:36 -0700 Subject: texture_builtins.py: The unsigned integer type is "uint", not "unsigned" This doesn't actually affect anything yet, but is good to fix anyway. --- builtins/tools/texture_builtins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtins/tools/texture_builtins.py b/builtins/tools/texture_builtins.py index be0bc6fc0af..23d53149161 100755 --- a/builtins/tools/texture_builtins.py +++ b/builtins/tools/texture_builtins.py @@ -8,7 +8,7 @@ def vec_type(g, size): if g == "i": return "int" elif g == "u": - return "unsigned" + return "uint" return "float" return g + "vec" + str(size) -- cgit v1.2.3 From af05703826687e78267d234aeea9b7469baced48 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 16:14:45 -0700 Subject: Implement 1.30 int/uint variants of min/max/clamp. --- builtin_function.cpp | 389 +++++++++++++++++++++++++++++++++++++++++++++++++++ builtins/130/clamp | 123 ++++++++++++++++ builtins/130/max | 127 +++++++++++++++++ builtins/130/min | 127 +++++++++++++++++ 4 files changed, 766 insertions(+) create mode 100644 builtins/130/clamp create mode 100644 builtins/130/max create mode 100644 builtins/130/min diff --git a/builtin_function.cpp b/builtin_function.cpp index 7f221216d8b..d248388a1ab 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -3056,6 +3056,132 @@ static const char *functions_for_120 [] = { /* 130 builtins */ +static const char *builtins_130_clamp = { + "((function clamp\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1)\n" + " (declare (in) ivec2 arg2))\n" + " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1)\n" + " (declare (in) ivec3 arg2))\n" + " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1)\n" + " (declare (in) ivec4 arg2))\n" + " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((declare () ivec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((declare () ivec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((declare () ivec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1)\n" + " (declare (in) uvec2 arg2))\n" + " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1)\n" + " (declare (in) uvec3 arg2))\n" + " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1)\n" + " (declare (in) uvec4 arg2))\n" + " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((declare () uvec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((declare () uvec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((declare () uvec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "))\n" +}; + static const char *builtins_130_cosh = { "((function cosh\n" " (signature float\n" @@ -3259,6 +3385,266 @@ static const char *builtins_130_lessThanEqual = { "))\n" }; +static const char *builtins_130_max = { + "((function max\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression int max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression int max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression int max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression int max (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uint max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression uint max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression uint max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression uint max (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "))\n" +}; + +static const char *builtins_130_min = { + "((function min\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression int min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression int min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression int min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression int min (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uint min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression uint min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression uint min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression uint min (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "))\n" +}; + static const char *builtins_130_notEqual = { "((function notEqual\n" " (signature bvec2\n" @@ -4243,12 +4629,15 @@ static const char *builtins_130_textureProjLod = { }; static const char *functions_for_130 [] = { + builtins_130_clamp, builtins_130_cosh, builtins_130_equal, builtins_130_greaterThan, builtins_130_greaterThanEqual, builtins_130_lessThan, builtins_130_lessThanEqual, + builtins_130_max, + builtins_130_min, builtins_130_notEqual, builtins_130_sign, builtins_130_sinh, diff --git a/builtins/130/clamp b/builtins/130/clamp new file mode 100644 index 00000000000..3aed22c20df --- /dev/null +++ b/builtins/130/clamp @@ -0,0 +1,123 @@ +((function clamp + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1) + (declare (in) ivec2 arg2)) + ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1) + (declare (in) ivec3 arg2)) + ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1) + (declare (in) ivec4 arg2)) + ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((declare () ivec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((declare () ivec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((declare () ivec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1) + (declare (in) uvec2 arg2)) + ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1) + (declare (in) uvec3 arg2)) + ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1) + (declare (in) uvec4 arg2)) + ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((declare () uvec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((declare () uvec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((declare () uvec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) +)) diff --git a/builtins/130/max b/builtins/130/max new file mode 100644 index 00000000000..45a6089c9f2 --- /dev/null +++ b/builtins/130/max @@ -0,0 +1,127 @@ +((function max + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1)) + ((return (expression int max (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression ivec2 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression ivec3 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression ivec4 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1)) + ((declare () ivec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1)) + ((declare () ivec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression int max (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1)) + ((declare () ivec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression int max (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression int max (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1)) + ((return (expression uint max (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression uvec2 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression uvec3 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression uvec4 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1)) + ((declare () uvec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1)) + ((declare () uvec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression uint max (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1)) + ((declare () uvec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression uint max (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression uint max (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) +)) diff --git a/builtins/130/min b/builtins/130/min new file mode 100644 index 00000000000..d98ec1e79da --- /dev/null +++ b/builtins/130/min @@ -0,0 +1,127 @@ +((function min + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1)) + ((return (expression int min (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression ivec2 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression ivec3 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression ivec4 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1)) + ((declare () ivec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1)) + ((declare () ivec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression int min (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1)) + ((declare () ivec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression int min (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression int min (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1)) + ((return (expression uint min (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression uvec2 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression uvec3 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression uvec4 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1)) + ((declare () uvec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1)) + ((declare () uvec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression uint min (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1)) + ((declare () uvec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression uint min (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression uint min (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) +)) -- cgit v1.2.3 From 75393ee16b2d4b24e3f268b66ae237e8fec49943 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 16:46:09 -0700 Subject: Add forgotten autogenerated EXT_texture_array_fs folder. --- builtins/EXT_texture_array_fs/textures | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 builtins/EXT_texture_array_fs/textures diff --git a/builtins/EXT_texture_array_fs/textures b/builtins/EXT_texture_array_fs/textures new file mode 100644 index 00000000000..74e184387ac --- /dev/null +++ b/builtins/EXT_texture_array_fs/textures @@ -0,0 +1,27 @@ +((function texture1DArray + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function texture2DArray + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function shadow1DArray + (signature vec4 + (parameters + (declare (in) sampler1DArrayShadow sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) + +)) -- cgit v1.2.3 From 332920a940a0f60322389a604933e3dc60d96547 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Jun 2010 17:05:14 -0700 Subject: Remove linux_list in favor of exec_list. --- ir_constant_variable.cpp | 22 +++++------- linux_list.h | 93 ------------------------------------------------ 2 files changed, 8 insertions(+), 107 deletions(-) delete mode 100644 linux_list.h diff --git a/ir_constant_variable.cpp b/ir_constant_variable.cpp index 75590dfdbfa..7210c17dc77 100644 --- a/ir_constant_variable.cpp +++ b/ir_constant_variable.cpp @@ -39,10 +39,9 @@ #include "ir_visitor.h" #include "ir_optimization.h" #include "glsl_types.h" -#include "linux_list.h" struct assignment_entry { - struct list link; + exec_node link; int assignment_count; ir_variable *var; ir_constant *constval; @@ -50,29 +49,24 @@ struct assignment_entry { class ir_constant_variable_visitor : public ir_hierarchical_visitor { public: - ir_constant_variable_visitor() - { - list_init(&list); - } - virtual ir_visitor_status visit_enter(ir_assignment *); - struct list list; + exec_list list; }; static struct assignment_entry * -get_assignment_entry(ir_variable *var, struct list *list) +get_assignment_entry(ir_variable *var, exec_list *list) { struct assignment_entry *entry; - list_foreach_entry(entry, struct assignment_entry, list, link) { + foreach_list_typed(struct assignment_entry, entry, link, list) { if (entry->var == var) return entry; } entry = (struct assignment_entry *)calloc(1, sizeof(*entry)); entry->var = var; - list_add(&entry->link, list); + list->push_head(&entry->link); return entry; } @@ -127,16 +121,16 @@ do_constant_variable(exec_list *instructions) v.run(instructions); - while (!list_is_empty(&v.list)) { + while (!v.list.is_empty()) { struct assignment_entry *entry; - entry = list_entry(v.list.next, struct assignment_entry, link); + entry = exec_node_data(struct assignment_entry, v.list.head, link); if (entry->assignment_count == 1 && entry->constval) { entry->var->constant_value = entry->constval; progress = true; } - list_del(&entry->link); + entry->link.remove(); free(entry); } diff --git a/linux_list.h b/linux_list.h deleted file mode 100644 index 88ec6fb62af..00000000000 --- a/linux_list.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright © 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - * - * Authors: - * Chris Wilson - * - */ - -/* classic doubly-link circular list */ -struct list { - struct list *next, *prev; -}; - -static void -list_init(struct list *list) -{ - list->next = list->prev = list; -} - -static inline void -__list_add(struct list *entry, - struct list *prev, - struct list *next) -{ - next->prev = entry; - entry->next = next; - entry->prev = prev; - prev->next = entry; -} - -static inline void -list_add(struct list *entry, struct list *head) -{ - __list_add(entry, head, head->next); -} - -static inline void -__list_del(struct list *prev, struct list *next) -{ - next->prev = prev; - prev->next = next; -} - -static inline void -list_del(struct list *entry) -{ - __list_del(entry->prev, entry->next); - list_init(entry); -} - -static inline bool -list_is_empty(struct list *head) -{ - return head->next == head; -} - -#ifndef container_of -#define container_of(ptr, type, member) \ - (type *)((char *)(ptr) - (char *) &((type *)0)->member) -#endif - -#define list_entry(ptr, type, member) \ - container_of(ptr, type, member) - -#define list_first_entry(ptr, type, member) \ - list_entry((ptr)->next, type, member) - -#define list_foreach(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) - -#define list_foreach_entry(pos, type, head, member) \ - for (pos = list_entry((head)->next, type, member);\ - &pos->member != (head); \ - pos = list_entry(pos->member.next, type, member)) -- cgit v1.2.3 From 565185cd8f3ea636d3d2aaad9218d63323390464 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 13:49:00 -0700 Subject: Use ir_unop_b2i when converting a bool-to-int and add a missing break The previous code just had dumb cut-and-paste errors. --- ast_function.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ast_function.cpp b/ast_function.cpp index 300108cb73e..06498b0e379 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -154,8 +154,9 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) return new ir_expression(ir_unop_f2i, desired_type, src, NULL); else { assert(b == GLSL_TYPE_BOOL); - return new ir_expression(ir_unop_f2b, desired_type, src, NULL); + return new ir_expression(ir_unop_b2i, desired_type, src, NULL); } + break; case GLSL_TYPE_FLOAT: switch (b) { case GLSL_TYPE_UINT: -- cgit v1.2.3 From 989cfc432ee7adef701a87783e0c6b064c1cfaee Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 4 Jun 2010 16:13:35 -0700 Subject: Construct an ir_constant from a scalar component of another ir_constant --- ir.cpp | 13 +++++++++++++ ir.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/ir.cpp b/ir.cpp index c5eb94d2d50..f7e03cb58dd 100644 --- a/ir.cpp +++ b/ir.cpp @@ -227,6 +227,19 @@ ir_constant::ir_constant(bool b) this->value.b[0] = b; } +ir_constant::ir_constant(const ir_constant *c, unsigned i) +{ + this->type = c->type->get_base_type(); + + switch (this->type->base_type) { + case GLSL_TYPE_UINT: this->value.u[0] = c->value.u[i]; break; + case GLSL_TYPE_INT: this->value.i[0] = c->value.i[i]; break; + case GLSL_TYPE_FLOAT: this->value.f[0] = c->value.f[i]; break; + case GLSL_TYPE_BOOL: this->value.b[0] = c->value.b[i]; break; + default: assert(!"Should not get here."); break; + } +} + ir_dereference_variable::ir_dereference_variable(ir_variable *var) { diff --git a/ir.h b/ir.h index ea4f5494689..102f2f37270 100644 --- a/ir.h +++ b/ir.h @@ -1026,6 +1026,18 @@ public: ir_constant(int i); ir_constant(float f); + /** + * Construct an ir_constant from a scalar component of another ir_constant + * + * The new \c ir_constant inherits the type of the component from the + * source constant. + * + * \note + * In the case of a matrix constant, the new constant is a scalar, \b not + * a vector. + */ + ir_constant(const ir_constant *c, unsigned i); + virtual ir_constant *as_constant() { return this; -- cgit v1.2.3 From c9cb1032be454ff5fdb802a629565cfaeb2e5d5a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 4 Jun 2010 16:20:35 -0700 Subject: Derefence components of constants smarter During generation of calls to constructors, derefernce constants by creating new constants instead of creating dereferences. --- ast_function.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ast_function.cpp b/ast_function.cpp index 06498b0e379..fc53d7ac1cb 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -188,6 +188,13 @@ dereference_component(ir_rvalue *src, unsigned component) { assert(component < src->type->components()); + /* If the source is a constant, just create a new constant instead of a + * dereference of the existing constant. + */ + ir_constant *constant = src->as_constant(); + if (constant) + return new ir_constant(constant, component); + if (src->type->is_scalar()) { return src; } else if (src->type->is_vector()) { -- cgit v1.2.3 From 31881908ebc11d84c2ff1821410c91340686aa17 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 4 Jun 2010 16:30:07 -0700 Subject: Add methods to ir_constant to get scalar components in a particular type --- ir.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ir.h | 14 ++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/ir.cpp b/ir.cpp index f7e03cb58dd..7e5873b646c 100644 --- a/ir.cpp +++ b/ir.cpp @@ -240,6 +240,74 @@ ir_constant::ir_constant(const ir_constant *c, unsigned i) } } +bool +ir_constant::get_bool_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return this->value.u[i] != 0; + case GLSL_TYPE_INT: return this->value.i[i] != 0; + case GLSL_TYPE_FLOAT: return ((int)this->value.f[i]) != 0; + case GLSL_TYPE_BOOL: return this->value.b[i]; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return false; +} + +float +ir_constant::get_float_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return (float) this->value.u[i]; + case GLSL_TYPE_INT: return (float) this->value.i[i]; + case GLSL_TYPE_FLOAT: return this->value.f[i]; + case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0 : 0.0; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return 0.0; +} + +int +ir_constant::get_int_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return this->value.u[i]; + case GLSL_TYPE_INT: return this->value.i[i]; + case GLSL_TYPE_FLOAT: return (int) this->value.f[i]; + case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return 0; +} + +unsigned +ir_constant::get_uint_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return this->value.u[i]; + case GLSL_TYPE_INT: return this->value.i[i]; + case GLSL_TYPE_FLOAT: return (unsigned) this->value.f[i]; + case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return 0; +} + ir_dereference_variable::ir_dereference_variable(ir_variable *var) { diff --git a/ir.h b/ir.h index 102f2f37270..033d6f2261e 100644 --- a/ir.h +++ b/ir.h @@ -1055,6 +1055,20 @@ public: return new ir_constant(this->type, &this->value); } + /** + * Get a particular component of a constant as a specific type + * + * This is useful, for example, to get a value from an integer constant + * as a float or bool. This appears frequently when constructors are + * called with all constant parameters. + */ + /*@{*/ + bool get_bool_component(unsigned i) const; + float get_float_component(unsigned i) const; + int get_int_component(unsigned i) const; + unsigned get_uint_component(unsigned i) const; + /*@}*/ + /** * Value of the constant. * -- cgit v1.2.3 From 7c40a3205439e406d54feca6cd0a09fda091522c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 4 Jun 2010 16:35:42 -0700 Subject: Add queries to determine if a node is a list sentinal --- list.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/list.h b/list.h index 615be054378..0b91647be4f 100644 --- a/list.h +++ b/list.h @@ -140,6 +140,22 @@ struct exec_node { this->prev->next = before; this->prev = before; } + + /** + * Is this the sentinal at the tail of the list? + */ + bool is_tail_sentinal() const + { + return this->next == NULL; + } + + /** + * Is this the sentinal at the head of the list? + */ + bool is_head_sentinal() const + { + return this->prev == NULL; + } #endif }; -- cgit v1.2.3 From 756a3fac4fbbc6b3785715db745f8d58a14baeb9 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 4 Jun 2010 16:34:38 -0700 Subject: Construct an ir_constant from a list of ir_constant values --- ir.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ ir.h | 5 +++++ 2 files changed, 50 insertions(+) diff --git a/ir.cpp b/ir.cpp index 7e5873b646c..759bf9f804a 100644 --- a/ir.cpp +++ b/ir.cpp @@ -240,6 +240,51 @@ ir_constant::ir_constant(const ir_constant *c, unsigned i) } } +ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) +{ + this->type = type; + + /* FINISHME: Support structure and array types. */ + assert(type->is_scalar() || type->is_vector() || type->is_matrix()); + + ir_constant *value = (ir_constant *) (value_list->head); + + /* Use each component from each entry in the value_list to initialize one + * component of the constant being constructed. + */ + for (unsigned i = 0; i < type->components(); /* empty */) { + assert(value->as_constant() != NULL); + assert(!value->is_tail_sentinal()); + + for (unsigned j = 0; j < value->type->components(); j++) { + switch (type->base_type) { + case GLSL_TYPE_UINT: + this->value.u[i] = value->get_uint_component(j); + break; + case GLSL_TYPE_INT: + this->value.i[i] = value->get_int_component(j); + break; + case GLSL_TYPE_FLOAT: + this->value.f[i] = value->get_float_component(j); + break; + case GLSL_TYPE_BOOL: + this->value.b[i] = value->get_bool_component(j); + break; + default: + /* FINISHME: What to do? Exceptions are not the answer. + */ + break; + } + + i++; + if (i >= type->components()) + break; + } + + value = (ir_constant *) value->next; + } +} + bool ir_constant::get_bool_component(unsigned i) const { diff --git a/ir.h b/ir.h index 033d6f2261e..60164a5ab1c 100644 --- a/ir.h +++ b/ir.h @@ -1026,6 +1026,11 @@ public: ir_constant(int i); ir_constant(float f); + /** + * Construct an ir_constant from a list of ir_constant values + */ + ir_constant(const struct glsl_type *type, exec_list *values); + /** * Construct an ir_constant from a scalar component of another ir_constant * -- cgit v1.2.3 From 9e08d019ce36aca8c5c95abbe0b07e8de8b7cf16 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 4 Jun 2010 16:36:09 -0700 Subject: Make constructors with all constant parameters generate in-line constants --- ast_function.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index fc53d7ac1cb..6de72ab2d8a 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -365,13 +365,27 @@ ast_function_expression::hir(exec_list *instructions, unsigned nonmatrix_parameters = 0; exec_list actual_parameters; + bool all_parameters_are_constant = true; + assert(!this->expressions.is_empty()); foreach_list (n, &this->expressions) { ast_node *ast = exec_node_data(ast_node, n, link); - ir_rvalue *const result = + ir_rvalue *result = ast->hir(instructions, state)->as_rvalue(); + /* Attempt to convert the parameter to a constant valued expression. + * After doing so, track whether or not all the parameters to the + * constructor are trivially constant valued expressions. + */ + ir_rvalue *const constant = + result->constant_expression_value(); + + if (constant != NULL) + result = constant; + else + all_parameters_are_constant = false; + /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: * * "It is an error to provide extra arguments beyond this @@ -417,6 +431,9 @@ ast_function_expression::hir(exec_list *instructions, */ assert(component->type == base_type); + if (component->as_constant() == NULL) + all_parameters_are_constant = false; + /* Don't actually generate constructor calls for scalars. * Instead, do the usual component selection and conversion, * and return the single component. @@ -479,7 +496,17 @@ ast_function_expression::hir(exec_list *instructions, const ir_function_signature *sig = f->matching_signature(& actual_parameters); if (sig != NULL) { - return new ir_call(sig, & actual_parameters); + /* If all of the parameters are trivially constant, create a + * constant representing the complete collection of parameters. + */ + if (all_parameters_are_constant + && (sig->return_type->is_scalar() + || sig->return_type->is_vector() + || sig->return_type->is_matrix()) + && (components_used >= type_components)) + return new ir_constant(sig->return_type, & actual_parameters); + else + return new ir_call(sig, & actual_parameters); } else { /* FINISHME: Log a better error message here. G++ will show the * FINSIHME: types of the actual parameters and the set of -- cgit v1.2.3 From 00eb466e38733f386794b35ae5b0aab18b60b1d2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 7 Jun 2010 15:08:04 -0700 Subject: Constant-fold constructor parameters after type conversion This causes the following tests to pass: glslparsertest/shaders/CorrectMatComma2.frag One of the incorrect errors in glslparsertest/shaders/CorrectComma.frag is also eliminated. --- ast_function.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 6de72ab2d8a..07674ada741 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -137,6 +137,7 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) { const unsigned a = desired_type->base_type; const unsigned b = src->type->base_type; + ir_expression *result = NULL; if (src->type->is_error()) return src; @@ -151,32 +152,37 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) case GLSL_TYPE_UINT: case GLSL_TYPE_INT: if (b == GLSL_TYPE_FLOAT) - return new ir_expression(ir_unop_f2i, desired_type, src, NULL); + result = new ir_expression(ir_unop_f2i, desired_type, src, NULL); else { assert(b == GLSL_TYPE_BOOL); - return new ir_expression(ir_unop_b2i, desired_type, src, NULL); + result = new ir_expression(ir_unop_b2i, desired_type, src, NULL); } break; case GLSL_TYPE_FLOAT: switch (b) { case GLSL_TYPE_UINT: - return new ir_expression(ir_unop_u2f, desired_type, src, NULL); + result = new ir_expression(ir_unop_u2f, desired_type, src, NULL); + break; case GLSL_TYPE_INT: - return new ir_expression(ir_unop_i2f, desired_type, src, NULL); + result = new ir_expression(ir_unop_i2f, desired_type, src, NULL); + break; case GLSL_TYPE_BOOL: - return new ir_expression(ir_unop_b2f, desired_type, src, NULL); + result = new ir_expression(ir_unop_b2f, desired_type, src, NULL); + break; } break; case GLSL_TYPE_BOOL: { int z = 0; ir_constant *const zero = new ir_constant(src->type, &z); - return new ir_expression(ir_binop_nequal, desired_type, src, zero); + result = new ir_expression(ir_binop_nequal, desired_type, src, zero); } } - assert(!"Should not get here."); - return NULL; + assert(result != NULL); + + ir_constant *const constant = result->constant_expression_value(); + return (constant != NULL) ? (ir_rvalue *) constant : (ir_rvalue *) result; } -- cgit v1.2.3 From 7dc2b71a89ac24f2d84f7db6bd8a4d499694cac5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 7 Jun 2010 15:10:14 -0700 Subject: Add float/bool conversion to ir_constant_expression.cpp. --- ir_constant_expression.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 4055a84ff15..96dfc56e31c 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -169,6 +169,20 @@ ir_constant_visitor::visit(ir_expression *ir) f[c] = op[0]->value.u[c]; } break; + case ir_unop_b2f: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + f[c] = op[0]->value.b[c] ? 1.0 : 0.0; + } + break; + case ir_unop_f2b: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + b[c] = bool(op[0]->value.f[c]); + } + break; case ir_unop_neg: type = ir->type; -- cgit v1.2.3 From 93073551f9fff0df5ad1f65e0f483e6699474b91 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 17:17:47 -0700 Subject: Add glsl_type::is_record query --- glsl_types.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glsl_types.h b/glsl_types.h index 22df13b07f0..823897df4ae 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -292,6 +292,14 @@ struct glsl_type { return base_type == GLSL_TYPE_ARRAY; } + /** + * Query whether or not a type is a record + */ + bool is_record() const + { + return base_type == GLSL_TYPE_STRUCT; + } + /** * Query whether or not a type is the void type singleton. */ -- cgit v1.2.3 From 7f1ab834d7aa901ce0e12f40db23d7d9891eae59 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 17:11:50 -0700 Subject: ir_constant: Add storage for multiple constants for arrays and records --- ir.cpp | 20 ++++++++++++++++++-- ir.h | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ir.cpp b/ir.cpp index 759bf9f804a..b60d1b468aa 100644 --- a/ir.cpp +++ b/ir.cpp @@ -244,8 +244,24 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) { this->type = type; - /* FINISHME: Support structure and array types. */ - assert(type->is_scalar() || type->is_vector() || type->is_matrix()); + /* FINISHME: Support array types. */ + assert(type->is_scalar() || type->is_vector() || type->is_matrix() + || type->is_record()); + + /* If the constant is a record, the types of each of the entries in + * value_list must be a 1-for-1 match with the structure components. Each + * entry must also be a constant. Just move the nodes from the value_list + * to the list in the ir_constant. + */ + /* FINISHME: Should there be some type checking and / or assertions here? */ + /* FINISHME: Should the new constant take ownership of the nodes from + * FINISHME: value_list, or should it make copies? + */ + if (type->is_record()) { + value_list->move_nodes_to(& this->components); + return; + } + ir_constant *value = (ir_constant *) (value_list->head); diff --git a/ir.h b/ir.h index 60164a5ab1c..8fd823db09c 100644 --- a/ir.h +++ b/ir.h @@ -1087,6 +1087,8 @@ public: float f[16]; bool b[16]; } value; + + exec_list components; }; void -- cgit v1.2.3 From 710919fd7cb7ac6cb640afa362f5c409e5a5ec91 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 17:18:04 -0700 Subject: ir_constant: Support constant structures in clone --- ir.cpp | 36 ++++++++++++++++++++++++++++++++++++ ir.h | 11 +++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/ir.cpp b/ir.cpp index b60d1b468aa..bb1c4589a57 100644 --- a/ir.cpp +++ b/ir.cpp @@ -184,6 +184,11 @@ ir_expression::get_operator(const char *str) return (ir_expression_operation) -1; } +ir_constant::ir_constant() +{ + /* empty */ +} + ir_constant::ir_constant(const struct glsl_type *type, const void *data) { unsigned size = 0; @@ -301,6 +306,37 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) } } +ir_constant * +ir_constant::clone() +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + return new ir_constant(this->type, &this->value); + + case GLSL_TYPE_STRUCT: { + ir_constant *c = new ir_constant; + + c->type = this->type; + for (exec_node *node = this->components.head + ; !node->is_tail_sentinal() + ; node = node->next) { + ir_constant *const orig = (ir_constant *) node; + + c->components.push_tail(orig->clone()); + } + + return c; + } + + default: + assert(!"Should not get here."); break; + return NULL; + } +} + bool ir_constant::get_bool_component(unsigned i) const { diff --git a/ir.h b/ir.h index 8fd823db09c..86beb2d7ce6 100644 --- a/ir.h +++ b/ir.h @@ -1055,10 +1055,7 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - ir_constant *clone() - { - return new ir_constant(this->type, &this->value); - } + ir_constant *clone(); /** * Get a particular component of a constant as a specific type @@ -1089,6 +1086,12 @@ public: } value; exec_list components; + +private: + /** + * Parameterless constructor only used by the clone method + */ + ir_constant(void); }; void -- cgit v1.2.3 From d4b33edbd0332addd616a0ba51ce6574c9b83b4f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 17:19:10 -0700 Subject: ir_constant_visitor: Use clone to create a constant from a variable reference --- ir_constant_expression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 96dfc56e31c..022692b9c92 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -550,7 +550,7 @@ ir_constant_visitor::visit(ir_dereference_variable *ir) ir_variable *var = ir->variable_referenced(); if (var && var->constant_value) - value = new ir_constant(ir->type, &var->constant_value->value); + value = var->constant_value->clone(); } -- cgit v1.2.3 From c077131c0f4692b46afb06ab236288a24f2cfa14 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 17:23:26 -0700 Subject: Move parameter processing out of match_function_by_name Eventually code that processes constant structure constructors will need to use the processed list of parameters. --- ast_function.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 07674ada741..889a239c6e3 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -106,7 +106,7 @@ process_call(exec_list *instructions, ir_function *f, static ir_rvalue * match_function_by_name(exec_list *instructions, const char *name, - YYLTYPE *loc, exec_list *parameters, + YYLTYPE *loc, exec_list *actual_parameters, struct _mesa_glsl_parse_state *state) { ir_function *f = state->symbols->get_function(name); @@ -116,16 +116,10 @@ match_function_by_name(exec_list *instructions, const char *name, return ir_call::get_error_instruction(); } - /* Once we've determined that the function being called might exist, - * process the parameters. + /* Once we've determined that the function being called might exist, try + * to find an overload of the function that matches the parameters. */ - exec_list actual_parameters; - process_parameters(instructions, &actual_parameters, parameters, state); - - /* After processing the function's actual parameters, try to find an - * overload of the function that matches. - */ - return process_call(instructions, f, loc, &actual_parameters, state); + return process_call(instructions, f, loc, actual_parameters, state); } @@ -529,10 +523,14 @@ ast_function_expression::hir(exec_list *instructions, } else { const ast_expression *id = subexpressions[0]; YYLTYPE loc = id->get_location(); + exec_list actual_parameters; + + process_parameters(instructions, &actual_parameters, &this->expressions, + state); return match_function_by_name(instructions, id->primary_expression.identifier, & loc, - &this->expressions, state); + &actual_parameters, state); } return ir_call::get_error_instruction(); -- cgit v1.2.3 From ab92d0e53eab9030742e5e6d938a5739e549f16c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 17:26:20 -0700 Subject: Detect and process constant record constructors --- ast_function.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/ast_function.cpp b/ast_function.cpp index 889a239c6e3..f0c1f0409a0 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -290,6 +290,50 @@ process_array_constructor(exec_list *instructions, } +/** + * Try to convert a record constructor to a constant expression + */ +static ir_constant * +constant_record_constructor(const glsl_type *constructor_type, + YYLTYPE *loc, exec_list *parameters, + struct _mesa_glsl_parse_state *state) +{ + bool all_parameters_are_constant = true; + + exec_node *node = parameters->head; + for (unsigned i = 0; i < constructor_type->length; i++) { + ir_instruction *ir = (ir_instruction *) node; + + if (node->is_tail_sentinal()) { + _mesa_glsl_error(loc, state, + "insufficient parameters to constructor for `%s'", + constructor_type->name); + return NULL; + } + + if (ir->type != constructor_type->fields.structure[i].type) { + _mesa_glsl_error(loc, state, + "parameter type mismatch in constructor for `%s' " + " (%s vs %s)", + constructor_type->name, + ir->type->name, + constructor_type->fields.structure[i].type->name); + return NULL; + } + + if (ir->as_constant() == NULL) + all_parameters_are_constant = false; + + node = node->next; + } + + if (!all_parameters_are_constant) + return NULL; + + return new ir_constant(constructor_type, parameters); +} + + ir_rvalue * ast_function_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -528,6 +572,17 @@ ast_function_expression::hir(exec_list *instructions, process_parameters(instructions, &actual_parameters, &this->expressions, state); + const glsl_type *const type = + state->symbols->get_type(id->primary_expression.identifier); + + if ((type != NULL) && type->is_record()) { + ir_constant *constant = + constant_record_constructor(type, &loc, &actual_parameters, state); + + if (constant != NULL) + return constant; + } + return match_function_by_name(instructions, id->primary_expression.identifier, & loc, &actual_parameters, state); -- cgit v1.2.3 From eeedd355cfc2f0c578282657bd4259440a88742c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 17:27:31 -0700 Subject: Add glsl_types::field_index to get the location of a record field --- glsl_types.cpp | 15 +++++++++++++++ glsl_types.h | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/glsl_types.cpp b/glsl_types.cpp index 9487819a447..4b6a61a13c2 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -718,3 +718,18 @@ glsl_type::field_type(const char *name) const return error_type; } + + +int +glsl_type::field_index(const char *name) const +{ + if (this->base_type != GLSL_TYPE_STRUCT) + return -1; + + for (unsigned i = 0; i < this->length; i++) { + if (strcmp(name, this->fields.structure[i].name) == 0) + return i; + } + + return -1; +} diff --git a/glsl_types.h b/glsl_types.h index 823897df4ae..3265016146d 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -355,6 +355,12 @@ struct glsl_type { const glsl_type *field_type(const char *name) const; + /** + * Get the location of a filed within a record type + */ + int field_index(const char *name) const; + + /** * Query the number of elements in an array type * -- cgit v1.2.3 From b94c29a47b5020e4d052679fc5d22c19533fd73b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 17:28:54 -0700 Subject: ir_constant: Add get_record_field query --- ir.cpp | 26 ++++++++++++++++++++++++++ ir.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/ir.cpp b/ir.cpp index bb1c4589a57..38e2739449c 100644 --- a/ir.cpp +++ b/ir.cpp @@ -406,6 +406,32 @@ ir_constant::get_uint_component(unsigned i) const } +ir_constant * +ir_constant::get_record_field(const char *name) +{ + int idx = this->type->field_index(name); + + if (idx < 0) + return NULL; + + if (this->components.is_empty()) + return NULL; + + exec_node *node = this->components.head; + for (int i = 0; i < idx; i++) { + node = node->next; + + /* If the end of the list is encountered before the element matching the + * requested field is found, return NULL. + */ + if (node->is_tail_sentinal()) + return NULL; + } + + return (ir_constant *) node; +} + + ir_dereference_variable::ir_dereference_variable(ir_variable *var) { this->var = var; diff --git a/ir.h b/ir.h index 86beb2d7ce6..718c495fb30 100644 --- a/ir.h +++ b/ir.h @@ -1071,6 +1071,8 @@ public: unsigned get_uint_component(unsigned i) const; /*@}*/ + ir_constant *get_record_field(const char *name); + /** * Value of the constant. * -- cgit v1.2.3 From 253dedeb6c3beb5192e76b5abafce58a302d9066 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 17:30:19 -0700 Subject: ir_constant_visitor: Handle dereferences of constant records --- ir_constant_expression.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 022692b9c92..8e9e74bb7d8 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -566,9 +566,9 @@ ir_constant_visitor::visit(ir_dereference_array *ir) void ir_constant_visitor::visit(ir_dereference_record *ir) { - (void) ir; - value = NULL; - /* FINISHME: Other dereference modes. */ + ir_constant *v = ir->record->constant_expression_value(); + + this->value = (v != NULL) ? v->get_record_field(ir->field) : NULL; } -- cgit v1.2.3 From 1a872b1af37927d689ec7af0921af7f3a9dcb1fd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 9 Jun 2010 17:31:02 -0700 Subject: Do simple constant folding while processing function call parameters --- ast_function.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ast_function.cpp b/ast_function.cpp index f0c1f0409a0..b0700bed5f9 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -36,7 +36,11 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters, foreach_list (n, parameters) { ast_node *const ast = exec_node_data(ast_node, n, link); - ir_rvalue *const result = ast->hir(instructions, state); + ir_rvalue *result = ast->hir(instructions, state); + + ir_constant *const constant = result->constant_expression_value(); + if (constant != NULL) + result = constant; actual_parameters->push_tail(result); count++; -- cgit v1.2.3 From 2cf0969de5e50f5e3673d5a400bedc26b2d746d6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 11:36:12 -0700 Subject: Remove redundant type checks for constant constructors All of the cases (e.g., arrays and structures) that were being filtered by these tests were already filtered by the earlier is_numeric and is_boolean tests. --- ast_function.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index b0700bed5f9..aba43749e06 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -548,9 +548,6 @@ ast_function_expression::hir(exec_list *instructions, * constant representing the complete collection of parameters. */ if (all_parameters_are_constant - && (sig->return_type->is_scalar() - || sig->return_type->is_vector() - || sig->return_type->is_matrix()) && (components_used >= type_components)) return new ir_constant(sig->return_type, & actual_parameters); else -- cgit v1.2.3 From 9b92af9ebc018eab63623812984a77f3aa834fe0 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 12:20:12 -0700 Subject: ir_constant_visitor: Handle array access of constant vectors and matrices --- ir_constant_expression.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 8e9e74bb7d8..a7c4fe6382e 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -557,9 +557,57 @@ ir_constant_visitor::visit(ir_dereference_variable *ir) void ir_constant_visitor::visit(ir_dereference_array *ir) { - (void) ir; - value = NULL; - /* FINISHME: Other dereference modes. */ + ir_constant *array = ir->array->constant_expression_value(); + ir_constant *idx = ir->array_index->constant_expression_value(); + + this->value = NULL; + + if ((array != NULL) && (idx != NULL)) { + if (array->type->is_matrix()) { + /* Array access of a matrix results in a vector. + */ + const unsigned column = idx->value.u[0]; + + const glsl_type *const column_type = array->type->column_type(); + + /* Offset in the constant matrix to the first element of the column + * to be extracted. + */ + const unsigned mat_idx = column * column_type->vector_elements; + + union { + unsigned u[4]; + float f[4]; + } data; + + switch (column_type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + for (unsigned i = 0; i < column_type->vector_elements; i++) + data.u[i] = array->value.u[mat_idx + i]; + + break; + + case GLSL_TYPE_FLOAT: + for (unsigned i = 0; i < column_type->vector_elements; i++) + data.f[i] = array->value.f[mat_idx + i]; + + break; + + default: + assert(!"Should not get here."); + break; + } + + this->value = new ir_constant(column_type, &data); + } else if (array->type->is_vector()) { + const unsigned component = idx->value.u[0]; + + this->value = new ir_constant(array, component); + } else { + /* FINISHME: Handle access of constant arrays. */ + } + } } -- cgit v1.2.3 From c2ba6190921be014fecaca0a5627ecc72fa7b2a1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 12:30:28 -0700 Subject: ir_constant_visitor: Handle constant swizzles --- ir_constant_expression.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index a7c4fe6382e..781166a8a26 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -538,8 +538,33 @@ ir_constant_visitor::visit(ir_texture *ir) void ir_constant_visitor::visit(ir_swizzle *ir) { - (void) ir; - value = NULL; + ir_constant *v = ir->val->constant_expression_value(); + + this->value = NULL; + + if (v != NULL) { + union { + float f[4]; + unsigned u[4]; + bool b[4]; + } data; + + const unsigned swiz_idx[4] = { + ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w + }; + + for (unsigned i = 0; i < ir->mask.num_components; i++) { + switch (v->type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break; + case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break; + case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break; + default: assert(!"Should not get here."); break; + } + } + + this->value = new ir_constant(ir->type, &data); + } } -- cgit v1.2.3 From 0ad76c67675c35a65a79752058f53eee74947ba5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 12:56:26 -0700 Subject: Rearrange code in HIR conversion of ?: operator There are no functional changes. Code is just moved arround. This prepares for the next set of changes that do change the functionality. --- ast_to_hir.cpp | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 307e4483696..b8375b3e57a 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1000,23 +1000,11 @@ ast_expression::hir(exec_list *instructions, * the if-statement assigns a value to the anonymous temporary. This * temporary is the r-value of the expression. */ - ir_variable *const tmp = generate_temporary(glsl_type::error_type, - instructions, state); - - ir_if *const stmt = new ir_if(op[0]); - instructions->push_tail(stmt); - - op[1] = this->subexpressions[1]->hir(& stmt->then_instructions, state); - ir_dereference *const then_deref = new ir_dereference_variable(tmp); - ir_assignment *const then_assign = - new ir_assignment(then_deref, op[1], NULL); - stmt->then_instructions.push_tail(then_assign); + exec_list then_instructions; + exec_list else_instructions; - op[2] = this->subexpressions[2]->hir(& stmt->else_instructions, state); - ir_dereference *const else_deref = new ir_dereference_variable(tmp); - ir_assignment *const else_assign = - new ir_assignment(else_deref, op[2], NULL); - stmt->else_instructions.push_tail(else_assign); + op[1] = this->subexpressions[1]->hir(&then_instructions, state); + op[2] = this->subexpressions[2]->hir(&else_instructions, state); /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: * @@ -1035,12 +1023,30 @@ ast_expression::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "Second and third operands of ?: " "operator must have matching types."); error_emitted = true; + type = glsl_type::error_type; } else { - tmp->type = op[1]->type; + type = op[1]->type; } + ir_variable *const tmp = generate_temporary(type, + instructions, state); + + ir_if *const stmt = new ir_if(op[0]); + instructions->push_tail(stmt); + + then_instructions.move_nodes_to(& stmt->then_instructions); + ir_dereference *const then_deref = new ir_dereference_variable(tmp); + ir_assignment *const then_assign = + new ir_assignment(then_deref, op[1], NULL); + stmt->then_instructions.push_tail(then_assign); + + else_instructions.move_nodes_to(& stmt->else_instructions); + ir_dereference *const else_deref = new ir_dereference_variable(tmp); + ir_assignment *const else_assign = + new ir_assignment(else_deref, op[2], NULL); + stmt->else_instructions.push_tail(else_assign); + result = new ir_dereference_variable(tmp); - type = tmp->type; break; } -- cgit v1.2.3 From 7825d3d15710fdfcfc503754862963aac8065480 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 13:45:51 -0700 Subject: Treat ?: with all constant subexpressions as a constant expression --- ast_to_hir.cpp | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index b8375b3e57a..927a9e4779f 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1028,25 +1028,35 @@ ast_expression::hir(exec_list *instructions, type = op[1]->type; } - ir_variable *const tmp = generate_temporary(type, - instructions, state); + ir_constant *cond_val = op[0]->constant_expression_value(); + ir_constant *then_val = op[1]->constant_expression_value(); + ir_constant *else_val = op[2]->constant_expression_value(); + + if (then_instructions.is_empty() + && else_instructions.is_empty() + && (cond_val != NULL) && (then_val != NULL) && (else_val != NULL)) { + result = (cond_val->value.b[0]) ? then_val : else_val; + } else { + ir_variable *const tmp = generate_temporary(type, + instructions, state); - ir_if *const stmt = new ir_if(op[0]); - instructions->push_tail(stmt); + ir_if *const stmt = new ir_if(op[0]); + instructions->push_tail(stmt); - then_instructions.move_nodes_to(& stmt->then_instructions); - ir_dereference *const then_deref = new ir_dereference_variable(tmp); - ir_assignment *const then_assign = - new ir_assignment(then_deref, op[1], NULL); - stmt->then_instructions.push_tail(then_assign); + then_instructions.move_nodes_to(& stmt->then_instructions); + ir_dereference *const then_deref = new ir_dereference_variable(tmp); + ir_assignment *const then_assign = + new ir_assignment(then_deref, op[1], NULL); + stmt->then_instructions.push_tail(then_assign); - else_instructions.move_nodes_to(& stmt->else_instructions); - ir_dereference *const else_deref = new ir_dereference_variable(tmp); - ir_assignment *const else_assign = - new ir_assignment(else_deref, op[2], NULL); - stmt->else_instructions.push_tail(else_assign); + else_instructions.move_nodes_to(& stmt->else_instructions); + ir_dereference *const else_deref = new ir_dereference_variable(tmp); + ir_assignment *const else_assign = + new ir_assignment(else_deref, op[2], NULL); + stmt->else_instructions.push_tail(else_assign); - result = new ir_dereference_variable(tmp); + result = new ir_dereference_variable(tmp); + } break; } -- cgit v1.2.3 From 39d6dd3537ce436806dbb5e7f6fa7c5477babb8e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 13:46:30 -0700 Subject: ir_constant_visitor: Handle bool-to-int and int-to-bool --- ir_constant_expression.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 781166a8a26..a3ce6e7e591 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -183,6 +183,21 @@ ir_constant_visitor::visit(ir_expression *ir) b[c] = bool(op[0]->value.f[c]); } break; + case ir_unop_b2i: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + u[c] = op[0]->value.b[c] ? 1 : 0; + i[c] = u[c]; + } + break; + case ir_unop_i2b: + assert(op[0]->type->is_integer()); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + b[c] = bool(op[0]->value.u[c]); + } + break; case ir_unop_neg: type = ir->type; -- cgit v1.2.3 From be1d2bfdeab5781b6546b704b566aa214e79da06 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 14:01:44 -0700 Subject: Matrix and vector constructors with a single constant scalar are constant --- ast_function.cpp | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- ir.h | 18 +++++--- 2 files changed, 131 insertions(+), 10 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index aba43749e06..d89266b9cc7 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -338,6 +338,100 @@ constant_record_constructor(const glsl_type *constructor_type, } +/** + * Generate data for a constant matrix constructor w/a single scalar parameter + * + * Matrix constructors in GLSL can be passed a single scalar of the + * approriate type. In these cases, the resulting matrix is the identity + * matrix multipled by the specified scalar. This function generates data for + * that matrix. + * + * \param type Type of the desired matrix. + * \param initializer Scalar value used to initialize the matrix diagonal. + * \param data Location to store the resulting matrix. + */ +void +generate_constructor_matrix(const glsl_type *type, ir_constant *initializer, + ir_constant_data *data) +{ + switch (type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + for (unsigned i = 0; i < type->components(); i++) + data->u[i] = 0; + + for (unsigned i = 0; i < type->matrix_columns; i++) { + /* The array offset of the ith row and column of the matrix. + */ + const unsigned idx = (i * type->vector_elements) + i; + + data->u[idx] = initializer->value.u[0]; + } + break; + + case GLSL_TYPE_FLOAT: + for (unsigned i = 0; i < type->components(); i++) + data->f[i] = 0; + + for (unsigned i = 0; i < type->matrix_columns; i++) { + /* The array offset of the ith row and column of the matrix. + */ + const unsigned idx = (i * type->vector_elements) + i; + + data->f[idx] = initializer->value.f[0]; + } + + break; + + default: + assert(!"Should not get here."); + break; + } +} + + +/** + * Generate data for a constant vector constructor w/a single scalar parameter + * + * Vector constructors in GLSL can be passed a single scalar of the + * approriate type. In these cases, the resulting vector contains the specified + * value in all components. This function generates data for that vector. + * + * \param type Type of the desired vector. + * \param initializer Scalar value used to initialize the vector. + * \param data Location to store the resulting vector data. + */ +void +generate_constructor_vector(const glsl_type *type, ir_constant *initializer, + ir_constant_data *data) +{ + switch (type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + for (unsigned i = 0; i < type->components(); i++) + data->u[i] = initializer->value.u[0]; + + break; + + case GLSL_TYPE_FLOAT: + for (unsigned i = 0; i < type->components(); i++) + data->f[i] = initializer->value.f[0]; + + break; + + case GLSL_TYPE_BOOL: + for (unsigned i = 0; i < type->components(); i++) + data->b[i] = initializer->value.b[0]; + + break; + + default: + assert(!"Should not get here."); + break; + } +} + + ir_rvalue * ast_function_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -547,10 +641,31 @@ ast_function_expression::hir(exec_list *instructions, /* If all of the parameters are trivially constant, create a * constant representing the complete collection of parameters. */ - if (all_parameters_are_constant - && (components_used >= type_components)) - return new ir_constant(sig->return_type, & actual_parameters); - else + if (all_parameters_are_constant) { + if (components_used >= type_components) + return new ir_constant(sig->return_type, & actual_parameters); + + assert(sig->return_type->is_vector() + || sig->return_type->is_matrix()); + + /* Constructors with exactly one component are special for + * vectors and matrices. For vectors it causes all elements of + * the vector to be filled with the value. For matrices it + * causes the matrix to be filled with 0 and the diagonal to be + * filled with the value. + */ + ir_constant_data data; + ir_constant *const initializer = + (ir_constant *) actual_parameters.head; + if (sig->return_type->is_matrix()) + generate_constructor_matrix(sig->return_type, initializer, + &data); + else + generate_constructor_vector(sig->return_type, initializer, + &data); + + return new ir_constant(sig->return_type, &data); + } else return new ir_call(sig, & actual_parameters); } else { /* FINISHME: Log a better error message here. G++ will show the diff --git a/ir.h b/ir.h index 718c495fb30..1fdd125d8ac 100644 --- a/ir.h +++ b/ir.h @@ -1018,6 +1018,17 @@ public: }; +/** + * Data stored in an ir_constant + */ +union ir_constant_data { + unsigned u[16]; + int i[16]; + float f[16]; + bool b[16]; +}; + + class ir_constant : public ir_rvalue { public: ir_constant(const struct glsl_type *type, const void *data); @@ -1080,12 +1091,7 @@ public: * by the type associated with the \c ir_instruction. Constants may be * scalars, vectors, or matrices. */ - union { - unsigned u[16]; - int i[16]; - float f[16]; - bool b[16]; - } value; + union ir_constant_data value; exec_list components; -- cgit v1.2.3 From 0bb70a30d5adbbd2b187f3e714420f2ce6f49046 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 15:49:49 -0700 Subject: ir_constant_visitor: Use 'union ir_constant_data' instead of open-coded version --- ir_constant_expression.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index a3ce6e7e591..4c92478db1d 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -558,11 +558,7 @@ ir_constant_visitor::visit(ir_swizzle *ir) this->value = NULL; if (v != NULL) { - union { - float f[4]; - unsigned u[4]; - bool b[4]; - } data; + ir_constant_data data; const unsigned swiz_idx[4] = { ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w @@ -615,10 +611,7 @@ ir_constant_visitor::visit(ir_dereference_array *ir) */ const unsigned mat_idx = column * column_type->vector_elements; - union { - unsigned u[4]; - float f[4]; - } data; + ir_constant_data data; switch (column_type->base_type) { case GLSL_TYPE_UINT: -- cgit v1.2.3 From 4daaab6040d2f2b6b366ec1007772e0793177cee Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 16:08:47 -0700 Subject: ir_constant_visitor: Use 'union ir_constant_data' in expression handler --- ir_constant_expression.cpp | 143 ++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 80 deletions(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 4c92478db1d..d77921ac895 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -131,10 +131,7 @@ ir_constant_visitor::visit(ir_expression *ir) value = NULL; ir_constant *op[2]; unsigned int operand, c; - unsigned u[16]; - int i[16]; - float f[16]; - bool b[16]; + ir_constant_data data; const glsl_type *type = NULL; for (operand = 0; operand < ir->get_num_operands(); operand++) { @@ -148,14 +145,14 @@ ir_constant_visitor::visit(ir_expression *ir) type = ir->operands[0]->type; assert(type->base_type == GLSL_TYPE_BOOL); for (c = 0; c < ir->operands[0]->type->components(); c++) - b[c] = !op[0]->value.b[c]; + data.b[c] = !op[0]->value.b[c]; break; case ir_unop_f2i: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - i[c] = op[0]->value.f[c]; + data.i[c] = op[0]->value.f[c]; } break; case ir_unop_i2f: @@ -164,38 +161,37 @@ ir_constant_visitor::visit(ir_expression *ir) type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { if (op[0]->type->base_type == GLSL_TYPE_INT) - f[c] = op[0]->value.i[c]; + data.f[c] = op[0]->value.i[c]; else - f[c] = op[0]->value.u[c]; + data.f[c] = op[0]->value.u[c]; } break; case ir_unop_b2f: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - f[c] = op[0]->value.b[c] ? 1.0 : 0.0; + data.f[c] = op[0]->value.b[c] ? 1.0 : 0.0; } break; case ir_unop_f2b: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - b[c] = bool(op[0]->value.f[c]); + data.b[c] = bool(op[0]->value.f[c]); } break; case ir_unop_b2i: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - u[c] = op[0]->value.b[c] ? 1 : 0; - i[c] = u[c]; + data.u[c] = op[0]->value.b[c] ? 1 : 0; } break; case ir_unop_i2b: assert(op[0]->type->is_integer()); type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - b[c] = bool(op[0]->value.u[c]); + data.b[c] = bool(op[0]->value.u[c]); } break; @@ -204,13 +200,13 @@ ir_constant_visitor::visit(ir_expression *ir) for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (type->base_type) { case GLSL_TYPE_UINT: - u[c] = -op[0]->value.u[c]; + data.u[c] = -op[0]->value.u[c]; break; case GLSL_TYPE_INT: - i[c] = -op[0]->value.i[c]; + data.i[c] = -op[0]->value.i[c]; break; case GLSL_TYPE_FLOAT: - f[c] = -op[0]->value.f[c]; + data.f[c] = -op[0]->value.f[c]; break; default: assert(0); @@ -224,15 +220,15 @@ ir_constant_visitor::visit(ir_expression *ir) for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (type->base_type) { case GLSL_TYPE_UINT: - u[c] = op[0]->value.u[c]; + data.u[c] = op[0]->value.u[c]; break; case GLSL_TYPE_INT: - i[c] = op[0]->value.i[c]; - if (i[c] < 0) - i[c] = -i[c]; + data.i[c] = op[0]->value.i[c]; + if (data.i[c] < 0) + data.i[c] = -data.i[c]; break; case GLSL_TYPE_FLOAT: - f[c] = fabs(op[0]->value.f[c]); + data.f[c] = fabs(op[0]->value.f[c]); break; default: assert(0); @@ -247,15 +243,15 @@ ir_constant_visitor::visit(ir_expression *ir) switch (type->base_type) { case GLSL_TYPE_UINT: if (op[0]->value.u[c] != 0.0) - u[c] = 1 / op[0]->value.u[c]; + data.u[c] = 1 / op[0]->value.u[c]; break; case GLSL_TYPE_INT: if (op[0]->value.i[c] != 0.0) - i[c] = 1 / op[0]->value.i[c]; + data.i[c] = 1 / op[0]->value.i[c]; break; case GLSL_TYPE_FLOAT: if (op[0]->value.f[c] != 0.0) - f[c] = 1.0 / op[0]->value.f[c]; + data.f[c] = 1.0 / op[0]->value.f[c]; break; default: assert(0); @@ -267,7 +263,7 @@ ir_constant_visitor::visit(ir_expression *ir) assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - f[c] = 1.0 / sqrtf(op[0]->value.f[c]); + data.f[c] = 1.0 / sqrtf(op[0]->value.f[c]); } break; @@ -275,7 +271,7 @@ ir_constant_visitor::visit(ir_expression *ir) assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - f[c] = sqrtf(op[0]->value.f[c]); + data.f[c] = sqrtf(op[0]->value.f[c]); } break; @@ -283,7 +279,7 @@ ir_constant_visitor::visit(ir_expression *ir) assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - f[c] = expf(op[0]->value.f[c]); + data.f[c] = expf(op[0]->value.f[c]); } break; @@ -291,7 +287,7 @@ ir_constant_visitor::visit(ir_expression *ir) assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - f[c] = logf(op[0]->value.f[c]); + data.f[c] = logf(op[0]->value.f[c]); } break; @@ -300,7 +296,7 @@ ir_constant_visitor::visit(ir_expression *ir) assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - f[c] = 0.0; + data.f[c] = 0.0; } break; @@ -310,13 +306,13 @@ ir_constant_visitor::visit(ir_expression *ir) for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - u[c] = op[0]->value.u[c] + op[1]->value.u[c]; + data.u[c] = op[0]->value.u[c] + op[1]->value.u[c]; break; case GLSL_TYPE_INT: - i[c] = op[0]->value.i[c] + op[1]->value.i[c]; + data.i[c] = op[0]->value.i[c] + op[1]->value.i[c]; break; case GLSL_TYPE_FLOAT: - f[c] = op[0]->value.f[c] + op[1]->value.f[c]; + data.f[c] = op[0]->value.f[c] + op[1]->value.f[c]; break; default: assert(0); @@ -330,13 +326,13 @@ ir_constant_visitor::visit(ir_expression *ir) for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - u[c] = op[0]->value.u[c] - op[1]->value.u[c]; + data.u[c] = op[0]->value.u[c] - op[1]->value.u[c]; break; case GLSL_TYPE_INT: - i[c] = op[0]->value.i[c] - op[1]->value.i[c]; + data.i[c] = op[0]->value.i[c] - op[1]->value.i[c]; break; case GLSL_TYPE_FLOAT: - f[c] = op[0]->value.f[c] - op[1]->value.f[c]; + data.f[c] = op[0]->value.f[c] - op[1]->value.f[c]; break; default: assert(0); @@ -351,13 +347,13 @@ ir_constant_visitor::visit(ir_expression *ir) for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - u[c] = op[0]->value.u[c] * op[1]->value.u[c]; + data.u[c] = op[0]->value.u[c] * op[1]->value.u[c]; break; case GLSL_TYPE_INT: - i[c] = op[0]->value.i[c] * op[1]->value.i[c]; + data.i[c] = op[0]->value.i[c] * op[1]->value.i[c]; break; case GLSL_TYPE_FLOAT: - f[c] = op[0]->value.f[c] * op[1]->value.f[c]; + data.f[c] = op[0]->value.f[c] * op[1]->value.f[c]; break; default: assert(0); @@ -371,13 +367,13 @@ ir_constant_visitor::visit(ir_expression *ir) for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - u[c] = op[0]->value.u[c] / op[1]->value.u[c]; + data.u[c] = op[0]->value.u[c] / op[1]->value.u[c]; break; case GLSL_TYPE_INT: - i[c] = op[0]->value.i[c] / op[1]->value.i[c]; + data.i[c] = op[0]->value.i[c] / op[1]->value.i[c]; break; case GLSL_TYPE_FLOAT: - f[c] = op[0]->value.f[c] / op[1]->value.f[c]; + data.f[c] = op[0]->value.f[c] / op[1]->value.f[c]; break; default: assert(0); @@ -389,32 +385,32 @@ ir_constant_visitor::visit(ir_expression *ir) type = ir->operands[0]->type; assert(type->base_type == GLSL_TYPE_BOOL); for (c = 0; c < ir->operands[0]->type->components(); c++) - b[c] = op[0]->value.b[c] && op[1]->value.b[c]; + data.b[c] = op[0]->value.b[c] && op[1]->value.b[c]; break; case ir_binop_logic_xor: type = ir->operands[0]->type; assert(type->base_type == GLSL_TYPE_BOOL); for (c = 0; c < ir->operands[0]->type->components(); c++) - b[c] = op[0]->value.b[c] ^ op[1]->value.b[c]; + data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c]; break; case ir_binop_logic_or: type = ir->operands[0]->type; assert(type->base_type == GLSL_TYPE_BOOL); for (c = 0; c < ir->operands[0]->type->components(); c++) - b[c] = op[0]->value.b[c] || op[1]->value.b[c]; + data.b[c] = op[0]->value.b[c] || op[1]->value.b[c]; break; case ir_binop_less: type = glsl_type::bool_type; switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - b[0] = op[0]->value.u[0] < op[1]->value.u[0]; + data.b[0] = op[0]->value.u[0] < op[1]->value.u[0]; break; case GLSL_TYPE_INT: - b[0] = op[0]->value.i[0] < op[1]->value.i[0]; + data.b[0] = op[0]->value.i[0] < op[1]->value.i[0]; break; case GLSL_TYPE_FLOAT: - b[0] = op[0]->value.f[0] < op[1]->value.f[0]; + data.b[0] = op[0]->value.f[0] < op[1]->value.f[0]; break; default: assert(0); @@ -424,13 +420,13 @@ ir_constant_visitor::visit(ir_expression *ir) type = glsl_type::bool_type; switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - b[0] = op[0]->value.u[0] > op[1]->value.u[0]; + data.b[0] = op[0]->value.u[0] > op[1]->value.u[0]; break; case GLSL_TYPE_INT: - b[0] = op[0]->value.i[0] > op[1]->value.i[0]; + data.b[0] = op[0]->value.i[0] > op[1]->value.i[0]; break; case GLSL_TYPE_FLOAT: - b[0] = op[0]->value.f[0] > op[1]->value.f[0]; + data.b[0] = op[0]->value.f[0] > op[1]->value.f[0]; break; default: assert(0); @@ -440,13 +436,13 @@ ir_constant_visitor::visit(ir_expression *ir) type = glsl_type::bool_type; switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - b[0] = op[0]->value.u[0] <= op[1]->value.u[0]; + data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0]; break; case GLSL_TYPE_INT: - b[0] = op[0]->value.i[0] <= op[1]->value.i[0]; + data.b[0] = op[0]->value.i[0] <= op[1]->value.i[0]; break; case GLSL_TYPE_FLOAT: - b[0] = op[0]->value.f[0] <= op[1]->value.f[0]; + data.b[0] = op[0]->value.f[0] <= op[1]->value.f[0]; break; default: assert(0); @@ -456,13 +452,13 @@ ir_constant_visitor::visit(ir_expression *ir) type = glsl_type::bool_type; switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - b[0] = op[0]->value.u[0] >= op[1]->value.u[0]; + data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0]; break; case GLSL_TYPE_INT: - b[0] = op[0]->value.i[0] >= op[1]->value.i[0]; + data.b[0] = op[0]->value.i[0] >= op[1]->value.i[0]; break; case GLSL_TYPE_FLOAT: - b[0] = op[0]->value.f[0] >= op[1]->value.f[0]; + data.b[0] = op[0]->value.f[0] >= op[1]->value.f[0]; break; default: assert(0); @@ -472,20 +468,20 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_binop_equal: if (ir->operands[0]->type == ir->operands[1]->type) { type = glsl_type::bool_type; - b[0] = true; + data.b[0] = true; for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - b[0] = b[0] && op[0]->value.u[c] == op[1]->value.u[c]; + data.b[0] = data.b[0] && op[0]->value.u[c] == op[1]->value.u[c]; break; case GLSL_TYPE_INT: - b[0] = b[0] && op[0]->value.i[c] == op[1]->value.i[c]; + data.b[0] = data.b[0] && op[0]->value.i[c] == op[1]->value.i[c]; break; case GLSL_TYPE_FLOAT: - b[0] = b[0] && op[0]->value.f[c] == op[1]->value.f[c]; + data.b[0] = data.b[0] && op[0]->value.f[c] == op[1]->value.f[c]; break; case GLSL_TYPE_BOOL: - b[0] = b[0] && op[0]->value.b[c] == op[1]->value.b[c]; + data.b[0] = data.b[0] && op[0]->value.b[c] == op[1]->value.b[c]; break; default: assert(0); @@ -496,20 +492,20 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_binop_nequal: if (ir->operands[0]->type == ir->operands[1]->type) { type = glsl_type::bool_type; - b[0] = false; + data.b[0] = false; for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - b[0] = b[0] || op[0]->value.u[c] != op[1]->value.u[c]; + data.b[0] = data.b[0] || op[0]->value.u[c] != op[1]->value.u[c]; break; case GLSL_TYPE_INT: - b[0] = b[0] || op[0]->value.i[c] != op[1]->value.i[c]; + data.b[0] = data.b[0] || op[0]->value.i[c] != op[1]->value.i[c]; break; case GLSL_TYPE_FLOAT: - b[0] = b[0] || op[0]->value.f[c] != op[1]->value.f[c]; + data.b[0] = data.b[0] || op[0]->value.f[c] != op[1]->value.f[c]; break; case GLSL_TYPE_BOOL: - b[0] = b[0] || op[0]->value.b[c] != op[1]->value.b[c]; + data.b[0] = data.b[0] || op[0]->value.b[c] != op[1]->value.b[c]; break; default: assert(0); @@ -523,20 +519,7 @@ ir_constant_visitor::visit(ir_expression *ir) } if (type) { - switch (type->base_type) { - case GLSL_TYPE_UINT: - value = new ir_constant(type, u); - break; - case GLSL_TYPE_INT: - value = new ir_constant(type, i); - break; - case GLSL_TYPE_FLOAT: - value = new ir_constant(type, f); - break; - case GLSL_TYPE_BOOL: - value = new ir_constant(type, b); - break; - } + this->value = new ir_constant(type, &data); } } -- cgit v1.2.3 From 083d75a9428cb5231a26ffbdff856a3a94b49dcc Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 16:20:43 -0700 Subject: ir_constant_visitor: Types of ir_binop_{equal,nequal} must match The types must match exactly, so there is no reason to check the types here. --- ir_constant_expression.cpp | 76 ++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index d77921ac895..3a3d994302e 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -466,50 +466,46 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_binop_equal: - if (ir->operands[0]->type == ir->operands[1]->type) { - type = glsl_type::bool_type; - data.b[0] = true; - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[0] = data.b[0] && op[0]->value.u[c] == op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[0] = data.b[0] && op[0]->value.i[c] == op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[0] = data.b[0] && op[0]->value.f[c] == op[1]->value.f[c]; - break; - case GLSL_TYPE_BOOL: - data.b[0] = data.b[0] && op[0]->value.b[c] == op[1]->value.b[c]; - break; - default: - assert(0); - } + type = glsl_type::bool_type; + data.b[0] = true; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = data.b[0] && op[0]->value.u[c] == op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[0] = data.b[0] && op[0]->value.i[c] == op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = data.b[0] && op[0]->value.f[c] == op[1]->value.f[c]; + break; + case GLSL_TYPE_BOOL: + data.b[0] = data.b[0] && op[0]->value.b[c] == op[1]->value.b[c]; + break; + default: + assert(0); } } break; case ir_binop_nequal: - if (ir->operands[0]->type == ir->operands[1]->type) { - type = glsl_type::bool_type; - data.b[0] = false; - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[0] = data.b[0] || op[0]->value.u[c] != op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[0] = data.b[0] || op[0]->value.i[c] != op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[0] = data.b[0] || op[0]->value.f[c] != op[1]->value.f[c]; - break; - case GLSL_TYPE_BOOL: - data.b[0] = data.b[0] || op[0]->value.b[c] != op[1]->value.b[c]; - break; - default: - assert(0); - } + type = glsl_type::bool_type; + data.b[0] = false; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = data.b[0] || op[0]->value.u[c] != op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[0] = data.b[0] || op[0]->value.i[c] != op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = data.b[0] || op[0]->value.f[c] != op[1]->value.f[c]; + break; + case GLSL_TYPE_BOOL: + data.b[0] = data.b[0] || op[0]->value.b[c] != op[1]->value.b[c]; + break; + default: + assert(0); } } break; -- cgit v1.2.3 From f8b88bea0fc45be02b7786efe46e941c2f6c8b5d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 16:23:52 -0700 Subject: ir_constant_visitor: Type of constant result is same as original expression The type of the resulting constant must be the same as the type of the original expression. The changes to the code require that the case where an unhandled expression is received, and there really shouldn't be any of these, must be an exit point. --- ir_constant_expression.cpp | 70 +++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 44 deletions(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 3a3d994302e..5bb592079a9 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -132,7 +132,6 @@ ir_constant_visitor::visit(ir_expression *ir) ir_constant *op[2]; unsigned int operand, c; ir_constant_data data; - const glsl_type *type = NULL; for (operand = 0; operand < ir->get_num_operands(); operand++) { op[operand] = ir->operands[operand]->constant_expression_value(); @@ -142,15 +141,13 @@ ir_constant_visitor::visit(ir_expression *ir) switch (ir->operation) { case ir_unop_logic_not: - type = ir->operands[0]->type; - assert(type->base_type == GLSL_TYPE_BOOL); + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); for (c = 0; c < ir->operands[0]->type->components(); c++) data.b[c] = !op[0]->value.b[c]; break; case ir_unop_f2i: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { data.i[c] = op[0]->value.f[c]; } @@ -158,7 +155,6 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_i2f: assert(op[0]->type->base_type == GLSL_TYPE_UINT || op[0]->type->base_type == GLSL_TYPE_INT); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { if (op[0]->type->base_type == GLSL_TYPE_INT) data.f[c] = op[0]->value.i[c]; @@ -168,37 +164,32 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_unop_b2f: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = op[0]->value.b[c] ? 1.0 : 0.0; } break; case ir_unop_f2b: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { data.b[c] = bool(op[0]->value.f[c]); } break; case ir_unop_b2i: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { data.u[c] = op[0]->value.b[c] ? 1 : 0; } break; case ir_unop_i2b: assert(op[0]->type->is_integer()); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { data.b[c] = bool(op[0]->value.u[c]); } break; case ir_unop_neg: - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (type->base_type) { + switch (ir->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = -op[0]->value.u[c]; break; @@ -216,9 +207,8 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_abs: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (type->base_type) { + switch (ir->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = op[0]->value.u[c]; break; @@ -238,9 +228,8 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_rcp: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (type->base_type) { + switch (ir->type->base_type) { case GLSL_TYPE_UINT: if (op[0]->value.u[c] != 0.0) data.u[c] = 1 / op[0]->value.u[c]; @@ -261,7 +250,6 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_rsq: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = 1.0 / sqrtf(op[0]->value.f[c]); } @@ -269,7 +257,6 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_sqrt: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = sqrtf(op[0]->value.f[c]); } @@ -277,7 +264,6 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_exp: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = expf(op[0]->value.f[c]); } @@ -285,7 +271,6 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_log: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = logf(op[0]->value.f[c]); } @@ -294,7 +279,6 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_dFdx: case ir_unop_dFdy: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - type = ir->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = 0.0; } @@ -302,7 +286,6 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_binop_add: if (ir->operands[0]->type == ir->operands[1]->type) { - type = ir->operands[0]->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: @@ -318,11 +301,13 @@ ir_constant_visitor::visit(ir_expression *ir) assert(0); } } - } + } else + /* FINISHME: Support operations with non-equal types. */ + return; + break; case ir_binop_sub: if (ir->operands[0]->type == ir->operands[1]->type) { - type = ir->operands[0]->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: @@ -338,12 +323,14 @@ ir_constant_visitor::visit(ir_expression *ir) assert(0); } } - } + } else + /* FINISHME: Support operations with non-equal types. */ + return; + break; case ir_binop_mul: if (ir->operands[0]->type == ir->operands[1]->type && !ir->operands[0]->type->is_matrix()) { - type = ir->operands[0]->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: @@ -359,11 +346,13 @@ ir_constant_visitor::visit(ir_expression *ir) assert(0); } } - } + } else + /* FINISHME: Support operations with non-equal types. */ + return; + break; case ir_binop_div: if (ir->operands[0]->type == ir->operands[1]->type) { - type = ir->operands[0]->type; for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: @@ -379,29 +368,28 @@ ir_constant_visitor::visit(ir_expression *ir) assert(0); } } - } + } else + /* FINISHME: Support operations with non-equal types. */ + return; + break; case ir_binop_logic_and: - type = ir->operands[0]->type; - assert(type->base_type == GLSL_TYPE_BOOL); + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); for (c = 0; c < ir->operands[0]->type->components(); c++) data.b[c] = op[0]->value.b[c] && op[1]->value.b[c]; break; case ir_binop_logic_xor: - type = ir->operands[0]->type; - assert(type->base_type == GLSL_TYPE_BOOL); + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); for (c = 0; c < ir->operands[0]->type->components(); c++) data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c]; break; case ir_binop_logic_or: - type = ir->operands[0]->type; - assert(type->base_type == GLSL_TYPE_BOOL); + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); for (c = 0; c < ir->operands[0]->type->components(); c++) data.b[c] = op[0]->value.b[c] || op[1]->value.b[c]; break; case ir_binop_less: - type = glsl_type::bool_type; switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = op[0]->value.u[0] < op[1]->value.u[0]; @@ -417,7 +405,6 @@ ir_constant_visitor::visit(ir_expression *ir) } break; case ir_binop_greater: - type = glsl_type::bool_type; switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = op[0]->value.u[0] > op[1]->value.u[0]; @@ -433,7 +420,6 @@ ir_constant_visitor::visit(ir_expression *ir) } break; case ir_binop_lequal: - type = glsl_type::bool_type; switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0]; @@ -449,7 +435,6 @@ ir_constant_visitor::visit(ir_expression *ir) } break; case ir_binop_gequal: - type = glsl_type::bool_type; switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0]; @@ -466,7 +451,6 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_binop_equal: - type = glsl_type::bool_type; data.b[0] = true; for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { @@ -488,7 +472,6 @@ ir_constant_visitor::visit(ir_expression *ir) } break; case ir_binop_nequal: - type = glsl_type::bool_type; data.b[0] = false; for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { @@ -511,12 +494,11 @@ ir_constant_visitor::visit(ir_expression *ir) break; default: - break; + /* FINISHME: Should handle all expression types. */ + return; } - if (type) { - this->value = new ir_constant(type, &data); - } + this->value = new ir_constant(ir->type, &data); } -- cgit v1.2.3 From 4976e57448b2d4ca753e95ef2162758542a69a77 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 16:43:42 -0700 Subject: ir_reader: Use 'union ir_constant_data' in read_constant --- ir_reader.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/ir_reader.cpp b/ir_reader.cpp index f05682640fd..23981a0f514 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -750,10 +750,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) const glsl_type *const base_type = type->get_base_type(); - unsigned u[16]; - int i[16]; - float f[16]; - bool b[16]; + ir_constant_data data; // Read in list of values (at most 16). int k = 0; @@ -771,7 +768,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) ir_read_error(st, values, "expected numbers"); return NULL; } - f[k] = value->fvalue(); + data.f[k] = value->fvalue(); } else { s_int *value = SX_AS_INT(expr); if (value == NULL) { @@ -781,15 +778,15 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) switch (base_type->base_type) { case GLSL_TYPE_UINT: { - u[k] = value->value(); + data.u[k] = value->value(); break; } case GLSL_TYPE_INT: { - i[k] = value->value(); + data.i[k] = value->value(); break; } case GLSL_TYPE_BOOL: { - b[k] = value->value(); + data.b[k] = value->value(); break; } default: @@ -799,17 +796,8 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) } ++k; } - switch (base_type->base_type) { - case GLSL_TYPE_UINT: - return new ir_constant(type, u); - case GLSL_TYPE_INT: - return new ir_constant(type, i); - case GLSL_TYPE_BOOL: - return new ir_constant(type, b); - case GLSL_TYPE_FLOAT: - return new ir_constant(type, f); - } - return NULL; // should not be reached + + return new ir_constant(type, &data); } static ir_dereference * -- cgit v1.2.3 From b74b43e4ba27a9b2e9da0f3499af261a4b997b00 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 16:52:09 -0700 Subject: Use statically typed ir_constant constructors wherever possible --- ast_function.cpp | 11 ++++++++--- ast_to_hir.cpp | 8 ++++---- glsl_types.cpp | 7 +++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index d89266b9cc7..279c45eac0e 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -170,8 +170,13 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) } break; case GLSL_TYPE_BOOL: { - int z = 0; - ir_constant *const zero = new ir_constant(src->type, &z); + ir_constant *zero = NULL; + + switch (b) { + case GLSL_TYPE_UINT: zero = new ir_constant(unsigned(0)); break; + case GLSL_TYPE_INT: zero = new ir_constant(int(0)); break; + case GLSL_TYPE_FLOAT: zero = new ir_constant(0.0f); break; + } result = new ir_expression(ir_binop_nequal, desired_type, src, zero); } @@ -211,7 +216,7 @@ dereference_component(ir_rvalue *src, unsigned component) */ const int c = component / src->type->column_type()->vector_elements; const int r = component % src->type->column_type()->vector_elements; - ir_constant *const col_index = new ir_constant(glsl_type::int_type, &c); + ir_constant *const col_index = new ir_constant(c); ir_dereference *const col = new ir_dereference_array(src, col_index); col->type = src->type->column_type(); diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 927a9e4779f..1c0b98b10ca 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1257,22 +1257,22 @@ ast_expression::hir(exec_list *instructions, case ast_int_constant: type = glsl_type::int_type; - result = new ir_constant(type, & this->primary_expression); + result = new ir_constant(this->primary_expression.int_constant); break; case ast_uint_constant: type = glsl_type::uint_type; - result = new ir_constant(type, & this->primary_expression); + result = new ir_constant(this->primary_expression.uint_constant); break; case ast_float_constant: type = glsl_type::float_type; - result = new ir_constant(type, & this->primary_expression); + result = new ir_constant(this->primary_expression.float_constant); break; case ast_bool_constant: type = glsl_type::bool_type; - result = new ir_constant(type, & this->primary_expression); + result = new ir_constant(bool(this->primary_expression.bool_constant)); break; case ast_sequence: { diff --git a/glsl_types.cpp b/glsl_types.cpp index 4b6a61a13c2..290756d453c 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -359,8 +359,7 @@ generate_mat_body_from_scalar(exec_list *instructions, inst = new ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); - const float z = 0.0f; - ir_constant *const zero = new ir_constant(glsl_type::float_type, &z); + ir_constant *const zero = new ir_constant(0.0f); for (unsigned i = 1; i < column_type->vector_elements; i++) { ir_dereference *const lhs_ref = new ir_dereference_variable(column); @@ -382,7 +381,7 @@ generate_mat_body_from_scalar(exec_list *instructions, swiz[5 - i], swiz[6 - i], column_type->vector_elements); - ir_constant *const idx = new ir_constant(glsl_type::int_type, &i); + ir_constant *const idx = new ir_constant(int(i)); ir_dereference *const lhs = new ir_dereference_array(declarations[16], idx); @@ -413,7 +412,7 @@ generate_mat_body_from_N_scalars(exec_list *instructions, */ for (unsigned i = 0; i < column_type->vector_elements; i++) { for (unsigned j = 0; j < row_type->vector_elements; j++) { - ir_constant *row_index = new ir_constant(glsl_type::int_type, &i); + ir_constant *row_index = new ir_constant(int(i)); ir_dereference *const row_access = new ir_dereference_array(declarations[16], row_index); -- cgit v1.2.3 From 824b659d917a5f14a1f66b891d25036ef9f9adc6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 11 Jun 2010 16:57:47 -0700 Subject: ir_constant: Eliminate 'void *' constructor All of the places that had been using the (glsl_type *, void *) constructor were actually passing an ir_constant_data for the 'void *'. The code can be greatly simplified by replacing this constructor with a (glsl_type *, ir_constant_data *) constructor. This should also help prevent one class of invalid uses of the old constructor. --- ir.cpp | 19 +++++-------------- ir.h | 2 +- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/ir.cpp b/ir.cpp index 38e2739449c..d50293d993c 100644 --- a/ir.cpp +++ b/ir.cpp @@ -189,23 +189,14 @@ ir_constant::ir_constant() /* empty */ } -ir_constant::ir_constant(const struct glsl_type *type, const void *data) +ir_constant::ir_constant(const struct glsl_type *type, + const ir_constant_data *data) { - unsigned size = 0; + assert((type->base_type >= GLSL_TYPE_UINT) + && (type->base_type <= GLSL_TYPE_BOOL)); this->type = type; - switch (type->base_type) { - case GLSL_TYPE_UINT: size = sizeof(this->value.u[0]); break; - case GLSL_TYPE_INT: size = sizeof(this->value.i[0]); break; - case GLSL_TYPE_FLOAT: size = sizeof(this->value.f[0]); break; - case GLSL_TYPE_BOOL: size = sizeof(this->value.b[0]); break; - default: - /* FINISHME: What to do? Exceptions are not the answer. - */ - break; - } - - memcpy(& this->value, data, size * type->components()); + memcpy(& this->value, data, sizeof(this->value)); } ir_constant::ir_constant(float f) diff --git a/ir.h b/ir.h index 1fdd125d8ac..33b6069ea5c 100644 --- a/ir.h +++ b/ir.h @@ -1031,7 +1031,7 @@ union ir_constant_data { class ir_constant : public ir_rvalue { public: - ir_constant(const struct glsl_type *type, const void *data); + ir_constant(const struct glsl_type *type, const ir_constant_data *data); ir_constant(bool b); ir_constant(unsigned int u); ir_constant(int i); -- cgit v1.2.3 From 61d4aa041f800429127aab3263c50cbc6e69ae50 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 14 Jun 2010 14:46:09 -0700 Subject: Move stand-alone compiler main routine to main.cpp --- Makefile.am | 1 + glsl_parser_extras.cpp | 148 ----------------------------------------- main.cpp | 175 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 176 insertions(+), 148 deletions(-) create mode 100644 main.cpp diff --git a/Makefile.am b/Makefile.am index 544d446aec9..44748dc886e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,6 +24,7 @@ AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = glsl glsl_SOURCES = \ + main.cpp \ builtin_types.h \ symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 5ebbc27aca8..8cf765f95de 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -22,21 +22,12 @@ */ #include #include -#include #include #include - -#include -#include -#include -#include #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" -#include "ir_optimization.h" -#include "ir_print_visitor.h" -#include "ir_reader.h" const char * _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) @@ -639,142 +630,3 @@ ast_struct_specifier::ast_struct_specifier(char *identifier, name = identifier; this->declarations.push_degenerate_list_at_head(&declarator_list->link); } - - -static char * -load_text_file(const char *file_name, size_t *size) -{ - char *text = NULL; - struct stat st; - ssize_t total_read = 0; - int fd = open(file_name, O_RDONLY); - - *size = 0; - if (fd < 0) { - return NULL; - } - - if (fstat(fd, & st) == 0) { - text = (char *) malloc(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'; - *size = total_read; - } - } - - close(fd); - - return text; -} - - -int -main(int argc, char **argv) -{ - struct _mesa_glsl_parse_state state; - char *shader; - size_t shader_len; - exec_list instructions; - - if (argc < 3) { - printf("Usage: %s [v|g|f|i] \n", argv[0]); - return EXIT_FAILURE; - } - - memset(& state, 0, sizeof(state)); - - switch (argv[1][0]) { - case 'v': - state.target = vertex_shader; - break; - case 'g': - state.target = geometry_shader; - break; - case 'f': - state.target = fragment_shader; - break; - case 'i': - state.target = ir_shader; - break; - default: - printf("Usage: %s [v|g|f|i] \n", argv[0]); - return EXIT_FAILURE; - } - - shader = load_text_file(argv[2], & shader_len); - - state.scanner = NULL; - state.translation_unit.make_empty(); - state.symbols = new glsl_symbol_table; - state.error = false; - state.temp_index = 0; - state.loop_or_switch_nesting = NULL; - state.ARB_texture_rectangle_enable = true; - - if (state.target != ir_shader) { - _mesa_glsl_lexer_ctor(& state, shader, shader_len); - _mesa_glsl_parse(& state); - _mesa_glsl_lexer_dtor(& state); - - foreach_list_const(n, &state.translation_unit) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - - if (!state.error && !state.translation_unit.is_empty()) - _mesa_ast_to_hir(&instructions, &state); - } else { - /* FINISHME: We should initialize this to the max GLSL version supported - * FINISHME: by the driver. At the moment, we don't know what that is. - */ - state.language_version = 130; - _mesa_glsl_initialize_types(&state); - - _mesa_glsl_read_ir(&state, &instructions, shader); - } - - /* Optimization passes */ - if (!state.error && !instructions.is_empty()) { - bool progress; - do { - progress = false; - - progress = do_function_inlining(&instructions) || progress; - progress = do_if_simplification(&instructions) || progress; - progress = do_copy_propagation(&instructions) || progress; - progress = do_dead_code_local(&instructions) || progress; - progress = do_dead_code_unlinked(&instructions) || progress; - progress = do_constant_variable_unlinked(&instructions) || progress; - progress = do_constant_folding(&instructions) || progress; - progress = do_vec_index_to_swizzle(&instructions) || progress; - progress = do_swizzle_swizzle(&instructions) || progress; - } while (progress); - } - - /* Print out the resulting IR */ - printf("\n\n"); - - if (!state.error) { - _mesa_print_ir(&instructions, &state); - } - - delete state.symbols; - - return state.error != 0; -} diff --git a/main.cpp b/main.cpp new file mode 100644 index 00000000000..12fb70315c4 --- /dev/null +++ b/main.cpp @@ -0,0 +1,175 @@ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include + +#include +#include +#include +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" +#include "ir_optimization.h" +#include "ir_print_visitor.h" +#include "ir_reader.h" + + +static char * +load_text_file(const char *file_name, size_t *size) +{ + char *text = NULL; + struct stat st; + ssize_t total_read = 0; + int fd = open(file_name, O_RDONLY); + + *size = 0; + if (fd < 0) { + return NULL; + } + + if (fstat(fd, & st) == 0) { + text = (char *) malloc(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'; + *size = total_read; + } + } + + close(fd); + + return text; +} + + +int +main(int argc, char **argv) +{ + struct _mesa_glsl_parse_state state; + char *shader; + size_t shader_len; + exec_list instructions; + + if (argc < 3) { + printf("Usage: %s [v|g|f|i] \n", argv[0]); + return EXIT_FAILURE; + } + + memset(& state, 0, sizeof(state)); + + switch (argv[1][0]) { + case 'v': + state.target = vertex_shader; + break; + case 'g': + state.target = geometry_shader; + break; + case 'f': + state.target = fragment_shader; + break; + case 'i': + state.target = ir_shader; + break; + default: + printf("Usage: %s [v|g|f|i] \n", argv[0]); + return EXIT_FAILURE; + } + + shader = load_text_file(argv[2], & shader_len); + + state.scanner = NULL; + state.translation_unit.make_empty(); + state.symbols = new glsl_symbol_table; + state.error = false; + state.temp_index = 0; + state.loop_or_switch_nesting = NULL; + state.ARB_texture_rectangle_enable = true; + + if (state.target != ir_shader) { + _mesa_glsl_lexer_ctor(& state, shader, shader_len); + _mesa_glsl_parse(& state); + _mesa_glsl_lexer_dtor(& state); + + foreach_list_const(n, &state.translation_unit) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + + if (!state.error && !state.translation_unit.is_empty()) + _mesa_ast_to_hir(&instructions, &state); + } else { + /* FINISHME: We should initialize this to the max GLSL version supported + * FINISHME: by the driver. At the moment, we don't know what that is. + */ + state.language_version = 130; + _mesa_glsl_initialize_types(&state); + + _mesa_glsl_read_ir(&state, &instructions, shader); + } + + /* Optimization passes */ + if (!state.error && !instructions.is_empty()) { + bool progress; + do { + progress = false; + + progress = do_function_inlining(&instructions) || progress; + progress = do_if_simplification(&instructions) || progress; + progress = do_copy_propagation(&instructions) || progress; + progress = do_dead_code_local(&instructions) || progress; + progress = do_dead_code_unlinked(&instructions) || progress; + progress = do_constant_variable_unlinked(&instructions) || progress; + progress = do_constant_folding(&instructions) || progress; + progress = do_vec_index_to_swizzle(&instructions) || progress; + progress = do_swizzle_swizzle(&instructions) || progress; + } while (progress); + } + + /* Print out the resulting IR */ + printf("\n\n"); + + if (!state.error) { + _mesa_print_ir(&instructions, &state); + } + + delete state.symbols; + + return state.error != 0; +} -- cgit v1.2.3 From 54992c30b00b13232641b5d2b6479f005a60abfd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 14 Jun 2010 14:47:26 -0700 Subject: Remove ability to read "IR shaders" from stand-alone compiler --- main.cpp | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/main.cpp b/main.cpp index 12fb70315c4..a044646d713 100644 --- a/main.cpp +++ b/main.cpp @@ -33,7 +33,6 @@ #include "glsl_parser.h" #include "ir_optimization.h" #include "ir_print_visitor.h" -#include "ir_reader.h" static char * @@ -104,11 +103,8 @@ main(int argc, char **argv) case 'f': state.target = fragment_shader; break; - case 'i': - state.target = ir_shader; - break; default: - printf("Usage: %s [v|g|f|i] \n", argv[0]); + printf("Usage: %s [v|g|f] \n", argv[0]); return EXIT_FAILURE; } @@ -122,28 +118,18 @@ main(int argc, char **argv) state.loop_or_switch_nesting = NULL; state.ARB_texture_rectangle_enable = true; - if (state.target != ir_shader) { - _mesa_glsl_lexer_ctor(& state, shader, shader_len); - _mesa_glsl_parse(& state); - _mesa_glsl_lexer_dtor(& state); - - foreach_list_const(n, &state.translation_unit) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - - if (!state.error && !state.translation_unit.is_empty()) - _mesa_ast_to_hir(&instructions, &state); - } else { - /* FINISHME: We should initialize this to the max GLSL version supported - * FINISHME: by the driver. At the moment, we don't know what that is. - */ - state.language_version = 130; - _mesa_glsl_initialize_types(&state); - - _mesa_glsl_read_ir(&state, &instructions, shader); + _mesa_glsl_lexer_ctor(& state, shader, shader_len); + _mesa_glsl_parse(& state); + _mesa_glsl_lexer_dtor(& state); + + foreach_list_const(n, &state.translation_unit) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); } + if (!state.error && !state.translation_unit.is_empty()) + _mesa_ast_to_hir(&instructions, &state); + /* Optimization passes */ if (!state.error && !instructions.is_empty()) { bool progress; -- cgit v1.2.3 From 2b36895f0c5bc569e15d63d2c865bda0b6928b36 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 15 Jun 2010 12:00:37 -0700 Subject: Infer shader type from suffix on filename --- main.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/main.cpp b/main.cpp index a044646d713..d32742b05b6 100644 --- a/main.cpp +++ b/main.cpp @@ -78,6 +78,14 @@ load_text_file(const char *file_name, size_t *size) } +void +usage_fail(const char *name) +{ + printf("%s \n", name); + exit(EXIT_FAILURE); +} + + int main(int argc, char **argv) { @@ -86,29 +94,26 @@ main(int argc, char **argv) size_t shader_len; exec_list instructions; - if (argc < 3) { - printf("Usage: %s [v|g|f|i] \n", argv[0]); - return EXIT_FAILURE; - } + if (argc < 2) + usage_fail(argv[0]); memset(& state, 0, sizeof(state)); - switch (argv[1][0]) { - case 'v': + const unsigned len = strlen(argv[1]); + if (len < 6) + usage_fail(argv[0]); + + const char *const ext = & argv[1][len - 5]; + if (strncmp(".vert", ext, 5) == 0) state.target = vertex_shader; - break; - case 'g': + else if (strncmp(".geom", ext, 5) == 0) state.target = geometry_shader; - break; - case 'f': + else if (strncmp(".frag", ext, 5) == 0) state.target = fragment_shader; - break; - default: - printf("Usage: %s [v|g|f] \n", argv[0]); - return EXIT_FAILURE; - } + else + usage_fail(argv[0]); - shader = load_text_file(argv[2], & shader_len); + shader = load_text_file(argv[1], & shader_len); state.scanner = NULL; state.translation_unit.make_empty(); -- cgit v1.2.3 From fc0ef6451cfada274ecc3ea9ff5bca2bf143ab8a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 15 Jun 2010 12:03:10 -0700 Subject: Minor bits of code rearranging --- main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index d32742b05b6..9b77cc8aca4 100644 --- a/main.cpp +++ b/main.cpp @@ -97,24 +97,25 @@ main(int argc, char **argv) if (argc < 2) usage_fail(argv[0]); - memset(& state, 0, sizeof(state)); - const unsigned len = strlen(argv[1]); if (len < 6) usage_fail(argv[0]); const char *const ext = & argv[1][len - 5]; + enum _mesa_glsl_parser_targets target; if (strncmp(".vert", ext, 5) == 0) - state.target = vertex_shader; + target = vertex_shader; else if (strncmp(".geom", ext, 5) == 0) - state.target = geometry_shader; + target = geometry_shader; else if (strncmp(".frag", ext, 5) == 0) - state.target = fragment_shader; + target = fragment_shader; else usage_fail(argv[0]); shader = load_text_file(argv[1], & shader_len); + memset(& state, 0, sizeof(state)); + state.target = target; state.scanner = NULL; state.translation_unit.make_empty(); state.symbols = new glsl_symbol_table; @@ -131,6 +132,7 @@ main(int argc, char **argv) ast_node *ast = exec_node_data(ast_node, n, link); ast->print(); } + printf("\n\n"); if (!state.error && !state.translation_unit.is_empty()) _mesa_ast_to_hir(&instructions, &state); @@ -154,8 +156,6 @@ main(int argc, char **argv) } /* Print out the resulting IR */ - printf("\n\n"); - if (!state.error) { _mesa_print_ir(&instructions, &state); } -- cgit v1.2.3 From 7babbdbd82701147e50a5296dd215376b7ec7da8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 15 Jun 2010 12:47:07 -0700 Subject: Printing the AST is optional --- main.cpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 9b77cc8aca4..616236c402d 100644 --- a/main.cpp +++ b/main.cpp @@ -22,6 +22,7 @@ */ #include #include +#include #include #include @@ -86,6 +87,13 @@ usage_fail(const char *name) } +int dump_ast = 0; + +const struct option compiler_opts[] = { + { "dump-ast", 0, &dump_ast, 1 }, + { NULL, 0, NULL, 0 } +}; + int main(int argc, char **argv) { @@ -94,14 +102,20 @@ main(int argc, char **argv) size_t shader_len; exec_list instructions; - if (argc < 2) + int c; + int idx = 0; + while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1) + /* empty */ ; + + + if (argc <= optind) usage_fail(argv[0]); - const unsigned len = strlen(argv[1]); + const unsigned len = strlen(argv[optind]); if (len < 6) usage_fail(argv[0]); - const char *const ext = & argv[1][len - 5]; + const char *const ext = & argv[optind][len - 5]; enum _mesa_glsl_parser_targets target; if (strncmp(".vert", ext, 5) == 0) target = vertex_shader; @@ -112,7 +126,7 @@ main(int argc, char **argv) else usage_fail(argv[0]); - shader = load_text_file(argv[1], & shader_len); + shader = load_text_file(argv[optind], & shader_len); memset(& state, 0, sizeof(state)); state.target = target; @@ -128,11 +142,13 @@ main(int argc, char **argv) _mesa_glsl_parse(& state); _mesa_glsl_lexer_dtor(& state); - foreach_list_const(n, &state.translation_unit) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); + if (dump_ast) { + foreach_list_const(n, &state.translation_unit) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + printf("\n\n"); } - printf("\n\n"); if (!state.error && !state.translation_unit.is_empty()) _mesa_ast_to_hir(&instructions, &state); -- cgit v1.2.3 From 81e1747ac5206948893876b7da6fdb27bff26e0f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 15 Jun 2010 12:51:38 -0700 Subject: Printing LIR is optional --- main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 616236c402d..662686373ad 100644 --- a/main.cpp +++ b/main.cpp @@ -88,9 +88,11 @@ usage_fail(const char *name) int dump_ast = 0; +int dump_lir = 0; const struct option compiler_opts[] = { { "dump-ast", 0, &dump_ast, 1 }, + { "dump-lir", 0, &dump_lir, 1 }, { NULL, 0, NULL, 0 } }; @@ -172,7 +174,7 @@ main(int argc, char **argv) } /* Print out the resulting IR */ - if (!state.error) { + if (!state.error && dump_lir) { _mesa_print_ir(&instructions, &state); } -- cgit v1.2.3 From 298586fd6cf413e661a5ba47132827c5f7bac32e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 15 Jun 2010 17:42:16 -0700 Subject: Add TODO list Don't want to forget anything, no do we? --- TODO | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 00000000000..1db3819178a --- /dev/null +++ b/TODO @@ -0,0 +1,78 @@ +- Implement AST-to-HIR conversion of discard instructions. + +- Handle constant expressions of (matrix {+,-,*,/} scalar) + +- Handle constant expressions of (vector {+,-,*,/} scalar) + +- Handle constant expressions of (matrix * vector) + +- Handle constant expressions of (matrix * matrix) + +- Handle currently unsupported constant expression types + - ir_unop_sign + - ir_unop_exp2 + - ir_unop_log2 + - ir_unop_u2f + - ir_unop_trunc + - ir_unop_ceil + - ir_unop_floor + - ir_unop_sin + - ir_unop_cos + - ir_binop_dot + - ir_binop_min + - ir_binop_max + - ir_binop_pow + +- Handle constant expressions of (struct == struct) + +- Handle constant expressions of (struct != struct) + +- Add support to ir_constant for array constants Arrays can only be + - declared 'const' in GLSL 1.20+. This is because there are no + array constructors in GLSL 1.10, and any variable declared as + 'const' must have an initializer. + +- Handle constant expressions of (array == array) + +- Handle constant expressions of (array != array) + +- Treat built-in functions with constant parameters as constant expressions. + - Rewrite all built-in functions return a single expression. + - Modify the HIR generator for functions to automatically inline built-in + functions durning translation. + - Care must be taken to handle both the 1.10 rules and the 1.20+ rules. In + 1.10, built-in functions cannot be constant expressions. + +- Detect non-void functions that lack a return statement + +- Detect return statements with a type not matching the funciton's + return type. + +- Handle over-riding built-in functions + - Is the overload per-compilation unit or per-linked shader? + +- Handle redeclaration of built-in variables + - Handle addition of qualifiers such as 'invariant' or 'centroid'. + - Handle resizing of arrays. + - Other? We'll have to look at the spec. + +1.30 features: + +- Implement AST-to-HIR conversion of bit-shift operators. + +- Implement AST-to-HIR conversion of bit-wise {&,|,^,!} operators. + +- Implement AST-to-HIR conversion of switch-statements + - switch + - case + - Update break to correcly handle mixed nexting of switch-statements + and loops. + +- Handle currently unsupported constant expression types + - ir_unop_bit_not + - ir_binop_mod + - ir_binop_lshift + - ir_binop_rshift + - ir_binop_bit_and + - ir_binop_bit_xor + - ir_binop_bit_or -- cgit v1.2.3 From 869b6f680f4f998cc032b17557ea8b5879bbb250 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 12:00:25 -0700 Subject: Add glsl_program that is similar to Mesa's gl_program This will be used as the header for individual compilation units. --- program.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 program.h diff --git a/program.h b/program.h new file mode 100644 index 00000000000..35f401696a2 --- /dev/null +++ b/program.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include + +/** + * Based on gl_program in Mesa's mtypes.h. + */ +struct glsl_program { + GLenum Type; + GLuint Name; + GLint RefCount; + GLboolean DeletePending; + GLboolean CompileStatus; + const GLchar *Source; /**< Source code string */ + GLuint SourceLen; + GLchar *InfoLog; + + struct exec_list ir; + struct glsl_symbol_table *symbols; +}; -- cgit v1.2.3 From 8ce55dbd9207ff4338588dcba155f1a754dc8f19 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 12:01:18 -0700 Subject: Extract compilation to a separate routine Pull all of the code that actually compiles shaders into a separate function. Use a glsl_program to track data about the compiled shader. --- main.cpp | 110 ++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 63 insertions(+), 47 deletions(-) diff --git a/main.cpp b/main.cpp index 662686373ad..ae564e860dd 100644 --- a/main.cpp +++ b/main.cpp @@ -34,6 +34,7 @@ #include "glsl_parser.h" #include "ir_optimization.h" #include "ir_print_visitor.h" +#include "program.h" static char * @@ -96,42 +97,18 @@ const struct option compiler_opts[] = { { NULL, 0, NULL, 0 } }; -int -main(int argc, char **argv) +void +compile_shader(struct glsl_program *prog) { struct _mesa_glsl_parse_state state; - char *shader; - size_t shader_len; - exec_list instructions; - - int c; - int idx = 0; - while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1) - /* empty */ ; - - - if (argc <= optind) - usage_fail(argv[0]); - - const unsigned len = strlen(argv[optind]); - if (len < 6) - usage_fail(argv[0]); - - const char *const ext = & argv[optind][len - 5]; - enum _mesa_glsl_parser_targets target; - if (strncmp(".vert", ext, 5) == 0) - target = vertex_shader; - else if (strncmp(".geom", ext, 5) == 0) - target = geometry_shader; - else if (strncmp(".frag", ext, 5) == 0) - target = fragment_shader; - else - usage_fail(argv[0]); - - shader = load_text_file(argv[optind], & shader_len); memset(& state, 0, sizeof(state)); - state.target = target; + switch (prog->Type) { + case GL_VERTEX_SHADER: state.target = vertex_shader; break; + case GL_FRAGMENT_SHADER: state.target = fragment_shader; break; + case GL_GEOMETRY_SHADER: state.target = geometry_shader; break; + } + state.scanner = NULL; state.translation_unit.make_empty(); state.symbols = new glsl_symbol_table; @@ -140,7 +117,7 @@ main(int argc, char **argv) state.loop_or_switch_nesting = NULL; state.ARB_texture_rectangle_enable = true; - _mesa_glsl_lexer_ctor(& state, shader, shader_len); + _mesa_glsl_lexer_ctor(& state, prog->Source, prog->SourceLen); _mesa_glsl_parse(& state); _mesa_glsl_lexer_dtor(& state); @@ -152,33 +129,72 @@ main(int argc, char **argv) printf("\n\n"); } + prog->ir.make_empty(); if (!state.error && !state.translation_unit.is_empty()) - _mesa_ast_to_hir(&instructions, &state); + _mesa_ast_to_hir(&prog->ir, &state); /* Optimization passes */ - if (!state.error && !instructions.is_empty()) { + if (!state.error && !prog->ir.is_empty()) { bool progress; do { progress = false; - progress = do_function_inlining(&instructions) || progress; - progress = do_if_simplification(&instructions) || progress; - progress = do_copy_propagation(&instructions) || progress; - progress = do_dead_code_local(&instructions) || progress; - progress = do_dead_code_unlinked(&instructions) || progress; - progress = do_constant_variable_unlinked(&instructions) || progress; - progress = do_constant_folding(&instructions) || progress; - progress = do_vec_index_to_swizzle(&instructions) || progress; - progress = do_swizzle_swizzle(&instructions) || progress; + progress = do_function_inlining(&prog->ir) || progress; + progress = do_if_simplification(&prog->ir) || progress; + progress = do_copy_propagation(&prog->ir) || progress; + progress = do_dead_code_local(&prog->ir) || progress; + progress = do_dead_code_unlinked(&prog->ir) || progress; + progress = do_constant_variable_unlinked(&prog->ir) || progress; + progress = do_constant_folding(&prog->ir) || progress; + progress = do_vec_index_to_swizzle(&prog->ir) || progress; + progress = do_swizzle_swizzle(&prog->ir) || progress; } while (progress); } /* Print out the resulting IR */ if (!state.error && dump_lir) { - _mesa_print_ir(&instructions, &state); + _mesa_print_ir(&prog->ir, &state); } - delete state.symbols; + prog->symbols = state.symbols; + prog->CompileStatus = !state.error; + return; +} + +int +main(int argc, char **argv) +{ + struct _mesa_glsl_parse_state state; + + int c; + int idx = 0; + while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1) + /* empty */ ; + + + if (argc <= optind) + usage_fail(argv[0]); + + struct glsl_program *prog = new glsl_program; + memset(prog, 0, sizeof(*prog)); + + const unsigned len = strlen(argv[optind]); + if (len < 6) + usage_fail(argv[0]); + + const char *const ext = & argv[optind][len - 5]; + if (strncmp(".vert", ext, 5) == 0) + prog->Type = GL_VERTEX_SHADER; + else if (strncmp(".geom", ext, 5) == 0) + prog->Type = GL_GEOMETRY_SHADER; + else if (strncmp(".frag", ext, 5) == 0) + prog->Type = GL_FRAGMENT_SHADER; + else + usage_fail(argv[0]); + + prog->Source = load_text_file(argv[optind], &prog->SourceLen); + + compile_shader(prog); - return state.error != 0; + return prog->CompileStatus ? EXIT_SUCCESS : EXIT_FAILURE; } -- cgit v1.2.3 From 6fd9fb23de908ec52089fdc6e24af9e2ebbe126e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 12:22:16 -0700 Subject: Compile multiple shaders listed on the command line --- main.cpp | 54 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/main.cpp b/main.cpp index ae564e860dd..68a8fd2b691 100644 --- a/main.cpp +++ b/main.cpp @@ -164,7 +164,7 @@ compile_shader(struct glsl_program *prog) int main(int argc, char **argv) { - struct _mesa_glsl_parse_state state; + int status = EXIT_SUCCESS; int c; int idx = 0; @@ -175,26 +175,44 @@ main(int argc, char **argv) if (argc <= optind) usage_fail(argv[0]); - struct glsl_program *prog = new glsl_program; - memset(prog, 0, sizeof(*prog)); + struct glsl_program **prog_list = NULL; + unsigned prog_list_len = 0; - const unsigned len = strlen(argv[optind]); - if (len < 6) - usage_fail(argv[0]); + for (/* empty */; argc > optind; optind++) { + prog_list = (struct glsl_program **) + realloc(prog_list, + sizeof(struct glsl_program *) * (prog_list_len + 1)); + assert(prog_list != NULL); - const char *const ext = & argv[optind][len - 5]; - if (strncmp(".vert", ext, 5) == 0) - prog->Type = GL_VERTEX_SHADER; - else if (strncmp(".geom", ext, 5) == 0) - prog->Type = GL_GEOMETRY_SHADER; - else if (strncmp(".frag", ext, 5) == 0) - prog->Type = GL_FRAGMENT_SHADER; - else - usage_fail(argv[0]); + struct glsl_program *prog = new glsl_program; + memset(prog, 0, sizeof(*prog)); + + prog_list[prog_list_len] = prog; + prog_list_len++; + + const unsigned len = strlen(argv[optind]); + if (len < 6) + usage_fail(argv[0]); - prog->Source = load_text_file(argv[optind], &prog->SourceLen); + const char *const ext = & argv[optind][len - 5]; + if (strncmp(".vert", ext, 5) == 0) + prog->Type = GL_VERTEX_SHADER; + else if (strncmp(".geom", ext, 5) == 0) + prog->Type = GL_GEOMETRY_SHADER; + else if (strncmp(".frag", ext, 5) == 0) + prog->Type = GL_FRAGMENT_SHADER; + else + usage_fail(argv[0]); - compile_shader(prog); + prog->Source = load_text_file(argv[optind], &prog->SourceLen); + + compile_shader(prog); + + if (!prog->CompileStatus) { + status = EXIT_FAILURE; + break; + } + } - return prog->CompileStatus ? EXIT_SUCCESS : EXIT_FAILURE; + return status; } -- cgit v1.2.3 From f8fe53ca2eef3876e801d7a3b83f50b8e1612dcf Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 12:54:24 -0700 Subject: Change glsl_program to glsl_shader --- main.cpp | 10 +++++----- program.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 68a8fd2b691..c8a1a038af8 100644 --- a/main.cpp +++ b/main.cpp @@ -98,7 +98,7 @@ const struct option compiler_opts[] = { }; void -compile_shader(struct glsl_program *prog) +compile_shader(struct glsl_shader *prog) { struct _mesa_glsl_parse_state state; @@ -175,16 +175,16 @@ main(int argc, char **argv) if (argc <= optind) usage_fail(argv[0]); - struct glsl_program **prog_list = NULL; + struct glsl_shader **prog_list = NULL; unsigned prog_list_len = 0; for (/* empty */; argc > optind; optind++) { - prog_list = (struct glsl_program **) + prog_list = (struct glsl_shader **) realloc(prog_list, - sizeof(struct glsl_program *) * (prog_list_len + 1)); + sizeof(struct glsl_shader *) * (prog_list_len + 1)); assert(prog_list != NULL); - struct glsl_program *prog = new glsl_program; + struct glsl_shader *prog = new glsl_shader; memset(prog, 0, sizeof(*prog)); prog_list[prog_list_len] = prog; diff --git a/program.h b/program.h index 35f401696a2..df903edc95c 100644 --- a/program.h +++ b/program.h @@ -24,9 +24,9 @@ #include /** - * Based on gl_program in Mesa's mtypes.h. + * Based on gl_shader in Mesa's mtypes.h. */ -struct glsl_program { +struct glsl_shader { GLenum Type; GLuint Name; GLint RefCount; -- cgit v1.2.3 From 3f09c2508a05f1505b5f5b2081514797fb3163ff Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 12:59:27 -0700 Subject: Add glsl_program that is similar to Mesa's gl_shader_program --- program.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/program.h b/program.h index df903edc95c..81137c4e98d 100644 --- a/program.h +++ b/program.h @@ -39,3 +39,28 @@ struct glsl_shader { struct exec_list ir; struct glsl_symbol_table *symbols; }; + + +struct gl_program_parameter_list; +struct gl_uniform_list; + +/** + * Based on gl_shader_program in Mesa's mtypes.h. + */ +struct glsl_program { + GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ + GLuint Name; /**< aka handle or ID */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; + + GLuint NumShaders; /**< number of attached shaders */ + struct glsl_shader **Shaders; /**< List of attached the shaders */ + + /* post-link info: */ + struct gl_uniform_list *Uniforms; + struct gl_program_parameter_list *Varying; + GLboolean LinkStatus; /**< GL_LINK_STATUS */ + GLboolean Validated; + GLboolean _Used; /**< Ever used for drawing? */ + GLchar *InfoLog; +}; -- cgit v1.2.3 From 705fb01b59bec8acb9ff21509d25aa675d7c1dee Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 12:59:45 -0700 Subject: Use glsl_program instead of an open-coded vector of shaders --- main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index c8a1a038af8..37057ab1c9a 100644 --- a/main.cpp +++ b/main.cpp @@ -175,20 +175,20 @@ main(int argc, char **argv) if (argc <= optind) usage_fail(argv[0]); - struct glsl_shader **prog_list = NULL; - unsigned prog_list_len = 0; + struct glsl_program whole_program; + memset(&whole_program, 0, sizeof(whole_program)); for (/* empty */; argc > optind; optind++) { - prog_list = (struct glsl_shader **) - realloc(prog_list, - sizeof(struct glsl_shader *) * (prog_list_len + 1)); - assert(prog_list != NULL); + whole_program.Shaders = (struct glsl_shader **) + realloc(whole_program.Shaders, + sizeof(struct glsl_shader *) * (whole_program.NumShaders + 1)); + assert(whole_program.Shaders != NULL); struct glsl_shader *prog = new glsl_shader; memset(prog, 0, sizeof(*prog)); - prog_list[prog_list_len] = prog; - prog_list_len++; + whole_program.Shaders[whole_program.NumShaders] = prog; + whole_program.NumShaders++; const unsigned len = strlen(argv[optind]); if (len < 6) -- cgit v1.2.3 From 832dfa58b2070d60111bc1997aea86228f630e75 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 15:04:20 -0700 Subject: linker: Initial bits of the linker No linking is done yet, but some of the semantic checking is done. --- Makefile.am | 3 +- linker.cpp | 214 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.cpp | 5 ++ program.h | 3 + 4 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 linker.cpp diff --git a/Makefile.am b/Makefile.am index 44748dc886e..c1b94a5d727 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,7 +51,8 @@ glsl_SOURCES = \ ir_hierarchical_visitor.h \ ir_hierarchical_visitor.cpp \ ir_swizzle_swizzle.cpp \ - ir_vec_index_to_swizzle.cpp + ir_vec_index_to_swizzle.cpp \ + linker.cpp BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/linker.cpp b/linker.cpp new file mode 100644 index 00000000000..6de42d31409 --- /dev/null +++ b/linker.cpp @@ -0,0 +1,214 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file linker.cpp + * GLSL linker implementation + * + * Given a set of shaders that are to be linked to generate a final program, + * there are three distinct stages. + * + * In the first stage shaders are partitioned into groups based on the shader + * type. All shaders of a particular type (e.g., vertex shaders) are linked + * together. + * + * - Undefined references in each shader are resolve to definitions in + * another shader. + * - Types and qualifiers of uniforms, outputs, and global variables defined + * in multiple shaders with the same name are verified to be the same. + * - Initializers for uniforms and global variables defined + * in multiple shaders with the same name are verified to be the same. + * + * The result, in the terminology of the GLSL spec, is a set of shader + * executables for each processing unit. + * + * After the first stage is complete, a series of semantic checks are performed + * on each of the shader executables. + * + * - Each shader executable must define a \c main function. + * - Each vertex shader executable must write to \c gl_Position. + * - Each fragment shader executable must write to either \c gl_FragData or + * \c gl_FragColor. + * + * In the final stage individual shader executables are linked to create a + * complete exectuable. + * + * - Types of uniforms defined in multiple shader stages with the same name + * are verified to be the same. + * - Initializers for uniforms defined in multiple shader stages with the + * same name are verified to be the same. + * - Types and qualifiers of outputs defined in one stage are verified to + * be the same as the types and qualifiers of inputs defined with the same + * name in a later stage. + * + * \author Ian Romanick + */ +#include +#include + +#include "glsl_symbol_table.h" +#include "glsl_parser_extras.h" +#include "ir.h" +#include "program.h" + +/** + * Visitor that determines whether or not a variable is ever written. + */ +class find_assignment_visitor : public ir_hierarchical_visitor { +public: + find_assignment_visitor(const char *name) + : name(name), found(false) + { + /* empty */ + } + + virtual ir_visitor_status visit_enter(ir_assignment *ir) + { + ir_variable *const var = ir->lhs->variable_referenced(); + + if (strcmp(name, var->name) == 0) { + found = true; + return visit_stop; + } + + return visit_continue_with_parent; + } + + bool variable_found() + { + return found; + } + +private: + const char *name; /**< Find writes to a variable with this name. */ + bool found; /**< Was a write to the variable found? */ +}; + +bool +validate_vertex_shader_executable(struct glsl_shader *shader) +{ + if (shader == NULL) + return true; + + if (!shader->symbols->get_function("main")) { + printf("error: vertex shader lacks `main'\n"); + return false; + } + + find_assignment_visitor find("gl_Position"); + find.run(&shader->ir); + if (!find.variable_found()) { + printf("error: vertex shader does not write to `gl_Position'\n"); + return false; + } + + return true; +} + + +bool +validate_fragment_shader_executable(struct glsl_shader *shader) +{ + if (shader == NULL) + return true; + + if (!shader->symbols->get_function("main")) { + printf("error: fragment shader lacks `main'\n"); + return false; + } + + find_assignment_visitor frag_color("gl_FragColor"); + find_assignment_visitor frag_data("gl_FragData"); + + frag_color.run(&shader->ir); + frag_data.run(&shader->ir); + + if (!frag_color.variable_found() && !frag_data.variable_found()) { + printf("error: fragment shader does not write to `gl_FragColor' or " + "`gl_FragData'\n"); + return false; + } + + if (frag_color.variable_found() && frag_data.variable_found()) { + printf("error: fragment shader write to both `gl_FragColor' and " + "`gl_FragData'\n"); + return false; + } + + return true; +} + + +void +link_shaders(struct glsl_program *prog) +{ + prog->LinkStatus = false; + prog->Validated = false; + prog->_Used = false; + + /* Separate the shaders into groups based on their type. + */ + struct glsl_shader **vert_shader_list; + unsigned num_vert_shaders = 0; + struct glsl_shader **frag_shader_list; + unsigned num_frag_shaders = 0; + + vert_shader_list = (struct glsl_shader **) + malloc(sizeof(struct glsl_shader *) * 2 * prog->NumShaders); + frag_shader_list = &vert_shader_list[prog->NumShaders]; + + for (unsigned i = 0; i < prog->NumShaders; i++) { + switch (prog->Shaders[i]->Type) { + case GL_VERTEX_SHADER: + vert_shader_list[num_vert_shaders] = prog->Shaders[i]; + num_vert_shaders++; + break; + case GL_FRAGMENT_SHADER: + frag_shader_list[num_frag_shaders] = prog->Shaders[i]; + num_frag_shaders++; + break; + case GL_GEOMETRY_SHADER: + /* FINISHME: Support geometry shaders. */ + assert(prog->Shaders[i]->Type != GL_GEOMETRY_SHADER); + break; + } + } + + /* FINISHME: Implement intra-stage linking. */ + assert(num_vert_shaders <= 1); + assert(num_frag_shaders <= 1); + + /* Verify that each of the per-target executables is valid. + */ + if (!validate_vertex_shader_executable(vert_shader_list[0]) + || !validate_fragment_shader_executable(frag_shader_list[0])) + goto done; + + + /* FINISHME: Perform inter-stage linking. */ + + prog->LinkStatus = true; + +done: + free(vert_shader_list); +} diff --git a/main.cpp b/main.cpp index 37057ab1c9a..48aa51f2821 100644 --- a/main.cpp +++ b/main.cpp @@ -214,5 +214,10 @@ main(int argc, char **argv) } } + if (status == EXIT_SUCCESS) { + link_shaders(&whole_program); + status = (whole_program.LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE; + } + return status; } diff --git a/program.h b/program.h index 81137c4e98d..8d4088dddde 100644 --- a/program.h +++ b/program.h @@ -64,3 +64,6 @@ struct glsl_program { GLboolean _Used; /**< Ever used for drawing? */ GLchar *InfoLog; }; + +extern void +link_shaders(struct glsl_program *prog); -- cgit v1.2.3 From c648a124b20c5e37cf4041062333fc177a65f997 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 19:51:48 -0700 Subject: Don't link shaders by default Add a command line option to trigger linking. This "fixes" all the failing test cases. Oops. --- main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 48aa51f2821..c7b8cf5a214 100644 --- a/main.cpp +++ b/main.cpp @@ -90,10 +90,12 @@ usage_fail(const char *name) int dump_ast = 0; int dump_lir = 0; +int do_link = 0; const struct option compiler_opts[] = { { "dump-ast", 0, &dump_ast, 1 }, { "dump-lir", 0, &dump_lir, 1 }, + { "link", 0, &do_link, 1 }, { NULL, 0, NULL, 0 } }; @@ -214,7 +216,7 @@ main(int argc, char **argv) } } - if (status == EXIT_SUCCESS) { + if ((status == EXIT_SUCCESS) && do_link) { link_shaders(&whole_program); status = (whole_program.LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE; } -- cgit v1.2.3 From ce030884064046925a655413097dd8257e9392dd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 20:09:34 -0700 Subject: Allow initializers for uniforms --- ast_to_hir.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 1c0b98b10ca..3414da00eb6 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1758,15 +1758,17 @@ ast_declarator_list::hir(exec_list *instructions, ir_dereference *const lhs = new ir_dereference_variable(var); ir_rvalue *rhs = decl->initializer->hir(instructions, state); - /* Calculate the constant value if this is a const + /* Calculate the constant value if this is a const or uniform * declaration. */ - if (this->type->qualifier.constant) { + if (this->type->qualifier.constant || this->type->qualifier.uniform) { ir_constant *constant_value = rhs->constant_expression_value(); if (!constant_value) { _mesa_glsl_error(& initializer_loc, state, - "initializer of const variable `%s' must be a " + "initializer of %s variable `%s' must be a " "constant expression", + (this->type->qualifier.constant) + ? "const" : "uniform", decl->identifier); } else { rhs = constant_value; @@ -1778,8 +1780,12 @@ ast_declarator_list::hir(exec_list *instructions, bool temp = var->read_only; if (this->type->qualifier.constant) var->read_only = false; - result = do_assignment(instructions, state, lhs, rhs, - this->get_location()); + + /* Never emit code to initialize a uniform. + */ + if (!this->type->qualifier.uniform) + result = do_assignment(instructions, state, lhs, rhs, + this->get_location()); var->read_only = temp; } } -- cgit v1.2.3 From 4230cfdb42061bdce806f35aec238d23ee37a26a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 20:37:17 -0700 Subject: TODO: Add note about initializers for constants --- TODO | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TODO b/TODO index 1db3819178a..193cfc767d8 100644 --- a/TODO +++ b/TODO @@ -56,6 +56,12 @@ - Handle resizing of arrays. - Other? We'll have to look at the spec. +- Improve handling of constants and their initializers. Constant initializers + should never generate any code. This is trival for scalar constants. It is + also trivial for arrays, matrices, and vectors that are accessed with + constant index values. For others it is more complicated. Perhaps these + cases should be silently converted to uniforms? + 1.30 features: - Implement AST-to-HIR conversion of bit-shift operators. -- cgit v1.2.3 From c93b8f1d2cd6a0b084f8e08bfa54e03c154081d4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 15:20:22 -0700 Subject: linker: Add some function header comments --- linker.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/linker.cpp b/linker.cpp index 6de42d31409..ca0cacdfb72 100644 --- a/linker.cpp +++ b/linker.cpp @@ -104,6 +104,12 @@ private: bool found; /**< Was a write to the variable found? */ }; + +/** + * Verify that a vertex shader executable meets all semantic requirements + * + * \param shader Vertex shader executable to be verified + */ bool validate_vertex_shader_executable(struct glsl_shader *shader) { @@ -126,6 +132,11 @@ validate_vertex_shader_executable(struct glsl_shader *shader) } +/** + * Verify that a fragment shader executable meets all semantic requirements + * + * \param shader Fragment shader executable to be verified + */ bool validate_fragment_shader_executable(struct glsl_shader *shader) { -- cgit v1.2.3 From 8655b7e78a40f7f64b744727071b946c0da75217 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 18 Jun 2010 18:36:51 -0700 Subject: glsl_lexer: Handle interpolation qualifiers --- glsl_lexer.lpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index 34ca229de8d..5cea534bafd 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -159,6 +159,31 @@ varying return VARYING; centroid return CENTROID; invariant return INVARIANT; +flat { + if (yyextra->language_version >= 130) { + return FLAT; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } +smooth { + if (yyextra->language_version >= 130) { + return SMOOTH; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } +noperspective { + if (yyextra->language_version >= 130) { + return NOPERSPECTIVE; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + sampler1D return SAMPLER1D; sampler2D return SAMPLER2D; sampler3D return SAMPLER3D; -- cgit v1.2.3 From 93dad36844a7e967aa9a9ec62587bac65b9eb5b4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 18 Jun 2010 18:40:12 -0700 Subject: glsl_lexer: centroid and invariant are not reserved words in GLSL 1.10 --- glsl_lexer.lpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index 5cea534bafd..cd150f81ca1 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -156,8 +156,22 @@ out return OUT; inout return INOUT; uniform return UNIFORM; varying return VARYING; -centroid return CENTROID; -invariant return INVARIANT; +centroid { + if (yyextra->language_version >= 120) { + return CENTROID; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } +invariant { + if (yyextra->language_version >= 120) { + return INVARIANT; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } flat { if (yyextra->language_version >= 130) { -- cgit v1.2.3 From c96822cf311d764a3cf6a2c62145851e8326c896 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 18 Jun 2010 18:57:31 -0700 Subject: Ensure that shader_in and shader_out are correctly set in declarations --- ast_to_hir.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 3414da00eb6..dbc36660697 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1471,11 +1471,27 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, if (qual->uniform) var->shader_in = true; - if (qual->varying) { - if (qual->in) + + /* Any 'in' or 'inout' variables at global scope must be marked as being + * shader inputs. Likewise, any 'out' or 'inout' variables at global scope + * must be marked as being shader outputs. + */ + if (state->current_function == NULL) { + switch (var->mode) { + case ir_var_in: + case ir_var_uniform: + var->shader_in = true; + break; + case ir_var_out: + var->shader_out = true; + break; + case ir_var_inout: var->shader_in = true; - if (qual->out) var->shader_out = true; + break; + default: + break; + } } if (qual->flat) -- cgit v1.2.3 From 520aad2c3ee56067361714ff27e1b3c84c601126 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 15:28:13 -0700 Subject: Fix compile on 64-bit. --- program.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program.h b/program.h index 8d4088dddde..44cf3456355 100644 --- a/program.h +++ b/program.h @@ -33,7 +33,7 @@ struct glsl_shader { GLboolean DeletePending; GLboolean CompileStatus; const GLchar *Source; /**< Source code string */ - GLuint SourceLen; + size_t SourceLen; GLchar *InfoLog; struct exec_list ir; -- cgit v1.2.3 From 29e60874812ae323780cfab67b8b1365059ff4b2 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 15:28:34 -0700 Subject: Rename prog to shader. Less confusing. --- main.cpp | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/main.cpp b/main.cpp index c7b8cf5a214..9301d5113f5 100644 --- a/main.cpp +++ b/main.cpp @@ -100,12 +100,12 @@ const struct option compiler_opts[] = { }; void -compile_shader(struct glsl_shader *prog) +compile_shader(struct glsl_shader *shader) { struct _mesa_glsl_parse_state state; memset(& state, 0, sizeof(state)); - switch (prog->Type) { + switch (shader->Type) { case GL_VERTEX_SHADER: state.target = vertex_shader; break; case GL_FRAGMENT_SHADER: state.target = fragment_shader; break; case GL_GEOMETRY_SHADER: state.target = geometry_shader; break; @@ -119,7 +119,7 @@ compile_shader(struct glsl_shader *prog) state.loop_or_switch_nesting = NULL; state.ARB_texture_rectangle_enable = true; - _mesa_glsl_lexer_ctor(& state, prog->Source, prog->SourceLen); + _mesa_glsl_lexer_ctor(& state, shader->Source, shader->SourceLen); _mesa_glsl_parse(& state); _mesa_glsl_lexer_dtor(& state); @@ -131,35 +131,35 @@ compile_shader(struct glsl_shader *prog) printf("\n\n"); } - prog->ir.make_empty(); + shader->ir.make_empty(); if (!state.error && !state.translation_unit.is_empty()) - _mesa_ast_to_hir(&prog->ir, &state); + _mesa_ast_to_hir(&shader->ir, &state); /* Optimization passes */ - if (!state.error && !prog->ir.is_empty()) { + if (!state.error && !shader->ir.is_empty()) { bool progress; do { progress = false; - progress = do_function_inlining(&prog->ir) || progress; - progress = do_if_simplification(&prog->ir) || progress; - progress = do_copy_propagation(&prog->ir) || progress; - progress = do_dead_code_local(&prog->ir) || progress; - progress = do_dead_code_unlinked(&prog->ir) || progress; - progress = do_constant_variable_unlinked(&prog->ir) || progress; - progress = do_constant_folding(&prog->ir) || progress; - progress = do_vec_index_to_swizzle(&prog->ir) || progress; - progress = do_swizzle_swizzle(&prog->ir) || progress; + progress = do_function_inlining(&shader->ir) || progress; + progress = do_if_simplification(&shader->ir) || progress; + progress = do_copy_propagation(&shader->ir) || progress; + progress = do_dead_code_local(&shader->ir) || progress; + progress = do_dead_code_unlinked(&shader->ir) || progress; + progress = do_constant_variable_unlinked(&shader->ir) || progress; + progress = do_constant_folding(&shader->ir) || progress; + progress = do_vec_index_to_swizzle(&shader->ir) || progress; + progress = do_swizzle_swizzle(&shader->ir) || progress; } while (progress); } /* Print out the resulting IR */ if (!state.error && dump_lir) { - _mesa_print_ir(&prog->ir, &state); + _mesa_print_ir(&shader->ir, &state); } - prog->symbols = state.symbols; - prog->CompileStatus = !state.error; + shader->symbols = state.symbols; + shader->CompileStatus = !state.error; return; } @@ -186,10 +186,10 @@ main(int argc, char **argv) sizeof(struct glsl_shader *) * (whole_program.NumShaders + 1)); assert(whole_program.Shaders != NULL); - struct glsl_shader *prog = new glsl_shader; - memset(prog, 0, sizeof(*prog)); + struct glsl_shader *shader = new glsl_shader; + memset(shader, 0, sizeof(*shader)); - whole_program.Shaders[whole_program.NumShaders] = prog; + whole_program.Shaders[whole_program.NumShaders] = shader; whole_program.NumShaders++; const unsigned len = strlen(argv[optind]); @@ -198,19 +198,19 @@ main(int argc, char **argv) const char *const ext = & argv[optind][len - 5]; if (strncmp(".vert", ext, 5) == 0) - prog->Type = GL_VERTEX_SHADER; + shader->Type = GL_VERTEX_SHADER; else if (strncmp(".geom", ext, 5) == 0) - prog->Type = GL_GEOMETRY_SHADER; + shader->Type = GL_GEOMETRY_SHADER; else if (strncmp(".frag", ext, 5) == 0) - prog->Type = GL_FRAGMENT_SHADER; + shader->Type = GL_FRAGMENT_SHADER; else usage_fail(argv[0]); - prog->Source = load_text_file(argv[optind], &prog->SourceLen); + shader->Source = load_text_file(argv[optind], &shader->SourceLen); - compile_shader(prog); + compile_shader(shader); - if (!prog->CompileStatus) { + if (!shader->CompileStatus) { status = EXIT_FAILURE; break; } -- cgit v1.2.3 From c186b3fbe0864caa12e3c3ab8136efd3ca0832a7 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 15:37:26 -0700 Subject: Fix crash when running glsl on a signle fragment shader. --- linker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linker.cpp b/linker.cpp index ca0cacdfb72..0a1afcf0345 100644 --- a/linker.cpp +++ b/linker.cpp @@ -185,7 +185,7 @@ link_shaders(struct glsl_program *prog) unsigned num_frag_shaders = 0; vert_shader_list = (struct glsl_shader **) - malloc(sizeof(struct glsl_shader *) * 2 * prog->NumShaders); + calloc(2 * prog->NumShaders, sizeof(struct glsl_shader *)); frag_shader_list = &vert_shader_list[prog->NumShaders]; for (unsigned i = 0; i < prog->NumShaders; i++) { -- cgit v1.2.3 From 57d0fc413976d0a80391080ee2b95369ecace4ad Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 15:14:47 -0700 Subject: Link against talloc. We're going to be using it. --- Makefile.am | 1 + configure.ac | 1 + 2 files changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index c1b94a5d727..efed87a5766 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,6 +23,7 @@ AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = glsl +glsl_LDFLAGS = @LDFLAGS@ $(talloc_LIBS) glsl_SOURCES = \ main.cpp \ builtin_types.h \ diff --git a/configure.ac b/configure.ac index 37f3283a887..09c5f4b4dbf 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # Checks for library functions. AC_HEADER_STDC +PKG_CHECK_MODULES([talloc], [talloc >= 2.0]) AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], -- cgit v1.2.3 From 32cf482215f698c46fd782104ca2e0560da5be17 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 19 Jun 2010 11:24:33 -0700 Subject: Make shader a talloc context. --- main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 9301d5113f5..f6e5e95fcbe 100644 --- a/main.cpp +++ b/main.cpp @@ -29,6 +29,10 @@ #include #include +extern "C" { +#include +} + #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" @@ -186,8 +190,8 @@ main(int argc, char **argv) sizeof(struct glsl_shader *) * (whole_program.NumShaders + 1)); assert(whole_program.Shaders != NULL); - struct glsl_shader *shader = new glsl_shader; - memset(shader, 0, sizeof(*shader)); + /* talloc context should probably be whole_program */ + struct glsl_shader *shader = talloc_zero(NULL, glsl_shader); whole_program.Shaders[whole_program.NumShaders] = shader; whole_program.NumShaders++; -- cgit v1.2.3 From ca97bd395f476ad2b5a009f92edef4656aab3650 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sat, 19 Jun 2010 01:39:14 -0700 Subject: Initialize the shader info log Signed-off-by: Kenneth Graunke --- main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.cpp b/main.cpp index f6e5e95fcbe..a613334d5cd 100644 --- a/main.cpp +++ b/main.cpp @@ -118,6 +118,7 @@ compile_shader(struct glsl_shader *shader) state.scanner = NULL; state.translation_unit.make_empty(); state.symbols = new glsl_symbol_table; + state.info_log = talloc_strdup(shader, ""); state.error = false; state.temp_index = 0; state.loop_or_switch_nesting = NULL; @@ -164,6 +165,12 @@ compile_shader(struct glsl_shader *shader) shader->symbols = state.symbols; shader->CompileStatus = !state.error; + + if (shader->InfoLog) + talloc_free(shader->InfoLog); + + shader->InfoLog = state.info_log; + return; } -- cgit v1.2.3 From b2ba6fac09df1f06161a7ea1ef1f25bb9fbe8a5a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 15:15:35 -0700 Subject: Change error/warning functions to print to the info log. --- glsl_parser_extras.cpp | 44 ++++++++++++++++++++------------------------ ir_reader.cpp | 16 +++++++++++----- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 8cf765f95de..7bd30de7c24 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -25,6 +25,10 @@ #include #include +extern "C" { +#include +} + #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" @@ -47,24 +51,20 @@ void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, const char *fmt, ...) { - char buf[1024]; - int len; va_list ap; state->error = true; - len = snprintf(buf, sizeof(buf), "%u:%u(%u): error: ", - locp->source, locp->first_line, locp->first_column); - + assert(state->info_log != NULL); + state->info_log = talloc_asprintf_append(state->info_log, + "%u:%u(%u): error: ", + locp->source, + locp->first_line, + locp->first_column); va_start(ap, fmt); - vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); + state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); va_end(ap); - - printf("%s\n", buf); - - if (state->info_log) - free(state->info_log); - state->info_log = strdup(buf); + state->info_log = talloc_strdup_append(state->info_log, "\n"); } @@ -72,22 +72,18 @@ void _mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, const char *fmt, ...) { - char buf[1024]; - int len; va_list ap; - len = snprintf(buf, sizeof(buf), "%u:%u(%u): warning: ", - locp->source, locp->first_line, locp->first_column); - + assert(state->info_log != NULL); + state->info_log = talloc_asprintf_append(state->info_log, + "%u:%u(%u): warning: ", + locp->source, + locp->first_line, + locp->first_column); va_start(ap, fmt); - vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); + state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); va_end(ap); - - printf("%s\n", buf); - - if (!state->info_log) { - state->info_log = strdup(buf); - } + state->info_log = talloc_strdup_append(state->info_log, "\n"); } diff --git a/ir_reader.cpp b/ir_reader.cpp index 23981a0f514..5cbce333f41 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -22,6 +22,11 @@ */ #include #include + +extern "C" { +#include +} + #include "ir_reader.h" #include "glsl_parser_extras.h" #include "glsl_types.h" @@ -86,17 +91,18 @@ ir_read_error(_mesa_glsl_parse_state *state, s_expression *expr, state->error = true; - printf("error: "); + state->info_log = talloc_strdup_append(state->info_log, "error: "); va_start(ap, fmt); - vprintf(fmt, ap); + state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); va_end(ap); - printf("\n"); + state->info_log = talloc_strdup_append(state->info_log, "\n"); if (expr != NULL) { - printf("...in this context:\n "); + state->info_log = talloc_strdup_append(state->info_log, + "...in this context:\n "); expr->print(); - printf("\n\n"); + state->info_log = talloc_strdup_append(state->info_log, "\n\n"); } } -- cgit v1.2.3 From f3eb42d200bb78afae64af6862e2b12396226707 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 19 Jun 2010 11:31:01 -0700 Subject: Print out the info log if compilation fails. --- main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/main.cpp b/main.cpp index a613334d5cd..a6d6c47bfda 100644 --- a/main.cpp +++ b/main.cpp @@ -222,6 +222,7 @@ main(int argc, char **argv) compile_shader(shader); if (!shader->CompileStatus) { + printf("Info log for %s:\n%s\n", argv[optind], shader->InfoLog); status = EXIT_FAILURE; break; } -- cgit v1.2.3 From 254a485c33c9692f527e33c1423399ce99b1aa2b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 11:51:43 -0700 Subject: Specify %option prefix="glcpp_" in the source code, not the Makefile. --- glcpp/Makefile | 2 +- glcpp/glcpp-lex.l | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/glcpp/Makefile b/glcpp/Makefile index 3fb44ac3b2e..1578a8ee308 100644 --- a/glcpp/Makefile +++ b/glcpp/Makefile @@ -13,7 +13,7 @@ glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o xtalloc.o bison --debug --defines=$*.h --output=$*.c $^ %.c: %.l - flex --prefix=glcpp_ --outfile=$@ $< + flex --outfile=$@ $< glcpp-lex.c: glcpp-parse.h diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index 0d9a75415a3..cc5f28f8f86 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -31,6 +31,7 @@ %option reentrant noyywrap %option extra-type="glcpp_parser_t *" +%option prefix="glcpp_" SPACE [[:space:]] NONSPACE [^[:space:]] -- cgit v1.2.3 From cbaab7093c43d1bc208c446367483f386dcb6bf5 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 11:54:01 -0700 Subject: Add glcpp to the build. --- Makefile.am | 4 ++++ configure.ac | 2 ++ glcpp/Makefile | 25 ------------------------- glcpp/Makefile.am | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 25 deletions(-) delete mode 100644 glcpp/Makefile create mode 100644 glcpp/Makefile.am diff --git a/Makefile.am b/Makefile.am index efed87a5766..f24f06d0aa7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,11 @@ AUTOMAKE_OPTIONS = foreign +SUBDIRS = glcpp + bin_PROGRAMS = glsl + +glsl_LDADD = ./glcpp/libglcpp.la glsl_LDFLAGS = @LDFLAGS@ $(talloc_LIBS) glsl_SOURCES = \ main.cpp \ diff --git a/configure.ac b/configure.ac index 09c5f4b4dbf..68241f1ceed 100644 --- a/configure.ac +++ b/configure.ac @@ -5,8 +5,10 @@ AC_PREREQ(2.61) AC_INIT(glsl, XXXXX, idr@freedesktop.org, glsl) AC_CONFIG_SRCDIR([Makefile.am]) AM_CONFIG_HEADER([config.h]) +AC_CONFIG_FILES([glcpp/Makefile]) AM_INIT_AUTOMAKE +LT_INIT AM_MAINTAINER_MODE diff --git a/glcpp/Makefile b/glcpp/Makefile deleted file mode 100644 index 1578a8ee308..00000000000 --- a/glcpp/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# Debug symbols by default, but let the user avoid that with something -# like "make CFLAGS=-O2" -CFLAGS = -g - -# But we use 'override' here so that "make CFLAGS=-O2" will still have -# all the warnings enabled. -override CFLAGS += -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wno-unused - -glcpp: glcpp.o glcpp-lex.o glcpp-parse.o hash_table.o xtalloc.o - gcc -o $@ -ltalloc -lm $^ - -%.c %.h: %.y - bison --debug --defines=$*.h --output=$*.c $^ - -%.c: %.l - flex --outfile=$@ $< - -glcpp-lex.c: glcpp-parse.h - -test: glcpp - @(cd tests; ./glcpp-test) - -clean: - rm -f glcpp glcpp-lex.c glcpp-parse.c *.o *~ - rm -f tests/*.out tests/*~ diff --git a/glcpp/Makefile.am b/glcpp/Makefile.am new file mode 100644 index 00000000000..26b769ca609 --- /dev/null +++ b/glcpp/Makefile.am @@ -0,0 +1,45 @@ +# Copyright © 2010 Intel Corporation +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +# USE OR OTHER DEALINGS IN THE SOFTWARE. + +noinst_LTLIBRARIES = libglcpp.la +libglcpp_la_SOURCES = \ + glcpp-lex.l \ + glcpp-parse.y \ + glcpp.h \ + hash_table.c \ + xtalloc.c + +BUILT_SOURCES = glcpp-parse.h glcpp-parse.c glcpp-lex.c +CLEANFILES = $(BUILT_SOURCES) + +glcpp-parse.h: glcpp-parse.c + +bin_PROGRAMS = glcpp +glcpp_LDADD = libglcpp.la +glcpp_LDFLAGS = @LDFLAGS@ $(talloc_LIBS) +glcpp_SOURCES = glcpp.c + +.l.c: + $(LEXCOMPILE) --outfile="$@" $< + +test: glcpp + @(cd tests; ./glcpp-test) -- cgit v1.2.3 From 0656f6b8750fe6139f74914bfe4e2c394db594e4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 11:56:36 -0700 Subject: glcpp: Fix a case of == where = probably ought to be. Caught by a GCC warning. --- glcpp/glcpp-parse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 807cf595090..ede2bb88fd1 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -1356,7 +1356,7 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser, else list->head = last->next; if (last == list->tail) - list->tail == NULL; + list->tail = NULL; } } else { node_prev = node; -- cgit v1.2.3 From 4c8a1af8117ac8e69883c6ef88d3f3b073dc6e0a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 11:57:48 -0700 Subject: glcpp: Output to a buffer and error log rather than directly printing. In the standalone case, simply print the buffers when done. --- glcpp/glcpp-parse.y | 103 ++++++++++++++++++++++++++++------------------------ glcpp/glcpp.c | 3 ++ glcpp/glcpp.h | 2 + 3 files changed, 60 insertions(+), 48 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index ede2bb88fd1..f9fab8bf293 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -29,8 +29,12 @@ #include "glcpp.h" +#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) +#define glcpp_printf(stream, fmt, args...) \ + stream = talloc_asprintf_append(stream, fmt, args) + static void -yyerror (void *scanner, const char *error); +yyerror (glcpp_parser_t *parser, const char *error); static void _define_object_macro (glcpp_parser_t *parser, @@ -167,11 +171,11 @@ input: line: control_line { - printf ("\n"); + glcpp_print(parser->output, "\n"); } | text_line { _glcpp_parser_print_expanded_token_list (parser, $1); - printf ("\n"); + glcpp_print(parser->output, "\n"); talloc_free ($1); } | expanded_line @@ -704,60 +708,60 @@ _token_list_length (token_list_t *list) } static void -_token_print (token_t *token) +_token_print (char **out, token_t *token) { if (token->type < 256) { - printf ("%c", token->type); + glcpp_printf (*out, "%c", token->type); return; } switch (token->type) { case INTEGER: - printf ("%" PRIxMAX, token->value.ival); + glcpp_printf (*out, "%" PRIxMAX, token->value.ival); break; case IDENTIFIER: case INTEGER_STRING: case OTHER: - printf ("%s", token->value.str); + glcpp_printf (*out, "%s", token->value.str); break; case SPACE: - printf (" "); + glcpp_print (*out, " "); break; case LEFT_SHIFT: - printf ("<<"); + glcpp_print (*out, "<<"); break; case RIGHT_SHIFT: - printf (">>"); + glcpp_print (*out, ">>"); break; case LESS_OR_EQUAL: - printf ("<="); + glcpp_print (*out, "<="); break; case GREATER_OR_EQUAL: - printf (">="); + glcpp_print (*out, ">="); break; case EQUAL: - printf ("=="); + glcpp_print (*out, "=="); break; case NOT_EQUAL: - printf ("!="); + glcpp_print (*out, "!="); break; case AND: - printf ("&&"); + glcpp_print (*out, "&&"); break; case OR: - printf ("||"); + glcpp_print (*out, "||"); break; case PASTE: - printf ("##"); + glcpp_print (*out, "##"); break; case COMMA_FINAL: - printf (","); + glcpp_print (*out, ","); break; case PLACEHOLDER: /* Nothing to print. */ break; default: - fprintf (stderr, "Error: Don't know how to print token type %d\n", token->type); + assert(!"Error: Don't know how to print token."); break; } } @@ -769,7 +773,7 @@ _token_print (token_t *token) * Caution: Only very cursory error-checking is performed to see if * the final result is a valid single token. */ static token_t * -_token_paste (token_t *token, token_t *other) +_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) { /* Pasting a placeholder onto anything makes no change. */ if (other->type == PLACEHOLDER) @@ -830,17 +834,17 @@ _token_paste (token_t *token, token_t *other) return _token_create_str (token, token->type, str); } - printf ("Error: Pasting \""); - _token_print (token); - printf ("\" and \""); - _token_print (other); - printf ("\" does not give a valid preprocessing token.\n"); + glcpp_print (parser->errors, "Error: Pasting \""); + _token_print (&parser->errors, token); + glcpp_print (parser->errors, "\" and \""); + _token_print (&parser->errors, other); + glcpp_print (parser->errors, "\" does not give a valid preprocessing token.\n"); return token; } static void -_token_list_print (token_list_t *list) +_token_list_print (glcpp_parser_t *parser, token_list_t *list) { token_node_t *node; @@ -848,13 +852,13 @@ _token_list_print (token_list_t *list) return; for (node = list->head; node; node = node->next) - _token_print (node->token); + _token_print (&parser->output, node->token); } void -yyerror (void *scanner, const char *error) +yyerror (glcpp_parser_t *parser, const char *error) { - fprintf (stderr, "Parse error: %s\n", error); + glcpp_printf(parser->errors, "Parse error: %s\n", error); } glcpp_parser_t * @@ -879,6 +883,9 @@ glcpp_parser_create (void) parser->lex_from_list = NULL; parser->lex_from_node = NULL; + parser->output = talloc_strdup(parser, ""); + parser->errors = talloc_strdup(parser, ""); + return parser; } @@ -892,7 +899,7 @@ void glcpp_parser_destroy (glcpp_parser_t *parser) { if (parser->skip_stack) - fprintf (stderr, "Error: Unterminated #if\n"); + glcpp_print (parser->errors, "Error: Unterminated #if\n"); glcpp_lex_destroy (parser->scanner); hash_table_dtor (parser->defines); talloc_free (parser); @@ -918,7 +925,7 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser, while (next && next->token->type == SPACE) next = next->next; if (next == NULL || next->token->type != IDENTIFIER) { - fprintf (stderr, "Error: operator \"defined\" requires an identifier\n"); + glcpp_print (parser->errors, "Error: operator \"defined\" requires an identifier\n"); exit (1); } macro = hash_table_find (parser->defines, @@ -1065,8 +1072,8 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, case FUNCTION_NOT_A_FUNCTION: return NULL; case FUNCTION_UNBALANCED_PARENTHESES: - fprintf (stderr, "Error: Macro %s call has unbalanced parentheses\n", - identifier); + glcpp_printf (parser->errors, "Error: Macro %s call has unbalanced parentheses\n", + identifier); exit (1); return NULL; } @@ -1082,11 +1089,11 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, _argument_list_length (arguments) == 1 && arguments->head->argument->head == NULL))) { - fprintf (stderr, - "Error: macro %s invoked with %d arguments (expected %d)\n", - identifier, - _argument_list_length (arguments), - _string_list_length (macro->parameters)); + glcpp_printf (parser->errors, + "Error: macro %s invoked with %d arguments (expected %d)\n", + identifier, + _argument_list_length (arguments), + _string_list_length (macro->parameters)); return NULL; } @@ -1152,11 +1159,11 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, next_non_space = next_non_space->next; if (next_non_space == NULL) { - fprintf (stderr, "Error: '##' cannot appear at either end of a macro expansion\n"); + glcpp_print (parser->errors, "Error: '##' cannot appear at either end of a macro expansion\n"); return NULL; } - node->token = _token_paste (node->token, next_non_space->token); + node->token = _token_paste (parser, node->token, next_non_space->token); node->next = next_non_space->next; if (next_non_space == substituted->tail) substituted->tail = node; @@ -1381,21 +1388,21 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, _token_list_trim_trailing_space (list); - _token_list_print (list); + _token_list_print (parser, list); } void -_check_for_reserved_macro_name (const char *identifier) +_check_for_reserved_macro_name (glcpp_parser_t *parser, const char *identifier) { /* According to the GLSL specification, macro names starting with "__" * or "GL_" are reserved for future use. So, don't allow them. */ if (strncmp(identifier, "__", 2) == 0) { - fprintf (stderr, "Error: Macro names starting with \"__\" are reserved.\n"); + glcpp_print (parser->errors, "Error: Macro names starting with \"__\" are reserved.\n"); exit(1); } if (strncmp(identifier, "GL_", 3) == 0) { - fprintf (stderr, "Error: Macro names starting with \"GL_\" are reserved.\n"); + glcpp_print (parser->errors, "Error: Macro names starting with \"GL_\" are reserved.\n"); exit(1); } } @@ -1407,7 +1414,7 @@ _define_object_macro (glcpp_parser_t *parser, { macro_t *macro; - _check_for_reserved_macro_name(identifier); + _check_for_reserved_macro_name(parser, identifier); macro = xtalloc (parser, macro_t); @@ -1427,7 +1434,7 @@ _define_function_macro (glcpp_parser_t *parser, { macro_t *macro; - _check_for_reserved_macro_name(identifier); + _check_for_reserved_macro_name(parser, identifier); macro = xtalloc (parser, macro_t); @@ -1574,7 +1581,7 @@ _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, const char *type, int condition) { if (parser->skip_stack == NULL) { - fprintf (stderr, "Error: %s without #if\n", type); + glcpp_printf (parser->errors, "Error: %s without #if\n", type); exit (1); } @@ -1592,7 +1599,7 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser) skip_node_t *node; if (parser->skip_stack == NULL) { - fprintf (stderr, "Error: #endif without #if\n"); + glcpp_print (parser->errors, "Error: #endif without #if\n"); exit (1); } diff --git a/glcpp/glcpp.c b/glcpp/glcpp.c index fcdc4ed8a0f..d204eee49ac 100644 --- a/glcpp/glcpp.c +++ b/glcpp/glcpp.c @@ -35,6 +35,9 @@ main (void) ret = glcpp_parser_parse (parser); + printf("%s", parser->output); + fprintf(stderr, "%s", parser->errors); + glcpp_parser_destroy (parser); return ret; diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index 4459daa4f32..ac103b7fb83 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -141,6 +141,8 @@ struct glcpp_parser { skip_node_t *skip_stack; token_list_t *lex_from_list; token_node_t *lex_from_node; + char *output; + char *errors; }; glcpp_parser_t * -- cgit v1.2.3 From 1b1f43e6089bf1f78e8ff19b43a649b931fe4e31 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 12:01:17 -0700 Subject: glcpp: Add support for lexing from a string. The standalone binary still reads from stdin, however. --- glcpp/glcpp-lex.l | 6 ++++++ glcpp/glcpp.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index cc5f28f8f86..f736ac4d59d 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -201,3 +201,9 @@ NON_STARS_THEN_STARS [^*]*[*]+ } %% + +void +glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader) +{ + yy_scan_string(shader, parser->scanner); +} diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index ac103b7fb83..0d43f0b69e1 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -159,6 +159,9 @@ glcpp_parser_destroy (glcpp_parser_t *parser); int glcpp_lex_init_extra (glcpp_parser_t *parser, yyscan_t* scanner); +void +glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader); + int glcpp_lex (yyscan_t scanner); -- cgit v1.2.3 From 2848c4c183ea0aaca2ca0a23a13196c786403a5c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 12:10:55 -0700 Subject: Complain and exit if the given shader file doesn't exist. --- main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.cpp b/main.cpp index a6d6c47bfda..b8b99bf0bb0 100644 --- a/main.cpp +++ b/main.cpp @@ -218,6 +218,10 @@ main(int argc, char **argv) usage_fail(argv[0]); shader->Source = load_text_file(argv[optind], &shader->SourceLen); + if (shader->Source == NULL) { + printf("File \"%s\" does not exist.\n", argv[optind]); + exit(EXIT_FAILURE); + } compile_shader(shader); -- cgit v1.2.3 From 04ba86a536d76ef24c749e16c785c1634b9187c9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 12:18:00 -0700 Subject: Make the main compiler call the preprocessor. By using a single function, the main compiler doesn't need to include glcpp.h, which currently has a lot of details about the preprocessor internals. In particular, this prevents the two yacc grammars from seeing each other, which would be rather messy to sort out. --- glcpp/Makefile.am | 1 + glcpp/pp.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ glsl_parser_extras.h | 4 ++++ main.cpp | 14 +++++++++++--- 4 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 glcpp/pp.c diff --git a/glcpp/Makefile.am b/glcpp/Makefile.am index 26b769ca609..a49fd615cda 100644 --- a/glcpp/Makefile.am +++ b/glcpp/Makefile.am @@ -26,6 +26,7 @@ libglcpp_la_SOURCES = \ glcpp-parse.y \ glcpp.h \ hash_table.c \ + pp.c \ xtalloc.c BUILT_SOURCES = glcpp-parse.h glcpp-parse.c glcpp-lex.c diff --git a/glcpp/pp.c b/glcpp/pp.c new file mode 100644 index 00000000000..7211bdb8d90 --- /dev/null +++ b/glcpp/pp.c @@ -0,0 +1,44 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "glcpp.h" + +extern int +preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) +{ + int errors; + glcpp_parser_t *parser = glcpp_parser_create (); + glcpp_lex_set_source_string (parser, *shader); + + glcpp_parser_parse (parser); + + errors = parser->errors[0] != '\0'; + fprintf(stderr, "%s", parser->errors); + + talloc_steal(talloc_ctx, parser->output); + *shader = parser->output; + *shader_len = strlen(parser->output); + + glcpp_parser_destroy (parser); + return errors; +} diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index e1585d2872a..cad3424f6bd 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -101,6 +101,10 @@ extern void _mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, const char *fmt, ...); +extern "C" { +extern int preprocess(void *ctx, const char **shader, size_t *shader_len); +} + extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string, size_t len); diff --git a/main.cpp b/main.cpp index b8b99bf0bb0..58657fe2012 100644 --- a/main.cpp +++ b/main.cpp @@ -124,9 +124,17 @@ compile_shader(struct glsl_shader *shader) state.loop_or_switch_nesting = NULL; state.ARB_texture_rectangle_enable = true; - _mesa_glsl_lexer_ctor(& state, shader->Source, shader->SourceLen); - _mesa_glsl_parse(& state); - _mesa_glsl_lexer_dtor(& state); + /* Create a new context for the preprocessor output. Ultimately, this + * should probably be the parser context, but there isn't one yet. + */ + const char *source = shader->Source; + state.error = preprocess(shader, &source, &shader->SourceLen); + + if (!state.error) { + _mesa_glsl_lexer_ctor(& state, source, shader->SourceLen); + _mesa_glsl_parse(& state); + _mesa_glsl_lexer_dtor(& state); + } if (dump_ast) { foreach_list_const(n, &state.translation_unit) { -- cgit v1.2.3 From 3b73ea36c4bda1353aa0315234233fc6fd6a28bd Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 12:21:17 -0700 Subject: glcpp: Pass #version, #extension, and #pragma directives through unchanged. Let the main compiler's lexer/parser handle them. --- glcpp/glcpp-lex.l | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index f736ac4d59d..c28f2f6269e 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -61,6 +61,13 @@ NON_STARS_THEN_STARS [^*]*[*]+ return SPACE; } + /* glcpp doesn't handle #extension, #version, or #pragma directives. + * Simply pass them through to the main compiler's lexer/parser. */ +{HASH}(extension|version|pragma).*\n { + yylval.str = xtalloc_strdup (yyextra, yytext); + return OTHER; +} + {HASH}if/.*\n { yyextra->lexing_if = 1; yyextra->space_tokens = 0; -- cgit v1.2.3 From 739ba06680c762ff0a2e93027fefe0ab84ab6adc Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 12:41:37 -0700 Subject: glcpp: Complain about unrecognized directives. --- glcpp/glcpp-parse.y | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index f9fab8bf293..fde9b92edec 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -360,7 +360,9 @@ text_line: ; non_directive: - pp_tokens NEWLINE + pp_tokens NEWLINE { + yyerror (parser, "Invalid tokens after #"); + } ; replacement_list: -- cgit v1.2.3 From f82d6736487c45ec92596729b004b5a291e9abb6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 12:53:19 -0700 Subject: glcpp: Handle missing newline at EOF. Fixes CorrectFuncOverload.vert. --- glcpp/glcpp-lex.l | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index c28f2f6269e..933d9f449a6 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -33,6 +33,8 @@ %option extra-type="glcpp_parser_t *" %option prefix="glcpp_" +%x DONE + SPACE [[:space:]] NONSPACE [^[:space:]] NEWLINE [\n] @@ -207,6 +209,13 @@ NON_STARS_THEN_STARS [^*]*[*]+ return NEWLINE; } + /* Handle missing newline at EOF. */ +<> { + BEGIN DONE; /* Don't keep matching this rule forever. */ + yyextra->lexing_if = 0; + return NEWLINE; +} + %% void -- cgit v1.2.3 From 3370c5f90b537771d73af7783434c0758ea5de29 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 14:49:40 -0700 Subject: glcpp/tests: Add extra newline at the end of expected output. This newline at EOF is harmless and generated by the previous commit. --- glcpp/tests/000-content-with-spaces.c.expected | 1 + glcpp/tests/001-define.c.expected | 1 + glcpp/tests/002-define-chain.c.expected | 1 + glcpp/tests/003-define-chain-reverse.c.expected | 1 + glcpp/tests/004-define-recursive.c.expected | 1 + glcpp/tests/005-define-composite-chain.c.expected | 1 + glcpp/tests/006-define-composite-chain-reverse.c.expected | 1 + glcpp/tests/007-define-composite-recursive.c.expected | 1 + glcpp/tests/008-define-empty.c.expected | 1 + glcpp/tests/009-undef.c.expected | 1 + glcpp/tests/010-undef-re-define.c.expected | 1 + glcpp/tests/011-define-func-empty.c.expected | 1 + glcpp/tests/012-define-func-no-args.c.expected | 1 + glcpp/tests/013-define-func-1-arg-unused.c.expected | 1 + glcpp/tests/014-define-func-2-arg-unused.c.expected | 1 + glcpp/tests/015-define-object-with-parens.c.expected | 1 + glcpp/tests/016-define-func-1-arg.c.expected | 1 + glcpp/tests/017-define-func-2-args.c.expected | 1 + glcpp/tests/018-define-func-macro-as-parameter.c.expected | 1 + glcpp/tests/019-define-func-1-arg-multi.c.expected | 1 + glcpp/tests/020-define-func-2-arg-multi.c.expected | 1 + glcpp/tests/021-define-func-compose.c.expected | 1 + glcpp/tests/022-define-func-arg-with-parens.c.expected | 1 + glcpp/tests/023-define-extra-whitespace.c.expected | 1 + glcpp/tests/024-define-chain-to-self-recursion.c.expected | 1 + glcpp/tests/025-func-macro-as-non-macro.c.expected | 1 + glcpp/tests/026-define-func-extra-newlines.c.expected | 1 + glcpp/tests/027-define-chain-obj-to-func.c.expected | 1 + glcpp/tests/028-define-chain-obj-to-non-func.c.expected | 1 + glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected | 1 + glcpp/tests/030-define-chain-obj-to-func-compose.c.expected | 1 + glcpp/tests/031-define-chain-func-to-func-compose.c.expected | 1 + glcpp/tests/032-define-func-self-recurse.c.expected | 1 + glcpp/tests/033-define-func-self-compose.c.expected | 1 + glcpp/tests/034-define-func-self-compose-non-func.c.expected | 1 + ...035-define-func-self-compose-non-func-multi-token-argument.c.expected | 1 + glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected | 1 + glcpp/tests/037-finalize-unexpanded-macro.c.expected | 1 + glcpp/tests/038-func-arg-with-commas.c.expected | 1 + glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected | 1 + glcpp/tests/040-token-pasting.c.expected | 1 + glcpp/tests/041-if-0.c.expected | 1 + glcpp/tests/042-if-1.c.expected | 1 + glcpp/tests/043-if-0-else.c.expected | 1 + glcpp/tests/044-if-1-else.c.expected | 1 + glcpp/tests/045-if-0-elif.c.expected | 1 + glcpp/tests/046-if-1-elsif.c.expected | 1 + glcpp/tests/047-if-elif-else.c.expected | 1 + glcpp/tests/048-if-nested.c.expected | 1 + glcpp/tests/049-if-expression-precedence.c.expected | 1 + glcpp/tests/050-if-defined.c.expected | 1 + glcpp/tests/051-if-relational.c.expected | 1 + glcpp/tests/052-if-bitwise.c.expected | 1 + glcpp/tests/053-if-divide-and-shift.c.expected | 1 + glcpp/tests/054-if-with-macros.c.expected | 1 + glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected | 1 + glcpp/tests/056-macro-argument-with-comma.c.expected | 1 + glcpp/tests/057-empty-arguments.c.expected | 1 + glcpp/tests/058-token-pasting-empty-arguments.c.expected | 1 + glcpp/tests/059-token-pasting-integer.c.expected | 1 + glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected | 1 + glcpp/tests/061-define-chain-obj-to-func-multi.c.expected | 1 + glcpp/tests/062-if-0-skips-garbage.c.expected | 1 + glcpp/tests/063-comments.c.expected | 1 + glcpp/tests/071-punctuator.c.expected | 1 + glcpp/tests/072-token-pasting-same-line.c.expected | 1 + glcpp/tests/099-c99-example.c.expected | 1 + 67 files changed, 67 insertions(+) diff --git a/glcpp/tests/000-content-with-spaces.c.expected b/glcpp/tests/000-content-with-spaces.c.expected index a7fc918c908..83f7834d547 100644 --- a/glcpp/tests/000-content-with-spaces.c.expected +++ b/glcpp/tests/000-content-with-spaces.c.expected @@ -1 +1,2 @@ this is four tokens + diff --git a/glcpp/tests/001-define.c.expected b/glcpp/tests/001-define.c.expected index a464d9da742..878fd15d6f8 100644 --- a/glcpp/tests/001-define.c.expected +++ b/glcpp/tests/001-define.c.expected @@ -1,2 +1,3 @@ 1 + diff --git a/glcpp/tests/002-define-chain.c.expected b/glcpp/tests/002-define-chain.c.expected index c6c9ee38a9e..43d484d7131 100644 --- a/glcpp/tests/002-define-chain.c.expected +++ b/glcpp/tests/002-define-chain.c.expected @@ -1,3 +1,4 @@ 1 + diff --git a/glcpp/tests/003-define-chain-reverse.c.expected b/glcpp/tests/003-define-chain-reverse.c.expected index c6c9ee38a9e..43d484d7131 100644 --- a/glcpp/tests/003-define-chain-reverse.c.expected +++ b/glcpp/tests/003-define-chain-reverse.c.expected @@ -1,3 +1,4 @@ 1 + diff --git a/glcpp/tests/004-define-recursive.c.expected b/glcpp/tests/004-define-recursive.c.expected index 2d07687f8ca..4d2698b7a7f 100644 --- a/glcpp/tests/004-define-recursive.c.expected +++ b/glcpp/tests/004-define-recursive.c.expected @@ -4,3 +4,4 @@ foo bar baz + diff --git a/glcpp/tests/005-define-composite-chain.c.expected b/glcpp/tests/005-define-composite-chain.c.expected index 892975c268c..c67358f4f69 100644 --- a/glcpp/tests/005-define-composite-chain.c.expected +++ b/glcpp/tests/005-define-composite-chain.c.expected @@ -1,3 +1,4 @@ a 1 + diff --git a/glcpp/tests/006-define-composite-chain-reverse.c.expected b/glcpp/tests/006-define-composite-chain-reverse.c.expected index 892975c268c..c67358f4f69 100644 --- a/glcpp/tests/006-define-composite-chain-reverse.c.expected +++ b/glcpp/tests/006-define-composite-chain-reverse.c.expected @@ -1,3 +1,4 @@ a 1 + diff --git a/glcpp/tests/007-define-composite-recursive.c.expected b/glcpp/tests/007-define-composite-recursive.c.expected index 0b0b477d9df..30fe4dc1f62 100644 --- a/glcpp/tests/007-define-composite-recursive.c.expected +++ b/glcpp/tests/007-define-composite-recursive.c.expected @@ -4,3 +4,4 @@ a b c foo b c a bar c a b baz + diff --git a/glcpp/tests/008-define-empty.c.expected b/glcpp/tests/008-define-empty.c.expected index 139597f9cb0..b28b04f6431 100644 --- a/glcpp/tests/008-define-empty.c.expected +++ b/glcpp/tests/008-define-empty.c.expected @@ -1,2 +1,3 @@ + diff --git a/glcpp/tests/009-undef.c.expected b/glcpp/tests/009-undef.c.expected index 9c0b35a4518..03a7061af03 100644 --- a/glcpp/tests/009-undef.c.expected +++ b/glcpp/tests/009-undef.c.expected @@ -2,3 +2,4 @@ 1 foo + diff --git a/glcpp/tests/010-undef-re-define.c.expected b/glcpp/tests/010-undef-re-define.c.expected index 5970f49028e..f4f7efdc2bf 100644 --- a/glcpp/tests/010-undef-re-define.c.expected +++ b/glcpp/tests/010-undef-re-define.c.expected @@ -4,3 +4,4 @@ foo 2 + diff --git a/glcpp/tests/011-define-func-empty.c.expected b/glcpp/tests/011-define-func-empty.c.expected index 139597f9cb0..b28b04f6431 100644 --- a/glcpp/tests/011-define-func-empty.c.expected +++ b/glcpp/tests/011-define-func-empty.c.expected @@ -1,2 +1,3 @@ + diff --git a/glcpp/tests/012-define-func-no-args.c.expected b/glcpp/tests/012-define-func-no-args.c.expected index 9f075f26004..03537672974 100644 --- a/glcpp/tests/012-define-func-no-args.c.expected +++ b/glcpp/tests/012-define-func-no-args.c.expected @@ -1,2 +1,3 @@ bar + diff --git a/glcpp/tests/013-define-func-1-arg-unused.c.expected b/glcpp/tests/013-define-func-1-arg-unused.c.expected index a464d9da742..878fd15d6f8 100644 --- a/glcpp/tests/013-define-func-1-arg-unused.c.expected +++ b/glcpp/tests/013-define-func-1-arg-unused.c.expected @@ -1,2 +1,3 @@ 1 + diff --git a/glcpp/tests/014-define-func-2-arg-unused.c.expected b/glcpp/tests/014-define-func-2-arg-unused.c.expected index a464d9da742..878fd15d6f8 100644 --- a/glcpp/tests/014-define-func-2-arg-unused.c.expected +++ b/glcpp/tests/014-define-func-2-arg-unused.c.expected @@ -1,2 +1,3 @@ 1 + diff --git a/glcpp/tests/015-define-object-with-parens.c.expected b/glcpp/tests/015-define-object-with-parens.c.expected index a70321a4c51..d6f8cb9dc61 100644 --- a/glcpp/tests/015-define-object-with-parens.c.expected +++ b/glcpp/tests/015-define-object-with-parens.c.expected @@ -2,3 +2,4 @@ ()1() ()2() + diff --git a/glcpp/tests/016-define-func-1-arg.c.expected b/glcpp/tests/016-define-func-1-arg.c.expected index 6bfe04f7381..7f1828a3c61 100644 --- a/glcpp/tests/016-define-func-1-arg.c.expected +++ b/glcpp/tests/016-define-func-1-arg.c.expected @@ -1,2 +1,3 @@ ((bar)+1) + diff --git a/glcpp/tests/017-define-func-2-args.c.expected b/glcpp/tests/017-define-func-2-args.c.expected index f7a2b8c26cb..9f341dac00a 100644 --- a/glcpp/tests/017-define-func-2-args.c.expected +++ b/glcpp/tests/017-define-func-2-args.c.expected @@ -1,2 +1,3 @@ ((bar)*(baz)) + diff --git a/glcpp/tests/018-define-func-macro-as-parameter.c.expected b/glcpp/tests/018-define-func-macro-as-parameter.c.expected index c6c9ee38a9e..43d484d7131 100644 --- a/glcpp/tests/018-define-func-macro-as-parameter.c.expected +++ b/glcpp/tests/018-define-func-macro-as-parameter.c.expected @@ -1,3 +1,4 @@ 1 + diff --git a/glcpp/tests/019-define-func-1-arg-multi.c.expected b/glcpp/tests/019-define-func-1-arg-multi.c.expected index 1e89b8cfd0c..4314fc88d83 100644 --- a/glcpp/tests/019-define-func-1-arg-multi.c.expected +++ b/glcpp/tests/019-define-func-1-arg-multi.c.expected @@ -1,2 +1,3 @@ (this is more than one word) + diff --git a/glcpp/tests/020-define-func-2-arg-multi.c.expected b/glcpp/tests/020-define-func-2-arg-multi.c.expected index 19f59f5ecb7..5648e4fb9d4 100644 --- a/glcpp/tests/020-define-func-2-arg-multi.c.expected +++ b/glcpp/tests/020-define-func-2-arg-multi.c.expected @@ -1,2 +1,3 @@ one fish,two fish,red fish,blue fish + diff --git a/glcpp/tests/021-define-func-compose.c.expected b/glcpp/tests/021-define-func-compose.c.expected index 87f51f0baca..1d62105de4c 100644 --- a/glcpp/tests/021-define-func-compose.c.expected +++ b/glcpp/tests/021-define-func-compose.c.expected @@ -1,3 +1,4 @@ (2*((1+(3)))) + diff --git a/glcpp/tests/022-define-func-arg-with-parens.c.expected b/glcpp/tests/022-define-func-arg-with-parens.c.expected index 1dfc6698bb7..66c16581758 100644 --- a/glcpp/tests/022-define-func-arg-with-parens.c.expected +++ b/glcpp/tests/022-define-func-arg-with-parens.c.expected @@ -1,2 +1,3 @@ (argument(including parens)for the win) + diff --git a/glcpp/tests/023-define-extra-whitespace.c.expected b/glcpp/tests/023-define-extra-whitespace.c.expected index 9c58275d0f9..573829c2d69 100644 --- a/glcpp/tests/023-define-extra-whitespace.c.expected +++ b/glcpp/tests/023-define-extra-whitespace.c.expected @@ -6,3 +6,4 @@ 2 3 4 5 6 7 + diff --git a/glcpp/tests/024-define-chain-to-self-recursion.c.expected b/glcpp/tests/024-define-chain-to-self-recursion.c.expected index 15600af546b..ad955fce6ec 100644 --- a/glcpp/tests/024-define-chain-to-self-recursion.c.expected +++ b/glcpp/tests/024-define-chain-to-self-recursion.c.expected @@ -1,3 +1,4 @@ foo + diff --git a/glcpp/tests/025-func-macro-as-non-macro.c.expected b/glcpp/tests/025-func-macro-as-non-macro.c.expected index 4a59f0520e3..960f44511a9 100644 --- a/glcpp/tests/025-func-macro-as-non-macro.c.expected +++ b/glcpp/tests/025-func-macro-as-non-macro.c.expected @@ -1,2 +1,3 @@ foo bar + diff --git a/glcpp/tests/026-define-func-extra-newlines.c.expected b/glcpp/tests/026-define-func-extra-newlines.c.expected index 5e3c70f2cc5..f0888f21b94 100644 --- a/glcpp/tests/026-define-func-extra-newlines.c.expected +++ b/glcpp/tests/026-define-func-extra-newlines.c.expected @@ -1,3 +1,4 @@ bar + diff --git a/glcpp/tests/027-define-chain-obj-to-func.c.expected b/glcpp/tests/027-define-chain-obj-to-func.c.expected index 94c15f95059..aef762e1e69 100644 --- a/glcpp/tests/027-define-chain-obj-to-func.c.expected +++ b/glcpp/tests/027-define-chain-obj-to-func.c.expected @@ -1,3 +1,4 @@ success + diff --git a/glcpp/tests/028-define-chain-obj-to-non-func.c.expected b/glcpp/tests/028-define-chain-obj-to-non-func.c.expected index 94c15f95059..aef762e1e69 100644 --- a/glcpp/tests/028-define-chain-obj-to-non-func.c.expected +++ b/glcpp/tests/028-define-chain-obj-to-non-func.c.expected @@ -1,3 +1,4 @@ success + diff --git a/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected b/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected index 94c15f95059..aef762e1e69 100644 --- a/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected +++ b/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected @@ -1,3 +1,4 @@ success + diff --git a/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected b/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected index bed826e7831..729bdd15f80 100644 --- a/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected +++ b/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected @@ -2,3 +2,4 @@ success + diff --git a/glcpp/tests/031-define-chain-func-to-func-compose.c.expected b/glcpp/tests/031-define-chain-func-to-func-compose.c.expected index bed826e7831..729bdd15f80 100644 --- a/glcpp/tests/031-define-chain-func-to-func-compose.c.expected +++ b/glcpp/tests/031-define-chain-func-to-func-compose.c.expected @@ -2,3 +2,4 @@ success + diff --git a/glcpp/tests/032-define-func-self-recurse.c.expected b/glcpp/tests/032-define-func-self-recurse.c.expected index 983f9417401..541d44db7ab 100644 --- a/glcpp/tests/032-define-func-self-recurse.c.expected +++ b/glcpp/tests/032-define-func-self-recurse.c.expected @@ -1,2 +1,3 @@ foo(2*(3)) + diff --git a/glcpp/tests/033-define-func-self-compose.c.expected b/glcpp/tests/033-define-func-self-compose.c.expected index 08183623643..6ea6905d80b 100644 --- a/glcpp/tests/033-define-func-self-compose.c.expected +++ b/glcpp/tests/033-define-func-self-compose.c.expected @@ -1,2 +1,3 @@ foo(2*(foo(2*(3)))) + diff --git a/glcpp/tests/034-define-func-self-compose-non-func.c.expected b/glcpp/tests/034-define-func-self-compose-non-func.c.expected index 3f808fe665d..24823b1b673 100644 --- a/glcpp/tests/034-define-func-self-compose-non-func.c.expected +++ b/glcpp/tests/034-define-func-self-compose-non-func.c.expected @@ -1,2 +1,3 @@ foo + diff --git a/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected b/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected index 09dfdd64e9b..137a9ea2db8 100644 --- a/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected +++ b/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected @@ -1,2 +1,3 @@ 1+foo + diff --git a/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected b/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected index 580ed9599c5..ff6360bfe4e 100644 --- a/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected +++ b/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected @@ -1,3 +1,4 @@ more success + diff --git a/glcpp/tests/037-finalize-unexpanded-macro.c.expected b/glcpp/tests/037-finalize-unexpanded-macro.c.expected index e804d7e4f9f..cbadee848a5 100644 --- a/glcpp/tests/037-finalize-unexpanded-macro.c.expected +++ b/glcpp/tests/037-finalize-unexpanded-macro.c.expected @@ -1,3 +1,4 @@ expand(just once) + diff --git a/glcpp/tests/038-func-arg-with-commas.c.expected b/glcpp/tests/038-func-arg-with-commas.c.expected index 6544adb3a25..5a28fb3b66c 100644 --- a/glcpp/tests/038-func-arg-with-commas.c.expected +++ b/glcpp/tests/038-func-arg-with-commas.c.expected @@ -1,2 +1,3 @@ success + diff --git a/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected b/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected index 8a15397a033..b73869d0238 100644 --- a/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected +++ b/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected @@ -1,3 +1,4 @@ (two,words) + diff --git a/glcpp/tests/040-token-pasting.c.expected b/glcpp/tests/040-token-pasting.c.expected index 48e836ec3fa..36f66992539 100644 --- a/glcpp/tests/040-token-pasting.c.expected +++ b/glcpp/tests/040-token-pasting.c.expected @@ -1,2 +1,3 @@ onetoken + diff --git a/glcpp/tests/041-if-0.c.expected b/glcpp/tests/041-if-0.c.expected index 8b506b32d55..3800024c6ff 100644 --- a/glcpp/tests/041-if-0.c.expected +++ b/glcpp/tests/041-if-0.c.expected @@ -3,3 +3,4 @@ success_1 success_2 + diff --git a/glcpp/tests/042-if-1.c.expected b/glcpp/tests/042-if-1.c.expected index a6ae9465a97..e591044adbb 100644 --- a/glcpp/tests/042-if-1.c.expected +++ b/glcpp/tests/042-if-1.c.expected @@ -3,3 +3,4 @@ success_1 success_2 success_3 + diff --git a/glcpp/tests/043-if-0-else.c.expected b/glcpp/tests/043-if-0-else.c.expected index 3d7e6be96c8..ee9e677096e 100644 --- a/glcpp/tests/043-if-0-else.c.expected +++ b/glcpp/tests/043-if-0-else.c.expected @@ -5,3 +5,4 @@ success_1 success_2 success_3 + diff --git a/glcpp/tests/044-if-1-else.c.expected b/glcpp/tests/044-if-1-else.c.expected index 4a31e1cfa9e..129f5c8542e 100644 --- a/glcpp/tests/044-if-1-else.c.expected +++ b/glcpp/tests/044-if-1-else.c.expected @@ -5,3 +5,4 @@ success_2 success_3 + diff --git a/glcpp/tests/045-if-0-elif.c.expected b/glcpp/tests/045-if-0-elif.c.expected index a9bb1588e4f..97a11b4472e 100644 --- a/glcpp/tests/045-if-0-elif.c.expected +++ b/glcpp/tests/045-if-0-elif.c.expected @@ -9,3 +9,4 @@ success_3 success_4 + diff --git a/glcpp/tests/046-if-1-elsif.c.expected b/glcpp/tests/046-if-1-elsif.c.expected index a4995713ca5..b928b917e3d 100644 --- a/glcpp/tests/046-if-1-elsif.c.expected +++ b/glcpp/tests/046-if-1-elsif.c.expected @@ -9,3 +9,4 @@ success_2 success_3 + diff --git a/glcpp/tests/047-if-elif-else.c.expected b/glcpp/tests/047-if-elif-else.c.expected index 54d30861197..e5b53a3fa59 100644 --- a/glcpp/tests/047-if-elif-else.c.expected +++ b/glcpp/tests/047-if-elif-else.c.expected @@ -9,3 +9,4 @@ success_1 success_2 success_3 + diff --git a/glcpp/tests/048-if-nested.c.expected b/glcpp/tests/048-if-nested.c.expected index 8beb9c32c37..c61fd0b3159 100644 --- a/glcpp/tests/048-if-nested.c.expected +++ b/glcpp/tests/048-if-nested.c.expected @@ -9,3 +9,4 @@ success_1 success_2 + diff --git a/glcpp/tests/049-if-expression-precedence.c.expected b/glcpp/tests/049-if-expression-precedence.c.expected index 729bdd15f80..569debb0bb6 100644 --- a/glcpp/tests/049-if-expression-precedence.c.expected +++ b/glcpp/tests/049-if-expression-precedence.c.expected @@ -3,3 +3,4 @@ success + diff --git a/glcpp/tests/050-if-defined.c.expected b/glcpp/tests/050-if-defined.c.expected index 737eb8d9403..3f01955ee40 100644 --- a/glcpp/tests/050-if-defined.c.expected +++ b/glcpp/tests/050-if-defined.c.expected @@ -15,3 +15,4 @@ success_2 success_3 + diff --git a/glcpp/tests/051-if-relational.c.expected b/glcpp/tests/051-if-relational.c.expected index 652fefdd43b..d2b76f14576 100644 --- a/glcpp/tests/051-if-relational.c.expected +++ b/glcpp/tests/051-if-relational.c.expected @@ -33,3 +33,4 @@ success_5 + diff --git a/glcpp/tests/052-if-bitwise.c.expected b/glcpp/tests/052-if-bitwise.c.expected index 44e52b206e5..bb5d92e8d92 100644 --- a/glcpp/tests/052-if-bitwise.c.expected +++ b/glcpp/tests/052-if-bitwise.c.expected @@ -18,3 +18,4 @@ success_4 + diff --git a/glcpp/tests/053-if-divide-and-shift.c.expected b/glcpp/tests/053-if-divide-and-shift.c.expected index 7e78e0454e0..f97e93673cc 100644 --- a/glcpp/tests/053-if-divide-and-shift.c.expected +++ b/glcpp/tests/053-if-divide-and-shift.c.expected @@ -13,3 +13,4 @@ success_2 success_3 + diff --git a/glcpp/tests/054-if-with-macros.c.expected b/glcpp/tests/054-if-with-macros.c.expected index 70f737c90a9..27ea4969628 100644 --- a/glcpp/tests/054-if-with-macros.c.expected +++ b/glcpp/tests/054-if-with-macros.c.expected @@ -32,3 +32,4 @@ success_6 + diff --git a/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected b/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected index 94c15f95059..aef762e1e69 100644 --- a/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected +++ b/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected @@ -1,3 +1,4 @@ success + diff --git a/glcpp/tests/056-macro-argument-with-comma.c.expected b/glcpp/tests/056-macro-argument-with-comma.c.expected index bed826e7831..729bdd15f80 100644 --- a/glcpp/tests/056-macro-argument-with-comma.c.expected +++ b/glcpp/tests/056-macro-argument-with-comma.c.expected @@ -2,3 +2,4 @@ success + diff --git a/glcpp/tests/057-empty-arguments.c.expected b/glcpp/tests/057-empty-arguments.c.expected index 7d97e15e29d..4e3aad52173 100644 --- a/glcpp/tests/057-empty-arguments.c.expected +++ b/glcpp/tests/057-empty-arguments.c.expected @@ -4,3 +4,4 @@ success success success + diff --git a/glcpp/tests/058-token-pasting-empty-arguments.c.expected b/glcpp/tests/058-token-pasting-empty-arguments.c.expected index e0967a1b951..a1c34e5c1f8 100644 --- a/glcpp/tests/058-token-pasting-empty-arguments.c.expected +++ b/glcpp/tests/058-token-pasting-empty-arguments.c.expected @@ -3,3 +3,4 @@ ab a b + diff --git a/glcpp/tests/059-token-pasting-integer.c.expected b/glcpp/tests/059-token-pasting-integer.c.expected index f1288aa7cb7..f1a2cd21c13 100644 --- a/glcpp/tests/059-token-pasting-integer.c.expected +++ b/glcpp/tests/059-token-pasting-integer.c.expected @@ -2,3 +2,4 @@ 12 1000 identifier2 + diff --git a/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected b/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected index 3e5501aa6e8..c1f0d24a144 100644 --- a/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected +++ b/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected @@ -1,3 +1,4 @@ 5*2 + diff --git a/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected b/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected index 15eb64b97f1..111f7d10634 100644 --- a/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected +++ b/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected @@ -3,3 +3,4 @@ success + diff --git a/glcpp/tests/062-if-0-skips-garbage.c.expected b/glcpp/tests/062-if-0-skips-garbage.c.expected index 3f2ff2d6cc8..6fb66a5e2f0 100644 --- a/glcpp/tests/062-if-0-skips-garbage.c.expected +++ b/glcpp/tests/062-if-0-skips-garbage.c.expected @@ -3,3 +3,4 @@ + diff --git a/glcpp/tests/063-comments.c.expected b/glcpp/tests/063-comments.c.expected index 4998d76cc22..ed4feedd457 100644 --- a/glcpp/tests/063-comments.c.expected +++ b/glcpp/tests/063-comments.c.expected @@ -11,3 +11,4 @@ more code here are not treated like comments. + diff --git a/glcpp/tests/071-punctuator.c.expected b/glcpp/tests/071-punctuator.c.expected index 959d6825988..fee253b7452 100644 --- a/glcpp/tests/071-punctuator.c.expected +++ b/glcpp/tests/071-punctuator.c.expected @@ -1 +1,2 @@ a = b + diff --git a/glcpp/tests/072-token-pasting-same-line.c.expected b/glcpp/tests/072-token-pasting-same-line.c.expected index 7b80af7e465..c780b43d70f 100644 --- a/glcpp/tests/072-token-pasting-same-line.c.expected +++ b/glcpp/tests/072-token-pasting-same-line.c.expected @@ -1,2 +1,3 @@ success_1 success_2 success_3 + diff --git a/glcpp/tests/099-c99-example.c.expected b/glcpp/tests/099-c99-example.c.expected index 352bbff48f5..19be7505552 100644 --- a/glcpp/tests/099-c99-example.c.expected +++ b/glcpp/tests/099-c99-example.c.expected @@ -14,3 +14,4 @@ f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); int i[] = { 1, 23, 4, 5, }; + -- cgit v1.2.3 From b673ff91abec7d0ddb09a1fcddc734c3425eb8eb Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 13:19:27 -0700 Subject: glcpp: Print errors on stdout instead of stderr (non-standalone version). Otherwise, piglit marks tests as "warn" when the shader was (correctly) failing. --- glcpp/pp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glcpp/pp.c b/glcpp/pp.c index 7211bdb8d90..04ea0a47972 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -33,7 +33,7 @@ preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) glcpp_parser_parse (parser); errors = parser->errors[0] != '\0'; - fprintf(stderr, "%s", parser->errors); + printf("%s", parser->errors); talloc_steal(talloc_ctx, parser->output); *shader = parser->output; -- cgit v1.2.3 From e0e429fca3f1f67e5d18f0989fd2dcc0d23a6bb9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 16:26:28 -0700 Subject: glcpp: Build a reentrant parser. --- glcpp/glcpp-lex.l | 14 +++++++------- glcpp/glcpp-parse.y | 12 +++++++----- glcpp/glcpp.h | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index 933d9f449a6..06bde3f1957 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -29,7 +29,7 @@ #include "glcpp-parse.h" %} -%option reentrant noyywrap +%option bison-bridge reentrant noyywrap %option extra-type="glcpp_parser_t *" %option prefix="glcpp_" @@ -66,7 +66,7 @@ NON_STARS_THEN_STARS [^*]*[*]+ /* glcpp doesn't handle #extension, #version, or #pragma directives. * Simply pass them through to the main compiler's lexer/parser. */ {HASH}(extension|version|pragma).*\n { - yylval.str = xtalloc_strdup (yyextra, yytext); + yylval->str = xtalloc_strdup (yyextra, yytext); return OTHER; } @@ -130,17 +130,17 @@ NON_STARS_THEN_STARS [^*]*[*]+ } {DECIMAL_INTEGER} { - yylval.str = xtalloc_strdup (yyextra, yytext); + yylval->str = xtalloc_strdup (yyextra, yytext); return INTEGER_STRING; } {OCTAL_INTEGER} { - yylval.str = xtalloc_strdup (yyextra, yytext); + yylval->str = xtalloc_strdup (yyextra, yytext); return INTEGER_STRING; } {HEXADECIMAL_INTEGER} { - yylval.str = xtalloc_strdup (yyextra, yytext); + yylval->str = xtalloc_strdup (yyextra, yytext); return INTEGER_STRING; } @@ -185,7 +185,7 @@ NON_STARS_THEN_STARS [^*]*[*]+ } {IDENTIFIER} { - yylval.str = xtalloc_strdup (yyextra, yytext); + yylval->str = xtalloc_strdup (yyextra, yytext); return IDENTIFIER; } @@ -194,7 +194,7 @@ NON_STARS_THEN_STARS [^*]*[*]+ } {OTHER}+ { - yylval.str = xtalloc_strdup (yyextra, yytext); + yylval->str = xtalloc_strdup (yyextra, yytext); return OTHER; } diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index fde9b92edec..8119de3aa5c 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -133,13 +133,15 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser); #define yylex glcpp_parser_lex static int -glcpp_parser_lex (glcpp_parser_t *parser); +glcpp_parser_lex (YYSTYPE *yylval, glcpp_parser_t *parser); static void glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); %} +%pure-parser + %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} @@ -1449,13 +1451,13 @@ _define_function_macro (glcpp_parser_t *parser, } static int -glcpp_parser_lex (glcpp_parser_t *parser) +glcpp_parser_lex (YYSTYPE *yylval, glcpp_parser_t *parser) { token_node_t *node; int ret; if (parser->lex_from_list == NULL) { - ret = glcpp_lex (parser->scanner); + ret = glcpp_lex (yylval, parser->scanner); /* XXX: This ugly block of code exists for the sole * purpose of converting a NEWLINE token into a SPACE @@ -1501,7 +1503,7 @@ glcpp_parser_lex (glcpp_parser_t *parser) { macro_t *macro; macro = hash_table_find (parser->defines, - yylval.str); + yylval->str); if (macro && macro->is_function) { parser->newline_as_space = 1; parser->paren_count = 0; @@ -1519,7 +1521,7 @@ glcpp_parser_lex (glcpp_parser_t *parser) return NEWLINE; } - yylval = node->token->value; + *yylval = node->token->value; ret = node->token->type; parser->lex_from_node = node->next; diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index 0d43f0b69e1..3441ab86327 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -163,7 +163,7 @@ void glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader); int -glcpp_lex (yyscan_t scanner); +glcpp_lex (YYSTYPE *lvalp, yyscan_t scanner); int glcpp_lex_destroy (yyscan_t scanner); -- cgit v1.2.3 From 77260fc0a04c72c98389adeb7244467e10ef2979 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 14:36:34 -0700 Subject: glcpp: Actually support #ifdef and #ifndef. Strangely, the lexer never created these tokens, even though the parser already had code to handle them. --- glcpp/glcpp-lex.l | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index 06bde3f1957..a04e0fabdf8 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -70,6 +70,16 @@ NON_STARS_THEN_STARS [^*]*[*]+ return OTHER; } +{HASH}ifdef/.*\n { + yyextra->space_tokens = 0; + return HASH_IFDEF; +} + +{HASH}ifndef/.*\n { + yyextra->space_tokens = 0; + return HASH_IFNDEF; +} + {HASH}if/.*\n { yyextra->lexing_if = 1; yyextra->space_tokens = 0; -- cgit v1.2.3 From f70f60739a9037102a257396822f0ed81b00cb77 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 13:07:13 -0700 Subject: glcpp: Add %error-verbose. --- glcpp/glcpp-parse.y | 1 + 1 file changed, 1 insertion(+) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 8119de3aa5c..c5c03b68fbd 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -141,6 +141,7 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); %} %pure-parser +%error-verbose %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -- cgit v1.2.3 From 465e03ee07b778ed4edc24a810b9795409bcdbf9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 16:35:57 -0700 Subject: glcpp: Add plumbing to support line locations. --- glcpp/glcpp-lex.l | 2 +- glcpp/glcpp-parse.y | 16 +++++++++------- glcpp/glcpp.h | 12 +++++++++++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index a04e0fabdf8..f17336974e6 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -29,7 +29,7 @@ #include "glcpp-parse.h" %} -%option bison-bridge reentrant noyywrap +%option bison-bridge bison-locations reentrant noyywrap %option extra-type="glcpp_parser_t *" %option prefix="glcpp_" diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index c5c03b68fbd..52927d83c6c 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -34,7 +34,7 @@ stream = talloc_asprintf_append(stream, fmt, args) static void -yyerror (glcpp_parser_t *parser, const char *error); +yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error); static void _define_object_macro (glcpp_parser_t *parser, @@ -133,7 +133,7 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser); #define yylex glcpp_parser_lex static int -glcpp_parser_lex (YYSTYPE *yylval, glcpp_parser_t *parser); +glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser); static void glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); @@ -142,6 +142,7 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); %pure-parser %error-verbose +%locations %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} @@ -364,7 +365,7 @@ text_line: non_directive: pp_tokens NEWLINE { - yyerror (parser, "Invalid tokens after #"); + yyerror (& @1, parser, "Invalid tokens after #"); } ; @@ -861,9 +862,10 @@ _token_list_print (glcpp_parser_t *parser, token_list_t *list) } void -yyerror (glcpp_parser_t *parser, const char *error) +yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error) { - glcpp_printf(parser->errors, "Parse error: %s\n", error); + glcpp_printf(parser->errors, "%u:%u(%u): preprocessor error: %s\n", + locp->source, locp->first_line, locp->first_column, error); } glcpp_parser_t * @@ -1452,13 +1454,13 @@ _define_function_macro (glcpp_parser_t *parser, } static int -glcpp_parser_lex (YYSTYPE *yylval, glcpp_parser_t *parser) +glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser) { token_node_t *node; int ret; if (parser->lex_from_list == NULL) { - ret = glcpp_lex (yylval, parser->scanner); + ret = glcpp_lex (yylval, yylloc, parser->scanner); /* XXX: This ugly block of code exists for the sole * purpose of converting a NEWLINE token into a SPACE diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index 3441ab86327..1d139af064f 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -59,6 +59,16 @@ typedef union YYSTYPE # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 +typedef struct YYLTYPE { + int first_line; + int first_column; + int last_line; + int last_column; + unsigned source; +} YYLTYPE; +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 + struct token { int type; YYSTYPE value; @@ -163,7 +173,7 @@ void glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader); int -glcpp_lex (YYSTYPE *lvalp, yyscan_t scanner); +glcpp_lex (YYSTYPE *lvalp, YYLTYPE *llocp, yyscan_t scanner); int glcpp_lex_destroy (yyscan_t scanner); -- cgit v1.2.3 From db938103c7d22a3bd4b14202f7f69f273840f2cc Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 17:41:12 -0700 Subject: glcpp: Set line locations in the lexer. --- glcpp/glcpp-lex.l | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index f17336974e6..3703ad90fe2 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -27,13 +27,22 @@ #include "glcpp.h" #include "glcpp-parse.h" + +#define YY_USER_ACTION \ + do { \ + yylloc->source = 0; \ + yylloc->first_column = yycolumn + 1; \ + yylloc->first_line = yylineno + 1; \ + yycolumn += yyleng; \ + } while(0); %} %option bison-bridge bison-locations reentrant noyywrap %option extra-type="glcpp_parser_t *" %option prefix="glcpp_" +%option stack -%x DONE +%x DONE COMMENT SPACE [[:space:]] NONSPACE [^[:space:]] @@ -48,17 +57,23 @@ DECIMAL_INTEGER [1-9][0-9]*[uU]? OCTAL_INTEGER 0[0-7]*[uU]? HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? -NON_STARS_THEN_STARS [^*]*[*]+ - %% /* Single-line comments */ "//"[^\n]+\n { + yylineno++; + yycolumn = 0; return NEWLINE; } /* Multi-line comments */ -"/*"({NON_STARS_THEN_STARS}[^*/])*{NON_STARS_THEN_STARS}"/" { +"/*" { yy_push_state(COMMENT, yyscanner); } +[^*\n]* +[^*\n]*\n { yylineno++; yycolumn = 0; } +"*"+[^*/\n]* +"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; } +"*"+"/" { + yy_pop_state(yyscanner); if (yyextra->space_tokens) return SPACE; } @@ -216,6 +231,8 @@ NON_STARS_THEN_STARS [^*]*[*]+ \n { yyextra->lexing_if = 0; + yylineno++; + yycolumn = 0; return NEWLINE; } -- cgit v1.2.3 From b78c9ddfbfecb983f7ab519bb07889333bdab959 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 16:58:31 -0700 Subject: glcpp: Set locations on tokens. --- glcpp/glcpp-parse.y | 33 ++++++++++++++++++++++++--------- glcpp/glcpp.h | 1 + 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 52927d83c6c..f26dd9a0dbc 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -391,18 +391,23 @@ pp_tokens: preprocessing_token: IDENTIFIER { $$ = _token_create_str (parser, IDENTIFIER, $1); + $$->location = yylloc; } | INTEGER_STRING { $$ = _token_create_str (parser, INTEGER_STRING, $1); + $$->location = yylloc; } | operator { $$ = _token_create_ival (parser, $1, $1); + $$->location = yylloc; } | OTHER { $$ = _token_create_str (parser, OTHER, $1); + $$->location = yylloc; } | SPACE { $$ = _token_create_ival (parser, SPACE, SPACE); + $$->location = yylloc; } ; @@ -781,6 +786,8 @@ _token_print (char **out, token_t *token) static token_t * _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) { + token_t *combined = NULL; + /* Pasting a placeholder onto anything makes no change. */ if (other->type == PLACEHOLDER) return token; @@ -794,34 +801,40 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) switch (token->type) { case '<': if (other->type == '<') - return _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT); + combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT); else if (other->type == '=') - return _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL); + combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL); break; case '>': if (other->type == '>') - return _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT); + combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT); else if (other->type == '=') - return _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL); + combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL); break; case '=': if (other->type == '=') - return _token_create_ival (token, EQUAL, EQUAL); + combined = _token_create_ival (token, EQUAL, EQUAL); break; case '!': if (other->type == '=') - return _token_create_ival (token, NOT_EQUAL, NOT_EQUAL); + combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL); break; case '&': if (other->type == '&') - return _token_create_ival (token, AND, AND); + combined = _token_create_ival (token, AND, AND); break; case '|': if (other->type == '|') - return _token_create_ival (token, OR, OR); + combined = _token_create_ival (token, OR, OR); break; } + if (combined != NULL) { + /* Inherit the location from the first token */ + combined->location = token->location; + return combined; + } + /* Two string-valued tokens can usually just be mashed * together. * @@ -837,7 +850,9 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) str = xtalloc_asprintf (token, "%s%s", token->value.str, other->value.str); - return _token_create_str (token, token->type, str); + combined = _token_create_str (token, token->type, str); + combined->location = token->location; + return combined; } glcpp_print (parser->errors, "Error: Pasting \""); diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index 1d139af064f..2d4c84796ba 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -72,6 +72,7 @@ typedef struct YYLTYPE { struct token { int type; YYSTYPE value; + YYLTYPE location; }; typedef struct token_node { -- cgit v1.2.3 From f1e6c069fac93dd2b7b2026ccd24833a066c895a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 12:03:25 -0700 Subject: glcpp: Introduce new glcpp_error function. --- glcpp/glcpp-parse.y | 3 +-- glcpp/glcpp.h | 3 +++ glcpp/pp.c | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index f26dd9a0dbc..d7a104893a0 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -879,8 +879,7 @@ _token_list_print (glcpp_parser_t *parser, token_list_t *list) void yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error) { - glcpp_printf(parser->errors, "%u:%u(%u): preprocessor error: %s\n", - locp->source, locp->first_line, locp->first_column, error); + glcpp_error(locp, parser, "%s", error); } glcpp_parser_t * diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index 2d4c84796ba..45bbff3ad4a 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -165,6 +165,9 @@ glcpp_parser_parse (glcpp_parser_t *parser); void glcpp_parser_destroy (glcpp_parser_t *parser); +void +glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...); + /* Generated by glcpp-lex.l to glcpp-lex.c */ int diff --git a/glcpp/pp.c b/glcpp/pp.c index 04ea0a47972..5d1ff8c6823 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -23,6 +23,20 @@ #include "glcpp.h" +void +glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) +{ + parser->errors = talloc_asprintf_append(parser->errors, "%u:%u(%u): " + "preprocessor error: ", + locp->source, locp->first_line, + locp->first_column); + va_list ap; + va_start(ap, fmt); + parser->errors = talloc_vasprintf_append(parser->errors, fmt, ap); + va_end(ap); + parser->errors = talloc_strdup_append(parser->errors, "\n"); +} + extern int preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) { -- cgit v1.2.3 From ca9e5fce25a8cffea04be0c1b9590265764c2af6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 16 Jun 2010 17:31:50 -0700 Subject: glcpp: Print locations in error messages where possible. --- glcpp/glcpp-parse.y | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index d7a104893a0..0444b0c8aa3 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -733,7 +733,7 @@ _token_print (char **out, token_t *token) case IDENTIFIER: case INTEGER_STRING: case OTHER: - glcpp_printf (*out, "%s", token->value.str); + glcpp_print (*out, token->value.str); break; case SPACE: glcpp_print (*out, " "); @@ -855,7 +855,8 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) return combined; } - glcpp_print (parser->errors, "Error: Pasting \""); + glcpp_error (&token->location, parser, ""); + glcpp_print (parser->errors, "Pasting \""); _token_print (&parser->errors, token); glcpp_print (parser->errors, "\" and \""); _token_print (&parser->errors, other); @@ -946,7 +947,7 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser, while (next && next->token->type == SPACE) next = next->next; if (next == NULL || next->token->type != IDENTIFIER) { - glcpp_print (parser->errors, "Error: operator \"defined\" requires an identifier\n"); + yyerror (&node->token->location, parser, "operator \"defined\" requires an identifier\n"); exit (1); } macro = hash_table_find (parser->defines, @@ -1093,8 +1094,7 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, case FUNCTION_NOT_A_FUNCTION: return NULL; case FUNCTION_UNBALANCED_PARENTHESES: - glcpp_printf (parser->errors, "Error: Macro %s call has unbalanced parentheses\n", - identifier); + glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier); exit (1); return NULL; } @@ -1110,7 +1110,7 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, _argument_list_length (arguments) == 1 && arguments->head->argument->head == NULL))) { - glcpp_printf (parser->errors, + glcpp_error (&node->token->location, parser, "Error: macro %s invoked with %d arguments (expected %d)\n", identifier, _argument_list_length (arguments), @@ -1180,7 +1180,7 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, next_non_space = next_non_space->next; if (next_non_space == NULL) { - glcpp_print (parser->errors, "Error: '##' cannot appear at either end of a macro expansion\n"); + yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n"); return NULL; } -- cgit v1.2.3 From dcdf62f1c64f41ca2d1da4cf59e1b6f40542a934 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 12:21:53 -0700 Subject: glcpp: Add line locations to "reserved name" error messages. --- glcpp/glcpp-parse.y | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 0444b0c8aa3..b1669fa331c 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -38,11 +38,13 @@ yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error); static void _define_object_macro (glcpp_parser_t *parser, + YYLTYPE *loc, const char *macro, token_list_t *replacements); static void _define_function_macro (glcpp_parser_t *parser, + YYLTYPE *loc, const char *macro, string_list_t *parameters, token_list_t *replacements); @@ -197,13 +199,13 @@ expanded_line: control_line: HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE { - _define_object_macro (parser, $2, $3); + _define_object_macro (parser, & @2, $2, $3); } | HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE { - _define_function_macro (parser, $2, NULL, $5); + _define_function_macro (parser, & @2, $2, NULL, $5); } | HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE { - _define_function_macro (parser, $2, $4, $6); + _define_function_macro (parser, & @2, $2, $4, $6); } | HASH_UNDEF IDENTIFIER NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); @@ -1413,29 +1415,31 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, } void -_check_for_reserved_macro_name (glcpp_parser_t *parser, const char *identifier) +_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc, + const char *identifier) { /* According to the GLSL specification, macro names starting with "__" * or "GL_" are reserved for future use. So, don't allow them. */ if (strncmp(identifier, "__", 2) == 0) { - glcpp_print (parser->errors, "Error: Macro names starting with \"__\" are reserved.\n"); + glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n"); exit(1); } if (strncmp(identifier, "GL_", 3) == 0) { - glcpp_print (parser->errors, "Error: Macro names starting with \"GL_\" are reserved.\n"); + glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n"); exit(1); } } void _define_object_macro (glcpp_parser_t *parser, + YYLTYPE *loc, const char *identifier, token_list_t *replacements) { macro_t *macro; - _check_for_reserved_macro_name(parser, identifier); + _check_for_reserved_macro_name(parser, loc, identifier); macro = xtalloc (parser, macro_t); @@ -1449,13 +1453,14 @@ _define_object_macro (glcpp_parser_t *parser, void _define_function_macro (glcpp_parser_t *parser, + YYLTYPE *loc, const char *identifier, string_list_t *parameters, token_list_t *replacements) { macro_t *macro; - _check_for_reserved_macro_name(parser, identifier); + _check_for_reserved_macro_name(parser, loc, identifier); macro = xtalloc (parser, macro_t); -- cgit v1.2.3 From 8a132aa08b423765f273e399baea7d68b44cd37d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 12:30:57 -0700 Subject: glcpp: Add line locations to various mismatched #if error messages. --- glcpp/glcpp-parse.y | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index b1669fa331c..02608644c38 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -126,11 +126,11 @@ static void _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition); static void -_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, const char *type, - int condition); +_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, + const char *type, int condition); static void -_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser); +_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc); #define yylex glcpp_parser_lex @@ -193,7 +193,7 @@ expanded_line: _glcpp_parser_skip_stack_push_if (parser, $2); } | ELIF_EXPANDED expression NEWLINE { - _glcpp_parser_skip_stack_change_if (parser, "elif", $2); + _glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2); } ; @@ -255,10 +255,10 @@ control_line: glcpp_parser_lex_from (parser, expanded); } | HASH_ELSE NEWLINE { - _glcpp_parser_skip_stack_change_if (parser, "else", 1); + _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1); } | HASH_ENDIF NEWLINE { - _glcpp_parser_skip_stack_pop (parser); + _glcpp_parser_skip_stack_pop (parser, & @1); } | HASH NEWLINE ; @@ -1603,11 +1603,11 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition) } static void -_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, const char *type, - int condition) +_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, + const char *type, int condition) { if (parser->skip_stack == NULL) { - glcpp_printf (parser->errors, "Error: %s without #if\n", type); + glcpp_error (loc, parser, "%s without #if\n", type); exit (1); } @@ -1620,12 +1620,12 @@ _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, const char *type, } static void -_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser) +_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc) { skip_node_t *node; if (parser->skip_stack == NULL) { - glcpp_print (parser->errors, "Error: #endif without #if\n"); + glcpp_error (loc, parser, "#endif without #if\n"); exit (1); } -- cgit v1.2.3 From 0774523d1882a087b648e4017e634eb12c12f377 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 12:41:46 -0700 Subject: glcpp: Add line locations to "Unterminated #if" error message. --- glcpp/glcpp-parse.y | 15 +++++++++------ glcpp/glcpp.h | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 02608644c38..74159c19d81 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -123,7 +123,8 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, token_list_t *list); static void -_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition); +_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, + int condition); static void _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, @@ -190,7 +191,7 @@ line: expanded_line: IF_EXPANDED expression NEWLINE { - _glcpp_parser_skip_stack_push_if (parser, $2); + _glcpp_parser_skip_stack_push_if (parser, & @1, $2); } | ELIF_EXPANDED expression NEWLINE { _glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2); @@ -234,12 +235,12 @@ control_line: | HASH_IFDEF IDENTIFIER NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); talloc_free ($2); - _glcpp_parser_skip_stack_push_if (parser, macro != NULL); + _glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL); } | HASH_IFNDEF IDENTIFIER NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); talloc_free ($2); - _glcpp_parser_skip_stack_push_if (parser, macro == NULL); + _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); } | HASH_ELIF pp_tokens NEWLINE { token_list_t *expanded; @@ -923,7 +924,7 @@ void glcpp_parser_destroy (glcpp_parser_t *parser) { if (parser->skip_stack) - glcpp_print (parser->errors, "Error: Unterminated #if\n"); + glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); glcpp_lex_destroy (parser->scanner); hash_table_dtor (parser->defines); talloc_free (parser); @@ -1579,7 +1580,8 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list) } static void -_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition) +_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, + int condition) { skip_type_t current = SKIP_NO_SKIP; skip_node_t *node; @@ -1588,6 +1590,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition) current = parser->skip_stack->type; node = xtalloc (parser, skip_node_t); + node->loc = *loc; if (current == SKIP_NO_SKIP) { if (condition) diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index 45bbff3ad4a..4a2489a96d9 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -131,6 +131,7 @@ typedef enum skip_type { typedef struct skip_node { skip_type_t type; + YYLTYPE loc; /* location of the initial #if/#elif/... */ struct skip_node *next; } skip_node_t; -- cgit v1.2.3 From e8e93a45436b06713b83e3d353ab848d85de6758 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Jun 2010 12:58:54 -0700 Subject: glcpp: Remove calls to exit(). Calling exit() would be really bad once integrated into mesa. Even in the standalone binary, we want to print the error log first. Since each case already flags an error, compilation will still fail, but it may go on (with something fudged) and generate more errors. --- glcpp/glcpp-parse.y | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 74159c19d81..984a4768515 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -951,7 +951,10 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser, next = next->next; if (next == NULL || next->token->type != IDENTIFIER) { yyerror (&node->token->location, parser, "operator \"defined\" requires an identifier\n"); - exit (1); + /* Already flagged an error; fake it. */ + node->token->type = INTEGER; + node->token->value.ival = 0; + return; } macro = hash_table_find (parser->defines, next->token->value.str); @@ -1098,7 +1101,6 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, return NULL; case FUNCTION_UNBALANCED_PARENTHESES: glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier); - exit (1); return NULL; } @@ -1424,11 +1426,9 @@ _check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc, */ if (strncmp(identifier, "__", 2) == 0) { glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n"); - exit(1); } if (strncmp(identifier, "GL_", 3) == 0) { glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n"); - exit(1); } } @@ -1611,7 +1611,7 @@ _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, { if (parser->skip_stack == NULL) { glcpp_error (loc, parser, "%s without #if\n", type); - exit (1); + return; } if (parser->skip_stack->type == SKIP_TO_ELSE) { @@ -1629,7 +1629,7 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc) if (parser->skip_stack == NULL) { glcpp_error (loc, parser, "#endif without #if\n"); - exit (1); + return; } node = parser->skip_stack; -- cgit v1.2.3 From 8f322216382e2f017b4f3adefd441f84f45b0249 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 18 Jun 2010 15:23:50 -0700 Subject: glcpp: Fix line and column numbering. Lines were off by one, and column numbering was completely daft. --- glcpp/glcpp-lex.l | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index 3703ad90fe2..3eb0fbc1d3e 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -32,7 +32,7 @@ do { \ yylloc->source = 0; \ yylloc->first_column = yycolumn + 1; \ - yylloc->first_line = yylineno + 1; \ + yylloc->first_line = yylineno; \ yycolumn += yyleng; \ } while(0); %} @@ -82,6 +82,8 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? * Simply pass them through to the main compiler's lexer/parser. */ {HASH}(extension|version|pragma).*\n { yylval->str = xtalloc_strdup (yyextra, yytext); + yylineno++; + yycolumn = 0; return OTHER; } @@ -126,6 +128,9 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? * We use the lexing_if flag to avoid skipping any part of an * if conditional expression. */ [^\n]+/\n { + /* Since this rule always matches, YY_USER_ACTION gets called for it, + * wrongly incrementing yycolumn. We undo that effect here. */ + yycolumn -= yyleng; if (yyextra->lexing_if || yyextra->skip_stack == NULL || yyextra->skip_stack->type == SKIP_NO_SKIP) -- cgit v1.2.3 From 214632f527c2698602580038763ec72154ca2109 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 18 Jun 2010 15:34:50 -0700 Subject: glcpp/tests: Add a test for #version followed by #define. This isn't really a C file, but...that's probably okay. --- glcpp/tests/064-version.c | 2 ++ glcpp/tests/064-version.c.expected | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 glcpp/tests/064-version.c create mode 100644 glcpp/tests/064-version.c.expected diff --git a/glcpp/tests/064-version.c b/glcpp/tests/064-version.c new file mode 100644 index 00000000000..21326481b87 --- /dev/null +++ b/glcpp/tests/064-version.c @@ -0,0 +1,2 @@ +#version 130 +#define FOO diff --git a/glcpp/tests/064-version.c.expected b/glcpp/tests/064-version.c.expected new file mode 100644 index 00000000000..3af71113c8c --- /dev/null +++ b/glcpp/tests/064-version.c.expected @@ -0,0 +1,3 @@ +#version 130 + + -- cgit v1.2.3 From 03ee33809f2e5c6ecff827188ec33be5a9397c16 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 18 Jun 2010 15:41:00 -0700 Subject: glcpp: Don't include newlines as part of #version-passthrough. Fixes glcpp/tests/064-version.c. --- glcpp/glcpp-lex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index 3eb0fbc1d3e..0dea9950015 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -80,7 +80,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? /* glcpp doesn't handle #extension, #version, or #pragma directives. * Simply pass them through to the main compiler's lexer/parser. */ -{HASH}(extension|version|pragma).*\n { +{HASH}(extension|version|pragma)[^\n]+ { yylval->str = xtalloc_strdup (yyextra, yytext); yylineno++; yycolumn = 0; -- cgit v1.2.3 From 33eaa3e0b3a8f94c2abb23ac3c9cbe571f170fb6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 18 Jun 2010 19:52:36 -0700 Subject: glcpp: Rename "errors" to "info_log." Eventually, we'll want to be be able to print out warnings as well. --- glcpp/glcpp-parse.y | 12 ++++++------ glcpp/glcpp.c | 2 +- glcpp/glcpp.h | 2 +- glcpp/pp.c | 24 +++++++++++++----------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 984a4768515..c70370a6c32 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -859,11 +859,11 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) } glcpp_error (&token->location, parser, ""); - glcpp_print (parser->errors, "Pasting \""); - _token_print (&parser->errors, token); - glcpp_print (parser->errors, "\" and \""); - _token_print (&parser->errors, other); - glcpp_print (parser->errors, "\" does not give a valid preprocessing token.\n"); + glcpp_print (parser->info_log, "Pasting \""); + _token_print (&parser->info_log, token); + glcpp_print (parser->info_log, "\" and \""); + _token_print (&parser->info_log, other); + glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n"); return token; } @@ -909,7 +909,7 @@ glcpp_parser_create (void) parser->lex_from_node = NULL; parser->output = talloc_strdup(parser, ""); - parser->errors = talloc_strdup(parser, ""); + parser->info_log = talloc_strdup(parser, ""); return parser; } diff --git a/glcpp/glcpp.c b/glcpp/glcpp.c index d204eee49ac..8ba4661f784 100644 --- a/glcpp/glcpp.c +++ b/glcpp/glcpp.c @@ -36,7 +36,7 @@ main (void) ret = glcpp_parser_parse (parser); printf("%s", parser->output); - fprintf(stderr, "%s", parser->errors); + fprintf(stderr, "%s", parser->info_log); glcpp_parser_destroy (parser); diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index 4a2489a96d9..e67469be2eb 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -154,7 +154,7 @@ struct glcpp_parser { token_list_t *lex_from_list; token_node_t *lex_from_node; char *output; - char *errors; + char *info_log; }; glcpp_parser_t * diff --git a/glcpp/pp.c b/glcpp/pp.c index 5d1ff8c6823..f8a7c2ea4d5 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -26,15 +26,17 @@ void glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) { - parser->errors = talloc_asprintf_append(parser->errors, "%u:%u(%u): " - "preprocessor error: ", - locp->source, locp->first_line, - locp->first_column); - va_list ap; - va_start(ap, fmt); - parser->errors = talloc_vasprintf_append(parser->errors, fmt, ap); - va_end(ap); - parser->errors = talloc_strdup_append(parser->errors, "\n"); + parser->info_log = talloc_asprintf_append(parser->info_log, + "%u:%u(%u): " + "preprocessor error: ", + locp->source, + locp->first_line, + locp->first_column); + va_list ap; + va_start(ap, fmt); + parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap); + va_end(ap); + parser->info_log = talloc_strdup_append(parser->info_log, "\n"); } extern int @@ -46,8 +48,8 @@ preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) glcpp_parser_parse (parser); - errors = parser->errors[0] != '\0'; - printf("%s", parser->errors); + errors = parser->info_log[0] != '\0'; + printf("%s", parser->info_log); talloc_steal(talloc_ctx, parser->output); *shader = parser->output; -- cgit v1.2.3 From 62b4b7785a01f11e7fcd9bf76dae6b3c0a16d537 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 21 Jun 2010 12:39:49 -0700 Subject: glcpp: Add boolean 'error' flag. We used to check if the info log is non-empty, but when we print warnings, this will no longer be valid. --- glcpp/glcpp.h | 1 + glcpp/pp.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index e67469be2eb..8167a481d5e 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -155,6 +155,7 @@ struct glcpp_parser { token_node_t *lex_from_node; char *output; char *info_log; + int error; }; glcpp_parser_t * diff --git a/glcpp/pp.c b/glcpp/pp.c index f8a7c2ea4d5..846d35506fb 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -26,6 +26,7 @@ void glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) { + parser->error = 1; parser->info_log = talloc_asprintf_append(parser->info_log, "%u:%u(%u): " "preprocessor error: ", @@ -48,13 +49,13 @@ preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) glcpp_parser_parse (parser); - errors = parser->info_log[0] != '\0'; printf("%s", parser->info_log); talloc_steal(talloc_ctx, parser->output); *shader = parser->output; *shader_len = strlen(parser->output); + errors = parser->error; glcpp_parser_destroy (parser); return errors; } -- cgit v1.2.3 From c9529c4d7727e0ff9da71f0941746e4d213dd689 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 18 Jun 2010 19:54:25 -0700 Subject: glcpp: Add glcpp_warning for printing warnings to the info log. --- glcpp/glcpp.h | 5 +++++ glcpp/pp.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index 8167a481d5e..bb0ac95aedf 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -167,9 +167,14 @@ glcpp_parser_parse (glcpp_parser_t *parser); void glcpp_parser_destroy (glcpp_parser_t *parser); +/* Functions for writing to the info log */ + void glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...); +void +glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...); + /* Generated by glcpp-lex.l to glcpp-lex.c */ int diff --git a/glcpp/pp.c b/glcpp/pp.c index 846d35506fb..eaca4819ce5 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -40,6 +40,22 @@ glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) parser->info_log = talloc_strdup_append(parser->info_log, "\n"); } +void +glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) +{ + parser->info_log = talloc_asprintf_append(parser->info_log, + "%u:%u(%u): " + "preprocessor warning: ", + locp->source, + locp->first_line, + locp->first_column); + va_list ap; + va_start(ap, fmt); + parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap); + va_end(ap); + parser->info_log = talloc_strdup_append(parser->info_log, "\n"); +} + extern int preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) { -- cgit v1.2.3 From 65875743542fd1388b18a1a3c1c2bec4a6a3007e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 18 Jun 2010 20:08:15 -0700 Subject: glcpp: Ignore junk tokens at end of #ifdef/#ifndef (with warning) Both nVidia's compiler and GCC accept this. Fixes CorrectPreprocess11.frag. --- glcpp/glcpp-parse.y | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index c70370a6c32..035a5c83f0e 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -232,12 +232,12 @@ control_line: _token_list_append_list (expanded, $2); glcpp_parser_lex_from (parser, expanded); } -| HASH_IFDEF IDENTIFIER NEWLINE { +| HASH_IFDEF IDENTIFIER junk NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); talloc_free ($2); _glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL); } -| HASH_IFNDEF IDENTIFIER NEWLINE { +| HASH_IFNDEF IDENTIFIER junk NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); talloc_free ($2); _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); @@ -377,6 +377,12 @@ replacement_list: | pp_tokens ; +junk: + /* empty */ +| pp_tokens { + glcpp_warning(&@1, parser, "extra tokens at end of directive"); + } + pp_tokens: preprocessing_token { parser->space_tokens = 1; -- cgit v1.2.3 From bac0e371e373bc51b1b3c575d0a46e324c36bc4f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 18 Jun 2010 23:04:44 -0700 Subject: glcpp/tests: Add a test for #if defined (identifier) Previously we only tested #if defined identifier (without parenthesis). --- glcpp/tests/065-if-defined-parens.c | 17 +++++++++++++++++ glcpp/tests/065-if-defined-parens.c.expected | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 glcpp/tests/065-if-defined-parens.c create mode 100644 glcpp/tests/065-if-defined-parens.c.expected diff --git a/glcpp/tests/065-if-defined-parens.c b/glcpp/tests/065-if-defined-parens.c new file mode 100644 index 00000000000..48aa0f8c3ef --- /dev/null +++ b/glcpp/tests/065-if-defined-parens.c @@ -0,0 +1,17 @@ +#if defined(foo) +failure_1 +#else +success_1 +#endif +#define foo +#if defined ( foo ) +success_2 +#else +failure_2 +#endif +#undef foo +#if defined (foo) +failure_3 +#else +success_3 +#endif diff --git a/glcpp/tests/065-if-defined-parens.c.expected b/glcpp/tests/065-if-defined-parens.c.expected new file mode 100644 index 00000000000..3f01955ee40 --- /dev/null +++ b/glcpp/tests/065-if-defined-parens.c.expected @@ -0,0 +1,18 @@ + + + +success_1 + + + +success_2 + + + + + + + +success_3 + + -- cgit v1.2.3 From 26e761edb26322eab497e884fcf7ae35fb3fd3e5 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 18 Jun 2010 23:06:54 -0700 Subject: glcpp: Rework handling of "defined" operator. It's now done in the grammar, and as a result, can easily handle parenthesis. defined ( identifier ) is now supported. Fixes glcpp/tests/065-if-defined-parens.c. --- glcpp/glcpp-parse.y | 78 +++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 035a5c83f0e..37c2f97c23d 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -110,10 +110,6 @@ _active_list_pop (active_list_t *list); int _active_list_contains (active_list_t *list, const char *identifier); -static void -_glcpp_parser_evaluate_defined (glcpp_parser_t *parser, - token_list_t *list); - static void _glcpp_parser_expand_token_list (glcpp_parser_t *parser, token_list_t *list); @@ -155,8 +151,8 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); %type expression INTEGER operator SPACE %type IDENTIFIER INTEGER_STRING OTHER %type identifier_list -%type preprocessing_token -%type pp_tokens replacement_list text_line +%type preprocessing_token conditional_token +%type pp_tokens replacement_list text_line conditional_tokens %left OR %left AND %left '|' @@ -219,7 +215,7 @@ control_line: } talloc_free ($2); } -| HASH_IF pp_tokens NEWLINE { +| HASH_IF conditional_tokens NEWLINE { token_list_t *expanded; token_t *token; @@ -227,7 +223,6 @@ control_line: token = _token_create_ival (parser, IF_EXPANDED, IF_EXPANDED); _token_list_append (expanded, token); talloc_unlink (parser, token); - _glcpp_parser_evaluate_defined (parser, $2); _glcpp_parser_expand_token_list (parser, $2); _token_list_append_list (expanded, $2); glcpp_parser_lex_from (parser, expanded); @@ -242,7 +237,7 @@ control_line: talloc_free ($2); _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); } -| HASH_ELIF pp_tokens NEWLINE { +| HASH_ELIF conditional_tokens NEWLINE { token_list_t *expanded; token_t *token; @@ -250,7 +245,6 @@ control_line: token = _token_create_ival (parser, ELIF_EXPANDED, ELIF_EXPANDED); _token_list_append (expanded, token); talloc_unlink (parser, token); - _glcpp_parser_evaluate_defined (parser, $2); _glcpp_parser_expand_token_list (parser, $2); _token_list_append_list (expanded, $2); glcpp_parser_lex_from (parser, expanded); @@ -382,6 +376,35 @@ junk: | pp_tokens { glcpp_warning(&@1, parser, "extra tokens at end of directive"); } +; + +conditional_token: + /* Handle "defined" operator */ + DEFINED IDENTIFIER { + int v = hash_table_find (parser->defines, $2) ? 1 : 0; + $$ = _token_create_ival (parser, INTEGER, v); + } +| DEFINED '(' IDENTIFIER ')' { + int v = hash_table_find (parser->defines, $3) ? 1 : 0; + $$ = _token_create_ival (parser, INTEGER, v); + } +| preprocessing_token +; + +conditional_tokens: + /* Exactly the same as pp_tokens, but using conditional_token */ + conditional_token { + parser->space_tokens = 1; + $$ = _token_list_create (parser); + _token_list_append ($$, $1); + talloc_unlink (parser, $1); + } +| conditional_tokens conditional_token { + $$ = $1; + _token_list_append ($$, $2); + talloc_unlink (parser, $2); + } +; pp_tokens: preprocessing_token { @@ -936,41 +959,6 @@ glcpp_parser_destroy (glcpp_parser_t *parser) talloc_free (parser); } -/* Replace any occurences of DEFINED tokens in 'list' with either a - * '0' or '1' INTEGER token depending on whether the next token in the - * list is defined or not. */ -static void -_glcpp_parser_evaluate_defined (glcpp_parser_t *parser, - token_list_t *list) -{ - token_node_t *node, *next; - macro_t *macro; - - if (list == NULL) - return; - - for (node = list->head; node; node = node->next) { - if (node->token->type != DEFINED) - continue; - next = node->next; - while (next && next->token->type == SPACE) - next = next->next; - if (next == NULL || next->token->type != IDENTIFIER) { - yyerror (&node->token->location, parser, "operator \"defined\" requires an identifier\n"); - /* Already flagged an error; fake it. */ - node->token->type = INTEGER; - node->token->value.ival = 0; - return; - } - macro = hash_table_find (parser->defines, - next->token->value.str); - - node->token->type = INTEGER; - node->token->value.ival = (macro != NULL); - node->next = next->next; - } -} - typedef enum function_status { FUNCTION_STATUS_SUCCESS, -- cgit v1.2.3 From 4a2bbdacfc29460de09e5f806fcc96040ad17dc4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 21 Jun 2010 11:43:42 -0700 Subject: Use yy_scan_string and stop caring about shader->SourceLen. We had to call strlen on the preprocessed source, which seemed a bit pointless; also, we updated shader->SourceLen but not shader->Source, which was even more confusing. Just leave both untouched. --- glcpp/pp.c | 3 +-- glsl_lexer.lpp | 5 ++--- glsl_parser_extras.h | 4 ++-- main.cpp | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/glcpp/pp.c b/glcpp/pp.c index eaca4819ce5..e6921db46b5 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -57,7 +57,7 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) } extern int -preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) +preprocess(void *talloc_ctx, const char **shader) { int errors; glcpp_parser_t *parser = glcpp_parser_create (); @@ -69,7 +69,6 @@ preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) talloc_steal(talloc_ctx, parser->output); *shader = parser->output; - *shader_len = strlen(parser->output); errors = parser->error; glcpp_parser_destroy (parser); diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index cd150f81ca1..9a3037a8ff5 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -330,11 +330,10 @@ precision return PRECISION; %% void -_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, - const char *string, size_t len) +_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) { yylex_init_extra(state, & state->scanner); - yy_scan_bytes(string, len, state->scanner); + yy_scan_string(string, state->scanner); } void diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index cad3424f6bd..1edd86bc6ea 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -102,11 +102,11 @@ extern void _mesa_glsl_warning(const YYLTYPE *locp, const char *fmt, ...); extern "C" { -extern int preprocess(void *ctx, const char **shader, size_t *shader_len); +extern int preprocess(void *ctx, const char **shader); } extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, - const char *string, size_t len); + const char *string); extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state); diff --git a/main.cpp b/main.cpp index 58657fe2012..25904380c95 100644 --- a/main.cpp +++ b/main.cpp @@ -128,10 +128,10 @@ compile_shader(struct glsl_shader *shader) * should probably be the parser context, but there isn't one yet. */ const char *source = shader->Source; - state.error = preprocess(shader, &source, &shader->SourceLen); + state.error = preprocess(shader, &source); if (!state.error) { - _mesa_glsl_lexer_ctor(& state, source, shader->SourceLen); + _mesa_glsl_lexer_ctor(& state, source); _mesa_glsl_parse(& state); _mesa_glsl_lexer_dtor(& state); } -- cgit v1.2.3 From 74704e80c69f400f7712aed4287a84adc13bfbed Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 21 Jun 2010 11:47:55 -0700 Subject: glcpp: Print to the main compiler's infolog, not stdout. --- glcpp/pp.c | 4 ++-- glsl_parser_extras.h | 2 +- main.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/glcpp/pp.c b/glcpp/pp.c index e6921db46b5..5455518c7c7 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -57,7 +57,7 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) } extern int -preprocess(void *talloc_ctx, const char **shader) +preprocess(void *talloc_ctx, const char **shader, char **info_log) { int errors; glcpp_parser_t *parser = glcpp_parser_create (); @@ -65,7 +65,7 @@ preprocess(void *talloc_ctx, const char **shader) glcpp_parser_parse (parser); - printf("%s", parser->info_log); + *info_log = talloc_strdup_append(*info_log, parser->info_log); talloc_steal(talloc_ctx, parser->output); *shader = parser->output; diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 1edd86bc6ea..87de9083c06 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -102,7 +102,7 @@ extern void _mesa_glsl_warning(const YYLTYPE *locp, const char *fmt, ...); extern "C" { -extern int preprocess(void *ctx, const char **shader); +extern int preprocess(void *ctx, const char **shader, char **info_log); } extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, diff --git a/main.cpp b/main.cpp index 25904380c95..7f094f8e3e4 100644 --- a/main.cpp +++ b/main.cpp @@ -128,7 +128,7 @@ compile_shader(struct glsl_shader *shader) * should probably be the parser context, but there isn't one yet. */ const char *source = shader->Source; - state.error = preprocess(shader, &source); + state.error = preprocess(shader, &source, &state.info_log); if (!state.error) { _mesa_glsl_lexer_ctor(& state, source); -- cgit v1.2.3 From 332fc47dc0998ac8e0a47e1ecded8829e712bde6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 21 Jun 2010 12:20:22 -0700 Subject: glcpp: Accept #elif without an expression if the expression doesn't matter. Issue a warning. nVidia's compiler seems to accept this; apparently GCC < 4.4 did as well: http://gcc.gnu.org/gcc-4.4/porting_to.html --- glcpp/glcpp-parse.y | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 37c2f97c23d..c314e9556ce 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -249,6 +249,17 @@ control_line: _token_list_append_list (expanded, $2); glcpp_parser_lex_from (parser, expanded); } +| HASH_ELIF NEWLINE { + /* #elif without an expression results in a warning if the + * condition doesn't matter (we just handled #if 1 or such) + * but an error otherwise. */ + if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) { + parser->skip_stack->type = SKIP_TO_ENDIF; + glcpp_warning(& @1, parser, "ignoring illegal #elif without expression"); + } else { + glcpp_error(& @1, parser, "#elif needs an expression"); + } + } | HASH_ELSE NEWLINE { _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1); } -- cgit v1.2.3 From 1b85c46bcf30a666493c9b4cda03617e8a81b13a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 21 Jun 2010 13:55:12 -0700 Subject: glcpp: Initialize error state. --- glcpp/glcpp-parse.y | 1 + 1 file changed, 1 insertion(+) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index c314e9556ce..2ce8632a28d 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -950,6 +950,7 @@ glcpp_parser_create (void) parser->output = talloc_strdup(parser, ""); parser->info_log = talloc_strdup(parser, ""); + parser->error = 0; return parser; } -- cgit v1.2.3 From b302359394312112a61aec58c99be9ffc3406c92 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 22 Jun 2010 12:24:42 -0700 Subject: Add missing build products to gitignore --- .gitignore | 2 ++ glcpp/.gitignore | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 9edd6daf71c..b3ce5e7086e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ ylwrap install-sh missing stamp-h1 +libtool +ltmain.sh Makefile *.o *~ diff --git a/glcpp/.gitignore b/glcpp/.gitignore index 077db8d8e14..c158dc8b862 100644 --- a/glcpp/.gitignore +++ b/glcpp/.gitignore @@ -2,6 +2,10 @@ glcpp glcpp-lex.c glcpp-parse.c glcpp-parse.h +glcpp-parse.output *.o +*.lo +*.la +.libs *~ tests/*.out -- cgit v1.2.3 From ac95f2f8c88d39aaa878f61172d9748af13e2c80 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 22 Jun 2010 10:38:52 -0700 Subject: Include stdio.h and stdlib.h everywhere, and don't cook our own #define NULL. --- ast_function.cpp | 1 - ast_to_hir.cpp | 2 +- hir_field_selection.cpp | 4 ++-- ir.h | 3 +++ ir_basic_block.cpp | 1 - ir_constant_expression.cpp | 1 - ir_constant_folding.cpp | 1 - ir_constant_variable.cpp | 2 -- ir_copy_propagation.cpp | 1 - ir_dead_code.cpp | 1 - ir_dead_code_local.cpp | 1 - ir_expression_flattening.cpp | 1 - ir_function_can_inline.cpp | 1 - ir_function_inlining.cpp | 1 - ir_hierarchical_visitor.cpp | 2 +- ir_hv_accept.cpp | 2 +- ir_if_simplification.cpp | 1 - ir_print_visitor.cpp | 2 +- ir_reader.cpp | 2 +- ir_swizzle_swizzle.cpp | 1 - ir_variable.cpp | 3 +-- ir_vec_index_to_swizzle.cpp | 1 - 22 files changed, 11 insertions(+), 24 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 279c45eac0e..26050977d52 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -21,7 +21,6 @@ * DEALINGS IN THE SOFTWARE. */ -#include #include "glsl_symbol_table.h" #include "ast.h" #include "glsl_types.h" diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index dbc36660697..aa90d4b6631 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -48,7 +48,7 @@ * As a result, my preference is to put as little C code as possible in the * parser (and lexer) sources. */ -#include + #include "main/imports.h" #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index f0be84dab4c..e60ea30d7ff 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -20,13 +20,13 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -#include + +#include "ir.h" #include "main/imports.h" #include "symbol_table.h" #include "glsl_parser_extras.h" #include "ast.h" #include "glsl_types.h" -#include "ir.h" struct ir_rvalue * _mesa_ast_field_selection_to_hir(const ast_expression *expr, diff --git a/ir.h b/ir.h index 33b6069ea5c..d99453c6025 100644 --- a/ir.h +++ b/ir.h @@ -26,6 +26,9 @@ #ifndef IR_H #define IR_H +#include +#include + #include "list.h" #include "ir_visitor.h" #include "ir_hierarchical_visitor.h" diff --git a/ir_basic_block.cpp b/ir_basic_block.cpp index 2cf37046059..f9953ea42da 100644 --- a/ir_basic_block.cpp +++ b/ir_basic_block.cpp @@ -27,7 +27,6 @@ * Basic block analysis of instruction streams. */ -#include #include "ir.h" #include "ir_visitor.h" #include "ir_basic_block.h" diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 5bb592079a9..e9f04998209 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -33,7 +33,6 @@ * * Initializers for \c const variables */ -#define NULL 0 #include #include "ir.h" #include "ir_visitor.h" diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index 5dc4a7dc654..342d027bbe8 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -26,7 +26,6 @@ * Replace constant-valued expressions with references to constant values. */ -#define NULL 0 #include "ir.h" #include "ir_visitor.h" #include "ir_optimization.h" diff --git a/ir_constant_variable.cpp b/ir_constant_variable.cpp index 7210c17dc77..a905474d858 100644 --- a/ir_constant_variable.cpp +++ b/ir_constant_variable.cpp @@ -32,8 +32,6 @@ * and calls to builtin functions. */ -#include -#include #include "ir.h" #include "ir_print_visitor.h" #include "ir_visitor.h" diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index 1c5c10d6fce..da5998109ff 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -32,7 +32,6 @@ * help anyway by triggering other optimizations that live in the HIR. */ -#include #include "ir.h" #include "ir_visitor.h" #include "ir_print_visitor.h" diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp index 2ede7ff0cf4..8465d863aa3 100644 --- a/ir_dead_code.cpp +++ b/ir_dead_code.cpp @@ -27,7 +27,6 @@ * Eliminates dead assignments and variable declarations from the code. */ -#define NULL 0 #include "ir.h" #include "ir_visitor.h" #include "ir_expression_flattening.h" diff --git a/ir_dead_code_local.cpp b/ir_dead_code_local.cpp index e83b300390b..344a6ebfbf5 100644 --- a/ir_dead_code_local.cpp +++ b/ir_dead_code_local.cpp @@ -33,7 +33,6 @@ * for assignments to variables that are never read. */ -#include #include "ir.h" #include "ir_print_visitor.h" #include "ir_basic_block.h" diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp index 394a0d0432b..3089f17ae14 100644 --- a/ir_expression_flattening.cpp +++ b/ir_expression_flattening.cpp @@ -33,7 +33,6 @@ * instruction stream. */ -#define NULL 0 #include "ir.h" #include "ir_visitor.h" #include "ir_expression_flattening.h" diff --git a/ir_function_can_inline.cpp b/ir_function_can_inline.cpp index 3be351055dd..5761a742049 100644 --- a/ir_function_can_inline.cpp +++ b/ir_function_can_inline.cpp @@ -33,7 +33,6 @@ * (0) loop surrounding the function body. */ -#define NULL 0 #include "ir.h" class ir_function_can_inline_visitor : public ir_hierarchical_visitor { diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index a501c813fb8..4e5604f89fe 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -27,7 +27,6 @@ * Replaces calls to functions with the body of the function. */ -#define NULL 0 #include "ir.h" #include "ir_visitor.h" #include "ir_function_inlining.h" diff --git a/ir_hierarchical_visitor.cpp b/ir_hierarchical_visitor.cpp index fd77391973f..11d30b4b6e7 100644 --- a/ir_hierarchical_visitor.cpp +++ b/ir_hierarchical_visitor.cpp @@ -20,7 +20,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -#define NULL 0 + #include "ir.h" #include "ir_hierarchical_visitor.h" diff --git a/ir_hv_accept.cpp b/ir_hv_accept.cpp index 7c1798a051a..54326332724 100644 --- a/ir_hv_accept.cpp +++ b/ir_hv_accept.cpp @@ -20,7 +20,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -#define NULL 0 + #include "ir.h" /** diff --git a/ir_if_simplification.cpp b/ir_if_simplification.cpp index 042d0b677fc..6882ef72b95 100644 --- a/ir_if_simplification.cpp +++ b/ir_if_simplification.cpp @@ -28,7 +28,6 @@ * instruction stream. */ -#define NULL 0 #include "ir.h" class ir_if_simplification_visitor : public ir_hierarchical_visitor { diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 18ff48c3b34..40fac8803c1 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -20,7 +20,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -#include + #include "ir_print_visitor.h" #include "glsl_types.h" #include "glsl_parser_extras.h" diff --git a/ir_reader.cpp b/ir_reader.cpp index 5cbce333f41..a8ccb30999f 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -20,7 +20,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -#include + #include extern "C" { diff --git a/ir_swizzle_swizzle.cpp b/ir_swizzle_swizzle.cpp index 8873bef8d61..0ffb4fa3133 100644 --- a/ir_swizzle_swizzle.cpp +++ b/ir_swizzle_swizzle.cpp @@ -27,7 +27,6 @@ * Eliminates the second swizzle in a swizzle chain. */ -#include #include "ir.h" #include "ir_visitor.h" #include "ir_optimization.h" diff --git a/ir_variable.cpp b/ir_variable.cpp index 0c0d1278a41..49d8e3dcfb5 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -21,10 +21,9 @@ * DEALINGS IN THE SOFTWARE. */ -#include +#include "ir.h" #include "glsl_parser_extras.h" #include "glsl_symbol_table.h" -#include "ir.h" #include "builtin_variables.h" #ifndef Elements diff --git a/ir_vec_index_to_swizzle.cpp b/ir_vec_index_to_swizzle.cpp index f0900cf70d6..cb2f6ca4097 100644 --- a/ir_vec_index_to_swizzle.cpp +++ b/ir_vec_index_to_swizzle.cpp @@ -29,7 +29,6 @@ * and codegen backends not have to worry about this case. */ -#include #include "ir.h" #include "ir_visitor.h" #include "ir_optimization.h" -- cgit v1.2.3 From 216580dbd733aa2e64df4ca95e37a0eb102c6ede Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 22 Jun 2010 10:45:15 -0700 Subject: Hook up texturing in the hierarchical visitor. --- ir_hv_accept.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/ir_hv_accept.cpp b/ir_hv_accept.cpp index 54326332724..f936b3500eb 100644 --- a/ir_hv_accept.cpp +++ b/ir_hv_accept.cpp @@ -159,6 +159,55 @@ done: ir_visitor_status ir_texture::accept(ir_hierarchical_visitor *v) { + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->sampler->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->coordinate->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (this->projector) { + s = this->projector->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + if (this->shadow_comparitor) { + s = this->shadow_comparitor->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + switch (this->op) { + case ir_tex: + break; + case ir_txb: + s = this->lod_info.bias->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + break; + case ir_txl: + case ir_txf: + s = this->lod_info.lod->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + break; + case ir_txd: + s = this->lod_info.grad.dPdx->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->lod_info.grad.dPdy->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + break; + } + return visit_continue_with_parent; } -- cgit v1.2.3 From e46a454305af64710ce8deadafc718f75363ac7e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 22 Jun 2010 12:09:21 -0700 Subject: ir: Give ir_instruction a print visitor helper. This avoids spamming each file with includes of ir_print_visitor.h because someone was doing debugging at some point, and is less typing when doing debugging. --- ir.h | 4 ++++ ir_constant_variable.cpp | 1 - ir_copy_propagation.cpp | 1 - ir_dead_code_local.cpp | 4 +--- ir_print_visitor.cpp | 11 ++++++++--- ir_vec_index_to_swizzle.cpp | 1 - 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ir.h b/ir.h index d99453c6025..7454947c97c 100644 --- a/ir.h +++ b/ir.h @@ -45,6 +45,10 @@ public: const struct glsl_type *type; class ir_constant *constant_expression_value(); + + /** ir_print_visitor helper for debugging. */ + void print(void); + virtual void accept(ir_visitor *) = 0; virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0; diff --git a/ir_constant_variable.cpp b/ir_constant_variable.cpp index a905474d858..ef5e1e418e5 100644 --- a/ir_constant_variable.cpp +++ b/ir_constant_variable.cpp @@ -33,7 +33,6 @@ */ #include "ir.h" -#include "ir_print_visitor.h" #include "ir_visitor.h" #include "ir_optimization.h" #include "glsl_types.h" diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index da5998109ff..16a2ba79bf6 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -34,7 +34,6 @@ #include "ir.h" #include "ir_visitor.h" -#include "ir_print_visitor.h" #include "ir_basic_block.h" #include "ir_optimization.h" #include "glsl_types.h" diff --git a/ir_dead_code_local.cpp b/ir_dead_code_local.cpp index 344a6ebfbf5..d3b3858617d 100644 --- a/ir_dead_code_local.cpp +++ b/ir_dead_code_local.cpp @@ -34,7 +34,6 @@ */ #include "ir.h" -#include "ir_print_visitor.h" #include "ir_basic_block.h" #include "ir_optimization.h" #include "glsl_types.h" @@ -192,8 +191,7 @@ dead_code_local_basic_block(ir_instruction *first, ir_assignment *ir_assign = ir->as_assignment(); if (debug) { - ir_print_visitor v; - ir->accept(&v); + ir->print(); printf("\n"); } diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 40fac8803c1..60fb33e2f55 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -27,6 +27,13 @@ static void print_type(const glsl_type *t); +void +ir_instruction::print(void) +{ + ir_print_visitor v; + accept(&v); +} + void _mesa_print_ir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -48,9 +55,7 @@ _mesa_print_ir(exec_list *instructions, printf("(\n"); foreach_iter(exec_list_iterator, iter, *instructions) { - ir_print_visitor v; - - ((ir_instruction *)iter.get())->accept(& v); + ((ir_instruction *)iter.get())->print(); printf("\n"); } printf("\n)"); diff --git a/ir_vec_index_to_swizzle.cpp b/ir_vec_index_to_swizzle.cpp index cb2f6ca4097..eb0e556c9db 100644 --- a/ir_vec_index_to_swizzle.cpp +++ b/ir_vec_index_to_swizzle.cpp @@ -32,7 +32,6 @@ #include "ir.h" #include "ir_visitor.h" #include "ir_optimization.h" -#include "ir_print_visitor.h" #include "glsl_types.h" /** -- cgit v1.2.3 From 53cdb7e51d85d4b4a35fba3ec200b27991b8488b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 22 Jun 2010 12:07:21 -0700 Subject: ir_validate: New pass for checking our invariants. --- Makefile.am | 1 + ir.h | 2 + ir_validate.cpp | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.cpp | 4 ++ 4 files changed, 199 insertions(+) create mode 100644 ir_validate.cpp diff --git a/Makefile.am b/Makefile.am index f24f06d0aa7..b65b8bab526 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,6 +56,7 @@ glsl_SOURCES = \ ir_hierarchical_visitor.h \ ir_hierarchical_visitor.cpp \ ir_swizzle_swizzle.cpp \ + ir_validate.cpp \ ir_vec_index_to_swizzle.cpp \ linker.cpp diff --git a/ir.h b/ir.h index 7454947c97c..d02f3caab97 100644 --- a/ir.h +++ b/ir.h @@ -1112,6 +1112,8 @@ private: void visit_exec_list(exec_list *list, ir_visitor *visitor); +void validate_ir_tree(exec_list *instructions); + extern void _mesa_glsl_initialize_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state); diff --git a/ir_validate.cpp b/ir_validate.cpp new file mode 100644 index 00000000000..c6c18df51a7 --- /dev/null +++ b/ir_validate.cpp @@ -0,0 +1,192 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_validate.cpp + * + * Attempts to verify that various invariants of the IR tree are true. + * + * In particular, at the moment it makes sure that no single + * ir_instruction node except for ir_variable appears multiple times + * in the ir tree. ir_variable does appear multiple times: Once as a + * declaration in an exec_list, and multiple times as the endpoint of + * a dereference chain. + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" +#include "hash_table.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + + +class ir_validate : public ir_hierarchical_visitor { +public: + virtual ir_visitor_status visit_enter(class ir_constant *); + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_enter(class ir_expression *); + virtual ir_visitor_status visit_enter(class ir_texture *); + virtual ir_visitor_status visit_enter(class ir_swizzle *); + virtual ir_visitor_status visit_enter(class ir_dereference_array *); + virtual ir_visitor_status visit_enter(class ir_dereference_record *); + virtual ir_visitor_status visit_enter(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_return *); + virtual ir_visitor_status visit_enter(class ir_if *); + + void validate_ir(ir_instruction *ir); + + struct hash_table *ht; +}; + +unsigned int hash_func(const void *key) +{ + return (unsigned int)(uintptr_t)key; +} + +int hash_compare_func(const void *key1, const void *key2) +{ + return key1 == key2 ? 0 : 1; +} + +void +ir_validate::validate_ir(ir_instruction *ir) +{ + if (hash_table_find(this->ht, ir)) { + printf("Instruction node present twice in ir tree:\n"); + ir->print(); + printf("\n"); + abort(); + } + hash_table_insert(this->ht, ir, ir); +} + +ir_visitor_status +ir_validate::visit_enter(ir_constant *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_loop *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_function_signature *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_function *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_expression *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_texture *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_swizzle *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_dereference_array *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_dereference_record *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_assignment *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_call *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_return *ir) +{ + validate_ir(ir); + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_if *ir) +{ + validate_ir(ir); + return visit_continue; +} + +void +validate_ir_tree(exec_list *instructions) +{ + ir_validate v; + + v.ht = hash_table_ctor(0, hash_func, hash_compare_func); + + v.run(instructions); + + hash_table_dtor(v.ht); +} diff --git a/main.cpp b/main.cpp index 7f094f8e3e4..17f25d741e4 100644 --- a/main.cpp +++ b/main.cpp @@ -148,6 +148,8 @@ compile_shader(struct glsl_shader *shader) if (!state.error && !state.translation_unit.is_empty()) _mesa_ast_to_hir(&shader->ir, &state); + validate_ir_tree(&shader->ir); + /* Optimization passes */ if (!state.error && !shader->ir.is_empty()) { bool progress; @@ -166,6 +168,8 @@ compile_shader(struct glsl_shader *shader) } while (progress); } + validate_ir_tree(&shader->ir); + /* Print out the resulting IR */ if (!state.error && dump_lir) { _mesa_print_ir(&shader->ir, &state); -- cgit v1.2.3 From 7c09576a97be3490fe36fff9241b9c148ba558cb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 22 Jun 2010 18:37:12 -0700 Subject: ir_hierarchical_visitor: Add generic callback functionality --- ir_hierarchical_visitor.cpp | 70 ++++++++++++++++++++++++++++++++++----------- ir_hierarchical_visitor.h | 18 ++++++++++++ 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/ir_hierarchical_visitor.cpp b/ir_hierarchical_visitor.cpp index 11d30b4b6e7..63ce8784adb 100644 --- a/ir_hierarchical_visitor.cpp +++ b/ir_hierarchical_visitor.cpp @@ -24,38 +24,54 @@ #include "ir.h" #include "ir_hierarchical_visitor.h" +ir_hierarchical_visitor::ir_hierarchical_visitor() +{ + this->callback = NULL; + this->data = NULL; +} + ir_visitor_status ir_hierarchical_visitor::visit(ir_variable *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit(ir_constant *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit(ir_loop_jump *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit(ir_dereference_variable *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_loop *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -69,7 +85,9 @@ ir_hierarchical_visitor::visit_leave(ir_loop *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_function_signature *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -83,7 +101,9 @@ ir_hierarchical_visitor::visit_leave(ir_function_signature *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_function *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -97,7 +117,9 @@ ir_hierarchical_visitor::visit_leave(ir_function *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_expression *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -111,7 +133,9 @@ ir_hierarchical_visitor::visit_leave(ir_expression *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_texture *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -125,7 +149,9 @@ ir_hierarchical_visitor::visit_leave(ir_texture *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_swizzle *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -139,7 +165,9 @@ ir_hierarchical_visitor::visit_leave(ir_swizzle *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -153,7 +181,9 @@ ir_hierarchical_visitor::visit_leave(ir_dereference_array *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -167,7 +197,9 @@ ir_hierarchical_visitor::visit_leave(ir_dereference_record *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_assignment *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -181,7 +213,9 @@ ir_hierarchical_visitor::visit_leave(ir_assignment *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_call *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -195,7 +229,9 @@ ir_hierarchical_visitor::visit_leave(ir_call *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_return *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } @@ -209,7 +245,9 @@ ir_hierarchical_visitor::visit_leave(ir_return *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_if *ir) { - (void) ir; + if (this->callback != NULL) + this->callback(ir, this->data); + return visit_continue; } diff --git a/ir_hierarchical_visitor.h b/ir_hierarchical_visitor.h index 85bc5bb150b..af8f83cac56 100644 --- a/ir_hierarchical_visitor.h +++ b/ir_hierarchical_visitor.h @@ -76,6 +76,8 @@ enum ir_visitor_status { class ir_hierarchical_visitor { public: + ir_hierarchical_visitor(); + /** * \name Visit methods for leaf-node classes */ @@ -136,6 +138,22 @@ public: * Utility function to process a linked list of instructions with a visitor */ void run(struct exec_list *instructions); + +protected: + /** + * Callback function that is invoked on entry to each node visited. + * + * \warning + * Visitor classes derived from \c ir_hierarchical_visitor \b may \b not + * invoke this function. This can be used, for example, to cause the + * callback to be invoked on every node type execpt one. + */ + void (*callback)(class ir_instruction *ir, void *data); + + /** + * Extra data parameter passed to the per-node callback function + */ + void *data; }; #endif /* IR_HIERARCHICAL_VISITOR_H */ -- cgit v1.2.3 From 865cf2d1f5e499916d360a246ad85554f3ff5b02 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 22 Jun 2010 18:41:50 -0700 Subject: ir_validate: Use callback functionality in ir_hierarchical_visitor --- ir_validate.cpp | 156 ++++++++++++-------------------------------------------- 1 file changed, 34 insertions(+), 122 deletions(-) diff --git a/ir_validate.cpp b/ir_validate.cpp index c6c18df51a7..507e88993f2 100644 --- a/ir_validate.cpp +++ b/ir_validate.cpp @@ -35,148 +35,64 @@ #include #include "ir.h" -#include "ir_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" +#include "ir_hierarchical_visitor.h" #include "hash_table.h" -/** - * Visitor class for replacing expressions with ir_constant values. - */ - - -class ir_validate : public ir_hierarchical_visitor { -public: - virtual ir_visitor_status visit_enter(class ir_constant *); - virtual ir_visitor_status visit_enter(class ir_loop *); - virtual ir_visitor_status visit_enter(class ir_function_signature *); - virtual ir_visitor_status visit_enter(class ir_function *); - virtual ir_visitor_status visit_enter(class ir_expression *); - virtual ir_visitor_status visit_enter(class ir_texture *); - virtual ir_visitor_status visit_enter(class ir_swizzle *); - virtual ir_visitor_status visit_enter(class ir_dereference_array *); - virtual ir_visitor_status visit_enter(class ir_dereference_record *); - virtual ir_visitor_status visit_enter(class ir_assignment *); - virtual ir_visitor_status visit_enter(class ir_call *); - virtual ir_visitor_status visit_enter(class ir_return *); - virtual ir_visitor_status visit_enter(class ir_if *); - - void validate_ir(ir_instruction *ir); - - struct hash_table *ht; -}; - -unsigned int hash_func(const void *key) +static unsigned int hash_func(const void *key) { return (unsigned int)(uintptr_t)key; } -int hash_compare_func(const void *key1, const void *key2) +static int hash_compare_func(const void *key1, const void *key2) { return key1 == key2 ? 0 : 1; } -void -ir_validate::validate_ir(ir_instruction *ir) -{ - if (hash_table_find(this->ht, ir)) { - printf("Instruction node present twice in ir tree:\n"); - ir->print(); - printf("\n"); - abort(); - } - hash_table_insert(this->ht, ir, ir); -} -ir_visitor_status -ir_validate::visit_enter(ir_constant *ir) -{ - validate_ir(ir); - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_enter(ir_loop *ir) -{ - validate_ir(ir); - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_enter(ir_function_signature *ir) -{ - validate_ir(ir); - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_enter(ir_function *ir) -{ - validate_ir(ir); - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_enter(ir_expression *ir) -{ - validate_ir(ir); - return visit_continue; -} +class ir_validate : public ir_hierarchical_visitor { +public: + ir_validate() + { + this->ht = hash_table_ctor(0, hash_func, hash_compare_func); -ir_visitor_status -ir_validate::visit_enter(ir_texture *ir) -{ - validate_ir(ir); - return visit_continue; -} + this->callback = ir_validate::validate_ir; + this->data = ht; + } -ir_visitor_status -ir_validate::visit_enter(ir_swizzle *ir) -{ - validate_ir(ir); - return visit_continue; -} + ~ir_validate() + { + hash_table_dtor(this->ht); + } -ir_visitor_status -ir_validate::visit_enter(ir_dereference_array *ir) -{ - validate_ir(ir); - return visit_continue; -} + virtual ir_visitor_status visit(ir_variable *v); -ir_visitor_status -ir_validate::visit_enter(ir_dereference_record *ir) -{ - validate_ir(ir); - return visit_continue; -} + static void validate_ir(ir_instruction *ir, void *data); -ir_visitor_status -ir_validate::visit_enter(ir_assignment *ir) -{ - validate_ir(ir); - return visit_continue; -} + struct hash_table *ht; +}; ir_visitor_status -ir_validate::visit_enter(ir_call *ir) +ir_validate::visit(ir_variable *ir) { - validate_ir(ir); + /* An ir_variable is the one thing that can (and will) appear multiple times + * in an IR tree. + */ + (void) ir; return visit_continue; } -ir_visitor_status -ir_validate::visit_enter(ir_return *ir) +void +ir_validate::validate_ir(ir_instruction *ir, void *data) { - validate_ir(ir); - return visit_continue; -} + struct hash_table *ht = (struct hash_table *) data; -ir_visitor_status -ir_validate::visit_enter(ir_if *ir) -{ - validate_ir(ir); - return visit_continue; + if (hash_table_find(ht, ir)) { + printf("Instruction node present twice in ir tree:\n"); + ir->print(); + printf("\n"); + abort(); + } + hash_table_insert(ht, ir, ir); } void @@ -184,9 +100,5 @@ validate_ir_tree(exec_list *instructions) { ir_validate v; - v.ht = hash_table_ctor(0, hash_func, hash_compare_func); - v.run(instructions); - - hash_table_dtor(v.ht); } -- cgit v1.2.3 From 53e48d3f6344964d99be89340343630dbf4175d1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 22 Jun 2010 14:22:42 -0700 Subject: Fix multiple usage of an rvalue in constructor component splitting. Store the thing in a variable and deref it for each swizzle if we have to. Signed-off-by: Ian Romanick --- ast_function.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 26050977d52..691e6aeba00 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -519,6 +519,7 @@ ast_function_expression::hir(exec_list *instructions, ast_node *ast = exec_node_data(ast_node, n, link); ir_rvalue *result = ast->hir(instructions, state)->as_rvalue(); + ir_variable *result_var = NULL; /* Attempt to convert the parameter to a constant valued expression. * After doing so, track whether or not all the parameters to the @@ -559,6 +560,19 @@ ast_function_expression::hir(exec_list *instructions, else nonmatrix_parameters++; + /* We can't use the same instruction node in the multiple + * swizzle dereferences that happen, so assign it to a + * variable and deref that. Plus it saves computation for + * complicated expressions and handles + * glsl-vs-constructor-call.shader_test. + */ + if (result->type->components() >= 1 && !result->as_constant()) { + result_var = new ir_variable(result->type, "constructor_tmp"); + ir_dereference_variable *lhs; + + lhs = new ir_dereference_variable(result_var); + instructions->push_tail(new ir_assignment(lhs, result, NULL)); + } /* Process each of the components of the parameter. Dereference * each component individually, perform any type conversions, and @@ -568,9 +582,15 @@ ast_function_expression::hir(exec_list *instructions, if (components_used >= type_components) break; - ir_rvalue *const component = - convert_component(dereference_component(result, i), - base_type); + ir_rvalue *component; + + if (result_var) { + ir_dereference *d = new ir_dereference_variable(result_var); + component = dereference_component(d, i); + } else { + component = dereference_component(result, i); + } + component = convert_component(component, base_type); /* All cases that could result in component->type being the * error type should have already been caught above. -- cgit v1.2.3 From 1e8b7a714e8acbb5028a250048452f2efc29d02e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 17 Jun 2010 19:50:36 -0700 Subject: ir_constant: Add method to determine if two constants have the same value --- ir.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ir.h | 5 +++++ 2 files changed, 61 insertions(+) diff --git a/ir.cpp b/ir.cpp index d50293d993c..7fc260db390 100644 --- a/ir.cpp +++ b/ir.cpp @@ -423,6 +423,62 @@ ir_constant::get_record_field(const char *name) } +bool +ir_constant::has_value(const ir_constant *c) const +{ + if (this->type != c->type) + return false; + + /* FINISHME: This will probably also handle constant arrays as soon as those + * FINISHME: are supported. + */ + if (this->type->base_type == GLSL_TYPE_STRUCT) { + const exec_node *a_node = this->components.head; + const exec_node *b_node = c->components.head; + + while (!a_node->is_tail_sentinal()) { + assert(!b_node->is_tail_sentinal()); + + const ir_constant *const a_field = (ir_constant *) a_node; + const ir_constant *const b_field = (ir_constant *) b_node; + + if (!a_field->has_value(b_field)) + return false; + + a_node = a_node->next; + b_node = b_node->next; + } + + return true; + } + + for (unsigned i = 0; i < this->type->components(); i++) { + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + if (this->value.u[i] != c->value.u[i]) + return false; + break; + case GLSL_TYPE_INT: + if (this->value.i[i] != c->value.i[i]) + return false; + break; + case GLSL_TYPE_FLOAT: + if (this->value.f[i] != c->value.f[i]) + return false; + break; + case GLSL_TYPE_BOOL: + if (this->value.b[i] != c->value.b[i]) + return false; + break; + default: + assert(!"Should not get here."); + return false; + } + } + + return true; +} + ir_dereference_variable::ir_dereference_variable(ir_variable *var) { this->var = var; diff --git a/ir.h b/ir.h index d02f3caab97..a04b688894b 100644 --- a/ir.h +++ b/ir.h @@ -1091,6 +1091,11 @@ public: ir_constant *get_record_field(const char *name); + /** + * Determine whether a constant has the same value as another constant + */ + bool has_value(const ir_constant *) const; + /** * Value of the constant. * -- cgit v1.2.3 From cc22c5a5447d1d710e49524ee61b76268c7da6b9 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 18 Jun 2010 17:13:42 -0700 Subject: linker: Initial implementation of interstage uniform validation --- linker.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/linker.cpp b/linker.cpp index 0a1afcf0345..a7eff556cf7 100644 --- a/linker.cpp +++ b/linker.cpp @@ -170,6 +170,60 @@ validate_fragment_shader_executable(struct glsl_shader *shader) } +/** + * Perform validation of uniforms used across multiple shader stages + */ +bool +cross_validate_uniforms(struct glsl_shader **shaders, unsigned num_shaders) +{ + /* Examine all of the uniforms in all of the shaders and cross validate + * them. + */ + glsl_symbol_table uniforms; + for (unsigned i = 0; i < num_shaders; i++) { + foreach_list(node, &shaders[i]->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_uniform)) + continue; + + /* If a uniform with this name has already been seen, verify that the + * new instance has the same type. In addition, if the uniforms have + * initializers, the values of the initializers must be the same. + */ + ir_variable *const existing = uniforms.get_variable(var->name); + if (existing != NULL) { + if (var->type != existing->type) { + printf("error: uniform `%s' declared as type `%s' and " + "type `%s'\n", + var->name, var->type->name, existing->type->name); + return false; + } + + if (var->constant_value != NULL) { + if (existing->constant_value != NULL) { + if (!var->constant_value->has_value(existing->constant_value)) { + printf("error: initializers for uniform `%s' have " + "differing values\n", + var->name); + return false; + } + } else + /* If the first-seen instance of a particular uniform did not + * have an initializer but a later instance does, copy the + * initializer to the version stored in the symbol table. + */ + existing->constant_value = var->constant_value->clone(); + } + } else + uniforms.add_variable(var->name, var); + } + } + + return true; +} + + void link_shaders(struct glsl_program *prog) { @@ -217,8 +271,22 @@ link_shaders(struct glsl_program *prog) /* FINISHME: Perform inter-stage linking. */ + glsl_shader *shader_executables[2]; + unsigned num_shader_executables; + + num_shader_executables = 0; + if (num_vert_shaders > 0) { + shader_executables[num_shader_executables] = vert_shader_list[0]; + num_shader_executables++; + } + + if (num_frag_shaders > 0) { + shader_executables[num_shader_executables] = frag_shader_list[0]; + num_shader_executables++; + } - prog->LinkStatus = true; + if (cross_validate_uniforms(shader_executables, num_shader_executables)) + prog->LinkStatus = true; done: free(vert_shader_list); -- cgit v1.2.3 From 950ceb2bd60c25e7fecdff0fbcbf6e69015588f3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 18 Jun 2010 19:00:28 -0700 Subject: ir_variable: Add method to get string representing interpolation qualifier --- ir.cpp | 17 +++++++++++++++++ ir.h | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/ir.cpp b/ir.cpp index 7fc260db390..61589c3ff20 100644 --- a/ir.cpp +++ b/ir.cpp @@ -738,6 +738,23 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) } +const char * +ir_variable::interpolation_string() const +{ + if (!this->shader_in && !this->shader_out) + return ""; + + switch (this->interpolation) { + case ir_var_smooth: return "smooth"; + case ir_var_flat: return "flat"; + case ir_var_noperspective: return "noperspective"; + } + + assert(!"Should not get here."); + return ""; +} + + ir_function_signature::ir_function_signature(const glsl_type *return_type) : return_type(return_type), is_defined(false) { diff --git a/ir.h b/ir.h index a04b688894b..04ecb582e48 100644 --- a/ir.h +++ b/ir.h @@ -177,6 +177,16 @@ public: return var; } + /** + * Get the string value for the interpolation qualifier + * + * \return + * If none of \c shader_in or \c shader_out is set, an empty string will + * be returned. Otherwise the string that would be used in a shader to + * specify \c mode will be returned. + */ + const char *interpolation_string() const; + const char *name; /** -- cgit v1.2.3 From 371019248ef94ddd7ee2491813e6f41c0412b2ba Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 18 Jun 2010 19:02:10 -0700 Subject: linker: Initial implementation of interstage input / output validation --- linker.cpp | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/linker.cpp b/linker.cpp index a7eff556cf7..7b1838a5af9 100644 --- a/linker.cpp +++ b/linker.cpp @@ -224,6 +224,100 @@ cross_validate_uniforms(struct glsl_shader **shaders, unsigned num_shaders) } +/** + * Validate that outputs from one stage match inputs of another + */ +bool +cross_validate_outputs_to_inputs(glsl_shader *producer, glsl_shader *consumer) +{ + glsl_symbol_table parameters; + /* FINISHME: Figure these out dynamically. */ + const char *const producer_stage = "vertex"; + const char *const consumer_stage = "fragment"; + + /* Find all shader outputs in the "producer" stage. + */ + foreach_list(node, &producer->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + /* FINISHME: For geometry shaders, this should also look for inout + * FINISHME: variables. + */ + if ((var == NULL) || (var->mode != ir_var_out)) + continue; + + parameters.add_variable(var->name, var); + } + + + /* Find all shader inputs in the "consumer" stage. Any variables that have + * matching outputs already in the symbol table must have the same type and + * qualifiers. + */ + foreach_list(node, &consumer->ir) { + ir_variable *const input = ((ir_instruction *) node)->as_variable(); + + /* FINISHME: For geometry shaders, this should also look for inout + * FINISHME: variables. + */ + if ((input == NULL) || (input->mode != ir_var_in)) + continue; + + ir_variable *const output = parameters.get_variable(input->name); + if (output != NULL) { + /* Check that the types match between stages. + */ + if (input->type != output->type) { + printf("error: %s shader output `%s' delcared as type `%s', but " + "%s shader input declared as type `%s'\n", + producer_stage, output->name, output->type->name, + consumer_stage, input->type->name); + return false; + } + + /* Check that all of the qualifiers match between stages. + */ + if (input->centroid != output->centroid) { + printf("error: %s shader output `%s' %s centroid qualifier, but " + "%s shader input %s centroid qualifier\n", + producer_stage, + output->name, + (output->centroid) ? "has" : "lacks", + consumer_stage, + (input->centroid) ? "has" : "lacks"); + return false; + } + + if (input->invariant != output->invariant) { + printf("error: %s shader output `%s' %s invariant qualifier, but " + "%s shader input %s invariant qualifier\n", + producer_stage, + output->name, + (output->invariant) ? "has" : "lacks", + consumer_stage, + (input->invariant) ? "has" : "lacks"); + return false; + } + + if (input->interpolation != output->interpolation) { + printf("error: %s shader output `%s' specifies %s interpolation " + "qualifier, " + "but %s shader input specifies %s interpolation " + "qualifier\n", + producer_stage, + output->name, + output->interpolation_string(), + consumer_stage, + input->interpolation_string()); + return false; + } + } + } + + return true; +} + + void link_shaders(struct glsl_program *prog) { @@ -285,8 +379,18 @@ link_shaders(struct glsl_program *prog) num_shader_executables++; } - if (cross_validate_uniforms(shader_executables, num_shader_executables)) + if (cross_validate_uniforms(shader_executables, num_shader_executables)) { + /* Validate the inputs of each stage with the output of the preceeding + * stage. + */ + for (unsigned i = 1; i < num_shader_executables; i++) { + if (!cross_validate_outputs_to_inputs(shader_executables[i - 1], + shader_executables[i])) + goto done; + } + prog->LinkStatus = true; + } done: free(vert_shader_list); -- cgit v1.2.3 From 69a079aee8f79104501faeb2a5092b643f956d33 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jun 2010 11:42:02 -0700 Subject: ir_variable: Track the location of uniforms, varings, attributes, etc. --- ir.cpp | 1 + ir.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ir.cpp b/ir.cpp index 61589c3ff20..08b2d888816 100644 --- a/ir.cpp +++ b/ir.cpp @@ -731,6 +731,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) { this->type = type; this->name = name; + this->location = -1; this->constant_value = NULL; if (type && type->base_type == GLSL_TYPE_SAMPLER) diff --git a/ir.h b/ir.h index 04ecb582e48..a2fc2b769c0 100644 --- a/ir.h +++ b/ir.h @@ -217,6 +217,23 @@ public: */ unsigned array_lvalue:1; + /** + * Storage location of the base of this variable + * + * The precise meaning of this field depends on the nature of the variable. + * + * - Vertex shader input: one of the values from \c gl_vert_attrib. + * - Vertex shader output: one of the values from \c gl_vert_result. + * - Fragment shader input: one of the values from \c gl_frag_attrib. + * - Fragment shader output: one of the values from \c gl_frag_result. + * - Uniforms: Per-stage uniform slot number. + * - Other: This field is not currently used. + * + * If the variable is a uniform, shader input, or shader output, and the + * slot has not been assigned, the value will be -1. + */ + int location; + /** * Emit a warning if this variable is accessed. */ -- cgit v1.2.3 From ed0626ebc7201cab365572a1326a088c5678a054 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jun 2010 11:42:57 -0700 Subject: ir_variable: Set locations for shader built-in variables --- builtin_variables.h | 89 +++++++++++++++++++++++++++-------------------------- ir_variable.cpp | 31 +++++++++++-------- 2 files changed, 65 insertions(+), 55 deletions(-) diff --git a/builtin_variables.h b/builtin_variables.h index b405b46f071..77f2fe55023 100644 --- a/builtin_variables.h +++ b/builtin_variables.h @@ -21,70 +21,73 @@ * DEALINGS IN THE SOFTWARE. */ +#include "main/mtypes.h" + struct builtin_variable { enum ir_variable_mode mode; + int slot; const char *type; const char *name; }; static const builtin_variable builtin_core_vs_variables[] = { - { ir_var_out, "vec4", "gl_Position" }, - { ir_var_out, "float", "gl_PointSize" }, + { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_Position" }, + { ir_var_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" }, }; static const builtin_variable builtin_core_fs_variables[] = { - { ir_var_in, "vec4", "gl_FragCoord" }, - { ir_var_in, "bool", "gl_FrontFacing" }, - { ir_var_out, "vec4", "gl_FragColor" }, - { ir_var_out, "float", "gl_FragDepth" }, + { ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" }, + { ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" }, + { ir_var_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" }, + { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" }, }; static const builtin_variable builtin_110_deprecated_fs_variables[] = { - { ir_var_in, "vec4", "gl_Color" }, - { ir_var_in, "vec4", "gl_SecondaryColor" }, - { ir_var_in, "float", "gl_FogFragCoord" }, + { ir_var_in, FRAG_ATTRIB_COL0, "vec4", "gl_Color" }, + { ir_var_in, FRAG_ATTRIB_COL1, "vec4", "gl_SecondaryColor" }, + { ir_var_in, FRAG_ATTRIB_FOGC, "float", "gl_FogFragCoord" }, }; static const builtin_variable builtin_110_deprecated_vs_variables[] = { - { ir_var_in, "vec4", "gl_Vertex" }, - { ir_var_in, "vec3", "gl_Normal" }, - { ir_var_in, "vec4", "gl_Color" }, - { ir_var_in, "vec4", "gl_SecondaryColor" }, - { ir_var_in, "vec4", "gl_MultiTexCoord0" }, - { ir_var_in, "vec4", "gl_MultiTexCoord1" }, - { ir_var_in, "vec4", "gl_MultiTexCoord2" }, - { ir_var_in, "vec4", "gl_MultiTexCoord3" }, - { ir_var_in, "vec4", "gl_MultiTexCoord4" }, - { ir_var_in, "vec4", "gl_MultiTexCoord5" }, - { ir_var_in, "vec4", "gl_MultiTexCoord6" }, - { ir_var_in, "vec4", "gl_MultiTexCoord7" }, - { ir_var_in, "float", "gl_FogCoord" }, - { ir_var_out, "vec4", "gl_ClipVertex" }, - { ir_var_out, "vec4", "gl_FrontColor" }, - { ir_var_out, "vec4", "gl_BackColor" }, - { ir_var_out, "vec4", "gl_FrontSecondaryColor" }, - { ir_var_out, "vec4", "gl_BackSecondaryColor" }, - { ir_var_out, "float", "gl_FogFragCoord" }, + { ir_var_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" }, + { ir_var_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" }, + { ir_var_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" }, + { ir_var_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" }, + { ir_var_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" }, + { ir_var_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" }, + { ir_var_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" }, + { ir_var_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" }, + { ir_var_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" }, + { ir_var_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" }, + { ir_var_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" }, + { ir_var_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" }, + { ir_var_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" }, + { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_ClipVertex" }, + { ir_var_out, VERT_RESULT_COL0, "vec4", "gl_FrontColor" }, + { ir_var_out, VERT_RESULT_BFC0, "vec4", "gl_BackColor" }, + { ir_var_out, VERT_RESULT_COL1, "vec4", "gl_FrontSecondaryColor" }, + { ir_var_out, VERT_RESULT_BFC1, "vec4", "gl_BackSecondaryColor" }, + { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" }, }; static const builtin_variable builtin_130_vs_variables[] = { - { ir_var_in, "int", "gl_VertexID" }, + { ir_var_in, -1, "int", "gl_VertexID" }, }; static const builtin_variable builtin_110_deprecated_uniforms[] = { - { ir_var_uniform, "mat4", "gl_ModelViewMatrix" }, - { ir_var_uniform, "mat4", "gl_ProjectionMatrix" }, - { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrix" }, - { ir_var_uniform, "mat3", "gl_NormalMatrix" }, - { ir_var_uniform, "mat4", "gl_ModelViewMatrixInverse" }, - { ir_var_uniform, "mat4", "gl_ProjectionMatrixInverse" }, - { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrixInverse" }, - { ir_var_uniform, "mat4", "gl_ModelViewMatrixTranspose" }, - { ir_var_uniform, "mat4", "gl_ProjectionMatrixTranspose" }, - { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrixTranspose" }, - { ir_var_uniform, "mat4", "gl_ModelViewMatrixInverseTranspose" }, - { ir_var_uniform, "mat4", "gl_ProjectionMatrixInverseTranspose" }, - { ir_var_uniform, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, - { ir_var_uniform, "float", "gl_NormalScale" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" }, + { ir_var_uniform, -1, "mat3", "gl_NormalMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, + { ir_var_uniform, -1, "float", "gl_NormalScale" }, }; diff --git a/ir_variable.cpp b/ir_variable.cpp index 49d8e3dcfb5..efebe9199fa 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -31,7 +31,7 @@ #endif static ir_variable * -add_variable(const char *name, enum ir_variable_mode mode, +add_variable(const char *name, enum ir_variable_mode mode, int slot, const glsl_type *type, exec_list *instructions, glsl_symbol_table *symtab) { @@ -59,6 +59,8 @@ add_variable(const char *name, enum ir_variable_mode mode, break; } + var->location = slot; + /* Once the variable is created an initialized, add it to the symbol table * and add the declaration to the IR stream. */ @@ -80,7 +82,8 @@ add_builtin_variable(const builtin_variable *proto, exec_list *instructions, assert(type != NULL); - add_variable(proto->name, proto->mode, type, instructions, symtab); + add_variable(proto->name, proto->mode, proto->slot, type, instructions, + symtab); } @@ -103,7 +106,7 @@ generate_110_uniforms(exec_list *instructions, const glsl_type *const mat4_array_type = glsl_type::get_array_instance(glsl_type::mat4_type, 4); - add_variable("gl_TextureMatrix", ir_var_uniform, mat4_array_type, + add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type, instructions, symtab); /* FINISHME: Add support for gl_DepthRangeParameters */ @@ -121,7 +124,7 @@ generate_110_uniforms(exec_list *instructions, const glsl_type *const light_source_array_type = glsl_type::get_array_instance(symtab->get_type("gl_LightSourceParameters"), 8); - add_variable("gl_LightSource", ir_var_uniform, light_source_array_type, + add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type, instructions, symtab); /* FINISHME: Add support for gl_LightModel */ @@ -156,8 +159,8 @@ generate_110_vs_variables(exec_list *instructions, const glsl_type *const vec4_array_type = glsl_type::get_array_instance(glsl_type::vec4_type, 4); - add_variable("gl_TexCoord", ir_var_out, vec4_array_type, instructions, - symtab); + add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type, + instructions, symtab); } @@ -188,7 +191,9 @@ generate_130_vs_variables(exec_list *instructions, */ const glsl_type *const clip_distance_array_type = glsl_type::get_array_instance(glsl_type::float_type, 8); - add_variable("gl_ClipDistance", ir_var_out, clip_distance_array_type, + + /* FINISHME: gl_ClipDistance needs a real location assigned. */ + add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type, instructions, symtab); } @@ -237,8 +242,8 @@ generate_110_fs_variables(exec_list *instructions, const glsl_type *const vec4_array_type = glsl_type::get_array_instance(glsl_type::vec4_type, 4); - add_variable("gl_TexCoord", ir_var_in, vec4_array_type, instructions, - symtab); + add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type, + instructions, symtab); } @@ -254,8 +259,8 @@ generate_ARB_draw_buffers_fs_variables(exec_list *instructions, glsl_type::get_array_instance(glsl_type::vec4_type, 1); ir_variable *const fd = - add_variable("gl_FragData", ir_var_out, vec4_array_type, instructions, - symtab); + add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0, + vec4_array_type, instructions, symtab); if (warn) fd->warn_extension = "GL_ARB_draw_buffers"; @@ -281,7 +286,9 @@ generate_130_fs_variables(exec_list *instructions, */ const glsl_type *const clip_distance_array_type = glsl_type::get_array_instance(glsl_type::float_type, 8); - add_variable("gl_ClipDistance", ir_var_in, clip_distance_array_type, + + /* FINISHME: gl_ClipDistance needs a real location assigned. */ + add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type, instructions, symtab); } -- cgit v1.2.3 From 13e10e43c315be3ba2bee509502bc9c542d90249 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jun 2010 12:03:24 -0700 Subject: linker: Document what remains to be done --- linker.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/linker.cpp b/linker.cpp index 7b1838a5af9..dadc0d92a05 100644 --- a/linker.cpp +++ b/linker.cpp @@ -392,6 +392,20 @@ link_shaders(struct glsl_program *prog) prog->LinkStatus = true; } + /* FINISHME: Perform whole-program optimization here. */ + + /* FINISHME: Assign uniform locations. */ + + /* FINISHME: Assign vertex shader input locations. */ + + /* FINISHME: Assign vertex shader output / fragment shader input + * FINISHME: locations. + */ + + /* FINISHME: Assign fragment shader output locations. */ + + /* FINISHME: Generate code here. */ + done: free(vert_shader_list); } -- cgit v1.2.3 From 57bb893a46ced683792f8e7ebdffbb5c5a892b84 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jun 2010 16:05:00 -0700 Subject: glsl_type: Add method to get number of slots used by a type --- glsl_types.cpp | 28 ++++++++++++++++++++++++++++ glsl_types.h | 9 +++++++++ 2 files changed, 37 insertions(+) diff --git a/glsl_types.cpp b/glsl_types.cpp index 290756d453c..2b7c5bce30f 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -732,3 +732,31 @@ glsl_type::field_index(const char *name) const return -1; } + + +unsigned +glsl_type::component_slots() const +{ + switch (this->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + return this->components(); + + case GLSL_TYPE_STRUCT: { + unsigned size = 0; + + for (unsigned i = 0; i < this->length; i++) + size += this->fields.structure[i].type->component_slots(); + + return size; + } + + case GLSL_TYPE_ARRAY: + return this->length * this->fields.array->component_slots(); + + default: + return 0; + } +} diff --git a/glsl_types.h b/glsl_types.h index 3265016146d..939c173fd41 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -214,6 +214,15 @@ struct glsl_type { return vector_elements * matrix_columns; } + /** + * Calculate the number of components slots required to hold this type + * + * This is used to determine how many uniform or varying locations a type + * might occupy. + */ + unsigned component_slots() const; + + /** * Query whether or not a type is a scalar (non-vector and non-matrix). */ -- cgit v1.2.3 From 8b80e9f9e3bc9ca41c95125826139471f73602c4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jun 2010 16:05:29 -0700 Subject: ir_variable: Add query to get number of slots used by a variable --- ir.cpp | 8 ++++++++ ir.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/ir.cpp b/ir.cpp index 08b2d888816..49191fb9295 100644 --- a/ir.cpp +++ b/ir.cpp @@ -756,6 +756,14 @@ ir_variable::interpolation_string() const } +unsigned +ir_variable::component_slots() const +{ + /* FINISHME: Sparsely accessed arrays require fewer slots. */ + return this->type->component_slots(); +} + + ir_function_signature::ir_function_signature(const glsl_type *return_type) : return_type(return_type), is_defined(false) { diff --git a/ir.h b/ir.h index a2fc2b769c0..9cbe11505a6 100644 --- a/ir.h +++ b/ir.h @@ -187,6 +187,14 @@ public: */ const char *interpolation_string() const; + /** + * Calculate the number of slots required to hold this variable + * + * This is used to determine how many uniform or varying locations a variable + * occupies. The count is in units of floating point components. + */ + unsigned component_slots() const; + const char *name; /** -- cgit v1.2.3 From 5edf6f98d8b7b945294c55284cefc8035d23ea8a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jun 2010 16:06:07 -0700 Subject: Import gl_uniform and gl_uniform_list types from Mesa --- program.h | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/program.h b/program.h index 44cf3456355..57985c47582 100644 --- a/program.h +++ b/program.h @@ -42,7 +42,40 @@ struct glsl_shader { struct gl_program_parameter_list; -struct gl_uniform_list; + +/** + * Shader program uniform variable. + * The glGetUniformLocation() and glUniform() commands will use this + * information. + * Note that a uniform such as "binormal" might be used in both the + * vertex shader and the fragment shader. When glUniform() is called to + * set the uniform's value, it must be updated in both the vertex and + * fragment shaders. The uniform may be in different locations in the + * two shaders so we keep track of that here. + */ +struct gl_uniform +{ + const char *Name; /**< Null-terminated string */ + GLint VertPos; + GLint FragPos; + GLboolean Initialized; /**< For debug. Has this uniform been set? */ +#if 0 + GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ + GLuint Size; /**< Number of components (1..4) */ +#endif +}; + + +/** + * List of gl_uniforms + */ +struct gl_uniform_list +{ + GLuint Size; /**< allocated size of Uniforms array */ + GLuint NumUniforms; /**< number of uniforms in the array */ + struct gl_uniform *Uniforms; /**< Array [Size] */ +}; + /** * Based on gl_shader_program in Mesa's mtypes.h. -- cgit v1.2.3 From 019a59b2642f403203d8bc8ea980efeeffcd6462 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jun 2010 16:10:42 -0700 Subject: linker: Initial implementation of uniform slot allocation --- linker.cpp | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/linker.cpp b/linker.cpp index dadc0d92a05..0c07b6d35f5 100644 --- a/linker.cpp +++ b/linker.cpp @@ -69,7 +69,9 @@ #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" #include "ir.h" +#include "ir_optimization.h" #include "program.h" +#include "hash_table.h" /** * Visitor that determines whether or not a variable is ever written. @@ -318,6 +320,101 @@ cross_validate_outputs_to_inputs(glsl_shader *producer, glsl_shader *consumer) } +struct uniform_node { + exec_node link; + struct gl_uniform *u; + unsigned slots; +}; + +struct gl_uniform_list * +assign_uniform_locations(struct glsl_shader **shaders, unsigned num_shaders) +{ + /* */ + exec_list uniforms; + unsigned total_uniforms = 0; + hash_table *ht = hash_table_ctor(32, hash_table_string_hash, + hash_table_string_compare); + + for (unsigned i = 0; i < num_shaders; i++) { + unsigned next_position = 0; + + foreach_list(node, &shaders[i]->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_uniform)) + continue; + + const unsigned vec4_slots = (var->component_slots() + 3) / 4; + assert(vec4_slots != 0); + + uniform_node *n = (uniform_node *) hash_table_find(ht, var->name); + if (n == NULL) { + n = (uniform_node *) calloc(1, sizeof(struct uniform_node)); + n->u = (gl_uniform *) calloc(vec4_slots, sizeof(struct gl_uniform)); + n->slots = vec4_slots; + + n->u[0].Name = strdup(var->name); + for (unsigned j = 1; j < vec4_slots; j++) + n->u[j].Name = n->u[0].Name; + + hash_table_insert(ht, n, n->u[0].Name); + uniforms.push_tail(& n->link); + total_uniforms += vec4_slots; + } + + if (var->constant_value != NULL) + for (unsigned j = 0; j < vec4_slots; j++) + n->u[j].Initialized = true; + + var->location = next_position; + + for (unsigned j = 0; j < vec4_slots; j++) { + switch (shaders[i]->Type) { + case GL_VERTEX_SHADER: + n->u[j].VertPos = next_position; + break; + case GL_FRAGMENT_SHADER: + n->u[j].FragPos = next_position; + break; + case GL_GEOMETRY_SHADER: + /* FINISHME: Support geometry shaders. */ + assert(shaders[i]->Type != GL_GEOMETRY_SHADER); + break; + } + + next_position++; + } + } + } + + gl_uniform_list *ul = (gl_uniform_list *) + calloc(1, sizeof(gl_uniform_list)); + + ul->Size = total_uniforms; + ul->NumUniforms = total_uniforms; + ul->Uniforms = (gl_uniform *) calloc(total_uniforms, sizeof(gl_uniform)); + + unsigned idx = 0; + uniform_node *next; + for (uniform_node *node = (uniform_node *) uniforms.head + ; node->link.next != NULL + ; node = next) { + next = (uniform_node *) node->link.next; + + node->link.remove(); + memcpy(&ul->Uniforms[idx], node->u, sizeof(gl_uniform) * node->slots); + idx += node->slots; + + free(node->u); + free(node); + } + + hash_table_dtor(ht); + + return ul; +} + + void link_shaders(struct glsl_program *prog) { @@ -394,7 +491,8 @@ link_shaders(struct glsl_program *prog) /* FINISHME: Perform whole-program optimization here. */ - /* FINISHME: Assign uniform locations. */ + prog->Uniforms = assign_uniform_locations(shader_executables, + num_shader_executables); /* FINISHME: Assign vertex shader input locations. */ -- cgit v1.2.3 From abee16e8cb3d894b05bc0d09552bfc143c0217fa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jun 2010 16:16:05 -0700 Subject: linker: Store the par-linked per-stage shaders in the glsl_program --- linker.cpp | 39 +++++++++++++++++++-------------------- program.h | 8 ++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/linker.cpp b/linker.cpp index 0c07b6d35f5..2285f01a0c4 100644 --- a/linker.cpp +++ b/linker.cpp @@ -326,8 +326,8 @@ struct uniform_node { unsigned slots; }; -struct gl_uniform_list * -assign_uniform_locations(struct glsl_shader **shaders, unsigned num_shaders) +void +assign_uniform_locations(struct glsl_program *prog) { /* */ exec_list uniforms; @@ -335,10 +335,10 @@ assign_uniform_locations(struct glsl_shader **shaders, unsigned num_shaders) hash_table *ht = hash_table_ctor(32, hash_table_string_hash, hash_table_string_compare); - for (unsigned i = 0; i < num_shaders; i++) { + for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { unsigned next_position = 0; - foreach_list(node, &shaders[i]->ir) { + foreach_list(node, &prog->_LinkedShaders[i]->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); if ((var == NULL) || (var->mode != ir_var_uniform)) @@ -369,7 +369,7 @@ assign_uniform_locations(struct glsl_shader **shaders, unsigned num_shaders) var->location = next_position; for (unsigned j = 0; j < vec4_slots; j++) { - switch (shaders[i]->Type) { + switch (prog->_LinkedShaders[i]->Type) { case GL_VERTEX_SHADER: n->u[j].VertPos = next_position; break; @@ -378,7 +378,7 @@ assign_uniform_locations(struct glsl_shader **shaders, unsigned num_shaders) break; case GL_GEOMETRY_SHADER: /* FINISHME: Support geometry shaders. */ - assert(shaders[i]->Type != GL_GEOMETRY_SHADER); + assert(prog->_LinkedShaders[i]->Type != GL_GEOMETRY_SHADER); break; } @@ -411,7 +411,7 @@ assign_uniform_locations(struct glsl_shader **shaders, unsigned num_shaders) hash_table_dtor(ht); - return ul; + prog->Uniforms = ul; } @@ -462,27 +462,27 @@ link_shaders(struct glsl_program *prog) /* FINISHME: Perform inter-stage linking. */ - glsl_shader *shader_executables[2]; - unsigned num_shader_executables; + prog->_LinkedShaders = (struct glsl_shader **) + calloc(2, sizeof(struct glsl_shader *)); + prog->_NumLinkedShaders = 0; - num_shader_executables = 0; if (num_vert_shaders > 0) { - shader_executables[num_shader_executables] = vert_shader_list[0]; - num_shader_executables++; + prog->_LinkedShaders[prog->_NumLinkedShaders] = vert_shader_list[0]; + prog->_NumLinkedShaders++; } if (num_frag_shaders > 0) { - shader_executables[num_shader_executables] = frag_shader_list[0]; - num_shader_executables++; + prog->_LinkedShaders[prog->_NumLinkedShaders] = frag_shader_list[0]; + prog->_NumLinkedShaders++; } - if (cross_validate_uniforms(shader_executables, num_shader_executables)) { + if (cross_validate_uniforms(prog->_LinkedShaders, prog->_NumLinkedShaders)) { /* Validate the inputs of each stage with the output of the preceeding * stage. */ - for (unsigned i = 1; i < num_shader_executables; i++) { - if (!cross_validate_outputs_to_inputs(shader_executables[i - 1], - shader_executables[i])) + for (unsigned i = 1; i < prog->_NumLinkedShaders; i++) { + if (!cross_validate_outputs_to_inputs(prog->_LinkedShaders[i - 1], + prog->_LinkedShaders[i])) goto done; } @@ -491,8 +491,7 @@ link_shaders(struct glsl_program *prog) /* FINISHME: Perform whole-program optimization here. */ - prog->Uniforms = assign_uniform_locations(shader_executables, - num_shader_executables); + assign_uniform_locations(prog); /* FINISHME: Assign vertex shader input locations. */ diff --git a/program.h b/program.h index 57985c47582..eff50080508 100644 --- a/program.h +++ b/program.h @@ -89,6 +89,14 @@ struct glsl_program { GLuint NumShaders; /**< number of attached shaders */ struct glsl_shader **Shaders; /**< List of attached the shaders */ + /** + * Per-stage shaders resulting from the first stage of linking. + */ + /*@{*/ + unsigned _NumLinkedShaders; + struct glsl_shader **_LinkedShaders; + /*@}*/ + /* post-link info: */ struct gl_uniform_list *Uniforms; struct gl_program_parameter_list *Varying; -- cgit v1.2.3 From 4485c5ae78f105f4ab3e72ca36749d3c172a6a35 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jun 2010 17:08:51 -0700 Subject: Import gl_program_parameter and gl_program_parameter_list types from Mesa --- program.h | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/program.h b/program.h index eff50080508..5c900b53cc0 100644 --- a/program.h +++ b/program.h @@ -41,7 +41,49 @@ struct glsl_shader { }; -struct gl_program_parameter_list; +typedef int gl_register_file; +typedef int gl_state_index; +#define STATE_LENGTH 5 + +/** + * Program parameter. + * Used by shaders/programs for uniforms, constants, varying vars, etc. + */ +struct gl_program_parameter +{ + const char *Name; /**< Null-terminated string */ + gl_register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */ + GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ + /** + * Number of components (1..4), or more. + * If the number of components is greater than 4, + * this parameter is part of a larger uniform like a GLSL matrix or array. + * The next program parameter's Size will be Size-4 of this parameter. + */ + GLuint Size; + GLboolean Used; /**< Helper flag for GLSL uniform tracking */ + GLboolean Initialized; /**< Has the ParameterValue[] been set? */ + GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ + /** + * A sequence of STATE_* tokens and integers to identify GL state. + */ + gl_state_index StateIndexes[STATE_LENGTH]; +}; + + +/** + * List of gl_program_parameter instances. + */ +struct gl_program_parameter_list +{ + GLuint Size; /**< allocated size of Parameters, ParameterValues */ + GLuint NumParameters; /**< number of parameters in arrays */ + struct gl_program_parameter *Parameters; /**< Array [Size] */ + GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */ + GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes + might invalidate ParameterValues[] */ +}; + /** * Shader program uniform variable. @@ -97,6 +139,9 @@ struct glsl_program { struct glsl_shader **_LinkedShaders; /*@}*/ + /** User-defined attribute bindings (glBindAttribLocation) */ + struct gl_program_parameter_list *Attributes; + /* post-link info: */ struct gl_uniform_list *Uniforms; struct gl_program_parameter_list *Varying; -- cgit v1.2.3 From a8ca9cbc6997848b084f26c3b6d90c56f90a6b70 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 22 Jun 2010 13:41:50 -0700 Subject: Import some bits Mesa's mtypes.h --- main/mtypes.h | 221 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 main/mtypes.h diff --git a/main/mtypes.h b/main/mtypes.h new file mode 100644 index 00000000000..f168b6605b3 --- /dev/null +++ b/main/mtypes.h @@ -0,0 +1,221 @@ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file mtypes.h + * Main Mesa data structures. + * + * Please try to mark derived values with a leading underscore ('_'). + */ + +#ifndef MTYPES_H +#define MTYPES_H + +#define MAX_DRAW_BUFFERS 8 +#define MAX_VARYING 16 + +/** + * Indexes for vertex program attributes. + * GL_NV_vertex_program aliases generic attributes over the conventional + * attributes. In GL_ARB_vertex_program shader the aliasing is optional. + * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the + * generic attributes are distinct/separate). + */ +typedef enum +{ + VERT_ATTRIB_POS = 0, + VERT_ATTRIB_WEIGHT = 1, + VERT_ATTRIB_NORMAL = 2, + VERT_ATTRIB_COLOR0 = 3, + VERT_ATTRIB_COLOR1 = 4, + VERT_ATTRIB_FOG = 5, + VERT_ATTRIB_COLOR_INDEX = 6, + VERT_ATTRIB_POINT_SIZE = 6, /*alias*/ + VERT_ATTRIB_EDGEFLAG = 7, + VERT_ATTRIB_TEX0 = 8, + VERT_ATTRIB_TEX1 = 9, + VERT_ATTRIB_TEX2 = 10, + VERT_ATTRIB_TEX3 = 11, + VERT_ATTRIB_TEX4 = 12, + VERT_ATTRIB_TEX5 = 13, + VERT_ATTRIB_TEX6 = 14, + VERT_ATTRIB_TEX7 = 15, + VERT_ATTRIB_GENERIC0 = 16, + VERT_ATTRIB_GENERIC1 = 17, + VERT_ATTRIB_GENERIC2 = 18, + VERT_ATTRIB_GENERIC3 = 19, + VERT_ATTRIB_GENERIC4 = 20, + VERT_ATTRIB_GENERIC5 = 21, + VERT_ATTRIB_GENERIC6 = 22, + VERT_ATTRIB_GENERIC7 = 23, + VERT_ATTRIB_GENERIC8 = 24, + VERT_ATTRIB_GENERIC9 = 25, + VERT_ATTRIB_GENERIC10 = 26, + VERT_ATTRIB_GENERIC11 = 27, + VERT_ATTRIB_GENERIC12 = 28, + VERT_ATTRIB_GENERIC13 = 29, + VERT_ATTRIB_GENERIC14 = 30, + VERT_ATTRIB_GENERIC15 = 31, + VERT_ATTRIB_MAX = 32 +} gl_vert_attrib; + +/** + * Bitflags for vertex attributes. + * These are used in bitfields in many places. + */ +/*@{*/ +#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) +#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) +#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) +#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) +#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) +#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) +#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) +#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG) +#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) +#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) +#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) +#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) +#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) +#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) +#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) +#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) +#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) +#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) +#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) +#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) +#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) +#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) +#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) +#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) +#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) +#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) +#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) +#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) +#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) +#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) +#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) +#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) + +#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) +#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) +/*@}*/ + + +/** + * Indexes for vertex program result attributes + */ +typedef enum +{ + VERT_RESULT_HPOS = 0, + VERT_RESULT_COL0 = 1, + VERT_RESULT_COL1 = 2, + VERT_RESULT_FOGC = 3, + VERT_RESULT_TEX0 = 4, + VERT_RESULT_TEX1 = 5, + VERT_RESULT_TEX2 = 6, + VERT_RESULT_TEX3 = 7, + VERT_RESULT_TEX4 = 8, + VERT_RESULT_TEX5 = 9, + VERT_RESULT_TEX6 = 10, + VERT_RESULT_TEX7 = 11, + VERT_RESULT_PSIZ = 12, + VERT_RESULT_BFC0 = 13, + VERT_RESULT_BFC1 = 14, + VERT_RESULT_EDGE = 15, + VERT_RESULT_VAR0 = 16, /**< shader varying */ + VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) +} gl_vert_result; + + +/** + * Indexes for fragment program input attributes. + */ +typedef enum +{ + FRAG_ATTRIB_WPOS = 0, + FRAG_ATTRIB_COL0 = 1, + FRAG_ATTRIB_COL1 = 2, + FRAG_ATTRIB_FOGC = 3, + FRAG_ATTRIB_TEX0 = 4, + FRAG_ATTRIB_TEX1 = 5, + FRAG_ATTRIB_TEX2 = 6, + FRAG_ATTRIB_TEX3 = 7, + FRAG_ATTRIB_TEX4 = 8, + FRAG_ATTRIB_TEX5 = 9, + FRAG_ATTRIB_TEX6 = 10, + FRAG_ATTRIB_TEX7 = 11, + FRAG_ATTRIB_FACE = 12, /**< front/back face */ + FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ + FRAG_ATTRIB_VAR0 = 14, /**< shader varying */ + FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) +} gl_frag_attrib; + +/** + * Bitflags for fragment program input attributes. + */ +/*@{*/ +#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) +#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) +#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) +#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) +#define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE) +#define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC) +#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) +#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1) +#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2) +#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3) +#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4) +#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5) +#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6) +#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7) +#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0) + +#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U)) +#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V)) + +#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \ + FRAG_BIT_TEX1| \ + FRAG_BIT_TEX2| \ + FRAG_BIT_TEX3| \ + FRAG_BIT_TEX4| \ + FRAG_BIT_TEX5| \ + FRAG_BIT_TEX6| \ + FRAG_BIT_TEX7) +/*@}*/ + + +/** + * Fragment program results + */ +typedef enum +{ + FRAG_RESULT_DEPTH = 0, + FRAG_RESULT_COLOR = 1, + FRAG_RESULT_DATA0 = 2, + FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) +} gl_frag_result; + +#endif -- cgit v1.2.3 From 0ad22cd1cea76e4fdedfd45fb714d9f9c0fc9626 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 21 Jun 2010 17:18:31 -0700 Subject: linker: Initial implementation of attribute slot allocation --- linker.cpp | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/linker.cpp b/linker.cpp index 2285f01a0c4..314db0bb0f7 100644 --- a/linker.cpp +++ b/linker.cpp @@ -66,6 +66,7 @@ #include #include +#include "main/mtypes.h" #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" #include "ir.h" @@ -107,6 +108,24 @@ private: }; +void +invalidate_variable_locations(glsl_shader *sh, enum ir_variable_mode mode, + int generic_base) +{ + foreach_list(node, &sh->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != (unsigned) mode)) + continue; + + /* Only assign locations for generic attributes / varyings / etc. + */ + if (var->location >= generic_base) + var->location = -1; + } +} + + /** * Verify that a vertex shader executable meets all semantic requirements * @@ -415,6 +434,66 @@ assign_uniform_locations(struct glsl_program *prog) } +void +assign_attribute_locations(glsl_shader *sh, + struct gl_program_parameter_list *attrib) +{ + unsigned used_locations = 0; + + assert(sh->Type == GL_VERTEX_SHADER); + + /* Operate in a total of three passes. + * + * 1. Invalidate the location assignments for all vertex shader inputs. + * + * 2. Assign locations for inputs that have user-defined (via + * glBindVertexAttribLocation) locatoins. + * + * 3. Assign locations to any inputs without assigned locations. + */ + + invalidate_variable_locations(sh, ir_var_in, VERT_ATTRIB_GENERIC0); + + if (attrib != NULL) { + for (unsigned i = 0; i < attrib->NumParameters; i++) { + ir_variable *const var = + sh->symbols->get_variable(attrib->Parameters[i].Name); + + if (var == NULL) + continue; + + const int attr = attrib->Parameters[i].StateIndexes[0]; + + var->location = VERT_ATTRIB_GENERIC0 + attr; + used_locations |= (1 << attr); + } + } + + foreach_list(node, &sh->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_in)) + continue; + + /* The location was explicitly assigned, nothing to do here. + */ + if (var->location != -1) + continue; + + /* Find an unused bit in used_locations and assign that as the + * attribute location. + */ + for (unsigned i = 0; i < (8 * sizeof(used_locations)); i++) { + if ((used_locations & (1 << i)) == 0) { + var->location = VERT_ATTRIB_GENERIC0 + i; + used_locations |= (1 << i); + break; + } + } + } +} + + void link_shaders(struct glsl_program *prog) { @@ -493,7 +572,9 @@ link_shaders(struct glsl_program *prog) assign_uniform_locations(prog); - /* FINISHME: Assign vertex shader input locations. */ + if (prog->_LinkedShaders[0]->Type == GL_VERTEX_SHADER) + assign_attribute_locations(prog->_LinkedShaders[0], + prog->Attributes); /* FINISHME: Assign vertex shader output / fragment shader input * FINISHME: locations. -- cgit v1.2.3 From 6984670f97aa0668ccdc99891d2881dbd95103f8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 22 Jun 2010 17:29:19 -0700 Subject: linker: Support matrix and array vertex inputs --- linker.cpp | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 179 insertions(+), 15 deletions(-) diff --git a/linker.cpp b/linker.cpp index 314db0bb0f7..1f2cee172dd 100644 --- a/linker.cpp +++ b/linker.cpp @@ -126,6 +126,41 @@ invalidate_variable_locations(glsl_shader *sh, enum ir_variable_mode mode, } +/** + * Determine the number of attribute slots required for a particular type + * + * This code is here because it implements the language rules of a specific + * GLSL version. Since it's a property of the language and not a property of + * types in general, it doesn't really belong in glsl_type. + */ +unsigned +count_attribute_slots(const glsl_type *t) +{ + /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: + * + * "A scalar input counts the same amount against this limit as a vec4, + * so applications may want to consider packing groups of four + * unrelated float inputs together into a vector to better utilize the + * capabilities of the underlying hardware. A matrix input will use up + * multiple locations. The number of locations used will equal the + * number of columns in the matrix." + * + * The spec does not explicitly say how arrays are counted. However, it + * should be safe to assume the total number of slots consumed by an array + * is the number of entries in the array multiplied by the number of slots + * consumed by a single element of the array. + */ + + if (t->is_array()) + return t->array_size() * count_attribute_slots(t->element_type()); + + if (t->is_matrix()) + return t->matrix_columns; + + return 1; +} + + /** * Verify that a vertex shader executable meets all semantic requirements * @@ -434,7 +469,39 @@ assign_uniform_locations(struct glsl_program *prog) } -void +/** + * Find a contiguous set of available bits in a bitmask + * + * \param used_mask Bits representing used (1) and unused (0) locations + * \param needed_count Number of contiguous bits needed. + * + * \return + * Base location of the available bits on success or -1 on failure. + */ +int +find_available_slots(unsigned used_mask, unsigned needed_count) +{ + unsigned needed_mask = (1 << needed_count) - 1; + const int max_bit_to_test = (8 * sizeof(used_mask)) - needed_count; + + /* The comparison to 32 is redundant, but without it GCC emits "warning: + * cannot optimize possibly infinite loops" for the loop below. + */ + if ((needed_count == 0) || (max_bit_to_test < 0) || (max_bit_to_test > 32)) + return -1; + + for (int i = 0; i <= max_bit_to_test; i++) { + if ((needed_mask & ~used_mask) == needed_mask) + return i; + + needed_mask <<= 1; + } + + return -1; +} + + +bool assign_attribute_locations(glsl_shader *sh, struct gl_program_parameter_list *attrib) { @@ -442,14 +509,19 @@ assign_attribute_locations(glsl_shader *sh, assert(sh->Type == GL_VERTEX_SHADER); - /* Operate in a total of three passes. + /* Operate in a total of four passes. * * 1. Invalidate the location assignments for all vertex shader inputs. * * 2. Assign locations for inputs that have user-defined (via * glBindVertexAttribLocation) locatoins. * - * 3. Assign locations to any inputs without assigned locations. + * 3. Sort the attributes without assigned locations by number of slots + * required in decreasing order. Fragmentation caused by attribute + * locations assigned by the application may prevent large attributes + * from having enough contiguous space. + * + * 4. Assign locations to any inputs without assigned locations. */ invalidate_variable_locations(sh, ir_var_in, VERT_ATTRIB_GENERIC0); @@ -459,16 +531,84 @@ assign_attribute_locations(glsl_shader *sh, ir_variable *const var = sh->symbols->get_variable(attrib->Parameters[i].Name); - if (var == NULL) + /* Note: attributes that occupy multiple slots, such as arrays or + * matrices, may appear in the attrib array multiple times. + */ + if ((var == NULL) || (var->location != -1)) continue; + /* From page 61 of the OpenGL 4.0 spec: + * + * "LinkProgram will fail if the attribute bindings assigned by + * BindAttribLocation do not leave not enough space to assign a + * location for an active matrix attribute or an active attribute + * array, both of which require multiple contiguous generic + * attributes." + * + * Previous versions of the spec contain similar language but omit the + * bit about attribute arrays. + * + * Page 61 of the OpenGL 4.0 spec also says: + * + * "It is possible for an application to bind more than one + * attribute name to the same location. This is referred to as + * aliasing. This will only work if only one of the aliased + * attributes is active in the executable program, or if no path + * through the shader consumes more than one attribute of a set + * of attributes aliased to the same location. A link error can + * occur if the linker determines that every path through the + * shader consumes multiple aliased attributes, but + * implementations are not required to generate an error in this + * case." + * + * These two paragraphs are either somewhat contradictory, or I don't + * fully understand one or both of them. + */ + /* FINISHME: The code as currently written does not support attribute + * FINISHME: location aliasing (see comment above). + */ const int attr = attrib->Parameters[i].StateIndexes[0]; + const unsigned slots = count_attribute_slots(var->type); + + /* Mask representing the contiguous slots that will be used by this + * attribute. + */ + const unsigned use_mask = (1 << slots) - 1; + + /* Generate a link error if the set of bits requested for this + * attribute overlaps any previously allocated bits. + */ + if ((~(use_mask << attr) & used_locations) != used_locations) { + printf("error: insufficient contiguous attribute locations " + "available for vertex shader input `%s'", + var->name); + return false; + } var->location = VERT_ATTRIB_GENERIC0 + attr; - used_locations |= (1 << attr); + used_locations |= (use_mask << attr); } } + /* Temporary storage for the set of attributes that need locations assigned. + */ + struct temp_attr { + unsigned slots; + ir_variable *var; + + /* Used below in the call to qsort. */ + static int compare(const void *a, const void *b) + { + const temp_attr *const l = (const temp_attr *) a; + const temp_attr *const r = (const temp_attr *) b; + + /* Reversed because we want a descending order sort below. */ + return r->slots - l->slots; + } + } to_assign[16]; + + unsigned num_attr = 0; + foreach_list(node, &sh->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); @@ -480,17 +620,40 @@ assign_attribute_locations(glsl_shader *sh, if (var->location != -1) continue; - /* Find an unused bit in used_locations and assign that as the - * attribute location. + to_assign[num_attr].slots = count_attribute_slots(var->type); + to_assign[num_attr].var = var; + num_attr++; + } + + /* If all of the attributes were assigned locations by the application (or + * are built-in attributes with fixed locations), return early. This should + * be the common case. + */ + if (num_attr == 0) + return true; + + qsort(to_assign, num_attr, sizeof(to_assign[0]), temp_attr::compare); + + for (unsigned i = 0; i < num_attr; i++) { + /* Mask representing the contiguous slots that will be used by this + * attribute. */ - for (unsigned i = 0; i < (8 * sizeof(used_locations)); i++) { - if ((used_locations & (1 << i)) == 0) { - var->location = VERT_ATTRIB_GENERIC0 + i; - used_locations |= (1 << i); - break; - } + const unsigned use_mask = (1 << to_assign[i].slots) - 1; + + int location = find_available_slots(used_locations, to_assign[i].slots); + + if (location < 0) { + printf("error: insufficient contiguous attribute locations " + "available for vertex shader input `%s'", + to_assign[i].var->name); + return false; } + + to_assign[i].var->location = VERT_ATTRIB_GENERIC0 + location; + used_locations |= (use_mask << location); } + + return true; } @@ -573,8 +736,9 @@ link_shaders(struct glsl_program *prog) assign_uniform_locations(prog); if (prog->_LinkedShaders[0]->Type == GL_VERTEX_SHADER) - assign_attribute_locations(prog->_LinkedShaders[0], - prog->Attributes); + if (!assign_attribute_locations(prog->_LinkedShaders[0], + prog->Attributes)) + goto done; /* FINISHME: Assign vertex shader output / fragment shader input * FINISHME: locations. -- cgit v1.2.3 From 9342d269a4818bf18296b07baa98f577efd1735c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 22 Jun 2010 17:41:37 -0700 Subject: linker: Limit attribute allocation to MAX_VERTEX_ATTRIBS --- linker.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/linker.cpp b/linker.cpp index 1f2cee172dd..76c3e9de8aa 100644 --- a/linker.cpp +++ b/linker.cpp @@ -503,9 +503,13 @@ find_available_slots(unsigned used_mask, unsigned needed_count) bool assign_attribute_locations(glsl_shader *sh, - struct gl_program_parameter_list *attrib) + struct gl_program_parameter_list *attrib, + unsigned max_attribute_index) { - unsigned used_locations = 0; + /* Mark invalid attribute locations as being used. + */ + unsigned used_locations = (max_attribute_index >= 32) + ? ~0 : ~((1 << max_attribute_index) - 1); assert(sh->Type == GL_VERTEX_SHADER); @@ -736,8 +740,14 @@ link_shaders(struct glsl_program *prog) assign_uniform_locations(prog); if (prog->_LinkedShaders[0]->Type == GL_VERTEX_SHADER) + /* FINISHME: The value of the max_attribute_index parameter is + * FINISHME: implementation dependent based on the value of + * FINISHME: GL_MAX_VERTEX_ATTRIBS. GL_MAX_VERTEX_ATTRIBS must be + * FINISHME: at least 16, so hardcode 16 for now. + */ if (!assign_attribute_locations(prog->_LinkedShaders[0], - prog->Attributes)) + prog->Attributes, + 16)) goto done; /* FINISHME: Assign vertex shader output / fragment shader input -- cgit v1.2.3 From 0e59b2698a7609183221e1266c1209611040609a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 23 Jun 2010 11:23:01 -0700 Subject: linker: Initial implementation of varying slot allocation --- linker.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/linker.cpp b/linker.cpp index 76c3e9de8aa..500a329e7d6 100644 --- a/linker.cpp +++ b/linker.cpp @@ -661,6 +661,79 @@ assign_attribute_locations(glsl_shader *sh, } +void +assign_varying_locations(glsl_shader *producer, glsl_shader *consumer) +{ + /* FINISHME: Set dynamically when geometry shader support is added. */ + unsigned output_index = VERT_RESULT_VAR0; + unsigned input_index = FRAG_ATTRIB_VAR0; + + /* Operate in a total of three passes. + * + * 1. Assign locations for any matching inputs and outputs. + * + * 2. Mark output variables in the producer that do not have locations as + * not being outputs. This lets the optimizer eliminate them. + * + * 3. Mark input variables in the consumer that do not have locations as + * not being inputs. This lets the optimizer eliminate them. + */ + + invalidate_variable_locations(producer, ir_var_out, VERT_RESULT_VAR0); + invalidate_variable_locations(consumer, ir_var_in, FRAG_ATTRIB_VAR0); + + foreach_list(node, &producer->ir) { + ir_variable *const output_var = ((ir_instruction *) node)->as_variable(); + + if ((output_var == NULL) || (output_var->mode != ir_var_out) + || (output_var->location != -1)) + continue; + + ir_variable *const input_var = + consumer->symbols->get_variable(output_var->name); + + if ((input_var == NULL) || (input_var->mode != ir_var_in)) + continue; + + assert(input_var->location == -1); + + /* FINISHME: Location assignment will need some changes when arrays, + * FINISHME: matrices, and structures are allowed as shader inputs / + * FINISHME: outputs. + */ + output_var->location = output_index; + input_var->location = input_index; + + output_index++; + input_index++; + } + + foreach_list(node, &producer->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_out)) + continue; + + /* An 'out' variable is only really a shader output if its value is read + * by the following stage. + */ + var->shader_out = (var->location != -1); + } + + foreach_list(node, &consumer->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_in)) + continue; + + /* An 'in' variable is only really a shader input if its value is written + * by the previous stage. + */ + var->shader_in = (var->location != -1); + } +} + + void link_shaders(struct glsl_program *prog) { @@ -750,9 +823,9 @@ link_shaders(struct glsl_program *prog) 16)) goto done; - /* FINISHME: Assign vertex shader output / fragment shader input - * FINISHME: locations. - */ + for (unsigned i = 1; i < prog->_NumLinkedShaders; i++) + assign_varying_locations(prog->_LinkedShaders[i - 1], + prog->_LinkedShaders[i]); /* FINISHME: Assign fragment shader output locations. */ -- cgit v1.2.3 From f36460e1a7de3bd311135673b3d5b60f3a8655da Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 23 Jun 2010 12:07:22 -0700 Subject: linker: Write errors to info log instead of stdout --- linker.cpp | 132 +++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 84 insertions(+), 48 deletions(-) diff --git a/linker.cpp b/linker.cpp index 500a329e7d6..4d1ff0167e8 100644 --- a/linker.cpp +++ b/linker.cpp @@ -65,6 +65,11 @@ */ #include #include +#include + +extern "C" { +#include +} #include "main/mtypes.h" #include "glsl_symbol_table.h" @@ -108,6 +113,18 @@ private: }; +void +linker_error_printf(glsl_program *prog, const char *fmt, ...) +{ + va_list ap; + + prog->InfoLog = talloc_strdup_append(prog->InfoLog, "error: "); + va_start(ap, fmt); + prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, ap); + va_end(ap); +} + + void invalidate_variable_locations(glsl_shader *sh, enum ir_variable_mode mode, int generic_base) @@ -167,20 +184,22 @@ count_attribute_slots(const glsl_type *t) * \param shader Vertex shader executable to be verified */ bool -validate_vertex_shader_executable(struct glsl_shader *shader) +validate_vertex_shader_executable(struct glsl_program *prog, + struct glsl_shader *shader) { if (shader == NULL) return true; if (!shader->symbols->get_function("main")) { - printf("error: vertex shader lacks `main'\n"); + linker_error_printf(prog, "vertex shader lacks `main'\n"); return false; } find_assignment_visitor find("gl_Position"); find.run(&shader->ir); if (!find.variable_found()) { - printf("error: vertex shader does not write to `gl_Position'\n"); + linker_error_printf(prog, + "vertex shader does not write to `gl_Position'\n"); return false; } @@ -194,13 +213,14 @@ validate_vertex_shader_executable(struct glsl_shader *shader) * \param shader Fragment shader executable to be verified */ bool -validate_fragment_shader_executable(struct glsl_shader *shader) +validate_fragment_shader_executable(struct glsl_program *prog, + struct glsl_shader *shader) { if (shader == NULL) return true; if (!shader->symbols->get_function("main")) { - printf("error: fragment shader lacks `main'\n"); + linker_error_printf(prog, "fragment shader lacks `main'\n"); return false; } @@ -211,14 +231,14 @@ validate_fragment_shader_executable(struct glsl_shader *shader) frag_data.run(&shader->ir); if (!frag_color.variable_found() && !frag_data.variable_found()) { - printf("error: fragment shader does not write to `gl_FragColor' or " - "`gl_FragData'\n"); + linker_error_printf(prog, "fragment shader does not write to " + "`gl_FragColor' or `gl_FragData'\n"); return false; } if (frag_color.variable_found() && frag_data.variable_found()) { - printf("error: fragment shader write to both `gl_FragColor' and " - "`gl_FragData'\n"); + linker_error_printf(prog, "fragment shader writes to both " + "`gl_FragColor' and `gl_FragData'\n"); return false; } @@ -230,7 +250,8 @@ validate_fragment_shader_executable(struct glsl_shader *shader) * Perform validation of uniforms used across multiple shader stages */ bool -cross_validate_uniforms(struct glsl_shader **shaders, unsigned num_shaders) +cross_validate_uniforms(struct glsl_program *prog, + struct glsl_shader **shaders, unsigned num_shaders) { /* Examine all of the uniforms in all of the shaders and cross validate * them. @@ -250,18 +271,19 @@ cross_validate_uniforms(struct glsl_shader **shaders, unsigned num_shaders) ir_variable *const existing = uniforms.get_variable(var->name); if (existing != NULL) { if (var->type != existing->type) { - printf("error: uniform `%s' declared as type `%s' and " - "type `%s'\n", - var->name, var->type->name, existing->type->name); + linker_error_printf(prog, "uniform `%s' declared as type " + "`%s' and type `%s'\n", + var->name, var->type->name, + existing->type->name); return false; } if (var->constant_value != NULL) { if (existing->constant_value != NULL) { if (!var->constant_value->has_value(existing->constant_value)) { - printf("error: initializers for uniform `%s' have " - "differing values\n", - var->name); + linker_error_printf(prog, "initializers for uniform " + "`%s' have differing values\n", + var->name); return false; } } else @@ -284,7 +306,8 @@ cross_validate_uniforms(struct glsl_shader **shaders, unsigned num_shaders) * Validate that outputs from one stage match inputs of another */ bool -cross_validate_outputs_to_inputs(glsl_shader *producer, glsl_shader *consumer) +cross_validate_outputs_to_inputs(struct glsl_program *prog, + glsl_shader *producer, glsl_shader *consumer) { glsl_symbol_table parameters; /* FINISHME: Figure these out dynamically. */ @@ -324,47 +347,53 @@ cross_validate_outputs_to_inputs(glsl_shader *producer, glsl_shader *consumer) /* Check that the types match between stages. */ if (input->type != output->type) { - printf("error: %s shader output `%s' delcared as type `%s', but " - "%s shader input declared as type `%s'\n", - producer_stage, output->name, output->type->name, - consumer_stage, input->type->name); + linker_error_printf(prog, + "%s shader output `%s' delcared as " + "type `%s', but %s shader input declared " + "as type `%s'\n", + producer_stage, output->name, + output->type->name, + consumer_stage, input->type->name); return false; } /* Check that all of the qualifiers match between stages. */ if (input->centroid != output->centroid) { - printf("error: %s shader output `%s' %s centroid qualifier, but " - "%s shader input %s centroid qualifier\n", - producer_stage, - output->name, - (output->centroid) ? "has" : "lacks", - consumer_stage, - (input->centroid) ? "has" : "lacks"); + linker_error_printf(prog, + "%s shader output `%s' %s centroid qualifier, " + "but %s shader input %s centroid qualifier\n", + producer_stage, + output->name, + (output->centroid) ? "has" : "lacks", + consumer_stage, + (input->centroid) ? "has" : "lacks"); return false; } if (input->invariant != output->invariant) { - printf("error: %s shader output `%s' %s invariant qualifier, but " - "%s shader input %s invariant qualifier\n", - producer_stage, - output->name, - (output->invariant) ? "has" : "lacks", - consumer_stage, - (input->invariant) ? "has" : "lacks"); + linker_error_printf(prog, + "%s shader output `%s' %s invariant qualifier, " + "but %s shader input %s invariant qualifier\n", + producer_stage, + output->name, + (output->invariant) ? "has" : "lacks", + consumer_stage, + (input->invariant) ? "has" : "lacks"); return false; } if (input->interpolation != output->interpolation) { - printf("error: %s shader output `%s' specifies %s interpolation " - "qualifier, " - "but %s shader input specifies %s interpolation " - "qualifier\n", - producer_stage, - output->name, - output->interpolation_string(), - consumer_stage, - input->interpolation_string()); + linker_error_printf(prog, + "%s shader output `%s' specifies %s " + "interpolation qualifier, " + "but %s shader input specifies %s " + "interpolation qualifier\n", + producer_stage, + output->name, + output->interpolation_string(), + consumer_stage, + input->interpolation_string()); return false; } } @@ -741,6 +770,11 @@ link_shaders(struct glsl_program *prog) prog->Validated = false; prog->_Used = false; + if (prog->InfoLog != NULL) + talloc_free(prog->InfoLog); + + prog->InfoLog = talloc_strdup(NULL, ""); + /* Separate the shaders into groups based on their type. */ struct glsl_shader **vert_shader_list; @@ -775,8 +809,8 @@ link_shaders(struct glsl_program *prog) /* Verify that each of the per-target executables is valid. */ - if (!validate_vertex_shader_executable(vert_shader_list[0]) - || !validate_fragment_shader_executable(frag_shader_list[0])) + if (!validate_vertex_shader_executable(prog, vert_shader_list[0]) + || !validate_fragment_shader_executable(prog, frag_shader_list[0])) goto done; @@ -795,12 +829,14 @@ link_shaders(struct glsl_program *prog) prog->_NumLinkedShaders++; } - if (cross_validate_uniforms(prog->_LinkedShaders, prog->_NumLinkedShaders)) { + if (cross_validate_uniforms(prog, prog->_LinkedShaders, + prog->_NumLinkedShaders)) { /* Validate the inputs of each stage with the output of the preceeding * stage. */ for (unsigned i = 1; i < prog->_NumLinkedShaders; i++) { - if (!cross_validate_outputs_to_inputs(prog->_LinkedShaders[i - 1], + if (!cross_validate_outputs_to_inputs(prog, + prog->_LinkedShaders[i - 1], prog->_LinkedShaders[i])) goto done; } -- cgit v1.2.3 From ed1fe3db3b871a6aa48d49b46fa22938b2784bdc Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 23 Jun 2010 12:09:14 -0700 Subject: linker: Refactor parameters to cross_validate_uniforms --- linker.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/linker.cpp b/linker.cpp index 4d1ff0167e8..bdc4c5765a6 100644 --- a/linker.cpp +++ b/linker.cpp @@ -250,15 +250,14 @@ validate_fragment_shader_executable(struct glsl_program *prog, * Perform validation of uniforms used across multiple shader stages */ bool -cross_validate_uniforms(struct glsl_program *prog, - struct glsl_shader **shaders, unsigned num_shaders) +cross_validate_uniforms(struct glsl_program *prog) { /* Examine all of the uniforms in all of the shaders and cross validate * them. */ glsl_symbol_table uniforms; - for (unsigned i = 0; i < num_shaders; i++) { - foreach_list(node, &shaders[i]->ir) { + for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { + foreach_list(node, &prog->_LinkedShaders[i]->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); if ((var == NULL) || (var->mode != ir_var_uniform)) @@ -829,8 +828,7 @@ link_shaders(struct glsl_program *prog) prog->_NumLinkedShaders++; } - if (cross_validate_uniforms(prog, prog->_LinkedShaders, - prog->_NumLinkedShaders)) { + if (cross_validate_uniforms(prog)) { /* Validate the inputs of each stage with the output of the preceeding * stage. */ -- cgit v1.2.3 From 553dcdcaaffa33dd62d38081a1a18af8d896a1a6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 23 Jun 2010 12:14:02 -0700 Subject: linker: Use InfoLog in assign_attribute_locations Since the program is now passed in, refactor the parameter list to the function as well. --- linker.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/linker.cpp b/linker.cpp index bdc4c5765a6..ebb1a81e7c9 100644 --- a/linker.cpp +++ b/linker.cpp @@ -530,15 +530,14 @@ find_available_slots(unsigned used_mask, unsigned needed_count) bool -assign_attribute_locations(glsl_shader *sh, - struct gl_program_parameter_list *attrib, - unsigned max_attribute_index) +assign_attribute_locations(glsl_program *prog, unsigned max_attribute_index) { /* Mark invalid attribute locations as being used. */ unsigned used_locations = (max_attribute_index >= 32) ? ~0 : ~((1 << max_attribute_index) - 1); + glsl_shader *const sh = prog->_LinkedShaders[0]; assert(sh->Type == GL_VERTEX_SHADER); /* Operate in a total of four passes. @@ -558,10 +557,10 @@ assign_attribute_locations(glsl_shader *sh, invalidate_variable_locations(sh, ir_var_in, VERT_ATTRIB_GENERIC0); - if (attrib != NULL) { - for (unsigned i = 0; i < attrib->NumParameters; i++) { + if (prog->Attributes != NULL) { + for (unsigned i = 0; i < prog->Attributes->NumParameters; i++) { ir_variable *const var = - sh->symbols->get_variable(attrib->Parameters[i].Name); + sh->symbols->get_variable(prog->Attributes->Parameters[i].Name); /* Note: attributes that occupy multiple slots, such as arrays or * matrices, may appear in the attrib array multiple times. @@ -599,7 +598,7 @@ assign_attribute_locations(glsl_shader *sh, /* FINISHME: The code as currently written does not support attribute * FINISHME: location aliasing (see comment above). */ - const int attr = attrib->Parameters[i].StateIndexes[0]; + const int attr = prog->Attributes->Parameters[i].StateIndexes[0]; const unsigned slots = count_attribute_slots(var->type); /* Mask representing the contiguous slots that will be used by this @@ -611,9 +610,10 @@ assign_attribute_locations(glsl_shader *sh, * attribute overlaps any previously allocated bits. */ if ((~(use_mask << attr) & used_locations) != used_locations) { - printf("error: insufficient contiguous attribute locations " - "available for vertex shader input `%s'", - var->name); + linker_error_printf(prog, + "insufficient contiguous attribute locations " + "available for vertex shader input `%s'", + var->name); return false; } @@ -675,9 +675,10 @@ assign_attribute_locations(glsl_shader *sh, int location = find_available_slots(used_locations, to_assign[i].slots); if (location < 0) { - printf("error: insufficient contiguous attribute locations " - "available for vertex shader input `%s'", - to_assign[i].var->name); + linker_error_printf(prog, + "insufficient contiguous attribute locations " + "available for vertex shader input `%s'", + to_assign[i].var->name); return false; } @@ -852,9 +853,7 @@ link_shaders(struct glsl_program *prog) * FINISHME: GL_MAX_VERTEX_ATTRIBS. GL_MAX_VERTEX_ATTRIBS must be * FINISHME: at least 16, so hardcode 16 for now. */ - if (!assign_attribute_locations(prog->_LinkedShaders[0], - prog->Attributes, - 16)) + if (!assign_attribute_locations(prog, 16)) goto done; for (unsigned i = 1; i < prog->_NumLinkedShaders; i++) -- cgit v1.2.3 From 3ed850e91c4aa4b520c1b7dd9c7e1eecd926bce7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 23 Jun 2010 12:18:21 -0700 Subject: linker: Update some comments, remove a couple FINISHMEs --- linker.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/linker.cpp b/linker.cpp index ebb1a81e7c9..abf5371ce90 100644 --- a/linker.cpp +++ b/linker.cpp @@ -814,7 +814,6 @@ link_shaders(struct glsl_program *prog) goto done; - /* FINISHME: Perform inter-stage linking. */ prog->_LinkedShaders = (struct glsl_shader **) calloc(2, sizeof(struct glsl_shader *)); prog->_NumLinkedShaders = 0; @@ -829,6 +828,10 @@ link_shaders(struct glsl_program *prog) prog->_NumLinkedShaders++; } + /* Here begins the inter-stage linking phase. Some initial validation is + * performed, then locations are assigned for uniforms, attributes, and + * varyings. + */ if (cross_validate_uniforms(prog)) { /* Validate the inputs of each stage with the output of the preceeding * stage. @@ -862,8 +865,6 @@ link_shaders(struct glsl_program *prog) /* FINISHME: Assign fragment shader output locations. */ - /* FINISHME: Generate code here. */ - done: free(vert_shader_list); } -- cgit v1.2.3 From fa455fc2a529d26a0e03b9ff837a554c511cee71 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 23 Jun 2010 13:58:34 -0700 Subject: Generate errors for empty constructors instead of asserting This causes the following tests to pass: glslparsertest/glsl2/constructor-10.vert --- ast_function.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ast_function.cpp b/ast_function.cpp index 691e6aeba00..ff2dfa502f3 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -513,7 +513,14 @@ ast_function_expression::hir(exec_list *instructions, bool all_parameters_are_constant = true; - assert(!this->expressions.is_empty()); + /* This handles invalid constructor calls such as 'vec4 v = vec4();' + */ + if (this->expressions.is_empty()) { + _mesa_glsl_error(& loc, state, "too few components to construct " + "`%s'", + constructor_type->name); + return ir_call::get_error_instruction(); + } foreach_list (n, &this->expressions) { ast_node *ast = exec_node_data(ast_node, n, link); -- cgit v1.2.3 From e6ae7afc0cf41922fdbdd45b7a433cc450424c87 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 21 Jun 2010 15:11:01 -0700 Subject: glcpp: Recognize plain "//" as a comment. Found in glsl-orangebook-ch06-bump.(frag|vert). This was resulting in the comments getting passed through to the main compiler's lexer. --- glcpp/glcpp-lex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index 0dea9950015..fabe7566030 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -60,7 +60,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? %% /* Single-line comments */ -"//"[^\n]+\n { +"//"[^\n]*\n { yylineno++; yycolumn = 0; return NEWLINE; -- cgit v1.2.3 From d07bb7b83a664717009c40bd940b3025f4bb96a7 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 21 Jun 2010 15:12:34 -0700 Subject: Remove comment support from the main lexer. Now handled by the preprocessor. --- glsl_lexer.lpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index 9a3037a8ff5..c15c99c4b06 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -41,9 +41,8 @@ %option never-interactive %option prefix="_mesa_glsl_" %option extra-type="struct _mesa_glsl_parse_state *" -%option stack -%x PP COMMENT +%x PP DEC_INT [1-9][0-9]* HEX_INT 0[xX][0-9a-fA-F]+ @@ -54,14 +53,6 @@ SPCP [ \t]+ HASH ^{SPC}#{SPC} %% -"/*" { yy_push_state(COMMENT, yyscanner); } -[^*\n]* -[^*\n]*\n { yylineno++; yycolumn = 0; } -"*"+[^*/\n]* -"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; } -"*"+"/" { yy_pop_state(yyscanner); } - -\/\/.*\n { yylineno++; yycolumn = 0; } [ \r\t]+ ; /* Preprocessor tokens. */ -- cgit v1.2.3 From 12a820c9d84cec0e2f36d9571ca841499b67eac4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 21 Jun 2010 15:15:34 -0700 Subject: glcpp: Fix "dangerous trailing context" warning. Flex couldn't be sure whether "def" and "ndef" were part of the #ifdef and #ifndef patterns or the trailing context of the #if pattern. --- glcpp/glcpp-lex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l index fabe7566030..afddd7ddb32 100644 --- a/glcpp/glcpp-lex.l +++ b/glcpp/glcpp-lex.l @@ -97,7 +97,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return HASH_IFNDEF; } -{HASH}if/.*\n { +{HASH}if{HSPACE}/.*\n { yyextra->lexing_if = 1; yyextra->space_tokens = 0; return HASH_IF; -- cgit v1.2.3 From 186e2634bfb8f624f3721673964e29428269cd47 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 23 Jun 2010 14:00:27 -0700 Subject: glcpp: Make standalone binary use preprocess(). This prevents the two code paths from getting out of sync. Also, future work will need the shader source as a string anyway. Unfortunately, this copies and pastes load_text_file from main.cpp, with small changes (support for reading from stdin, talloc). --- glcpp/glcpp.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- glcpp/glcpp.h | 3 +++ 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/glcpp/glcpp.c b/glcpp/glcpp.c index 8ba4661f784..cc87e14950b 100644 --- a/glcpp/glcpp.c +++ b/glcpp/glcpp.c @@ -21,24 +21,68 @@ * DEALINGS IN THE SOFTWARE. */ +#include +#include +#include +#include #include "glcpp.h" extern int yydebug; -int -main (void) +static char * +load_text_file(void *ctx, const char *file_name) { - glcpp_parser_t *parser; - int ret; + char *text = NULL; + struct stat st; + ssize_t total_read = 0; + int fd = file_name == NULL ? STDIN_FILENO : open(file_name, O_RDONLY); + + if (fd < 0) { + 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) { + text = NULL; + break; + } + + if (bytes == 0) { + break; + } + + total_read += bytes; + } while (total_read < st.st_size); + + text[total_read] = '\0'; + } + } - parser = glcpp_parser_create (); + close(fd); - ret = glcpp_parser_parse (parser); + return text; +} + +int +preprocess(void *talloc_ctx, const char **shader, char **info_log); + +int +main (void) +{ + void *ctx = talloc(NULL, void*); + const char *shader = load_text_file(ctx, NULL); + char *info_log = talloc_strdup(ctx, ""); + int ret = preprocess(ctx, &shader, &info_log); - printf("%s", parser->output); - fprintf(stderr, "%s", parser->info_log); + printf("%s", shader); + fprintf(stderr, "%s", info_log); - glcpp_parser_destroy (parser); + talloc_free(ctx); return ret; } diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h index bb0ac95aedf..2cfa98d2b1d 100644 --- a/glcpp/glcpp.h +++ b/glcpp/glcpp.h @@ -167,6 +167,9 @@ glcpp_parser_parse (glcpp_parser_t *parser); void glcpp_parser_destroy (glcpp_parser_t *parser); +int +preprocess(void *talloc_ctx, const char **shader, char **info_log); + /* Functions for writing to the info log */ void -- cgit v1.2.3 From bc1097d151677ace501a1f78c11e40ed5b80fdc6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 23 Jun 2010 12:31:09 -0700 Subject: glcpp: Support line continuations within preprocessor directives. Fixes CorrectPreprocess5.frag. --- glcpp/pp.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/glcpp/pp.c b/glcpp/pp.c index 5455518c7c7..a25b7b72a6b 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -21,6 +21,8 @@ * DEALINGS IN THE SOFTWARE. */ +#include +#include #include "glcpp.h" void @@ -56,11 +58,88 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) parser->info_log = talloc_strdup_append(parser->info_log, "\n"); } +/* Searches backwards for '^ *#' from a given starting point. */ +static int +in_directive(const char *shader, const char *ptr) +{ + assert(ptr >= shader); + + /* Search backwards for '#'. If we find a \n first, it doesn't count */ + for (; ptr >= shader && *ptr != '#'; ptr--) { + if (*ptr == '\n') + return 0; + } + if (ptr >= shader) { + /* Found '#'...look for spaces preceded by a newline */ + for (ptr--; ptr >= shader && isblank(*ptr); ptr--); + // FIXME: I don't think the '\n' case can happen + if (ptr < shader || *ptr == '\n') + return 1; + } + return 0; +} + +/* Remove any line continuation characters in preprocessing directives. + * However, ignore any in GLSL code, as "There is no line continuation + * character" (1.30 page 9) in GLSL. + */ +static char * +remove_line_continuations(glcpp_parser_t *ctx, const char *shader) +{ + int in_continued_line = 0; + int extra_newlines = 0; + char *clean = talloc_strdup(ctx, ""); + const char *search_start = shader; + const char *newline; + while ((newline = strchr(search_start, '\n')) != NULL) { + const char *backslash = NULL; + /* Find the preceding '\', if it exists */ + if (newline[-1] == '\\') { + backslash = newline - 1; + } else if (newline[-1] == '\r' && newline[-2] == '\\') { + backslash = newline - 2; + } + /* Double backslashes don't count (the backslash is escaped) */ + if (backslash != NULL && backslash[-1] == '\\') { + backslash = NULL; + } + + if (backslash != NULL) { + /* We found a line continuation, but do we care? */ + if (!in_continued_line) { + if (in_directive(shader, backslash)) { + in_continued_line = 1; + extra_newlines = 0; + } + } + if (in_continued_line) { + /* Copy everything before the \ */ + clean = talloc_strndup_append(clean, shader, backslash - shader); + shader = newline + 1; + extra_newlines++; + } + } else if (in_continued_line) { + /* Copy everything up to and including the \n */ + clean = talloc_strndup_append(clean, shader, newline - shader + 1); + shader = newline + 1; + /* Output extra newlines to make line numbers match */ + for (; extra_newlines > 0; extra_newlines--) + clean = talloc_strdup_append(clean, "\n"); + in_continued_line = 0; + } + search_start = newline + 1; + } + clean = talloc_strdup_append(clean, shader); + return clean; +} + extern int preprocess(void *talloc_ctx, const char **shader, char **info_log) { int errors; glcpp_parser_t *parser = glcpp_parser_create (); + *shader = remove_line_continuations(parser, *shader); + glcpp_lex_set_source_string (parser, *shader); glcpp_parser_parse (parser); -- cgit v1.2.3 From 02fc4b34e40f655eebc99f6502293b4d4000e0b3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 23 Jun 2010 14:33:30 -0700 Subject: Avoid using the same ir_constant 0.0 multiple times in mat constructors. --- glsl_types.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/glsl_types.cpp b/glsl_types.cpp index 2b7c5bce30f..ca19de6bec3 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -359,10 +359,9 @@ generate_mat_body_from_scalar(exec_list *instructions, inst = new ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); - ir_constant *const zero = new ir_constant(0.0f); - for (unsigned i = 1; i < column_type->vector_elements; i++) { ir_dereference *const lhs_ref = new ir_dereference_variable(column); + ir_constant *const zero = new ir_constant(0.0f); ir_swizzle *lhs = new ir_swizzle(lhs_ref, i, 0, 0, 0, 1); -- cgit v1.2.3 From 4b6fd39c89f308a379882426c1ed3616d60c4628 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 23 Jun 2010 11:37:12 -0700 Subject: Add a virtual clone() method to ir_instruction. This will be used by function inlining, the linker, and avoiding double usage of the LHS deref chains in ++, *=, and similar operations. --- Makefile.am | 1 + ast_to_hir.cpp | 5 +- ir.cpp | 6 +- ir.h | 73 +++++------ ir_clone.cpp | 240 +++++++++++++++++++++++++++++++++++++ ir_constant_expression.cpp | 2 +- ir_function_inlining.cpp | 293 ++------------------------------------------- ir_print_visitor.cpp | 6 +- ir_reader.cpp | 4 +- linker.cpp | 3 +- 10 files changed, 305 insertions(+), 328 deletions(-) create mode 100644 ir_clone.cpp diff --git a/Makefile.am b/Makefile.am index b65b8bab526..a88bf0022ad 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,6 +38,7 @@ glsl_SOURCES = \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \ ir_basic_block.cpp \ ir_basic_block.h \ + ir_clone.cpp \ ir_constant_expression.cpp \ ir_constant_folding.cpp \ ir_constant_variable.cpp \ diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index aa90d4b6631..b4692c69228 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2171,8 +2171,7 @@ ast_jump_statement::hir(exec_list *instructions, if (loop != NULL) { ir_loop_jump *const jump = - new ir_loop_jump(loop, - (mode == ast_break) + new ir_loop_jump((mode == ast_break) ? ir_loop_jump::jump_break : ir_loop_jump::jump_continue); instructions->push_tail(jump); @@ -2251,7 +2250,7 @@ ast_iteration_statement::condition_to_hir(ir_loop *stmt, ir_if *const if_stmt = new ir_if(not_cond); ir_jump *const break_stmt = - new ir_loop_jump(stmt, ir_loop_jump::jump_break); + new ir_loop_jump(ir_loop_jump::jump_break); if_stmt->then_instructions.push_tail(break_stmt); stmt->body_instructions.push_tail(if_stmt); diff --git a/ir.cpp b/ir.cpp index 49191fb9295..95142016007 100644 --- a/ir.cpp +++ b/ir.cpp @@ -297,8 +297,8 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) } } -ir_constant * -ir_constant::clone() +ir_instruction * +ir_constant::clone(struct hash_table *ht) const { switch (this->type->base_type) { case GLSL_TYPE_UINT: @@ -316,7 +316,7 @@ ir_constant::clone() ; node = node->next) { ir_constant *const orig = (ir_constant *) node; - c->components.push_tail(orig->clone()); + c->components.push_tail(orig->clone(NULL)); } return c; diff --git a/ir.h b/ir.h index 9cbe11505a6..f3402a38a16 100644 --- a/ir.h +++ b/ir.h @@ -47,10 +47,11 @@ public: class ir_constant *constant_expression_value(); /** ir_print_visitor helper for debugging. */ - void print(void); + void print(void) const; virtual void accept(ir_visitor *) = 0; virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0; + virtual ir_instruction *clone(struct hash_table *ht) const = 0; /** * \name IR instruction downcast functions @@ -144,6 +145,8 @@ class ir_variable : public ir_instruction { public: ir_variable(const struct glsl_type *, const char *); + virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_variable *as_variable() { return this; @@ -156,26 +159,6 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - /** - * Duplicate an IR variable - * - * \note - * This will probably be made \c virtual and moved to the base class - * eventually. - */ - ir_variable *clone() const - { - ir_variable *var = new ir_variable(type, name); - - var->max_array_access = this->max_array_access; - var->read_only = this->read_only; - var->centroid = this->centroid; - var->invariant = this->invariant; - var->mode = this->mode; - var->interpolation = this->interpolation; - - return var; - } /** * Get the string value for the interpolation qualifier @@ -266,6 +249,8 @@ class ir_function_signature : public ir_instruction { public: ir_function_signature(const glsl_type *return_type); + virtual ir_instruction *clone(struct hash_table *ht) const; + virtual void accept(ir_visitor *v) { v->visit(this); @@ -330,6 +315,8 @@ class ir_function : public ir_instruction { public: ir_function(const char *name); + virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_function *as_function() { return this; @@ -398,6 +385,8 @@ public: /* empty */ } + virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_if *as_if() { return this; @@ -428,6 +417,8 @@ public: /* empty */ } + virtual ir_instruction *clone(struct hash_table *ht) const; + virtual void accept(ir_visitor *v) { v->visit(this); @@ -467,6 +458,8 @@ class ir_assignment : public ir_rvalue { public: ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); + virtual ir_instruction *clone(struct hash_table *ht) const; + virtual void accept(ir_visitor *v) { v->visit(this); @@ -589,8 +582,10 @@ public: ir_expression(int op, const struct glsl_type *type, ir_rvalue *, ir_rvalue *); + virtual ir_instruction *clone(struct hash_table *ht) const; + static unsigned int get_num_operands(ir_expression_operation); - unsigned int get_num_operands() + unsigned int get_num_operands() const { return get_num_operands(operation); } @@ -612,8 +607,6 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - ir_expression *clone(); - ir_expression_operation operation; ir_rvalue *operands[2]; }; @@ -632,6 +625,8 @@ public: actual_parameters->move_nodes_to(& this->actual_parameters); } + virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_call *as_call() { return this; @@ -718,6 +713,8 @@ public: /* empty */ } + virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_return *as_return() { return this; @@ -754,12 +751,14 @@ public: jump_continue }; - ir_loop_jump(ir_loop *loop, jump_mode mode) - : loop(loop), mode(mode) + ir_loop_jump(jump_mode mode) + : mode(mode) { /* empty */ } + virtual ir_instruction *clone(struct hash_table *) const; + virtual void accept(ir_visitor *v) { v->visit(this); @@ -778,9 +777,6 @@ public: } private: - /** Loop containing this break instruction. */ - ir_loop *loop; - /** Mode selector for the jump instruction. */ enum jump_mode mode; }; @@ -825,6 +821,8 @@ public: /* empty */ } + virtual ir_instruction *clone(struct hash_table *) const; + virtual void accept(ir_visitor *v) { v->visit(this); @@ -910,16 +908,13 @@ public: unsigned count); ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask); + virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_swizzle *as_swizzle() { return this; } - ir_swizzle *clone() - { - return new ir_swizzle(this->val, this->mask); - } - /** * Construct an ir_swizzle from the textual representation. Can fail. */ @@ -967,6 +962,8 @@ class ir_dereference_variable : public ir_dereference { public: ir_dereference_variable(ir_variable *var); + virtual ir_instruction *clone(struct hash_table *) const; + /** * Get the variable that is ultimately referenced by an r-value */ @@ -1006,6 +1003,8 @@ public: ir_dereference_array(ir_variable *var, ir_rvalue *array_index); + virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_dereference_array *as_dereference_array() { return this; @@ -1040,6 +1039,8 @@ public: ir_dereference_record(ir_variable *var, const char *field); + virtual ir_instruction *clone(struct hash_table *) const; + /** * Get the variable that is ultimately referenced by an r-value */ @@ -1096,6 +1097,8 @@ public: */ ir_constant(const ir_constant *c, unsigned i); + virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_constant *as_constant() { return this; @@ -1108,8 +1111,6 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - ir_constant *clone(); - /** * Get a particular component of a constant as a specific type * diff --git a/ir_clone.cpp b/ir_clone.cpp new file mode 100644 index 00000000000..c810fe86164 --- /dev/null +++ b/ir_clone.cpp @@ -0,0 +1,240 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "ir.h" +#include "glsl_types.h" +#include "hash_table.h" + +/** + * Duplicate an IR variable + * + * \note + * This will probably be made \c virtual and moved to the base class + * eventually. + */ +ir_instruction * +ir_variable::clone(struct hash_table *ht) const +{ + ir_variable *var = new ir_variable(type, name); + + var->max_array_access = this->max_array_access; + var->read_only = this->read_only; + var->centroid = this->centroid; + var->invariant = this->invariant; + var->mode = this->mode; + var->interpolation = this->interpolation; + + if (ht) { + hash_table_insert(ht, (void *)const_cast(this), var); + } + + return var; +} + +ir_instruction * +ir_swizzle::clone(struct hash_table *ht) const +{ + return new ir_swizzle((ir_rvalue *)this->val->clone(ht), this->mask); +} + +ir_instruction * +ir_return::clone(struct hash_table *ht) const +{ + ir_rvalue *new_value = NULL; + + if (this->value) + new_value = (ir_rvalue *)this->value->clone(ht); + + return new ir_return(new_value); +} + +ir_instruction * +ir_loop_jump::clone(struct hash_table *ht) const +{ + (void)ht; + + return new ir_loop_jump(this->mode); +} + +ir_instruction * +ir_if::clone(struct hash_table *ht) const +{ + ir_if *new_if = new ir_if((ir_rvalue *)this->condition->clone(ht)); + + foreach_iter(exec_list_iterator, iter, this->then_instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_if->then_instructions.push_tail(ir->clone(ht)); + } + + foreach_iter(exec_list_iterator, iter, this->else_instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_if->else_instructions.push_tail(ir->clone(ht)); + } + + return new_if; +} + +ir_instruction * +ir_loop::clone(struct hash_table *ht) const +{ + ir_loop *new_loop = new ir_loop(); + + if (this->from) + new_loop->from = (ir_rvalue *)this->from->clone(ht); + if (this->to) + new_loop->to = (ir_rvalue *)this->to->clone(ht); + if (this->increment) + new_loop->increment = (ir_rvalue *)this->increment->clone(ht); + new_loop->counter = counter; + + foreach_iter(exec_list_iterator, iter, this->body_instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_loop->body_instructions.push_tail(ir->clone(ht)); + } + + return new_loop; +} + +ir_instruction * +ir_call::clone(struct hash_table *ht) const +{ + exec_list new_parameters; + + foreach_iter(exec_list_iterator, iter, this->actual_parameters) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_parameters.push_tail(ir->clone(ht)); + } + + return new ir_call(this->callee, &new_parameters); +} + +ir_instruction * +ir_expression::clone(struct hash_table *ht) const +{ + ir_rvalue *op[2] = {NULL, NULL}; + unsigned int i; + + for (i = 0; i < get_num_operands(); i++) { + op[i] = (ir_rvalue *)this->operands[i]->clone(ht); + } + + return new ir_expression(this->operation, this->type, op[0], op[1]); +} + +ir_instruction * +ir_dereference_variable::clone(struct hash_table *ht) const +{ + ir_variable *new_var; + + if (ht) { + new_var = (ir_variable *)hash_table_find(ht, this->var); + if (!new_var) + new_var = this->var; + } else { + new_var = this->var; + } + + return new ir_dereference_variable(new_var); +} + +ir_instruction * +ir_dereference_array::clone(struct hash_table *ht) const +{ + return new ir_dereference_array((ir_rvalue *)this->array->clone(ht), + (ir_rvalue *)this->array_index->clone(ht)); +} + +ir_instruction * +ir_dereference_record::clone(struct hash_table *ht) const +{ + return new ir_dereference_record((ir_rvalue *)this->record->clone(ht), + this->field); +} + +ir_instruction * +ir_texture::clone(struct hash_table *ht) const +{ + ir_texture *new_tex = new ir_texture(this->op); + + new_tex->sampler = (ir_dereference *)this->sampler->clone(ht); + new_tex->coordinate = (ir_rvalue *)this->coordinate->clone(ht); + if (this->projector) + new_tex->projector = (ir_rvalue *)this->projector->clone(ht); + if (this->shadow_comparitor) { + new_tex->shadow_comparitor = + (ir_rvalue *)this->shadow_comparitor->clone(ht); + } + + for (int i = 0; i < 3; i++) + new_tex->offsets[i] = this->offsets[i]; + + switch (this->op) { + case ir_tex: + break; + case ir_txb: + new_tex->lod_info.bias = (ir_rvalue *)this->lod_info.bias->clone(ht); + break; + case ir_txl: + case ir_txf: + new_tex->lod_info.lod = (ir_rvalue *)this->lod_info.lod->clone(ht); + break; + case ir_txd: + new_tex->lod_info.grad.dPdx = + (ir_rvalue *)this->lod_info.grad.dPdx->clone(ht); + new_tex->lod_info.grad.dPdy = + (ir_rvalue *)this->lod_info.grad.dPdy->clone(ht); + break; + } + + return new_tex; +} + +ir_instruction * +ir_assignment::clone(struct hash_table *ht) const +{ + ir_rvalue *new_condition = NULL; + + if (this->condition) + new_condition = (ir_rvalue *)this->condition->clone(ht); + + return new ir_assignment((ir_rvalue *)this->lhs->clone(ht), + (ir_rvalue *)this->rhs->clone(ht), + new_condition); +} + +ir_instruction * +ir_function::clone(struct hash_table *ht) const +{ + (void)ht; + /* FINISHME */ + abort(); +} + +ir_instruction * +ir_function_signature::clone(struct hash_table *ht) const +{ + (void)ht; + /* FINISHME */ + abort(); +} diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index e9f04998209..effb88844ee 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -546,7 +546,7 @@ ir_constant_visitor::visit(ir_dereference_variable *ir) ir_variable *var = ir->variable_referenced(); if (var && var->constant_value) - value = var->constant_value->clone(); + value = (ir_constant *)var->constant_value->clone(NULL); } diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 4e5604f89fe..effb01c8f68 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -27,11 +27,13 @@ * Replaces calls to functions with the body of the function. */ +#include #include "ir.h" #include "ir_visitor.h" #include "ir_function_inlining.h" #include "ir_expression_flattening.h" #include "glsl_types.h" +#include "hash_table.h" class ir_function_inlining_visitor : public ir_hierarchical_visitor { public: @@ -55,283 +57,15 @@ public: bool progress; }; -class variable_remap : public exec_node { -public: - variable_remap(const ir_variable *old_var, ir_variable *new_var) - : old_var(old_var), new_var(new_var) - { - /* empty */ - } - const ir_variable *old_var; - ir_variable *new_var; -}; - -class ir_function_cloning_visitor : public ir_visitor { -public: - ir_function_cloning_visitor(ir_variable *retval) - : retval(retval) - { - /* empty */ - } - - virtual ~ir_function_cloning_visitor() - { - /* empty */ - } - - void remap_variable(const ir_variable *old_var, ir_variable *new_var) { - variable_remap *remap = new variable_remap(old_var, new_var); - this->remap_list.push_tail(remap); - } - - ir_variable *get_remapped_variable(ir_variable *var) { - foreach_iter(exec_list_iterator, iter, this->remap_list) { - variable_remap *remap = (variable_remap *)iter.get(); - - if (var == remap->old_var) - return remap->new_var; - } - - /* Not a reapped variable, so a global scoped reference, for example. */ - return var; - } - - /* List of variable_remap for mapping from original function body variables - * to inlined function body variables. - */ - exec_list remap_list; - - /* Return value for the inlined function. */ - ir_variable *retval; - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_texture *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - /*@}*/ - - ir_instruction *result; -}; - -void -ir_function_cloning_visitor::visit(ir_variable *ir) -{ - ir_variable *new_var = ir->clone(); - - this->result = new_var; - this->remap_variable(ir, new_var); -} - -void -ir_function_cloning_visitor::visit(ir_loop *ir) -{ - /* FINISHME: Implement loop cloning. */ - assert(0); - - (void)ir; - this->result = NULL; -} - -void -ir_function_cloning_visitor::visit(ir_loop_jump *ir) -{ - /* FINISHME: Implement loop cloning. */ - assert(0); - - (void) ir; - this->result = NULL; -} - - -void -ir_function_cloning_visitor::visit(ir_function_signature *ir) -{ - assert(0); - (void)ir; - this->result = NULL; -} - - -void -ir_function_cloning_visitor::visit(ir_function *ir) +unsigned int hash_func(const void *key) { - assert(0); - (void) ir; - this->result = NULL; + return (unsigned int)(uintptr_t)key; } -void -ir_function_cloning_visitor::visit(ir_expression *ir) +int hash_compare_func(const void *key1, const void *key2) { - unsigned int operand; - ir_rvalue *op[2] = {NULL, NULL}; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - ir->operands[operand]->accept(this); - op[operand] = this->result->as_rvalue(); - assert(op[operand]); - } - - this->result = new ir_expression(ir->operation, ir->type, op[0], op[1]); -} - - -void -ir_function_cloning_visitor::visit(ir_texture *ir) -{ - ir_texture *tex = new ir_texture(ir->op); - - ir->sampler->accept(this); - tex->set_sampler(this->result->as_dereference()); - - ir->coordinate->accept(this); - tex->coordinate = this->result->as_rvalue(); - - if (ir->projector != NULL) { - ir->projector->accept(this); - tex->projector = this->result->as_rvalue(); - } - - if (ir->shadow_comparitor != NULL) { - ir->shadow_comparitor->accept(this); - tex->shadow_comparitor = this->result->as_rvalue(); - } - - for (int i = 0; i < 3; i++) - tex->offsets[i] = ir->offsets[i]; - - tex->lod_info = ir->lod_info; -} - - -void -ir_function_cloning_visitor::visit(ir_swizzle *ir) -{ - ir->val->accept(this); - - this->result = new ir_swizzle(this->result->as_rvalue(), ir->mask); -} - -void -ir_function_cloning_visitor::visit(ir_dereference_variable *ir) -{ - ir_variable *var = this->get_remapped_variable(ir->variable_referenced()); - this->result = new ir_dereference_variable(var); -} - -void -ir_function_cloning_visitor::visit(ir_dereference_array *ir) -{ - ir->array->accept(this); - - ir_rvalue *var = this->result->as_rvalue(); - - ir->array_index->accept(this); - - ir_rvalue *index = this->result->as_rvalue(); - - this->result = new ir_dereference_array(var, index); -} - -void -ir_function_cloning_visitor::visit(ir_dereference_record *ir) -{ - ir->record->accept(this); - - ir_rvalue *var = this->result->as_rvalue(); - - this->result = new ir_dereference_record(var, strdup(ir->field)); -} - -void -ir_function_cloning_visitor::visit(ir_assignment *ir) -{ - ir_rvalue *lhs, *rhs, *condition = NULL; - - ir->lhs->accept(this); - lhs = this->result->as_rvalue(); - - ir->rhs->accept(this); - rhs = this->result->as_rvalue(); - - if (ir->condition) { - ir->condition->accept(this); - condition = this->result->as_rvalue(); - } - - this->result = new ir_assignment(lhs, rhs, condition); -} - - -void -ir_function_cloning_visitor::visit(ir_constant *ir) -{ - this->result = ir->clone(); -} - - -void -ir_function_cloning_visitor::visit(ir_call *ir) -{ - exec_list parameters; - - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - - param->accept(this); - parameters.push_tail(this->result); - } - - this->result = new ir_call(ir->get_callee(), ¶meters); -} - - -void -ir_function_cloning_visitor::visit(ir_return *ir) -{ - ir_rvalue *rval; - - assert(this->retval); - - rval = ir->get_value(); - rval->accept(this); - rval = this->result->as_rvalue(); - assert(rval); - - result = new ir_assignment(new ir_dereference_variable(this->retval), rval, - NULL); -} - - -void -ir_function_cloning_visitor::visit(ir_if *ir) -{ - /* FINISHME: Implement if cloning. */ - assert(0); - - (void) ir; - result = NULL; + return key1 == key2 ? 0 : 1; } bool @@ -364,6 +98,9 @@ ir_call::generate_inline(ir_instruction *next_ir) int num_parameters; int i; ir_variable *retval = NULL; + struct hash_table *ht; + + ht = hash_table_ctor(0, hash_func, hash_compare_func); num_parameters = 0; foreach_iter(exec_list_iterator, iter_sig, this->callee->parameters) @@ -377,8 +114,6 @@ ir_call::generate_inline(ir_instruction *next_ir) next_ir->insert_before(retval); } - ir_function_cloning_visitor v = ir_function_cloning_visitor(retval); - /* Generate the declarations for the parameters to our inlined code, * and set up the mapping of real function body variables to ours. */ @@ -390,11 +125,9 @@ ir_call::generate_inline(ir_instruction *next_ir) ir_rvalue *param = (ir_rvalue *) param_iter.get(); /* Generate a new variable for the parameter. */ - parameters[i] = sig_param->clone(); + parameters[i] = (ir_variable *)sig_param->clone(ht); next_ir->insert_before(parameters[i]); - v.remap_variable(sig_param, parameters[i]); - /* Move the actual param into our param variable if it's an 'in' type. */ if (parameters[i]->mode == ir_var_in || parameters[i]->mode == ir_var_inout) { @@ -413,9 +146,7 @@ ir_call::generate_inline(ir_instruction *next_ir) foreach_iter(exec_list_iterator, iter, callee->body) { ir_instruction *ir = (ir_instruction *)iter.get(); - ir->accept(&v); - assert(v.result); - next_ir->insert_before(v.result); + next_ir->insert_before(ir->clone(ht)); } /* Copy back the value of any 'out' parameters from the function body @@ -442,6 +173,8 @@ ir_call::generate_inline(ir_instruction *next_ir) delete [] parameters; + hash_table_dtor(ht); + if (retval) return new ir_dereference_variable(retval); else diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 60fb33e2f55..f15ffb66141 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -28,10 +28,12 @@ static void print_type(const glsl_type *t); void -ir_instruction::print(void) +ir_instruction::print(void) const { + ir_instruction *deconsted = const_cast(this); + ir_print_visitor v; - accept(&v); + deconsted->accept(&v); } void diff --git a/ir_reader.cpp b/ir_reader.cpp index a8ccb30999f..ee320ddac28 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -334,9 +334,9 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, s_symbol *symbol = SX_AS_SYMBOL(expr); if (symbol != NULL) { if (strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL) - return new ir_loop_jump(loop_ctx, ir_loop_jump::jump_break); + return new ir_loop_jump(ir_loop_jump::jump_break); if (strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL) - return new ir_loop_jump(loop_ctx, ir_loop_jump::jump_continue); + return new ir_loop_jump(ir_loop_jump::jump_continue); } s_list *list = SX_AS_LIST(expr); diff --git a/linker.cpp b/linker.cpp index abf5371ce90..ba382fe8816 100644 --- a/linker.cpp +++ b/linker.cpp @@ -290,7 +290,8 @@ cross_validate_uniforms(struct glsl_program *prog) * have an initializer but a later instance does, copy the * initializer to the version stored in the symbol table. */ - existing->constant_value = var->constant_value->clone(); + existing->constant_value = + (ir_constant *)var->constant_value->clone(NULL); } } else uniforms.add_variable(var->name, var); -- cgit v1.2.3 From 8006576b3646f3ee621b38b5f27a138a50d073bf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 23 Jun 2010 12:19:07 -0700 Subject: ir_function_inlining: Allow inlining of loops and conditionals. The new cloning code handles them. --- ir_function_can_inline.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/ir_function_can_inline.cpp b/ir_function_can_inline.cpp index 5761a742049..8bb8e0d9ed7 100644 --- a/ir_function_can_inline.cpp +++ b/ir_function_can_inline.cpp @@ -39,28 +39,14 @@ class ir_function_can_inline_visitor : public ir_hierarchical_visitor { public: ir_function_can_inline_visitor() { - this->can_inline = true; this->num_returns = 0; } - virtual ir_visitor_status visit_enter(ir_loop *); virtual ir_visitor_status visit_enter(ir_return *); - virtual ir_visitor_status visit_enter(ir_if *); - bool can_inline; int num_returns; }; -ir_visitor_status -ir_function_can_inline_visitor::visit_enter(ir_loop *ir) -{ - /* FINISHME: Implement loop cloning in ir_function_inlining.cpp */ - (void) ir; - this->can_inline = false; - return visit_stop; -} - - ir_visitor_status ir_function_can_inline_visitor::visit_enter(ir_return *ir) { @@ -69,16 +55,6 @@ ir_function_can_inline_visitor::visit_enter(ir_return *ir) return visit_continue; } - -ir_visitor_status -ir_function_can_inline_visitor::visit_enter(ir_if *ir) -{ - /* FINISHME: Implement if cloning in ir_function_inlining.cpp. */ - (void) ir; - this->can_inline = false; - return visit_stop; -} - bool can_inline(ir_call *call) { @@ -91,5 +67,5 @@ can_inline(ir_call *call) if (last && !last->as_return()) v.num_returns++; - return v.can_inline && v.num_returns == 1; + return v.num_returns == 1; } -- cgit v1.2.3 From 3e24ef68a9b22918c8b21b743d81bbf86f43c119 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 23 Jun 2010 12:40:17 -0700 Subject: ast_to_hir: Clone LHS derefs of assignment expressions. --- ast_to_hir.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index b4692c69228..613009b8a3c 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -932,7 +932,8 @@ ast_expression::hir(exec_list *instructions, ir_rvalue *temp_rhs = new ir_expression(operations[this->oper], type, op[0], op[1]); - result = do_assignment(instructions, state, op[0], temp_rhs, + result = do_assignment(instructions, state, + (ir_rvalue *)op[0]->clone(NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; error_emitted = (op[0]->type->is_error()); @@ -957,7 +958,8 @@ ast_expression::hir(exec_list *instructions, temp_rhs = new ir_expression(operations[this->oper], type, op[0], op[1]); - result = do_assignment(instructions, state, op[0], temp_rhs, + result = do_assignment(instructions, state, + (ir_rvalue *)op[0]->clone(NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; error_emitted = type->is_error(); @@ -1074,7 +1076,8 @@ ast_expression::hir(exec_list *instructions, temp_rhs = new ir_expression(operations[this->oper], type, op[0], op[1]); - result = do_assignment(instructions, state, op[0], temp_rhs, + result = do_assignment(instructions, state, + (ir_rvalue *)op[0]->clone(NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; error_emitted = op[0]->type->is_error(); @@ -1100,10 +1103,12 @@ ast_expression::hir(exec_list *instructions, /* Get a temporary of a copy of the lvalue before it's modified. * This may get thrown away later. */ - result = get_lvalue_copy(instructions, state, op[0], + result = get_lvalue_copy(instructions, state, + (ir_rvalue *)op[0]->clone(NULL), this->subexpressions[0]->get_location()); - (void)do_assignment(instructions, state, op[0], temp_rhs, + (void)do_assignment(instructions, state, + (ir_rvalue *)op[0]->clone(NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; -- cgit v1.2.3 From 959a9ecdd8fbc3375e4149f2b44d253622ff12ee Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 23 Jun 2010 14:43:50 -0700 Subject: get_lvalue_copy doesn't need all the checking of do_assignment(). --- ast_to_hir.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 613009b8a3c..c059abbff6a 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -536,8 +536,7 @@ generate_temporary(const glsl_type *type, exec_list *instructions, static ir_rvalue * -get_lvalue_copy(exec_list *instructions, struct _mesa_glsl_parse_state *state, - ir_rvalue *lvalue, YYLTYPE loc) +get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) { ir_variable *var; ir_rvalue *var_deref; @@ -547,7 +546,7 @@ get_lvalue_copy(exec_list *instructions, struct _mesa_glsl_parse_state *state, var->mode = ir_var_auto; var_deref = new ir_dereference_variable(var); - do_assignment(instructions, state, var_deref, lvalue, loc); + instructions->push_tail(new ir_assignment(var_deref, lvalue, NULL)); /* Once we've created this temporary, mark it read only so it's no * longer considered an lvalue. @@ -1103,9 +1102,7 @@ ast_expression::hir(exec_list *instructions, /* Get a temporary of a copy of the lvalue before it's modified. * This may get thrown away later. */ - result = get_lvalue_copy(instructions, state, - (ir_rvalue *)op[0]->clone(NULL), - this->subexpressions[0]->get_location()); + result = get_lvalue_copy(instructions, (ir_rvalue *)op[0]->clone(NULL)); (void)do_assignment(instructions, state, (ir_rvalue *)op[0]->clone(NULL), temp_rhs, -- cgit v1.2.3 From 2731a739d047e4aadc1cab4bcf8c01c1cf8e86db Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 23 Jun 2010 14:51:14 -0700 Subject: Avoid using the RHS of an assignment twice. This would fix double-evaluation of assignment RHS expressions, including possible side effects. --- ast_to_hir.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index c059abbff6a..61e0d01a900 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -509,10 +509,26 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, } } - ir_instruction *tmp = new ir_assignment(lhs, rhs, NULL); - instructions->push_tail(tmp); + /* Most callers of do_assignment (assign, add_assign, pre_inc/dec, + * but not post_inc) need the converted assigned value as an rvalue + * to handle things like: + * + * i = j += 1; + * + * So we always just store the computed value being assigned to a + * temporary and return a deref of that temporary. If the rvalue + * ends up not being used, the temp will get copy-propagated out. + */ + ir_variable *var = new ir_variable(rhs->type, "assignment_tmp"); + instructions->push_tail(new ir_assignment(new ir_dereference_variable(var), + rhs, + NULL)); + + instructions->push_tail(new ir_assignment(lhs, + new ir_dereference_variable(var), + NULL)); - return rhs; + return new ir_dereference_variable(var); } -- cgit v1.2.3 From a9d58ad6c9ca4243c8a4b35fbf562c8123593a05 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 23 Jun 2010 14:57:47 -0700 Subject: Fix double usage of the post-inc/dec's temporary pre-inc/dec copy. Fixes CorrectSwizzle3.frag. --- ast_to_hir.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 61e0d01a900..c70f0f9de9f 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -555,21 +555,20 @@ static ir_rvalue * get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) { ir_variable *var; - ir_rvalue *var_deref; /* FINISHME: Give unique names to the temporaries. */ - var = new ir_variable(lvalue->type, "_internal_tmp"); + var = new ir_variable(lvalue->type, "_post_incdec_tmp"); var->mode = ir_var_auto; - var_deref = new ir_dereference_variable(var); - instructions->push_tail(new ir_assignment(var_deref, lvalue, NULL)); + instructions->push_tail(new ir_assignment(new ir_dereference_variable(var), + lvalue, NULL)); /* Once we've created this temporary, mark it read only so it's no * longer considered an lvalue. */ var->read_only = true; - return var_deref; + return new ir_dereference_variable(var); } -- cgit v1.2.3 From 7fd7104fbb331e7d9fae7a79c6eca13dda3dfc55 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 17 Jun 2010 00:35:46 -0700 Subject: ir_variable: Add some missing initialization to the constructor. Thanks to valgrind for noticing this problem. --- ir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ir.cpp b/ir.cpp index 95142016007..98b085e91bf 100644 --- a/ir.cpp +++ b/ir.cpp @@ -727,11 +727,13 @@ ir_swizzle::variable_referenced() ir_variable::ir_variable(const struct glsl_type *type, const char *name) : max_array_access(0), read_only(false), centroid(false), invariant(false), - mode(ir_var_auto), interpolation(ir_var_smooth) + shader_in(false), shader_out(false), + mode(ir_var_auto), interpolation(ir_var_smooth), array_lvalue(false) { this->type = type; this->name = name; this->location = -1; + this->warn_extension = NULL; this->constant_value = NULL; if (type && type->base_type == GLSL_TYPE_SAMPLER) -- cgit v1.2.3 From a22426dc4c934673e8f0af5c70a67505a4de7aad Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 17 Jun 2010 00:37:39 -0700 Subject: Fix typos of "variable" as "varaible" One of these was just in a comment. But ther other was in an enum tag, (which is apparently not being used anywhere yet). --- ir.h | 2 +- ir_hierarchical_visitor.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ir.h b/ir.h index f3402a38a16..9277f762042 100644 --- a/ir.h +++ b/ir.h @@ -134,7 +134,7 @@ enum ir_variable_mode { ir_var_inout }; -enum ir_varaible_interpolation { +enum ir_variable_interpolation { ir_var_smooth = 0, ir_var_flat, ir_var_noperspective diff --git a/ir_hierarchical_visitor.h b/ir_hierarchical_visitor.h index af8f83cac56..e741155e19f 100644 --- a/ir_hierarchical_visitor.h +++ b/ir_hierarchical_visitor.h @@ -93,7 +93,7 @@ public: * nodes can always be handled as variable declarations. Code that used * non-hierarchical visitors had to set an "in a dereference" flag to * determine how to handle an ir_variable. By forcing the visitor to - * handle the ir_variable within the ir_dereference_varaible visitor, this + * handle the ir_variable within the ir_dereference_variable visitor, this * kludge can be avoided. * * In addition, I can envision no use for having separate enter and leave -- cgit v1.2.3 From a32305a8bd28e19b2e97d430a9f61587b7222bd5 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 17 Jun 2010 14:08:36 -0700 Subject: configure: Remove some dead code. This block of code is useless because a (nearly-equivalent) assignment is made immediately after. The only difference is the omission of -Wunreadchable-code in the assignment being used. Presumably, that was intended to be -Wunreachable-code (without the first 'd'), but since this hasn't been being used we just drop it. --- configure.ac | 7 ------- 1 file changed, 7 deletions(-) diff --git a/configure.ac b/configure.ac index 68241f1ceed..74dd6618462 100644 --- a/configure.ac +++ b/configure.ac @@ -52,13 +52,6 @@ if test "x$enable_debug" = xyes; then fi fi - -if test "x$GCC" = xyes ; then - WARN="-Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector -Wunreadchable-code" -else - WARN="" -fi - if test "x$GXX" = xyes ; then WARN="-Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector" else -- cgit v1.2.3 From 60c67e46b1b0c69171929be5915bb5468a7faff6 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 17 Jun 2010 15:25:07 -0700 Subject: configure: Ensure that config.h can be safely included multiple times. Use AH_TOP and AH_BOTTOM macros so that the standard include guard mechanisms are emitted by autoheader into the generated config.h file. --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index 74dd6618462..73ce67de3d1 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,10 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # Checks for library functions. AC_HEADER_STDC +AH_TOP([#ifndef GLSL_CONFIG_H +#define GLSL_CONFIG_H]) +AH_BOTTOM([#endif /* GLSL_CONFIG_H */]) + PKG_CHECK_MODULES([talloc], [talloc >= 2.0]) AC_ARG_ENABLE([debug], -- cgit v1.2.3 From 45cbc08438227d5cc702c271a4c9afd3ba017b63 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 22 Jun 2010 15:34:59 -0700 Subject: preprocessor: Remove dead code _string_list_append_list As gcc noticed, this function is not currently being used. Good-bye. --- glcpp/glcpp-parse.y | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 2ce8632a28d..710ede640a9 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -55,9 +55,6 @@ _string_list_create (void *ctx); static void _string_list_append_item (string_list_t *list, const char *str); -static void -_string_list_append_list (string_list_t *list, string_list_t *tail); - static int _string_list_contains (string_list_t *list, const char *member, int *index); @@ -503,18 +500,6 @@ _string_list_create (void *ctx) return list; } -void -_string_list_append_list (string_list_t *list, string_list_t *tail) -{ - if (list->head == NULL) { - list->head = tail->head; - } else { - list->tail->next = tail->head; - } - - list->tail = tail->tail; -} - void _string_list_append_item (string_list_t *list, const char *str) { -- cgit v1.2.3 From 726faddda2d69ea0f81da8e81c6a2e0f3fb6fdda Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 22 Jun 2010 15:50:38 -0700 Subject: preprocessor: Remove dead code _token_list_length As gcc noticed, this function is not currently being used. Good-bye. --- glcpp/glcpp-parse.y | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 710ede640a9..88a30f89755 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -93,9 +93,6 @@ _token_list_append (token_list_t *list, token_t *token); static void _token_list_append_list (token_list_t *list, token_list_t *tail); -static int -_token_list_length (token_list_t *list); - static active_list_t * _active_list_push (active_list_t *list, const char *identifier, @@ -731,21 +728,6 @@ _token_list_trim_trailing_space (token_list_t *list) } } -static int -_token_list_length (token_list_t *list) -{ - int length = 0; - token_node_t *node; - - if (list == NULL) - return 0; - - for (node = list->head; node; node = node->next) - length++; - - return length; -} - static void _token_print (char **out, token_t *token) { -- cgit v1.2.3 From c42e64099b80e112eb0b172801a7107e143f78dc Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 22 Jun 2010 15:51:34 -0700 Subject: preprocessor: Initialize a potentially uninitialized variable. My current reading of the relevant static functions suggests that last is never used without being uninitialized, (we only use it if the expansion function returned non-NULL and the expansion functions always set it before returning non-NULL). Apparently gcc isn't coming to the same conclusion. Initializing this to NULL nicely quites gcc and will guarantee a nice, early segfault if my anaylsis turns out to be wrong. --- glcpp/glcpp-parse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y index 88a30f89755..6beac18c65d 100644 --- a/glcpp/glcpp-parse.y +++ b/glcpp/glcpp-parse.y @@ -1312,7 +1312,7 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser, token_list_t *list) { token_node_t *node_prev; - token_node_t *node, *last; + token_node_t *node, *last = NULL; token_list_t *expansion; if (list == NULL) -- cgit v1.2.3 From 4b2d32b5b5864869419a88d194b740bc0ec211e8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 16:16:32 -0700 Subject: ast_node: Remove empty destructor. This wasn't serving any purpose. So delete it. --- ast.h | 1 - glsl_parser_extras.cpp | 7 ------- 2 files changed, 8 deletions(-) diff --git a/ast.h b/ast.h index 1cf80af9144..782e2c7ce74 100644 --- a/ast.h +++ b/ast.h @@ -36,7 +36,6 @@ struct YYLTYPE; class ast_node { public: - virtual ~ast_node(); virtual void print(void) const; virtual ir_rvalue *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 7bd30de7c24..1d16ef55f57 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -155,13 +155,6 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, return true; } - -ast_node::~ast_node() -{ - /* empty */ -} - - void _mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q) { -- cgit v1.2.3 From be83eb8671e7789cbe5ca1fc8d3f5d133e2e7014 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 13:34:05 -0700 Subject: glsl2 main: Use talloc to allocate whole_program struct. This way, whole_program can be our top-level talloc context object, allowing us to free the lot with a single talloc_free in the end. --- main.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/main.cpp b/main.cpp index 17f25d741e4..78169d257d0 100644 --- a/main.cpp +++ b/main.cpp @@ -200,20 +200,21 @@ main(int argc, char **argv) if (argc <= optind) usage_fail(argv[0]); - struct glsl_program whole_program; - memset(&whole_program, 0, sizeof(whole_program)); + struct glsl_program *whole_program; + + whole_program = talloc_zero (NULL, struct glsl_program); + assert(whole_program != NULL); for (/* empty */; argc > optind; optind++) { - whole_program.Shaders = (struct glsl_shader **) - realloc(whole_program.Shaders, - sizeof(struct glsl_shader *) * (whole_program.NumShaders + 1)); - assert(whole_program.Shaders != NULL); + whole_program->Shaders = (struct glsl_shader **) + realloc(whole_program->Shaders, + sizeof(struct glsl_shader *) * (whole_program->NumShaders + 1)); + assert(whole_program->Shaders != NULL); - /* talloc context should probably be whole_program */ - struct glsl_shader *shader = talloc_zero(NULL, glsl_shader); + struct glsl_shader *shader = talloc_zero(whole_program, glsl_shader); - whole_program.Shaders[whole_program.NumShaders] = shader; - whole_program.NumShaders++; + whole_program->Shaders[whole_program->NumShaders] = shader; + whole_program->NumShaders++; const unsigned len = strlen(argv[optind]); if (len < 6) @@ -245,9 +246,11 @@ main(int argc, char **argv) } if ((status == EXIT_SUCCESS) && do_link) { - link_shaders(&whole_program); - status = (whole_program.LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE; + link_shaders(whole_program); + status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE; } + talloc_free(whole_program); + return status; } -- cgit v1.2.3 From 2d2561ef9696aa5ff0c1a85e3a4a95475f927935 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 15:43:38 -0700 Subject: glsl2 main: Use talloc to allocate _mesa_glsl_parse_state This is a short-lived object. It exists only for the duration of the compile_shader() function, (as opposed to the shader and whole_program which live longer). The state is created with the same talloc parent as the shader, so that other allocation can be done with talloc_parent(state) as the owner in order to attach to a long-lived object. --- main.cpp | 57 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/main.cpp b/main.cpp index 78169d257d0..f56e6f6142e 100644 --- a/main.cpp +++ b/main.cpp @@ -106,38 +106,39 @@ const struct option compiler_opts[] = { void compile_shader(struct glsl_shader *shader) { - struct _mesa_glsl_parse_state state; + struct _mesa_glsl_parse_state *state; + + state = talloc_zero(talloc_parent(shader), struct _mesa_glsl_parse_state); - memset(& state, 0, sizeof(state)); switch (shader->Type) { - case GL_VERTEX_SHADER: state.target = vertex_shader; break; - case GL_FRAGMENT_SHADER: state.target = fragment_shader; break; - case GL_GEOMETRY_SHADER: state.target = geometry_shader; break; + case GL_VERTEX_SHADER: state->target = vertex_shader; break; + case GL_FRAGMENT_SHADER: state->target = fragment_shader; break; + case GL_GEOMETRY_SHADER: state->target = geometry_shader; break; } - state.scanner = NULL; - state.translation_unit.make_empty(); - state.symbols = new glsl_symbol_table; - state.info_log = talloc_strdup(shader, ""); - state.error = false; - state.temp_index = 0; - state.loop_or_switch_nesting = NULL; - state.ARB_texture_rectangle_enable = true; + state->scanner = NULL; + state->translation_unit.make_empty(); + state->symbols = new glsl_symbol_table; + state->info_log = talloc_strdup(shader, ""); + state->error = false; + state->temp_index = 0; + state->loop_or_switch_nesting = NULL; + state->ARB_texture_rectangle_enable = true; /* Create a new context for the preprocessor output. Ultimately, this * should probably be the parser context, but there isn't one yet. */ const char *source = shader->Source; - state.error = preprocess(shader, &source, &state.info_log); + state->error = preprocess(shader, &source, &state->info_log); - if (!state.error) { - _mesa_glsl_lexer_ctor(& state, source); - _mesa_glsl_parse(& state); - _mesa_glsl_lexer_dtor(& state); + if (!state->error) { + _mesa_glsl_lexer_ctor(state, source); + _mesa_glsl_parse(state); + _mesa_glsl_lexer_dtor(state); } if (dump_ast) { - foreach_list_const(n, &state.translation_unit) { + foreach_list_const(n, &state->translation_unit) { ast_node *ast = exec_node_data(ast_node, n, link); ast->print(); } @@ -145,13 +146,13 @@ compile_shader(struct glsl_shader *shader) } shader->ir.make_empty(); - if (!state.error && !state.translation_unit.is_empty()) - _mesa_ast_to_hir(&shader->ir, &state); + if (!state->error && !state->translation_unit.is_empty()) + _mesa_ast_to_hir(&shader->ir, state); validate_ir_tree(&shader->ir); /* Optimization passes */ - if (!state.error && !shader->ir.is_empty()) { + if (!state->error && !shader->ir.is_empty()) { bool progress; do { progress = false; @@ -171,17 +172,19 @@ compile_shader(struct glsl_shader *shader) validate_ir_tree(&shader->ir); /* Print out the resulting IR */ - if (!state.error && dump_lir) { - _mesa_print_ir(&shader->ir, &state); + if (!state->error && dump_lir) { + _mesa_print_ir(&shader->ir, state); } - shader->symbols = state.symbols; - shader->CompileStatus = !state.error; + shader->symbols = state->symbols; + shader->CompileStatus = !state->error; if (shader->InfoLog) talloc_free(shader->InfoLog); - shader->InfoLog = state.info_log; + shader->InfoLog = state->info_log; + + talloc_free(state); return; } -- cgit v1.2.3 From f961e4458f1e894ca782c1627b69cdee993a16f8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 15:47:04 -0700 Subject: glsl_symbol_table: Add new talloc-based new() We take advantage of overloading of the new operator (with an additional parameter!) to make this look as "C++ like" as possible. This closes 507 memory leaks when compiling glsl-orangebook-ch06-bump.frag when measured with: valgrind ./glsl glsl-orangebook-ch06-bump.frag as seen here: total heap usage: 55,623 allocs, 14,389 frees (was 13,882 frees before) --- glsl_symbol_table.h | 33 +++++++++++++++++++++++++++++++++ ir.h | 4 ++++ main.cpp | 6 +----- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/glsl_symbol_table.h b/glsl_symbol_table.h index 26b90fdb7c6..ae2fd3f4f1f 100644 --- a/glsl_symbol_table.h +++ b/glsl_symbol_table.h @@ -26,6 +26,8 @@ #ifndef GLSL_SYMBOL_TABLE #define GLSL_SYMBOL_TABLE +#include + #include "symbol_table.h" #include "ir.h" #include "glsl_types.h" @@ -44,7 +46,38 @@ private: glsl_function_name_space = 2 }; + static int + _glsl_symbol_table_destructor (glsl_symbol_table *table) + { + table->~glsl_symbol_table(); + + return 0; + } + public: + /* Callers of this talloc-based new need not call delete. It's + * easier to just talloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *table; + + table = talloc_size(ctx, size); + assert(table != NULL); + + talloc_set_destructor(table, (int (*)(void*)) _glsl_symbol_table_destructor); + + return table; + } + + /* If the user *does* call delete, that's OK, we will just + * talloc_free in that case. Here, C++ will have already called the + * destructor so tell talloc not to do that again. */ + static void operator delete(void *table) + { + talloc_set_destructor(table, NULL); + talloc_free(table); + } + glsl_symbol_table() { table = _mesa_symbol_table_ctor(); diff --git a/ir.h b/ir.h index 9277f762042..68e90653ed7 100644 --- a/ir.h +++ b/ir.h @@ -29,6 +29,10 @@ #include #include +extern "C" { +#include +} + #include "list.h" #include "ir_visitor.h" #include "ir_hierarchical_visitor.h" diff --git a/main.cpp b/main.cpp index f56e6f6142e..dcd4b8f6725 100644 --- a/main.cpp +++ b/main.cpp @@ -29,10 +29,6 @@ #include #include -extern "C" { -#include -} - #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" @@ -118,7 +114,7 @@ compile_shader(struct glsl_shader *shader) state->scanner = NULL; state->translation_unit.make_empty(); - state->symbols = new glsl_symbol_table; + state->symbols = new(shader) glsl_symbol_table; state->info_log = talloc_strdup(shader, ""); state->error = false; state->temp_index = 0; -- cgit v1.2.3 From 015b3a5115df9a53b73d4b99fed86cf245c87aca Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 16:27:18 -0700 Subject: exec_node: Remove destructor from exec_node and all descendants. Two of these destructors are non-empty, (s_symbol and s_list), so this commit could potentially introduce memory leaks, (though, no additional leaks are found in glsl-orangebook-ch06-bump.frag at least---perhaps the current code is never calling delete on these classes?). Going forward, we will switch to talloc for exec_node so we won't need explicit destrcutors to free up any memory used. --- s_expression.cpp | 15 --------------- s_expression.h | 8 -------- 2 files changed, 23 deletions(-) diff --git a/s_expression.cpp b/s_expression.cpp index 4022dfab7a7..0fb296ef671 100644 --- a/s_expression.cpp +++ b/s_expression.cpp @@ -34,25 +34,10 @@ s_symbol::s_symbol(const char *tmp) strcpy(this->str, tmp); } -s_symbol::~s_symbol() -{ - delete [] this->str; - this->str = NULL; -} - s_list::s_list() { } -s_list::~s_list() -{ - exec_list_iterator it(this->subexpressions.iterator()); - while (it.has_next()) - it.remove(); - - assert(this->subexpressions.is_empty()); -} - unsigned s_list::length() const { diff --git a/s_expression.h b/s_expression.h index d5e52c16e83..8a4eda28dae 100644 --- a/s_expression.h +++ b/s_expression.h @@ -46,8 +46,6 @@ class s_expression : public exec_node { public: - virtual ~s_expression() { } - /** * Read an S-Expression from the given string. * Advances the supplied pointer to just after the expression read. @@ -73,8 +71,6 @@ protected: class s_number : public s_expression { public: - virtual ~s_number() { } - bool is_number() const { return true; } virtual float fvalue() = 0; @@ -87,7 +83,6 @@ class s_int : public s_number { public: s_int(int x) : val(x) { } - virtual ~s_int() { } bool is_int() const { return true; } @@ -104,7 +99,6 @@ class s_float : public s_number { public: s_float(float x) : val(x) { } - virtual ~s_float() { } float fvalue() { return this->val; } @@ -118,7 +112,6 @@ class s_symbol : public s_expression { public: s_symbol(const char *); - virtual ~s_symbol(); bool is_symbol() const { return true; } @@ -135,7 +128,6 @@ class s_list : public s_expression { public: s_list(); - virtual ~s_list(); virtual bool is_list() const { return true; } unsigned length() const; -- cgit v1.2.3 From 8f52c9b5fcbc73ed12b23253caa44c28fd4452e2 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 17:12:11 -0700 Subject: ast_node: Add new talloc-based new() And use the talloc-based new for all of the ast objects created by the parser. This closes a lot of memory leaks, and will allow us to use these ast objects as talloc parents in the future, (for things like exec_nodes, etc.). This closes 164 leaks in the glsl-orangebook-ch06-bump.frag test: total heap usage: 55,623 allocs, 14,553 frees (was 14,389 frees) --- ast.h | 19 ++++ glsl_parser.ypp | 297 ++++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 211 insertions(+), 105 deletions(-) diff --git a/ast.h b/ast.h index 782e2c7ce74..de300e719c4 100644 --- a/ast.h +++ b/ast.h @@ -36,6 +36,25 @@ struct YYLTYPE; class ast_node { public: + /* Callers of this talloc-based new need not call delete. It's + * easier to just talloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *node; + + node = talloc_size(ctx, size); + assert(node != NULL); + + return node; + } + + /* If the user *does* call delete, that's OK, we will just + * talloc_free in that case. */ + static void operator delete(void *table) + { + talloc_free(table); + } + virtual void print(void) const; virtual ir_rvalue *hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); diff --git a/glsl_parser.ypp b/glsl_parser.ypp index ae009ed20cb..4132495f403 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -255,31 +255,36 @@ variable_identifier: primary_expression: variable_identifier { - $$ = new ast_expression(ast_identifier, NULL, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.identifier = $1; } | INTCONSTANT { - $$ = new ast_expression(ast_int_constant, NULL, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.int_constant = $1; } | UINTCONSTANT { - $$ = new ast_expression(ast_uint_constant, NULL, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.uint_constant = $1; } | FLOATCONSTANT { - $$ = new ast_expression(ast_float_constant, NULL, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.float_constant = $1; } | BOOLCONSTANT { - $$ = new ast_expression(ast_bool_constant, NULL, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.bool_constant = $1; } @@ -293,7 +298,8 @@ postfix_expression: primary_expression | postfix_expression '[' integer_expression ']' { - $$ = new ast_expression(ast_array_index, $1, $3, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL); $$->set_location(yylloc); } | function_call @@ -308,18 +314,21 @@ postfix_expression: } | postfix_expression '.' IDENTIFIER { - $$ = new ast_expression(ast_field_selection, $1, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.identifier = $3; } | postfix_expression INC_OP { - $$ = new ast_expression(ast_post_inc, $1, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL); $$->set_location(yylloc); } | postfix_expression DEC_OP { - $$ = new ast_expression(ast_post_dec, $1, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL); $$->set_location(yylloc); } ; @@ -336,7 +345,8 @@ function_call_or_method: function_call_generic | postfix_expression '.' function_call_generic { - $$ = new ast_expression(ast_field_selection, $1, $3, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL); $$->set_location(yylloc); } ; @@ -376,19 +386,22 @@ function_call_header: function_identifier: type_specifier { - $$ = new ast_function_expression($1); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_function_expression($1); $$->set_location(yylloc); } | IDENTIFIER { - ast_expression *callee = new ast_expression($1); - $$ = new ast_function_expression(callee); + void *ctx = talloc_parent(state); + ast_expression *callee = new(ctx) ast_expression($1); + $$ = new(ctx) ast_function_expression(callee); $$->set_location(yylloc); } | FIELD_SELECTION { - ast_expression *callee = new ast_expression($1); - $$ = new ast_function_expression(callee); + void *ctx = talloc_parent(state); + ast_expression *callee = new(ctx) ast_expression($1); + $$ = new(ctx) ast_function_expression(callee); $$->set_location(yylloc); } ; @@ -398,17 +411,20 @@ unary_expression: postfix_expression | INC_OP unary_expression { - $$ = new ast_expression(ast_pre_inc, $2, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL); $$->set_location(yylloc); } | DEC_OP unary_expression { - $$ = new ast_expression(ast_pre_dec, $2, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL); $$->set_location(yylloc); } | unary_operator unary_expression { - $$ = new ast_expression($1, $2, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression($1, $2, NULL, NULL); $$->set_location(yylloc); } ; @@ -425,17 +441,20 @@ multiplicative_expression: unary_expression | multiplicative_expression '*' unary_expression { - $$ = new ast_expression_bin(ast_mul, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3); $$->set_location(yylloc); } | multiplicative_expression '/' unary_expression { - $$ = new ast_expression_bin(ast_div, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_div, $1, $3); $$->set_location(yylloc); } | multiplicative_expression '%' unary_expression { - $$ = new ast_expression_bin(ast_mod, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3); $$->set_location(yylloc); } ; @@ -444,12 +463,14 @@ additive_expression: multiplicative_expression | additive_expression '+' multiplicative_expression { - $$ = new ast_expression_bin(ast_add, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_add, $1, $3); $$->set_location(yylloc); } | additive_expression '-' multiplicative_expression { - $$ = new ast_expression_bin(ast_sub, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3); $$->set_location(yylloc); } ; @@ -458,12 +479,14 @@ shift_expression: additive_expression | shift_expression LEFT_OP additive_expression { - $$ = new ast_expression_bin(ast_lshift, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3); $$->set_location(yylloc); } | shift_expression RIGHT_OP additive_expression { - $$ = new ast_expression_bin(ast_rshift, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3); $$->set_location(yylloc); } ; @@ -472,22 +495,26 @@ relational_expression: shift_expression | relational_expression '<' shift_expression { - $$ = new ast_expression_bin(ast_less, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_less, $1, $3); $$->set_location(yylloc); } | relational_expression '>' shift_expression { - $$ = new ast_expression_bin(ast_greater, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3); $$->set_location(yylloc); } | relational_expression LE_OP shift_expression { - $$ = new ast_expression_bin(ast_lequal, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3); $$->set_location(yylloc); } | relational_expression GE_OP shift_expression { - $$ = new ast_expression_bin(ast_gequal, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3); $$->set_location(yylloc); } ; @@ -496,12 +523,14 @@ equality_expression: relational_expression | equality_expression EQ_OP relational_expression { - $$ = new ast_expression_bin(ast_equal, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3); $$->set_location(yylloc); } | equality_expression NE_OP relational_expression { - $$ = new ast_expression_bin(ast_nequal, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3); $$->set_location(yylloc); } ; @@ -510,7 +539,8 @@ and_expression: equality_expression | and_expression '&' equality_expression { - $$ = new ast_expression_bin(ast_bit_or, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); $$->set_location(yylloc); } ; @@ -519,7 +549,8 @@ exclusive_or_expression: and_expression | exclusive_or_expression '^' and_expression { - $$ = new ast_expression_bin(ast_bit_xor, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3); $$->set_location(yylloc); } ; @@ -528,7 +559,8 @@ inclusive_or_expression: exclusive_or_expression | inclusive_or_expression '|' exclusive_or_expression { - $$ = new ast_expression_bin(ast_bit_or, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); $$->set_location(yylloc); } ; @@ -537,7 +569,8 @@ logical_and_expression: inclusive_or_expression | logical_and_expression AND_OP inclusive_or_expression { - $$ = new ast_expression_bin(ast_logic_and, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3); $$->set_location(yylloc); } ; @@ -546,7 +579,8 @@ logical_xor_expression: logical_and_expression | logical_xor_expression XOR_OP logical_and_expression { - $$ = new ast_expression_bin(ast_logic_xor, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3); $$->set_location(yylloc); } ; @@ -555,7 +589,8 @@ logical_or_expression: logical_xor_expression | logical_or_expression OR_OP logical_xor_expression { - $$ = new ast_expression_bin(ast_logic_or, $1, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3); $$->set_location(yylloc); } ; @@ -564,7 +599,8 @@ conditional_expression: logical_or_expression | logical_or_expression '?' expression ':' assignment_expression { - $$ = new ast_expression(ast_conditional, $1, $3, $5); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5); $$->set_location(yylloc); } ; @@ -573,7 +609,8 @@ assignment_expression: conditional_expression | unary_expression assignment_operator assignment_expression { - $$ = new ast_expression($2, $1, $3, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression($2, $1, $3, NULL); $$->set_location(yylloc); } ; @@ -599,8 +636,9 @@ expression: } | expression ',' assignment_expression { + void *ctx = talloc_parent(state); if ($1->oper != ast_sequence) { - $$ = new ast_expression(ast_sequence, NULL, NULL, NULL); + $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL); $$->set_location(yylloc); $$->expressions.push_tail(& $1->link); } else { @@ -662,7 +700,8 @@ function_header_with_parameters: function_header: fully_specified_type IDENTIFIER '(' { - $$ = new ast_function(); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_function(); $$->set_location(yylloc); $$->return_type = $1; $$->identifier = $2; @@ -672,18 +711,20 @@ function_header: parameter_declarator: type_specifier IDENTIFIER { - $$ = new ast_parameter_declarator(); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_parameter_declarator(); $$->set_location(yylloc); - $$->type = new ast_fully_specified_type(); + $$->type = new(ctx) ast_fully_specified_type(); $$->type->set_location(yylloc); $$->type->specifier = $1; $$->identifier = $2; } | type_specifier IDENTIFIER '[' constant_expression ']' { - $$ = new ast_parameter_declarator(); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_parameter_declarator(); $$->set_location(yylloc); - $$->type = new ast_fully_specified_type(); + $$->type = new(ctx) ast_fully_specified_type(); $$->type->set_location(yylloc); $$->type->specifier = $1; $$->identifier = $2; @@ -707,19 +748,21 @@ parameter_declaration: } | parameter_type_qualifier parameter_qualifier parameter_type_specifier { + void *ctx = talloc_parent(state); $1.i |= $2.i; - $$ = new ast_parameter_declarator(); + $$ = new(ctx) ast_parameter_declarator(); $$->set_location(yylloc); - $$->type = new ast_fully_specified_type(); + $$->type = new(ctx) ast_fully_specified_type(); $$->type->qualifier = $1.q; $$->type->specifier = $3; } | parameter_qualifier parameter_type_specifier { - $$ = new ast_parameter_declarator(); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_parameter_declarator(); $$->set_location(yylloc); - $$->type = new ast_fully_specified_type(); + $$->type = new(ctx) ast_fully_specified_type(); $$->type->qualifier = $1.q; $$->type->specifier = $2; } @@ -740,7 +783,8 @@ init_declarator_list: single_declaration | init_declarator_list ',' IDENTIFIER { - ast_declaration *decl = new ast_declaration($3, false, NULL, NULL); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL); decl->set_location(yylloc); $$ = $1; @@ -748,7 +792,8 @@ init_declarator_list: } | init_declarator_list ',' IDENTIFIER '[' ']' { - ast_declaration *decl = new ast_declaration($3, true, NULL, NULL); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL); decl->set_location(yylloc); $$ = $1; @@ -756,7 +801,8 @@ init_declarator_list: } | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' { - ast_declaration *decl = new ast_declaration($3, true, $5, NULL); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL); decl->set_location(yylloc); $$ = $1; @@ -764,7 +810,8 @@ init_declarator_list: } | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer { - ast_declaration *decl = new ast_declaration($3, true, NULL, $7); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7); decl->set_location(yylloc); $$ = $1; @@ -772,7 +819,8 @@ init_declarator_list: } | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer { - ast_declaration *decl = new ast_declaration($3, true, $5, $8); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8); decl->set_location(yylloc); $$ = $1; @@ -780,7 +828,8 @@ init_declarator_list: } | init_declarator_list ',' IDENTIFIER '=' initializer { - ast_declaration *decl = new ast_declaration($3, false, NULL, $5); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5); decl->set_location(yylloc); $$ = $1; @@ -792,67 +841,75 @@ init_declarator_list: single_declaration: fully_specified_type { + void *ctx = talloc_parent(state); if ($1->specifier->type_specifier != ast_struct) { _mesa_glsl_error(& @1, state, "empty declaration list\n"); YYERROR; } else { - $$ = new ast_declarator_list($1); + $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); } } | fully_specified_type IDENTIFIER { - ast_declaration *decl = new ast_declaration($2, false, NULL, NULL); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); - $$ = new ast_declarator_list($1); + $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); $$->declarations.push_tail(&decl->link); } | fully_specified_type IDENTIFIER '[' ']' { - ast_declaration *decl = new ast_declaration($2, true, NULL, NULL); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL); - $$ = new ast_declarator_list($1); + $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); $$->declarations.push_tail(&decl->link); } | fully_specified_type IDENTIFIER '[' constant_expression ']' { - ast_declaration *decl = new ast_declaration($2, true, $4, NULL); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL); - $$ = new ast_declarator_list($1); + $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); $$->declarations.push_tail(&decl->link); } | fully_specified_type IDENTIFIER '[' ']' '=' initializer { - ast_declaration *decl = new ast_declaration($2, true, NULL, $6); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6); - $$ = new ast_declarator_list($1); + $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); $$->declarations.push_tail(&decl->link); } | fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer { - ast_declaration *decl = new ast_declaration($2, true, $4, $7); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7); - $$ = new ast_declarator_list($1); + $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); $$->declarations.push_tail(&decl->link); } | fully_specified_type IDENTIFIER '=' initializer { - ast_declaration *decl = new ast_declaration($2, false, NULL, $4); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); - $$ = new ast_declarator_list($1); + $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); $$->declarations.push_tail(&decl->link); } | INVARIANT IDENTIFIER // Vertex only. { - ast_declaration *decl = new ast_declaration($2, false, NULL, NULL); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); - $$ = new ast_declarator_list(NULL); + $$ = new(ctx) ast_declarator_list(NULL); $$->set_location(yylloc); $$->invariant = true; @@ -863,13 +920,15 @@ single_declaration: fully_specified_type: type_specifier { - $$ = new ast_fully_specified_type(); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_fully_specified_type(); $$->set_location(yylloc); $$->specifier = $1; } | type_qualifier type_specifier { - $$ = new ast_fully_specified_type(); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_fully_specified_type(); $$->set_location(yylloc); $$->qualifier = $1.q; $$->specifier = $2; @@ -939,17 +998,20 @@ type_specifier_no_prec: type_specifier_nonarray: basic_type_specifier_nonarray { - $$ = new ast_type_specifier($1); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_type_specifier($1); $$->set_location(yylloc); } | struct_specifier { - $$ = new ast_type_specifier($1); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_type_specifier($1); $$->set_location(yylloc); } | IDENTIFIER { - $$ = new ast_type_specifier($1); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_type_specifier($1); $$->set_location(yylloc); } ; @@ -1050,12 +1112,14 @@ precision_qualifier: struct_specifier: STRUCT IDENTIFIER '{' struct_declaration_list '}' { - $$ = new ast_struct_specifier($2, $4); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_struct_specifier($2, $4); $$->set_location(yylloc); } | STRUCT '{' struct_declaration_list '}' { - $$ = new ast_struct_specifier(NULL, $3); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_struct_specifier(NULL, $3); $$->set_location(yylloc); } ; @@ -1076,11 +1140,12 @@ struct_declaration_list: struct_declaration: type_specifier struct_declarator_list ';' { - ast_fully_specified_type *type = new ast_fully_specified_type(); + void *ctx = talloc_parent(state); + ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); type->set_location(yylloc); type->specifier = $1; - $$ = new ast_declarator_list(type); + $$ = new(ctx) ast_declarator_list(type); $$->set_location(yylloc); $$->declarations.push_degenerate_list_at_head(& $2->link); @@ -1103,12 +1168,14 @@ struct_declarator_list: struct_declarator: IDENTIFIER { - $$ = new ast_declaration($1, false, NULL, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_declaration($1, false, NULL, NULL); $$->set_location(yylloc); } | IDENTIFIER '[' constant_expression ']' { - $$ = new ast_declaration($1, true, $3, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_declaration($1, true, $3, NULL); $$->set_location(yylloc); } ; @@ -1150,12 +1217,14 @@ simple_statement: compound_statement: '{' '}' { - $$ = new ast_compound_statement(true, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_compound_statement(true, NULL); $$->set_location(yylloc); } | '{' statement_list '}' { - $$ = new ast_compound_statement(true, $2); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_compound_statement(true, $2); $$->set_location(yylloc); } ; @@ -1168,12 +1237,14 @@ statement_no_new_scope: compound_statement_no_new_scope: '{' '}' { - $$ = new ast_compound_statement(false, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_compound_statement(false, NULL); $$->set_location(yylloc); } | '{' statement_list '}' { - $$ = new ast_compound_statement(false, $2); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_compound_statement(false, $2); $$->set_location(yylloc); } ; @@ -1203,12 +1274,14 @@ statement_list: expression_statement: ';' { - $$ = new ast_expression_statement(NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_statement(NULL); $$->set_location(yylloc); } | expression ';' { - $$ = new ast_expression_statement($1); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_statement($1); $$->set_location(yylloc); } ; @@ -1216,7 +1289,8 @@ expression_statement: selection_statement_matched: IF '(' expression ')' statement_matched ELSE statement_matched { - $$ = new ast_selection_statement($3, $5, $7); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_selection_statement($3, $5, $7); $$->set_location(yylloc); } ; @@ -1224,17 +1298,20 @@ selection_statement_matched: selection_statement_unmatched: IF '(' expression ')' statement_matched { - $$ = new ast_selection_statement($3, $5, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_selection_statement($3, $5, NULL); $$->set_location(yylloc); } | IF '(' expression ')' statement_unmatched { - $$ = new ast_selection_statement($3, $5, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_selection_statement($3, $5, NULL); $$->set_location(yylloc); } | IF '(' expression ')' statement_matched ELSE statement_unmatched { - $$ = new ast_selection_statement($3, $5, $7); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_selection_statement($3, $5, $7); $$->set_location(yylloc); } ; @@ -1246,8 +1323,9 @@ condition: } | fully_specified_type IDENTIFIER '=' initializer { - ast_declaration *decl = new ast_declaration($2, false, NULL, $4); - ast_declarator_list *declarator = new ast_declarator_list($1); + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); + ast_declarator_list *declarator = new(ctx) ast_declarator_list($1); decl->set_location(yylloc); declarator->set_location(yylloc); @@ -1268,20 +1346,23 @@ case_label: iteration_statement: WHILE '(' condition ')' statement_no_new_scope { - $$ = new ast_iteration_statement(ast_iteration_statement::ast_while, - NULL, $3, NULL, $5); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, + NULL, $3, NULL, $5); $$->set_location(yylloc); } | DO statement WHILE '(' expression ')' ';' { - $$ = new ast_iteration_statement(ast_iteration_statement::ast_do_while, - NULL, $5, NULL, $2); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, + NULL, $5, NULL, $2); $$->set_location(yylloc); } | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope { - $$ = new ast_iteration_statement(ast_iteration_statement::ast_for, - $3, $4.cond, $4.rest, $6); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, + $3, $4.cond, $4.rest, $6); $$->set_location(yylloc); } ; @@ -1316,27 +1397,32 @@ for_rest_statement: jump_statement: CONTINUE ';' { - $$ = new ast_jump_statement(ast_jump_statement::ast_continue, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); $$->set_location(yylloc); } | BREAK ';' { - $$ = new ast_jump_statement(ast_jump_statement::ast_break, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); $$->set_location(yylloc); } | RETURN ';' { - $$ = new ast_jump_statement(ast_jump_statement::ast_return, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); $$->set_location(yylloc); } | RETURN expression ';' { - $$ = new ast_jump_statement(ast_jump_statement::ast_return, $2); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2); $$->set_location(yylloc); } | DISCARD ';' // Fragment shader only. { - $$ = new ast_jump_statement(ast_jump_statement::ast_discard, NULL); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); $$->set_location(yylloc); } ; @@ -1349,7 +1435,8 @@ external_declaration: function_definition: function_prototype compound_statement_no_new_scope { - $$ = new ast_function_definition(); + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_function_definition(); $$->set_location(yylloc); $$->prototype = $1; $$->body = $2; -- cgit v1.2.3 From 1660a2954797e056caba319c5d6c70b0d4be22fe Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 18:11:51 -0700 Subject: exec_node: Add new talloc-based new() And fix all callers to use the tallbac-based new for exec_node construction. We make ready use of talloc_parent in order to get valid, (and appropriate) talloc owners for everything we construct without having to add new 'ctx' parameters up and down all the call trees. This closes the majority of the memory leaks in the glsl-orangebook-ch06-bump.frag test: total heap usage: 55,623 allocs, 42,672 frees (was 14,533 frees) Now 76.7% leak-free. Woo-hoo! --- ast_function.cpp | 53 +++++++------ ast_to_hir.cpp | 181 +++++++++++++++++++++++-------------------- glsl_types.cpp | 128 ++++++++++++++++-------------- hir_field_selection.cpp | 5 +- ir.cpp | 25 ++++-- ir_clone.cpp | 47 +++++++---- ir_constant_expression.cpp | 11 ++- ir_copy_propagation.cpp | 3 +- ir_dead_code.cpp | 3 +- ir_dead_code_local.cpp | 3 +- ir_expression_flattening.cpp | 11 +-- ir_function_inlining.cpp | 15 ++-- ir_reader.cpp | 50 ++++++++---- ir_variable.cpp | 2 +- ir_vec_index_to_swizzle.cpp | 4 +- list.h | 25 ++++++ s_expression.cpp | 16 ++-- s_expression.h | 4 +- 18 files changed, 351 insertions(+), 235 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index ff2dfa502f3..866cbc4ecdf 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -54,6 +54,8 @@ process_call(exec_list *instructions, ir_function *f, YYLTYPE *loc, exec_list *actual_parameters, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); + const ir_function_signature *sig = f->matching_signature(actual_parameters); @@ -93,7 +95,7 @@ process_call(exec_list *instructions, ir_function *f, /* FINISHME: The list of actual parameters needs to be modified to * FINISHME: include any necessary conversions. */ - return new ir_call(sig, actual_parameters); + return new(ctx) ir_call(sig, actual_parameters); } else { /* FINISHME: Log a better error message here. G++ will show the types * FINISHME: of the actual parameters and the set of candidate @@ -132,6 +134,7 @@ match_function_by_name(exec_list *instructions, const char *name, static ir_rvalue * convert_component(ir_rvalue *src, const glsl_type *desired_type) { + void *ctx = talloc_parent(src); const unsigned a = desired_type->base_type; const unsigned b = src->type->base_type; ir_expression *result = NULL; @@ -149,22 +152,22 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) case GLSL_TYPE_UINT: case GLSL_TYPE_INT: if (b == GLSL_TYPE_FLOAT) - result = new ir_expression(ir_unop_f2i, desired_type, src, NULL); + result = new(ctx) ir_expression(ir_unop_f2i, desired_type, src, NULL); else { assert(b == GLSL_TYPE_BOOL); - result = new ir_expression(ir_unop_b2i, desired_type, src, NULL); + result = new(ctx) ir_expression(ir_unop_b2i, desired_type, src, NULL); } break; case GLSL_TYPE_FLOAT: switch (b) { case GLSL_TYPE_UINT: - result = new ir_expression(ir_unop_u2f, desired_type, src, NULL); + result = new(ctx) ir_expression(ir_unop_u2f, desired_type, src, NULL); break; case GLSL_TYPE_INT: - result = new ir_expression(ir_unop_i2f, desired_type, src, NULL); + result = new(ctx) ir_expression(ir_unop_i2f, desired_type, src, NULL); break; case GLSL_TYPE_BOOL: - result = new ir_expression(ir_unop_b2f, desired_type, src, NULL); + result = new(ctx) ir_expression(ir_unop_b2f, desired_type, src, NULL); break; } break; @@ -172,12 +175,12 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) ir_constant *zero = NULL; switch (b) { - case GLSL_TYPE_UINT: zero = new ir_constant(unsigned(0)); break; - case GLSL_TYPE_INT: zero = new ir_constant(int(0)); break; - case GLSL_TYPE_FLOAT: zero = new ir_constant(0.0f); break; + case GLSL_TYPE_UINT: zero = new(ctx) ir_constant(unsigned(0)); break; + case GLSL_TYPE_INT: zero = new(ctx) ir_constant(int(0)); break; + case GLSL_TYPE_FLOAT: zero = new(ctx) ir_constant(0.0f); break; } - result = new ir_expression(ir_binop_nequal, desired_type, src, zero); + result = new(ctx) ir_expression(ir_binop_nequal, desired_type, src, zero); } } @@ -194,6 +197,7 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) static ir_rvalue * dereference_component(ir_rvalue *src, unsigned component) { + void *ctx = talloc_parent(src); assert(component < src->type->components()); /* If the source is a constant, just create a new constant instead of a @@ -201,12 +205,12 @@ dereference_component(ir_rvalue *src, unsigned component) */ ir_constant *constant = src->as_constant(); if (constant) - return new ir_constant(constant, component); + return new(ctx) ir_constant(constant, component); if (src->type->is_scalar()) { return src; } else if (src->type->is_vector()) { - return new ir_swizzle(src, component, 0, 0, 0, 1); + return new(ctx) ir_swizzle(src, component, 0, 0, 0, 1); } else { assert(src->type->is_matrix()); @@ -215,8 +219,8 @@ dereference_component(ir_rvalue *src, unsigned component) */ const int c = component / src->type->column_type()->vector_elements; const int r = component % src->type->column_type()->vector_elements; - ir_constant *const col_index = new ir_constant(c); - ir_dereference *const col = new ir_dereference_array(src, col_index); + ir_constant *const col_index = new(ctx) ir_constant(c); + ir_dereference *const col = new(ctx) ir_dereference_array(src, col_index); col->type = src->type->column_type(); @@ -306,6 +310,7 @@ constant_record_constructor(const glsl_type *constructor_type, YYLTYPE *loc, exec_list *parameters, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); bool all_parameters_are_constant = true; exec_node *node = parameters->head; @@ -338,7 +343,7 @@ constant_record_constructor(const glsl_type *constructor_type, if (!all_parameters_are_constant) return NULL; - return new ir_constant(constructor_type, parameters); + return new(ctx) ir_constant(constructor_type, parameters); } @@ -440,6 +445,7 @@ ir_rvalue * ast_function_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); /* There are three sorts of function calls. * * 1. contstructors - The first subexpression is an ast_type_specifier. @@ -574,11 +580,13 @@ ast_function_expression::hir(exec_list *instructions, * glsl-vs-constructor-call.shader_test. */ if (result->type->components() >= 1 && !result->as_constant()) { - result_var = new ir_variable(result->type, "constructor_tmp"); + result_var = new(ctx) ir_variable(result->type, + "constructor_tmp"); ir_dereference_variable *lhs; - lhs = new ir_dereference_variable(result_var); - instructions->push_tail(new ir_assignment(lhs, result, NULL)); + lhs = new(ctx) ir_dereference_variable(result_var); + instructions->push_tail(new(ctx) ir_assignment(lhs, + result, NULL)); } /* Process each of the components of the parameter. Dereference @@ -592,7 +600,7 @@ ast_function_expression::hir(exec_list *instructions, ir_rvalue *component; if (result_var) { - ir_dereference *d = new ir_dereference_variable(result_var); + ir_dereference *d = new(ctx) ir_dereference_variable(result_var); component = dereference_component(d, i); } else { component = dereference_component(result, i); @@ -674,7 +682,8 @@ ast_function_expression::hir(exec_list *instructions, */ if (all_parameters_are_constant) { if (components_used >= type_components) - return new ir_constant(sig->return_type, & actual_parameters); + return new(ctx) ir_constant(sig->return_type, + & actual_parameters); assert(sig->return_type->is_vector() || sig->return_type->is_matrix()); @@ -695,9 +704,9 @@ ast_function_expression::hir(exec_list *instructions, generate_constructor_vector(sig->return_type, initializer, &data); - return new ir_constant(sig->return_type, &data); + return new(ctx) ir_constant(sig->return_type, &data); } else - return new ir_call(sig, & actual_parameters); + return new(ctx) ir_call(sig, & actual_parameters); } else { /* FINISHME: Log a better error message here. G++ will show the * FINSIHME: types of the actual parameters and the set of diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index c70f0f9de9f..eafc9e81145 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -87,6 +87,7 @@ static bool apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); if (to->base_type == from->type->base_type) return true; @@ -111,13 +112,13 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, switch (from->type->base_type) { case GLSL_TYPE_INT: - from = new ir_expression(ir_unop_i2f, to, from, NULL); + from = new(ctx) ir_expression(ir_unop_i2f, to, from, NULL); break; case GLSL_TYPE_UINT: - from = new ir_expression(ir_unop_u2f, to, from, NULL); + from = new(ctx) ir_expression(ir_unop_u2f, to, from, NULL); break; case GLSL_TYPE_BOOL: - from = new ir_expression(ir_unop_b2f, to, from, NULL); + from = new(ctx) ir_expression(ir_unop_b2f, to, from, NULL); break; default: assert(0); @@ -467,6 +468,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, ir_rvalue *lhs, ir_rvalue *rhs, YYLTYPE lhs_loc) { + void *ctx = talloc_parent(state); bool error_emitted = (lhs->type->is_error() || rhs->type->is_error()); if (!error_emitted) { @@ -519,16 +521,16 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, * temporary and return a deref of that temporary. If the rvalue * ends up not being used, the temp will get copy-propagated out. */ - ir_variable *var = new ir_variable(rhs->type, "assignment_tmp"); - instructions->push_tail(new ir_assignment(new ir_dereference_variable(var), - rhs, - NULL)); + ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp"); + instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), + rhs, + NULL)); - instructions->push_tail(new ir_assignment(lhs, - new ir_dereference_variable(var), - NULL)); + instructions->push_tail(new(ctx) ir_assignment(lhs, + new(ctx) ir_dereference_variable(var), + NULL)); - return new ir_dereference_variable(var); + return new(ctx) ir_dereference_variable(var); } @@ -539,12 +541,13 @@ static ir_variable * generate_temporary(const glsl_type *type, exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); char *name = (char *) malloc(sizeof(char) * 13); snprintf(name, 13, "tmp_%08X", state->temp_index); state->temp_index++; - ir_variable *const var = new ir_variable(type, name); + ir_variable *const var = new(ctx) ir_variable(type, name); instructions->push_tail(var); return var; @@ -554,21 +557,22 @@ generate_temporary(const glsl_type *type, exec_list *instructions, static ir_rvalue * get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) { + void *ctx = talloc_parent(lvalue); ir_variable *var; /* FINISHME: Give unique names to the temporaries. */ - var = new ir_variable(lvalue->type, "_post_incdec_tmp"); + var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp"); var->mode = ir_var_auto; - instructions->push_tail(new ir_assignment(new ir_dereference_variable(var), - lvalue, NULL)); + instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), + lvalue, NULL)); /* Once we've created this temporary, mark it read only so it's no * longer considered an lvalue. */ var->read_only = true; - return new ir_dereference_variable(var); + return new(ctx) ir_dereference_variable(var); } @@ -587,6 +591,7 @@ ir_rvalue * ast_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); static const int operations[AST_NUM_OPERATORS] = { -1, /* ast_assign doesn't convert to ir_expression. */ -1, /* ast_plus doesn't convert to ir_expression. */ @@ -679,8 +684,8 @@ ast_expression::hir(exec_list *instructions, error_emitted = type->is_error(); - result = new ir_expression(operations[this->oper], type, - op[0], NULL); + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], NULL); break; case ast_add: @@ -695,8 +700,8 @@ ast_expression::hir(exec_list *instructions, state, & loc); error_emitted = type->is_error(); - result = new ir_expression(operations[this->oper], type, - op[0], op[1]); + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); break; case ast_mod: @@ -707,8 +712,8 @@ ast_expression::hir(exec_list *instructions, assert(operations[this->oper] == ir_binop_mod); - result = new ir_expression(operations[this->oper], type, - op[0], op[1]); + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); error_emitted = type->is_error(); break; @@ -734,8 +739,8 @@ ast_expression::hir(exec_list *instructions, || ((type->base_type == GLSL_TYPE_BOOL) && type->is_scalar())); - result = new ir_expression(operations[this->oper], type, - op[0], op[1]); + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); error_emitted = type->is_error(); break; @@ -766,8 +771,8 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; } - result = new ir_expression(operations[this->oper], glsl_type::bool_type, - op[0], op[1]); + result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], op[1]); type = glsl_type::bool_type; assert(result->type == glsl_type::bool_type); @@ -811,7 +816,7 @@ ast_expression::hir(exec_list *instructions, } type = glsl_type::bool_type; } else { - ir_if *const stmt = new ir_if(op[0]); + ir_if *const stmt = new(ctx) ir_if(op[0]); instructions->push_tail(stmt); op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); @@ -828,17 +833,17 @@ ast_expression::hir(exec_list *instructions, ir_variable *const tmp = generate_temporary(glsl_type::bool_type, instructions, state); - ir_dereference *const then_deref = new ir_dereference_variable(tmp); + ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); ir_assignment *const then_assign = - new ir_assignment(then_deref, op[1], NULL); + new(ctx) ir_assignment(then_deref, op[1], NULL); stmt->then_instructions.push_tail(then_assign); - ir_dereference *const else_deref = new ir_dereference_variable(tmp); + ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp); ir_assignment *const else_assign = - new ir_assignment(else_deref, new ir_constant(false), NULL); + new(ctx) ir_assignment(else_deref, new(ctx) ir_constant(false), NULL); stmt->else_instructions.push_tail(else_assign); - result = new ir_dereference_variable(tmp); + result = new(ctx) ir_dereference_variable(tmp); type = tmp->type; } break; @@ -874,7 +879,7 @@ ast_expression::hir(exec_list *instructions, } type = glsl_type::bool_type; } else { - ir_if *const stmt = new ir_if(op[0]); + ir_if *const stmt = new(ctx) ir_if(op[0]); instructions->push_tail(stmt); ir_variable *const tmp = generate_temporary(glsl_type::bool_type, @@ -890,17 +895,17 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; } - ir_dereference *const then_deref = new ir_dereference_variable(tmp); + ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); ir_assignment *const then_assign = - new ir_assignment(then_deref, new ir_constant(true), NULL); + new(ctx) ir_assignment(then_deref, new(ctx) ir_constant(true), NULL); stmt->then_instructions.push_tail(then_assign); - ir_dereference *const else_deref = new ir_dereference_variable(tmp); + ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp); ir_assignment *const else_assign = - new ir_assignment(else_deref, op[1], NULL); + new(ctx) ir_assignment(else_deref, op[1], NULL); stmt->else_instructions.push_tail(else_assign); - result = new ir_dereference_variable(tmp); + result = new(ctx) ir_dereference_variable(tmp); type = tmp->type; } break; @@ -911,8 +916,8 @@ ast_expression::hir(exec_list *instructions, op[1] = this->subexpressions[1]->hir(instructions, state); - result = new ir_expression(operations[this->oper], glsl_type::bool_type, - op[0], op[1]); + result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], op[1]); type = glsl_type::bool_type; break; @@ -927,8 +932,8 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; } - result = new ir_expression(operations[this->oper], glsl_type::bool_type, - op[0], NULL); + result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], NULL); type = glsl_type::bool_type; break; @@ -943,8 +948,8 @@ ast_expression::hir(exec_list *instructions, (this->oper == ast_mul_assign), state, & loc); - ir_rvalue *temp_rhs = new ir_expression(operations[this->oper], type, - op[0], op[1]); + ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); result = do_assignment(instructions, state, (ir_rvalue *)op[0]->clone(NULL), temp_rhs, @@ -969,8 +974,8 @@ ast_expression::hir(exec_list *instructions, assert(operations[this->oper] == ir_binop_mod); struct ir_rvalue *temp_rhs; - temp_rhs = new ir_expression(operations[this->oper], type, - op[0], op[1]); + temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); result = do_assignment(instructions, state, (ir_rvalue *)op[0]->clone(NULL), temp_rhs, @@ -1056,22 +1061,24 @@ ast_expression::hir(exec_list *instructions, ir_variable *const tmp = generate_temporary(type, instructions, state); - ir_if *const stmt = new ir_if(op[0]); + ir_if *const stmt = new(ctx) ir_if(op[0]); instructions->push_tail(stmt); then_instructions.move_nodes_to(& stmt->then_instructions); - ir_dereference *const then_deref = new ir_dereference_variable(tmp); + ir_dereference *const then_deref = + new(ctx) ir_dereference_variable(tmp); ir_assignment *const then_assign = - new ir_assignment(then_deref, op[1], NULL); + new(ctx) ir_assignment(then_deref, op[1], NULL); stmt->then_instructions.push_tail(then_assign); else_instructions.move_nodes_to(& stmt->else_instructions); - ir_dereference *const else_deref = new ir_dereference_variable(tmp); + ir_dereference *const else_deref = + new(ctx) ir_dereference_variable(tmp); ir_assignment *const else_assign = - new ir_assignment(else_deref, op[2], NULL); + new(ctx) ir_assignment(else_deref, op[2], NULL); stmt->else_instructions.push_tail(else_assign); - result = new ir_dereference_variable(tmp); + result = new(ctx) ir_dereference_variable(tmp); } break; } @@ -1080,15 +1087,15 @@ ast_expression::hir(exec_list *instructions, case ast_pre_dec: { op[0] = this->subexpressions[0]->hir(instructions, state); if (op[0]->type->base_type == GLSL_TYPE_FLOAT) - op[1] = new ir_constant(1.0f); + op[1] = new(ctx) ir_constant(1.0f); else - op[1] = new ir_constant(1); + op[1] = new(ctx) ir_constant(1); type = arithmetic_result_type(op[0], op[1], false, state, & loc); struct ir_rvalue *temp_rhs; - temp_rhs = new ir_expression(operations[this->oper], type, - op[0], op[1]); + temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); result = do_assignment(instructions, state, (ir_rvalue *)op[0]->clone(NULL), temp_rhs, @@ -1102,17 +1109,17 @@ ast_expression::hir(exec_list *instructions, case ast_post_dec: { op[0] = this->subexpressions[0]->hir(instructions, state); if (op[0]->type->base_type == GLSL_TYPE_FLOAT) - op[1] = new ir_constant(1.0f); + op[1] = new(ctx) ir_constant(1.0f); else - op[1] = new ir_constant(1); + op[1] = new(ctx) ir_constant(1); error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); type = arithmetic_result_type(op[0], op[1], false, state, & loc); struct ir_rvalue *temp_rhs; - temp_rhs = new ir_expression(operations[this->oper], type, - op[0], op[1]); + temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); /* Get a temporary of a copy of the lvalue before it's modified. * This may get thrown away later. @@ -1143,7 +1150,7 @@ ast_expression::hir(exec_list *instructions, ir_rvalue *const array = op[0]; - result = new ir_dereference_array(op[0], op[1]); + result = new(ctx) ir_dereference_array(op[0], op[1]); /* Do not use op[0] after this point. Use array. */ @@ -1259,7 +1266,7 @@ ast_expression::hir(exec_list *instructions, ir_variable *var = state->symbols->get_variable(this->primary_expression.identifier); - result = new ir_dereference_variable(var); + result = new(ctx) ir_dereference_variable(var); if (var != NULL) { type = result->type; @@ -1274,22 +1281,22 @@ ast_expression::hir(exec_list *instructions, case ast_int_constant: type = glsl_type::int_type; - result = new ir_constant(this->primary_expression.int_constant); + result = new(ctx) ir_constant(this->primary_expression.int_constant); break; case ast_uint_constant: type = glsl_type::uint_type; - result = new ir_constant(this->primary_expression.uint_constant); + result = new(ctx) ir_constant(this->primary_expression.uint_constant); break; case ast_float_constant: type = glsl_type::float_type; - result = new ir_constant(this->primary_expression.float_constant); + result = new(ctx) ir_constant(this->primary_expression.float_constant); break; case ast_bool_constant: type = glsl_type::bool_type; - result = new ir_constant(bool(this->primary_expression.bool_constant)); + result = new(ctx) ir_constant(bool(this->primary_expression.bool_constant)); break; case ast_sequence: { @@ -1528,6 +1535,7 @@ ir_rvalue * ast_declarator_list::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); const struct glsl_type *decl_type; const char *type_name = NULL; ir_rvalue *result = NULL; @@ -1588,7 +1596,7 @@ ast_declarator_list::hir(exec_list *instructions, var_type = decl_type; } - var = new ir_variable(var_type, decl->identifier); + var = new(ctx) ir_variable(var_type, decl->identifier); /* From page 22 (page 28 of the PDF) of the GLSL 1.10 specification; * @@ -1788,7 +1796,7 @@ ast_declarator_list::hir(exec_list *instructions, ? "attribute" : "varying"); } - ir_dereference *const lhs = new ir_dereference_variable(var); + ir_dereference *const lhs = new(ctx) ir_dereference_variable(var); ir_rvalue *rhs = decl->initializer->hir(instructions, state); /* Calculate the constant value if this is a const or uniform @@ -1866,6 +1874,7 @@ ir_rvalue * ast_parameter_declarator::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); const struct glsl_type *type; const char *name = NULL; YYLTYPE loc = this->get_location(); @@ -1913,7 +1922,7 @@ ast_parameter_declarator::hir(exec_list *instructions, } is_void = false; - ir_variable *var = new ir_variable(type, this->identifier); + ir_variable *var = new(ctx) ir_variable(type, this->identifier); /* FINISHME: Handle array declarations. Note that this requires * FINISHME: complete handling of constant expressions. @@ -1966,6 +1975,7 @@ ir_rvalue * ast_function::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); ir_function *f = NULL; ir_function_signature *sig = NULL; exec_list hir_parameters; @@ -2025,7 +2035,7 @@ ast_function::hir(exec_list *instructions, "non-function", name); sig = NULL; } else { - f = new ir_function(name); + f = new(ctx) ir_function(name); state->symbols->add_function(f->name, f); /* Emit the new function header */ @@ -2050,7 +2060,7 @@ ast_function::hir(exec_list *instructions, /* Finish storing the information about this new function in its signature. */ if (sig == NULL) { - sig = new ir_function_signature(return_type); + sig = new(ctx) ir_function_signature(return_type); f->add_signature(sig); } @@ -2115,6 +2125,7 @@ ir_rvalue * ast_jump_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); switch (mode) { case ast_return: { @@ -2140,7 +2151,7 @@ ast_jump_statement::hir(exec_list *instructions, * FINISHME: type of the enclosing function. */ - inst = new ir_return(ret); + inst = new(ctx) ir_return(ret); } else { if (state->current_function->return_type->base_type != GLSL_TYPE_VOID) { @@ -2151,7 +2162,7 @@ ast_jump_statement::hir(exec_list *instructions, "non-void", state->current_function->function_name()); } - inst = new ir_return; + inst = new(ctx) ir_return; } instructions->push_tail(inst); @@ -2188,9 +2199,9 @@ ast_jump_statement::hir(exec_list *instructions, if (loop != NULL) { ir_loop_jump *const jump = - new ir_loop_jump((mode == ast_break) - ? ir_loop_jump::jump_break - : ir_loop_jump::jump_continue); + new(ctx) ir_loop_jump((mode == ast_break) + ? ir_loop_jump::jump_break + : ir_loop_jump::jump_continue); instructions->push_tail(jump); } } @@ -2208,6 +2219,8 @@ ir_rvalue * ast_selection_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); + ir_rvalue *const condition = this->condition->hir(instructions, state); /* From page 66 (page 72 of the PDF) of the GLSL 1.50 spec: @@ -2226,7 +2239,7 @@ ast_selection_statement::hir(exec_list *instructions, "boolean"); } - ir_if *const stmt = new ir_if(condition); + ir_if *const stmt = new(ctx) ir_if(condition); if (then_statement != NULL) then_statement->hir(& stmt->then_instructions, state); @@ -2246,6 +2259,8 @@ void ast_iteration_statement::condition_to_hir(ir_loop *stmt, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); + if (condition != NULL) { ir_rvalue *const cond = condition->hir(& stmt->body_instructions, state); @@ -2261,13 +2276,13 @@ ast_iteration_statement::condition_to_hir(ir_loop *stmt, * like 'if (!condition) break;' as the loop termination condition. */ ir_rvalue *const not_cond = - new ir_expression(ir_unop_logic_not, glsl_type::bool_type, cond, - NULL); + new(ctx) ir_expression(ir_unop_logic_not, glsl_type::bool_type, cond, + NULL); - ir_if *const if_stmt = new ir_if(not_cond); + ir_if *const if_stmt = new(ctx) ir_if(not_cond); ir_jump *const break_stmt = - new ir_loop_jump(ir_loop_jump::jump_break); + new(ctx) ir_loop_jump(ir_loop_jump::jump_break); if_stmt->then_instructions.push_tail(break_stmt); stmt->body_instructions.push_tail(if_stmt); @@ -2280,6 +2295,8 @@ ir_rvalue * ast_iteration_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); + /* For-loops and while-loops start a new scope, but do-while loops do not. */ if (mode != ast_do_while) @@ -2288,7 +2305,7 @@ ast_iteration_statement::hir(exec_list *instructions, if (init_statement != NULL) init_statement->hir(instructions, state); - ir_loop *const stmt = new ir_loop(); + ir_loop *const stmt = new(ctx) ir_loop(); instructions->push_tail(stmt); /* Track the current loop and / or switch-statement nesting. diff --git a/glsl_types.cpp b/glsl_types.cpp index ca19de6bec3..fcc77458b28 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -150,14 +150,16 @@ const glsl_type *glsl_type::get_base_type() const ir_function * glsl_type::generate_constructor(glsl_symbol_table *symtab) const { + void *ctx = symtab; + /* Generate the function name and add it to the symbol table. */ - ir_function *const f = new ir_function(name); + ir_function *const f = new(ctx) ir_function(name); bool added = symtab->add_function(name, f); assert(added); - ir_function_signature *const sig = new ir_function_signature(this); + ir_function_signature *const sig = new(ctx) ir_function_signature(this); f->add_signature(sig); ir_variable **declarations = @@ -168,8 +170,8 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const snprintf(param_name, 10, "p%08X", i); ir_variable *var = (this->base_type == GLSL_TYPE_ARRAY) - ? new ir_variable(fields.array, param_name) - : new ir_variable(fields.structure[i].type, param_name); + ? new(ctx) ir_variable(fields.array, param_name) + : new(ctx) ir_variable(fields.structure[i].type, param_name); var->mode = ir_var_in; declarations[i] = var; @@ -181,24 +183,26 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const * the same type as the constructor. After initializing __retval, * __retval is returned. */ - ir_variable *retval = new ir_variable(this, "__retval"); + ir_variable *retval = new(ctx) ir_variable(this, "__retval"); sig->body.push_tail(retval); for (unsigned i = 0; i < length; i++) { ir_dereference *const lhs = (this->base_type == GLSL_TYPE_ARRAY) - ? (ir_dereference *) new ir_dereference_array(retval, new ir_constant(i)) - : (ir_dereference *) new ir_dereference_record(retval, fields.structure[i].name); + ? (ir_dereference *) new(ctx) ir_dereference_array(retval, + new(ctx) ir_constant(i)) + : (ir_dereference *) new(ctx) ir_dereference_record(retval, + fields.structure[i].name); - ir_dereference *const rhs = new ir_dereference_variable(declarations[i]); - ir_instruction *const assign = new ir_assignment(lhs, rhs, NULL); + ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[i]); + ir_instruction *const assign = new(ctx) ir_assignment(lhs, rhs, NULL); sig->body.push_tail(assign); } free(declarations); - ir_dereference *const retref = new ir_dereference_variable(retval); - ir_instruction *const inst = new ir_return(retref); + ir_dereference *const retref = new(ctx) ir_dereference_variable(retval); + ir_instruction *const inst = new(ctx) ir_return(retref); sig->body.push_tail(inst); return f; @@ -223,6 +227,8 @@ static ir_function_signature * generate_constructor_intro(const glsl_type *type, unsigned parameter_count, ir_variable **declarations) { + /* NULL is wrong here and leaks. */ + void *ctx = NULL; /* Names of parameters used in vector and matrix constructors */ static const char *const names[] = { @@ -234,10 +240,10 @@ generate_constructor_intro(const glsl_type *type, unsigned parameter_count, const glsl_type *const parameter_type = type->get_base_type(); - ir_function_signature *const signature = new ir_function_signature(type); + ir_function_signature *const signature = new(ctx) ir_function_signature(type); for (unsigned i = 0; i < parameter_count; i++) { - ir_variable *var = new ir_variable(parameter_type, names[i]); + ir_variable *var = new(ctx) ir_variable(parameter_type, names[i]); var->mode = ir_var_in; signature->parameters.push_tail(var); @@ -245,7 +251,7 @@ generate_constructor_intro(const glsl_type *type, unsigned parameter_count, declarations[i] = var; } - ir_variable *retval = new ir_variable(type, "__retval"); + ir_variable *retval = new(ctx) ir_variable(type, "__retval"); signature->body.push_tail(retval); declarations[16] = retval; @@ -260,26 +266,28 @@ static void generate_vec_body_from_scalar(exec_list *instructions, ir_variable **declarations) { + /* NULL is wrong here and leaks. */ + void *ctx = NULL; ir_instruction *inst; /* Generate a single assignment of the parameter to __retval.x and return * __retval.xxxx for however many vector components there are. */ ir_dereference *const lhs_ref = - new ir_dereference_variable(declarations[16]); - ir_dereference *const rhs = new ir_dereference_variable(declarations[0]); + new(ctx) ir_dereference_variable(declarations[16]); + ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[0]); - ir_swizzle *lhs = new ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); + ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); - inst = new ir_assignment(lhs, rhs, NULL); + inst = new(ctx) ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); - ir_dereference *const retref = new ir_dereference_variable(declarations[16]); + ir_dereference *const retref = new(ctx) ir_dereference_variable(declarations[16]); - ir_swizzle *retval = new ir_swizzle(retref, 0, 0, 0, 0, - declarations[16]->type->vector_elements); + ir_swizzle *retval = new(ctx) ir_swizzle(retref, 0, 0, 0, 0, + declarations[16]->type->vector_elements); - inst = new ir_return(retval); + inst = new(ctx) ir_return(retval); instructions->push_tail(inst); } @@ -291,27 +299,28 @@ static void generate_vec_body_from_N_scalars(exec_list *instructions, ir_variable **declarations) { + /* NULL is wrong here and leaks. */ + void *ctx = NULL; ir_instruction *inst; const glsl_type *const vec_type = declarations[16]->type; - /* Generate an assignment of each parameter to a single component of * __retval.x and return __retval. */ for (unsigned i = 0; i < vec_type->vector_elements; i++) { ir_dereference *const lhs_ref = - new ir_dereference_variable(declarations[16]); - ir_dereference *const rhs = new ir_dereference_variable(declarations[i]); + new(ctx) ir_dereference_variable(declarations[16]); + ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[i]); - ir_swizzle *lhs = new ir_swizzle(lhs_ref, i, 0, 0, 0, 1); + ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, i, 0, 0, 0, 1); - inst = new ir_assignment(lhs, rhs, NULL); + inst = new(ctx) ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); } - ir_dereference *retval = new ir_dereference_variable(declarations[16]); + ir_dereference *retval = new(ctx) ir_dereference_variable(declarations[16]); - inst = new ir_return(retval); + inst = new(ctx) ir_return(retval); instructions->push_tail(inst); } @@ -323,6 +332,8 @@ static void generate_mat_body_from_scalar(exec_list *instructions, ir_variable **declarations) { + /* NULL is wrong here and leaks. */ + void *ctx = NULL; ir_instruction *inst; /* Generate an assignment of the parameter to the X component of a @@ -347,49 +358,50 @@ generate_mat_body_from_scalar(exec_list *instructions, */ const glsl_type *const column_type = declarations[16]->type->column_type(); const glsl_type *const row_type = declarations[16]->type->row_type(); - ir_variable *const column = new ir_variable(column_type, "v"); + + ir_variable *const column = new(ctx) ir_variable(column_type, "v"); instructions->push_tail(column); - ir_dereference *const lhs_ref = new ir_dereference_variable(column); - ir_dereference *const rhs = new ir_dereference_variable(declarations[0]); + ir_dereference *const lhs_ref = new(ctx) ir_dereference_variable(column); + ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[0]); - ir_swizzle *lhs = new ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); + ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); - inst = new ir_assignment(lhs, rhs, NULL); + inst = new(ctx) ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); for (unsigned i = 1; i < column_type->vector_elements; i++) { - ir_dereference *const lhs_ref = new ir_dereference_variable(column); - ir_constant *const zero = new ir_constant(0.0f); + ir_dereference *const lhs_ref = new(ctx) ir_dereference_variable(column); + ir_constant *const zero = new(ctx) ir_constant(0.0f); - ir_swizzle *lhs = new ir_swizzle(lhs_ref, i, 0, 0, 0, 1); + ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, i, 0, 0, 0, 1); - inst = new ir_assignment(lhs, zero, NULL); + inst = new(ctx) ir_assignment(lhs, zero, NULL); instructions->push_tail(inst); } for (unsigned i = 0; i < row_type->vector_elements; i++) { static const unsigned swiz[] = { 1, 1, 1, 0, 1, 1, 1 }; - ir_dereference *const rhs_ref = new ir_dereference_variable(column); + ir_dereference *const rhs_ref = new(ctx) ir_dereference_variable(column); /* This will be .xyyy when i=0, .yxyy when i=1, etc. */ - ir_swizzle *rhs = new ir_swizzle(rhs_ref, swiz[3 - i], swiz[4 - i], - swiz[5 - i], swiz[6 - i], - column_type->vector_elements); + ir_swizzle *rhs = new(ctx) ir_swizzle(rhs_ref, swiz[3 - i], swiz[4 - i], + swiz[5 - i], swiz[6 - i], + column_type->vector_elements); - ir_constant *const idx = new ir_constant(int(i)); + ir_constant *const idx = new(ctx) ir_constant(int(i)); ir_dereference *const lhs = - new ir_dereference_array(declarations[16], idx); + new(ctx) ir_dereference_array(declarations[16], idx); - inst = new ir_assignment(lhs, rhs, NULL); + inst = new(ctx) ir_assignment(lhs, rhs, NULL); instructions->push_tail(inst); } - ir_dereference *const retval = new ir_dereference_variable(declarations[16]); - inst = new ir_return(retval); + ir_dereference *const retval = new(ctx) ir_dereference_variable(declarations[16]); + inst = new(ctx) ir_return(retval); instructions->push_tail(inst); } @@ -401,35 +413,36 @@ static void generate_mat_body_from_N_scalars(exec_list *instructions, ir_variable **declarations) { + /* NULL is wrong here and leaks. */ + void *ctx = NULL; ir_instruction *inst; const glsl_type *const row_type = declarations[16]->type->row_type(); const glsl_type *const column_type = declarations[16]->type->column_type(); - /* Generate an assignment of each parameter to a single component of * of a particular column of __retval and return __retval. */ for (unsigned i = 0; i < column_type->vector_elements; i++) { for (unsigned j = 0; j < row_type->vector_elements; j++) { - ir_constant *row_index = new ir_constant(int(i)); + ir_constant *row_index = new(ctx) ir_constant(int(i)); ir_dereference *const row_access = - new ir_dereference_array(declarations[16], row_index); + new(ctx) ir_dereference_array(declarations[16], row_index); - ir_swizzle *component_access = new ir_swizzle(row_access, - j, 0, 0, 0, 1); + ir_swizzle *component_access = new(ctx) ir_swizzle(row_access, + j, 0, 0, 0, 1); const unsigned param = (i * row_type->vector_elements) + j; ir_dereference *const rhs = - new ir_dereference_variable(declarations[param]); + new(ctx) ir_dereference_variable(declarations[param]); - inst = new ir_assignment(component_access, rhs, NULL); + inst = new(ctx) ir_assignment(component_access, rhs, NULL); instructions->push_tail(inst); } } - ir_dereference *retval = new ir_dereference_variable(declarations[16]); + ir_dereference *retval = new(ctx) ir_dereference_variable(declarations[16]); - inst = new ir_return(retval); + inst = new(ctx) ir_return(retval); instructions->push_tail(inst); } @@ -444,6 +457,7 @@ static void generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, unsigned num_types, exec_list *instructions) { + void *ctx = symtab; ir_variable *declarations[17]; for (unsigned i = 0; i < num_types; i++) { @@ -459,7 +473,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, /* Generate the function block, add it to the symbol table, and emit it. */ - ir_function *const f = new ir_function(types[i].name); + ir_function *const f = new(ctx) ir_function(types[i].name); bool added = symtab->add_function(types[i].name, f); assert(added); diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index e60ea30d7ff..6da14925b98 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -33,6 +33,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); ir_rvalue *result = NULL; ir_rvalue *op; @@ -62,8 +63,8 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, expr->primary_expression.identifier); } } else if (op->type->base_type == GLSL_TYPE_STRUCT) { - result = new ir_dereference_record(op, - expr->primary_expression.identifier); + result = new(ctx) ir_dereference_record(op, + expr->primary_expression.identifier); if (result->type->is_error()) { _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " diff --git a/ir.cpp b/ir.cpp index 98b085e91bf..26cd4755520 100644 --- a/ir.cpp +++ b/ir.cpp @@ -300,15 +300,17 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) ir_instruction * ir_constant::clone(struct hash_table *ht) const { + void *ctx = talloc_parent(this); + switch (this->type->base_type) { case GLSL_TYPE_UINT: case GLSL_TYPE_INT: case GLSL_TYPE_FLOAT: case GLSL_TYPE_BOOL: - return new ir_constant(this->type, &this->value); + return new(ctx) ir_constant(this->type, &this->value); case GLSL_TYPE_STRUCT: { - ir_constant *c = new ir_constant; + ir_constant *c = new(ctx)ir_constant; c->type = this->type; for (exec_node *node = this->components.head @@ -497,8 +499,10 @@ ir_dereference_array::ir_dereference_array(ir_rvalue *value, ir_dereference_array::ir_dereference_array(ir_variable *var, ir_rvalue *array_index) { + void *ctx = talloc_parent(var); + this->array_index = array_index; - this->set_array(new ir_dereference_variable(var)); + this->set_array(new(ctx) ir_dereference_variable(var)); } @@ -535,7 +539,9 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value, ir_dereference_record::ir_dereference_record(ir_variable *var, const char *field) { - this->record = new ir_dereference_variable(var); + void *ctx = talloc_parent(var); + + this->record = new(ctx) ir_dereference_variable(var); this->field = field; this->type = (this->record != NULL) ? this->record->type->field_type(field) : glsl_type::error_type; @@ -646,6 +652,8 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) ir_swizzle * ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) { + void *ctx = talloc_parent(val); + /* For each possible swizzle character, this table encodes the value in * \c idx_map that represents the 0th element of the vector. For invalid * swizzle characters (e.g., 'k'), a special value is used that will allow @@ -710,8 +718,8 @@ ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) if (str[i] != '\0') return NULL; - return new ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2], - swiz_idx[3], i); + return new(ctx) ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2], + swiz_idx[3], i); } #undef X @@ -811,7 +819,6 @@ ir_function_signature::replace_parameters(exec_list *new_params) assert(((ir_instruction *) iter.get())->as_variable() != NULL); iter.remove(); - delete (ir_instruction*) iter.get(); } new_params->move_nodes_to(¶meters); @@ -828,7 +835,9 @@ ir_function::ir_function(const char *name) ir_call * ir_call::get_error_instruction() { - ir_call *call = new ir_call; + /* NULL is wrong and leaks */ + void *ctx = NULL; + ir_call *call = new(ctx) ir_call; call->type = glsl_type::error_type; return call; diff --git a/ir_clone.cpp b/ir_clone.cpp index c810fe86164..5ffd3fc00b2 100644 --- a/ir_clone.cpp +++ b/ir_clone.cpp @@ -36,7 +36,8 @@ ir_instruction * ir_variable::clone(struct hash_table *ht) const { - ir_variable *var = new ir_variable(type, name); + void *ctx = talloc_parent(this); + ir_variable *var = new(ctx) ir_variable(type, name); var->max_array_access = this->max_array_access; var->read_only = this->read_only; @@ -55,32 +56,36 @@ ir_variable::clone(struct hash_table *ht) const ir_instruction * ir_swizzle::clone(struct hash_table *ht) const { - return new ir_swizzle((ir_rvalue *)this->val->clone(ht), this->mask); + void *ctx = talloc_parent(this); + return new(ctx) ir_swizzle((ir_rvalue *)this->val->clone(ht), this->mask); } ir_instruction * ir_return::clone(struct hash_table *ht) const { + void *ctx = talloc_parent(this); ir_rvalue *new_value = NULL; if (this->value) new_value = (ir_rvalue *)this->value->clone(ht); - return new ir_return(new_value); + return new(ctx) ir_return(new_value); } ir_instruction * ir_loop_jump::clone(struct hash_table *ht) const { + void *ctx = talloc_parent(this); (void)ht; - return new ir_loop_jump(this->mode); + return new(ctx) ir_loop_jump(this->mode); } ir_instruction * ir_if::clone(struct hash_table *ht) const { - ir_if *new_if = new ir_if((ir_rvalue *)this->condition->clone(ht)); + void *ctx = talloc_parent(this); + ir_if *new_if = new(ctx) ir_if((ir_rvalue *)this->condition->clone(ht)); foreach_iter(exec_list_iterator, iter, this->then_instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); @@ -98,7 +103,8 @@ ir_if::clone(struct hash_table *ht) const ir_instruction * ir_loop::clone(struct hash_table *ht) const { - ir_loop *new_loop = new ir_loop(); + void *ctx = talloc_parent(this); + ir_loop *new_loop = new(ctx) ir_loop(); if (this->from) new_loop->from = (ir_rvalue *)this->from->clone(ht); @@ -119,6 +125,7 @@ ir_loop::clone(struct hash_table *ht) const ir_instruction * ir_call::clone(struct hash_table *ht) const { + void *ctx = talloc_parent(this); exec_list new_parameters; foreach_iter(exec_list_iterator, iter, this->actual_parameters) { @@ -126,12 +133,13 @@ ir_call::clone(struct hash_table *ht) const new_parameters.push_tail(ir->clone(ht)); } - return new ir_call(this->callee, &new_parameters); + return new(ctx) ir_call(this->callee, &new_parameters); } ir_instruction * ir_expression::clone(struct hash_table *ht) const { + void *ctx = talloc_parent(this); ir_rvalue *op[2] = {NULL, NULL}; unsigned int i; @@ -139,12 +147,13 @@ ir_expression::clone(struct hash_table *ht) const op[i] = (ir_rvalue *)this->operands[i]->clone(ht); } - return new ir_expression(this->operation, this->type, op[0], op[1]); + return new(ctx) ir_expression(this->operation, this->type, op[0], op[1]); } ir_instruction * ir_dereference_variable::clone(struct hash_table *ht) const { + void *ctx = talloc_parent(this); ir_variable *new_var; if (ht) { @@ -155,27 +164,30 @@ ir_dereference_variable::clone(struct hash_table *ht) const new_var = this->var; } - return new ir_dereference_variable(new_var); + return new(ctx) ir_dereference_variable(new_var); } ir_instruction * ir_dereference_array::clone(struct hash_table *ht) const { - return new ir_dereference_array((ir_rvalue *)this->array->clone(ht), - (ir_rvalue *)this->array_index->clone(ht)); + void *ctx = talloc_parent(this); + return new(ctx) ir_dereference_array((ir_rvalue *)this->array->clone(ht), + (ir_rvalue *)this->array_index->clone(ht)); } ir_instruction * ir_dereference_record::clone(struct hash_table *ht) const { - return new ir_dereference_record((ir_rvalue *)this->record->clone(ht), - this->field); + void *ctx = talloc_parent(this); + return new(ctx) ir_dereference_record((ir_rvalue *)this->record->clone(ht), + this->field); } ir_instruction * ir_texture::clone(struct hash_table *ht) const { - ir_texture *new_tex = new ir_texture(this->op); + void *ctx = talloc_parent(this); + ir_texture *new_tex = new(ctx) ir_texture(this->op); new_tex->sampler = (ir_dereference *)this->sampler->clone(ht); new_tex->coordinate = (ir_rvalue *)this->coordinate->clone(ht); @@ -218,9 +230,10 @@ ir_assignment::clone(struct hash_table *ht) const if (this->condition) new_condition = (ir_rvalue *)this->condition->clone(ht); - return new ir_assignment((ir_rvalue *)this->lhs->clone(ht), - (ir_rvalue *)this->rhs->clone(ht), - new_condition); + void *ctx = talloc_parent(this); + return new(ctx) ir_assignment((ir_rvalue *)this->lhs->clone(ht), + (ir_rvalue *)this->rhs->clone(ht), + new_condition); } ir_instruction * diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index effb88844ee..4010e462674 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -127,6 +127,7 @@ ir_constant_visitor::visit(ir_function *ir) void ir_constant_visitor::visit(ir_expression *ir) { + void *ctx = talloc_parent(ir); value = NULL; ir_constant *op[2]; unsigned int operand, c; @@ -497,7 +498,7 @@ ir_constant_visitor::visit(ir_expression *ir) return; } - this->value = new ir_constant(ir->type, &data); + this->value = new(ctx) ir_constant(ir->type, &data); } @@ -513,6 +514,7 @@ ir_constant_visitor::visit(ir_texture *ir) void ir_constant_visitor::visit(ir_swizzle *ir) { + void *ctx = talloc_parent(ir); ir_constant *v = ir->val->constant_expression_value(); this->value = NULL; @@ -534,7 +536,7 @@ ir_constant_visitor::visit(ir_swizzle *ir) } } - this->value = new ir_constant(ir->type, &data); + this->value = new(ctx) ir_constant(ir->type, &data); } } @@ -553,6 +555,7 @@ ir_constant_visitor::visit(ir_dereference_variable *ir) void ir_constant_visitor::visit(ir_dereference_array *ir) { + void *ctx = talloc_parent(ir); ir_constant *array = ir->array->constant_expression_value(); ir_constant *idx = ir->array_index->constant_expression_value(); @@ -592,11 +595,11 @@ ir_constant_visitor::visit(ir_dereference_array *ir) break; } - this->value = new ir_constant(column_type, &data); + this->value = new(ctx) ir_constant(column_type, &data); } else if (array->type->is_vector()) { const unsigned component = idx->value.u[0]; - this->value = new ir_constant(array, component); + this->value = new(ctx) ir_constant(array, component); } else { /* FINISHME: Handle access of constant arrays. */ } diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index 16a2ba79bf6..46ef6679d9f 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -197,6 +197,7 @@ kill_invalidated_copies(ir_assignment *ir, exec_list *acp) static void add_copy(ir_assignment *ir, exec_list *acp) { + void *ctx = talloc_parent(ir); acp_entry *entry; if (ir->condition) { @@ -209,7 +210,7 @@ add_copy(ir_assignment *ir, exec_list *acp) ir_variable *rhs_var = ir->rhs->whole_variable_referenced(); if ((lhs_var != NULL) && (rhs_var != NULL)) { - entry = new acp_entry(lhs_var, rhs_var); + entry = new(ctx) acp_entry(lhs_var, rhs_var); acp->push_tail(entry); } } diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp index 8465d863aa3..01b7d2d832a 100644 --- a/ir_dead_code.cpp +++ b/ir_dead_code.cpp @@ -77,6 +77,7 @@ public: variable_entry * ir_dead_code_visitor::get_variable_entry(ir_variable *var) { + void *ctx = talloc_parent(var); assert(var); foreach_iter(exec_list_iterator, iter, this->variable_list) { variable_entry *entry = (variable_entry *)iter.get(); @@ -84,7 +85,7 @@ ir_dead_code_visitor::get_variable_entry(ir_variable *var) return entry; } - variable_entry *entry = new variable_entry(var); + variable_entry *entry = new(ctx) variable_entry(var); this->variable_list.push_tail(entry); return entry; } diff --git a/ir_dead_code_local.cpp b/ir_dead_code_local.cpp index d3b3858617d..e01877077c9 100644 --- a/ir_dead_code_local.cpp +++ b/ir_dead_code_local.cpp @@ -113,6 +113,7 @@ public: static bool process_assignment(ir_assignment *ir, exec_list *assignments) { + void *ctx = talloc_parent(ir); ir_variable *var = NULL; bool progress = false; kill_for_derefs_visitor v(assignments); @@ -157,7 +158,7 @@ process_assignment(ir_assignment *ir, exec_list *assignments) } /* Add this instruction to the assignment list. */ - assignment_entry *entry = new assignment_entry(var, ir); + assignment_entry *entry = new(ctx) assignment_entry(var, ir); assignments->push_tail(entry); if (debug) { diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp index 3089f17ae14..5ba24e390b4 100644 --- a/ir_expression_flattening.cpp +++ b/ir_expression_flattening.cpp @@ -80,18 +80,19 @@ do_expression_flattening(exec_list *instructions, static ir_rvalue * operand_to_temp(ir_instruction *base_ir, ir_rvalue *ir) { + void *ctx = talloc_parent(base_ir); ir_variable *var; ir_assignment *assign; - var = new ir_variable(ir->type, "flattening_tmp"); + var = new(ctx) ir_variable(ir->type, "flattening_tmp"); base_ir->insert_before(var); - assign = new ir_assignment(new ir_dereference_variable(var), - ir, - NULL); + assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), + ir, + NULL); base_ir->insert_before(assign); - return new ir_dereference_variable(var); + return new(ctx) ir_dereference_variable(var); } ir_visitor_status diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index effb01c8f68..8a1cf4f1d24 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -94,6 +94,7 @@ do_function_inlining(exec_list *instructions) ir_rvalue * ir_call::generate_inline(ir_instruction *next_ir) { + void *ctx = talloc_parent(this); ir_variable **parameters; int num_parameters; int i; @@ -110,7 +111,7 @@ ir_call::generate_inline(ir_instruction *next_ir) /* Generate storage for the return value. */ if (this->callee->return_type) { - retval = new ir_variable(this->callee->return_type, "__retval"); + retval = new(ctx) ir_variable(this->callee->return_type, "__retval"); next_ir->insert_before(retval); } @@ -133,8 +134,8 @@ ir_call::generate_inline(ir_instruction *next_ir) parameters[i]->mode == ir_var_inout) { ir_assignment *assign; - assign = new ir_assignment(new ir_dereference_variable(parameters[i]), - param, NULL); + assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]), + param, NULL); next_ir->insert_before(assign); } @@ -162,9 +163,9 @@ ir_call::generate_inline(ir_instruction *next_ir) parameters[i]->mode == ir_var_inout) { ir_assignment *assign; - assign = new ir_assignment(param->as_rvalue(), - new ir_dereference_variable(parameters[i]), - NULL); + assign = new(ctx) ir_assignment(param->as_rvalue(), + new(ctx) ir_dereference_variable(parameters[i]), + NULL); next_ir->insert_before(assign); } @@ -176,7 +177,7 @@ ir_call::generate_inline(ir_instruction *next_ir) hash_table_dtor(ht); if (retval) - return new ir_dereference_variable(retval); + return new(ctx) ir_dereference_variable(retval); else return NULL; } diff --git a/ir_reader.cpp b/ir_reader.cpp index ee320ddac28..d6985c4981c 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -70,7 +70,8 @@ void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, const char *src) { - s_expression *expr = s_expression::read_expression(src); + void *ctx = talloc_parent(state); + s_expression *expr = s_expression::read_expression(ctx, src); if (expr == NULL) { ir_read_error(state, NULL, "couldn't parse S-Expression."); return; @@ -190,6 +191,7 @@ scan_for_prototypes(_mesa_glsl_parse_state *st, exec_list *instructions, static ir_function * read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) { + void *ctx = talloc_parent(st); if (list->length() < 3) { ir_read_error(st, list, "Expected (function (signature ...) ...)"); return NULL; @@ -203,7 +205,7 @@ read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) ir_function *f = st->symbols->get_function(name->value()); if (f == NULL) { - f = new ir_function(name->value()); + f = new(ctx) ir_function(name->value()); bool added = st->symbols->add_function(name->value(), f); assert(added); } @@ -233,6 +235,7 @@ static void read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list, bool skip_body) { + void *ctx = talloc_parent(st); if (list->length() != 4) { ir_read_error(st, list, "Expected (signature (parameters ...) " "( ...))"); @@ -286,7 +289,7 @@ read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list, return; } } else { - sig = new ir_function_signature(return_type); + sig = new(ctx) ir_function_signature(return_type); f->add_signature(sig); } @@ -331,12 +334,13 @@ static ir_instruction * read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, ir_loop *loop_ctx) { + void *ctx = talloc_parent(st); s_symbol *symbol = SX_AS_SYMBOL(expr); if (symbol != NULL) { if (strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL) - return new ir_loop_jump(ir_loop_jump::jump_break); + return new(ctx) ir_loop_jump(ir_loop_jump::jump_break); if (strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL) - return new ir_loop_jump(ir_loop_jump::jump_continue); + return new(ctx) ir_loop_jump(ir_loop_jump::jump_continue); } s_list *list = SX_AS_LIST(expr); @@ -372,6 +376,7 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, static ir_variable * read_declaration(_mesa_glsl_parse_state *st, s_list *list) { + void *ctx = talloc_parent(st); if (list->length() != 4) { ir_read_error(st, list, "expected (declare () " ")"); @@ -395,7 +400,7 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) return NULL; } - ir_variable *var = new ir_variable(type, var_name->value()); + ir_variable *var = new(ctx) ir_variable(type, var_name->value()); foreach_iter(exec_list_iterator, it, quals->subexpressions) { s_symbol *qualifier = SX_AS_SYMBOL(it.get()); @@ -443,6 +448,7 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) static ir_if * read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx) { + void *ctx = talloc_parent(st); if (list->length() != 4) { ir_read_error(st, list, "expected (if ( ...) " "( ...))"); @@ -459,7 +465,7 @@ read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx) s_expression *then_expr = (s_expression*) cond_expr->next; s_expression *else_expr = (s_expression*) then_expr->next; - ir_if *iff = new 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); @@ -474,6 +480,7 @@ 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) { + void *ctx = talloc_parent(st); if (list->length() != 6) { ir_read_error(st, list, "expected (loop " " )"); @@ -488,7 +495,7 @@ read_loop(_mesa_glsl_parse_state *st, s_list *list) // FINISHME: actually read the count/from/to fields. - ir_loop *loop = new ir_loop; + ir_loop *loop = new(ctx) ir_loop; read_instructions(st, &loop->body_instructions, body_expr, loop); if (st->error) { delete loop; @@ -501,6 +508,7 @@ read_loop(_mesa_glsl_parse_state *st, s_list *list) static ir_return * read_return(_mesa_glsl_parse_state *st, s_list *list) { + void *ctx = talloc_parent(st); if (list->length() != 2) { ir_read_error(st, list, "expected (return )"); return NULL; @@ -514,7 +522,7 @@ read_return(_mesa_glsl_parse_state *st, s_list *list) return NULL; } - return new ir_return(retval); + return new(ctx) ir_return(retval); } @@ -556,6 +564,7 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) static ir_assignment * read_assignment(_mesa_glsl_parse_state *st, s_list *list) { + void *ctx = talloc_parent(st); if (list->length() != 4) { ir_read_error(st, list, "expected (assign )"); return NULL; @@ -584,12 +593,13 @@ read_assignment(_mesa_glsl_parse_state *st, s_list *list) return NULL; } - return new ir_assignment(lhs, rhs, condition); + return new(ctx) ir_assignment(lhs, rhs, condition); } static ir_call * read_call(_mesa_glsl_parse_state *st, s_list *list) { + void *ctx = talloc_parent(st); if (list->length() != 3) { ir_read_error(st, list, "expected (call ( ...))"); return NULL; @@ -628,12 +638,13 @@ read_call(_mesa_glsl_parse_state *st, s_list *list) return NULL; } - return new ir_call(callee, ¶meters); + return new(ctx) ir_call(callee, ¶meters); } static ir_expression * read_expression(_mesa_glsl_parse_state *st, s_list *list) { + void *ctx = talloc_parent(st); const unsigned list_length = list->length(); if (list_length < 4) { ir_read_error(st, list, "expected (expression " @@ -693,7 +704,7 @@ read_expression(_mesa_glsl_parse_state *st, s_list *list) } } - return new ir_expression(op, type, arg1, arg2); + return new(ctx) ir_expression(op, type, arg1, arg2); } static ir_swizzle * @@ -738,6 +749,7 @@ read_swizzle(_mesa_glsl_parse_state *st, s_list *list) static ir_constant * read_constant(_mesa_glsl_parse_state *st, s_list *list) { + void *ctx = talloc_parent(st); if (list->length() != 3) { ir_read_error(st, list, "expected (constant ( ... ))"); return NULL; @@ -803,7 +815,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) ++k; } - return new ir_constant(type, &data); + return new(ctx) ir_constant(type, &data); } static ir_dereference * @@ -828,6 +840,7 @@ read_dereference(_mesa_glsl_parse_state *st, s_expression *expr) static ir_dereference * read_var_ref(_mesa_glsl_parse_state *st, s_list *list) { + void *ctx = talloc_parent(st); if (list->length() != 2) { ir_read_error(st, list, "expected (var_ref )"); return NULL; @@ -844,12 +857,13 @@ read_var_ref(_mesa_glsl_parse_state *st, s_list *list) return NULL; } - return new ir_dereference_variable(var); + return new(ctx) ir_dereference_variable(var); } static ir_dereference * read_array_ref(_mesa_glsl_parse_state *st, s_list *list) { + void *ctx = talloc_parent(st); if (list->length() != 3) { ir_read_error(st, list, "expected (array_ref )"); return NULL; @@ -864,12 +878,13 @@ read_array_ref(_mesa_glsl_parse_state *st, s_list *list) s_expression *idx_expr = (s_expression*) subj_expr->next; ir_rvalue *idx = read_rvalue(st, idx_expr); - return new ir_dereference_array(subject, idx); + return new(ctx) ir_dereference_array(subject, idx); } static ir_dereference * read_record_ref(_mesa_glsl_parse_state *st, s_list *list) { + void *ctx = talloc_parent(st); if (list->length() != 3) { ir_read_error(st, list, "expected (record_ref )"); return NULL; @@ -887,7 +902,7 @@ read_record_ref(_mesa_glsl_parse_state *st, s_list *list) ir_read_error(st, list, "expected (record_ref ... )"); return NULL; } - return new ir_dereference_record(subject, field->value()); + return new(ctx) ir_dereference_record(subject, field->value()); } static bool @@ -905,6 +920,7 @@ valid_texture_list_length(ir_texture_opcode op, s_list *list) static ir_texture * read_texture(_mesa_glsl_parse_state *st, s_list *list) { + void *ctx = talloc_parent(st); s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head); assert(tag != NULL); @@ -917,7 +933,7 @@ read_texture(_mesa_glsl_parse_state *st, s_list *list) return NULL; } - ir_texture *tex = new ir_texture(op); + ir_texture *tex = new(ctx) ir_texture(op); // Read sampler (must be a deref) s_expression *sampler_expr = (s_expression *) tag->next; diff --git a/ir_variable.cpp b/ir_variable.cpp index efebe9199fa..fabd856591a 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -35,7 +35,7 @@ add_variable(const char *name, enum ir_variable_mode mode, int slot, const glsl_type *type, exec_list *instructions, glsl_symbol_table *symtab) { - ir_variable *var = new ir_variable(type, name); + ir_variable *var = new(symtab) ir_variable(type, name); var->mode = mode; switch (var->mode) { diff --git a/ir_vec_index_to_swizzle.cpp b/ir_vec_index_to_swizzle.cpp index eb0e556c9db..bbd873791a1 100644 --- a/ir_vec_index_to_swizzle.cpp +++ b/ir_vec_index_to_swizzle.cpp @@ -60,6 +60,7 @@ public: ir_rvalue * ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) { + void *ctx = talloc_parent(ir); ir_dereference_array *deref = ir->as_dereference_array(); ir_constant *ir_constant; @@ -75,7 +76,8 @@ ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) return ir; this->progress = true; - return new ir_swizzle(deref->array, ir_constant->value.i[0], 0, 0, 0, 1); + return new(ctx) ir_swizzle(deref->array, + ir_constant->value.i[0], 0, 0, 0, 1); } ir_visitor_status diff --git a/list.h b/list.h index 0b91647be4f..7732d66d7a6 100644 --- a/list.h +++ b/list.h @@ -66,7 +66,13 @@ #ifndef __cplusplus #include +#include +#else +extern "C" { +#include +} #endif + #include struct exec_node { @@ -74,6 +80,25 @@ struct exec_node { struct exec_node *prev; #ifdef __cplusplus + /* Callers of this talloc-based new need not call delete. It's + * easier to just talloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *node; + + node = talloc_size(ctx, size); + assert(node != NULL); + + return node; + } + + /* If the user *does* call delete, that's OK, we will just + * talloc_free in that case. */ + static void operator delete(void *node) + { + talloc_free(node); + } + exec_node() : next(NULL), prev(NULL) { /* empty */ diff --git a/s_expression.cpp b/s_expression.cpp index 0fb296ef671..875d739d842 100644 --- a/s_expression.cpp +++ b/s_expression.cpp @@ -49,7 +49,7 @@ s_list::length() const } static s_expression * -read_atom(const char *& src) +read_atom(void *ctx, const char *& src) { char buf[101]; int n; @@ -65,20 +65,20 @@ read_atom(const char *& src) int i = strtol(buf, &int_end, 10); // If strtod matched more characters, it must have a decimal part if (float_end > int_end) - return new s_float(f); + return new(ctx) s_float(f); - return new s_int(i); + return new(ctx) s_int(i); } // Not a number; return a symbol. - return new s_symbol(buf); + return new(ctx) s_symbol(buf); } s_expression * -s_expression::read_expression(const char *&src) +s_expression::read_expression(void *ctx, const char *&src) { assert(src != NULL); - s_expression *atom = read_atom(src); + s_expression *atom = read_atom(ctx, src); if (atom != NULL) return atom; @@ -87,10 +87,10 @@ s_expression::read_expression(const char *&src) if (sscanf(src, " %c%n", &c, &n) == 1 && c == '(') { src += n; - s_list *list = new s_list; + s_list *list = new(ctx) s_list; s_expression *expr; - while ((expr = read_expression(src)) != NULL) { + while ((expr = read_expression(ctx, src)) != NULL) { list->subexpressions.push_tail(expr); } if (sscanf(src, " %c%n", &c, &n) != 1 || c != ')') { diff --git a/s_expression.h b/s_expression.h index 8a4eda28dae..1a0c03c2189 100644 --- a/s_expression.h +++ b/s_expression.h @@ -49,8 +49,10 @@ public: /** * Read an S-Expression from the given string. * Advances the supplied pointer to just after the expression read. + * + * Any allocation will be performed with 'ctx' as the talloc owner. */ - static s_expression *read_expression(const char *&src); + static s_expression *read_expression(void *ctx, const char *&src); /** * Print out an S-Expression. Useful for debugging. -- cgit v1.2.3 From 522de3f5ecbfe3f84e92ac03d1438a44eb1beae7 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 18:19:46 -0700 Subject: Close memory leaks from generate_constructor_intro By simply propagating a 'ctx' parameter through these function calls. (We do this because these function are otherwise only receiving an exec_list, which is not a valid talloc context.) This closes 1611 leaks in the glsl-orangebook-ch06-bump.frag test: total heap usage: 55,623 allocs, 44,283 frees (was 42,672 frees) --- glsl_types.cpp | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/glsl_types.cpp b/glsl_types.cpp index fcc77458b28..7dcb4a4caf2 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -224,11 +224,10 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const * the symbol table. */ static ir_function_signature * -generate_constructor_intro(const glsl_type *type, unsigned parameter_count, +generate_constructor_intro(void *ctx, + const glsl_type *type, unsigned parameter_count, ir_variable **declarations) { - /* NULL is wrong here and leaks. */ - void *ctx = NULL; /* Names of parameters used in vector and matrix constructors */ static const char *const names[] = { @@ -263,11 +262,10 @@ generate_constructor_intro(const glsl_type *type, unsigned parameter_count, * Generate the body of a vector constructor that takes a single scalar */ static void -generate_vec_body_from_scalar(exec_list *instructions, +generate_vec_body_from_scalar(void *ctx, + exec_list *instructions, ir_variable **declarations) { - /* NULL is wrong here and leaks. */ - void *ctx = NULL; ir_instruction *inst; /* Generate a single assignment of the parameter to __retval.x and return @@ -296,11 +294,10 @@ generate_vec_body_from_scalar(exec_list *instructions, * Generate the body of a vector constructor that takes multiple scalars */ static void -generate_vec_body_from_N_scalars(exec_list *instructions, +generate_vec_body_from_N_scalars(void *ctx, + exec_list *instructions, ir_variable **declarations) { - /* NULL is wrong here and leaks. */ - void *ctx = NULL; ir_instruction *inst; const glsl_type *const vec_type = declarations[16]->type; @@ -329,11 +326,10 @@ generate_vec_body_from_N_scalars(exec_list *instructions, * Generate the body of a matrix constructor that takes a single scalar */ static void -generate_mat_body_from_scalar(exec_list *instructions, +generate_mat_body_from_scalar(void *ctx, + exec_list *instructions, ir_variable **declarations) { - /* NULL is wrong here and leaks. */ - void *ctx = NULL; ir_instruction *inst; /* Generate an assignment of the parameter to the X component of a @@ -410,11 +406,10 @@ generate_mat_body_from_scalar(exec_list *instructions, * Generate the body of a vector constructor that takes multiple scalars */ static void -generate_mat_body_from_N_scalars(exec_list *instructions, +generate_mat_body_from_N_scalars(void *ctx, + exec_list *instructions, ir_variable **declarations) { - /* NULL is wrong here and leaks. */ - void *ctx = NULL; ir_instruction *inst; const glsl_type *const row_type = declarations[16]->type->row_type(); const glsl_type *const column_type = declarations[16]->type->column_type(); @@ -498,31 +493,33 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, * appropriate from-scalars constructor. */ ir_function_signature *const sig = - generate_constructor_intro(&types[i], 1, declarations); + generate_constructor_intro(ctx, &types[i], 1, declarations); f->add_signature(sig); if (types[i].is_vector()) { - generate_vec_body_from_scalar(&sig->body, declarations); + generate_vec_body_from_scalar(ctx, &sig->body, declarations); ir_function_signature *const vec_sig = - generate_constructor_intro(&types[i], types[i].vector_elements, + generate_constructor_intro(ctx, + &types[i], types[i].vector_elements, declarations); f->add_signature(vec_sig); - generate_vec_body_from_N_scalars(&vec_sig->body, declarations); + generate_vec_body_from_N_scalars(ctx, &vec_sig->body, declarations); } else { assert(types[i].is_matrix()); - generate_mat_body_from_scalar(&sig->body, declarations); + generate_mat_body_from_scalar(ctx, &sig->body, declarations); ir_function_signature *const mat_sig = - generate_constructor_intro(&types[i], + generate_constructor_intro(ctx, + &types[i], (types[i].vector_elements * types[i].matrix_columns), declarations); f->add_signature(mat_sig); - generate_mat_body_from_N_scalars(&mat_sig->body, declarations); + generate_mat_body_from_N_scalars(ctx, &mat_sig->body, declarations); } } } -- cgit v1.2.3 From e01193af325cbdde51b3219c85c58f19d5a87f1b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 18:25:04 -0700 Subject: Close memory leak in ir_call::get_error_instruction. By propagating a 'ctx' parameter through these calls. This fix happens to have no impact on glsl-orangebook-ch06-bump.frag, (since it doesn't trigger any errors). --- ast_function.cpp | 32 +++++++++++++++++--------------- hir_field_selection.cpp | 2 +- ir.cpp | 4 +--- ir.h | 4 +++- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 866cbc4ecdf..9550d4d2f02 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -104,7 +104,7 @@ process_call(exec_list *instructions, ir_function *f, */ _mesa_glsl_error(loc, state, "no matching function for call to `%s'", f->name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } } @@ -114,11 +114,12 @@ match_function_by_name(exec_list *instructions, const char *name, YYLTYPE *loc, exec_list *actual_parameters, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); ir_function *f = state->symbols->get_function(name); if (f == NULL) { _mesa_glsl_error(loc, state, "function `%s' undeclared", name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } /* Once we've determined that the function being called might exist, try @@ -238,6 +239,7 @@ process_array_constructor(exec_list *instructions, YYLTYPE *loc, exec_list *parameters, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); /* Array constructors come in two forms: sized and unsized. Sized array * constructors look like 'vec4[2](a, b)', where 'a' and 'b' are vec4 * variables. In this case the number of parameters must exactly match the @@ -272,7 +274,7 @@ process_array_constructor(exec_list *instructions, "parameter%s", (constructor_type->length != 0) ? "at least" : "exactly", min_param, (min_param <= 1) ? "" : "s"); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } if (constructor_type->length == 0) { @@ -468,14 +470,14 @@ ast_function_expression::hir(exec_list *instructions, if (constructor_type->is_sampler()) { _mesa_glsl_error(& loc, state, "cannot construct sampler type `%s'", constructor_type->name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } if (constructor_type->is_array()) { if (state->language_version <= 110) { _mesa_glsl_error(& loc, state, "array constructors forbidden in GLSL 1.10"); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } return process_array_constructor(instructions, constructor_type, @@ -525,7 +527,7 @@ ast_function_expression::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "too few components to construct " "`%s'", constructor_type->name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } foreach_list (n, &this->expressions) { @@ -555,14 +557,14 @@ ast_function_expression::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "too many parameters to `%s' " "constructor", constructor_type->name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } if (!result->type->is_numeric() && !result->type->is_boolean()) { _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " "non-numeric data type", constructor_type->name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } /* Count the number of matrix and nonmatrix parameters. This @@ -637,7 +639,7 @@ ast_function_expression::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " "matrix in GLSL 1.10", constructor_type->name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: @@ -651,7 +653,7 @@ ast_function_expression::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, " "matrix must be only parameter", constructor_type->name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: @@ -664,14 +666,14 @@ ast_function_expression::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "too few components to construct " "`%s'", constructor_type->name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } ir_function *f = state->symbols->get_function(constructor_type->name); if (f == NULL) { _mesa_glsl_error(& loc, state, "no constructor for type `%s'", constructor_type->name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } const ir_function_signature *sig = @@ -715,11 +717,11 @@ ast_function_expression::hir(exec_list *instructions, */ _mesa_glsl_error(& loc, state, "no matching constructor for `%s'", constructor_type->name); - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } } - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } else { const ast_expression *id = subexpressions[0]; YYLTYPE loc = id->get_location(); @@ -744,5 +746,5 @@ ast_function_expression::hir(exec_list *instructions, &actual_parameters, state); } - return ir_call::get_error_instruction(); + return ir_call::get_error_instruction(ctx); } diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 6da14925b98..e2efff60d34 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -77,5 +77,5 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, expr->primary_expression.identifier); } - return result ? result : ir_call::get_error_instruction(); + return result ? result : ir_call::get_error_instruction(ctx); } diff --git a/ir.cpp b/ir.cpp index 26cd4755520..6286d874e67 100644 --- a/ir.cpp +++ b/ir.cpp @@ -833,10 +833,8 @@ ir_function::ir_function(const char *name) ir_call * -ir_call::get_error_instruction() +ir_call::get_error_instruction(void *ctx) { - /* NULL is wrong and leaks */ - void *ctx = NULL; ir_call *call = new(ctx) ir_call; call->type = glsl_type::error_type; diff --git a/ir.h b/ir.h index 68e90653ed7..1c95512fb18 100644 --- a/ir.h +++ b/ir.h @@ -645,8 +645,10 @@ public: /** * Get a generic ir_call object when an error occurs + * + * Any allocation will be performed with 'ctx' as talloc owner. */ - static ir_call *get_error_instruction(); + static ir_call *get_error_instruction(void *ctx); /** * Get an iterator for the set of acutal parameters -- cgit v1.2.3 From 007efe50fdd87c8ceb2a700b6105ce6f00ba56e8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 18:30:55 -0700 Subject: s_symbol: Close memory leak of symbol name. Easily done now that s_expression is allocated with talloc. Simply switch from new to talloc_strdup and the job is done. This closes the great majority (11263) of the remaining leaks in the glsl-orangebook-ch06-bump.frag test: total heap usage: 55,623 allocs, 55,546 frees (was 44,283 frees) This test is now 99.86% leak-free. --- s_expression.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s_expression.cpp b/s_expression.cpp index 875d739d842..26be23ea8fa 100644 --- a/s_expression.cpp +++ b/s_expression.cpp @@ -30,8 +30,8 @@ s_symbol::s_symbol(const char *tmp) { - this->str = new char [strlen(tmp) + 1]; - strcpy(this->str, tmp); + this->str = talloc_strdup (this, tmp); + assert(this->str != NULL); } s_list::s_list() -- cgit v1.2.3 From a9696e79fb3afc6a4724bd16ee1ccdfebebfd0fd Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 18 Jun 2010 17:37:02 -0700 Subject: main: Close memory leak of shader string from load_text_file. Could have just added a call to free() to main, but since we're using talloc everywhere else, we might as well just use it here too. So pass a new 'ctx' argument to load_text_file. This removes a single memory leak from all invocations of the standalone glsl compiler. --- main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index dcd4b8f6725..dfed4a30e83 100644 --- a/main.cpp +++ b/main.cpp @@ -36,9 +36,9 @@ #include "ir_print_visitor.h" #include "program.h" - +/* Returned string will have 'ctx' as its talloc owner. */ static char * -load_text_file(const char *file_name, size_t *size) +load_text_file(void *ctx, const char *file_name, size_t *size) { char *text = NULL; struct stat st; @@ -51,7 +51,7 @@ load_text_file(const char *file_name, size_t *size) } if (fstat(fd, & st) == 0) { - text = (char *) malloc(st.st_size + 1); + text = (char *) talloc_size(ctx, st.st_size + 1); if (text != NULL) { do { ssize_t bytes = read(fd, text + total_read, @@ -229,7 +229,8 @@ main(int argc, char **argv) else usage_fail(argv[0]); - shader->Source = load_text_file(argv[optind], &shader->SourceLen); + shader->Source = load_text_file(whole_program, + argv[optind], &shader->SourceLen); if (shader->Source == NULL) { printf("File \"%s\" does not exist.\n", argv[optind]); exit(EXIT_FAILURE); -- cgit v1.2.3 From dc5811fd0c7600b165ddd4e04a0ccae69bb19ec8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 18 Jun 2010 17:43:40 -0700 Subject: Close memory leak in lexer. Simply call talloc_strdup rather than strdup, (using the talloc_parent of our 'state' object, (known here as yyextra). This fix now makes glsl-orangebook-ch06-bump.frag 99.97% leak free: total heap usage: 55,623 allocs, 55,609 frees Only 14 missing frees now. --- glsl_lexer.lpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index c15c99c4b06..fa439f12787 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -312,7 +312,9 @@ highp return HIGHP; precision return PRECISION; [_a-zA-Z][_a-zA-Z0-9]* { - yylval->identifier = strdup(yytext); + struct _mesa_glsl_parse_state *state = yyextra; + void *ctx = talloc_parent(state); + yylval->identifier = talloc_strdup(ctx, yytext); return IDENTIFIER; } -- cgit v1.2.3 From 12c411504ca86341f8b96c349c15413ee198cc71 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 18 Jun 2010 17:52:59 -0700 Subject: Close memory leaks in glsl_type (constructor and get_array_instance) Add a talloc ctx to both get_array_instance and the glsl_type constructor in order to be able to call talloc_size instead of malloc. This fix now makes glsl-orangebook-ch06-bump.frag 99.99% leak free: total heap usage: 55,623 allocs, 55,615 Only 8 missing frees now. --- ast_function.cpp | 3 ++- ast_to_hir.cpp | 5 +++-- glsl_types.cpp | 11 ++++++----- glsl_types.h | 5 +++-- ir_reader.cpp | 2 +- ir_variable.cpp | 17 ++++++++++------- 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 9550d4d2f02..761af00b95e 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -279,7 +279,8 @@ process_array_constructor(exec_list *instructions, if (constructor_type->length == 0) { constructor_type = - glsl_type::get_array_instance(constructor_type->element_type(), + glsl_type::get_array_instance(state, + constructor_type->element_type(), parameter_count); assert(constructor_type != NULL); assert(constructor_type->length == parameter_count); diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index eafc9e81145..38e344f0d25 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -506,7 +506,8 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, var->max_array_access); } - var->type = glsl_type::get_array_instance(lhs->type->element_type(), + var->type = glsl_type::get_array_instance(state, + lhs->type->element_type(), rhs->type->array_size()); } } @@ -1409,7 +1410,7 @@ process_array_type(const glsl_type *base, ast_node *array_size, } } - return glsl_type::get_array_instance(base, length); + return glsl_type::get_array_instance(state, base, length); } diff --git a/glsl_types.cpp b/glsl_types.cpp index 7dcb4a4caf2..d1b9dc64121 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -574,7 +574,7 @@ _mesa_glsl_initialize_constructors(exec_list *instructions, } -glsl_type::glsl_type(const glsl_type *array, unsigned length) : +glsl_type::glsl_type(void *ctx, const glsl_type *array, unsigned length) : base_type(GLSL_TYPE_ARRAY), sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), sampler_type(0), @@ -588,7 +588,7 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) : * NUL. */ const unsigned name_length = strlen(array->name) + 10 + 3; - char *const n = (char *) malloc(name_length); + char *const n = (char *) talloc_size(ctx, name_length); if (length == 0) snprintf(n, name_length, "%s[]", array->name); @@ -691,9 +691,10 @@ glsl_type::array_key_hash(const void *a) const glsl_type * -glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) +glsl_type::get_array_instance(void *ctx, const glsl_type *base, + unsigned array_size) { - const glsl_type key(base, array_size); + const glsl_type key(ctx, base, array_size); if (array_types == NULL) { array_types = hash_table_ctor(64, array_key_hash, array_key_compare); @@ -701,7 +702,7 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) const glsl_type *t = (glsl_type *) hash_table_find(array_types, & key); if (t == NULL) { - t = new glsl_type(base, array_size); + t = new glsl_type(ctx, base, array_size); hash_table_insert(array_types, (void *) t, t); } diff --git a/glsl_types.h b/glsl_types.h index 939c173fd41..baec763c42f 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -198,7 +198,8 @@ struct glsl_type { /** * Get the instance of an array type */ - static const glsl_type *get_array_instance(const glsl_type *base, + static const glsl_type *get_array_instance(void *ctx, + const glsl_type *base, unsigned elements); /** @@ -387,7 +388,7 @@ private: /** * Constructor for array types */ - glsl_type(const glsl_type *array, unsigned length); + glsl_type(void *ctx, const glsl_type *array, unsigned length); /** Hash table containing the known array types. */ static struct hash_table *array_types; diff --git a/ir_reader.cpp b/ir_reader.cpp index d6985c4981c..7383c42cbc7 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -138,7 +138,7 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) return NULL; } - return glsl_type::get_array_instance(base_type, size->value()); + return glsl_type::get_array_instance(st, base_type, size->value()); } else if (strcmp(type_sym->value(), "struct") == 0) { assert(false); // FINISHME } else { diff --git a/ir_variable.cpp b/ir_variable.cpp index fabd856591a..15a4a92f628 100644 --- a/ir_variable.cpp +++ b/ir_variable.cpp @@ -104,7 +104,7 @@ generate_110_uniforms(exec_list *instructions, * FINISHME: for now. */ const glsl_type *const mat4_array_type = - glsl_type::get_array_instance(glsl_type::mat4_type, 4); + glsl_type::get_array_instance(symtab, glsl_type::mat4_type, 4); add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type, instructions, symtab); @@ -122,7 +122,8 @@ generate_110_uniforms(exec_list *instructions, * FINISHME: at least 8, so hard-code 8 for now. */ const glsl_type *const light_source_array_type = - glsl_type::get_array_instance(symtab->get_type("gl_LightSourceParameters"), 8); + glsl_type::get_array_instance(symtab, + symtab->get_type("gl_LightSourceParameters"), 8); add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type, instructions, symtab); @@ -157,7 +158,7 @@ generate_110_vs_variables(exec_list *instructions, * FINISHME: for now. */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, 4); + glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 4); add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type, instructions, symtab); @@ -179,6 +180,7 @@ static void generate_130_vs_variables(exec_list *instructions, glsl_symbol_table *symtab) { + void *ctx = symtab; generate_120_vs_variables(instructions, symtab); for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { @@ -190,7 +192,7 @@ generate_130_vs_variables(exec_list *instructions, * FINISHME: the value of GL_MAX_CLIP_DISTANCES. */ const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(glsl_type::float_type, 8); + glsl_type::get_array_instance(ctx, glsl_type::float_type, 8); /* FINISHME: gl_ClipDistance needs a real location assigned. */ add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type, @@ -240,7 +242,7 @@ generate_110_fs_variables(exec_list *instructions, * FINISHME: for now. */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, 4); + glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 4); add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type, instructions, symtab); @@ -256,7 +258,7 @@ generate_ARB_draw_buffers_fs_variables(exec_list *instructions, * FINISHME: at least 1, so hard-code 1 for now. */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, 1); + glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 1); ir_variable *const fd = add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0, @@ -279,13 +281,14 @@ static void generate_130_fs_variables(exec_list *instructions, glsl_symbol_table *symtab) { + void *ctx = symtab; generate_120_fs_variables(instructions, symtab); /* FINISHME: The size of this array is implementation dependent based on * FINISHME: the value of GL_MAX_CLIP_DISTANCES. */ const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(glsl_type::float_type, 8); + glsl_type::get_array_instance(ctx, glsl_type::float_type, 8); /* FINISHME: gl_ClipDistance needs a real location assigned. */ add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type, -- cgit v1.2.3 From b3bd77da56ce8aa225ee91565e4d1e640685728c Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 19:04:45 -0700 Subject: glsl_type: Add a talloc-based new And hook it up at the two sites it's called. Note that with this change we still don't use glsl_type* objects as talloc contexts, (see things like get_array_instance that accept both a talloc 'ctx' as well as a glsl_type*). The reason for this is that the code is still using many instance of glsl_type objects not created with new. This closes 3 leaks in the glsl-orangebook-ch06-bump.frag test: total heap usage: 55,623 allocs, 55,618 Leaving only 5 leaks to go. --- ast_to_hir.cpp | 3 ++- glsl_types.cpp | 2 +- glsl_types.h | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 38e344f0d25..ddd4b732662 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2354,6 +2354,7 @@ ir_rvalue * ast_struct_specifier::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + void *ctx = talloc_parent(state); unsigned decl_count = 0; /* Make an initial pass over the list of structure fields to determine how @@ -2416,7 +2417,7 @@ ast_struct_specifier::hir(exec_list *instructions, name = this->name; } - glsl_type *t = new glsl_type(fields, decl_count, name); + glsl_type *t = new(ctx) glsl_type(fields, decl_count, name); YYLTYPE loc = this->get_location(); if (!state->symbols->add_type(name, t)) { diff --git a/glsl_types.cpp b/glsl_types.cpp index d1b9dc64121..bef267fa6be 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -702,7 +702,7 @@ glsl_type::get_array_instance(void *ctx, const glsl_type *base, const glsl_type *t = (glsl_type *) hash_table_find(array_types, & key); if (t == NULL) { - t = new glsl_type(ctx, base, array_size); + t = new(ctx) glsl_type(ctx, base, array_size); hash_table_insert(array_types, (void *) t, t); } diff --git a/glsl_types.h b/glsl_types.h index baec763c42f..39e6ac970aa 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -29,6 +29,10 @@ #include #include +extern "C" { +#include +} + #define GLSL_TYPE_UINT 0 #define GLSL_TYPE_INT 1 #define GLSL_TYPE_FLOAT 2 @@ -61,6 +65,25 @@ struct glsl_type { * and \c GLSL_TYPE_UINT are valid. */ + /* Callers of this talloc-based new need not call delete. It's + * easier to just talloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *type; + + type = talloc_size(ctx, size); + assert(type != NULL); + + return type; + } + + /* If the user *does* call delete, that's OK, we will just + * talloc_free in that case. */ + static void operator delete(void *type) + { + talloc_free(type); + } + /** * \name Vector and matrix element counts * -- cgit v1.2.3 From 26bbfb7917a71d46d9227bbf960606cb673636d3 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 23 Jun 2010 19:09:56 -0700 Subject: glsl2 main: Switch from realloc to talloc_realloc to construct program source. This closes 1 leak in the glsl-orangebook-ch06-bump.frag test leaving 4 to go, (all of which are inside hash_table.c). --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index dfed4a30e83..dcd9bd69c0c 100644 --- a/main.cpp +++ b/main.cpp @@ -206,8 +206,8 @@ main(int argc, char **argv) for (/* empty */; argc > optind; optind++) { whole_program->Shaders = (struct glsl_shader **) - realloc(whole_program->Shaders, - sizeof(struct glsl_shader *) * (whole_program->NumShaders + 1)); + talloc_realloc(whole_program, whole_program->Shaders, + struct glsl_shader *, whole_program->NumShaders + 1); assert(whole_program->Shaders != NULL); struct glsl_shader *shader = talloc_zero(whole_program, glsl_shader); -- cgit v1.2.3 From 1b2bcf791365f7bab282e38808efadba19291261 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 13:31:34 -0700 Subject: Fix variable remapping in function cloning. It's (ht, data, key) not (ht, key, data). --- ir_clone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir_clone.cpp b/ir_clone.cpp index c810fe86164..cb4b02b7de9 100644 --- a/ir_clone.cpp +++ b/ir_clone.cpp @@ -46,7 +46,7 @@ ir_variable::clone(struct hash_table *ht) const var->interpolation = this->interpolation; if (ht) { - hash_table_insert(ht, (void *)const_cast(this), var); + hash_table_insert(ht, var, (void *)const_cast(this)); } return var; -- cgit v1.2.3 From f66ba4f3579d69841176bfe7ced9df80eac57a80 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 08:59:57 -0700 Subject: ir_function_inlining: Re-add the "s/return/retval =/" functionality. I ripped it out with the cloning changes yesterday, and should have tested and noticed that there were now returns all over. --- ir_function_inlining.cpp | 24 +++++++++++++++++++++++- ir_hierarchical_visitor.cpp | 14 ++++++++++++++ ir_hierarchical_visitor.h | 5 ++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index effb01c8f68..d74de650e0a 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -91,6 +91,26 @@ do_function_inlining(exec_list *instructions) return v.progress; } +static void +replace_return_with_assignment(ir_instruction *ir, void *data) +{ + ir_variable *retval = (ir_variable *)data; + ir_return *ret = ir->as_return(); + + if (ret) { + if (ret->value) { + ir_rvalue *lhs = new ir_dereference_variable(retval); + ret->insert_before(new ir_assignment(lhs, ret->value, NULL)); + ret->remove(); + } else { + /* un-valued return has to be the last return, or we shouldn't + * have reached here. (see can_inline()). + */ + assert(!ret->next->is_tail_sentinal()); + } + } +} + ir_rvalue * ir_call::generate_inline(ir_instruction *next_ir) { @@ -145,8 +165,10 @@ ir_call::generate_inline(ir_instruction *next_ir) /* Generate the inlined body of the function. */ foreach_iter(exec_list_iterator, iter, callee->body) { ir_instruction *ir = (ir_instruction *)iter.get(); + ir_instruction *new_ir = ir->clone(ht); - next_ir->insert_before(ir->clone(ht)); + next_ir->insert_before(new_ir); + visit_tree(new_ir, replace_return_with_assignment, retval); } /* Copy back the value of any 'out' parameters from the function body diff --git a/ir_hierarchical_visitor.cpp b/ir_hierarchical_visitor.cpp index 63ce8784adb..0d520b127f2 100644 --- a/ir_hierarchical_visitor.cpp +++ b/ir_hierarchical_visitor.cpp @@ -268,3 +268,17 @@ ir_hierarchical_visitor::run(exec_list *instructions) break; } } + + +void +visit_tree(ir_instruction *ir, + void (*callback)(class ir_instruction *ir, void *data), + void *data) +{ + ir_hierarchical_visitor v; + + v.callback = callback; + v.data = data; + + ir->accept(&v); +} diff --git a/ir_hierarchical_visitor.h b/ir_hierarchical_visitor.h index e741155e19f..8b9e49dab13 100644 --- a/ir_hierarchical_visitor.h +++ b/ir_hierarchical_visitor.h @@ -139,7 +139,6 @@ public: */ void run(struct exec_list *instructions); -protected: /** * Callback function that is invoked on entry to each node visited. * @@ -156,4 +155,8 @@ protected: void *data; }; +void visit_tree(ir_instruction *ir, + void (*callback)(class ir_instruction *ir, void *data), + void *data); + #endif /* IR_HIERARCHICAL_VISITOR_H */ -- cgit v1.2.3 From ae805922b7e3cdaf3aee26c3b799fe3608669bba Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 09:06:12 -0700 Subject: Don't forget to add the declaration of our temporary variable for assigns. Otherwise, dead code elimination gets confused since it relies on seeing decls. --- ast_to_hir.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index c70f0f9de9f..25bbe2f2def 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -520,6 +520,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, * ends up not being used, the temp will get copy-propagated out. */ ir_variable *var = new ir_variable(rhs->type, "assignment_tmp"); + instructions->push_tail(var); instructions->push_tail(new ir_assignment(new ir_dereference_variable(var), rhs, NULL)); -- cgit v1.2.3 From 5f384088336c23c4fe332d2735450bf455c88200 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 23 Jun 2010 16:42:37 -0700 Subject: Move ir_constant cloning alongside the other cloning functions. --- ir.cpp | 31 ------------------------------- ir_clone.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/ir.cpp b/ir.cpp index 98b085e91bf..9252ccfd3a3 100644 --- a/ir.cpp +++ b/ir.cpp @@ -297,37 +297,6 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) } } -ir_instruction * -ir_constant::clone(struct hash_table *ht) const -{ - switch (this->type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_BOOL: - return new ir_constant(this->type, &this->value); - - case GLSL_TYPE_STRUCT: { - ir_constant *c = new ir_constant; - - c->type = this->type; - for (exec_node *node = this->components.head - ; !node->is_tail_sentinal() - ; node = node->next) { - ir_constant *const orig = (ir_constant *) node; - - c->components.push_tail(orig->clone(NULL)); - } - - return c; - } - - default: - assert(!"Should not get here."); break; - return NULL; - } -} - bool ir_constant::get_bool_component(unsigned i) const { diff --git a/ir_clone.cpp b/ir_clone.cpp index cb4b02b7de9..fe66510bfdf 100644 --- a/ir_clone.cpp +++ b/ir_clone.cpp @@ -238,3 +238,34 @@ ir_function_signature::clone(struct hash_table *ht) const /* FINISHME */ abort(); } + +ir_instruction * +ir_constant::clone(struct hash_table *ht) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + return new ir_constant(this->type, &this->value); + + case GLSL_TYPE_STRUCT: { + ir_constant *c = new ir_constant; + + c->type = this->type; + for (exec_node *node = this->components.head + ; !node->is_tail_sentinal() + ; node = node->next) { + ir_constant *const orig = (ir_constant *) node; + + c->components.push_tail(orig->clone(NULL)); + } + + return c; + } + + default: + assert(!"Should not get here."); break; + return NULL; + } +} -- cgit v1.2.3 From 9ca0a022e6fcd46a6ce06b8d08dd4c046ec215c4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 23 Jun 2010 16:43:08 -0700 Subject: Quiet unused arg warning for ir_constant cloning. --- ir_clone.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ir_clone.cpp b/ir_clone.cpp index fe66510bfdf..6db5073f75f 100644 --- a/ir_clone.cpp +++ b/ir_clone.cpp @@ -242,6 +242,8 @@ ir_function_signature::clone(struct hash_table *ht) const ir_instruction * ir_constant::clone(struct hash_table *ht) const { + (void)ht; + switch (this->type->base_type) { case GLSL_TYPE_UINT: case GLSL_TYPE_INT: -- cgit v1.2.3 From ebefeb2bdd9b440f4b515986667e2bfb3147fe35 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 09:07:38 -0700 Subject: Attach a pointer to variable names in LIR dumping. Since variable names are not unique, and we like to make lots of __retvals and assignment_tmps and a,b,c,d this helps in debugging. --- ir_print_visitor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index f15ffb66141..be5a843f67d 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -92,7 +92,7 @@ void ir_print_visitor::visit(ir_variable *ir) cent, inv, mode[ir->mode], interp[ir->interpolation]); print_type(ir->type); - printf(" %s)", ir->name); + printf(" %s@%p)", ir->name, ir); } @@ -220,7 +220,8 @@ void ir_print_visitor::visit(ir_swizzle *ir) void ir_print_visitor::visit(ir_dereference_variable *ir) { - printf("(var_ref %s) ", ir->variable_referenced()->name); + ir_variable *var = ir->variable_referenced(); + printf("(var_ref %s@%p) ", var->name, var); } -- cgit v1.2.3 From 84341f4b2014810b2964230384fe76338be1d78e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 19 Mar 2010 15:32:57 -0700 Subject: Make sure that symbols aren't multiply defined in the same scope. The assembly parser is already checking this, but we're relying on the symbol table handling it in glsl2. --- src/mesa/shader/symbol_table.c | 52 +++++++++++++++++++++++++++++++++++++++++- src/mesa/shader/symbol_table.h | 3 +++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/mesa/shader/symbol_table.c b/src/mesa/shader/symbol_table.c index 6a5d6868974..3fea5ee1f1f 100644 --- a/src/mesa/shader/symbol_table.c +++ b/src/mesa/shader/symbol_table.c @@ -58,7 +58,9 @@ struct symbol { */ int name_space; - + /** Scope depth where this symbol was defined. */ + unsigned depth; + /** * Arbitrary user supplied data. */ @@ -104,6 +106,9 @@ struct _mesa_symbol_table { /** List of all symbol headers in the table. */ struct symbol_header *hdr; + + /** Current scope depth. */ + unsigned depth; }; @@ -157,6 +162,7 @@ _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table) struct symbol *sym = scope->symbols; table->current_scope = scope->next; + table->depth--; free(scope); @@ -184,6 +190,7 @@ _mesa_symbol_table_push_scope(struct _mesa_symbol_table *table) scope->next = table->current_scope; table->current_scope = scope; + table->depth++; } @@ -261,6 +268,36 @@ _mesa_symbol_table_iterator_next(struct _mesa_symbol_table_iterator *iter) } +/** + * Determine the scope "distance" of a symbol from the current scope + * + * \return + * A non-negative number for the number of scopes between the current scope + * and the scope where a symbol was defined. A value of zero means the current + * scope. A negative number if the symbol does not exist. + */ +int +_mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, + int name_space, const char *name) +{ + struct symbol_header *const hdr = find_symbol(table, name); + struct symbol *sym; + + if (hdr != NULL) { + for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { + assert(sym->hdr == hdr); + + if ((name_space == -1) || (sym->name_space == name_space)) { + assert(sym->depth <= table->depth); + return sym->depth - table->depth; + } + } + } + + return -1; +} + + void * _mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table, int name_space, const char *name) @@ -309,12 +346,25 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, check_symbol_table(table); + /* If the symbol already exists in this namespace at this scope, it cannot + * be added to the table. + */ + for (sym = hdr->symbols + ; (sym != NULL) && (sym->name_space != name_space) + ; sym = sym->next_with_same_name) { + /* empty */ + } + + if (sym && (sym->depth == table->depth)) + return -1; + sym = calloc(1, sizeof(*sym)); sym->next_with_same_name = hdr->symbols; sym->next_with_same_scope = table->current_scope->symbols; sym->hdr = hdr; sym->name_space = name_space; sym->data = declaration; + sym->depth = table->depth; assert(sym->hdr == hdr); diff --git a/src/mesa/shader/symbol_table.h b/src/mesa/shader/symbol_table.h index 0c054ef1396..1d570fc1a09 100644 --- a/src/mesa/shader/symbol_table.h +++ b/src/mesa/shader/symbol_table.h @@ -33,6 +33,9 @@ extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table); extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, int name_space, const char *name, void *declaration); +extern int _mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, + int name_space, const char *name); + extern void *_mesa_symbol_table_find_symbol( struct _mesa_symbol_table *symtab, int name_space, const char *name); -- cgit v1.2.3 From 9290e0dd28e646c3dc810e0a6405582f8bf643b6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 15:03:05 -0700 Subject: Make inlined function variables auto, not in/out. --- ir_function_inlining.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index d74de650e0a..851c0dd9f7b 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -146,11 +146,12 @@ ir_call::generate_inline(ir_instruction *next_ir) /* Generate a new variable for the parameter. */ parameters[i] = (ir_variable *)sig_param->clone(ht); + parameters[i]->mode = ir_var_auto; next_ir->insert_before(parameters[i]); /* Move the actual param into our param variable if it's an 'in' type. */ - if (parameters[i]->mode == ir_var_in || - parameters[i]->mode == ir_var_inout) { + if (sig_param->mode == ir_var_in || + sig_param->mode == ir_var_inout) { ir_assignment *assign; assign = new ir_assignment(new ir_dereference_variable(parameters[i]), -- cgit v1.2.3 From 84771df82ed2ed8718013795089edd38cf5bd84d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Apr 2010 09:02:09 -0700 Subject: ir_to_mesa: Start building GLSL IR to Mesa IR conversion. There are major missing pieces here. Most operations aren't supported. Matrices need to be broken down to vector ops before we get here. Scalar operations (RSQ, RCP) are handled incorrectly. Arrays and structures are not even considered. --- Makefile.am | 15 +- ir_to_mesa.cpp | 548 +++++++++++++++++++++++++++++++++++++++++ ir_to_mesa.h | 170 +++++++++++++ main/mtypes.h | 32 +++ mesa/shader/prog_instruction.h | 437 ++++++++++++++++++++++++++++++++ mesa_codegen.brg | 173 +++++++++++++ program.h | 2 +- 7 files changed, 1375 insertions(+), 2 deletions(-) create mode 100644 ir_to_mesa.cpp create mode 100644 ir_to_mesa.h create mode 100644 mesa/shader/prog_instruction.h create mode 100644 mesa_codegen.brg diff --git a/Makefile.am b/Makefile.am index a88bf0022ad..88d8f0587c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,6 +21,7 @@ # USE OR OTHER DEALINGS IN THE SOFTWARE. AUTOMAKE_OPTIONS = foreign +AM_CPPFLAGS = -I mesa SUBDIRS = glcpp @@ -57,9 +58,16 @@ glsl_SOURCES = \ ir_hierarchical_visitor.h \ ir_hierarchical_visitor.cpp \ ir_swizzle_swizzle.cpp \ + ir_to_mesa.cpp \ + ir_to_mesa.h \ ir_validate.cpp \ ir_vec_index_to_swizzle.cpp \ - linker.cpp + linker.cpp \ + mesa_codegen.cpp \ + msea_codegen.h + +DISTFILES = \ + mesa_codegen.brg BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) @@ -70,3 +78,8 @@ glsl_parser.h: glsl_parser.cpp .lpp.cpp: $(LEXCOMPILE) --outfile="$@" $< + +mesa_codegen.h: mesa_codegen.cpp + +mesa_codegen.cpp: mesa_codegen.brg + monoburg --no-glib -s $@ -d mesa_codegen.h $< diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp new file mode 100644 index 00000000000..5cbd451b214 --- /dev/null +++ b/ir_to_mesa.cpp @@ -0,0 +1,548 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_to_mesa.cpp + * + * Translates the IR to ARB_fragment_program text if possible, + * printing the result + * + * The code generation is performed using monoburg. Because monoburg + * produces a single C file with the definitions of the node types in + * it, this file is included from the monoburg output. + */ + +/* Quiet compiler warnings due to monoburg not marking functions defined + * in the header as inline. + */ +#define g_new +#define g_error +#include "mesa_codegen.h" + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_print_visitor.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +#include "shader/prog_instruction.h" + +ir_to_mesa_src_reg ir_to_mesa_undef = { + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP +}; + +ir_to_mesa_instruction * +ir_to_mesa_emit_op3(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1, + ir_to_mesa_src_reg src2) +{ + ir_to_mesa_instruction *inst = new ir_to_mesa_instruction(); + + inst->op = op; + inst->dst_reg = dst; + inst->src_reg[0] = src0; + inst->src_reg[1] = src1; + inst->src_reg[2] = src2; + + tree->v->instructions.push_tail(inst); + + return inst; +} + + +ir_to_mesa_instruction * +ir_to_mesa_emit_op2(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1) +{ + return ir_to_mesa_emit_op3(tree, op, dst, src0, src1, ir_to_mesa_undef); +} + +ir_to_mesa_instruction * +ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0) +{ + return ir_to_mesa_emit_op3(tree, op, + dst, src0, ir_to_mesa_undef, ir_to_mesa_undef); +} + +struct mbtree * +ir_to_mesa_visitor::create_tree(int op, struct mbtree *left, struct mbtree *right) +{ + struct mbtree *tree = (struct mbtree *)calloc(sizeof(struct mbtree), 1); + + tree->op = op; + tree->left = left; + tree->right = right; + tree->v = this; + tree->src_reg.swizzle = SWIZZLE_XYZW; + + return tree; +} + +const char * +produce_swizzle(int8_t *swizzle, const char *reg_name, + const char **swizzle_reg_name) +{ + if (swizzle[0] == 0 && + swizzle[1] == 1 && + swizzle[2] == 2 && + swizzle[3] == 3) + { + *swizzle_reg_name = reg_name; + } else { + char swizzle_letters[4] = { 'x', 'y', 'z', 'w' }; + char *temp; + asprintf(&temp, "%s.%c%c%c%c", + reg_name, + swizzle_letters[swizzle[0]], + swizzle_letters[swizzle[1]], + swizzle_letters[swizzle[2]], + swizzle_letters[swizzle[3]]); + *swizzle_reg_name = temp; + } + return *swizzle_reg_name; +} + +/** + * In the initial pass of codegen, we assign temporary numbers to + * intermediate results. (not SSA -- variable assignments will reuse + * storage). Actual register allocation for the Mesa VM occurs in a + * pass over the Mesa IR later. + */ +void +ir_to_mesa_visitor::get_temp(struct mbtree *tree) +{ + tree->src_reg.file = PROGRAM_TEMPORARY; + tree->src_reg.index = this->next_temp++; +} + +void +ir_to_mesa_visitor::get_temp_for_var(ir_variable *var, struct mbtree *tree) +{ + temp_entry *entry; + + foreach_iter(exec_list_iterator, iter, this->variable_storage) { + entry = (temp_entry *)iter.get(); + + if (entry->var == var) { + tree->src_reg.file = entry->file; + tree->src_reg.index = entry->index; + return; + } + } + + entry = new temp_entry(var, PROGRAM_TEMPORARY, this->next_temp++); + this->variable_storage.push_tail(entry); + + tree->src_reg.file = entry->file; + tree->src_reg.index = entry->index; +} + +static void +reduce(struct mbtree *t, int goal) +{ + struct mbtree *kids[10]; + int rule = mono_burg_rule((MBState *)t->state, goal); + const uint16_t *nts = mono_burg_nts[rule]; + int i; + + mono_burg_kids (t, rule, kids); + + for (i = 0; nts[i]; i++) { + reduce(kids[i], nts[i]); + } + + if (t->left) { + if (mono_burg_func[rule]) { + mono_burg_func[rule](t, NULL); + } else { + printf("no code for rules %s\n", mono_burg_rule_string[rule]); + exit(1); + } + } else { + if (mono_burg_func[rule]) { + printf("unused code for rule %s\n", mono_burg_rule_string[rule]); + exit(1); + } + } +} + +void +ir_to_mesa_visitor::visit(ir_variable *ir) +{ + (void)ir; +} + +void +ir_to_mesa_visitor::visit(ir_loop *ir) +{ + (void)ir; + + printf("Can't support loops, should be flattened before here\n"); + exit(1); +} + +void +ir_to_mesa_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; + printf("Can't support loops, should be flattened before here\n"); + exit(1); +} + + +void +ir_to_mesa_visitor::visit(ir_function_signature *ir) +{ + assert(0); + (void)ir; +} + +void +ir_to_mesa_visitor::visit(ir_function *ir) +{ + /* Ignore function bodies other than main() -- we shouldn't see calls to + * them since they should all be inlined before we get to ir_to_mesa. + */ + if (strcmp(ir->name, "main") == 0) { + const ir_function_signature *sig; + exec_list empty; + + sig = ir->matching_signature(&empty); + + assert(sig); + + foreach_iter(exec_list_iterator, iter, sig->body) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + ir->accept(this); + } + } +} + +void +ir_to_mesa_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + struct mbtree *op[2]; + const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); + const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); + const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + this->result = NULL; + ir->operands[operand]->accept(this); + if (!this->result) { + ir_print_visitor v; + printf("Failed to get tree for expression operand:\n"); + ir->operands[operand]->accept(&v); + exit(1); + } + op[operand] = this->result; + } + + this->result = NULL; + + switch (ir->operation) { + case ir_binop_add: + this->result = this->create_tree(MB_TERM_add_vec4_vec4, op[0], op[1]); + break; + case ir_binop_sub: + this->result = this->create_tree(MB_TERM_sub_vec4_vec4, op[0], op[1]); + break; + case ir_binop_mul: + this->result = this->create_tree(MB_TERM_mul_vec4_vec4, op[0], op[1]); + break; + case ir_binop_div: + this->result = this->create_tree(MB_TERM_div_vec4_vec4, op[0], op[1]); + break; + case ir_binop_dot: + if (ir->operands[0]->type == vec4_type) { + assert(ir->operands[1]->type == vec4_type); + this->result = this->create_tree(MB_TERM_dp4_vec4_vec4, op[0], op[1]); + } else if (ir->operands[0]->type == vec3_type) { + assert(ir->operands[1]->type == vec3_type); + this->result = this->create_tree(MB_TERM_dp3_vec4_vec4, op[0], op[1]); + } else if (ir->operands[0]->type == vec2_type) { + assert(ir->operands[1]->type == vec2_type); + this->result = this->create_tree(MB_TERM_dp2_vec4_vec4, op[0], op[1]); + } + break; + case ir_unop_sqrt: + this->result = this->create_tree(MB_TERM_sqrt_vec4, op[0], op[1]); + break; + default: + break; + } + if (!this->result) { + ir_print_visitor v; + printf("Failed to get tree for expression:\n"); + ir->accept(&v); + exit(1); + } +} + + +void +ir_to_mesa_visitor::visit(ir_swizzle *ir) +{ + struct mbtree *tree; + int i; + int swizzle[4]; + + /* FINISHME: Handle swizzles on the left side of an assignment. */ + + ir->val->accept(this); + assert(this->result); + + tree = this->create_tree(MB_TERM_swizzle_vec4, this->result, NULL); + + for (i = 0; i < 4; i++) { + if (i < ir->type->vector_elements) { + switch (i) { + case 0: + swizzle[i] = ir->mask.x; + break; + case 1: + swizzle[i] = ir->mask.y; + break; + case 2: + swizzle[i] = ir->mask.z; + break; + case 3: + swizzle[i] = ir->mask.w; + break; + } + } else { + /* If the type is smaller than a vec4, replicate the last + * channel out. + */ + swizzle[i] = ir->type->vector_elements - 1; + } + } + + tree->src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], + swizzle[1], + swizzle[2], + swizzle[3]); + + this->result = tree; +} + + +void +ir_to_mesa_visitor::visit(ir_dereference_variable *ir) +{ + struct mbtree *tree; + int size_swizzles[4] = { + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), + }; + + ir_variable *var = ir->var->as_variable(); + + /* By the time we make it to this stage, matric`es should be broken down + * to vectors. + */ + assert(!var->type->is_matrix()); + + tree = this->create_tree(MB_TERM_reference_vec4, NULL, NULL); + + if (strncmp(var->name, "gl_", 3) == 0) { + if (strcmp(var->name, "gl_FragColor") == 0) { + tree->src_reg.file = PROGRAM_INPUT; + tree->src_reg.index = FRAG_ATTRIB_COL0; + } else { + assert(0); + } + } else { + this->get_temp_for_var(var, tree); + } + + /* If the type is smaller than a vec4, replicate the last channel out. */ + tree->src_reg.swizzle = size_swizzles[ir->type->vector_elements - 1]; + + this->result = tree; +} + +void +ir_to_mesa_visitor::visit(ir_dereference_array *ir) +{ + struct mbtree *tree; + int size_swizzles[4] = { + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), + }; + + ir_variable *var = ir->array->as_variable(); + ir_constant *index = ir->array_index->constant_expression_value(); + char *name; + + assert(var); + assert(index); + assert(strcmp(var->name, "gl_TexCoord") == 0); + + asprintf(&name, "fragment.texcoord[%d]", index->value.i[0]); + tree = this->create_tree(MB_TERM_reference_vec4, NULL, NULL); + tree->reg_name = name; + + /* If the type is smaller than a vec4, replicate the last channel out. */ + tree->src_reg.swizzle = size_swizzles[ir->type->vector_elements - 1]; + + this->result = tree; +} + +void +ir_to_mesa_visitor::visit(ir_dereference_record *ir) +{ + (void)ir; + assert(0); +} + +void +ir_to_mesa_visitor::visit(ir_assignment *ir) +{ + struct mbtree *l, *r, *t; + + ir->lhs->accept(this); + l = this->result; + ir->rhs->accept(this); + r = this->result; + assert(l); + assert(r); + + assert(!ir->condition); + + t = this->create_tree(MB_TERM_assign, l, r); + mono_burg_label(t, NULL); + reduce(t, MB_NTERM_stmt); +} + + +void +ir_to_mesa_visitor::visit(ir_constant *ir) +{ + struct mbtree *tree; + + assert(!ir->type->is_matrix()); + + tree = this->create_tree(MB_TERM_reference_vec4, NULL, NULL); + + assert(ir->type->base_type == GLSL_TYPE_FLOAT); + + /* FINISHME: This will end up being _mesa_add_unnamed_constant, + * which handles sharing values and sharing channels of vec4 + * constants for small values. + */ + /* FINISHME: Do something with the constant values for now. + */ + tree->src_reg.file = PROGRAM_CONSTANT; + tree->src_reg.index = this->next_constant++; + tree->src_reg.swizzle = SWIZZLE_NOOP; + + this->result = tree; +} + + +void +ir_to_mesa_visitor::visit(ir_call *ir) +{ + printf("Can't support call to %s\n", ir->callee_name()); + exit(1); +} + + +void +ir_to_mesa_visitor::visit(ir_texture *ir) +{ + assert(0); + + ir->coordinate->accept(this); +} + +void +ir_to_mesa_visitor::visit(ir_return *ir) +{ + assert(0); + + ir->get_value()->accept(this); +} + + +void +ir_to_mesa_visitor::visit(ir_if *ir) +{ + (void)ir; + printf("Can't support conditionals, should be flattened before here.\n"); + exit(1); +} + +static struct prog_src_register +mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) +{ + struct prog_src_register mesa_reg; + + mesa_reg.File = reg.file; + mesa_reg.Index = reg.index; + + return mesa_reg; +} + +void +do_ir_to_mesa(exec_list *instructions) +{ + ir_to_mesa_visitor v; + struct prog_instruction *mesa_instructions, *mesa_inst; + + visit_exec_list(instructions, &v); + + int num_instructions = 0; + foreach_iter(exec_list_iterator, iter, v.instructions) { + num_instructions++; + } + + mesa_instructions = + (struct prog_instruction *)calloc(num_instructions, + sizeof(*mesa_instructions)); + + mesa_inst = mesa_instructions; + foreach_iter(exec_list_iterator, iter, v.instructions) { + ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); + mesa_inst->Opcode = inst->op; + mesa_inst->DstReg.File = inst->dst_reg.file; + mesa_inst->DstReg.Index = inst->dst_reg.index; + mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); + mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); + mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); + mesa_inst++; + } +} diff --git a/ir_to_mesa.h b/ir_to_mesa.h new file mode 100644 index 00000000000..6154c1ca583 --- /dev/null +++ b/ir_to_mesa.h @@ -0,0 +1,170 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" +#include "shader/prog_instruction.h" + +/** + * \file ir_to_mesa.h + * + * Translates the IR to Mesa IR if possible. + */ + +/** + * This struct is a corresponding struct to Mesa prog_src_register, with + * wider fields. + */ +typedef struct ir_to_mesa_src_reg { + int file; /**< PROGRAM_* from Mesa */ + int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ + int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ +} ir_to_mesa_src_reg; + +typedef struct ir_to_mesa_dst_reg { + int file; /**< PROGRAM_* from Mesa */ + int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ +} ir_to_mesa_dst_reg; + +extern ir_to_mesa_src_reg ir_to_mesa_undef; + +class ir_to_mesa_instruction : public exec_node { +public: + enum prog_opcode op; + ir_to_mesa_dst_reg dst_reg; + ir_to_mesa_src_reg src_reg[3]; +}; + +struct mbtree { + struct mbtree *left; + struct mbtree *right; + void *state; + uint16_t op; + const char *reg_name; + const char *swizzle_reg_name; + class ir_to_mesa_visitor *v; + + /** + * This is the representation of this tree node's results as a + * source register for its consumer. + */ + ir_to_mesa_src_reg src_reg; +}; + +void do_ir_to_mesa(exec_list *instructions); + +class temp_entry : public exec_node { +public: + temp_entry(ir_variable *var, int file, int index) + : file(file), index(index), var(var) + { + /* empty */ + } + + int file; + int index; + ir_variable *var; /* variable that maps to this, if any */ +}; + +class ir_to_mesa_visitor : public ir_visitor { +public: + ir_to_mesa_visitor() + { + result = NULL; + next_temp = 0; + next_constant = 0; + } + + int next_temp; + int next_constant; + + void get_temp(struct mbtree *tree); + + void get_temp_for_var(ir_variable *var, struct mbtree *tree); + + struct mbtree *create_tree(int op, + struct mbtree *left, + struct mbtree *right); + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_texture *); + virtual void visit(ir_if *); + /*@}*/ + + struct mbtree *result; + + /** List of temp_entry */ + exec_list variable_storage; + + /** List of ir_to_mesa_instruction */ + exec_list instructions; +}; + +ir_to_mesa_instruction * +ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); + +ir_to_mesa_instruction * +ir_to_mesa_emit_op2(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1); + +ir_to_mesa_instruction * +ir_to_mesa_emit_op3(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1, + ir_to_mesa_src_reg src2); + +inline ir_to_mesa_dst_reg +ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) +{ + ir_to_mesa_dst_reg dst_reg; + + dst_reg.file = reg.file; + dst_reg.index = reg.index; + + return dst_reg; +} diff --git a/main/mtypes.h b/main/mtypes.h index f168b6605b3..cab5ffde6cc 100644 --- a/main/mtypes.h +++ b/main/mtypes.h @@ -36,6 +36,8 @@ #define MAX_DRAW_BUFFERS 8 #define MAX_VARYING 16 +#include + /** * Indexes for vertex program attributes. * GL_NV_vertex_program aliases generic attributes over the conventional @@ -218,4 +220,34 @@ typedef enum FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) } gl_frag_result; +/** + * Names of the various vertex/fragment program register files, etc. + * + * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) + * All values should fit in a 4-bit field. + * + * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, + * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to + * be "uniform" variables since they can only be set outside glBegin/End. + * They're also all stored in the same Parameters array. + */ +typedef enum +{ + PROGRAM_TEMPORARY, /**< machine->Temporary[] */ + PROGRAM_INPUT, /**< machine->Inputs[] */ + PROGRAM_OUTPUT, /**< machine->Outputs[] */ + PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */ + PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ + PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */ + PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ + PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ + PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ + PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ + PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ + PROGRAM_ADDRESS, /**< machine->AddressReg */ + PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ + PROGRAM_UNDEFINED, /**< Invalid/TBD value */ + PROGRAM_FILE_MAX +} gl_register_file; + #endif diff --git a/mesa/shader/prog_instruction.h b/mesa/shader/prog_instruction.h new file mode 100644 index 00000000000..2c95d274cab --- /dev/null +++ b/mesa/shader/prog_instruction.h @@ -0,0 +1,437 @@ +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file prog_instruction.h + * + * Vertex/fragment program instruction datatypes and constants. + * + * \author Brian Paul + * \author Keith Whitwell + * \author Ian Romanick + */ + + +#ifndef PROG_INSTRUCTION_H +#define PROG_INSTRUCTION_H + + +#include "main/mtypes.h" + + +/** + * Swizzle indexes. + * Do not change! + */ +/*@{*/ +#define SWIZZLE_X 0 +#define SWIZZLE_Y 1 +#define SWIZZLE_Z 2 +#define SWIZZLE_W 3 +#define SWIZZLE_ZERO 4 /**< For SWZ instruction only */ +#define SWIZZLE_ONE 5 /**< For SWZ instruction only */ +#define SWIZZLE_NIL 7 /**< used during shader code gen (undefined value) */ +/*@}*/ + +#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9)) +#define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3) +#define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7) +#define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1) + +#define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) +#define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X) +#define SWIZZLE_YYYY MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y) +#define SWIZZLE_ZZZZ MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z) +#define SWIZZLE_WWWW MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W) + + +/** + * Writemask values, 1 bit per component. + */ +/*@{*/ +#define WRITEMASK_X 0x1 +#define WRITEMASK_Y 0x2 +#define WRITEMASK_XY 0x3 +#define WRITEMASK_Z 0x4 +#define WRITEMASK_XZ 0x5 +#define WRITEMASK_YZ 0x6 +#define WRITEMASK_XYZ 0x7 +#define WRITEMASK_W 0x8 +#define WRITEMASK_XW 0x9 +#define WRITEMASK_YW 0xa +#define WRITEMASK_XYW 0xb +#define WRITEMASK_ZW 0xc +#define WRITEMASK_XZW 0xd +#define WRITEMASK_YZW 0xe +#define WRITEMASK_XYZW 0xf +/*@}*/ + + +/** + * Condition codes + */ +/*@{*/ +#define COND_GT 1 /**< greater than zero */ +#define COND_EQ 2 /**< equal to zero */ +#define COND_LT 3 /**< less than zero */ +#define COND_UN 4 /**< unordered (NaN) */ +#define COND_GE 5 /**< greater than or equal to zero */ +#define COND_LE 6 /**< less than or equal to zero */ +#define COND_NE 7 /**< not equal to zero */ +#define COND_TR 8 /**< always true */ +#define COND_FL 9 /**< always false */ +/*@}*/ + + +/** + * Instruction precision for GL_NV_fragment_program + */ +/*@{*/ +#define FLOAT32 0x1 +#define FLOAT16 0x2 +#define FIXED12 0x4 +/*@}*/ + + +/** + * Saturation modes when storing values. + */ +/*@{*/ +#define SATURATE_OFF 0 +#define SATURATE_ZERO_ONE 1 +/*@}*/ + + +/** + * Per-component negation masks + */ +/*@{*/ +#define NEGATE_X 0x1 +#define NEGATE_Y 0x2 +#define NEGATE_Z 0x4 +#define NEGATE_W 0x8 +#define NEGATE_XYZ 0x7 +#define NEGATE_XYZW 0xf +#define NEGATE_NONE 0x0 +/*@}*/ + + +/** + * Program instruction opcodes, for both vertex and fragment programs. + * \note changes to this opcode list must be reflected in t_vb_arbprogram.c + */ +typedef enum prog_opcode { + /* ARB_vp ARB_fp NV_vp NV_fp GLSL */ + /*------------------------------------------*/ + OPCODE_NOP = 0, /* X */ + OPCODE_ABS, /* X X 1.1 X */ + OPCODE_ADD, /* X X X X X */ + OPCODE_AND, /* */ + OPCODE_ARA, /* 2 */ + OPCODE_ARL, /* X X */ + OPCODE_ARL_NV, /* 2 */ + OPCODE_ARR, /* 2 */ + OPCODE_BGNLOOP, /* opt */ + OPCODE_BGNSUB, /* opt */ + OPCODE_BRA, /* 2 X */ + OPCODE_BRK, /* 2 opt */ + OPCODE_CAL, /* 2 2 */ + OPCODE_CMP, /* X */ + OPCODE_CONT, /* opt */ + OPCODE_COS, /* X 2 X X */ + OPCODE_DDX, /* X X */ + OPCODE_DDY, /* X X */ + OPCODE_DP2, /* 2 */ + OPCODE_DP2A, /* 2 */ + OPCODE_DP3, /* X X X X X */ + OPCODE_DP4, /* X X X X X */ + OPCODE_DPH, /* X X 1.1 */ + OPCODE_DST, /* X X X X */ + OPCODE_ELSE, /* X */ + OPCODE_END, /* X X X X opt */ + OPCODE_ENDIF, /* opt */ + OPCODE_ENDLOOP, /* opt */ + OPCODE_ENDSUB, /* opt */ + OPCODE_EX2, /* X X 2 X X */ + OPCODE_EXP, /* X X X */ + OPCODE_FLR, /* X X 2 X X */ + OPCODE_FRC, /* X X 2 X X */ + OPCODE_IF, /* opt */ + OPCODE_KIL, /* X */ + OPCODE_KIL_NV, /* X X */ + OPCODE_LG2, /* X X 2 X X */ + OPCODE_LIT, /* X X X X */ + OPCODE_LOG, /* X X X */ + OPCODE_LRP, /* X X */ + OPCODE_MAD, /* X X X X X */ + OPCODE_MAX, /* X X X X X */ + OPCODE_MIN, /* X X X X X */ + OPCODE_MOV, /* X X X X X */ + OPCODE_MUL, /* X X X X X */ + OPCODE_NOISE1, /* X */ + OPCODE_NOISE2, /* X */ + OPCODE_NOISE3, /* X */ + OPCODE_NOISE4, /* X */ + OPCODE_NOT, /* */ + OPCODE_NRM3, /* */ + OPCODE_NRM4, /* */ + OPCODE_OR, /* */ + OPCODE_PK2H, /* X */ + OPCODE_PK2US, /* X */ + OPCODE_PK4B, /* X */ + OPCODE_PK4UB, /* X */ + OPCODE_POW, /* X X X X */ + OPCODE_POPA, /* 3 */ + OPCODE_PRINT, /* X X */ + OPCODE_PUSHA, /* 3 */ + OPCODE_RCC, /* 1.1 */ + OPCODE_RCP, /* X X X X X */ + OPCODE_RET, /* 2 2 */ + OPCODE_RFL, /* X X */ + OPCODE_RSQ, /* X X X X X */ + OPCODE_SCS, /* X */ + OPCODE_SEQ, /* 2 X X */ + OPCODE_SFL, /* 2 X */ + OPCODE_SGE, /* X X X X X */ + OPCODE_SGT, /* 2 X X */ + OPCODE_SIN, /* X 2 X X */ + OPCODE_SLE, /* 2 X X */ + OPCODE_SLT, /* X X X X X */ + OPCODE_SNE, /* 2 X X */ + OPCODE_SSG, /* 2 */ + OPCODE_STR, /* 2 X */ + OPCODE_SUB, /* X X 1.1 X X */ + OPCODE_SWZ, /* X X */ + OPCODE_TEX, /* X 3 X X */ + OPCODE_TXB, /* X 3 X */ + OPCODE_TXD, /* X X */ + OPCODE_TXL, /* 3 2 X */ + OPCODE_TXP, /* X X */ + OPCODE_TXP_NV, /* 3 X */ + OPCODE_TRUNC, /* X */ + OPCODE_UP2H, /* X */ + OPCODE_UP2US, /* X */ + OPCODE_UP4B, /* X */ + OPCODE_UP4UB, /* X */ + OPCODE_X2D, /* X */ + OPCODE_XOR, /* */ + OPCODE_XPD, /* X X X */ + MAX_OPCODE +} gl_inst_opcode; + + +/** + * Number of bits for the src/dst register Index field. + * This limits the size of temp/uniform register files. + */ +#define INST_INDEX_BITS 10 + + +/** + * Instruction source register. + */ +struct prog_src_register +{ + GLuint File:4; /**< One of the PROGRAM_* register file values. */ + GLint Index:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit. + * May be negative for relative addressing. + */ + GLuint Swizzle:12; + GLuint RelAddr:1; + + /** Take the component-wise absolute value */ + GLuint Abs:1; + + /** + * Post-Abs negation. + * This will either be NEGATE_NONE or NEGATE_XYZW, except for the SWZ + * instruction which allows per-component negation. + */ + GLuint Negate:4; +}; + + +/** + * Instruction destination register. + */ +struct prog_dst_register +{ + GLuint File:4; /**< One of the PROGRAM_* register file values */ + GLuint Index:INST_INDEX_BITS; /**< Unsigned, never negative */ + GLuint WriteMask:4; + GLuint RelAddr:1; + + /** + * \name Conditional destination update control. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, + * NV_vertex_program2_option. + */ + /*@{*/ + /** + * Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT, + * NE, TR, or UN). Dest reg is only written to if the matching + * (swizzled) condition code value passes. When a conditional update mask + * is not specified, this will be \c COND_TR. + */ + GLuint CondMask:4; + + /** + * Condition code swizzle value. + */ + GLuint CondSwizzle:12; + + /** + * Selects the condition code register to use for conditional destination + * update masking. In NV_fragmnet_program or NV_vertex_program2 mode, only + * condition code register 0 is available. In NV_vertex_program3 mode, + * condition code registers 0 and 1 are available. + */ + GLuint CondSrc:1; + /*@}*/ +}; + + +/** + * Vertex/fragment program instruction. + */ +struct prog_instruction +{ + gl_inst_opcode Opcode; + struct prog_src_register SrcReg[3]; + struct prog_dst_register DstReg; + + /** + * Indicates that the instruction should update the condition code + * register. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, + * NV_vertex_program2_option. + */ + GLuint CondUpdate:1; + + /** + * If prog_instruction::CondUpdate is \c GL_TRUE, this value selects the + * condition code register that is to be updated. + * + * In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition + * code register 0 is available. In GL_NV_vertex_program3 mode, condition + * code registers 0 and 1 are available. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, + * NV_vertex_program2_option. + */ + GLuint CondDst:1; + + /** + * Saturate each value of the vectored result to the range [0,1] or the + * range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is + * only available in NV_fragment_program2 mode. + * Value is one of the SATURATE_* tokens. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program3. + */ + GLuint SaturateMode:2; + + /** + * Per-instruction selectable precision: FLOAT32, FLOAT16, FIXED12. + * + * \since + * NV_fragment_program, NV_fragment_program_option. + */ + GLuint Precision:3; + + /** + * \name Extra fields for TEX, TXB, TXD, TXL, TXP instructions. + */ + /*@{*/ + /** Source texture unit. */ + GLuint TexSrcUnit:5; + + /** Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX */ + GLuint TexSrcTarget:3; + + /** True if tex instruction should do shadow comparison */ + GLuint TexShadow:1; + /*@}*/ + + /** + * For BRA and CAL instructions, the location to jump to. + * For BGNLOOP, points to ENDLOOP (and vice-versa). + * For BRK, points to BGNLOOP (which points to ENDLOOP). + * For IF, points to ELSE or ENDIF. + * For ELSE, points to ENDIF. + */ + GLint BranchTarget; + + /** for debugging purposes */ + const char *Comment; + + /** Arbitrary data. Used for OPCODE_PRINT and some drivers */ + void *Data; + + /** for driver use (try to remove someday) */ + GLint Aux; +}; + + +extern void +_mesa_init_instructions(struct prog_instruction *inst, GLuint count); + +extern struct prog_instruction * +_mesa_alloc_instructions(GLuint numInst); + +extern struct prog_instruction * +_mesa_realloc_instructions(struct prog_instruction *oldInst, + GLuint numOldInst, GLuint numNewInst); + +extern struct prog_instruction * +_mesa_copy_instructions(struct prog_instruction *dest, + const struct prog_instruction *src, GLuint n); + +extern void +_mesa_free_instructions(struct prog_instruction *inst, GLuint count); + +extern GLuint +_mesa_num_inst_src_regs(gl_inst_opcode opcode); + +extern GLuint +_mesa_num_inst_dst_regs(gl_inst_opcode opcode); + +extern GLboolean +_mesa_is_tex_instruction(gl_inst_opcode opcode); + +extern GLboolean +_mesa_check_soa_dependencies(const struct prog_instruction *inst); + +extern const char * +_mesa_opcode_string(gl_inst_opcode opcode); + + +#endif /* PROG_INSTRUCTION_H */ diff --git a/mesa_codegen.brg b/mesa_codegen.brg new file mode 100644 index 00000000000..1f6ccfaf0c2 --- /dev/null +++ b/mesa_codegen.brg @@ -0,0 +1,173 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Eric Anholt + * + */ + +/* DO NOT EDIT mesa_codegen.h. It is a generated file produced + * from mesa_codegen.brg and will be overwritten. + */ + +#include +#include +#include +#include +#include + +/* Everything before the first %% is pasted at the start of the + * mesa_codegen.h header file. + */ + +#include "ir_to_mesa.h" + +#define MBTREE_TYPE struct mbtree + +%% +%term assign +%term reference_vec4 +%term add_vec4_vec4 +%term sub_vec4_vec4 +%term mul_vec4_vec4 +%term div_vec4_vec4 +%term dp4_vec4_vec4 +%term dp3_vec4_vec4 +%term dp2_vec4_vec4 +%term sqrt_vec4 +%term swizzle_vec4 + +%start stmt + +alloced_vec4: reference_vec4 0 + +vec4: alloced_vec4 0 +alloced_vec4: vec4 1 +{ + /* FINISHME */ + tree->v->get_temp(tree); +} + +stmt: assign(alloced_vec4, alloced_vec4) 1 +{ + ir_to_mesa_emit_op1(tree, OPCODE_MOV, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->left->src_reg); +} + +vec4: swizzle_vec4(alloced_vec4) 1 +{ + ir_to_mesa_src_reg reg = tree->left->src_reg; + int swiz[4]; + int i; + + for (i = 0; i < 4; i++) { + swiz[i] = GET_SWZ(tree->src_reg.swizzle, i); + if (swiz[i] >= SWIZZLE_X && swiz[i] <= SWIZZLE_Y) { + swiz[i] = GET_SWZ(tree->left->src_reg.swizzle, swiz[i]); + } + } + reg.swizzle = MAKE_SWIZZLE4(swiz[0], swiz[1], swiz[2], swiz[3]); + + ir_to_mesa_emit_op1(tree, OPCODE_MOV, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + reg); +} + +vec4: add_vec4_vec4(alloced_vec4, alloced_vec4) 1 +{ + ir_to_mesa_emit_op2(tree, OPCODE_ADD, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->left->src_reg, + tree->right->src_reg); +} + +vec4: sub_vec4_vec4(alloced_vec4, alloced_vec4) 1 +{ + ir_to_mesa_emit_op2(tree, OPCODE_SUB, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->left->src_reg, + tree->right->src_reg); +} + +vec4: mul_vec4_vec4(alloced_vec4, alloced_vec4) 1 +{ + ir_to_mesa_emit_op2(tree, OPCODE_MUL, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->left->src_reg, + tree->right->src_reg); +} + +vec4: dp4_vec4_vec4(alloced_vec4, alloced_vec4) 1 +{ + ir_to_mesa_emit_op2(tree, OPCODE_DP4, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->left->src_reg, + tree->right->src_reg); + tree->src_reg.swizzle = SWIZZLE_XXXX; +} + +vec4: dp3_vec4_vec4(alloced_vec4, alloced_vec4) 1 +{ + ir_to_mesa_emit_op2(tree, OPCODE_DP3, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->left->src_reg, + tree->right->src_reg); + tree->src_reg.swizzle = SWIZZLE_XXXX; +} + + +vec4: dp2_vec4_vec4(alloced_vec4, alloced_vec4) 1 +{ + ir_to_mesa_emit_op2(tree, OPCODE_DP2, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->left->src_reg, + tree->right->src_reg); + tree->src_reg.swizzle = SWIZZLE_XXXX; +} + +vec4: div_vec4_vec4(alloced_vec4, alloced_vec4) 1 +{ + /* FINISHME: Mesa RCP only uses the X channel, this node is for vec4. */ + ir_to_mesa_emit_op1(tree, OPCODE_RCP, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->right->src_reg); + + ir_to_mesa_emit_op2(tree, OPCODE_MUL, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->src_reg, + tree->left->src_reg); +} + +vec4: sqrt_vec4(alloced_vec4) 1 +{ + /* FINISHME: Mesa RSQ only uses the X channel, this node is for vec4. */ + ir_to_mesa_emit_op1(tree, OPCODE_RSQ, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->left->src_reg); + + ir_to_mesa_emit_op1(tree, OPCODE_RCP, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->src_reg); +} + +%% diff --git a/program.h b/program.h index 5c900b53cc0..d21b04344cd 100644 --- a/program.h +++ b/program.h @@ -22,6 +22,7 @@ */ #include +#include "main/mtypes.h" /** * Based on gl_shader in Mesa's mtypes.h. @@ -41,7 +42,6 @@ struct glsl_shader { }; -typedef int gl_register_file; typedef int gl_state_index; #define STATE_LENGTH 5 -- cgit v1.2.3 From 182b623de3beafaf586644014e108339a644b2db Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 3 May 2010 10:16:57 -0700 Subject: Ignore the generated codegen files for now. Later we'll throw them in revision control. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b3ce5e7086e..376aaeda13a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ glsl_parser.output glsl_parser.cpp glsl_parser.h glsl +mesa_codegen.cpp +mesa_codegen.h -- cgit v1.2.3 From b5039eff3f361f281e0da65fb413180357e2a762 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 3 May 2010 10:19:33 -0700 Subject: Add missing dist file. --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 88d8f0587c1..bb2cc34ccc3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,7 +64,8 @@ glsl_SOURCES = \ ir_vec_index_to_swizzle.cpp \ linker.cpp \ mesa_codegen.cpp \ - msea_codegen.h + mesa_codegen.h \ + mesa/shader/prog_instruction.h DISTFILES = \ mesa_codegen.brg -- cgit v1.2.3 From aaee40e107cf07a12c8e373d8bb910254f4ba30b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 3 May 2010 10:16:20 -0700 Subject: ir_to_mesa: Print out the resulting program. --- Makefile.am | 7 +- ir_to_mesa.cpp | 7 + ir_to_mesa.h | 2 + main/mtypes.h | 19 +- mesa/shader/prog_instruction.c | 363 ++++++++++++++ mesa/shader/prog_print.c | 1089 ++++++++++++++++++++++++++++++++++++++++ mesa/shader/prog_print.h | 98 ++++ 7 files changed, 1582 insertions(+), 3 deletions(-) create mode 100644 mesa/shader/prog_instruction.c create mode 100644 mesa/shader/prog_print.c create mode 100644 mesa/shader/prog_print.h diff --git a/Makefile.am b/Makefile.am index bb2cc34ccc3..bf062595a9d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,8 +64,11 @@ glsl_SOURCES = \ ir_vec_index_to_swizzle.cpp \ linker.cpp \ mesa_codegen.cpp \ - mesa_codegen.h \ - mesa/shader/prog_instruction.h + msea_codegen.h \ + mesa/shader/prog_instruction.c \ + mesa/shader/prog_instruction.h \ + mesa/shader/prog_print.c \ + mesa/shader/prog_print.h DISTFILES = \ mesa_codegen.brg diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 5cbd451b214..a0d3ae9c8d4 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -45,7 +45,10 @@ #include "ir_expression_flattening.h" #include "glsl_types.h" +extern "C" { #include "shader/prog_instruction.h" +#include "shader/prog_print.h" +} ir_to_mesa_src_reg ir_to_mesa_undef = { PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP @@ -512,6 +515,7 @@ mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) struct prog_src_register mesa_reg; mesa_reg.File = reg.file; + assert(reg.index < (1 << INST_INDEX_BITS) - 1); mesa_reg.Index = reg.index; return mesa_reg; @@ -543,6 +547,9 @@ do_ir_to_mesa(exec_list *instructions) mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); + + _mesa_print_instruction(mesa_inst); + mesa_inst++; } } diff --git a/ir_to_mesa.h b/ir_to_mesa.h index 6154c1ca583..cdf4f2c621a 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -22,7 +22,9 @@ */ #include "ir.h" +extern "C" { #include "shader/prog_instruction.h" +}; /** * \file ir_to_mesa.h diff --git a/main/mtypes.h b/main/mtypes.h index cab5ffde6cc..06e2dd4b540 100644 --- a/main/mtypes.h +++ b/main/mtypes.h @@ -250,4 +250,21 @@ typedef enum PROGRAM_FILE_MAX } gl_register_file; -#endif +/** + * An index for each type of texture object. These correspond to the GL + * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. + * Note: the order is from highest priority to lowest priority. + */ +typedef enum +{ + TEXTURE_2D_ARRAY_INDEX, + TEXTURE_1D_ARRAY_INDEX, + TEXTURE_CUBE_INDEX, + TEXTURE_3D_INDEX, + TEXTURE_RECT_INDEX, + TEXTURE_2D_INDEX, + TEXTURE_1D_INDEX, + NUM_TEXTURE_TARGETS +} gl_texture_index; + +#endif /* MTYPES_H */ diff --git a/mesa/shader/prog_instruction.c b/mesa/shader/prog_instruction.c new file mode 100644 index 00000000000..fbcf868f509 --- /dev/null +++ b/mesa/shader/prog_instruction.c @@ -0,0 +1,363 @@ +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#define _GNU_SOURCE +#include +#include +#include + +#if 0 +#include "main/glheader.h" +#else +#define _mesa_strdup strdup +#define _mesa_snprintf snprintf +#define ASSERT assert +#endif +#include "main/imports.h" +#include "main/mtypes.h" +#include "prog_instruction.h" + + +/** + * Initialize program instruction fields to defaults. + * \param inst first instruction to initialize + * \param count number of instructions to initialize + */ +void +_mesa_init_instructions(struct prog_instruction *inst, GLuint count) +{ + GLuint i; + + memset(inst, 0, count * sizeof(struct prog_instruction)); + + for (i = 0; i < count; i++) { + inst[i].SrcReg[0].File = PROGRAM_UNDEFINED; + inst[i].SrcReg[0].Swizzle = SWIZZLE_NOOP; + inst[i].SrcReg[1].File = PROGRAM_UNDEFINED; + inst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP; + inst[i].SrcReg[2].File = PROGRAM_UNDEFINED; + inst[i].SrcReg[2].Swizzle = SWIZZLE_NOOP; + + inst[i].DstReg.File = PROGRAM_UNDEFINED; + inst[i].DstReg.WriteMask = WRITEMASK_XYZW; + inst[i].DstReg.CondMask = COND_TR; + inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP; + + inst[i].SaturateMode = SATURATE_OFF; + inst[i].Precision = FLOAT32; + } +} + + +/** + * Allocate an array of program instructions. + * \param numInst number of instructions + * \return pointer to instruction memory + */ +struct prog_instruction * +_mesa_alloc_instructions(GLuint numInst) +{ + return (struct prog_instruction *) + calloc(1, numInst * sizeof(struct prog_instruction)); +} + + +/** + * Reallocate memory storing an array of program instructions. + * This is used when we need to append additional instructions onto an + * program. + * \param oldInst pointer to first of old/src instructions + * \param numOldInst number of instructions at + * \param numNewInst desired size of new instruction array. + * \return pointer to start of new instruction array. + */ +struct prog_instruction * +_mesa_realloc_instructions(struct prog_instruction *oldInst, + GLuint numOldInst, GLuint numNewInst) +{ + struct prog_instruction *newInst; + + (void)numOldInst; + newInst = (struct prog_instruction *) + realloc(oldInst, + numNewInst * sizeof(struct prog_instruction)); + + return newInst; +} + + +/** + * Copy an array of program instructions. + * \param dest pointer to destination. + * \param src pointer to source. + * \param n number of instructions to copy. + * \return pointer to destination. + */ +struct prog_instruction * +_mesa_copy_instructions(struct prog_instruction *dest, + const struct prog_instruction *src, GLuint n) +{ + GLuint i; + memcpy(dest, src, n * sizeof(struct prog_instruction)); + for (i = 0; i < n; i++) { + if (src[i].Comment) + dest[i].Comment = _mesa_strdup(src[i].Comment); + } + return dest; +} + + +/** + * Free an array of instructions + */ +void +_mesa_free_instructions(struct prog_instruction *inst, GLuint count) +{ + GLuint i; + for (i = 0; i < count; i++) { + if (inst[i].Data) + free(inst[i].Data); + if (inst[i].Comment) + free((char *) inst[i].Comment); + } + free(inst); +} + + +/** + * Basic info about each instruction + */ +struct instruction_info +{ + gl_inst_opcode Opcode; + const char *Name; + GLuint NumSrcRegs; + GLuint NumDstRegs; +}; + +/** + * Instruction info + * \note Opcode should equal array index! + */ +static const struct instruction_info InstInfo[MAX_OPCODE] = { + { OPCODE_NOP, "NOP", 0, 0 }, + { OPCODE_ABS, "ABS", 1, 1 }, + { OPCODE_ADD, "ADD", 2, 1 }, + { OPCODE_AND, "AND", 2, 1 }, + { OPCODE_ARA, "ARA", 1, 1 }, + { OPCODE_ARL, "ARL", 1, 1 }, + { OPCODE_ARL_NV, "ARL_NV", 1, 1 }, + { OPCODE_ARR, "ARL", 1, 1 }, + { OPCODE_BGNLOOP,"BGNLOOP", 0, 0 }, + { OPCODE_BGNSUB, "BGNSUB", 0, 0 }, + { OPCODE_BRA, "BRA", 0, 0 }, + { OPCODE_BRK, "BRK", 0, 0 }, + { OPCODE_CAL, "CAL", 0, 0 }, + { OPCODE_CMP, "CMP", 3, 1 }, + { OPCODE_CONT, "CONT", 0, 0 }, + { OPCODE_COS, "COS", 1, 1 }, + { OPCODE_DDX, "DDX", 1, 1 }, + { OPCODE_DDY, "DDY", 1, 1 }, + { OPCODE_DP2, "DP2", 2, 1 }, + { OPCODE_DP2A, "DP2A", 3, 1 }, + { OPCODE_DP3, "DP3", 2, 1 }, + { OPCODE_DP4, "DP4", 2, 1 }, + { OPCODE_DPH, "DPH", 2, 1 }, + { OPCODE_DST, "DST", 2, 1 }, + { OPCODE_ELSE, "ELSE", 0, 0 }, + { OPCODE_END, "END", 0, 0 }, + { OPCODE_ENDIF, "ENDIF", 0, 0 }, + { OPCODE_ENDLOOP,"ENDLOOP", 0, 0 }, + { OPCODE_ENDSUB, "ENDSUB", 0, 0 }, + { OPCODE_EX2, "EX2", 1, 1 }, + { OPCODE_EXP, "EXP", 1, 1 }, + { OPCODE_FLR, "FLR", 1, 1 }, + { OPCODE_FRC, "FRC", 1, 1 }, + { OPCODE_IF, "IF", 1, 0 }, + { OPCODE_KIL, "KIL", 1, 0 }, + { OPCODE_KIL_NV, "KIL_NV", 0, 0 }, + { OPCODE_LG2, "LG2", 1, 1 }, + { OPCODE_LIT, "LIT", 1, 1 }, + { OPCODE_LOG, "LOG", 1, 1 }, + { OPCODE_LRP, "LRP", 3, 1 }, + { OPCODE_MAD, "MAD", 3, 1 }, + { OPCODE_MAX, "MAX", 2, 1 }, + { OPCODE_MIN, "MIN", 2, 1 }, + { OPCODE_MOV, "MOV", 1, 1 }, + { OPCODE_MUL, "MUL", 2, 1 }, + { OPCODE_NOISE1, "NOISE1", 1, 1 }, + { OPCODE_NOISE2, "NOISE2", 1, 1 }, + { OPCODE_NOISE3, "NOISE3", 1, 1 }, + { OPCODE_NOISE4, "NOISE4", 1, 1 }, + { OPCODE_NOT, "NOT", 1, 1 }, + { OPCODE_NRM3, "NRM3", 1, 1 }, + { OPCODE_NRM4, "NRM4", 1, 1 }, + { OPCODE_OR, "OR", 2, 1 }, + { OPCODE_PK2H, "PK2H", 1, 1 }, + { OPCODE_PK2US, "PK2US", 1, 1 }, + { OPCODE_PK4B, "PK4B", 1, 1 }, + { OPCODE_PK4UB, "PK4UB", 1, 1 }, + { OPCODE_POW, "POW", 2, 1 }, + { OPCODE_POPA, "POPA", 0, 0 }, + { OPCODE_PRINT, "PRINT", 1, 0 }, + { OPCODE_PUSHA, "PUSHA", 0, 0 }, + { OPCODE_RCC, "RCC", 1, 1 }, + { OPCODE_RCP, "RCP", 1, 1 }, + { OPCODE_RET, "RET", 0, 0 }, + { OPCODE_RFL, "RFL", 1, 1 }, + { OPCODE_RSQ, "RSQ", 1, 1 }, + { OPCODE_SCS, "SCS", 1, 1 }, + { OPCODE_SEQ, "SEQ", 2, 1 }, + { OPCODE_SFL, "SFL", 0, 1 }, + { OPCODE_SGE, "SGE", 2, 1 }, + { OPCODE_SGT, "SGT", 2, 1 }, + { OPCODE_SIN, "SIN", 1, 1 }, + { OPCODE_SLE, "SLE", 2, 1 }, + { OPCODE_SLT, "SLT", 2, 1 }, + { OPCODE_SNE, "SNE", 2, 1 }, + { OPCODE_SSG, "SSG", 1, 1 }, + { OPCODE_STR, "STR", 0, 1 }, + { OPCODE_SUB, "SUB", 2, 1 }, + { OPCODE_SWZ, "SWZ", 1, 1 }, + { OPCODE_TEX, "TEX", 1, 1 }, + { OPCODE_TXB, "TXB", 1, 1 }, + { OPCODE_TXD, "TXD", 3, 1 }, + { OPCODE_TXL, "TXL", 1, 1 }, + { OPCODE_TXP, "TXP", 1, 1 }, + { OPCODE_TXP_NV, "TXP_NV", 1, 1 }, + { OPCODE_TRUNC, "TRUNC", 1, 1 }, + { OPCODE_UP2H, "UP2H", 1, 1 }, + { OPCODE_UP2US, "UP2US", 1, 1 }, + { OPCODE_UP4B, "UP4B", 1, 1 }, + { OPCODE_UP4UB, "UP4UB", 1, 1 }, + { OPCODE_X2D, "X2D", 3, 1 }, + { OPCODE_XOR, "XOR", 2, 1 }, + { OPCODE_XPD, "XPD", 2, 1 } +}; + + +/** + * Return the number of src registers for the given instruction/opcode. + */ +GLuint +_mesa_num_inst_src_regs(gl_inst_opcode opcode) +{ + ASSERT(opcode < MAX_OPCODE); + ASSERT(opcode == InstInfo[opcode].Opcode); + ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); + return InstInfo[opcode].NumSrcRegs; +} + + +/** + * Return the number of dst registers for the given instruction/opcode. + */ +GLuint +_mesa_num_inst_dst_regs(gl_inst_opcode opcode) +{ + ASSERT(opcode < MAX_OPCODE); + ASSERT(opcode == InstInfo[opcode].Opcode); + ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); + return InstInfo[opcode].NumDstRegs; +} + + +GLboolean +_mesa_is_tex_instruction(gl_inst_opcode opcode) +{ + return (opcode == OPCODE_TEX || + opcode == OPCODE_TXB || + opcode == OPCODE_TXD || + opcode == OPCODE_TXL || + opcode == OPCODE_TXP); +} + + +/** + * Check if there's a potential src/dst register data dependency when + * using SOA execution. + * Example: + * MOV T, T.yxwz; + * This would expand into: + * MOV t0, t1; + * MOV t1, t0; + * MOV t2, t3; + * MOV t3, t2; + * The second instruction will have the wrong value for t0 if executed as-is. + */ +GLboolean +_mesa_check_soa_dependencies(const struct prog_instruction *inst) +{ + GLuint i, chan; + + if (inst->DstReg.WriteMask == WRITEMASK_X || + inst->DstReg.WriteMask == WRITEMASK_Y || + inst->DstReg.WriteMask == WRITEMASK_Z || + inst->DstReg.WriteMask == WRITEMASK_W || + inst->DstReg.WriteMask == 0x0) { + /* no chance of data dependency */ + return GL_FALSE; + } + + /* loop over src regs */ + for (i = 0; i < 3; i++) { + if (inst->SrcReg[i].File == inst->DstReg.File && + inst->SrcReg[i].Index == inst->DstReg.Index) { + /* loop over dest channels */ + GLuint channelsWritten = 0x0; + for (chan = 0; chan < 4; chan++) { + if (inst->DstReg.WriteMask & (1 << chan)) { + /* check if we're reading a channel that's been written */ + GLuint swizzle = GET_SWZ(inst->SrcReg[i].Swizzle, chan); + if (swizzle <= SWIZZLE_W && + (channelsWritten & (1 << swizzle))) { + return GL_TRUE; + } + + channelsWritten |= (1 << chan); + } + } + } + } + return GL_FALSE; +} + + +/** + * Return string name for given program opcode. + */ +const char * +_mesa_opcode_string(gl_inst_opcode opcode) +{ + if (opcode < MAX_OPCODE) + return InstInfo[opcode].Name; + else { + static char s[20]; + _mesa_snprintf(s, sizeof(s), "OP%u", opcode); + return s; + } +} + diff --git a/mesa/shader/prog_print.c b/mesa/shader/prog_print.c new file mode 100644 index 00000000000..9ac090b2617 --- /dev/null +++ b/mesa/shader/prog_print.c @@ -0,0 +1,1089 @@ +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file prog_print.c + * Print vertex/fragment programs - for debugging. + * \author Brian Paul + */ + +#if 0 +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" +#else + +#define _GNU_SOURCE + +#include +#include +#include +#include +struct gl_program { + int Target; +}; + +void _mesa_problem(void *ctx, char *msg) +{ + (void)ctx; + fprintf(stderr, "%s", msg); + exit(1); +} + +#endif + +#include "prog_instruction.h" +#include "prog_print.h" + + + +/** + * Return string name for given program/register file. + */ +static const char * +file_string(gl_register_file f, gl_prog_print_mode mode) +{ + (void)mode; + switch (f) { + case PROGRAM_TEMPORARY: + return "TEMP"; + case PROGRAM_LOCAL_PARAM: + return "LOCAL"; + case PROGRAM_ENV_PARAM: + return "ENV"; + case PROGRAM_STATE_VAR: + return "STATE"; + case PROGRAM_INPUT: + return "INPUT"; + case PROGRAM_OUTPUT: + return "OUTPUT"; + case PROGRAM_NAMED_PARAM: + return "NAMED"; + case PROGRAM_CONSTANT: + return "CONST"; + case PROGRAM_UNIFORM: + return "UNIFORM"; + case PROGRAM_VARYING: + return "VARYING"; + case PROGRAM_WRITE_ONLY: + return "WRITE_ONLY"; + case PROGRAM_ADDRESS: + return "ADDR"; + case PROGRAM_SAMPLER: + return "SAMPLER"; + case PROGRAM_UNDEFINED: + return "UNDEFINED"; + default: + { + static char s[20]; + snprintf(s, sizeof(s), "FILE%u", f); + return s; + } + } +} + + +/** + * Return ARB_v/f_prog-style input attrib string. + */ +static const char * +arb_input_attrib_string(GLint index, GLenum progType) +{ + /* + * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens. + */ + const char *vertAttribs[] = { + "vertex.position", + "vertex.weight", + "vertex.normal", + "vertex.color.primary", + "vertex.color.secondary", + "vertex.fogcoord", + "vertex.(six)", + "vertex.(seven)", + "vertex.texcoord[0]", + "vertex.texcoord[1]", + "vertex.texcoord[2]", + "vertex.texcoord[3]", + "vertex.texcoord[4]", + "vertex.texcoord[5]", + "vertex.texcoord[6]", + "vertex.texcoord[7]", + "vertex.attrib[0]", + "vertex.attrib[1]", + "vertex.attrib[2]", + "vertex.attrib[3]", + "vertex.attrib[4]", + "vertex.attrib[5]", + "vertex.attrib[6]", + "vertex.attrib[7]", + "vertex.attrib[8]", + "vertex.attrib[9]", + "vertex.attrib[10]", + "vertex.attrib[11]", + "vertex.attrib[12]", + "vertex.attrib[13]", + "vertex.attrib[14]", + "vertex.attrib[15]" + }; + const char *fragAttribs[] = { + "fragment.position", + "fragment.color.primary", + "fragment.color.secondary", + "fragment.fogcoord", + "fragment.texcoord[0]", + "fragment.texcoord[1]", + "fragment.texcoord[2]", + "fragment.texcoord[3]", + "fragment.texcoord[4]", + "fragment.texcoord[5]", + "fragment.texcoord[6]", + "fragment.texcoord[7]", + "fragment.varying[0]", + "fragment.varying[1]", + "fragment.varying[2]", + "fragment.varying[3]", + "fragment.varying[4]", + "fragment.varying[5]", + "fragment.varying[6]", + "fragment.varying[7]" + }; + + /* sanity checks */ + assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0); + assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0); + + if (progType == GL_VERTEX_PROGRAM_ARB) { + assert((unsigned int)index < sizeof(vertAttribs) / sizeof(vertAttribs[0])); + return vertAttribs[index]; + } + else { + assert((unsigned int)index < sizeof(fragAttribs) / sizeof(fragAttribs[0])); + return fragAttribs[index]; + } +} + + +/** + * Print a vertex program's InputsRead field in human-readable format. + * For debugging. + */ +void +_mesa_print_vp_inputs(GLbitfield inputs) +{ + printf("VP Inputs 0x%x: \n", inputs); + while (inputs) { + GLint attr = ffs(inputs) - 1; + const char *name = arb_input_attrib_string(attr, + GL_VERTEX_PROGRAM_ARB); + printf(" %d: %s\n", attr, name); + inputs &= ~(1 << attr); + } +} + + +/** + * Print a fragment program's InputsRead field in human-readable format. + * For debugging. + */ +void +_mesa_print_fp_inputs(GLbitfield inputs) +{ + printf("FP Inputs 0x%x: \n", inputs); + while (inputs) { + GLint attr = ffs(inputs) - 1; + const char *name = arb_input_attrib_string(attr, + GL_FRAGMENT_PROGRAM_ARB); + printf(" %d: %s\n", attr, name); + inputs &= ~(1 << attr); + } +} + + +#if 0 +/** + * Return ARB_v/f_prog-style output attrib string. + */ +static const char * +arb_output_attrib_string(GLint index, GLenum progType) +{ + /* + * These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens. + */ + const char *vertResults[] = { + "result.position", + "result.color.primary", + "result.color.secondary", + "result.fogcoord", + "result.texcoord[0]", + "result.texcoord[1]", + "result.texcoord[2]", + "result.texcoord[3]", + "result.texcoord[4]", + "result.texcoord[5]", + "result.texcoord[6]", + "result.texcoord[7]", + "result.varying[0]", + "result.varying[1]", + "result.varying[2]", + "result.varying[3]", + "result.varying[4]", + "result.varying[5]", + "result.varying[6]", + "result.varying[7]" + }; + const char *fragResults[] = { + "result.color", + "result.color(half)", + "result.depth", + "result.color[0]", + "result.color[1]", + "result.color[2]", + "result.color[3]" + }; + + if (progType == GL_VERTEX_PROGRAM_ARB) { + assert(index < sizeof(vertResults) / sizeof(vertResults[0])); + return vertResults[index]; + } + else { + assert(index < sizeof(fragResults) / sizeof(fragResults[0])); + return fragResults[index]; + } +} +#endif + +/** + * Return string representation of the given register. + * Note that some types of registers (like PROGRAM_UNIFORM) aren't defined + * by the ARB/NV program languages so we've taken some liberties here. + * \param f the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc) + * \param index number of the register in the register file + * \param mode the output format/mode/style + * \param prog pointer to containing program + */ +static const char * +reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, + GLboolean relAddr, const struct gl_program *prog) +{ + static char str[100]; + const char *addr = relAddr ? "ADDR+" : ""; + + str[0] = 0; + + switch (mode) { + case PROG_PRINT_DEBUG: + sprintf(str, "%s[%s%d]", file_string(f, mode), addr, index); + break; + case PROG_PRINT_ARB: +#if 0 + switch (f) { + case PROGRAM_INPUT: + sprintf(str, "%s", arb_input_attrib_string(index, prog->Target)); + break; + case PROGRAM_OUTPUT: + sprintf(str, "%s", arb_output_attrib_string(index, prog->Target)); + break; + case PROGRAM_TEMPORARY: + sprintf(str, "temp%d", index); + break; + case PROGRAM_ENV_PARAM: + sprintf(str, "program.env[%s%d]", addr, index); + break; + case PROGRAM_LOCAL_PARAM: + sprintf(str, "program.local[%s%d]", addr, index); + break; + case PROGRAM_VARYING: /* extension */ + sprintf(str, "varying[%s%d]", addr, index); + break; + case PROGRAM_CONSTANT: /* extension */ + sprintf(str, "constant[%s%d]", addr, index); + break; + case PROGRAM_UNIFORM: /* extension */ + sprintf(str, "uniform[%s%d]", addr, index); + break; + case PROGRAM_STATE_VAR: + { + struct gl_program_parameter *param + = prog->Parameters->Parameters + index; + char *state = _mesa_program_state_string(param->StateIndexes); + sprintf(str, "%s", state); + free(state); + } + break; + case PROGRAM_ADDRESS: + sprintf(str, "A%d", index); + break; + default: + _mesa_problem(NULL, "bad file in reg_string()"); + } + break; +#else + assert(0); + break; +#endif + + case PROG_PRINT_NV: + switch (f) { + case PROGRAM_INPUT: + if (prog->Target == GL_VERTEX_PROGRAM_ARB) + sprintf(str, "v[%d]", index); + else + sprintf(str, "f[%d]", index); + break; + case PROGRAM_OUTPUT: + sprintf(str, "o[%d]", index); + break; + case PROGRAM_TEMPORARY: + sprintf(str, "R%d", index); + break; + case PROGRAM_ENV_PARAM: + sprintf(str, "c[%d]", index); + break; + case PROGRAM_VARYING: /* extension */ + sprintf(str, "varying[%s%d]", addr, index); + break; + case PROGRAM_UNIFORM: /* extension */ + sprintf(str, "uniform[%s%d]", addr, index); + break; + case PROGRAM_CONSTANT: /* extension */ + sprintf(str, "constant[%s%d]", addr, index); + break; + case PROGRAM_STATE_VAR: /* extension */ + sprintf(str, "state[%s%d]", addr, index); + break; + default: + _mesa_problem(NULL, "bad file in reg_string()"); + } + break; + + default: + _mesa_problem(NULL, "bad mode in reg_string()"); + } + + return str; +} + + +/** + * Return a string representation of the given swizzle word. + * If extended is true, use extended (comma-separated) format. + * \param swizzle the swizzle field + * \param negateBase 4-bit negation vector + * \param extended if true, also allow 0, 1 values + */ +const char * +_mesa_swizzle_string(GLuint swizzle, GLuint negateMask, GLboolean extended) +{ + static const char swz[] = "xyzw01!?"; /* See SWIZZLE_x definitions */ + static char s[20]; + GLuint i = 0; + + if (!extended && swizzle == SWIZZLE_NOOP && negateMask == 0) + return ""; /* no swizzle/negation */ + + if (!extended) + s[i++] = '.'; + + if (negateMask & NEGATE_X) + s[i++] = '-'; + s[i++] = swz[GET_SWZ(swizzle, 0)]; + + if (extended) { + s[i++] = ','; + } + + if (negateMask & NEGATE_Y) + s[i++] = '-'; + s[i++] = swz[GET_SWZ(swizzle, 1)]; + + if (extended) { + s[i++] = ','; + } + + if (negateMask & NEGATE_Z) + s[i++] = '-'; + s[i++] = swz[GET_SWZ(swizzle, 2)]; + + if (extended) { + s[i++] = ','; + } + + if (negateMask & NEGATE_W) + s[i++] = '-'; + s[i++] = swz[GET_SWZ(swizzle, 3)]; + + s[i] = 0; + return s; +} + + +void +_mesa_print_swizzle(GLuint swizzle) +{ + if (swizzle == SWIZZLE_XYZW) { + printf(".xyzw\n"); + } + else { + const char *s = _mesa_swizzle_string(swizzle, 0, 0); + printf("%s\n", s); + } +} + + +const char * +_mesa_writemask_string(GLuint writeMask) +{ + static char s[10]; + GLuint i = 0; + + if (writeMask == WRITEMASK_XYZW) + return ""; + + s[i++] = '.'; + if (writeMask & WRITEMASK_X) + s[i++] = 'x'; + if (writeMask & WRITEMASK_Y) + s[i++] = 'y'; + if (writeMask & WRITEMASK_Z) + s[i++] = 'z'; + if (writeMask & WRITEMASK_W) + s[i++] = 'w'; + + s[i] = 0; + return s; +} + + +const char * +_mesa_condcode_string(GLuint condcode) +{ + switch (condcode) { + case COND_GT: return "GT"; + case COND_EQ: return "EQ"; + case COND_LT: return "LT"; + case COND_UN: return "UN"; + case COND_GE: return "GE"; + case COND_LE: return "LE"; + case COND_NE: return "NE"; + case COND_TR: return "TR"; + case COND_FL: return "FL"; + default: return "cond???"; + } +} + + +static void +fprint_dst_reg(FILE * f, + const struct prog_dst_register *dstReg, + gl_prog_print_mode mode, + const struct gl_program *prog) +{ + fprintf(f, "%s%s", + reg_string((gl_register_file) dstReg->File, + dstReg->Index, mode, dstReg->RelAddr, prog), + _mesa_writemask_string(dstReg->WriteMask)); + + if (dstReg->CondMask != COND_TR) { + fprintf(f, " (%s.%s)", + _mesa_condcode_string(dstReg->CondMask), + _mesa_swizzle_string(dstReg->CondSwizzle, + GL_FALSE, GL_FALSE)); + } + +#if 0 + fprintf(f, "%s[%d]%s", + file_string((gl_register_file) dstReg->File, mode), + dstReg->Index, + _mesa_writemask_string(dstReg->WriteMask)); +#endif +} + + +static void +fprint_src_reg(FILE *f, + const struct prog_src_register *srcReg, + gl_prog_print_mode mode, + const struct gl_program *prog) +{ + const char *abs = srcReg->Abs ? "|" : ""; + + fprintf(f, "%s%s%s%s", + abs, + reg_string((gl_register_file) srcReg->File, + srcReg->Index, mode, srcReg->RelAddr, prog), + _mesa_swizzle_string(srcReg->Swizzle, + srcReg->Negate, GL_FALSE), + abs); +#if 0 + fprintf(f, "%s[%d]%s", + file_string((gl_register_file) srcReg->File, mode), + srcReg->Index, + _mesa_swizzle_string(srcReg->Swizzle, + srcReg->Negate, GL_FALSE)); +#endif +} + + +static void +fprint_comment(FILE *f, const struct prog_instruction *inst) +{ + if (inst->Comment) + fprintf(f, "; # %s\n", inst->Comment); + else + fprintf(f, ";\n"); +} + + +static void +fprint_alu_instruction(FILE *f, + const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs, + gl_prog_print_mode mode, + const struct gl_program *prog) +{ + GLuint j; + + fprintf(f, "%s", opcode_string); + if (inst->CondUpdate) + fprintf(f, ".C"); + + /* frag prog only */ + if (inst->SaturateMode == SATURATE_ZERO_ONE) + fprintf(f, "_SAT"); + + fprintf(f, " "); + if (inst->DstReg.File != PROGRAM_UNDEFINED) { + fprint_dst_reg(f, &inst->DstReg, mode, prog); + } + else { + fprintf(f, " ???"); + } + + if (numRegs > 0) + fprintf(f, ", "); + + for (j = 0; j < numRegs; j++) { + fprint_src_reg(f, inst->SrcReg + j, mode, prog); + if (j + 1 < numRegs) + fprintf(f, ", "); + } + + fprint_comment(f, inst); +} + + +void +_mesa_print_alu_instruction(const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs) +{ + fprint_alu_instruction(stderr, inst, opcode_string, + numRegs, PROG_PRINT_DEBUG, NULL); +} + + +/** + * Print a single vertex/fragment program instruction. + */ +GLint +_mesa_fprint_instruction_opt(FILE *f, + const struct prog_instruction *inst, + GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog) +{ + GLint i; + + if (inst->Opcode == OPCODE_ELSE || + inst->Opcode == OPCODE_ENDIF || + inst->Opcode == OPCODE_ENDLOOP || + inst->Opcode == OPCODE_ENDSUB) { + indent -= 3; + } + for (i = 0; i < indent; i++) { + fprintf(f, " "); + } + + switch (inst->Opcode) { + case OPCODE_PRINT: + fprintf(f, "PRINT '%s'", (char *) inst->Data); + if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { + fprintf(f, ", "); + fprintf(f, "%s[%d]%s", + file_string((gl_register_file) inst->SrcReg[0].File, + mode), + inst->SrcReg[0].Index, + _mesa_swizzle_string(inst->SrcReg[0].Swizzle, + inst->SrcReg[0].Negate, GL_FALSE)); + } + if (inst->Comment) + fprintf(f, " # %s", inst->Comment); + fprint_comment(f, inst); + break; + case OPCODE_SWZ: + fprintf(f, "SWZ"); + if (inst->SaturateMode == SATURATE_ZERO_ONE) + fprintf(f, "_SAT"); + fprintf(f, " "); + fprint_dst_reg(f, &inst->DstReg, mode, prog); + fprintf(f, ", %s[%d], %s", + file_string((gl_register_file) inst->SrcReg[0].File, + mode), + inst->SrcReg[0].Index, + _mesa_swizzle_string(inst->SrcReg[0].Swizzle, + inst->SrcReg[0].Negate, GL_TRUE)); + fprint_comment(f, inst); + break; + case OPCODE_TEX: + case OPCODE_TXP: + case OPCODE_TXL: + case OPCODE_TXB: + fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); + if (inst->SaturateMode == SATURATE_ZERO_ONE) + fprintf(f, "_SAT"); + fprintf(f, " "); + fprint_dst_reg(f, &inst->DstReg, mode, prog); + fprintf(f, ", "); + fprint_src_reg(f, &inst->SrcReg[0], mode, prog); + fprintf(f, ", texture[%d], ", inst->TexSrcUnit); + switch (inst->TexSrcTarget) { + case TEXTURE_1D_INDEX: fprintf(f, "1D"); break; + case TEXTURE_2D_INDEX: fprintf(f, "2D"); break; + case TEXTURE_3D_INDEX: fprintf(f, "3D"); break; + case TEXTURE_CUBE_INDEX: fprintf(f, "CUBE"); break; + case TEXTURE_RECT_INDEX: fprintf(f, "RECT"); break; + case TEXTURE_1D_ARRAY_INDEX: fprintf(f, "1D_ARRAY"); break; + case TEXTURE_2D_ARRAY_INDEX: fprintf(f, "2D_ARRAY"); break; + default: + ; + } + if (inst->TexShadow) + fprintf(f, " SHADOW"); + fprint_comment(f, inst); + break; + + case OPCODE_KIL: + fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); + fprintf(f, " "); + fprint_src_reg(f, &inst->SrcReg[0], mode, prog); + fprint_comment(f, inst); + break; + case OPCODE_KIL_NV: + fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); + fprintf(f, " "); + fprintf(f, "%s.%s", + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, + GL_FALSE, GL_FALSE)); + fprint_comment(f, inst); + break; + + case OPCODE_ARL: + fprintf(f, "ARL "); + fprint_dst_reg(f, &inst->DstReg, mode, prog); + fprintf(f, ", "); + fprint_src_reg(f, &inst->SrcReg[0], mode, prog); + fprint_comment(f, inst); + break; + case OPCODE_BRA: + fprintf(f, "BRA %d (%s%s)", + inst->BranchTarget, + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); + fprint_comment(f, inst); + break; + case OPCODE_IF: + if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { + /* Use ordinary register */ + fprintf(f, "IF "); + fprint_src_reg(f, &inst->SrcReg[0], mode, prog); + fprintf(f, "; "); + } + else { + /* Use cond codes */ + fprintf(f, "IF (%s%s);", + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, + 0, GL_FALSE)); + } + fprintf(f, " # (if false, goto %d)", inst->BranchTarget); + fprint_comment(f, inst); + return indent + 3; + case OPCODE_ELSE: + fprintf(f, "ELSE; # (goto %d)\n", inst->BranchTarget); + return indent + 3; + case OPCODE_ENDIF: + fprintf(f, "ENDIF;\n"); + break; + case OPCODE_BGNLOOP: + fprintf(f, "BGNLOOP; # (end at %d)\n", inst->BranchTarget); + return indent + 3; + case OPCODE_ENDLOOP: + fprintf(f, "ENDLOOP; # (goto %d)\n", inst->BranchTarget); + break; + case OPCODE_BRK: + case OPCODE_CONT: + fprintf(f, "%s (%s%s); # (goto %d)", + _mesa_opcode_string(inst->Opcode), + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), + inst->BranchTarget); + fprint_comment(f, inst); + break; + + case OPCODE_BGNSUB: + if (mode == PROG_PRINT_NV) { + fprintf(f, "%s:\n", inst->Comment); /* comment is label */ + return indent; + } + else { + fprintf(f, "BGNSUB"); + fprint_comment(f, inst); + return indent + 3; + } + case OPCODE_ENDSUB: + if (mode == PROG_PRINT_DEBUG) { + fprintf(f, "ENDSUB"); + fprint_comment(f, inst); + } + break; + case OPCODE_CAL: + if (mode == PROG_PRINT_NV) { + fprintf(f, "CAL %s; # (goto %d)\n", inst->Comment, inst->BranchTarget); + } + else { + fprintf(f, "CAL %u", inst->BranchTarget); + fprint_comment(f, inst); + } + break; + case OPCODE_RET: + fprintf(f, "RET (%s%s)", + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); + fprint_comment(f, inst); + break; + + case OPCODE_END: + fprintf(f, "END\n"); + break; + case OPCODE_NOP: + if (mode == PROG_PRINT_DEBUG) { + fprintf(f, "NOP"); + fprint_comment(f, inst); + } + else if (inst->Comment) { + /* ARB/NV extensions don't have NOP instruction */ + fprintf(f, "# %s\n", inst->Comment); + } + break; + /* XXX may need other special-case instructions */ + default: + if (inst->Opcode < MAX_OPCODE) { + /* typical alu instruction */ + fprint_alu_instruction(f, inst, + _mesa_opcode_string(inst->Opcode), + _mesa_num_inst_src_regs(inst->Opcode), + mode, prog); + } + else { + fprint_alu_instruction(f, inst, + _mesa_opcode_string(inst->Opcode), + 3/*_mesa_num_inst_src_regs(inst->Opcode)*/, + mode, prog); + } + break; + } + return indent; +} + + +GLint +_mesa_print_instruction_opt(const struct prog_instruction *inst, + GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog) +{ + return _mesa_fprint_instruction_opt(stderr, inst, indent, mode, prog); +} + + +void +_mesa_print_instruction(const struct prog_instruction *inst) +{ + /* note: 4th param should be ignored for PROG_PRINT_DEBUG */ + _mesa_fprint_instruction_opt(stderr, inst, 0, PROG_PRINT_DEBUG, NULL); +} + +#if 0 +/** + * Print program, with options. + */ +void +_mesa_fprint_program_opt(FILE *f, + const struct gl_program *prog, + gl_prog_print_mode mode, + GLboolean lineNumbers) +{ + GLuint i, indent = 0; + + switch (prog->Target) { + case GL_VERTEX_PROGRAM_ARB: + if (mode == PROG_PRINT_ARB) + fprintf(f, "!!ARBvp1.0\n"); + else if (mode == PROG_PRINT_NV) + fprintf(f, "!!VP1.0\n"); + else + fprintf(f, "# Vertex Program/Shader %u\n", prog->Id); + break; + case GL_FRAGMENT_PROGRAM_ARB: + case GL_FRAGMENT_PROGRAM_NV: + if (mode == PROG_PRINT_ARB) + fprintf(f, "!!ARBfp1.0\n"); + else if (mode == PROG_PRINT_NV) + fprintf(f, "!!FP1.0\n"); + else + fprintf(f, "# Fragment Program/Shader %u\n", prog->Id); + break; + } + + for (i = 0; i < prog->NumInstructions; i++) { + if (lineNumbers) + fprintf(f, "%3d: ", i); + indent = _mesa_fprint_instruction_opt(f, prog->Instructions + i, + indent, mode, prog); + } +} + + +/** + * Print program to stderr, default options. + */ +void +_mesa_print_program(const struct gl_program *prog) +{ + _mesa_fprint_program_opt(stderr, prog, PROG_PRINT_DEBUG, GL_TRUE); +} + +/** + * Return binary representation of 64-bit value (as a string). + * Insert a comma to separate each group of 8 bits. + * Note we return a pointer to local static storage so this is not + * re-entrant, etc. + * XXX move to imports.[ch] if useful elsewhere. + */ +static const char * +binary(GLbitfield64 val) +{ + static char buf[80]; + GLint i, len = 0; + for (i = 63; i >= 0; --i) { + if (val & (1ULL << i)) + buf[len++] = '1'; + else if (len > 0 || i == 0) + buf[len++] = '0'; + if (len > 0 && ((i-1) % 8) == 7) + buf[len++] = ','; + } + buf[len] = '\0'; + return buf; +} + + +/** + * Print all of a program's parameters/fields to given file. + */ +static void +_mesa_fprint_program_parameters(FILE *f, + GLcontext *ctx, + const struct gl_program *prog) +{ + GLuint i; + + fprintf(f, "InputsRead: 0x%x (0b%s)\n", + prog->InputsRead, binary(prog->InputsRead)); + fprintf(f, "OutputsWritten: 0x%llx (0b%s)\n", + prog->OutputsWritten, binary(prog->OutputsWritten)); + fprintf(f, "NumInstructions=%d\n", prog->NumInstructions); + fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries); + fprintf(f, "NumParameters=%d\n", prog->NumParameters); + fprintf(f, "NumAttributes=%d\n", prog->NumAttributes); + fprintf(f, "NumAddressRegs=%d\n", prog->NumAddressRegs); + fprintf(f, "SamplersUsed: 0x%x (0b%s)\n", + prog->SamplersUsed, binary(prog->SamplersUsed)); + fprintf(f, "Samplers=[ "); + for (i = 0; i < MAX_SAMPLERS; i++) { + fprintf(f, "%d ", prog->SamplerUnits[i]); + } + fprintf(f, "]\n"); + + _mesa_load_state_parameters(ctx, prog->Parameters); + +#if 0 + fprintf(f, "Local Params:\n"); + for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){ + const GLfloat *p = prog->LocalParams[i]; + fprintf(f, "%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]); + } +#endif + _mesa_print_parameter_list(prog->Parameters); +} + + +/** + * Print all of a program's parameters/fields to stderr. + */ +void +_mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog) +{ + _mesa_fprint_program_parameters(stderr, ctx, prog); +} + + +/** + * Print a program parameter list to given file. + */ +static void +_mesa_fprint_parameter_list(FILE *f, + const struct gl_program_parameter_list *list) +{ + const gl_prog_print_mode mode = PROG_PRINT_DEBUG; + GLuint i; + + if (!list) + return; + + if (0) + fprintf(f, "param list %p\n", (void *) list); + fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags); + for (i = 0; i < list->NumParameters; i++){ + struct gl_program_parameter *param = list->Parameters + i; + const GLfloat *v = list->ParameterValues[i]; + fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", + i, param->Size, + file_string(list->Parameters[i].Type, mode), + param->Name, v[0], v[1], v[2], v[3]); + if (param->Flags & PROG_PARAM_BIT_CENTROID) + fprintf(f, " Centroid"); + if (param->Flags & PROG_PARAM_BIT_INVARIANT) + fprintf(f, " Invariant"); + if (param->Flags & PROG_PARAM_BIT_FLAT) + fprintf(f, " Flat"); + if (param->Flags & PROG_PARAM_BIT_LINEAR) + fprintf(f, " Linear"); + fprintf(f, "\n"); + } +} + + +/** + * Print a program parameter list to stderr. + */ +void +_mesa_print_parameter_list(const struct gl_program_parameter_list *list) +{ + _mesa_fprint_parameter_list(stderr, list); +} + + +/** + * Write shader and associated info to a file. + */ +void +_mesa_write_shader_to_file(const struct gl_shader *shader) +{ + const char *type; + char filename[100]; + FILE *f; + + if (shader->Type == GL_FRAGMENT_SHADER) + type = "frag"; + else + type = "vert"; + + snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + f = fopen(filename, "w"); + if (!f) { + fprintf(stderr, "Unable to open %s for writing\n", filename); + return; + } + + fprintf(f, "/* Shader %u source, checksum %u */\n", shader->Name, shader->SourceChecksum); + fputs(shader->Source, f); + fprintf(f, "\n"); + + fprintf(f, "/* Compile status: %s */\n", + shader->CompileStatus ? "ok" : "fail"); + if (!shader->CompileStatus) { + fprintf(f, "/* Log Info: */\n"); + fputs(shader->InfoLog, f); + } + else { + fprintf(f, "/* GPU code */\n"); + fprintf(f, "/*\n"); + _mesa_fprint_program_opt(f, shader->Program, PROG_PRINT_DEBUG, GL_TRUE); + fprintf(f, "*/\n"); + fprintf(f, "/* Parameters / constants */\n"); + fprintf(f, "/*\n"); + _mesa_fprint_parameter_list(f, shader->Program->Parameters); + fprintf(f, "*/\n"); + } + + fclose(f); +} + + +/** + * Append the shader's uniform info/values to the shader log file. + * The log file will typically have been created by the + * _mesa_write_shader_to_file function. + */ +void +_mesa_append_uniforms_to_file(const struct gl_shader *shader, + const struct gl_program *prog) +{ + const char *type; + char filename[100]; + FILE *f; + + if (shader->Type == GL_FRAGMENT_SHADER) + type = "frag"; + else + type = "vert"; + + snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + f = fopen(filename, "a"); /* append */ + if (!f) { + fprintf(stderr, "Unable to open %s for appending\n", filename); + return; + } + + fprintf(f, "/* First-draw parameters / constants */\n"); + fprintf(f, "/*\n"); + _mesa_fprint_parameter_list(f, prog->Parameters); + fprintf(f, "*/\n"); + + fclose(f); +} +#endif diff --git a/mesa/shader/prog_print.h b/mesa/shader/prog_print.h new file mode 100644 index 00000000000..f0df77b5129 --- /dev/null +++ b/mesa/shader/prog_print.h @@ -0,0 +1,98 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef PROG_PRINT_H +#define PROG_PRINT_H + + +/** + * The output style to use when printing programs. + */ +typedef enum { + PROG_PRINT_ARB, + PROG_PRINT_NV, + PROG_PRINT_DEBUG +} gl_prog_print_mode; + + +extern void +_mesa_print_vp_inputs(GLbitfield inputs); + +extern void +_mesa_print_fp_inputs(GLbitfield inputs); + +extern const char * +_mesa_condcode_string(GLuint condcode); + +extern const char * +_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended); + +const char * +_mesa_writemask_string(GLuint writeMask); + +extern void +_mesa_print_swizzle(GLuint swizzle); + +extern void +_mesa_print_alu_instruction(const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs); + +extern void +_mesa_print_instruction(const struct prog_instruction *inst); + +extern GLint +_mesa_fprint_instruction_opt(FILE *f, + const struct prog_instruction *inst, + GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog); + +extern GLint +_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog); + +extern void +_mesa_print_program(const struct gl_program *prog); + +extern void +_mesa_fprint_program_opt(FILE *f, + const struct gl_program *prog, gl_prog_print_mode mode, + GLboolean lineNumbers); + +#if 0 +extern void +_mesa_print_parameter_list(const struct gl_program_parameter_list *list); + +extern void +_mesa_write_shader_to_file(const struct gl_shader *shader); + +extern void +_mesa_append_uniforms_to_file(const struct gl_shader *shader, + const struct gl_program *prog); +#endif + + +#endif /* PROG_PRINT_H */ -- cgit v1.2.3 From 8197eeee3bbca4ab2deacfbf675285560f49e13c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 3 May 2010 16:17:57 -0700 Subject: ir_to_mesa: Fill in more bits of dest resg. --- ir_to_mesa.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index a0d3ae9c8d4..b55e5df9f66 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -544,6 +544,8 @@ do_ir_to_mesa(exec_list *instructions) mesa_inst->Opcode = inst->op; mesa_inst->DstReg.File = inst->dst_reg.file; mesa_inst->DstReg.Index = inst->dst_reg.index; + mesa_inst->DstReg.CondMask = COND_TR; + mesa_inst->DstReg.WriteMask = WRITEMASK_XYZW; mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); -- cgit v1.2.3 From c554d7cedee51bc170916c554c5f3dda51b3ab1e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 3 May 2010 16:20:04 -0700 Subject: ir_to_mesa: Remove dead code from when this was an ARB_fp printer. --- ir_to_mesa.cpp | 24 ------------------------ ir_to_mesa.h | 2 -- 2 files changed, 26 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index b55e5df9f66..feb7f454679 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -107,30 +107,6 @@ ir_to_mesa_visitor::create_tree(int op, struct mbtree *left, struct mbtree *righ return tree; } -const char * -produce_swizzle(int8_t *swizzle, const char *reg_name, - const char **swizzle_reg_name) -{ - if (swizzle[0] == 0 && - swizzle[1] == 1 && - swizzle[2] == 2 && - swizzle[3] == 3) - { - *swizzle_reg_name = reg_name; - } else { - char swizzle_letters[4] = { 'x', 'y', 'z', 'w' }; - char *temp; - asprintf(&temp, "%s.%c%c%c%c", - reg_name, - swizzle_letters[swizzle[0]], - swizzle_letters[swizzle[1]], - swizzle_letters[swizzle[2]], - swizzle_letters[swizzle[3]]); - *swizzle_reg_name = temp; - } - return *swizzle_reg_name; -} - /** * In the initial pass of codegen, we assign temporary numbers to * intermediate results. (not SSA -- variable assignments will reuse diff --git a/ir_to_mesa.h b/ir_to_mesa.h index cdf4f2c621a..e4c6940a338 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -61,8 +61,6 @@ struct mbtree { struct mbtree *right; void *state; uint16_t op; - const char *reg_name; - const char *swizzle_reg_name; class ir_to_mesa_visitor *v; /** -- cgit v1.2.3 From 34195832669f0eb7c4a80997cc524f8d10319307 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 3 May 2010 16:22:59 -0700 Subject: ir_to_mesa: Fix up src reg swizzling. --- ir_to_mesa.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index feb7f454679..11665a93e78 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -339,10 +339,10 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) { struct mbtree *tree; int size_swizzles[4] = { - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), }; ir_variable *var = ir->var->as_variable(); @@ -493,6 +493,7 @@ mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) mesa_reg.File = reg.file; assert(reg.index < (1 << INST_INDEX_BITS) - 1); mesa_reg.Index = reg.index; + mesa_reg.Swizzle = reg.swizzle; return mesa_reg; } -- cgit v1.2.3 From b7abce770fe9bb09a6f435d35c1a4afd134fa855 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 3 May 2010 17:26:14 -0700 Subject: ir_to_mesa: Print out the ir along with the Mesa IR. Ideally this would be hooked up by ir_print_visitor dumping into a string that we could include as prog_instruction->Comment when in debug mode, and not try keeping ir_instruction trees around after conversion to Mesa. The ir_print_visitor isn't set up to do that for us today. --- ir_to_mesa.cpp | 46 +++++++++++++++++++++++++++++++++------------- ir_to_mesa.h | 6 ++++++ mesa/shader/prog_print.c | 2 +- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 11665a93e78..fc0649c60ee 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -68,6 +68,7 @@ ir_to_mesa_emit_op3(struct mbtree *tree, enum prog_opcode op, inst->src_reg[0] = src0; inst->src_reg[1] = src1; inst->src_reg[2] = src2; + inst->ir = tree->ir; tree->v->instructions.push_tail(inst); @@ -94,15 +95,20 @@ ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op, } struct mbtree * -ir_to_mesa_visitor::create_tree(int op, struct mbtree *left, struct mbtree *right) +ir_to_mesa_visitor::create_tree(int op, + ir_instruction *ir, + struct mbtree *left, struct mbtree *right) { struct mbtree *tree = (struct mbtree *)calloc(sizeof(struct mbtree), 1); + assert(ir); + tree->op = op; tree->left = left; tree->right = right; tree->v = this; tree->src_reg.swizzle = SWIZZLE_XYZW; + tree->ir = ir; return tree; } @@ -249,31 +255,34 @@ ir_to_mesa_visitor::visit(ir_expression *ir) switch (ir->operation) { case ir_binop_add: - this->result = this->create_tree(MB_TERM_add_vec4_vec4, op[0], op[1]); + this->result = this->create_tree(MB_TERM_add_vec4_vec4, ir, op[0], op[1]); break; case ir_binop_sub: - this->result = this->create_tree(MB_TERM_sub_vec4_vec4, op[0], op[1]); + this->result = this->create_tree(MB_TERM_sub_vec4_vec4, ir, op[0], op[1]); break; case ir_binop_mul: - this->result = this->create_tree(MB_TERM_mul_vec4_vec4, op[0], op[1]); + this->result = this->create_tree(MB_TERM_mul_vec4_vec4, ir, op[0], op[1]); break; case ir_binop_div: - this->result = this->create_tree(MB_TERM_div_vec4_vec4, op[0], op[1]); + this->result = this->create_tree(MB_TERM_div_vec4_vec4, ir, op[0], op[1]); break; case ir_binop_dot: if (ir->operands[0]->type == vec4_type) { assert(ir->operands[1]->type == vec4_type); - this->result = this->create_tree(MB_TERM_dp4_vec4_vec4, op[0], op[1]); + this->result = this->create_tree(MB_TERM_dp4_vec4_vec4, + ir, op[0], op[1]); } else if (ir->operands[0]->type == vec3_type) { assert(ir->operands[1]->type == vec3_type); - this->result = this->create_tree(MB_TERM_dp3_vec4_vec4, op[0], op[1]); + this->result = this->create_tree(MB_TERM_dp3_vec4_vec4, + ir, op[0], op[1]); } else if (ir->operands[0]->type == vec2_type) { assert(ir->operands[1]->type == vec2_type); - this->result = this->create_tree(MB_TERM_dp2_vec4_vec4, op[0], op[1]); + this->result = this->create_tree(MB_TERM_dp2_vec4_vec4, + ir, op[0], op[1]); } break; case ir_unop_sqrt: - this->result = this->create_tree(MB_TERM_sqrt_vec4, op[0], op[1]); + this->result = this->create_tree(MB_TERM_sqrt_vec4, ir, op[0], op[1]); break; default: break; @@ -299,7 +308,7 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) ir->val->accept(this); assert(this->result); - tree = this->create_tree(MB_TERM_swizzle_vec4, this->result, NULL); + tree = this->create_tree(MB_TERM_swizzle_vec4, ir, this->result, NULL); for (i = 0; i < 4; i++) { if (i < ir->type->vector_elements) { @@ -391,7 +400,9 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) assert(strcmp(var->name, "gl_TexCoord") == 0); asprintf(&name, "fragment.texcoord[%d]", index->value.i[0]); - tree = this->create_tree(MB_TERM_reference_vec4, NULL, NULL); + tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); + tree->src_reg.file = PROGRAM_INPUT; + tree->src_reg.index = FRAG_ATTRIB_TEX0 + index->value.i[0]; tree->reg_name = name; /* If the type is smaller than a vec4, replicate the last channel out. */ @@ -421,7 +432,7 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) assert(!ir->condition); - t = this->create_tree(MB_TERM_assign, l, r); + t = this->create_tree(MB_TERM_assign, ir, l, r); mono_burg_label(t, NULL); reduce(t, MB_NTERM_stmt); } @@ -434,7 +445,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir) assert(!ir->type->is_matrix()); - tree = this->create_tree(MB_TERM_reference_vec4, NULL, NULL); + tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); assert(ir->type->base_type == GLSL_TYPE_FLOAT); @@ -503,6 +514,7 @@ do_ir_to_mesa(exec_list *instructions) { ir_to_mesa_visitor v; struct prog_instruction *mesa_instructions, *mesa_inst; + ir_instruction *last_ir = NULL; visit_exec_list(instructions, &v); @@ -518,6 +530,14 @@ do_ir_to_mesa(exec_list *instructions) mesa_inst = mesa_instructions; foreach_iter(exec_list_iterator, iter, v.instructions) { ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); + + if (last_ir != inst->ir) { + ir_print_visitor print; + inst->ir->accept(&print); + printf("\n"); + last_ir = inst->ir; + } + mesa_inst->Opcode = inst->op; mesa_inst->DstReg.File = inst->dst_reg.file; mesa_inst->DstReg.Index = inst->dst_reg.index; diff --git a/ir_to_mesa.h b/ir_to_mesa.h index e4c6940a338..d9482264d46 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -54,6 +54,8 @@ public: enum prog_opcode op; ir_to_mesa_dst_reg dst_reg; ir_to_mesa_src_reg src_reg[3]; + /** Pointer to the ir source this tree came from for debugging */ + ir_instruction *ir; }; struct mbtree { @@ -63,6 +65,9 @@ struct mbtree { uint16_t op; class ir_to_mesa_visitor *v; + /** Pointer to the ir source this tree came from for debugging */ + ir_instruction *ir; + /** * This is the representation of this tree node's results as a * source register for its consumer. @@ -102,6 +107,7 @@ public: void get_temp_for_var(ir_variable *var, struct mbtree *tree); struct mbtree *create_tree(int op, + ir_instruction *ir, struct mbtree *left, struct mbtree *right); diff --git a/mesa/shader/prog_print.c b/mesa/shader/prog_print.c index 9ac090b2617..3f1cb48e4bf 100644 --- a/mesa/shader/prog_print.c +++ b/mesa/shader/prog_print.c @@ -833,7 +833,7 @@ void _mesa_print_instruction(const struct prog_instruction *inst) { /* note: 4th param should be ignored for PROG_PRINT_DEBUG */ - _mesa_fprint_instruction_opt(stderr, inst, 0, PROG_PRINT_DEBUG, NULL); + _mesa_fprint_instruction_opt(stdout, inst, 0, PROG_PRINT_DEBUG, NULL); } #if 0 -- cgit v1.2.3 From f14913d4b7ede498803615296651cab4bbd341d7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 4 May 2010 11:42:20 -0700 Subject: ir_to_mesa: Do my best to explain how the codegen rules work. --- mesa_codegen.brg | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/mesa_codegen.brg b/mesa_codegen.brg index 1f6ccfaf0c2..6a34b68068e 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -44,6 +44,8 @@ #define MBTREE_TYPE struct mbtree %% +# The list of terminals is the set of things that ir_to_mesa.cpp will +# generate in its trees. %term assign %term reference_vec4 %term add_vec4_vec4 @@ -56,17 +58,65 @@ %term sqrt_vec4 %term swizzle_vec4 +# Each tree will produce stmt. Currently, the only production for +# stmt is from an assign rule -- every statement tree from +# ir_to_mesa.cpp assigns a result to a register. + %start stmt +# Now comes all the rules for code generation. Each rule is of the +# general form +# +# produced: term(term, term) cost +# { +# code_run_when_we_choose_this_rule(); +# } +# +# where choosing this rule means we turn term(term, term) into +# produced at the cost of "cost". We measure "cost" in approximate +# instruction count. The BURG should then more or less minimize the +# number of instructions. +# +# A reference of a variable has an allocated register already, so it +# can be used as an argument for pretty much anything. alloced_vec4: reference_vec4 0 +# If something produces a vec4 with a location already, then we don't need +# to allocate a temp reg for it. vec4: alloced_vec4 0 + +# If something produces a vec4 result that needs a place to live, +# then there's a cost with allocating a temporary for it. We +# approximate that as one instruction's cost, even though sometimes +# that temp might not be a newly-allocated temp due to later +# live-dead analysis. alloced_vec4: vec4 1 { /* FINISHME */ tree->v->get_temp(tree); } +# Here's the rule everyone will hit: Moving the result of an +# expression into a variable-dereference register location. +# +# Note that this is likely a gratuitous move. We could make variants +# of each of the following rules, e.g: +# +# vec4: add_vec4_vec4(alloced_vec4, alloced_vec4) 1 +# { +# emit(ADD, tree, tree->left, tree->right); +# } +# +# becoming +# +# vec4: assign(alloced_vec4_vec4, add_vec4_vec4(alloced_vec4, alloced_vec4) 1 +# { +# emit(ADD, tree->left, tree->right->left, tree->right->right); +# } +# +# But it seems like a lot of extra typing and duped code, when we +# probably want copy propagation and dead code after codegen anyway, +# which would clean these up. stmt: assign(alloced_vec4, alloced_vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_MOV, @@ -74,6 +124,8 @@ stmt: assign(alloced_vec4, alloced_vec4) 1 tree->left->src_reg); } +# Perform a swizzle by composing our swizzle with the swizzle +# required to get at the src reg. vec4: swizzle_vec4(alloced_vec4) 1 { ir_to_mesa_src_reg reg = tree->left->src_reg; -- cgit v1.2.3 From 7aa0b034f70e3140aece94091b2ab200427077e9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 4 May 2010 11:47:57 -0700 Subject: ir_to_mesa: Fix up the assign rule to use left and right correctly. The destination of assign is in left, not in the node itself. --- mesa_codegen.brg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesa_codegen.brg b/mesa_codegen.brg index 6a34b68068e..9f2761b08e2 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -120,8 +120,8 @@ alloced_vec4: vec4 1 stmt: assign(alloced_vec4, alloced_vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_MOV, - ir_to_mesa_dst_reg_from_src(tree->src_reg), - tree->left->src_reg); + ir_to_mesa_dst_reg_from_src(tree->left->src_reg), + tree->right->src_reg); } # Perform a swizzle by composing our swizzle with the swizzle -- cgit v1.2.3 From ae252d3613d10a051657c4ca6db27409f7cf40ae Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 4 May 2010 11:51:41 -0700 Subject: ir_to_mesa: Make the first temp index we use 1 to show off bugs. Regs aren't allocated at the right times yet, so we see TEMP[0] a lot. --- ir_to_mesa.cpp | 7 +++++++ ir_to_mesa.h | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index fc0649c60ee..f36dea5f314 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -496,6 +496,13 @@ ir_to_mesa_visitor::visit(ir_if *ir) exit(1); } +ir_to_mesa_visitor::ir_to_mesa_visitor() +{ + result = NULL; + next_temp = 1; + next_constant = 0; +} + static struct prog_src_register mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) { diff --git a/ir_to_mesa.h b/ir_to_mesa.h index d9482264d46..cef27f8b79c 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -92,12 +92,7 @@ public: class ir_to_mesa_visitor : public ir_visitor { public: - ir_to_mesa_visitor() - { - result = NULL; - next_temp = 0; - next_constant = 0; - } + ir_to_mesa_visitor(); int next_temp; int next_constant; -- cgit v1.2.3 From b2ed4dd7b0270e469302965269007292117d02e2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 4 May 2010 11:58:03 -0700 Subject: ir_to_mesa: Get temps allocated at the right times. The alloced_vec4/vec4 distinction was an experiment to expose the cost of temps to the codegen. But the problem is that the temporary production rule gets called after the emit rule that was using the temp. We could have the args to emit_op be pointers to where the temp would get allocated later, but that seems overly hard while just trying to bring this thing up. Besides, the temps used in expressions bear only the vaguest relation to how many temps will be used after register allocation. --- ir_to_mesa.cpp | 4 ++++ mesa_codegen.brg | 47 ++++++++++++++++------------------------------- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index f36dea5f314..eb55f82e27f 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -293,6 +293,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir) ir->accept(&v); exit(1); } + + /* Allocate a temporary for the result. */ + this->get_temp(this->result); } @@ -309,6 +312,7 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) assert(this->result); tree = this->create_tree(MB_TERM_swizzle_vec4, ir, this->result, NULL); + this->get_temp(tree); for (i = 0; i < 4; i++) { if (i < ir->type->vector_elements) { diff --git a/mesa_codegen.brg b/mesa_codegen.brg index 9f2761b08e2..f1f24dab84f 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -76,25 +76,10 @@ # produced at the cost of "cost". We measure "cost" in approximate # instruction count. The BURG should then more or less minimize the # number of instructions. -# -# A reference of a variable has an allocated register already, so it -# can be used as an argument for pretty much anything. -alloced_vec4: reference_vec4 0 - -# If something produces a vec4 with a location already, then we don't need -# to allocate a temp reg for it. -vec4: alloced_vec4 0 - -# If something produces a vec4 result that needs a place to live, -# then there's a cost with allocating a temporary for it. We -# approximate that as one instruction's cost, even though sometimes -# that temp might not be a newly-allocated temp due to later -# live-dead analysis. -alloced_vec4: vec4 1 -{ - /* FINISHME */ - tree->v->get_temp(tree); -} + +# A reference of a variable is just a vec4 register location, +# so it can be used as an argument for pretty much anything. +vec4: reference_vec4 0 # Here's the rule everyone will hit: Moving the result of an # expression into a variable-dereference register location. @@ -102,14 +87,14 @@ alloced_vec4: vec4 1 # Note that this is likely a gratuitous move. We could make variants # of each of the following rules, e.g: # -# vec4: add_vec4_vec4(alloced_vec4, alloced_vec4) 1 +# vec4: add_vec4_vec4(vec4, vec4) 1 # { # emit(ADD, tree, tree->left, tree->right); # } # # becoming # -# vec4: assign(alloced_vec4_vec4, add_vec4_vec4(alloced_vec4, alloced_vec4) 1 +# vec4: assign(vec4_vec4, add_vec4_vec4(vec4, vec4) 1 # { # emit(ADD, tree->left, tree->right->left, tree->right->right); # } @@ -117,7 +102,7 @@ alloced_vec4: vec4 1 # But it seems like a lot of extra typing and duped code, when we # probably want copy propagation and dead code after codegen anyway, # which would clean these up. -stmt: assign(alloced_vec4, alloced_vec4) 1 +stmt: assign(vec4, vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_MOV, ir_to_mesa_dst_reg_from_src(tree->left->src_reg), @@ -126,7 +111,7 @@ stmt: assign(alloced_vec4, alloced_vec4) 1 # Perform a swizzle by composing our swizzle with the swizzle # required to get at the src reg. -vec4: swizzle_vec4(alloced_vec4) 1 +vec4: swizzle_vec4(vec4) 1 { ir_to_mesa_src_reg reg = tree->left->src_reg; int swiz[4]; @@ -145,7 +130,7 @@ vec4: swizzle_vec4(alloced_vec4) 1 reg); } -vec4: add_vec4_vec4(alloced_vec4, alloced_vec4) 1 +vec4: add_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_ADD, ir_to_mesa_dst_reg_from_src(tree->src_reg), @@ -153,7 +138,7 @@ vec4: add_vec4_vec4(alloced_vec4, alloced_vec4) 1 tree->right->src_reg); } -vec4: sub_vec4_vec4(alloced_vec4, alloced_vec4) 1 +vec4: sub_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SUB, ir_to_mesa_dst_reg_from_src(tree->src_reg), @@ -161,7 +146,7 @@ vec4: sub_vec4_vec4(alloced_vec4, alloced_vec4) 1 tree->right->src_reg); } -vec4: mul_vec4_vec4(alloced_vec4, alloced_vec4) 1 +vec4: mul_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_MUL, ir_to_mesa_dst_reg_from_src(tree->src_reg), @@ -169,7 +154,7 @@ vec4: mul_vec4_vec4(alloced_vec4, alloced_vec4) 1 tree->right->src_reg); } -vec4: dp4_vec4_vec4(alloced_vec4, alloced_vec4) 1 +vec4: dp4_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_DP4, ir_to_mesa_dst_reg_from_src(tree->src_reg), @@ -178,7 +163,7 @@ vec4: dp4_vec4_vec4(alloced_vec4, alloced_vec4) 1 tree->src_reg.swizzle = SWIZZLE_XXXX; } -vec4: dp3_vec4_vec4(alloced_vec4, alloced_vec4) 1 +vec4: dp3_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_DP3, ir_to_mesa_dst_reg_from_src(tree->src_reg), @@ -188,7 +173,7 @@ vec4: dp3_vec4_vec4(alloced_vec4, alloced_vec4) 1 } -vec4: dp2_vec4_vec4(alloced_vec4, alloced_vec4) 1 +vec4: dp2_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_DP2, ir_to_mesa_dst_reg_from_src(tree->src_reg), @@ -197,7 +182,7 @@ vec4: dp2_vec4_vec4(alloced_vec4, alloced_vec4) 1 tree->src_reg.swizzle = SWIZZLE_XXXX; } -vec4: div_vec4_vec4(alloced_vec4, alloced_vec4) 1 +vec4: div_vec4_vec4(vec4, vec4) 1 { /* FINISHME: Mesa RCP only uses the X channel, this node is for vec4. */ ir_to_mesa_emit_op1(tree, OPCODE_RCP, @@ -210,7 +195,7 @@ vec4: div_vec4_vec4(alloced_vec4, alloced_vec4) 1 tree->left->src_reg); } -vec4: sqrt_vec4(alloced_vec4) 1 +vec4: sqrt_vec4(vec4) 1 { /* FINISHME: Mesa RSQ only uses the X channel, this node is for vec4. */ ir_to_mesa_emit_op1(tree, OPCODE_RSQ, -- cgit v1.2.3 From 12f654c63bc42d353e258cde989d9114cdde26c6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 5 May 2010 17:21:18 -0700 Subject: ir_to_mesa: Produce multiple scalar ops when required to produce vec4s. Fixes the code emitted in a test shader for vec2 texcoord / vec2 tex_size. --- ir_to_mesa.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++++- ir_to_mesa.h | 7 +++++++ mesa_codegen.brg | 14 ++++++-------- 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index eb55f82e27f..77ca6df73c7 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -94,6 +94,51 @@ ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op, dst, src0, ir_to_mesa_undef, ir_to_mesa_undef); } +/** + * Emits Mesa scalar opcodes to produce unique answers across channels. + * + * Some Mesa opcodes are scalar-only, like ARB_fp/vp. The src X + * channel determines the result across all channels. So to do a vec4 + * of this operation, we want to emit a scalar per source channel used + * to produce dest channels. + */ +void +ir_to_mesa_emit_scalar_op1(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0) +{ + int i, j; + int done_mask = 0; + + /* Mesa RCP is a scalar operation splatting results to all channels, + * like ARB_fp/vp. So emit as many RCPs as necessary to cover our + * dst channels. + */ + for (i = 0; i < 4; i++) { + int this_mask = (1 << i); + ir_to_mesa_instruction *inst; + ir_to_mesa_src_reg src = src0; + + if (done_mask & this_mask) + continue; + + int src_swiz = GET_SWZ(src.swizzle, i); + for (j = i + 1; j < 4; j++) { + if (GET_SWZ(src.swizzle, j) == src_swiz) { + this_mask |= (1 << j); + } + } + src.swizzle = MAKE_SWIZZLE4(src_swiz, src_swiz, + src_swiz, src_swiz); + + inst = ir_to_mesa_emit_op1(tree, op, + dst, + src); + inst->dst_reg.writemask = this_mask; + done_mask |= this_mask; + } +} + struct mbtree * ir_to_mesa_visitor::create_tree(int op, ir_instruction *ir, @@ -553,7 +598,7 @@ do_ir_to_mesa(exec_list *instructions) mesa_inst->DstReg.File = inst->dst_reg.file; mesa_inst->DstReg.Index = inst->dst_reg.index; mesa_inst->DstReg.CondMask = COND_TR; - mesa_inst->DstReg.WriteMask = WRITEMASK_XYZW; + mesa_inst->DstReg.WriteMask = inst->dst_reg.writemask; mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); diff --git a/ir_to_mesa.h b/ir_to_mesa.h index cef27f8b79c..c8ceb4c1715 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -45,6 +45,7 @@ typedef struct ir_to_mesa_src_reg { typedef struct ir_to_mesa_dst_reg { int file; /**< PROGRAM_* from Mesa */ int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ + int writemask; /**< Bitfield of WRITEMASK_[XYZW] */ } ir_to_mesa_dst_reg; extern ir_to_mesa_src_reg ir_to_mesa_undef; @@ -159,6 +160,11 @@ ir_to_mesa_emit_op3(struct mbtree *tree, enum prog_opcode op, ir_to_mesa_src_reg src1, ir_to_mesa_src_reg src2); +void +ir_to_mesa_emit_scalar_op1(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); + inline ir_to_mesa_dst_reg ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) { @@ -166,6 +172,7 @@ ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) dst_reg.file = reg.file; dst_reg.index = reg.index; + dst_reg.writemask = WRITEMASK_XYZW; return dst_reg; } diff --git a/mesa_codegen.brg b/mesa_codegen.brg index f1f24dab84f..3191a44c210 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -184,10 +184,9 @@ vec4: dp2_vec4_vec4(vec4, vec4) 1 vec4: div_vec4_vec4(vec4, vec4) 1 { - /* FINISHME: Mesa RCP only uses the X channel, this node is for vec4. */ - ir_to_mesa_emit_op1(tree, OPCODE_RCP, - ir_to_mesa_dst_reg_from_src(tree->src_reg), - tree->right->src_reg); + ir_to_mesa_emit_scalar_op1(tree, OPCODE_RCP, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->left->src_reg); ir_to_mesa_emit_op2(tree, OPCODE_MUL, ir_to_mesa_dst_reg_from_src(tree->src_reg), @@ -197,10 +196,9 @@ vec4: div_vec4_vec4(vec4, vec4) 1 vec4: sqrt_vec4(vec4) 1 { - /* FINISHME: Mesa RSQ only uses the X channel, this node is for vec4. */ - ir_to_mesa_emit_op1(tree, OPCODE_RSQ, - ir_to_mesa_dst_reg_from_src(tree->src_reg), - tree->left->src_reg); + ir_to_mesa_emit_scalar_op1(tree, OPCODE_RSQ, + ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->left->src_reg); ir_to_mesa_emit_op1(tree, OPCODE_RCP, ir_to_mesa_dst_reg_from_src(tree->src_reg), -- cgit v1.2.3 From b07cc372c6360d0e59c84bb7586597f028c74b02 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 09:25:56 -0700 Subject: ir_to_mesa: Handle swizzles on LHS of assignment (writemasks). --- ir_to_mesa.cpp | 73 +++++++++++++++++++++++++++++++++++++++++--------------- ir_to_mesa.h | 2 ++ mesa_codegen.brg | 24 +++++++++---------- 3 files changed, 68 insertions(+), 31 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 77ca6df73c7..3976f437f93 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -139,6 +139,16 @@ ir_to_mesa_emit_scalar_op1(struct mbtree *tree, enum prog_opcode op, } } +static void +ir_to_mesa_set_tree_reg(struct mbtree *tree, int file, int index) +{ + tree->dst_reg.file = file; + tree->dst_reg.index = index; + + tree->src_reg.file = file; + tree->src_reg.index = index; +} + struct mbtree * ir_to_mesa_visitor::create_tree(int op, ir_instruction *ir, @@ -153,6 +163,8 @@ ir_to_mesa_visitor::create_tree(int op, tree->right = right; tree->v = this; tree->src_reg.swizzle = SWIZZLE_XYZW; + tree->dst_reg.writemask = WRITEMASK_XYZW; + ir_to_mesa_set_tree_reg(tree, PROGRAM_UNDEFINED, 0); tree->ir = ir; return tree; @@ -167,8 +179,7 @@ ir_to_mesa_visitor::create_tree(int op, void ir_to_mesa_visitor::get_temp(struct mbtree *tree) { - tree->src_reg.file = PROGRAM_TEMPORARY; - tree->src_reg.index = this->next_temp++; + ir_to_mesa_set_tree_reg(tree, PROGRAM_TEMPORARY, this->next_temp++); } void @@ -180,8 +191,7 @@ ir_to_mesa_visitor::get_temp_for_var(ir_variable *var, struct mbtree *tree) entry = (temp_entry *)iter.get(); if (entry->var == var) { - tree->src_reg.file = entry->file; - tree->src_reg.index = entry->index; + ir_to_mesa_set_tree_reg(tree, entry->file, entry->index); return; } } @@ -189,8 +199,7 @@ ir_to_mesa_visitor::get_temp_for_var(ir_variable *var, struct mbtree *tree) entry = new temp_entry(var, PROGRAM_TEMPORARY, this->next_temp++); this->variable_storage.push_tail(entry); - tree->src_reg.file = entry->file; - tree->src_reg.index = entry->index; + ir_to_mesa_set_tree_reg(tree, entry->file, entry->index); } static void @@ -351,7 +360,10 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) int i; int swizzle[4]; - /* FINISHME: Handle swizzles on the left side of an assignment. */ + /* Note that this is only swizzles in expressions, not those on the left + * hand side of an assignment, which do write masking. See ir_assignment + * for that. + */ ir->val->accept(this); assert(this->result); @@ -410,12 +422,11 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) */ assert(!var->type->is_matrix()); - tree = this->create_tree(MB_TERM_reference_vec4, NULL, NULL); + tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); if (strncmp(var->name, "gl_", 3) == 0) { if (strcmp(var->name, "gl_FragColor") == 0) { - tree->src_reg.file = PROGRAM_INPUT; - tree->src_reg.index = FRAG_ATTRIB_COL0; + ir_to_mesa_set_tree_reg(tree, PROGRAM_INPUT, FRAG_ATTRIB_COL0); } else { assert(0); } @@ -442,17 +453,14 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) ir_variable *var = ir->array->as_variable(); ir_constant *index = ir->array_index->constant_expression_value(); - char *name; assert(var); assert(index); assert(strcmp(var->name, "gl_TexCoord") == 0); - asprintf(&name, "fragment.texcoord[%d]", index->value.i[0]); tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - tree->src_reg.file = PROGRAM_INPUT; - tree->src_reg.index = FRAG_ATTRIB_TEX0 + index->value.i[0]; - tree->reg_name = name; + ir_to_mesa_set_tree_reg(tree, PROGRAM_INPUT, + FRAG_ATTRIB_TEX0 + index->value.i[0]); /* If the type is smaller than a vec4, replicate the last channel out. */ tree->src_reg.swizzle = size_swizzles[ir->type->vector_elements - 1]; @@ -460,6 +468,34 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) this->result = tree; } +static struct mbtree * +get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) +{ + struct mbtree *tree = NULL; + ir_dereference *deref; + ir_swizzle *swiz; + + if ((deref = ir->as_dereference())) { + ir->accept(v); + tree = v->result; + } else if ((swiz = ir->as_swizzle())) { + tree = get_assignment_lhs(swiz->val, v); + tree->dst_reg.writemask = 0; + if (swiz->mask.num_components >= 1) + tree->dst_reg.writemask |= (1 << swiz->mask.x); + if (swiz->mask.num_components >= 2) + tree->dst_reg.writemask |= (1 << swiz->mask.y); + if (swiz->mask.num_components >= 3) + tree->dst_reg.writemask |= (1 << swiz->mask.z); + if (swiz->mask.num_components >= 4) + tree->dst_reg.writemask |= (1 << swiz->mask.w); + } + + assert(tree); + + return tree; +} + void ir_to_mesa_visitor::visit(ir_dereference_record *ir) { @@ -472,8 +508,8 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) { struct mbtree *l, *r, *t; - ir->lhs->accept(this); - l = this->result; + l = get_assignment_lhs(ir->lhs, this); + ir->rhs->accept(this); r = this->result; assert(l); @@ -504,8 +540,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir) */ /* FINISHME: Do something with the constant values for now. */ - tree->src_reg.file = PROGRAM_CONSTANT; - tree->src_reg.index = this->next_constant++; + ir_to_mesa_set_tree_reg(tree, PROGRAM_CONSTANT, this->next_constant++); tree->src_reg.swizzle = SWIZZLE_NOOP; this->result = tree; diff --git a/ir_to_mesa.h b/ir_to_mesa.h index c8ceb4c1715..00328e5fab2 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -69,6 +69,8 @@ struct mbtree { /** Pointer to the ir source this tree came from for debugging */ ir_instruction *ir; + ir_to_mesa_dst_reg dst_reg; + /** * This is the representation of this tree node's results as a * source register for its consumer. diff --git a/mesa_codegen.brg b/mesa_codegen.brg index 3191a44c210..b117aff0f6b 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -105,7 +105,7 @@ vec4: reference_vec4 0 stmt: assign(vec4, vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_MOV, - ir_to_mesa_dst_reg_from_src(tree->left->src_reg), + tree->left->dst_reg, tree->right->src_reg); } @@ -126,14 +126,14 @@ vec4: swizzle_vec4(vec4) 1 reg.swizzle = MAKE_SWIZZLE4(swiz[0], swiz[1], swiz[2], swiz[3]); ir_to_mesa_emit_op1(tree, OPCODE_MOV, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, reg); } vec4: add_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_ADD, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, tree->left->src_reg, tree->right->src_reg); } @@ -141,7 +141,7 @@ vec4: add_vec4_vec4(vec4, vec4) 1 vec4: sub_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SUB, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, tree->left->src_reg, tree->right->src_reg); } @@ -149,7 +149,7 @@ vec4: sub_vec4_vec4(vec4, vec4) 1 vec4: mul_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_MUL, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, tree->left->src_reg, tree->right->src_reg); } @@ -157,7 +157,7 @@ vec4: mul_vec4_vec4(vec4, vec4) 1 vec4: dp4_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_DP4, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, tree->left->src_reg, tree->right->src_reg); tree->src_reg.swizzle = SWIZZLE_XXXX; @@ -166,7 +166,7 @@ vec4: dp4_vec4_vec4(vec4, vec4) 1 vec4: dp3_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_DP3, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, tree->left->src_reg, tree->right->src_reg); tree->src_reg.swizzle = SWIZZLE_XXXX; @@ -176,7 +176,7 @@ vec4: dp3_vec4_vec4(vec4, vec4) 1 vec4: dp2_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_DP2, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, tree->left->src_reg, tree->right->src_reg); tree->src_reg.swizzle = SWIZZLE_XXXX; @@ -185,11 +185,11 @@ vec4: dp2_vec4_vec4(vec4, vec4) 1 vec4: div_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_scalar_op1(tree, OPCODE_RCP, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, tree->left->src_reg); ir_to_mesa_emit_op2(tree, OPCODE_MUL, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, tree->src_reg, tree->left->src_reg); } @@ -197,11 +197,11 @@ vec4: div_vec4_vec4(vec4, vec4) 1 vec4: sqrt_vec4(vec4) 1 { ir_to_mesa_emit_scalar_op1(tree, OPCODE_RSQ, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, tree->left->src_reg); ir_to_mesa_emit_op1(tree, OPCODE_RCP, - ir_to_mesa_dst_reg_from_src(tree->src_reg), + tree->dst_reg, tree->src_reg); } -- cgit v1.2.3 From 3d70d1f4d684a943b8b4a65319641415882b72cb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 09:35:56 -0700 Subject: ir_to_mesa: Emit more reduced writemasks for ops on small types. This should help prevent Mesa from having to be smart to give channel-wise drivers better information. --- ir_to_mesa.cpp | 16 +++++++++++++--- ir_to_mesa.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 3976f437f93..a01c50cbc2f 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -177,9 +177,19 @@ ir_to_mesa_visitor::create_tree(int op, * pass over the Mesa IR later. */ void -ir_to_mesa_visitor::get_temp(struct mbtree *tree) +ir_to_mesa_visitor::get_temp(struct mbtree *tree, int size) { + int swizzle = 0; + int i; + ir_to_mesa_set_tree_reg(tree, PROGRAM_TEMPORARY, this->next_temp++); + + for (i = 0; i < size; i++) + swizzle |= 1 << i; + for (; i < 4; i++) + swizzle |= 1 << (size - 1); + tree->src_reg.swizzle = swizzle; + tree->dst_reg.writemask = (1 << size) - 1; } void @@ -349,7 +359,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) } /* Allocate a temporary for the result. */ - this->get_temp(this->result); + this->get_temp(this->result, ir->type->vector_elements); } @@ -369,7 +379,7 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) assert(this->result); tree = this->create_tree(MB_TERM_swizzle_vec4, ir, this->result, NULL); - this->get_temp(tree); + this->get_temp(tree, 4); for (i = 0; i < 4; i++) { if (i < ir->type->vector_elements) { diff --git a/ir_to_mesa.h b/ir_to_mesa.h index 00328e5fab2..fbf10d86bb6 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -100,7 +100,7 @@ public: int next_temp; int next_constant; - void get_temp(struct mbtree *tree); + void get_temp(struct mbtree *tree, int size); void get_temp_for_var(ir_variable *var, struct mbtree *tree); -- cgit v1.2.3 From f30100c19c5f4e95e18c03292947de2dbd9e28cf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 10:31:44 -0700 Subject: ir_to_mesa: Fix copy'n'paste bug where divide multiplied left by 1/left. Multiply left by 1/right, please. --- mesa_codegen.brg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesa_codegen.brg b/mesa_codegen.brg index b117aff0f6b..0bfd8dae903 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -186,7 +186,7 @@ vec4: div_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_scalar_op1(tree, OPCODE_RCP, tree->dst_reg, - tree->left->src_reg); + tree->right->src_reg); ir_to_mesa_emit_op2(tree, OPCODE_MUL, tree->dst_reg, -- cgit v1.2.3 From 315c638b8cf0a92f9f0a8ee496e77e90e4b66d09 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 10:38:40 -0700 Subject: ir_to_mesa: Fix bugs in swizzle handling for scalar operations. Looking at a vec2 / float codegen, the writemasks on the RCPs were wrong and the swizzle on the multiply by the RCP results was wrong. --- ir_to_mesa.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index a01c50cbc2f..35c24ca174d 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -108,7 +108,7 @@ ir_to_mesa_emit_scalar_op1(struct mbtree *tree, enum prog_opcode op, ir_to_mesa_src_reg src0) { int i, j; - int done_mask = 0; + int done_mask = ~dst.writemask; /* Mesa RCP is a scalar operation splatting results to all channels, * like ARB_fp/vp. So emit as many RCPs as necessary to cover our @@ -124,7 +124,7 @@ ir_to_mesa_emit_scalar_op1(struct mbtree *tree, enum prog_opcode op, int src_swiz = GET_SWZ(src.swizzle, i); for (j = i + 1; j < 4; j++) { - if (GET_SWZ(src.swizzle, j) == src_swiz) { + if (!(done_mask & (1 << j)) && GET_SWZ(src.swizzle, j) == src_swiz) { this_mask |= (1 << j); } } @@ -179,16 +179,17 @@ ir_to_mesa_visitor::create_tree(int op, void ir_to_mesa_visitor::get_temp(struct mbtree *tree, int size) { - int swizzle = 0; + int swizzle[4]; int i; ir_to_mesa_set_tree_reg(tree, PROGRAM_TEMPORARY, this->next_temp++); for (i = 0; i < size; i++) - swizzle |= 1 << i; + swizzle[i] = i; for (; i < 4; i++) - swizzle |= 1 << (size - 1); - tree->src_reg.swizzle = swizzle; + swizzle[i] = size - 1; + tree->src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], + swizzle[2], swizzle[3]); tree->dst_reg.writemask = (1 << size) - 1; } -- cgit v1.2.3 From 50ad96ebce6ea19b414a02d2d45f0b0c73586abf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 10:53:51 -0700 Subject: ir_to_mesa: Start doing some int support. --- ir_to_mesa.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 35c24ca174d..e77a6e2ddd3 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -349,6 +349,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_unop_sqrt: this->result = this->create_tree(MB_TERM_sqrt_vec4, ir, op[0], op[1]); break; + case ir_unop_i2f: + /* Mesa IR lacks types, ints are stored as floats. */ + this->result = op[0]; + break; default: break; } @@ -543,7 +547,10 @@ ir_to_mesa_visitor::visit(ir_constant *ir) tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->base_type == GLSL_TYPE_FLOAT || + ir->type->base_type == GLSL_TYPE_UINT || + ir->type->base_type == GLSL_TYPE_INT || + ir->type->base_type == GLSL_TYPE_BOOL); /* FINISHME: This will end up being _mesa_add_unnamed_constant, * which handles sharing values and sharing channels of vec4 -- cgit v1.2.3 From 48e282d8a2dc7b3ef9f37efdae4618b25ef28628 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 11:17:47 -0700 Subject: ir_to_mesa: Support gl_FragData[] output. --- ir_to_mesa.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index e77a6e2ddd3..40b7f65afbe 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -465,17 +465,23 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), }; - - ir_variable *var = ir->array->as_variable(); - ir_constant *index = ir->array_index->constant_expression_value(); + ir_variable *var = ir->var->as_variable(); + ir_constant *index = ir->selector.array_index->constant_expression_value(); + int file = PROGRAM_UNDEFINED; + int base_index = 0; assert(var); assert(index); - assert(strcmp(var->name, "gl_TexCoord") == 0); + if (strcmp(var->name, "gl_TexCoord") == 0) { + file = PROGRAM_INPUT; + base_index = FRAG_ATTRIB_TEX0; + } else if (strcmp(var->name, "gl_FragData") == 0) { + file = PROGRAM_OUTPUT; + base_index = FRAG_RESULT_DATA0; + } tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - ir_to_mesa_set_tree_reg(tree, PROGRAM_INPUT, - FRAG_ATTRIB_TEX0 + index->value.i[0]); + ir_to_mesa_set_tree_reg(tree, file, base_index + index->value.i[0]); /* If the type is smaller than a vec4, replicate the last channel out. */ tree->src_reg.swizzle = size_swizzles[ir->type->vector_elements - 1]; -- cgit v1.2.3 From 8041bce333a48033975eb83d47ecc6bd7a91cd1d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 11:17:47 -0700 Subject: ir_to_mesa: Support gl_FragData[] output. --- ir_to_mesa.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 40b7f65afbe..f8b37dd2028 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -465,8 +465,8 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), }; - ir_variable *var = ir->var->as_variable(); - ir_constant *index = ir->selector.array_index->constant_expression_value(); + ir_variable *var = ir->variable_referenced(); + ir_constant *index = ir->array_index->constant_expression_value(); int file = PROGRAM_UNDEFINED; int base_index = 0; -- cgit v1.2.3 From 110d5cc83c18999e578ef7485e3c976446176b81 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 11:24:50 -0700 Subject: ir_to_mesa: Support gl_Position output. --- ir_to_mesa.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index f8b37dd2028..9f9113d2c31 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -442,6 +442,9 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) if (strncmp(var->name, "gl_", 3) == 0) { if (strcmp(var->name, "gl_FragColor") == 0) { ir_to_mesa_set_tree_reg(tree, PROGRAM_INPUT, FRAG_ATTRIB_COL0); + } else if (strcmp(var->name, "gl_Position") == 0) { + ir_to_mesa_set_tree_reg(tree, PROGRAM_OUTPUT, + VERT_RESULT_HPOS); } else { assert(0); } -- cgit v1.2.3 From 829e0a8eff0e657c85fa7fc53a4b456375b434cc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 13:09:54 -0700 Subject: ir_to_mesa: Add (almost) the rest of the builtin varyings. --- ir.h | 4 ++++ ir_to_mesa.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/ir.h b/ir.h index 9277f762042..dbf5df893a9 100644 --- a/ir.h +++ b/ir.h @@ -33,6 +33,10 @@ #include "ir_visitor.h" #include "ir_hierarchical_visitor.h" +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + struct ir_program { void *bong_hits; }; diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 9f9113d2c31..bc9ad252d02 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -418,6 +418,51 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) this->result = tree; } +/* This list should match up with builtin_variables.h */ +static const struct { + const char *name; + int file; + int index; +} builtin_var_to_mesa_reg[] = { + /* core_vs */ + {"gl_Position", PROGRAM_OUTPUT, VERT_RESULT_HPOS}, + {"gl_PointSize", PROGRAM_OUTPUT, VERT_RESULT_PSIZ}, + + /* core_fs */ + {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS}, + {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE}, + {"gl_FragColor", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, + {"gl_FragDepth", PROGRAM_UNDEFINED, FRAG_ATTRIB_WPOS}, /* FINISHME: WPOS.z */ + + /* 110_deprecated_fs */ + {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, + {"gl_SecondaryColor", PROGRAM_INPUT, FRAG_ATTRIB_COL1}, + {"gl_FogFragCoord", PROGRAM_INPUT, FRAG_ATTRIB_FOGC}, + + /* 110_deprecated_vs */ + {"gl_Vertex", PROGRAM_INPUT, VERT_ATTRIB_POS}, + {"gl_Normal", PROGRAM_INPUT, VERT_ATTRIB_NORMAL}, + {"gl_Color", PROGRAM_INPUT, VERT_ATTRIB_COLOR0}, + {"gl_SecondaryColor", PROGRAM_INPUT, VERT_ATTRIB_COLOR1}, + {"gl_MultiTexCoord0", PROGRAM_INPUT, VERT_ATTRIB_TEX0}, + {"gl_MultiTexCoord1", PROGRAM_INPUT, VERT_ATTRIB_TEX1}, + {"gl_MultiTexCoord2", PROGRAM_INPUT, VERT_ATTRIB_TEX2}, + {"gl_MultiTexCoord3", PROGRAM_INPUT, VERT_ATTRIB_TEX3}, + {"gl_MultiTexCoord4", PROGRAM_INPUT, VERT_ATTRIB_TEX4}, + {"gl_MultiTexCoord5", PROGRAM_INPUT, VERT_ATTRIB_TEX5}, + {"gl_MultiTexCoord6", PROGRAM_INPUT, VERT_ATTRIB_TEX6}, + {"gl_MultiTexCoord7", PROGRAM_INPUT, VERT_ATTRIB_TEX7}, + {"gl_FogCoord", PROGRAM_INPUT, VERT_RESULT_FOGC}, + /*{"gl_ClipVertex", PROGRAM_OUTPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ + {"gl_FrontColor", PROGRAM_OUTPUT, VERT_RESULT_COL0}, + {"gl_BackColor", PROGRAM_OUTPUT, VERT_RESULT_BFC0}, + {"gl_FrontSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_COL1}, + {"gl_BackSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_BFC1}, + {"gl_FogFragCoord", PROGRAM_OUTPUT, VERT_RESULT_FOGC}, + + /* 130_vs */ + /*{"gl_VertexID", PROGRAM_INPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ +}; void ir_to_mesa_visitor::visit(ir_dereference_variable *ir) @@ -432,7 +477,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) ir_variable *var = ir->var->as_variable(); - /* By the time we make it to this stage, matric`es should be broken down + /* By the time we make it to this stage, matrices should be broken down * to vectors. */ assert(!var->type->is_matrix()); @@ -440,14 +485,15 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); if (strncmp(var->name, "gl_", 3) == 0) { - if (strcmp(var->name, "gl_FragColor") == 0) { - ir_to_mesa_set_tree_reg(tree, PROGRAM_INPUT, FRAG_ATTRIB_COL0); - } else if (strcmp(var->name, "gl_Position") == 0) { - ir_to_mesa_set_tree_reg(tree, PROGRAM_OUTPUT, - VERT_RESULT_HPOS); - } else { - assert(0); + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { + if (strcmp(var->name, builtin_var_to_mesa_reg[i].name) == 0) + break; } + assert(i != ARRAY_SIZE(builtin_var_to_mesa_reg)); + ir_to_mesa_set_tree_reg(tree, builtin_var_to_mesa_reg[i].file, + builtin_var_to_mesa_reg[i].index); } else { this->get_temp_for_var(var, tree); } -- cgit v1.2.3 From 8c29a1d84d738cfddf16d5f013876ee2cca96a81 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 13:20:44 -0700 Subject: ir_to_mesa: Add exp/log expression operations. --- ir_to_mesa.cpp | 12 ++++++++++++ mesa_codegen.brg | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index bc9ad252d02..3fed1577796 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -319,6 +319,18 @@ ir_to_mesa_visitor::visit(ir_expression *ir) this->result = NULL; switch (ir->operation) { + case ir_unop_exp: + this->result = this->create_tree(MB_TERM_exp_vec4, ir, op[0], NULL); + break; + case ir_unop_exp2: + this->result = this->create_tree(MB_TERM_exp2_vec4, ir, op[0], NULL); + break; + case ir_unop_log: + this->result = this->create_tree(MB_TERM_log_vec4, ir, op[0], NULL); + break; + case ir_unop_log2: + this->result = this->create_tree(MB_TERM_log2_vec4, ir, op[0], NULL); + break; case ir_binop_add: this->result = this->create_tree(MB_TERM_add_vec4_vec4, ir, op[0], op[1]); break; diff --git a/mesa_codegen.brg b/mesa_codegen.brg index 0bfd8dae903..ed9afdc57cd 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -48,6 +48,10 @@ # generate in its trees. %term assign %term reference_vec4 +%term exp_vec4 +%term exp2_vec4 +%term log_vec4 +%term log2_vec4 %term add_vec4_vec4 %term sub_vec4_vec4 %term mul_vec4_vec4 @@ -205,4 +209,32 @@ vec4: sqrt_vec4(vec4) 1 tree->src_reg); } +vec4: exp_vec4(vec4) 1 +{ + ir_to_mesa_emit_scalar_op1(tree, OPCODE_EXP, + tree->dst_reg, + tree->left->src_reg); +} + +vec4: exp2_vec4(vec4) 1 +{ + ir_to_mesa_emit_scalar_op1(tree, OPCODE_EX2, + tree->dst_reg, + tree->left->src_reg); +} + +vec4: log_vec4(vec4) 1 +{ + ir_to_mesa_emit_scalar_op1(tree, OPCODE_LOG, + tree->dst_reg, + tree->left->src_reg); +} + +vec4: log2_vec4(vec4) 1 +{ + ir_to_mesa_emit_scalar_op1(tree, OPCODE_LG2, + tree->dst_reg, + tree->left->src_reg); +} + %% -- cgit v1.2.3 From 878740bedf418e5bf42ed6d350c938d29abaaf25 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 14:52:16 -0700 Subject: ir_to_mesa: Add codegen for rsq expression operation. --- ir_to_mesa.cpp | 3 +++ mesa_codegen.brg | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 3fed1577796..b28747e6a26 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -361,6 +361,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_unop_sqrt: this->result = this->create_tree(MB_TERM_sqrt_vec4, ir, op[0], op[1]); break; + case ir_unop_rsq: + this->result = this->create_tree(MB_TERM_rsq_vec4, ir, op[0], op[1]); + break; case ir_unop_i2f: /* Mesa IR lacks types, ints are stored as floats. */ this->result = op[0]; diff --git a/mesa_codegen.brg b/mesa_codegen.brg index ed9afdc57cd..e8d499fd74e 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -60,6 +60,7 @@ %term dp3_vec4_vec4 %term dp2_vec4_vec4 %term sqrt_vec4 +%term rsq_vec4 %term swizzle_vec4 # Each tree will produce stmt. Currently, the only production for @@ -209,6 +210,13 @@ vec4: sqrt_vec4(vec4) 1 tree->src_reg); } +vec4: rsq_vec4(vec4) 1 +{ + ir_to_mesa_emit_scalar_op1(tree, OPCODE_RSQ, + tree->dst_reg, + tree->left->src_reg); +} + vec4: exp_vec4(vec4) 1 { ir_to_mesa_emit_scalar_op1(tree, OPCODE_EXP, -- cgit v1.2.3 From 423a75c5d607a33cb5fe76a0a9c903cccc645fa7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 15:52:05 -0700 Subject: ir_to_mesa: Add ir_unop_f2i -> OPCODE_TRUNC. --- ir_to_mesa.cpp | 5 ++++- mesa_codegen.brg | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index b28747e6a26..77a8822934e 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -365,9 +365,12 @@ ir_to_mesa_visitor::visit(ir_expression *ir) this->result = this->create_tree(MB_TERM_rsq_vec4, ir, op[0], op[1]); break; case ir_unop_i2f: - /* Mesa IR lacks types, ints are stored as floats. */ + /* Mesa IR lacks types, ints are stored as truncated floats. */ this->result = op[0]; break; + case ir_unop_f2i: + this->result = this->create_tree(MB_TERM_trunc_vec4, ir, op[0], NULL); + break; default: break; } diff --git a/mesa_codegen.brg b/mesa_codegen.brg index e8d499fd74e..5e7953b75c7 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -62,6 +62,7 @@ %term sqrt_vec4 %term rsq_vec4 %term swizzle_vec4 +%term trunc_vec4 # Each tree will produce stmt. Currently, the only production for # stmt is from an assign rule -- every statement tree from @@ -245,4 +246,11 @@ vec4: log2_vec4(vec4) 1 tree->left->src_reg); } +vec4: trunc_vec4(vec4) 1 +{ + ir_to_mesa_emit_scalar_op1(tree, OPCODE_TRUNC, + tree->dst_reg, + tree->left->src_reg); +} + %% -- cgit v1.2.3 From bf9953335031b3de721245ec7a2986d0b4f70027 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 17:38:27 -0700 Subject: ir_to_mesa: Introduce shorthand for common Mesa IR emit patterns. --- ir_to_mesa.cpp | 37 ++++++++++++++++++++++--------- ir_to_mesa.h | 20 +++++++++++------ mesa_codegen.brg | 67 ++++++++++++++++---------------------------------------- 3 files changed, 59 insertions(+), 65 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 77a8822934e..1bdb61801c0 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -77,23 +77,40 @@ ir_to_mesa_emit_op3(struct mbtree *tree, enum prog_opcode op, ir_to_mesa_instruction * -ir_to_mesa_emit_op2(struct mbtree *tree, enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1) +ir_to_mesa_emit_op2_full(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1) { return ir_to_mesa_emit_op3(tree, op, dst, src0, src1, ir_to_mesa_undef); } ir_to_mesa_instruction * -ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0) +ir_to_mesa_emit_op2(struct mbtree *tree, enum prog_opcode op) +{ + return ir_to_mesa_emit_op2_full(tree, op, + tree->dst_reg, + tree->left->src_reg, + tree->right->src_reg); +} + +ir_to_mesa_instruction * +ir_to_mesa_emit_op1_full(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0) { return ir_to_mesa_emit_op3(tree, op, dst, src0, ir_to_mesa_undef, ir_to_mesa_undef); } +ir_to_mesa_instruction * +ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op) +{ + return ir_to_mesa_emit_op1_full(tree, op, + tree->dst_reg, + tree->left->src_reg); +} + /** * Emits Mesa scalar opcodes to produce unique answers across channels. * @@ -131,9 +148,9 @@ ir_to_mesa_emit_scalar_op1(struct mbtree *tree, enum prog_opcode op, src.swizzle = MAKE_SWIZZLE4(src_swiz, src_swiz, src_swiz, src_swiz); - inst = ir_to_mesa_emit_op1(tree, op, - dst, - src); + inst = ir_to_mesa_emit_op1_full(tree, op, + dst, + src); inst->dst_reg.writemask = this_mask; done_mask |= this_mask; } diff --git a/ir_to_mesa.h b/ir_to_mesa.h index fbf10d86bb6..ee776bd55fe 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -145,15 +145,21 @@ public: }; ir_to_mesa_instruction * -ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0); +ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op); ir_to_mesa_instruction * -ir_to_mesa_emit_op2(struct mbtree *tree, enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1); +ir_to_mesa_emit_op1_full(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); + +ir_to_mesa_instruction * +ir_to_mesa_emit_op2(struct mbtree *tree, enum prog_opcode op); + +ir_to_mesa_instruction * +ir_to_mesa_emit_op2_full(struct mbtree *tree, enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1); ir_to_mesa_instruction * ir_to_mesa_emit_op3(struct mbtree *tree, enum prog_opcode op, diff --git a/mesa_codegen.brg b/mesa_codegen.brg index 5e7953b75c7..e52798bcf51 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -110,9 +110,9 @@ vec4: reference_vec4 0 # which would clean these up. stmt: assign(vec4, vec4) 1 { - ir_to_mesa_emit_op1(tree, OPCODE_MOV, - tree->left->dst_reg, - tree->right->src_reg); + ir_to_mesa_emit_op1_full(tree, OPCODE_MOV, + tree->left->dst_reg, + tree->right->src_reg); } # Perform a swizzle by composing our swizzle with the swizzle @@ -131,60 +131,31 @@ vec4: swizzle_vec4(vec4) 1 } reg.swizzle = MAKE_SWIZZLE4(swiz[0], swiz[1], swiz[2], swiz[3]); - ir_to_mesa_emit_op1(tree, OPCODE_MOV, - tree->dst_reg, - reg); + ir_to_mesa_emit_op1_full(tree, OPCODE_MOV, + tree->dst_reg, + reg); } -vec4: add_vec4_vec4(vec4, vec4) 1 -{ - ir_to_mesa_emit_op2(tree, OPCODE_ADD, - tree->dst_reg, - tree->left->src_reg, - tree->right->src_reg); -} - -vec4: sub_vec4_vec4(vec4, vec4) 1 -{ - ir_to_mesa_emit_op2(tree, OPCODE_SUB, - tree->dst_reg, - tree->left->src_reg, - tree->right->src_reg); -} - -vec4: mul_vec4_vec4(vec4, vec4) 1 -{ - ir_to_mesa_emit_op2(tree, OPCODE_MUL, - tree->dst_reg, - tree->left->src_reg, - tree->right->src_reg); -} +vec4: add_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_ADD); } +vec4: sub_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SUB); } +vec4: mul_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_MUL); } vec4: dp4_vec4_vec4(vec4, vec4) 1 { - ir_to_mesa_emit_op2(tree, OPCODE_DP4, - tree->dst_reg, - tree->left->src_reg, - tree->right->src_reg); + ir_to_mesa_emit_op2(tree, OPCODE_DP4); tree->src_reg.swizzle = SWIZZLE_XXXX; } vec4: dp3_vec4_vec4(vec4, vec4) 1 { - ir_to_mesa_emit_op2(tree, OPCODE_DP3, - tree->dst_reg, - tree->left->src_reg, - tree->right->src_reg); + ir_to_mesa_emit_op2(tree, OPCODE_DP3); tree->src_reg.swizzle = SWIZZLE_XXXX; } vec4: dp2_vec4_vec4(vec4, vec4) 1 { - ir_to_mesa_emit_op2(tree, OPCODE_DP2, - tree->dst_reg, - tree->left->src_reg, - tree->right->src_reg); + ir_to_mesa_emit_op2(tree, OPCODE_DP2); tree->src_reg.swizzle = SWIZZLE_XXXX; } @@ -194,10 +165,10 @@ vec4: div_vec4_vec4(vec4, vec4) 1 tree->dst_reg, tree->right->src_reg); - ir_to_mesa_emit_op2(tree, OPCODE_MUL, - tree->dst_reg, - tree->src_reg, - tree->left->src_reg); + ir_to_mesa_emit_op2_full(tree, OPCODE_MUL, + tree->dst_reg, + tree->src_reg, + tree->left->src_reg); } vec4: sqrt_vec4(vec4) 1 @@ -206,9 +177,9 @@ vec4: sqrt_vec4(vec4) 1 tree->dst_reg, tree->left->src_reg); - ir_to_mesa_emit_op1(tree, OPCODE_RCP, - tree->dst_reg, - tree->src_reg); + ir_to_mesa_emit_op1_full(tree, OPCODE_RCP, + tree->dst_reg, + tree->src_reg); } vec4: rsq_vec4(vec4) 1 -- cgit v1.2.3 From 38315079571512dc5b502d9522d7a8c3eaf2cc8f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 6 May 2010 17:41:22 -0700 Subject: ir_to_mesa: Add support for comparison operations. --- ir_to_mesa.cpp | 20 ++++++++++++++++++++ ir_to_mesa.h | 3 +++ mesa_codegen.brg | 13 +++++++++++++ 3 files changed, 36 insertions(+) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 1bdb61801c0..465a8e19164 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -360,6 +360,26 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_binop_div: this->result = this->create_tree(MB_TERM_div_vec4_vec4, ir, op[0], op[1]); break; + + case ir_binop_less: + this->result = this->create_tree(MB_TERM_slt_vec4_vec4, ir, op[0], op[1]); + break; + case ir_binop_greater: + this->result = this->create_tree(MB_TERM_sgt_vec4_vec4, ir, op[0], op[1]); + break; + case ir_binop_lequal: + this->result = this->create_tree(MB_TERM_sle_vec4_vec4, ir, op[0], op[1]); + break; + case ir_binop_gequal: + this->result = this->create_tree(MB_TERM_sge_vec4_vec4, ir, op[0], op[1]); + break; + case ir_binop_equal: + this->result = this->create_tree(MB_TERM_seq_vec4_vec4, ir, op[0], op[1]); + break; + case ir_binop_nequal: + this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir, op[0], op[1]); + break; + case ir_binop_dot: if (ir->operands[0]->type == vec4_type) { assert(ir->operands[1]->type == vec4_type); diff --git a/ir_to_mesa.h b/ir_to_mesa.h index ee776bd55fe..ffa27dbd00f 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -161,6 +161,9 @@ ir_to_mesa_emit_op2_full(struct mbtree *tree, enum prog_opcode op, ir_to_mesa_src_reg src0, ir_to_mesa_src_reg src1); +ir_to_mesa_instruction * +ir_to_mesa_emit_simple_op2(struct mbtree *tree, enum prog_opcode op); + ir_to_mesa_instruction * ir_to_mesa_emit_op3(struct mbtree *tree, enum prog_opcode op, ir_to_mesa_dst_reg dst, diff --git a/mesa_codegen.brg b/mesa_codegen.brg index e52798bcf51..4e761343ae3 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -56,6 +56,12 @@ %term sub_vec4_vec4 %term mul_vec4_vec4 %term div_vec4_vec4 +%term slt_vec4_vec4 +%term sgt_vec4_vec4 +%term sle_vec4_vec4 +%term sge_vec4_vec4 +%term seq_vec4_vec4 +%term sne_vec4_vec4 %term dp4_vec4_vec4 %term dp3_vec4_vec4 %term dp2_vec4_vec4 @@ -171,6 +177,13 @@ vec4: div_vec4_vec4(vec4, vec4) 1 tree->left->src_reg); } +vec4: slt_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SLT); } +vec4: sgt_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SGT); } +vec4: sle_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SLE); } +vec4: sge_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SGE); } +vec4: sne_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SNE); } +vec4: seq_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SEQ); } + vec4: sqrt_vec4(vec4) 1 { ir_to_mesa_emit_scalar_op1(tree, OPCODE_RSQ, -- cgit v1.2.3 From c5ca73e72c27b2e5d7fcf4662b9921ddb3a9627b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 7 May 2010 11:31:47 -0700 Subject: ir_to_mesa: Add support for ir_if. --- ir_to_mesa.cpp | 138 +++++++++++++++++++++++++++++++++++++++++++++---------- ir_to_mesa.h | 9 ++-- mesa_codegen.brg | 8 ++-- 3 files changed, 125 insertions(+), 30 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 465a8e19164..487e24986f9 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -54,8 +54,13 @@ ir_to_mesa_src_reg ir_to_mesa_undef = { PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP }; +ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP +}; + ir_to_mesa_instruction * -ir_to_mesa_emit_op3(struct mbtree *tree, enum prog_opcode op, +ir_to_mesa_emit_op3(ir_to_mesa_visitor *v, ir_instruction *ir, + enum prog_opcode op, ir_to_mesa_dst_reg dst, ir_to_mesa_src_reg src0, ir_to_mesa_src_reg src1, @@ -68,45 +73,48 @@ ir_to_mesa_emit_op3(struct mbtree *tree, enum prog_opcode op, inst->src_reg[0] = src0; inst->src_reg[1] = src1; inst->src_reg[2] = src2; - inst->ir = tree->ir; + inst->ir = ir; - tree->v->instructions.push_tail(inst); + v->instructions.push_tail(inst); return inst; } ir_to_mesa_instruction * -ir_to_mesa_emit_op2_full(struct mbtree *tree, enum prog_opcode op, +ir_to_mesa_emit_op2_full(ir_to_mesa_visitor *v, ir_instruction *ir, + enum prog_opcode op, ir_to_mesa_dst_reg dst, ir_to_mesa_src_reg src0, ir_to_mesa_src_reg src1) { - return ir_to_mesa_emit_op3(tree, op, dst, src0, src1, ir_to_mesa_undef); + return ir_to_mesa_emit_op3(v, ir, + op, dst, src0, src1, ir_to_mesa_undef); } ir_to_mesa_instruction * ir_to_mesa_emit_op2(struct mbtree *tree, enum prog_opcode op) { - return ir_to_mesa_emit_op2_full(tree, op, + return ir_to_mesa_emit_op2_full(tree->v, tree->ir, op, tree->dst_reg, tree->left->src_reg, tree->right->src_reg); } ir_to_mesa_instruction * -ir_to_mesa_emit_op1_full(struct mbtree *tree, enum prog_opcode op, +ir_to_mesa_emit_op1_full(ir_to_mesa_visitor *v, ir_instruction *ir, + enum prog_opcode op, ir_to_mesa_dst_reg dst, ir_to_mesa_src_reg src0) { - return ir_to_mesa_emit_op3(tree, op, + return ir_to_mesa_emit_op3(v, ir, op, dst, src0, ir_to_mesa_undef, ir_to_mesa_undef); } ir_to_mesa_instruction * ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op) { - return ir_to_mesa_emit_op1_full(tree, op, + return ir_to_mesa_emit_op1_full(tree->v, tree->ir, op, tree->dst_reg, tree->left->src_reg); } @@ -148,7 +156,7 @@ ir_to_mesa_emit_scalar_op1(struct mbtree *tree, enum prog_opcode op, src.swizzle = MAKE_SWIZZLE4(src_swiz, src_swiz, src_swiz, src_swiz); - inst = ir_to_mesa_emit_op1_full(tree, op, + inst = ir_to_mesa_emit_op1_full(tree->v, tree->ir, op, dst, src); inst->dst_reg.writemask = this_mask; @@ -703,9 +711,29 @@ ir_to_mesa_visitor::visit(ir_return *ir) void ir_to_mesa_visitor::visit(ir_if *ir) { - (void)ir; - printf("Can't support conditionals, should be flattened before here.\n"); - exit(1); + ir_to_mesa_instruction *if_inst, *else_inst = NULL; + + ir->condition->accept(this); + assert(this->result); + + if_inst = ir_to_mesa_emit_op1_full(this, ir->condition, + OPCODE_IF, ir_to_mesa_undef_dst, + this->result->src_reg); + + this->instructions.push_tail(if_inst); + + visit_exec_list(&ir->then_instructions, this); + + if (!ir->else_instructions.is_empty()) { + else_inst = ir_to_mesa_emit_op1_full(this, ir->condition, + OPCODE_ELSE, ir_to_mesa_undef_dst, + ir_to_mesa_undef); + visit_exec_list(&ir->then_instructions, this); + } + + if_inst = ir_to_mesa_emit_op1_full(this, ir->condition, + OPCODE_ENDIF, ir_to_mesa_undef_dst, + ir_to_mesa_undef); } ir_to_mesa_visitor::ir_to_mesa_visitor() @@ -728,12 +756,74 @@ mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) return mesa_reg; } +static void +set_branchtargets(struct prog_instruction *mesa_instructions, + int num_instructions) +{ + int if_count = 0; + struct prog_instruction **if_stack; + int if_stack_pos = 0; + int i; + + for (i = 0; i < num_instructions; i++) { + if (mesa_instructions[i].Opcode == OPCODE_IF) + if_count++; + } + + if_stack = (struct prog_instruction **)calloc(if_count, sizeof(*if_stack)); + + for (i = 0; i < num_instructions; i++) { + switch (mesa_instructions[i].Opcode) { + case OPCODE_IF: + if_stack[if_stack_pos] = mesa_instructions + i; + if_stack_pos++; + break; + case OPCODE_ELSE: + if_stack[if_stack_pos - 1]->BranchTarget = i; + if_stack[if_stack_pos - 1] = mesa_instructions + i; + break; + case OPCODE_ENDIF: + if_stack[if_stack_pos - 1]->BranchTarget = i; + if_stack_pos--; + break; + default: + break; + } + } + + free(if_stack); +} + +static void +print_program(struct prog_instruction *mesa_instructions, + ir_instruction **mesa_instruction_annotation, + int num_instructions) +{ + ir_instruction *last_ir = NULL; + int i; + + for (i = 0; i < num_instructions; i++) { + struct prog_instruction *mesa_inst = mesa_instructions + i; + ir_instruction *ir = mesa_instruction_annotation[i]; + + if (last_ir != ir) { + ir_print_visitor print; + ir->accept(&print); + printf("\n"); + last_ir = ir; + } + + _mesa_print_instruction(mesa_inst); + } +} + void do_ir_to_mesa(exec_list *instructions) { ir_to_mesa_visitor v; struct prog_instruction *mesa_instructions, *mesa_inst; - ir_instruction *last_ir = NULL; + ir_instruction **mesa_instruction_annotation; + int i; visit_exec_list(instructions, &v); @@ -745,18 +835,15 @@ do_ir_to_mesa(exec_list *instructions) mesa_instructions = (struct prog_instruction *)calloc(num_instructions, sizeof(*mesa_instructions)); + mesa_instruction_annotation = + (ir_instruction **)calloc(num_instructions, + sizeof(*mesa_instruction_annotation)); mesa_inst = mesa_instructions; + i = 0; foreach_iter(exec_list_iterator, iter, v.instructions) { ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); - if (last_ir != inst->ir) { - ir_print_visitor print; - inst->ir->accept(&print); - printf("\n"); - last_ir = inst->ir; - } - mesa_inst->Opcode = inst->op; mesa_inst->DstReg.File = inst->dst_reg.file; mesa_inst->DstReg.Index = inst->dst_reg.index; @@ -765,9 +852,14 @@ do_ir_to_mesa(exec_list *instructions) mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); - - _mesa_print_instruction(mesa_inst); + mesa_instruction_annotation[i] = inst->ir; mesa_inst++; + i++; } + + set_branchtargets(mesa_instructions, num_instructions); + print_program(mesa_instructions, mesa_instruction_annotation, num_instructions); + + free(mesa_instruction_annotation); } diff --git a/ir_to_mesa.h b/ir_to_mesa.h index ffa27dbd00f..3aa88bcdc40 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -148,7 +148,8 @@ ir_to_mesa_instruction * ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op); ir_to_mesa_instruction * -ir_to_mesa_emit_op1_full(struct mbtree *tree, enum prog_opcode op, +ir_to_mesa_emit_op1_full(ir_to_mesa_visitor *v, ir_instruction *ir, + enum prog_opcode op, ir_to_mesa_dst_reg dst, ir_to_mesa_src_reg src0); @@ -156,7 +157,8 @@ ir_to_mesa_instruction * ir_to_mesa_emit_op2(struct mbtree *tree, enum prog_opcode op); ir_to_mesa_instruction * -ir_to_mesa_emit_op2_full(struct mbtree *tree, enum prog_opcode op, +ir_to_mesa_emit_op2_full(ir_to_mesa_visitor *v, ir_instruction *ir, + enum prog_opcode op, ir_to_mesa_dst_reg dst, ir_to_mesa_src_reg src0, ir_to_mesa_src_reg src1); @@ -165,7 +167,8 @@ ir_to_mesa_instruction * ir_to_mesa_emit_simple_op2(struct mbtree *tree, enum prog_opcode op); ir_to_mesa_instruction * -ir_to_mesa_emit_op3(struct mbtree *tree, enum prog_opcode op, +ir_to_mesa_emit_op3(ir_to_mesa_visitor *v, ir_instruction *ir, + enum prog_opcode op, ir_to_mesa_dst_reg dst, ir_to_mesa_src_reg src0, ir_to_mesa_src_reg src1, diff --git a/mesa_codegen.brg b/mesa_codegen.brg index 4e761343ae3..a906542dd53 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -116,7 +116,7 @@ vec4: reference_vec4 0 # which would clean these up. stmt: assign(vec4, vec4) 1 { - ir_to_mesa_emit_op1_full(tree, OPCODE_MOV, + ir_to_mesa_emit_op1_full(tree->v, tree->ir, OPCODE_MOV, tree->left->dst_reg, tree->right->src_reg); } @@ -137,7 +137,7 @@ vec4: swizzle_vec4(vec4) 1 } reg.swizzle = MAKE_SWIZZLE4(swiz[0], swiz[1], swiz[2], swiz[3]); - ir_to_mesa_emit_op1_full(tree, OPCODE_MOV, + ir_to_mesa_emit_op1_full(tree->v, tree->ir, OPCODE_MOV, tree->dst_reg, reg); } @@ -171,7 +171,7 @@ vec4: div_vec4_vec4(vec4, vec4) 1 tree->dst_reg, tree->right->src_reg); - ir_to_mesa_emit_op2_full(tree, OPCODE_MUL, + ir_to_mesa_emit_op2_full(tree->v, tree->ir, OPCODE_MUL, tree->dst_reg, tree->src_reg, tree->left->src_reg); @@ -190,7 +190,7 @@ vec4: sqrt_vec4(vec4) 1 tree->dst_reg, tree->left->src_reg); - ir_to_mesa_emit_op1_full(tree, OPCODE_RCP, + ir_to_mesa_emit_op1_full(tree->v, tree->ir, OPCODE_RCP, tree->dst_reg, tree->src_reg); } -- cgit v1.2.3 From 1d20862c8a0e100e43458f01217c047c76da05f3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 7 May 2010 12:12:49 -0700 Subject: ir_to_mesa: add logic_not and f2b to get CorrectParse2.frag working. --- ir_to_mesa.cpp | 31 +++++++++++++++++++++++++++++++ ir_to_mesa.h | 1 + 2 files changed, 32 insertions(+) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 487e24986f9..8858d4be68e 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -195,6 +195,27 @@ ir_to_mesa_visitor::create_tree(int op, return tree; } +struct mbtree * +ir_to_mesa_visitor::create_tree_for_float(ir_instruction *ir, float val) +{ + struct mbtree *tree = (struct mbtree *)calloc(sizeof(struct mbtree), 1); + + tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); + + /* FINISHME: This will end up being _mesa_add_unnamed_constant, + * which handles sharing values and sharing channels of vec4 + * constants for small values. + */ + /* FINISHME: Do something with the constant values for now. + */ + (void)val; + ir_to_mesa_set_tree_reg(tree, PROGRAM_CONSTANT, this->next_constant++); + tree->src_reg.swizzle = SWIZZLE_NOOP; + + this->result = tree; + return tree; +} + /** * In the initial pass of codegen, we assign temporary numbers to * intermediate results. (not SSA -- variable assignments will reuse @@ -344,6 +365,11 @@ ir_to_mesa_visitor::visit(ir_expression *ir) this->result = NULL; switch (ir->operation) { + case ir_unop_logic_not: + this->result = this->create_tree_for_float(ir, 0.0); + this->result = this->create_tree(MB_TERM_seq_vec4_vec4, ir, + op[0], this->result); + break; case ir_unop_exp: this->result = this->create_tree(MB_TERM_exp_vec4, ir, op[0], NULL); break; @@ -416,6 +442,11 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_unop_f2i: this->result = this->create_tree(MB_TERM_trunc_vec4, ir, op[0], NULL); break; + case ir_unop_f2b: + this->result = this->create_tree_for_float(ir, 0.0); + this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir, + op[0], this->result); + break; default: break; } diff --git a/ir_to_mesa.h b/ir_to_mesa.h index 3aa88bcdc40..43ddd5fe517 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -108,6 +108,7 @@ public: ir_instruction *ir, struct mbtree *left, struct mbtree *right); + struct mbtree *create_tree_for_float(ir_instruction *ir, float val); /** * \name Visit methods -- cgit v1.2.3 From 763cd75863ed9a16912e585887580c44d1e8109f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 7 May 2010 12:14:41 -0700 Subject: ir_to_mesa: add logic_xor to get CorrectParse2.vert working. --- ir_to_mesa.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 8858d4be68e..3ae848a21bc 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -410,6 +410,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_binop_equal: this->result = this->create_tree(MB_TERM_seq_vec4_vec4, ir, op[0], op[1]); break; + case ir_binop_logic_xor: case ir_binop_nequal: this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir, op[0], op[1]); break; -- cgit v1.2.3 From 4380099c98119611ceee684669d00be26195c7d7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 7 May 2010 12:20:58 -0700 Subject: ir_to_mesa: Add logic_or and logic_and to get CorrectFunction1.vert working. --- ir_to_mesa.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 3ae848a21bc..f45421057b2 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -415,6 +415,19 @@ ir_to_mesa_visitor::visit(ir_expression *ir) this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir, op[0], op[1]); break; + case ir_binop_logic_or: + /* This could be a saturated add. */ + this->result = this->create_tree(MB_TERM_add_vec4_vec4, ir, op[0], op[1]); + this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir, + this->create_tree_for_float(ir, 0.0), + this->result); + break; + + case ir_binop_logic_and: + /* the bool args are stored as float 0.0 or 1.0, so "mul" gives us "and". */ + this->result = this->create_tree(MB_TERM_mul_vec4_vec4, ir, op[0], op[1]); + break; + case ir_binop_dot: if (ir->operands[0]->type == vec4_type) { assert(ir->operands[1]->type == vec4_type); -- cgit v1.2.3 From 0c005bd773784ee5feb2ee3d7d00c2c4335eafb4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 7 May 2010 12:35:47 -0700 Subject: Make loop jump mode public so I can switch on it. --- ir.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ir.h b/ir.h index dbf5df893a9..ab041aa848a 100644 --- a/ir.h +++ b/ir.h @@ -756,9 +756,9 @@ public: }; ir_loop_jump(jump_mode mode) - : mode(mode) { - /* empty */ + this->mode = mode; + this->loop = loop; } virtual ir_instruction *clone(struct hash_table *) const; @@ -780,9 +780,11 @@ public: return mode == jump_continue; } -private: /** Mode selector for the jump instruction. */ enum jump_mode mode; +private: + /** Loop containing this break instruction. */ + ir_loop *loop; }; /*@}*/ -- cgit v1.2.3 From 64fcbbca9ca8191b5131304af2026d0ed914b765 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 7 May 2010 12:59:08 -0700 Subject: ir_to_mesa: Add support for loops. Fixes CorrectParse1 and the glsl2 loop tests that don't use arrays. --- ir_to_mesa.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 17 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index f45421057b2..2be5bf1ef05 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -297,18 +297,37 @@ ir_to_mesa_visitor::visit(ir_variable *ir) void ir_to_mesa_visitor::visit(ir_loop *ir) { - (void)ir; + assert(!ir->from); + assert(!ir->to); + assert(!ir->increment); + assert(!ir->counter); - printf("Can't support loops, should be flattened before here\n"); - exit(1); + ir_to_mesa_emit_op1_full(this, NULL, + OPCODE_BGNLOOP, ir_to_mesa_undef_dst, + ir_to_mesa_undef); + + visit_exec_list(&ir->body_instructions, this); + + ir_to_mesa_emit_op1_full(this, NULL, + OPCODE_ENDLOOP, ir_to_mesa_undef_dst, + ir_to_mesa_undef); } void ir_to_mesa_visitor::visit(ir_loop_jump *ir) { - (void) ir; - printf("Can't support loops, should be flattened before here\n"); - exit(1); + switch (ir->mode) { + case ir_loop_jump::jump_break: + ir_to_mesa_emit_op1_full(this, NULL, + OPCODE_BRK, ir_to_mesa_undef_dst, + ir_to_mesa_undef); + break; + case ir_loop_jump::jump_continue: + ir_to_mesa_emit_op1_full(this, NULL, + OPCODE_CONT, ir_to_mesa_undef_dst, + ir_to_mesa_undef); + break; + } } @@ -805,32 +824,66 @@ static void set_branchtargets(struct prog_instruction *mesa_instructions, int num_instructions) { - int if_count = 0; - struct prog_instruction **if_stack; - int if_stack_pos = 0; - int i; + int if_count = 0, loop_count; + int *if_stack, *loop_stack; + int if_stack_pos = 0, loop_stack_pos = 0; + int i, j; for (i = 0; i < num_instructions; i++) { - if (mesa_instructions[i].Opcode == OPCODE_IF) + switch (mesa_instructions[i].Opcode) { + case OPCODE_IF: if_count++; + break; + case OPCODE_BGNLOOP: + loop_count++; + break; + case OPCODE_BRK: + case OPCODE_CONT: + mesa_instructions[i].BranchTarget = -1; + break; + default: + break; + } } - if_stack = (struct prog_instruction **)calloc(if_count, sizeof(*if_stack)); + if_stack = (int *)calloc(if_count, sizeof(*if_stack)); + loop_stack = (int *)calloc(loop_count, sizeof(*loop_stack)); for (i = 0; i < num_instructions; i++) { switch (mesa_instructions[i].Opcode) { case OPCODE_IF: - if_stack[if_stack_pos] = mesa_instructions + i; + if_stack[if_stack_pos] = i; if_stack_pos++; break; case OPCODE_ELSE: - if_stack[if_stack_pos - 1]->BranchTarget = i; - if_stack[if_stack_pos - 1] = mesa_instructions + i; + mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; + if_stack[if_stack_pos - 1] = i; break; case OPCODE_ENDIF: - if_stack[if_stack_pos - 1]->BranchTarget = i; + mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; if_stack_pos--; break; + case OPCODE_BGNLOOP: + loop_stack[loop_stack_pos] = i; + loop_stack_pos++; + break; + case OPCODE_ENDLOOP: + loop_stack_pos--; + /* Rewrite any breaks/conts at this nesting level (haven't + * already had a BranchTarget assigned) to point to the end + * of the loop. + */ + for (j = loop_stack[loop_stack_pos]; j < i; j++) { + if (mesa_instructions[j].Opcode == OPCODE_BRK || + mesa_instructions[j].Opcode == OPCODE_CONT) { + if (mesa_instructions[j].BranchTarget == -1) { + mesa_instructions[j].BranchTarget = i; + } + } + } + /* The loop ends point at each other. */ + mesa_instructions[i].BranchTarget = loop_stack[loop_stack_pos]; + mesa_instructions[loop_stack[loop_stack_pos]].BranchTarget = i; default: break; } @@ -851,7 +904,7 @@ print_program(struct prog_instruction *mesa_instructions, struct prog_instruction *mesa_inst = mesa_instructions + i; ir_instruction *ir = mesa_instruction_annotation[i]; - if (last_ir != ir) { + if (last_ir != ir && ir) { ir_print_visitor print; ir->accept(&print); printf("\n"); -- cgit v1.2.3 From 4e5e0f018baedb2d0aa0e1f43efe339da16a09c6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 10 May 2010 18:15:33 -0700 Subject: ir_to_mesa: Clean up some handling of builtins and arrays. Constant-index dereferences of arrays should work now. One test is regressed, but it should have been failing before this commit, too. --- ir_to_mesa.cpp | 57 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 2be5bf1ef05..3451fc887db 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -253,9 +253,17 @@ ir_to_mesa_visitor::get_temp_for_var(ir_variable *var, struct mbtree *tree) } } - entry = new temp_entry(var, PROGRAM_TEMPORARY, this->next_temp++); + entry = new temp_entry(var, PROGRAM_TEMPORARY, this->next_temp); this->variable_storage.push_tail(entry); + /* Store each array element in a temp. This is poor packing for + * things like floats, but we can't do better in the Mesa IR. + */ + if (var->type->length > 1) + next_temp += var->type->length; + else + next_temp++; + ir_to_mesa_set_tree_reg(tree, entry->file, entry->index); } @@ -579,6 +587,7 @@ static const struct { {"gl_MultiTexCoord5", PROGRAM_INPUT, VERT_ATTRIB_TEX5}, {"gl_MultiTexCoord6", PROGRAM_INPUT, VERT_ATTRIB_TEX6}, {"gl_MultiTexCoord7", PROGRAM_INPUT, VERT_ATTRIB_TEX7}, + {"gl_TexCoord", PROGRAM_OUTPUT, VERT_RESULT_TEX0}, /* array */ {"gl_FogCoord", PROGRAM_INPUT, VERT_RESULT_FOGC}, /*{"gl_ClipVertex", PROGRAM_OUTPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ {"gl_FrontColor", PROGRAM_OUTPUT, VERT_RESULT_COL0}, @@ -589,6 +598,8 @@ static const struct { /* 130_vs */ /*{"gl_VertexID", PROGRAM_INPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ + + {"gl_FragData", PROGRAM_OUTPUT, FRAG_RESULT_DATA0}, /* array */ }; void @@ -601,8 +612,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), }; - - ir_variable *var = ir->var->as_variable(); + ir_variable *var = ir->var; /* By the time we make it to this stage, matrices should be broken down * to vectors. @@ -643,21 +653,36 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) }; ir_variable *var = ir->variable_referenced(); ir_constant *index = ir->array_index->constant_expression_value(); - int file = PROGRAM_UNDEFINED; - int base_index = 0; - - assert(var); - assert(index); - if (strcmp(var->name, "gl_TexCoord") == 0) { - file = PROGRAM_INPUT; - base_index = FRAG_ATTRIB_TEX0; - } else if (strcmp(var->name, "gl_FragData") == 0) { - file = PROGRAM_OUTPUT; - base_index = FRAG_RESULT_DATA0; - } + + /* By the time we make it to this stage, matrices should be broken down + * to vectors. + */ + assert(!var->type->is_matrix()); tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - ir_to_mesa_set_tree_reg(tree, file, base_index + index->value.i[0]); + + if (strncmp(var->name, "gl_", 3) == 0) { + unsigned int i; + unsigned int offset = 0; + + assert(index); /* FINISHME: Handle variable indexing of builtins. */ + + offset = index->value.i[0]; + + for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { + if (strcmp(var->name, builtin_var_to_mesa_reg[i].name) == 0) + break; + } + assert(i != ARRAY_SIZE(builtin_var_to_mesa_reg)); + ir_to_mesa_set_tree_reg(tree, builtin_var_to_mesa_reg[i].file, + builtin_var_to_mesa_reg[i].index + offset); + } else { + this->get_temp_for_var(var, tree); + assert(index); /* FINISHME: Handle variable indexing. */ + + tree->src_reg.index += index->value.i[0]; + tree->dst_reg.index += index->value.i[0]; + } /* If the type is smaller than a vec4, replicate the last channel out. */ tree->src_reg.swizzle = size_swizzles[ir->type->vector_elements - 1]; -- cgit v1.2.3 From bdbd9f112e2832eeddce8fc4f70f11005bbe4027 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 10 May 2010 10:06:36 -0700 Subject: ir_to_mesa: Add support for variable indexing of temporary arrays. Fixes loop-01.vert, loop-02.vert. --- ir_to_mesa.cpp | 26 +++++++++++++++++++------- ir_to_mesa.h | 4 ++++ mesa_codegen.brg | 15 +++++++++++++++ 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 3451fc887db..44786258db1 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -51,7 +51,7 @@ extern "C" { } ir_to_mesa_src_reg ir_to_mesa_undef = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, false, }; ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { @@ -659,13 +659,11 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) */ assert(!var->type->is_matrix()); - tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - if (strncmp(var->name, "gl_", 3) == 0) { unsigned int i; unsigned int offset = 0; - assert(index); /* FINISHME: Handle variable indexing of builtins. */ + tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); offset = index->value.i[0]; @@ -677,11 +675,24 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) ir_to_mesa_set_tree_reg(tree, builtin_var_to_mesa_reg[i].file, builtin_var_to_mesa_reg[i].index + offset); } else { + tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); this->get_temp_for_var(var, tree); - assert(index); /* FINISHME: Handle variable indexing. */ - tree->src_reg.index += index->value.i[0]; - tree->dst_reg.index += index->value.i[0]; + if (index) { + tree->src_reg.index += index->value.i[0]; + tree->dst_reg.index += index->value.i[0]; + } else { + /* Variable index array dereference. It eats the "vec4" of the + * base of the array and an index that offsets the Mesa register + * index. + */ + ir->array_index->accept(this); + + tree->src_reg.reladdr = true; + tree = this->create_tree(MB_TERM_array_reference_vec4_vec4, + ir, tree, this->result); + this->get_temp(tree, ir->type->vector_elements); + } } /* If the type is smaller than a vec4, replicate the last channel out. */ @@ -841,6 +852,7 @@ mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) assert(reg.index < (1 << INST_INDEX_BITS) - 1); mesa_reg.Index = reg.index; mesa_reg.Swizzle = reg.swizzle; + mesa_reg.RelAddr = reg.reladdr; return mesa_reg; } diff --git a/ir_to_mesa.h b/ir_to_mesa.h index 43ddd5fe517..515feb19a38 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -40,6 +40,7 @@ typedef struct ir_to_mesa_src_reg { int file; /**< PROGRAM_* from Mesa */ int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ + bool reladdr; /**< Register index should be offset by address reg. */ } ir_to_mesa_src_reg; typedef struct ir_to_mesa_dst_reg { @@ -145,6 +146,9 @@ public: exec_list instructions; }; +extern ir_to_mesa_src_reg ir_to_mesa_undef; +extern ir_to_mesa_dst_reg ir_to_mesa_undef_dst; + ir_to_mesa_instruction * ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op); diff --git a/mesa_codegen.brg b/mesa_codegen.brg index a906542dd53..109e8b2d513 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -48,6 +48,7 @@ # generate in its trees. %term assign %term reference_vec4 +%term array_reference_vec4_vec4 %term exp_vec4 %term exp2_vec4 %term log_vec4 @@ -93,6 +94,20 @@ # so it can be used as an argument for pretty much anything. vec4: reference_vec4 0 +# A reference of a variable is just a vec4 register location, +# so it can be used as an argument for pretty much anything. +vec4: array_reference_vec4_vec4 1 +{ + ir_to_mesa_dst_reg address_reg = {PROGRAM_ADDRESS, 0, WRITEMASK_X}; + + ir_to_mesa_emit_op1_full(tree->v, tree->ir, OPCODE_ARL, + address_reg, + tree->right->src_reg); + ir_to_mesa_emit_op1_full(tree->v, tree->ir, OPCODE_MOV, + tree->dst_reg, + tree->left->src_reg); +} + # Here's the rule everyone will hit: Moving the result of an # expression into a variable-dereference register location. # -- cgit v1.2.3 From 2ee85e20c888d45d3a05ed020dbaf616337f8955 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 11 May 2010 00:00:35 -0700 Subject: ir_to_mesa: Remove stale comment about monoburg. --- ir_to_mesa.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 44786258db1..1485b6a2c0f 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -26,10 +26,6 @@ * * Translates the IR to ARB_fragment_program text if possible, * printing the result - * - * The code generation is performed using monoburg. Because monoburg - * produces a single C file with the definitions of the node types in - * it, this file is included from the monoburg output. */ /* Quiet compiler warnings due to monoburg not marking functions defined -- cgit v1.2.3 From 4a1bd916e79659abfa9dfdcf013eaff2daa66c29 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 11 May 2010 16:20:21 -0700 Subject: ir_to_mesa: Fix up array indexing. The grammar for array_reference_vec4_vec4 was set up wrong, so we weren't generating instructions if necessary for the array index. --- mesa_codegen.brg | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mesa_codegen.brg b/mesa_codegen.brg index 109e8b2d513..a0ab7c86305 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -96,7 +96,7 @@ vec4: reference_vec4 0 # A reference of a variable is just a vec4 register location, # so it can be used as an argument for pretty much anything. -vec4: array_reference_vec4_vec4 1 +vec4: array_reference_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_dst_reg address_reg = {PROGRAM_ADDRESS, 0, WRITEMASK_X}; @@ -245,11 +245,6 @@ vec4: log2_vec4(vec4) 1 tree->left->src_reg); } -vec4: trunc_vec4(vec4) 1 -{ - ir_to_mesa_emit_scalar_op1(tree, OPCODE_TRUNC, - tree->dst_reg, - tree->left->src_reg); -} +vec4: trunc_vec4(vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_TRUNC); } %% -- cgit v1.2.3 From 2c432637d0960aa522ccd09416ba1d8a65c6988b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 12 May 2010 10:16:11 -0700 Subject: ir_to_mesa: Start trying to support struct storage. --- ir_to_mesa.cpp | 90 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 15 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 1485b6a2c0f..67c79b66ee5 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -235,6 +235,37 @@ ir_to_mesa_visitor::get_temp(struct mbtree *tree, int size) tree->dst_reg.writemask = (1 << size) - 1; } +static int +type_size(const struct glsl_type *type) +{ + unsigned int i; + int size; + + switch (type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + assert(!type->is_matrix()); + /* Regardless of size of vector, it gets a vec4. This is bad + * packing for things like floats, but otherwise arrays become a + * mess. Hopefully a later pass over the code can pack scalars + * down if appropriate. + */ + return 1; + case GLSL_TYPE_ARRAY: + return type_size(type->fields.array) * type->length; + case GLSL_TYPE_STRUCT: + size = 0; + for (i = 0; i < type->length; i++) { + size += type_size(type->fields.structure[i].type); + } + return size; + default: + assert(0); + } +} + void ir_to_mesa_visitor::get_temp_for_var(ir_variable *var, struct mbtree *tree) { @@ -252,13 +283,7 @@ ir_to_mesa_visitor::get_temp_for_var(ir_variable *var, struct mbtree *tree) entry = new temp_entry(var, PROGRAM_TEMPORARY, this->next_temp); this->variable_storage.push_tail(entry); - /* Store each array element in a temp. This is poor packing for - * things like floats, but we can't do better in the Mesa IR. - */ - if (var->type->length > 1) - next_temp += var->type->length; - else - next_temp++; + next_temp += type_size(var->type); ir_to_mesa_set_tree_reg(tree, entry->file, entry->index); } @@ -697,6 +722,39 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) this->result = tree; } +void +ir_to_mesa_visitor::visit(ir_dereference_record *ir) +{ + ir_variable *var = ir->variable_referenced(); + const char *field = ir->field; + struct mbtree *tree; + unsigned int i; + + const glsl_type *struct_type = var->type; + int offset = 0; + + tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); + this->get_temp_for_var(var, tree); + + for (i = 0; i < struct_type->length; i++) { + if (strcmp(struct_type->fields.structure[i].name, field) == 0) + break; + offset += type_size(struct_type->fields.structure[i].type); + } + tree->src_reg.index += offset; + tree->dst_reg.index += offset; +} + +/** + * We want to be careful in assignment setup to hit the actual storage + * instead of potentially using a temporary like we might with the + * ir_dereference handler. + * + * Thanks to ir_swizzle_swizzle, and ir_vec_index_to_swizzle, we + * should only see potentially one variable array index of a vector, + * and one swizzle, before getting to actual vec4 storage. So handle + * those, then go use ir_dereference to handle the rest. + */ static struct mbtree * get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) { @@ -704,11 +762,16 @@ get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) ir_dereference *deref; ir_swizzle *swiz; + ir->accept(v); + tree = v->result; + if ((deref = ir->as_dereference())) { + ir_dereference_array *deref_array = ir->as_dereference_array(); + assert(!deref_array || deref_array->array->type->is_array()); + ir->accept(v); tree = v->result; } else if ((swiz = ir->as_swizzle())) { - tree = get_assignment_lhs(swiz->val, v); tree->dst_reg.writemask = 0; if (swiz->mask.num_components >= 1) tree->dst_reg.writemask |= (1 << swiz->mask.x); @@ -725,18 +788,15 @@ get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) return tree; } -void -ir_to_mesa_visitor::visit(ir_dereference_record *ir) -{ - (void)ir; - assert(0); -} - void ir_to_mesa_visitor::visit(ir_assignment *ir) { struct mbtree *l, *r, *t; + assert(!ir->lhs->type->is_matrix()); + assert(!ir->lhs->type->is_array()); + assert(ir->lhs->type->base_type != GLSL_TYPE_STRUCT); + l = get_assignment_lhs(ir->lhs, this); ir->rhs->accept(this); -- cgit v1.2.3 From 3c5979565facebc82000a611b991d2977b8e9bbf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 15:50:02 -0700 Subject: ir_to_mesa: Add sin/cos. --- ir_to_mesa.cpp | 6 ++++++ mesa_codegen.brg | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 67c79b66ee5..205e2fc8c95 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -430,6 +430,12 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_unop_log2: this->result = this->create_tree(MB_TERM_log2_vec4, ir, op[0], NULL); break; + case ir_unop_sin: + this->result = this->create_tree(MB_TERM_sin_vec4, ir, op[0], NULL); + break; + case ir_unop_cos: + this->result = this->create_tree(MB_TERM_cos_vec4, ir, op[0], NULL); + break; case ir_binop_add: this->result = this->create_tree(MB_TERM_add_vec4_vec4, ir, op[0], op[1]); break; diff --git a/mesa_codegen.brg b/mesa_codegen.brg index a0ab7c86305..fc59a834f05 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -53,6 +53,8 @@ %term exp2_vec4 %term log_vec4 %term log2_vec4 +%term sin_vec4 +%term cos_vec4 %term add_vec4_vec4 %term sub_vec4_vec4 %term mul_vec4_vec4 @@ -157,6 +159,20 @@ vec4: swizzle_vec4(vec4) 1 reg); } +vec4: sin_vec4(vec4) 1 +{ + ir_to_mesa_emit_scalar_op1(tree, OPCODE_SIN, + tree->dst_reg, + tree->left->src_reg); +} + +vec4: cos_vec4(vec4) 1 +{ + ir_to_mesa_emit_scalar_op1(tree, OPCODE_COS, + tree->dst_reg, + tree->left->src_reg); +} + vec4: add_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_ADD); } vec4: sub_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SUB); } vec4: mul_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_MUL); } -- cgit v1.2.3 From c45b615a379e5b9cbcf951f9d738a1be77a5964b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 15:54:28 -0700 Subject: ir_to_mesa: Implement neg expression. --- ir_to_mesa.cpp | 7 ++++++- ir_to_mesa.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 205e2fc8c95..722e93a7977 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -47,7 +47,7 @@ extern "C" { } ir_to_mesa_src_reg ir_to_mesa_undef = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, false, + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, NEGATE_NONE, false, }; ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { @@ -184,6 +184,7 @@ ir_to_mesa_visitor::create_tree(int op, tree->right = right; tree->v = this; tree->src_reg.swizzle = SWIZZLE_XYZW; + tree->src_reg.negate = 0; tree->dst_reg.writemask = WRITEMASK_XYZW; ir_to_mesa_set_tree_reg(tree, PROGRAM_UNDEFINED, 0); tree->ir = ir; @@ -418,6 +419,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir) this->result = this->create_tree(MB_TERM_seq_vec4_vec4, ir, op[0], this->result); break; + case ir_unop_neg: + op[0]->src_reg.negate = ~op[0]->src_reg.negate; + this->result = op[0]; + break; case ir_unop_exp: this->result = this->create_tree(MB_TERM_exp_vec4, ir, op[0], NULL); break; diff --git a/ir_to_mesa.h b/ir_to_mesa.h index 515feb19a38..0535bc08a2a 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -40,6 +40,7 @@ typedef struct ir_to_mesa_src_reg { int file; /**< PROGRAM_* from Mesa */ int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ + int negate; /**< NEGATE_XYZW mask from mesa */ bool reladdr; /**< Register index should be offset by address reg. */ } ir_to_mesa_src_reg; -- cgit v1.2.3 From c2014f03e8d6b7e21e2d0c31270ced04e1025653 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 16:02:00 -0700 Subject: ir_to_mesa: Add support for trunc/ceil/floor. --- ir_to_mesa.cpp | 9 +++++++++ mesa_codegen.brg | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 722e93a7977..edc95eb5caa 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -520,6 +520,15 @@ ir_to_mesa_visitor::visit(ir_expression *ir) this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir, op[0], this->result); break; + case ir_unop_trunc: + this->result = this->create_tree(MB_TERM_trunc_vec4, ir, op[0], NULL); + break; + case ir_unop_ceil: + this->result = this->create_tree(MB_TERM_ceil_vec4, ir, op[0], NULL); + break; + case ir_unop_floor: + this->result = this->create_tree(MB_TERM_floor_vec4, ir, op[0], NULL); + break; default: break; } diff --git a/mesa_codegen.brg b/mesa_codegen.brg index fc59a834f05..25c0c47c02f 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -53,6 +53,9 @@ %term exp2_vec4 %term log_vec4 %term log2_vec4 +%term trunc_vec4 +%term ceil_vec4 +%term floor_vec4 %term sin_vec4 %term cos_vec4 %term add_vec4_vec4 @@ -71,7 +74,6 @@ %term sqrt_vec4 %term rsq_vec4 %term swizzle_vec4 -%term trunc_vec4 # Each tree will produce stmt. Currently, the only production for # stmt is from an assign rule -- every statement tree from @@ -159,6 +161,16 @@ vec4: swizzle_vec4(vec4) 1 reg); } +vec4: trunc_vec4(vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_TRUNC); } + +vec4: ceil_vec4(vec4) 1 { + tree->left->src_reg.negate = ~tree->left->src_reg.negate; + ir_to_mesa_emit_op1(tree, OPCODE_FLR); + tree->src_reg.negate = ~tree->left->src_reg.negate; +} + +vec4: floor_vec4(vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_FLR); } + vec4: sin_vec4(vec4) 1 { ir_to_mesa_emit_scalar_op1(tree, OPCODE_SIN, @@ -261,6 +273,4 @@ vec4: log2_vec4(vec4) 1 tree->left->src_reg); } -vec4: trunc_vec4(vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_TRUNC); } - %% -- cgit v1.2.3 From 346daeca07d3c19c051799f96fa9f442262bd49f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 16:06:37 -0700 Subject: ir_to_mesa: Don't assert over assignments with a constant-true condition. --- ir_to_mesa.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index edc95eb5caa..4238d9a8c81 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -824,7 +824,13 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) assert(l); assert(r); - assert(!ir->condition); + if (ir->condition) { + ir_constant *condition_constant; + + condition_constant = ir->condition->constant_expression_value(); + + assert(condition_constant && condition_constant->value.b[0]); + } t = this->create_tree(MB_TERM_assign, ir, l, r); mono_burg_label(t, NULL); -- cgit v1.2.3 From c23c6c773a5c79b458e52ff42bd9f431c87d4036 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 May 2010 16:10:37 -0700 Subject: ir_to_mesa: Implement min and max expressions. fixes glsl-orangebook-ch06-bump.frag. --- ir_to_mesa.cpp | 6 ++++++ mesa_codegen.brg | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 4238d9a8c81..59ee3b29f0a 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -529,6 +529,12 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_unop_floor: this->result = this->create_tree(MB_TERM_floor_vec4, ir, op[0], NULL); break; + case ir_binop_min: + this->result = this->create_tree(MB_TERM_min_vec4_vec4, ir, op[0], op[1]); + break; + case ir_binop_max: + this->result = this->create_tree(MB_TERM_max_vec4_vec4, ir, op[0], op[1]); + break; default: break; } diff --git a/mesa_codegen.brg b/mesa_codegen.brg index 25c0c47c02f..d53ccf39070 100644 --- a/mesa_codegen.brg +++ b/mesa_codegen.brg @@ -74,6 +74,8 @@ %term sqrt_vec4 %term rsq_vec4 %term swizzle_vec4 +%term min_vec4_vec4 +%term max_vec4_vec4 # Each tree will produce stmt. Currently, the only production for # stmt is from an assign rule -- every statement tree from @@ -273,4 +275,7 @@ vec4: log2_vec4(vec4) 1 tree->left->src_reg); } +vec4: min_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_MIN); } +vec4: max_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_MAX); } + %% -- cgit v1.2.3 From ab386f18b045fe260112bd9a239cb503e737c1db Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 1 Jun 2010 16:23:57 -0700 Subject: ir_to_mesa: Try to fix up the dereference handling for the visitor rework. One of the gstreamer shaders I play with now compiles, but input mappings are wrong. --- ir_to_mesa.cpp | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 59ee3b29f0a..8d3f65ffb20 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -659,27 +659,26 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), }; - ir_variable *var = ir->var; /* By the time we make it to this stage, matrices should be broken down * to vectors. */ - assert(!var->type->is_matrix()); + assert(!ir->var->type->is_matrix()); tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - if (strncmp(var->name, "gl_", 3) == 0) { + if (strncmp(ir->var->name, "gl_", 3) == 0) { unsigned int i; for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { - if (strcmp(var->name, builtin_var_to_mesa_reg[i].name) == 0) + if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0) break; } assert(i != ARRAY_SIZE(builtin_var_to_mesa_reg)); ir_to_mesa_set_tree_reg(tree, builtin_var_to_mesa_reg[i].file, builtin_var_to_mesa_reg[i].index); } else { - this->get_temp_for_var(var, tree); + this->get_temp_for_var(ir->var, tree); } /* If the type is smaller than a vec4, replicate the last channel out. */ @@ -698,33 +697,25 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), }; - ir_variable *var = ir->variable_referenced(); - ir_constant *index = ir->array_index->constant_expression_value(); + ir_constant *index; + + index = ir->array_index->constant_expression_value(); /* By the time we make it to this stage, matrices should be broken down * to vectors. */ - assert(!var->type->is_matrix()); - - if (strncmp(var->name, "gl_", 3) == 0) { - unsigned int i; - unsigned int offset = 0; + assert(!ir->type->is_matrix()); - tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); + ir->array->accept(this); + tree = this->result; - offset = index->value.i[0]; + if (tree->src_reg.file == PROGRAM_INPUT || + tree->src_reg.file == PROGRAM_OUTPUT) { + assert(index); /* FINISHME: Handle variable indexing of builtins. */ - for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { - if (strcmp(var->name, builtin_var_to_mesa_reg[i].name) == 0) - break; - } - assert(i != ARRAY_SIZE(builtin_var_to_mesa_reg)); - ir_to_mesa_set_tree_reg(tree, builtin_var_to_mesa_reg[i].file, - builtin_var_to_mesa_reg[i].index + offset); + tree->src_reg.index += index->value.i[0]; + tree->dst_reg.index += index->value.i[0]; } else { - tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - this->get_temp_for_var(var, tree); - if (index) { tree->src_reg.index += index->value.i[0]; tree->dst_reg.index += index->value.i[0]; -- cgit v1.2.3 From 224f712950494730c76b48864f2ca19acde1c8cf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 1 Jun 2010 16:32:46 -0700 Subject: ir_to_mesa: Fix mapping of FS texcoord inputs and color output. --- ir_to_mesa.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 8d3f65ffb20..f121fc88b34 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -613,13 +613,14 @@ static const struct { /* core_fs */ {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS}, {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE}, - {"gl_FragColor", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, + {"gl_FragColor", PROGRAM_OUTPUT, FRAG_ATTRIB_COL0}, {"gl_FragDepth", PROGRAM_UNDEFINED, FRAG_ATTRIB_WPOS}, /* FINISHME: WPOS.z */ /* 110_deprecated_fs */ {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, {"gl_SecondaryColor", PROGRAM_INPUT, FRAG_ATTRIB_COL1}, {"gl_FogFragCoord", PROGRAM_INPUT, FRAG_ATTRIB_FOGC}, + {"gl_TexCoord", PROGRAM_INPUT, FRAG_ATTRIB_TEX0}, /* array */ /* 110_deprecated_vs */ {"gl_Vertex", PROGRAM_INPUT, VERT_ATTRIB_POS}, @@ -669,12 +670,24 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) if (strncmp(ir->var->name, "gl_", 3) == 0) { unsigned int i; + bool var_in = (ir->var->mode == ir_var_in || + ir->var->mode == ir_var_inout); + + tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { - if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0) + bool in = builtin_var_to_mesa_reg[i].file == PROGRAM_INPUT; + + if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0 && + !(var_in ^ in)) break; } - assert(i != ARRAY_SIZE(builtin_var_to_mesa_reg)); + if (i == ARRAY_SIZE(builtin_var_to_mesa_reg)) { + printf("Failed to find builtin for %s variable %s\n", + var_in ? "in" : "out", + ir->var->name); + abort(); + } ir_to_mesa_set_tree_reg(tree, builtin_var_to_mesa_reg[i].file, builtin_var_to_mesa_reg[i].index); } else { -- cgit v1.2.3 From 0161515c395c44233529c8d51f823b60050bc7ba Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 2 Jun 2010 17:43:43 -0700 Subject: ir_to_mesa: Remove the BURG code. The promise of the BURG was to recognize multi-instruction sequences and emit reduced sequences for them. It would have worked well for recognizing MUL+ADD -> MAD and possibly even MIN(MAX(val, 0), 1) -> MOV_SAT with some grammar changes. However, that potential benefit in making those optimizations easy is outweighed by the fragility of monoburg, the amount of (incorrect, as I wrote it) code for using it, and the burden it was going to cause for handling operations on aggregate types. --- Makefile.am | 10 -- ir_to_mesa.cpp | 509 +++++++++++++++++++++++++------------------------------ ir_to_mesa.h | 81 +++------ mesa_codegen.brg | 281 ------------------------------ 4 files changed, 258 insertions(+), 623 deletions(-) delete mode 100644 mesa_codegen.brg diff --git a/Makefile.am b/Makefile.am index bf062595a9d..c34f7d8abfb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,16 +63,11 @@ glsl_SOURCES = \ ir_validate.cpp \ ir_vec_index_to_swizzle.cpp \ linker.cpp \ - mesa_codegen.cpp \ - msea_codegen.h \ mesa/shader/prog_instruction.c \ mesa/shader/prog_instruction.h \ mesa/shader/prog_print.c \ mesa/shader/prog_print.h -DISTFILES = \ - mesa_codegen.brg - BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) @@ -82,8 +77,3 @@ glsl_parser.h: glsl_parser.cpp .lpp.cpp: $(LEXCOMPILE) --outfile="$@" $< - -mesa_codegen.h: mesa_codegen.cpp - -mesa_codegen.cpp: mesa_codegen.brg - monoburg --no-glib -s $@ -d mesa_codegen.h $< diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index f121fc88b34..3376e897050 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -33,10 +33,11 @@ */ #define g_new #define g_error -#include "mesa_codegen.h" +#include #include "ir.h" #include "ir_visitor.h" +#include "ir_to_mesa.h" #include "ir_print_visitor.h" #include "ir_expression_flattening.h" #include "glsl_types.h" @@ -54,13 +55,29 @@ ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP }; +ir_to_mesa_dst_reg ir_to_mesa_address_reg = { + PROGRAM_ADDRESS, 0, WRITEMASK_X +}; + +static int swizzle_for_size(int size) +{ + int size_swizzles[4] = { + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), + }; + + return size_swizzles[size - 1]; +} + ir_to_mesa_instruction * -ir_to_mesa_emit_op3(ir_to_mesa_visitor *v, ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1, - ir_to_mesa_src_reg src2) +ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1, + ir_to_mesa_src_reg src2) { ir_to_mesa_instruction *inst = new ir_to_mesa_instruction(); @@ -71,48 +88,42 @@ ir_to_mesa_emit_op3(ir_to_mesa_visitor *v, ir_instruction *ir, inst->src_reg[2] = src2; inst->ir = ir; - v->instructions.push_tail(inst); + this->instructions.push_tail(inst); return inst; } ir_to_mesa_instruction * -ir_to_mesa_emit_op2_full(ir_to_mesa_visitor *v, ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1) +ir_to_mesa_visitor::ir_to_mesa_emit_op2(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1) { - return ir_to_mesa_emit_op3(v, ir, - op, dst, src0, src1, ir_to_mesa_undef); + return ir_to_mesa_emit_op3(ir, op, dst, src0, src1, ir_to_mesa_undef); } ir_to_mesa_instruction * -ir_to_mesa_emit_op2(struct mbtree *tree, enum prog_opcode op) +ir_to_mesa_visitor::ir_to_mesa_emit_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0) { - return ir_to_mesa_emit_op2_full(tree->v, tree->ir, op, - tree->dst_reg, - tree->left->src_reg, - tree->right->src_reg); + return ir_to_mesa_emit_op3(ir, op, dst, + src0, ir_to_mesa_undef, ir_to_mesa_undef); } -ir_to_mesa_instruction * -ir_to_mesa_emit_op1_full(ir_to_mesa_visitor *v, ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0) +inline ir_to_mesa_dst_reg +ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) { - return ir_to_mesa_emit_op3(v, ir, op, - dst, src0, ir_to_mesa_undef, ir_to_mesa_undef); -} + ir_to_mesa_dst_reg dst_reg; -ir_to_mesa_instruction * -ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op) -{ - return ir_to_mesa_emit_op1_full(tree->v, tree->ir, op, - tree->dst_reg, - tree->left->src_reg); + dst_reg.file = reg.file; + dst_reg.index = reg.index; + dst_reg.writemask = WRITEMASK_XYZW; + + return dst_reg; } /** @@ -124,9 +135,10 @@ ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op) * to produce dest channels. */ void -ir_to_mesa_emit_scalar_op1(struct mbtree *tree, enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0) +ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0) { int i, j; int done_mask = ~dst.writemask; @@ -152,52 +164,18 @@ ir_to_mesa_emit_scalar_op1(struct mbtree *tree, enum prog_opcode op, src.swizzle = MAKE_SWIZZLE4(src_swiz, src_swiz, src_swiz, src_swiz); - inst = ir_to_mesa_emit_op1_full(tree->v, tree->ir, op, - dst, - src); + inst = ir_to_mesa_emit_op1(ir, op, + dst, + src); inst->dst_reg.writemask = this_mask; done_mask |= this_mask; } } -static void -ir_to_mesa_set_tree_reg(struct mbtree *tree, int file, int index) -{ - tree->dst_reg.file = file; - tree->dst_reg.index = index; - - tree->src_reg.file = file; - tree->src_reg.index = index; -} - -struct mbtree * -ir_to_mesa_visitor::create_tree(int op, - ir_instruction *ir, - struct mbtree *left, struct mbtree *right) -{ - struct mbtree *tree = (struct mbtree *)calloc(sizeof(struct mbtree), 1); - - assert(ir); - - tree->op = op; - tree->left = left; - tree->right = right; - tree->v = this; - tree->src_reg.swizzle = SWIZZLE_XYZW; - tree->src_reg.negate = 0; - tree->dst_reg.writemask = WRITEMASK_XYZW; - ir_to_mesa_set_tree_reg(tree, PROGRAM_UNDEFINED, 0); - tree->ir = ir; - - return tree; -} - -struct mbtree * -ir_to_mesa_visitor::create_tree_for_float(ir_instruction *ir, float val) +struct ir_to_mesa_src_reg +ir_to_mesa_visitor::src_reg_for_float(float val) { - struct mbtree *tree = (struct mbtree *)calloc(sizeof(struct mbtree), 1); - - tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); + ir_to_mesa_src_reg src_reg; /* FINISHME: This will end up being _mesa_add_unnamed_constant, * which handles sharing values and sharing channels of vec4 @@ -206,11 +184,11 @@ ir_to_mesa_visitor::create_tree_for_float(ir_instruction *ir, float val) /* FINISHME: Do something with the constant values for now. */ (void)val; - ir_to_mesa_set_tree_reg(tree, PROGRAM_CONSTANT, this->next_constant++); - tree->src_reg.swizzle = SWIZZLE_NOOP; + src_reg.file = PROGRAM_CONSTANT; + src_reg.index = this->next_constant++; + src_reg.swizzle = SWIZZLE_NOOP; - this->result = tree; - return tree; + return src_reg; } /** @@ -219,21 +197,24 @@ ir_to_mesa_visitor::create_tree_for_float(ir_instruction *ir, float val) * storage). Actual register allocation for the Mesa VM occurs in a * pass over the Mesa IR later. */ -void -ir_to_mesa_visitor::get_temp(struct mbtree *tree, int size) +ir_to_mesa_src_reg +ir_to_mesa_visitor::get_temp(int size) { + ir_to_mesa_src_reg src_reg; int swizzle[4]; int i; - ir_to_mesa_set_tree_reg(tree, PROGRAM_TEMPORARY, this->next_temp++); + src_reg.file = PROGRAM_TEMPORARY; + src_reg.index = this->next_temp++; for (i = 0; i < size; i++) swizzle[i] = i; for (; i < 4; i++) swizzle[i] = size - 1; - tree->src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], - swizzle[2], swizzle[3]); - tree->dst_reg.writemask = (1 << size) - 1; + src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], + swizzle[2], swizzle[3]); + + return src_reg; } static int @@ -267,18 +248,18 @@ type_size(const struct glsl_type *type) } } -void -ir_to_mesa_visitor::get_temp_for_var(ir_variable *var, struct mbtree *tree) +ir_to_mesa_src_reg +ir_to_mesa_visitor::get_temp_for_var(ir_variable *var) { + ir_to_mesa_src_reg src_reg; + temp_entry *entry; foreach_iter(exec_list_iterator, iter, this->variable_storage) { entry = (temp_entry *)iter.get(); - if (entry->var == var) { - ir_to_mesa_set_tree_reg(tree, entry->file, entry->index); - return; - } + if (entry->var == var) + goto done; } entry = new temp_entry(var, PROGRAM_TEMPORARY, this->next_temp); @@ -286,36 +267,12 @@ ir_to_mesa_visitor::get_temp_for_var(ir_variable *var, struct mbtree *tree) next_temp += type_size(var->type); - ir_to_mesa_set_tree_reg(tree, entry->file, entry->index); -} +done: + src_reg.file = entry->file; + src_reg.index = entry->index; + src_reg.swizzle = swizzle_for_size(var->type->vector_elements); -static void -reduce(struct mbtree *t, int goal) -{ - struct mbtree *kids[10]; - int rule = mono_burg_rule((MBState *)t->state, goal); - const uint16_t *nts = mono_burg_nts[rule]; - int i; - - mono_burg_kids (t, rule, kids); - - for (i = 0; nts[i]; i++) { - reduce(kids[i], nts[i]); - } - - if (t->left) { - if (mono_burg_func[rule]) { - mono_burg_func[rule](t, NULL); - } else { - printf("no code for rules %s\n", mono_burg_rule_string[rule]); - exit(1); - } - } else { - if (mono_burg_func[rule]) { - printf("unused code for rule %s\n", mono_burg_rule_string[rule]); - exit(1); - } - } + return src_reg; } void @@ -332,15 +289,13 @@ ir_to_mesa_visitor::visit(ir_loop *ir) assert(!ir->increment); assert(!ir->counter); - ir_to_mesa_emit_op1_full(this, NULL, - OPCODE_BGNLOOP, ir_to_mesa_undef_dst, - ir_to_mesa_undef); + ir_to_mesa_emit_op1(NULL, OPCODE_BGNLOOP, + ir_to_mesa_undef_dst, ir_to_mesa_undef); visit_exec_list(&ir->body_instructions, this); - ir_to_mesa_emit_op1_full(this, NULL, - OPCODE_ENDLOOP, ir_to_mesa_undef_dst, - ir_to_mesa_undef); + ir_to_mesa_emit_op1(NULL, OPCODE_ENDLOOP, + ir_to_mesa_undef_dst, ir_to_mesa_undef); } void @@ -348,14 +303,12 @@ ir_to_mesa_visitor::visit(ir_loop_jump *ir) { switch (ir->mode) { case ir_loop_jump::jump_break: - ir_to_mesa_emit_op1_full(this, NULL, - OPCODE_BRK, ir_to_mesa_undef_dst, - ir_to_mesa_undef); + ir_to_mesa_emit_op1(NULL, OPCODE_BRK, + ir_to_mesa_undef_dst, ir_to_mesa_undef); break; case ir_loop_jump::jump_continue: - ir_to_mesa_emit_op1_full(this, NULL, - OPCODE_CONT, ir_to_mesa_undef_dst, - ir_to_mesa_undef); + ir_to_mesa_emit_op1(NULL, OPCODE_CONT, + ir_to_mesa_undef_dst, ir_to_mesa_undef); break; } } @@ -394,15 +347,17 @@ void ir_to_mesa_visitor::visit(ir_expression *ir) { unsigned int operand; - struct mbtree *op[2]; + struct ir_to_mesa_src_reg op[2], temp; + struct ir_to_mesa_src_reg result_src; + struct ir_to_mesa_dst_reg result_dst; const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); for (operand = 0; operand < ir->get_num_operands(); operand++) { - this->result = NULL; + this->result.file = PROGRAM_UNDEFINED; ir->operands[operand]->accept(this); - if (!this->result) { + if (this->result.file == PROGRAM_UNDEFINED) { ir_print_visitor v; printf("Failed to get tree for expression operand:\n"); ir->operands[operand]->accept(&v); @@ -411,149 +366,163 @@ ir_to_mesa_visitor::visit(ir_expression *ir) op[operand] = this->result; } - this->result = NULL; + this->result.file = PROGRAM_UNDEFINED; + + /* Storage for our result. Ideally for an assignment we'd be using + * the actual storage for the result here, instead. + */ + result_src = get_temp(4); + /* convenience for the emit functions below. */ + result_dst = ir_to_mesa_dst_reg_from_src(result_src); switch (ir->operation) { case ir_unop_logic_not: - this->result = this->create_tree_for_float(ir, 0.0); - this->result = this->create_tree(MB_TERM_seq_vec4_vec4, ir, - op[0], this->result); + temp = src_reg_for_float(0.0); + ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, op[0], temp); break; case ir_unop_neg: - op[0]->src_reg.negate = ~op[0]->src_reg.negate; - this->result = op[0]; + op[0].negate = ~op[0].negate; + result_src = op[0]; break; case ir_unop_exp: - this->result = this->create_tree(MB_TERM_exp_vec4, ir, op[0], NULL); + ir_to_mesa_emit_scalar_op1(ir, OPCODE_EXP, result_dst, op[0]); break; case ir_unop_exp2: - this->result = this->create_tree(MB_TERM_exp2_vec4, ir, op[0], NULL); + ir_to_mesa_emit_scalar_op1(ir, OPCODE_EX2, result_dst, op[0]); break; case ir_unop_log: - this->result = this->create_tree(MB_TERM_log_vec4, ir, op[0], NULL); + ir_to_mesa_emit_scalar_op1(ir, OPCODE_LOG, result_dst, op[0]); break; case ir_unop_log2: - this->result = this->create_tree(MB_TERM_log2_vec4, ir, op[0], NULL); + ir_to_mesa_emit_scalar_op1(ir, OPCODE_LG2, result_dst, op[0]); break; case ir_unop_sin: - this->result = this->create_tree(MB_TERM_sin_vec4, ir, op[0], NULL); + ir_to_mesa_emit_scalar_op1(ir, OPCODE_SIN, result_dst, op[0]); break; case ir_unop_cos: - this->result = this->create_tree(MB_TERM_cos_vec4, ir, op[0], NULL); + ir_to_mesa_emit_scalar_op1(ir, OPCODE_COS, result_dst, op[0]); break; case ir_binop_add: - this->result = this->create_tree(MB_TERM_add_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]); break; case ir_binop_sub: - this->result = this->create_tree(MB_TERM_sub_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); break; case ir_binop_mul: - this->result = this->create_tree(MB_TERM_mul_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], op[1]); break; case ir_binop_div: - this->result = this->create_tree(MB_TERM_div_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_RCP, result_dst, op[0], result_src); break; case ir_binop_less: - this->result = this->create_tree(MB_TERM_slt_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_SLT, result_dst, op[0], temp); break; case ir_binop_greater: - this->result = this->create_tree(MB_TERM_sgt_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_SGT, result_dst, op[0], temp); break; case ir_binop_lequal: - this->result = this->create_tree(MB_TERM_sle_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_SLE, result_dst, op[0], temp); break; case ir_binop_gequal: - this->result = this->create_tree(MB_TERM_sge_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_SGE, result_dst, op[0], temp); break; case ir_binop_equal: - this->result = this->create_tree(MB_TERM_seq_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, op[0], temp); break; case ir_binop_logic_xor: case ir_binop_nequal: - this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, op[0], temp); break; case ir_binop_logic_or: - /* This could be a saturated add. */ - this->result = this->create_tree(MB_TERM_add_vec4_vec4, ir, op[0], op[1]); - this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir, - this->create_tree_for_float(ir, 0.0), - this->result); + /* This could be a saturated add and skip the SNE. */ + ir_to_mesa_emit_op2(ir, OPCODE_ADD, + result_dst, + op[0], op[1]); + + ir_to_mesa_emit_op2(ir, OPCODE_SNE, + result_dst, + result_src, src_reg_for_float(0.0)); break; case ir_binop_logic_and: /* the bool args are stored as float 0.0 or 1.0, so "mul" gives us "and". */ - this->result = this->create_tree(MB_TERM_mul_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + result_dst, + op[0], op[1]); break; case ir_binop_dot: if (ir->operands[0]->type == vec4_type) { assert(ir->operands[1]->type == vec4_type); - this->result = this->create_tree(MB_TERM_dp4_vec4_vec4, - ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_DP4, + result_dst, + op[0], op[1]); } else if (ir->operands[0]->type == vec3_type) { assert(ir->operands[1]->type == vec3_type); - this->result = this->create_tree(MB_TERM_dp3_vec4_vec4, - ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_DP3, + result_dst, + op[0], op[1]); } else if (ir->operands[0]->type == vec2_type) { assert(ir->operands[1]->type == vec2_type); - this->result = this->create_tree(MB_TERM_dp2_vec4_vec4, - ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_DP2, + result_dst, + op[0], op[1]); } break; case ir_unop_sqrt: - this->result = this->create_tree(MB_TERM_sqrt_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); + ir_to_mesa_emit_op1(ir, OPCODE_RCP, result_dst, result_src); break; case ir_unop_rsq: - this->result = this->create_tree(MB_TERM_rsq_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); break; case ir_unop_i2f: /* Mesa IR lacks types, ints are stored as truncated floats. */ - this->result = op[0]; + result_src = op[0]; break; case ir_unop_f2i: - this->result = this->create_tree(MB_TERM_trunc_vec4, ir, op[0], NULL); + ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); break; case ir_unop_f2b: - this->result = this->create_tree_for_float(ir, 0.0); - this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir, - op[0], this->result); + ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, + result_src, src_reg_for_float(0.0)); break; case ir_unop_trunc: - this->result = this->create_tree(MB_TERM_trunc_vec4, ir, op[0], NULL); + ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); break; case ir_unop_ceil: - this->result = this->create_tree(MB_TERM_ceil_vec4, ir, op[0], NULL); + op[0].negate = ~op[0].negate; + ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); + result_src.negate = ~result_src.negate; break; case ir_unop_floor: - this->result = this->create_tree(MB_TERM_floor_vec4, ir, op[0], NULL); + ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); break; case ir_binop_min: - this->result = this->create_tree(MB_TERM_min_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_MIN, result_dst, op[0], op[1]); break; case ir_binop_max: - this->result = this->create_tree(MB_TERM_max_vec4_vec4, ir, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_MAX, result_dst, op[0], op[1]); break; default: - break; - } - if (!this->result) { ir_print_visitor v; printf("Failed to get tree for expression:\n"); ir->accept(&v); exit(1); + break; } - /* Allocate a temporary for the result. */ - this->get_temp(this->result, ir->type->vector_elements); + this->result = result_src; } void ir_to_mesa_visitor::visit(ir_swizzle *ir) { - struct mbtree *tree; + ir_to_mesa_src_reg src_reg; int i; int swizzle[4]; @@ -563,10 +532,9 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) */ ir->val->accept(this); - assert(this->result); + assert(this->result.file != PROGRAM_UNDEFINED); - tree = this->create_tree(MB_TERM_swizzle_vec4, ir, this->result, NULL); - this->get_temp(tree, 4); + src_reg = this->get_temp(4); for (i = 0; i < 4; i++) { if (i < ir->type->vector_elements) { @@ -592,12 +560,12 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) } } - tree->src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], - swizzle[1], - swizzle[2], - swizzle[3]); + src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], + swizzle[1], + swizzle[2], + swizzle[3]); - this->result = tree; + this->result = src_reg; } /* This list should match up with builtin_variables.h */ @@ -653,28 +621,18 @@ static const struct { void ir_to_mesa_visitor::visit(ir_dereference_variable *ir) { - struct mbtree *tree; - int size_swizzles[4] = { - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), - }; + ir_to_mesa_src_reg src_reg; /* By the time we make it to this stage, matrices should be broken down * to vectors. */ assert(!ir->var->type->is_matrix()); - tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - if (strncmp(ir->var->name, "gl_", 3) == 0) { unsigned int i; bool var_in = (ir->var->mode == ir_var_in || ir->var->mode == ir_var_inout); - tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { bool in = builtin_var_to_mesa_reg[i].file == PROGRAM_INPUT; @@ -688,29 +646,25 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) ir->var->name); abort(); } - ir_to_mesa_set_tree_reg(tree, builtin_var_to_mesa_reg[i].file, - builtin_var_to_mesa_reg[i].index); + src_reg.file = builtin_var_to_mesa_reg[i].file; + src_reg.index = builtin_var_to_mesa_reg[i].index; } else { - this->get_temp_for_var(ir->var, tree); + src_reg = get_temp_for_var(ir->var); } /* If the type is smaller than a vec4, replicate the last channel out. */ - tree->src_reg.swizzle = size_swizzles[ir->type->vector_elements - 1]; + src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); + src_reg.reladdr = false; + src_reg.negate = 0; - this->result = tree; + this->result = src_reg; } void ir_to_mesa_visitor::visit(ir_dereference_array *ir) { - struct mbtree *tree; - int size_swizzles[4] = { - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), - }; ir_constant *index; + ir_to_mesa_src_reg src_reg; index = ir->array_index->constant_expression_value(); @@ -720,59 +674,59 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) assert(!ir->type->is_matrix()); ir->array->accept(this); - tree = this->result; + src_reg = this->result; - if (tree->src_reg.file == PROGRAM_INPUT || - tree->src_reg.file == PROGRAM_OUTPUT) { + if (src_reg.file == PROGRAM_INPUT || + src_reg.file == PROGRAM_OUTPUT) { assert(index); /* FINISHME: Handle variable indexing of builtins. */ - tree->src_reg.index += index->value.i[0]; - tree->dst_reg.index += index->value.i[0]; + src_reg.index += index->value.i[0]; } else { if (index) { - tree->src_reg.index += index->value.i[0]; - tree->dst_reg.index += index->value.i[0]; + src_reg.index += index->value.i[0]; } else { + ir_to_mesa_src_reg array_base = this->result; /* Variable index array dereference. It eats the "vec4" of the * base of the array and an index that offsets the Mesa register * index. */ ir->array_index->accept(this); - tree->src_reg.reladdr = true; - tree = this->create_tree(MB_TERM_array_reference_vec4_vec4, - ir, tree, this->result); - this->get_temp(tree, ir->type->vector_elements); + /* FINISHME: This doesn't work when we're trying to do the LHS + * of an assignment. + */ + src_reg.reladdr = true; + ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, + this->result); + + this->result = get_temp(ir->type->vector_elements); + ir_to_mesa_emit_op1(ir, OPCODE_MOV, + ir_to_mesa_dst_reg_from_src(this->result), + src_reg); } } /* If the type is smaller than a vec4, replicate the last channel out. */ - tree->src_reg.swizzle = size_swizzles[ir->type->vector_elements - 1]; + src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); - this->result = tree; + this->result = src_reg; } void ir_to_mesa_visitor::visit(ir_dereference_record *ir) { - ir_variable *var = ir->variable_referenced(); - const char *field = ir->field; - struct mbtree *tree; unsigned int i; - - const glsl_type *struct_type = var->type; + const glsl_type *struct_type = ir->record->type; int offset = 0; - tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - this->get_temp_for_var(var, tree); + ir->record->accept(this); for (i = 0; i < struct_type->length; i++) { - if (strcmp(struct_type->fields.structure[i].name, field) == 0) + if (strcmp(struct_type->fields.structure[i].name, ir->field) == 0) break; offset += type_size(struct_type->fields.structure[i].type); } - tree->src_reg.index += offset; - tree->dst_reg.index += offset; + this->result.index += offset; } /** @@ -785,43 +739,44 @@ ir_to_mesa_visitor::visit(ir_dereference_record *ir) * and one swizzle, before getting to actual vec4 storage. So handle * those, then go use ir_dereference to handle the rest. */ -static struct mbtree * +static struct ir_to_mesa_dst_reg get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) { - struct mbtree *tree = NULL; + struct ir_to_mesa_dst_reg dst_reg; ir_dereference *deref; ir_swizzle *swiz; + /* Use the rvalue deref handler for the most part. We'll ignore + * swizzles in it and write swizzles using writemask, though. + */ ir->accept(v); - tree = v->result; + dst_reg = ir_to_mesa_dst_reg_from_src(v->result); if ((deref = ir->as_dereference())) { ir_dereference_array *deref_array = ir->as_dereference_array(); assert(!deref_array || deref_array->array->type->is_array()); ir->accept(v); - tree = v->result; } else if ((swiz = ir->as_swizzle())) { - tree->dst_reg.writemask = 0; + dst_reg.writemask = 0; if (swiz->mask.num_components >= 1) - tree->dst_reg.writemask |= (1 << swiz->mask.x); + dst_reg.writemask |= (1 << swiz->mask.x); if (swiz->mask.num_components >= 2) - tree->dst_reg.writemask |= (1 << swiz->mask.y); + dst_reg.writemask |= (1 << swiz->mask.y); if (swiz->mask.num_components >= 3) - tree->dst_reg.writemask |= (1 << swiz->mask.z); + dst_reg.writemask |= (1 << swiz->mask.z); if (swiz->mask.num_components >= 4) - tree->dst_reg.writemask |= (1 << swiz->mask.w); + dst_reg.writemask |= (1 << swiz->mask.w); } - assert(tree); - - return tree; + return dst_reg; } void ir_to_mesa_visitor::visit(ir_assignment *ir) { - struct mbtree *l, *r, *t; + struct ir_to_mesa_dst_reg l; + struct ir_to_mesa_src_reg r; assert(!ir->lhs->type->is_matrix()); assert(!ir->lhs->type->is_array()); @@ -831,8 +786,8 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) ir->rhs->accept(this); r = this->result; - assert(l); - assert(r); + assert(l.file != PROGRAM_UNDEFINED); + assert(r.file != PROGRAM_UNDEFINED); if (ir->condition) { ir_constant *condition_constant; @@ -842,21 +797,17 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) assert(condition_constant && condition_constant->value.b[0]); } - t = this->create_tree(MB_TERM_assign, ir, l, r); - mono_burg_label(t, NULL); - reduce(t, MB_NTERM_stmt); + ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); } void ir_to_mesa_visitor::visit(ir_constant *ir) { - struct mbtree *tree; + ir_to_mesa_src_reg src_reg; assert(!ir->type->is_matrix()); - tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL); - assert(ir->type->base_type == GLSL_TYPE_FLOAT || ir->type->base_type == GLSL_TYPE_UINT || ir->type->base_type == GLSL_TYPE_INT || @@ -868,10 +819,13 @@ ir_to_mesa_visitor::visit(ir_constant *ir) */ /* FINISHME: Do something with the constant values for now. */ - ir_to_mesa_set_tree_reg(tree, PROGRAM_CONSTANT, this->next_constant++); - tree->src_reg.swizzle = SWIZZLE_NOOP; + src_reg.file = PROGRAM_CONSTANT; + src_reg.index = this->next_constant++; + src_reg.swizzle = SWIZZLE_NOOP; + src_reg.reladdr = false; + src_reg.negate = 0; - this->result = tree; + this->result = src_reg; } @@ -906,31 +860,30 @@ ir_to_mesa_visitor::visit(ir_if *ir) ir_to_mesa_instruction *if_inst, *else_inst = NULL; ir->condition->accept(this); - assert(this->result); + assert(this->result.file != PROGRAM_UNDEFINED); - if_inst = ir_to_mesa_emit_op1_full(this, ir->condition, - OPCODE_IF, ir_to_mesa_undef_dst, - this->result->src_reg); + if_inst = ir_to_mesa_emit_op1(ir->condition, + OPCODE_IF, ir_to_mesa_undef_dst, + this->result); this->instructions.push_tail(if_inst); visit_exec_list(&ir->then_instructions, this); if (!ir->else_instructions.is_empty()) { - else_inst = ir_to_mesa_emit_op1_full(this, ir->condition, - OPCODE_ELSE, ir_to_mesa_undef_dst, - ir_to_mesa_undef); + else_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ELSE, + ir_to_mesa_undef_dst, + ir_to_mesa_undef); visit_exec_list(&ir->then_instructions, this); } - if_inst = ir_to_mesa_emit_op1_full(this, ir->condition, - OPCODE_ENDIF, ir_to_mesa_undef_dst, - ir_to_mesa_undef); + if_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ENDIF, + ir_to_mesa_undef_dst, ir_to_mesa_undef); } ir_to_mesa_visitor::ir_to_mesa_visitor() { - result = NULL; + result.file = PROGRAM_UNDEFINED; next_temp = 1; next_constant = 0; } diff --git a/ir_to_mesa.h b/ir_to_mesa.h index 0535bc08a2a..b05b9ebc7ae 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -102,15 +102,11 @@ public: int next_temp; int next_constant; - void get_temp(struct mbtree *tree, int size); + ir_to_mesa_src_reg get_temp(int size); - void get_temp_for_var(ir_variable *var, struct mbtree *tree); + ir_to_mesa_src_reg get_temp_for_var(ir_variable *var); - struct mbtree *create_tree(int op, - ir_instruction *ir, - struct mbtree *left, - struct mbtree *right); - struct mbtree *create_tree_for_float(ir_instruction *ir, float val); + struct ir_to_mesa_src_reg src_reg_for_float(float val); /** * \name Visit methods @@ -138,61 +134,38 @@ public: virtual void visit(ir_if *); /*@}*/ - struct mbtree *result; + struct ir_to_mesa_src_reg result; /** List of temp_entry */ exec_list variable_storage; /** List of ir_to_mesa_instruction */ exec_list instructions; + + ir_to_mesa_instruction *ir_to_mesa_emit_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); + + ir_to_mesa_instruction *ir_to_mesa_emit_op2(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1); + + ir_to_mesa_instruction *ir_to_mesa_emit_op3(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1, + ir_to_mesa_src_reg src2); + + void ir_to_mesa_emit_scalar_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); }; extern ir_to_mesa_src_reg ir_to_mesa_undef; extern ir_to_mesa_dst_reg ir_to_mesa_undef_dst; -ir_to_mesa_instruction * -ir_to_mesa_emit_op1(struct mbtree *tree, enum prog_opcode op); - -ir_to_mesa_instruction * -ir_to_mesa_emit_op1_full(ir_to_mesa_visitor *v, ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0); - -ir_to_mesa_instruction * -ir_to_mesa_emit_op2(struct mbtree *tree, enum prog_opcode op); - -ir_to_mesa_instruction * -ir_to_mesa_emit_op2_full(ir_to_mesa_visitor *v, ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1); - -ir_to_mesa_instruction * -ir_to_mesa_emit_simple_op2(struct mbtree *tree, enum prog_opcode op); - -ir_to_mesa_instruction * -ir_to_mesa_emit_op3(ir_to_mesa_visitor *v, ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1, - ir_to_mesa_src_reg src2); - -void -ir_to_mesa_emit_scalar_op1(struct mbtree *tree, enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0); - -inline ir_to_mesa_dst_reg -ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) -{ - ir_to_mesa_dst_reg dst_reg; - - dst_reg.file = reg.file; - dst_reg.index = reg.index; - dst_reg.writemask = WRITEMASK_XYZW; - - return dst_reg; -} diff --git a/mesa_codegen.brg b/mesa_codegen.brg deleted file mode 100644 index d53ccf39070..00000000000 --- a/mesa_codegen.brg +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - * - * Authors: - * Eric Anholt - * - */ - -/* DO NOT EDIT mesa_codegen.h. It is a generated file produced - * from mesa_codegen.brg and will be overwritten. - */ - -#include -#include -#include -#include -#include - -/* Everything before the first %% is pasted at the start of the - * mesa_codegen.h header file. - */ - -#include "ir_to_mesa.h" - -#define MBTREE_TYPE struct mbtree - -%% -# The list of terminals is the set of things that ir_to_mesa.cpp will -# generate in its trees. -%term assign -%term reference_vec4 -%term array_reference_vec4_vec4 -%term exp_vec4 -%term exp2_vec4 -%term log_vec4 -%term log2_vec4 -%term trunc_vec4 -%term ceil_vec4 -%term floor_vec4 -%term sin_vec4 -%term cos_vec4 -%term add_vec4_vec4 -%term sub_vec4_vec4 -%term mul_vec4_vec4 -%term div_vec4_vec4 -%term slt_vec4_vec4 -%term sgt_vec4_vec4 -%term sle_vec4_vec4 -%term sge_vec4_vec4 -%term seq_vec4_vec4 -%term sne_vec4_vec4 -%term dp4_vec4_vec4 -%term dp3_vec4_vec4 -%term dp2_vec4_vec4 -%term sqrt_vec4 -%term rsq_vec4 -%term swizzle_vec4 -%term min_vec4_vec4 -%term max_vec4_vec4 - -# Each tree will produce stmt. Currently, the only production for -# stmt is from an assign rule -- every statement tree from -# ir_to_mesa.cpp assigns a result to a register. - -%start stmt - -# Now comes all the rules for code generation. Each rule is of the -# general form -# -# produced: term(term, term) cost -# { -# code_run_when_we_choose_this_rule(); -# } -# -# where choosing this rule means we turn term(term, term) into -# produced at the cost of "cost". We measure "cost" in approximate -# instruction count. The BURG should then more or less minimize the -# number of instructions. - -# A reference of a variable is just a vec4 register location, -# so it can be used as an argument for pretty much anything. -vec4: reference_vec4 0 - -# A reference of a variable is just a vec4 register location, -# so it can be used as an argument for pretty much anything. -vec4: array_reference_vec4_vec4(vec4, vec4) 1 -{ - ir_to_mesa_dst_reg address_reg = {PROGRAM_ADDRESS, 0, WRITEMASK_X}; - - ir_to_mesa_emit_op1_full(tree->v, tree->ir, OPCODE_ARL, - address_reg, - tree->right->src_reg); - ir_to_mesa_emit_op1_full(tree->v, tree->ir, OPCODE_MOV, - tree->dst_reg, - tree->left->src_reg); -} - -# Here's the rule everyone will hit: Moving the result of an -# expression into a variable-dereference register location. -# -# Note that this is likely a gratuitous move. We could make variants -# of each of the following rules, e.g: -# -# vec4: add_vec4_vec4(vec4, vec4) 1 -# { -# emit(ADD, tree, tree->left, tree->right); -# } -# -# becoming -# -# vec4: assign(vec4_vec4, add_vec4_vec4(vec4, vec4) 1 -# { -# emit(ADD, tree->left, tree->right->left, tree->right->right); -# } -# -# But it seems like a lot of extra typing and duped code, when we -# probably want copy propagation and dead code after codegen anyway, -# which would clean these up. -stmt: assign(vec4, vec4) 1 -{ - ir_to_mesa_emit_op1_full(tree->v, tree->ir, OPCODE_MOV, - tree->left->dst_reg, - tree->right->src_reg); -} - -# Perform a swizzle by composing our swizzle with the swizzle -# required to get at the src reg. -vec4: swizzle_vec4(vec4) 1 -{ - ir_to_mesa_src_reg reg = tree->left->src_reg; - int swiz[4]; - int i; - - for (i = 0; i < 4; i++) { - swiz[i] = GET_SWZ(tree->src_reg.swizzle, i); - if (swiz[i] >= SWIZZLE_X && swiz[i] <= SWIZZLE_Y) { - swiz[i] = GET_SWZ(tree->left->src_reg.swizzle, swiz[i]); - } - } - reg.swizzle = MAKE_SWIZZLE4(swiz[0], swiz[1], swiz[2], swiz[3]); - - ir_to_mesa_emit_op1_full(tree->v, tree->ir, OPCODE_MOV, - tree->dst_reg, - reg); -} - -vec4: trunc_vec4(vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_TRUNC); } - -vec4: ceil_vec4(vec4) 1 { - tree->left->src_reg.negate = ~tree->left->src_reg.negate; - ir_to_mesa_emit_op1(tree, OPCODE_FLR); - tree->src_reg.negate = ~tree->left->src_reg.negate; -} - -vec4: floor_vec4(vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_FLR); } - -vec4: sin_vec4(vec4) 1 -{ - ir_to_mesa_emit_scalar_op1(tree, OPCODE_SIN, - tree->dst_reg, - tree->left->src_reg); -} - -vec4: cos_vec4(vec4) 1 -{ - ir_to_mesa_emit_scalar_op1(tree, OPCODE_COS, - tree->dst_reg, - tree->left->src_reg); -} - -vec4: add_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_ADD); } -vec4: sub_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SUB); } -vec4: mul_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_MUL); } - -vec4: dp4_vec4_vec4(vec4, vec4) 1 -{ - ir_to_mesa_emit_op2(tree, OPCODE_DP4); - tree->src_reg.swizzle = SWIZZLE_XXXX; -} - -vec4: dp3_vec4_vec4(vec4, vec4) 1 -{ - ir_to_mesa_emit_op2(tree, OPCODE_DP3); - tree->src_reg.swizzle = SWIZZLE_XXXX; -} - - -vec4: dp2_vec4_vec4(vec4, vec4) 1 -{ - ir_to_mesa_emit_op2(tree, OPCODE_DP2); - tree->src_reg.swizzle = SWIZZLE_XXXX; -} - -vec4: div_vec4_vec4(vec4, vec4) 1 -{ - ir_to_mesa_emit_scalar_op1(tree, OPCODE_RCP, - tree->dst_reg, - tree->right->src_reg); - - ir_to_mesa_emit_op2_full(tree->v, tree->ir, OPCODE_MUL, - tree->dst_reg, - tree->src_reg, - tree->left->src_reg); -} - -vec4: slt_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SLT); } -vec4: sgt_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SGT); } -vec4: sle_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SLE); } -vec4: sge_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SGE); } -vec4: sne_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SNE); } -vec4: seq_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_SEQ); } - -vec4: sqrt_vec4(vec4) 1 -{ - ir_to_mesa_emit_scalar_op1(tree, OPCODE_RSQ, - tree->dst_reg, - tree->left->src_reg); - - ir_to_mesa_emit_op1_full(tree->v, tree->ir, OPCODE_RCP, - tree->dst_reg, - tree->src_reg); -} - -vec4: rsq_vec4(vec4) 1 -{ - ir_to_mesa_emit_scalar_op1(tree, OPCODE_RSQ, - tree->dst_reg, - tree->left->src_reg); -} - -vec4: exp_vec4(vec4) 1 -{ - ir_to_mesa_emit_scalar_op1(tree, OPCODE_EXP, - tree->dst_reg, - tree->left->src_reg); -} - -vec4: exp2_vec4(vec4) 1 -{ - ir_to_mesa_emit_scalar_op1(tree, OPCODE_EX2, - tree->dst_reg, - tree->left->src_reg); -} - -vec4: log_vec4(vec4) 1 -{ - ir_to_mesa_emit_scalar_op1(tree, OPCODE_LOG, - tree->dst_reg, - tree->left->src_reg); -} - -vec4: log2_vec4(vec4) 1 -{ - ir_to_mesa_emit_scalar_op1(tree, OPCODE_LG2, - tree->dst_reg, - tree->left->src_reg); -} - -vec4: min_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_MIN); } -vec4: max_vec4_vec4(vec4, vec4) 1 { ir_to_mesa_emit_op2(tree, OPCODE_MAX); } - -%% -- cgit v1.2.3 From 9d2b8e0b70acce2678bea2cb6a990e0dee380b37 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 3 Jun 2010 09:04:57 -0700 Subject: ir_to_mesa: Fix copy-and-wasted DIV instruction sequence. --- ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 3376e897050..d9d7a91b296 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -413,7 +413,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) break; case ir_binop_div: ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[1]); - ir_to_mesa_emit_op2(ir, OPCODE_RCP, result_dst, op[0], result_src); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], result_src); break; case ir_binop_less: -- cgit v1.2.3 From 9cd8cad9f3dc4774366193acbfc5ab22198096e7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 3 Jun 2010 09:17:54 -0700 Subject: ir_to_mesa: Restrict dst writemasks like we did in the monoburg setup. --- ir_to_mesa.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index d9d7a91b296..8a5b2a6dbbb 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -371,9 +371,14 @@ ir_to_mesa_visitor::visit(ir_expression *ir) /* Storage for our result. Ideally for an assignment we'd be using * the actual storage for the result here, instead. */ - result_src = get_temp(4); + result_src = get_temp(ir->type->vector_elements); /* convenience for the emit functions below. */ result_dst = ir_to_mesa_dst_reg_from_src(result_src); + /* Limit writes to the channels that will be used by result_src later. + * This does limit this temp's use as a temporary for multi-instruction + * sequences. + */ + result_dst.writemask = (1 << ir->type->vector_elements) - 1; switch (ir->operation) { case ir_unop_logic_not: -- cgit v1.2.3 From 2401338ef8ba73e8a0b85ea1129a8e6127842117 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 3 Jun 2010 09:29:29 -0700 Subject: ir_to_mesa: Remove old monoburg structure. --- ir_to_mesa.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/ir_to_mesa.h b/ir_to_mesa.h index b05b9ebc7ae..839d36964f0 100644 --- a/ir_to_mesa.h +++ b/ir_to_mesa.h @@ -61,25 +61,6 @@ public: ir_instruction *ir; }; -struct mbtree { - struct mbtree *left; - struct mbtree *right; - void *state; - uint16_t op; - class ir_to_mesa_visitor *v; - - /** Pointer to the ir source this tree came from for debugging */ - ir_instruction *ir; - - ir_to_mesa_dst_reg dst_reg; - - /** - * This is the representation of this tree node's results as a - * source register for its consumer. - */ - ir_to_mesa_src_reg src_reg; -}; - void do_ir_to_mesa(exec_list *instructions); class temp_entry : public exec_node { -- cgit v1.2.3 From 554dbcce77cc7eb38b786c77eee87a5f391b090b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 3 Jun 2010 09:31:46 -0700 Subject: ir_to_mesa: Move the classes into the file now that we don't have the burg. At 1kloc, it doesn't look like I'll want to split the ir_to_mesa file up even once it's feature-complete. Move definitions closer to usage, and prevent rebuilding the world when changing the definitions. --- glsl_parser_extras.h | 2 + ir_to_mesa.cpp | 120 +++++++++++++++++++++++++++++++++++++--- ir_to_mesa.h | 152 --------------------------------------------------- 3 files changed, 115 insertions(+), 159 deletions(-) delete mode 100644 ir_to_mesa.h diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 87de9083c06..cfe02e3b0c1 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -134,4 +134,6 @@ extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, extern const char * _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target); +void do_ir_to_mesa(exec_list *instructions); + #endif /* GLSL_PARSER_EXTRAS_H */ diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 8a5b2a6dbbb..7a1f206cd41 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -28,16 +28,9 @@ * printing the result */ -/* Quiet compiler warnings due to monoburg not marking functions defined - * in the header as inline. - */ -#define g_new -#define g_error - #include #include "ir.h" #include "ir_visitor.h" -#include "ir_to_mesa.h" #include "ir_print_visitor.h" #include "ir_expression_flattening.h" #include "glsl_types.h" @@ -47,6 +40,119 @@ extern "C" { #include "shader/prog_print.h" } +/** + * This struct is a corresponding struct to Mesa prog_src_register, with + * wider fields. + */ +typedef struct ir_to_mesa_src_reg { + int file; /**< PROGRAM_* from Mesa */ + int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ + int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ + int negate; /**< NEGATE_XYZW mask from mesa */ + bool reladdr; /**< Register index should be offset by address reg. */ +} ir_to_mesa_src_reg; + +typedef struct ir_to_mesa_dst_reg { + int file; /**< PROGRAM_* from Mesa */ + int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ + int writemask; /**< Bitfield of WRITEMASK_[XYZW] */ +} ir_to_mesa_dst_reg; + +extern ir_to_mesa_src_reg ir_to_mesa_undef; + +class ir_to_mesa_instruction : public exec_node { +public: + enum prog_opcode op; + ir_to_mesa_dst_reg dst_reg; + ir_to_mesa_src_reg src_reg[3]; + /** Pointer to the ir source this tree came from for debugging */ + ir_instruction *ir; +}; + +class temp_entry : public exec_node { +public: + temp_entry(ir_variable *var, int file, int index) + : file(file), index(index), var(var) + { + /* empty */ + } + + int file; + int index; + ir_variable *var; /* variable that maps to this, if any */ +}; + +class ir_to_mesa_visitor : public ir_visitor { +public: + ir_to_mesa_visitor(); + + int next_temp; + int next_constant; + + ir_to_mesa_src_reg get_temp(int size); + + ir_to_mesa_src_reg get_temp_for_var(ir_variable *var); + + struct ir_to_mesa_src_reg src_reg_for_float(float val); + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_texture *); + virtual void visit(ir_if *); + /*@}*/ + + struct ir_to_mesa_src_reg result; + + /** List of temp_entry */ + exec_list variable_storage; + + /** List of ir_to_mesa_instruction */ + exec_list instructions; + + ir_to_mesa_instruction *ir_to_mesa_emit_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); + + ir_to_mesa_instruction *ir_to_mesa_emit_op2(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1); + + ir_to_mesa_instruction *ir_to_mesa_emit_op3(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1, + ir_to_mesa_src_reg src2); + + void ir_to_mesa_emit_scalar_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); +}; + ir_to_mesa_src_reg ir_to_mesa_undef = { PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, NEGATE_NONE, false, }; diff --git a/ir_to_mesa.h b/ir_to_mesa.h deleted file mode 100644 index 839d36964f0..00000000000 --- a/ir_to_mesa.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "ir.h" -extern "C" { -#include "shader/prog_instruction.h" -}; - -/** - * \file ir_to_mesa.h - * - * Translates the IR to Mesa IR if possible. - */ - -/** - * This struct is a corresponding struct to Mesa prog_src_register, with - * wider fields. - */ -typedef struct ir_to_mesa_src_reg { - int file; /**< PROGRAM_* from Mesa */ - int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ - int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ - int negate; /**< NEGATE_XYZW mask from mesa */ - bool reladdr; /**< Register index should be offset by address reg. */ -} ir_to_mesa_src_reg; - -typedef struct ir_to_mesa_dst_reg { - int file; /**< PROGRAM_* from Mesa */ - int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ - int writemask; /**< Bitfield of WRITEMASK_[XYZW] */ -} ir_to_mesa_dst_reg; - -extern ir_to_mesa_src_reg ir_to_mesa_undef; - -class ir_to_mesa_instruction : public exec_node { -public: - enum prog_opcode op; - ir_to_mesa_dst_reg dst_reg; - ir_to_mesa_src_reg src_reg[3]; - /** Pointer to the ir source this tree came from for debugging */ - ir_instruction *ir; -}; - -void do_ir_to_mesa(exec_list *instructions); - -class temp_entry : public exec_node { -public: - temp_entry(ir_variable *var, int file, int index) - : file(file), index(index), var(var) - { - /* empty */ - } - - int file; - int index; - ir_variable *var; /* variable that maps to this, if any */ -}; - -class ir_to_mesa_visitor : public ir_visitor { -public: - ir_to_mesa_visitor(); - - int next_temp; - int next_constant; - - ir_to_mesa_src_reg get_temp(int size); - - ir_to_mesa_src_reg get_temp_for_var(ir_variable *var); - - struct ir_to_mesa_src_reg src_reg_for_float(float val); - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_texture *); - virtual void visit(ir_if *); - /*@}*/ - - struct ir_to_mesa_src_reg result; - - /** List of temp_entry */ - exec_list variable_storage; - - /** List of ir_to_mesa_instruction */ - exec_list instructions; - - ir_to_mesa_instruction *ir_to_mesa_emit_op1(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0); - - ir_to_mesa_instruction *ir_to_mesa_emit_op2(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1); - - ir_to_mesa_instruction *ir_to_mesa_emit_op3(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1, - ir_to_mesa_src_reg src2); - - void ir_to_mesa_emit_scalar_op1(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0); -}; - -extern ir_to_mesa_src_reg ir_to_mesa_undef; -extern ir_to_mesa_dst_reg ir_to_mesa_undef_dst; - -- cgit v1.2.3 From a9b619bb3b96a90d14650771dedaf1db840d70a6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 3 Jun 2010 09:39:54 -0700 Subject: ir_to_mesa: Set up storage for uniform vars. --- ir_to_mesa.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 7a1f206cd41..56815ac8e1a 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -88,6 +88,9 @@ public: int next_temp; int next_constant; + int next_uniform; + + temp_entry *find_variable_storage(ir_variable *var); ir_to_mesa_src_reg get_temp(int size); @@ -334,13 +337,16 @@ type_size(const struct glsl_type *type) case GLSL_TYPE_INT: case GLSL_TYPE_FLOAT: case GLSL_TYPE_BOOL: - assert(!type->is_matrix()); - /* Regardless of size of vector, it gets a vec4. This is bad - * packing for things like floats, but otherwise arrays become a - * mess. Hopefully a later pass over the code can pack scalars - * down if appropriate. - */ - return 1; + if (type->is_matrix()) { + return 4; /* FINISHME: Not all matrices are 4x4. */ + } else { + /* Regardless of size of vector, it gets a vec4. This is bad + * packing for things like floats, but otherwise arrays become a + * mess. Hopefully a later pass over the code can pack scalars + * down if appropriate. + */ + return 1; + } case GLSL_TYPE_ARRAY: return type_size(type->fields.array) * type->length; case GLSL_TYPE_STRUCT: @@ -354,29 +360,40 @@ type_size(const struct glsl_type *type) } } -ir_to_mesa_src_reg -ir_to_mesa_visitor::get_temp_for_var(ir_variable *var) +temp_entry * +ir_to_mesa_visitor::find_variable_storage(ir_variable *var) { - ir_to_mesa_src_reg src_reg; - + temp_entry *entry; foreach_iter(exec_list_iterator, iter, this->variable_storage) { entry = (temp_entry *)iter.get(); if (entry->var == var) - goto done; + return entry; } - entry = new temp_entry(var, PROGRAM_TEMPORARY, this->next_temp); - this->variable_storage.push_tail(entry); + return NULL; +} - next_temp += type_size(var->type); +ir_to_mesa_src_reg +ir_to_mesa_visitor::get_temp_for_var(ir_variable *var) +{ + temp_entry *entry; + ir_to_mesa_src_reg src_reg; + + entry = find_variable_storage(var); + if (!entry) { + entry = new temp_entry(var, PROGRAM_TEMPORARY, this->next_temp); + this->variable_storage.push_tail(entry); + + next_temp += type_size(var->type); + } -done: src_reg.file = entry->file; src_reg.index = entry->index; src_reg.swizzle = swizzle_for_size(var->type->vector_elements); + src_reg.reladdr = false; return src_reg; } @@ -384,7 +401,16 @@ done: void ir_to_mesa_visitor::visit(ir_variable *ir) { - (void)ir; + if (ir->mode == ir_var_uniform) { + temp_entry *entry = find_variable_storage(ir); + + if (!entry) { + entry = new temp_entry(ir, PROGRAM_UNIFORM, this->next_uniform); + this->variable_storage.push_tail(entry); + + this->next_uniform += type_size(ir->type); + } + } } void @@ -997,6 +1023,7 @@ ir_to_mesa_visitor::ir_to_mesa_visitor() result.file = PROGRAM_UNDEFINED; next_temp = 1; next_constant = 0; + next_uniform = 0; } static struct prog_src_register -- cgit v1.2.3 From 4006424f5b5b3b189209faf03f2335f45c22b148 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 3 Jun 2010 10:13:18 -0700 Subject: ir_to_mesa: Don't allocate temps for swizzles. We do them in place by actually, you know, swizzling. --- ir_to_mesa.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 56815ac8e1a..53b7337d64b 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -669,9 +669,8 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) */ ir->val->accept(this); - assert(this->result.file != PROGRAM_UNDEFINED); - - src_reg = this->get_temp(4); + src_reg = this->result; + assert(src_reg.file != PROGRAM_UNDEFINED); for (i = 0; i < 4; i++) { if (i < ir->type->vector_elements) { -- cgit v1.2.3 From f4bd7f262e43301158f059af90176a476ffdbf60 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 3 Jun 2010 11:18:51 -0700 Subject: ir_to_mesa: Fix copy-and-wasted second argument to compare expresssion ops. Fixes CorrectParse2.vert assertion due to uninitialized values. --- ir_to_mesa.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 53b7337d64b..afb5ad0e468 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -315,6 +315,7 @@ ir_to_mesa_visitor::get_temp(int size) src_reg.file = PROGRAM_TEMPORARY; src_reg.index = this->next_temp++; + src_reg.reladdr = false; for (i = 0; i < size; i++) swizzle[i] = i; @@ -479,7 +480,7 @@ void ir_to_mesa_visitor::visit(ir_expression *ir) { unsigned int operand; - struct ir_to_mesa_src_reg op[2], temp; + struct ir_to_mesa_src_reg op[2]; struct ir_to_mesa_src_reg result_src; struct ir_to_mesa_dst_reg result_dst; const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); @@ -514,8 +515,8 @@ ir_to_mesa_visitor::visit(ir_expression *ir) switch (ir->operation) { case ir_unop_logic_not: - temp = src_reg_for_float(0.0); - ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, op[0], temp); + ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, + op[0], src_reg_for_float(0.0)); break; case ir_unop_neg: op[0].negate = ~op[0].negate; @@ -554,23 +555,23 @@ ir_to_mesa_visitor::visit(ir_expression *ir) break; case ir_binop_less: - ir_to_mesa_emit_op2(ir, OPCODE_SLT, result_dst, op[0], temp); + ir_to_mesa_emit_op2(ir, OPCODE_SLT, result_dst, op[0], op[1]); break; case ir_binop_greater: - ir_to_mesa_emit_op2(ir, OPCODE_SGT, result_dst, op[0], temp); + ir_to_mesa_emit_op2(ir, OPCODE_SGT, result_dst, op[0], op[1]); break; case ir_binop_lequal: - ir_to_mesa_emit_op2(ir, OPCODE_SLE, result_dst, op[0], temp); + ir_to_mesa_emit_op2(ir, OPCODE_SLE, result_dst, op[0], op[1]); break; case ir_binop_gequal: - ir_to_mesa_emit_op2(ir, OPCODE_SGE, result_dst, op[0], temp); + ir_to_mesa_emit_op2(ir, OPCODE_SGE, result_dst, op[0], op[1]); break; case ir_binop_equal: - ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, op[0], temp); + ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, op[0], op[1]); break; case ir_binop_logic_xor: case ir_binop_nequal: - ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, op[0], temp); + ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, op[0], op[1]); break; case ir_binop_logic_or: -- cgit v1.2.3 From 76720647566db8126b9f29a0e705ba03ebcdad27 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 3 Jun 2010 16:31:14 -0700 Subject: ir_to_mesa: Handle constant matrices. There's not much to it since we're not actually storing constant data yet. --- ir_to_mesa.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index afb5ad0e468..2ec2b11f03e 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -943,8 +943,6 @@ ir_to_mesa_visitor::visit(ir_constant *ir) { ir_to_mesa_src_reg src_reg; - assert(!ir->type->is_matrix()); - assert(ir->type->base_type == GLSL_TYPE_FLOAT || ir->type->base_type == GLSL_TYPE_UINT || ir->type->base_type == GLSL_TYPE_INT || @@ -957,11 +955,13 @@ ir_to_mesa_visitor::visit(ir_constant *ir) /* FINISHME: Do something with the constant values for now. */ src_reg.file = PROGRAM_CONSTANT; - src_reg.index = this->next_constant++; + src_reg.index = this->next_constant; src_reg.swizzle = SWIZZLE_NOOP; src_reg.reladdr = false; src_reg.negate = 0; + this->next_constant += type_size(ir->type); + this->result = src_reg; } -- cgit v1.2.3 From 8364fc85b8273b4d0f2ecebe7e0085e250d29990 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 3 Jun 2010 16:37:17 -0700 Subject: ir_to_mesa: Handle a limited subset of matrix multiplication. glsl-mvp.vert now generates believable code, and mesa mode fails only 5 tests that master doesn't. I must have left out some asserts... --- ir_to_mesa.cpp | 253 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 137 insertions(+), 116 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 2ec2b11f03e..b496a87df56 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -92,9 +92,7 @@ public: temp_entry *find_variable_storage(ir_variable *var); - ir_to_mesa_src_reg get_temp(int size); - - ir_to_mesa_src_reg get_temp_for_var(ir_variable *var); + ir_to_mesa_src_reg get_temp(const glsl_type *type); struct ir_to_mesa_src_reg src_reg_for_float(float val); @@ -180,6 +178,56 @@ static int swizzle_for_size(int size) return size_swizzles[size - 1]; } +/* This list should match up with builtin_variables.h */ +static const struct { + const char *name; + int file; + int index; +} builtin_var_to_mesa_reg[] = { + /* core_vs */ + {"gl_Position", PROGRAM_OUTPUT, VERT_RESULT_HPOS}, + {"gl_PointSize", PROGRAM_OUTPUT, VERT_RESULT_PSIZ}, + + /* core_fs */ + {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS}, + {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE}, + {"gl_FragColor", PROGRAM_OUTPUT, FRAG_ATTRIB_COL0}, + {"gl_FragDepth", PROGRAM_UNDEFINED, FRAG_ATTRIB_WPOS}, /* FINISHME: WPOS.z */ + + /* 110_deprecated_fs */ + {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, + {"gl_SecondaryColor", PROGRAM_INPUT, FRAG_ATTRIB_COL1}, + {"gl_FogFragCoord", PROGRAM_INPUT, FRAG_ATTRIB_FOGC}, + {"gl_TexCoord", PROGRAM_INPUT, FRAG_ATTRIB_TEX0}, /* array */ + + /* 110_deprecated_vs */ + {"gl_Vertex", PROGRAM_INPUT, VERT_ATTRIB_POS}, + {"gl_Normal", PROGRAM_INPUT, VERT_ATTRIB_NORMAL}, + {"gl_Color", PROGRAM_INPUT, VERT_ATTRIB_COLOR0}, + {"gl_SecondaryColor", PROGRAM_INPUT, VERT_ATTRIB_COLOR1}, + {"gl_MultiTexCoord0", PROGRAM_INPUT, VERT_ATTRIB_TEX0}, + {"gl_MultiTexCoord1", PROGRAM_INPUT, VERT_ATTRIB_TEX1}, + {"gl_MultiTexCoord2", PROGRAM_INPUT, VERT_ATTRIB_TEX2}, + {"gl_MultiTexCoord3", PROGRAM_INPUT, VERT_ATTRIB_TEX3}, + {"gl_MultiTexCoord4", PROGRAM_INPUT, VERT_ATTRIB_TEX4}, + {"gl_MultiTexCoord5", PROGRAM_INPUT, VERT_ATTRIB_TEX5}, + {"gl_MultiTexCoord6", PROGRAM_INPUT, VERT_ATTRIB_TEX6}, + {"gl_MultiTexCoord7", PROGRAM_INPUT, VERT_ATTRIB_TEX7}, + {"gl_TexCoord", PROGRAM_OUTPUT, VERT_RESULT_TEX0}, /* array */ + {"gl_FogCoord", PROGRAM_INPUT, VERT_RESULT_FOGC}, + /*{"gl_ClipVertex", PROGRAM_OUTPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ + {"gl_FrontColor", PROGRAM_OUTPUT, VERT_RESULT_COL0}, + {"gl_BackColor", PROGRAM_OUTPUT, VERT_RESULT_BFC0}, + {"gl_FrontSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_COL1}, + {"gl_BackSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_BFC1}, + {"gl_FogFragCoord", PROGRAM_OUTPUT, VERT_RESULT_FOGC}, + + /* 130_vs */ + /*{"gl_VertexID", PROGRAM_INPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ + + {"gl_FragData", PROGRAM_OUTPUT, FRAG_RESULT_DATA0}, /* array */ +}; + ir_to_mesa_instruction * ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir, enum prog_opcode op, @@ -307,20 +355,22 @@ ir_to_mesa_visitor::src_reg_for_float(float val) * pass over the Mesa IR later. */ ir_to_mesa_src_reg -ir_to_mesa_visitor::get_temp(int size) +ir_to_mesa_visitor::get_temp(const glsl_type *type) { ir_to_mesa_src_reg src_reg; int swizzle[4]; int i; + assert(!type->is_array()); + src_reg.file = PROGRAM_TEMPORARY; - src_reg.index = this->next_temp++; + src_reg.index = type->matrix_columns; src_reg.reladdr = false; - for (i = 0; i < size; i++) + for (i = 0; i < type->vector_elements; i++) swizzle[i] = i; for (; i < 4; i++) - swizzle[i] = size - 1; + swizzle[i] = type->vector_elements - 1; src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], swizzle[2], swizzle[3]); @@ -377,41 +427,10 @@ ir_to_mesa_visitor::find_variable_storage(ir_variable *var) return NULL; } -ir_to_mesa_src_reg -ir_to_mesa_visitor::get_temp_for_var(ir_variable *var) -{ - temp_entry *entry; - ir_to_mesa_src_reg src_reg; - - entry = find_variable_storage(var); - if (!entry) { - entry = new temp_entry(var, PROGRAM_TEMPORARY, this->next_temp); - this->variable_storage.push_tail(entry); - - next_temp += type_size(var->type); - } - - src_reg.file = entry->file; - src_reg.index = entry->index; - src_reg.swizzle = swizzle_for_size(var->type->vector_elements); - src_reg.reladdr = false; - - return src_reg; -} - void ir_to_mesa_visitor::visit(ir_variable *ir) { - if (ir->mode == ir_var_uniform) { - temp_entry *entry = find_variable_storage(ir); - - if (!entry) { - entry = new temp_entry(ir, PROGRAM_UNIFORM, this->next_uniform); - this->variable_storage.push_tail(entry); - - this->next_uniform += type_size(ir->type); - } - } + (void)ir; } void @@ -497,6 +516,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir) exit(1); } op[operand] = this->result; + + /* Only expression implemented for matrices yet */ + assert(!ir->operands[operand]->type->is_matrix() || + ir->operation == ir_binop_mul); } this->result.file = PROGRAM_UNDEFINED; @@ -504,7 +527,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) /* Storage for our result. Ideally for an assignment we'd be using * the actual storage for the result here, instead. */ - result_src = get_temp(ir->type->vector_elements); + result_src = get_temp(ir->type); /* convenience for the emit functions below. */ result_dst = ir_to_mesa_dst_reg_from_src(result_src); /* Limit writes to the channels that will be used by result_src later. @@ -547,7 +570,34 @@ ir_to_mesa_visitor::visit(ir_expression *ir) ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); break; case ir_binop_mul: - ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], op[1]); + if (ir->operands[0]->type->is_matrix() && + !ir->operands[1]->type->is_matrix()) { + if (ir->operands[0]->type->is_scalar()) { + ir_to_mesa_dst_reg dst_column = result_dst; + ir_to_mesa_src_reg src_column = op[0]; + for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + dst_column, src_column, op[1]); + dst_column.index++; + src_column.index++; + } + } else { + ir_to_mesa_dst_reg dst_chan = result_dst; + ir_to_mesa_src_reg src_column = op[0]; + ir_to_mesa_src_reg src_chan = op[1]; + for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { + dst_chan.writemask = (1 << i); + src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + dst_chan, src_column, src_chan); + src_column.index++; + } + } + } else { + assert(!ir->operands[0]->type->is_matrix()); + assert(!ir->operands[1]->type->is_matrix()); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], op[1]); + } break; case ir_binop_div: ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[1]); @@ -705,92 +755,63 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) this->result = src_reg; } -/* This list should match up with builtin_variables.h */ -static const struct { - const char *name; - int file; - int index; -} builtin_var_to_mesa_reg[] = { - /* core_vs */ - {"gl_Position", PROGRAM_OUTPUT, VERT_RESULT_HPOS}, - {"gl_PointSize", PROGRAM_OUTPUT, VERT_RESULT_PSIZ}, - - /* core_fs */ - {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS}, - {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE}, - {"gl_FragColor", PROGRAM_OUTPUT, FRAG_ATTRIB_COL0}, - {"gl_FragDepth", PROGRAM_UNDEFINED, FRAG_ATTRIB_WPOS}, /* FINISHME: WPOS.z */ - - /* 110_deprecated_fs */ - {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, - {"gl_SecondaryColor", PROGRAM_INPUT, FRAG_ATTRIB_COL1}, - {"gl_FogFragCoord", PROGRAM_INPUT, FRAG_ATTRIB_FOGC}, - {"gl_TexCoord", PROGRAM_INPUT, FRAG_ATTRIB_TEX0}, /* array */ - - /* 110_deprecated_vs */ - {"gl_Vertex", PROGRAM_INPUT, VERT_ATTRIB_POS}, - {"gl_Normal", PROGRAM_INPUT, VERT_ATTRIB_NORMAL}, - {"gl_Color", PROGRAM_INPUT, VERT_ATTRIB_COLOR0}, - {"gl_SecondaryColor", PROGRAM_INPUT, VERT_ATTRIB_COLOR1}, - {"gl_MultiTexCoord0", PROGRAM_INPUT, VERT_ATTRIB_TEX0}, - {"gl_MultiTexCoord1", PROGRAM_INPUT, VERT_ATTRIB_TEX1}, - {"gl_MultiTexCoord2", PROGRAM_INPUT, VERT_ATTRIB_TEX2}, - {"gl_MultiTexCoord3", PROGRAM_INPUT, VERT_ATTRIB_TEX3}, - {"gl_MultiTexCoord4", PROGRAM_INPUT, VERT_ATTRIB_TEX4}, - {"gl_MultiTexCoord5", PROGRAM_INPUT, VERT_ATTRIB_TEX5}, - {"gl_MultiTexCoord6", PROGRAM_INPUT, VERT_ATTRIB_TEX6}, - {"gl_MultiTexCoord7", PROGRAM_INPUT, VERT_ATTRIB_TEX7}, - {"gl_TexCoord", PROGRAM_OUTPUT, VERT_RESULT_TEX0}, /* array */ - {"gl_FogCoord", PROGRAM_INPUT, VERT_RESULT_FOGC}, - /*{"gl_ClipVertex", PROGRAM_OUTPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ - {"gl_FrontColor", PROGRAM_OUTPUT, VERT_RESULT_COL0}, - {"gl_BackColor", PROGRAM_OUTPUT, VERT_RESULT_BFC0}, - {"gl_FrontSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_COL1}, - {"gl_BackSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_BFC1}, - {"gl_FogFragCoord", PROGRAM_OUTPUT, VERT_RESULT_FOGC}, - - /* 130_vs */ - /*{"gl_VertexID", PROGRAM_INPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ - - {"gl_FragData", PROGRAM_OUTPUT, FRAG_RESULT_DATA0}, /* array */ -}; - void ir_to_mesa_visitor::visit(ir_dereference_variable *ir) { ir_to_mesa_src_reg src_reg; + temp_entry *entry = find_variable_storage(ir->var); + unsigned int i; + bool var_in; - /* By the time we make it to this stage, matrices should be broken down - * to vectors. - */ - assert(!ir->var->type->is_matrix()); - - if (strncmp(ir->var->name, "gl_", 3) == 0) { - unsigned int i; - bool var_in = (ir->var->mode == ir_var_in || - ir->var->mode == ir_var_inout); + if (!entry) { + switch (ir->var->mode) { + case ir_var_uniform: + entry = new temp_entry(ir->var, PROGRAM_UNIFORM, this->next_uniform); + this->variable_storage.push_tail(entry); - for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { - bool in = builtin_var_to_mesa_reg[i].file == PROGRAM_INPUT; + this->next_uniform += type_size(ir->var->type); + break; + case ir_var_in: + case ir_var_out: + case ir_var_inout: + var_in = (ir->var->mode == ir_var_in || + ir->var->mode == ir_var_inout); + + for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { + bool in = builtin_var_to_mesa_reg[i].file == PROGRAM_INPUT; + + if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0 && + !(var_in ^ in)) + break; + } + if (i == ARRAY_SIZE(builtin_var_to_mesa_reg)) { + printf("Failed to find builtin for %s variable %s\n", + var_in ? "in" : "out", + ir->var->name); + abort(); + } + entry = new temp_entry(ir->var, + builtin_var_to_mesa_reg[i].file, + builtin_var_to_mesa_reg[i].index); + break; + case ir_var_auto: + entry = new temp_entry(ir->var, PROGRAM_TEMPORARY, this->next_temp); + this->variable_storage.push_tail(entry); - if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0 && - !(var_in ^ in)) - break; + next_temp += type_size(ir->var->type); + break; } - if (i == ARRAY_SIZE(builtin_var_to_mesa_reg)) { - printf("Failed to find builtin for %s variable %s\n", - var_in ? "in" : "out", - ir->var->name); - abort(); + + if (!entry) { + printf("Failed to make storage for %s\n", ir->var->name); + exit(1); } - src_reg.file = builtin_var_to_mesa_reg[i].file; - src_reg.index = builtin_var_to_mesa_reg[i].index; - } else { - src_reg = get_temp_for_var(ir->var); } + src_reg.file = entry->file; + src_reg.index = entry->index; /* If the type is smaller than a vec4, replicate the last channel out. */ - src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); + src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); src_reg.reladdr = false; src_reg.negate = 0; @@ -836,7 +857,7 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, this->result); - this->result = get_temp(ir->type->vector_elements); + this->result = get_temp(ir->type); ir_to_mesa_emit_op1(ir, OPCODE_MOV, ir_to_mesa_dst_reg_from_src(this->result), src_reg); -- cgit v1.2.3 From 6b01b50888d22ee330df44240591051cb55cf2a9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 15:18:39 -0700 Subject: Move the talloc_parent lookup down in a few hot paths. talloc_parent is still 80% of our runtime, but likely talloc_parent lookups will be reduced as we improve the handling of memory ownership. --- ir_constant_expression.cpp | 4 ++-- ir_dead_code.cpp | 3 ++- ir_vec_index_to_swizzle.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 4010e462674..3408f5256a7 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -127,7 +127,6 @@ ir_constant_visitor::visit(ir_function *ir) void ir_constant_visitor::visit(ir_expression *ir) { - void *ctx = talloc_parent(ir); value = NULL; ir_constant *op[2]; unsigned int operand, c; @@ -498,6 +497,7 @@ ir_constant_visitor::visit(ir_expression *ir) return; } + void *ctx = talloc_parent(ir); this->value = new(ctx) ir_constant(ir->type, &data); } @@ -514,7 +514,6 @@ ir_constant_visitor::visit(ir_texture *ir) void ir_constant_visitor::visit(ir_swizzle *ir) { - void *ctx = talloc_parent(ir); ir_constant *v = ir->val->constant_expression_value(); this->value = NULL; @@ -536,6 +535,7 @@ ir_constant_visitor::visit(ir_swizzle *ir) } } + void *ctx = talloc_parent(ir); this->value = new(ctx) ir_constant(ir->type, &data); } } diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp index 01b7d2d832a..88213046825 100644 --- a/ir_dead_code.cpp +++ b/ir_dead_code.cpp @@ -77,7 +77,6 @@ public: variable_entry * ir_dead_code_visitor::get_variable_entry(ir_variable *var) { - void *ctx = talloc_parent(var); assert(var); foreach_iter(exec_list_iterator, iter, this->variable_list) { variable_entry *entry = (variable_entry *)iter.get(); @@ -85,6 +84,8 @@ ir_dead_code_visitor::get_variable_entry(ir_variable *var) return entry; } + void *ctx = talloc_parent(var); + variable_entry *entry = new(ctx) variable_entry(var); this->variable_list.push_tail(entry); return entry; diff --git a/ir_vec_index_to_swizzle.cpp b/ir_vec_index_to_swizzle.cpp index bbd873791a1..abeb43cd68e 100644 --- a/ir_vec_index_to_swizzle.cpp +++ b/ir_vec_index_to_swizzle.cpp @@ -60,7 +60,6 @@ public: ir_rvalue * ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) { - void *ctx = talloc_parent(ir); ir_dereference_array *deref = ir->as_dereference_array(); ir_constant *ir_constant; @@ -75,6 +74,7 @@ ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) if (!ir_constant) return ir; + void *ctx = talloc_parent(ir); this->progress = true; return new(ctx) ir_swizzle(deref->array, ir_constant->value.i[0], 0, 0, 0, 1); -- cgit v1.2.3 From 29285882676388aacff123e8bdf025904abf8ea9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 15:32:15 -0700 Subject: glsl2: Move the compiler to the subdirectory it will live in in Mesa. --- .dir-locals.el | 3 - .gitignore | 25 - Makefile.am | 79 - TODO | 84 - ast.h | 651 --- ast_expr.cpp | 96 - ast_function.cpp | 751 --- ast_to_hir.cpp | 2453 ---------- ast_type.cpp | 110 - autogen.sh | 12 - builtin_function.cpp | 5080 -------------------- builtin_types.h | 268 -- builtin_variables.h | 93 - builtins/110/abs | 21 - builtins/110/all | 16 - builtins/110/any | 16 - builtins/110/asin | 112 - builtins/110/atan | 154 - builtins/110/ceil | 21 - builtins/110/clamp | 62 - builtins/110/cos | 21 - builtins/110/cross | 17 - builtins/110/degrees | 21 - builtins/110/distance | 33 - builtins/110/dot | 25 - builtins/110/equal | 61 - builtins/110/exp | 21 - builtins/110/exp2 | 21 - builtins/110/faceforward | 37 - builtins/110/floor | 21 - builtins/110/fract | 34 - builtins/110/greaterThan | 61 - builtins/110/greaterThanEqual | 61 - builtins/110/inversesqrt | 21 - builtins/110/length | 21 - builtins/110/lessThan | 61 - builtins/110/lessThanEqual | 61 - builtins/110/log | 21 - builtins/110/log2 | 21 - builtins/110/matrixCompMult | 32 - builtins/110/max | 64 - builtins/110/min | 64 - builtins/110/mix | 50 - builtins/110/mod | 64 - builtins/110/noise_fake | 76 - builtins/110/normalize | 21 - builtins/110/not | 16 - builtins/110/notEqual | 61 - builtins/110/pow | 25 - builtins/110/radians | 21 - builtins/110/reflect | 58 - builtins/110/refract | 102 - builtins/110/sign | 34 - builtins/110/sin | 21 - builtins/110/smoothstep | 224 - builtins/110/sqrt | 21 - builtins/110/step | 68 - builtins/110/tan | 21 - builtins/110/textures | 213 - builtins/110_fs/derivatives | 73 - builtins/110_fs/textures | 113 - builtins/110_vs/ftransform | 7 - builtins/120/matrixCompMult | 61 - builtins/120/outerProduct | 92 - builtins/120/transpose | 139 - builtins/130/clamp | 123 - builtins/130/cosh | 30 - builtins/130/equal | 31 - builtins/130/greaterThan | 31 - builtins/130/greaterThanEqual | 31 - builtins/130/lessThan | 31 - builtins/130/lessThanEqual | 31 - builtins/130/max | 127 - builtins/130/min | 127 - builtins/130/notEqual | 31 - builtins/130/sign | 34 - builtins/130/sinh | 30 - builtins/130/tanh | 42 - builtins/130/texelFetch | 107 - builtins/130/texture | 110 - builtins/130/textureGrad | 147 - builtins/130/textureLod | 128 - builtins/130/textureProj | 92 - builtins/130/textureProjGrad | 122 - builtins/130/textureProjLod | 107 - builtins/130_fs/texture | 128 - builtins/130_fs/textureProj | 107 - builtins/ARB_texture_rectangle/textures | 16 - builtins/EXT_texture_array/textures | 59 - builtins/EXT_texture_array_fs/textures | 27 - builtins/tools/generate_builtins.pl | 123 - builtins/tools/generate_matrixCompMultGLSL.py | 28 - builtins/tools/generate_outerProductGLSL.py | 23 - builtins/tools/generate_transposeGLSL.py | 28 - builtins/tools/texture_builtins.py | 298 -- configure.ac | 69 - glcpp/.gitignore | 11 - glcpp/Makefile.am | 46 - glcpp/README | 30 - glcpp/glcpp-lex.l | 257 - glcpp/glcpp-parse.y | 1611 ------- glcpp/glcpp.c | 88 - glcpp/glcpp.h | 224 - glcpp/hash_table.c | 159 - glcpp/hash_table.h | 125 - glcpp/main/imports.h | 6 - glcpp/main/simple_list.h | 235 - glcpp/pp.c | 155 - glcpp/tests/000-content-with-spaces.c | 1 - glcpp/tests/000-content-with-spaces.c.expected | 2 - glcpp/tests/001-define.c | 2 - glcpp/tests/001-define.c.expected | 3 - glcpp/tests/002-define-chain.c | 3 - glcpp/tests/002-define-chain.c.expected | 4 - glcpp/tests/003-define-chain-reverse.c | 3 - glcpp/tests/003-define-chain-reverse.c.expected | 4 - glcpp/tests/004-define-recursive.c | 6 - glcpp/tests/004-define-recursive.c.expected | 7 - glcpp/tests/005-define-composite-chain.c | 3 - glcpp/tests/005-define-composite-chain.c.expected | 4 - glcpp/tests/006-define-composite-chain-reverse.c | 3 - .../006-define-composite-chain-reverse.c.expected | 4 - glcpp/tests/007-define-composite-recursive.c | 6 - .../007-define-composite-recursive.c.expected | 7 - glcpp/tests/008-define-empty.c | 2 - glcpp/tests/008-define-empty.c.expected | 3 - glcpp/tests/009-undef.c | 4 - glcpp/tests/009-undef.c.expected | 5 - glcpp/tests/010-undef-re-define.c | 6 - glcpp/tests/010-undef-re-define.c.expected | 7 - glcpp/tests/011-define-func-empty.c | 2 - glcpp/tests/011-define-func-empty.c.expected | 3 - glcpp/tests/012-define-func-no-args.c | 2 - glcpp/tests/012-define-func-no-args.c.expected | 3 - glcpp/tests/013-define-func-1-arg-unused.c | 2 - .../tests/013-define-func-1-arg-unused.c.expected | 3 - glcpp/tests/014-define-func-2-arg-unused.c | 2 - .../tests/014-define-func-2-arg-unused.c.expected | 3 - glcpp/tests/015-define-object-with-parens.c | 4 - .../tests/015-define-object-with-parens.c.expected | 5 - glcpp/tests/016-define-func-1-arg.c | 2 - glcpp/tests/016-define-func-1-arg.c.expected | 3 - glcpp/tests/017-define-func-2-args.c | 2 - glcpp/tests/017-define-func-2-args.c.expected | 3 - glcpp/tests/018-define-func-macro-as-parameter.c | 3 - .../018-define-func-macro-as-parameter.c.expected | 4 - glcpp/tests/019-define-func-1-arg-multi.c | 2 - glcpp/tests/019-define-func-1-arg-multi.c.expected | 3 - glcpp/tests/020-define-func-2-arg-multi.c | 2 - glcpp/tests/020-define-func-2-arg-multi.c.expected | 3 - glcpp/tests/021-define-func-compose.c | 3 - glcpp/tests/021-define-func-compose.c.expected | 4 - glcpp/tests/022-define-func-arg-with-parens.c | 2 - .../022-define-func-arg-with-parens.c.expected | 3 - glcpp/tests/023-define-extra-whitespace.c | 8 - glcpp/tests/023-define-extra-whitespace.c.expected | 9 - glcpp/tests/024-define-chain-to-self-recursion.c | 3 - .../024-define-chain-to-self-recursion.c.expected | 4 - glcpp/tests/025-func-macro-as-non-macro.c | 2 - glcpp/tests/025-func-macro-as-non-macro.c.expected | 3 - glcpp/tests/026-define-func-extra-newlines.c | 6 - .../026-define-func-extra-newlines.c.expected | 4 - glcpp/tests/027-define-chain-obj-to-func.c | 3 - .../tests/027-define-chain-obj-to-func.c.expected | 4 - glcpp/tests/028-define-chain-obj-to-non-func.c | 3 - .../028-define-chain-obj-to-non-func.c.expected | 4 - .../tests/029-define-chain-obj-to-func-with-args.c | 3 - ...9-define-chain-obj-to-func-with-args.c.expected | 4 - glcpp/tests/030-define-chain-obj-to-func-compose.c | 4 - ...030-define-chain-obj-to-func-compose.c.expected | 5 - .../tests/031-define-chain-func-to-func-compose.c | 4 - ...31-define-chain-func-to-func-compose.c.expected | 5 - glcpp/tests/032-define-func-self-recurse.c | 2 - .../tests/032-define-func-self-recurse.c.expected | 3 - glcpp/tests/033-define-func-self-compose.c | 2 - .../tests/033-define-func-self-compose.c.expected | 3 - .../tests/034-define-func-self-compose-non-func.c | 2 - ...34-define-func-self-compose-non-func.c.expected | 3 - ...nc-self-compose-non-func-multi-token-argument.c | 2 - ...ompose-non-func-multi-token-argument.c.expected | 3 - ...36-define-func-non-macro-multi-token-argument.c | 3 - ...-func-non-macro-multi-token-argument.c.expected | 4 - glcpp/tests/037-finalize-unexpanded-macro.c | 3 - .../tests/037-finalize-unexpanded-macro.c.expected | 4 - glcpp/tests/038-func-arg-with-commas.c | 2 - glcpp/tests/038-func-arg-with-commas.c.expected | 3 - glcpp/tests/039-func-arg-obj-macro-with-comma.c | 3 - .../039-func-arg-obj-macro-with-comma.c.expected | 4 - glcpp/tests/040-token-pasting.c | 2 - glcpp/tests/040-token-pasting.c.expected | 3 - glcpp/tests/041-if-0.c | 5 - glcpp/tests/041-if-0.c.expected | 6 - glcpp/tests/042-if-1.c | 5 - glcpp/tests/042-if-1.c.expected | 6 - glcpp/tests/043-if-0-else.c | 7 - glcpp/tests/043-if-0-else.c.expected | 8 - glcpp/tests/044-if-1-else.c | 7 - glcpp/tests/044-if-1-else.c.expected | 8 - glcpp/tests/045-if-0-elif.c | 11 - glcpp/tests/045-if-0-elif.c.expected | 12 - glcpp/tests/046-if-1-elsif.c | 11 - glcpp/tests/046-if-1-elsif.c.expected | 12 - glcpp/tests/047-if-elif-else.c | 11 - glcpp/tests/047-if-elif-else.c.expected | 12 - glcpp/tests/048-if-nested.c | 11 - glcpp/tests/048-if-nested.c.expected | 12 - glcpp/tests/049-if-expression-precedence.c | 5 - .../tests/049-if-expression-precedence.c.expected | 6 - glcpp/tests/050-if-defined.c | 17 - glcpp/tests/050-if-defined.c.expected | 18 - glcpp/tests/051-if-relational.c | 35 - glcpp/tests/051-if-relational.c.expected | 36 - glcpp/tests/052-if-bitwise.c | 20 - glcpp/tests/052-if-bitwise.c.expected | 21 - glcpp/tests/053-if-divide-and-shift.c | 15 - glcpp/tests/053-if-divide-and-shift.c.expected | 16 - glcpp/tests/054-if-with-macros.c | 34 - glcpp/tests/054-if-with-macros.c.expected | 35 - .../055-define-chain-obj-to-func-parens-in-text.c | 3 - ...ine-chain-obj-to-func-parens-in-text.c.expected | 4 - glcpp/tests/056-macro-argument-with-comma.c | 4 - .../tests/056-macro-argument-with-comma.c.expected | 5 - glcpp/tests/057-empty-arguments.c | 6 - glcpp/tests/057-empty-arguments.c.expected | 7 - glcpp/tests/058-token-pasting-empty-arguments.c | 5 - .../058-token-pasting-empty-arguments.c.expected | 6 - glcpp/tests/059-token-pasting-integer.c | 4 - glcpp/tests/059-token-pasting-integer.c.expected | 5 - .../060-left-paren-in-macro-right-paren-in-text.c | 3 - ...t-paren-in-macro-right-paren-in-text.c.expected | 4 - glcpp/tests/061-define-chain-obj-to-func-multi.c | 5 - .../061-define-chain-obj-to-func-multi.c.expected | 6 - glcpp/tests/062-if-0-skips-garbage.c | 5 - glcpp/tests/062-if-0-skips-garbage.c.expected | 6 - glcpp/tests/063-comments.c | 20 - glcpp/tests/063-comments.c.expected | 14 - glcpp/tests/064-version.c | 2 - glcpp/tests/064-version.c.expected | 3 - glcpp/tests/065-if-defined-parens.c | 17 - glcpp/tests/065-if-defined-parens.c.expected | 18 - glcpp/tests/071-punctuator.c | 1 - glcpp/tests/071-punctuator.c.expected | 2 - glcpp/tests/072-token-pasting-same-line.c | 2 - glcpp/tests/072-token-pasting-same-line.c.expected | 3 - glcpp/tests/099-c99-example.c | 17 - glcpp/tests/099-c99-example.c.expected | 17 - glcpp/tests/glcpp-test | 7 - glcpp/xtalloc.c | 99 - glsl_lexer.lpp | 336 -- glsl_parser.ypp | 1444 ------ glsl_parser_extras.cpp | 621 --- glsl_parser_extras.h | 139 - glsl_symbol_table.h | 163 - glsl_types.cpp | 773 --- glsl_types.h | 445 -- hash_table.c | 159 - hash_table.h | 125 - hir_field_selection.cpp | 81 - ir.cpp | 818 ---- ir.h | 1178 ----- ir_basic_block.cpp | 144 - ir_basic_block.h | 28 - ir_clone.cpp | 287 -- ir_constant_expression.cpp | 671 --- ir_constant_folding.cpp | 229 - ir_constant_variable.cpp | 156 - ir_copy_propagation.cpp | 256 - ir_dead_code.cpp | 219 - ir_dead_code_local.cpp | 223 - ir_expression_flattening.cpp | 172 - ir_expression_flattening.h | 38 - ir_function.cpp | 225 - ir_function_can_inline.cpp | 71 - ir_function_inlining.cpp | 272 -- ir_function_inlining.h | 30 - ir_hierarchical_visitor.cpp | 284 -- ir_hierarchical_visitor.h | 162 - ir_hv_accept.cpp | 348 -- ir_if_simplification.cpp | 84 - ir_optimization.h | 41 - ir_print_visitor.cpp | 373 -- ir_print_visitor.h | 81 - ir_reader.cpp | 1053 ---- ir_reader.h | 34 - ir_swizzle_swizzle.cpp | 93 - ir_to_mesa.cpp | 1211 ----- ir_validate.cpp | 104 - ir_variable.cpp | 345 -- ir_vec_index_to_swizzle.cpp | 158 - ir_visitor.h | 66 - linker.cpp | 871 ---- list.h | 403 -- main.cpp | 256 - main/imports.h | 6 - main/mtypes.h | 270 -- main/simple_list.h | 235 - mesa/shader/prog_instruction.c | 363 -- mesa/shader/prog_instruction.h | 437 -- mesa/shader/prog_print.c | 1089 ----- mesa/shader/prog_print.h | 98 - program.h | 155 - s_expression.cpp | 131 - s_expression.h | 142 - src/glsl/.dir-locals.el | 3 + src/glsl/.gitignore | 25 + src/glsl/Makefile.am | 79 + src/glsl/TODO | 84 + src/glsl/ast.h | 651 +++ src/glsl/ast_expr.cpp | 96 + src/glsl/ast_function.cpp | 751 +++ src/glsl/ast_to_hir.cpp | 2453 ++++++++++ src/glsl/ast_type.cpp | 110 + src/glsl/autogen.sh | 12 + src/glsl/builtin_function.cpp | 5080 ++++++++++++++++++++ src/glsl/builtin_types.h | 268 ++ src/glsl/builtin_variables.h | 93 + src/glsl/builtins/110/abs | 21 + src/glsl/builtins/110/all | 16 + src/glsl/builtins/110/any | 16 + src/glsl/builtins/110/asin | 112 + src/glsl/builtins/110/atan | 154 + src/glsl/builtins/110/ceil | 21 + src/glsl/builtins/110/clamp | 62 + src/glsl/builtins/110/cos | 21 + src/glsl/builtins/110/cross | 17 + src/glsl/builtins/110/degrees | 21 + src/glsl/builtins/110/distance | 33 + src/glsl/builtins/110/dot | 25 + src/glsl/builtins/110/equal | 61 + src/glsl/builtins/110/exp | 21 + src/glsl/builtins/110/exp2 | 21 + src/glsl/builtins/110/faceforward | 37 + src/glsl/builtins/110/floor | 21 + src/glsl/builtins/110/fract | 34 + src/glsl/builtins/110/greaterThan | 61 + src/glsl/builtins/110/greaterThanEqual | 61 + src/glsl/builtins/110/inversesqrt | 21 + src/glsl/builtins/110/length | 21 + src/glsl/builtins/110/lessThan | 61 + src/glsl/builtins/110/lessThanEqual | 61 + src/glsl/builtins/110/log | 21 + src/glsl/builtins/110/log2 | 21 + src/glsl/builtins/110/matrixCompMult | 32 + src/glsl/builtins/110/max | 64 + src/glsl/builtins/110/min | 64 + src/glsl/builtins/110/mix | 50 + src/glsl/builtins/110/mod | 64 + src/glsl/builtins/110/noise_fake | 76 + src/glsl/builtins/110/normalize | 21 + src/glsl/builtins/110/not | 16 + src/glsl/builtins/110/notEqual | 61 + src/glsl/builtins/110/pow | 25 + src/glsl/builtins/110/radians | 21 + src/glsl/builtins/110/reflect | 58 + src/glsl/builtins/110/refract | 102 + src/glsl/builtins/110/sign | 34 + src/glsl/builtins/110/sin | 21 + src/glsl/builtins/110/smoothstep | 224 + src/glsl/builtins/110/sqrt | 21 + src/glsl/builtins/110/step | 68 + src/glsl/builtins/110/tan | 21 + src/glsl/builtins/110/textures | 213 + src/glsl/builtins/110_fs/derivatives | 73 + src/glsl/builtins/110_fs/textures | 113 + src/glsl/builtins/110_vs/ftransform | 7 + src/glsl/builtins/120/matrixCompMult | 61 + src/glsl/builtins/120/outerProduct | 92 + src/glsl/builtins/120/transpose | 139 + src/glsl/builtins/130/clamp | 123 + src/glsl/builtins/130/cosh | 30 + src/glsl/builtins/130/equal | 31 + src/glsl/builtins/130/greaterThan | 31 + src/glsl/builtins/130/greaterThanEqual | 31 + src/glsl/builtins/130/lessThan | 31 + src/glsl/builtins/130/lessThanEqual | 31 + src/glsl/builtins/130/max | 127 + src/glsl/builtins/130/min | 127 + src/glsl/builtins/130/notEqual | 31 + src/glsl/builtins/130/sign | 34 + src/glsl/builtins/130/sinh | 30 + src/glsl/builtins/130/tanh | 42 + src/glsl/builtins/130/texelFetch | 107 + src/glsl/builtins/130/texture | 110 + src/glsl/builtins/130/textureGrad | 147 + src/glsl/builtins/130/textureLod | 128 + src/glsl/builtins/130/textureProj | 92 + src/glsl/builtins/130/textureProjGrad | 122 + src/glsl/builtins/130/textureProjLod | 107 + src/glsl/builtins/130_fs/texture | 128 + src/glsl/builtins/130_fs/textureProj | 107 + src/glsl/builtins/ARB_texture_rectangle/textures | 16 + src/glsl/builtins/EXT_texture_array/textures | 59 + src/glsl/builtins/EXT_texture_array_fs/textures | 27 + src/glsl/builtins/tools/generate_builtins.pl | 123 + .../builtins/tools/generate_matrixCompMultGLSL.py | 28 + .../builtins/tools/generate_outerProductGLSL.py | 23 + src/glsl/builtins/tools/generate_transposeGLSL.py | 28 + src/glsl/builtins/tools/texture_builtins.py | 298 ++ src/glsl/configure.ac | 69 + src/glsl/glcpp/.gitignore | 11 + src/glsl/glcpp/Makefile.am | 46 + src/glsl/glcpp/README | 30 + src/glsl/glcpp/glcpp-lex.l | 257 + src/glsl/glcpp/glcpp-parse.y | 1611 +++++++ src/glsl/glcpp/glcpp.c | 88 + src/glsl/glcpp/glcpp.h | 224 + src/glsl/glcpp/hash_table.c | 159 + src/glsl/glcpp/hash_table.h | 125 + src/glsl/glcpp/main/imports.h | 6 + src/glsl/glcpp/main/simple_list.h | 235 + src/glsl/glcpp/pp.c | 155 + src/glsl/glcpp/tests/000-content-with-spaces.c | 1 + .../glcpp/tests/000-content-with-spaces.c.expected | 2 + src/glsl/glcpp/tests/001-define.c | 2 + src/glsl/glcpp/tests/001-define.c.expected | 3 + src/glsl/glcpp/tests/002-define-chain.c | 3 + src/glsl/glcpp/tests/002-define-chain.c.expected | 4 + src/glsl/glcpp/tests/003-define-chain-reverse.c | 3 + .../tests/003-define-chain-reverse.c.expected | 4 + src/glsl/glcpp/tests/004-define-recursive.c | 6 + .../glcpp/tests/004-define-recursive.c.expected | 7 + src/glsl/glcpp/tests/005-define-composite-chain.c | 3 + .../tests/005-define-composite-chain.c.expected | 4 + .../tests/006-define-composite-chain-reverse.c | 3 + .../006-define-composite-chain-reverse.c.expected | 4 + .../glcpp/tests/007-define-composite-recursive.c | 6 + .../007-define-composite-recursive.c.expected | 7 + src/glsl/glcpp/tests/008-define-empty.c | 2 + src/glsl/glcpp/tests/008-define-empty.c.expected | 3 + src/glsl/glcpp/tests/009-undef.c | 4 + src/glsl/glcpp/tests/009-undef.c.expected | 5 + src/glsl/glcpp/tests/010-undef-re-define.c | 6 + .../glcpp/tests/010-undef-re-define.c.expected | 7 + src/glsl/glcpp/tests/011-define-func-empty.c | 2 + .../glcpp/tests/011-define-func-empty.c.expected | 3 + src/glsl/glcpp/tests/012-define-func-no-args.c | 2 + .../glcpp/tests/012-define-func-no-args.c.expected | 3 + .../glcpp/tests/013-define-func-1-arg-unused.c | 2 + .../tests/013-define-func-1-arg-unused.c.expected | 3 + .../glcpp/tests/014-define-func-2-arg-unused.c | 2 + .../tests/014-define-func-2-arg-unused.c.expected | 3 + .../glcpp/tests/015-define-object-with-parens.c | 4 + .../tests/015-define-object-with-parens.c.expected | 5 + src/glsl/glcpp/tests/016-define-func-1-arg.c | 2 + .../glcpp/tests/016-define-func-1-arg.c.expected | 3 + src/glsl/glcpp/tests/017-define-func-2-args.c | 2 + .../glcpp/tests/017-define-func-2-args.c.expected | 3 + .../tests/018-define-func-macro-as-parameter.c | 3 + .../018-define-func-macro-as-parameter.c.expected | 4 + src/glsl/glcpp/tests/019-define-func-1-arg-multi.c | 2 + .../tests/019-define-func-1-arg-multi.c.expected | 3 + src/glsl/glcpp/tests/020-define-func-2-arg-multi.c | 2 + .../tests/020-define-func-2-arg-multi.c.expected | 3 + src/glsl/glcpp/tests/021-define-func-compose.c | 3 + .../glcpp/tests/021-define-func-compose.c.expected | 4 + .../glcpp/tests/022-define-func-arg-with-parens.c | 2 + .../022-define-func-arg-with-parens.c.expected | 3 + src/glsl/glcpp/tests/023-define-extra-whitespace.c | 8 + .../tests/023-define-extra-whitespace.c.expected | 9 + .../tests/024-define-chain-to-self-recursion.c | 3 + .../024-define-chain-to-self-recursion.c.expected | 4 + src/glsl/glcpp/tests/025-func-macro-as-non-macro.c | 2 + .../tests/025-func-macro-as-non-macro.c.expected | 3 + .../glcpp/tests/026-define-func-extra-newlines.c | 6 + .../026-define-func-extra-newlines.c.expected | 4 + .../glcpp/tests/027-define-chain-obj-to-func.c | 3 + .../tests/027-define-chain-obj-to-func.c.expected | 4 + .../glcpp/tests/028-define-chain-obj-to-non-func.c | 3 + .../028-define-chain-obj-to-non-func.c.expected | 4 + .../tests/029-define-chain-obj-to-func-with-args.c | 3 + ...9-define-chain-obj-to-func-with-args.c.expected | 4 + .../tests/030-define-chain-obj-to-func-compose.c | 4 + ...030-define-chain-obj-to-func-compose.c.expected | 5 + .../tests/031-define-chain-func-to-func-compose.c | 4 + ...31-define-chain-func-to-func-compose.c.expected | 5 + .../glcpp/tests/032-define-func-self-recurse.c | 2 + .../tests/032-define-func-self-recurse.c.expected | 3 + .../glcpp/tests/033-define-func-self-compose.c | 2 + .../tests/033-define-func-self-compose.c.expected | 3 + .../tests/034-define-func-self-compose-non-func.c | 2 + ...34-define-func-self-compose-non-func.c.expected | 3 + ...nc-self-compose-non-func-multi-token-argument.c | 2 + ...ompose-non-func-multi-token-argument.c.expected | 3 + ...36-define-func-non-macro-multi-token-argument.c | 3 + ...-func-non-macro-multi-token-argument.c.expected | 4 + .../glcpp/tests/037-finalize-unexpanded-macro.c | 3 + .../tests/037-finalize-unexpanded-macro.c.expected | 4 + src/glsl/glcpp/tests/038-func-arg-with-commas.c | 2 + .../tests/038-func-arg-with-commas.c.expected | 3 + .../tests/039-func-arg-obj-macro-with-comma.c | 3 + .../039-func-arg-obj-macro-with-comma.c.expected | 4 + src/glsl/glcpp/tests/040-token-pasting.c | 2 + src/glsl/glcpp/tests/040-token-pasting.c.expected | 3 + src/glsl/glcpp/tests/041-if-0.c | 5 + src/glsl/glcpp/tests/041-if-0.c.expected | 6 + src/glsl/glcpp/tests/042-if-1.c | 5 + src/glsl/glcpp/tests/042-if-1.c.expected | 6 + src/glsl/glcpp/tests/043-if-0-else.c | 7 + src/glsl/glcpp/tests/043-if-0-else.c.expected | 8 + src/glsl/glcpp/tests/044-if-1-else.c | 7 + src/glsl/glcpp/tests/044-if-1-else.c.expected | 8 + src/glsl/glcpp/tests/045-if-0-elif.c | 11 + src/glsl/glcpp/tests/045-if-0-elif.c.expected | 12 + src/glsl/glcpp/tests/046-if-1-elsif.c | 11 + src/glsl/glcpp/tests/046-if-1-elsif.c.expected | 12 + src/glsl/glcpp/tests/047-if-elif-else.c | 11 + src/glsl/glcpp/tests/047-if-elif-else.c.expected | 12 + src/glsl/glcpp/tests/048-if-nested.c | 11 + src/glsl/glcpp/tests/048-if-nested.c.expected | 12 + .../glcpp/tests/049-if-expression-precedence.c | 5 + .../tests/049-if-expression-precedence.c.expected | 6 + src/glsl/glcpp/tests/050-if-defined.c | 17 + src/glsl/glcpp/tests/050-if-defined.c.expected | 18 + src/glsl/glcpp/tests/051-if-relational.c | 35 + src/glsl/glcpp/tests/051-if-relational.c.expected | 36 + src/glsl/glcpp/tests/052-if-bitwise.c | 20 + src/glsl/glcpp/tests/052-if-bitwise.c.expected | 21 + src/glsl/glcpp/tests/053-if-divide-and-shift.c | 15 + .../glcpp/tests/053-if-divide-and-shift.c.expected | 16 + src/glsl/glcpp/tests/054-if-with-macros.c | 34 + src/glsl/glcpp/tests/054-if-with-macros.c.expected | 35 + .../055-define-chain-obj-to-func-parens-in-text.c | 3 + ...ine-chain-obj-to-func-parens-in-text.c.expected | 4 + .../glcpp/tests/056-macro-argument-with-comma.c | 4 + .../tests/056-macro-argument-with-comma.c.expected | 5 + src/glsl/glcpp/tests/057-empty-arguments.c | 6 + .../glcpp/tests/057-empty-arguments.c.expected | 7 + .../tests/058-token-pasting-empty-arguments.c | 5 + .../058-token-pasting-empty-arguments.c.expected | 6 + src/glsl/glcpp/tests/059-token-pasting-integer.c | 4 + .../tests/059-token-pasting-integer.c.expected | 5 + .../060-left-paren-in-macro-right-paren-in-text.c | 3 + ...t-paren-in-macro-right-paren-in-text.c.expected | 4 + .../tests/061-define-chain-obj-to-func-multi.c | 5 + .../061-define-chain-obj-to-func-multi.c.expected | 6 + src/glsl/glcpp/tests/062-if-0-skips-garbage.c | 5 + .../glcpp/tests/062-if-0-skips-garbage.c.expected | 6 + src/glsl/glcpp/tests/063-comments.c | 20 + src/glsl/glcpp/tests/063-comments.c.expected | 14 + src/glsl/glcpp/tests/064-version.c | 2 + src/glsl/glcpp/tests/064-version.c.expected | 3 + src/glsl/glcpp/tests/065-if-defined-parens.c | 17 + .../glcpp/tests/065-if-defined-parens.c.expected | 18 + src/glsl/glcpp/tests/071-punctuator.c | 1 + src/glsl/glcpp/tests/071-punctuator.c.expected | 2 + src/glsl/glcpp/tests/072-token-pasting-same-line.c | 2 + .../tests/072-token-pasting-same-line.c.expected | 3 + src/glsl/glcpp/tests/099-c99-example.c | 17 + src/glsl/glcpp/tests/099-c99-example.c.expected | 17 + src/glsl/glcpp/tests/glcpp-test | 7 + src/glsl/glcpp/xtalloc.c | 99 + src/glsl/glsl_lexer.lpp | 336 ++ src/glsl/glsl_parser.ypp | 1444 ++++++ src/glsl/glsl_parser_extras.cpp | 621 +++ src/glsl/glsl_parser_extras.h | 139 + src/glsl/glsl_symbol_table.h | 163 + src/glsl/glsl_types.cpp | 773 +++ src/glsl/glsl_types.h | 445 ++ src/glsl/hash_table.c | 159 + src/glsl/hash_table.h | 125 + src/glsl/hir_field_selection.cpp | 81 + src/glsl/ir.cpp | 818 ++++ src/glsl/ir.h | 1178 +++++ src/glsl/ir_basic_block.cpp | 144 + src/glsl/ir_basic_block.h | 28 + src/glsl/ir_clone.cpp | 287 ++ src/glsl/ir_constant_expression.cpp | 671 +++ src/glsl/ir_constant_folding.cpp | 229 + src/glsl/ir_constant_variable.cpp | 156 + src/glsl/ir_copy_propagation.cpp | 256 + src/glsl/ir_dead_code.cpp | 219 + src/glsl/ir_dead_code_local.cpp | 223 + src/glsl/ir_expression_flattening.cpp | 172 + src/glsl/ir_expression_flattening.h | 38 + src/glsl/ir_function.cpp | 225 + src/glsl/ir_function_can_inline.cpp | 71 + src/glsl/ir_function_inlining.cpp | 272 ++ src/glsl/ir_function_inlining.h | 30 + src/glsl/ir_hierarchical_visitor.cpp | 284 ++ src/glsl/ir_hierarchical_visitor.h | 162 + src/glsl/ir_hv_accept.cpp | 348 ++ src/glsl/ir_if_simplification.cpp | 84 + src/glsl/ir_optimization.h | 41 + src/glsl/ir_print_visitor.cpp | 373 ++ src/glsl/ir_print_visitor.h | 81 + src/glsl/ir_reader.cpp | 1053 ++++ src/glsl/ir_reader.h | 34 + src/glsl/ir_swizzle_swizzle.cpp | 93 + src/glsl/ir_to_mesa.cpp | 1211 +++++ src/glsl/ir_validate.cpp | 104 + src/glsl/ir_variable.cpp | 345 ++ src/glsl/ir_vec_index_to_swizzle.cpp | 158 + src/glsl/ir_visitor.h | 66 + src/glsl/linker.cpp | 871 ++++ src/glsl/list.h | 403 ++ src/glsl/main.cpp | 256 + src/glsl/main/imports.h | 6 + src/glsl/main/mtypes.h | 270 ++ src/glsl/main/simple_list.h | 235 + src/glsl/mesa/shader/prog_instruction.c | 363 ++ src/glsl/mesa/shader/prog_instruction.h | 437 ++ src/glsl/mesa/shader/prog_print.c | 1089 +++++ src/glsl/mesa/shader/prog_print.h | 98 + src/glsl/program.h | 155 + src/glsl/s_expression.cpp | 131 + src/glsl/s_expression.h | 142 + src/glsl/symbol_table.c | 413 ++ src/glsl/symbol_table.h | 66 + src/glsl/tests/array-01.glsl | 3 + src/glsl/tests/array-02.glsl | 3 + src/glsl/tests/array-03.glsl | 3 + src/glsl/tests/array-04.glsl | 2 + src/glsl/tests/array-05.glsl | 2 + src/glsl/tests/array-06.glsl | 2 + src/glsl/tests/array-07.glsl | 2 + src/glsl/tests/array-08.glsl | 2 + src/glsl/tests/array-09.glsl | 9 + src/glsl/tests/array-10.glsl | 11 + src/glsl/tests/array-11.glsl | 9 + src/glsl/tests/array-12.glsl | 11 + src/glsl/tests/array-13.glsl | 11 + src/glsl/tests/attribute-01.glsl | 7 + src/glsl/tests/attribute-02.glsl | 7 + src/glsl/tests/attribute-03.glsl | 7 + src/glsl/tests/attribute-04.glsl | 7 + src/glsl/tests/attribute-05.glsl | 7 + src/glsl/tests/attribute-06.glsl | 7 + src/glsl/tests/attribute-07.glsl | 7 + src/glsl/tests/attribute-08.glsl | 7 + src/glsl/tests/attribute-09.glsl | 7 + src/glsl/tests/attribute-10.glsl | 8 + src/glsl/tests/attribute-11.glsl | 8 + src/glsl/tests/condition-01.glsl | 8 + src/glsl/tests/condition-02.glsl | 8 + src/glsl/tests/condition-03.glsl | 8 + src/glsl/tests/condition-04.glsl | 8 + src/glsl/tests/condition-05.glsl | 13 + src/glsl/tests/constructor-01.glsl | 6 + src/glsl/tests/constructor-02.glsl | 7 + src/glsl/tests/constructor-03.glsl | 12 + src/glsl/tests/constructor-04.glsl | 14 + src/glsl/tests/constructor-05.glsl | 13 + src/glsl/tests/constructor-06.glsl | 13 + src/glsl/tests/constructor-07.glsl | 13 + src/glsl/tests/constructor-08.glsl | 13 + src/glsl/tests/constructor-09.glsl | 26 + src/glsl/tests/function-01.glsl | 16 + src/glsl/tests/function-02.glsl | 16 + src/glsl/tests/function-03.glsl | 16 + src/glsl/tests/function-04.glsl | 15 + src/glsl/tests/function-05.glsl | 26 + src/glsl/tests/if-01.glsl | 11 + src/glsl/tests/if-02.glsl | 11 + src/glsl/tests/if-03.glsl | 11 + src/glsl/tests/if-04.glsl | 11 + src/glsl/tests/matrix-01.glsl | 6 + src/glsl/tests/matrix-02.glsl | 6 + src/glsl/tests/matrix-03.glsl | 6 + src/glsl/tests/matrix-04.glsl | 6 + src/glsl/tests/matrix-05.glsl | 6 + src/glsl/tests/matrix-06.glsl | 6 + src/glsl/tests/matrix-07.glsl | 27 + src/glsl/tests/matrix-08.glsl | 19 + src/glsl/tests/matrix-09.glsl | 11 + src/glsl/tests/matrix-10.glsl | 12 + src/glsl/tests/parameters-01.glsl | 11 + src/glsl/tests/parameters-02.glsl | 11 + src/glsl/tests/parameters-03.glsl | 9 + src/glsl/tests/qualifier-01.glsl | 3 + src/glsl/tests/qualifier-02.glsl | 2 + src/glsl/tests/qualifier-03.glsl | 2 + src/glsl/tests/qualifier-04.glsl | 3 + src/glsl/tests/qualifier-05.glsl | 3 + src/glsl/tests/qualifier-06.glsl | 7 + src/glsl/tests/qualifier-07.glsl | 7 + src/glsl/tests/swiz-01.glsl | 11 + src/glsl/tests/swiz-02.glsl | 11 + src/glsl/tests/void-01.glsl | 2 + symbol_table.c | 413 -- symbol_table.h | 66 - tests/array-01.glsl | 3 - tests/array-02.glsl | 3 - tests/array-03.glsl | 3 - tests/array-04.glsl | 2 - tests/array-05.glsl | 2 - tests/array-06.glsl | 2 - tests/array-07.glsl | 2 - tests/array-08.glsl | 2 - tests/array-09.glsl | 9 - tests/array-10.glsl | 11 - tests/array-11.glsl | 9 - tests/array-12.glsl | 11 - tests/array-13.glsl | 11 - tests/attribute-01.glsl | 7 - tests/attribute-02.glsl | 7 - tests/attribute-03.glsl | 7 - tests/attribute-04.glsl | 7 - tests/attribute-05.glsl | 7 - tests/attribute-06.glsl | 7 - tests/attribute-07.glsl | 7 - tests/attribute-08.glsl | 7 - tests/attribute-09.glsl | 7 - tests/attribute-10.glsl | 8 - tests/attribute-11.glsl | 8 - tests/condition-01.glsl | 8 - tests/condition-02.glsl | 8 - tests/condition-03.glsl | 8 - tests/condition-04.glsl | 8 - tests/condition-05.glsl | 13 - tests/constructor-01.glsl | 6 - tests/constructor-02.glsl | 7 - tests/constructor-03.glsl | 12 - tests/constructor-04.glsl | 14 - tests/constructor-05.glsl | 13 - tests/constructor-06.glsl | 13 - tests/constructor-07.glsl | 13 - tests/constructor-08.glsl | 13 - tests/constructor-09.glsl | 26 - tests/function-01.glsl | 16 - tests/function-02.glsl | 16 - tests/function-03.glsl | 16 - tests/function-04.glsl | 15 - tests/function-05.glsl | 26 - tests/if-01.glsl | 11 - tests/if-02.glsl | 11 - tests/if-03.glsl | 11 - tests/if-04.glsl | 11 - tests/matrix-01.glsl | 6 - tests/matrix-02.glsl | 6 - tests/matrix-03.glsl | 6 - tests/matrix-04.glsl | 6 - tests/matrix-05.glsl | 6 - tests/matrix-06.glsl | 6 - tests/matrix-07.glsl | 27 - tests/matrix-08.glsl | 19 - tests/matrix-09.glsl | 11 - tests/matrix-10.glsl | 12 - tests/parameters-01.glsl | 11 - tests/parameters-02.glsl | 11 - tests/parameters-03.glsl | 9 - tests/qualifier-01.glsl | 3 - tests/qualifier-02.glsl | 2 - tests/qualifier-03.glsl | 2 - tests/qualifier-04.glsl | 3 - tests/qualifier-05.glsl | 3 - tests/qualifier-06.glsl | 7 - tests/qualifier-07.glsl | 7 - tests/swiz-01.glsl | 11 - tests/swiz-02.glsl | 11 - tests/void-01.glsl | 2 - 750 files changed, 38147 insertions(+), 38147 deletions(-) delete mode 100644 .dir-locals.el delete mode 100644 .gitignore delete mode 100644 Makefile.am delete mode 100644 TODO delete mode 100644 ast.h delete mode 100644 ast_expr.cpp delete mode 100644 ast_function.cpp delete mode 100644 ast_to_hir.cpp delete mode 100644 ast_type.cpp delete mode 100755 autogen.sh delete mode 100644 builtin_function.cpp delete mode 100644 builtin_types.h delete mode 100644 builtin_variables.h delete mode 100644 builtins/110/abs delete mode 100644 builtins/110/all delete mode 100644 builtins/110/any delete mode 100644 builtins/110/asin delete mode 100644 builtins/110/atan delete mode 100644 builtins/110/ceil delete mode 100644 builtins/110/clamp delete mode 100644 builtins/110/cos delete mode 100644 builtins/110/cross delete mode 100644 builtins/110/degrees delete mode 100644 builtins/110/distance delete mode 100644 builtins/110/dot delete mode 100644 builtins/110/equal delete mode 100644 builtins/110/exp delete mode 100644 builtins/110/exp2 delete mode 100644 builtins/110/faceforward delete mode 100644 builtins/110/floor delete mode 100644 builtins/110/fract delete mode 100644 builtins/110/greaterThan delete mode 100644 builtins/110/greaterThanEqual delete mode 100644 builtins/110/inversesqrt delete mode 100644 builtins/110/length delete mode 100644 builtins/110/lessThan delete mode 100644 builtins/110/lessThanEqual delete mode 100644 builtins/110/log delete mode 100644 builtins/110/log2 delete mode 100644 builtins/110/matrixCompMult delete mode 100644 builtins/110/max delete mode 100644 builtins/110/min delete mode 100644 builtins/110/mix delete mode 100644 builtins/110/mod delete mode 100644 builtins/110/noise_fake delete mode 100644 builtins/110/normalize delete mode 100644 builtins/110/not delete mode 100644 builtins/110/notEqual delete mode 100644 builtins/110/pow delete mode 100644 builtins/110/radians delete mode 100644 builtins/110/reflect delete mode 100644 builtins/110/refract delete mode 100644 builtins/110/sign delete mode 100644 builtins/110/sin delete mode 100644 builtins/110/smoothstep delete mode 100644 builtins/110/sqrt delete mode 100644 builtins/110/step delete mode 100644 builtins/110/tan delete mode 100644 builtins/110/textures delete mode 100644 builtins/110_fs/derivatives delete mode 100644 builtins/110_fs/textures delete mode 100644 builtins/110_vs/ftransform delete mode 100644 builtins/120/matrixCompMult delete mode 100644 builtins/120/outerProduct delete mode 100644 builtins/120/transpose delete mode 100644 builtins/130/clamp delete mode 100644 builtins/130/cosh delete mode 100644 builtins/130/equal delete mode 100644 builtins/130/greaterThan delete mode 100644 builtins/130/greaterThanEqual delete mode 100644 builtins/130/lessThan delete mode 100644 builtins/130/lessThanEqual delete mode 100644 builtins/130/max delete mode 100644 builtins/130/min delete mode 100644 builtins/130/notEqual delete mode 100644 builtins/130/sign delete mode 100644 builtins/130/sinh delete mode 100644 builtins/130/tanh delete mode 100644 builtins/130/texelFetch delete mode 100644 builtins/130/texture delete mode 100644 builtins/130/textureGrad delete mode 100644 builtins/130/textureLod delete mode 100644 builtins/130/textureProj delete mode 100644 builtins/130/textureProjGrad delete mode 100644 builtins/130/textureProjLod delete mode 100644 builtins/130_fs/texture delete mode 100644 builtins/130_fs/textureProj delete mode 100644 builtins/ARB_texture_rectangle/textures delete mode 100644 builtins/EXT_texture_array/textures delete mode 100644 builtins/EXT_texture_array_fs/textures delete mode 100755 builtins/tools/generate_builtins.pl delete mode 100755 builtins/tools/generate_matrixCompMultGLSL.py delete mode 100755 builtins/tools/generate_outerProductGLSL.py delete mode 100755 builtins/tools/generate_transposeGLSL.py delete mode 100755 builtins/tools/texture_builtins.py delete mode 100644 configure.ac delete mode 100644 glcpp/.gitignore delete mode 100644 glcpp/Makefile.am delete mode 100644 glcpp/README delete mode 100644 glcpp/glcpp-lex.l delete mode 100644 glcpp/glcpp-parse.y delete mode 100644 glcpp/glcpp.c delete mode 100644 glcpp/glcpp.h delete mode 100644 glcpp/hash_table.c delete mode 100644 glcpp/hash_table.h delete mode 100644 glcpp/main/imports.h delete mode 100644 glcpp/main/simple_list.h delete mode 100644 glcpp/pp.c delete mode 100644 glcpp/tests/000-content-with-spaces.c delete mode 100644 glcpp/tests/000-content-with-spaces.c.expected delete mode 100644 glcpp/tests/001-define.c delete mode 100644 glcpp/tests/001-define.c.expected delete mode 100644 glcpp/tests/002-define-chain.c delete mode 100644 glcpp/tests/002-define-chain.c.expected delete mode 100644 glcpp/tests/003-define-chain-reverse.c delete mode 100644 glcpp/tests/003-define-chain-reverse.c.expected delete mode 100644 glcpp/tests/004-define-recursive.c delete mode 100644 glcpp/tests/004-define-recursive.c.expected delete mode 100644 glcpp/tests/005-define-composite-chain.c delete mode 100644 glcpp/tests/005-define-composite-chain.c.expected delete mode 100644 glcpp/tests/006-define-composite-chain-reverse.c delete mode 100644 glcpp/tests/006-define-composite-chain-reverse.c.expected delete mode 100644 glcpp/tests/007-define-composite-recursive.c delete mode 100644 glcpp/tests/007-define-composite-recursive.c.expected delete mode 100644 glcpp/tests/008-define-empty.c delete mode 100644 glcpp/tests/008-define-empty.c.expected delete mode 100644 glcpp/tests/009-undef.c delete mode 100644 glcpp/tests/009-undef.c.expected delete mode 100644 glcpp/tests/010-undef-re-define.c delete mode 100644 glcpp/tests/010-undef-re-define.c.expected delete mode 100644 glcpp/tests/011-define-func-empty.c delete mode 100644 glcpp/tests/011-define-func-empty.c.expected delete mode 100644 glcpp/tests/012-define-func-no-args.c delete mode 100644 glcpp/tests/012-define-func-no-args.c.expected delete mode 100644 glcpp/tests/013-define-func-1-arg-unused.c delete mode 100644 glcpp/tests/013-define-func-1-arg-unused.c.expected delete mode 100644 glcpp/tests/014-define-func-2-arg-unused.c delete mode 100644 glcpp/tests/014-define-func-2-arg-unused.c.expected delete mode 100644 glcpp/tests/015-define-object-with-parens.c delete mode 100644 glcpp/tests/015-define-object-with-parens.c.expected delete mode 100644 glcpp/tests/016-define-func-1-arg.c delete mode 100644 glcpp/tests/016-define-func-1-arg.c.expected delete mode 100644 glcpp/tests/017-define-func-2-args.c delete mode 100644 glcpp/tests/017-define-func-2-args.c.expected delete mode 100644 glcpp/tests/018-define-func-macro-as-parameter.c delete mode 100644 glcpp/tests/018-define-func-macro-as-parameter.c.expected delete mode 100644 glcpp/tests/019-define-func-1-arg-multi.c delete mode 100644 glcpp/tests/019-define-func-1-arg-multi.c.expected delete mode 100644 glcpp/tests/020-define-func-2-arg-multi.c delete mode 100644 glcpp/tests/020-define-func-2-arg-multi.c.expected delete mode 100644 glcpp/tests/021-define-func-compose.c delete mode 100644 glcpp/tests/021-define-func-compose.c.expected delete mode 100644 glcpp/tests/022-define-func-arg-with-parens.c delete mode 100644 glcpp/tests/022-define-func-arg-with-parens.c.expected delete mode 100644 glcpp/tests/023-define-extra-whitespace.c delete mode 100644 glcpp/tests/023-define-extra-whitespace.c.expected delete mode 100644 glcpp/tests/024-define-chain-to-self-recursion.c delete mode 100644 glcpp/tests/024-define-chain-to-self-recursion.c.expected delete mode 100644 glcpp/tests/025-func-macro-as-non-macro.c delete mode 100644 glcpp/tests/025-func-macro-as-non-macro.c.expected delete mode 100644 glcpp/tests/026-define-func-extra-newlines.c delete mode 100644 glcpp/tests/026-define-func-extra-newlines.c.expected delete mode 100644 glcpp/tests/027-define-chain-obj-to-func.c delete mode 100644 glcpp/tests/027-define-chain-obj-to-func.c.expected delete mode 100644 glcpp/tests/028-define-chain-obj-to-non-func.c delete mode 100644 glcpp/tests/028-define-chain-obj-to-non-func.c.expected delete mode 100644 glcpp/tests/029-define-chain-obj-to-func-with-args.c delete mode 100644 glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected delete mode 100644 glcpp/tests/030-define-chain-obj-to-func-compose.c delete mode 100644 glcpp/tests/030-define-chain-obj-to-func-compose.c.expected delete mode 100644 glcpp/tests/031-define-chain-func-to-func-compose.c delete mode 100644 glcpp/tests/031-define-chain-func-to-func-compose.c.expected delete mode 100644 glcpp/tests/032-define-func-self-recurse.c delete mode 100644 glcpp/tests/032-define-func-self-recurse.c.expected delete mode 100644 glcpp/tests/033-define-func-self-compose.c delete mode 100644 glcpp/tests/033-define-func-self-compose.c.expected delete mode 100644 glcpp/tests/034-define-func-self-compose-non-func.c delete mode 100644 glcpp/tests/034-define-func-self-compose-non-func.c.expected delete mode 100644 glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c delete mode 100644 glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected delete mode 100644 glcpp/tests/036-define-func-non-macro-multi-token-argument.c delete mode 100644 glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected delete mode 100644 glcpp/tests/037-finalize-unexpanded-macro.c delete mode 100644 glcpp/tests/037-finalize-unexpanded-macro.c.expected delete mode 100644 glcpp/tests/038-func-arg-with-commas.c delete mode 100644 glcpp/tests/038-func-arg-with-commas.c.expected delete mode 100644 glcpp/tests/039-func-arg-obj-macro-with-comma.c delete mode 100644 glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected delete mode 100644 glcpp/tests/040-token-pasting.c delete mode 100644 glcpp/tests/040-token-pasting.c.expected delete mode 100644 glcpp/tests/041-if-0.c delete mode 100644 glcpp/tests/041-if-0.c.expected delete mode 100644 glcpp/tests/042-if-1.c delete mode 100644 glcpp/tests/042-if-1.c.expected delete mode 100644 glcpp/tests/043-if-0-else.c delete mode 100644 glcpp/tests/043-if-0-else.c.expected delete mode 100644 glcpp/tests/044-if-1-else.c delete mode 100644 glcpp/tests/044-if-1-else.c.expected delete mode 100644 glcpp/tests/045-if-0-elif.c delete mode 100644 glcpp/tests/045-if-0-elif.c.expected delete mode 100644 glcpp/tests/046-if-1-elsif.c delete mode 100644 glcpp/tests/046-if-1-elsif.c.expected delete mode 100644 glcpp/tests/047-if-elif-else.c delete mode 100644 glcpp/tests/047-if-elif-else.c.expected delete mode 100644 glcpp/tests/048-if-nested.c delete mode 100644 glcpp/tests/048-if-nested.c.expected delete mode 100644 glcpp/tests/049-if-expression-precedence.c delete mode 100644 glcpp/tests/049-if-expression-precedence.c.expected delete mode 100644 glcpp/tests/050-if-defined.c delete mode 100644 glcpp/tests/050-if-defined.c.expected delete mode 100644 glcpp/tests/051-if-relational.c delete mode 100644 glcpp/tests/051-if-relational.c.expected delete mode 100644 glcpp/tests/052-if-bitwise.c delete mode 100644 glcpp/tests/052-if-bitwise.c.expected delete mode 100644 glcpp/tests/053-if-divide-and-shift.c delete mode 100644 glcpp/tests/053-if-divide-and-shift.c.expected delete mode 100644 glcpp/tests/054-if-with-macros.c delete mode 100644 glcpp/tests/054-if-with-macros.c.expected delete mode 100644 glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c delete mode 100644 glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected delete mode 100644 glcpp/tests/056-macro-argument-with-comma.c delete mode 100644 glcpp/tests/056-macro-argument-with-comma.c.expected delete mode 100644 glcpp/tests/057-empty-arguments.c delete mode 100644 glcpp/tests/057-empty-arguments.c.expected delete mode 100644 glcpp/tests/058-token-pasting-empty-arguments.c delete mode 100644 glcpp/tests/058-token-pasting-empty-arguments.c.expected delete mode 100644 glcpp/tests/059-token-pasting-integer.c delete mode 100644 glcpp/tests/059-token-pasting-integer.c.expected delete mode 100644 glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c delete mode 100644 glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected delete mode 100644 glcpp/tests/061-define-chain-obj-to-func-multi.c delete mode 100644 glcpp/tests/061-define-chain-obj-to-func-multi.c.expected delete mode 100644 glcpp/tests/062-if-0-skips-garbage.c delete mode 100644 glcpp/tests/062-if-0-skips-garbage.c.expected delete mode 100644 glcpp/tests/063-comments.c delete mode 100644 glcpp/tests/063-comments.c.expected delete mode 100644 glcpp/tests/064-version.c delete mode 100644 glcpp/tests/064-version.c.expected delete mode 100644 glcpp/tests/065-if-defined-parens.c delete mode 100644 glcpp/tests/065-if-defined-parens.c.expected delete mode 100644 glcpp/tests/071-punctuator.c delete mode 100644 glcpp/tests/071-punctuator.c.expected delete mode 100644 glcpp/tests/072-token-pasting-same-line.c delete mode 100644 glcpp/tests/072-token-pasting-same-line.c.expected delete mode 100644 glcpp/tests/099-c99-example.c delete mode 100644 glcpp/tests/099-c99-example.c.expected delete mode 100755 glcpp/tests/glcpp-test delete mode 100644 glcpp/xtalloc.c delete mode 100644 glsl_lexer.lpp delete mode 100644 glsl_parser.ypp delete mode 100644 glsl_parser_extras.cpp delete mode 100644 glsl_parser_extras.h delete mode 100644 glsl_symbol_table.h delete mode 100644 glsl_types.cpp delete mode 100644 glsl_types.h delete mode 100644 hash_table.c delete mode 100644 hash_table.h delete mode 100644 hir_field_selection.cpp delete mode 100644 ir.cpp delete mode 100644 ir.h delete mode 100644 ir_basic_block.cpp delete mode 100644 ir_basic_block.h delete mode 100644 ir_clone.cpp delete mode 100644 ir_constant_expression.cpp delete mode 100644 ir_constant_folding.cpp delete mode 100644 ir_constant_variable.cpp delete mode 100644 ir_copy_propagation.cpp delete mode 100644 ir_dead_code.cpp delete mode 100644 ir_dead_code_local.cpp delete mode 100644 ir_expression_flattening.cpp delete mode 100644 ir_expression_flattening.h delete mode 100644 ir_function.cpp delete mode 100644 ir_function_can_inline.cpp delete mode 100644 ir_function_inlining.cpp delete mode 100644 ir_function_inlining.h delete mode 100644 ir_hierarchical_visitor.cpp delete mode 100644 ir_hierarchical_visitor.h delete mode 100644 ir_hv_accept.cpp delete mode 100644 ir_if_simplification.cpp delete mode 100644 ir_optimization.h delete mode 100644 ir_print_visitor.cpp delete mode 100644 ir_print_visitor.h delete mode 100644 ir_reader.cpp delete mode 100644 ir_reader.h delete mode 100644 ir_swizzle_swizzle.cpp delete mode 100644 ir_to_mesa.cpp delete mode 100644 ir_validate.cpp delete mode 100644 ir_variable.cpp delete mode 100644 ir_vec_index_to_swizzle.cpp delete mode 100644 ir_visitor.h delete mode 100644 linker.cpp delete mode 100644 list.h delete mode 100644 main.cpp delete mode 100644 main/imports.h delete mode 100644 main/mtypes.h delete mode 100644 main/simple_list.h delete mode 100644 mesa/shader/prog_instruction.c delete mode 100644 mesa/shader/prog_instruction.h delete mode 100644 mesa/shader/prog_print.c delete mode 100644 mesa/shader/prog_print.h delete mode 100644 program.h delete mode 100644 s_expression.cpp delete mode 100644 s_expression.h create mode 100644 src/glsl/.dir-locals.el create mode 100644 src/glsl/.gitignore create mode 100644 src/glsl/Makefile.am create mode 100644 src/glsl/TODO create mode 100644 src/glsl/ast.h create mode 100644 src/glsl/ast_expr.cpp create mode 100644 src/glsl/ast_function.cpp create mode 100644 src/glsl/ast_to_hir.cpp create mode 100644 src/glsl/ast_type.cpp create mode 100755 src/glsl/autogen.sh create mode 100644 src/glsl/builtin_function.cpp create mode 100644 src/glsl/builtin_types.h create mode 100644 src/glsl/builtin_variables.h create mode 100644 src/glsl/builtins/110/abs create mode 100644 src/glsl/builtins/110/all create mode 100644 src/glsl/builtins/110/any create mode 100644 src/glsl/builtins/110/asin create mode 100644 src/glsl/builtins/110/atan create mode 100644 src/glsl/builtins/110/ceil create mode 100644 src/glsl/builtins/110/clamp create mode 100644 src/glsl/builtins/110/cos create mode 100644 src/glsl/builtins/110/cross create mode 100644 src/glsl/builtins/110/degrees create mode 100644 src/glsl/builtins/110/distance create mode 100644 src/glsl/builtins/110/dot create mode 100644 src/glsl/builtins/110/equal create mode 100644 src/glsl/builtins/110/exp create mode 100644 src/glsl/builtins/110/exp2 create mode 100644 src/glsl/builtins/110/faceforward create mode 100644 src/glsl/builtins/110/floor create mode 100644 src/glsl/builtins/110/fract create mode 100644 src/glsl/builtins/110/greaterThan create mode 100644 src/glsl/builtins/110/greaterThanEqual create mode 100644 src/glsl/builtins/110/inversesqrt create mode 100644 src/glsl/builtins/110/length create mode 100644 src/glsl/builtins/110/lessThan create mode 100644 src/glsl/builtins/110/lessThanEqual create mode 100644 src/glsl/builtins/110/log create mode 100644 src/glsl/builtins/110/log2 create mode 100644 src/glsl/builtins/110/matrixCompMult create mode 100644 src/glsl/builtins/110/max create mode 100644 src/glsl/builtins/110/min create mode 100644 src/glsl/builtins/110/mix create mode 100644 src/glsl/builtins/110/mod create mode 100644 src/glsl/builtins/110/noise_fake create mode 100644 src/glsl/builtins/110/normalize create mode 100644 src/glsl/builtins/110/not create mode 100644 src/glsl/builtins/110/notEqual create mode 100644 src/glsl/builtins/110/pow create mode 100644 src/glsl/builtins/110/radians create mode 100644 src/glsl/builtins/110/reflect create mode 100644 src/glsl/builtins/110/refract create mode 100644 src/glsl/builtins/110/sign create mode 100644 src/glsl/builtins/110/sin create mode 100644 src/glsl/builtins/110/smoothstep create mode 100644 src/glsl/builtins/110/sqrt create mode 100644 src/glsl/builtins/110/step create mode 100644 src/glsl/builtins/110/tan create mode 100644 src/glsl/builtins/110/textures create mode 100644 src/glsl/builtins/110_fs/derivatives create mode 100644 src/glsl/builtins/110_fs/textures create mode 100644 src/glsl/builtins/110_vs/ftransform create mode 100644 src/glsl/builtins/120/matrixCompMult create mode 100644 src/glsl/builtins/120/outerProduct create mode 100644 src/glsl/builtins/120/transpose create mode 100644 src/glsl/builtins/130/clamp create mode 100644 src/glsl/builtins/130/cosh create mode 100644 src/glsl/builtins/130/equal create mode 100644 src/glsl/builtins/130/greaterThan create mode 100644 src/glsl/builtins/130/greaterThanEqual create mode 100644 src/glsl/builtins/130/lessThan create mode 100644 src/glsl/builtins/130/lessThanEqual create mode 100644 src/glsl/builtins/130/max create mode 100644 src/glsl/builtins/130/min create mode 100644 src/glsl/builtins/130/notEqual create mode 100644 src/glsl/builtins/130/sign create mode 100644 src/glsl/builtins/130/sinh create mode 100644 src/glsl/builtins/130/tanh create mode 100644 src/glsl/builtins/130/texelFetch create mode 100644 src/glsl/builtins/130/texture create mode 100644 src/glsl/builtins/130/textureGrad create mode 100644 src/glsl/builtins/130/textureLod create mode 100644 src/glsl/builtins/130/textureProj create mode 100644 src/glsl/builtins/130/textureProjGrad create mode 100644 src/glsl/builtins/130/textureProjLod create mode 100644 src/glsl/builtins/130_fs/texture create mode 100644 src/glsl/builtins/130_fs/textureProj create mode 100644 src/glsl/builtins/ARB_texture_rectangle/textures create mode 100644 src/glsl/builtins/EXT_texture_array/textures create mode 100644 src/glsl/builtins/EXT_texture_array_fs/textures create mode 100755 src/glsl/builtins/tools/generate_builtins.pl create mode 100755 src/glsl/builtins/tools/generate_matrixCompMultGLSL.py create mode 100755 src/glsl/builtins/tools/generate_outerProductGLSL.py create mode 100755 src/glsl/builtins/tools/generate_transposeGLSL.py create mode 100755 src/glsl/builtins/tools/texture_builtins.py create mode 100644 src/glsl/configure.ac create mode 100644 src/glsl/glcpp/.gitignore create mode 100644 src/glsl/glcpp/Makefile.am create mode 100644 src/glsl/glcpp/README create mode 100644 src/glsl/glcpp/glcpp-lex.l create mode 100644 src/glsl/glcpp/glcpp-parse.y create mode 100644 src/glsl/glcpp/glcpp.c create mode 100644 src/glsl/glcpp/glcpp.h create mode 100644 src/glsl/glcpp/hash_table.c create mode 100644 src/glsl/glcpp/hash_table.h create mode 100644 src/glsl/glcpp/main/imports.h create mode 100644 src/glsl/glcpp/main/simple_list.h create mode 100644 src/glsl/glcpp/pp.c create mode 100644 src/glsl/glcpp/tests/000-content-with-spaces.c create mode 100644 src/glsl/glcpp/tests/000-content-with-spaces.c.expected create mode 100644 src/glsl/glcpp/tests/001-define.c create mode 100644 src/glsl/glcpp/tests/001-define.c.expected create mode 100644 src/glsl/glcpp/tests/002-define-chain.c create mode 100644 src/glsl/glcpp/tests/002-define-chain.c.expected create mode 100644 src/glsl/glcpp/tests/003-define-chain-reverse.c create mode 100644 src/glsl/glcpp/tests/003-define-chain-reverse.c.expected create mode 100644 src/glsl/glcpp/tests/004-define-recursive.c create mode 100644 src/glsl/glcpp/tests/004-define-recursive.c.expected create mode 100644 src/glsl/glcpp/tests/005-define-composite-chain.c create mode 100644 src/glsl/glcpp/tests/005-define-composite-chain.c.expected create mode 100644 src/glsl/glcpp/tests/006-define-composite-chain-reverse.c create mode 100644 src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected create mode 100644 src/glsl/glcpp/tests/007-define-composite-recursive.c create mode 100644 src/glsl/glcpp/tests/007-define-composite-recursive.c.expected create mode 100644 src/glsl/glcpp/tests/008-define-empty.c create mode 100644 src/glsl/glcpp/tests/008-define-empty.c.expected create mode 100644 src/glsl/glcpp/tests/009-undef.c create mode 100644 src/glsl/glcpp/tests/009-undef.c.expected create mode 100644 src/glsl/glcpp/tests/010-undef-re-define.c create mode 100644 src/glsl/glcpp/tests/010-undef-re-define.c.expected create mode 100644 src/glsl/glcpp/tests/011-define-func-empty.c create mode 100644 src/glsl/glcpp/tests/011-define-func-empty.c.expected create mode 100644 src/glsl/glcpp/tests/012-define-func-no-args.c create mode 100644 src/glsl/glcpp/tests/012-define-func-no-args.c.expected create mode 100644 src/glsl/glcpp/tests/013-define-func-1-arg-unused.c create mode 100644 src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected create mode 100644 src/glsl/glcpp/tests/014-define-func-2-arg-unused.c create mode 100644 src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected create mode 100644 src/glsl/glcpp/tests/015-define-object-with-parens.c create mode 100644 src/glsl/glcpp/tests/015-define-object-with-parens.c.expected create mode 100644 src/glsl/glcpp/tests/016-define-func-1-arg.c create mode 100644 src/glsl/glcpp/tests/016-define-func-1-arg.c.expected create mode 100644 src/glsl/glcpp/tests/017-define-func-2-args.c create mode 100644 src/glsl/glcpp/tests/017-define-func-2-args.c.expected create mode 100644 src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c create mode 100644 src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected create mode 100644 src/glsl/glcpp/tests/019-define-func-1-arg-multi.c create mode 100644 src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected create mode 100644 src/glsl/glcpp/tests/020-define-func-2-arg-multi.c create mode 100644 src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected create mode 100644 src/glsl/glcpp/tests/021-define-func-compose.c create mode 100644 src/glsl/glcpp/tests/021-define-func-compose.c.expected create mode 100644 src/glsl/glcpp/tests/022-define-func-arg-with-parens.c create mode 100644 src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected create mode 100644 src/glsl/glcpp/tests/023-define-extra-whitespace.c create mode 100644 src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected create mode 100644 src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c create mode 100644 src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected create mode 100644 src/glsl/glcpp/tests/025-func-macro-as-non-macro.c create mode 100644 src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected create mode 100644 src/glsl/glcpp/tests/026-define-func-extra-newlines.c create mode 100644 src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected create mode 100644 src/glsl/glcpp/tests/027-define-chain-obj-to-func.c create mode 100644 src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected create mode 100644 src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c create mode 100644 src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected create mode 100644 src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c create mode 100644 src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected create mode 100644 src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c create mode 100644 src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected create mode 100644 src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c create mode 100644 src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected create mode 100644 src/glsl/glcpp/tests/032-define-func-self-recurse.c create mode 100644 src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected create mode 100644 src/glsl/glcpp/tests/033-define-func-self-compose.c create mode 100644 src/glsl/glcpp/tests/033-define-func-self-compose.c.expected create mode 100644 src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c create mode 100644 src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected create mode 100644 src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c create mode 100644 src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected create mode 100644 src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c create mode 100644 src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected create mode 100644 src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c create mode 100644 src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected create mode 100644 src/glsl/glcpp/tests/038-func-arg-with-commas.c create mode 100644 src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected create mode 100644 src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c create mode 100644 src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected create mode 100644 src/glsl/glcpp/tests/040-token-pasting.c create mode 100644 src/glsl/glcpp/tests/040-token-pasting.c.expected create mode 100644 src/glsl/glcpp/tests/041-if-0.c create mode 100644 src/glsl/glcpp/tests/041-if-0.c.expected create mode 100644 src/glsl/glcpp/tests/042-if-1.c create mode 100644 src/glsl/glcpp/tests/042-if-1.c.expected create mode 100644 src/glsl/glcpp/tests/043-if-0-else.c create mode 100644 src/glsl/glcpp/tests/043-if-0-else.c.expected create mode 100644 src/glsl/glcpp/tests/044-if-1-else.c create mode 100644 src/glsl/glcpp/tests/044-if-1-else.c.expected create mode 100644 src/glsl/glcpp/tests/045-if-0-elif.c create mode 100644 src/glsl/glcpp/tests/045-if-0-elif.c.expected create mode 100644 src/glsl/glcpp/tests/046-if-1-elsif.c create mode 100644 src/glsl/glcpp/tests/046-if-1-elsif.c.expected create mode 100644 src/glsl/glcpp/tests/047-if-elif-else.c create mode 100644 src/glsl/glcpp/tests/047-if-elif-else.c.expected create mode 100644 src/glsl/glcpp/tests/048-if-nested.c create mode 100644 src/glsl/glcpp/tests/048-if-nested.c.expected create mode 100644 src/glsl/glcpp/tests/049-if-expression-precedence.c create mode 100644 src/glsl/glcpp/tests/049-if-expression-precedence.c.expected create mode 100644 src/glsl/glcpp/tests/050-if-defined.c create mode 100644 src/glsl/glcpp/tests/050-if-defined.c.expected create mode 100644 src/glsl/glcpp/tests/051-if-relational.c create mode 100644 src/glsl/glcpp/tests/051-if-relational.c.expected create mode 100644 src/glsl/glcpp/tests/052-if-bitwise.c create mode 100644 src/glsl/glcpp/tests/052-if-bitwise.c.expected create mode 100644 src/glsl/glcpp/tests/053-if-divide-and-shift.c create mode 100644 src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected create mode 100644 src/glsl/glcpp/tests/054-if-with-macros.c create mode 100644 src/glsl/glcpp/tests/054-if-with-macros.c.expected create mode 100644 src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c create mode 100644 src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected create mode 100644 src/glsl/glcpp/tests/056-macro-argument-with-comma.c create mode 100644 src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected create mode 100644 src/glsl/glcpp/tests/057-empty-arguments.c create mode 100644 src/glsl/glcpp/tests/057-empty-arguments.c.expected create mode 100644 src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c create mode 100644 src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected create mode 100644 src/glsl/glcpp/tests/059-token-pasting-integer.c create mode 100644 src/glsl/glcpp/tests/059-token-pasting-integer.c.expected create mode 100644 src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c create mode 100644 src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected create mode 100644 src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c create mode 100644 src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected create mode 100644 src/glsl/glcpp/tests/062-if-0-skips-garbage.c create mode 100644 src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected create mode 100644 src/glsl/glcpp/tests/063-comments.c create mode 100644 src/glsl/glcpp/tests/063-comments.c.expected create mode 100644 src/glsl/glcpp/tests/064-version.c create mode 100644 src/glsl/glcpp/tests/064-version.c.expected create mode 100644 src/glsl/glcpp/tests/065-if-defined-parens.c create mode 100644 src/glsl/glcpp/tests/065-if-defined-parens.c.expected create mode 100644 src/glsl/glcpp/tests/071-punctuator.c create mode 100644 src/glsl/glcpp/tests/071-punctuator.c.expected create mode 100644 src/glsl/glcpp/tests/072-token-pasting-same-line.c create mode 100644 src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected create mode 100644 src/glsl/glcpp/tests/099-c99-example.c create mode 100644 src/glsl/glcpp/tests/099-c99-example.c.expected create mode 100755 src/glsl/glcpp/tests/glcpp-test create mode 100644 src/glsl/glcpp/xtalloc.c create mode 100644 src/glsl/glsl_lexer.lpp create mode 100644 src/glsl/glsl_parser.ypp create mode 100644 src/glsl/glsl_parser_extras.cpp create mode 100644 src/glsl/glsl_parser_extras.h create mode 100644 src/glsl/glsl_symbol_table.h create mode 100644 src/glsl/glsl_types.cpp create mode 100644 src/glsl/glsl_types.h create mode 100644 src/glsl/hash_table.c create mode 100644 src/glsl/hash_table.h create mode 100644 src/glsl/hir_field_selection.cpp create mode 100644 src/glsl/ir.cpp create mode 100644 src/glsl/ir.h create mode 100644 src/glsl/ir_basic_block.cpp create mode 100644 src/glsl/ir_basic_block.h create mode 100644 src/glsl/ir_clone.cpp create mode 100644 src/glsl/ir_constant_expression.cpp create mode 100644 src/glsl/ir_constant_folding.cpp create mode 100644 src/glsl/ir_constant_variable.cpp create mode 100644 src/glsl/ir_copy_propagation.cpp create mode 100644 src/glsl/ir_dead_code.cpp create mode 100644 src/glsl/ir_dead_code_local.cpp create mode 100644 src/glsl/ir_expression_flattening.cpp create mode 100644 src/glsl/ir_expression_flattening.h create mode 100644 src/glsl/ir_function.cpp create mode 100644 src/glsl/ir_function_can_inline.cpp create mode 100644 src/glsl/ir_function_inlining.cpp create mode 100644 src/glsl/ir_function_inlining.h create mode 100644 src/glsl/ir_hierarchical_visitor.cpp create mode 100644 src/glsl/ir_hierarchical_visitor.h create mode 100644 src/glsl/ir_hv_accept.cpp create mode 100644 src/glsl/ir_if_simplification.cpp create mode 100644 src/glsl/ir_optimization.h create mode 100644 src/glsl/ir_print_visitor.cpp create mode 100644 src/glsl/ir_print_visitor.h create mode 100644 src/glsl/ir_reader.cpp create mode 100644 src/glsl/ir_reader.h create mode 100644 src/glsl/ir_swizzle_swizzle.cpp create mode 100644 src/glsl/ir_to_mesa.cpp create mode 100644 src/glsl/ir_validate.cpp create mode 100644 src/glsl/ir_variable.cpp create mode 100644 src/glsl/ir_vec_index_to_swizzle.cpp create mode 100644 src/glsl/ir_visitor.h create mode 100644 src/glsl/linker.cpp create mode 100644 src/glsl/list.h create mode 100644 src/glsl/main.cpp create mode 100644 src/glsl/main/imports.h create mode 100644 src/glsl/main/mtypes.h create mode 100644 src/glsl/main/simple_list.h create mode 100644 src/glsl/mesa/shader/prog_instruction.c create mode 100644 src/glsl/mesa/shader/prog_instruction.h create mode 100644 src/glsl/mesa/shader/prog_print.c create mode 100644 src/glsl/mesa/shader/prog_print.h create mode 100644 src/glsl/program.h create mode 100644 src/glsl/s_expression.cpp create mode 100644 src/glsl/s_expression.h create mode 100644 src/glsl/symbol_table.c create mode 100644 src/glsl/symbol_table.h create mode 100644 src/glsl/tests/array-01.glsl create mode 100644 src/glsl/tests/array-02.glsl create mode 100644 src/glsl/tests/array-03.glsl create mode 100644 src/glsl/tests/array-04.glsl create mode 100644 src/glsl/tests/array-05.glsl create mode 100644 src/glsl/tests/array-06.glsl create mode 100644 src/glsl/tests/array-07.glsl create mode 100644 src/glsl/tests/array-08.glsl create mode 100644 src/glsl/tests/array-09.glsl create mode 100644 src/glsl/tests/array-10.glsl create mode 100644 src/glsl/tests/array-11.glsl create mode 100644 src/glsl/tests/array-12.glsl create mode 100644 src/glsl/tests/array-13.glsl create mode 100644 src/glsl/tests/attribute-01.glsl create mode 100644 src/glsl/tests/attribute-02.glsl create mode 100644 src/glsl/tests/attribute-03.glsl create mode 100644 src/glsl/tests/attribute-04.glsl create mode 100644 src/glsl/tests/attribute-05.glsl create mode 100644 src/glsl/tests/attribute-06.glsl create mode 100644 src/glsl/tests/attribute-07.glsl create mode 100644 src/glsl/tests/attribute-08.glsl create mode 100644 src/glsl/tests/attribute-09.glsl create mode 100644 src/glsl/tests/attribute-10.glsl create mode 100644 src/glsl/tests/attribute-11.glsl create mode 100644 src/glsl/tests/condition-01.glsl create mode 100644 src/glsl/tests/condition-02.glsl create mode 100644 src/glsl/tests/condition-03.glsl create mode 100644 src/glsl/tests/condition-04.glsl create mode 100644 src/glsl/tests/condition-05.glsl create mode 100644 src/glsl/tests/constructor-01.glsl create mode 100644 src/glsl/tests/constructor-02.glsl create mode 100644 src/glsl/tests/constructor-03.glsl create mode 100644 src/glsl/tests/constructor-04.glsl create mode 100644 src/glsl/tests/constructor-05.glsl create mode 100644 src/glsl/tests/constructor-06.glsl create mode 100644 src/glsl/tests/constructor-07.glsl create mode 100644 src/glsl/tests/constructor-08.glsl create mode 100644 src/glsl/tests/constructor-09.glsl create mode 100644 src/glsl/tests/function-01.glsl create mode 100644 src/glsl/tests/function-02.glsl create mode 100644 src/glsl/tests/function-03.glsl create mode 100644 src/glsl/tests/function-04.glsl create mode 100644 src/glsl/tests/function-05.glsl create mode 100644 src/glsl/tests/if-01.glsl create mode 100644 src/glsl/tests/if-02.glsl create mode 100644 src/glsl/tests/if-03.glsl create mode 100644 src/glsl/tests/if-04.glsl create mode 100644 src/glsl/tests/matrix-01.glsl create mode 100644 src/glsl/tests/matrix-02.glsl create mode 100644 src/glsl/tests/matrix-03.glsl create mode 100644 src/glsl/tests/matrix-04.glsl create mode 100644 src/glsl/tests/matrix-05.glsl create mode 100644 src/glsl/tests/matrix-06.glsl create mode 100644 src/glsl/tests/matrix-07.glsl create mode 100644 src/glsl/tests/matrix-08.glsl create mode 100644 src/glsl/tests/matrix-09.glsl create mode 100644 src/glsl/tests/matrix-10.glsl create mode 100644 src/glsl/tests/parameters-01.glsl create mode 100644 src/glsl/tests/parameters-02.glsl create mode 100644 src/glsl/tests/parameters-03.glsl create mode 100644 src/glsl/tests/qualifier-01.glsl create mode 100644 src/glsl/tests/qualifier-02.glsl create mode 100644 src/glsl/tests/qualifier-03.glsl create mode 100644 src/glsl/tests/qualifier-04.glsl create mode 100644 src/glsl/tests/qualifier-05.glsl create mode 100644 src/glsl/tests/qualifier-06.glsl create mode 100644 src/glsl/tests/qualifier-07.glsl create mode 100644 src/glsl/tests/swiz-01.glsl create mode 100644 src/glsl/tests/swiz-02.glsl create mode 100644 src/glsl/tests/void-01.glsl delete mode 100644 symbol_table.c delete mode 100644 symbol_table.h delete mode 100644 tests/array-01.glsl delete mode 100644 tests/array-02.glsl delete mode 100644 tests/array-03.glsl delete mode 100644 tests/array-04.glsl delete mode 100644 tests/array-05.glsl delete mode 100644 tests/array-06.glsl delete mode 100644 tests/array-07.glsl delete mode 100644 tests/array-08.glsl delete mode 100644 tests/array-09.glsl delete mode 100644 tests/array-10.glsl delete mode 100644 tests/array-11.glsl delete mode 100644 tests/array-12.glsl delete mode 100644 tests/array-13.glsl delete mode 100644 tests/attribute-01.glsl delete mode 100644 tests/attribute-02.glsl delete mode 100644 tests/attribute-03.glsl delete mode 100644 tests/attribute-04.glsl delete mode 100644 tests/attribute-05.glsl delete mode 100644 tests/attribute-06.glsl delete mode 100644 tests/attribute-07.glsl delete mode 100644 tests/attribute-08.glsl delete mode 100644 tests/attribute-09.glsl delete mode 100644 tests/attribute-10.glsl delete mode 100644 tests/attribute-11.glsl delete mode 100644 tests/condition-01.glsl delete mode 100644 tests/condition-02.glsl delete mode 100644 tests/condition-03.glsl delete mode 100644 tests/condition-04.glsl delete mode 100644 tests/condition-05.glsl delete mode 100644 tests/constructor-01.glsl delete mode 100644 tests/constructor-02.glsl delete mode 100644 tests/constructor-03.glsl delete mode 100644 tests/constructor-04.glsl delete mode 100644 tests/constructor-05.glsl delete mode 100644 tests/constructor-06.glsl delete mode 100644 tests/constructor-07.glsl delete mode 100644 tests/constructor-08.glsl delete mode 100644 tests/constructor-09.glsl delete mode 100644 tests/function-01.glsl delete mode 100644 tests/function-02.glsl delete mode 100644 tests/function-03.glsl delete mode 100644 tests/function-04.glsl delete mode 100644 tests/function-05.glsl delete mode 100644 tests/if-01.glsl delete mode 100644 tests/if-02.glsl delete mode 100644 tests/if-03.glsl delete mode 100644 tests/if-04.glsl delete mode 100644 tests/matrix-01.glsl delete mode 100644 tests/matrix-02.glsl delete mode 100644 tests/matrix-03.glsl delete mode 100644 tests/matrix-04.glsl delete mode 100644 tests/matrix-05.glsl delete mode 100644 tests/matrix-06.glsl delete mode 100644 tests/matrix-07.glsl delete mode 100644 tests/matrix-08.glsl delete mode 100644 tests/matrix-09.glsl delete mode 100644 tests/matrix-10.glsl delete mode 100644 tests/parameters-01.glsl delete mode 100644 tests/parameters-02.glsl delete mode 100644 tests/parameters-03.glsl delete mode 100644 tests/qualifier-01.glsl delete mode 100644 tests/qualifier-02.glsl delete mode 100644 tests/qualifier-03.glsl delete mode 100644 tests/qualifier-04.glsl delete mode 100644 tests/qualifier-05.glsl delete mode 100644 tests/qualifier-06.glsl delete mode 100644 tests/qualifier-07.glsl delete mode 100644 tests/swiz-01.glsl delete mode 100644 tests/swiz-02.glsl delete mode 100644 tests/void-01.glsl diff --git a/.dir-locals.el b/.dir-locals.el deleted file mode 100644 index be19e29a5ab..00000000000 --- a/.dir-locals.el +++ /dev/null @@ -1,3 +0,0 @@ -((c-mode . ((c-basic-offset . 3))) - (c++-mode . ((c-basic-offset . 3))) -) diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 376aaeda13a..00000000000 --- a/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -.deps -COPYING -INSTALL -Makefile.in -aclocal.m4 -autom4te.cache -config.* -configure -depcomp -ylwrap -install-sh -missing -stamp-h1 -libtool -ltmain.sh -Makefile -*.o -*~ -glsl_lexer.cpp -glsl_parser.output -glsl_parser.cpp -glsl_parser.h -glsl -mesa_codegen.cpp -mesa_codegen.h diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index c34f7d8abfb..00000000000 --- a/Makefile.am +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright © 2010 Intel Corporation -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# on the rights to use, copy, modify, merge, publish, distribute, sub -# license, and/or sell copies of the Software, and to permit persons to whom -# the Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -# USE OR OTHER DEALINGS IN THE SOFTWARE. - -AUTOMAKE_OPTIONS = foreign -AM_CPPFLAGS = -I mesa - -SUBDIRS = glcpp - -bin_PROGRAMS = glsl - -glsl_LDADD = ./glcpp/libglcpp.la -glsl_LDFLAGS = @LDFLAGS@ $(talloc_LIBS) -glsl_SOURCES = \ - main.cpp \ - builtin_types.h \ - symbol_table.c hash_table.c glsl_types.cpp \ - glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ - ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \ - ir.cpp hir_field_selection.cpp builtin_function.cpp \ - ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \ - ir_basic_block.cpp \ - ir_basic_block.h \ - ir_clone.cpp \ - ir_constant_expression.cpp \ - ir_constant_folding.cpp \ - ir_constant_variable.cpp \ - ir_copy_propagation.cpp \ - ir_copy_propagation.h \ - ir_dead_code.cpp \ - ir_dead_code.h \ - ir_dead_code_local.cpp \ - ir_expression_flattening.cpp \ - ir_function_can_inline.cpp \ - ir_function_inlining.cpp \ - ir_if_simplification.cpp \ - ir_optimization.h \ - ir_reader.cpp s_expression.cpp \ - ir_hv_accept.cpp \ - ir_hierarchical_visitor.h \ - ir_hierarchical_visitor.cpp \ - ir_swizzle_swizzle.cpp \ - ir_to_mesa.cpp \ - ir_to_mesa.h \ - ir_validate.cpp \ - ir_vec_index_to_swizzle.cpp \ - linker.cpp \ - mesa/shader/prog_instruction.c \ - mesa/shader/prog_instruction.h \ - mesa/shader/prog_print.c \ - mesa/shader/prog_print.h - -BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp -CLEANFILES = $(BUILT_SOURCES) - -builtin_function.cpp: builtins/*/* - ./builtins/tools/generate_builtins.pl > builtin_function.cpp -glsl_parser.h: glsl_parser.cpp - -.lpp.cpp: - $(LEXCOMPILE) --outfile="$@" $< diff --git a/TODO b/TODO deleted file mode 100644 index 193cfc767d8..00000000000 --- a/TODO +++ /dev/null @@ -1,84 +0,0 @@ -- Implement AST-to-HIR conversion of discard instructions. - -- Handle constant expressions of (matrix {+,-,*,/} scalar) - -- Handle constant expressions of (vector {+,-,*,/} scalar) - -- Handle constant expressions of (matrix * vector) - -- Handle constant expressions of (matrix * matrix) - -- Handle currently unsupported constant expression types - - ir_unop_sign - - ir_unop_exp2 - - ir_unop_log2 - - ir_unop_u2f - - ir_unop_trunc - - ir_unop_ceil - - ir_unop_floor - - ir_unop_sin - - ir_unop_cos - - ir_binop_dot - - ir_binop_min - - ir_binop_max - - ir_binop_pow - -- Handle constant expressions of (struct == struct) - -- Handle constant expressions of (struct != struct) - -- Add support to ir_constant for array constants Arrays can only be - - declared 'const' in GLSL 1.20+. This is because there are no - array constructors in GLSL 1.10, and any variable declared as - 'const' must have an initializer. - -- Handle constant expressions of (array == array) - -- Handle constant expressions of (array != array) - -- Treat built-in functions with constant parameters as constant expressions. - - Rewrite all built-in functions return a single expression. - - Modify the HIR generator for functions to automatically inline built-in - functions durning translation. - - Care must be taken to handle both the 1.10 rules and the 1.20+ rules. In - 1.10, built-in functions cannot be constant expressions. - -- Detect non-void functions that lack a return statement - -- Detect return statements with a type not matching the funciton's - return type. - -- Handle over-riding built-in functions - - Is the overload per-compilation unit or per-linked shader? - -- Handle redeclaration of built-in variables - - Handle addition of qualifiers such as 'invariant' or 'centroid'. - - Handle resizing of arrays. - - Other? We'll have to look at the spec. - -- Improve handling of constants and their initializers. Constant initializers - should never generate any code. This is trival for scalar constants. It is - also trivial for arrays, matrices, and vectors that are accessed with - constant index values. For others it is more complicated. Perhaps these - cases should be silently converted to uniforms? - -1.30 features: - -- Implement AST-to-HIR conversion of bit-shift operators. - -- Implement AST-to-HIR conversion of bit-wise {&,|,^,!} operators. - -- Implement AST-to-HIR conversion of switch-statements - - switch - - case - - Update break to correcly handle mixed nexting of switch-statements - and loops. - -- Handle currently unsupported constant expression types - - ir_unop_bit_not - - ir_binop_mod - - ir_binop_lshift - - ir_binop_rshift - - ir_binop_bit_and - - ir_binop_bit_xor - - ir_binop_bit_or diff --git a/ast.h b/ast.h deleted file mode 100644 index de300e719c4..00000000000 --- a/ast.h +++ /dev/null @@ -1,651 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef AST_H -#define AST_H - -#include "list.h" -#include "glsl_parser_extras.h" - -struct ir_instruction; -struct _mesa_glsl_parse_state; - -struct YYLTYPE; - -class ast_node { -public: - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = talloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. */ - static void operator delete(void *table) - { - talloc_free(table); - } - - virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - /** - * Retrieve the source location of an AST node - * - * This function is primarily used to get the source position of an AST node - * into a form that can be passed to \c _mesa_glsl_error. - * - * \sa _mesa_glsl_error, ast_node::set_location - */ - struct YYLTYPE get_location(void) const - { - struct YYLTYPE locp; - - locp.source = this->location.source; - locp.first_line = this->location.line; - locp.first_column = this->location.column; - locp.last_line = locp.first_line; - locp.last_column = locp.first_column; - - return locp; - } - - /** - * Set the source location of an AST node from a parser location - * - * \sa ast_node::get_location - */ - void set_location(const struct YYLTYPE &locp) - { - this->location.source = locp.source; - this->location.line = locp.first_line; - this->location.column = locp.first_column; - } - - struct { - unsigned source; - unsigned line; - unsigned column; - } location; - - exec_node link; - -protected: - ast_node(void); -}; - - -enum ast_operators { - ast_assign, - ast_plus, /**< Unary + operator. */ - ast_neg, - ast_add, - ast_sub, - ast_mul, - ast_div, - ast_mod, - ast_lshift, - ast_rshift, - ast_less, - ast_greater, - ast_lequal, - ast_gequal, - ast_equal, - ast_nequal, - ast_bit_and, - ast_bit_xor, - ast_bit_or, - ast_bit_not, - ast_logic_and, - ast_logic_xor, - ast_logic_or, - ast_logic_not, - - ast_mul_assign, - ast_div_assign, - ast_mod_assign, - ast_add_assign, - ast_sub_assign, - ast_ls_assign, - ast_rs_assign, - ast_and_assign, - ast_xor_assign, - ast_or_assign, - - ast_conditional, - - ast_pre_inc, - ast_pre_dec, - ast_post_inc, - ast_post_dec, - ast_field_selection, - ast_array_index, - - ast_function_call, - - ast_identifier, - ast_int_constant, - ast_uint_constant, - ast_float_constant, - ast_bool_constant, - - ast_sequence -}; - -class ast_expression : public ast_node { -public: - ast_expression(int oper, ast_expression *, - ast_expression *, ast_expression *); - - ast_expression(const char *identifier) : - oper(ast_identifier) - { - subexpressions[0] = NULL; - subexpressions[1] = NULL; - subexpressions[2] = NULL; - primary_expression.identifier = (char *) identifier; - } - - static const char *operator_string(enum ast_operators op); - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - virtual void print(void) const; - - enum ast_operators oper; - - ast_expression *subexpressions[3]; - - union { - char *identifier; - int int_constant; - float float_constant; - unsigned uint_constant; - int bool_constant; - } primary_expression; - - - /** - * List of expressions for an \c ast_sequence or parameters for an - * \c ast_function_call - */ - exec_list expressions; -}; - -class ast_expression_bin : public ast_expression { -public: - ast_expression_bin(int oper, ast_expression *, ast_expression *); - - virtual void print(void) const; -}; - -/** - * Subclass of expressions for function calls - */ -class ast_function_expression : public ast_expression { -public: - ast_function_expression(ast_expression *callee) - : ast_expression(ast_function_call, callee, - NULL, NULL), - cons(false) - { - /* empty */ - } - - ast_function_expression(class ast_type_specifier *type) - : ast_expression(ast_function_call, (ast_expression *) type, - NULL, NULL), - cons(true) - { - /* empty */ - } - - bool is_constructor() const - { - return cons; - } - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - -private: - /** - * Is this function call actually a constructor? - */ - bool cons; -}; - - -/** - * Number of possible operators for an ast_expression - * - * This is done as a define instead of as an additional value in the enum so - * that the compiler won't generate spurious messages like "warning: - * enumeration value ‘ast_num_operators’ not handled in switch" - */ -#define AST_NUM_OPERATORS (ast_sequence + 1) - - -class ast_compound_statement : public ast_node { -public: - ast_compound_statement(int new_scope, ast_node *statements); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - int new_scope; - exec_list statements; -}; - -class ast_declaration : public ast_node { -public: - ast_declaration(char *identifier, int is_array, ast_expression *array_size, - ast_expression *initializer); - virtual void print(void) const; - - char *identifier; - - int is_array; - ast_expression *array_size; - - ast_expression *initializer; -}; - - -enum { - ast_precision_high = 0, /**< Default precision. */ - ast_precision_medium, - ast_precision_low -}; - -struct ast_type_qualifier { - unsigned invariant:1; - unsigned constant:1; - unsigned attribute:1; - unsigned varying:1; - unsigned in:1; - unsigned out:1; - unsigned centroid:1; - unsigned uniform:1; - unsigned smooth:1; - unsigned flat:1; - unsigned noperspective:1; -}; - -class ast_struct_specifier : public ast_node { -public: - ast_struct_specifier(char *identifier, ast_node *declarator_list); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - char *name; - exec_list declarations; -}; - - -enum ast_types { - ast_void, - ast_float, - ast_int, - ast_uint, - ast_bool, - ast_vec2, - ast_vec3, - ast_vec4, - ast_bvec2, - ast_bvec3, - ast_bvec4, - ast_ivec2, - ast_ivec3, - ast_ivec4, - ast_uvec2, - ast_uvec3, - ast_uvec4, - ast_mat2, - ast_mat2x3, - ast_mat2x4, - ast_mat3x2, - ast_mat3, - ast_mat3x4, - ast_mat4x2, - ast_mat4x3, - ast_mat4, - ast_sampler1d, - ast_sampler2d, - ast_sampler2drect, - ast_sampler3d, - ast_samplercube, - ast_sampler1dshadow, - ast_sampler2dshadow, - ast_sampler2drectshadow, - ast_samplercubeshadow, - ast_sampler1darray, - ast_sampler2darray, - ast_sampler1darrayshadow, - ast_sampler2darrayshadow, - ast_isampler1d, - ast_isampler2d, - ast_isampler3d, - ast_isamplercube, - ast_isampler1darray, - ast_isampler2darray, - ast_usampler1d, - ast_usampler2d, - ast_usampler3d, - ast_usamplercube, - ast_usampler1darray, - ast_usampler2darray, - - ast_struct, - ast_type_name -}; - - -class ast_type_specifier : public ast_node { -public: - ast_type_specifier(int specifier); - - /** Construct a type specifier from a type name */ - ast_type_specifier(const char *name) - : type_specifier(ast_type_name), type_name(name), structure(NULL), - is_array(false), array_size(NULL), precision(ast_precision_high) - { - /* empty */ - } - - /** Construct a type specifier from a structure definition */ - ast_type_specifier(ast_struct_specifier *s) - : type_specifier(ast_struct), type_name(s->name), structure(s), - is_array(false), array_size(NULL), precision(ast_precision_high) - { - /* empty */ - } - - const struct glsl_type *glsl_type(const char **name, - struct _mesa_glsl_parse_state *state) - const; - - virtual void print(void) const; - - ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); - - enum ast_types type_specifier; - - const char *type_name; - ast_struct_specifier *structure; - - int is_array; - ast_expression *array_size; - - unsigned precision:2; -}; - - -class ast_fully_specified_type : public ast_node { -public: - virtual void print(void) const; - - ast_type_qualifier qualifier; - ast_type_specifier *specifier; -}; - - -class ast_declarator_list : public ast_node { -public: - ast_declarator_list(ast_fully_specified_type *); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_fully_specified_type *type; - exec_list declarations; - - /** - * Special flag for vertex shader "invariant" declarations. - * - * Vertex shaders can contain "invariant" variable redeclarations that do - * not include a type. For example, "invariant gl_Position;". This flag - * is used to note these cases when no type is specified. - */ - int invariant; -}; - - -class ast_parameter_declarator : public ast_node { -public: - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_fully_specified_type *type; - char *identifier; - int is_array; - ast_expression *array_size; - - static void parameters_to_hir(exec_list *ast_parameters, - bool formal, exec_list *ir_parameters, - struct _mesa_glsl_parse_state *state); - -private: - /** Is this parameter declaration part of a formal parameter list? */ - bool formal_parameter; - - /** - * Is this parameter 'void' type? - * - * This field is set by \c ::hir. - */ - bool is_void; -}; - - -class ast_function : public ast_node { -public: - ast_function(void); - - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_fully_specified_type *return_type; - char *identifier; - - exec_list parameters; - -private: - /** - * Is this prototype part of the function definition? - * - * Used by ast_function_definition::hir to process the parameters, etc. - * of the function. - * - * \sa ::hir - */ - bool is_definition; - - /** - * Function signature corresponding to this function prototype instance - * - * Used by ast_function_definition::hir to process the parameters, etc. - * of the function. - * - * \sa ::hir - */ - class ir_function_signature *signature; - - friend class ast_function_definition; -}; - - -class ast_declaration_statement : public ast_node { -public: - ast_declaration_statement(void); - - enum { - ast_function, - ast_declaration, - ast_precision - } mode; - - union { - class ast_function *function; - ast_declarator_list *declarator; - ast_type_specifier *type; - ast_node *node; - } declaration; -}; - - -class ast_expression_statement : public ast_node { -public: - ast_expression_statement(ast_expression *); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_expression *expression; -}; - - -class ast_case_label : public ast_node { -public: - - /** - * An expression of NULL means 'default'. - */ - ast_expression *expression; -}; - -class ast_selection_statement : public ast_node { -public: - ast_selection_statement(ast_expression *condition, - ast_node *then_statement, - ast_node *else_statement); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_expression *condition; - ast_node *then_statement; - ast_node *else_statement; -}; - - -class ast_switch_statement : public ast_node { -public: - ast_expression *expression; - exec_list statements; -}; - -class ast_iteration_statement : public ast_node { -public: - ast_iteration_statement(int mode, ast_node *init, ast_node *condition, - ast_expression *rest_expression, ast_node *body); - - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); - - enum ast_iteration_modes { - ast_for, - ast_while, - ast_do_while - } mode; - - - ast_node *init_statement; - ast_node *condition; - ast_expression *rest_expression; - - ast_node *body; - -private: - /** - * Generate IR from the condition of a loop - * - * This is factored out of ::hir because some loops have the condition - * test at the top (for and while), and others have it at the end (do-while). - */ - void condition_to_hir(class ir_loop *, struct _mesa_glsl_parse_state *); -}; - - -class ast_jump_statement : public ast_node { -public: - ast_jump_statement(int mode, ast_expression *return_value); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - enum ast_jump_modes { - ast_continue, - ast_break, - ast_return, - ast_discard - } mode; - - ast_expression *opt_return_value; -}; - - -class ast_function_definition : public ast_node { -public: - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_function *prototype; - ast_compound_statement *body; -}; - - -extern void -_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); - -extern struct ir_rvalue * -_mesa_ast_field_selection_to_hir(const struct ast_expression *expr, - exec_list *instructions, - struct _mesa_glsl_parse_state *state); - -#endif /* AST_H */ diff --git a/ast_expr.cpp b/ast_expr.cpp deleted file mode 100644 index 4e83decb924..00000000000 --- a/ast_expr.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include -#include "ast.h" - -const char * -ast_expression::operator_string(enum ast_operators op) -{ - static const char *const operators[] = { - "=", - "+", - "-", - "+", - "-", - "*", - "/", - "%", - "<<", - ">>", - "<", - ">", - "<=", - ">=", - "==", - "!=", - "&", - "^", - "|", - "~", - "&&", - "^^", - "||", - "!", - - "*=", - "/=", - "%=", - "+=", - "-=", - "<<=", - ">>=", - "&=", - "^=", - "|=", - - "?:", - - "++", - "--", - "++", - "--", - ".", - }; - - assert((unsigned int)op < sizeof(operators) / sizeof(operators[0])); - - return operators[op]; -} - - -ast_expression_bin::ast_expression_bin(int oper, ast_expression *ex0, - ast_expression *ex1) : - ast_expression(oper, ex0, ex1, NULL) -{ - assert((oper >= ast_plus) && (oper <= ast_logic_not)); -} - - -void -ast_expression_bin::print(void) const -{ - subexpressions[0]->print(); - printf("%s ", operator_string(oper)); - subexpressions[1]->print(); -} diff --git a/ast_function.cpp b/ast_function.cpp deleted file mode 100644 index 761af00b95e..00000000000 --- a/ast_function.cpp +++ /dev/null @@ -1,751 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "glsl_symbol_table.h" -#include "ast.h" -#include "glsl_types.h" -#include "ir.h" - -static unsigned -process_parameters(exec_list *instructions, exec_list *actual_parameters, - exec_list *parameters, - struct _mesa_glsl_parse_state *state) -{ - unsigned count = 0; - - foreach_list (n, parameters) { - ast_node *const ast = exec_node_data(ast_node, n, link); - ir_rvalue *result = ast->hir(instructions, state); - - ir_constant *const constant = result->constant_expression_value(); - if (constant != NULL) - result = constant; - - actual_parameters->push_tail(result); - count++; - } - - return count; -} - - -static ir_rvalue * -process_call(exec_list *instructions, ir_function *f, - YYLTYPE *loc, exec_list *actual_parameters, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - - const ir_function_signature *sig = - f->matching_signature(actual_parameters); - - /* The instructions param will be used when the FINISHMEs below are done */ - (void) instructions; - - if (sig != NULL) { - /* Verify that 'out' and 'inout' actual parameters are lvalues. This - * isn't done in ir_function::matching_signature because that function - * cannot generate the necessary diagnostics. - */ - exec_list_iterator actual_iter = actual_parameters->iterator(); - exec_list_iterator formal_iter = sig->parameters.iterator(); - - while (actual_iter.has_next()) { - ir_rvalue *actual = (ir_rvalue *) actual_iter.get(); - ir_variable *formal = (ir_variable *) formal_iter.get(); - - assert(actual != NULL); - assert(formal != NULL); - - if ((formal->mode == ir_var_out) - || (formal->mode == ir_var_inout)) { - if (! actual->is_lvalue()) { - /* FINISHME: Log a better diagnostic here. There is no way - * FINISHME: to tell the user which parameter is invalid. - */ - _mesa_glsl_error(loc, state, "`%s' parameter is not lvalue", - (formal->mode == ir_var_out) ? "out" : "inout"); - } - } - - actual_iter.next(); - formal_iter.next(); - } - - /* FINISHME: The list of actual parameters needs to be modified to - * FINISHME: include any necessary conversions. - */ - return new(ctx) ir_call(sig, actual_parameters); - } else { - /* FINISHME: Log a better error message here. G++ will show the types - * FINISHME: of the actual parameters and the set of candidate - * FINISHME: functions. A different error should also be logged when - * FINISHME: multiple functions match. - */ - _mesa_glsl_error(loc, state, "no matching function for call to `%s'", - f->name); - return ir_call::get_error_instruction(ctx); - } -} - - -static ir_rvalue * -match_function_by_name(exec_list *instructions, const char *name, - YYLTYPE *loc, exec_list *actual_parameters, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - ir_function *f = state->symbols->get_function(name); - - if (f == NULL) { - _mesa_glsl_error(loc, state, "function `%s' undeclared", name); - return ir_call::get_error_instruction(ctx); - } - - /* Once we've determined that the function being called might exist, try - * to find an overload of the function that matches the parameters. - */ - return process_call(instructions, f, loc, actual_parameters, state); -} - - -/** - * Perform automatic type conversion of constructor parameters - */ -static ir_rvalue * -convert_component(ir_rvalue *src, const glsl_type *desired_type) -{ - void *ctx = talloc_parent(src); - const unsigned a = desired_type->base_type; - const unsigned b = src->type->base_type; - ir_expression *result = NULL; - - if (src->type->is_error()) - return src; - - assert(a <= GLSL_TYPE_BOOL); - assert(b <= GLSL_TYPE_BOOL); - - if ((a == b) || (src->type->is_integer() && desired_type->is_integer())) - return src; - - switch (a) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - if (b == GLSL_TYPE_FLOAT) - result = new(ctx) ir_expression(ir_unop_f2i, desired_type, src, NULL); - else { - assert(b == GLSL_TYPE_BOOL); - result = new(ctx) ir_expression(ir_unop_b2i, desired_type, src, NULL); - } - break; - case GLSL_TYPE_FLOAT: - switch (b) { - case GLSL_TYPE_UINT: - result = new(ctx) ir_expression(ir_unop_u2f, desired_type, src, NULL); - break; - case GLSL_TYPE_INT: - result = new(ctx) ir_expression(ir_unop_i2f, desired_type, src, NULL); - break; - case GLSL_TYPE_BOOL: - result = new(ctx) ir_expression(ir_unop_b2f, desired_type, src, NULL); - break; - } - break; - case GLSL_TYPE_BOOL: { - ir_constant *zero = NULL; - - switch (b) { - case GLSL_TYPE_UINT: zero = new(ctx) ir_constant(unsigned(0)); break; - case GLSL_TYPE_INT: zero = new(ctx) ir_constant(int(0)); break; - case GLSL_TYPE_FLOAT: zero = new(ctx) ir_constant(0.0f); break; - } - - result = new(ctx) ir_expression(ir_binop_nequal, desired_type, src, zero); - } - } - - assert(result != NULL); - - ir_constant *const constant = result->constant_expression_value(); - return (constant != NULL) ? (ir_rvalue *) constant : (ir_rvalue *) result; -} - - -/** - * Dereference a specific component from a scalar, vector, or matrix - */ -static ir_rvalue * -dereference_component(ir_rvalue *src, unsigned component) -{ - void *ctx = talloc_parent(src); - assert(component < src->type->components()); - - /* If the source is a constant, just create a new constant instead of a - * dereference of the existing constant. - */ - ir_constant *constant = src->as_constant(); - if (constant) - return new(ctx) ir_constant(constant, component); - - if (src->type->is_scalar()) { - return src; - } else if (src->type->is_vector()) { - return new(ctx) ir_swizzle(src, component, 0, 0, 0, 1); - } else { - assert(src->type->is_matrix()); - - /* Dereference a row of the matrix, then call this function again to get - * a specific element from that row. - */ - const int c = component / src->type->column_type()->vector_elements; - const int r = component % src->type->column_type()->vector_elements; - ir_constant *const col_index = new(ctx) ir_constant(c); - ir_dereference *const col = new(ctx) ir_dereference_array(src, col_index); - - col->type = src->type->column_type(); - - return dereference_component(col, r); - } - - assert(!"Should not get here."); - return NULL; -} - - -static ir_rvalue * -process_array_constructor(exec_list *instructions, - const glsl_type *constructor_type, - YYLTYPE *loc, exec_list *parameters, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - /* Array constructors come in two forms: sized and unsized. Sized array - * constructors look like 'vec4[2](a, b)', where 'a' and 'b' are vec4 - * variables. In this case the number of parameters must exactly match the - * specified size of the array. - * - * Unsized array constructors look like 'vec4[](a, b)', where 'a' and 'b' - * are vec4 variables. In this case the size of the array being constructed - * is determined by the number of parameters. - * - * From page 52 (page 58 of the PDF) of the GLSL 1.50 spec: - * - * "There must be exactly the same number of arguments as the size of - * the array being constructed. If no size is present in the - * constructor, then the array is explicitly sized to the number of - * arguments provided. The arguments are assigned in order, starting at - * element 0, to the elements of the constructed array. Each argument - * must be the same type as the element type of the array, or be a type - * that can be converted to the element type of the array according to - * Section 4.1.10 "Implicit Conversions."" - */ - exec_list actual_parameters; - const unsigned parameter_count = - process_parameters(instructions, &actual_parameters, parameters, state); - - if ((parameter_count == 0) - || ((constructor_type->length != 0) - && (constructor_type->length != parameter_count))) { - const unsigned min_param = (constructor_type->length == 0) - ? 1 : constructor_type->length; - - _mesa_glsl_error(loc, state, "array constructor must have %s %u " - "parameter%s", - (constructor_type->length != 0) ? "at least" : "exactly", - min_param, (min_param <= 1) ? "" : "s"); - return ir_call::get_error_instruction(ctx); - } - - if (constructor_type->length == 0) { - constructor_type = - glsl_type::get_array_instance(state, - constructor_type->element_type(), - parameter_count); - assert(constructor_type != NULL); - assert(constructor_type->length == parameter_count); - } - - ir_function *f = state->symbols->get_function(constructor_type->name); - - /* If the constructor for this type of array does not exist, generate the - * prototype and add it to the symbol table. - */ - if (f == NULL) { - f = constructor_type->generate_constructor(state->symbols); - } - - ir_rvalue *const r = - process_call(instructions, f, loc, &actual_parameters, state); - - assert(r != NULL); - assert(r->type->is_error() || (r->type == constructor_type)); - - return r; -} - - -/** - * Try to convert a record constructor to a constant expression - */ -static ir_constant * -constant_record_constructor(const glsl_type *constructor_type, - YYLTYPE *loc, exec_list *parameters, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - bool all_parameters_are_constant = true; - - exec_node *node = parameters->head; - for (unsigned i = 0; i < constructor_type->length; i++) { - ir_instruction *ir = (ir_instruction *) node; - - if (node->is_tail_sentinal()) { - _mesa_glsl_error(loc, state, - "insufficient parameters to constructor for `%s'", - constructor_type->name); - return NULL; - } - - if (ir->type != constructor_type->fields.structure[i].type) { - _mesa_glsl_error(loc, state, - "parameter type mismatch in constructor for `%s' " - " (%s vs %s)", - constructor_type->name, - ir->type->name, - constructor_type->fields.structure[i].type->name); - return NULL; - } - - if (ir->as_constant() == NULL) - all_parameters_are_constant = false; - - node = node->next; - } - - if (!all_parameters_are_constant) - return NULL; - - return new(ctx) ir_constant(constructor_type, parameters); -} - - -/** - * Generate data for a constant matrix constructor w/a single scalar parameter - * - * Matrix constructors in GLSL can be passed a single scalar of the - * approriate type. In these cases, the resulting matrix is the identity - * matrix multipled by the specified scalar. This function generates data for - * that matrix. - * - * \param type Type of the desired matrix. - * \param initializer Scalar value used to initialize the matrix diagonal. - * \param data Location to store the resulting matrix. - */ -void -generate_constructor_matrix(const glsl_type *type, ir_constant *initializer, - ir_constant_data *data) -{ - switch (type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - for (unsigned i = 0; i < type->components(); i++) - data->u[i] = 0; - - for (unsigned i = 0; i < type->matrix_columns; i++) { - /* The array offset of the ith row and column of the matrix. - */ - const unsigned idx = (i * type->vector_elements) + i; - - data->u[idx] = initializer->value.u[0]; - } - break; - - case GLSL_TYPE_FLOAT: - for (unsigned i = 0; i < type->components(); i++) - data->f[i] = 0; - - for (unsigned i = 0; i < type->matrix_columns; i++) { - /* The array offset of the ith row and column of the matrix. - */ - const unsigned idx = (i * type->vector_elements) + i; - - data->f[idx] = initializer->value.f[0]; - } - - break; - - default: - assert(!"Should not get here."); - break; - } -} - - -/** - * Generate data for a constant vector constructor w/a single scalar parameter - * - * Vector constructors in GLSL can be passed a single scalar of the - * approriate type. In these cases, the resulting vector contains the specified - * value in all components. This function generates data for that vector. - * - * \param type Type of the desired vector. - * \param initializer Scalar value used to initialize the vector. - * \param data Location to store the resulting vector data. - */ -void -generate_constructor_vector(const glsl_type *type, ir_constant *initializer, - ir_constant_data *data) -{ - switch (type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - for (unsigned i = 0; i < type->components(); i++) - data->u[i] = initializer->value.u[0]; - - break; - - case GLSL_TYPE_FLOAT: - for (unsigned i = 0; i < type->components(); i++) - data->f[i] = initializer->value.f[0]; - - break; - - case GLSL_TYPE_BOOL: - for (unsigned i = 0; i < type->components(); i++) - data->b[i] = initializer->value.b[0]; - - break; - - default: - assert(!"Should not get here."); - break; - } -} - - -ir_rvalue * -ast_function_expression::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - /* There are three sorts of function calls. - * - * 1. contstructors - The first subexpression is an ast_type_specifier. - * 2. methods - Only the .length() method of array types. - * 3. functions - Calls to regular old functions. - * - * Method calls are actually detected when the ast_field_selection - * expression is handled. - */ - if (is_constructor()) { - const ast_type_specifier *type = (ast_type_specifier *) subexpressions[0]; - YYLTYPE loc = type->get_location(); - const char *name; - - const glsl_type *const constructor_type = type->glsl_type(& name, state); - - - /* Constructors for samplers are illegal. - */ - if (constructor_type->is_sampler()) { - _mesa_glsl_error(& loc, state, "cannot construct sampler type `%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - if (constructor_type->is_array()) { - if (state->language_version <= 110) { - _mesa_glsl_error(& loc, state, - "array constructors forbidden in GLSL 1.10"); - return ir_call::get_error_instruction(ctx); - } - - return process_array_constructor(instructions, constructor_type, - & loc, &this->expressions, state); - } - - /* There are two kinds of constructor call. Constructors for built-in - * language types, such as mat4 and vec2, are free form. The only - * requirement is that the parameters must provide enough values of the - * correct scalar type. Constructors for arrays and structures must - * have the exact number of parameters with matching types in the - * correct order. These constructors follow essentially the same type - * matching rules as functions. - */ - if (constructor_type->is_numeric() || constructor_type->is_boolean()) { - /* Constructing a numeric type has a couple steps. First all values - * passed to the constructor are broken into individual parameters - * and type converted to the base type of the thing being constructed. - * - * At that point we have some number of values that match the base - * type of the thing being constructed. Now the constructor can be - * treated like a function call. Each numeric type has a small set - * of constructor functions. The set of new parameters will either - * match one of those functions or the original constructor is - * invalid. - */ - const glsl_type *const base_type = constructor_type->get_base_type(); - - /* Total number of components of the type being constructed. - */ - const unsigned type_components = constructor_type->components(); - - /* Number of components from parameters that have actually been - * consumed. This is used to perform several kinds of error checking. - */ - unsigned components_used = 0; - - unsigned matrix_parameters = 0; - unsigned nonmatrix_parameters = 0; - exec_list actual_parameters; - - bool all_parameters_are_constant = true; - - /* This handles invalid constructor calls such as 'vec4 v = vec4();' - */ - if (this->expressions.is_empty()) { - _mesa_glsl_error(& loc, state, "too few components to construct " - "`%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - foreach_list (n, &this->expressions) { - ast_node *ast = exec_node_data(ast_node, n, link); - ir_rvalue *result = - ast->hir(instructions, state)->as_rvalue(); - ir_variable *result_var = NULL; - - /* Attempt to convert the parameter to a constant valued expression. - * After doing so, track whether or not all the parameters to the - * constructor are trivially constant valued expressions. - */ - ir_rvalue *const constant = - result->constant_expression_value(); - - if (constant != NULL) - result = constant; - else - all_parameters_are_constant = false; - - /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: - * - * "It is an error to provide extra arguments beyond this - * last used argument." - */ - if (components_used >= type_components) { - _mesa_glsl_error(& loc, state, "too many parameters to `%s' " - "constructor", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - if (!result->type->is_numeric() && !result->type->is_boolean()) { - _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " - "non-numeric data type", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - /* Count the number of matrix and nonmatrix parameters. This - * is used below to enforce some of the constructor rules. - */ - if (result->type->is_matrix()) - matrix_parameters++; - else - nonmatrix_parameters++; - - /* We can't use the same instruction node in the multiple - * swizzle dereferences that happen, so assign it to a - * variable and deref that. Plus it saves computation for - * complicated expressions and handles - * glsl-vs-constructor-call.shader_test. - */ - if (result->type->components() >= 1 && !result->as_constant()) { - result_var = new(ctx) ir_variable(result->type, - "constructor_tmp"); - ir_dereference_variable *lhs; - - lhs = new(ctx) ir_dereference_variable(result_var); - instructions->push_tail(new(ctx) ir_assignment(lhs, - result, NULL)); - } - - /* Process each of the components of the parameter. Dereference - * each component individually, perform any type conversions, and - * add it to the parameter list for the constructor. - */ - for (unsigned i = 0; i < result->type->components(); i++) { - if (components_used >= type_components) - break; - - ir_rvalue *component; - - if (result_var) { - ir_dereference *d = new(ctx) ir_dereference_variable(result_var); - component = dereference_component(d, i); - } else { - component = dereference_component(result, i); - } - component = convert_component(component, base_type); - - /* All cases that could result in component->type being the - * error type should have already been caught above. - */ - assert(component->type == base_type); - - if (component->as_constant() == NULL) - all_parameters_are_constant = false; - - /* Don't actually generate constructor calls for scalars. - * Instead, do the usual component selection and conversion, - * and return the single component. - */ - if (constructor_type->is_scalar()) - return component; - - actual_parameters.push_tail(component); - components_used++; - } - } - - /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: - * - * "It is an error to construct matrices from other matrices. This - * is reserved for future use." - */ - if ((state->language_version <= 110) && (matrix_parameters > 0) - && constructor_type->is_matrix()) { - _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " - "matrix in GLSL 1.10", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: - * - * "If a matrix argument is given to a matrix constructor, it is - * an error to have any other arguments." - */ - if ((matrix_parameters > 0) - && ((matrix_parameters + nonmatrix_parameters) > 1) - && constructor_type->is_matrix()) { - _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, " - "matrix must be only parameter", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: - * - * "In these cases, there must be enough components provided in the - * arguments to provide an initializer for every component in the - * constructed value." - */ - if ((components_used < type_components) && (components_used != 1)) { - _mesa_glsl_error(& loc, state, "too few components to construct " - "`%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - ir_function *f = state->symbols->get_function(constructor_type->name); - if (f == NULL) { - _mesa_glsl_error(& loc, state, "no constructor for type `%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - const ir_function_signature *sig = - f->matching_signature(& actual_parameters); - if (sig != NULL) { - /* If all of the parameters are trivially constant, create a - * constant representing the complete collection of parameters. - */ - if (all_parameters_are_constant) { - if (components_used >= type_components) - return new(ctx) ir_constant(sig->return_type, - & actual_parameters); - - assert(sig->return_type->is_vector() - || sig->return_type->is_matrix()); - - /* Constructors with exactly one component are special for - * vectors and matrices. For vectors it causes all elements of - * the vector to be filled with the value. For matrices it - * causes the matrix to be filled with 0 and the diagonal to be - * filled with the value. - */ - ir_constant_data data; - ir_constant *const initializer = - (ir_constant *) actual_parameters.head; - if (sig->return_type->is_matrix()) - generate_constructor_matrix(sig->return_type, initializer, - &data); - else - generate_constructor_vector(sig->return_type, initializer, - &data); - - return new(ctx) ir_constant(sig->return_type, &data); - } else - return new(ctx) ir_call(sig, & actual_parameters); - } else { - /* FINISHME: Log a better error message here. G++ will show the - * FINSIHME: types of the actual parameters and the set of - * FINSIHME: candidate functions. A different error should also be - * FINSIHME: logged when multiple functions match. - */ - _mesa_glsl_error(& loc, state, "no matching constructor for `%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - } - - return ir_call::get_error_instruction(ctx); - } else { - const ast_expression *id = subexpressions[0]; - YYLTYPE loc = id->get_location(); - exec_list actual_parameters; - - process_parameters(instructions, &actual_parameters, &this->expressions, - state); - - const glsl_type *const type = - state->symbols->get_type(id->primary_expression.identifier); - - if ((type != NULL) && type->is_record()) { - ir_constant *constant = - constant_record_constructor(type, &loc, &actual_parameters, state); - - if (constant != NULL) - return constant; - } - - return match_function_by_name(instructions, - id->primary_expression.identifier, & loc, - &actual_parameters, state); - } - - return ir_call::get_error_instruction(ctx); -} diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp deleted file mode 100644 index 33eb27533fd..00000000000 --- a/ast_to_hir.cpp +++ /dev/null @@ -1,2453 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ast_to_hir.c - * Convert abstract syntax to to high-level intermediate reprensentation (HIR). - * - * During the conversion to HIR, the majority of the symantic checking is - * preformed on the program. This includes: - * - * * Symbol table management - * * Type checking - * * Function binding - * - * The majority of this work could be done during parsing, and the parser could - * probably generate HIR directly. However, this results in frequent changes - * to the parser code. Since we do not assume that every system this complier - * is built on will have Flex and Bison installed, we have to store the code - * generated by these tools in our version control system. In other parts of - * the system we've seen problems where a parser was changed but the generated - * code was not committed, merge conflicts where created because two developers - * had slightly different versions of Bison installed, etc. - * - * I have also noticed that running Bison generated parsers in GDB is very - * irritating. When you get a segfault on '$$ = $1->foo', you can't very - * well 'print $1' in GDB. - * - * As a result, my preference is to put as little C code as possible in the - * parser (and lexer) sources. - */ - -#include "main/imports.h" -#include "glsl_symbol_table.h" -#include "glsl_parser_extras.h" -#include "ast.h" -#include "glsl_types.h" -#include "ir.h" - -void -_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) -{ - _mesa_glsl_initialize_variables(instructions, state); - _mesa_glsl_initialize_constructors(instructions, state); - _mesa_glsl_initialize_functions(instructions, state); - - state->current_function = NULL; - - foreach_list_typed (ast_node, ast, link, & state->translation_unit) - ast->hir(instructions, state); -} - - -/** - * If a conversion is available, convert one operand to a different type - * - * The \c from \c ir_rvalue is converted "in place". - * - * \param to Type that the operand it to be converted to - * \param from Operand that is being converted - * \param state GLSL compiler state - * - * \return - * If a conversion is possible (or unnecessary), \c true is returned. - * Otherwise \c false is returned. - */ -static bool -apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - if (to->base_type == from->type->base_type) - return true; - - /* This conversion was added in GLSL 1.20. If the compilation mode is - * GLSL 1.10, the conversion is skipped. - */ - if (state->language_version < 120) - return false; - - /* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec: - * - * "There are no implicit array or structure conversions. For - * example, an array of int cannot be implicitly converted to an - * array of float. There are no implicit conversions between - * signed and unsigned integers." - */ - /* FINISHME: The above comment is partially a lie. There is int/uint - * FINISHME: conversion for immediate constants. - */ - if (!to->is_float() || !from->type->is_numeric()) - return false; - - switch (from->type->base_type) { - case GLSL_TYPE_INT: - from = new(ctx) ir_expression(ir_unop_i2f, to, from, NULL); - break; - case GLSL_TYPE_UINT: - from = new(ctx) ir_expression(ir_unop_u2f, to, from, NULL); - break; - case GLSL_TYPE_BOOL: - from = new(ctx) ir_expression(ir_unop_b2f, to, from, NULL); - break; - default: - assert(0); - } - - return true; -} - - -static const struct glsl_type * -arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, - bool multiply, - struct _mesa_glsl_parse_state *state, YYLTYPE *loc) -{ - const glsl_type *type_a = value_a->type; - const glsl_type *type_b = value_b->type; - - /* From GLSL 1.50 spec, page 56: - * - * "The arithmetic binary operators add (+), subtract (-), - * multiply (*), and divide (/) operate on integer and - * floating-point scalars, vectors, and matrices." - */ - if (!type_a->is_numeric() || !type_b->is_numeric()) { - _mesa_glsl_error(loc, state, - "Operands to arithmetic operators must be numeric"); - return glsl_type::error_type; - } - - - /* "If one operand is floating-point based and the other is - * not, then the conversions from Section 4.1.10 "Implicit - * Conversions" are applied to the non-floating-point-based operand." - */ - if (!apply_implicit_conversion(type_a, value_b, state) - && !apply_implicit_conversion(type_b, value_a, state)) { - _mesa_glsl_error(loc, state, - "Could not implicitly convert operands to " - "arithmetic operator"); - return glsl_type::error_type; - } - type_a = value_a->type; - type_b = value_b->type; - - /* "If the operands are integer types, they must both be signed or - * both be unsigned." - * - * From this rule and the preceeding conversion it can be inferred that - * both types must be GLSL_TYPE_FLOAT, or GLSL_TYPE_UINT, or GLSL_TYPE_INT. - * The is_numeric check above already filtered out the case where either - * type is not one of these, so now the base types need only be tested for - * equality. - */ - if (type_a->base_type != type_b->base_type) { - _mesa_glsl_error(loc, state, - "base type mismatch for arithmetic operator"); - return glsl_type::error_type; - } - - /* "All arithmetic binary operators result in the same fundamental type - * (signed integer, unsigned integer, or floating-point) as the - * operands they operate on, after operand type conversion. After - * conversion, the following cases are valid - * - * * The two operands are scalars. In this case the operation is - * applied, resulting in a scalar." - */ - if (type_a->is_scalar() && type_b->is_scalar()) - return type_a; - - /* "* One operand is a scalar, and the other is a vector or matrix. - * In this case, the scalar operation is applied independently to each - * component of the vector or matrix, resulting in the same size - * vector or matrix." - */ - if (type_a->is_scalar()) { - if (!type_b->is_scalar()) - return type_b; - } else if (type_b->is_scalar()) { - return type_a; - } - - /* All of the combinations of , , - * , , and have been - * handled. - */ - assert(!type_a->is_scalar()); - assert(!type_b->is_scalar()); - - /* "* The two operands are vectors of the same size. In this case, the - * operation is done component-wise resulting in the same size - * vector." - */ - if (type_a->is_vector() && type_b->is_vector()) { - if (type_a == type_b) { - return type_a; - } else { - _mesa_glsl_error(loc, state, - "vector size mismatch for arithmetic operator"); - return glsl_type::error_type; - } - } - - /* All of the combinations of , , - * , , , and - * have been handled. At least one of the operands must - * be matrix. Further, since there are no integer matrix types, the base - * type of both operands must be float. - */ - assert(type_a->is_matrix() || type_b->is_matrix()); - assert(type_a->base_type == GLSL_TYPE_FLOAT); - assert(type_b->base_type == GLSL_TYPE_FLOAT); - - /* "* The operator is add (+), subtract (-), or divide (/), and the - * operands are matrices with the same number of rows and the same - * number of columns. In this case, the operation is done component- - * wise resulting in the same size matrix." - * * The operator is multiply (*), where both operands are matrices or - * one operand is a vector and the other a matrix. A right vector - * operand is treated as a column vector and a left vector operand as a - * row vector. In all these cases, it is required that the number of - * columns of the left operand is equal to the number of rows of the - * right operand. Then, the multiply (*) operation does a linear - * algebraic multiply, yielding an object that has the same number of - * rows as the left operand and the same number of columns as the right - * operand. Section 5.10 "Vector and Matrix Operations" explains in - * more detail how vectors and matrices are operated on." - */ - if (! multiply) { - if (type_a == type_b) - return type_a; - } else { - if (type_a->is_matrix() && type_b->is_matrix()) { - /* Matrix multiply. The columns of A must match the rows of B. Given - * the other previously tested constraints, this means the vector type - * of a row from A must be the same as the vector type of a column from - * B. - */ - if (type_a->row_type() == type_b->column_type()) { - /* The resulting matrix has the number of columns of matrix B and - * the number of rows of matrix A. We get the row count of A by - * looking at the size of a vector that makes up a column. The - * transpose (size of a row) is done for B. - */ - const glsl_type *const type = - glsl_type::get_instance(type_a->base_type, - type_a->column_type()->vector_elements, - type_b->row_type()->vector_elements); - assert(type != glsl_type::error_type); - - return type; - } - } else if (type_a->is_matrix()) { - /* A is a matrix and B is a column vector. Columns of A must match - * rows of B. Given the other previously tested constraints, this - * means the vector type of a row from A must be the same as the - * vector the type of B. - */ - if (type_a->row_type() == type_b) - return type_b; - } else { - assert(type_b->is_matrix()); - - /* A is a row vector and B is a matrix. Columns of A must match rows - * of B. Given the other previously tested constraints, this means - * the type of A must be the same as the vector type of a column from - * B. - */ - if (type_a == type_b->column_type()) - return type_a; - } - - _mesa_glsl_error(loc, state, "size mismatch for matrix multiplication"); - return glsl_type::error_type; - } - - - /* "All other cases are illegal." - */ - _mesa_glsl_error(loc, state, "type mismatch"); - return glsl_type::error_type; -} - - -static const struct glsl_type * -unary_arithmetic_result_type(const struct glsl_type *type, - struct _mesa_glsl_parse_state *state, YYLTYPE *loc) -{ - /* From GLSL 1.50 spec, page 57: - * - * "The arithmetic unary operators negate (-), post- and pre-increment - * and decrement (-- and ++) operate on integer or floating-point - * values (including vectors and matrices). All unary operators work - * component-wise on their operands. These result with the same type - * they operated on." - */ - if (!type->is_numeric()) { - _mesa_glsl_error(loc, state, - "Operands to arithmetic operators must be numeric"); - return glsl_type::error_type; - } - - return type; -} - - -static const struct glsl_type * -modulus_result_type(const struct glsl_type *type_a, - const struct glsl_type *type_b, - struct _mesa_glsl_parse_state *state, YYLTYPE *loc) -{ - /* From GLSL 1.50 spec, page 56: - * "The operator modulus (%) operates on signed or unsigned integers or - * integer vectors. The operand types must both be signed or both be - * unsigned." - */ - if (!type_a->is_integer() || !type_b->is_integer() - || (type_a->base_type != type_b->base_type)) { - _mesa_glsl_error(loc, state, "type mismatch"); - return glsl_type::error_type; - } - - /* "The operands cannot be vectors of differing size. If one operand is - * a scalar and the other vector, then the scalar is applied component- - * wise to the vector, resulting in the same type as the vector. If both - * are vectors of the same size, the result is computed component-wise." - */ - if (type_a->is_vector()) { - if (!type_b->is_vector() - || (type_a->vector_elements == type_b->vector_elements)) - return type_a; - } else - return type_b; - - /* "The operator modulus (%) is not defined for any other data types - * (non-integer types)." - */ - _mesa_glsl_error(loc, state, "type mismatch"); - return glsl_type::error_type; -} - - -static const struct glsl_type * -relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, - struct _mesa_glsl_parse_state *state, YYLTYPE *loc) -{ - const glsl_type *type_a = value_a->type; - const glsl_type *type_b = value_b->type; - - /* From GLSL 1.50 spec, page 56: - * "The relational operators greater than (>), less than (<), greater - * than or equal (>=), and less than or equal (<=) operate only on - * scalar integer and scalar floating-point expressions." - */ - if (!type_a->is_numeric() - || !type_b->is_numeric() - || !type_a->is_scalar() - || !type_b->is_scalar()) { - _mesa_glsl_error(loc, state, - "Operands to relational operators must be scalar and " - "numeric"); - return glsl_type::error_type; - } - - /* "Either the operands' types must match, or the conversions from - * Section 4.1.10 "Implicit Conversions" will be applied to the integer - * operand, after which the types must match." - */ - if (!apply_implicit_conversion(type_a, value_b, state) - && !apply_implicit_conversion(type_b, value_a, state)) { - _mesa_glsl_error(loc, state, - "Could not implicitly convert operands to " - "relational operator"); - return glsl_type::error_type; - } - type_a = value_a->type; - type_b = value_b->type; - - if (type_a->base_type != type_b->base_type) { - _mesa_glsl_error(loc, state, "base type mismatch"); - return glsl_type::error_type; - } - - /* "The result is scalar Boolean." - */ - return glsl_type::bool_type; -} - - -/** - * Validates that a value can be assigned to a location with a specified type - * - * Validates that \c rhs can be assigned to some location. If the types are - * not an exact match but an automatic conversion is possible, \c rhs will be - * converted. - * - * \return - * \c NULL if \c rhs cannot be assigned to a location with type \c lhs_type. - * Otherwise the actual RHS to be assigned will be returned. This may be - * \c rhs, or it may be \c rhs after some type conversion. - * - * \note - * In addition to being used for assignments, this function is used to - * type-check return values. - */ -ir_rvalue * -validate_assignment(struct _mesa_glsl_parse_state *state, - const glsl_type *lhs_type, ir_rvalue *rhs) -{ - const glsl_type *rhs_type = rhs->type; - - /* If there is already some error in the RHS, just return it. Anything - * else will lead to an avalanche of error message back to the user. - */ - if (rhs_type->is_error()) - return rhs; - - /* If the types are identical, the assignment can trivially proceed. - */ - if (rhs_type == lhs_type) - return rhs; - - /* If the array element types are the same and the size of the LHS is zero, - * the assignment is okay. - * - * Note: Whole-array assignments are not permitted in GLSL 1.10, but this - * is handled by ir_dereference::is_lvalue. - */ - if (lhs_type->is_array() && rhs->type->is_array() - && (lhs_type->element_type() == rhs->type->element_type()) - && (lhs_type->array_size() == 0)) { - return rhs; - } - - /* Check for implicit conversion in GLSL 1.20 */ - if (apply_implicit_conversion(lhs_type, rhs, state)) { - rhs_type = rhs->type; - if (rhs_type == lhs_type) - return rhs; - } - - return NULL; -} - -ir_rvalue * -do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, - ir_rvalue *lhs, ir_rvalue *rhs, - YYLTYPE lhs_loc) -{ - void *ctx = talloc_parent(state); - bool error_emitted = (lhs->type->is_error() || rhs->type->is_error()); - - if (!error_emitted) { - /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ - if (!lhs->is_lvalue()) { - _mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment"); - error_emitted = true; - } - } - - ir_rvalue *new_rhs = validate_assignment(state, lhs->type, rhs); - if (new_rhs == NULL) { - _mesa_glsl_error(& lhs_loc, state, "type mismatch"); - } else { - rhs = new_rhs; - - /* If the LHS array was not declared with a size, it takes it size from - * the RHS. If the LHS is an l-value and a whole array, it must be a - * dereference of a variable. Any other case would require that the LHS - * is either not an l-value or not a whole array. - */ - if (lhs->type->array_size() == 0) { - ir_dereference *const d = lhs->as_dereference(); - - assert(d != NULL); - - ir_variable *const var = d->variable_referenced(); - - assert(var != NULL); - - if (var->max_array_access >= unsigned(rhs->type->array_size())) { - /* FINISHME: This should actually log the location of the RHS. */ - _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due to " - "previous access", - var->max_array_access); - } - - var->type = glsl_type::get_array_instance(state, - lhs->type->element_type(), - rhs->type->array_size()); - } - } - - /* Most callers of do_assignment (assign, add_assign, pre_inc/dec, - * but not post_inc) need the converted assigned value as an rvalue - * to handle things like: - * - * i = j += 1; - * - * So we always just store the computed value being assigned to a - * temporary and return a deref of that temporary. If the rvalue - * ends up not being used, the temp will get copy-propagated out. - */ - ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp"); - ir_dereference_variable *deref_var = new(ctx) ir_dereference_variable(var); - instructions->push_tail(var); - instructions->push_tail(new(ctx) ir_assignment(deref_var, - rhs, - NULL)); - deref_var = new(ctx) ir_dereference_variable(var); - - instructions->push_tail(new(ctx) ir_assignment(lhs, - deref_var, - NULL)); - - return new(ctx) ir_dereference_variable(var); -} - - -/** - * Generate a new temporary and add its declaration to the instruction stream - */ -static ir_variable * -generate_temporary(const glsl_type *type, exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - char *name = (char *) malloc(sizeof(char) * 13); - - snprintf(name, 13, "tmp_%08X", state->temp_index); - state->temp_index++; - - ir_variable *const var = new(ctx) ir_variable(type, name); - instructions->push_tail(var); - - return var; -} - - -static ir_rvalue * -get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) -{ - void *ctx = talloc_parent(lvalue); - ir_variable *var; - - /* FINISHME: Give unique names to the temporaries. */ - var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp"); - var->mode = ir_var_auto; - - instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), - lvalue, NULL)); - - /* Once we've created this temporary, mark it read only so it's no - * longer considered an lvalue. - */ - var->read_only = true; - - return new(ctx) ir_dereference_variable(var); -} - - -ir_rvalue * -ast_node::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - (void) instructions; - (void) state; - - return NULL; -} - - -ir_rvalue * -ast_expression::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - static const int operations[AST_NUM_OPERATORS] = { - -1, /* ast_assign doesn't convert to ir_expression. */ - -1, /* ast_plus doesn't convert to ir_expression. */ - ir_unop_neg, - ir_binop_add, - ir_binop_sub, - ir_binop_mul, - ir_binop_div, - ir_binop_mod, - ir_binop_lshift, - ir_binop_rshift, - ir_binop_less, - ir_binop_greater, - ir_binop_lequal, - ir_binop_gequal, - ir_binop_equal, - ir_binop_nequal, - ir_binop_bit_and, - ir_binop_bit_xor, - ir_binop_bit_or, - ir_unop_bit_not, - ir_binop_logic_and, - ir_binop_logic_xor, - ir_binop_logic_or, - ir_unop_logic_not, - - /* Note: The following block of expression types actually convert - * to multiple IR instructions. - */ - ir_binop_mul, /* ast_mul_assign */ - ir_binop_div, /* ast_div_assign */ - ir_binop_mod, /* ast_mod_assign */ - ir_binop_add, /* ast_add_assign */ - ir_binop_sub, /* ast_sub_assign */ - ir_binop_lshift, /* ast_ls_assign */ - ir_binop_rshift, /* ast_rs_assign */ - ir_binop_bit_and, /* ast_and_assign */ - ir_binop_bit_xor, /* ast_xor_assign */ - ir_binop_bit_or, /* ast_or_assign */ - - -1, /* ast_conditional doesn't convert to ir_expression. */ - ir_binop_add, /* ast_pre_inc. */ - ir_binop_sub, /* ast_pre_dec. */ - ir_binop_add, /* ast_post_inc. */ - ir_binop_sub, /* ast_post_dec. */ - -1, /* ast_field_selection doesn't conv to ir_expression. */ - -1, /* ast_array_index doesn't convert to ir_expression. */ - -1, /* ast_function_call doesn't conv to ir_expression. */ - -1, /* ast_identifier doesn't convert to ir_expression. */ - -1, /* ast_int_constant doesn't convert to ir_expression. */ - -1, /* ast_uint_constant doesn't conv to ir_expression. */ - -1, /* ast_float_constant doesn't conv to ir_expression. */ - -1, /* ast_bool_constant doesn't conv to ir_expression. */ - -1, /* ast_sequence doesn't convert to ir_expression. */ - }; - ir_rvalue *result = NULL; - ir_rvalue *op[2]; - const struct glsl_type *type = glsl_type::error_type; - bool error_emitted = false; - YYLTYPE loc; - - loc = this->get_location(); - - switch (this->oper) { - case ast_assign: { - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - result = do_assignment(instructions, state, op[0], op[1], - this->subexpressions[0]->get_location()); - error_emitted = result->type->is_error(); - type = result->type; - break; - } - - case ast_plus: - op[0] = this->subexpressions[0]->hir(instructions, state); - - error_emitted = op[0]->type->is_error(); - if (type->is_error()) - op[0]->type = type; - - result = op[0]; - break; - - case ast_neg: - op[0] = this->subexpressions[0]->hir(instructions, state); - - type = unary_arithmetic_result_type(op[0]->type, state, & loc); - - error_emitted = type->is_error(); - - result = new(ctx) ir_expression(operations[this->oper], type, - op[0], NULL); - break; - - case ast_add: - case ast_sub: - case ast_mul: - case ast_div: - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - type = arithmetic_result_type(op[0], op[1], - (this->oper == ast_mul), - state, & loc); - error_emitted = type->is_error(); - - result = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - break; - - case ast_mod: - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - type = modulus_result_type(op[0]->type, op[1]->type, state, & loc); - - assert(operations[this->oper] == ir_binop_mod); - - result = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - error_emitted = type->is_error(); - break; - - case ast_lshift: - case ast_rshift: - _mesa_glsl_error(& loc, state, "FINISHME: implement bit-shift operators"); - error_emitted = true; - break; - - case ast_less: - case ast_greater: - case ast_lequal: - case ast_gequal: - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - type = relational_result_type(op[0], op[1], state, & loc); - - /* The relational operators must either generate an error or result - * in a scalar boolean. See page 57 of the GLSL 1.50 spec. - */ - assert(type->is_error() - || ((type->base_type == GLSL_TYPE_BOOL) - && type->is_scalar())); - - result = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - error_emitted = type->is_error(); - break; - - case ast_nequal: - case ast_equal: - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - /* From page 58 (page 64 of the PDF) of the GLSL 1.50 spec: - * - * "The equality operators equal (==), and not equal (!=) - * operate on all types. They result in a scalar Boolean. If - * the operand types do not match, then there must be a - * conversion from Section 4.1.10 "Implicit Conversions" - * applied to one operand that can make them match, in which - * case this conversion is done." - */ - if ((!apply_implicit_conversion(op[0]->type, op[1], state) - && !apply_implicit_conversion(op[1]->type, op[0], state)) - || (op[0]->type != op[1]->type)) { - _mesa_glsl_error(& loc, state, "operands of `%s' must have the same " - "type", (this->oper == ast_equal) ? "==" : "!="); - error_emitted = true; - } else if ((state->language_version <= 110) - && (op[0]->type->is_array() || op[1]->type->is_array())) { - _mesa_glsl_error(& loc, state, "array comparisons forbidden in " - "GLSL 1.10"); - error_emitted = true; - } - - result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, - op[0], op[1]); - type = glsl_type::bool_type; - - assert(result->type == glsl_type::bool_type); - break; - - case ast_bit_and: - case ast_bit_xor: - case ast_bit_or: - case ast_bit_not: - _mesa_glsl_error(& loc, state, "FINISHME: implement bit-wise operators"); - error_emitted = true; - break; - - case ast_logic_and: { - op[0] = this->subexpressions[0]->hir(instructions, state); - - if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { - YYLTYPE loc = this->subexpressions[0]->get_location(); - - _mesa_glsl_error(& loc, state, "LHS of `%s' must be scalar boolean", - operator_string(this->oper)); - error_emitted = true; - } - - ir_constant *op0_const = op[0]->constant_expression_value(); - if (op0_const) { - if (op0_const->value.b[0]) { - op[1] = this->subexpressions[1]->hir(instructions, state); - - if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { - YYLTYPE loc = this->subexpressions[1]->get_location(); - - _mesa_glsl_error(& loc, state, - "RHS of `%s' must be scalar boolean", - operator_string(this->oper)); - error_emitted = true; - } - result = op[1]; - } else { - result = op0_const; - } - type = glsl_type::bool_type; - } else { - ir_if *const stmt = new(ctx) ir_if(op[0]); - instructions->push_tail(stmt); - - op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); - - if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { - YYLTYPE loc = this->subexpressions[1]->get_location(); - - _mesa_glsl_error(& loc, state, - "RHS of `%s' must be scalar boolean", - operator_string(this->oper)); - error_emitted = true; - } - - ir_variable *const tmp = generate_temporary(glsl_type::bool_type, - instructions, state); - - ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); - ir_assignment *const then_assign = - new(ctx) ir_assignment(then_deref, op[1], NULL); - stmt->then_instructions.push_tail(then_assign); - - ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp); - ir_assignment *const else_assign = - new(ctx) ir_assignment(else_deref, new(ctx) ir_constant(false), NULL); - stmt->else_instructions.push_tail(else_assign); - - result = new(ctx) ir_dereference_variable(tmp); - type = tmp->type; - } - break; - } - - case ast_logic_or: { - op[0] = this->subexpressions[0]->hir(instructions, state); - - if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { - YYLTYPE loc = this->subexpressions[0]->get_location(); - - _mesa_glsl_error(& loc, state, "LHS of `%s' must be scalar boolean", - operator_string(this->oper)); - error_emitted = true; - } - - ir_constant *op0_const = op[0]->constant_expression_value(); - if (op0_const) { - if (op0_const->value.b[0]) { - result = op0_const; - } else { - op[1] = this->subexpressions[1]->hir(instructions, state); - - if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { - YYLTYPE loc = this->subexpressions[1]->get_location(); - - _mesa_glsl_error(& loc, state, - "RHS of `%s' must be scalar boolean", - operator_string(this->oper)); - error_emitted = true; - } - result = op[1]; - } - type = glsl_type::bool_type; - } else { - ir_if *const stmt = new(ctx) ir_if(op[0]); - instructions->push_tail(stmt); - - ir_variable *const tmp = generate_temporary(glsl_type::bool_type, - instructions, state); - - op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); - - if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { - YYLTYPE loc = this->subexpressions[1]->get_location(); - - _mesa_glsl_error(& loc, state, "RHS of `%s' must be scalar boolean", - operator_string(this->oper)); - error_emitted = true; - } - - ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); - ir_assignment *const then_assign = - new(ctx) ir_assignment(then_deref, new(ctx) ir_constant(true), NULL); - stmt->then_instructions.push_tail(then_assign); - - ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp); - ir_assignment *const else_assign = - new(ctx) ir_assignment(else_deref, op[1], NULL); - stmt->else_instructions.push_tail(else_assign); - - result = new(ctx) ir_dereference_variable(tmp); - type = tmp->type; - } - break; - } - - case ast_logic_xor: - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - - result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, - op[0], op[1]); - type = glsl_type::bool_type; - break; - - case ast_logic_not: - op[0] = this->subexpressions[0]->hir(instructions, state); - - if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { - YYLTYPE loc = this->subexpressions[0]->get_location(); - - _mesa_glsl_error(& loc, state, - "operand of `!' must be scalar boolean"); - error_emitted = true; - } - - result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, - op[0], NULL); - type = glsl_type::bool_type; - break; - - case ast_mul_assign: - case ast_div_assign: - case ast_add_assign: - case ast_sub_assign: { - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - type = arithmetic_result_type(op[0], op[1], - (this->oper == ast_mul_assign), - state, & loc); - - ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - - result = do_assignment(instructions, state, - (ir_rvalue *)op[0]->clone(NULL), temp_rhs, - this->subexpressions[0]->get_location()); - type = result->type; - error_emitted = (op[0]->type->is_error()); - - /* GLSL 1.10 does not allow array assignment. However, we don't have to - * explicitly test for this because none of the binary expression - * operators allow array operands either. - */ - - break; - } - - case ast_mod_assign: { - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - type = modulus_result_type(op[0]->type, op[1]->type, state, & loc); - - assert(operations[this->oper] == ir_binop_mod); - - struct ir_rvalue *temp_rhs; - temp_rhs = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - - result = do_assignment(instructions, state, - (ir_rvalue *)op[0]->clone(NULL), temp_rhs, - this->subexpressions[0]->get_location()); - type = result->type; - error_emitted = type->is_error(); - break; - } - - case ast_ls_assign: - case ast_rs_assign: - _mesa_glsl_error(& loc, state, - "FINISHME: implement bit-shift assignment operators"); - error_emitted = true; - break; - - case ast_and_assign: - case ast_xor_assign: - case ast_or_assign: - _mesa_glsl_error(& loc, state, - "FINISHME: implement logic assignment operators"); - error_emitted = true; - break; - - case ast_conditional: { - op[0] = this->subexpressions[0]->hir(instructions, state); - - /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: - * - * "The ternary selection operator (?:). It operates on three - * expressions (exp1 ? exp2 : exp3). This operator evaluates the - * first expression, which must result in a scalar Boolean." - */ - if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { - YYLTYPE loc = this->subexpressions[0]->get_location(); - - _mesa_glsl_error(& loc, state, "?: condition must be scalar boolean"); - error_emitted = true; - } - - /* The :? operator is implemented by generating an anonymous temporary - * followed by an if-statement. The last instruction in each branch of - * the if-statement assigns a value to the anonymous temporary. This - * temporary is the r-value of the expression. - */ - exec_list then_instructions; - exec_list else_instructions; - - op[1] = this->subexpressions[1]->hir(&then_instructions, state); - op[2] = this->subexpressions[2]->hir(&else_instructions, state); - - /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: - * - * "The second and third expressions can be any type, as - * long their types match, or there is a conversion in - * Section 4.1.10 "Implicit Conversions" that can be applied - * to one of the expressions to make their types match. This - * resulting matching type is the type of the entire - * expression." - */ - if ((!apply_implicit_conversion(op[1]->type, op[2], state) - && !apply_implicit_conversion(op[2]->type, op[1], state)) - || (op[1]->type != op[2]->type)) { - YYLTYPE loc = this->subexpressions[1]->get_location(); - - _mesa_glsl_error(& loc, state, "Second and third operands of ?: " - "operator must have matching types."); - error_emitted = true; - type = glsl_type::error_type; - } else { - type = op[1]->type; - } - - ir_constant *cond_val = op[0]->constant_expression_value(); - ir_constant *then_val = op[1]->constant_expression_value(); - ir_constant *else_val = op[2]->constant_expression_value(); - - if (then_instructions.is_empty() - && else_instructions.is_empty() - && (cond_val != NULL) && (then_val != NULL) && (else_val != NULL)) { - result = (cond_val->value.b[0]) ? then_val : else_val; - } else { - ir_variable *const tmp = generate_temporary(type, - instructions, state); - - ir_if *const stmt = new(ctx) ir_if(op[0]); - instructions->push_tail(stmt); - - then_instructions.move_nodes_to(& stmt->then_instructions); - ir_dereference *const then_deref = - new(ctx) ir_dereference_variable(tmp); - ir_assignment *const then_assign = - new(ctx) ir_assignment(then_deref, op[1], NULL); - stmt->then_instructions.push_tail(then_assign); - - else_instructions.move_nodes_to(& stmt->else_instructions); - ir_dereference *const else_deref = - new(ctx) ir_dereference_variable(tmp); - ir_assignment *const else_assign = - new(ctx) ir_assignment(else_deref, op[2], NULL); - stmt->else_instructions.push_tail(else_assign); - - result = new(ctx) ir_dereference_variable(tmp); - } - break; - } - - case ast_pre_inc: - case ast_pre_dec: { - op[0] = this->subexpressions[0]->hir(instructions, state); - if (op[0]->type->base_type == GLSL_TYPE_FLOAT) - op[1] = new(ctx) ir_constant(1.0f); - else - op[1] = new(ctx) ir_constant(1); - - type = arithmetic_result_type(op[0], op[1], false, state, & loc); - - struct ir_rvalue *temp_rhs; - temp_rhs = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - - result = do_assignment(instructions, state, - (ir_rvalue *)op[0]->clone(NULL), temp_rhs, - this->subexpressions[0]->get_location()); - type = result->type; - error_emitted = op[0]->type->is_error(); - break; - } - - case ast_post_inc: - case ast_post_dec: { - op[0] = this->subexpressions[0]->hir(instructions, state); - if (op[0]->type->base_type == GLSL_TYPE_FLOAT) - op[1] = new(ctx) ir_constant(1.0f); - else - op[1] = new(ctx) ir_constant(1); - - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - - type = arithmetic_result_type(op[0], op[1], false, state, & loc); - - struct ir_rvalue *temp_rhs; - temp_rhs = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - - /* Get a temporary of a copy of the lvalue before it's modified. - * This may get thrown away later. - */ - result = get_lvalue_copy(instructions, (ir_rvalue *)op[0]->clone(NULL)); - - (void)do_assignment(instructions, state, - (ir_rvalue *)op[0]->clone(NULL), temp_rhs, - this->subexpressions[0]->get_location()); - - type = result->type; - error_emitted = op[0]->type->is_error(); - break; - } - - case ast_field_selection: - result = _mesa_ast_field_selection_to_hir(this, instructions, state); - type = result->type; - break; - - case ast_array_index: { - YYLTYPE index_loc = subexpressions[1]->get_location(); - - op[0] = subexpressions[0]->hir(instructions, state); - op[1] = subexpressions[1]->hir(instructions, state); - - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - - ir_rvalue *const array = op[0]; - - result = new(ctx) ir_dereference_array(op[0], op[1]); - - /* Do not use op[0] after this point. Use array. - */ - op[0] = NULL; - - - if (error_emitted) - break; - - if (!array->type->is_array() - && !array->type->is_matrix() - && !array->type->is_vector()) { - _mesa_glsl_error(& index_loc, state, - "cannot dereference non-array / non-matrix / " - "non-vector"); - error_emitted = true; - } - - if (!op[1]->type->is_integer()) { - _mesa_glsl_error(& index_loc, state, - "array index must be integer type"); - error_emitted = true; - } else if (!op[1]->type->is_scalar()) { - _mesa_glsl_error(& index_loc, state, - "array index must be scalar"); - error_emitted = true; - } - - /* If the array index is a constant expression and the array has a - * declared size, ensure that the access is in-bounds. If the array - * index is not a constant expression, ensure that the array has a - * declared size. - */ - ir_constant *const const_index = op[1]->constant_expression_value(); - if (const_index != NULL) { - const int idx = const_index->value.i[0]; - const char *type_name; - unsigned bound = 0; - - if (array->type->is_matrix()) { - type_name = "matrix"; - } else if (array->type->is_vector()) { - type_name = "vector"; - } else { - type_name = "array"; - } - - /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec: - * - * "It is illegal to declare an array with a size, and then - * later (in the same shader) index the same array with an - * integral constant expression greater than or equal to the - * declared size. It is also illegal to index an array with a - * negative constant expression." - */ - if (array->type->is_matrix()) { - if (array->type->row_type()->vector_elements <= idx) { - bound = array->type->row_type()->vector_elements; - } - } else if (array->type->is_vector()) { - if (array->type->vector_elements <= idx) { - bound = array->type->vector_elements; - } - } else { - if ((array->type->array_size() > 0) - && (array->type->array_size() <= idx)) { - bound = array->type->array_size(); - } - } - - if (bound > 0) { - _mesa_glsl_error(& loc, state, "%s index must be < %u", - type_name, bound); - error_emitted = true; - } else if (idx < 0) { - _mesa_glsl_error(& loc, state, "%s index must be >= 0", - type_name); - error_emitted = true; - } - - if (array->type->is_array()) { - /* If the array is a variable dereference, it dereferences the - * whole array, by definition. Use this to get the variable. - * - * FINISHME: Should some methods for getting / setting / testing - * FINISHME: array access limits be added to ir_dereference? - */ - ir_variable *const v = array->whole_variable_referenced(); - if ((v != NULL) && (unsigned(idx) > v->max_array_access)) - v->max_array_access = idx; - } - } - - if (error_emitted) - result->type = glsl_type::error_type; - - type = result->type; - break; - } - - case ast_function_call: - /* Should *NEVER* get here. ast_function_call should always be handled - * by ast_function_expression::hir. - */ - assert(0); - break; - - case ast_identifier: { - /* ast_identifier can appear several places in a full abstract syntax - * tree. This particular use must be at location specified in the grammar - * as 'variable_identifier'. - */ - ir_variable *var = - state->symbols->get_variable(this->primary_expression.identifier); - - result = new(ctx) ir_dereference_variable(var); - - if (var != NULL) { - type = result->type; - } else { - _mesa_glsl_error(& loc, state, "`%s' undeclared", - this->primary_expression.identifier); - - error_emitted = true; - } - break; - } - - case ast_int_constant: - type = glsl_type::int_type; - result = new(ctx) ir_constant(this->primary_expression.int_constant); - break; - - case ast_uint_constant: - type = glsl_type::uint_type; - result = new(ctx) ir_constant(this->primary_expression.uint_constant); - break; - - case ast_float_constant: - type = glsl_type::float_type; - result = new(ctx) ir_constant(this->primary_expression.float_constant); - break; - - case ast_bool_constant: - type = glsl_type::bool_type; - result = new(ctx) ir_constant(bool(this->primary_expression.bool_constant)); - break; - - case ast_sequence: { - /* It should not be possible to generate a sequence in the AST without - * any expressions in it. - */ - assert(!this->expressions.is_empty()); - - /* The r-value of a sequence is the last expression in the sequence. If - * the other expressions in the sequence do not have side-effects (and - * therefore add instructions to the instruction list), they get dropped - * on the floor. - */ - foreach_list_typed (ast_node, ast, link, &this->expressions) - result = ast->hir(instructions, state); - - type = result->type; - - /* Any errors should have already been emitted in the loop above. - */ - error_emitted = true; - break; - } - } - - if (type->is_error() && !error_emitted) - _mesa_glsl_error(& loc, state, "type mismatch"); - - return result; -} - - -ir_rvalue * -ast_expression_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - /* It is possible to have expression statements that don't have an - * expression. This is the solitary semicolon: - * - * for (i = 0; i < 5; i++) - * ; - * - * In this case the expression will be NULL. Test for NULL and don't do - * anything in that case. - */ - if (expression != NULL) - expression->hir(instructions, state); - - /* Statements do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_compound_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (new_scope) - state->symbols->push_scope(); - - foreach_list_typed (ast_node, ast, link, &this->statements) - ast->hir(instructions, state); - - if (new_scope) - state->symbols->pop_scope(); - - /* Compound statements do not have r-values. - */ - return NULL; -} - - -static const glsl_type * -process_array_type(const glsl_type *base, ast_node *array_size, - struct _mesa_glsl_parse_state *state) -{ - unsigned length = 0; - - /* FINISHME: Reject delcarations of multidimensional arrays. */ - - if (array_size != NULL) { - exec_list dummy_instructions; - ir_rvalue *const ir = array_size->hir(& dummy_instructions, state); - YYLTYPE loc = array_size->get_location(); - - /* FINISHME: Verify that the grammar forbids side-effects in array - * FINISHME: sizes. i.e., 'vec4 [x = 12] data' - */ - assert(dummy_instructions.is_empty()); - - if (ir != NULL) { - if (!ir->type->is_integer()) { - _mesa_glsl_error(& loc, state, "array size must be integer type"); - } else if (!ir->type->is_scalar()) { - _mesa_glsl_error(& loc, state, "array size must be scalar type"); - } else { - ir_constant *const size = ir->constant_expression_value(); - - if (size == NULL) { - _mesa_glsl_error(& loc, state, "array size must be a " - "constant valued expression"); - } else if (size->value.i[0] <= 0) { - _mesa_glsl_error(& loc, state, "array size must be > 0"); - } else { - assert(size->type == ir->type); - length = size->value.u[0]; - } - } - } - } - - return glsl_type::get_array_instance(state, base, length); -} - - -const glsl_type * -ast_type_specifier::glsl_type(const char **name, - struct _mesa_glsl_parse_state *state) const -{ - const struct glsl_type *type; - - if ((this->type_specifier == ast_struct) && (this->type_name == NULL)) { - /* FINISHME: Handle annonymous structures. */ - type = NULL; - } else { - type = state->symbols->get_type(this->type_name); - *name = this->type_name; - - if (this->is_array) { - type = process_array_type(type, this->array_size, state); - } - } - - return type; -} - - -static void -apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, - struct ir_variable *var, - struct _mesa_glsl_parse_state *state, - YYLTYPE *loc) -{ - if (qual->invariant) - var->invariant = 1; - - /* FINISHME: Mark 'in' variables at global scope as read-only. */ - if (qual->constant || qual->attribute || qual->uniform - || (qual->varying && (state->target == fragment_shader))) - var->read_only = 1; - - if (qual->centroid) - var->centroid = 1; - - if (qual->attribute && state->target != vertex_shader) { - var->type = glsl_type::error_type; - _mesa_glsl_error(loc, state, - "`attribute' variables may not be declared in the " - "%s shader", - _mesa_glsl_shader_target_name(state->target)); - } - - /* From page 25 (page 31 of the PDF) of the GLSL 1.10 spec: - * - * "The varying qualifier can be used only with the data types - * float, vec2, vec3, vec4, mat2, mat3, and mat4, or arrays of - * these." - */ - if (qual->varying) { - const glsl_type *non_array_type; - - if (var->type && var->type->is_array()) - non_array_type = var->type->fields.array; - else - non_array_type = var->type; - - if (non_array_type && non_array_type->base_type != GLSL_TYPE_FLOAT) { - var->type = glsl_type::error_type; - _mesa_glsl_error(loc, state, - "varying variables must be of base type float"); - } - } - - if (qual->in && qual->out) - var->mode = ir_var_inout; - else if (qual->attribute || qual->in - || (qual->varying && (state->target == fragment_shader))) - var->mode = ir_var_in; - else if (qual->out || (qual->varying && (state->target == vertex_shader))) - var->mode = ir_var_out; - else if (qual->uniform) - var->mode = ir_var_uniform; - else - var->mode = ir_var_auto; - - if (qual->uniform) - var->shader_in = true; - - /* Any 'in' or 'inout' variables at global scope must be marked as being - * shader inputs. Likewise, any 'out' or 'inout' variables at global scope - * must be marked as being shader outputs. - */ - if (state->current_function == NULL) { - switch (var->mode) { - case ir_var_in: - case ir_var_uniform: - var->shader_in = true; - break; - case ir_var_out: - var->shader_out = true; - break; - case ir_var_inout: - var->shader_in = true; - var->shader_out = true; - break; - default: - break; - } - } - - if (qual->flat) - var->interpolation = ir_var_flat; - else if (qual->noperspective) - var->interpolation = ir_var_noperspective; - else - var->interpolation = ir_var_smooth; - - if (var->type->is_array() && (state->language_version >= 120)) { - var->array_lvalue = true; - } -} - - -ir_rvalue * -ast_declarator_list::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - const struct glsl_type *decl_type; - const char *type_name = NULL; - ir_rvalue *result = NULL; - YYLTYPE loc = this->get_location(); - - /* The type specifier may contain a structure definition. Process that - * before any of the variable declarations. - */ - (void) this->type->specifier->hir(instructions, state); - - /* FINISHME: Handle vertex shader "invariant" declarations that do not - * FINISHME: include a type. These re-declare built-in variables to be - * FINISHME: invariant. - */ - - decl_type = this->type->specifier->glsl_type(& type_name, state); - if (this->declarations.is_empty()) { - /* There are only two valid cases where the declaration list can be - * empty. - * - * 1. The declaration is setting the default precision of a built-in - * type (e.g., 'precision highp vec4;'). - * - * 2. Adding 'invariant' to an existing vertex shader output. - */ - - if (this->type->qualifier.invariant) { - } else if (decl_type != NULL) { - } else { - _mesa_glsl_error(& loc, state, "incomplete declaration"); - } - } - - foreach_list_typed (ast_declaration, decl, link, &this->declarations) { - const struct glsl_type *var_type; - struct ir_variable *var; - - /* FINISHME: Emit a warning if a variable declaration shadows a - * FINISHME: declaration at a higher scope. - */ - - if ((decl_type == NULL) || decl_type->is_void()) { - if (type_name != NULL) { - _mesa_glsl_error(& loc, state, - "invalid type `%s' in declaration of `%s'", - type_name, decl->identifier); - } else { - _mesa_glsl_error(& loc, state, - "invalid type in declaration of `%s'", - decl->identifier); - } - continue; - } - - if (decl->is_array) { - var_type = process_array_type(decl_type, decl->array_size, state); - } else { - var_type = decl_type; - } - - var = new(ctx) ir_variable(var_type, decl->identifier); - - /* From page 22 (page 28 of the PDF) of the GLSL 1.10 specification; - * - * "Global variables can only use the qualifiers const, - * attribute, uni form, or varying. Only one may be - * specified. - * - * Local variables can only use the qualifier const." - * - * This is relaxed in GLSL 1.30. - */ - if (state->language_version < 120) { - if (this->type->qualifier.out) { - _mesa_glsl_error(& loc, state, - "`out' qualifier in declaration of `%s' " - "only valid for function parameters in GLSL 1.10.", - decl->identifier); - } - if (this->type->qualifier.in) { - _mesa_glsl_error(& loc, state, - "`in' qualifier in declaration of `%s' " - "only valid for function parameters in GLSL 1.10.", - decl->identifier); - } - /* FINISHME: Test for other invalid qualifiers. */ - } - - apply_type_qualifier_to_variable(& this->type->qualifier, var, state, - & loc); - - /* Attempt to add the variable to the symbol table. If this fails, it - * means the variable has already been declared at this scope. Arrays - * fudge this rule a little bit. - * - * From page 24 (page 30 of the PDF) of the GLSL 1.50 spec, - * - * "It is legal to declare an array without a size and then - * later re-declare the same name as an array of the same - * type and specify a size." - */ - if (state->symbols->name_declared_this_scope(decl->identifier)) { - ir_variable *const earlier = - state->symbols->get_variable(decl->identifier); - - if ((earlier != NULL) - && (earlier->type->array_size() == 0) - && var->type->is_array() - && (var->type->element_type() == earlier->type->element_type())) { - /* FINISHME: This doesn't match the qualifiers on the two - * FINISHME: declarations. It's not 100% clear whether this is - * FINISHME: required or not. - */ - - if (var->type->array_size() <= (int)earlier->max_array_access) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "array size must be > %u due to " - "previous access", - earlier->max_array_access); - } - - earlier->type = var->type; - delete var; - var = NULL; - } else { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "`%s' redeclared", - decl->identifier); - } - - continue; - } - - /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec, - * - * "Identifiers starting with "gl_" are reserved for use by - * OpenGL, and may not be declared in a shader as either a - * variable or a function." - */ - if (strncmp(decl->identifier, "gl_", 3) == 0) { - /* FINISHME: This should only trigger if we're not redefining - * FINISHME: a builtin (to add a qualifier, for example). - */ - _mesa_glsl_error(& loc, state, - "identifier `%s' uses reserved `gl_' prefix", - decl->identifier); - } - - instructions->push_tail(var); - - if (state->current_function != NULL) { - const char *mode = NULL; - const char *extra = ""; - - /* There is no need to check for 'inout' here because the parser will - * only allow that in function parameter lists. - */ - if (this->type->qualifier.attribute) { - mode = "attribute"; - } else if (this->type->qualifier.uniform) { - mode = "uniform"; - } else if (this->type->qualifier.varying) { - mode = "varying"; - } else if (this->type->qualifier.in) { - mode = "in"; - extra = " or in function parameter list"; - } else if (this->type->qualifier.out) { - mode = "out"; - extra = " or in function parameter list"; - } - - if (mode) { - _mesa_glsl_error(& loc, state, - "%s variable `%s' must be declared at " - "global scope%s", - mode, var->name, extra); - } - } else if (var->mode == ir_var_in) { - if (state->target == vertex_shader) { - bool error_emitted = false; - - /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: - * - * "Vertex shader inputs can only be float, floating-point - * vectors, matrices, signed and unsigned integers and integer - * vectors. Vertex shader inputs can also form arrays of these - * types, but not structures." - * - * From page 31 (page 27 of the PDF) of the GLSL 1.30 spec: - * - * "Vertex shader inputs can only be float, floating-point - * vectors, matrices, signed and unsigned integers and integer - * vectors. They cannot be arrays or structures." - * - * From page 23 (page 29 of the PDF) of the GLSL 1.20 spec: - * - * "The attribute qualifier can be used only with float, - * floating-point vectors, and matrices. Attribute variables - * cannot be declared as arrays or structures." - */ - const glsl_type *check_type = var->type->is_array() - ? var->type->fields.array : var->type; - - switch (check_type->base_type) { - case GLSL_TYPE_FLOAT: - break; - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - if (state->language_version > 120) - break; - /* FALLTHROUGH */ - default: - _mesa_glsl_error(& loc, state, - "vertex shader input / attribute cannot have " - "type %s`%s'", - var->type->is_array() ? "array of " : "", - check_type->name); - error_emitted = true; - } - - if (!error_emitted && (state->language_version <= 130) - && var->type->is_array()) { - _mesa_glsl_error(& loc, state, - "vertex shader input / attribute cannot have " - "array type"); - error_emitted = true; - } - } - } - - if (decl->initializer != NULL) { - YYLTYPE initializer_loc = decl->initializer->get_location(); - - /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec: - * - * "All uniform variables are read-only and are initialized either - * directly by an application via API commands, or indirectly by - * OpenGL." - */ - if ((state->language_version <= 110) - && (var->mode == ir_var_uniform)) { - _mesa_glsl_error(& initializer_loc, state, - "cannot initialize uniforms in GLSL 1.10"); - } - - if (var->type->is_sampler()) { - _mesa_glsl_error(& initializer_loc, state, - "cannot initialize samplers"); - } - - if ((var->mode == ir_var_in) && (state->current_function == NULL)) { - _mesa_glsl_error(& initializer_loc, state, - "cannot initialize %s shader input / %s", - _mesa_glsl_shader_target_name(state->target), - (state->target == vertex_shader) - ? "attribute" : "varying"); - } - - ir_dereference *const lhs = new(ctx) ir_dereference_variable(var); - ir_rvalue *rhs = decl->initializer->hir(instructions, state); - - /* Calculate the constant value if this is a const or uniform - * declaration. - */ - if (this->type->qualifier.constant || this->type->qualifier.uniform) { - ir_constant *constant_value = rhs->constant_expression_value(); - if (!constant_value) { - _mesa_glsl_error(& initializer_loc, state, - "initializer of %s variable `%s' must be a " - "constant expression", - (this->type->qualifier.constant) - ? "const" : "uniform", - decl->identifier); - } else { - rhs = constant_value; - var->constant_value = constant_value; - } - } - - if (rhs && !rhs->type->is_error()) { - bool temp = var->read_only; - if (this->type->qualifier.constant) - var->read_only = false; - - /* Never emit code to initialize a uniform. - */ - if (!this->type->qualifier.uniform) - result = do_assignment(instructions, state, lhs, rhs, - this->get_location()); - var->read_only = temp; - } - } - - /* From page 23 (page 29 of the PDF) of the GLSL 1.10 spec: - * - * "It is an error to write to a const variable outside of - * its declaration, so they must be initialized when - * declared." - */ - if (this->type->qualifier.constant && decl->initializer == NULL) { - _mesa_glsl_error(& loc, state, - "const declaration of `%s' must be initialized"); - } - - /* Add the vairable to the symbol table after processing the initializer. - * This differs from most C-like languages, but it follows the GLSL - * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 - * spec: - * - * "Within a declaration, the scope of a name starts immediately - * after the initializer if present or immediately after the name - * being declared if not." - */ - const bool added_variable = - state->symbols->add_variable(decl->identifier, var); - assert(added_variable); - } - - - /* Generally, variable declarations do not have r-values. However, - * one is used for the declaration in - * - * while (bool b = some_condition()) { - * ... - * } - * - * so we return the rvalue from the last seen declaration here. - */ - return result; -} - - -ir_rvalue * -ast_parameter_declarator::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - const struct glsl_type *type; - const char *name = NULL; - YYLTYPE loc = this->get_location(); - - type = this->type->specifier->glsl_type(& name, state); - - if (type == NULL) { - if (name != NULL) { - _mesa_glsl_error(& loc, state, - "invalid type `%s' in declaration of `%s'", - name, this->identifier); - } else { - _mesa_glsl_error(& loc, state, - "invalid type in declaration of `%s'", - this->identifier); - } - - type = glsl_type::error_type; - } - - /* From page 62 (page 68 of the PDF) of the GLSL 1.50 spec: - * - * "Functions that accept no input arguments need not use void in the - * argument list because prototypes (or definitions) are required and - * therefore there is no ambiguity when an empty argument list "( )" is - * declared. The idiom "(void)" as a parameter list is provided for - * convenience." - * - * Placing this check here prevents a void parameter being set up - * for a function, which avoids tripping up checks for main taking - * parameters and lookups of an unnamed symbol. - */ - if (type->is_void()) { - if (this->identifier != NULL) - _mesa_glsl_error(& loc, state, - "named parameter cannot have type `void'"); - - is_void = true; - return NULL; - } - - if (formal_parameter && (this->identifier == NULL)) { - _mesa_glsl_error(& loc, state, "formal parameter lacks a name"); - return NULL; - } - - is_void = false; - ir_variable *var = new(ctx) ir_variable(type, this->identifier); - - /* FINISHME: Handle array declarations. Note that this requires - * FINISHME: complete handling of constant expressions. - */ - - /* Apply any specified qualifiers to the parameter declaration. Note that - * for function parameters the default mode is 'in'. - */ - apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc); - if (var->mode == ir_var_auto) - var->mode = ir_var_in; - - instructions->push_tail(var); - - /* Parameter declarations do not have r-values. - */ - return NULL; -} - - -void -ast_parameter_declarator::parameters_to_hir(exec_list *ast_parameters, - bool formal, - exec_list *ir_parameters, - _mesa_glsl_parse_state *state) -{ - ast_parameter_declarator *void_param = NULL; - unsigned count = 0; - - foreach_list_typed (ast_parameter_declarator, param, link, ast_parameters) { - param->formal_parameter = formal; - param->hir(ir_parameters, state); - - if (param->is_void) - void_param = param; - - count++; - } - - if ((void_param != NULL) && (count > 1)) { - YYLTYPE loc = void_param->get_location(); - - _mesa_glsl_error(& loc, state, - "`void' parameter must be only parameter"); - } -} - - -ir_rvalue * -ast_function::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - ir_function *f = NULL; - ir_function_signature *sig = NULL; - exec_list hir_parameters; - - - /* Convert the list of function parameters to HIR now so that they can be - * used below to compare this function's signature with previously seen - * signatures for functions with the same name. - */ - ast_parameter_declarator::parameters_to_hir(& this->parameters, - is_definition, - & hir_parameters, state); - - const char *return_type_name; - const glsl_type *return_type = - this->return_type->specifier->glsl_type(& return_type_name, state); - - assert(return_type != NULL); - - /* Verify that this function's signature either doesn't match a previously - * seen signature for a function with the same name, or, if a match is found, - * that the previously seen signature does not have an associated definition. - */ - const char *const name = identifier; - f = state->symbols->get_function(name); - if (f != NULL) { - ir_function_signature *sig = f->exact_matching_signature(&hir_parameters); - if (sig != NULL) { - const char *badvar = sig->qualifiers_match(&hir_parameters); - if (badvar != NULL) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(&loc, state, "function `%s' parameter `%s' " - "qualifiers don't match prototype", name, badvar); - } - - if (sig->return_type != return_type) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(&loc, state, "function `%s' return type doesn't " - "match prototype", name); - } - - if (is_definition && sig->is_defined) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "function `%s' redefined", name); - sig = NULL; - } - } - } else if (state->symbols->name_declared_this_scope(name)) { - /* This function name shadows a non-function use of the same name. - */ - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "function name `%s' conflicts with " - "non-function", name); - sig = NULL; - } else { - f = new(ctx) ir_function(name); - state->symbols->add_function(f->name, f); - - /* Emit the new function header */ - instructions->push_tail(f); - } - - /* Verify the return type of main() */ - if (strcmp(name, "main") == 0) { - if (! return_type->is_void()) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "main() must return void"); - } - - if (!hir_parameters.is_empty()) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "main() must not take any parameters"); - } - } - - /* Finish storing the information about this new function in its signature. - */ - if (sig == NULL) { - sig = new(ctx) ir_function_signature(return_type); - f->add_signature(sig); - } - - sig->replace_parameters(&hir_parameters); - signature = sig; - - /* Function declarations (prototypes) do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_function_definition::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - prototype->is_definition = true; - prototype->hir(instructions, state); - - ir_function_signature *signature = prototype->signature; - - assert(state->current_function == NULL); - state->current_function = signature; - - /* Duplicate parameters declared in the prototype as concrete variables. - * Add these to the symbol table. - */ - state->symbols->push_scope(); - foreach_iter(exec_list_iterator, iter, signature->parameters) { - ir_variable *const var = ((ir_instruction *) iter.get())->as_variable(); - - assert(var != NULL); - - /* The only way a parameter would "exist" is if two parameters have - * the same name. - */ - if (state->symbols->name_declared_this_scope(var->name)) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "parameter `%s' redeclared", var->name); - } else { - state->symbols->add_variable(var->name, var); - } - } - - /* Convert the body of the function to HIR. */ - this->body->hir(&signature->body, state); - signature->is_defined = true; - - state->symbols->pop_scope(); - - assert(state->current_function == signature); - state->current_function = NULL; - - /* Function definitions do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_jump_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - - switch (mode) { - case ast_return: { - ir_return *inst; - assert(state->current_function); - - if (opt_return_value) { - if (state->current_function->return_type->base_type == - GLSL_TYPE_VOID) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "`return` with a value, in function `%s' " - "returning void", - state->current_function->function_name()); - } - - ir_expression *const ret = (ir_expression *) - opt_return_value->hir(instructions, state); - assert(ret != NULL); - - /* FINISHME: Make sure the type of the return value matches the return - * FINISHME: type of the enclosing function. - */ - - inst = new(ctx) ir_return(ret); - } else { - if (state->current_function->return_type->base_type != - GLSL_TYPE_VOID) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "`return' with no value, in function %s returning " - "non-void", - state->current_function->function_name()); - } - inst = new(ctx) ir_return; - } - - instructions->push_tail(inst); - break; - } - - case ast_discard: - /* FINISHME: discard support */ - if (state->target != fragment_shader) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "`discard' may only appear in a fragment shader"); - } - break; - - case ast_break: - case ast_continue: - /* FINISHME: Handle switch-statements. They cannot contain 'continue', - * FINISHME: and they use a different IR instruction for 'break'. - */ - /* FINISHME: Correctly handle the nesting. If a switch-statement is - * FINISHME: inside a loop, a 'continue' is valid and will bind to the - * FINISHME: loop. - */ - if (state->loop_or_switch_nesting == NULL) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "`%s' may only appear in a loop", - (mode == ast_break) ? "break" : "continue"); - } else { - ir_loop *const loop = state->loop_or_switch_nesting->as_loop(); - - if (loop != NULL) { - ir_loop_jump *const jump = - new(ctx) ir_loop_jump((mode == ast_break) - ? ir_loop_jump::jump_break - : ir_loop_jump::jump_continue); - instructions->push_tail(jump); - } - } - - break; - } - - /* Jump instructions do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_selection_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - - ir_rvalue *const condition = this->condition->hir(instructions, state); - - /* From page 66 (page 72 of the PDF) of the GLSL 1.50 spec: - * - * "Any expression whose type evaluates to a Boolean can be used as the - * conditional expression bool-expression. Vector types are not accepted - * as the expression to if." - * - * The checks are separated so that higher quality diagnostics can be - * generated for cases where both rules are violated. - */ - if (!condition->type->is_boolean() || !condition->type->is_scalar()) { - YYLTYPE loc = this->condition->get_location(); - - _mesa_glsl_error(& loc, state, "if-statement condition must be scalar " - "boolean"); - } - - ir_if *const stmt = new(ctx) ir_if(condition); - - if (then_statement != NULL) - then_statement->hir(& stmt->then_instructions, state); - - if (else_statement != NULL) - else_statement->hir(& stmt->else_instructions, state); - - instructions->push_tail(stmt); - - /* if-statements do not have r-values. - */ - return NULL; -} - - -void -ast_iteration_statement::condition_to_hir(ir_loop *stmt, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - - if (condition != NULL) { - ir_rvalue *const cond = - condition->hir(& stmt->body_instructions, state); - - if ((cond == NULL) - || !cond->type->is_boolean() || !cond->type->is_scalar()) { - YYLTYPE loc = condition->get_location(); - - _mesa_glsl_error(& loc, state, - "loop condition must be scalar boolean"); - } else { - /* As the first code in the loop body, generate a block that looks - * like 'if (!condition) break;' as the loop termination condition. - */ - ir_rvalue *const not_cond = - new(ctx) ir_expression(ir_unop_logic_not, glsl_type::bool_type, cond, - NULL); - - ir_if *const if_stmt = new(ctx) ir_if(not_cond); - - ir_jump *const break_stmt = - new(ctx) ir_loop_jump(ir_loop_jump::jump_break); - - if_stmt->then_instructions.push_tail(break_stmt); - stmt->body_instructions.push_tail(if_stmt); - } - } -} - - -ir_rvalue * -ast_iteration_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - - /* For-loops and while-loops start a new scope, but do-while loops do not. - */ - if (mode != ast_do_while) - state->symbols->push_scope(); - - if (init_statement != NULL) - init_statement->hir(instructions, state); - - ir_loop *const stmt = new(ctx) ir_loop(); - instructions->push_tail(stmt); - - /* Track the current loop and / or switch-statement nesting. - */ - ir_instruction *const nesting = state->loop_or_switch_nesting; - state->loop_or_switch_nesting = stmt; - - if (mode != ast_do_while) - condition_to_hir(stmt, state); - - if (body != NULL) - body->hir(& stmt->body_instructions, state); - - if (rest_expression != NULL) - rest_expression->hir(& stmt->body_instructions, state); - - if (mode == ast_do_while) - condition_to_hir(stmt, state); - - if (mode != ast_do_while) - state->symbols->pop_scope(); - - /* Restore previous nesting before returning. - */ - state->loop_or_switch_nesting = nesting; - - /* Loops do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_type_specifier::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (this->structure != NULL) - return this->structure->hir(instructions, state); - - return NULL; -} - - -ir_rvalue * -ast_struct_specifier::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - unsigned decl_count = 0; - - /* Make an initial pass over the list of structure fields to determine how - * many there are. Each element in this list is an ast_declarator_list. - * This means that we actually need to count the number of elements in the - * 'declarations' list in each of the elements. - */ - foreach_list_typed (ast_declarator_list, decl_list, link, - &this->declarations) { - foreach_list_const (decl_ptr, & decl_list->declarations) { - decl_count++; - } - } - - - /* Allocate storage for the structure fields and process the field - * declarations. As the declarations are processed, try to also convert - * the types to HIR. This ensures that structure definitions embedded in - * other structure definitions are processed. - */ - glsl_struct_field *const fields = (glsl_struct_field *) - malloc(sizeof(*fields) * decl_count); - - unsigned i = 0; - foreach_list_typed (ast_declarator_list, decl_list, link, - &this->declarations) { - const char *type_name; - - decl_list->type->specifier->hir(instructions, state); - - const glsl_type *decl_type = - decl_list->type->specifier->glsl_type(& type_name, state); - - foreach_list_typed (ast_declaration, decl, link, - &decl_list->declarations) { - const struct glsl_type *const field_type = - (decl->is_array) - ? process_array_type(decl_type, decl->array_size, state) - : decl_type; - - fields[i].type = (field_type != NULL) - ? field_type : glsl_type::error_type; - fields[i].name = decl->identifier; - i++; - } - } - - assert(i == decl_count); - - const char *name; - if (this->name == NULL) { - static unsigned anon_count = 1; - char buf[32]; - - snprintf(buf, sizeof(buf), "#anon_struct_%04x", anon_count); - anon_count++; - - name = strdup(buf); - } else { - name = this->name; - } - - glsl_type *t = new(ctx) glsl_type(fields, decl_count, name); - - YYLTYPE loc = this->get_location(); - if (!state->symbols->add_type(name, t)) { - _mesa_glsl_error(& loc, state, "struct `%s' previously defined", name); - } else { - /* This logic is a bit tricky. It is an error to declare a structure at - * global scope if there is also a function with the same name. - */ - if ((state->current_function == NULL) - && (state->symbols->get_function(name) != NULL)) { - _mesa_glsl_error(& loc, state, "name `%s' previously defined", name); - } else { - t->generate_constructor(state->symbols); - } - - const glsl_type **s = (const glsl_type **) - realloc(state->user_structures, - sizeof(state->user_structures[0]) * - (state->num_user_structures + 1)); - if (s != NULL) { - s[state->num_user_structures] = t; - state->user_structures = s; - state->num_user_structures++; - } - } - - /* Structure type definitions do not have r-values. - */ - return NULL; -} diff --git a/ast_type.cpp b/ast_type.cpp deleted file mode 100644 index cb0852bb773..00000000000 --- a/ast_type.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include "ast.h" -#include "symbol_table.h" - -void -ast_type_specifier::print(void) const -{ - if (type_specifier == ast_struct) { - structure->print(); - } else { - printf("%s ", type_name); - } - - if (is_array) { - printf("[ "); - - if (array_size) { - array_size->print(); - } - - printf("] "); - } -} - -ast_type_specifier::ast_type_specifier(int specifier) - : type_specifier(ast_types(specifier)), type_name(NULL), structure(NULL), - is_array(false), array_size(NULL), precision(ast_precision_high) -{ - static const char *const names[] = { - "void", - "float", - "int", - "uint", - "bool", - "vec2", - "vec3", - "vec4", - "bvec2", - "bvec3", - "bvec4", - "ivec2", - "ivec3", - "ivec4", - "uvec2", - "uvec3", - "uvec4", - "mat2", - "mat2x3", - "mat2x4", - "mat3x2", - "mat3", - "mat3x4", - "mat4x2", - "mat4x3", - "mat4", - "sampler1D", - "sampler2D", - "sampler2DRect", - "sampler3D", - "samplerCube", - "sampler1DShadow", - "sampler2DShadow", - "sampler2DRectShadow", - "samplerCubeShadow", - "sampler1DArray", - "sampler2DArray", - "sampler1DArrayShadow", - "sampler2DArrayShadow", - "isampler1D", - "isampler2D", - "isampler3D", - "isamplerCube", - "isampler1DArray", - "isampler2DArray", - "usampler1D", - "usampler2D", - "usampler3D", - "usamplerCube", - "usampler1DArray", - "usampler2DArray", - - NULL, /* ast_struct */ - NULL /* ast_type_name */ - }; - - type_name = names[specifier]; -} diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 904cd6746c8..00000000000 --- a/autogen.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/sh - -srcdir=`dirname $0` -test -z "$srcdir" && srcdir=. - -ORIGDIR=`pwd` -cd $srcdir - -autoreconf -v --install || exit 1 -cd $ORIGDIR || exit $? - -$srcdir/configure --enable-maintainer-mode "$@" diff --git a/builtin_function.cpp b/builtin_function.cpp deleted file mode 100644 index d248388a1ab..00000000000 --- a/builtin_function.cpp +++ /dev/null @@ -1,5080 +0,0 @@ -/* DO NOT MODIFY - automatically generated by generate_builtins.pl */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include "glsl_parser_extras.h" -#include "ir_reader.h" - -void -read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, - const char **functions, unsigned count) -{ - if (st->error) - return; - - for (unsigned i = 0; i < count; i++) { - _mesa_glsl_read_ir(st, instructions, functions[i]); - - if (st->error) { - printf("error reading builtin: %.35s ...\n", functions[i]); - return; - } - } -} - -/* 110 builtins */ - -static const char *builtins_110_abs = { - "((function abs\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float abs (var_ref arg0)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 abs (var_ref arg0)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 abs (var_ref arg0)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 abs (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_all = { - "((function all\n" - " (signature bool\n" - " (parameters\n" - " (declare (in) bvec2 arg0))\n" - " ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n" - "\n" - " (signature bool\n" - " (parameters\n" - " (declare (in) bvec3 arg0))\n" - " ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n" - "\n" - " (signature bool\n" - " (parameters\n" - " (declare (in) bvec4 arg0))\n" - " ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n" - "))\n" -}; - -static const char *builtins_110_any = { - "((function any\n" - " (signature bool\n" - " (parameters\n" - " (declare (in) bvec2 arg0))\n" - " ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n" - "\n" - " (signature bool\n" - " (parameters\n" - " (declare (in) bvec3 arg0))\n" - " ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n" - "\n" - " (signature bool\n" - " (parameters\n" - " (declare (in) bvec4 arg0))\n" - " ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n" - "))\n" -}; - -static const char *builtins_110_asin = { - "((function asin\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float *\n" - " (expression float -\n" - " (expression float *\n" - " (constant float (3.1415926))\n" - " (constant float (0.5)))\n" - " (expression float sqrt\n" - " (expression float -\n" - " (constant float (1.0))\n" - " (expression float abs (var_ref x)))))\n" - " (expression float +\n" - " (constant float (1.5707288))\n" - " (expression float *\n" - " (expression float abs (var_ref x))\n" - " (expression float +\n" - " (constant float (-0.2121144))\n" - " (expression float *\n" - " (constant float (0.0742610))\n" - " (expression float abs (var_ref x))))))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 *\n" - " (expression float -\n" - " (expression float *\n" - " (constant float (3.1415926))\n" - " (constant float (0.5)))\n" - " (expression vec2 sqrt\n" - " (expression vec2 -\n" - " (constant float (1.0))\n" - " (expression vec2 abs (var_ref x)))))\n" - " (expression vec2 +\n" - " (constant float (1.5707288))\n" - " (expression vec2 *\n" - " (expression vec2 abs (var_ref x))\n" - " (expression vec2 +\n" - " (constant float (-0.2121144))\n" - " (expression vec2 *\n" - " (constant float (0.0742610))\n" - " (expression vec2 abs (var_ref x))))))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 *\n" - " (expression vec3 -\n" - " (expression float *\n" - " (constant float (3.1415926))\n" - " (constant float (0.5)))\n" - " (expression vec3 sqrt\n" - " (expression vec3 -\n" - " (constant float (1.0))\n" - " (expression vec3 abs (var_ref x)))))\n" - " (expression vec3 +\n" - " (constant float (1.5707288))\n" - " (expression vec3 *\n" - " (expression vec3 abs (var_ref x))\n" - " (expression vec3 +\n" - " (constant float (-0.2121144))\n" - " (expression vec3 *\n" - " (constant float (0.0742610))\n" - " (expression vec3 abs (var_ref x))))))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 *\n" - " (expression vec4 -\n" - " (expression float *\n" - " (constant float (3.1415926))\n" - " (constant float (0.5)))\n" - " (expression vec4 sqrt\n" - " (expression vec4 -\n" - " (constant float (1.0))\n" - " (expression vec4 abs (var_ref x)))))\n" - " (expression vec4 +\n" - " (constant float (1.5707288))\n" - " (expression vec4 *\n" - " (expression vec4 abs (var_ref x))\n" - " (expression vec4 +\n" - " (constant float (-0.2121144))\n" - " (expression vec4 *\n" - " (constant float (0.0742610))\n" - " (expression vec4 abs (var_ref x))))))))))\n" - ")\n" - "\n" - " (function acos\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float - (constant float (1.5707963))\n" - " (call asin ((var_ref x)))))))\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 - (constant float (1.5707963))\n" - " (call asin ((var_ref x)))))))\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 - (constant float (1.5707963))\n" - " (call asin ((var_ref x)))))))\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 - (constant float (1.5707963))\n" - " (call asin ((var_ref x)))))))\n" - "))\n" -}; - -static const char *builtins_110_atan = { - "((function atan\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (call asin ((expression float *\n" - " (var_ref x)\n" - " (expression float rsq\n" - " (expression float +\n" - " (expression float *\n" - " (var_ref x)\n" - " (var_ref x))\n" - " (constant float (1.0))))))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 y_over_x))\n" - " ((return (call asin ((expression vec2 *\n" - " (var_ref y_over_x)\n" - " (expression vec2 rsq\n" - " (expression vec2 +\n" - " (expression vec2 *\n" - " (var_ref y_over_x)\n" - " (var_ref y_over_x))\n" - " (constant float (1.0))))))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 y_over_x))\n" - " ((return (call asin ((expression vec3 *\n" - " (var_ref y_over_x)\n" - " (expression vec3 rsq\n" - " (expression vec3 +\n" - " (expression vec3 *\n" - " (var_ref y_over_x)\n" - " (var_ref y_over_x))\n" - " (constant float (1.0))))))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 y_over_x))\n" - " ((return (call asin ((expression vec4 *\n" - " (var_ref y_over_x)\n" - " (expression vec4 rsq\n" - " (expression vec4 +\n" - " (expression vec4 *\n" - " (var_ref y_over_x)\n" - " (var_ref y_over_x))\n" - " (constant float (1.0))))))))))\n" - "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float y)\n" - " (declare (in) float x))\n" - " ((declare () float r)\n" - " (if (expression bool >\n" - " (expression float abs (var_ref x))\n" - " (constant float (.0001)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r) (call atan ((expression float /\n" - " (var_ref y)\n" - " (var_ref x)))))\n" - " (if (expression bool <\n" - " (var_ref x)\n" - " (constant float (0.0)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r)\n" - " (expression float +\n" - " (var_ref r)\n" - " (expression float *\n" - " (expression int sign (var_ref y))\n" - " (constant float (3.1415926))))))\n" - " ()))\n" - " ())\n" - " (return (var_ref r))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 y)\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 r)\n" - " (if (expression bool >\n" - " (expression vec2 abs (var_ref x))\n" - " (constant float (.0001)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r) (call atan ((expression vec2 /\n" - " (var_ref y)\n" - " (var_ref x)))))\n" - " (if (expression bool <\n" - " (var_ref x)\n" - " (constant float (0.0)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r)\n" - " (expression vec2 +\n" - " (var_ref r)\n" - " (expression vec2 *\n" - " (expression int sign (var_ref y))\n" - " (constant float (3.1415926))))))\n" - " ()))\n" - " ())\n" - " (return (var_ref r))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 y)\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 r)\n" - " (if (expression bool >\n" - " (expression vec3 abs (var_ref x))\n" - " (constant float (.0001)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r) (call atan ((expression vec3 /\n" - " (var_ref y)\n" - " (var_ref x)))))\n" - " (if (expression bool <\n" - " (var_ref x)\n" - " (constant float (0.0)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r)\n" - " (expression vec3 +\n" - " (var_ref r)\n" - " (expression vec3 *\n" - " (expression int sign (var_ref y))\n" - " (constant float (3.1415926))))))\n" - " ()))\n" - " ())\n" - " (return (var_ref r))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 y)\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 r)\n" - " (if (expression bool >\n" - " (expression vec4 abs (var_ref x))\n" - " (constant float (.0001)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r) (call atan ((expression vec4 /\n" - " (var_ref y)\n" - " (var_ref x)))))\n" - " (if (expression bool <\n" - " (var_ref x)\n" - " (constant float (0.0)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r)\n" - " (expression vec4 +\n" - " (var_ref r)\n" - " (expression vec4 *\n" - " (expression int sign (var_ref y))\n" - " (constant float (3.1415926))))))\n" - " ()))\n" - " ())\n" - " (return (var_ref r))))\n" - "\n" - "))\n" -}; - -static const char *builtins_110_ceil = { - "((function ceil\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float ceil (var_ref arg0)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 ceil (var_ref arg0)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 ceil (var_ref arg0)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 ceil (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_clamp = { - "((function clamp\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1)\n" - " (declare (in) vec2 arg2))\n" - " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1)\n" - " (declare (in) vec3 arg2))\n" - " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1)\n" - " (declare (in) vec4 arg2))\n" - " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) float arg1)\n" - " (declare (in) float arg2))\n" - " ((declare () vec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) float arg1)\n" - " (declare (in) float arg2))\n" - " ((declare () vec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) float arg1)\n" - " (declare (in) float arg2))\n" - " ((declare () vec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result)) (expression vec4 max (expression vec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "))\n" -}; - -static const char *builtins_110_cos = { - "((function cos\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float angle))\n" - " ((return (expression float cos (var_ref angle)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 angle))\n" - " ((return (expression vec2 cos (var_ref angle)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 angle))\n" - " ((return (expression vec3 cos (var_ref angle)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 angle))\n" - " ((return (expression vec4 cos (var_ref angle)))))\n" - "))\n" -}; - -static const char *builtins_110_cross = { - "((function cross\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float - (expression float * (swiz y (var_ref arg0)) (swiz z (var_ref arg1)))\n" - " (expression float * (swiz y (var_ref arg1)) (swiz z (var_ref arg0)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float - (expression float * (swiz z (var_ref arg0)) (swiz x (var_ref arg1)))\n" - " (expression float * (swiz z (var_ref arg1)) (swiz x (var_ref arg0)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t))\n" - " (expression float - (expression float * (swiz x (var_ref arg0)) (swiz y (var_ref arg1)))\n" - " (expression float * (swiz x (var_ref arg1)) (swiz y (var_ref arg0)))))\n" - " (return (var_ref t))))\n" - "))\n" -}; - -static const char *builtins_110_degrees = { - "((function degrees\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float * (var_ref arg0) (constant float (57.295780))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 * (var_ref arg0) (constant float (57.295780))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 * (var_ref arg0) (constant float (57.295780))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 * (var_ref arg0) (constant float (57.295780))))))\n" - "))\n" -}; - -static const char *builtins_110_distance = { - "((function distance\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float p0)\n" - " (declare (in) float p1))\n" - " ((declare () float p)\n" - " (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1)))\n" - " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" - "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec2 p0)\n" - " (declare (in) vec2 p1))\n" - " ((declare () vec2 p)\n" - " (assign (constant bool (1)) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))\n" - " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" - "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec3 p0)\n" - " (declare (in) vec3 p1))\n" - " ((declare () vec3 p)\n" - " (assign (constant bool (1)) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))\n" - " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" - "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec4 p0)\n" - " (declare (in) vec4 p1))\n" - " ((declare () vec4 p)\n" - " (assign (constant bool (1)) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))\n" - " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" - "))\n" -}; - -static const char *builtins_110_dot = { - "((function dot\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" - "))\n" -}; - -static const char *builtins_110_equal = { - "((function equal\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_110_exp = { - "((function exp\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float exp (var_ref arg0)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 exp (var_ref arg0)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 exp (var_ref arg0)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 exp (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_exp2 = { - "((function exp2\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float exp2 (var_ref arg0)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 exp2 (var_ref arg0)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 exp2 (var_ref arg0)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 exp2 (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_faceforward = { - "((function faceforward\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float N)\n" - " (declare (in) float I)\n" - " (declare (in) float Nref))\n" - " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" - " ((return (var_ref N)))\n" - " ((return (expression float neg (var_ref N)))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 N)\n" - " (declare (in) vec2 I)\n" - " (declare (in) vec2 Nref))\n" - " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" - " ((return (var_ref N)))\n" - " ((return (expression vec2 neg (var_ref N)))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 N)\n" - " (declare (in) vec3 I)\n" - " (declare (in) vec3 Nref))\n" - " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" - " ((return (var_ref N)))\n" - " ((return (expression vec3 neg (var_ref N)))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 N)\n" - " (declare (in) vec4 I)\n" - " (declare (in) vec4 Nref))\n" - " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" - " ((return (var_ref N)))\n" - " ((return (expression vec4 neg (var_ref N)))))))\n" - "))\n" -}; - -static const char *builtins_110_floor = { - "((function floor\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float floor (var_ref arg0)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 floor (var_ref arg0)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 floor (var_ref arg0)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 floor (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_fract = { - "((function fract\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float - (var_ref x) (expression float floor (var_ref x))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x)))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float - (swiz w (var_ref x)) (expression float floor (swiz w (var_ref x)))))\n" - " (return (var_ref t))))\n" - "))\n" - "\n" -}; - -static const char *builtins_110_greaterThan = { - "((function greaterThan\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_110_greaterThanEqual = { - "((function greaterThanEqual\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_110_inversesqrt = { - "((function inversesqrt\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float rsq (var_ref arg0)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 rsq (var_ref arg0)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 rsq (var_ref arg0)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 rsq (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_length = { - "((function length\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" - "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" - "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" - "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" - "))\n" -}; - -static const char *builtins_110_lessThan = { - "((function lessThan\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_110_lessThanEqual = { - "((function lessThanEqual\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_110_log = { - "((function log\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float log (var_ref arg0)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 log (var_ref arg0)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 log (var_ref arg0)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 log (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_log2 = { - "((function log2\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float log2 (var_ref arg0)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 log2 (var_ref arg0)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 log2 (var_ref arg0)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 log2 (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_matrixCompMult = { - "((function matrixCompMult\n" - " (signature mat2\n" - " (parameters\n" - " (declare (in) mat2 x)\n" - " (declare (in) mat2 y))\n" - " ((declare () mat2 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" - "\n" - " (signature mat3\n" - " (parameters\n" - " (declare (in) mat3 x)\n" - " (declare (in) mat3 y))\n" - " ((declare () mat3 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" - "\n" - " (signature mat4\n" - " (parameters\n" - " (declare (in) mat4 x)\n" - " (declare (in) mat4 y))\n" - " ((declare () mat4 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" - "))\n" - "\n" -}; - -static const char *builtins_110_max = { - "((function max\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression float max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) float arg1))\n" - " ((declare () vec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) float arg1))\n" - " ((declare () vec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) float arg1))\n" - " ((declare () vec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression float max (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "))\n" -}; - -static const char *builtins_110_min = { - "((function min\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression float min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) float arg1))\n" - " ((declare () vec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) float arg1))\n" - " ((declare () vec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) float arg1))\n" - " ((declare () vec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression float min (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "))\n" -}; - -static const char *builtins_110_mix = { - "((function mix\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1)\n" - " (declare (in) vec2 arg2))\n" - " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1)\n" - " (declare (in) vec3 arg2))\n" - " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1)\n" - " (declare (in) vec4 arg2))\n" - " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" - "))\n" -}; - -static const char *builtins_110_mod = { - "((function mod\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression float % (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) float arg1))\n" - " ((declare () vec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) float arg1))\n" - " ((declare () vec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float % (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) float arg1))\n" - " ((declare () vec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float % (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression float % (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "))\n" -}; - -static const char *builtins_110_noise_fake = { - "((function noise1\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (constant float (0)))))\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (constant float (0)))))\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (constant float (0)))))\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (constant float (0)))))\n" - " )\n" - "\n" - " (function noise2\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (constant vec2 (0 0)))))\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (constant vec2 (0 0)))))\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (constant vec2 (0 0)))))\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (constant vec2 (0 0)))))\n" - " )\n" - "\n" - " (function noise3\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (constant vec3 (0 0 0)))))\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (constant vec3 (0 0 0)))))\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (constant vec3 (0 0 0)))))\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (constant vec3 (0 0 0)))))\n" - " )\n" - "\n" - " (function noise4\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (constant vec4 (0 0 0 0)))))\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (constant vec4 (0 0 0 0)))))\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (constant vec4 (0 0 0 0)))))\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (constant vec4 (0 0 0 0)))))\n" - " )\n" - ")\n" -}; - -static const char *builtins_110_normalize = { - "((function normalize\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" - "))\n" -}; - -static const char *builtins_110_not = { - "((function not\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) bvec2 arg0))\n" - " ((return (expression bvec2 ! (var_ref arg0)))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) bvec3 arg0))\n" - " ((return (expression bvec3 ! (var_ref arg0)))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) bvec4 arg0))\n" - " ((return (expression bvec4 ! (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_notEqual = { - "((function notEqual\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_110_pow = { - "((function pow\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression float pow (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((return (expression vec2 pow (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression vec3 pow (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((return (expression vec4 pow (var_ref arg0) (var_ref arg1)))))\n" - "))\n" -}; - -static const char *builtins_110_radians = { - "((function radians\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float * (var_ref arg0) (constant float (0.017453))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 * (var_ref arg0) (constant float (0.017453))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 * (var_ref arg0) (constant float (0.017453))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 * (var_ref arg0) (constant float (0.017453))))))\n" - "))\n" -}; - -static const char *builtins_110_reflect = { - "((function reflect\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float i)\n" - " (declare (in) float n))\n" - " ((return (expression float -\n" - " (var_ref i)\n" - " (expression float *\n" - " (constant float (2.0))\n" - " (expression float *\n" - " (expression float dot\n" - " (var_ref n)\n" - " (var_ref i))\n" - " (var_ref n)))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 i)\n" - " (declare (in) vec2 n))\n" - " ((return (expression vec2 -\n" - " (var_ref i)\n" - " (expression vec2 *\n" - " (constant float (2.0))\n" - " (expression vec2 *\n" - " (expression float dot\n" - " (var_ref n)\n" - " (var_ref i))\n" - " (var_ref n)))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 i)\n" - " (declare (in) vec3 n))\n" - " ((return (expression vec3 -\n" - " (var_ref i)\n" - " (expression vec3 *\n" - " (constant float (2.0))\n" - " (expression vec3 *\n" - " (expression float dot\n" - " (var_ref n)\n" - " (var_ref i))\n" - " (var_ref n)))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 i)\n" - " (declare (in) vec4 n))\n" - " ((return (expression vec4 -\n" - " (var_ref i)\n" - " (expression vec4 *\n" - " (constant float (2.0))\n" - " (expression vec4 *\n" - " (expression float dot\n" - " (var_ref n)\n" - " (var_ref i))\n" - " (var_ref n)))))))\n" - "\n" - "))\n" -}; - -static const char *builtins_110_refract = { - "((function refract\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float i)\n" - " (declare (in) float n)\n" - " (declare (in) float eta))\n" - " ((declare () float k)\n" - " (assign (constant bool (1)) (var_ref k)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * (var_ref eta)\n" - " (expression float * (var_ref eta)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * \n" - " (expression float dot (var_ref n) (var_ref i))\n" - " (expression float dot (var_ref n) (var_ref i))))))))\n" - " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant float (0.0))))\n" - " ((return (expression float -\n" - " (expression float * (var_ref eta) (var_ref i))\n" - " (expression float *\n" - " (expression float +\n" - " (expression float * (var_ref eta)\n" - " (expression float dot (var_ref n) (var_ref i)))\n" - " (expression float sqrt (var_ref k)))\n" - " (var_ref n))))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 i)\n" - " (declare (in) vec2 n)\n" - " (declare (in) float eta))\n" - " ((declare () float k)\n" - " (assign (constant bool (1)) (var_ref k)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * (var_ref eta)\n" - " (expression float * (var_ref eta)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * \n" - " (expression float dot (var_ref n) (var_ref i))\n" - " (expression float dot (var_ref n) (var_ref i))))))))\n" - " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant vec2 (0.0 0.0))))\n" - " ((return (expression vec2 -\n" - " (expression vec2 * (var_ref eta) (var_ref i))\n" - " (expression vec2 *\n" - " (expression float +\n" - " (expression float * (var_ref eta)\n" - " (expression float dot (var_ref n) (var_ref i)))\n" - " (expression float sqrt (var_ref k)))\n" - " (var_ref n))))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 i)\n" - " (declare (in) vec3 n)\n" - " (declare (in) float eta))\n" - " ((declare () float k)\n" - " (assign (constant bool (1)) (var_ref k)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * (var_ref eta)\n" - " (expression float * (var_ref eta)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * \n" - " (expression float dot (var_ref n) (var_ref i))\n" - " (expression float dot (var_ref n) (var_ref i))))))))\n" - " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant vec3 (0.0 0.0))))\n" - " ((return (expression vec3 -\n" - " (expression vec3 * (var_ref eta) (var_ref i))\n" - " (expression vec3 *\n" - " (expression float +\n" - " (expression float * (var_ref eta)\n" - " (expression float dot (var_ref n) (var_ref i)))\n" - " (expression float sqrt (var_ref k)))\n" - " (var_ref n))))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 i)\n" - " (declare (in) vec4 n)\n" - " (declare (in) float eta))\n" - " ((declare () float k)\n" - " (assign (constant bool (1)) (var_ref k)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * (var_ref eta)\n" - " (expression float * (var_ref eta)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * \n" - " (expression float dot (var_ref n) (var_ref i))\n" - " (expression float dot (var_ref n) (var_ref i))))))))\n" - " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant vec4 (0.0 0.0))))\n" - " ((return (expression vec4 -\n" - " (expression vec4 * (var_ref eta) (var_ref i))\n" - " (expression vec4 *\n" - " (expression float +\n" - " (expression float * (var_ref eta)\n" - " (expression float dot (var_ref n) (var_ref i)))\n" - " (expression float sqrt (var_ref k)))\n" - " (var_ref n))))))))\n" - "\n" - "))\n" -}; - -static const char *builtins_110_sign = { - "((function sign\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float sign (var_ref x)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float sign (swiz w (var_ref x))))\n" - " (return (var_ref t))))\n" - "))\n" - "\n" -}; - -static const char *builtins_110_sin = { - "((function sin\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float angle))\n" - " ((return (expression float sin (var_ref angle)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 angle))\n" - " ((return (expression vec2 sin (var_ref angle)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 angle))\n" - " ((return (expression vec3 sin (var_ref angle)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 angle))\n" - " ((return (expression vec4 sin (var_ref angle)))))\n" - "))\n" -}; - -static const char *builtins_110_smoothstep = { - "((function smoothstep\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float edge0)\n" - " (declare (in) float edge1)\n" - " (declare (in) float x))\n" - " ((declare () float t)\n" - "\n" - " (assign (constant bool (1)) (var_ref t)\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t))))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) float edge0)\n" - " (declare (in) float edge1)\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (declare () vec2 retval)\n" - "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) float edge0)\n" - " (declare (in) float edge1)\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (declare () vec3 retval)\n" - "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz z (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" - "\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) float edge0)\n" - " (declare (in) float edge1)\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (declare () vec4 retval)\n" - "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz z (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz w (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 edge0)\n" - " (declare (in) vec2 edge1)\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (declare () vec2 retval)\n" - "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 edge0)\n" - " (declare (in) vec3 edge1)\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (declare () vec3 retval)\n" - "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz z (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" - "\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 edge0)\n" - " (declare (in) vec4 edge1)\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (declare () vec4 retval)\n" - "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz z (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz w (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz w (var_ref x)) (swiz w (var_ref edge0))) (expression float - (swiz w (var_ref edge1)) (swiz w (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" - "\n" - "))\n" - "\n" -}; - -static const char *builtins_110_sqrt = { - "((function sqrt\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float sqrt (var_ref arg0)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 sqrt (var_ref arg0)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 sqrt (var_ref arg0)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 sqrt (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_step = { - "((function step\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float edge)\n" - " (declare (in) float x))\n" - " ((return (expression float b2f (expression bool < (var_ref x) (var_ref edge))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) float edge)\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) float edge)\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) float edge)\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(var_ref edge))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 edge)\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 edge)\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(swiz z (var_ref edge)))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 edge)\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz z (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(swiz w (var_ref edge)))))\n" - " (return (var_ref t))))\n" - "))\n" - "\n" -}; - -static const char *builtins_110_tan = { - "((function tan\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float angle))\n" - " ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 angle))\n" - " ((return (expression float / (expression float sin (var_ref angle)) (expression vec2 cos (var_ref angle))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 angle))\n" - " ((return (expression float / (expression float sin (var_ref angle)) (expression vec3 cos (var_ref angle))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 angle))\n" - " ((return (expression float / (expression float sin (var_ref angle)) (expression vec4 cos (var_ref angle))))))\n" - "))\n" -}; - -static const char *builtins_110_textures = { - "((function texture1D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - ")\n" - " (function texture1DLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - ")\n" - " (function texture1DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - ")\n" - " (function texture1DProjLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - ")\n" - " (function texture2D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - ")\n" - "(function texture2DLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - ")\n" - " (function texture2DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - ")\n" - " (function texture2DProjLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - ")\n" - " (function texture3D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - ")\n" - " (function texture3DLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - ")\n" - " (function texture3DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - ")\n" - " (function texture3DProjLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - ")\n" - " (function textureCube\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - ")\n" - " (function textureCubeLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - ")\n" - " (function shadow1D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" - "\n" - ")\n" - " (function shadow1DLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" - "\n" - ")\n" - " (function shadow1DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" - "\n" - ")\n" - " (function shadow1DProjLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" - "\n" - ")\n" - " (function shadow2D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" - "\n" - ")\n" - " (function shadow2DLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" - "\n" - ")\n" - " (function shadow2DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" - "\n" - ")\n" - " (function shadow2DProjLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" - "\n" - "))\n" -}; - -static const char *functions_for_110 [] = { - builtins_110_abs, - builtins_110_all, - builtins_110_any, - builtins_110_asin, - builtins_110_atan, - builtins_110_ceil, - builtins_110_clamp, - builtins_110_cos, - builtins_110_cross, - builtins_110_degrees, - builtins_110_distance, - builtins_110_dot, - builtins_110_equal, - builtins_110_exp, - builtins_110_exp2, - builtins_110_faceforward, - builtins_110_floor, - builtins_110_fract, - builtins_110_greaterThan, - builtins_110_greaterThanEqual, - builtins_110_inversesqrt, - builtins_110_length, - builtins_110_lessThan, - builtins_110_lessThanEqual, - builtins_110_log, - builtins_110_log2, - builtins_110_matrixCompMult, - builtins_110_max, - builtins_110_min, - builtins_110_mix, - builtins_110_mod, - builtins_110_noise_fake, - builtins_110_normalize, - builtins_110_not, - builtins_110_notEqual, - builtins_110_pow, - builtins_110_radians, - builtins_110_reflect, - builtins_110_refract, - builtins_110_sign, - builtins_110_sin, - builtins_110_smoothstep, - builtins_110_sqrt, - builtins_110_step, - builtins_110_tan, - builtins_110_textures, -}; - -/* 110_fs builtins */ - -static const char *builtins_110_fs_derivatives = { - "((function dFdx\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float p))\n" - " ((return (expression float dFdx (var_ref p)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 p))\n" - " ((return (expression vec2 dFdx (var_ref p)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 p))\n" - " ((return (expression vec3 dFdx (var_ref p)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 p))\n" - " ((return (expression vec4 dFdx (var_ref p)))))\n" - " )\n" - "\n" - " (function dFdy\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float p))\n" - " ((return (expression float dFdy (var_ref p)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 p))\n" - " ((return (expression vec2 dFdy (var_ref p)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 p))\n" - " ((return (expression vec3 dFdy (var_ref p)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 p))\n" - " ((return (expression vec4 dFdy (var_ref p)))))\n" - " )\n" - "\n" - " (function fwidth\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float p))\n" - " ((return (expression float +\n" - " (expression float abs (expression float dFdx (var_ref p)))\n" - " (expression float abs (expression float dFdy (var_ref p)))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 p))\n" - " ((return (expression vec2 +\n" - " (expression vec2 abs (expression vec2 dFdx (var_ref p)))\n" - " (expression vec2 abs (expression vec2 dFdy (var_ref p)))))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 p))\n" - " ((return (expression vec3 +\n" - " (expression vec3 abs (expression vec3 dFdx (var_ref p)))\n" - " (expression vec3 abs (expression vec3 dFdy (var_ref p)))))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 p))\n" - " ((return (expression vec4 +\n" - " (expression vec4 abs (expression vec4 dFdx (var_ref p)))\n" - " (expression vec4 abs (expression vec4 dFdy (var_ref p)))))))\n" - "))\n" -}; - -static const char *builtins_110_fs_textures = { - "((function texture1D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - ")\n" - " (function texture1DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - ")\n" - " (function texture2D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - ")\n" - " (function texture2DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - ")\n" - " (function texture3D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - ")\n" - " (function texture3DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - ")\n" - " (function textureCube\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - ")\n" - " (function shadow1D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" - "\n" - ")\n" - " (function shadow1DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" - "\n" - ")\n" - " (function shadow2D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" - "\n" - ")\n" - " (function shadow2DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" - "\n" - "))\n" -}; - -static const char *functions_for_110_fs [] = { - builtins_110_fs_derivatives, - builtins_110_fs_textures, -}; - -/* 110_vs builtins */ - -static const char *builtins_110_vs_ftransform = { - "((function ftransform\n" - " (signature vec4\n" - " (parameters)\n" - " ((return (expression vec4 *\n" - " (var_ref gl_ModelViewProjectionMatrix)\n" - " (var_ref gl_Vertex)))))\n" - "))\n" -}; - -static const char *functions_for_110_vs [] = { - builtins_110_vs_ftransform, -}; - -/* 120 builtins */ - -static const char *builtins_120_matrixCompMult = { - "((function matrixCompMult\n" - " (signature mat2x3\n" - " (parameters\n" - " (declare (in) mat2x3 x)\n" - " (declare (in) mat2x3 y))\n" - " ((declare () mat2x3 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" - "\n" - " (signature mat3x2\n" - " (parameters\n" - " (declare (in) mat3x2 x)\n" - " (declare (in) mat3x2 y))\n" - " ((declare () mat3x2 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" - "\n" - " (signature mat2x4\n" - " (parameters\n" - " (declare (in) mat2x4 x)\n" - " (declare (in) mat2x4 y))\n" - " ((declare () mat2x4 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" - "\n" - " (signature mat4x2\n" - " (parameters\n" - " (declare (in) mat4x2 x)\n" - " (declare (in) mat4x2 y))\n" - " ((declare () mat4x2 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" - "\n" - " (signature mat3x4\n" - " (parameters\n" - " (declare (in) mat3x4 x)\n" - " (declare (in) mat3x4 y))\n" - " ((declare () mat3x4 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" - "\n" - " (signature mat4x3\n" - " (parameters\n" - " (declare (in) mat4x3 x)\n" - " (declare (in) mat4x3 y))\n" - " ((declare () mat4x3 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" - "))\n" -}; - -static const char *builtins_120_outerProduct = { - "((function outerProduct\n" - " (signature mat2\n" - " (parameters\n" - " (declare (in) vec2 u)\n" - " (declare (in) vec2 v))\n" - " ((declare () mat2 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" - "(return (var_ref m))))\n" - "\n" - " (signature mat2x3\n" - " (parameters\n" - " (declare (in) vec2 u)\n" - " (declare (in) vec3 v))\n" - " ((declare () mat2x3 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" - "(return (var_ref m))))\n" - "\n" - " (signature mat2x4\n" - " (parameters\n" - " (declare (in) vec2 u)\n" - " (declare (in) vec4 v))\n" - " ((declare () mat2x4 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" - "(return (var_ref m))))\n" - "\n" - " (signature mat3x2\n" - " (parameters\n" - " (declare (in) vec3 u)\n" - " (declare (in) vec2 v))\n" - " ((declare () mat3x2 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) \n" - "(return (var_ref m))))\n" - "\n" - " (signature mat3\n" - " (parameters\n" - " (declare (in) vec3 u)\n" - " (declare (in) vec3 v))\n" - " ((declare () mat3 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) \n" - "(return (var_ref m))))\n" - "\n" - " (signature mat3x4\n" - " (parameters\n" - " (declare (in) vec3 u)\n" - " (declare (in) vec4 v))\n" - " ((declare () mat3x4 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) \n" - "(return (var_ref m))))\n" - "\n" - " (signature mat4x2\n" - " (parameters\n" - " (declare (in) vec4 u)\n" - " (declare (in) vec2 v))\n" - " ((declare () mat4x2 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref v) (swiz w (var_ref u)))) \n" - "(return (var_ref m))))\n" - "\n" - " (signature mat4x3\n" - " (parameters\n" - " (declare (in) vec4 u)\n" - " (declare (in) vec3 v))\n" - " ((declare () mat4x3 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref v) (swiz w (var_ref u)))) \n" - "(return (var_ref m))))\n" - "\n" - " (signature mat4\n" - " (parameters\n" - " (declare (in) vec4 u)\n" - " (declare (in) vec4 v))\n" - " ((declare () mat4 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref v) (swiz w (var_ref u)))) \n" - "(return (var_ref m))))\n" - "))\n" - "\n" -}; - -static const char *builtins_120_transpose = { - "((function transpose\n" - " (signature mat2\n" - " (parameters\n" - " (declare (in) mat2 m))\n" - " ((declare () mat2 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - "(return (var_ref t))))\n" - "\n" - " (signature mat3x2\n" - " (parameters\n" - " (declare (in) mat2x3 m))\n" - " ((declare () mat3x2 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - "(return (var_ref t))))\n" - "\n" - " (signature mat4x2\n" - " (parameters\n" - " (declare (in) mat2x4 m))\n" - " ((declare () mat4x2 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" - "(return (var_ref t))))\n" - "\n" - " (signature mat2x3\n" - " (parameters\n" - " (declare (in) mat3x2 m))\n" - " ((declare () mat2x3 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - "(return (var_ref t))))\n" - "\n" - " (signature mat3\n" - " (parameters\n" - " (declare (in) mat3 m))\n" - " ((declare () mat3 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" - "(return (var_ref t))))\n" - "\n" - " (signature mat4x3\n" - " (parameters\n" - " (declare (in) mat3x4 m))\n" - " ((declare () mat4x3 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n" - "(return (var_ref t))))\n" - "\n" - " (signature mat2x4\n" - " (parameters\n" - " (declare (in) mat4x2 m))\n" - " ((declare () mat2x4 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" - "(return (var_ref t))))\n" - "\n" - " (signature mat3x4\n" - " (parameters\n" - " (declare (in) mat4x3 m))\n" - " ((declare () mat3x4 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n" - "(return (var_ref t))))\n" - "\n" - " (signature mat4\n" - " (parameters\n" - " (declare (in) mat4 m))\n" - " ((declare () mat4 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (3))))) \n" - "(return (var_ref t))))\n" - ")\n" - "\n" - ")\n" - "\n" -}; - -static const char *functions_for_120 [] = { - builtins_120_matrixCompMult, - builtins_120_outerProduct, - builtins_120_transpose, -}; - -/* 130 builtins */ - -static const char *builtins_130_clamp = { - "((function clamp\n" - " (signature int\n" - " (parameters\n" - " (declare (in) int arg0)\n" - " (declare (in) int arg1)\n" - " (declare (in) int arg2))\n" - " ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature ivec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1)\n" - " (declare (in) ivec2 arg2))\n" - " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature ivec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1)\n" - " (declare (in) ivec3 arg2))\n" - " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1)\n" - " (declare (in) ivec4 arg2))\n" - " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature ivec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) int arg1)\n" - " (declare (in) int arg2))\n" - " ((declare () ivec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature ivec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) int arg1)\n" - " (declare (in) int arg2))\n" - " ((declare () ivec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) int arg1)\n" - " (declare (in) int arg2))\n" - " ((declare () ivec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature uint\n" - " (parameters\n" - " (declare (in) uint arg0)\n" - " (declare (in) uint arg1)\n" - " (declare (in) uint arg2))\n" - " ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature uvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1)\n" - " (declare (in) uvec2 arg2))\n" - " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature uvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1)\n" - " (declare (in) uvec3 arg2))\n" - " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1)\n" - " (declare (in) uvec4 arg2))\n" - " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" - "\n" - " (signature uvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uint arg1)\n" - " (declare (in) uint arg2))\n" - " ((declare () uvec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature uvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uint arg1)\n" - " (declare (in) uint arg2))\n" - " ((declare () uvec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uint arg1)\n" - " (declare (in) uint arg2))\n" - " ((declare () uvec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "))\n" -}; - -static const char *builtins_130_cosh = { - "((function cosh\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float * (constant float (0.5))\n" - " (expression float +\n" - " (expression float exp (var_ref x))\n" - " (expression float exp (expression float neg (var_ref x))))))))\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 * (constant vec2 (0.5))\n" - " (expression vec2 +\n" - " (expression vec2 exp (var_ref x))\n" - " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 * (constant vec3 (0.5))\n" - " (expression vec3 +\n" - " (expression vec3 exp (var_ref x))\n" - " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 * (constant vec4 (0.5))\n" - " (expression vec4 +\n" - " (expression vec4 exp (var_ref x))\n" - " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" - "))\n" -}; - -static const char *builtins_130_equal = { - "((function equal\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_130_greaterThan = { - "((function greaterThan\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_130_greaterThanEqual = { - "((function greaterThanEqual\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_130_lessThan = { - "((function lessThan\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_130_lessThanEqual = { - "((function lessThanEqual\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_130_max = { - "((function max\n" - " (signature int\n" - " (parameters\n" - " (declare (in) int arg0)\n" - " (declare (in) int arg1))\n" - " ((return (expression int max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature ivec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature ivec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature ivec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) int arg1))\n" - " ((declare () ivec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature ivec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) int arg1))\n" - " ((declare () ivec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression int max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) int arg1))\n" - " ((declare () ivec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression int max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression int max (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature uint\n" - " (parameters\n" - " (declare (in) uint arg0)\n" - " (declare (in) uint arg1))\n" - " ((return (expression uint max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature uvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature uvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature uvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uint arg1))\n" - " ((declare () uvec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature uvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uint arg1))\n" - " ((declare () uvec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression uint max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uint arg1))\n" - " ((declare () uvec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression uint max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression uint max (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "))\n" -}; - -static const char *builtins_130_min = { - "((function min\n" - " (signature int\n" - " (parameters\n" - " (declare (in) int arg0)\n" - " (declare (in) int arg1))\n" - " ((return (expression int min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature ivec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature ivec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature ivec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) int arg1))\n" - " ((declare () ivec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature ivec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) int arg1))\n" - " ((declare () ivec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression int min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) int arg1))\n" - " ((declare () ivec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression int min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression int min (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature uint\n" - " (parameters\n" - " (declare (in) uint arg0)\n" - " (declare (in) uint arg1))\n" - " ((return (expression uint min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature uvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature uvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature uvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uint arg1))\n" - " ((declare () uvec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature uvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uint arg1))\n" - " ((declare () uvec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression uint min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uint arg1))\n" - " ((declare () uvec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression uint min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression uint min (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" - "))\n" -}; - -static const char *builtins_130_notEqual = { - "((function notEqual\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_130_sign = { - "((function sign\n" - " (signature int\n" - " (parameters\n" - " (declare (in) int x))\n" - " ((return (expression int / (var_ref x) (expression int abs (var_ref x))))))\n" - "\n" - " (signature ivec2\n" - " (parameters\n" - " (declare (in) ivec2 x))\n" - " ((declare () ivec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature ivec3\n" - " (parameters\n" - " (declare (in) ivec3 x))\n" - " ((declare () ivec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x))))\n" - " (return (var_ref t))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) ivec4 x))\n" - " ((declare () ivec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression int sign (swiz w (var_ref x))))\n" - " (return (var_ref t))))\n" - "))\n" - "\n" -}; - -static const char *builtins_130_sinh = { - "((function sinh\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float * (constant float (0.5))\n" - " (expression float -\n" - " (expression float exp (var_ref x))\n" - " (expression float exp (expression float neg (var_ref x))))))))\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 * (constant vec2 (0.5))\n" - " (expression vec2 -\n" - " (expression vec2 exp (var_ref x))\n" - " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 * (constant vec3 (0.5))\n" - " (expression vec3 -\n" - " (expression vec3 exp (var_ref x))\n" - " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 * (constant vec4 (0.5))\n" - " (expression vec4 -\n" - " (expression vec4 exp (var_ref x))\n" - " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" - "))\n" -}; - -static const char *builtins_130_tanh = { - "((function tanh\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float /\n" - " (expression float -\n" - " (expression float exp (var_ref x))\n" - " (expression float exp (expression float neg (var_ref x))))\n" - " (expression float +\n" - " (expression float exp (var_ref x))\n" - " (expression float exp (expression float neg (var_ref x))))))))\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 /\n" - " (expression vec2 -\n" - " (expression vec2 exp (var_ref x))\n" - " (expression vec2 exp (expression vec2 neg (var_ref x))))\n" - " (expression vec2 +\n" - " (expression vec2 exp (var_ref x))\n" - " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 /\n" - " (expression vec3 -\n" - " (expression vec3 exp (var_ref x))\n" - " (expression vec3 exp (expression vec3 neg (var_ref x))))\n" - " (expression vec3 +\n" - " (expression vec3 exp (var_ref x))\n" - " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 /\n" - " (expression vec4 -\n" - " (expression vec4 exp (var_ref x))\n" - " (expression vec4 exp (expression vec4 neg (var_ref x))))\n" - " (expression vec4 +\n" - " (expression vec4 exp (var_ref x))\n" - " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" - "))\n" -}; - -static const char *builtins_130_texelFetch = { - "((function texelFetch\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) int P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) int P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) int P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1DArray sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1DArray sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2DArray sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2DArray sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - "))\n" -}; - -static const char *builtins_130_texture = { - "((function texture\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) float P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) float P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isamplerCube sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usamplerCube sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1DArray sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1DArray sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2DArray sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2DArray sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - "))\n" -}; - -static const char *builtins_130_textureGrad = { - "((function textureGrad\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - ")\n" - ")\n" -}; - -static const char *builtins_130_textureLod = { - "((function textureLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - "))\n" -}; - -static const char *builtins_130_textureProj = { - "((function textureProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - "))\n" -}; - -static const char *builtins_130_textureProjGrad = { - "((function textureLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - "))\n" -}; - -static const char *builtins_130_textureProjLod = { - "((function textureLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - "))\n" -}; - -static const char *functions_for_130 [] = { - builtins_130_clamp, - builtins_130_cosh, - builtins_130_equal, - builtins_130_greaterThan, - builtins_130_greaterThanEqual, - builtins_130_lessThan, - builtins_130_lessThanEqual, - builtins_130_max, - builtins_130_min, - builtins_130_notEqual, - builtins_130_sign, - builtins_130_sinh, - builtins_130_tanh, - builtins_130_texelFetch, - builtins_130_texture, - builtins_130_textureGrad, - builtins_130_textureLod, - builtins_130_textureProj, - builtins_130_textureProjGrad, - builtins_130_textureProjLod, -}; - -/* 130_fs builtins */ - -static const char *builtins_130_fs_texture = { - "((function texture\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - "))\n" -}; - -static const char *builtins_130_fs_textureProj = { - "((function textureProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" - "\n" - "))\n" -}; - -static const char *functions_for_130_fs [] = { - builtins_130_fs_texture, - builtins_130_fs_textureProj, -}; - -/* ARB_texture_rectangle builtins */ - -static const char *builtins_ARB_texture_rectangle_textures = { - "((function texture2DRect\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DRect sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - ")\n" - " (function shadow2DRect\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DRectShadow sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" - "\n" - "))\n" -}; - -static const char *functions_for_ARB_texture_rectangle [] = { - builtins_ARB_texture_rectangle_textures, -}; - -/* EXT_texture_array builtins */ - -static const char *builtins_EXT_texture_array_textures = { - "((function texture1DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - ")\n" - " (function texture1DArrayLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - ")\n" - " (function texture2DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" - "\n" - ")\n" - " (function texture2DArrayLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - ")\n" - " (function shadow1DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArrayShadow sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" - "\n" - ")\n" - " (function shadow1DArrayLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArrayShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" - "\n" - ")\n" - " (function shadow2DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArrayShadow sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) 1 (swiz w (var_ref P)) ))))\n" - "\n" - "))\n" -}; - -static const char *functions_for_EXT_texture_array [] = { - builtins_EXT_texture_array_textures, -}; - -/* EXT_texture_array_fs builtins */ - -static const char *builtins_EXT_texture_array_fs_textures = { - "((function texture1DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - ")\n" - " (function texture2DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - ")\n" - " (function shadow1DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArrayShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" - "\n" - "))\n" -}; - -static const char *functions_for_EXT_texture_array_fs [] = { - builtins_EXT_texture_array_fs_textures, -}; - -void -_mesa_glsl_initialize_functions(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (state->language_version >= 110) - read_builtins(state, instructions, - functions_for_110, - sizeof(functions_for_110) / sizeof(const char *)); - - if (state->target == fragment_shader && state->language_version >= 110) - read_builtins(state, instructions, - functions_for_110_fs, - sizeof(functions_for_110_fs) / sizeof(const char *)); - - if (state->target == vertex_shader && state->language_version >= 110) - read_builtins(state, instructions, - functions_for_110_vs, - sizeof(functions_for_110_vs) / sizeof(const char *)); - - if (state->language_version >= 120) - read_builtins(state, instructions, - functions_for_120, - sizeof(functions_for_120) / sizeof(const char *)); - - if (state->language_version >= 130) - read_builtins(state, instructions, - functions_for_130, - sizeof(functions_for_130) / sizeof(const char *)); - - if (state->target == fragment_shader && state->language_version >= 130) - read_builtins(state, instructions, - functions_for_130_fs, - sizeof(functions_for_130_fs) / sizeof(const char *)); - - if (state->ARB_texture_rectangle_enable) - read_builtins(state, instructions, - functions_for_ARB_texture_rectangle, - sizeof(functions_for_ARB_texture_rectangle) / sizeof(const char *)); - - if (state->EXT_texture_array_enable) - read_builtins(state, instructions, - functions_for_EXT_texture_array, - sizeof(functions_for_EXT_texture_array) / sizeof(const char *)); - - if (state->target == fragment_shader && state->EXT_texture_array_enable) - read_builtins(state, instructions, - functions_for_EXT_texture_array_fs, - sizeof(functions_for_EXT_texture_array_fs) / sizeof(const char *)); - -} diff --git a/builtin_types.h b/builtin_types.h deleted file mode 100644 index 48202f56454..00000000000 --- a/builtin_types.h +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright © 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif - -static const struct glsl_type _error_type = - glsl_type(GLSL_TYPE_ERROR, 0, 0, ""); - -static const struct glsl_type void_type = - glsl_type(GLSL_TYPE_VOID, 0, 0, "void"); - -const glsl_type *const glsl_type::error_type = & _error_type; - -/** \name Core built-in types - * - * These types exist in all versions of GLSL. - */ -/*@{*/ - -static const struct glsl_type builtin_core_types[] = { - glsl_type( GLSL_TYPE_BOOL, 1, 1, "bool"), - glsl_type( GLSL_TYPE_BOOL, 2, 1, "bvec2"), - glsl_type( GLSL_TYPE_BOOL, 3, 1, "bvec3"), - glsl_type( GLSL_TYPE_BOOL, 4, 1, "bvec4"), - glsl_type( GLSL_TYPE_INT, 1, 1, "int"), - glsl_type( GLSL_TYPE_INT, 2, 1, "ivec2"), - glsl_type( GLSL_TYPE_INT, 3, 1, "ivec3"), - glsl_type( GLSL_TYPE_INT, 4, 1, "ivec4"), - glsl_type( GLSL_TYPE_FLOAT, 1, 1, "float"), - glsl_type( GLSL_TYPE_FLOAT, 2, 1, "vec2"), - glsl_type( GLSL_TYPE_FLOAT, 3, 1, "vec3"), - glsl_type( GLSL_TYPE_FLOAT, 4, 1, "vec4"), - glsl_type( GLSL_TYPE_FLOAT, 2, 2, "mat2"), - glsl_type( GLSL_TYPE_FLOAT, 3, 3, "mat3"), - glsl_type( GLSL_TYPE_FLOAT, 4, 4, "mat4"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT, "sampler1D"), - glsl_type( GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT, "sampler1DShadow"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT, "sampler2D"), - glsl_type( GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT, "sampler2DShadow"), - glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT, "sampler3D"), - glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT, "samplerCube"), -}; - -const glsl_type *const glsl_type::bool_type = & builtin_core_types[0]; -const glsl_type *const glsl_type::int_type = & builtin_core_types[4]; -const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7]; -const glsl_type *const glsl_type::float_type = & builtin_core_types[8]; -const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9]; -const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10]; -const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11]; -const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12]; -const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13]; -const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14]; -/*@}*/ - -/** \name GLSL structures that have not been deprecated. - */ -/*@{*/ - -static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = { - { glsl_type::float_type, "near" }, - { glsl_type::float_type, "far" }, - { glsl_type::float_type, "diff" }, -}; - -static const struct glsl_type builtin_structure_types[] = { - glsl_type(gl_DepthRangeParameters_fields, - Elements(gl_DepthRangeParameters_fields), - "gl_DepthRangeParameters"), -}; -/*@}*/ - -/** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30 - */ -/*@{*/ - -static const struct glsl_struct_field gl_PointParameters_fields[] = { - { glsl_type::float_type, "size" }, - { glsl_type::float_type, "sizeMin" }, - { glsl_type::float_type, "sizeMax" }, - { glsl_type::float_type, "fadeThresholdSize" }, - { glsl_type::float_type, "distanceConstantAttenuation" }, - { glsl_type::float_type, "distanceLinearAttenuation" }, - { glsl_type::float_type, "distanceQuadraticAttenuation" }, -}; - -static const struct glsl_struct_field gl_MaterialParameters_fields[] = { - { glsl_type::vec4_type, "emission" }, - { glsl_type::vec4_type, "ambient" }, - { glsl_type::vec4_type, "diffuse" }, - { glsl_type::vec4_type, "specular" }, - { glsl_type::float_type, "shininess" }, -}; - -static const struct glsl_struct_field gl_LightSourceParameters_fields[] = { - { glsl_type::vec4_type, "ambient" }, - { glsl_type::vec4_type, "diffuse" }, - { glsl_type::vec4_type, "specular" }, - { glsl_type::vec4_type, "position" }, - { glsl_type::vec4_type, "halfVector" }, - { glsl_type::vec3_type, "spotDirection" }, - { glsl_type::float_type, "spotExponent" }, - { glsl_type::float_type, "spotCutoff" }, - { glsl_type::float_type, "spotCosCutoff" }, - { glsl_type::float_type, "constantAttenuation" }, - { glsl_type::float_type, "linearAttenuation" }, - { glsl_type::float_type, "quadraticAttenuation" }, -}; - -static const struct glsl_struct_field gl_LightModelParameters_fields[] = { - { glsl_type::vec4_type, "ambient" }, -}; - -static const struct glsl_struct_field gl_LightModelProducts_fields[] = { - { glsl_type::vec4_type, "sceneColor" }, -}; - -static const struct glsl_struct_field gl_LightProducts_fields[] = { - { glsl_type::vec4_type, "ambient" }, - { glsl_type::vec4_type, "diffuse" }, - { glsl_type::vec4_type, "specular" }, -}; - -static const struct glsl_struct_field gl_FogParameters_fields[] = { - { glsl_type::vec4_type, "color" }, - { glsl_type::float_type, "density" }, - { glsl_type::float_type, "start" }, - { glsl_type::float_type, "end" }, - { glsl_type::float_type, "scale" }, -}; - -static const struct glsl_type builtin_110_deprecated_structure_types[] = { - glsl_type(gl_PointParameters_fields, - Elements(gl_PointParameters_fields), - "gl_PointParameters"), - glsl_type(gl_MaterialParameters_fields, - Elements(gl_MaterialParameters_fields), - "gl_MaterialParameters"), - glsl_type(gl_LightSourceParameters_fields, - Elements(gl_LightSourceParameters_fields), - "gl_LightSourceParameters"), - glsl_type(gl_LightModelParameters_fields, - Elements(gl_LightModelParameters_fields), - "gl_LightModelParameters"), - glsl_type(gl_LightModelProducts_fields, - Elements(gl_LightModelProducts_fields), - "gl_LightModelProducts"), - glsl_type(gl_LightProducts_fields, - Elements(gl_LightProducts_fields), - "gl_LightProducts"), - glsl_type(gl_FogParameters_fields, - Elements(gl_FogParameters_fields), - "gl_FogParameters"), -}; -/*@}*/ - -/** \name Types added in GLSL 1.20 - */ -/*@{*/ - -static const struct glsl_type builtin_120_types[] = { - glsl_type( GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), - glsl_type( GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), - glsl_type( GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), - glsl_type( GLSL_TYPE_FLOAT, 4, 3, "mat3x4"), - glsl_type( GLSL_TYPE_FLOAT, 2, 4, "mat4x2"), - glsl_type( GLSL_TYPE_FLOAT, 3, 4, "mat4x3"), -}; -const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0]; -const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1]; -const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2]; -const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3]; -const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4]; -const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5]; -/*@}*/ - -/** \name Types added in GLSL 1.30 - */ -/*@{*/ - -static const struct glsl_type builtin_130_types[] = { - glsl_type( GLSL_TYPE_UINT, 1, 1, "uint"), - glsl_type( GLSL_TYPE_UINT, 2, 1, "uvec2"), - glsl_type( GLSL_TYPE_UINT, 3, 1, "uvec3"), - glsl_type( GLSL_TYPE_UINT, 4, 1, "uvec4"), - - /* 1D and 2D texture arrays */ - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), - - /* cube shadow samplers */ - glsl_type(GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"), - - /* signed and unsigned integer samplers */ - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"), - glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"), - glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"), - glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"), - glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"), -}; - -const glsl_type *const glsl_type::uint_type = & builtin_130_types[0]; -const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3]; -/*@}*/ - -/** \name Sampler types added by GL_ARB_texture_rectangle - */ -/*@{*/ - -static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { - glsl_type(GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"), - glsl_type(GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"), -}; -/*@}*/ - -/** \name Sampler types added by GL_EXT_texture_array - */ -/*@{*/ - -static const struct glsl_type builtin_EXT_texture_array_types[] = { - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), - glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), -}; -/*@}*/ - -/** \name Sampler types added by GL_EXT_texture_buffer_object - */ -/*@{*/ - -static const struct glsl_type builtin_EXT_texture_buffer_object_types[] = { - glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"), - glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"), - glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"), -}; -/*@}*/ diff --git a/builtin_variables.h b/builtin_variables.h deleted file mode 100644 index 77f2fe55023..00000000000 --- a/builtin_variables.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "main/mtypes.h" - -struct builtin_variable { - enum ir_variable_mode mode; - int slot; - const char *type; - const char *name; -}; - -static const builtin_variable builtin_core_vs_variables[] = { - { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_Position" }, - { ir_var_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" }, -}; - -static const builtin_variable builtin_core_fs_variables[] = { - { ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" }, - { ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" }, - { ir_var_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" }, - { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" }, -}; - -static const builtin_variable builtin_110_deprecated_fs_variables[] = { - { ir_var_in, FRAG_ATTRIB_COL0, "vec4", "gl_Color" }, - { ir_var_in, FRAG_ATTRIB_COL1, "vec4", "gl_SecondaryColor" }, - { ir_var_in, FRAG_ATTRIB_FOGC, "float", "gl_FogFragCoord" }, -}; - -static const builtin_variable builtin_110_deprecated_vs_variables[] = { - { ir_var_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" }, - { ir_var_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" }, - { ir_var_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" }, - { ir_var_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" }, - { ir_var_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" }, - { ir_var_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" }, - { ir_var_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" }, - { ir_var_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" }, - { ir_var_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" }, - { ir_var_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" }, - { ir_var_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" }, - { ir_var_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" }, - { ir_var_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" }, - { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_ClipVertex" }, - { ir_var_out, VERT_RESULT_COL0, "vec4", "gl_FrontColor" }, - { ir_var_out, VERT_RESULT_BFC0, "vec4", "gl_BackColor" }, - { ir_var_out, VERT_RESULT_COL1, "vec4", "gl_FrontSecondaryColor" }, - { ir_var_out, VERT_RESULT_BFC1, "vec4", "gl_BackSecondaryColor" }, - { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" }, -}; - -static const builtin_variable builtin_130_vs_variables[] = { - { ir_var_in, -1, "int", "gl_VertexID" }, -}; - -static const builtin_variable builtin_110_deprecated_uniforms[] = { - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" }, - { ir_var_uniform, -1, "mat3", "gl_NormalMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, - { ir_var_uniform, -1, "float", "gl_NormalScale" }, -}; - diff --git a/builtins/110/abs b/builtins/110/abs deleted file mode 100644 index 904845307c4..00000000000 --- a/builtins/110/abs +++ /dev/null @@ -1,21 +0,0 @@ -((function abs - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float abs (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 abs (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 abs (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 abs (var_ref arg0))))) -)) diff --git a/builtins/110/all b/builtins/110/all deleted file mode 100644 index 2cac0dfb684..00000000000 --- a/builtins/110/all +++ /dev/null @@ -1,16 +0,0 @@ -((function all - (signature bool - (parameters - (declare (in) bvec2 arg0)) - ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) - - (signature bool - (parameters - (declare (in) bvec3 arg0)) - ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) - - (signature bool - (parameters - (declare (in) bvec4 arg0)) - ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) -)) diff --git a/builtins/110/any b/builtins/110/any deleted file mode 100644 index f10e8a7b478..00000000000 --- a/builtins/110/any +++ /dev/null @@ -1,16 +0,0 @@ -((function any - (signature bool - (parameters - (declare (in) bvec2 arg0)) - ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) - - (signature bool - (parameters - (declare (in) bvec3 arg0)) - ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) - - (signature bool - (parameters - (declare (in) bvec4 arg0)) - ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) -)) diff --git a/builtins/110/asin b/builtins/110/asin deleted file mode 100644 index fe93337bffc..00000000000 --- a/builtins/110/asin +++ /dev/null @@ -1,112 +0,0 @@ -((function asin - (signature float - (parameters - (declare (in) float x)) - ((return (expression float * - (expression float - - (expression float * - (constant float (3.1415926)) - (constant float (0.5))) - (expression float sqrt - (expression float - - (constant float (1.0)) - (expression float abs (var_ref x))))) - (expression float + - (constant float (1.5707288)) - (expression float * - (expression float abs (var_ref x)) - (expression float + - (constant float (-0.2121144)) - (expression float * - (constant float (0.0742610)) - (expression float abs (var_ref x)))))))))) - - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 * - (expression float - - (expression float * - (constant float (3.1415926)) - (constant float (0.5))) - (expression vec2 sqrt - (expression vec2 - - (constant float (1.0)) - (expression vec2 abs (var_ref x))))) - (expression vec2 + - (constant float (1.5707288)) - (expression vec2 * - (expression vec2 abs (var_ref x)) - (expression vec2 + - (constant float (-0.2121144)) - (expression vec2 * - (constant float (0.0742610)) - (expression vec2 abs (var_ref x)))))))))) - - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 * - (expression vec3 - - (expression float * - (constant float (3.1415926)) - (constant float (0.5))) - (expression vec3 sqrt - (expression vec3 - - (constant float (1.0)) - (expression vec3 abs (var_ref x))))) - (expression vec3 + - (constant float (1.5707288)) - (expression vec3 * - (expression vec3 abs (var_ref x)) - (expression vec3 + - (constant float (-0.2121144)) - (expression vec3 * - (constant float (0.0742610)) - (expression vec3 abs (var_ref x)))))))))) - - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 * - (expression vec4 - - (expression float * - (constant float (3.1415926)) - (constant float (0.5))) - (expression vec4 sqrt - (expression vec4 - - (constant float (1.0)) - (expression vec4 abs (var_ref x))))) - (expression vec4 + - (constant float (1.5707288)) - (expression vec4 * - (expression vec4 abs (var_ref x)) - (expression vec4 + - (constant float (-0.2121144)) - (expression vec4 * - (constant float (0.0742610)) - (expression vec4 abs (var_ref x)))))))))) -) - - (function acos - (signature float - (parameters - (declare (in) float x)) - ((return (expression float - (constant float (1.5707963)) - (call asin ((var_ref x))))))) - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 - (constant float (1.5707963)) - (call asin ((var_ref x))))))) - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 - (constant float (1.5707963)) - (call asin ((var_ref x))))))) - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 - (constant float (1.5707963)) - (call asin ((var_ref x))))))) -)) diff --git a/builtins/110/atan b/builtins/110/atan deleted file mode 100644 index e5542350b51..00000000000 --- a/builtins/110/atan +++ /dev/null @@ -1,154 +0,0 @@ -((function atan - (signature float - (parameters - (declare (in) float x)) - ((return (call asin ((expression float * - (var_ref x) - (expression float rsq - (expression float + - (expression float * - (var_ref x) - (var_ref x)) - (constant float (1.0)))))))))) - - (signature vec2 - (parameters - (declare (in) vec2 y_over_x)) - ((return (call asin ((expression vec2 * - (var_ref y_over_x) - (expression vec2 rsq - (expression vec2 + - (expression vec2 * - (var_ref y_over_x) - (var_ref y_over_x)) - (constant float (1.0)))))))))) - - (signature vec3 - (parameters - (declare (in) vec3 y_over_x)) - ((return (call asin ((expression vec3 * - (var_ref y_over_x) - (expression vec3 rsq - (expression vec3 + - (expression vec3 * - (var_ref y_over_x) - (var_ref y_over_x)) - (constant float (1.0)))))))))) - - (signature vec4 - (parameters - (declare (in) vec4 y_over_x)) - ((return (call asin ((expression vec4 * - (var_ref y_over_x) - (expression vec4 rsq - (expression vec4 + - (expression vec4 * - (var_ref y_over_x) - (var_ref y_over_x)) - (constant float (1.0)))))))))) - - (signature float - (parameters - (declare (in) float y) - (declare (in) float x)) - ((declare () float r) - (if (expression bool > - (expression float abs (var_ref x)) - (constant float (.0001))) - ((assign (constant bool (1)) - (var_ref r) (call atan ((expression float / - (var_ref y) - (var_ref x))))) - (if (expression bool < - (var_ref x) - (constant float (0.0))) - ((assign (constant bool (1)) - (var_ref r) - (expression float + - (var_ref r) - (expression float * - (expression int sign (var_ref y)) - (constant float (3.1415926)))))) - ())) - ()) - (return (var_ref r)))) - - (signature vec2 - (parameters - (declare (in) vec2 y) - (declare (in) vec2 x)) - ((declare () vec2 r) - (if (expression bool > - (expression vec2 abs (var_ref x)) - (constant float (.0001))) - ((assign (constant bool (1)) - (var_ref r) (call atan ((expression vec2 / - (var_ref y) - (var_ref x))))) - (if (expression bool < - (var_ref x) - (constant float (0.0))) - ((assign (constant bool (1)) - (var_ref r) - (expression vec2 + - (var_ref r) - (expression vec2 * - (expression int sign (var_ref y)) - (constant float (3.1415926)))))) - ())) - ()) - (return (var_ref r)))) - - (signature vec3 - (parameters - (declare (in) vec3 y) - (declare (in) vec3 x)) - ((declare () vec3 r) - (if (expression bool > - (expression vec3 abs (var_ref x)) - (constant float (.0001))) - ((assign (constant bool (1)) - (var_ref r) (call atan ((expression vec3 / - (var_ref y) - (var_ref x))))) - (if (expression bool < - (var_ref x) - (constant float (0.0))) - ((assign (constant bool (1)) - (var_ref r) - (expression vec3 + - (var_ref r) - (expression vec3 * - (expression int sign (var_ref y)) - (constant float (3.1415926)))))) - ())) - ()) - (return (var_ref r)))) - - (signature vec4 - (parameters - (declare (in) vec4 y) - (declare (in) vec4 x)) - ((declare () vec4 r) - (if (expression bool > - (expression vec4 abs (var_ref x)) - (constant float (.0001))) - ((assign (constant bool (1)) - (var_ref r) (call atan ((expression vec4 / - (var_ref y) - (var_ref x))))) - (if (expression bool < - (var_ref x) - (constant float (0.0))) - ((assign (constant bool (1)) - (var_ref r) - (expression vec4 + - (var_ref r) - (expression vec4 * - (expression int sign (var_ref y)) - (constant float (3.1415926)))))) - ())) - ()) - (return (var_ref r)))) - -)) diff --git a/builtins/110/ceil b/builtins/110/ceil deleted file mode 100644 index a26a7750493..00000000000 --- a/builtins/110/ceil +++ /dev/null @@ -1,21 +0,0 @@ -((function ceil - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float ceil (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 ceil (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 ceil (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 ceil (var_ref arg0))))) -)) diff --git a/builtins/110/clamp b/builtins/110/clamp deleted file mode 100644 index 94c8e5ed168..00000000000 --- a/builtins/110/clamp +++ /dev/null @@ -1,62 +0,0 @@ -((function clamp - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1) - (declare (in) float arg2)) - ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1) - (declare (in) vec2 arg2)) - ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1) - (declare (in) vec3 arg2)) - ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1) - (declare (in) vec4 arg2)) - ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) float arg1) - (declare (in) float arg2)) - ((declare () vec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) float arg1) - (declare (in) float arg2)) - ((declare () vec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) float arg1) - (declare (in) float arg2)) - ((declare () vec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) (expression vec4 max (expression vec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) -)) diff --git a/builtins/110/cos b/builtins/110/cos deleted file mode 100644 index 88f266eccbe..00000000000 --- a/builtins/110/cos +++ /dev/null @@ -1,21 +0,0 @@ -((function cos - (signature float - (parameters - (declare (in) float angle)) - ((return (expression float cos (var_ref angle))))) - - (signature vec2 - (parameters - (declare (in) vec2 angle)) - ((return (expression vec2 cos (var_ref angle))))) - - (signature vec3 - (parameters - (declare (in) vec3 angle)) - ((return (expression vec3 cos (var_ref angle))))) - - (signature vec4 - (parameters - (declare (in) vec4 angle)) - ((return (expression vec4 cos (var_ref angle))))) -)) diff --git a/builtins/110/cross b/builtins/110/cross deleted file mode 100644 index deb2f952bfc..00000000000 --- a/builtins/110/cross +++ /dev/null @@ -1,17 +0,0 @@ -((function cross - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () vec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float - (expression float * (swiz y (var_ref arg0)) (swiz z (var_ref arg1))) - (expression float * (swiz y (var_ref arg1)) (swiz z (var_ref arg0))))) - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float - (expression float * (swiz z (var_ref arg0)) (swiz x (var_ref arg1))) - (expression float * (swiz z (var_ref arg1)) (swiz x (var_ref arg0))))) - (assign (constant bool (1)) (swiz z (var_ref t)) - (expression float - (expression float * (swiz x (var_ref arg0)) (swiz y (var_ref arg1))) - (expression float * (swiz x (var_ref arg1)) (swiz y (var_ref arg0))))) - (return (var_ref t)))) -)) diff --git a/builtins/110/degrees b/builtins/110/degrees deleted file mode 100644 index dc0d7b9e20d..00000000000 --- a/builtins/110/degrees +++ /dev/null @@ -1,21 +0,0 @@ -((function degrees - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float * (var_ref arg0) (constant float (57.295780)))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 * (var_ref arg0) (constant float (57.295780)))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 * (var_ref arg0) (constant float (57.295780)))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 * (var_ref arg0) (constant float (57.295780)))))) -)) diff --git a/builtins/110/distance b/builtins/110/distance deleted file mode 100644 index a2309c484f9..00000000000 --- a/builtins/110/distance +++ /dev/null @@ -1,33 +0,0 @@ -((function distance - (signature float - (parameters - (declare (in) float p0) - (declare (in) float p1)) - ((declare () float p) - (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1))) - (return (expression float sqrt (expression float dot (var_ref p) (var_ref p)))))) - - (signature float - (parameters - (declare (in) vec2 p0) - (declare (in) vec2 p1)) - ((declare () vec2 p) - (assign (constant bool (1)) (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 - (parameters - (declare (in) vec3 p0) - (declare (in) vec3 p1)) - ((declare () vec3 p) - (assign (constant bool (1)) (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 - (parameters - (declare (in) vec4 p0) - (declare (in) vec4 p1)) - ((declare () vec4 p) - (assign (constant bool (1)) (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/builtins/110/dot b/builtins/110/dot deleted file mode 100644 index a91a6d2c56d..00000000000 --- a/builtins/110/dot +++ /dev/null @@ -1,25 +0,0 @@ -((function dot - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1)) - ((return (expression float dot (var_ref arg0) (var_ref arg1))))) - - (signature float - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((return (expression float dot (var_ref arg0) (var_ref arg1))))) - - (signature float - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression float dot (var_ref arg0) (var_ref arg1))))) - - (signature float - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((return (expression float dot (var_ref arg0) (var_ref arg1))))) -)) diff --git a/builtins/110/equal b/builtins/110/equal deleted file mode 100644 index ae7ddc53bdc..00000000000 --- a/builtins/110/equal +++ /dev/null @@ -1,61 +0,0 @@ -((function equal - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/110/exp b/builtins/110/exp deleted file mode 100644 index a73bd6a7f84..00000000000 --- a/builtins/110/exp +++ /dev/null @@ -1,21 +0,0 @@ -((function exp - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float exp (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 exp (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 exp (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 exp (var_ref arg0))))) -)) diff --git a/builtins/110/exp2 b/builtins/110/exp2 deleted file mode 100644 index a842d3fe65b..00000000000 --- a/builtins/110/exp2 +++ /dev/null @@ -1,21 +0,0 @@ -((function exp2 - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float exp2 (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 exp2 (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 exp2 (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 exp2 (var_ref arg0))))) -)) diff --git a/builtins/110/faceforward b/builtins/110/faceforward deleted file mode 100644 index d1703972388..00000000000 --- a/builtins/110/faceforward +++ /dev/null @@ -1,37 +0,0 @@ -((function faceforward - (signature float - (parameters - (declare (in) float N) - (declare (in) float I) - (declare (in) float Nref)) - ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) - ((return (var_ref N))) - ((return (expression float neg (var_ref N))))))) - - (signature vec2 - (parameters - (declare (in) vec2 N) - (declare (in) vec2 I) - (declare (in) vec2 Nref)) - ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) - ((return (var_ref N))) - ((return (expression vec2 neg (var_ref N))))))) - - (signature vec3 - (parameters - (declare (in) vec3 N) - (declare (in) vec3 I) - (declare (in) vec3 Nref)) - ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) - ((return (var_ref N))) - ((return (expression vec3 neg (var_ref N))))))) - - (signature vec4 - (parameters - (declare (in) vec4 N) - (declare (in) vec4 I) - (declare (in) vec4 Nref)) - ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) - ((return (var_ref N))) - ((return (expression vec4 neg (var_ref N))))))) -)) diff --git a/builtins/110/floor b/builtins/110/floor deleted file mode 100644 index 8dd8052799b..00000000000 --- a/builtins/110/floor +++ /dev/null @@ -1,21 +0,0 @@ -((function floor - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float floor (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 floor (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 floor (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 floor (var_ref arg0))))) -)) diff --git a/builtins/110/fract b/builtins/110/fract deleted file mode 100644 index 3995bfaf3f9..00000000000 --- a/builtins/110/fract +++ /dev/null @@ -1,34 +0,0 @@ -((function fract - (signature float - (parameters - (declare (in) float x)) - ((return (expression float - (var_ref x) (expression float floor (var_ref x)))))) - - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((declare () vec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) - (return (var_ref t)))) - - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((declare () vec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x))))) - (return (var_ref t)))) - - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((declare () vec4 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x))))) - (assign (constant bool (1)) (swiz w (var_ref t)) (expression float - (swiz w (var_ref x)) (expression float floor (swiz w (var_ref x))))) - (return (var_ref t)))) -)) - diff --git a/builtins/110/greaterThan b/builtins/110/greaterThan deleted file mode 100644 index ae03030e495..00000000000 --- a/builtins/110/greaterThan +++ /dev/null @@ -1,61 +0,0 @@ -((function greaterThan - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/110/greaterThanEqual b/builtins/110/greaterThanEqual deleted file mode 100644 index 204d5fd1439..00000000000 --- a/builtins/110/greaterThanEqual +++ /dev/null @@ -1,61 +0,0 @@ -((function greaterThanEqual - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/110/inversesqrt b/builtins/110/inversesqrt deleted file mode 100644 index 5b66d2b3695..00000000000 --- a/builtins/110/inversesqrt +++ /dev/null @@ -1,21 +0,0 @@ -((function inversesqrt - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float rsq (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 rsq (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 rsq (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 rsq (var_ref arg0))))) -)) diff --git a/builtins/110/length b/builtins/110/length deleted file mode 100644 index 89ff7f3ef12..00000000000 --- a/builtins/110/length +++ /dev/null @@ -1,21 +0,0 @@ -((function length - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) - - (signature float - (parameters - (declare (in) vec2 arg0)) - ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) - - (signature float - (parameters - (declare (in) vec3 arg0)) - ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) - - (signature float - (parameters - (declare (in) vec4 arg0)) - ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) -)) diff --git a/builtins/110/lessThan b/builtins/110/lessThan deleted file mode 100644 index 5c4254165c7..00000000000 --- a/builtins/110/lessThan +++ /dev/null @@ -1,61 +0,0 @@ -((function lessThan - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/110/lessThanEqual b/builtins/110/lessThanEqual deleted file mode 100644 index ccb955b8a76..00000000000 --- a/builtins/110/lessThanEqual +++ /dev/null @@ -1,61 +0,0 @@ -((function lessThanEqual - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/110/log b/builtins/110/log deleted file mode 100644 index d168abb5a73..00000000000 --- a/builtins/110/log +++ /dev/null @@ -1,21 +0,0 @@ -((function log - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float log (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 log (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 log (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 log (var_ref arg0))))) -)) diff --git a/builtins/110/log2 b/builtins/110/log2 deleted file mode 100644 index b96c6276f0a..00000000000 --- a/builtins/110/log2 +++ /dev/null @@ -1,21 +0,0 @@ -((function log2 - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float log2 (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 log2 (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 log2 (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 log2 (var_ref arg0))))) -)) diff --git a/builtins/110/matrixCompMult b/builtins/110/matrixCompMult deleted file mode 100644 index cb5a2cb1f7b..00000000000 --- a/builtins/110/matrixCompMult +++ /dev/null @@ -1,32 +0,0 @@ -((function matrixCompMult - (signature mat2 - (parameters - (declare (in) mat2 x) - (declare (in) mat2 y)) - ((declare () mat2 z) - (assign (constant bool (1)) (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)) (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 - (parameters - (declare (in) mat3 x) - (declare (in) mat3 y)) - ((declare () mat3 z) - (assign (constant bool (1)) (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)) (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)) (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 - (parameters - (declare (in) mat4 x) - (declare (in) mat4 y)) - ((declare () mat4 z) - (assign (constant bool (1)) (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)) (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)) (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)) (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)))) -)) - diff --git a/builtins/110/max b/builtins/110/max deleted file mode 100644 index c05545f3d93..00000000000 --- a/builtins/110/max +++ /dev/null @@ -1,64 +0,0 @@ -((function max - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1)) - ((return (expression float max (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((return (expression vec2 max (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression vec3 max (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) float arg1)) - ((declare () vec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) float arg1)) - ((declare () vec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float max (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) float arg1)) - ((declare () vec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float max (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression float max (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) -)) diff --git a/builtins/110/min b/builtins/110/min deleted file mode 100644 index 31e79489405..00000000000 --- a/builtins/110/min +++ /dev/null @@ -1,64 +0,0 @@ -((function min - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1)) - ((return (expression float min (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((return (expression vec2 min (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression vec3 min (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) float arg1)) - ((declare () vec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) float arg1)) - ((declare () vec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float min (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) float arg1)) - ((declare () vec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float min (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression float min (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) -)) diff --git a/builtins/110/mix b/builtins/110/mix deleted file mode 100644 index 032f29e5fa8..00000000000 --- a/builtins/110/mix +++ /dev/null @@ -1,50 +0,0 @@ -((function mix - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1) - (declare (in) float arg2)) - ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2)))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1) - (declare (in) vec2 arg2)) - ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1) - (declare (in) vec3 arg2)) - ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1) - (declare (in) vec4 arg2)) - ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1) - (declare (in) float arg2)) - ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1) - (declare (in) float arg2)) - ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1) - (declare (in) float arg2)) - ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) -)) diff --git a/builtins/110/mod b/builtins/110/mod deleted file mode 100644 index 9e08bbc7ef4..00000000000 --- a/builtins/110/mod +++ /dev/null @@ -1,64 +0,0 @@ -((function mod - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1)) - ((return (expression float % (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((return (expression vec2 % (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression vec3 % (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) float arg1)) - ((declare () vec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) float arg1)) - ((declare () vec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float % (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) float arg1)) - ((declare () vec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float % (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression float % (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) -)) diff --git a/builtins/110/noise_fake b/builtins/110/noise_fake deleted file mode 100644 index bcfb17b04b8..00000000000 --- a/builtins/110/noise_fake +++ /dev/null @@ -1,76 +0,0 @@ -((function noise1 - (signature float - (parameters - (declare (in) float x)) - ((return (constant float (0))))) - (signature float - (parameters - (declare (in) vec2 x)) - ((return (constant float (0))))) - (signature float - (parameters - (declare (in) vec3 x)) - ((return (constant float (0))))) - (signature float - (parameters - (declare (in) vec4 x)) - ((return (constant float (0))))) - ) - - (function noise2 - (signature vec2 - (parameters - (declare (in) float x)) - ((return (constant vec2 (0 0))))) - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (constant vec2 (0 0))))) - (signature vec2 - (parameters - (declare (in) vec3 x)) - ((return (constant vec2 (0 0))))) - (signature vec2 - (parameters - (declare (in) vec4 x)) - ((return (constant vec2 (0 0))))) - ) - - (function noise3 - (signature vec3 - (parameters - (declare (in) float x)) - ((return (constant vec3 (0 0 0))))) - (signature vec3 - (parameters - (declare (in) vec2 x)) - ((return (constant vec3 (0 0 0))))) - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (constant vec3 (0 0 0))))) - (signature vec3 - (parameters - (declare (in) vec4 x)) - ((return (constant vec3 (0 0 0))))) - ) - - (function noise4 - (signature vec4 - (parameters - (declare (in) float x)) - ((return (constant vec4 (0 0 0 0))))) - (signature vec4 - (parameters - (declare (in) vec2 x)) - ((return (constant vec4 (0 0 0 0))))) - (signature vec4 - (parameters - (declare (in) vec3 x)) - ((return (constant vec4 (0 0 0 0))))) - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (constant vec4 (0 0 0 0))))) - ) -) diff --git a/builtins/110/normalize b/builtins/110/normalize deleted file mode 100644 index be88a9830d1..00000000000 --- a/builtins/110/normalize +++ /dev/null @@ -1,21 +0,0 @@ -((function normalize - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) -)) diff --git a/builtins/110/not b/builtins/110/not deleted file mode 100644 index b696b06557f..00000000000 --- a/builtins/110/not +++ /dev/null @@ -1,16 +0,0 @@ -((function not - (signature bvec2 - (parameters - (declare (in) bvec2 arg0)) - ((return (expression bvec2 ! (var_ref arg0))))) - - (signature bvec3 - (parameters - (declare (in) bvec3 arg0)) - ((return (expression bvec3 ! (var_ref arg0))))) - - (signature bvec4 - (parameters - (declare (in) bvec4 arg0)) - ((return (expression bvec4 ! (var_ref arg0))))) -)) diff --git a/builtins/110/notEqual b/builtins/110/notEqual deleted file mode 100644 index c87efa317f7..00000000000 --- a/builtins/110/notEqual +++ /dev/null @@ -1,61 +0,0 @@ -((function notEqual - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/110/pow b/builtins/110/pow deleted file mode 100644 index a61bc4418e3..00000000000 --- a/builtins/110/pow +++ /dev/null @@ -1,25 +0,0 @@ -((function pow - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1)) - ((return (expression float pow (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((return (expression vec2 pow (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression vec3 pow (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((return (expression vec4 pow (var_ref arg0) (var_ref arg1))))) -)) diff --git a/builtins/110/radians b/builtins/110/radians deleted file mode 100644 index 6a0f5d2e219..00000000000 --- a/builtins/110/radians +++ /dev/null @@ -1,21 +0,0 @@ -((function radians - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float * (var_ref arg0) (constant float (0.017453)))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 * (var_ref arg0) (constant float (0.017453)))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 * (var_ref arg0) (constant float (0.017453)))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 * (var_ref arg0) (constant float (0.017453)))))) -)) diff --git a/builtins/110/reflect b/builtins/110/reflect deleted file mode 100644 index 8238fdc93fd..00000000000 --- a/builtins/110/reflect +++ /dev/null @@ -1,58 +0,0 @@ -((function reflect - (signature float - (parameters - (declare (in) float i) - (declare (in) float n)) - ((return (expression float - - (var_ref i) - (expression float * - (constant float (2.0)) - (expression float * - (expression float dot - (var_ref n) - (var_ref i)) - (var_ref n))))))) - - (signature vec2 - (parameters - (declare (in) vec2 i) - (declare (in) vec2 n)) - ((return (expression vec2 - - (var_ref i) - (expression vec2 * - (constant float (2.0)) - (expression vec2 * - (expression float dot - (var_ref n) - (var_ref i)) - (var_ref n))))))) - - (signature vec3 - (parameters - (declare (in) vec3 i) - (declare (in) vec3 n)) - ((return (expression vec3 - - (var_ref i) - (expression vec3 * - (constant float (2.0)) - (expression vec3 * - (expression float dot - (var_ref n) - (var_ref i)) - (var_ref n))))))) - - (signature vec4 - (parameters - (declare (in) vec4 i) - (declare (in) vec4 n)) - ((return (expression vec4 - - (var_ref i) - (expression vec4 * - (constant float (2.0)) - (expression vec4 * - (expression float dot - (var_ref n) - (var_ref i)) - (var_ref n))))))) - -)) diff --git a/builtins/110/refract b/builtins/110/refract deleted file mode 100644 index e9b1475294a..00000000000 --- a/builtins/110/refract +++ /dev/null @@ -1,102 +0,0 @@ -((function refract - (signature float - (parameters - (declare (in) float i) - (declare (in) float n) - (declare (in) float eta)) - ((declare () float k) - (assign (constant bool (1)) (var_ref k) - (expression float - (constant float (1.0)) - (expression float * (var_ref eta) - (expression float * (var_ref eta) - (expression float - (constant float (1.0)) - (expression float * - (expression float dot (var_ref n) (var_ref i)) - (expression float dot (var_ref n) (var_ref i)))))))) - (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant float (0.0)))) - ((return (expression float - - (expression float * (var_ref eta) (var_ref i)) - (expression float * - (expression float + - (expression float * (var_ref eta) - (expression float dot (var_ref n) (var_ref i))) - (expression float sqrt (var_ref k))) - (var_ref n)))))))) - - (signature vec2 - (parameters - (declare (in) vec2 i) - (declare (in) vec2 n) - (declare (in) float eta)) - ((declare () float k) - (assign (constant bool (1)) (var_ref k) - (expression float - (constant float (1.0)) - (expression float * (var_ref eta) - (expression float * (var_ref eta) - (expression float - (constant float (1.0)) - (expression float * - (expression float dot (var_ref n) (var_ref i)) - (expression float dot (var_ref n) (var_ref i)))))))) - (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant vec2 (0.0 0.0)))) - ((return (expression vec2 - - (expression vec2 * (var_ref eta) (var_ref i)) - (expression vec2 * - (expression float + - (expression float * (var_ref eta) - (expression float dot (var_ref n) (var_ref i))) - (expression float sqrt (var_ref k))) - (var_ref n)))))))) - - (signature vec3 - (parameters - (declare (in) vec3 i) - (declare (in) vec3 n) - (declare (in) float eta)) - ((declare () float k) - (assign (constant bool (1)) (var_ref k) - (expression float - (constant float (1.0)) - (expression float * (var_ref eta) - (expression float * (var_ref eta) - (expression float - (constant float (1.0)) - (expression float * - (expression float dot (var_ref n) (var_ref i)) - (expression float dot (var_ref n) (var_ref i)))))))) - (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant vec3 (0.0 0.0)))) - ((return (expression vec3 - - (expression vec3 * (var_ref eta) (var_ref i)) - (expression vec3 * - (expression float + - (expression float * (var_ref eta) - (expression float dot (var_ref n) (var_ref i))) - (expression float sqrt (var_ref k))) - (var_ref n)))))))) - - (signature vec4 - (parameters - (declare (in) vec4 i) - (declare (in) vec4 n) - (declare (in) float eta)) - ((declare () float k) - (assign (constant bool (1)) (var_ref k) - (expression float - (constant float (1.0)) - (expression float * (var_ref eta) - (expression float * (var_ref eta) - (expression float - (constant float (1.0)) - (expression float * - (expression float dot (var_ref n) (var_ref i)) - (expression float dot (var_ref n) (var_ref i)))))))) - (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant vec4 (0.0 0.0)))) - ((return (expression vec4 - - (expression vec4 * (var_ref eta) (var_ref i)) - (expression vec4 * - (expression float + - (expression float * (var_ref eta) - (expression float dot (var_ref n) (var_ref i))) - (expression float sqrt (var_ref k))) - (var_ref n)))))))) - -)) diff --git a/builtins/110/sign b/builtins/110/sign deleted file mode 100644 index 7d540de405b..00000000000 --- a/builtins/110/sign +++ /dev/null @@ -1,34 +0,0 @@ -((function sign - (signature float - (parameters - (declare (in) float x)) - ((return (expression float sign (var_ref x))))) - - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((declare () vec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) - (return (var_ref t)))) - - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((declare () vec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x)))) - (return (var_ref t)))) - - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((declare () vec4 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x)))) - (assign (constant bool (1)) (swiz w (var_ref t)) (expression float sign (swiz w (var_ref x)))) - (return (var_ref t)))) -)) - diff --git a/builtins/110/sin b/builtins/110/sin deleted file mode 100644 index e6009d8ef12..00000000000 --- a/builtins/110/sin +++ /dev/null @@ -1,21 +0,0 @@ -((function sin - (signature float - (parameters - (declare (in) float angle)) - ((return (expression float sin (var_ref angle))))) - - (signature vec2 - (parameters - (declare (in) vec2 angle)) - ((return (expression vec2 sin (var_ref angle))))) - - (signature vec3 - (parameters - (declare (in) vec3 angle)) - ((return (expression vec3 sin (var_ref angle))))) - - (signature vec4 - (parameters - (declare (in) vec4 angle)) - ((return (expression vec4 sin (var_ref angle))))) -)) diff --git a/builtins/110/smoothstep b/builtins/110/smoothstep deleted file mode 100644 index b4255ba78f1..00000000000 --- a/builtins/110/smoothstep +++ /dev/null @@ -1,224 +0,0 @@ -((function smoothstep - (signature float - (parameters - (declare (in) float edge0) - (declare (in) float edge1) - (declare (in) float x)) - ((declare () float t) - - (assign (constant bool (1)) (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))) - (constant float (1.0))) - (constant float (0.0)))) - (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t)))))))) - - (signature vec2 - (parameters - (declare (in) float edge0) - (declare (in) float edge1) - (declare (in) vec2 x)) - ((declare () vec2 t) - (declare () vec2 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - (return (var_ref retval)) - )) - - (signature vec3 - (parameters - (declare (in) float edge0) - (declare (in) float edge1) - (declare (in) vec3 x)) - ((declare () vec3 t) - (declare () vec3 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - - (assign (constant bool (1)) (swiz z (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) - (return (var_ref retval)) - )) - - - (signature vec4 - (parameters - (declare (in) float edge0) - (declare (in) float edge1) - (declare (in) vec4 x)) - ((declare () vec4 t) - (declare () vec4 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - - (assign (constant bool (1)) (swiz z (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) - - (assign (constant bool (1)) (swiz w (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t))))))) - (return (var_ref retval)) - )) - - (signature vec2 - (parameters - (declare (in) vec2 edge0) - (declare (in) vec2 edge1) - (declare (in) vec2 x)) - ((declare () vec2 t) - (declare () vec2 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - (return (var_ref retval)) - )) - - (signature vec3 - (parameters - (declare (in) vec3 edge0) - (declare (in) vec3 edge1) - (declare (in) vec3 x)) - ((declare () vec3 t) - (declare () vec3 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - - (assign (constant bool (1)) (swiz z (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) - (return (var_ref retval)) - )) - - - (signature vec4 - (parameters - (declare (in) vec4 edge0) - (declare (in) vec4 edge1) - (declare (in) vec4 x)) - ((declare () vec4 t) - (declare () vec4 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - - (assign (constant bool (1)) (swiz z (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) - - (assign (constant bool (1)) (swiz w (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz w (var_ref x)) (swiz w (var_ref edge0))) (expression float - (swiz w (var_ref edge1)) (swiz w (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t))))))) - (return (var_ref retval)) - )) - -)) - diff --git a/builtins/110/sqrt b/builtins/110/sqrt deleted file mode 100644 index 0302d164ae5..00000000000 --- a/builtins/110/sqrt +++ /dev/null @@ -1,21 +0,0 @@ -((function sqrt - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float sqrt (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 sqrt (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 sqrt (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 sqrt (var_ref arg0))))) -)) diff --git a/builtins/110/step b/builtins/110/step deleted file mode 100644 index 1cc2b51f8fb..00000000000 --- a/builtins/110/step +++ /dev/null @@ -1,68 +0,0 @@ -((function step - (signature float - (parameters - (declare (in) float edge) - (declare (in) float x)) - ((return (expression float b2f (expression bool < (var_ref x) (var_ref edge)))))) - - (signature vec2 - (parameters - (declare (in) float edge) - (declare (in) vec2 x)) - ((declare () vec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) - (return (var_ref t)))) - - (signature vec3 - (parameters - (declare (in) float edge) - (declare (in) vec3 x)) - ((declare () vec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge)))) - (return (var_ref t)))) - - (signature vec4 - (parameters - (declare (in) float edge) - (declare (in) vec4 x)) - ((declare () vec4 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(var_ref edge)))) - (return (var_ref t)))) - - (signature vec2 - (parameters - (declare (in) vec2 edge) - (declare (in) vec2 x)) - ((declare () vec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) - (assign (constant bool (1)) (swiz 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 - (parameters - (declare (in) vec3 edge) - (declare (in) vec3 x)) - ((declare () vec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge))))) - (assign (constant bool (1)) (swiz 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 - (parameters - (declare (in) vec4 edge) - (declare (in) vec4 x)) - ((declare () vec4 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge))))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz z (var_ref edge))))) - (assign (constant bool (1)) (swiz 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/builtins/110/tan b/builtins/110/tan deleted file mode 100644 index 3e04892a76c..00000000000 --- a/builtins/110/tan +++ /dev/null @@ -1,21 +0,0 @@ -((function tan - (signature float - (parameters - (declare (in) float angle)) - ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle)))))) - - (signature vec2 - (parameters - (declare (in) vec2 angle)) - ((return (expression float / (expression float sin (var_ref angle)) (expression vec2 cos (var_ref angle)))))) - - (signature vec3 - (parameters - (declare (in) vec3 angle)) - ((return (expression float / (expression float sin (var_ref angle)) (expression vec3 cos (var_ref angle)))))) - - (signature vec4 - (parameters - (declare (in) vec4 angle)) - ((return (expression float / (expression float sin (var_ref angle)) (expression vec4 cos (var_ref angle)))))) -)) diff --git a/builtins/110/textures b/builtins/110/textures deleted file mode 100644 index c81b7e8ad49..00000000000 --- a/builtins/110/textures +++ /dev/null @@ -1,213 +0,0 @@ -((function texture1D - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function texture1DLod - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function texture1DProj - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - -) - (function texture1DProjLod - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - -) - (function texture2D - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) -(function texture2DLod - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function texture2DProj - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - -) - (function texture2DProjLod - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - -) - (function texture3D - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function texture3DLod - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function texture3DProj - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - -) - (function texture3DProjLod - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - -) - (function textureCube - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function textureCubeLod - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function shadow1D - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) - -) - (function shadow1DLod - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) - -) - (function shadow1DProj - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) )))) - -) - (function shadow1DProjLod - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) )))) - -) - (function shadow2D - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) - -) - (function shadow2DLod - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) - -) - (function shadow2DProj - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) )))) - -) - (function shadow2DProjLod - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) )))) - -)) diff --git a/builtins/110_fs/derivatives b/builtins/110_fs/derivatives deleted file mode 100644 index b79852ee1ff..00000000000 --- a/builtins/110_fs/derivatives +++ /dev/null @@ -1,73 +0,0 @@ -((function dFdx - (signature float - (parameters - (declare (in) float p)) - ((return (expression float dFdx (var_ref p))))) - - (signature vec2 - (parameters - (declare (in) vec2 p)) - ((return (expression vec2 dFdx (var_ref p))))) - - (signature vec3 - (parameters - (declare (in) vec3 p)) - ((return (expression vec3 dFdx (var_ref p))))) - - (signature vec4 - (parameters - (declare (in) vec4 p)) - ((return (expression vec4 dFdx (var_ref p))))) - ) - - (function dFdy - (signature float - (parameters - (declare (in) float p)) - ((return (expression float dFdy (var_ref p))))) - - (signature vec2 - (parameters - (declare (in) vec2 p)) - ((return (expression vec2 dFdy (var_ref p))))) - - (signature vec3 - (parameters - (declare (in) vec3 p)) - ((return (expression vec3 dFdy (var_ref p))))) - - (signature vec4 - (parameters - (declare (in) vec4 p)) - ((return (expression vec4 dFdy (var_ref p))))) - ) - - (function fwidth - (signature float - (parameters - (declare (in) float p)) - ((return (expression float + - (expression float abs (expression float dFdx (var_ref p))) - (expression float abs (expression float dFdy (var_ref p))))))) - - (signature vec2 - (parameters - (declare (in) vec2 p)) - ((return (expression vec2 + - (expression vec2 abs (expression vec2 dFdx (var_ref p))) - (expression vec2 abs (expression vec2 dFdy (var_ref p))))))) - - (signature vec3 - (parameters - (declare (in) vec3 p)) - ((return (expression vec3 + - (expression vec3 abs (expression vec3 dFdx (var_ref p))) - (expression vec3 abs (expression vec3 dFdy (var_ref p))))))) - - (signature vec4 - (parameters - (declare (in) vec4 p)) - ((return (expression vec4 + - (expression vec4 abs (expression vec4 dFdx (var_ref p))) - (expression vec4 abs (expression vec4 dFdy (var_ref p))))))) -)) diff --git a/builtins/110_fs/textures b/builtins/110_fs/textures deleted file mode 100644 index 38f3787e9ef..00000000000 --- a/builtins/110_fs/textures +++ /dev/null @@ -1,113 +0,0 @@ -((function texture1D - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function texture1DProj - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - -) - (function texture2D - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function texture2DProj - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - -) - (function texture3D - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function texture3DProj - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - -) - (function textureCube - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function shadow1D - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) - -) - (function shadow1DProj - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) )))) - -) - (function shadow2D - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) - -) - (function shadow2DProj - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) )))) - -)) diff --git a/builtins/110_vs/ftransform b/builtins/110_vs/ftransform deleted file mode 100644 index 3a5e8ccecfc..00000000000 --- a/builtins/110_vs/ftransform +++ /dev/null @@ -1,7 +0,0 @@ -((function ftransform - (signature vec4 - (parameters) - ((return (expression vec4 * - (var_ref gl_ModelViewProjectionMatrix) - (var_ref gl_Vertex))))) -)) diff --git a/builtins/120/matrixCompMult b/builtins/120/matrixCompMult deleted file mode 100644 index 69331e26525..00000000000 --- a/builtins/120/matrixCompMult +++ /dev/null @@ -1,61 +0,0 @@ -((function matrixCompMult - (signature mat2x3 - (parameters - (declare (in) mat2x3 x) - (declare (in) mat2x3 y)) - ((declare () mat2x3 z) - (assign (constant bool (1)) (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)) (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 - (parameters - (declare (in) mat3x2 x) - (declare (in) mat3x2 y)) - ((declare () mat3x2 z) - (assign (constant bool (1)) (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)) (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)) (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 - (parameters - (declare (in) mat2x4 x) - (declare (in) mat2x4 y)) - ((declare () mat2x4 z) - (assign (constant bool (1)) (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)) (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 - (parameters - (declare (in) mat4x2 x) - (declare (in) mat4x2 y)) - ((declare () mat4x2 z) - (assign (constant bool (1)) (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)) (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)) (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)) (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 - (parameters - (declare (in) mat3x4 x) - (declare (in) mat3x4 y)) - ((declare () mat3x4 z) - (assign (constant bool (1)) (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)) (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)) (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 - (parameters - (declare (in) mat4x3 x) - (declare (in) mat4x3 y)) - ((declare () mat4x3 z) - (assign (constant bool (1)) (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)) (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)) (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)) (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/builtins/120/outerProduct b/builtins/120/outerProduct deleted file mode 100644 index b401ba02337..00000000000 --- a/builtins/120/outerProduct +++ /dev/null @@ -1,92 +0,0 @@ -((function outerProduct - (signature mat2 - (parameters - (declare (in) vec2 u) - (declare (in) vec2 v)) - ((declare () mat2 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) -(return (var_ref m)))) - - (signature mat2x3 - (parameters - (declare (in) vec2 u) - (declare (in) vec3 v)) - ((declare () mat2x3 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) -(return (var_ref m)))) - - (signature mat2x4 - (parameters - (declare (in) vec2 u) - (declare (in) vec4 v)) - ((declare () mat2x4 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) -(return (var_ref m)))) - - (signature mat3x2 - (parameters - (declare (in) vec3 u) - (declare (in) vec2 v)) - ((declare () mat3x2 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) -(return (var_ref m)))) - - (signature mat3 - (parameters - (declare (in) vec3 u) - (declare (in) vec3 v)) - ((declare () mat3 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) -(return (var_ref m)))) - - (signature mat3x4 - (parameters - (declare (in) vec3 u) - (declare (in) vec4 v)) - ((declare () mat3x4 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) -(return (var_ref m)))) - - (signature mat4x2 - (parameters - (declare (in) vec4 u) - (declare (in) vec2 v)) - ((declare () mat4x2 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref v) (swiz w (var_ref u)))) -(return (var_ref m)))) - - (signature mat4x3 - (parameters - (declare (in) vec4 u) - (declare (in) vec3 v)) - ((declare () mat4x3 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref v) (swiz w (var_ref u)))) -(return (var_ref m)))) - - (signature mat4 - (parameters - (declare (in) vec4 u) - (declare (in) vec4 v)) - ((declare () mat4 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref v) (swiz w (var_ref u)))) -(return (var_ref m)))) -)) - diff --git a/builtins/120/transpose b/builtins/120/transpose deleted file mode 100644 index 416a0ee4677..00000000000 --- a/builtins/120/transpose +++ /dev/null @@ -1,139 +0,0 @@ -((function transpose - (signature mat2 - (parameters - (declare (in) mat2 m)) - ((declare () mat2 t) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz 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/builtins/130/clamp b/builtins/130/clamp deleted file mode 100644 index 3aed22c20df..00000000000 --- a/builtins/130/clamp +++ /dev/null @@ -1,123 +0,0 @@ -((function clamp - (signature int - (parameters - (declare (in) int arg0) - (declare (in) int arg1) - (declare (in) int arg2)) - ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1) - (declare (in) ivec2 arg2)) - ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1) - (declare (in) ivec3 arg2)) - ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1) - (declare (in) ivec4 arg2)) - ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) int arg1) - (declare (in) int arg2)) - ((declare () ivec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) int arg1) - (declare (in) int arg2)) - ((declare () ivec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) int arg1) - (declare (in) int arg2)) - ((declare () ivec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) - - (signature uint - (parameters - (declare (in) uint arg0) - (declare (in) uint arg1) - (declare (in) uint arg2)) - ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1) - (declare (in) uvec2 arg2)) - ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1) - (declare (in) uvec3 arg2)) - ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1) - (declare (in) uvec4 arg2)) - ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uint arg1) - (declare (in) uint arg2)) - ((declare () uvec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uint arg1) - (declare (in) uint arg2)) - ((declare () uvec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uint arg1) - (declare (in) uint arg2)) - ((declare () uvec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) -)) diff --git a/builtins/130/cosh b/builtins/130/cosh deleted file mode 100644 index 45e0ae427d6..00000000000 --- a/builtins/130/cosh +++ /dev/null @@ -1,30 +0,0 @@ -((function cosh - (signature float - (parameters - (declare (in) float x)) - ((return (expression float * (constant float (0.5)) - (expression float + - (expression float exp (var_ref x)) - (expression float exp (expression float neg (var_ref x)))))))) - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 * (constant vec2 (0.5)) - (expression vec2 + - (expression vec2 exp (var_ref x)) - (expression vec2 exp (expression vec2 neg (var_ref x)))))))) - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 * (constant vec3 (0.5)) - (expression vec3 + - (expression vec3 exp (var_ref x)) - (expression vec3 exp (expression vec3 neg (var_ref x)))))))) - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 * (constant vec4 (0.5)) - (expression vec4 + - (expression vec4 exp (var_ref x)) - (expression vec4 exp (expression vec4 neg (var_ref x)))))))) -)) diff --git a/builtins/130/equal b/builtins/130/equal deleted file mode 100644 index 079c3e97fb2..00000000000 --- a/builtins/130/equal +++ /dev/null @@ -1,31 +0,0 @@ -((function equal - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/130/greaterThan b/builtins/130/greaterThan deleted file mode 100644 index a9fb7b3a43e..00000000000 --- a/builtins/130/greaterThan +++ /dev/null @@ -1,31 +0,0 @@ -((function greaterThan - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/130/greaterThanEqual b/builtins/130/greaterThanEqual deleted file mode 100644 index 293c93c7cca..00000000000 --- a/builtins/130/greaterThanEqual +++ /dev/null @@ -1,31 +0,0 @@ -((function greaterThanEqual - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/130/lessThan b/builtins/130/lessThan deleted file mode 100644 index d9f693fd63f..00000000000 --- a/builtins/130/lessThan +++ /dev/null @@ -1,31 +0,0 @@ -((function lessThan - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/130/lessThanEqual b/builtins/130/lessThanEqual deleted file mode 100644 index 494411b869a..00000000000 --- a/builtins/130/lessThanEqual +++ /dev/null @@ -1,31 +0,0 @@ -((function lessThanEqual - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/130/max b/builtins/130/max deleted file mode 100644 index 45a6089c9f2..00000000000 --- a/builtins/130/max +++ /dev/null @@ -1,127 +0,0 @@ -((function max - (signature int - (parameters - (declare (in) int arg0) - (declare (in) int arg1)) - ((return (expression int max (var_ref arg0) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((return (expression ivec2 max (var_ref arg0) (var_ref arg1))))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((return (expression ivec3 max (var_ref arg0) (var_ref arg1))))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((return (expression ivec4 max (var_ref arg0) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) int arg1)) - ((declare () ivec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) int arg1)) - ((declare () ivec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression int max (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) int arg1)) - ((declare () ivec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression int max (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression int max (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature uint - (parameters - (declare (in) uint arg0) - (declare (in) uint arg1)) - ((return (expression uint max (var_ref arg0) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((return (expression uvec2 max (var_ref arg0) (var_ref arg1))))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((return (expression uvec3 max (var_ref arg0) (var_ref arg1))))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((return (expression uvec4 max (var_ref arg0) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uint arg1)) - ((declare () uvec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uint arg1)) - ((declare () uvec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression uint max (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uint arg1)) - ((declare () uvec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression uint max (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression uint max (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) -)) diff --git a/builtins/130/min b/builtins/130/min deleted file mode 100644 index d98ec1e79da..00000000000 --- a/builtins/130/min +++ /dev/null @@ -1,127 +0,0 @@ -((function min - (signature int - (parameters - (declare (in) int arg0) - (declare (in) int arg1)) - ((return (expression int min (var_ref arg0) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((return (expression ivec2 min (var_ref arg0) (var_ref arg1))))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((return (expression ivec3 min (var_ref arg0) (var_ref arg1))))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((return (expression ivec4 min (var_ref arg0) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) int arg1)) - ((declare () ivec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) int arg1)) - ((declare () ivec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression int min (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) int arg1)) - ((declare () ivec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression int min (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression int min (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature uint - (parameters - (declare (in) uint arg0) - (declare (in) uint arg1)) - ((return (expression uint min (var_ref arg0) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((return (expression uvec2 min (var_ref arg0) (var_ref arg1))))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((return (expression uvec3 min (var_ref arg0) (var_ref arg1))))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((return (expression uvec4 min (var_ref arg0) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uint arg1)) - ((declare () uvec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uint arg1)) - ((declare () uvec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression uint min (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uint arg1)) - ((declare () uvec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression uint min (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression uint min (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) -)) diff --git a/builtins/130/notEqual b/builtins/130/notEqual deleted file mode 100644 index 81e6376bd9c..00000000000 --- a/builtins/130/notEqual +++ /dev/null @@ -1,31 +0,0 @@ -((function notEqual - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/builtins/130/sign b/builtins/130/sign deleted file mode 100644 index 0bdc0e09d25..00000000000 --- a/builtins/130/sign +++ /dev/null @@ -1,34 +0,0 @@ -((function sign - (signature int - (parameters - (declare (in) int x)) - ((return (expression int / (var_ref x) (expression int abs (var_ref x)))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 x)) - ((declare () ivec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) - (return (var_ref t)))) - - (signature ivec3 - (parameters - (declare (in) ivec3 x)) - ((declare () ivec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x)))) - (return (var_ref t)))) - - (signature ivec4 - (parameters - (declare (in) ivec4 x)) - ((declare () ivec4 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x)))) - (assign (constant bool (1)) (swiz w (var_ref t)) (expression int sign (swiz w (var_ref x)))) - (return (var_ref t)))) -)) - diff --git a/builtins/130/sinh b/builtins/130/sinh deleted file mode 100644 index 7ad4f58e204..00000000000 --- a/builtins/130/sinh +++ /dev/null @@ -1,30 +0,0 @@ -((function sinh - (signature float - (parameters - (declare (in) float x)) - ((return (expression float * (constant float (0.5)) - (expression float - - (expression float exp (var_ref x)) - (expression float exp (expression float neg (var_ref x)))))))) - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 * (constant vec2 (0.5)) - (expression vec2 - - (expression vec2 exp (var_ref x)) - (expression vec2 exp (expression vec2 neg (var_ref x)))))))) - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 * (constant vec3 (0.5)) - (expression vec3 - - (expression vec3 exp (var_ref x)) - (expression vec3 exp (expression vec3 neg (var_ref x)))))))) - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 * (constant vec4 (0.5)) - (expression vec4 - - (expression vec4 exp (var_ref x)) - (expression vec4 exp (expression vec4 neg (var_ref x)))))))) -)) diff --git a/builtins/130/tanh b/builtins/130/tanh deleted file mode 100644 index 3b7271bf779..00000000000 --- a/builtins/130/tanh +++ /dev/null @@ -1,42 +0,0 @@ -((function tanh - (signature float - (parameters - (declare (in) float x)) - ((return (expression float / - (expression float - - (expression float exp (var_ref x)) - (expression float exp (expression float neg (var_ref x)))) - (expression float + - (expression float exp (var_ref x)) - (expression float exp (expression float neg (var_ref x)))))))) - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 / - (expression vec2 - - (expression vec2 exp (var_ref x)) - (expression vec2 exp (expression vec2 neg (var_ref x)))) - (expression vec2 + - (expression vec2 exp (var_ref x)) - (expression vec2 exp (expression vec2 neg (var_ref x)))))))) - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 / - (expression vec3 - - (expression vec3 exp (var_ref x)) - (expression vec3 exp (expression vec3 neg (var_ref x)))) - (expression vec3 + - (expression vec3 exp (var_ref x)) - (expression vec3 exp (expression vec3 neg (var_ref x)))))))) - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 / - (expression vec4 - - (expression vec4 exp (var_ref x)) - (expression vec4 exp (expression vec4 neg (var_ref x)))) - (expression vec4 + - (expression vec4 exp (var_ref x)) - (expression vec4 exp (expression vec4 neg (var_ref x)))))))) -)) diff --git a/builtins/130/texelFetch b/builtins/130/texelFetch deleted file mode 100644 index d51ce65a897..00000000000 --- a/builtins/130/texelFetch +++ /dev/null @@ -1,107 +0,0 @@ -((function texelFetch - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) int P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) int P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) int P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1DArray sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1DArray sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2DArray sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2DArray sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - -)) diff --git a/builtins/130/texture b/builtins/130/texture deleted file mode 100644 index b170b583094..00000000000 --- a/builtins/130/texture +++ /dev/null @@ -1,110 +0,0 @@ -((function texture - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) float P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) float P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isamplerCube sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usamplerCube sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isampler1DArray sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usampler1DArray sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isampler2DArray sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usampler2DArray sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -)) diff --git a/builtins/130/textureGrad b/builtins/130/textureGrad deleted file mode 100644 index 0ef428c224a..00000000000 --- a/builtins/130/textureGrad +++ /dev/null @@ -1,147 +0,0 @@ -((function textureGrad - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) float P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) float P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isamplerCube sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usamplerCube sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - -) -) diff --git a/builtins/130/textureLod b/builtins/130/textureLod deleted file mode 100644 index 7d7059d848c..00000000000 --- a/builtins/130/textureLod +++ /dev/null @@ -1,128 +0,0 @@ -((function textureLod - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) float P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) float P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isamplerCube sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usamplerCube sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -)) diff --git a/builtins/130/textureProj b/builtins/130/textureProj deleted file mode 100644 index 40ea1c2af68..00000000000 --- a/builtins/130/textureProj +++ /dev/null @@ -1,92 +0,0 @@ -((function textureProj - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - -)) diff --git a/builtins/130/textureProjGrad b/builtins/130/textureProjGrad deleted file mode 100644 index a0142c5e683..00000000000 --- a/builtins/130/textureProjGrad +++ /dev/null @@ -1,122 +0,0 @@ -((function textureLod - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec2 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec2 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec4 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec4 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec3 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec3 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec4 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec4 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec4 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec4 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - -)) diff --git a/builtins/130/textureProjLod b/builtins/130/textureProjLod deleted file mode 100644 index 9f4ce1b493d..00000000000 --- a/builtins/130/textureProjLod +++ /dev/null @@ -1,107 +0,0 @@ -((function textureLod - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - -)) diff --git a/builtins/130_fs/texture b/builtins/130_fs/texture deleted file mode 100644 index 0de981397f0..00000000000 --- a/builtins/130_fs/texture +++ /dev/null @@ -1,128 +0,0 @@ -((function texture - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) float P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) float P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isamplerCube sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usamplerCube sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -)) diff --git a/builtins/130_fs/textureProj b/builtins/130_fs/textureProj deleted file mode 100644 index b1d8f0a2f33..00000000000 --- a/builtins/130_fs/textureProj +++ /dev/null @@ -1,107 +0,0 @@ -((function textureProj - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - -)) diff --git a/builtins/ARB_texture_rectangle/textures b/builtins/ARB_texture_rectangle/textures deleted file mode 100644 index 161d8c4a541..00000000000 --- a/builtins/ARB_texture_rectangle/textures +++ /dev/null @@ -1,16 +0,0 @@ -((function texture2DRect - (signature vec4 - (parameters - (declare (in) sampler2DRect sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function shadow2DRect - (signature vec4 - (parameters - (declare (in) sampler2DRectShadow sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) - -)) diff --git a/builtins/EXT_texture_array/textures b/builtins/EXT_texture_array/textures deleted file mode 100644 index 8a91f901401..00000000000 --- a/builtins/EXT_texture_array/textures +++ /dev/null @@ -1,59 +0,0 @@ -((function texture1DArray - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function texture1DArrayLod - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function texture2DArray - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function texture2DArrayLod - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function shadow1DArray - (signature vec4 - (parameters - (declare (in) sampler1DArrayShadow sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) - -) - (function shadow1DArrayLod - (signature vec4 - (parameters - (declare (in) sampler1DArrayShadow sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) - -) - (function shadow2DArray - (signature vec4 - (parameters - (declare (in) sampler2DArrayShadow sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) 1 (swiz w (var_ref P)) )))) - -)) diff --git a/builtins/EXT_texture_array_fs/textures b/builtins/EXT_texture_array_fs/textures deleted file mode 100644 index 74e184387ac..00000000000 --- a/builtins/EXT_texture_array_fs/textures +++ /dev/null @@ -1,27 +0,0 @@ -((function texture1DArray - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function texture2DArray - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function shadow1DArray - (signature vec4 - (parameters - (declare (in) sampler1DArrayShadow sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) - -)) diff --git a/builtins/tools/generate_builtins.pl b/builtins/tools/generate_builtins.pl deleted file mode 100755 index 8b640ab8ff9..00000000000 --- a/builtins/tools/generate_builtins.pl +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env perl - -sub process_version { - my ($version) = @_; - my @vars; - print "/* $version builtins */\n\n"; - - my @files = ; - foreach $file (@files) { - push(@vars, process_file($file)); - } - - print "static const char *functions_for_$version [] = {\n"; - foreach $var (@vars) { - print " $var,\n"; - } - print "};\n\n" -} - -sub process_file { - my ($file) = @_; - - # Change from builtins/110/foo to builtins_110_foo - my $var = $file; $var =~ s!/!_!g; - - print "static const char *$var = {\n"; - open SRC, "<", "$file" or die $!; - while () { - s/\\/\\\\/g; - s/\"/\\\"/g; - s/\n/\\n/g; - print " \"$_\"\n"; - } - print "};\n\n"; - close SRC or die $!; - return $var; -} - -print << 'EOF'; -/* DO NOT MODIFY - automatically generated by generate_builtins.pl */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include "glsl_parser_extras.h" -#include "ir_reader.h" - -void -read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, - const char **functions, unsigned count) -{ - if (st->error) - return; - - for (unsigned i = 0; i < count; i++) { - _mesa_glsl_read_ir(st, instructions, functions[i]); - - if (st->error) { - printf("error reading builtin: %.35s ...\n", functions[i]); - return; - } - } -} - -EOF - -@versions = sort(); -foreach $version (@versions) { - $version =~ s!builtins/!!g; - process_version($version); -} - -print << 'EOF'; -void -_mesa_glsl_initialize_functions(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ -EOF - -foreach $version_xs (@versions) { - $check = ""; - if ($version_xs =~ /_vs/) { - $check = "state->target == vertex_shader && "; - } elsif ($version_xs =~ /_fs/) { - $check = "state->target == fragment_shader && "; - } - $version = $version_xs; - $version =~ s/_[vf]s//g; - - if ($version =~ /^[1-9][0-9][0-9]/) { - $check = "${check}state->language_version >= $version"; - } else { - # Not a version...an extension name - $check = "${check}state->${version}_enable"; - } - print " if ($check)\n"; - print " read_builtins(state, instructions,\n"; - print " functions_for_$version_xs,\n"; - print " sizeof(functions_for_$version_xs) / "; - print "sizeof(const char *));\n\n" -} - -print "}\n"; diff --git a/builtins/tools/generate_matrixCompMultGLSL.py b/builtins/tools/generate_matrixCompMultGLSL.py deleted file mode 100755 index 391ad110d37..00000000000 --- a/builtins/tools/generate_matrixCompMultGLSL.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python - -def gen_matrix(x, y = 0): - if y == 0: - y = x - type = "mat" + str(x) - if x != y: - type = type + "x" + str(y) - print type + " matrixCompMult(" + type + " x, " + type + " y)\n{" - print " " + type + " z;" - - for i in range(x): - print " z[" + str(i) + "] = x[" + str(i) + "] * y[" + str(i) + "];" - print " return z;\n}" - -print "#version 120" -# 1.10 -gen_matrix(2) -gen_matrix(3) -gen_matrix(4) - -# 1.20 -gen_matrix(2,3) # mat2x3 means 2 columns, 3 rows -gen_matrix(3,2) -gen_matrix(2,4) -gen_matrix(4,2) -gen_matrix(3,4) -gen_matrix(4,3) diff --git a/builtins/tools/generate_outerProductGLSL.py b/builtins/tools/generate_outerProductGLSL.py deleted file mode 100755 index 48fb72197c3..00000000000 --- a/builtins/tools/generate_outerProductGLSL.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/python - -def gen(x, y): - type = "mat" + str(x) - if x != y: - type = type + "x" + str(y) - print type + " outerProduct(vec" + str(x) + " u, vec" + str(y) + " v)\n{" - print " " + type + " m;" - - for i in range(x): - print " m[" + str(i) + "] = v * u[" + str(i) + "];" - print " return m;\n}" - -print "#version 120" -gen(2,2) -gen(2,3) # mat2x3 means 2 columns, 3 rows -gen(2,4) -gen(3,2) -gen(3,3) -gen(3,4) -gen(4,2) -gen(4,3) -gen(4,4) diff --git a/builtins/tools/generate_transposeGLSL.py b/builtins/tools/generate_transposeGLSL.py deleted file mode 100755 index 8f669ce9839..00000000000 --- a/builtins/tools/generate_transposeGLSL.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python - -def gen(x, y): - origtype = "mat" + str(x) - trantype = "mat" + str(y) - if x != y: - origtype = origtype + "x" + str(y) - trantype = trantype + "x" + str(x) - print trantype + " transpose(" + origtype + " m)\n{" - print " " + trantype + " t;" - - # The obvious implementation of transpose - for i in range(x): - for j in range(y): - print " t[" + str(j) + "][" + str(i) + "] =", - print "m[" + str(i) + "][" + str(j) + "];" - print " return t;\n}" - -print "#version 120" -gen(2,2) -gen(2,3) # mat2x3 means 2 columns, 3 rows -gen(2,4) -gen(3,2) -gen(3,3) -gen(3,4) -gen(4,2) -gen(4,3) -gen(4,4) diff --git a/builtins/tools/texture_builtins.py b/builtins/tools/texture_builtins.py deleted file mode 100755 index 23d53149161..00000000000 --- a/builtins/tools/texture_builtins.py +++ /dev/null @@ -1,298 +0,0 @@ -#!/usr/bin/python - -from os import path -import sys - -def vec_type(g, size): - if size == 1: - if g == "i": - return "int" - elif g == "u": - return "uint" - return "float" - return g + "vec" + str(size) - -# Get the base dimension - i.e. sampler3D gives 3 -# Array samplers also get +1 here since the layer is really an extra coordinate -def get_coord_dim(sampler_type): - if sampler_type[0].isdigit(): - coord_dim = int(sampler_type[0]) - elif sampler_type.startswith("Cube"): - coord_dim = 3 - else: - assert False ("coord_dim: invalid sampler_type: " + sampler_type) - - if sampler_type.find("Array") != -1: - coord_dim += 1 - return coord_dim - -# Get the number of extra vector components (i.e. shadow comparitor) -def get_extra_dim(sampler_type, use_proj, unused_fields): - extra_dim = unused_fields - if sampler_type.find("Shadow") != -1: - extra_dim += 1 - if use_proj: - extra_dim += 1 - return extra_dim - -def generate_sigs(g, tex_inst, sampler_type, use_proj = False, unused_fields = 0): - coord_dim = get_coord_dim(sampler_type) - extra_dim = get_extra_dim(sampler_type, use_proj, unused_fields) - - # Print parameters - print " (signature " + g + "vec4" - print " (parameters" - print " (declare (in) " + g + "sampler" + sampler_type + " sampler)" - print " (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)", - if tex_inst == "txb": - print "\n (declare (in) float bias)", - elif tex_inst == "txl": - print "\n (declare (in) float lod)", - elif tex_inst == "txf": - print "\n (declare (in) int lod)", - elif tex_inst == "txd": - grad_type = vec_type("", coord_dim) - print "\n (declare (in) " + grad_type + " dPdx)", - print "\n (declare (in) " + grad_type + " dPdy)", - - print ")\n ((return (" + tex_inst + " (var_ref sampler)", - - # Coordinate - if extra_dim > 0: - print "(swiz " + "xyzw"[:coord_dim] + " (var_ref P))", - else: - print "(var_ref P)", - - # Offset - print "(0 0 0)", - - if tex_inst != "txf": - # Projective divisor - if use_proj: - print "(swiz " + "xyzw"[coord_dim + extra_dim-1] + " (var_ref P))", - else: - print "1", - - # Shadow comparitor - if sampler_type == "2DArrayShadow": # a special case: - print "(swiz w (var_ref P))", # ...array layer is z; shadow is w - elif sampler_type.endswith("Shadow"): - print "(swiz z (var_ref P))", - else: - print "()", - - # Bias/explicit LOD/gradient: - if tex_inst == "txb": - print "(var_ref bias)", - elif tex_inst == "txl" or tex_inst == "txf": - print "(var_ref lod)", - elif tex_inst == "txd": - print "((var_ref dPdx) (var_ref dPdy))", - print "))))\n" - -def generate_fiu_sigs(tex_inst, sampler_type, use_proj = False, unused_fields = 0): - generate_sigs("", tex_inst, sampler_type, use_proj, unused_fields) - generate_sigs("i", tex_inst, sampler_type, use_proj, unused_fields) - generate_sigs("u", tex_inst, sampler_type, use_proj, unused_fields) - -builtins_dir = path.join(path.dirname(path.abspath(__file__)), "..") - -with open(path.join(builtins_dir, "130", "texture"), 'w') as sys.stdout: - print "((function texture" - generate_fiu_sigs("tex", "1D") - generate_fiu_sigs("tex", "2D") - generate_fiu_sigs("tex", "3D") - generate_fiu_sigs("tex", "Cube") - generate_fiu_sigs("tex", "1DArray") - generate_fiu_sigs("tex", "2DArray") - print "))" - -# txb variants are only allowed within a fragment shader (GLSL 1.30 p. 86) -with open(path.join(builtins_dir, "130_fs", "texture"), 'w') as sys.stdout: - print "((function texture" - generate_fiu_sigs("txb", "1D") - generate_fiu_sigs("txb", "2D") - generate_fiu_sigs("txb", "3D") - generate_fiu_sigs("txb", "Cube") - generate_fiu_sigs("txb", "1DArray") - generate_fiu_sigs("txb", "2DArray") - print "))" - -with open(path.join(builtins_dir, "130", "textureProj"), 'w') as sys.stdout: - print "((function textureProj" - generate_fiu_sigs("tex", "1D", True) - generate_fiu_sigs("tex", "1D", True, 2) - generate_fiu_sigs("tex", "2D", True) - generate_fiu_sigs("tex", "2D", True, 1) - generate_fiu_sigs("tex", "3D", True) - print "))" - -with open(path.join(builtins_dir, "130_fs", "textureProj"), 'w') as sys.stdout: - print "((function textureProj" - generate_fiu_sigs("txb", "1D", True) - generate_fiu_sigs("txb", "1D", True, 2) - generate_fiu_sigs("txb", "2D", True) - generate_fiu_sigs("txb", "2D", True, 1) - generate_fiu_sigs("txb", "3D", True) - print "))" - -with open(path.join(builtins_dir, "130", "textureLod"), 'w') as sys.stdout: - print "((function textureLod" - generate_fiu_sigs("txl", "1D") - generate_fiu_sigs("txl", "2D") - generate_fiu_sigs("txl", "3D") - generate_fiu_sigs("txl", "Cube") - generate_fiu_sigs("txl", "1DArray") - generate_fiu_sigs("txl", "2DArray") - print "))" - -with open(path.join(builtins_dir, "130", "texelFetch"), 'w') as sys.stdout: - print "((function texelFetch" - generate_fiu_sigs("txf", "1D") - generate_fiu_sigs("txf", "2D") - generate_fiu_sigs("txf", "3D") - generate_fiu_sigs("txf", "1DArray") - generate_fiu_sigs("txf", "2DArray") - print "))" - -with open(path.join(builtins_dir, "130", "textureProjLod"), 'w') as sys.stdout: - print "((function textureLod" - generate_fiu_sigs("txl", "1D", True) - generate_fiu_sigs("txl", "1D", True, 2) - generate_fiu_sigs("txl", "2D", True) - generate_fiu_sigs("txl", "2D", True, 1) - generate_fiu_sigs("txl", "3D", True) - print "))" - -with open(path.join(builtins_dir, "130", "textureGrad"), 'w') as sys.stdout: - print "((function textureGrad" - generate_fiu_sigs("txd", "1D") - generate_fiu_sigs("txd", "2D") - generate_fiu_sigs("txd", "3D") - generate_fiu_sigs("txd", "Cube") - generate_fiu_sigs("txd", "1DArray") - generate_fiu_sigs("txd", "2DArray") - print ")\n)" - -with open(path.join(builtins_dir, "130", "textureProjGrad"), 'w') as sys.stdout: - print "((function textureLod" - generate_fiu_sigs("txd", "1D", True) - generate_fiu_sigs("txd", "1D", True, 2) - generate_fiu_sigs("txd", "2D", True) - generate_fiu_sigs("txd", "2D", True, 1) - generate_fiu_sigs("txd", "3D", True) - print "))" - -# ARB_texture_rectangle extension -with open(path.join(builtins_dir, "ARB_texture_rectangle", "textures"), 'w') as sys.stdout: - print "((function texture2DRect" - generate_sigs("", "tex", "2DRect") - print ")\n (function shadow2DRect" - generate_sigs("", "tex", "2DRectShadow") - print "))" - -# EXT_texture_array extension -with open(path.join(builtins_dir, "EXT_texture_array", "textures"), 'w') as sys.stdout: - print "((function texture1DArray" - generate_sigs("", "tex", "1DArray") - print ")\n (function texture1DArrayLod" - generate_sigs("", "txl", "1DArray") - print ")\n (function texture2DArray" - generate_sigs("", "tex", "2DArray") - print ")\n (function texture2DArrayLod" - generate_sigs("", "txl", "2DArray") - print ")\n (function shadow1DArray" - generate_sigs("", "tex", "1DArrayShadow") - print ")\n (function shadow1DArrayLod" - generate_sigs("", "txl", "1DArrayShadow") - print ")\n (function shadow2DArray" - generate_sigs("", "tex", "2DArrayShadow") - print "))" - -with open(path.join(builtins_dir, "EXT_texture_array_fs", "textures"), 'w') as sys.stdout: - print "((function texture1DArray" - generate_sigs("", "txb", "1DArray") # MOVE TO _fs - print ")\n (function texture2DArray" - generate_sigs("", "txb", "2DArray") # MOVE TO _fs - print ")\n (function shadow1DArray" - generate_sigs("", "txb", "1DArrayShadow") - print "))" - -# Deprecated (110/120 style) functions with silly names: -with open(path.join(builtins_dir, "110", "textures"), 'w') as sys.stdout: - print "((function texture1D" - generate_sigs("", "tex", "1D") - print ")\n (function texture1DLod" - generate_sigs("", "txl", "1D") - print ")\n (function texture1DProj" - generate_sigs("", "tex", "1D", True) - generate_sigs("", "tex", "1D", True, 2) - print ")\n (function texture1DProjLod" - generate_sigs("", "txl", "1D", True) - generate_sigs("", "txl", "1D", True, 2) - print ")\n (function texture2D" - generate_sigs("", "tex", "2D") - print ")\n(function texture2DLod" - generate_sigs("", "txl", "2D") - print ")\n (function texture2DProj" - generate_sigs("", "tex", "2D", True) - generate_sigs("", "tex", "2D", True, 1) - print ")\n (function texture2DProjLod" - generate_sigs("", "txl", "2D", True) - generate_sigs("", "txl", "2D", True, 1) - print ")\n (function texture3D" - generate_sigs("", "tex", "3D") - print ")\n (function texture3DLod" - generate_sigs("", "txl", "3D") - print ")\n (function texture3DProj" - generate_sigs("", "tex", "3D", True) - print ")\n (function texture3DProjLod" - generate_sigs("", "txl", "3D", True) - print ")\n (function textureCube" - generate_sigs("", "tex", "Cube") - print ")\n (function textureCubeLod" - generate_sigs("", "txl", "Cube") - print ")\n (function shadow1D" - generate_sigs("", "tex", "1DShadow", False, 1) - print ")\n (function shadow1DLod" - generate_sigs("", "txl", "1DShadow", False, 1) - print ")\n (function shadow1DProj" - generate_sigs("", "tex", "1DShadow", True, 1) - print ")\n (function shadow1DProjLod" - generate_sigs("", "txl", "1DShadow", True, 1) - print ")\n (function shadow2D" - generate_sigs("", "tex", "2DShadow") - print ")\n (function shadow2DLod" - generate_sigs("", "txl", "2DShadow") - print ")\n (function shadow2DProj" - generate_sigs("", "tex", "2DShadow", True) - print ")\n (function shadow2DProjLod" - generate_sigs("", "txl", "2DShadow", True) - print "))" - -with open(path.join(builtins_dir, "110_fs", "textures"), 'w') as sys.stdout: - print "((function texture1D" - generate_sigs("", "txb", "1D") - print ")\n (function texture1DProj" - generate_sigs("", "txb", "1D", True) - generate_sigs("", "txb", "1D", True, 2) - print ")\n (function texture2D" - generate_sigs("", "txb", "2D") - print ")\n (function texture2DProj" - generate_sigs("", "txb", "2D", True) - generate_sigs("", "txb", "2D", True, 1) - print ")\n (function texture3D" - generate_sigs("", "txb", "3D") - print ")\n (function texture3DProj" - generate_sigs("", "txb", "3D", True) - print ")\n (function textureCube" - generate_sigs("", "txb", "Cube") - print ")\n (function shadow1D" - generate_sigs("", "txb", "1DShadow", False, 1) - print ")\n (function shadow1DProj" - generate_sigs("", "txb", "1DShadow", True, 1) - print ")\n (function shadow2D" - generate_sigs("", "txb", "2DShadow") - print ")\n (function shadow2DProj" - generate_sigs("", "txb", "2DShadow", True) - print "))" diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 73ce67de3d1..00000000000 --- a/configure.ac +++ /dev/null @@ -1,69 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.61) -AC_INIT(glsl, XXXXX, idr@freedesktop.org, glsl) -AC_CONFIG_SRCDIR([Makefile.am]) -AM_CONFIG_HEADER([config.h]) -AC_CONFIG_FILES([glcpp/Makefile]) - -AM_INIT_AUTOMAKE -LT_INIT - -AM_MAINTAINER_MODE - -# Checks for programs. -AC_PROG_CXX -AC_PROG_CC -AC_PROG_MAKE_SET -AC_PROG_YACC -AC_PROG_LEX - -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -# Checks for libraries. - -# Checks for header files. - -# Checks for typedefs, structures, and compiler characteristics. - -# Checks for library functions. -AC_HEADER_STDC - -AH_TOP([#ifndef GLSL_CONFIG_H -#define GLSL_CONFIG_H]) -AH_BOTTOM([#endif /* GLSL_CONFIG_H */]) - -PKG_CHECK_MODULES([talloc], [talloc >= 2.0]) - -AC_ARG_ENABLE([debug], - [AS_HELP_STRING([--enable-debug], - [use debug compiler flags and macros @<:@default=disabled@:>@])], - [enable_debug="$enableval"], - [enable_debug=no] -) -if test "x$enable_debug" = xyes; then - DEFINES="$DEFINES -DDEBUG" - if test "x$GCC" = xyes; then - # Remove any -g or -O flags from the command line - CFLAGS=[`echo $CFLAGS | sed 's/-g[^ \t]*[ \t]*//g;s/-O[^ \t]*[ \t]*//g'`] - CFLAGS="$CFLAGS -O0 -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2" - fi - if test "x$GXX" = xyes; then - # Remove any -g flags from the command line - CXXFLAGS=[`echo $CXXFLAGS | sed 's/-g[^ \t]*[ \t]*//g;s/-O[^ \t]*[ \t]*//g'`] - CXXFLAGS="$CXXFLAGS -O0 -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2" - fi -fi - -if test "x$GXX" = xyes ; then - WARN="-Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector" -else - WARN="" -fi - -CFLAGS="$CFLAGS $WARN" -CXXFLAGS="$CXXFLAGS $WARN" -YFLAGS="-d -v" - -AC_OUTPUT([Makefile]) diff --git a/glcpp/.gitignore b/glcpp/.gitignore deleted file mode 100644 index c158dc8b862..00000000000 --- a/glcpp/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -glcpp -glcpp-lex.c -glcpp-parse.c -glcpp-parse.h -glcpp-parse.output -*.o -*.lo -*.la -.libs -*~ -tests/*.out diff --git a/glcpp/Makefile.am b/glcpp/Makefile.am deleted file mode 100644 index a49fd615cda..00000000000 --- a/glcpp/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright © 2010 Intel Corporation -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# on the rights to use, copy, modify, merge, publish, distribute, sub -# license, and/or sell copies of the Software, and to permit persons to whom -# the Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -# USE OR OTHER DEALINGS IN THE SOFTWARE. - -noinst_LTLIBRARIES = libglcpp.la -libglcpp_la_SOURCES = \ - glcpp-lex.l \ - glcpp-parse.y \ - glcpp.h \ - hash_table.c \ - pp.c \ - xtalloc.c - -BUILT_SOURCES = glcpp-parse.h glcpp-parse.c glcpp-lex.c -CLEANFILES = $(BUILT_SOURCES) - -glcpp-parse.h: glcpp-parse.c - -bin_PROGRAMS = glcpp -glcpp_LDADD = libglcpp.la -glcpp_LDFLAGS = @LDFLAGS@ $(talloc_LIBS) -glcpp_SOURCES = glcpp.c - -.l.c: - $(LEXCOMPILE) --outfile="$@" $< - -test: glcpp - @(cd tests; ./glcpp-test) diff --git a/glcpp/README b/glcpp/README deleted file mode 100644 index ab42a3ffe12..00000000000 --- a/glcpp/README +++ /dev/null @@ -1,30 +0,0 @@ -glcpp -- GLSL "C" preprocessor - -This is a simple preprocessor designed to provide the preprocessing -needs of the GLSL language. The requirements for this preprocessor are -specified in the GLSL 1.30 specification availble from: - -http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.30.08.pdf - -This specification is not precise on some semantics, (for example, -#define and #if), defining these merely "as is standard for C++ -preprocessors". To fill in these details, I've been using the C99 -standard (for which I had a convenient copy) as available from: - -http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf - -Known limitations ------------------ -Macro invocations cannot include embedded newlines. - -The __LINE__, __FILE__, and __VERSION__ macros are not yet supported. - -The argument of the 'defined' operator cannot yet include enclosing -parentheses. - -The #error, #pragma, #extension, #version, and #line macros are not -yet supported. - -A file that ends with a function-like macro name as the last -non-whitespace token will result in a parse error, (where it should be -passed through as is). \ No newline at end of file diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l deleted file mode 100644 index afddd7ddb32..00000000000 --- a/glcpp/glcpp-lex.l +++ /dev/null @@ -1,257 +0,0 @@ -%{ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include - -#include "glcpp.h" -#include "glcpp-parse.h" - -#define YY_USER_ACTION \ - do { \ - yylloc->source = 0; \ - yylloc->first_column = yycolumn + 1; \ - yylloc->first_line = yylineno; \ - yycolumn += yyleng; \ - } while(0); -%} - -%option bison-bridge bison-locations reentrant noyywrap -%option extra-type="glcpp_parser_t *" -%option prefix="glcpp_" -%option stack - -%x DONE COMMENT - -SPACE [[:space:]] -NONSPACE [^[:space:]] -NEWLINE [\n] -HSPACE [ \t] -HASH ^{HSPACE}*#{HSPACE}* -IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* -PUNCTUATION [][(){}.&*~!/%<>^|;,=+-] -OTHER [^][(){}.&*~!/%<>^|;,=#[:space:]+-]+ - -DECIMAL_INTEGER [1-9][0-9]*[uU]? -OCTAL_INTEGER 0[0-7]*[uU]? -HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? - -%% - - /* Single-line comments */ -"//"[^\n]*\n { - yylineno++; - yycolumn = 0; - return NEWLINE; -} - - /* Multi-line comments */ -"/*" { yy_push_state(COMMENT, yyscanner); } -[^*\n]* -[^*\n]*\n { yylineno++; yycolumn = 0; } -"*"+[^*/\n]* -"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; } -"*"+"/" { - yy_pop_state(yyscanner); - if (yyextra->space_tokens) - return SPACE; -} - - /* glcpp doesn't handle #extension, #version, or #pragma directives. - * Simply pass them through to the main compiler's lexer/parser. */ -{HASH}(extension|version|pragma)[^\n]+ { - yylval->str = xtalloc_strdup (yyextra, yytext); - yylineno++; - yycolumn = 0; - return OTHER; -} - -{HASH}ifdef/.*\n { - yyextra->space_tokens = 0; - return HASH_IFDEF; -} - -{HASH}ifndef/.*\n { - yyextra->space_tokens = 0; - return HASH_IFNDEF; -} - -{HASH}if{HSPACE}/.*\n { - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_IF; -} - -{HASH}elif/.*\n { - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_ELIF; -} - -{HASH}else/.*\n { - yyextra->space_tokens = 0; - return HASH_ELSE; -} - -{HASH}endif/.*\n { - yyextra->space_tokens = 0; - return HASH_ENDIF; -} - - /* When skipping (due to an #if 0 or similar) consume anything - * up to a newline. We do this less priroty than any - * #if-related directive (#if, #elif, #else, #endif), but with - * more priority than any other directive or token to avoid - * any side-effects from skipped content. - * - * We use the lexing_if flag to avoid skipping any part of an - * if conditional expression. */ -[^\n]+/\n { - /* Since this rule always matches, YY_USER_ACTION gets called for it, - * wrongly incrementing yycolumn. We undo that effect here. */ - yycolumn -= yyleng; - if (yyextra->lexing_if || - yyextra->skip_stack == NULL || - yyextra->skip_stack->type == SKIP_NO_SKIP) - { - REJECT; - } -} - -{HASH}define{HSPACE}+/{IDENTIFIER}"(" { - yyextra->space_tokens = 0; - return HASH_DEFINE_FUNC; -} - -{HASH}define { - yyextra->space_tokens = 0; - return HASH_DEFINE_OBJ; -} - -{HASH}undef { - yyextra->space_tokens = 0; - return HASH_UNDEF; -} - -{HASH} { - yyextra->space_tokens = 0; - return HASH; -} - -{DECIMAL_INTEGER} { - yylval->str = xtalloc_strdup (yyextra, yytext); - return INTEGER_STRING; -} - -{OCTAL_INTEGER} { - yylval->str = xtalloc_strdup (yyextra, yytext); - return INTEGER_STRING; -} - -{HEXADECIMAL_INTEGER} { - yylval->str = xtalloc_strdup (yyextra, yytext); - return INTEGER_STRING; -} - -"<<" { - return LEFT_SHIFT; -} - -">>" { - return RIGHT_SHIFT; -} - -"<=" { - return LESS_OR_EQUAL; -} - -">=" { - return GREATER_OR_EQUAL; -} - -"==" { - return EQUAL; -} - -"!=" { - return NOT_EQUAL; -} - -"&&" { - return AND; -} - -"||" { - return OR; -} - -"##" { - return PASTE; -} - -"defined" { - return DEFINED; -} - -{IDENTIFIER} { - yylval->str = xtalloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - -{PUNCTUATION} { - return yytext[0]; -} - -{OTHER}+ { - yylval->str = xtalloc_strdup (yyextra, yytext); - return OTHER; -} - -{HSPACE}+ { - if (yyextra->space_tokens) { - return SPACE; - } -} - -\n { - yyextra->lexing_if = 0; - yylineno++; - yycolumn = 0; - return NEWLINE; -} - - /* Handle missing newline at EOF. */ -<> { - BEGIN DONE; /* Don't keep matching this rule forever. */ - yyextra->lexing_if = 0; - return NEWLINE; -} - -%% - -void -glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader) -{ - yy_scan_string(shader, parser->scanner); -} diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y deleted file mode 100644 index 6beac18c65d..00000000000 --- a/glcpp/glcpp-parse.y +++ /dev/null @@ -1,1611 +0,0 @@ -%{ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include - -#include "glcpp.h" - -#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) -#define glcpp_printf(stream, fmt, args...) \ - stream = talloc_asprintf_append(stream, fmt, args) - -static void -yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error); - -static void -_define_object_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *macro, - token_list_t *replacements); - -static void -_define_function_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *macro, - string_list_t *parameters, - token_list_t *replacements); - -static string_list_t * -_string_list_create (void *ctx); - -static void -_string_list_append_item (string_list_t *list, const char *str); - -static int -_string_list_contains (string_list_t *list, const char *member, int *index); - -static int -_string_list_length (string_list_t *list); - -static argument_list_t * -_argument_list_create (void *ctx); - -static void -_argument_list_append (argument_list_t *list, token_list_t *argument); - -static int -_argument_list_length (argument_list_t *list); - -static token_list_t * -_argument_list_member_at (argument_list_t *list, int index); - -/* Note: This function talloc_steal()s the str pointer. */ -static token_t * -_token_create_str (void *ctx, int type, char *str); - -static token_t * -_token_create_ival (void *ctx, int type, int ival); - -static token_list_t * -_token_list_create (void *ctx); - -/* Note: This function adds a talloc_reference() to token. - * - * You may want to talloc_unlink any current reference if you no - * longer need it. */ -static void -_token_list_append (token_list_t *list, token_t *token); - -static void -_token_list_append_list (token_list_t *list, token_list_t *tail); - -static active_list_t * -_active_list_push (active_list_t *list, - const char *identifier, - token_node_t *marker); - -static active_list_t * -_active_list_pop (active_list_t *list); - -int -_active_list_contains (active_list_t *list, const char *identifier); - -static void -_glcpp_parser_expand_token_list (glcpp_parser_t *parser, - token_list_t *list); - -static void -_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, - token_list_t *list); - -static void -_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, - int condition); - -static void -_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, - const char *type, int condition); - -static void -_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc); - -#define yylex glcpp_parser_lex - -static int -glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser); - -static void -glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); - -%} - -%pure-parser -%error-verbose -%locations - -%parse-param {glcpp_parser_t *parser} -%lex-param {glcpp_parser_t *parser} - -%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING NEWLINE OTHER PLACEHOLDER SPACE -%token PASTE -%type expression INTEGER operator SPACE -%type IDENTIFIER INTEGER_STRING OTHER -%type identifier_list -%type preprocessing_token conditional_token -%type pp_tokens replacement_list text_line conditional_tokens -%left OR -%left AND -%left '|' -%left '^' -%left '&' -%left EQUAL NOT_EQUAL -%left '<' '>' LESS_OR_EQUAL GREATER_OR_EQUAL -%left LEFT_SHIFT RIGHT_SHIFT -%left '+' '-' -%left '*' '/' '%' -%right UNARY - -%% - -input: - /* empty */ -| input line -; - -line: - control_line { - glcpp_print(parser->output, "\n"); - } -| text_line { - _glcpp_parser_print_expanded_token_list (parser, $1); - glcpp_print(parser->output, "\n"); - talloc_free ($1); - } -| expanded_line -| HASH non_directive -; - -expanded_line: - IF_EXPANDED expression NEWLINE { - _glcpp_parser_skip_stack_push_if (parser, & @1, $2); - } -| ELIF_EXPANDED expression NEWLINE { - _glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2); - } -; - -control_line: - HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE { - _define_object_macro (parser, & @2, $2, $3); - } -| HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE { - _define_function_macro (parser, & @2, $2, NULL, $5); - } -| HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE { - _define_function_macro (parser, & @2, $2, $4, $6); - } -| HASH_UNDEF IDENTIFIER NEWLINE { - macro_t *macro = hash_table_find (parser->defines, $2); - if (macro) { - /* XXX: Need hash table to support a real way - * to remove an element rather than prefixing - * a new node with data of NULL like this. */ - hash_table_insert (parser->defines, NULL, $2); - talloc_free (macro); - } - talloc_free ($2); - } -| HASH_IF conditional_tokens NEWLINE { - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, IF_EXPANDED, IF_EXPANDED); - _token_list_append (expanded, token); - talloc_unlink (parser, token); - _glcpp_parser_expand_token_list (parser, $2); - _token_list_append_list (expanded, $2); - glcpp_parser_lex_from (parser, expanded); - } -| HASH_IFDEF IDENTIFIER junk NEWLINE { - macro_t *macro = hash_table_find (parser->defines, $2); - talloc_free ($2); - _glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL); - } -| HASH_IFNDEF IDENTIFIER junk NEWLINE { - macro_t *macro = hash_table_find (parser->defines, $2); - talloc_free ($2); - _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); - } -| HASH_ELIF conditional_tokens NEWLINE { - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, ELIF_EXPANDED, ELIF_EXPANDED); - _token_list_append (expanded, token); - talloc_unlink (parser, token); - _glcpp_parser_expand_token_list (parser, $2); - _token_list_append_list (expanded, $2); - glcpp_parser_lex_from (parser, expanded); - } -| HASH_ELIF NEWLINE { - /* #elif without an expression results in a warning if the - * condition doesn't matter (we just handled #if 1 or such) - * but an error otherwise. */ - if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) { - parser->skip_stack->type = SKIP_TO_ENDIF; - glcpp_warning(& @1, parser, "ignoring illegal #elif without expression"); - } else { - glcpp_error(& @1, parser, "#elif needs an expression"); - } - } -| HASH_ELSE NEWLINE { - _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1); - } -| HASH_ENDIF NEWLINE { - _glcpp_parser_skip_stack_pop (parser, & @1); - } -| HASH NEWLINE -; - -expression: - INTEGER_STRING { - if (strlen ($1) >= 3 && strncmp ($1, "0x", 2) == 0) { - $$ = strtoll ($1 + 2, NULL, 16); - } else if ($1[0] == '0') { - $$ = strtoll ($1, NULL, 8); - } else { - $$ = strtoll ($1, NULL, 10); - } - } -| INTEGER { - $$ = $1; - } -| expression OR expression { - $$ = $1 || $3; - } -| expression AND expression { - $$ = $1 && $3; - } -| expression '|' expression { - $$ = $1 | $3; - } -| expression '^' expression { - $$ = $1 ^ $3; - } -| expression '&' expression { - $$ = $1 & $3; - } -| expression NOT_EQUAL expression { - $$ = $1 != $3; - } -| expression EQUAL expression { - $$ = $1 == $3; - } -| expression GREATER_OR_EQUAL expression { - $$ = $1 >= $3; - } -| expression LESS_OR_EQUAL expression { - $$ = $1 <= $3; - } -| expression '>' expression { - $$ = $1 > $3; - } -| expression '<' expression { - $$ = $1 < $3; - } -| expression RIGHT_SHIFT expression { - $$ = $1 >> $3; - } -| expression LEFT_SHIFT expression { - $$ = $1 << $3; - } -| expression '-' expression { - $$ = $1 - $3; - } -| expression '+' expression { - $$ = $1 + $3; - } -| expression '%' expression { - $$ = $1 % $3; - } -| expression '/' expression { - $$ = $1 / $3; - } -| expression '*' expression { - $$ = $1 * $3; - } -| '!' expression %prec UNARY { - $$ = ! $2; - } -| '~' expression %prec UNARY { - $$ = ~ $2; - } -| '-' expression %prec UNARY { - $$ = - $2; - } -| '+' expression %prec UNARY { - $$ = + $2; - } -| '(' expression ')' { - $$ = $2; - } -; - -identifier_list: - IDENTIFIER { - $$ = _string_list_create (parser); - _string_list_append_item ($$, $1); - talloc_steal ($$, $1); - } -| identifier_list ',' IDENTIFIER { - $$ = $1; - _string_list_append_item ($$, $3); - talloc_steal ($$, $3); - } -; - -text_line: - NEWLINE { $$ = NULL; } -| pp_tokens NEWLINE -; - -non_directive: - pp_tokens NEWLINE { - yyerror (& @1, parser, "Invalid tokens after #"); - } -; - -replacement_list: - /* empty */ { $$ = NULL; } -| pp_tokens -; - -junk: - /* empty */ -| pp_tokens { - glcpp_warning(&@1, parser, "extra tokens at end of directive"); - } -; - -conditional_token: - /* Handle "defined" operator */ - DEFINED IDENTIFIER { - int v = hash_table_find (parser->defines, $2) ? 1 : 0; - $$ = _token_create_ival (parser, INTEGER, v); - } -| DEFINED '(' IDENTIFIER ')' { - int v = hash_table_find (parser->defines, $3) ? 1 : 0; - $$ = _token_create_ival (parser, INTEGER, v); - } -| preprocessing_token -; - -conditional_tokens: - /* Exactly the same as pp_tokens, but using conditional_token */ - conditional_token { - parser->space_tokens = 1; - $$ = _token_list_create (parser); - _token_list_append ($$, $1); - talloc_unlink (parser, $1); - } -| conditional_tokens conditional_token { - $$ = $1; - _token_list_append ($$, $2); - talloc_unlink (parser, $2); - } -; - -pp_tokens: - preprocessing_token { - parser->space_tokens = 1; - $$ = _token_list_create (parser); - _token_list_append ($$, $1); - talloc_unlink (parser, $1); - } -| pp_tokens preprocessing_token { - $$ = $1; - _token_list_append ($$, $2); - talloc_unlink (parser, $2); - } -; - -preprocessing_token: - IDENTIFIER { - $$ = _token_create_str (parser, IDENTIFIER, $1); - $$->location = yylloc; - } -| INTEGER_STRING { - $$ = _token_create_str (parser, INTEGER_STRING, $1); - $$->location = yylloc; - } -| operator { - $$ = _token_create_ival (parser, $1, $1); - $$->location = yylloc; - } -| OTHER { - $$ = _token_create_str (parser, OTHER, $1); - $$->location = yylloc; - } -| SPACE { - $$ = _token_create_ival (parser, SPACE, SPACE); - $$->location = yylloc; - } -; - -operator: - '[' { $$ = '['; } -| ']' { $$ = ']'; } -| '(' { $$ = '('; } -| ')' { $$ = ')'; } -| '{' { $$ = '{'; } -| '}' { $$ = '}'; } -| '.' { $$ = '.'; } -| '&' { $$ = '&'; } -| '*' { $$ = '*'; } -| '+' { $$ = '+'; } -| '-' { $$ = '-'; } -| '~' { $$ = '~'; } -| '!' { $$ = '!'; } -| '/' { $$ = '/'; } -| '%' { $$ = '%'; } -| LEFT_SHIFT { $$ = LEFT_SHIFT; } -| RIGHT_SHIFT { $$ = RIGHT_SHIFT; } -| '<' { $$ = '<'; } -| '>' { $$ = '>'; } -| LESS_OR_EQUAL { $$ = LESS_OR_EQUAL; } -| GREATER_OR_EQUAL { $$ = GREATER_OR_EQUAL; } -| EQUAL { $$ = EQUAL; } -| NOT_EQUAL { $$ = NOT_EQUAL; } -| '^' { $$ = '^'; } -| '|' { $$ = '|'; } -| AND { $$ = AND; } -| OR { $$ = OR; } -| ';' { $$ = ';'; } -| ',' { $$ = ','; } -| '=' { $$ = '='; } -| PASTE { $$ = PASTE; } -| DEFINED { $$ = DEFINED; } -; - -%% - -string_list_t * -_string_list_create (void *ctx) -{ - string_list_t *list; - - list = xtalloc (ctx, string_list_t); - list->head = NULL; - list->tail = NULL; - - return list; -} - -void -_string_list_append_item (string_list_t *list, const char *str) -{ - string_node_t *node; - - node = xtalloc (list, string_node_t); - node->str = xtalloc_strdup (node, str); - - node->next = NULL; - - if (list->head == NULL) { - list->head = node; - } else { - list->tail->next = node; - } - - list->tail = node; -} - -int -_string_list_contains (string_list_t *list, const char *member, int *index) -{ - string_node_t *node; - int i; - - if (list == NULL) - return 0; - - for (i = 0, node = list->head; node; i++, node = node->next) { - if (strcmp (node->str, member) == 0) { - if (index) - *index = i; - return 1; - } - } - - return 0; -} - -int -_string_list_length (string_list_t *list) -{ - int length = 0; - string_node_t *node; - - if (list == NULL) - return 0; - - for (node = list->head; node; node = node->next) - length++; - - return length; -} - -argument_list_t * -_argument_list_create (void *ctx) -{ - argument_list_t *list; - - list = xtalloc (ctx, argument_list_t); - list->head = NULL; - list->tail = NULL; - - return list; -} - -void -_argument_list_append (argument_list_t *list, token_list_t *argument) -{ - argument_node_t *node; - - node = xtalloc (list, argument_node_t); - node->argument = argument; - - node->next = NULL; - - if (list->head == NULL) { - list->head = node; - } else { - list->tail->next = node; - } - - list->tail = node; -} - -int -_argument_list_length (argument_list_t *list) -{ - int length = 0; - argument_node_t *node; - - if (list == NULL) - return 0; - - for (node = list->head; node; node = node->next) - length++; - - return length; -} - -token_list_t * -_argument_list_member_at (argument_list_t *list, int index) -{ - argument_node_t *node; - int i; - - if (list == NULL) - return NULL; - - node = list->head; - for (i = 0; i < index; i++) { - node = node->next; - if (node == NULL) - break; - } - - if (node) - return node->argument; - - return NULL; -} - -/* Note: This function talloc_steal()s the str pointer. */ -token_t * -_token_create_str (void *ctx, int type, char *str) -{ - token_t *token; - - token = xtalloc (ctx, token_t); - token->type = type; - token->value.str = talloc_steal (token, str); - - return token; -} - -token_t * -_token_create_ival (void *ctx, int type, int ival) -{ - token_t *token; - - token = xtalloc (ctx, token_t); - token->type = type; - token->value.ival = ival; - - return token; -} - -token_list_t * -_token_list_create (void *ctx) -{ - token_list_t *list; - - list = xtalloc (ctx, token_list_t); - list->head = NULL; - list->tail = NULL; - list->non_space_tail = NULL; - - return list; -} - -void -_token_list_append (token_list_t *list, token_t *token) -{ - token_node_t *node; - - node = xtalloc (list, token_node_t); - node->token = xtalloc_reference (list, token); - - node->next = NULL; - - if (list->head == NULL) { - list->head = node; - } else { - list->tail->next = node; - } - - list->tail = node; - if (token->type != SPACE) - list->non_space_tail = node; -} - -void -_token_list_append_list (token_list_t *list, token_list_t *tail) -{ - if (tail == NULL || tail->head == NULL) - return; - - if (list->head == NULL) { - list->head = tail->head; - } else { - list->tail->next = tail->head; - } - - list->tail = tail->tail; - list->non_space_tail = tail->non_space_tail; -} - -token_list_t * -_token_list_copy (void *ctx, token_list_t *other) -{ - token_list_t *copy; - token_node_t *node; - - if (other == NULL) - return NULL; - - copy = _token_list_create (ctx); - for (node = other->head; node; node = node->next) - _token_list_append (copy, node->token); - - return copy; -} - -void -_token_list_trim_trailing_space (token_list_t *list) -{ - token_node_t *tail, *next; - - if (list->non_space_tail) { - tail = list->non_space_tail->next; - list->non_space_tail->next = NULL; - list->tail = list->non_space_tail; - - while (tail) { - next = tail->next; - talloc_free (tail); - tail = next; - } - } -} - -static void -_token_print (char **out, token_t *token) -{ - if (token->type < 256) { - glcpp_printf (*out, "%c", token->type); - return; - } - - switch (token->type) { - case INTEGER: - glcpp_printf (*out, "%" PRIxMAX, token->value.ival); - break; - case IDENTIFIER: - case INTEGER_STRING: - case OTHER: - glcpp_print (*out, token->value.str); - break; - case SPACE: - glcpp_print (*out, " "); - break; - case LEFT_SHIFT: - glcpp_print (*out, "<<"); - break; - case RIGHT_SHIFT: - glcpp_print (*out, ">>"); - break; - case LESS_OR_EQUAL: - glcpp_print (*out, "<="); - break; - case GREATER_OR_EQUAL: - glcpp_print (*out, ">="); - break; - case EQUAL: - glcpp_print (*out, "=="); - break; - case NOT_EQUAL: - glcpp_print (*out, "!="); - break; - case AND: - glcpp_print (*out, "&&"); - break; - case OR: - glcpp_print (*out, "||"); - break; - case PASTE: - glcpp_print (*out, "##"); - break; - case COMMA_FINAL: - glcpp_print (*out, ","); - break; - case PLACEHOLDER: - /* Nothing to print. */ - break; - default: - assert(!"Error: Don't know how to print token."); - break; - } -} - -/* Return a new token (talloc()ed off of 'token') formed by pasting - * 'token' and 'other'. Note that this function may return 'token' or - * 'other' directly rather than allocating anything new. - * - * Caution: Only very cursory error-checking is performed to see if - * the final result is a valid single token. */ -static token_t * -_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) -{ - token_t *combined = NULL; - - /* Pasting a placeholder onto anything makes no change. */ - if (other->type == PLACEHOLDER) - return token; - - /* When 'token' is a placeholder, just return 'other'. */ - if (token->type == PLACEHOLDER) - return other; - - /* A very few single-character punctuators can be combined - * with another to form a multi-character punctuator. */ - switch (token->type) { - case '<': - if (other->type == '<') - combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT); - else if (other->type == '=') - combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL); - break; - case '>': - if (other->type == '>') - combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT); - else if (other->type == '=') - combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL); - break; - case '=': - if (other->type == '=') - combined = _token_create_ival (token, EQUAL, EQUAL); - break; - case '!': - if (other->type == '=') - combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL); - break; - case '&': - if (other->type == '&') - combined = _token_create_ival (token, AND, AND); - break; - case '|': - if (other->type == '|') - combined = _token_create_ival (token, OR, OR); - break; - } - - if (combined != NULL) { - /* Inherit the location from the first token */ - combined->location = token->location; - return combined; - } - - /* Two string-valued tokens can usually just be mashed - * together. - * - * XXX: This isn't actually legitimate. Several things here - * should result in a diagnostic since the result cannot be a - * valid, single pre-processing token. For example, pasting - * "123" and "abc" is not legal, but we don't catch that - * here. */ - if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) && - (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING)) - { - char *str; - - str = xtalloc_asprintf (token, "%s%s", - token->value.str, other->value.str); - combined = _token_create_str (token, token->type, str); - combined->location = token->location; - return combined; - } - - glcpp_error (&token->location, parser, ""); - glcpp_print (parser->info_log, "Pasting \""); - _token_print (&parser->info_log, token); - glcpp_print (parser->info_log, "\" and \""); - _token_print (&parser->info_log, other); - glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n"); - - return token; -} - -static void -_token_list_print (glcpp_parser_t *parser, token_list_t *list) -{ - token_node_t *node; - - if (list == NULL) - return; - - for (node = list->head; node; node = node->next) - _token_print (&parser->output, node->token); -} - -void -yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error) -{ - glcpp_error(locp, parser, "%s", error); -} - -glcpp_parser_t * -glcpp_parser_create (void) -{ - glcpp_parser_t *parser; - - parser = xtalloc (NULL, glcpp_parser_t); - - glcpp_lex_init_extra (parser, &parser->scanner); - parser->defines = hash_table_ctor (32, hash_table_string_hash, - hash_table_string_compare); - parser->active = NULL; - parser->lexing_if = 0; - parser->space_tokens = 1; - parser->newline_as_space = 0; - parser->in_control_line = 0; - parser->paren_count = 0; - - parser->skip_stack = NULL; - - parser->lex_from_list = NULL; - parser->lex_from_node = NULL; - - parser->output = talloc_strdup(parser, ""); - parser->info_log = talloc_strdup(parser, ""); - parser->error = 0; - - return parser; -} - -int -glcpp_parser_parse (glcpp_parser_t *parser) -{ - return yyparse (parser); -} - -void -glcpp_parser_destroy (glcpp_parser_t *parser) -{ - if (parser->skip_stack) - glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); - glcpp_lex_destroy (parser->scanner); - hash_table_dtor (parser->defines); - talloc_free (parser); -} - -typedef enum function_status -{ - FUNCTION_STATUS_SUCCESS, - FUNCTION_NOT_A_FUNCTION, - FUNCTION_UNBALANCED_PARENTHESES -} function_status_t; - -/* Find a set of function-like macro arguments by looking for a - * balanced set of parentheses. - * - * When called, 'node' should be the opening-parenthesis token, (or - * perhaps preceeding SPACE tokens). Upon successful return *last will - * be the last consumed node, (corresponding to the closing right - * parenthesis). - * - * Return values: - * - * FUNCTION_STATUS_SUCCESS: - * - * Successfully parsed a set of function arguments. - * - * FUNCTION_NOT_A_FUNCTION: - * - * Macro name not followed by a '('. This is not an error, but - * simply that the macro name should be treated as a non-macro. - * - * FUNCTION_UNBALANCED_PARENTHESES - * - * Macro name is not followed by a balanced set of parentheses. - */ -static function_status_t -_arguments_parse (argument_list_t *arguments, - token_node_t *node, - token_node_t **last) -{ - token_list_t *argument; - int paren_count; - - node = node->next; - - /* Ignore whitespace before first parenthesis. */ - while (node && node->token->type == SPACE) - node = node->next; - - if (node == NULL || node->token->type != '(') - return FUNCTION_NOT_A_FUNCTION; - - node = node->next; - - argument = _token_list_create (arguments); - _argument_list_append (arguments, argument); - - for (paren_count = 1; node; node = node->next) { - if (node->token->type == '(') - { - paren_count++; - } - else if (node->token->type == ')') - { - paren_count--; - if (paren_count == 0) - break; - } - - if (node->token->type == ',' && - paren_count == 1) - { - _token_list_trim_trailing_space (argument); - argument = _token_list_create (arguments); - _argument_list_append (arguments, argument); - } - else { - if (argument->head == NULL) { - /* Don't treat initial whitespace as - * part of the arguement. */ - if (node->token->type == SPACE) - continue; - } - _token_list_append (argument, node->token); - } - } - - if (paren_count) - return FUNCTION_UNBALANCED_PARENTHESES; - - *last = node; - - return FUNCTION_STATUS_SUCCESS; -} - -/* This is a helper function that's essentially part of the - * implementation of _glcpp_parser_expand_node. It shouldn't be called - * except for by that function. - * - * Returns NULL if node is a simple token with no expansion, (that is, - * although 'node' corresponds to an identifier defined as a - * function-like macro, it is not followed with a parenthesized - * argument list). - * - * Compute the complete expansion of node (which is a function-like - * macro) and subsequent nodes which are arguments. - * - * Returns the token list that results from the expansion and sets - * *last to the last node in the list that was consumed by the - * expansion. Specificallty, *last will be set as follows: as the - * token of the closing right parenthesis. - */ -static token_list_t * -_glcpp_parser_expand_function (glcpp_parser_t *parser, - token_node_t *node, - token_node_t **last) - -{ - macro_t *macro; - const char *identifier; - argument_list_t *arguments; - function_status_t status; - token_list_t *substituted; - int parameter_index; - - identifier = node->token->value.str; - - macro = hash_table_find (parser->defines, identifier); - - assert (macro->is_function); - - arguments = _argument_list_create (parser); - status = _arguments_parse (arguments, node, last); - - switch (status) { - case FUNCTION_STATUS_SUCCESS: - break; - case FUNCTION_NOT_A_FUNCTION: - return NULL; - case FUNCTION_UNBALANCED_PARENTHESES: - glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier); - return NULL; - } - - if (macro->replacements == NULL) { - talloc_free (arguments); - return _token_list_create (parser); - } - - if (! ((_argument_list_length (arguments) == - _string_list_length (macro->parameters)) || - (_string_list_length (macro->parameters) == 0 && - _argument_list_length (arguments) == 1 && - arguments->head->argument->head == NULL))) - { - glcpp_error (&node->token->location, parser, - "Error: macro %s invoked with %d arguments (expected %d)\n", - identifier, - _argument_list_length (arguments), - _string_list_length (macro->parameters)); - return NULL; - } - - /* Perform argument substitution on the replacement list. */ - substituted = _token_list_create (arguments); - - for (node = macro->replacements->head; node; node = node->next) - { - if (node->token->type == IDENTIFIER && - _string_list_contains (macro->parameters, - node->token->value.str, - ¶meter_index)) - { - token_list_t *argument; - argument = _argument_list_member_at (arguments, - parameter_index); - /* Before substituting, we expand the argument - * tokens, or append a placeholder token for - * an empty argument. */ - if (argument->head) { - _glcpp_parser_expand_token_list (parser, - argument); - _token_list_append_list (substituted, argument); - } else { - token_t *new_token; - - new_token = _token_create_ival (substituted, - PLACEHOLDER, - PLACEHOLDER); - _token_list_append (substituted, new_token); - } - } else { - _token_list_append (substituted, node->token); - } - } - - /* After argument substitution, and before further expansion - * below, implement token pasting. */ - - _token_list_trim_trailing_space (substituted); - - node = substituted->head; - while (node) - { - token_node_t *next_non_space; - - /* Look ahead for a PASTE token, skipping space. */ - next_non_space = node->next; - while (next_non_space && next_non_space->token->type == SPACE) - next_non_space = next_non_space->next; - - if (next_non_space == NULL) - break; - - if (next_non_space->token->type != PASTE) { - node = next_non_space; - continue; - } - - /* Now find the next non-space token after the PASTE. */ - next_non_space = next_non_space->next; - while (next_non_space && next_non_space->token->type == SPACE) - next_non_space = next_non_space->next; - - if (next_non_space == NULL) { - yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n"); - return NULL; - } - - node->token = _token_paste (parser, node->token, next_non_space->token); - node->next = next_non_space->next; - if (next_non_space == substituted->tail) - substituted->tail = node; - - node = node->next; - } - - substituted->non_space_tail = substituted->tail; - - return substituted; -} - -/* Compute the complete expansion of node, (and subsequent nodes after - * 'node' in the case that 'node' is a function-like macro and - * subsequent nodes are arguments). - * - * Returns NULL if node is a simple token with no expansion. - * - * Otherwise, returns the token list that results from the expansion - * and sets *last to the last node in the list that was consumed by - * the expansion. Specificallty, *last will be set as follows: - * - * As 'node' in the case of object-like macro expansion. - * - * As the token of the closing right parenthesis in the case of - * function-like macro expansion. - */ -static token_list_t * -_glcpp_parser_expand_node (glcpp_parser_t *parser, - token_node_t *node, - token_node_t **last) -{ - token_t *token = node->token; - const char *identifier; - macro_t *macro; - - /* We only expand identifiers */ - if (token->type != IDENTIFIER) { - /* We change any COMMA into a COMMA_FINAL to prevent - * it being mistaken for an argument separator - * later. */ - if (token->type == ',') { - token->type = COMMA_FINAL; - token->value.ival = COMMA_FINAL; - } - - return NULL; - } - - /* Look up this identifier in the hash table. */ - identifier = token->value.str; - macro = hash_table_find (parser->defines, identifier); - - /* Not a macro, so no expansion needed. */ - if (macro == NULL) - return NULL; - - /* Finally, don't expand this macro if we're already actively - * expanding it, (to avoid infinite recursion). */ - if (_active_list_contains (parser->active, identifier)) { - /* We change the token type here from IDENTIFIER to - * OTHER to prevent any future expansion of this - * unexpanded token. */ - char *str; - token_list_t *expansion; - token_t *final; - - str = xtalloc_strdup (parser, token->value.str); - final = _token_create_str (parser, OTHER, str); - expansion = _token_list_create (parser); - _token_list_append (expansion, final); - *last = node; - return expansion; - } - - if (! macro->is_function) - { - *last = node; - - if (macro->replacements == NULL) - return _token_list_create (parser); - - return _token_list_copy (parser, macro->replacements); - } - - return _glcpp_parser_expand_function (parser, node, last); -} - -/* Push a new identifier onto the active list, returning the new list. - * - * Here, 'marker' is the token node that appears in the list after the - * expansion of 'identifier'. That is, when the list iterator begins - * examinging 'marker', then it is time to pop this node from the - * active stack. - */ -active_list_t * -_active_list_push (active_list_t *list, - const char *identifier, - token_node_t *marker) -{ - active_list_t *node; - - node = xtalloc (list, active_list_t); - node->identifier = xtalloc_strdup (node, identifier); - node->marker = marker; - node->next = list; - - return node; -} - -active_list_t * -_active_list_pop (active_list_t *list) -{ - active_list_t *node = list; - - if (node == NULL) - return NULL; - - node = list->next; - talloc_free (list); - - return node; -} - -int -_active_list_contains (active_list_t *list, const char *identifier) -{ - active_list_t *node; - - if (list == NULL) - return 0; - - for (node = list; node; node = node->next) - if (strcmp (node->identifier, identifier) == 0) - return 1; - - return 0; -} - -/* Walk over the token list replacing nodes with their expansion. - * Whenever nodes are expanded the walking will walk over the new - * nodes, continuing to expand as necessary. The results are placed in - * 'list' itself; - */ -static void -_glcpp_parser_expand_token_list (glcpp_parser_t *parser, - token_list_t *list) -{ - token_node_t *node_prev; - token_node_t *node, *last = NULL; - token_list_t *expansion; - - if (list == NULL) - return; - - _token_list_trim_trailing_space (list); - - node_prev = NULL; - node = list->head; - - while (node) { - - while (parser->active && parser->active->marker == node) - parser->active = _active_list_pop (parser->active); - - /* Find the expansion for node, which will replace all - * nodes from node to last, inclusive. */ - expansion = _glcpp_parser_expand_node (parser, node, &last); - if (expansion) { - token_node_t *n; - - for (n = node; n != last->next; n = n->next) - while (parser->active && - parser->active->marker == n) - { - parser->active = _active_list_pop (parser->active); - } - - parser->active = _active_list_push (parser->active, - node->token->value.str, - last->next); - - /* Splice expansion into list, supporting a - * simple deletion if the expansion is - * empty. */ - if (expansion->head) { - if (node_prev) - node_prev->next = expansion->head; - else - list->head = expansion->head; - expansion->tail->next = last->next; - if (last == list->tail) - list->tail = expansion->tail; - } else { - if (node_prev) - node_prev->next = last->next; - else - list->head = last->next; - if (last == list->tail) - list->tail = NULL; - } - } else { - node_prev = node; - } - node = node_prev ? node_prev->next : list->head; - } - - while (parser->active) - parser->active = _active_list_pop (parser->active); - - list->non_space_tail = list->tail; -} - -void -_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, - token_list_t *list) -{ - if (list == NULL) - return; - - _glcpp_parser_expand_token_list (parser, list); - - _token_list_trim_trailing_space (list); - - _token_list_print (parser, list); -} - -void -_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc, - const char *identifier) -{ - /* According to the GLSL specification, macro names starting with "__" - * or "GL_" are reserved for future use. So, don't allow them. - */ - if (strncmp(identifier, "__", 2) == 0) { - glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n"); - } - if (strncmp(identifier, "GL_", 3) == 0) { - glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n"); - } -} - -void -_define_object_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *identifier, - token_list_t *replacements) -{ - macro_t *macro; - - _check_for_reserved_macro_name(parser, loc, identifier); - - macro = xtalloc (parser, macro_t); - - macro->is_function = 0; - macro->parameters = NULL; - macro->identifier = talloc_strdup (macro, identifier); - macro->replacements = talloc_steal (macro, replacements); - - hash_table_insert (parser->defines, macro, identifier); -} - -void -_define_function_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *identifier, - string_list_t *parameters, - token_list_t *replacements) -{ - macro_t *macro; - - _check_for_reserved_macro_name(parser, loc, identifier); - - macro = xtalloc (parser, macro_t); - - macro->is_function = 1; - macro->parameters = talloc_steal (macro, parameters); - macro->identifier = talloc_strdup (macro, identifier); - macro->replacements = talloc_steal (macro, replacements); - - hash_table_insert (parser->defines, macro, identifier); -} - -static int -glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser) -{ - token_node_t *node; - int ret; - - if (parser->lex_from_list == NULL) { - ret = glcpp_lex (yylval, yylloc, parser->scanner); - - /* XXX: This ugly block of code exists for the sole - * purpose of converting a NEWLINE token into a SPACE - * token, but only in the case where we have seen a - * function-like macro name, but have not yet seen its - * closing parenthesis. - * - * There's perhaps a more compact way to do this with - * mid-rule actions in the grammar. - * - * I'm definitely not pleased with the complexity of - * this code here. - */ - if (parser->newline_as_space) - { - if (ret == '(') { - parser->paren_count++; - } else if (ret == ')') { - parser->paren_count--; - if (parser->paren_count == 0) - parser->newline_as_space = 0; - } else if (ret == NEWLINE) { - ret = SPACE; - } else if (ret != SPACE) { - if (parser->paren_count == 0) - parser->newline_as_space = 0; - } - } - else if (parser->in_control_line) - { - if (ret == NEWLINE) - parser->in_control_line = 0; - } - else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC || - ret == HASH_UNDEF || ret == HASH_IF || - ret == HASH_IFDEF || ret == HASH_IFNDEF || - ret == HASH_ELIF || ret == HASH_ELSE || - ret == HASH_ENDIF || ret == HASH) - { - parser->in_control_line = 1; - } - else if (ret == IDENTIFIER) - { - macro_t *macro; - macro = hash_table_find (parser->defines, - yylval->str); - if (macro && macro->is_function) { - parser->newline_as_space = 1; - parser->paren_count = 0; - } - } - - return ret; - } - - node = parser->lex_from_node; - - if (node == NULL) { - talloc_free (parser->lex_from_list); - parser->lex_from_list = NULL; - return NEWLINE; - } - - *yylval = node->token->value; - ret = node->token->type; - - parser->lex_from_node = node->next; - - return ret; -} - -static void -glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list) -{ - token_node_t *node; - - assert (parser->lex_from_list == NULL); - - /* Copy list, eliminating any space tokens. */ - parser->lex_from_list = _token_list_create (parser); - - for (node = list->head; node; node = node->next) { - if (node->token->type == SPACE) - continue; - _token_list_append (parser->lex_from_list, node->token); - } - - talloc_free (list); - - parser->lex_from_node = parser->lex_from_list->head; - - /* It's possible the list consisted of nothing but whitespace. */ - if (parser->lex_from_node == NULL) { - talloc_free (parser->lex_from_list); - parser->lex_from_list = NULL; - } -} - -static void -_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, - int condition) -{ - skip_type_t current = SKIP_NO_SKIP; - skip_node_t *node; - - if (parser->skip_stack) - current = parser->skip_stack->type; - - node = xtalloc (parser, skip_node_t); - node->loc = *loc; - - if (current == SKIP_NO_SKIP) { - if (condition) - node->type = SKIP_NO_SKIP; - else - node->type = SKIP_TO_ELSE; - } else { - node->type = SKIP_TO_ENDIF; - } - - node->next = parser->skip_stack; - parser->skip_stack = node; -} - -static void -_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, - const char *type, int condition) -{ - if (parser->skip_stack == NULL) { - glcpp_error (loc, parser, "%s without #if\n", type); - return; - } - - if (parser->skip_stack->type == SKIP_TO_ELSE) { - if (condition) - parser->skip_stack->type = SKIP_NO_SKIP; - } else { - parser->skip_stack->type = SKIP_TO_ENDIF; - } -} - -static void -_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc) -{ - skip_node_t *node; - - if (parser->skip_stack == NULL) { - glcpp_error (loc, parser, "#endif without #if\n"); - return; - } - - node = parser->skip_stack; - parser->skip_stack = node->next; - talloc_free (node); -} diff --git a/glcpp/glcpp.c b/glcpp/glcpp.c deleted file mode 100644 index cc87e14950b..00000000000 --- a/glcpp/glcpp.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include "glcpp.h" - -extern int yydebug; - -static char * -load_text_file(void *ctx, const char *file_name) -{ - char *text = NULL; - struct stat st; - ssize_t total_read = 0; - int fd = file_name == NULL ? STDIN_FILENO : open(file_name, O_RDONLY); - - if (fd < 0) { - 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) { - text = NULL; - break; - } - - if (bytes == 0) { - break; - } - - total_read += bytes; - } while (total_read < st.st_size); - - text[total_read] = '\0'; - } - } - - close(fd); - - return text; -} - -int -preprocess(void *talloc_ctx, const char **shader, char **info_log); - -int -main (void) -{ - void *ctx = talloc(NULL, void*); - const char *shader = load_text_file(ctx, NULL); - char *info_log = talloc_strdup(ctx, ""); - int ret = preprocess(ctx, &shader, &info_log); - - printf("%s", shader); - fprintf(stderr, "%s", info_log); - - talloc_free(ctx); - - return ret; -} diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h deleted file mode 100644 index 2cfa98d2b1d..00000000000 --- a/glcpp/glcpp.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef GLCPP_H -#define GLCPP_H - -#include - -#include - -#include "hash_table.h" - -#define yyscan_t void* - -/* Some data types used for parser values. */ - -typedef struct string_node { - const char *str; - struct string_node *next; -} string_node_t; - -typedef struct string_list { - string_node_t *head; - string_node_t *tail; -} string_list_t; - -typedef struct token token_t; -typedef struct token_list token_list_t; - -typedef union YYSTYPE -{ - intmax_t ival; - char *str; - string_list_t *string_list; - token_t *token; - token_list_t *token_list; -} YYSTYPE; - -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 - -typedef struct YYLTYPE { - int first_line; - int first_column; - int last_line; - int last_column; - unsigned source; -} YYLTYPE; -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 - -struct token { - int type; - YYSTYPE value; - YYLTYPE location; -}; - -typedef struct token_node { - token_t *token; - struct token_node *next; -} token_node_t; - -struct token_list { - token_node_t *head; - token_node_t *tail; - token_node_t *non_space_tail; -}; - -typedef struct argument_node { - token_list_t *argument; - struct argument_node *next; -} argument_node_t; - -typedef struct argument_list { - argument_node_t *head; - argument_node_t *tail; -} argument_list_t; - -typedef struct glcpp_parser glcpp_parser_t; - -typedef enum { - TOKEN_CLASS_IDENTIFIER, - TOKEN_CLASS_IDENTIFIER_FINALIZED, - TOKEN_CLASS_FUNC_MACRO, - TOKEN_CLASS_OBJ_MACRO -} token_class_t; - -token_class_t -glcpp_parser_classify_token (glcpp_parser_t *parser, - const char *identifier, - int *parameter_index); - -typedef struct { - int is_function; - string_list_t *parameters; - const char *identifier; - token_list_t *replacements; -} macro_t; - -typedef struct expansion_node { - macro_t *macro; - token_node_t *replacements; - struct expansion_node *next; -} expansion_node_t; - -typedef enum skip_type { - SKIP_NO_SKIP, - SKIP_TO_ELSE, - SKIP_TO_ENDIF -} skip_type_t; - -typedef struct skip_node { - skip_type_t type; - YYLTYPE loc; /* location of the initial #if/#elif/... */ - struct skip_node *next; -} skip_node_t; - -typedef struct active_list { - const char *identifier; - token_node_t *marker; - struct active_list *next; -} active_list_t; - -struct glcpp_parser { - yyscan_t scanner; - struct hash_table *defines; - active_list_t *active; - int lexing_if; - int space_tokens; - int newline_as_space; - int in_control_line; - int paren_count; - skip_node_t *skip_stack; - token_list_t *lex_from_list; - token_node_t *lex_from_node; - char *output; - char *info_log; - int error; -}; - -glcpp_parser_t * -glcpp_parser_create (void); - -int -glcpp_parser_parse (glcpp_parser_t *parser); - -void -glcpp_parser_destroy (glcpp_parser_t *parser); - -int -preprocess(void *talloc_ctx, const char **shader, char **info_log); - -/* Functions for writing to the info log */ - -void -glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...); - -void -glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...); - -/* Generated by glcpp-lex.l to glcpp-lex.c */ - -int -glcpp_lex_init_extra (glcpp_parser_t *parser, yyscan_t* scanner); - -void -glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader); - -int -glcpp_lex (YYSTYPE *lvalp, YYLTYPE *llocp, yyscan_t scanner); - -int -glcpp_lex_destroy (yyscan_t scanner); - -/* Generated by glcpp-parse.y to glcpp-parse.c */ - -int -yyparse (glcpp_parser_t *parser); - -/* xtalloc - wrappers around talloc to check for out-of-memory */ - -#define xtalloc(ctx, type) (type *)xtalloc_named_const(ctx, sizeof(type), #type) - -#define xtalloc_size(ctx, size) xtalloc_named_const(ctx, size, __location__) - -void * -xtalloc_named_const (const void *context, size_t size, const char *name); - -char * -xtalloc_strdup (const void *t, const char *p); - -char * -xtalloc_strndup (const void *t, const char *p, size_t n); - -char * -xtalloc_asprintf (const void *t, const char *fmt, ...); - -void * -_xtalloc_reference_loc (const void *context, - const void *ptr, const char *location); - -#define xtalloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_xtalloc_reference_loc((ctx),(ptr), __location__) - -#endif diff --git a/glcpp/hash_table.c b/glcpp/hash_table.c deleted file mode 100644 index e89a2564d76..00000000000 --- a/glcpp/hash_table.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file hash_table.c - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick - */ - -#include "main/imports.h" -#include "main/simple_list.h" -#include "hash_table.h" - -struct node { - struct node *next; - struct node *prev; -}; - -struct hash_table { - hash_func_t hash; - hash_compare_func_t compare; - - unsigned num_buckets; - struct node buckets[1]; -}; - - -struct hash_node { - struct node link; - const void *key; - void *data; -}; - - -struct hash_table * -hash_table_ctor(unsigned num_buckets, hash_func_t hash, - hash_compare_func_t compare) -{ - struct hash_table *ht; - unsigned i; - - - if (num_buckets < 16) { - num_buckets = 16; - } - - ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1) - * sizeof(ht->buckets[0]))); - if (ht != NULL) { - ht->hash = hash; - ht->compare = compare; - ht->num_buckets = num_buckets; - - for (i = 0; i < num_buckets; i++) { - make_empty_list(& ht->buckets[i]); - } - } - - return ht; -} - - -void -hash_table_dtor(struct hash_table *ht) -{ - hash_table_clear(ht); - _mesa_free(ht); -} - - -void -hash_table_clear(struct hash_table *ht) -{ - struct node *node; - struct node *temp; - unsigned i; - - - for (i = 0; i < ht->num_buckets; i++) { - foreach_s(node, temp, & ht->buckets[i]) { - remove_from_list(node); - _mesa_free(node); - } - - assert(is_empty_list(& ht->buckets[i])); - } -} - - -void * -hash_table_find(struct hash_table *ht, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct node *node; - - foreach(node, & ht->buckets[bucket]) { - struct hash_node *hn = (struct hash_node *) node; - - if ((*ht->compare)(hn->key, key) == 0) { - return hn->data; - } - } - - return NULL; -} - - -void -hash_table_insert(struct hash_table *ht, void *data, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct hash_node *node; - - node = _mesa_calloc(sizeof(*node)); - - node->data = data; - node->key = key; - - insert_at_head(& ht->buckets[bucket], & node->link); -} - - -unsigned -hash_table_string_hash(const void *key) -{ - const char *str = (const char *) key; - unsigned hash = 5381; - - - while (*str != '\0') { - hash = (hash * 33) + *str; - str++; - } - - return hash; -} diff --git a/glcpp/hash_table.h b/glcpp/hash_table.h deleted file mode 100644 index b9dd343dee9..00000000000 --- a/glcpp/hash_table.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file hash_table.h - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick - */ - -#ifndef HASH_TABLE_H -#define HASH_TABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -struct hash_table; - -typedef unsigned (*hash_func_t)(const void *key); -typedef int (*hash_compare_func_t)(const void *key1, const void *key2); - -/** - * Hash table constructor - * - * Creates a hash table with the specified number of buckets. The supplied - * \c hash and \c compare routines are used when adding elements to the table - * and when searching for elements in the table. - * - * \param num_buckets Number of buckets (bins) in the hash table. - * \param hash Function used to compute hash value of input keys. - * \param compare Function used to compare keys. - */ -extern struct hash_table *hash_table_ctor(unsigned num_buckets, - hash_func_t hash, hash_compare_func_t compare); - - -/** - * Release all memory associated with a hash table - * - * \warning - * This function cannot release memory occupied either by keys or data. - */ -extern void hash_table_dtor(struct hash_table *ht); - - -/** - * Flush all entries from a hash table - * - * \param ht Table to be cleared of its entries. - */ -extern void hash_table_clear(struct hash_table *ht); - - -/** - * Search a hash table for a specific element - * - * \param ht Table to be searched - * \param key Key of the desired element - * - * \return - * The \c data value supplied to \c hash_table_insert when the element with - * the matching key was added. If no matching key exists in the table, - * \c NULL is returned. - */ -extern void *hash_table_find(struct hash_table *ht, const void *key); - - -/** - * Add an element to a hash table - */ -extern void hash_table_insert(struct hash_table *ht, void *data, - const void *key); - - -/** - * Compute hash value of a string - * - * Computes the hash value of a string using the DJB2 algorithm developed by - * Professor Daniel J. Bernstein. It was published on comp.lang.c once upon - * a time. I was unable to find the original posting in the archives. - * - * \param key Pointer to a NUL terminated string to be hashed. - * - * \sa hash_table_string_compare - */ -extern unsigned hash_table_string_hash(const void *key); - - -/** - * Compare two strings used as keys - * - * This is just a macro wrapper around \c strcmp. - * - * \sa hash_table_string_hash - */ -#define hash_table_string_compare ((hash_compare_func_t) strcmp) - -#ifdef __cplusplus -}; -#endif - -#endif /* HASH_TABLE_H */ diff --git a/glcpp/main/imports.h b/glcpp/main/imports.h deleted file mode 100644 index d2197342c04..00000000000 --- a/glcpp/main/imports.h +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -#define _mesa_malloc(x) malloc(x) -#define _mesa_free(x) free(x) -#define _mesa_calloc(x) calloc(1,x) diff --git a/glcpp/main/simple_list.h b/glcpp/main/simple_list.h deleted file mode 100644 index 5ef39e14cc6..00000000000 --- a/glcpp/main/simple_list.h +++ /dev/null @@ -1,235 +0,0 @@ -/** - * \file simple_list.h - * Simple macros for type-safe, intrusive lists. - * - * Intended to work with a list sentinal which is created as an empty - * list. Insert & delete are O(1). - * - * \author - * (C) 1997, Keith Whitwell - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _SIMPLE_LIST_H -#define _SIMPLE_LIST_H - -struct simple_node { - struct simple_node *next; - struct simple_node *prev; -}; - -/** - * Remove an element from list. - * - * \param elem element to remove. - */ -#define remove_from_list(elem) \ -do { \ - (elem)->next->prev = (elem)->prev; \ - (elem)->prev->next = (elem)->next; \ -} while (0) - -/** - * Insert an element to the list head. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_head(list, elem) \ -do { \ - (elem)->prev = list; \ - (elem)->next = (list)->next; \ - (list)->next->prev = elem; \ - (list)->next = elem; \ -} while(0) - -/** - * Insert an element to the list tail. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_tail(list, elem) \ -do { \ - (elem)->next = list; \ - (elem)->prev = (list)->prev; \ - (list)->prev->next = elem; \ - (list)->prev = elem; \ -} while(0) - -/** - * Move an element to the list head. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_head(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_head(list, elem); \ -} while (0) - -/** - * Move an element to the list tail. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_tail(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_tail(list, elem); \ -} while (0) - -/** - * Consatinate a cyclic list to a list - * - * Appends the sequence of nodes starting with \c tail to the list \c head. - * A "cyclic list" is a list that does not have a sentinal node. This means - * that the data pointed to by \c tail is an actual node, not a dataless - * sentinal. Note that if \c tail constist of a single node, this macro - * behaves identically to \c insert_at_tail - * - * \param head Head of the list to be appended to. This may or may not - * be a cyclic list. - * \param tail Head of the cyclic list to be appended to \c head. - * \param temp Temporary \c simple_list used by the macro - * - * \sa insert_at_tail - */ -#define concat_list_and_cycle(head, tail, temp) \ -do { \ - (head)->prev->next = (tail); \ - (tail)->prev->next = (head); \ - (temp) = (head)->prev; \ - (head)->prev = (tail)->prev; \ - (tail)->prev = (temp); \ -} while (0) - -#define concat_list(head, next_list) \ -do { \ - (next_list)->next->prev = (head)->prev; \ - (next_list)->prev->next = (head); \ - (head)->prev->next = (next_list)->next; \ - (head)->prev = (next_list)->prev; \ -} while (0) - -/** - * Make a empty list empty. - * - * \param sentinal list (sentinal element). - */ -#define make_empty_list(sentinal) \ -do { \ - (sentinal)->next = sentinal; \ - (sentinal)->prev = sentinal; \ -} while (0) - -/** - * Get list first element. - * - * \param list list. - * - * \return pointer to first element. - */ -#define first_elem(list) ((list)->next) - -/** - * Get list last element. - * - * \param list list. - * - * \return pointer to last element. - */ -#define last_elem(list) ((list)->prev) - -/** - * Get next element. - * - * \param elem element. - * - * \return pointer to next element. - */ -#define next_elem(elem) ((elem)->next) - -/** - * Get previous element. - * - * \param elem element. - * - * \return pointer to previous element. - */ -#define prev_elem(elem) ((elem)->prev) - -/** - * Test whether element is at end of the list. - * - * \param list list. - * \param elem element. - * - * \return non-zero if element is at end of list, or zero otherwise. - */ -#define at_end(list, elem) ((elem) == (list)) - -/** - * Test if a list is empty. - * - * \param list list. - * - * \return non-zero if list empty, or zero otherwise. - */ -#define is_empty_list(list) ((list)->next == (list)) - -/** - * Walk through the elements of a list. - * - * \param ptr pointer to the current element. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach(ptr, list) \ - for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) - -/** - * Walk through the elements of a list. - * - * Same as #foreach but lets you unlink the current value during a list - * traversal. Useful for freeing a list, element by element. - * - * \param ptr pointer to the current element. - * \param t temporary pointer. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach_s(ptr, t, list) \ - for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) - -#endif diff --git a/glcpp/pp.c b/glcpp/pp.c deleted file mode 100644 index a25b7b72a6b..00000000000 --- a/glcpp/pp.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include "glcpp.h" - -void -glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) -{ - parser->error = 1; - parser->info_log = talloc_asprintf_append(parser->info_log, - "%u:%u(%u): " - "preprocessor error: ", - locp->source, - locp->first_line, - locp->first_column); - va_list ap; - va_start(ap, fmt); - parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap); - va_end(ap); - parser->info_log = talloc_strdup_append(parser->info_log, "\n"); -} - -void -glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) -{ - parser->info_log = talloc_asprintf_append(parser->info_log, - "%u:%u(%u): " - "preprocessor warning: ", - locp->source, - locp->first_line, - locp->first_column); - va_list ap; - va_start(ap, fmt); - parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap); - va_end(ap); - parser->info_log = talloc_strdup_append(parser->info_log, "\n"); -} - -/* Searches backwards for '^ *#' from a given starting point. */ -static int -in_directive(const char *shader, const char *ptr) -{ - assert(ptr >= shader); - - /* Search backwards for '#'. If we find a \n first, it doesn't count */ - for (; ptr >= shader && *ptr != '#'; ptr--) { - if (*ptr == '\n') - return 0; - } - if (ptr >= shader) { - /* Found '#'...look for spaces preceded by a newline */ - for (ptr--; ptr >= shader && isblank(*ptr); ptr--); - // FIXME: I don't think the '\n' case can happen - if (ptr < shader || *ptr == '\n') - return 1; - } - return 0; -} - -/* Remove any line continuation characters in preprocessing directives. - * However, ignore any in GLSL code, as "There is no line continuation - * character" (1.30 page 9) in GLSL. - */ -static char * -remove_line_continuations(glcpp_parser_t *ctx, const char *shader) -{ - int in_continued_line = 0; - int extra_newlines = 0; - char *clean = talloc_strdup(ctx, ""); - const char *search_start = shader; - const char *newline; - while ((newline = strchr(search_start, '\n')) != NULL) { - const char *backslash = NULL; - /* Find the preceding '\', if it exists */ - if (newline[-1] == '\\') { - backslash = newline - 1; - } else if (newline[-1] == '\r' && newline[-2] == '\\') { - backslash = newline - 2; - } - /* Double backslashes don't count (the backslash is escaped) */ - if (backslash != NULL && backslash[-1] == '\\') { - backslash = NULL; - } - - if (backslash != NULL) { - /* We found a line continuation, but do we care? */ - if (!in_continued_line) { - if (in_directive(shader, backslash)) { - in_continued_line = 1; - extra_newlines = 0; - } - } - if (in_continued_line) { - /* Copy everything before the \ */ - clean = talloc_strndup_append(clean, shader, backslash - shader); - shader = newline + 1; - extra_newlines++; - } - } else if (in_continued_line) { - /* Copy everything up to and including the \n */ - clean = talloc_strndup_append(clean, shader, newline - shader + 1); - shader = newline + 1; - /* Output extra newlines to make line numbers match */ - for (; extra_newlines > 0; extra_newlines--) - clean = talloc_strdup_append(clean, "\n"); - in_continued_line = 0; - } - search_start = newline + 1; - } - clean = talloc_strdup_append(clean, shader); - return clean; -} - -extern int -preprocess(void *talloc_ctx, const char **shader, char **info_log) -{ - int errors; - glcpp_parser_t *parser = glcpp_parser_create (); - *shader = remove_line_continuations(parser, *shader); - - glcpp_lex_set_source_string (parser, *shader); - - glcpp_parser_parse (parser); - - *info_log = talloc_strdup_append(*info_log, parser->info_log); - - talloc_steal(talloc_ctx, parser->output); - *shader = parser->output; - - errors = parser->error; - glcpp_parser_destroy (parser); - return errors; -} diff --git a/glcpp/tests/000-content-with-spaces.c b/glcpp/tests/000-content-with-spaces.c deleted file mode 100644 index 696cb3a74fc..00000000000 --- a/glcpp/tests/000-content-with-spaces.c +++ /dev/null @@ -1 +0,0 @@ -this is four tokens diff --git a/glcpp/tests/000-content-with-spaces.c.expected b/glcpp/tests/000-content-with-spaces.c.expected deleted file mode 100644 index 83f7834d547..00000000000 --- a/glcpp/tests/000-content-with-spaces.c.expected +++ /dev/null @@ -1,2 +0,0 @@ -this is four tokens - diff --git a/glcpp/tests/001-define.c b/glcpp/tests/001-define.c deleted file mode 100644 index cbf2fee0e75..00000000000 --- a/glcpp/tests/001-define.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo 1 -foo diff --git a/glcpp/tests/001-define.c.expected b/glcpp/tests/001-define.c.expected deleted file mode 100644 index 878fd15d6f8..00000000000 --- a/glcpp/tests/001-define.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -1 - diff --git a/glcpp/tests/002-define-chain.c b/glcpp/tests/002-define-chain.c deleted file mode 100644 index 87d75c68751..00000000000 --- a/glcpp/tests/002-define-chain.c +++ /dev/null @@ -1,3 +0,0 @@ -#define foo 1 -#define bar foo -bar diff --git a/glcpp/tests/002-define-chain.c.expected b/glcpp/tests/002-define-chain.c.expected deleted file mode 100644 index 43d484d7131..00000000000 --- a/glcpp/tests/002-define-chain.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -1 - diff --git a/glcpp/tests/003-define-chain-reverse.c b/glcpp/tests/003-define-chain-reverse.c deleted file mode 100644 index a18b724eca0..00000000000 --- a/glcpp/tests/003-define-chain-reverse.c +++ /dev/null @@ -1,3 +0,0 @@ -#define bar foo -#define foo 1 -bar diff --git a/glcpp/tests/003-define-chain-reverse.c.expected b/glcpp/tests/003-define-chain-reverse.c.expected deleted file mode 100644 index 43d484d7131..00000000000 --- a/glcpp/tests/003-define-chain-reverse.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -1 - diff --git a/glcpp/tests/004-define-recursive.c b/glcpp/tests/004-define-recursive.c deleted file mode 100644 index 2ac56ea3dcf..00000000000 --- a/glcpp/tests/004-define-recursive.c +++ /dev/null @@ -1,6 +0,0 @@ -#define foo bar -#define bar baz -#define baz foo -foo -bar -baz diff --git a/glcpp/tests/004-define-recursive.c.expected b/glcpp/tests/004-define-recursive.c.expected deleted file mode 100644 index 4d2698b7a7f..00000000000 --- a/glcpp/tests/004-define-recursive.c.expected +++ /dev/null @@ -1,7 +0,0 @@ - - - -foo -bar -baz - diff --git a/glcpp/tests/005-define-composite-chain.c b/glcpp/tests/005-define-composite-chain.c deleted file mode 100644 index f5521df968d..00000000000 --- a/glcpp/tests/005-define-composite-chain.c +++ /dev/null @@ -1,3 +0,0 @@ -#define foo 1 -#define bar a foo -bar diff --git a/glcpp/tests/005-define-composite-chain.c.expected b/glcpp/tests/005-define-composite-chain.c.expected deleted file mode 100644 index c67358f4f69..00000000000 --- a/glcpp/tests/005-define-composite-chain.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -a 1 - diff --git a/glcpp/tests/006-define-composite-chain-reverse.c b/glcpp/tests/006-define-composite-chain-reverse.c deleted file mode 100644 index 4bb91a1221a..00000000000 --- a/glcpp/tests/006-define-composite-chain-reverse.c +++ /dev/null @@ -1,3 +0,0 @@ -#define bar a foo -#define foo 1 -bar diff --git a/glcpp/tests/006-define-composite-chain-reverse.c.expected b/glcpp/tests/006-define-composite-chain-reverse.c.expected deleted file mode 100644 index c67358f4f69..00000000000 --- a/glcpp/tests/006-define-composite-chain-reverse.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -a 1 - diff --git a/glcpp/tests/007-define-composite-recursive.c b/glcpp/tests/007-define-composite-recursive.c deleted file mode 100644 index 5784565bdf3..00000000000 --- a/glcpp/tests/007-define-composite-recursive.c +++ /dev/null @@ -1,6 +0,0 @@ -#define foo a bar -#define bar b baz -#define baz c foo -foo -bar -baz diff --git a/glcpp/tests/007-define-composite-recursive.c.expected b/glcpp/tests/007-define-composite-recursive.c.expected deleted file mode 100644 index 30fe4dc1f62..00000000000 --- a/glcpp/tests/007-define-composite-recursive.c.expected +++ /dev/null @@ -1,7 +0,0 @@ - - - -a b c foo -b c a bar -c a b baz - diff --git a/glcpp/tests/008-define-empty.c b/glcpp/tests/008-define-empty.c deleted file mode 100644 index b1bd17ec215..00000000000 --- a/glcpp/tests/008-define-empty.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo -foo diff --git a/glcpp/tests/008-define-empty.c.expected b/glcpp/tests/008-define-empty.c.expected deleted file mode 100644 index b28b04f6431..00000000000 --- a/glcpp/tests/008-define-empty.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/glcpp/tests/009-undef.c b/glcpp/tests/009-undef.c deleted file mode 100644 index 3fc1fb44243..00000000000 --- a/glcpp/tests/009-undef.c +++ /dev/null @@ -1,4 +0,0 @@ -#define foo 1 -foo -#undef foo -foo diff --git a/glcpp/tests/009-undef.c.expected b/glcpp/tests/009-undef.c.expected deleted file mode 100644 index 03a7061af03..00000000000 --- a/glcpp/tests/009-undef.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - -1 - -foo - diff --git a/glcpp/tests/010-undef-re-define.c b/glcpp/tests/010-undef-re-define.c deleted file mode 100644 index 32ff73798b1..00000000000 --- a/glcpp/tests/010-undef-re-define.c +++ /dev/null @@ -1,6 +0,0 @@ -#define foo 1 -foo -#undef foo -foo -#define foo 2 -foo diff --git a/glcpp/tests/010-undef-re-define.c.expected b/glcpp/tests/010-undef-re-define.c.expected deleted file mode 100644 index f4f7efdc2bf..00000000000 --- a/glcpp/tests/010-undef-re-define.c.expected +++ /dev/null @@ -1,7 +0,0 @@ - -1 - -foo - -2 - diff --git a/glcpp/tests/011-define-func-empty.c b/glcpp/tests/011-define-func-empty.c deleted file mode 100644 index d9ce13c2284..00000000000 --- a/glcpp/tests/011-define-func-empty.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo() -foo() diff --git a/glcpp/tests/011-define-func-empty.c.expected b/glcpp/tests/011-define-func-empty.c.expected deleted file mode 100644 index b28b04f6431..00000000000 --- a/glcpp/tests/011-define-func-empty.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/glcpp/tests/012-define-func-no-args.c b/glcpp/tests/012-define-func-no-args.c deleted file mode 100644 index c2bb730b115..00000000000 --- a/glcpp/tests/012-define-func-no-args.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo() bar -foo() diff --git a/glcpp/tests/012-define-func-no-args.c.expected b/glcpp/tests/012-define-func-no-args.c.expected deleted file mode 100644 index 03537672974..00000000000 --- a/glcpp/tests/012-define-func-no-args.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -bar - diff --git a/glcpp/tests/013-define-func-1-arg-unused.c b/glcpp/tests/013-define-func-1-arg-unused.c deleted file mode 100644 index f78fb8b118a..00000000000 --- a/glcpp/tests/013-define-func-1-arg-unused.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x) 1 -foo(bar) diff --git a/glcpp/tests/013-define-func-1-arg-unused.c.expected b/glcpp/tests/013-define-func-1-arg-unused.c.expected deleted file mode 100644 index 878fd15d6f8..00000000000 --- a/glcpp/tests/013-define-func-1-arg-unused.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -1 - diff --git a/glcpp/tests/014-define-func-2-arg-unused.c b/glcpp/tests/014-define-func-2-arg-unused.c deleted file mode 100644 index 11feb2624b7..00000000000 --- a/glcpp/tests/014-define-func-2-arg-unused.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x,y) 1 -foo(bar,baz) diff --git a/glcpp/tests/014-define-func-2-arg-unused.c.expected b/glcpp/tests/014-define-func-2-arg-unused.c.expected deleted file mode 100644 index 878fd15d6f8..00000000000 --- a/glcpp/tests/014-define-func-2-arg-unused.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -1 - diff --git a/glcpp/tests/015-define-object-with-parens.c b/glcpp/tests/015-define-object-with-parens.c deleted file mode 100644 index 558da9c617b..00000000000 --- a/glcpp/tests/015-define-object-with-parens.c +++ /dev/null @@ -1,4 +0,0 @@ -#define foo ()1 -foo() -#define bar ()2 -bar() diff --git a/glcpp/tests/015-define-object-with-parens.c.expected b/glcpp/tests/015-define-object-with-parens.c.expected deleted file mode 100644 index d6f8cb9dc61..00000000000 --- a/glcpp/tests/015-define-object-with-parens.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - -()1() - -()2() - diff --git a/glcpp/tests/016-define-func-1-arg.c b/glcpp/tests/016-define-func-1-arg.c deleted file mode 100644 index a2e2404c7c1..00000000000 --- a/glcpp/tests/016-define-func-1-arg.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x) ((x)+1) -foo(bar) diff --git a/glcpp/tests/016-define-func-1-arg.c.expected b/glcpp/tests/016-define-func-1-arg.c.expected deleted file mode 100644 index 7f1828a3c61..00000000000 --- a/glcpp/tests/016-define-func-1-arg.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -((bar)+1) - diff --git a/glcpp/tests/017-define-func-2-args.c b/glcpp/tests/017-define-func-2-args.c deleted file mode 100644 index c7253835278..00000000000 --- a/glcpp/tests/017-define-func-2-args.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x,y) ((x)*(y)) -foo(bar,baz) diff --git a/glcpp/tests/017-define-func-2-args.c.expected b/glcpp/tests/017-define-func-2-args.c.expected deleted file mode 100644 index 9f341dac00a..00000000000 --- a/glcpp/tests/017-define-func-2-args.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -((bar)*(baz)) - diff --git a/glcpp/tests/018-define-func-macro-as-parameter.c b/glcpp/tests/018-define-func-macro-as-parameter.c deleted file mode 100644 index 668130b8f9b..00000000000 --- a/glcpp/tests/018-define-func-macro-as-parameter.c +++ /dev/null @@ -1,3 +0,0 @@ -#define x 0 -#define foo(x) x -foo(1) diff --git a/glcpp/tests/018-define-func-macro-as-parameter.c.expected b/glcpp/tests/018-define-func-macro-as-parameter.c.expected deleted file mode 100644 index 43d484d7131..00000000000 --- a/glcpp/tests/018-define-func-macro-as-parameter.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -1 - diff --git a/glcpp/tests/019-define-func-1-arg-multi.c b/glcpp/tests/019-define-func-1-arg-multi.c deleted file mode 100644 index c4e62b25508..00000000000 --- a/glcpp/tests/019-define-func-1-arg-multi.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x) (x) -foo(this is more than one word) diff --git a/glcpp/tests/019-define-func-1-arg-multi.c.expected b/glcpp/tests/019-define-func-1-arg-multi.c.expected deleted file mode 100644 index 4314fc88d83..00000000000 --- a/glcpp/tests/019-define-func-1-arg-multi.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -(this is more than one word) - diff --git a/glcpp/tests/020-define-func-2-arg-multi.c b/glcpp/tests/020-define-func-2-arg-multi.c deleted file mode 100644 index 3049ad15465..00000000000 --- a/glcpp/tests/020-define-func-2-arg-multi.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x,y) x,two fish,red fish,y -foo(one fish, blue fish) diff --git a/glcpp/tests/020-define-func-2-arg-multi.c.expected b/glcpp/tests/020-define-func-2-arg-multi.c.expected deleted file mode 100644 index 5648e4fb9d4..00000000000 --- a/glcpp/tests/020-define-func-2-arg-multi.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -one fish,two fish,red fish,blue fish - diff --git a/glcpp/tests/021-define-func-compose.c b/glcpp/tests/021-define-func-compose.c deleted file mode 100644 index 21ddd0e65f9..00000000000 --- a/glcpp/tests/021-define-func-compose.c +++ /dev/null @@ -1,3 +0,0 @@ -#define bar(x) (1+(x)) -#define foo(y) (2*(y)) -foo(bar(3)) diff --git a/glcpp/tests/021-define-func-compose.c.expected b/glcpp/tests/021-define-func-compose.c.expected deleted file mode 100644 index 1d62105de4c..00000000000 --- a/glcpp/tests/021-define-func-compose.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -(2*((1+(3)))) - diff --git a/glcpp/tests/022-define-func-arg-with-parens.c b/glcpp/tests/022-define-func-arg-with-parens.c deleted file mode 100644 index c20d73a4a28..00000000000 --- a/glcpp/tests/022-define-func-arg-with-parens.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x) (x) -foo(argument(including parens)for the win) diff --git a/glcpp/tests/022-define-func-arg-with-parens.c.expected b/glcpp/tests/022-define-func-arg-with-parens.c.expected deleted file mode 100644 index 66c16581758..00000000000 --- a/glcpp/tests/022-define-func-arg-with-parens.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -(argument(including parens)for the win) - diff --git a/glcpp/tests/023-define-extra-whitespace.c b/glcpp/tests/023-define-extra-whitespace.c deleted file mode 100644 index 7ebfed6516c..00000000000 --- a/glcpp/tests/023-define-extra-whitespace.c +++ /dev/null @@ -1,8 +0,0 @@ -#define noargs() 1 -# define onearg(foo) foo - # define twoargs( x , y ) x y - # define threeargs( a , b , c ) a b c -noargs ( ) -onearg ( 2 ) -twoargs ( 3 , 4 ) -threeargs ( 5 , 6 , 7 ) diff --git a/glcpp/tests/023-define-extra-whitespace.c.expected b/glcpp/tests/023-define-extra-whitespace.c.expected deleted file mode 100644 index 573829c2d69..00000000000 --- a/glcpp/tests/023-define-extra-whitespace.c.expected +++ /dev/null @@ -1,9 +0,0 @@ - - - - -1 -2 -3 4 -5 6 7 - diff --git a/glcpp/tests/024-define-chain-to-self-recursion.c b/glcpp/tests/024-define-chain-to-self-recursion.c deleted file mode 100644 index e788adce30c..00000000000 --- a/glcpp/tests/024-define-chain-to-self-recursion.c +++ /dev/null @@ -1,3 +0,0 @@ -#define foo foo -#define bar foo -bar diff --git a/glcpp/tests/024-define-chain-to-self-recursion.c.expected b/glcpp/tests/024-define-chain-to-self-recursion.c.expected deleted file mode 100644 index ad955fce6ec..00000000000 --- a/glcpp/tests/024-define-chain-to-self-recursion.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -foo - diff --git a/glcpp/tests/025-func-macro-as-non-macro.c b/glcpp/tests/025-func-macro-as-non-macro.c deleted file mode 100644 index b433671d1bf..00000000000 --- a/glcpp/tests/025-func-macro-as-non-macro.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(bar) bar -foo bar diff --git a/glcpp/tests/025-func-macro-as-non-macro.c.expected b/glcpp/tests/025-func-macro-as-non-macro.c.expected deleted file mode 100644 index 960f44511a9..00000000000 --- a/glcpp/tests/025-func-macro-as-non-macro.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -foo bar - diff --git a/glcpp/tests/026-define-func-extra-newlines.c b/glcpp/tests/026-define-func-extra-newlines.c deleted file mode 100644 index 0d837405309..00000000000 --- a/glcpp/tests/026-define-func-extra-newlines.c +++ /dev/null @@ -1,6 +0,0 @@ -#define foo(a) bar - -foo -( -1 -) diff --git a/glcpp/tests/026-define-func-extra-newlines.c.expected b/glcpp/tests/026-define-func-extra-newlines.c.expected deleted file mode 100644 index f0888f21b94..00000000000 --- a/glcpp/tests/026-define-func-extra-newlines.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -bar - diff --git a/glcpp/tests/027-define-chain-obj-to-func.c b/glcpp/tests/027-define-chain-obj-to-func.c deleted file mode 100644 index 5ccb52caba5..00000000000 --- a/glcpp/tests/027-define-chain-obj-to-func.c +++ /dev/null @@ -1,3 +0,0 @@ -#define failure() success -#define foo failure() -foo diff --git a/glcpp/tests/027-define-chain-obj-to-func.c.expected b/glcpp/tests/027-define-chain-obj-to-func.c.expected deleted file mode 100644 index aef762e1e69..00000000000 --- a/glcpp/tests/027-define-chain-obj-to-func.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -success - diff --git a/glcpp/tests/028-define-chain-obj-to-non-func.c b/glcpp/tests/028-define-chain-obj-to-non-func.c deleted file mode 100644 index 44962a71876..00000000000 --- a/glcpp/tests/028-define-chain-obj-to-non-func.c +++ /dev/null @@ -1,3 +0,0 @@ -#define success() failure -#define foo success -foo diff --git a/glcpp/tests/028-define-chain-obj-to-non-func.c.expected b/glcpp/tests/028-define-chain-obj-to-non-func.c.expected deleted file mode 100644 index aef762e1e69..00000000000 --- a/glcpp/tests/028-define-chain-obj-to-non-func.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -success - diff --git a/glcpp/tests/029-define-chain-obj-to-func-with-args.c b/glcpp/tests/029-define-chain-obj-to-func-with-args.c deleted file mode 100644 index 261f7d28fc2..00000000000 --- a/glcpp/tests/029-define-chain-obj-to-func-with-args.c +++ /dev/null @@ -1,3 +0,0 @@ -#define bar(failure) failure -#define foo bar(success) -foo diff --git a/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected b/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected deleted file mode 100644 index aef762e1e69..00000000000 --- a/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -success - diff --git a/glcpp/tests/030-define-chain-obj-to-func-compose.c b/glcpp/tests/030-define-chain-obj-to-func-compose.c deleted file mode 100644 index e56fbefd62d..00000000000 --- a/glcpp/tests/030-define-chain-obj-to-func-compose.c +++ /dev/null @@ -1,4 +0,0 @@ -#define baz(failure) failure -#define bar(failure) failure -#define foo bar(baz(success)) -foo diff --git a/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected b/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected deleted file mode 100644 index 729bdd15f80..00000000000 --- a/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - - - -success - diff --git a/glcpp/tests/031-define-chain-func-to-func-compose.c b/glcpp/tests/031-define-chain-func-to-func-compose.c deleted file mode 100644 index 3f4c8744dff..00000000000 --- a/glcpp/tests/031-define-chain-func-to-func-compose.c +++ /dev/null @@ -1,4 +0,0 @@ -#define baz(failure) failure -#define bar(failure) failure -#define foo() bar(baz(success)) -foo() diff --git a/glcpp/tests/031-define-chain-func-to-func-compose.c.expected b/glcpp/tests/031-define-chain-func-to-func-compose.c.expected deleted file mode 100644 index 729bdd15f80..00000000000 --- a/glcpp/tests/031-define-chain-func-to-func-compose.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - - - -success - diff --git a/glcpp/tests/032-define-func-self-recurse.c b/glcpp/tests/032-define-func-self-recurse.c deleted file mode 100644 index b3ac70f499c..00000000000 --- a/glcpp/tests/032-define-func-self-recurse.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(a) foo(2*(a)) -foo(3) diff --git a/glcpp/tests/032-define-func-self-recurse.c.expected b/glcpp/tests/032-define-func-self-recurse.c.expected deleted file mode 100644 index 541d44db7ab..00000000000 --- a/glcpp/tests/032-define-func-self-recurse.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -foo(2*(3)) - diff --git a/glcpp/tests/033-define-func-self-compose.c b/glcpp/tests/033-define-func-self-compose.c deleted file mode 100644 index f65e48286cf..00000000000 --- a/glcpp/tests/033-define-func-self-compose.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(a) foo(2*(a)) -foo(foo(3)) diff --git a/glcpp/tests/033-define-func-self-compose.c.expected b/glcpp/tests/033-define-func-self-compose.c.expected deleted file mode 100644 index 6ea6905d80b..00000000000 --- a/glcpp/tests/033-define-func-self-compose.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -foo(2*(foo(2*(3)))) - diff --git a/glcpp/tests/034-define-func-self-compose-non-func.c b/glcpp/tests/034-define-func-self-compose-non-func.c deleted file mode 100644 index 209a5f7e07c..00000000000 --- a/glcpp/tests/034-define-func-self-compose-non-func.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(bar) bar -foo(foo) diff --git a/glcpp/tests/034-define-func-self-compose-non-func.c.expected b/glcpp/tests/034-define-func-self-compose-non-func.c.expected deleted file mode 100644 index 24823b1b673..00000000000 --- a/glcpp/tests/034-define-func-self-compose-non-func.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -foo - diff --git a/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c b/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c deleted file mode 100644 index c307fbe830f..00000000000 --- a/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(bar) bar -foo(1+foo) diff --git a/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected b/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected deleted file mode 100644 index 137a9ea2db8..00000000000 --- a/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -1+foo - diff --git a/glcpp/tests/036-define-func-non-macro-multi-token-argument.c b/glcpp/tests/036-define-func-non-macro-multi-token-argument.c deleted file mode 100644 index b21ff336738..00000000000 --- a/glcpp/tests/036-define-func-non-macro-multi-token-argument.c +++ /dev/null @@ -1,3 +0,0 @@ -#define bar success -#define foo(x) x -foo(more bar) diff --git a/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected b/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected deleted file mode 100644 index ff6360bfe4e..00000000000 --- a/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -more success - diff --git a/glcpp/tests/037-finalize-unexpanded-macro.c b/glcpp/tests/037-finalize-unexpanded-macro.c deleted file mode 100644 index b3a2f37f1b9..00000000000 --- a/glcpp/tests/037-finalize-unexpanded-macro.c +++ /dev/null @@ -1,3 +0,0 @@ -#define expand(x) expand(x once) -#define foo(x) x -foo(expand(just)) diff --git a/glcpp/tests/037-finalize-unexpanded-macro.c.expected b/glcpp/tests/037-finalize-unexpanded-macro.c.expected deleted file mode 100644 index cbadee848a5..00000000000 --- a/glcpp/tests/037-finalize-unexpanded-macro.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -expand(just once) - diff --git a/glcpp/tests/038-func-arg-with-commas.c b/glcpp/tests/038-func-arg-with-commas.c deleted file mode 100644 index 1407c7d6e3c..00000000000 --- a/glcpp/tests/038-func-arg-with-commas.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x) success -foo(argument (with,embedded , commas) -- tricky) diff --git a/glcpp/tests/038-func-arg-with-commas.c.expected b/glcpp/tests/038-func-arg-with-commas.c.expected deleted file mode 100644 index 5a28fb3b66c..00000000000 --- a/glcpp/tests/038-func-arg-with-commas.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -success - diff --git a/glcpp/tests/039-func-arg-obj-macro-with-comma.c b/glcpp/tests/039-func-arg-obj-macro-with-comma.c deleted file mode 100644 index 0f7fe632b56..00000000000 --- a/glcpp/tests/039-func-arg-obj-macro-with-comma.c +++ /dev/null @@ -1,3 +0,0 @@ -#define foo(a) (a) -#define bar two,words -foo(bar) diff --git a/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected b/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected deleted file mode 100644 index b73869d0238..00000000000 --- a/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -(two,words) - diff --git a/glcpp/tests/040-token-pasting.c b/glcpp/tests/040-token-pasting.c deleted file mode 100644 index caab3ba7368..00000000000 --- a/glcpp/tests/040-token-pasting.c +++ /dev/null @@ -1,2 +0,0 @@ -#define paste(a,b) a ## b -paste(one , token) diff --git a/glcpp/tests/040-token-pasting.c.expected b/glcpp/tests/040-token-pasting.c.expected deleted file mode 100644 index 36f66992539..00000000000 --- a/glcpp/tests/040-token-pasting.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -onetoken - diff --git a/glcpp/tests/041-if-0.c b/glcpp/tests/041-if-0.c deleted file mode 100644 index 2cab677d3e8..00000000000 --- a/glcpp/tests/041-if-0.c +++ /dev/null @@ -1,5 +0,0 @@ -success_1 -#if 0 -failure -#endif -success_2 diff --git a/glcpp/tests/041-if-0.c.expected b/glcpp/tests/041-if-0.c.expected deleted file mode 100644 index 3800024c6ff..00000000000 --- a/glcpp/tests/041-if-0.c.expected +++ /dev/null @@ -1,6 +0,0 @@ -success_1 - - - -success_2 - diff --git a/glcpp/tests/042-if-1.c b/glcpp/tests/042-if-1.c deleted file mode 100644 index 874a25cf41b..00000000000 --- a/glcpp/tests/042-if-1.c +++ /dev/null @@ -1,5 +0,0 @@ -success_1 -#if 1 -success_2 -#endif -success_3 diff --git a/glcpp/tests/042-if-1.c.expected b/glcpp/tests/042-if-1.c.expected deleted file mode 100644 index e591044adbb..00000000000 --- a/glcpp/tests/042-if-1.c.expected +++ /dev/null @@ -1,6 +0,0 @@ -success_1 - -success_2 - -success_3 - diff --git a/glcpp/tests/043-if-0-else.c b/glcpp/tests/043-if-0-else.c deleted file mode 100644 index 323351f9dbf..00000000000 --- a/glcpp/tests/043-if-0-else.c +++ /dev/null @@ -1,7 +0,0 @@ -success_1 -#if 0 -failure -#else -success_2 -#endif -success_3 diff --git a/glcpp/tests/043-if-0-else.c.expected b/glcpp/tests/043-if-0-else.c.expected deleted file mode 100644 index ee9e677096e..00000000000 --- a/glcpp/tests/043-if-0-else.c.expected +++ /dev/null @@ -1,8 +0,0 @@ -success_1 - - - -success_2 - -success_3 - diff --git a/glcpp/tests/044-if-1-else.c b/glcpp/tests/044-if-1-else.c deleted file mode 100644 index 28dfc25c6f0..00000000000 --- a/glcpp/tests/044-if-1-else.c +++ /dev/null @@ -1,7 +0,0 @@ -success_1 -#if 1 -success_2 -#else -failure -#endif -success_3 diff --git a/glcpp/tests/044-if-1-else.c.expected b/glcpp/tests/044-if-1-else.c.expected deleted file mode 100644 index 129f5c8542e..00000000000 --- a/glcpp/tests/044-if-1-else.c.expected +++ /dev/null @@ -1,8 +0,0 @@ -success_1 - -success_2 - - - -success_3 - diff --git a/glcpp/tests/045-if-0-elif.c b/glcpp/tests/045-if-0-elif.c deleted file mode 100644 index e50f686d461..00000000000 --- a/glcpp/tests/045-if-0-elif.c +++ /dev/null @@ -1,11 +0,0 @@ -success_1 -#if 0 -failure_1 -#elif 0 -failure_2 -#elif 1 -success_3 -#elif 1 -failure_3 -#endif -success_4 diff --git a/glcpp/tests/045-if-0-elif.c.expected b/glcpp/tests/045-if-0-elif.c.expected deleted file mode 100644 index 97a11b4472e..00000000000 --- a/glcpp/tests/045-if-0-elif.c.expected +++ /dev/null @@ -1,12 +0,0 @@ -success_1 - - - - - -success_3 - - - -success_4 - diff --git a/glcpp/tests/046-if-1-elsif.c b/glcpp/tests/046-if-1-elsif.c deleted file mode 100644 index 130515a01ea..00000000000 --- a/glcpp/tests/046-if-1-elsif.c +++ /dev/null @@ -1,11 +0,0 @@ -success_1 -#if 1 -success_2 -#elif 0 -failure_1 -#elif 1 -failure_2 -#elif 0 -failure_3 -#endif -success_3 diff --git a/glcpp/tests/046-if-1-elsif.c.expected b/glcpp/tests/046-if-1-elsif.c.expected deleted file mode 100644 index b928b917e3d..00000000000 --- a/glcpp/tests/046-if-1-elsif.c.expected +++ /dev/null @@ -1,12 +0,0 @@ -success_1 - -success_2 - - - - - - - -success_3 - diff --git a/glcpp/tests/047-if-elif-else.c b/glcpp/tests/047-if-elif-else.c deleted file mode 100644 index e8f0838a9ed..00000000000 --- a/glcpp/tests/047-if-elif-else.c +++ /dev/null @@ -1,11 +0,0 @@ -success_1 -#if 0 -failure_1 -#elif 0 -failure_2 -#elif 0 -failure_3 -#else -success_2 -#endif -success_3 diff --git a/glcpp/tests/047-if-elif-else.c.expected b/glcpp/tests/047-if-elif-else.c.expected deleted file mode 100644 index e5b53a3fa59..00000000000 --- a/glcpp/tests/047-if-elif-else.c.expected +++ /dev/null @@ -1,12 +0,0 @@ -success_1 - - - - - - - -success_2 - -success_3 - diff --git a/glcpp/tests/048-if-nested.c b/glcpp/tests/048-if-nested.c deleted file mode 100644 index fc4679c3be4..00000000000 --- a/glcpp/tests/048-if-nested.c +++ /dev/null @@ -1,11 +0,0 @@ -success_1 -#if 0 -failure_1 -#if 1 -failure_2 -#else -failure_3 -#endif -failure_4 -#endif -success_2 diff --git a/glcpp/tests/048-if-nested.c.expected b/glcpp/tests/048-if-nested.c.expected deleted file mode 100644 index c61fd0b3159..00000000000 --- a/glcpp/tests/048-if-nested.c.expected +++ /dev/null @@ -1,12 +0,0 @@ -success_1 - - - - - - - - - -success_2 - diff --git a/glcpp/tests/049-if-expression-precedence.c b/glcpp/tests/049-if-expression-precedence.c deleted file mode 100644 index 833ea03882a..00000000000 --- a/glcpp/tests/049-if-expression-precedence.c +++ /dev/null @@ -1,5 +0,0 @@ -#if 1 + 2 * 3 + - (25 % 17 - + 1) -failure with operator precedence -#else -success -#endif diff --git a/glcpp/tests/049-if-expression-precedence.c.expected b/glcpp/tests/049-if-expression-precedence.c.expected deleted file mode 100644 index 569debb0bb6..00000000000 --- a/glcpp/tests/049-if-expression-precedence.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - - - -success - - diff --git a/glcpp/tests/050-if-defined.c b/glcpp/tests/050-if-defined.c deleted file mode 100644 index 34f0f95140e..00000000000 --- a/glcpp/tests/050-if-defined.c +++ /dev/null @@ -1,17 +0,0 @@ -#if defined foo -failure_1 -#else -success_1 -#endif -#define foo -#if defined foo -success_2 -#else -failure_2 -#endif -#undef foo -#if defined foo -failure_3 -#else -success_3 -#endif diff --git a/glcpp/tests/050-if-defined.c.expected b/glcpp/tests/050-if-defined.c.expected deleted file mode 100644 index 3f01955ee40..00000000000 --- a/glcpp/tests/050-if-defined.c.expected +++ /dev/null @@ -1,18 +0,0 @@ - - - -success_1 - - - -success_2 - - - - - - - -success_3 - - diff --git a/glcpp/tests/051-if-relational.c b/glcpp/tests/051-if-relational.c deleted file mode 100644 index c3db488e0de..00000000000 --- a/glcpp/tests/051-if-relational.c +++ /dev/null @@ -1,35 +0,0 @@ -#if 3 < 2 -failure_1 -#else -success_1 -#endif - -#if 3 >= 2 -success_2 -#else -failure_2 -#endif - -#if 2 + 3 <= 5 -success_3 -#else -failure_3 -#endif - -#if 3 - 2 == 1 -success_3 -#else -failure_3 -#endif - -#if 1 > 3 -failure_4 -#else -success_4 -#endif - -#if 1 != 5 -success_5 -#else -failure_5 -#endif diff --git a/glcpp/tests/051-if-relational.c.expected b/glcpp/tests/051-if-relational.c.expected deleted file mode 100644 index d2b76f14576..00000000000 --- a/glcpp/tests/051-if-relational.c.expected +++ /dev/null @@ -1,36 +0,0 @@ - - - -success_1 - - - -success_2 - - - - - -success_3 - - - - - -success_3 - - - - - - - -success_4 - - - -success_5 - - - - diff --git a/glcpp/tests/052-if-bitwise.c b/glcpp/tests/052-if-bitwise.c deleted file mode 100644 index 2d8e45eb61e..00000000000 --- a/glcpp/tests/052-if-bitwise.c +++ /dev/null @@ -1,20 +0,0 @@ -#if (0xaaaaaaaa | 0x55555555) != 4294967295 -failure_1 -#else -success_1 -#endif -#if (0x12345678 ^ 0xfdecba98) == 4023971040 -success_2 -#else -failure_2 -#endif -#if (~ 0xdeadbeef) != -3735928560 -failure_3 -#else -success_3 -#endif -#if (0667 & 0733) == 403 -success_4 -#else -failure_4 -#endif diff --git a/glcpp/tests/052-if-bitwise.c.expected b/glcpp/tests/052-if-bitwise.c.expected deleted file mode 100644 index bb5d92e8d92..00000000000 --- a/glcpp/tests/052-if-bitwise.c.expected +++ /dev/null @@ -1,21 +0,0 @@ - - - -success_1 - - -success_2 - - - - - - -success_3 - - -success_4 - - - - diff --git a/glcpp/tests/053-if-divide-and-shift.c b/glcpp/tests/053-if-divide-and-shift.c deleted file mode 100644 index d24c54a88d1..00000000000 --- a/glcpp/tests/053-if-divide-and-shift.c +++ /dev/null @@ -1,15 +0,0 @@ -#if (15 / 2) != 7 -failure_1 -#else -success_1 -#endif -#if (1 << 12) == 4096 -success_2 -#else -failure_2 -#endif -#if (31762 >> 8) != 124 -failure_3 -#else -success_3 -#endif diff --git a/glcpp/tests/053-if-divide-and-shift.c.expected b/glcpp/tests/053-if-divide-and-shift.c.expected deleted file mode 100644 index f97e93673cc..00000000000 --- a/glcpp/tests/053-if-divide-and-shift.c.expected +++ /dev/null @@ -1,16 +0,0 @@ - - - -success_1 - - -success_2 - - - - - - -success_3 - - diff --git a/glcpp/tests/054-if-with-macros.c b/glcpp/tests/054-if-with-macros.c deleted file mode 100644 index 3da79a0d96e..00000000000 --- a/glcpp/tests/054-if-with-macros.c +++ /dev/null @@ -1,34 +0,0 @@ -#define one 1 -#define two 2 -#define three 3 -#define five 5 -#if five < two -failure_1 -#else -success_1 -#endif -#if three >= two -success_2 -#else -failure_2 -#endif -#if two + three <= five -success_3 -#else -failure_3 -#endif -#if five - two == three -success_4 -#else -failure_4 -#endif -#if one > three -failure_5 -#else -success_5 -#endif -#if one != five -success_6 -#else -failure_6 -#endif diff --git a/glcpp/tests/054-if-with-macros.c.expected b/glcpp/tests/054-if-with-macros.c.expected deleted file mode 100644 index 27ea4969628..00000000000 --- a/glcpp/tests/054-if-with-macros.c.expected +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - -success_1 - - -success_2 - - - - -success_3 - - - - -success_4 - - - - - - -success_5 - - -success_6 - - - - diff --git a/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c b/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c deleted file mode 100644 index 00f2c2346d6..00000000000 --- a/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c +++ /dev/null @@ -1,3 +0,0 @@ -#define failure() success -#define foo failure -foo() diff --git a/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected b/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected deleted file mode 100644 index aef762e1e69..00000000000 --- a/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -success - diff --git a/glcpp/tests/056-macro-argument-with-comma.c b/glcpp/tests/056-macro-argument-with-comma.c deleted file mode 100644 index 58701d1f25b..00000000000 --- a/glcpp/tests/056-macro-argument-with-comma.c +++ /dev/null @@ -1,4 +0,0 @@ -#define bar with,embedded,commas -#define function(x) success -#define foo function -foo(bar) diff --git a/glcpp/tests/056-macro-argument-with-comma.c.expected b/glcpp/tests/056-macro-argument-with-comma.c.expected deleted file mode 100644 index 729bdd15f80..00000000000 --- a/glcpp/tests/056-macro-argument-with-comma.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - - - -success - diff --git a/glcpp/tests/057-empty-arguments.c b/glcpp/tests/057-empty-arguments.c deleted file mode 100644 index 6140232865d..00000000000 --- a/glcpp/tests/057-empty-arguments.c +++ /dev/null @@ -1,6 +0,0 @@ -#define zero() success -zero() -#define one(x) success -one() -#define two(x,y) success -two(,) diff --git a/glcpp/tests/057-empty-arguments.c.expected b/glcpp/tests/057-empty-arguments.c.expected deleted file mode 100644 index 4e3aad52173..00000000000 --- a/glcpp/tests/057-empty-arguments.c.expected +++ /dev/null @@ -1,7 +0,0 @@ - -success - -success - -success - diff --git a/glcpp/tests/058-token-pasting-empty-arguments.c b/glcpp/tests/058-token-pasting-empty-arguments.c deleted file mode 100644 index 8ac260c76b6..00000000000 --- a/glcpp/tests/058-token-pasting-empty-arguments.c +++ /dev/null @@ -1,5 +0,0 @@ -#define paste(x,y) x ## y -paste(a,b) -paste(a,) -paste(,b) -paste(,) diff --git a/glcpp/tests/058-token-pasting-empty-arguments.c.expected b/glcpp/tests/058-token-pasting-empty-arguments.c.expected deleted file mode 100644 index a1c34e5c1f8..00000000000 --- a/glcpp/tests/058-token-pasting-empty-arguments.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - -ab -a -b - - diff --git a/glcpp/tests/059-token-pasting-integer.c b/glcpp/tests/059-token-pasting-integer.c deleted file mode 100644 index 37b895a4237..00000000000 --- a/glcpp/tests/059-token-pasting-integer.c +++ /dev/null @@ -1,4 +0,0 @@ -#define paste(x,y) x ## y -paste(1,2) -paste(1,000) -paste(identifier,2) diff --git a/glcpp/tests/059-token-pasting-integer.c.expected b/glcpp/tests/059-token-pasting-integer.c.expected deleted file mode 100644 index f1a2cd21c13..00000000000 --- a/glcpp/tests/059-token-pasting-integer.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - -12 -1000 -identifier2 - diff --git a/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c b/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c deleted file mode 100644 index ed80ea879ce..00000000000 --- a/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c +++ /dev/null @@ -1,3 +0,0 @@ -#define double(a) a*2 -#define foo double( -foo 5) diff --git a/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected b/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected deleted file mode 100644 index c1f0d24a144..00000000000 --- a/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -5*2 - diff --git a/glcpp/tests/061-define-chain-obj-to-func-multi.c b/glcpp/tests/061-define-chain-obj-to-func-multi.c deleted file mode 100644 index 6dbfd1f62d1..00000000000 --- a/glcpp/tests/061-define-chain-obj-to-func-multi.c +++ /dev/null @@ -1,5 +0,0 @@ -#define foo(x) success -#define bar foo -#define baz bar -#define joe baz -joe (failure) diff --git a/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected b/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected deleted file mode 100644 index 111f7d10634..00000000000 --- a/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - - - - -success - diff --git a/glcpp/tests/062-if-0-skips-garbage.c b/glcpp/tests/062-if-0-skips-garbage.c deleted file mode 100644 index d9e439bb890..00000000000 --- a/glcpp/tests/062-if-0-skips-garbage.c +++ /dev/null @@ -1,5 +0,0 @@ -#define foo(a,b) -#if 0 -foo(bar) -foo( -#endif diff --git a/glcpp/tests/062-if-0-skips-garbage.c.expected b/glcpp/tests/062-if-0-skips-garbage.c.expected deleted file mode 100644 index 6fb66a5e2f0..00000000000 --- a/glcpp/tests/062-if-0-skips-garbage.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/glcpp/tests/063-comments.c b/glcpp/tests/063-comments.c deleted file mode 100644 index e641d2f0f9e..00000000000 --- a/glcpp/tests/063-comments.c +++ /dev/null @@ -1,20 +0,0 @@ -/* this is a comment */ -// so is this -// */ -f = g/**//h; -/*//*/l(); -m = n//**/o -+ p; -/* this -comment spans -multiple lines and -contains *** stars -and slashes / *** / -and other stuff. -****/ -more code here -/* Test that /* nested - comments */ -are not treated like comments. -/*/ this is a comment */ -/*/*/ diff --git a/glcpp/tests/063-comments.c.expected b/glcpp/tests/063-comments.c.expected deleted file mode 100644 index ed4feedd457..00000000000 --- a/glcpp/tests/063-comments.c.expected +++ /dev/null @@ -1,14 +0,0 @@ - - - -f = g /h; - l(); -m = n -+ p; - -more code here - -are not treated like comments. - - - diff --git a/glcpp/tests/064-version.c b/glcpp/tests/064-version.c deleted file mode 100644 index 21326481b87..00000000000 --- a/glcpp/tests/064-version.c +++ /dev/null @@ -1,2 +0,0 @@ -#version 130 -#define FOO diff --git a/glcpp/tests/064-version.c.expected b/glcpp/tests/064-version.c.expected deleted file mode 100644 index 3af71113c8c..00000000000 --- a/glcpp/tests/064-version.c.expected +++ /dev/null @@ -1,3 +0,0 @@ -#version 130 - - diff --git a/glcpp/tests/065-if-defined-parens.c b/glcpp/tests/065-if-defined-parens.c deleted file mode 100644 index 48aa0f8c3ef..00000000000 --- a/glcpp/tests/065-if-defined-parens.c +++ /dev/null @@ -1,17 +0,0 @@ -#if defined(foo) -failure_1 -#else -success_1 -#endif -#define foo -#if defined ( foo ) -success_2 -#else -failure_2 -#endif -#undef foo -#if defined (foo) -failure_3 -#else -success_3 -#endif diff --git a/glcpp/tests/065-if-defined-parens.c.expected b/glcpp/tests/065-if-defined-parens.c.expected deleted file mode 100644 index 3f01955ee40..00000000000 --- a/glcpp/tests/065-if-defined-parens.c.expected +++ /dev/null @@ -1,18 +0,0 @@ - - - -success_1 - - - -success_2 - - - - - - - -success_3 - - diff --git a/glcpp/tests/071-punctuator.c b/glcpp/tests/071-punctuator.c deleted file mode 100644 index 959d6825988..00000000000 --- a/glcpp/tests/071-punctuator.c +++ /dev/null @@ -1 +0,0 @@ -a = b diff --git a/glcpp/tests/071-punctuator.c.expected b/glcpp/tests/071-punctuator.c.expected deleted file mode 100644 index fee253b7452..00000000000 --- a/glcpp/tests/071-punctuator.c.expected +++ /dev/null @@ -1,2 +0,0 @@ -a = b - diff --git a/glcpp/tests/072-token-pasting-same-line.c b/glcpp/tests/072-token-pasting-same-line.c deleted file mode 100644 index e421e9d5e29..00000000000 --- a/glcpp/tests/072-token-pasting-same-line.c +++ /dev/null @@ -1,2 +0,0 @@ -#define paste(x) success_ ## x -paste(1) paste(2) paste(3) diff --git a/glcpp/tests/072-token-pasting-same-line.c.expected b/glcpp/tests/072-token-pasting-same-line.c.expected deleted file mode 100644 index c780b43d70f..00000000000 --- a/glcpp/tests/072-token-pasting-same-line.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -success_1 success_2 success_3 - diff --git a/glcpp/tests/099-c99-example.c b/glcpp/tests/099-c99-example.c deleted file mode 100644 index d1976b1f265..00000000000 --- a/glcpp/tests/099-c99-example.c +++ /dev/null @@ -1,17 +0,0 @@ -#define x 3 -#define f(a) f(x * (a)) -#undef x -#define x 2 -#define g f -#define z z[0] -#define h g(~ -#define m(a) a(w) -#define w 0,1 -#define t(a) a -#define p() int -#define q(x) x -#define r(x,y) x ## y -f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); -g(x +(3,4)-w) | h 5) & m - (f)^m(m); -p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,)}; diff --git a/glcpp/tests/099-c99-example.c.expected b/glcpp/tests/099-c99-example.c.expected deleted file mode 100644 index 19be7505552..00000000000 --- a/glcpp/tests/099-c99-example.c.expected +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - -f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); -f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); -int i[] = { 1, 23, 4, 5, }; - diff --git a/glcpp/tests/glcpp-test b/glcpp/tests/glcpp-test deleted file mode 100755 index 396f6e175e8..00000000000 --- a/glcpp/tests/glcpp-test +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -for test in *.c; do - echo "Testing $test" - ../glcpp < $test > $test.out - diff -u $test.expected $test.out -done diff --git a/glcpp/xtalloc.c b/glcpp/xtalloc.c deleted file mode 100644 index 656ac2d6cb5..00000000000 --- a/glcpp/xtalloc.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include - -void * -xtalloc_named_const (const void *context, size_t size, const char *name) -{ - void *ret; - - ret = talloc_named_const (context, size, name); - if (ret == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - return ret; -} - -char * -xtalloc_strdup (const void *t, const char *p) -{ - char *ret; - - ret = talloc_strdup (t, p); - if (ret == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - return ret; -} - -char * -xtalloc_strndup (const void *t, const char *p, size_t n) -{ - char *ret; - - ret = talloc_strndup (t, p, n); - if (ret == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - return ret; -} - -char * -xtalloc_asprintf (const void *t, const char *fmt, ...) -{ - va_list ap; - char *ret; - - va_start(ap, fmt); - - ret = talloc_vasprintf(t, fmt, ap); - if (ret == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - va_end(ap); - return ret; -} - -void * -_xtalloc_reference_loc (const void *context, - const void *ptr, const char *location) -{ - void *ret; - - ret = _talloc_reference_loc (context, ptr, location); - if (ret == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - return ret; -} diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp deleted file mode 100644 index fa439f12787..00000000000 --- a/glsl_lexer.lpp +++ /dev/null @@ -1,336 +0,0 @@ -%{ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_parser.h" - -#define YY_USER_ACTION \ - do { \ - yylloc->source = 0; \ - yylloc->first_column = yycolumn + 1; \ - yylloc->first_line = yylineno + 1; \ - yycolumn += yyleng; \ - } while(0); - -%} - -%option bison-bridge bison-locations reentrant noyywrap -%option nounput noyy_top_state -%option never-interactive -%option prefix="_mesa_glsl_" -%option extra-type="struct _mesa_glsl_parse_state *" - -%x PP - -DEC_INT [1-9][0-9]* -HEX_INT 0[xX][0-9a-fA-F]+ -OCT_INT 0[0-7]* -INT ({DEC_INT}|{HEX_INT}|{OCT_INT}) -SPC [ \t]* -SPCP [ \t]+ -HASH ^{SPC}#{SPC} -%% - -[ \r\t]+ ; - - /* Preprocessor tokens. */ -^[ \t]*#[ \t]*$ ; -^[ \t]*#[ \t]*version { BEGIN PP; return VERSION; } -^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; } -{HASH}line{SPCP}{INT}{SPCP}{INT}{SPC}$ { - /* Eat characters until the first digit is - * encountered - */ - char *ptr = yytext; - while (!isdigit(*ptr)) - ptr++; - - /* Subtract one from the line number because - * yylineno is zero-based instead of - * one-based. - */ - yylineno = strtol(ptr, &ptr, 0) - 1; - yylloc->source = strtol(ptr, NULL, 0); - } -{HASH}line{SPCP}{INT}{SPC}$ { - /* Eat characters until the first digit is - * encountered - */ - char *ptr = yytext; - while (!isdigit(*ptr)) - ptr++; - - /* Subtract one from the line number because - * yylineno is zero-based instead of - * one-based. - */ - yylineno = strtol(ptr, &ptr, 0) - 1; - } -^[ \t]*#[ \t]*pragma { BEGIN PP; return PRAGMA; } -\/\/[^\n]* { } -[ \t\r]* { } -: return COLON; -[_a-zA-Z][_a-zA-Z0-9]* { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } -[1-9][0-9]* { - yylval->n = strtol(yytext, NULL, 10); - return INTCONSTANT; - } -\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } - -\n { yylineno++; yycolumn = 0; } - -attribute return ATTRIBUTE; -const return CONST; -bool return BOOL; -float return FLOAT; -int return INT; - -break return BREAK; -continue return CONTINUE; -do return DO; -while return WHILE; -else return ELSE; -for return FOR; -if return IF; -discard return DISCARD; -return return RETURN; - -bvec2 return BVEC2; -bvec3 return BVEC3; -bvec4 return BVEC4; -ivec2 return IVEC2; -ivec3 return IVEC3; -ivec4 return IVEC4; -vec2 return VEC2; -vec3 return VEC3; -vec4 return VEC4; -mat2 return MAT2; -mat3 return MAT3; -mat4 return MAT4; -mat2x2 return MAT2X2; -mat2x3 return MAT2X3; -mat2x4 return MAT2X4; -mat3x2 return MAT3X2; -mat3x3 return MAT3X3; -mat3x4 return MAT3X4; -mat4x2 return MAT4X2; -mat4x3 return MAT4X3; -mat4x4 return MAT4X4; - -in return IN; -out return OUT; -inout return INOUT; -uniform return UNIFORM; -varying return VARYING; -centroid { - if (yyextra->language_version >= 120) { - return CENTROID; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } -invariant { - if (yyextra->language_version >= 120) { - return INVARIANT; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } - -flat { - if (yyextra->language_version >= 130) { - return FLAT; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } -smooth { - if (yyextra->language_version >= 130) { - return SMOOTH; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } -noperspective { - if (yyextra->language_version >= 130) { - return NOPERSPECTIVE; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } - -sampler1D return SAMPLER1D; -sampler2D return SAMPLER2D; -sampler3D return SAMPLER3D; -samplerCube return SAMPLERCUBE; -sampler1DShadow return SAMPLER1DSHADOW; -sampler2DShadow return SAMPLER2DSHADOW; - -struct return STRUCT; -void return VOID; - -\+\+ return INC_OP; --- return DEC_OP; -\<= return LE_OP; ->= return GE_OP; -== return EQ_OP; -!= return NE_OP; -&& return AND_OP; -\|\| return OR_OP; -"^^" return XOR_OP; - -\*= return MUL_ASSIGN; -\/= return DIV_ASSIGN; -\+= return ADD_ASSIGN; -\%= return MOD_ASSIGN; -\<\<= return LEFT_ASSIGN; ->>= return RIGHT_ASSIGN; -&= return AND_ASSIGN; -^= return XOR_ASSIGN; -\|= return OR_ASSIGN; --= return SUB_ASSIGN; - -[1-9][0-9]* { - yylval->n = strtol(yytext, NULL, 10); - return INTCONSTANT; - } -0[xX][0-9a-fA-F]+ { - yylval->n = strtol(yytext + 2, NULL, 16); - return INTCONSTANT; - } -0[0-7]* { - yylval->n = strtol(yytext + 2, NULL, 8); - return INTCONSTANT; - } - -[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { - yylval->real = strtod(yytext, NULL); - return FLOATCONSTANT; - } -\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { - yylval->real = strtod(yytext, NULL); - return FLOATCONSTANT; - } -[0-9]+\.([eE][+-]?[0-9]+)?[fF]? { - yylval->real = strtod(yytext, NULL); - return FLOATCONSTANT; - } -[0-9]+[eE][+-]?[0-9]+[fF]? { - yylval->real = strtod(yytext, NULL); - return FLOATCONSTANT; - } - -true { - yylval->n = 1; - return BOOLCONSTANT; - } -false { - yylval->n = 0; - return BOOLCONSTANT; - } - - - /* Reserved words in GLSL 1.10. */ -asm return ASM; -class return CLASS; -union return UNION; -enum return ENUM; -typedef return TYPEDEF; -template return TEMPLATE; -this return THIS; -packed return PACKED; -goto return GOTO; -switch return SWITCH; -default return DEFAULT; -inline return INLINE; -noinline return NOINLINE; -volatile return VOLATILE; -public return PUBLIC; -static return STATIC; -extern return EXTERN; -external return EXTERNAL; -interface return INTERFACE; -long return LONG; -short return SHORT; -double return DOUBLE; -half return HALF; -fixed return FIXED; -unsigned return UNSIGNED; -input return INPUT; -output return OUTPUT; -hvec2 return HVEC2; -hvec3 return HVEC3; -hvec4 return HVEC4; -dvec2 return DVEC2; -dvec3 return DVEC3; -dvec4 return DVEC4; -fvec2 return FVEC2; -fvec3 return FVEC3; -fvec4 return FVEC4; -sampler2DRect return SAMPLER2DRECT; -sampler3DRect return SAMPLER3DRECT; -sampler2DRectShadow return SAMPLER2DRECTSHADOW; -sizeof return SIZEOF; -cast return CAST; -namespace return NAMESPACE; -using return USING; - - /* Additional reserved words in GLSL 1.20. */ -lowp return LOWP; -mediump return MEDIUMP; -highp return HIGHP; -precision return PRECISION; - -[_a-zA-Z][_a-zA-Z0-9]* { - struct _mesa_glsl_parse_state *state = yyextra; - void *ctx = talloc_parent(state); - yylval->identifier = talloc_strdup(ctx, yytext); - return IDENTIFIER; - } - -. { return yytext[0]; } - -%% - -void -_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) -{ - yylex_init_extra(state, & state->scanner); - yy_scan_string(string, state->scanner); -} - -void -_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) -{ - yylex_destroy(state->scanner); -} diff --git a/glsl_parser.ypp b/glsl_parser.ypp deleted file mode 100644 index 4132495f403..00000000000 --- a/glsl_parser.ypp +++ /dev/null @@ -1,1444 +0,0 @@ -%{ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include -#include -#include - -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_types.h" - -#define YYLEX_PARAM state->scanner - -%} - -%pure-parser -%locations -%error-verbose - -%lex-param {void *scanner} -%parse-param {struct _mesa_glsl_parse_state *state} -%name-prefix "_mesa_glsl_" - -%union { - int n; - float real; - char *identifier; - - union { - struct ast_type_qualifier q; - unsigned i; - } type_qualifier; - - struct ast_node *node; - struct ast_type_specifier *type_specifier; - struct ast_fully_specified_type *fully_specified_type; - struct ast_function *function; - struct ast_parameter_declarator *parameter_declarator; - struct ast_function_definition *function_definition; - struct ast_compound_statement *compound_statement; - struct ast_expression *expression; - struct ast_declarator_list *declarator_list; - struct ast_struct_specifier *struct_specifier; - struct ast_declaration *declaration; - - struct { - struct ast_node *cond; - struct ast_expression *rest; - } for_rest_statement; -} - -%token ATTRIBUTE CONST BOOL FLOAT INT UINT -%token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT -%token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 -%token MAT2 MAT3 MAT4 CENTROID IN OUT INOUT UNIFORM VARYING -%token NOPERSPECTIVE FLAT SMOOTH -%token MAT2X2 MAT2X3 MAT2X4 -%token MAT3X2 MAT3X3 MAT3X4 -%token MAT4X2 MAT4X3 MAT4X4 -%token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW -%token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW -%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE -%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D -%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY -%token STRUCT VOID WHILE -%token IDENTIFIER -%token FLOATCONSTANT -%token INTCONSTANT UINTCONSTANT BOOLCONSTANT -%token FIELD_SELECTION -%token LEFT_OP RIGHT_OP -%token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP -%token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN -%token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN -%token SUB_ASSIGN -%token INVARIANT -%token LOWP MEDIUMP HIGHP PRECISION - -%token VERSION EXTENSION LINE PRAGMA COLON EOL INTERFACE OUTPUT - - /* Reserved words that are not actually used in the grammar. - */ -%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED GOTO -%token INLINE NOINLINE VOLATILE PUBLIC STATIC EXTERN EXTERNAL -%token LONG SHORT DOUBLE HALF FIXED UNSIGNED INPUT OUPTUT -%token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 -%token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW -%token SIZEOF CAST NAMESPACE USING - -%type variable_identifier -%type statement -%type statement_list -%type simple_statement -%type statement_matched -%type statement_unmatched -%type precision_qualifier -%type type_qualifier -%type storage_qualifier -%type interpolation_qualifier -%type type_specifier -%type type_specifier_no_prec -%type type_specifier_nonarray -%type basic_type_specifier_nonarray -%type fully_specified_type -%type function_prototype -%type function_header -%type function_header_with_parameters -%type function_declarator -%type parameter_declarator -%type parameter_declaration -%type parameter_qualifier -%type parameter_type_qualifier -%type parameter_type_specifier -%type function_definition -%type compound_statement_no_new_scope -%type compound_statement -%type statement_no_new_scope -%type expression_statement -%type expression -%type primary_expression -%type assignment_expression -%type conditional_expression -%type logical_or_expression -%type logical_xor_expression -%type logical_and_expression -%type inclusive_or_expression -%type exclusive_or_expression -%type and_expression -%type equality_expression -%type relational_expression -%type shift_expression -%type additive_expression -%type multiplicative_expression -%type unary_expression -%type constant_expression -%type integer_expression -%type postfix_expression -%type function_call_header_with_parameters -%type function_call_header_no_parameters -%type function_call_header -%type function_call_generic -%type function_call_or_method -%type function_call -%type assignment_operator -%type unary_operator -%type function_identifier -%type external_declaration -%type init_declarator_list -%type single_declaration -%type initializer -%type declaration -%type declaration_statement -%type jump_statement -%type struct_specifier -%type struct_declaration_list -%type struct_declaration -%type struct_declarator -%type struct_declarator_list -%type selection_statement_matched -%type selection_statement_unmatched -%type iteration_statement -%type condition -%type conditionopt -%type for_init_statement -%type for_rest_statement -%% - -translation_unit: - version_statement extension_statement_list - { - _mesa_glsl_initialize_types(state); - } - external_declaration_list - ; - -version_statement: - /* blank - no #version specified */ - { - state->language_version = 110; - } - | VERSION INTCONSTANT EOL - { - switch ($2) { - case 110: - case 120: - case 130: - /* FINISHME: Check against implementation support versions. */ - state->language_version = $2; - break; - default: - _mesa_glsl_error(& @2, state, "Shading language version" - "%u is not supported\n", $2); - break; - } - } - ; - -extension_statement_list: - - | extension_statement_list extension_statement - ; - -extension_statement: - EXTENSION IDENTIFIER COLON IDENTIFIER EOL - { - if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) { - YYERROR; - } - } - ; - -external_declaration_list: - external_declaration - { - /* FINISHME: The NULL test is only required because 'precision' - * FINISHME: statements are not yet supported. - */ - if ($1 != NULL) - state->translation_unit.push_tail(& $1->link); - } - | external_declaration_list external_declaration - { - /* FINISHME: The NULL test is only required because 'precision' - * FINISHME: statements are not yet supported. - */ - if ($2 != NULL) - state->translation_unit.push_tail(& $2->link); - } - ; - -variable_identifier: - IDENTIFIER - ; - -primary_expression: - variable_identifier - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.identifier = $1; - } - | INTCONSTANT - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.int_constant = $1; - } - | UINTCONSTANT - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.uint_constant = $1; - } - | FLOATCONSTANT - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.float_constant = $1; - } - | BOOLCONSTANT - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.bool_constant = $1; - } - | '(' expression ')' - { - $$ = $2; - } - ; - -postfix_expression: - primary_expression - | postfix_expression '[' integer_expression ']' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL); - $$->set_location(yylloc); - } - | function_call - { - /* Function call parameters used to be stored as a circular list in - * subexpressions[1]. They are now stored as a regular list in - * expressions. This assertion validates that the old code was - * correctly converted. It can eventually be removed. - */ - assert($1->subexpressions[1] == NULL); - $$ = $1; - } - | postfix_expression '.' IDENTIFIER - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.identifier = $3; - } - | postfix_expression INC_OP - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL); - $$->set_location(yylloc); - } - | postfix_expression DEC_OP - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL); - $$->set_location(yylloc); - } - ; - -integer_expression: - expression - ; - -function_call: - function_call_or_method - ; - -function_call_or_method: - function_call_generic - | postfix_expression '.' function_call_generic - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL); - $$->set_location(yylloc); - } - ; - -function_call_generic: - function_call_header_with_parameters ')' - | function_call_header_no_parameters ')' - ; - -function_call_header_no_parameters: - function_call_header VOID - | function_call_header - ; - -function_call_header_with_parameters: - function_call_header assignment_expression - { - $$ = $1; - $$->set_location(yylloc); - $$->expressions.push_tail(& $2->link); - } - | function_call_header_with_parameters ',' assignment_expression - { - $$ = $1; - $$->set_location(yylloc); - $$->expressions.push_tail(& $3->link); - } - ; - - // Grammar Note: Constructors look like functions, but lexical - // analysis recognized most of them as keywords. They are now - // recognized through "type_specifier". -function_call_header: - function_identifier '(' - ; - -function_identifier: - type_specifier - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_function_expression($1); - $$->set_location(yylloc); - } - | IDENTIFIER - { - void *ctx = talloc_parent(state); - ast_expression *callee = new(ctx) ast_expression($1); - $$ = new(ctx) ast_function_expression(callee); - $$->set_location(yylloc); - } - | FIELD_SELECTION - { - void *ctx = talloc_parent(state); - ast_expression *callee = new(ctx) ast_expression($1); - $$ = new(ctx) ast_function_expression(callee); - $$->set_location(yylloc); - } - ; - - // Grammar Note: No traditional style type casts. -unary_expression: - postfix_expression - | INC_OP unary_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL); - $$->set_location(yylloc); - } - | DEC_OP unary_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL); - $$->set_location(yylloc); - } - | unary_operator unary_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression($1, $2, NULL, NULL); - $$->set_location(yylloc); - } - ; - - // Grammar Note: No '*' or '&' unary ops. Pointers are not supported. -unary_operator: - '+' { $$ = ast_plus; } - | '-' { $$ = ast_neg; } - | '!' { $$ = ast_logic_not; } - | '~' { $$ = ast_bit_not; } - ; - -multiplicative_expression: - unary_expression - | multiplicative_expression '*' unary_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3); - $$->set_location(yylloc); - } - | multiplicative_expression '/' unary_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_div, $1, $3); - $$->set_location(yylloc); - } - | multiplicative_expression '%' unary_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3); - $$->set_location(yylloc); - } - ; - -additive_expression: - multiplicative_expression - | additive_expression '+' multiplicative_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_add, $1, $3); - $$->set_location(yylloc); - } - | additive_expression '-' multiplicative_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3); - $$->set_location(yylloc); - } - ; - -shift_expression: - additive_expression - | shift_expression LEFT_OP additive_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3); - $$->set_location(yylloc); - } - | shift_expression RIGHT_OP additive_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3); - $$->set_location(yylloc); - } - ; - -relational_expression: - shift_expression - | relational_expression '<' shift_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_less, $1, $3); - $$->set_location(yylloc); - } - | relational_expression '>' shift_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3); - $$->set_location(yylloc); - } - | relational_expression LE_OP shift_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3); - $$->set_location(yylloc); - } - | relational_expression GE_OP shift_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3); - $$->set_location(yylloc); - } - ; - -equality_expression: - relational_expression - | equality_expression EQ_OP relational_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3); - $$->set_location(yylloc); - } - | equality_expression NE_OP relational_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3); - $$->set_location(yylloc); - } - ; - -and_expression: - equality_expression - | and_expression '&' equality_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); - $$->set_location(yylloc); - } - ; - -exclusive_or_expression: - and_expression - | exclusive_or_expression '^' and_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3); - $$->set_location(yylloc); - } - ; - -inclusive_or_expression: - exclusive_or_expression - | inclusive_or_expression '|' exclusive_or_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); - $$->set_location(yylloc); - } - ; - -logical_and_expression: - inclusive_or_expression - | logical_and_expression AND_OP inclusive_or_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3); - $$->set_location(yylloc); - } - ; - -logical_xor_expression: - logical_and_expression - | logical_xor_expression XOR_OP logical_and_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3); - $$->set_location(yylloc); - } - ; - -logical_or_expression: - logical_xor_expression - | logical_or_expression OR_OP logical_xor_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3); - $$->set_location(yylloc); - } - ; - -conditional_expression: - logical_or_expression - | logical_or_expression '?' expression ':' assignment_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5); - $$->set_location(yylloc); - } - ; - -assignment_expression: - conditional_expression - | unary_expression assignment_operator assignment_expression - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression($2, $1, $3, NULL); - $$->set_location(yylloc); - } - ; - -assignment_operator: - '=' { $$ = ast_assign; } - | MUL_ASSIGN { $$ = ast_mul_assign; } - | DIV_ASSIGN { $$ = ast_div_assign; } - | MOD_ASSIGN { $$ = ast_mod_assign; } - | ADD_ASSIGN { $$ = ast_add_assign; } - | SUB_ASSIGN { $$ = ast_sub_assign; } - | LEFT_ASSIGN { $$ = ast_ls_assign; } - | RIGHT_ASSIGN { $$ = ast_rs_assign; } - | AND_ASSIGN { $$ = ast_and_assign; } - | XOR_ASSIGN { $$ = ast_xor_assign; } - | OR_ASSIGN { $$ = ast_or_assign; } - ; - -expression: - assignment_expression - { - $$ = $1; - } - | expression ',' assignment_expression - { - void *ctx = talloc_parent(state); - if ($1->oper != ast_sequence) { - $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->expressions.push_tail(& $1->link); - } else { - $$ = $1; - } - - $$->expressions.push_tail(& $3->link); - } - ; - -constant_expression: - conditional_expression - ; - -declaration: - function_prototype ';' - { - $$ = $1; - } - | init_declarator_list ';' - { - $$ = $1; - } - | PRECISION precision_qualifier type_specifier_no_prec ';' - { - if (($3->type_specifier != ast_float) - && ($3->type_specifier != ast_int)) { - _mesa_glsl_error(& @3, state, "global precision qualifier can " - "only be applied to `int' or `float'\n"); - YYERROR; - } - - $$ = NULL; /* FINISHME */ - } - ; - -function_prototype: - function_declarator ')' - ; - -function_declarator: - function_header - | function_header_with_parameters - ; - -function_header_with_parameters: - function_header parameter_declaration - { - $$ = $1; - $$->parameters.push_tail(& $2->link); - } - | function_header_with_parameters ',' parameter_declaration - { - $$ = $1; - $$->parameters.push_tail(& $3->link); - } - ; - -function_header: - fully_specified_type IDENTIFIER '(' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_function(); - $$->set_location(yylloc); - $$->return_type = $1; - $$->identifier = $2; - } - ; - -parameter_declarator: - type_specifier IDENTIFIER - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); - $$->type = new(ctx) ast_fully_specified_type(); - $$->type->set_location(yylloc); - $$->type->specifier = $1; - $$->identifier = $2; - } - | type_specifier IDENTIFIER '[' constant_expression ']' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); - $$->type = new(ctx) ast_fully_specified_type(); - $$->type->set_location(yylloc); - $$->type->specifier = $1; - $$->identifier = $2; - $$->is_array = true; - $$->array_size = $4; - } - ; - -parameter_declaration: - parameter_type_qualifier parameter_qualifier parameter_declarator - { - $1.i |= $2.i; - - $$ = $3; - $$->type->qualifier = $1.q; - } - | parameter_qualifier parameter_declarator - { - $$ = $2; - $$->type->qualifier = $1.q; - } - | parameter_type_qualifier parameter_qualifier parameter_type_specifier - { - void *ctx = talloc_parent(state); - $1.i |= $2.i; - - $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); - $$->type = new(ctx) ast_fully_specified_type(); - $$->type->qualifier = $1.q; - $$->type->specifier = $3; - } - | parameter_qualifier parameter_type_specifier - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); - $$->type = new(ctx) ast_fully_specified_type(); - $$->type->qualifier = $1.q; - $$->type->specifier = $2; - } - ; - -parameter_qualifier: - /* empty */ { $$.i = 0; } - | IN { $$.i = 0; $$.q.in = 1; } - | OUT { $$.i = 0; $$.q.out = 1; } - | INOUT { $$.i = 0; $$.q.in = 1; $$.q.out = 1; } - ; - -parameter_type_specifier: - type_specifier - ; - -init_declarator_list: - single_declaration - | init_declarator_list ',' IDENTIFIER - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - } - | init_declarator_list ',' IDENTIFIER '[' ']' - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - } - | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - } - | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - } - | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - } - | init_declarator_list ',' IDENTIFIER '=' initializer - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - } - ; - - // Grammar Note: No 'enum', or 'typedef'. -single_declaration: - fully_specified_type - { - void *ctx = talloc_parent(state); - if ($1->specifier->type_specifier != ast_struct) { - _mesa_glsl_error(& @1, state, "empty declaration list\n"); - YYERROR; - } else { - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - } - } - | fully_specified_type IDENTIFIER - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | fully_specified_type IDENTIFIER '[' ']' - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | fully_specified_type IDENTIFIER '[' constant_expression ']' - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | fully_specified_type IDENTIFIER '[' ']' '=' initializer - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | fully_specified_type IDENTIFIER '=' initializer - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | INVARIANT IDENTIFIER // Vertex only. - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); - - $$ = new(ctx) ast_declarator_list(NULL); - $$->set_location(yylloc); - $$->invariant = true; - - $$->declarations.push_tail(&decl->link); - } - ; - -fully_specified_type: - type_specifier - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_fully_specified_type(); - $$->set_location(yylloc); - $$->specifier = $1; - } - | type_qualifier type_specifier - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_fully_specified_type(); - $$->set_location(yylloc); - $$->qualifier = $1.q; - $$->specifier = $2; - } - ; - -interpolation_qualifier: - SMOOTH { $$.i = 0; $$.q.smooth = 1; } - | FLAT { $$.i = 0; $$.q.flat = 1; } - | NOPERSPECTIVE { $$.i = 0; $$.q.noperspective = 1; } - ; - -parameter_type_qualifier: - CONST { $$.i = 0; $$.q.constant = 1; } - ; - -type_qualifier: - storage_qualifier - | interpolation_qualifier type_qualifier - { - $$.i = $1.i | $2.i; - } - | INVARIANT type_qualifier - { - $$ = $2; - $$.q.invariant = 1; - } - ; - -storage_qualifier: - CONST { $$.i = 0; $$.q.constant = 1; } - | ATTRIBUTE { $$.i = 0; $$.q.attribute = 1; } - | VARYING { $$.i = 0; $$.q.varying = 1; } - | CENTROID VARYING { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; } - | IN { $$.i = 0; $$.q.in = 1; } - | OUT { $$.i = 0; $$.q.out = 1; } - | CENTROID IN { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; } - | CENTROID OUT { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; } - | UNIFORM { $$.i = 0; $$.q.uniform = 1; } - ; - -type_specifier: - type_specifier_no_prec - | precision_qualifier type_specifier_no_prec - { - $$ = $2; - $$->precision = $1; - } - ; - -type_specifier_no_prec: - type_specifier_nonarray - | type_specifier_nonarray '[' ']' - { - $$ = $1; - $$->is_array = true; - $$->array_size = NULL; - } - | type_specifier_nonarray '[' constant_expression ']' - { - $$ = $1; - $$->is_array = true; - $$->array_size = $3; - } - ; - -type_specifier_nonarray: - basic_type_specifier_nonarray - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_type_specifier($1); - $$->set_location(yylloc); - } - | struct_specifier - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_type_specifier($1); - $$->set_location(yylloc); - } - | IDENTIFIER - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_type_specifier($1); - $$->set_location(yylloc); - } - ; - -basic_type_specifier_nonarray: - VOID { $$ = ast_void; } - | FLOAT { $$ = ast_float; } - | INT { $$ = ast_int; } - | UINT { $$ = ast_uint; } - | BOOL { $$ = ast_bool; } - | VEC2 { $$ = ast_vec2; } - | VEC3 { $$ = ast_vec3; } - | VEC4 { $$ = ast_vec4; } - | BVEC2 { $$ = ast_bvec2; } - | BVEC3 { $$ = ast_bvec3; } - | BVEC4 { $$ = ast_bvec4; } - | IVEC2 { $$ = ast_ivec2; } - | IVEC3 { $$ = ast_ivec3; } - | IVEC4 { $$ = ast_ivec4; } - | UVEC2 { $$ = ast_uvec2; } - | UVEC3 { $$ = ast_uvec3; } - | UVEC4 { $$ = ast_uvec4; } - | MAT2 { $$ = ast_mat2; } - | MAT3 { $$ = ast_mat3; } - | MAT4 { $$ = ast_mat4; } - | MAT2X2 { $$ = ast_mat2; } - | MAT2X3 { $$ = ast_mat2x3; } - | MAT2X4 { $$ = ast_mat2x4; } - | MAT3X2 { $$ = ast_mat3x2; } - | MAT3X3 { $$ = ast_mat3; } - | MAT3X4 { $$ = ast_mat3x4; } - | MAT4X2 { $$ = ast_mat4x2; } - | MAT4X3 { $$ = ast_mat4x3; } - | MAT4X4 { $$ = ast_mat4; } - | SAMPLER1D { $$ = ast_sampler1d; } - | SAMPLER2D { $$ = ast_sampler2d; } - | SAMPLER2DRECT { $$ = ast_sampler2drect; } - | SAMPLER3D { $$ = ast_sampler3d; } - | SAMPLERCUBE { $$ = ast_samplercube; } - | SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; } - | SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; } - | SAMPLER2DRECTSHADOW { $$ = ast_sampler2drectshadow; } - | SAMPLERCUBESHADOW { $$ = ast_samplercubeshadow; } - | SAMPLER1DARRAY { $$ = ast_sampler1darray; } - | SAMPLER2DARRAY { $$ = ast_sampler2darray; } - | SAMPLER1DARRAYSHADOW { $$ = ast_sampler1darrayshadow; } - | SAMPLER2DARRAYSHADOW { $$ = ast_sampler2darrayshadow; } - | ISAMPLER1D { $$ = ast_isampler1d; } - | ISAMPLER2D { $$ = ast_isampler2d; } - | ISAMPLER3D { $$ = ast_isampler3d; } - | ISAMPLERCUBE { $$ = ast_isamplercube; } - | ISAMPLER1DARRAY { $$ = ast_isampler1darray; } - | ISAMPLER2DARRAY { $$ = ast_isampler2darray; } - | USAMPLER1D { $$ = ast_usampler1d; } - | USAMPLER2D { $$ = ast_usampler2d; } - | USAMPLER3D { $$ = ast_usampler3d; } - | USAMPLERCUBE { $$ = ast_usamplercube; } - | USAMPLER1DARRAY { $$ = ast_usampler1darray; } - | USAMPLER2DARRAY { $$ = ast_usampler2darray; } - ; - -precision_qualifier: - HIGHP { - if (state->language_version < 130) - _mesa_glsl_error(& @1, state, - "precission qualifier forbidden " - "in GLSL %d.%d (1.30 or later " - "required)\n", - state->language_version / 100, - state->language_version % 100); - - $$ = ast_precision_high; - } - | MEDIUMP { - if (state->language_version < 130) - _mesa_glsl_error(& @1, state, - "precission qualifier forbidden " - "in GLSL %d.%d (1.30 or later " - "required)\n", - state->language_version / 100, - state->language_version % 100); - - $$ = ast_precision_medium; - } - | LOWP { - if (state->language_version < 130) - _mesa_glsl_error(& @1, state, - "precission qualifier forbidden " - "in GLSL %d.%d (1.30 or later " - "required)\n", - state->language_version / 100, - state->language_version % 100); - - $$ = ast_precision_low; - } - ; - -struct_specifier: - STRUCT IDENTIFIER '{' struct_declaration_list '}' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_struct_specifier($2, $4); - $$->set_location(yylloc); - } - | STRUCT '{' struct_declaration_list '}' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_struct_specifier(NULL, $3); - $$->set_location(yylloc); - } - ; - -struct_declaration_list: - struct_declaration - { - $$ = (struct ast_node *) $1; - $1->link.self_link(); - } - | struct_declaration_list struct_declaration - { - $$ = (struct ast_node *) $1; - $$->link.insert_before(& $2->link); - } - ; - -struct_declaration: - type_specifier struct_declarator_list ';' - { - void *ctx = talloc_parent(state); - ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); - type->set_location(yylloc); - - type->specifier = $1; - $$ = new(ctx) ast_declarator_list(type); - $$->set_location(yylloc); - - $$->declarations.push_degenerate_list_at_head(& $2->link); - } - ; - -struct_declarator_list: - struct_declarator - { - $$ = $1; - $1->link.self_link(); - } - | struct_declarator_list ',' struct_declarator - { - $$ = $1; - $$->link.insert_before(& $3->link); - } - ; - -struct_declarator: - IDENTIFIER - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_declaration($1, false, NULL, NULL); - $$->set_location(yylloc); - } - | IDENTIFIER '[' constant_expression ']' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_declaration($1, true, $3, NULL); - $$->set_location(yylloc); - } - ; - -initializer: - assignment_expression - ; - -declaration_statement: - declaration - ; - - // Grammar Note: labeled statements for SWITCH only; 'goto' is not - // supported. -statement: - statement_matched - | statement_unmatched - ; - -statement_matched: - compound_statement { $$ = (struct ast_node *) $1; } - | simple_statement - ; - -statement_unmatched: - selection_statement_unmatched - ; - -simple_statement: - declaration_statement - | expression_statement - | selection_statement_matched - | switch_statement { $$ = NULL; } - | case_label { $$ = NULL; } - | iteration_statement - | jump_statement - ; - -compound_statement: - '{' '}' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_compound_statement(true, NULL); - $$->set_location(yylloc); - } - | '{' statement_list '}' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_compound_statement(true, $2); - $$->set_location(yylloc); - } - ; - -statement_no_new_scope: - compound_statement_no_new_scope { $$ = (struct ast_node *) $1; } - | simple_statement - ; - -compound_statement_no_new_scope: - '{' '}' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_compound_statement(false, NULL); - $$->set_location(yylloc); - } - | '{' statement_list '}' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_compound_statement(false, $2); - $$->set_location(yylloc); - } - ; - -statement_list: - statement - { - if ($1 == NULL) { - _mesa_glsl_error(& @1, state, " statement\n"); - assert($1 != NULL); - } - - $$ = $1; - $$->link.self_link(); - } - | statement_list statement - { - if ($2 == NULL) { - _mesa_glsl_error(& @2, state, " statement\n"); - assert($2 != NULL); - } - $$ = $1; - $$->link.insert_before(& $2->link); - } - ; - -expression_statement: - ';' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_statement(NULL); - $$->set_location(yylloc); - } - | expression ';' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_expression_statement($1); - $$->set_location(yylloc); - } - ; - -selection_statement_matched: - IF '(' expression ')' statement_matched ELSE statement_matched - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_selection_statement($3, $5, $7); - $$->set_location(yylloc); - } - ; - -selection_statement_unmatched: - IF '(' expression ')' statement_matched - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_selection_statement($3, $5, NULL); - $$->set_location(yylloc); - } - | IF '(' expression ')' statement_unmatched - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_selection_statement($3, $5, NULL); - $$->set_location(yylloc); - } - | IF '(' expression ')' statement_matched ELSE statement_unmatched - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_selection_statement($3, $5, $7); - $$->set_location(yylloc); - } - ; - -condition: - expression - { - $$ = (struct ast_node *) $1; - } - | fully_specified_type IDENTIFIER '=' initializer - { - void *ctx = talloc_parent(state); - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); - ast_declarator_list *declarator = new(ctx) ast_declarator_list($1); - decl->set_location(yylloc); - declarator->set_location(yylloc); - - declarator->declarations.push_tail(&decl->link); - $$ = declarator; - } - ; - -switch_statement: - SWITCH '(' expression ')' compound_statement - ; - -case_label: - CASE expression ':' - | DEFAULT ':' - ; - -iteration_statement: - WHILE '(' condition ')' statement_no_new_scope - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, - NULL, $3, NULL, $5); - $$->set_location(yylloc); - } - | DO statement WHILE '(' expression ')' ';' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, - NULL, $5, NULL, $2); - $$->set_location(yylloc); - } - | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, - $3, $4.cond, $4.rest, $6); - $$->set_location(yylloc); - } - ; - -for_init_statement: - expression_statement - | declaration_statement - ; - -conditionopt: - condition - | /* empty */ - { - $$ = NULL; - } - ; - -for_rest_statement: - conditionopt ';' - { - $$.cond = $1; - $$.rest = NULL; - } - | conditionopt ';' expression - { - $$.cond = $1; - $$.rest = $3; - } - ; - - // Grammar Note: No 'goto'. Gotos are not supported. -jump_statement: - CONTINUE ';' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); - $$->set_location(yylloc); - } - | BREAK ';' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); - $$->set_location(yylloc); - } - | RETURN ';' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); - $$->set_location(yylloc); - } - | RETURN expression ';' - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2); - $$->set_location(yylloc); - } - | DISCARD ';' // Fragment shader only. - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); - $$->set_location(yylloc); - } - ; - -external_declaration: - function_definition { $$ = $1; } - | declaration { $$ = $1; } - ; - -function_definition: - function_prototype compound_statement_no_new_scope - { - void *ctx = talloc_parent(state); - $$ = new(ctx) ast_function_definition(); - $$->set_location(yylloc); - $$->prototype = $1; - $$->body = $2; - } - ; diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp deleted file mode 100644 index 1d16ef55f57..00000000000 --- a/glsl_parser_extras.cpp +++ /dev/null @@ -1,621 +0,0 @@ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include -#include -#include - -extern "C" { -#include -} - -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_parser.h" - -const char * -_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) -{ - switch (target) { - case vertex_shader: return "vertex"; - case fragment_shader: return "fragment"; - case geometry_shader: return "geometry"; - case ir_shader: break; - } - - assert(!"Should not get here."); -} - - -void -_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, - const char *fmt, ...) -{ - va_list ap; - - state->error = true; - - assert(state->info_log != NULL); - state->info_log = talloc_asprintf_append(state->info_log, - "%u:%u(%u): error: ", - locp->source, - locp->first_line, - locp->first_column); - va_start(ap, fmt); - state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); - va_end(ap); - state->info_log = talloc_strdup_append(state->info_log, "\n"); -} - - -void -_mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, - const char *fmt, ...) -{ - va_list ap; - - assert(state->info_log != NULL); - state->info_log = talloc_asprintf_append(state->info_log, - "%u:%u(%u): warning: ", - locp->source, - locp->first_line, - locp->first_column); - va_start(ap, fmt); - state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); - va_end(ap); - state->info_log = talloc_strdup_append(state->info_log, "\n"); -} - - -bool -_mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, - const char *behavior, YYLTYPE *behavior_locp, - _mesa_glsl_parse_state *state) -{ - enum { - extension_disable, - extension_enable, - extension_require, - extension_warn - } ext_mode; - - if (strcmp(behavior, "warn") == 0) { - ext_mode = extension_warn; - } else if (strcmp(behavior, "require") == 0) { - ext_mode = extension_require; - } else if (strcmp(behavior, "enable") == 0) { - ext_mode = extension_enable; - } else if (strcmp(behavior, "disable") == 0) { - ext_mode = extension_disable; - } else { - _mesa_glsl_error(behavior_locp, state, - "Unknown extension behavior `%s'", - behavior); - return false; - } - - bool unsupported = false; - - if (strcmp(name, "all") == 0) { - if ((ext_mode == extension_enable) || (ext_mode == extension_require)) { - _mesa_glsl_error(name_locp, state, "Cannot %s all extensions", - (ext_mode == extension_enable) - ? "enable" : "require"); - return false; - } - } else if (strcmp(name, "GL_ARB_draw_buffers") == 0) { - /* This extension is only supported in fragment shaders. - */ - if (state->target != fragment_shader) { - unsupported = true; - } else { - state->ARB_draw_buffers_enable = (ext_mode != extension_disable); - state->ARB_draw_buffers_warn = (ext_mode == extension_warn); - } - } else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) { - state->ARB_texture_rectangle_enable = (ext_mode != extension_disable); - state->ARB_texture_rectangle_warn = (ext_mode == extension_warn); - } else { - unsupported = true; - } - - if (unsupported) { - static const char *const fmt = "extension `%s' unsupported in %s shader"; - - if (ext_mode == extension_require) { - _mesa_glsl_error(name_locp, state, fmt, - name, _mesa_glsl_shader_target_name(state->target)); - return false; - } else { - _mesa_glsl_warning(name_locp, state, fmt, - name, _mesa_glsl_shader_target_name(state->target)); - } - } - - return true; -} - -void -_mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q) -{ - if (q->constant) - printf("const "); - - if (q->invariant) - printf("invariant "); - - if (q->attribute) - printf("attribute "); - - if (q->varying) - printf("varying "); - - if (q->in && q->out) - printf("inout "); - else { - if (q->in) - printf("in "); - - if (q->out) - printf("out "); - } - - if (q->centroid) - printf("centroid "); - if (q->uniform) - printf("uniform "); - if (q->smooth) - printf("smooth "); - if (q->flat) - printf("flat "); - if (q->noperspective) - printf("noperspective "); -} - - -void -ast_node::print(void) const -{ - printf("unhandled node "); -} - - -ast_node::ast_node(void) -{ - /* empty */ -} - - -static void -ast_opt_array_size_print(bool is_array, const ast_expression *array_size) -{ - if (is_array) { - printf("[ "); - - if (array_size) - array_size->print(); - - printf("] "); - } -} - - -void -ast_compound_statement::print(void) const -{ - printf("{\n"); - - foreach_list_const(n, &this->statements) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - - printf("}\n"); -} - - -ast_compound_statement::ast_compound_statement(int new_scope, - ast_node *statements) -{ - this->new_scope = new_scope; - - if (statements != NULL) { - this->statements.push_degenerate_list_at_head(&statements->link); - } -} - - -void -ast_expression::print(void) const -{ - switch (oper) { - case ast_assign: - case ast_mul_assign: - case ast_div_assign: - case ast_mod_assign: - case ast_add_assign: - case ast_sub_assign: - case ast_ls_assign: - case ast_rs_assign: - case ast_and_assign: - case ast_xor_assign: - case ast_or_assign: - subexpressions[0]->print(); - printf("%s ", operator_string(oper)); - subexpressions[1]->print(); - break; - - case ast_field_selection: - subexpressions[0]->print(); - printf(". %s ", primary_expression.identifier); - break; - - case ast_plus: - case ast_neg: - case ast_bit_not: - case ast_logic_not: - case ast_pre_inc: - case ast_pre_dec: - printf("%s ", operator_string(oper)); - subexpressions[0]->print(); - break; - - case ast_post_inc: - case ast_post_dec: - subexpressions[0]->print(); - printf("%s ", operator_string(oper)); - break; - - case ast_conditional: - subexpressions[0]->print(); - printf("? "); - subexpressions[1]->print(); - printf(": "); - subexpressions[1]->print(); - break; - - case ast_array_index: - subexpressions[0]->print(); - printf("[ "); - subexpressions[1]->print(); - printf("] "); - break; - - case ast_function_call: { - subexpressions[0]->print(); - printf("( "); - - foreach_list_const (n, &this->expressions) { - if (n != this->expressions.get_head()) - printf(", "); - - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - - printf(") "); - break; - } - - case ast_identifier: - printf("%s ", primary_expression.identifier); - break; - - case ast_int_constant: - printf("%d ", primary_expression.int_constant); - break; - - case ast_uint_constant: - printf("%u ", primary_expression.uint_constant); - break; - - case ast_float_constant: - printf("%f ", primary_expression.float_constant); - break; - - case ast_bool_constant: - printf("%s ", - primary_expression.bool_constant - ? "true" : "false"); - break; - - case ast_sequence: { - printf("( "); - foreach_list_const(n, & this->expressions) { - if (n != this->expressions.get_head()) - printf(", "); - - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - printf(") "); - break; - } - - default: - assert(0); - break; - } -} - -ast_expression::ast_expression(int oper, - ast_expression *ex0, - ast_expression *ex1, - ast_expression *ex2) -{ - this->oper = ast_operators(oper); - this->subexpressions[0] = ex0; - this->subexpressions[1] = ex1; - this->subexpressions[2] = ex2; -} - - -void -ast_expression_statement::print(void) const -{ - if (expression) - expression->print(); - - printf("; "); -} - - -ast_expression_statement::ast_expression_statement(ast_expression *ex) : - expression(ex) -{ - /* empty */ -} - - -void -ast_function::print(void) const -{ - return_type->print(); - printf(" %s (", identifier); - - foreach_list_const(n, & this->parameters) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - - printf(")"); -} - - -ast_function::ast_function(void) - : is_definition(false), signature(NULL) -{ - /* empty */ -} - - -void -ast_fully_specified_type::print(void) const -{ - _mesa_ast_type_qualifier_print(& qualifier); - specifier->print(); -} - - -void -ast_parameter_declarator::print(void) const -{ - type->print(); - if (identifier) - printf("%s ", identifier); - ast_opt_array_size_print(is_array, array_size); -} - - -void -ast_function_definition::print(void) const -{ - prototype->print(); - body->print(); -} - - -void -ast_declaration::print(void) const -{ - printf("%s ", identifier); - ast_opt_array_size_print(is_array, array_size); - - if (initializer) { - printf("= "); - initializer->print(); - } -} - - -ast_declaration::ast_declaration(char *identifier, int is_array, - ast_expression *array_size, - ast_expression *initializer) -{ - this->identifier = identifier; - this->is_array = is_array; - this->array_size = array_size; - this->initializer = initializer; -} - - -void -ast_declarator_list::print(void) const -{ - assert(type || invariant); - - if (type) - type->print(); - else - printf("invariant "); - - foreach_list_const (ptr, & this->declarations) { - if (ptr != this->declarations.get_head()) - printf(", "); - - ast_node *ast = exec_node_data(ast_node, ptr, link); - ast->print(); - } - - printf("; "); -} - - -ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type) -{ - this->type = type; -} - -void -ast_jump_statement::print(void) const -{ - switch (mode) { - case ast_continue: - printf("continue; "); - break; - case ast_break: - printf("break; "); - break; - case ast_return: - printf("return "); - if (opt_return_value) - opt_return_value->print(); - - printf("; "); - break; - case ast_discard: - printf("discard; "); - break; - } -} - - -ast_jump_statement::ast_jump_statement(int mode, ast_expression *return_value) -{ - this->mode = ast_jump_modes(mode); - - if (mode == ast_return) - opt_return_value = return_value; -} - - -void -ast_selection_statement::print(void) const -{ - printf("if ( "); - condition->print(); - printf(") "); - - then_statement->print(); - - if (else_statement) { - printf("else "); - else_statement->print(); - } - -} - - -ast_selection_statement::ast_selection_statement(ast_expression *condition, - ast_node *then_statement, - ast_node *else_statement) -{ - this->condition = condition; - this->then_statement = then_statement; - this->else_statement = else_statement; -} - - -void -ast_iteration_statement::print(void) const -{ - switch (mode) { - case ast_for: - printf("for( "); - if (init_statement) - init_statement->print(); - printf("; "); - - if (condition) - condition->print(); - printf("; "); - - if (rest_expression) - rest_expression->print(); - printf(") "); - - body->print(); - break; - - case ast_while: - printf("while ( "); - if (condition) - condition->print(); - printf(") "); - body->print(); - break; - - case ast_do_while: - printf("do "); - body->print(); - printf("while ( "); - if (condition) - condition->print(); - printf("); "); - break; - } -} - - -ast_iteration_statement::ast_iteration_statement(int mode, - ast_node *init, - ast_node *condition, - ast_expression *rest_expression, - ast_node *body) -{ - this->mode = ast_iteration_modes(mode); - this->init_statement = init; - this->condition = condition; - this->rest_expression = rest_expression; - this->body = body; -} - - -void -ast_struct_specifier::print(void) const -{ - printf("struct %s { ", name); - foreach_list_const(n, &this->declarations) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - printf("} "); -} - - -ast_struct_specifier::ast_struct_specifier(char *identifier, - ast_node *declarator_list) -{ - name = identifier; - this->declarations.push_degenerate_list_at_head(&declarator_list->link); -} diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h deleted file mode 100644 index cfe02e3b0c1..00000000000 --- a/glsl_parser_extras.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef GLSL_PARSER_EXTRAS_H -#define GLSL_PARSER_EXTRAS_H - -#include -#include "glsl_symbol_table.h" - -enum _mesa_glsl_parser_targets { - vertex_shader, - geometry_shader, - fragment_shader, - ir_shader -}; - -struct _mesa_glsl_parse_state { - void *scanner; - exec_list translation_unit; - glsl_symbol_table *symbols; - - unsigned language_version; - enum _mesa_glsl_parser_targets target; - - /** - * During AST to IR conversion, pointer to current IR function - * - * Will be \c NULL whenever the AST to IR conversion is not inside a - * function definition. - */ - class ir_function_signature *current_function; - - /** Was there an error during compilation? */ - bool error; - - /** Index of last generated anonymous temporary. */ - unsigned temp_index; - - /** Loop or switch statement containing the current instructions. */ - class ir_instruction *loop_or_switch_nesting; - - /** List of structures defined in user code. */ - const glsl_type **user_structures; - unsigned num_user_structures; - - char *info_log; - - /** - * \name Enable bits for GLSL extensions - */ - /*@{*/ - unsigned ARB_draw_buffers_enable:1; - unsigned ARB_draw_buffers_warn:1; - unsigned ARB_texture_rectangle_enable:1; - unsigned ARB_texture_rectangle_warn:1; - unsigned EXT_texture_array_enable:1; - unsigned EXT_texture_array_warn:1; - /*@}*/ -}; - -typedef struct YYLTYPE { - int first_line; - int first_column; - int last_line; - int last_column; - unsigned source; -} YYLTYPE; -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 - -extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, - const char *fmt, ...); - -/** - * Emit a warning to the shader log - * - * \sa _mesa_glsl_error - */ -extern void _mesa_glsl_warning(const YYLTYPE *locp, - _mesa_glsl_parse_state *state, - const char *fmt, ...); - -extern "C" { -extern int preprocess(void *ctx, const char **shader, char **info_log); -} - -extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, - const char *string); - -extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state); - -union YYSTYPE; -extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc, - void *scanner); - -extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *); - -/** - * Process elements of the #extension directive - * - * \return - * If \c name and \c behavior are valid, \c true is returned. Otherwise - * \c false is returned. - */ -extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, - const char *behavior, - YYLTYPE *behavior_locp, - _mesa_glsl_parse_state *state); - -/** - * Get the textual name of the specified shader target - */ -extern const char * -_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target); - -void do_ir_to_mesa(exec_list *instructions); - -#endif /* GLSL_PARSER_EXTRAS_H */ diff --git a/glsl_symbol_table.h b/glsl_symbol_table.h deleted file mode 100644 index ae2fd3f4f1f..00000000000 --- a/glsl_symbol_table.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef GLSL_SYMBOL_TABLE -#define GLSL_SYMBOL_TABLE - -#include - -#include "symbol_table.h" -#include "ir.h" -#include "glsl_types.h" - -/** - * Facade class for _mesa_symbol_table - * - * Wraps the existing \c _mesa_symbol_table data structure to enforce some - * type safe and some symbol table invariants. - */ -class glsl_symbol_table { -private: - enum glsl_symbol_name_space { - glsl_variable_name_space = 0, - glsl_type_name_space = 1, - glsl_function_name_space = 2 - }; - - static int - _glsl_symbol_table_destructor (glsl_symbol_table *table) - { - table->~glsl_symbol_table(); - - return 0; - } - -public: - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *table; - - table = talloc_size(ctx, size); - assert(table != NULL); - - talloc_set_destructor(table, (int (*)(void*)) _glsl_symbol_table_destructor); - - return table; - } - - /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. Here, C++ will have already called the - * destructor so tell talloc not to do that again. */ - static void operator delete(void *table) - { - talloc_set_destructor(table, NULL); - talloc_free(table); - } - - glsl_symbol_table() - { - table = _mesa_symbol_table_ctor(); - } - - ~glsl_symbol_table() - { - _mesa_symbol_table_dtor(table); - } - - void push_scope() - { - _mesa_symbol_table_push_scope(table); - } - - void pop_scope() - { - _mesa_symbol_table_pop_scope(table); - } - - /** - * Determine whether a name was declared at the current scope - */ - bool name_declared_this_scope(const char *name) - { - return _mesa_symbol_table_symbol_scope(table, -1, name) == 0; - } - - /** - * \name Methods to add symbols to the table - * - * There is some temptation to rename all these functions to \c add_symbol - * or similar. However, this breaks symmetry with the getter functions and - * reduces the clarity of the intention of code that uses these methods. - */ - /*@{*/ - bool add_variable(const char *name, ir_variable *v) - { - return _mesa_symbol_table_add_symbol(table, glsl_variable_name_space, - name, v) == 0; - } - - bool add_type(const char *name, const glsl_type *t) - { - return _mesa_symbol_table_add_symbol(table, glsl_type_name_space, - name, (void *) t) == 0; - } - - bool add_function(const char *name, ir_function *f) - { - return _mesa_symbol_table_add_symbol(table, glsl_function_name_space, - name, f) == 0; - } - /*@}*/ - - /** - * \name Methods to get symbols from the table - */ - /*@{*/ - ir_variable *get_variable(const char *name) - { - return (ir_variable *) - _mesa_symbol_table_find_symbol(table, glsl_variable_name_space, name); - } - - glsl_type *get_type(const char *name) - { - return (glsl_type *) - _mesa_symbol_table_find_symbol(table, glsl_type_name_space, name); - } - - ir_function *get_function(const char *name) - { - return (ir_function *) - _mesa_symbol_table_find_symbol(table, glsl_function_name_space, name); - } - /*@}*/ - -private: - struct _mesa_symbol_table *table; -}; - -#endif /* GLSL_SYMBOL_TABLE */ diff --git a/glsl_types.cpp b/glsl_types.cpp deleted file mode 100644 index bef267fa6be..00000000000 --- a/glsl_types.cpp +++ /dev/null @@ -1,773 +0,0 @@ -/* - * Copyright © 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include "glsl_symbol_table.h" -#include "glsl_parser_extras.h" -#include "glsl_types.h" -#include "builtin_types.h" -#include "hash_table.h" - - -hash_table *glsl_type::array_types = NULL; - -static void -add_types_to_symbol_table(glsl_symbol_table *symtab, - const struct glsl_type *types, - unsigned num_types, bool warn) -{ - (void) warn; - - for (unsigned i = 0; i < num_types; i++) { - symtab->add_type(types[i].name, & types[i]); - } -} - - -static void -generate_110_types(glsl_symbol_table *symtab) -{ - add_types_to_symbol_table(symtab, builtin_core_types, - Elements(builtin_core_types), - false); - add_types_to_symbol_table(symtab, builtin_structure_types, - Elements(builtin_structure_types), - false); - add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types, - Elements(builtin_110_deprecated_structure_types), - false); - add_types_to_symbol_table(symtab, & void_type, 1, false); -} - - -static void -generate_120_types(glsl_symbol_table *symtab) -{ - generate_110_types(symtab); - - add_types_to_symbol_table(symtab, builtin_120_types, - Elements(builtin_120_types), false); -} - - -static void -generate_130_types(glsl_symbol_table *symtab) -{ - generate_120_types(symtab); - - add_types_to_symbol_table(symtab, builtin_130_types, - Elements(builtin_130_types), false); -} - - -static void -generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, bool warn) -{ - add_types_to_symbol_table(symtab, builtin_ARB_texture_rectangle_types, - Elements(builtin_ARB_texture_rectangle_types), - warn); -} - - -static void -generate_EXT_texture_array_types(glsl_symbol_table *symtab, bool warn) -{ - add_types_to_symbol_table(symtab, builtin_EXT_texture_array_types, - Elements(builtin_EXT_texture_array_types), - warn); -} - - -void -_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) -{ - switch (state->language_version) { - case 110: - generate_110_types(state->symbols); - break; - case 120: - generate_120_types(state->symbols); - break; - case 130: - generate_130_types(state->symbols); - break; - default: - /* error */ - break; - } - - if (state->ARB_texture_rectangle_enable) { - generate_ARB_texture_rectangle_types(state->symbols, - state->ARB_texture_rectangle_warn); - } - - if (state->EXT_texture_array_enable && state->language_version < 130) { - // These are already included in 130; don't create twice. - generate_EXT_texture_array_types(state->symbols, - state->EXT_texture_array_warn); - } -} - - -const glsl_type *glsl_type::get_base_type() const -{ - switch (base_type) { - case GLSL_TYPE_UINT: - return uint_type; - case GLSL_TYPE_INT: - return int_type; - case GLSL_TYPE_FLOAT: - return float_type; - case GLSL_TYPE_BOOL: - return bool_type; - default: - return error_type; - } -} - - -ir_function * -glsl_type::generate_constructor(glsl_symbol_table *symtab) const -{ - void *ctx = symtab; - - /* Generate the function name and add it to the symbol table. - */ - ir_function *const f = new(ctx) ir_function(name); - - bool added = symtab->add_function(name, f); - assert(added); - - ir_function_signature *const sig = new(ctx) ir_function_signature(this); - f->add_signature(sig); - - ir_variable **declarations = - (ir_variable **) malloc(sizeof(ir_variable *) * this->length); - for (unsigned i = 0; i < length; i++) { - char *const param_name = (char *) malloc(10); - - snprintf(param_name, 10, "p%08X", i); - - ir_variable *var = (this->base_type == GLSL_TYPE_ARRAY) - ? new(ctx) ir_variable(fields.array, param_name) - : new(ctx) ir_variable(fields.structure[i].type, param_name); - - var->mode = ir_var_in; - declarations[i] = var; - sig->parameters.push_tail(var); - } - - /* Generate the body of the constructor. The body assigns each of the - * parameters to a portion of a local variable called __retval that has - * the same type as the constructor. After initializing __retval, - * __retval is returned. - */ - ir_variable *retval = new(ctx) ir_variable(this, "__retval"); - sig->body.push_tail(retval); - - for (unsigned i = 0; i < length; i++) { - ir_dereference *const lhs = (this->base_type == GLSL_TYPE_ARRAY) - ? (ir_dereference *) new(ctx) ir_dereference_array(retval, - new(ctx) ir_constant(i)) - : (ir_dereference *) new(ctx) ir_dereference_record(retval, - fields.structure[i].name); - - ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[i]); - ir_instruction *const assign = new(ctx) ir_assignment(lhs, rhs, NULL); - - sig->body.push_tail(assign); - } - - free(declarations); - - ir_dereference *const retref = new(ctx) ir_dereference_variable(retval); - ir_instruction *const inst = new(ctx) ir_return(retref); - sig->body.push_tail(inst); - - return f; -} - - -/** - * Generate the function intro for a constructor - * - * \param type Data type to be constructed - * \param count Number of parameters to this concrete constructor. Most - * types have at least two constructors. One will take a - * single scalar parameter and the other will take "N" - * scalar parameters. - * \param parameters Storage for the list of parameters. These are - * typically stored in an \c ir_function_signature. - * \param declarations Pointers to the variable declarations for the function - * parameters. These are used later to avoid having to use - * the symbol table. - */ -static ir_function_signature * -generate_constructor_intro(void *ctx, - const glsl_type *type, unsigned parameter_count, - ir_variable **declarations) -{ - /* Names of parameters used in vector and matrix constructors - */ - static const char *const names[] = { - "a", "b", "c", "d", "e", "f", "g", "h", - "i", "j", "k", "l", "m", "n", "o", "p", - }; - - assert(parameter_count <= Elements(names)); - - const glsl_type *const parameter_type = type->get_base_type(); - - ir_function_signature *const signature = new(ctx) ir_function_signature(type); - - for (unsigned i = 0; i < parameter_count; i++) { - ir_variable *var = new(ctx) ir_variable(parameter_type, names[i]); - - var->mode = ir_var_in; - signature->parameters.push_tail(var); - - declarations[i] = var; - } - - ir_variable *retval = new(ctx) ir_variable(type, "__retval"); - signature->body.push_tail(retval); - - declarations[16] = retval; - return signature; -} - - -/** - * Generate the body of a vector constructor that takes a single scalar - */ -static void -generate_vec_body_from_scalar(void *ctx, - exec_list *instructions, - ir_variable **declarations) -{ - ir_instruction *inst; - - /* Generate a single assignment of the parameter to __retval.x and return - * __retval.xxxx for however many vector components there are. - */ - ir_dereference *const lhs_ref = - new(ctx) ir_dereference_variable(declarations[16]); - ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[0]); - - ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); - - inst = new(ctx) ir_assignment(lhs, rhs, NULL); - instructions->push_tail(inst); - - ir_dereference *const retref = new(ctx) ir_dereference_variable(declarations[16]); - - ir_swizzle *retval = new(ctx) ir_swizzle(retref, 0, 0, 0, 0, - declarations[16]->type->vector_elements); - - inst = new(ctx) ir_return(retval); - instructions->push_tail(inst); -} - - -/** - * Generate the body of a vector constructor that takes multiple scalars - */ -static void -generate_vec_body_from_N_scalars(void *ctx, - exec_list *instructions, - ir_variable **declarations) -{ - ir_instruction *inst; - const glsl_type *const vec_type = declarations[16]->type; - - /* Generate an assignment of each parameter to a single component of - * __retval.x and return __retval. - */ - for (unsigned i = 0; i < vec_type->vector_elements; i++) { - ir_dereference *const lhs_ref = - new(ctx) ir_dereference_variable(declarations[16]); - ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[i]); - - ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, i, 0, 0, 0, 1); - - inst = new(ctx) ir_assignment(lhs, rhs, NULL); - instructions->push_tail(inst); - } - - ir_dereference *retval = new(ctx) ir_dereference_variable(declarations[16]); - - inst = new(ctx) ir_return(retval); - instructions->push_tail(inst); -} - - -/** - * Generate the body of a matrix constructor that takes a single scalar - */ -static void -generate_mat_body_from_scalar(void *ctx, - exec_list *instructions, - ir_variable **declarations) -{ - ir_instruction *inst; - - /* Generate an assignment of the parameter to the X component of a - * temporary vector. Set the remaining fields of the vector to 0. The - * size of the vector is equal to the number of rows of the matrix. - * - * Set each column of the matrix to a successive "rotation" of the - * temporary vector. This fills the matrix with 0s, but writes the single - * scalar along the matrix's diagonal. - * - * For a mat4x3, this is equivalent to: - * - * vec3 tmp; - * mat4x3 __retval; - * tmp.x = a; - * tmp.y = 0.0; - * tmp.z = 0.0; - * __retval[0] = tmp.xyy; - * __retval[1] = tmp.yxy; - * __retval[2] = tmp.yyx; - * __retval[3] = tmp.yyy; - */ - const glsl_type *const column_type = declarations[16]->type->column_type(); - const glsl_type *const row_type = declarations[16]->type->row_type(); - - ir_variable *const column = new(ctx) ir_variable(column_type, "v"); - - instructions->push_tail(column); - - ir_dereference *const lhs_ref = new(ctx) ir_dereference_variable(column); - ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[0]); - - ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); - - inst = new(ctx) ir_assignment(lhs, rhs, NULL); - instructions->push_tail(inst); - - for (unsigned i = 1; i < column_type->vector_elements; i++) { - ir_dereference *const lhs_ref = new(ctx) ir_dereference_variable(column); - ir_constant *const zero = new(ctx) ir_constant(0.0f); - - ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, i, 0, 0, 0, 1); - - inst = new(ctx) ir_assignment(lhs, zero, NULL); - instructions->push_tail(inst); - } - - - for (unsigned i = 0; i < row_type->vector_elements; i++) { - static const unsigned swiz[] = { 1, 1, 1, 0, 1, 1, 1 }; - ir_dereference *const rhs_ref = new(ctx) ir_dereference_variable(column); - - /* This will be .xyyy when i=0, .yxyy when i=1, etc. - */ - ir_swizzle *rhs = new(ctx) ir_swizzle(rhs_ref, swiz[3 - i], swiz[4 - i], - swiz[5 - i], swiz[6 - i], - column_type->vector_elements); - - ir_constant *const idx = new(ctx) ir_constant(int(i)); - ir_dereference *const lhs = - new(ctx) ir_dereference_array(declarations[16], idx); - - inst = new(ctx) ir_assignment(lhs, rhs, NULL); - instructions->push_tail(inst); - } - - ir_dereference *const retval = new(ctx) ir_dereference_variable(declarations[16]); - inst = new(ctx) ir_return(retval); - instructions->push_tail(inst); -} - - -/** - * Generate the body of a vector constructor that takes multiple scalars - */ -static void -generate_mat_body_from_N_scalars(void *ctx, - exec_list *instructions, - ir_variable **declarations) -{ - ir_instruction *inst; - const glsl_type *const row_type = declarations[16]->type->row_type(); - const glsl_type *const column_type = declarations[16]->type->column_type(); - - /* Generate an assignment of each parameter to a single component of - * of a particular column of __retval and return __retval. - */ - for (unsigned i = 0; i < column_type->vector_elements; i++) { - for (unsigned j = 0; j < row_type->vector_elements; j++) { - ir_constant *row_index = new(ctx) ir_constant(int(i)); - ir_dereference *const row_access = - new(ctx) ir_dereference_array(declarations[16], row_index); - - ir_swizzle *component_access = new(ctx) ir_swizzle(row_access, - j, 0, 0, 0, 1); - - const unsigned param = (i * row_type->vector_elements) + j; - ir_dereference *const rhs = - new(ctx) ir_dereference_variable(declarations[param]); - - inst = new(ctx) ir_assignment(component_access, rhs, NULL); - instructions->push_tail(inst); - } - } - - ir_dereference *retval = new(ctx) ir_dereference_variable(declarations[16]); - - inst = new(ctx) ir_return(retval); - instructions->push_tail(inst); -} - - -/** - * Generate the constructors for a set of GLSL types - * - * Constructor implementations are added to \c instructions, and the symbols - * are added to \c symtab. - */ -static void -generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, - unsigned num_types, exec_list *instructions) -{ - void *ctx = symtab; - ir_variable *declarations[17]; - - for (unsigned i = 0; i < num_types; i++) { - /* Only numeric and boolean vectors and matrices get constructors here. - * Structures need to be handled elsewhere. It is expected that scalar - * constructors are never actually called, so they are not generated. - */ - if (!types[i].is_numeric() && !types[i].is_boolean()) - continue; - - if (types[i].is_scalar()) - continue; - - /* Generate the function block, add it to the symbol table, and emit it. - */ - ir_function *const f = new(ctx) ir_function(types[i].name); - - bool added = symtab->add_function(types[i].name, f); - assert(added); - - instructions->push_tail(f); - - /* Each type has several basic constructors. The total number of forms - * depends on the derived type. - * - * Vectors: 1 scalar, N scalars - * Matrices: 1 scalar, NxM scalars - * - * Several possible types of constructors are not included in this list. - * - * Scalar constructors are not included. The expectation is that the - * IR generator won't actually generate these as constructor calls. The - * expectation is that it will just generate the necessary type - * conversion. - * - * Matrix contructors from matrices are also not included. The - * expectation is that the IR generator will generate a call to the - * appropriate from-scalars constructor. - */ - ir_function_signature *const sig = - generate_constructor_intro(ctx, &types[i], 1, declarations); - f->add_signature(sig); - - if (types[i].is_vector()) { - generate_vec_body_from_scalar(ctx, &sig->body, declarations); - - ir_function_signature *const vec_sig = - generate_constructor_intro(ctx, - &types[i], types[i].vector_elements, - declarations); - f->add_signature(vec_sig); - - generate_vec_body_from_N_scalars(ctx, &vec_sig->body, declarations); - } else { - assert(types[i].is_matrix()); - - generate_mat_body_from_scalar(ctx, &sig->body, declarations); - - ir_function_signature *const mat_sig = - generate_constructor_intro(ctx, - &types[i], - (types[i].vector_elements - * types[i].matrix_columns), - declarations); - f->add_signature(mat_sig); - - generate_mat_body_from_N_scalars(ctx, &mat_sig->body, declarations); - } - } -} - - -void -generate_110_constructors(glsl_symbol_table *symtab, exec_list *instructions) -{ - generate_constructor(symtab, builtin_core_types, - Elements(builtin_core_types), instructions); -} - - -void -generate_120_constructors(glsl_symbol_table *symtab, exec_list *instructions) -{ - generate_110_constructors(symtab, instructions); - - generate_constructor(symtab, builtin_120_types, - Elements(builtin_120_types), instructions); -} - - -void -generate_130_constructors(glsl_symbol_table *symtab, exec_list *instructions) -{ - generate_120_constructors(symtab, instructions); - - generate_constructor(symtab, builtin_130_types, - Elements(builtin_130_types), instructions); -} - - -void -_mesa_glsl_initialize_constructors(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - switch (state->language_version) { - case 110: - generate_110_constructors(state->symbols, instructions); - break; - case 120: - generate_120_constructors(state->symbols, instructions); - break; - case 130: - generate_130_constructors(state->symbols, instructions); - break; - default: - /* error */ - break; - } -} - - -glsl_type::glsl_type(void *ctx, const glsl_type *array, unsigned length) : - base_type(GLSL_TYPE_ARRAY), - sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), - sampler_type(0), - vector_elements(0), matrix_columns(0), - name(NULL), length(length) -{ - this->fields.array = array; - - /* Allow a maximum of 10 characters for the array size. This is enough - * for 32-bits of ~0. The extra 3 are for the '[', ']', and terminating - * NUL. - */ - const unsigned name_length = strlen(array->name) + 10 + 3; - char *const n = (char *) talloc_size(ctx, name_length); - - if (length == 0) - snprintf(n, name_length, "%s[]", array->name); - else - snprintf(n, name_length, "%s[%u]", array->name, length); - - this->name = n; -} - - -const glsl_type * -glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) -{ - if (base_type == GLSL_TYPE_VOID) - return &void_type; - - if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4)) - return error_type; - - /* Treat GLSL vectors as Nx1 matrices. - */ - if (columns == 1) { - switch (base_type) { - case GLSL_TYPE_UINT: - return uint_type + (rows - 1); - case GLSL_TYPE_INT: - return int_type + (rows - 1); - case GLSL_TYPE_FLOAT: - return float_type + (rows - 1); - case GLSL_TYPE_BOOL: - return bool_type + (rows - 1); - default: - return error_type; - } - } else { - if ((base_type != GLSL_TYPE_FLOAT) || (rows == 1)) - return error_type; - - /* GLSL matrix types are named mat{COLUMNS}x{ROWS}. Only the following - * combinations are valid: - * - * 1 2 3 4 - * 1 - * 2 x x x - * 3 x x x - * 4 x x x - */ -#define IDX(c,r) (((c-1)*3) + (r-1)) - - switch (IDX(columns, rows)) { - case IDX(2,2): return mat2_type; - case IDX(2,3): return mat2x3_type; - case IDX(2,4): return mat2x4_type; - case IDX(3,2): return mat3x2_type; - case IDX(3,3): return mat3_type; - case IDX(3,4): return mat3x4_type; - case IDX(4,2): return mat4x2_type; - case IDX(4,3): return mat4x3_type; - case IDX(4,4): return mat4_type; - default: return error_type; - } - } - - assert(!"Should not get here."); - return error_type; -} - - -int -glsl_type::array_key_compare(const void *a, const void *b) -{ - const glsl_type *const key1 = (glsl_type *) a; - const glsl_type *const key2 = (glsl_type *) b; - - /* Return zero is the types match (there is zero difference) or non-zero - * otherwise. - */ - return ((key1->fields.array == key2->fields.array) - && (key1->length == key2->length)) ? 0 : 1; -} - - -unsigned -glsl_type::array_key_hash(const void *a) -{ - const glsl_type *const key = (glsl_type *) a; - - const struct { - const glsl_type *t; - unsigned l; - char nul; - } hash_key = { - key->fields.array, - key->length, - '\0' - }; - - return hash_table_string_hash(& hash_key); -} - - -const glsl_type * -glsl_type::get_array_instance(void *ctx, const glsl_type *base, - unsigned array_size) -{ - const glsl_type key(ctx, base, array_size); - - if (array_types == NULL) { - array_types = hash_table_ctor(64, array_key_hash, array_key_compare); - } - - const glsl_type *t = (glsl_type *) hash_table_find(array_types, & key); - if (t == NULL) { - t = new(ctx) glsl_type(ctx, base, array_size); - - hash_table_insert(array_types, (void *) t, t); - } - - assert(t->base_type == GLSL_TYPE_ARRAY); - assert(t->length == array_size); - assert(t->fields.array == base); - - return t; -} - - -const glsl_type * -glsl_type::field_type(const char *name) const -{ - if (this->base_type != GLSL_TYPE_STRUCT) - return error_type; - - for (unsigned i = 0; i < this->length; i++) { - if (strcmp(name, this->fields.structure[i].name) == 0) - return this->fields.structure[i].type; - } - - return error_type; -} - - -int -glsl_type::field_index(const char *name) const -{ - if (this->base_type != GLSL_TYPE_STRUCT) - return -1; - - for (unsigned i = 0; i < this->length; i++) { - if (strcmp(name, this->fields.structure[i].name) == 0) - return i; - } - - return -1; -} - - -unsigned -glsl_type::component_slots() const -{ - switch (this->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_BOOL: - return this->components(); - - case GLSL_TYPE_STRUCT: { - unsigned size = 0; - - for (unsigned i = 0; i < this->length; i++) - size += this->fields.structure[i].type->component_slots(); - - return size; - } - - case GLSL_TYPE_ARRAY: - return this->length * this->fields.array->component_slots(); - - default: - return 0; - } -} diff --git a/glsl_types.h b/glsl_types.h deleted file mode 100644 index 39e6ac970aa..00000000000 --- a/glsl_types.h +++ /dev/null @@ -1,445 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef GLSL_TYPES_H -#define GLSL_TYPES_H - -#include -#include - -extern "C" { -#include -} - -#define GLSL_TYPE_UINT 0 -#define GLSL_TYPE_INT 1 -#define GLSL_TYPE_FLOAT 2 -#define GLSL_TYPE_BOOL 3 -#define GLSL_TYPE_SAMPLER 4 -#define GLSL_TYPE_STRUCT 5 -#define GLSL_TYPE_ARRAY 6 -#define GLSL_TYPE_FUNCTION 7 -#define GLSL_TYPE_VOID 8 -#define GLSL_TYPE_ERROR 9 - -enum glsl_sampler_dim { - GLSL_SAMPLER_DIM_1D = 0, - GLSL_SAMPLER_DIM_2D, - GLSL_SAMPLER_DIM_3D, - GLSL_SAMPLER_DIM_CUBE, - GLSL_SAMPLER_DIM_RECT, - GLSL_SAMPLER_DIM_BUF -}; - - -struct glsl_type { - unsigned base_type:4; - - unsigned sampler_dimensionality:3; - unsigned sampler_shadow:1; - unsigned sampler_array:1; - unsigned sampler_type:2; /**< Type of data returned using this sampler. - * only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT, - * and \c GLSL_TYPE_UINT are valid. - */ - - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *type; - - type = talloc_size(ctx, size); - assert(type != NULL); - - return type; - } - - /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. */ - static void operator delete(void *type) - { - talloc_free(type); - } - - /** - * \name Vector and matrix element counts - * - * For scalars, each of these values will be 1. For non-numeric types - * these will be 0. - */ - /*@{*/ - unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */ - unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */ - /*@}*/ - - /** - * Name of the data type - * - * This may be \c NULL for anonymous structures, for arrays, or for - * function types. - */ - const char *name; - - /** - * For \c GLSL_TYPE_ARRAY, this is the length of the array. For - * \c GLSL_TYPE_STRUCT, it is the number of elements in the structure and - * the number of values pointed to by \c fields.structure (below). - * - * For \c GLSL_TYPE_FUNCTION, it is the number of parameters to the - * function. The return value from a function is implicitly the first - * parameter. The types of the parameters are stored in - * \c fields.parameters (below). - */ - unsigned length; - - /** - * Subtype of composite data types. - */ - union { - const struct glsl_type *array; /**< Type of array elements. */ - const struct glsl_type *parameters; /**< Parameters to function. */ - const struct glsl_struct_field *structure;/**< List of struct fields. */ - } fields; - - - /** - * \name Pointers to various public type singletons - */ - /*@{*/ - static const glsl_type *const error_type; - static const glsl_type *const int_type; - static const glsl_type *const ivec4_type; - static const glsl_type *const uint_type; - static const glsl_type *const uvec4_type; - static const glsl_type *const float_type; - static const glsl_type *const vec2_type; - static const glsl_type *const vec3_type; - static const glsl_type *const vec4_type; - static const glsl_type *const bool_type; - static const glsl_type *const mat2_type; - static const glsl_type *const mat2x3_type; - static const glsl_type *const mat2x4_type; - static const glsl_type *const mat3x2_type; - static const glsl_type *const mat3_type; - static const glsl_type *const mat3x4_type; - static const glsl_type *const mat4x2_type; - static const glsl_type *const mat4x3_type; - static const glsl_type *const mat4_type; - /*@}*/ - - - glsl_type(unsigned base_type, unsigned vector_elements, - unsigned matrix_columns, const char *name) : - base_type(base_type), - sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), - sampler_type(0), - vector_elements(vector_elements), matrix_columns(matrix_columns), - name(name), - length(0) - { - /* Neither dimension is zero or both dimensions are zero. - */ - assert((vector_elements == 0) == (matrix_columns == 0)); - memset(& fields, 0, sizeof(fields)); - } - - glsl_type(enum glsl_sampler_dim dim, bool shadow, bool array, - unsigned type, const char *name) : - base_type(GLSL_TYPE_SAMPLER), - sampler_dimensionality(dim), sampler_shadow(shadow), - sampler_array(array), sampler_type(type), - vector_elements(0), matrix_columns(0), - name(name), - length(0) - { - memset(& fields, 0, sizeof(fields)); - } - - glsl_type(const glsl_struct_field *fields, unsigned num_fields, - const char *name) : - base_type(GLSL_TYPE_STRUCT), - sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), - sampler_type(0), - vector_elements(0), matrix_columns(0), - name(name), - length(num_fields) - { - this->fields.structure = fields; - } - - /** - * For numeric and boolean derrived types returns the basic scalar type - * - * If the type is a numeric or boolean scalar, vector, or matrix type, - * this function gets the scalar type of the individual components. For - * all other types, including arrays of numeric or boolean types, the - * error type is returned. - */ - const glsl_type *get_base_type() const; - - /** - * Query the type of elements in an array - * - * \return - * Pointer to the type of elements in the array for array types, or \c NULL - * for non-array types. - */ - const glsl_type *element_type() const - { - return is_array() ? fields.array : NULL; - } - - /** - * Get the instance of a built-in scalar, vector, or matrix type - */ - static const glsl_type *get_instance(unsigned base_type, unsigned rows, - unsigned columns); - - /** - * Get the instance of an array type - */ - static const glsl_type *get_array_instance(void *ctx, - const glsl_type *base, - unsigned elements); - - /** - * Generate the constructor for this type and add it to the symbol table - */ - class ir_function *generate_constructor(class glsl_symbol_table *) const; - - /** - * Query the total number of scalars that make up a scalar, vector or matrix - */ - unsigned components() const - { - return vector_elements * matrix_columns; - } - - /** - * Calculate the number of components slots required to hold this type - * - * This is used to determine how many uniform or varying locations a type - * might occupy. - */ - unsigned component_slots() const; - - - /** - * Query whether or not a type is a scalar (non-vector and non-matrix). - */ - bool is_scalar() const - { - return (vector_elements == 1) - && (base_type >= GLSL_TYPE_UINT) - && (base_type <= GLSL_TYPE_BOOL); - } - - /** - * Query whether or not a type is a vector - */ - bool is_vector() const - { - return (vector_elements > 1) - && (matrix_columns == 1) - && (base_type >= GLSL_TYPE_UINT) - && (base_type <= GLSL_TYPE_BOOL); - } - - /** - * Query whether or not a type is a matrix - */ - bool is_matrix() const - { - /* GLSL only has float matrices. */ - return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT); - } - - /** - * Query whether or not a type is a non-array numeric type - */ - bool is_numeric() const - { - return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_FLOAT); - } - - /** - * Query whether or not a type is an integral type - */ - bool is_integer() const - { - return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT); - } - - /** - * Query whether or not a type is a float type - */ - bool is_float() const - { - return base_type == GLSL_TYPE_FLOAT; - } - - /** - * Query whether or not a type is a non-array boolean type - */ - bool is_boolean() const - { - return base_type == GLSL_TYPE_BOOL; - } - - /** - * Query whether or not a type is a sampler - */ - bool is_sampler() const - { - return base_type == GLSL_TYPE_SAMPLER; - } - - /** - * Query whether or not a type is an array - */ - bool is_array() const - { - return base_type == GLSL_TYPE_ARRAY; - } - - /** - * Query whether or not a type is a record - */ - bool is_record() const - { - return base_type == GLSL_TYPE_STRUCT; - } - - /** - * Query whether or not a type is the void type singleton. - */ - bool is_void() const - { - return base_type == GLSL_TYPE_VOID; - } - - /** - * Query whether or not a type is the error type singleton. - */ - bool is_error() const - { - return base_type == GLSL_TYPE_ERROR; - } - - /** - * Query the full type of a matrix row - * - * \return - * If the type is not a matrix, \c glsl_type::error_type is returned. - * Otherwise a type matching the rows of the matrix is returned. - */ - const glsl_type *row_type() const - { - return is_matrix() - ? get_instance(base_type, matrix_columns, 1) - : error_type; - } - - /** - * Query the full type of a matrix column - * - * \return - * If the type is not a matrix, \c glsl_type::error_type is returned. - * Otherwise a type matching the columns of the matrix is returned. - */ - const glsl_type *column_type() const - { - return is_matrix() - ? get_instance(base_type, vector_elements, 1) - : error_type; - } - - - /** - * Get the type of a structure field - * - * \return - * Pointer to the type of the named field. If the type is not a structure - * or the named field does not exist, \c glsl_type::error_type is returned. - */ - const glsl_type *field_type(const char *name) const; - - - /** - * Get the location of a filed within a record type - */ - int field_index(const char *name) const; - - - /** - * Query the number of elements in an array type - * - * \return - * The number of elements in the array for array types or -1 for non-array - * types. If the number of elements in the array has not yet been declared, - * zero is returned. - */ - int array_size() const - { - return is_array() ? length : -1; - } - -private: - /** - * Constructor for array types - */ - glsl_type(void *ctx, const glsl_type *array, unsigned length); - - /** Hash table containing the known array types. */ - static struct hash_table *array_types; - - static int array_key_compare(const void *a, const void *b); - static unsigned array_key_hash(const void *key); -}; - -struct glsl_struct_field { - const struct glsl_type *type; - const char *name; -}; - -struct _mesa_glsl_parse_state; - -#ifdef __cplusplus -extern "C" { -#endif - -extern void -_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); - -extern void -_mesa_glsl_initialize_constructors(struct exec_list *instructions, - struct _mesa_glsl_parse_state *state); - -#ifdef __cplusplus -} -#endif - -#endif /* GLSL_TYPES_H */ diff --git a/hash_table.c b/hash_table.c deleted file mode 100644 index e89a2564d76..00000000000 --- a/hash_table.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file hash_table.c - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick - */ - -#include "main/imports.h" -#include "main/simple_list.h" -#include "hash_table.h" - -struct node { - struct node *next; - struct node *prev; -}; - -struct hash_table { - hash_func_t hash; - hash_compare_func_t compare; - - unsigned num_buckets; - struct node buckets[1]; -}; - - -struct hash_node { - struct node link; - const void *key; - void *data; -}; - - -struct hash_table * -hash_table_ctor(unsigned num_buckets, hash_func_t hash, - hash_compare_func_t compare) -{ - struct hash_table *ht; - unsigned i; - - - if (num_buckets < 16) { - num_buckets = 16; - } - - ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1) - * sizeof(ht->buckets[0]))); - if (ht != NULL) { - ht->hash = hash; - ht->compare = compare; - ht->num_buckets = num_buckets; - - for (i = 0; i < num_buckets; i++) { - make_empty_list(& ht->buckets[i]); - } - } - - return ht; -} - - -void -hash_table_dtor(struct hash_table *ht) -{ - hash_table_clear(ht); - _mesa_free(ht); -} - - -void -hash_table_clear(struct hash_table *ht) -{ - struct node *node; - struct node *temp; - unsigned i; - - - for (i = 0; i < ht->num_buckets; i++) { - foreach_s(node, temp, & ht->buckets[i]) { - remove_from_list(node); - _mesa_free(node); - } - - assert(is_empty_list(& ht->buckets[i])); - } -} - - -void * -hash_table_find(struct hash_table *ht, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct node *node; - - foreach(node, & ht->buckets[bucket]) { - struct hash_node *hn = (struct hash_node *) node; - - if ((*ht->compare)(hn->key, key) == 0) { - return hn->data; - } - } - - return NULL; -} - - -void -hash_table_insert(struct hash_table *ht, void *data, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct hash_node *node; - - node = _mesa_calloc(sizeof(*node)); - - node->data = data; - node->key = key; - - insert_at_head(& ht->buckets[bucket], & node->link); -} - - -unsigned -hash_table_string_hash(const void *key) -{ - const char *str = (const char *) key; - unsigned hash = 5381; - - - while (*str != '\0') { - hash = (hash * 33) + *str; - str++; - } - - return hash; -} diff --git a/hash_table.h b/hash_table.h deleted file mode 100644 index b9dd343dee9..00000000000 --- a/hash_table.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file hash_table.h - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick - */ - -#ifndef HASH_TABLE_H -#define HASH_TABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -struct hash_table; - -typedef unsigned (*hash_func_t)(const void *key); -typedef int (*hash_compare_func_t)(const void *key1, const void *key2); - -/** - * Hash table constructor - * - * Creates a hash table with the specified number of buckets. The supplied - * \c hash and \c compare routines are used when adding elements to the table - * and when searching for elements in the table. - * - * \param num_buckets Number of buckets (bins) in the hash table. - * \param hash Function used to compute hash value of input keys. - * \param compare Function used to compare keys. - */ -extern struct hash_table *hash_table_ctor(unsigned num_buckets, - hash_func_t hash, hash_compare_func_t compare); - - -/** - * Release all memory associated with a hash table - * - * \warning - * This function cannot release memory occupied either by keys or data. - */ -extern void hash_table_dtor(struct hash_table *ht); - - -/** - * Flush all entries from a hash table - * - * \param ht Table to be cleared of its entries. - */ -extern void hash_table_clear(struct hash_table *ht); - - -/** - * Search a hash table for a specific element - * - * \param ht Table to be searched - * \param key Key of the desired element - * - * \return - * The \c data value supplied to \c hash_table_insert when the element with - * the matching key was added. If no matching key exists in the table, - * \c NULL is returned. - */ -extern void *hash_table_find(struct hash_table *ht, const void *key); - - -/** - * Add an element to a hash table - */ -extern void hash_table_insert(struct hash_table *ht, void *data, - const void *key); - - -/** - * Compute hash value of a string - * - * Computes the hash value of a string using the DJB2 algorithm developed by - * Professor Daniel J. Bernstein. It was published on comp.lang.c once upon - * a time. I was unable to find the original posting in the archives. - * - * \param key Pointer to a NUL terminated string to be hashed. - * - * \sa hash_table_string_compare - */ -extern unsigned hash_table_string_hash(const void *key); - - -/** - * Compare two strings used as keys - * - * This is just a macro wrapper around \c strcmp. - * - * \sa hash_table_string_hash - */ -#define hash_table_string_compare ((hash_compare_func_t) strcmp) - -#ifdef __cplusplus -}; -#endif - -#endif /* HASH_TABLE_H */ diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp deleted file mode 100644 index e2efff60d34..00000000000 --- a/hir_field_selection.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "ir.h" -#include "main/imports.h" -#include "symbol_table.h" -#include "glsl_parser_extras.h" -#include "ast.h" -#include "glsl_types.h" - -struct ir_rvalue * -_mesa_ast_field_selection_to_hir(const ast_expression *expr, - exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = talloc_parent(state); - ir_rvalue *result = NULL; - ir_rvalue *op; - - op = expr->subexpressions[0]->hir(instructions, state); - - /* There are two kinds of field selection. There is the selection of a - * specific field from a structure, and there is the selection of a - * swizzle / mask from a vector. Which is which is determined entirely - * by the base type of the thing to which the field selection operator is - * being applied. - */ - YYLTYPE loc = expr->get_location(); - if (op->type->is_error()) { - /* silently propagate the error */ - } else if (op->type->is_vector()) { - ir_swizzle *swiz = ir_swizzle::create(op, - expr->primary_expression.identifier, - op->type->vector_elements); - if (swiz != NULL) { - result = swiz; - } else { - /* FINISHME: Logging of error messages should be moved into - * FINISHME: ir_swizzle::create. This allows the generation of more - * FINISHME: specific error messages. - */ - _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'", - expr->primary_expression.identifier); - } - } else if (op->type->base_type == GLSL_TYPE_STRUCT) { - result = new(ctx) ir_dereference_record(op, - expr->primary_expression.identifier); - - if (result->type->is_error()) { - _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " - "structure", - expr->primary_expression.identifier); - } - } else { - _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " - "non-structure / non-vector.", - expr->primary_expression.identifier); - } - - return result ? result : ir_call::get_error_instruction(ctx); -} diff --git a/ir.cpp b/ir.cpp deleted file mode 100644 index 2756752ba49..00000000000 --- a/ir.cpp +++ /dev/null @@ -1,818 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include "main/imports.h" -#include "ir.h" -#include "ir_visitor.h" -#include "glsl_types.h" - -ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, - ir_rvalue *condition) -{ - this->lhs = lhs; - this->rhs = rhs; - this->condition = condition; -} - - -ir_expression::ir_expression(int op, const struct glsl_type *type, - ir_rvalue *op0, ir_rvalue *op1) -{ - this->type = type; - this->operation = ir_expression_operation(op); - this->operands[0] = op0; - this->operands[1] = op1; -} - -unsigned int -ir_expression::get_num_operands(ir_expression_operation op) -{ -/* Update ir_print_visitor.cpp when updating this list. */ - const int num_operands[] = { - 1, /* ir_unop_bit_not */ - 1, /* ir_unop_logic_not */ - 1, /* ir_unop_neg */ - 1, /* ir_unop_abs */ - 1, /* ir_unop_sign */ - 1, /* ir_unop_rcp */ - 1, /* ir_unop_rsq */ - 1, /* ir_unop_sqrt */ - 1, /* ir_unop_exp */ - 1, /* ir_unop_log */ - 1, /* ir_unop_exp2 */ - 1, /* ir_unop_log2 */ - 1, /* ir_unop_f2i */ - 1, /* ir_unop_i2f */ - 1, /* ir_unop_f2b */ - 1, /* ir_unop_b2f */ - 1, /* ir_unop_i2b */ - 1, /* ir_unop_b2i */ - 1, /* ir_unop_u2f */ - - 1, /* ir_unop_trunc */ - 1, /* ir_unop_ceil */ - 1, /* ir_unop_floor */ - - 1, /* ir_unop_sin */ - 1, /* ir_unop_cos */ - - 1, /* ir_unop_dFdx */ - 1, /* ir_unop_dFdy */ - - 2, /* ir_binop_add */ - 2, /* ir_binop_sub */ - 2, /* ir_binop_mul */ - 2, /* ir_binop_div */ - 2, /* ir_binop_mod */ - - 2, /* ir_binop_less */ - 2, /* ir_binop_greater */ - 2, /* ir_binop_lequal */ - 2, /* ir_binop_gequal */ - 2, /* ir_binop_equal */ - 2, /* ir_binop_nequal */ - - 2, /* ir_binop_lshift */ - 2, /* ir_binop_rshift */ - 2, /* ir_binop_bit_and */ - 2, /* ir_binop_bit_xor */ - 2, /* ir_binop_bit_or */ - - 2, /* ir_binop_logic_and */ - 2, /* ir_binop_logic_xor */ - 2, /* ir_binop_logic_or */ - - 2, /* ir_binop_dot */ - 2, /* ir_binop_min */ - 2, /* ir_binop_max */ - - 2, /* ir_binop_pow */ - }; - - assert(sizeof(num_operands) / sizeof(num_operands[0]) == ir_binop_pow + 1); - - return num_operands[op]; -} - -static const char *const operator_strs[] = { - "~", - "!", - "neg", - "abs", - "sign", - "rcp", - "rsq", - "sqrt", - "exp", - "log", - "exp2", - "log2", - "f2i", - "i2f", - "f2b", - "b2f", - "i2b", - "b2i", - "u2f", - "trunc", - "ceil", - "floor", - "sin", - "cos", - "dFdx", - "dFdy", - "+", - "-", - "*", - "/", - "%", - "<", - ">", - "<=", - ">=", - "==", - "!=", - "<<", - ">>", - "&", - "^", - "|", - "&&", - "^^", - "||", - "dot", - "min", - "max", - "pow", -}; - -const char *ir_expression::operator_string() -{ - assert((unsigned int) operation <= - sizeof(operator_strs) / sizeof(operator_strs[0])); - return operator_strs[operation]; -} - -ir_expression_operation -ir_expression::get_operator(const char *str) -{ - const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]); - for (int op = 0; op < operator_count; op++) { - if (strcmp(str, operator_strs[op]) == 0) - return (ir_expression_operation) op; - } - return (ir_expression_operation) -1; -} - -ir_constant::ir_constant() -{ - /* empty */ -} - -ir_constant::ir_constant(const struct glsl_type *type, - const ir_constant_data *data) -{ - assert((type->base_type >= GLSL_TYPE_UINT) - && (type->base_type <= GLSL_TYPE_BOOL)); - - this->type = type; - memcpy(& this->value, data, sizeof(this->value)); -} - -ir_constant::ir_constant(float f) -{ - this->type = glsl_type::float_type; - this->value.f[0] = f; -} - -ir_constant::ir_constant(unsigned int u) -{ - this->type = glsl_type::uint_type; - this->value.u[0] = u; -} - -ir_constant::ir_constant(int i) -{ - this->type = glsl_type::int_type; - this->value.i[0] = i; -} - -ir_constant::ir_constant(bool b) -{ - this->type = glsl_type::bool_type; - this->value.b[0] = b; -} - -ir_constant::ir_constant(const ir_constant *c, unsigned i) -{ - this->type = c->type->get_base_type(); - - switch (this->type->base_type) { - case GLSL_TYPE_UINT: this->value.u[0] = c->value.u[i]; break; - case GLSL_TYPE_INT: this->value.i[0] = c->value.i[i]; break; - case GLSL_TYPE_FLOAT: this->value.f[0] = c->value.f[i]; break; - case GLSL_TYPE_BOOL: this->value.b[0] = c->value.b[i]; break; - default: assert(!"Should not get here."); break; - } -} - -ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) -{ - this->type = type; - - /* FINISHME: Support array types. */ - assert(type->is_scalar() || type->is_vector() || type->is_matrix() - || type->is_record()); - - /* If the constant is a record, the types of each of the entries in - * value_list must be a 1-for-1 match with the structure components. Each - * entry must also be a constant. Just move the nodes from the value_list - * to the list in the ir_constant. - */ - /* FINISHME: Should there be some type checking and / or assertions here? */ - /* FINISHME: Should the new constant take ownership of the nodes from - * FINISHME: value_list, or should it make copies? - */ - if (type->is_record()) { - value_list->move_nodes_to(& this->components); - return; - } - - - ir_constant *value = (ir_constant *) (value_list->head); - - /* Use each component from each entry in the value_list to initialize one - * component of the constant being constructed. - */ - for (unsigned i = 0; i < type->components(); /* empty */) { - assert(value->as_constant() != NULL); - assert(!value->is_tail_sentinal()); - - for (unsigned j = 0; j < value->type->components(); j++) { - switch (type->base_type) { - case GLSL_TYPE_UINT: - this->value.u[i] = value->get_uint_component(j); - break; - case GLSL_TYPE_INT: - this->value.i[i] = value->get_int_component(j); - break; - case GLSL_TYPE_FLOAT: - this->value.f[i] = value->get_float_component(j); - break; - case GLSL_TYPE_BOOL: - this->value.b[i] = value->get_bool_component(j); - break; - default: - /* FINISHME: What to do? Exceptions are not the answer. - */ - break; - } - - i++; - if (i >= type->components()) - break; - } - - value = (ir_constant *) value->next; - } -} - -bool -ir_constant::get_bool_component(unsigned i) const -{ - switch (this->type->base_type) { - case GLSL_TYPE_UINT: return this->value.u[i] != 0; - case GLSL_TYPE_INT: return this->value.i[i] != 0; - case GLSL_TYPE_FLOAT: return ((int)this->value.f[i]) != 0; - case GLSL_TYPE_BOOL: return this->value.b[i]; - default: assert(!"Should not get here."); break; - } - - /* Must return something to make the compiler happy. This is clearly an - * error case. - */ - return false; -} - -float -ir_constant::get_float_component(unsigned i) const -{ - switch (this->type->base_type) { - case GLSL_TYPE_UINT: return (float) this->value.u[i]; - case GLSL_TYPE_INT: return (float) this->value.i[i]; - case GLSL_TYPE_FLOAT: return this->value.f[i]; - case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0 : 0.0; - default: assert(!"Should not get here."); break; - } - - /* Must return something to make the compiler happy. This is clearly an - * error case. - */ - return 0.0; -} - -int -ir_constant::get_int_component(unsigned i) const -{ - switch (this->type->base_type) { - case GLSL_TYPE_UINT: return this->value.u[i]; - case GLSL_TYPE_INT: return this->value.i[i]; - case GLSL_TYPE_FLOAT: return (int) this->value.f[i]; - case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; - default: assert(!"Should not get here."); break; - } - - /* Must return something to make the compiler happy. This is clearly an - * error case. - */ - return 0; -} - -unsigned -ir_constant::get_uint_component(unsigned i) const -{ - switch (this->type->base_type) { - case GLSL_TYPE_UINT: return this->value.u[i]; - case GLSL_TYPE_INT: return this->value.i[i]; - case GLSL_TYPE_FLOAT: return (unsigned) this->value.f[i]; - case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; - default: assert(!"Should not get here."); break; - } - - /* Must return something to make the compiler happy. This is clearly an - * error case. - */ - return 0; -} - - -ir_constant * -ir_constant::get_record_field(const char *name) -{ - int idx = this->type->field_index(name); - - if (idx < 0) - return NULL; - - if (this->components.is_empty()) - return NULL; - - exec_node *node = this->components.head; - for (int i = 0; i < idx; i++) { - node = node->next; - - /* If the end of the list is encountered before the element matching the - * requested field is found, return NULL. - */ - if (node->is_tail_sentinal()) - return NULL; - } - - return (ir_constant *) node; -} - - -bool -ir_constant::has_value(const ir_constant *c) const -{ - if (this->type != c->type) - return false; - - /* FINISHME: This will probably also handle constant arrays as soon as those - * FINISHME: are supported. - */ - if (this->type->base_type == GLSL_TYPE_STRUCT) { - const exec_node *a_node = this->components.head; - const exec_node *b_node = c->components.head; - - while (!a_node->is_tail_sentinal()) { - assert(!b_node->is_tail_sentinal()); - - const ir_constant *const a_field = (ir_constant *) a_node; - const ir_constant *const b_field = (ir_constant *) b_node; - - if (!a_field->has_value(b_field)) - return false; - - a_node = a_node->next; - b_node = b_node->next; - } - - return true; - } - - for (unsigned i = 0; i < this->type->components(); i++) { - switch (this->type->base_type) { - case GLSL_TYPE_UINT: - if (this->value.u[i] != c->value.u[i]) - return false; - break; - case GLSL_TYPE_INT: - if (this->value.i[i] != c->value.i[i]) - return false; - break; - case GLSL_TYPE_FLOAT: - if (this->value.f[i] != c->value.f[i]) - return false; - break; - case GLSL_TYPE_BOOL: - if (this->value.b[i] != c->value.b[i]) - return false; - break; - default: - assert(!"Should not get here."); - return false; - } - } - - return true; -} - -ir_dereference_variable::ir_dereference_variable(ir_variable *var) -{ - this->var = var; - this->type = (var != NULL) ? var->type : glsl_type::error_type; -} - - -ir_dereference_array::ir_dereference_array(ir_rvalue *value, - ir_rvalue *array_index) -{ - this->array_index = array_index; - this->set_array(value); -} - - -ir_dereference_array::ir_dereference_array(ir_variable *var, - ir_rvalue *array_index) -{ - void *ctx = talloc_parent(var); - - this->array_index = array_index; - this->set_array(new(ctx) ir_dereference_variable(var)); -} - - -void -ir_dereference_array::set_array(ir_rvalue *value) -{ - this->array = value; - this->type = glsl_type::error_type; - - if (this->array != NULL) { - const glsl_type *const vt = this->array->type; - - if (vt->is_array()) { - type = vt->element_type(); - } else if (vt->is_matrix()) { - type = vt->column_type(); - } else if (vt->is_vector()) { - type = vt->get_base_type(); - } - } -} - - -ir_dereference_record::ir_dereference_record(ir_rvalue *value, - const char *field) -{ - this->record = value; - this->field = field; - this->type = (this->record != NULL) - ? this->record->type->field_type(field) : glsl_type::error_type; -} - - -ir_dereference_record::ir_dereference_record(ir_variable *var, - const char *field) -{ - void *ctx = talloc_parent(var); - - this->record = new(ctx) ir_dereference_variable(var); - this->field = field; - this->type = (this->record != NULL) - ? this->record->type->field_type(field) : glsl_type::error_type; -} - - -bool -ir_dereference::is_lvalue() -{ - ir_variable *var = this->variable_referenced(); - - /* Every l-value derference chain eventually ends in a variable. - */ - if ((var == NULL) || var->read_only) - return false; - - if (this->type->is_array() && !var->array_lvalue) - return false; - - return true; -} - - -const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf" }; - -const char *ir_texture::opcode_string() -{ - assert((unsigned int) op <= - sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0])); - return tex_opcode_strs[op]; -} - -ir_texture_opcode -ir_texture::get_opcode(const char *str) -{ - const int count = sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]); - for (int op = 0; op < count; op++) { - if (strcmp(str, tex_opcode_strs[op]) == 0) - return (ir_texture_opcode) op; - } - return (ir_texture_opcode) -1; -} - - -void -ir_texture::set_sampler(ir_dereference *sampler) -{ - assert(sampler != NULL); - this->sampler = sampler; - - switch (sampler->type->sampler_type) { - case GLSL_TYPE_FLOAT: - this->type = glsl_type::vec4_type; - break; - case GLSL_TYPE_INT: - this->type = glsl_type::ivec4_type; - break; - case GLSL_TYPE_UINT: - this->type = glsl_type::uvec4_type; - break; - } -} - - -ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, - unsigned w, unsigned count) - : val(val) -{ - assert((count >= 1) && (count <= 4)); - - const unsigned dup_mask = 0 - | ((count > 1) ? ((1U << y) & ((1U << x) )) : 0) - | ((count > 2) ? ((1U << z) & ((1U << x) | (1U << y) )) : 0) - | ((count > 3) ? ((1U << w) & ((1U << x) | (1U << y) | (1U << z))) : 0); - - assert(x <= 3); - assert(y <= 3); - assert(z <= 3); - assert(w <= 3); - - mask.x = x; - mask.y = y; - mask.z = z; - mask.w = w; - mask.num_components = count; - mask.has_duplicates = dup_mask != 0; - - /* Based on the number of elements in the swizzle and the base type - * (i.e., float, int, unsigned, or bool) of the vector being swizzled, - * generate the type of the resulting value. - */ - type = glsl_type::get_instance(val->type->base_type, mask.num_components, 1); -} - -ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) -{ - this->val = val; - this->mask = mask; - this->type = glsl_type::get_instance(val->type->base_type, - mask.num_components, 1); -} - -#define X 1 -#define R 5 -#define S 9 -#define I 13 - -ir_swizzle * -ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) -{ - void *ctx = talloc_parent(val); - - /* For each possible swizzle character, this table encodes the value in - * \c idx_map that represents the 0th element of the vector. For invalid - * swizzle characters (e.g., 'k'), a special value is used that will allow - * detection of errors. - */ - static const unsigned char base_idx[26] = { - /* a b c d e f g h i j k l m */ - R, R, I, I, I, I, R, I, I, I, I, I, I, - /* n o p q r s t u v w x y z */ - I, I, S, S, R, S, S, I, I, X, X, X, X - }; - - /* Each valid swizzle character has an entry in the previous table. This - * table encodes the base index encoded in the previous table plus the actual - * index of the swizzle character. When processing swizzles, the first - * character in the string is indexed in the previous table. Each character - * in the string is indexed in this table, and the value found there has the - * value form the first table subtracted. The result must be on the range - * [0,3]. - * - * For example, the string "wzyx" will get X from the first table. Each of - * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After - * subtraction, the swizzle values are { 3, 2, 1, 0 }. - * - * The string "wzrg" will get X from the first table. Each of the characters - * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the - * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range - * [0,3], the error is detected. - */ - static const unsigned char idx_map[26] = { - /* a b c d e f g h i j k l m */ - R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, - /* n o p q r s t u v w x y z */ - 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2 - }; - - int swiz_idx[4] = { 0, 0, 0, 0 }; - unsigned i; - - - /* Validate the first character in the swizzle string and look up the base - * index value as described above. - */ - if ((str[0] < 'a') || (str[0] > 'z')) - return NULL; - - const unsigned base = base_idx[str[0] - 'a']; - - - for (i = 0; (i < 4) && (str[i] != '\0'); i++) { - /* Validate the next character, and, as described above, convert it to a - * swizzle index. - */ - if ((str[i] < 'a') || (str[i] > 'z')) - return NULL; - - swiz_idx[i] = idx_map[str[i] - 'a'] - base; - if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) - return NULL; - } - - if (str[i] != '\0') - return NULL; - - return new(ctx) ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2], - swiz_idx[3], i); -} - -#undef X -#undef R -#undef S -#undef I - -ir_variable * -ir_swizzle::variable_referenced() -{ - return this->val->variable_referenced(); -} - -ir_variable::ir_variable(const struct glsl_type *type, const char *name) - : max_array_access(0), read_only(false), centroid(false), invariant(false), - shader_in(false), shader_out(false), - mode(ir_var_auto), interpolation(ir_var_smooth), array_lvalue(false) -{ - this->type = type; - this->name = name; - this->location = -1; - this->warn_extension = NULL; - this->constant_value = NULL; - - if (type && type->base_type == GLSL_TYPE_SAMPLER) - this->read_only = true; -} - - -const char * -ir_variable::interpolation_string() const -{ - if (!this->shader_in && !this->shader_out) - return ""; - - switch (this->interpolation) { - case ir_var_smooth: return "smooth"; - case ir_var_flat: return "flat"; - case ir_var_noperspective: return "noperspective"; - } - - assert(!"Should not get here."); - return ""; -} - - -unsigned -ir_variable::component_slots() const -{ - /* FINISHME: Sparsely accessed arrays require fewer slots. */ - return this->type->component_slots(); -} - - -ir_function_signature::ir_function_signature(const glsl_type *return_type) - : return_type(return_type), is_defined(false) -{ - /* empty */ -} - - -const char * -ir_function_signature::qualifiers_match(exec_list *params) -{ - exec_list_iterator iter_a = parameters.iterator(); - exec_list_iterator iter_b = params->iterator(); - - /* check that the qualifiers match. */ - while (iter_a.has_next()) { - ir_variable *a = (ir_variable *)iter_a.get(); - ir_variable *b = (ir_variable *)iter_b.get(); - - if (a->read_only != b->read_only || - a->mode != b->mode || - a->interpolation != b->interpolation || - a->centroid != b->centroid) { - - /* parameter a's qualifiers don't match */ - return a->name; - } - - iter_a.next(); - iter_b.next(); - } - return NULL; -} - - -void -ir_function_signature::replace_parameters(exec_list *new_params) -{ - /* Destroy all of the previous parameter information. If the previous - * parameter information comes from the function prototype, it may either - * specify incorrect parameter names or not have names at all. - */ - foreach_iter(exec_list_iterator, iter, parameters) { - assert(((ir_instruction *) iter.get())->as_variable() != NULL); - - iter.remove(); - } - - new_params->move_nodes_to(¶meters); -} - - -ir_function::ir_function(const char *name) - : name(name) -{ - /* empty */ -} - - -ir_call * -ir_call::get_error_instruction(void *ctx) -{ - ir_call *call = new(ctx) ir_call; - - call->type = glsl_type::error_type; - return call; -} - -void -visit_exec_list(exec_list *list, ir_visitor *visitor) -{ - foreach_iter(exec_list_iterator, iter, *list) { - ((ir_instruction *)iter.get())->accept(visitor); - } -} - diff --git a/ir.h b/ir.h deleted file mode 100644 index 3d2c7ff5cf5..00000000000 --- a/ir.h +++ /dev/null @@ -1,1178 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef IR_H -#define IR_H - -#include -#include - -extern "C" { -#include -} - -#include "list.h" -#include "ir_visitor.h" -#include "ir_hierarchical_visitor.h" - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -struct ir_program { - void *bong_hits; -}; - -/** - * Base class of all IR instructions - */ -class ir_instruction : public exec_node { -public: - const struct glsl_type *type; - - class ir_constant *constant_expression_value(); - - /** ir_print_visitor helper for debugging. */ - void print(void) const; - - virtual void accept(ir_visitor *) = 0; - virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0; - virtual ir_instruction *clone(struct hash_table *ht) const = 0; - - /** - * \name IR instruction downcast functions - * - * These functions either cast the object to a derived class or return - * \c NULL if the object's type does not match the specified derived class. - * Additional downcast functions will be added as needed. - */ - /*@{*/ - virtual class ir_variable * as_variable() { return NULL; } - virtual class ir_function * as_function() { return NULL; } - virtual class ir_dereference * as_dereference() { return NULL; } - virtual class ir_dereference_array * as_dereference_array() { return NULL; } - virtual class ir_rvalue * as_rvalue() { return NULL; } - virtual class ir_loop * as_loop() { return NULL; } - virtual class ir_assignment * as_assignment() { return NULL; } - virtual class ir_call * as_call() { return NULL; } - virtual class ir_return * as_return() { return NULL; } - virtual class ir_if * as_if() { return NULL; } - virtual class ir_swizzle * as_swizzle() { return NULL; } - virtual class ir_constant * as_constant() { return NULL; } - /*@}*/ - -protected: - ir_instruction() - { - /* empty */ - } -}; - - -class ir_rvalue : public ir_instruction { -public: - virtual ir_rvalue * as_rvalue() - { - return this; - } - - virtual bool is_lvalue() - { - return false; - } - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() - { - return NULL; - } - - - /** - * If an r-value is a reference to a whole variable, get that variable - * - * \return - * Pointer to a variable that is completely dereferenced by the r-value. If - * the r-value is not a dereference or the dereference does not access the - * entire variable (i.e., it's just one array element, struct field), \c NULL - * is returned. - */ - virtual ir_variable *whole_variable_referenced() - { - return NULL; - } - -protected: - ir_rvalue() - { - /* empty */ - } -}; - - -enum ir_variable_mode { - ir_var_auto = 0, - ir_var_uniform, - ir_var_in, - ir_var_out, - ir_var_inout -}; - -enum ir_variable_interpolation { - ir_var_smooth = 0, - ir_var_flat, - ir_var_noperspective -}; - - -class ir_variable : public ir_instruction { -public: - ir_variable(const struct glsl_type *, const char *); - - virtual ir_instruction *clone(struct hash_table *ht) const; - - virtual ir_variable *as_variable() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - - /** - * Get the string value for the interpolation qualifier - * - * \return - * If none of \c shader_in or \c shader_out is set, an empty string will - * be returned. Otherwise the string that would be used in a shader to - * specify \c mode will be returned. - */ - const char *interpolation_string() const; - - /** - * Calculate the number of slots required to hold this variable - * - * This is used to determine how many uniform or varying locations a variable - * occupies. The count is in units of floating point components. - */ - unsigned component_slots() const; - - const char *name; - - /** - * Highest element accessed with a constant expression array index - * - * Not used for non-array variables. - */ - unsigned max_array_access; - - unsigned read_only:1; - unsigned centroid:1; - unsigned invariant:1; - /** If the variable is initialized outside of the scope of the shader */ - unsigned shader_in:1; - /** - * If the variable value is later used outside of the scope of the shader. - */ - unsigned shader_out:1; - - unsigned mode:3; - unsigned interpolation:2; - - /** - * Flag that the whole array is assignable - * - * In GLSL 1.20 and later whole arrays are assignable (and comparable for - * equality). This flag enables this behavior. - */ - unsigned array_lvalue:1; - - /** - * Storage location of the base of this variable - * - * The precise meaning of this field depends on the nature of the variable. - * - * - Vertex shader input: one of the values from \c gl_vert_attrib. - * - Vertex shader output: one of the values from \c gl_vert_result. - * - Fragment shader input: one of the values from \c gl_frag_attrib. - * - Fragment shader output: one of the values from \c gl_frag_result. - * - Uniforms: Per-stage uniform slot number. - * - Other: This field is not currently used. - * - * If the variable is a uniform, shader input, or shader output, and the - * slot has not been assigned, the value will be -1. - */ - int location; - - /** - * Emit a warning if this variable is accessed. - */ - const char *warn_extension; - - /** - * Value assigned in the initializer of a variable declared "const" - */ - ir_constant *constant_value; -}; - - -/*@{*/ -/** - * The representation of a function instance; may be the full definition or - * simply a prototype. - */ -class ir_function_signature : public ir_instruction { - /* An ir_function_signature will be part of the list of signatures in - * an ir_function. - */ -public: - ir_function_signature(const glsl_type *return_type); - - virtual ir_instruction *clone(struct hash_table *ht) const; - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - /** - * Get the name of the function for which this is a signature - */ - const char *function_name() const; - - /** - * Check whether the qualifiers match between this signature's parameters - * and the supplied parameter list. If not, returns the name of the first - * parameter with mismatched qualifiers (for use in error messages). - */ - const char *qualifiers_match(exec_list *params); - - /** - * Replace the current parameter list with the given one. This is useful - * if the current information came from a prototype, and either has invalid - * or missing parameter names. - */ - void replace_parameters(exec_list *new_params); - - /** - * Function return type. - * - * \note This discards the optional precision qualifier. - */ - const struct glsl_type *return_type; - - /** - * List of ir_variable of function parameters. - * - * This represents the storage. The paramaters passed in a particular - * call will be in ir_call::actual_paramaters. - */ - struct exec_list parameters; - - /** Whether or not this function has a body (which may be empty). */ - unsigned is_defined:1; - - /** Body of instructions in the function. */ - struct exec_list body; - -private: - /** Function of which this signature is one overload. */ - class ir_function *function; - - friend class ir_function; -}; - - -/** - * Header for tracking multiple overloaded functions with the same name. - * Contains a list of ir_function_signatures representing each of the - * actual functions. - */ -class ir_function : public ir_instruction { -public: - ir_function(const char *name); - - virtual ir_instruction *clone(struct hash_table *ht) const; - - virtual ir_function *as_function() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - void add_signature(ir_function_signature *sig) - { - sig->function = this; - signatures.push_tail(sig); - } - - /** - * Get an iterator for the set of function signatures - */ - exec_list_iterator iterator() - { - return signatures.iterator(); - } - - /** - * Find a signature that matches a set of actual parameters, taking implicit - * conversions into account. - */ - const ir_function_signature *matching_signature(exec_list *actual_param); - - /** - * Find a signature that exactly matches a set of actual parameters without - * any implicit type conversions. - */ - ir_function_signature *exact_matching_signature(exec_list *actual_ps); - - /** - * Name of the function. - */ - const char *name; - -private: - /** - * List of ir_function_signature for each overloaded function with this name. - */ - struct exec_list signatures; -}; - -inline const char *ir_function_signature::function_name() const -{ - return function->name; -} -/*@}*/ - - -/** - * IR instruction representing high-level if-statements - */ -class ir_if : public ir_instruction { -public: - ir_if(ir_rvalue *condition) - : condition(condition) - { - /* empty */ - } - - virtual ir_instruction *clone(struct hash_table *ht) const; - - virtual ir_if *as_if() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - ir_rvalue *condition; - /** List of ir_instruction for the body of the then branch */ - exec_list then_instructions; - /** List of ir_instruction for the body of the else branch */ - exec_list else_instructions; -}; - - -/** - * IR instruction representing a high-level loop structure. - */ -class ir_loop : public ir_instruction { -public: - ir_loop() : from(NULL), to(NULL), increment(NULL), counter(NULL) - { - /* empty */ - } - - virtual ir_instruction *clone(struct hash_table *ht) const; - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - virtual ir_loop *as_loop() - { - return this; - } - - /** - * Get an iterator for the instructions of the loop body - */ - exec_list_iterator iterator() - { - return body_instructions.iterator(); - } - - /** List of ir_instruction that make up the body of the loop. */ - exec_list body_instructions; - - /** - * \name Loop counter and controls - */ - /*@{*/ - ir_rvalue *from; - ir_rvalue *to; - ir_rvalue *increment; - ir_variable *counter; - /*@}*/ -}; - - -class ir_assignment : public ir_rvalue { -public: - ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); - - virtual ir_instruction *clone(struct hash_table *ht) const; - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - virtual ir_assignment * as_assignment() - { - return this; - } - - /** - * Left-hand side of the assignment. - */ - ir_rvalue *lhs; - - /** - * Value being assigned - */ - ir_rvalue *rhs; - - /** - * Optional condition for the assignment. - */ - ir_rvalue *condition; -}; - -/* Update ir_expression::num_operands() and operator_strs when - * updating this list. - */ -enum ir_expression_operation { - ir_unop_bit_not, - ir_unop_logic_not, - ir_unop_neg, - ir_unop_abs, - ir_unop_sign, - ir_unop_rcp, - ir_unop_rsq, - ir_unop_sqrt, - ir_unop_exp, - ir_unop_log, - ir_unop_exp2, - ir_unop_log2, - ir_unop_f2i, /**< Float-to-integer conversion. */ - ir_unop_i2f, /**< Integer-to-float conversion. */ - ir_unop_f2b, /**< Float-to-boolean conversion */ - ir_unop_b2f, /**< Boolean-to-float conversion */ - ir_unop_i2b, /**< int-to-boolean conversion */ - ir_unop_b2i, /**< Boolean-to-int conversion */ - ir_unop_u2f, /**< Unsigned-to-float conversion. */ - - /** - * \name Unary floating-point rounding operations. - */ - /*@{*/ - ir_unop_trunc, - ir_unop_ceil, - ir_unop_floor, - /*@}*/ - - /** - * \name Trigonometric operations. - */ - /*@{*/ - ir_unop_sin, - ir_unop_cos, - /*@}*/ - - /** - * \name Partial derivatives. - */ - /*@{*/ - ir_unop_dFdx, - ir_unop_dFdy, - /*@}*/ - - ir_binop_add, - ir_binop_sub, - ir_binop_mul, - ir_binop_div, - ir_binop_mod, - - /** - * \name Binary comparison operators - */ - /*@{*/ - ir_binop_less, - ir_binop_greater, - ir_binop_lequal, - ir_binop_gequal, - ir_binop_equal, - ir_binop_nequal, - /*@}*/ - - /** - * \name Bit-wise binary operations. - */ - /*@{*/ - ir_binop_lshift, - ir_binop_rshift, - ir_binop_bit_and, - ir_binop_bit_xor, - ir_binop_bit_or, - /*@}*/ - - ir_binop_logic_and, - ir_binop_logic_xor, - ir_binop_logic_or, - - ir_binop_dot, - ir_binop_min, - ir_binop_max, - - ir_binop_pow -}; - -class ir_expression : public ir_rvalue { -public: - ir_expression(int op, const struct glsl_type *type, - ir_rvalue *, ir_rvalue *); - - virtual ir_instruction *clone(struct hash_table *ht) const; - - static unsigned int get_num_operands(ir_expression_operation); - unsigned int get_num_operands() const - { - return get_num_operands(operation); - } - - /** - * Return a string representing this expression's operator. - */ - const char *operator_string(); - - /** - * Do a reverse-lookup to translate the given string into an operator. - */ - static ir_expression_operation get_operator(const char *); - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - ir_expression_operation operation; - ir_rvalue *operands[2]; -}; - - -/** - * IR instruction representing a function call - */ -class ir_call : public ir_rvalue { -public: - ir_call(const ir_function_signature *callee, exec_list *actual_parameters) - : callee(callee) - { - assert(callee->return_type != NULL); - type = callee->return_type; - actual_parameters->move_nodes_to(& this->actual_parameters); - } - - virtual ir_instruction *clone(struct hash_table *ht) const; - - virtual ir_call *as_call() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - /** - * Get a generic ir_call object when an error occurs - * - * Any allocation will be performed with 'ctx' as talloc owner. - */ - static ir_call *get_error_instruction(void *ctx); - - /** - * Get an iterator for the set of acutal parameters - */ - exec_list_iterator iterator() - { - return actual_parameters.iterator(); - } - - /** - * Get the name of the function being called. - */ - const char *callee_name() const - { - return callee->function_name(); - } - - const ir_function_signature *get_callee() - { - return callee; - } - - /** - * Generates an inline version of the function before @ir, - * returning the return value of the function. - */ - ir_rvalue *generate_inline(ir_instruction *ir); - -private: - ir_call() - : callee(NULL) - { - /* empty */ - } - - const ir_function_signature *callee; - - /* List of ir_rvalue of paramaters passed in this call. */ - exec_list actual_parameters; -}; - - -/** - * \name Jump-like IR instructions. - * - * These include \c break, \c continue, \c return, and \c discard. - */ -/*@{*/ -class ir_jump : public ir_instruction { -protected: - ir_jump() - { - /* empty */ - } -}; - -class ir_return : public ir_jump { -public: - ir_return() - : value(NULL) - { - /* empty */ - } - - ir_return(ir_rvalue *value) - : value(value) - { - /* empty */ - } - - virtual ir_instruction *clone(struct hash_table *) const; - - virtual ir_return *as_return() - { - return this; - } - - ir_rvalue *get_value() const - { - return value; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - ir_rvalue *value; -}; - - -/** - * Jump instructions used inside loops - * - * These include \c break and \c continue. The \c break within a loop is - * different from the \c break within a switch-statement. - * - * \sa ir_switch_jump - */ -class ir_loop_jump : public ir_jump { -public: - enum jump_mode { - jump_break, - jump_continue - }; - - ir_loop_jump(jump_mode mode) - { - this->mode = mode; - this->loop = loop; - } - - virtual ir_instruction *clone(struct hash_table *) const; - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - bool is_break() const - { - return mode == jump_break; - } - - bool is_continue() const - { - return mode == jump_continue; - } - - /** Mode selector for the jump instruction. */ - enum jump_mode mode; -private: - /** Loop containing this break instruction. */ - ir_loop *loop; -}; -/*@}*/ - - -/** - * Texture sampling opcodes used in ir_texture - */ -enum ir_texture_opcode { - ir_tex, /* Regular texture look-up */ - ir_txb, /* Texture look-up with LOD bias */ - ir_txl, /* Texture look-up with explicit LOD */ - ir_txd, /* Texture look-up with partial derivatvies */ - ir_txf /* Texel fetch with explicit LOD */ -}; - - -/** - * IR instruction to sample a texture - * - * The specific form of the IR instruction depends on the \c mode value - * selected from \c ir_texture_opcodes. In the printed IR, these will - * appear as: - * - * Texel offset - * | Projection divisor - * | | Shadow comparitor - * | | | - * v v v - * (tex (sampler) (coordinate) (0 0 0) (1) ( )) - * (txb (sampler) (coordinate) (0 0 0) (1) ( ) (bias)) - * (txl (sampler) (coordinate) (0 0 0) (1) ( ) (lod)) - * (txd (sampler) (coordinate) (0 0 0) (1) ( ) (dPdx dPdy)) - * (txf (sampler) (coordinate) (0 0 0) (lod)) - */ -class ir_texture : public ir_rvalue { -public: - ir_texture(enum ir_texture_opcode op) - : op(op), projector(NULL), shadow_comparitor(NULL) - { - /* empty */ - } - - virtual ir_instruction *clone(struct hash_table *) const; - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - /** - * Return a string representing the ir_texture_opcode. - */ - const char *opcode_string(); - - /** Set the sampler and infer the type. */ - void set_sampler(ir_dereference *sampler); - - /** - * Do a reverse-lookup to translate a string into an ir_texture_opcode. - */ - static ir_texture_opcode get_opcode(const char *); - - enum ir_texture_opcode op; - - /** Sampler to use for the texture access. */ - ir_dereference *sampler; - - /** Texture coordinate to sample */ - ir_rvalue *coordinate; - - /** - * Value used for projective divide. - * - * If there is no projective divide (the common case), this will be - * \c NULL. Optimization passes should check for this to point to a constant - * of 1.0 and replace that with \c NULL. - */ - ir_rvalue *projector; - - /** - * Coordinate used for comparison on shadow look-ups. - * - * If there is no shadow comparison, this will be \c NULL. For the - * \c ir_txf opcode, this *must* be \c NULL. - */ - ir_rvalue *shadow_comparitor; - - /** Explicit texel offsets. */ - signed char offsets[3]; - - union { - ir_rvalue *lod; /**< Floating point LOD */ - ir_rvalue *bias; /**< Floating point LOD bias */ - struct { - ir_rvalue *dPdx; /**< Partial derivative of coordinate wrt X */ - ir_rvalue *dPdy; /**< Partial derivative of coordinate wrt Y */ - } grad; - } lod_info; -}; - - -struct ir_swizzle_mask { - unsigned x:2; - unsigned y:2; - unsigned z:2; - unsigned w:2; - - /** - * Number of components in the swizzle. - */ - unsigned num_components:3; - - /** - * Does the swizzle contain duplicate components? - * - * L-value swizzles cannot contain duplicate components. - */ - unsigned has_duplicates:1; -}; - - -class ir_swizzle : public ir_rvalue { -public: - ir_swizzle(ir_rvalue *, unsigned x, unsigned y, unsigned z, unsigned w, - unsigned count); - ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask); - - virtual ir_instruction *clone(struct hash_table *) const; - - virtual ir_swizzle *as_swizzle() - { - return this; - } - - /** - * Construct an ir_swizzle from the textual representation. Can fail. - */ - static ir_swizzle *create(ir_rvalue *, const char *, unsigned vector_length); - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - bool is_lvalue() - { - return val->is_lvalue() && !mask.has_duplicates; - } - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced(); - - ir_rvalue *val; - ir_swizzle_mask mask; -}; - - -class ir_dereference : public ir_rvalue { -public: - virtual ir_dereference *as_dereference() - { - return this; - } - - bool is_lvalue(); - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() = 0; -}; - - -class ir_dereference_variable : public ir_dereference { -public: - ir_dereference_variable(ir_variable *var); - - virtual ir_instruction *clone(struct hash_table *) const; - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() - { - return this->var; - } - - virtual ir_variable *whole_variable_referenced() - { - /* ir_dereference_variable objects always dereference the entire - * variable. However, if this dereference is dereferenced by anything - * else, the complete deferefernce chain is not a whole-variable - * dereference. This method should only be called on the top most - * ir_rvalue in a dereference chain. - */ - return this->var; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - /** - * Object being dereferenced. - */ - ir_variable *var; -}; - - -class ir_dereference_array : public ir_dereference { -public: - ir_dereference_array(ir_rvalue *value, ir_rvalue *array_index); - - ir_dereference_array(ir_variable *var, ir_rvalue *array_index); - - virtual ir_instruction *clone(struct hash_table *) const; - - virtual ir_dereference_array *as_dereference_array() - { - return this; - } - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() - { - return this->array->variable_referenced(); - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - ir_rvalue *array; - ir_rvalue *array_index; - -private: - void set_array(ir_rvalue *value); -}; - - -class ir_dereference_record : public ir_dereference { -public: - ir_dereference_record(ir_rvalue *value, const char *field); - - ir_dereference_record(ir_variable *var, const char *field); - - virtual ir_instruction *clone(struct hash_table *) const; - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() - { - return this->record->variable_referenced(); - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - ir_rvalue *record; - const char *field; -}; - - -/** - * Data stored in an ir_constant - */ -union ir_constant_data { - unsigned u[16]; - int i[16]; - float f[16]; - bool b[16]; -}; - - -class ir_constant : public ir_rvalue { -public: - ir_constant(const struct glsl_type *type, const ir_constant_data *data); - ir_constant(bool b); - ir_constant(unsigned int u); - ir_constant(int i); - ir_constant(float f); - - /** - * Construct an ir_constant from a list of ir_constant values - */ - ir_constant(const struct glsl_type *type, exec_list *values); - - /** - * Construct an ir_constant from a scalar component of another ir_constant - * - * The new \c ir_constant inherits the type of the component from the - * source constant. - * - * \note - * In the case of a matrix constant, the new constant is a scalar, \b not - * a vector. - */ - ir_constant(const ir_constant *c, unsigned i); - - virtual ir_instruction *clone(struct hash_table *) const; - - virtual ir_constant *as_constant() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - /** - * Get a particular component of a constant as a specific type - * - * This is useful, for example, to get a value from an integer constant - * as a float or bool. This appears frequently when constructors are - * called with all constant parameters. - */ - /*@{*/ - bool get_bool_component(unsigned i) const; - float get_float_component(unsigned i) const; - int get_int_component(unsigned i) const; - unsigned get_uint_component(unsigned i) const; - /*@}*/ - - ir_constant *get_record_field(const char *name); - - /** - * Determine whether a constant has the same value as another constant - */ - bool has_value(const ir_constant *) const; - - /** - * Value of the constant. - * - * The field used to back the values supplied by the constant is determined - * by the type associated with the \c ir_instruction. Constants may be - * scalars, vectors, or matrices. - */ - union ir_constant_data value; - - exec_list components; - -private: - /** - * Parameterless constructor only used by the clone method - */ - ir_constant(void); -}; - -void -visit_exec_list(exec_list *list, ir_visitor *visitor); - -void validate_ir_tree(exec_list *instructions); - -extern void -_mesa_glsl_initialize_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - -extern void -_mesa_glsl_initialize_functions(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - -#endif /* IR_H */ diff --git a/ir_basic_block.cpp b/ir_basic_block.cpp deleted file mode 100644 index f9953ea42da..00000000000 --- a/ir_basic_block.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_basic_block.cpp - * - * Basic block analysis of instruction streams. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_basic_block.h" -#include "glsl_types.h" - -class ir_has_call_visitor : public ir_hierarchical_visitor { -public: - ir_has_call_visitor() - { - has_call = false; - } - - virtual ir_visitor_status visit_enter(ir_call *ir) - { - (void) ir; - has_call = true; - return visit_stop; - } - - bool has_call; -}; - -/** - * Calls a user function for every basic block in the instruction stream. - * - * Basic block analysis is pretty easy in our IR thanks to the lack of - * unstructured control flow. We've got: - * - * ir_loop (for () {}, while () {}, do {} while ()) - * ir_loop_jump ( - * ir_if () {} - * ir_return - * ir_call() - * - * Note that the basic blocks returned by this don't encompass all - * operations performed by the program -- for example, if conditions - * don't get returned, nor do the assignments that will be generated - * for ir_call parameters. - */ -void call_for_basic_blocks(exec_list *instructions, - void (*callback)(ir_instruction *first, - ir_instruction *last, - void *data), - void *data) -{ - ir_instruction *leader = NULL; - ir_instruction *last = NULL; - - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_if *ir_if; - ir_loop *ir_loop; - ir_function *ir_function; - - if (!leader) - leader = ir; - - if ((ir_if = ir->as_if())) { - callback(leader, ir, data); - leader = NULL; - - call_for_basic_blocks(&ir_if->then_instructions, callback, data); - call_for_basic_blocks(&ir_if->else_instructions, callback, data); - } else if ((ir_loop = ir->as_loop())) { - callback(leader, ir, data); - leader = NULL; - call_for_basic_blocks(&ir_loop->body_instructions, callback, data); - } else if (ir->as_return() || ir->as_call()) { - callback(leader, ir, data); - leader = NULL; - } else if ((ir_function = ir->as_function())) { - /* A function definition doesn't interrupt our basic block - * since execution doesn't go into it. We should process the - * bodies of its signatures for BBs, though. - * - * Note that we miss an opportunity for producing more - * maximal BBs between the instructions that precede main() - * and the body of main(). Perhaps those instructions ought - * to live inside of main(). - */ - foreach_iter(exec_list_iterator, fun_iter, *ir_function) { - ir_function_signature *ir_sig; - - ir_sig = (ir_function_signature *)fun_iter.get(); - - call_for_basic_blocks(&ir_sig->body, callback, data); - } - } else if (ir->as_assignment()) { - ir_has_call_visitor v; - - /* If there's a call in the expression tree being assigned, - * then that ends the BB too. - * - * The assumption is that any consumer of the basic block - * walker is fine with the fact that the call is somewhere in - * the tree even if portions of the tree may be evaluated - * after the call. - * - * A consumer that has an issue with this could not process - * the last instruction of the basic block. If doing so, - * expression flattener may be useful before using the basic - * block finder to get more maximal basic blocks out. - */ - ir->accept(&v); - if (v.has_call) { - callback(leader, ir, data); - leader = NULL; - } - } - last = ir; - } - if (leader) { - callback(leader, last, data); - } -} diff --git a/ir_basic_block.h b/ir_basic_block.h deleted file mode 100644 index dbd678b5c4f..00000000000 --- a/ir_basic_block.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -void call_for_basic_blocks(exec_list *instructions, - void (*callback)(ir_instruction *first, - ir_instruction *last, - void *data), - void *data); diff --git a/ir_clone.cpp b/ir_clone.cpp deleted file mode 100644 index 84176383fca..00000000000 --- a/ir_clone.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include "ir.h" -#include "glsl_types.h" -#include "hash_table.h" - -/** - * Duplicate an IR variable - * - * \note - * This will probably be made \c virtual and moved to the base class - * eventually. - */ -ir_instruction * -ir_variable::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - ir_variable *var = new(ctx) ir_variable(type, name); - - var->max_array_access = this->max_array_access; - var->read_only = this->read_only; - var->centroid = this->centroid; - var->invariant = this->invariant; - var->mode = this->mode; - var->interpolation = this->interpolation; - - if (ht) { - hash_table_insert(ht, var, (void *)const_cast(this)); - } - - return var; -} - -ir_instruction * -ir_swizzle::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - return new(ctx) ir_swizzle((ir_rvalue *)this->val->clone(ht), this->mask); -} - -ir_instruction * -ir_return::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - ir_rvalue *new_value = NULL; - - if (this->value) - new_value = (ir_rvalue *)this->value->clone(ht); - - return new(ctx) ir_return(new_value); -} - -ir_instruction * -ir_loop_jump::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - (void)ht; - - return new(ctx) ir_loop_jump(this->mode); -} - -ir_instruction * -ir_if::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - ir_if *new_if = new(ctx) ir_if((ir_rvalue *)this->condition->clone(ht)); - - foreach_iter(exec_list_iterator, iter, this->then_instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - new_if->then_instructions.push_tail(ir->clone(ht)); - } - - foreach_iter(exec_list_iterator, iter, this->else_instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - new_if->else_instructions.push_tail(ir->clone(ht)); - } - - return new_if; -} - -ir_instruction * -ir_loop::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - ir_loop *new_loop = new(ctx) ir_loop(); - - if (this->from) - new_loop->from = (ir_rvalue *)this->from->clone(ht); - if (this->to) - new_loop->to = (ir_rvalue *)this->to->clone(ht); - if (this->increment) - new_loop->increment = (ir_rvalue *)this->increment->clone(ht); - new_loop->counter = counter; - - foreach_iter(exec_list_iterator, iter, this->body_instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - new_loop->body_instructions.push_tail(ir->clone(ht)); - } - - return new_loop; -} - -ir_instruction * -ir_call::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - exec_list new_parameters; - - foreach_iter(exec_list_iterator, iter, this->actual_parameters) { - ir_instruction *ir = (ir_instruction *)iter.get(); - new_parameters.push_tail(ir->clone(ht)); - } - - return new(ctx) ir_call(this->callee, &new_parameters); -} - -ir_instruction * -ir_expression::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - ir_rvalue *op[2] = {NULL, NULL}; - unsigned int i; - - for (i = 0; i < get_num_operands(); i++) { - op[i] = (ir_rvalue *)this->operands[i]->clone(ht); - } - - return new(ctx) ir_expression(this->operation, this->type, op[0], op[1]); -} - -ir_instruction * -ir_dereference_variable::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - ir_variable *new_var; - - if (ht) { - new_var = (ir_variable *)hash_table_find(ht, this->var); - if (!new_var) - new_var = this->var; - } else { - new_var = this->var; - } - - return new(ctx) ir_dereference_variable(new_var); -} - -ir_instruction * -ir_dereference_array::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - return new(ctx) ir_dereference_array((ir_rvalue *)this->array->clone(ht), - (ir_rvalue *)this->array_index->clone(ht)); -} - -ir_instruction * -ir_dereference_record::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - return new(ctx) ir_dereference_record((ir_rvalue *)this->record->clone(ht), - this->field); -} - -ir_instruction * -ir_texture::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - ir_texture *new_tex = new(ctx) ir_texture(this->op); - - new_tex->sampler = (ir_dereference *)this->sampler->clone(ht); - new_tex->coordinate = (ir_rvalue *)this->coordinate->clone(ht); - if (this->projector) - new_tex->projector = (ir_rvalue *)this->projector->clone(ht); - if (this->shadow_comparitor) { - new_tex->shadow_comparitor = - (ir_rvalue *)this->shadow_comparitor->clone(ht); - } - - for (int i = 0; i < 3; i++) - new_tex->offsets[i] = this->offsets[i]; - - switch (this->op) { - case ir_tex: - break; - case ir_txb: - new_tex->lod_info.bias = (ir_rvalue *)this->lod_info.bias->clone(ht); - break; - case ir_txl: - case ir_txf: - new_tex->lod_info.lod = (ir_rvalue *)this->lod_info.lod->clone(ht); - break; - case ir_txd: - new_tex->lod_info.grad.dPdx = - (ir_rvalue *)this->lod_info.grad.dPdx->clone(ht); - new_tex->lod_info.grad.dPdy = - (ir_rvalue *)this->lod_info.grad.dPdy->clone(ht); - break; - } - - return new_tex; -} - -ir_instruction * -ir_assignment::clone(struct hash_table *ht) const -{ - ir_rvalue *new_condition = NULL; - - if (this->condition) - new_condition = (ir_rvalue *)this->condition->clone(ht); - - void *ctx = talloc_parent(this); - return new(ctx) ir_assignment((ir_rvalue *)this->lhs->clone(ht), - (ir_rvalue *)this->rhs->clone(ht), - new_condition); -} - -ir_instruction * -ir_function::clone(struct hash_table *ht) const -{ - (void)ht; - /* FINISHME */ - abort(); -} - -ir_instruction * -ir_function_signature::clone(struct hash_table *ht) const -{ - (void)ht; - /* FINISHME */ - abort(); -} - -ir_instruction * -ir_constant::clone(struct hash_table *ht) const -{ - void *ctx = talloc_parent(this); - (void)ht; - - switch (this->type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_BOOL: - return new(ctx) ir_constant(this->type, &this->value); - - case GLSL_TYPE_STRUCT: { - ir_constant *c = new(ctx) ir_constant; - - c->type = this->type; - for (exec_node *node = this->components.head - ; !node->is_tail_sentinal() - ; node = node->next) { - ir_constant *const orig = (ir_constant *) node; - - c->components.push_tail(orig->clone(NULL)); - } - - return c; - } - - default: - assert(!"Should not get here."); break; - return NULL; - } -} diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp deleted file mode 100644 index 3408f5256a7..00000000000 --- a/ir_constant_expression.cpp +++ /dev/null @@ -1,671 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_constant_expression.cpp - * Evaluate and process constant valued expressions - * - * In GLSL, constant valued expressions are used in several places. These - * must be processed and evaluated very early in the compilation process. - * - * * Sizes of arrays - * * Initializers for uniforms - * * Initializers for \c const variables - */ - -#include -#include "ir.h" -#include "ir_visitor.h" -#include "glsl_types.h" - -/** - * Visitor class for evaluating constant expressions - */ -class ir_constant_visitor : public ir_visitor { -public: - ir_constant_visitor() - : value(NULL) - { - /* empty */ - } - - virtual ~ir_constant_visitor() - { - /* empty */ - } - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_texture *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - /*@}*/ - - /** - * Value of the constant expression. - * - * \note - * This field will be \c NULL if the expression is not constant valued. - */ - /* FINIHSME: This cannot hold values for constant arrays or structures. */ - ir_constant *value; -}; - - -ir_constant * -ir_instruction::constant_expression_value() -{ - ir_constant_visitor visitor; - - this->accept(& visitor); - return visitor.value; -} - - -void -ir_constant_visitor::visit(ir_variable *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_function_signature *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_function *ir) -{ - (void) ir; - value = NULL; -} - -void -ir_constant_visitor::visit(ir_expression *ir) -{ - value = NULL; - ir_constant *op[2]; - unsigned int operand, c; - ir_constant_data data; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - op[operand] = ir->operands[operand]->constant_expression_value(); - if (!op[operand]) - return; - } - - switch (ir->operation) { - case ir_unop_logic_not: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) - data.b[c] = !op[0]->value.b[c]; - break; - - case ir_unop_f2i: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - data.i[c] = op[0]->value.f[c]; - } - break; - case ir_unop_i2f: - assert(op[0]->type->base_type == GLSL_TYPE_UINT || - op[0]->type->base_type == GLSL_TYPE_INT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - if (op[0]->type->base_type == GLSL_TYPE_INT) - data.f[c] = op[0]->value.i[c]; - else - data.f[c] = op[0]->value.u[c]; - } - break; - case ir_unop_b2f: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - data.f[c] = op[0]->value.b[c] ? 1.0 : 0.0; - } - break; - case ir_unop_f2b: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - data.b[c] = bool(op[0]->value.f[c]); - } - break; - case ir_unop_b2i: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - data.u[c] = op[0]->value.b[c] ? 1 : 0; - } - break; - case ir_unop_i2b: - assert(op[0]->type->is_integer()); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - data.b[c] = bool(op[0]->value.u[c]); - } - break; - - case ir_unop_neg: - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = -op[0]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[c] = -op[0]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = -op[0]->value.f[c]; - break; - default: - assert(0); - } - } - break; - - case ir_unop_abs: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c]; - if (data.i[c] < 0) - data.i[c] = -data.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = fabs(op[0]->value.f[c]); - break; - default: - assert(0); - } - } - break; - - case ir_unop_rcp: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->type->base_type) { - case GLSL_TYPE_UINT: - if (op[0]->value.u[c] != 0.0) - data.u[c] = 1 / op[0]->value.u[c]; - break; - case GLSL_TYPE_INT: - if (op[0]->value.i[c] != 0.0) - data.i[c] = 1 / op[0]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - if (op[0]->value.f[c] != 0.0) - data.f[c] = 1.0 / op[0]->value.f[c]; - break; - default: - assert(0); - } - } - break; - - case ir_unop_rsq: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - data.f[c] = 1.0 / sqrtf(op[0]->value.f[c]); - } - break; - - case ir_unop_sqrt: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - data.f[c] = sqrtf(op[0]->value.f[c]); - } - break; - - case ir_unop_exp: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - data.f[c] = expf(op[0]->value.f[c]); - } - break; - - case ir_unop_log: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - data.f[c] = logf(op[0]->value.f[c]); - } - break; - - case ir_unop_dFdx: - case ir_unop_dFdy: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { - data.f[c] = 0.0; - } - break; - - case ir_binop_add: - if (ir->operands[0]->type == ir->operands[1]->type) { - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c] + op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c] + op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c] + op[1]->value.f[c]; - break; - default: - assert(0); - } - } - } else - /* FINISHME: Support operations with non-equal types. */ - return; - - break; - case ir_binop_sub: - if (ir->operands[0]->type == ir->operands[1]->type) { - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c] - op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c] - op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c] - op[1]->value.f[c]; - break; - default: - assert(0); - } - } - } else - /* FINISHME: Support operations with non-equal types. */ - return; - - break; - case ir_binop_mul: - if (ir->operands[0]->type == ir->operands[1]->type && - !ir->operands[0]->type->is_matrix()) { - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c] * op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c] * op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c] * op[1]->value.f[c]; - break; - default: - assert(0); - } - } - } else - /* FINISHME: Support operations with non-equal types. */ - return; - - break; - case ir_binop_div: - if (ir->operands[0]->type == ir->operands[1]->type) { - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c] / op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c] / op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c] / op[1]->value.f[c]; - break; - default: - assert(0); - } - } - } else - /* FINISHME: Support operations with non-equal types. */ - return; - - break; - case ir_binop_logic_and: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) - data.b[c] = op[0]->value.b[c] && op[1]->value.b[c]; - break; - case ir_binop_logic_xor: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) - data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c]; - break; - case ir_binop_logic_or: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) - data.b[c] = op[0]->value.b[c] || op[1]->value.b[c]; - break; - - case ir_binop_less: - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[0] = op[0]->value.u[0] < op[1]->value.u[0]; - break; - case GLSL_TYPE_INT: - data.b[0] = op[0]->value.i[0] < op[1]->value.i[0]; - break; - case GLSL_TYPE_FLOAT: - data.b[0] = op[0]->value.f[0] < op[1]->value.f[0]; - break; - default: - assert(0); - } - break; - case ir_binop_greater: - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[0] = op[0]->value.u[0] > op[1]->value.u[0]; - break; - case GLSL_TYPE_INT: - data.b[0] = op[0]->value.i[0] > op[1]->value.i[0]; - break; - case GLSL_TYPE_FLOAT: - data.b[0] = op[0]->value.f[0] > op[1]->value.f[0]; - break; - default: - assert(0); - } - break; - case ir_binop_lequal: - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0]; - break; - case GLSL_TYPE_INT: - data.b[0] = op[0]->value.i[0] <= op[1]->value.i[0]; - break; - case GLSL_TYPE_FLOAT: - data.b[0] = op[0]->value.f[0] <= op[1]->value.f[0]; - break; - default: - assert(0); - } - break; - case ir_binop_gequal: - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0]; - break; - case GLSL_TYPE_INT: - data.b[0] = op[0]->value.i[0] >= op[1]->value.i[0]; - break; - case GLSL_TYPE_FLOAT: - data.b[0] = op[0]->value.f[0] >= op[1]->value.f[0]; - break; - default: - assert(0); - } - break; - - case ir_binop_equal: - data.b[0] = true; - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[0] = data.b[0] && op[0]->value.u[c] == op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[0] = data.b[0] && op[0]->value.i[c] == op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[0] = data.b[0] && op[0]->value.f[c] == op[1]->value.f[c]; - break; - case GLSL_TYPE_BOOL: - data.b[0] = data.b[0] && op[0]->value.b[c] == op[1]->value.b[c]; - break; - default: - assert(0); - } - } - break; - case ir_binop_nequal: - data.b[0] = false; - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[0] = data.b[0] || op[0]->value.u[c] != op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[0] = data.b[0] || op[0]->value.i[c] != op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[0] = data.b[0] || op[0]->value.f[c] != op[1]->value.f[c]; - break; - case GLSL_TYPE_BOOL: - data.b[0] = data.b[0] || op[0]->value.b[c] != op[1]->value.b[c]; - break; - default: - assert(0); - } - } - break; - - default: - /* FINISHME: Should handle all expression types. */ - return; - } - - void *ctx = talloc_parent(ir); - this->value = new(ctx) ir_constant(ir->type, &data); -} - - -void -ir_constant_visitor::visit(ir_texture *ir) -{ - // FINISHME: Do stuff with texture lookups - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_swizzle *ir) -{ - ir_constant *v = ir->val->constant_expression_value(); - - this->value = NULL; - - if (v != NULL) { - ir_constant_data data; - - const unsigned swiz_idx[4] = { - ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w - }; - - for (unsigned i = 0; i < ir->mask.num_components; i++) { - switch (v->type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break; - case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break; - case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break; - default: assert(!"Should not get here."); break; - } - } - - void *ctx = talloc_parent(ir); - this->value = new(ctx) ir_constant(ir->type, &data); - } -} - - -void -ir_constant_visitor::visit(ir_dereference_variable *ir) -{ - value = NULL; - - ir_variable *var = ir->variable_referenced(); - if (var && var->constant_value) - value = (ir_constant *)var->constant_value->clone(NULL); -} - - -void -ir_constant_visitor::visit(ir_dereference_array *ir) -{ - void *ctx = talloc_parent(ir); - ir_constant *array = ir->array->constant_expression_value(); - ir_constant *idx = ir->array_index->constant_expression_value(); - - this->value = NULL; - - if ((array != NULL) && (idx != NULL)) { - if (array->type->is_matrix()) { - /* Array access of a matrix results in a vector. - */ - const unsigned column = idx->value.u[0]; - - const glsl_type *const column_type = array->type->column_type(); - - /* Offset in the constant matrix to the first element of the column - * to be extracted. - */ - const unsigned mat_idx = column * column_type->vector_elements; - - ir_constant_data data; - - switch (column_type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - for (unsigned i = 0; i < column_type->vector_elements; i++) - data.u[i] = array->value.u[mat_idx + i]; - - break; - - case GLSL_TYPE_FLOAT: - for (unsigned i = 0; i < column_type->vector_elements; i++) - data.f[i] = array->value.f[mat_idx + i]; - - break; - - default: - assert(!"Should not get here."); - break; - } - - this->value = new(ctx) ir_constant(column_type, &data); - } else if (array->type->is_vector()) { - const unsigned component = idx->value.u[0]; - - this->value = new(ctx) ir_constant(array, component); - } else { - /* FINISHME: Handle access of constant arrays. */ - } - } -} - - -void -ir_constant_visitor::visit(ir_dereference_record *ir) -{ - ir_constant *v = ir->record->constant_expression_value(); - - this->value = (v != NULL) ? v->get_record_field(ir->field) : NULL; -} - - -void -ir_constant_visitor::visit(ir_assignment *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_constant *ir) -{ - value = ir; -} - - -void -ir_constant_visitor::visit(ir_call *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_return *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_if *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_loop *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_loop_jump *ir) -{ - (void) ir; - value = NULL; -} diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp deleted file mode 100644 index 342d027bbe8..00000000000 --- a/ir_constant_folding.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_constant_folding.cpp - * Replace constant-valued expressions with references to constant values. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -/** - * Visitor class for replacing expressions with ir_constant values. - */ - -class ir_constant_folding_visitor : public ir_visitor { -public: - ir_constant_folding_visitor() - { - /* empty */ - } - - virtual ~ir_constant_folding_visitor() - { - /* empty */ - } - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_texture *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - /*@}*/ -}; - -void -ir_constant_folding_visitor::visit(ir_variable *ir) -{ - (void) ir; -} - - -void -ir_constant_folding_visitor::visit(ir_function_signature *ir) -{ - visit_exec_list(&ir->body, this); -} - - -void -ir_constant_folding_visitor::visit(ir_function *ir) -{ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_function_signature *const sig = (ir_function_signature *) iter.get(); - sig->accept(this); - } -} - -void -ir_constant_folding_visitor::visit(ir_expression *ir) -{ - ir_constant *op[2]; - unsigned int operand; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - op[operand] = ir->operands[operand]->constant_expression_value(); - if (op[operand]) { - ir->operands[operand] = op[operand]; - } else { - ir->operands[operand]->accept(this); - } - } -} - - -void -ir_constant_folding_visitor::visit(ir_texture *ir) -{ - // FINISHME: Do stuff with texture lookups - (void) ir; -} - - -void -ir_constant_folding_visitor::visit(ir_swizzle *ir) -{ - ir->val->accept(this); -} - - -void -ir_constant_folding_visitor::visit(ir_dereference_variable *ir) -{ - (void) ir; -} - - -void -ir_constant_folding_visitor::visit(ir_dereference_array *ir) -{ - ir_constant *const_val = - ir->array_index->constant_expression_value(); - - if (const_val) - ir->array_index = const_val; - else - ir->array_index->accept(this); - - ir->array->accept(this); -} - - -void -ir_constant_folding_visitor::visit(ir_dereference_record *ir) -{ - ir->record->accept(this); -} - - -void -ir_constant_folding_visitor::visit(ir_assignment *ir) -{ - ir_constant *const_val = ir->rhs->constant_expression_value(); - if (const_val) - ir->rhs = const_val; - else - ir->rhs->accept(this); -} - - -void -ir_constant_folding_visitor::visit(ir_constant *ir) -{ - (void) ir; -} - - -void -ir_constant_folding_visitor::visit(ir_call *ir) -{ - (void) ir; -} - - -void -ir_constant_folding_visitor::visit(ir_return *ir) -{ - (void) ir; -} - - -void -ir_constant_folding_visitor::visit(ir_if *ir) -{ - ir_constant *const_val = ir->condition->constant_expression_value(); - if (const_val) - ir->condition = const_val; - else - ir->condition->accept(this); - - visit_exec_list(&ir->then_instructions, this); - visit_exec_list(&ir->else_instructions, this); -} - - -void -ir_constant_folding_visitor::visit(ir_loop *ir) -{ - (void) ir; -} - - -void -ir_constant_folding_visitor::visit(ir_loop_jump *ir) -{ - (void) ir; -} - -bool -do_constant_folding(exec_list *instructions) -{ - ir_constant_folding_visitor constant_folding; - - visit_exec_list(instructions, &constant_folding); - - /* FINISHME: Return real progress. */ - return false; -} diff --git a/ir_constant_variable.cpp b/ir_constant_variable.cpp deleted file mode 100644 index ef5e1e418e5..00000000000 --- a/ir_constant_variable.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_constant_variable.cpp - * - * Marks variables assigned a single constant value over the course - * of the program as constant. - * - * The goal here is to trigger further constant folding and then dead - * code elimination. This is common with vector/matrix constructors - * and calls to builtin functions. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -struct assignment_entry { - exec_node link; - int assignment_count; - ir_variable *var; - ir_constant *constval; -}; - -class ir_constant_variable_visitor : public ir_hierarchical_visitor { -public: - virtual ir_visitor_status visit_enter(ir_assignment *); - - exec_list list; -}; - -static struct assignment_entry * -get_assignment_entry(ir_variable *var, exec_list *list) -{ - struct assignment_entry *entry; - - foreach_list_typed(struct assignment_entry, entry, link, list) { - if (entry->var == var) - return entry; - } - - entry = (struct assignment_entry *)calloc(1, sizeof(*entry)); - entry->var = var; - list->push_head(&entry->link); - return entry; -} - -ir_visitor_status -ir_constant_variable_visitor::visit_enter(ir_assignment *ir) -{ - ir_constant *constval; - struct assignment_entry *entry; - - entry = get_assignment_entry(ir->lhs->variable_referenced(), &this->list); - assert(entry); - entry->assignment_count++; - - /* If it's already constant, don't do the work. */ - if (entry->var->constant_value) - return visit_continue; - - /* OK, now find if we actually have all the right conditions for - * this to be a constant value assigned to the var. - */ - if (ir->condition) { - constval = ir->condition->constant_expression_value(); - if (!constval || !constval->value.b[0]) - return visit_continue; - } - - ir_variable *var = ir->lhs->whole_variable_referenced(); - if (!var) - return visit_continue; - - constval = ir->rhs->constant_expression_value(); - if (!constval) - return visit_continue; - - /* Mark this entry as having a constant assignment (if the - * assignment count doesn't go >1). do_constant_variable will fix - * up the variable with the constant value later. - */ - entry->constval = constval; - - return visit_continue; -} - -/** - * Does a copy propagation pass on the code present in the instruction stream. - */ -bool -do_constant_variable(exec_list *instructions) -{ - bool progress = false; - ir_constant_variable_visitor v; - - v.run(instructions); - - while (!v.list.is_empty()) { - - struct assignment_entry *entry; - entry = exec_node_data(struct assignment_entry, v.list.head, link); - - if (entry->assignment_count == 1 && entry->constval) { - entry->var->constant_value = entry->constval; - progress = true; - } - entry->link.remove(); - free(entry); - } - - return progress; -} - -bool -do_constant_variable_unlinked(exec_list *instructions) -{ - bool progress = false; - - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_function *f = ir->as_function(); - if (f) { - foreach_iter(exec_list_iterator, sigiter, *f) { - ir_function_signature *sig = - (ir_function_signature *) sigiter.get(); - if (do_constant_variable(&sig->body)) - progress = true; - } - } - } - - return progress; -} diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp deleted file mode 100644 index 46ef6679d9f..00000000000 --- a/ir_copy_propagation.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_copy_propagation.cpp - * - * Moves usage of recently-copied variables to the previous copy of - * the variable within basic blocks. - * - * This should reduce the number of MOV instructions in the generated - * programs unless copy propagation is also done on the LIR, and may - * help anyway by triggering other optimizations that live in the HIR. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_basic_block.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -class acp_entry : public exec_node -{ -public: - acp_entry(ir_variable *lhs, ir_variable *rhs) - { - assert(lhs); - assert(rhs); - this->lhs = lhs; - this->rhs = rhs; - } - - ir_variable *lhs; - ir_variable *rhs; -}; - -class ir_copy_propagation_visitor : public ir_hierarchical_visitor { -public: - ir_copy_propagation_visitor(exec_list *acp) - { - progress = false; - in_lhs = false; - this->acp = acp; - } - - virtual ir_visitor_status visit(class ir_dereference_variable *); - virtual ir_visitor_status visit_enter(class ir_loop *); - virtual ir_visitor_status visit_enter(class ir_function_signature *); - virtual ir_visitor_status visit_enter(class ir_function *); - virtual ir_visitor_status visit_enter(class ir_assignment *); - virtual ir_visitor_status visit_enter(class ir_call *); - virtual ir_visitor_status visit_enter(class ir_if *); - - /** List of acp_entry */ - exec_list *acp; - bool progress; - - /** Currently in the LHS of an assignment? */ - bool in_lhs; -}; - - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_loop *ir) -{ - (void)ir; - return visit_continue_with_parent; -} - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir) -{ - (void)ir; - return visit_continue_with_parent; -} - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_assignment *ir) -{ - (void) ir; - this->in_lhs = true; - return visit_continue; -} - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_function *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - -/** - * Replaces dereferences of ACP RHS variables with ACP LHS variables. - * - * This is where the actual copy propagation occurs. Note that the - * rewriting of ir_dereference means that the ir_dereference instance - * must not be shared by multiple IR operations! - */ -ir_visitor_status -ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) -{ - /* Ignores the LHS. Don't want to rewrite the LHS to point at some - * other storage! - */ - if (this->in_lhs) { - this->in_lhs = false; - return visit_continue; - } - - ir_variable *var = ir->variable_referenced(); - - foreach_iter(exec_list_iterator, iter, *this->acp) { - acp_entry *entry = (acp_entry *)iter.get(); - - if (var == entry->lhs) { - ir->var = entry->rhs; - this->progress = true; - break; - } - } - - return visit_continue; -} - - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_call *ir) -{ - (void)ir; - - /* Note, if we were to do copy propagation to parameters of calls, we'd - * have to be careful about out params. - */ - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_if *ir) -{ - ir->condition->accept(this); - - /* Do not traverse into the body of the if-statement since that is a - * different basic block. - */ - return visit_continue_with_parent; -} - -static bool -propagate_copies(ir_instruction *ir, exec_list *acp) -{ - ir_copy_propagation_visitor v(acp); - - ir->accept(&v); - - return v.progress; -} - -static void -kill_invalidated_copies(ir_assignment *ir, exec_list *acp) -{ - ir_variable *var = ir->lhs->variable_referenced(); - assert(var != NULL); - - foreach_iter(exec_list_iterator, iter, *acp) { - acp_entry *entry = (acp_entry *)iter.get(); - - if (entry->lhs == var || entry->rhs == var) { - entry->remove(); - } - } -} - -/** - * Adds an entry to the available copy list if it's a plain assignment - * of a variable to a variable. - */ -static void -add_copy(ir_assignment *ir, exec_list *acp) -{ - void *ctx = talloc_parent(ir); - acp_entry *entry; - - if (ir->condition) { - ir_constant *condition = ir->condition->as_constant(); - if (!condition || !condition->value.b[0]) - return; - } - - ir_variable *lhs_var = ir->lhs->whole_variable_referenced(); - ir_variable *rhs_var = ir->rhs->whole_variable_referenced(); - - if ((lhs_var != NULL) && (rhs_var != NULL)) { - entry = new(ctx) acp_entry(lhs_var, rhs_var); - acp->push_tail(entry); - } -} - -static void -copy_propagation_basic_block(ir_instruction *first, - ir_instruction *last, - void *data) -{ - ir_instruction *ir; - /* List of avaialble_copy */ - exec_list acp; - bool *out_progress = (bool *)data; - bool progress = false; - - for (ir = first;; ir = (ir_instruction *)ir->next) { - ir_assignment *ir_assign = ir->as_assignment(); - - progress = propagate_copies(ir, &acp) || progress; - - if (ir_assign) { - kill_invalidated_copies(ir_assign, &acp); - - add_copy(ir_assign, &acp); - } - if (ir == last) - break; - } - *out_progress = progress; -} - -/** - * Does a copy propagation pass on the code present in the instruction stream. - */ -bool -do_copy_propagation(exec_list *instructions) -{ - bool progress = false; - - call_for_basic_blocks(instructions, copy_propagation_basic_block, &progress); - - return progress; -} diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp deleted file mode 100644 index 88213046825..00000000000 --- a/ir_dead_code.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_dead_code.cpp - * - * Eliminates dead assignments and variable declarations from the code. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_expression_flattening.h" -#include "glsl_types.h" - -class variable_entry : public exec_node -{ -public: - variable_entry(ir_variable *var) - { - this->var = var; - assign = NULL; - referenced_count = 0; - assigned_count = 0; - declaration = false; - } - - ir_variable *var; /* The key: the variable's pointer. */ - ir_assignment *assign; /* An assignment to the variable, if any */ - - /** Number of times the variable is referenced, including assignments. */ - unsigned referenced_count; - - /** Number of times the variable is assignmened. */ - unsigned assigned_count; - - bool declaration; /* If the variable had a decl in the instruction stream */ -}; - -class ir_dead_code_visitor : public ir_hierarchical_visitor { -public: - virtual ir_visitor_status visit(ir_variable *); - virtual ir_visitor_status visit(ir_dereference_variable *); - - virtual ir_visitor_status visit_enter(ir_function *); - virtual ir_visitor_status visit_leave(ir_assignment *); - - variable_entry *get_variable_entry(ir_variable *var); - - bool (*predicate)(ir_instruction *ir); - ir_instruction *base_ir; - - /* List of variable_entry */ - exec_list variable_list; -}; - - -variable_entry * -ir_dead_code_visitor::get_variable_entry(ir_variable *var) -{ - assert(var); - foreach_iter(exec_list_iterator, iter, this->variable_list) { - variable_entry *entry = (variable_entry *)iter.get(); - if (entry->var == var) - return entry; - } - - void *ctx = talloc_parent(var); - - variable_entry *entry = new(ctx) variable_entry(var); - this->variable_list.push_tail(entry); - return entry; -} - - -ir_visitor_status -ir_dead_code_visitor::visit(ir_variable *ir) -{ - variable_entry *entry = this->get_variable_entry(ir); - if (entry) - entry->declaration = true; - - return visit_continue; -} - - -ir_visitor_status -ir_dead_code_visitor::visit(ir_dereference_variable *ir) -{ - ir_variable *const var = ir->variable_referenced(); - variable_entry *entry = this->get_variable_entry(var); - - if (entry) - entry->referenced_count++; - - return visit_continue; -} - - -ir_visitor_status -ir_dead_code_visitor::visit_enter(ir_function *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_dead_code_visitor::visit_leave(ir_assignment *ir) -{ - variable_entry *entry; - entry = this->get_variable_entry(ir->lhs->variable_referenced()); - if (entry) { - entry->assigned_count++; - if (entry->assign == NULL) - entry->assign = ir; - } - - return visit_continue; -} - - -/** - * Do a dead code pass over instructions and everything that instructions - * references. - * - * Note that this will remove assignments to globals, so it is not suitable - * for usage on an unlinked instruction stream. - */ -bool -do_dead_code(exec_list *instructions) -{ - ir_dead_code_visitor v; - bool progress = false; - - v.run(instructions); - - foreach_iter(exec_list_iterator, iter, v.variable_list) { - variable_entry *entry = (variable_entry *)iter.get(); - - /* Since each assignment is a reference, the refereneced count must be - * greater than or equal to the assignment count. If they are equal, - * then all of the references are assignments, and the variable is - * dead. - * - * Note that if the variable is neither assigned nor referenced, both - * counts will be zero and will be caught by the equality test. - */ - assert(entry->referenced_count >= entry->assigned_count); - - if ((entry->referenced_count > entry->assigned_count) - || !entry->declaration) - continue; - - if (entry->assign) { - /* Remove a single dead assignment to the variable we found. - * Don't do so if it's a shader output, though. - */ - if (!entry->var->shader_out) { - entry->assign->remove(); - progress = true; - } - } else { - /* If there are no assignments or references to the variable left, - * then we can remove its declaration. - */ - entry->var->remove(); - progress = true; - } - } - return progress; -} - -/** - * Does a dead code pass on the functions present in the instruction stream. - * - * This is suitable for use while the program is not linked, as it will - * ignore variable declarations (and the assignments to them) for variables - * with global scope. - */ -bool -do_dead_code_unlinked(exec_list *instructions) -{ - bool progress = false; - - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_function *f = ir->as_function(); - if (f) { - foreach_iter(exec_list_iterator, sigiter, *f) { - ir_function_signature *sig = - (ir_function_signature *) sigiter.get(); - if (do_dead_code(&sig->body)) - progress = true; - } - } - } - - return progress; -} diff --git a/ir_dead_code_local.cpp b/ir_dead_code_local.cpp deleted file mode 100644 index e01877077c9..00000000000 --- a/ir_dead_code_local.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_dead_code_local.cpp - * - * Eliminates local dead assignments from the code. - * - * This operates on basic blocks, tracking assignments and finding if - * they're used before the variable is completely reassigned. - * - * Compare this to ir_dead_code.cpp, which operates globally looking - * for assignments to variables that are never read. - */ - -#include "ir.h" -#include "ir_basic_block.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -static bool debug = false; - -class assignment_entry : public exec_node -{ -public: - assignment_entry(ir_variable *lhs, ir_instruction *ir) - { - assert(lhs); - assert(ir); - this->lhs = lhs; - this->ir = ir; - } - - ir_variable *lhs; - ir_instruction *ir; -}; - -class kill_for_derefs_visitor : public ir_hierarchical_visitor { -public: - kill_for_derefs_visitor(exec_list *assignments) - { - this->assignments = assignments; - } - - virtual ir_visitor_status visit(ir_dereference_variable *ir) - { - ir_variable *const var = ir->variable_referenced(); - - foreach_iter(exec_list_iterator, iter, *this->assignments) { - assignment_entry *entry = (assignment_entry *)iter.get(); - - if (entry->lhs == var) { - if (debug) - printf("kill %s\n", entry->lhs->name); - entry->remove(); - } - } - - return visit_continue; - } - -private: - exec_list *assignments; -}; - -class array_index_visit : public ir_hierarchical_visitor { -public: - array_index_visit(ir_hierarchical_visitor *v) - { - this->visitor = v; - } - - virtual ir_visitor_status visit_enter(class ir_dereference_array *ir) - { - ir->array_index->accept(visitor); - return visit_continue; - } - - static void run(ir_instruction *ir, ir_hierarchical_visitor *v) - { - array_index_visit top_visit(v); - ir->accept(& top_visit); - } - - ir_hierarchical_visitor *visitor; -}; - - -/** - * Adds an entry to the available copy list if it's a plain assignment - * of a variable to a variable. - */ -static bool -process_assignment(ir_assignment *ir, exec_list *assignments) -{ - void *ctx = talloc_parent(ir); - ir_variable *var = NULL; - bool progress = false; - kill_for_derefs_visitor v(assignments); - - /* Kill assignment entries for things used to produce this assignment. */ - ir->rhs->accept(&v); - if (ir->condition) { - ir->condition->accept(&v); - } - - /* Kill assignment enties used as array indices. - */ - array_index_visit::run(ir->lhs, &v); - var = ir->lhs->variable_referenced(); - assert(var); - - bool always_assign = true; - if (ir->condition) { - ir_constant *condition = ir->condition->as_constant(); - if (!condition || !condition->value.b[0]) - always_assign = false; - } - - /* Now, check if we did a whole-variable assignment. */ - if (always_assign && (ir->lhs->whole_variable_referenced() != NULL)) { - /* We did a whole-variable assignment. So, any instruction in - * the assignment list with the same LHS is dead. - */ - if (debug) - printf("looking for %s to remove\n", var->name); - foreach_iter(exec_list_iterator, iter, *assignments) { - assignment_entry *entry = (assignment_entry *)iter.get(); - - if (entry->lhs == var) { - if (debug) - printf("removing %s\n", var->name); - entry->ir->remove(); - entry->remove(); - progress = true; - } - } - } - - /* Add this instruction to the assignment list. */ - assignment_entry *entry = new(ctx) assignment_entry(var, ir); - assignments->push_tail(entry); - - if (debug) { - printf("add %s\n", var->name); - - printf("current entries\n"); - foreach_iter(exec_list_iterator, iter, *assignments) { - assignment_entry *entry = (assignment_entry *)iter.get(); - - printf(" %s\n", entry->lhs->name); - } - } - - return progress; -} - -static void -dead_code_local_basic_block(ir_instruction *first, - ir_instruction *last, - void *data) -{ - ir_instruction *ir, *ir_next; - /* List of avaialble_copy */ - exec_list assignments; - bool *out_progress = (bool *)data; - bool progress = false; - - /* Safe looping, since process_assignment */ - for (ir = first, ir_next = (ir_instruction *)first->next;; - ir = ir_next, ir_next = (ir_instruction *)ir->next) { - ir_assignment *ir_assign = ir->as_assignment(); - - if (debug) { - ir->print(); - printf("\n"); - } - - if (ir_assign) { - progress = process_assignment(ir_assign, &assignments) || progress; - } else { - kill_for_derefs_visitor kill(&assignments); - ir->accept(&kill); - } - - if (ir == last) - break; - } - *out_progress = progress; -} - -/** - * Does a copy propagation pass on the code present in the instruction stream. - */ -bool -do_dead_code_local(exec_list *instructions) -{ - bool progress = false; - - call_for_basic_blocks(instructions, dead_code_local_basic_block, &progress); - - return progress; -} diff --git a/ir_expression_flattening.cpp b/ir_expression_flattening.cpp deleted file mode 100644 index 5ba24e390b4..00000000000 --- a/ir_expression_flattening.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_expression_flattening.cpp - * - * Takes the leaves of expression trees and makes them dereferences of - * assignments of the leaves to temporaries, according to a predicate. - * - * This is used for automatic function inlining, where we want to take - * an expression containing a call and move the call out to its own - * assignment so that we can inline it at the appropriate place in the - * instruction stream. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_expression_flattening.h" -#include "glsl_types.h" - -class ir_expression_flattening_visitor : public ir_hierarchical_visitor { -public: - ir_expression_flattening_visitor(ir_instruction *base_ir, - bool (*predicate)(ir_instruction *ir)) - { - this->base_ir = base_ir; - this->predicate = predicate; - } - - virtual ~ir_expression_flattening_visitor() - { - /* empty */ - } - - virtual ir_visitor_status visit_enter(ir_call *); - virtual ir_visitor_status visit_enter(ir_return *); - virtual ir_visitor_status visit_enter(ir_function_signature *); - virtual ir_visitor_status visit_enter(ir_if *); - virtual ir_visitor_status visit_enter(ir_loop *); - virtual ir_visitor_status visit_leave(ir_expression *); - virtual ir_visitor_status visit_leave(ir_swizzle *); - - bool (*predicate)(ir_instruction *ir); - ir_instruction *base_ir; -}; - -void -do_expression_flattening(exec_list *instructions, - bool (*predicate)(ir_instruction *ir)) -{ - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - - ir_expression_flattening_visitor v(ir, predicate); - ir->accept(&v); - } -} - - -static ir_rvalue * -operand_to_temp(ir_instruction *base_ir, ir_rvalue *ir) -{ - void *ctx = talloc_parent(base_ir); - ir_variable *var; - ir_assignment *assign; - - var = new(ctx) ir_variable(ir->type, "flattening_tmp"); - base_ir->insert_before(var); - - assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), - ir, - NULL); - base_ir->insert_before(assign); - - return new(ctx) ir_dereference_variable(var); -} - -ir_visitor_status -ir_expression_flattening_visitor::visit_enter(ir_function_signature *ir) -{ - do_expression_flattening(&ir->body, this->predicate); - - return visit_continue_with_parent; -} - -ir_visitor_status -ir_expression_flattening_visitor::visit_enter(ir_loop *ir) -{ - do_expression_flattening(&ir->body_instructions, this->predicate); - - return visit_continue_with_parent; -} - -ir_visitor_status -ir_expression_flattening_visitor::visit_enter(ir_if *ir) -{ - ir->condition->accept(this); - - do_expression_flattening(&ir->then_instructions, this->predicate); - do_expression_flattening(&ir->else_instructions, this->predicate); - - return visit_continue_with_parent; -} - -ir_visitor_status -ir_expression_flattening_visitor::visit_leave(ir_expression *ir) -{ - unsigned int operand; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - /* If the operand matches the predicate, then we'll assign its - * value to a temporary and deref the temporary as the operand. - */ - if (this->predicate(ir->operands[operand])) { - ir->operands[operand] = operand_to_temp(base_ir, - ir->operands[operand]); - } - } - - return visit_continue; -} - -ir_visitor_status -ir_expression_flattening_visitor::visit_leave(ir_swizzle *ir) -{ - if (this->predicate(ir->val)) { - ir->val = operand_to_temp(this->base_ir, ir->val); - } - - return visit_continue; -} - -ir_visitor_status -ir_expression_flattening_visitor::visit_enter(ir_call *ir) -{ - /* FINISHME: Why not process the call parameters? (Same behavior as original - * FINISHME: code.) - */ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_expression_flattening_visitor::visit_enter(ir_return *ir) -{ - /* FINISHME: Why not process the return value? (Same behavior as original - * FINISHME: code.) - */ - (void) ir; - return visit_continue_with_parent; -} diff --git a/ir_expression_flattening.h b/ir_expression_flattening.h deleted file mode 100644 index 2eda1590001..00000000000 --- a/ir_expression_flattening.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file ir_expression_flattening.h - * - * Takes the leaves of expression trees and makes them dereferences of - * assignments of the leaves to temporaries, according to a predicate. - * - * This is used for automatic function inlining, where we want to take - * an expression containing a call and move the call out to its own - * assignment so that we can inline it at the appropriate place in the - * instruction stream. - */ - -void do_expression_flattening(exec_list *instructions, - bool (*predicate)(ir_instruction *ir)); diff --git a/ir_function.cpp b/ir_function.cpp deleted file mode 100644 index 5db93f67fb8..00000000000 --- a/ir_function.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "glsl_types.h" -#include "ir.h" - -int -type_compare(const glsl_type *a, const glsl_type *b) -{ - /* If the types are the same, they trivially match. - */ - if (a == b) - return 0; - - switch (a->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_BOOL: - /* There is no implicit conversion to or from integer types or bool. - */ - if ((a->is_integer() != b->is_integer()) - || (a->is_boolean() != b->is_boolean())) - return -1; - - /* FALLTHROUGH */ - - case GLSL_TYPE_FLOAT: - if ((a->vector_elements != b->vector_elements) - || (a->matrix_columns != b->matrix_columns)) - return -1; - - return 1; - - case GLSL_TYPE_SAMPLER: - case GLSL_TYPE_STRUCT: - /* Samplers and structures must match exactly. - */ - return -1; - - case GLSL_TYPE_ARRAY: - if ((b->base_type != GLSL_TYPE_ARRAY) - || (a->length != b->length)) - return -1; - - /* From GLSL 1.50 spec, page 27 (page 33 of the PDF): - * "There are no implicit array or structure conversions." - * - * If the comparison of the array element types detects that a conversion - * would be required, the array types do not match. - */ - return (type_compare(a->fields.array, b->fields.array) == 0) ? 0 : -1; - - case GLSL_TYPE_FUNCTION: - case GLSL_TYPE_VOID: - case GLSL_TYPE_ERROR: - default: - /* These are all error conditions. It is invalid for a parameter to - * a function to be declared as error, void, or a function. - */ - return -1; - } - - /* This point should be unreachable. - */ - assert(0); -} - - -static int -parameter_lists_match(exec_list *list_a, exec_list *list_b) -{ - exec_list_iterator iter_a = list_a->iterator(); - exec_list_iterator iter_b = list_b->iterator(); - int total_score = 0; - - for (/* empty */ ; iter_a.has_next(); iter_a.next(), iter_b.next()) { - /* If all of the parameters from the other parameter list have been - * exhausted, the lists have different length and, by definition, - * do not match. - */ - if (!iter_b.has_next()) - return -1; - - - const ir_variable *const param = (ir_variable *) iter_a.get(); - const ir_instruction *const actual = (ir_instruction *) iter_b.get(); - - /* Determine whether or not the types match. If the types are an - * exact match, the match score is zero. If the types don't match - * but the actual parameter can be coerced to the type of the declared - * parameter, the match score is one. - */ - int score; - switch ((enum ir_variable_mode)(param->mode)) { - case ir_var_auto: - case ir_var_uniform: - /* These are all error conditions. It is invalid for a parameter to - * a function to be declared as auto (not in, out, or inout) or - * as uniform. - */ - assert(0); - return -1; - - case ir_var_in: - score = type_compare(param->type, actual->type); - break; - - case ir_var_out: - score = type_compare(actual->type, param->type); - break; - - case ir_var_inout: - /* Since there are no bi-directional automatic conversions (e.g., - * there is int -> float but no float -> int), inout parameters must - * be exact matches. - */ - score = (type_compare(actual->type, param->type) == 0) ? 0 : -1; - break; - } - - if (score < 0) - return -1; - - total_score += score; - } - - /* If all of the parameters from the other parameter list have been - * exhausted, the lists have different length and, by definition, do not - * match. - */ - if (iter_b.has_next()) - return -1; - - return total_score; -} - - -const ir_function_signature * -ir_function::matching_signature(exec_list *actual_parameters) -{ - ir_function_signature *match = NULL; - - foreach_iter(exec_list_iterator, iter, signatures) { - ir_function_signature *const sig = - (ir_function_signature *) iter.get(); - - const int score = parameter_lists_match(& sig->parameters, - actual_parameters); - - if (score == 0) - return sig; - - if (score > 0) { - if (match != NULL) - return NULL; - - match = sig; - } - } - - return match; -} - - -static bool -parameter_lists_match_exact(exec_list *list_a, exec_list *list_b) -{ - exec_list_iterator iter_a = list_a->iterator(); - exec_list_iterator iter_b = list_b->iterator(); - - while (iter_a.has_next() && iter_b.has_next()) { - ir_variable *a = (ir_variable *)iter_a.get(); - ir_variable *b = (ir_variable *)iter_b.get(); - - /* If the types of the parameters do not match, the parameters lists - * are different. - */ - if (a->type != b->type) - return false; - - iter_a.next(); - iter_b.next(); - } - - /* Unless both lists are exhausted, they differ in length and, by - * definition, do not match. - */ - if (iter_a.has_next() != iter_b.has_next()) - return false; - - return true; -} - -ir_function_signature * -ir_function::exact_matching_signature(exec_list *actual_parameters) -{ - foreach_iter(exec_list_iterator, iter, signatures) { - ir_function_signature *const sig = - (ir_function_signature *) iter.get(); - - if (parameter_lists_match_exact(&sig->parameters, actual_parameters)) - return sig; - } - return NULL; -} diff --git a/ir_function_can_inline.cpp b/ir_function_can_inline.cpp deleted file mode 100644 index 8bb8e0d9ed7..00000000000 --- a/ir_function_can_inline.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_function_can_inline.cpp - * - * Determines if we can inline a function call using ir_function_inlining.cpp. - * - * The primary restriction is that we can't return from the function - * other than as the last instruction. We could potentially work - * around this for some constructs by flattening control flow and - * moving the return to the end, or by using breaks from a do {} while - * (0) loop surrounding the function body. - */ - -#include "ir.h" - -class ir_function_can_inline_visitor : public ir_hierarchical_visitor { -public: - ir_function_can_inline_visitor() - { - this->num_returns = 0; - } - - virtual ir_visitor_status visit_enter(ir_return *); - - int num_returns; -}; - -ir_visitor_status -ir_function_can_inline_visitor::visit_enter(ir_return *ir) -{ - (void) ir; - this->num_returns++; - return visit_continue; -} - -bool -can_inline(ir_call *call) -{ - ir_function_can_inline_visitor v; - const ir_function_signature *callee = call->get_callee(); - - v.run((exec_list *) &callee->body); - - ir_instruction *last = (ir_instruction *)callee->body.get_tail(); - if (last && !last->as_return()) - v.num_returns++; - - return v.num_returns == 1; -} diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp deleted file mode 100644 index e55780c940e..00000000000 --- a/ir_function_inlining.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_function_inlining.cpp - * - * Replaces calls to functions with the body of the function. - */ - -#include -#include "ir.h" -#include "ir_visitor.h" -#include "ir_function_inlining.h" -#include "ir_expression_flattening.h" -#include "glsl_types.h" -#include "hash_table.h" - -class ir_function_inlining_visitor : public ir_hierarchical_visitor { -public: - ir_function_inlining_visitor() - { - progress = false; - } - - virtual ~ir_function_inlining_visitor() - { - /* empty */ - } - - virtual ir_visitor_status visit_enter(ir_expression *); - virtual ir_visitor_status visit_enter(ir_call *); - virtual ir_visitor_status visit_enter(ir_assignment *); - virtual ir_visitor_status visit_enter(ir_return *); - virtual ir_visitor_status visit_enter(ir_texture *); - virtual ir_visitor_status visit_enter(ir_swizzle *); - - bool progress; -}; - - -unsigned int hash_func(const void *key) -{ - return (unsigned int)(uintptr_t)key; -} - -int hash_compare_func(const void *key1, const void *key2) -{ - return key1 == key2 ? 0 : 1; -} - -bool -automatic_inlining_predicate(ir_instruction *ir) -{ - ir_call *call = ir->as_call(); - - if (call && can_inline(call)) - return true; - - return false; -} - -bool -do_function_inlining(exec_list *instructions) -{ - ir_function_inlining_visitor v; - - do_expression_flattening(instructions, automatic_inlining_predicate); - - v.run(instructions); - - return v.progress; -} - -static void -replace_return_with_assignment(ir_instruction *ir, void *data) -{ - void *ctx = talloc_parent(ir); - ir_variable *retval = (ir_variable *)data; - ir_return *ret = ir->as_return(); - - if (ret) { - if (ret->value) { - ir_rvalue *lhs = new(ctx) ir_dereference_variable(retval); - ret->insert_before(new(ctx) ir_assignment(lhs, ret->value, NULL)); - ret->remove(); - } else { - /* un-valued return has to be the last return, or we shouldn't - * have reached here. (see can_inline()). - */ - assert(!ret->next->is_tail_sentinal()); - } - } -} - -ir_rvalue * -ir_call::generate_inline(ir_instruction *next_ir) -{ - void *ctx = talloc_parent(this); - ir_variable **parameters; - int num_parameters; - int i; - ir_variable *retval = NULL; - struct hash_table *ht; - - ht = hash_table_ctor(0, hash_func, hash_compare_func); - - num_parameters = 0; - foreach_iter(exec_list_iterator, iter_sig, this->callee->parameters) - num_parameters++; - - parameters = new ir_variable *[num_parameters]; - - /* Generate storage for the return value. */ - if (this->callee->return_type) { - retval = new(ctx) ir_variable(this->callee->return_type, "__retval"); - next_ir->insert_before(retval); - } - - /* Generate the declarations for the parameters to our inlined code, - * and set up the mapping of real function body variables to ours. - */ - i = 0; - exec_list_iterator sig_param_iter = this->callee->parameters.iterator(); - exec_list_iterator param_iter = this->actual_parameters.iterator(); - for (i = 0; i < num_parameters; i++) { - const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get(); - ir_rvalue *param = (ir_rvalue *) param_iter.get(); - - /* Generate a new variable for the parameter. */ - parameters[i] = (ir_variable *)sig_param->clone(ht); - parameters[i]->mode = ir_var_auto; - next_ir->insert_before(parameters[i]); - - /* Move the actual param into our param variable if it's an 'in' type. */ - if (sig_param->mode == ir_var_in || - sig_param->mode == ir_var_inout) { - ir_assignment *assign; - - assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]), - param, NULL); - next_ir->insert_before(assign); - } - - sig_param_iter.next(); - param_iter.next(); - } - - /* Generate the inlined body of the function. */ - foreach_iter(exec_list_iterator, iter, callee->body) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_instruction *new_ir = ir->clone(ht); - - next_ir->insert_before(new_ir); - visit_tree(new_ir, replace_return_with_assignment, retval); - } - - /* Copy back the value of any 'out' parameters from the function body - * variables to our own. - */ - i = 0; - param_iter = this->actual_parameters.iterator(); - for (i = 0; i < num_parameters; i++) { - ir_instruction *const param = (ir_instruction *) param_iter.get(); - - /* Move our param variable into the actual param if it's an 'out' type. */ - if (parameters[i]->mode == ir_var_out || - parameters[i]->mode == ir_var_inout) { - ir_assignment *assign; - - assign = new(ctx) ir_assignment(param->as_rvalue(), - new(ctx) ir_dereference_variable(parameters[i]), - NULL); - next_ir->insert_before(assign); - } - - param_iter.next(); - } - - delete [] parameters; - - hash_table_dtor(ht); - - if (retval) - return new(ctx) ir_dereference_variable(retval); - else - return NULL; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_expression *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_return *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_texture *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_swizzle *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_call *ir) -{ - if (can_inline(ir)) { - (void) ir->generate_inline(ir); - ir->remove(); - this->progress = true; - } - - return visit_continue; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_assignment *ir) -{ - ir_call *call = ir->rhs->as_call(); - if (!call || !can_inline(call)) - return visit_continue; - - /* generates the parameter setup, function body, and returns the return - * value of the function - */ - ir_rvalue *rhs = call->generate_inline(ir); - assert(rhs); - - ir->rhs = rhs; - this->progress = true; - - return visit_continue; -} diff --git a/ir_function_inlining.h b/ir_function_inlining.h deleted file mode 100644 index 6db011bbcae..00000000000 --- a/ir_function_inlining.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_function_inlining.h - * - * Replaces calls to functions with the body of the function. - */ - -bool can_inline(ir_call *call); diff --git a/ir_hierarchical_visitor.cpp b/ir_hierarchical_visitor.cpp deleted file mode 100644 index 0d520b127f2..00000000000 --- a/ir_hierarchical_visitor.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "ir.h" -#include "ir_hierarchical_visitor.h" - -ir_hierarchical_visitor::ir_hierarchical_visitor() -{ - this->callback = NULL; - this->data = NULL; -} - -ir_visitor_status -ir_hierarchical_visitor::visit(ir_variable *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit(ir_constant *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit(ir_loop_jump *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit(ir_dereference_variable *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_loop *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_loop *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_function_signature *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_function_signature *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_function *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_function *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_expression *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_expression *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_texture *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_texture *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_swizzle *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_swizzle *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_dereference_array *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_dereference_record *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_assignment *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_assignment *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_call *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_call *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_return *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_return *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_if *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_if *ir) -{ - (void) ir; - return visit_continue; -} - -void -ir_hierarchical_visitor::run(exec_list *instructions) -{ - foreach_list(n, instructions) { - ir_instruction *ir = (ir_instruction *) n; - - if (ir->accept(this) != visit_continue) - break; - } -} - - -void -visit_tree(ir_instruction *ir, - void (*callback)(class ir_instruction *ir, void *data), - void *data) -{ - ir_hierarchical_visitor v; - - v.callback = callback; - v.data = data; - - ir->accept(&v); -} diff --git a/ir_hierarchical_visitor.h b/ir_hierarchical_visitor.h deleted file mode 100644 index 8b9e49dab13..00000000000 --- a/ir_hierarchical_visitor.h +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef IR_HIERARCHICAL_VISITOR_H -#define IR_HIERARCHICAL_VISITOR_H - -/** - * Enumeration values returned by visit methods to guide processing - */ -enum ir_visitor_status { - visit_continue, /**< Continue visiting as normal. */ - visit_continue_with_parent, /**< Don't visit siblings, continue w/parent. */ - visit_stop /**< Stop visiting immediately. */ -}; - - -/** - * Base class of hierarchical visitors of IR instruction trees - * - * Hierarchical visitors differ from traditional visitors in a couple of - * important ways. Rather than having a single \c visit method for each - * subclass in the composite, there are three kinds of visit methods. - * Leaf-node classes have a traditional \c visit method. Internal-node - * classes have a \c visit_enter method, which is invoked just before - * processing child nodes, and a \c visit_leave method which is invoked just - * after processing child nodes. - * - * In addition, each visit method and the \c accept methods in the composite - * have a return value which guides the navigation. Any of the visit methods - * can choose to continue visiting the tree as normal (by returning \c - * visit_continue), terminate visiting any further nodes immediately (by - * returning \c visit_stop), or stop visiting sibling nodes (by returning \c - * visit_continue_with_parent). - * - * These two changes combine to allow nagivation of children to be implemented - * in the composite's \c accept method. The \c accept method for a leaf-node - * class will simply call the \c visit method, as usual, and pass its return - * value on. The \c accept method for internal-node classes will call the \c - * visit_enter method, call the \c accpet method of each child node, and, - * finally, call the \c visit_leave method. If any of these return a value - * other that \c visit_continue, the correct action must be taken. - * - * The final benefit is that the hierarchical visitor base class need not be - * abstract. Default implementations of every \c visit, \c visit_enter, and - * \c visit_leave method can be provided. By default each of these methods - * simply returns \c visit_continue. This allows a significant reduction in - * derived class code. - * - * For more information about hierarchical visitors, see: - * - * http://c2.com/cgi/wiki?HierarchicalVisitorPattern - * http://c2.com/cgi/wiki?HierarchicalVisitorDiscussion - */ - -class ir_hierarchical_visitor { -public: - ir_hierarchical_visitor(); - - /** - * \name Visit methods for leaf-node classes - */ - /*@{*/ - virtual ir_visitor_status visit(class ir_variable *); - virtual ir_visitor_status visit(class ir_constant *); - virtual ir_visitor_status visit(class ir_loop_jump *); - - /** - * ir_dereference_variable isn't technically a leaf, but it is treated as a - * leaf here for a couple reasons. By not automatically visiting the one - * child ir_variable node from the ir_dereference_variable, ir_variable - * nodes can always be handled as variable declarations. Code that used - * non-hierarchical visitors had to set an "in a dereference" flag to - * determine how to handle an ir_variable. By forcing the visitor to - * handle the ir_variable within the ir_dereference_variable visitor, this - * kludge can be avoided. - * - * In addition, I can envision no use for having separate enter and leave - * methods. Anything that could be done in the enter and leave methods - * that couldn't just be done in the visit method. - */ - virtual ir_visitor_status visit(class ir_dereference_variable *); - /*@}*/ - - /** - * \name Visit methods for internal-node classes - */ - /*@{*/ - virtual ir_visitor_status visit_enter(class ir_loop *); - virtual ir_visitor_status visit_leave(class ir_loop *); - virtual ir_visitor_status visit_enter(class ir_function_signature *); - virtual ir_visitor_status visit_leave(class ir_function_signature *); - virtual ir_visitor_status visit_enter(class ir_function *); - virtual ir_visitor_status visit_leave(class ir_function *); - virtual ir_visitor_status visit_enter(class ir_expression *); - virtual ir_visitor_status visit_leave(class ir_expression *); - virtual ir_visitor_status visit_enter(class ir_texture *); - virtual ir_visitor_status visit_leave(class ir_texture *); - virtual ir_visitor_status visit_enter(class ir_swizzle *); - virtual ir_visitor_status visit_leave(class ir_swizzle *); - virtual ir_visitor_status visit_enter(class ir_dereference_array *); - virtual ir_visitor_status visit_leave(class ir_dereference_array *); - virtual ir_visitor_status visit_enter(class ir_dereference_record *); - virtual ir_visitor_status visit_leave(class ir_dereference_record *); - virtual ir_visitor_status visit_enter(class ir_assignment *); - virtual ir_visitor_status visit_leave(class ir_assignment *); - virtual ir_visitor_status visit_enter(class ir_call *); - virtual ir_visitor_status visit_leave(class ir_call *); - virtual ir_visitor_status visit_enter(class ir_return *); - virtual ir_visitor_status visit_leave(class ir_return *); - virtual ir_visitor_status visit_enter(class ir_if *); - virtual ir_visitor_status visit_leave(class ir_if *); - /*@}*/ - - - /** - * Utility function to process a linked list of instructions with a visitor - */ - void run(struct exec_list *instructions); - - /** - * Callback function that is invoked on entry to each node visited. - * - * \warning - * Visitor classes derived from \c ir_hierarchical_visitor \b may \b not - * invoke this function. This can be used, for example, to cause the - * callback to be invoked on every node type execpt one. - */ - void (*callback)(class ir_instruction *ir, void *data); - - /** - * Extra data parameter passed to the per-node callback function - */ - void *data; -}; - -void visit_tree(ir_instruction *ir, - void (*callback)(class ir_instruction *ir, void *data), - void *data); - -#endif /* IR_HIERARCHICAL_VISITOR_H */ diff --git a/ir_hv_accept.cpp b/ir_hv_accept.cpp deleted file mode 100644 index f936b3500eb..00000000000 --- a/ir_hv_accept.cpp +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "ir.h" - -/** - * \file ir_hv_accept.cpp - * Implementations of all hierarchical visitor accept methods for IR - * instructions. - */ - -/** - * Process a list of nodes using a hierarchical vistor - * - * \warning - * This function will operate correctly if a node being processed is removed - * from list. However, if nodes are added to the list after the node being - * processed, some of the added noded may not be processed. - */ -static ir_visitor_status -visit_list_elements(ir_hierarchical_visitor *v, exec_list *l) -{ - exec_node *next; - - for (exec_node *n = l->head; n->next != NULL; n = next) { - next = n->next; - - ir_instruction *const ir = (ir_instruction *) n; - ir_visitor_status s = ir->accept(v); - - if (s != visit_continue) - return s; - } - - return visit_continue; -} - - -ir_visitor_status -ir_variable::accept(ir_hierarchical_visitor *v) -{ - return v->visit(this); -} - - -ir_visitor_status -ir_loop::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = visit_list_elements(v, &this->body_instructions); - if (s == visit_stop) - return s; - - if (s != visit_continue_with_parent) { - if (this->from) { - s = this->from->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - if (this->to) { - s = this->to->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - if (this->increment) { - s = this->increment->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - } - - return v->visit_leave(this); -} - - -ir_visitor_status -ir_loop_jump::accept(ir_hierarchical_visitor *v) -{ - return v->visit(this); -} - - -ir_visitor_status -ir_function_signature::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = visit_list_elements(v, &this->body); - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_function::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = visit_list_elements(v, &this->signatures); - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_expression::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - for (unsigned i = 0; i < this->get_num_operands(); i++) { - switch (this->operands[i]->accept(v)) { - case visit_continue: - break; - - case visit_continue_with_parent: - // I wish for Java's labeled break-statement here. - goto done; - - case visit_stop: - return s; - } - } - -done: - return v->visit_leave(this); -} - -ir_visitor_status -ir_texture::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->sampler->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->coordinate->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - if (this->projector) { - s = this->projector->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - if (this->shadow_comparitor) { - s = this->shadow_comparitor->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - switch (this->op) { - case ir_tex: - break; - case ir_txb: - s = this->lod_info.bias->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - break; - case ir_txl: - case ir_txf: - s = this->lod_info.lod->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - break; - case ir_txd: - s = this->lod_info.grad.dPdx->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->lod_info.grad.dPdy->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - break; - } - - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_swizzle::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->val->accept(v); - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_dereference_variable::accept(ir_hierarchical_visitor *v) -{ - return v->visit(this); -} - - -ir_visitor_status -ir_dereference_array::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->array_index->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->array->accept(v); - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_dereference_record::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->record->accept(v); - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_assignment::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->lhs->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->rhs->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - if (this->condition) - s = this->condition->accept(v); - - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_constant::accept(ir_hierarchical_visitor *v) -{ - return v->visit(this); -} - - -ir_visitor_status -ir_call::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = visit_list_elements(v, &this->actual_parameters); - if (s == visit_stop) - return s; - - return v->visit_leave(this); -} - - -ir_visitor_status -ir_return::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - ir_rvalue *val = this->get_value(); - if (val) { - s = val->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - return v->visit_leave(this); -} - - -ir_visitor_status -ir_if::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->condition->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - if (s != visit_continue_with_parent) { - s = visit_list_elements(v, &this->then_instructions); - if (s == visit_stop) - return s; - } - - if (s != visit_continue_with_parent) { - s = visit_list_elements(v, &this->else_instructions); - if (s == visit_stop) - return s; - } - - return v->visit_leave(this); -} diff --git a/ir_if_simplification.cpp b/ir_if_simplification.cpp deleted file mode 100644 index 6882ef72b95..00000000000 --- a/ir_if_simplification.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_function_inlining.cpp - * - * Moves constant branches of if statements out to the surrounding - * instruction stream. - */ - -#include "ir.h" - -class ir_if_simplification_visitor : public ir_hierarchical_visitor { -public: - ir_if_simplification_visitor() - { - this->made_progress = false; - } - - ir_visitor_status visit_leave(ir_if *); - - bool made_progress; -}; - -bool -do_if_simplification(exec_list *instructions) -{ - ir_if_simplification_visitor v; - - v.run(instructions); - return v.made_progress; -} - - -ir_visitor_status -ir_if_simplification_visitor::visit_leave(ir_if *ir) -{ - /* FINISHME: Ideally there would be a way to note that the condition results - * FINISHME: in a constant before processing both of the other subtrees. - * FINISHME: This can probably be done with some flags, but it would take - * FINISHME: some work to get right. - */ - ir_constant *condition_constant = ir->condition->constant_expression_value(); - if (condition_constant) { - /* Move the contents of the one branch of the conditional - * that matters out. - */ - if (condition_constant->value.b[0]) { - foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { - ir_instruction *then_ir = (ir_instruction *)then_iter.get(); - ir->insert_before(then_ir); - } - } else { - foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { - ir_instruction *else_ir = (ir_instruction *)else_iter.get(); - ir->insert_before(else_ir); - } - } - ir->remove(); - this->made_progress = true; - } - - return visit_continue; -} diff --git a/ir_optimization.h b/ir_optimization.h deleted file mode 100644 index 432a33458c2..00000000000 --- a/ir_optimization.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file ir_dead_code.h - * - * Prototypes for optimization passes to be called by the compiler and drivers. - */ - -bool do_constant_folding(exec_list *instructions); -bool do_constant_variable(exec_list *instructions); -bool do_constant_variable_unlinked(exec_list *instructions); -bool do_copy_propagation(exec_list *instructions); -bool do_dead_code(exec_list *instructions); -bool do_dead_code_local(exec_list *instructions); -bool do_dead_code_unlinked(exec_list *instructions); -bool do_function_inlining(exec_list *instructions); -bool do_if_simplification(exec_list *instructions); -bool do_swizzle_swizzle(exec_list *instructions); -bool do_vec_index_to_swizzle(exec_list *instructions); diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp deleted file mode 100644 index be5a843f67d..00000000000 --- a/ir_print_visitor.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "ir_print_visitor.h" -#include "glsl_types.h" -#include "glsl_parser_extras.h" - -static void print_type(const glsl_type *t); - -void -ir_instruction::print(void) const -{ - ir_instruction *deconsted = const_cast(this); - - ir_print_visitor v; - deconsted->accept(&v); -} - -void -_mesa_print_ir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - for (unsigned i = 0; i < state->num_user_structures; i++) { - const glsl_type *const s = state->user_structures[i]; - - printf("(structure (%s) (%s@%p) (%u) (\n", - s->name, s->name, s, s->length); - - for (unsigned j = 0; j < s->length; j++) { - printf("\t(("); - print_type(s->fields.structure[j].type); - printf(")(%s))\n", s->fields.structure[j].name); - } - - printf(")\n"); - } - - printf("(\n"); - foreach_iter(exec_list_iterator, iter, *instructions) { - ((ir_instruction *)iter.get())->print(); - printf("\n"); - } - printf("\n)"); -} - -static void -print_type(const glsl_type *t) -{ - if (t->base_type == GLSL_TYPE_ARRAY) { - printf("(array "); - print_type(t->fields.array); - printf(" %u)", t->length); - } else if ((t->base_type == GLSL_TYPE_STRUCT) - && (strncmp("gl_", t->name, 3) != 0)) { - printf("%s@%p", t->name, t); - } else { - printf("%s", t->name); - } -} - - -void ir_print_visitor::visit(ir_variable *ir) -{ - printf("(declare "); - - const char *const cent = (ir->centroid) ? "centroid " : ""; - const char *const inv = (ir->invariant) ? "invariant " : ""; - const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " }; - const char *const interp[] = { "", "flat", "noperspective" }; - - printf("(%s%s%s%s) ", - cent, inv, mode[ir->mode], interp[ir->interpolation]); - - print_type(ir->type); - printf(" %s@%p)", ir->name, ir); -} - - -void ir_print_visitor::visit(ir_function_signature *ir) -{ - printf("(signature "); - print_type(ir->return_type); - printf("\n (parameters\n"); - foreach_iter(exec_list_iterator, iter, ir->parameters) { - ir_variable *const inst = (ir_variable *) iter.get(); - - inst->accept(this); - printf("\n"); - } - printf(" )\n("); - - foreach_iter(exec_list_iterator, iter, ir->body) { - ir_instruction *const inst = (ir_instruction *) iter.get(); - - inst->accept(this); - printf("\n"); - } - printf("))\n"); -} - - -void ir_print_visitor::visit(ir_function *ir) -{ - printf("(function %s\n", ir->name); - foreach_iter(exec_list_iterator, iter, *ir) { - ir_function_signature *const sig = (ir_function_signature *) iter.get(); - - sig->accept(this); - printf("\n"); - } - - printf(")\n"); -} - - -void ir_print_visitor::visit(ir_expression *ir) -{ - printf("(expression "); - - print_type(ir->type); - - printf(" %s ", ir->operator_string()); - - if (ir->operands[0]) - ir->operands[0]->accept(this); - - if (ir->operands[1]) - ir->operands[1]->accept(this); - printf(") "); -} - - -void ir_print_visitor::visit(ir_texture *ir) -{ - printf("(%s ", ir->opcode_string()); - - ir->sampler->accept(this); - printf(" "); - - ir->coordinate->accept(this); - - printf(" (%d %d %d) ", ir->offsets[0], ir->offsets[1], ir->offsets[2]); - - if (ir->op != ir_txf) { - if (ir->projector) - ir->projector->accept(this); - else - printf("1"); - - if (ir->shadow_comparitor) { - printf(" "); - ir->shadow_comparitor->accept(this); - } else { - printf(" ()"); - } - } - - printf(" "); - switch (ir->op) - { - case ir_tex: - break; - case ir_txb: - ir->lod_info.bias->accept(this); - break; - case ir_txl: - case ir_txf: - ir->lod_info.lod->accept(this); - break; - case ir_txd: - printf("("); - ir->lod_info.grad.dPdx->accept(this); - printf(" "); - ir->lod_info.grad.dPdy->accept(this); - printf(")"); - break; - }; - printf(")"); -} - - -void ir_print_visitor::visit(ir_swizzle *ir) -{ - const unsigned swiz[4] = { - ir->mask.x, - ir->mask.y, - ir->mask.z, - ir->mask.w, - }; - - printf("(swiz "); - for (unsigned i = 0; i < ir->mask.num_components; i++) { - printf("%c", "xyzw"[swiz[i]]); - } - printf(" "); - ir->val->accept(this); - printf(")"); -} - - -void ir_print_visitor::visit(ir_dereference_variable *ir) -{ - ir_variable *var = ir->variable_referenced(); - printf("(var_ref %s@%p) ", var->name, var); -} - - -void ir_print_visitor::visit(ir_dereference_array *ir) -{ - printf("(array_ref "); - ir->array->accept(this); - ir->array_index->accept(this); - printf(") "); -} - - -void ir_print_visitor::visit(ir_dereference_record *ir) -{ - printf("(record_ref "); - ir->record->accept(this); - printf(" %s) ", ir->field); -} - - -void ir_print_visitor::visit(ir_assignment *ir) -{ - printf("(assign "); - - if (ir->condition) - ir->condition->accept(this); - else - printf("(constant bool (1))"); - - printf(" "); - - ir->lhs->accept(this); - - printf(" "); - - ir->rhs->accept(this); - printf(") "); -} - - -void ir_print_visitor::visit(ir_constant *ir) -{ - const glsl_type *const base_type = ir->type->get_base_type(); - - printf("(constant "); - print_type(ir->type); - printf(" ("); - - for (unsigned i = 0; i < ir->type->components(); i++) { - if (i != 0) - printf(", "); - - switch (base_type->base_type) { - case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break; - case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break; - case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break; - case GLSL_TYPE_BOOL: printf("%d", ir->value.b[i]); break; - default: assert(0); - } - } - printf(")) "); -} - - -void -ir_print_visitor::visit(ir_call *ir) -{ - printf("(call %s (", ir->callee_name()); - foreach_iter(exec_list_iterator, iter, *ir) { - ir_instruction *const inst = (ir_instruction *) iter.get(); - - inst->accept(this); - } - printf("))\n"); -} - - -void -ir_print_visitor::visit(ir_return *ir) -{ - printf("(return"); - - ir_rvalue *const value = ir->get_value(); - if (value) { - printf(" "); - value->accept(this); - } - - printf(")"); -} - - -void -ir_print_visitor::visit(ir_if *ir) -{ - printf("(if "); - ir->condition->accept(this); - - printf("(\n"); - foreach_iter(exec_list_iterator, iter, ir->then_instructions) { - ir_instruction *const inst = (ir_instruction *) iter.get(); - - inst->accept(this); - printf("\n"); - } - printf(")\n"); - - printf("(\n"); - foreach_iter(exec_list_iterator, iter, ir->else_instructions) { - ir_instruction *const inst = (ir_instruction *) iter.get(); - - inst->accept(this); - printf("\n"); - } - printf("))\n"); -} - - -void -ir_print_visitor::visit(ir_loop *ir) -{ - printf("(loop ("); - if (ir->counter != NULL) - ir->counter->accept(this); - printf(") ("); - if (ir->from != NULL) - ir->from->accept(this); - printf(") ("); - if (ir->to != NULL) - ir->to->accept(this); - printf(") ("); - if (ir->increment != NULL) - ir->increment->accept(this); - printf(") (\n"); - foreach_iter(exec_list_iterator, iter, ir->body_instructions) { - ir_instruction *const inst = (ir_instruction *) iter.get(); - - inst->accept(this); - printf("\n"); - } - printf("))\n"); -} - - -void -ir_print_visitor::visit(ir_loop_jump *ir) -{ - printf("%s", ir->is_break() ? "break" : "continue"); -} diff --git a/ir_print_visitor.h b/ir_print_visitor.h deleted file mode 100644 index e97b823522a..00000000000 --- a/ir_print_visitor.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef IR_PRINT_VISITOR_H -#define IR_PRINT_VISITOR_H - -#include "ir.h" -#include "ir_visitor.h" - -extern void _mesa_print_ir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - -/** - * Abstract base class of visitors of IR instruction trees - */ -class ir_print_visitor : public ir_visitor { -public: - ir_print_visitor() - : deref_depth(0) - { - /* empty */ - } - - virtual ~ir_print_visitor() - { - /* empty */ - } - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_texture *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - /*@}*/ - -private: - int deref_depth; -}; - -#endif /* IR_PRINT_VISITOR_H */ diff --git a/ir_reader.cpp b/ir_reader.cpp deleted file mode 100644 index 7383c42cbc7..00000000000 --- a/ir_reader.cpp +++ /dev/null @@ -1,1053 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include - -extern "C" { -#include -} - -#include "ir_reader.h" -#include "glsl_parser_extras.h" -#include "glsl_types.h" -#include "s_expression.h" - -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 *read_var_ref(_mesa_glsl_parse_state *, s_list *); -static ir_dereference *read_array_ref(_mesa_glsl_parse_state *, s_list *); -static ir_dereference *read_record_ref(_mesa_glsl_parse_state *, s_list *); - -void -_mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, - const char *src) -{ - void *ctx = talloc_parent(state); - s_expression *expr = s_expression::read_expression(ctx, src); - if (expr == NULL) { - ir_read_error(state, NULL, "couldn't parse S-Expression."); - return; - } - - scan_for_prototypes(state, instructions, expr); - if (state->error) - return; - - read_instructions(state, instructions, expr, NULL); -} - -static void -ir_read_error(_mesa_glsl_parse_state *state, s_expression *expr, - const char *fmt, ...) -{ - va_list ap; - - state->error = true; - - state->info_log = talloc_strdup_append(state->info_log, "error: "); - - va_start(ap, fmt); - state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); - va_end(ap); - state->info_log = talloc_strdup_append(state->info_log, "\n"); - - if (expr != NULL) { - state->info_log = talloc_strdup_append(state->info_log, - "...in this context:\n "); - expr->print(); - state->info_log = talloc_strdup_append(state->info_log, "\n\n"); - } -} - -static const glsl_type * -read_type(_mesa_glsl_parse_state *st, 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 ...)"); - return NULL; - } - if (strcmp(type_sym->value(), "array") == 0) { - if (list->length() != 3) { - ir_read_error(st, expr, "expected type (array )"); - 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(st, 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; - } - } - - s_symbol *type_sym = SX_AS_SYMBOL(expr); - if (type_sym == NULL) { - ir_read_error(st, expr, "expected (symbol or list)"); - return NULL; - } - - const glsl_type *type = st->symbols->get_type(type_sym->value()); - if (type == NULL) - ir_read_error(st, 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) -{ - s_list *list = SX_AS_LIST(expr); - if (list == NULL) { - ir_read_error(st, expr, "Expected ( ...); found an atom."); - return; - } - - foreach_iter(exec_list_iterator, it, list->subexpressions) { - s_list *sub = SX_AS_LIST(it.get()); - if (sub == NULL) - continue; // not a (function ...); ignore it. - - s_symbol *tag = SX_AS_SYMBOL(sub->subexpressions.get_head()); - if (tag == NULL || strcmp(tag->value(), "function") != 0) - continue; // not a (function ...); ignore it. - - ir_function *f = read_function(st, 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) -{ - void *ctx = talloc_parent(st); - if (list->length() < 3) { - ir_read_error(st, list, "Expected (function (signature ...) ...)"); - return NULL; - } - - s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next); - if (name == NULL) { - ir_read_error(st, list, "Expected (function ...)"); - return NULL; - } - - ir_function *f = st->symbols->get_function(name->value()); - if (f == NULL) { - f = new(ctx) ir_function(name->value()); - bool added = st->symbols->add_function(name->value(), f); - assert(added); - } - - exec_list_iterator it = list->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); - } - return f; -} - -static void -read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list, - bool skip_body) -{ - void *ctx = talloc_parent(st); - if (list->length() != 4) { - ir_read_error(st, list, "Expected (signature (parameters ...) " - "( ...))"); - return; - } - - s_expression *type_expr = (s_expression*) list->subexpressions.head->next; - const glsl_type *return_type = read_type(st, type_expr); - if (return_type == NULL) - return; - - s_list *paramlist = SX_AS_LIST(type_expr->next); - s_list *body_list = SX_AS_LIST(paramlist->next); - if (paramlist == NULL || body_list == NULL) { - ir_read_error(st, list, "Expected (signature (parameters ...) " - "( ...))"); - 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 ...)"); - return; - } - - // Read the parameters list into a temporary place. - exec_list hir_parameters; - st->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); - if (var == NULL) - return; - - hir_parameters.push_tail(var); - } - - ir_function_signature *sig = f->exact_matching_signature(&hir_parameters); - if (sig != NULL) { - const char *badvar = sig->qualifiers_match(&hir_parameters); - if (badvar != NULL) { - ir_read_error(st, list, "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 " - "match prototype", f->name); - return; - } - } else { - sig = new(ctx) ir_function_signature(return_type); - f->add_signature(sig); - } - - sig->replace_parameters(&hir_parameters); - - if (!skip_body) { - if (sig->is_defined) { - ir_read_error(st, list, "function %s redefined", f->name); - return; - } - read_instructions(st, &sig->body, body_list, NULL); - sig->is_defined = true; - } - - st->symbols->pop_scope(); -} - -static void -read_instructions(_mesa_glsl_parse_state *st, 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 ( ...); 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); - if (ir == NULL) { - ir_read_error(st, sub, "Invalid instruction.\n"); - return; - } - instructions->push_tail(ir); - } -} - - -static ir_instruction * -read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, - ir_loop *loop_ctx) -{ - void *ctx = talloc_parent(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); - if (strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL) - return new(ctx) ir_loop_jump(ir_loop_jump::jump_continue); - } - - s_list *list = SX_AS_LIST(expr); - if (list == NULL || list->subexpressions.is_empty()) - return NULL; - - s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head()); - if (tag == NULL) { - ir_read_error(st, expr, "expected instruction tag"); - return NULL; - } - - ir_instruction *inst = NULL; - if (strcmp(tag->value(), "declare") == 0) { - inst = read_declaration(st, list); - } else if (strcmp(tag->value(), "if") == 0) { - inst = read_if(st, list, loop_ctx); - } else if (strcmp(tag->value(), "loop") == 0) { - inst = read_loop(st, list); - } else if (strcmp(tag->value(), "return") == 0) { - inst = read_return(st, list); - } else if (strcmp(tag->value(), "function") == 0) { - inst = read_function(st, list, false); - } else { - inst = read_rvalue(st, list); - if (inst == NULL) - ir_read_error(st, NULL, "when reading instruction"); - } - return inst; -} - - -static ir_variable * -read_declaration(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(st); - if (list->length() != 4) { - ir_read_error(st, list, "expected (declare () " - ")"); - return NULL; - } - - s_list *quals = SX_AS_LIST(list->subexpressions.head->next); - if (quals == NULL) { - ir_read_error(st, list, "expected a list of variable qualifiers"); - return NULL; - } - - s_expression *type_expr = (s_expression*) quals->next; - const glsl_type *type = read_type(st, type_expr); - 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()); - - foreach_iter(exec_list_iterator, it, 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; - return NULL; - } - - // FINISHME: Check for duplicate/conflicting qualifiers. - if (strcmp(qualifier->value(), "centroid") == 0) { - var->centroid = 1; - } else if (strcmp(qualifier->value(), "invariant") == 0) { - var->invariant = 1; - } else if (strcmp(qualifier->value(), "uniform") == 0) { - var->mode = ir_var_uniform; - } else if (strcmp(qualifier->value(), "auto") == 0) { - var->mode = ir_var_auto; - } else if (strcmp(qualifier->value(), "in") == 0) { - var->mode = ir_var_in; - } else if (strcmp(qualifier->value(), "out") == 0) { - var->mode = ir_var_out; - } else if (strcmp(qualifier->value(), "inout") == 0) { - var->mode = ir_var_inout; - } else if (strcmp(qualifier->value(), "smooth") == 0) { - var->interpolation = ir_var_smooth; - } else if (strcmp(qualifier->value(), "flat") == 0) { - var->interpolation = ir_var_flat; - } 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; - return NULL; - } - } - - // Add the variable to the symbol table - st->symbols->add_variable(var_name->value(), var); - - return var; -} - - -static ir_if * -read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx) -{ - void *ctx = talloc_parent(st); - if (list->length() != 4) { - ir_read_error(st, list, "expected (if ( ...) " - "( ...))"); - return NULL; - } - - s_expression *cond_expr = (s_expression*) list->subexpressions.head->next; - ir_rvalue *condition = read_rvalue(st, cond_expr); - if (condition == NULL) { - ir_read_error(st, 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(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) { - delete iff; - iff = NULL; - } - return iff; -} - - -static ir_loop * -read_loop(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(st); - if (list->length() != 6) { - ir_read_error(st, list, "expected (loop " - " )"); - 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) { - delete loop; - loop = NULL; - } - return loop; -} - - -static ir_return * -read_return(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(st); - if (list->length() != 2) { - ir_read_error(st, list, "expected (return )"); - return NULL; - } - - s_expression *expr = (s_expression*) list->subexpressions.head->next; - - ir_rvalue *retval = read_rvalue(st, expr); - if (retval == NULL) { - ir_read_error(st, NULL, "when reading return value"); - return NULL; - } - - return new(ctx) ir_return(retval); -} - - -static ir_rvalue * -read_rvalue(_mesa_glsl_parse_state *st, 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.get_head()); - if (tag == NULL) { - ir_read_error(st, expr, "expected rvalue tag"); - return NULL; - } - - ir_rvalue *rvalue = read_dereference(st, list); - if (rvalue != NULL || st->error) - return rvalue; - else if (strcmp(tag->value(), "swiz") == 0) { - rvalue = read_swizzle(st, list); - } else if (strcmp(tag->value(), "assign") == 0) { - rvalue = read_assignment(st, list); - } else if (strcmp(tag->value(), "expression") == 0) { - rvalue = read_expression(st, list); - } else if (strcmp(tag->value(), "call") == 0) { - rvalue = read_call(st, list); - } else if (strcmp(tag->value(), "constant") == 0) { - rvalue = read_constant(st, list); - } else { - rvalue = read_texture(st, list); - if (rvalue == NULL && !st->error) - ir_read_error(st, expr, "unrecognized rvalue tag: %s", tag->value()); - } - - return rvalue; -} - -static ir_assignment * -read_assignment(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(st); - if (list->length() != 4) { - ir_read_error(st, list, "expected (assign )"); - return NULL; - } - - s_expression *cond_expr = (s_expression*) list->subexpressions.head->next; - s_expression *lhs_expr = (s_expression*) cond_expr->next; - s_expression *rhs_expr = (s_expression*) lhs_expr->next; - - // FINISHME: Deal with "true" condition - ir_rvalue *condition = read_rvalue(st, cond_expr); - if (condition == NULL) { - ir_read_error(st, NULL, "when reading condition of assignment"); - return NULL; - } - - ir_rvalue *lhs = read_rvalue(st, lhs_expr); - if (lhs == NULL) { - ir_read_error(st, NULL, "when reading left-hand side of assignment"); - return NULL; - } - - ir_rvalue *rhs = read_rvalue(st, rhs_expr); - if (rhs == NULL) { - ir_read_error(st, NULL, "when reading right-hand side of assignment"); - return NULL; - } - - return new(ctx) ir_assignment(lhs, rhs, condition); -} - -static ir_call * -read_call(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(st); - if (list->length() != 3) { - ir_read_error(st, list, "expected (call ( ...))"); - return NULL; - } - - s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next); - s_list *params = SX_AS_LIST(name->next); - if (name == NULL || params == NULL) { - ir_read_error(st, list, "expected (call ( ...))"); - return NULL; - } - - exec_list parameters; - - foreach_iter(exec_list_iterator, it, params->subexpressions) { - s_expression *expr = (s_expression*) it.get(); - ir_rvalue *param = read_rvalue(st, expr); - if (param == NULL) { - ir_read_error(st, list, "when reading parameter to function call"); - return NULL; - } - parameters.push_tail(param); - } - - ir_function *f = st->symbols->get_function(name->value()); - if (f == NULL) { - ir_read_error(st, list, "found call to undefined function %s", - name->value()); - return NULL; - } - - const ir_function_signature *callee = f->matching_signature(¶meters); - if (callee == NULL) { - ir_read_error(st, list, "couldn't find matching signature for function " - "%s", name->value()); - return NULL; - } - - return new(ctx) ir_call(callee, ¶meters); -} - -static ir_expression * -read_expression(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(st); - const unsigned list_length = list->length(); - if (list_length < 4) { - ir_read_error(st, list, "expected (expression " - " [])"); - return NULL; - } - - s_expression *type_expr = (s_expression*) list->subexpressions.head->next; - const glsl_type *type = read_type(st, type_expr); - 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()); - if (op == (ir_expression_operation) -1) { - ir_read_error(st, list, "invalid operator: %s", op_sym->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 %s " - " )", op_sym->value()); - return NULL; - } - } else { - if (list_length != 4) { - ir_read_error(st, list, "expected (expression %s )", - op_sym->value()); - return NULL; - } - } - - s_expression *exp1 = (s_expression*) (op_sym->next); - ir_rvalue *arg1 = read_rvalue(st, exp1); - if (arg1 == NULL) { - ir_read_error(st, NULL, "when reading first operand of %s", - op_sym->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 (arg2 == NULL) { - ir_read_error(st, NULL, "when reading second operand of %s", - op_sym->value()); - return NULL; - } - } - - return new(ctx) ir_expression(op, type, arg1, arg2); -} - -static ir_swizzle * -read_swizzle(_mesa_glsl_parse_state *st, s_list *list) -{ - if (list->length() != 3) { - ir_read_error(st, list, "expected (swiz )"); - return NULL; - } - - 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"); - return NULL; - } - - if (strlen(swiz->value()) > 4) { - ir_read_error(st, list, "expected a valid swizzle; found %s", - swiz->value()); - return NULL; - } - - s_expression *sub = (s_expression*) swiz->next; - if (sub == NULL) { - ir_read_error(st, list, "expected rvalue: (swizzle %s )", - swiz->value()); - return NULL; - } - - ir_rvalue *rvalue = read_rvalue(st, 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"); - - return ir; -} - -static ir_constant * -read_constant(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(st); - if (list->length() != 3) { - ir_read_error(st, list, "expected (constant ( ... ))"); - return NULL; - } - - s_expression *type_expr = (s_expression*) list->subexpressions.head->next; - const glsl_type *type = read_type(st, 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 ( ... ))"); - return NULL; - } - - const glsl_type *const base_type = type->get_base_type(); - - ir_constant_data data; - - // Read in list of values (at most 16). - int k = 0; - foreach_iter(exec_list_iterator, it, values->subexpressions) { - if (k >= 16) { - ir_read_error(st, values, "expected at most 16 numbers"); - return NULL; - } - - s_expression *expr = (s_expression*) it.get(); - - 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"); - 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"); - return NULL; - } - - switch (base_type->base_type) { - case GLSL_TYPE_UINT: { - data.u[k] = value->value(); - break; - } - case GLSL_TYPE_INT: { - data.i[k] = value->value(); - break; - } - case GLSL_TYPE_BOOL: { - data.b[k] = value->value(); - break; - } - default: - ir_read_error(st, values, "unsupported constant type"); - return NULL; - } - } - ++k; - } - - return new(ctx) ir_constant(type, &data); -} - -static ir_dereference * -read_dereference(_mesa_glsl_parse_state *st, 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 * -read_var_ref(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(st); - if (list->length() != 2) { - ir_read_error(st, list, "expected (var_ref )"); - 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 )"); - 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 * -read_array_ref(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(st); - if (list->length() != 3) { - ir_read_error(st, list, "expected (array_ref )"); - 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 * -read_record_ref(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(st); - if (list->length() != 3) { - ir_read_error(st, list, "expected (record_ref )"); - 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 *field = SX_AS_SYMBOL(subj_expr->next); - if (field == NULL) { - ir_read_error(st, list, "expected (record_ref ... )"); - return NULL; - } - 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; -} - -static ir_texture * -read_texture(_mesa_glsl_parse_state *st, s_list *list) -{ - void *ctx = talloc_parent(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; - } - - ir_texture *tex = new(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); - if (sampler == NULL) { - ir_read_error(st, NULL, "when reading sampler in (%s ...)", tag->value()); - 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); - if (tex->coordinate == NULL) { - ir_read_error(st, NULL, "when reading coordinate in (%s ...)", - tag->value()); - 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 ( )"); - return NULL; - } - s_int *offset_x = SX_AS_INT(offset_list->subexpressions.head); - s_int *offset_y = SX_AS_INT(offset_x->next); - s_int *offset_z = SX_AS_INT(offset_y->next); - if (offset_x == NULL || offset_y == NULL || offset_z == NULL) { - ir_read_error(st, offset_list, "expected ( )"); - 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 (proj_as_int && proj_as_int->value() == 1) { - tex->projector = NULL; - } else { - tex->projector = read_rvalue(st, proj_expr); - if (tex->projector == NULL) { - ir_read_error(st, NULL, "when reading projective divide in (%s ..)", - tag->value()); - 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; - } else { - tex->shadow_comparitor = read_rvalue(st, shadow_list); - if (tex->shadow_comparitor == NULL) { - ir_read_error(st, NULL, "when reading shadow comparitor in (%s ..)", - tag->value()); - 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; - } - default: - // tex doesn't have any extra parameters and txf was handled earlier. - break; - }; - } - return tex; -} diff --git a/ir_reader.h b/ir_reader.h deleted file mode 100644 index b6afdc81ab1..00000000000 --- a/ir_reader.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef IR_READER_H -#define IR_READER_H - -#include "ir.h" - -void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, - const char *src); - -#endif /* IR_READER_H */ diff --git a/ir_swizzle_swizzle.cpp b/ir_swizzle_swizzle.cpp deleted file mode 100644 index 0ffb4fa3133..00000000000 --- a/ir_swizzle_swizzle.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_swizzle_swizzle.cpp - * - * Eliminates the second swizzle in a swizzle chain. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -class ir_swizzle_swizzle_visitor : public ir_hierarchical_visitor { -public: - ir_swizzle_swizzle_visitor() - { - progress = false; - } - - virtual ir_visitor_status visit_enter(ir_swizzle *); - - bool progress; -}; - -ir_visitor_status -ir_swizzle_swizzle_visitor::visit_enter(ir_swizzle *ir) -{ - int mask2[4]; - - ir_swizzle *swiz2 = ir->val->as_swizzle(); - if (!swiz2) - return visit_continue; - - memset(&mask2, 0, sizeof(mask2)); - if (swiz2->mask.num_components >= 1) - mask2[0] = swiz2->mask.x; - if (swiz2->mask.num_components >= 2) - mask2[1] = swiz2->mask.y; - if (swiz2->mask.num_components >= 3) - mask2[2] = swiz2->mask.z; - if (swiz2->mask.num_components >= 4) - mask2[3] = swiz2->mask.w; - - if (ir->mask.num_components >= 1) - ir->mask.x = mask2[ir->mask.x]; - if (ir->mask.num_components >= 2) - ir->mask.y = mask2[ir->mask.y]; - if (ir->mask.num_components >= 3) - ir->mask.z = mask2[ir->mask.z]; - if (ir->mask.num_components >= 4) - ir->mask.w = mask2[ir->mask.w]; - - ir->val = swiz2->val; - - this->progress = true; - - return visit_continue; -} - -/** - * Does a copy propagation pass on the code present in the instruction stream. - */ -bool -do_swizzle_swizzle(exec_list *instructions) -{ - ir_swizzle_swizzle_visitor v; - - v.run(instructions); - - return v.progress; -} diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp deleted file mode 100644 index 26449c5a5c4..00000000000 --- a/ir_to_mesa.cpp +++ /dev/null @@ -1,1211 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_to_mesa.cpp - * - * Translates the IR to ARB_fragment_program text if possible, - * printing the result - */ - -#include -#include "ir.h" -#include "ir_visitor.h" -#include "ir_print_visitor.h" -#include "ir_expression_flattening.h" -#include "glsl_types.h" - -extern "C" { -#include "shader/prog_instruction.h" -#include "shader/prog_print.h" -} - -/** - * This struct is a corresponding struct to Mesa prog_src_register, with - * wider fields. - */ -typedef struct ir_to_mesa_src_reg { - int file; /**< PROGRAM_* from Mesa */ - int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ - int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ - int negate; /**< NEGATE_XYZW mask from mesa */ - bool reladdr; /**< Register index should be offset by address reg. */ -} ir_to_mesa_src_reg; - -typedef struct ir_to_mesa_dst_reg { - int file; /**< PROGRAM_* from Mesa */ - int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ - int writemask; /**< Bitfield of WRITEMASK_[XYZW] */ -} ir_to_mesa_dst_reg; - -extern ir_to_mesa_src_reg ir_to_mesa_undef; - -class ir_to_mesa_instruction : public exec_node { -public: - enum prog_opcode op; - ir_to_mesa_dst_reg dst_reg; - ir_to_mesa_src_reg src_reg[3]; - /** Pointer to the ir source this tree came from for debugging */ - ir_instruction *ir; -}; - -class temp_entry : public exec_node { -public: - temp_entry(ir_variable *var, int file, int index) - : file(file), index(index), var(var) - { - /* empty */ - } - - int file; - int index; - ir_variable *var; /* variable that maps to this, if any */ -}; - -class ir_to_mesa_visitor : public ir_visitor { -public: - ir_to_mesa_visitor(); - - int next_temp; - int next_constant; - int next_uniform; - - temp_entry *find_variable_storage(ir_variable *var); - - ir_to_mesa_src_reg get_temp(const glsl_type *type); - - struct ir_to_mesa_src_reg src_reg_for_float(float val); - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_texture *); - virtual void visit(ir_if *); - /*@}*/ - - struct ir_to_mesa_src_reg result; - - /** List of temp_entry */ - exec_list variable_storage; - - /** List of ir_to_mesa_instruction */ - exec_list instructions; - - ir_to_mesa_instruction *ir_to_mesa_emit_op1(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0); - - ir_to_mesa_instruction *ir_to_mesa_emit_op2(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1); - - ir_to_mesa_instruction *ir_to_mesa_emit_op3(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1, - ir_to_mesa_src_reg src2); - - void ir_to_mesa_emit_scalar_op1(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0); - - /* talloc context (the ) */ - void *ctx; -}; - -ir_to_mesa_src_reg ir_to_mesa_undef = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, NEGATE_NONE, false, -}; - -ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP -}; - -ir_to_mesa_dst_reg ir_to_mesa_address_reg = { - PROGRAM_ADDRESS, 0, WRITEMASK_X -}; - -static int swizzle_for_size(int size) -{ - int size_swizzles[4] = { - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), - }; - - return size_swizzles[size - 1]; -} - -/* This list should match up with builtin_variables.h */ -static const struct { - const char *name; - int file; - int index; -} builtin_var_to_mesa_reg[] = { - /* core_vs */ - {"gl_Position", PROGRAM_OUTPUT, VERT_RESULT_HPOS}, - {"gl_PointSize", PROGRAM_OUTPUT, VERT_RESULT_PSIZ}, - - /* core_fs */ - {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS}, - {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE}, - {"gl_FragColor", PROGRAM_OUTPUT, FRAG_ATTRIB_COL0}, - {"gl_FragDepth", PROGRAM_UNDEFINED, FRAG_ATTRIB_WPOS}, /* FINISHME: WPOS.z */ - - /* 110_deprecated_fs */ - {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, - {"gl_SecondaryColor", PROGRAM_INPUT, FRAG_ATTRIB_COL1}, - {"gl_FogFragCoord", PROGRAM_INPUT, FRAG_ATTRIB_FOGC}, - {"gl_TexCoord", PROGRAM_INPUT, FRAG_ATTRIB_TEX0}, /* array */ - - /* 110_deprecated_vs */ - {"gl_Vertex", PROGRAM_INPUT, VERT_ATTRIB_POS}, - {"gl_Normal", PROGRAM_INPUT, VERT_ATTRIB_NORMAL}, - {"gl_Color", PROGRAM_INPUT, VERT_ATTRIB_COLOR0}, - {"gl_SecondaryColor", PROGRAM_INPUT, VERT_ATTRIB_COLOR1}, - {"gl_MultiTexCoord0", PROGRAM_INPUT, VERT_ATTRIB_TEX0}, - {"gl_MultiTexCoord1", PROGRAM_INPUT, VERT_ATTRIB_TEX1}, - {"gl_MultiTexCoord2", PROGRAM_INPUT, VERT_ATTRIB_TEX2}, - {"gl_MultiTexCoord3", PROGRAM_INPUT, VERT_ATTRIB_TEX3}, - {"gl_MultiTexCoord4", PROGRAM_INPUT, VERT_ATTRIB_TEX4}, - {"gl_MultiTexCoord5", PROGRAM_INPUT, VERT_ATTRIB_TEX5}, - {"gl_MultiTexCoord6", PROGRAM_INPUT, VERT_ATTRIB_TEX6}, - {"gl_MultiTexCoord7", PROGRAM_INPUT, VERT_ATTRIB_TEX7}, - {"gl_TexCoord", PROGRAM_OUTPUT, VERT_RESULT_TEX0}, /* array */ - {"gl_FogCoord", PROGRAM_INPUT, VERT_RESULT_FOGC}, - /*{"gl_ClipVertex", PROGRAM_OUTPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ - {"gl_FrontColor", PROGRAM_OUTPUT, VERT_RESULT_COL0}, - {"gl_BackColor", PROGRAM_OUTPUT, VERT_RESULT_BFC0}, - {"gl_FrontSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_COL1}, - {"gl_BackSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_BFC1}, - {"gl_FogFragCoord", PROGRAM_OUTPUT, VERT_RESULT_FOGC}, - - /* 130_vs */ - /*{"gl_VertexID", PROGRAM_INPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ - - {"gl_FragData", PROGRAM_OUTPUT, FRAG_RESULT_DATA0}, /* array */ -}; - -ir_to_mesa_instruction * -ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1, - ir_to_mesa_src_reg src2) -{ - ir_to_mesa_instruction *inst = new(ctx) ir_to_mesa_instruction(); - - inst->op = op; - inst->dst_reg = dst; - inst->src_reg[0] = src0; - inst->src_reg[1] = src1; - inst->src_reg[2] = src2; - inst->ir = ir; - - this->instructions.push_tail(inst); - - return inst; -} - - -ir_to_mesa_instruction * -ir_to_mesa_visitor::ir_to_mesa_emit_op2(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1) -{ - return ir_to_mesa_emit_op3(ir, op, dst, src0, src1, ir_to_mesa_undef); -} - -ir_to_mesa_instruction * -ir_to_mesa_visitor::ir_to_mesa_emit_op1(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0) -{ - return ir_to_mesa_emit_op3(ir, op, dst, - src0, ir_to_mesa_undef, ir_to_mesa_undef); -} - -inline ir_to_mesa_dst_reg -ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) -{ - ir_to_mesa_dst_reg dst_reg; - - dst_reg.file = reg.file; - dst_reg.index = reg.index; - dst_reg.writemask = WRITEMASK_XYZW; - - return dst_reg; -} - -/** - * Emits Mesa scalar opcodes to produce unique answers across channels. - * - * Some Mesa opcodes are scalar-only, like ARB_fp/vp. The src X - * channel determines the result across all channels. So to do a vec4 - * of this operation, we want to emit a scalar per source channel used - * to produce dest channels. - */ -void -ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0) -{ - int i, j; - int done_mask = ~dst.writemask; - - /* Mesa RCP is a scalar operation splatting results to all channels, - * like ARB_fp/vp. So emit as many RCPs as necessary to cover our - * dst channels. - */ - for (i = 0; i < 4; i++) { - int this_mask = (1 << i); - ir_to_mesa_instruction *inst; - ir_to_mesa_src_reg src = src0; - - if (done_mask & this_mask) - continue; - - int src_swiz = GET_SWZ(src.swizzle, i); - for (j = i + 1; j < 4; j++) { - if (!(done_mask & (1 << j)) && GET_SWZ(src.swizzle, j) == src_swiz) { - this_mask |= (1 << j); - } - } - src.swizzle = MAKE_SWIZZLE4(src_swiz, src_swiz, - src_swiz, src_swiz); - - inst = ir_to_mesa_emit_op1(ir, op, - dst, - src); - inst->dst_reg.writemask = this_mask; - done_mask |= this_mask; - } -} - -struct ir_to_mesa_src_reg -ir_to_mesa_visitor::src_reg_for_float(float val) -{ - ir_to_mesa_src_reg src_reg; - - /* FINISHME: This will end up being _mesa_add_unnamed_constant, - * which handles sharing values and sharing channels of vec4 - * constants for small values. - */ - /* FINISHME: Do something with the constant values for now. - */ - (void)val; - src_reg.file = PROGRAM_CONSTANT; - src_reg.index = this->next_constant++; - src_reg.swizzle = SWIZZLE_NOOP; - - return src_reg; -} - -/** - * In the initial pass of codegen, we assign temporary numbers to - * intermediate results. (not SSA -- variable assignments will reuse - * storage). Actual register allocation for the Mesa VM occurs in a - * pass over the Mesa IR later. - */ -ir_to_mesa_src_reg -ir_to_mesa_visitor::get_temp(const glsl_type *type) -{ - ir_to_mesa_src_reg src_reg; - int swizzle[4]; - int i; - - assert(!type->is_array()); - - src_reg.file = PROGRAM_TEMPORARY; - src_reg.index = type->matrix_columns; - src_reg.reladdr = false; - - for (i = 0; i < type->vector_elements; i++) - swizzle[i] = i; - for (; i < 4; i++) - swizzle[i] = type->vector_elements - 1; - src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], - swizzle[2], swizzle[3]); - - return src_reg; -} - -static int -type_size(const struct glsl_type *type) -{ - unsigned int i; - int size; - - switch (type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_BOOL: - if (type->is_matrix()) { - return 4; /* FINISHME: Not all matrices are 4x4. */ - } else { - /* Regardless of size of vector, it gets a vec4. This is bad - * packing for things like floats, but otherwise arrays become a - * mess. Hopefully a later pass over the code can pack scalars - * down if appropriate. - */ - return 1; - } - case GLSL_TYPE_ARRAY: - return type_size(type->fields.array) * type->length; - case GLSL_TYPE_STRUCT: - size = 0; - for (i = 0; i < type->length; i++) { - size += type_size(type->fields.structure[i].type); - } - return size; - default: - assert(0); - } -} - -temp_entry * -ir_to_mesa_visitor::find_variable_storage(ir_variable *var) -{ - - temp_entry *entry; - - foreach_iter(exec_list_iterator, iter, this->variable_storage) { - entry = (temp_entry *)iter.get(); - - if (entry->var == var) - return entry; - } - - return NULL; -} - -void -ir_to_mesa_visitor::visit(ir_variable *ir) -{ - (void)ir; -} - -void -ir_to_mesa_visitor::visit(ir_loop *ir) -{ - assert(!ir->from); - assert(!ir->to); - assert(!ir->increment); - assert(!ir->counter); - - ir_to_mesa_emit_op1(NULL, OPCODE_BGNLOOP, - ir_to_mesa_undef_dst, ir_to_mesa_undef); - - visit_exec_list(&ir->body_instructions, this); - - ir_to_mesa_emit_op1(NULL, OPCODE_ENDLOOP, - ir_to_mesa_undef_dst, ir_to_mesa_undef); -} - -void -ir_to_mesa_visitor::visit(ir_loop_jump *ir) -{ - switch (ir->mode) { - case ir_loop_jump::jump_break: - ir_to_mesa_emit_op1(NULL, OPCODE_BRK, - ir_to_mesa_undef_dst, ir_to_mesa_undef); - break; - case ir_loop_jump::jump_continue: - ir_to_mesa_emit_op1(NULL, OPCODE_CONT, - ir_to_mesa_undef_dst, ir_to_mesa_undef); - break; - } -} - - -void -ir_to_mesa_visitor::visit(ir_function_signature *ir) -{ - assert(0); - (void)ir; -} - -void -ir_to_mesa_visitor::visit(ir_function *ir) -{ - /* Ignore function bodies other than main() -- we shouldn't see calls to - * them since they should all be inlined before we get to ir_to_mesa. - */ - if (strcmp(ir->name, "main") == 0) { - const ir_function_signature *sig; - exec_list empty; - - sig = ir->matching_signature(&empty); - - assert(sig); - - foreach_iter(exec_list_iterator, iter, sig->body) { - ir_instruction *ir = (ir_instruction *)iter.get(); - - ir->accept(this); - } - } -} - -void -ir_to_mesa_visitor::visit(ir_expression *ir) -{ - unsigned int operand; - struct ir_to_mesa_src_reg op[2]; - struct ir_to_mesa_src_reg result_src; - struct ir_to_mesa_dst_reg result_dst; - const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); - const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); - const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - this->result.file = PROGRAM_UNDEFINED; - ir->operands[operand]->accept(this); - if (this->result.file == PROGRAM_UNDEFINED) { - ir_print_visitor v; - printf("Failed to get tree for expression operand:\n"); - ir->operands[operand]->accept(&v); - exit(1); - } - op[operand] = this->result; - - /* Only expression implemented for matrices yet */ - assert(!ir->operands[operand]->type->is_matrix() || - ir->operation == ir_binop_mul); - } - - this->result.file = PROGRAM_UNDEFINED; - - /* Storage for our result. Ideally for an assignment we'd be using - * the actual storage for the result here, instead. - */ - result_src = get_temp(ir->type); - /* convenience for the emit functions below. */ - result_dst = ir_to_mesa_dst_reg_from_src(result_src); - /* Limit writes to the channels that will be used by result_src later. - * This does limit this temp's use as a temporary for multi-instruction - * sequences. - */ - result_dst.writemask = (1 << ir->type->vector_elements) - 1; - - switch (ir->operation) { - case ir_unop_logic_not: - ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, - op[0], src_reg_for_float(0.0)); - break; - case ir_unop_neg: - op[0].negate = ~op[0].negate; - result_src = op[0]; - break; - case ir_unop_exp: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_EXP, result_dst, op[0]); - break; - case ir_unop_exp2: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_EX2, result_dst, op[0]); - break; - case ir_unop_log: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_LOG, result_dst, op[0]); - break; - case ir_unop_log2: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_LG2, result_dst, op[0]); - break; - case ir_unop_sin: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_SIN, result_dst, op[0]); - break; - case ir_unop_cos: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_COS, result_dst, op[0]); - break; - case ir_binop_add: - ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]); - break; - case ir_binop_sub: - ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); - break; - case ir_binop_mul: - if (ir->operands[0]->type->is_matrix() && - !ir->operands[1]->type->is_matrix()) { - if (ir->operands[0]->type->is_scalar()) { - ir_to_mesa_dst_reg dst_column = result_dst; - ir_to_mesa_src_reg src_column = op[0]; - for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - dst_column, src_column, op[1]); - dst_column.index++; - src_column.index++; - } - } else { - ir_to_mesa_dst_reg dst_chan = result_dst; - ir_to_mesa_src_reg src_column = op[0]; - ir_to_mesa_src_reg src_chan = op[1]; - for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { - dst_chan.writemask = (1 << i); - src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - dst_chan, src_column, src_chan); - src_column.index++; - } - } - } else { - assert(!ir->operands[0]->type->is_matrix()); - assert(!ir->operands[1]->type->is_matrix()); - ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], op[1]); - } - break; - case ir_binop_div: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[1]); - ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], result_src); - break; - - case ir_binop_less: - ir_to_mesa_emit_op2(ir, OPCODE_SLT, result_dst, op[0], op[1]); - break; - case ir_binop_greater: - ir_to_mesa_emit_op2(ir, OPCODE_SGT, result_dst, op[0], op[1]); - break; - case ir_binop_lequal: - ir_to_mesa_emit_op2(ir, OPCODE_SLE, result_dst, op[0], op[1]); - break; - case ir_binop_gequal: - ir_to_mesa_emit_op2(ir, OPCODE_SGE, result_dst, op[0], op[1]); - break; - case ir_binop_equal: - ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, op[0], op[1]); - break; - case ir_binop_logic_xor: - case ir_binop_nequal: - ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, op[0], op[1]); - break; - - case ir_binop_logic_or: - /* This could be a saturated add and skip the SNE. */ - ir_to_mesa_emit_op2(ir, OPCODE_ADD, - result_dst, - op[0], op[1]); - - ir_to_mesa_emit_op2(ir, OPCODE_SNE, - result_dst, - result_src, src_reg_for_float(0.0)); - break; - - case ir_binop_logic_and: - /* the bool args are stored as float 0.0 or 1.0, so "mul" gives us "and". */ - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - result_dst, - op[0], op[1]); - break; - - case ir_binop_dot: - if (ir->operands[0]->type == vec4_type) { - assert(ir->operands[1]->type == vec4_type); - ir_to_mesa_emit_op2(ir, OPCODE_DP4, - result_dst, - op[0], op[1]); - } else if (ir->operands[0]->type == vec3_type) { - assert(ir->operands[1]->type == vec3_type); - ir_to_mesa_emit_op2(ir, OPCODE_DP3, - result_dst, - op[0], op[1]); - } else if (ir->operands[0]->type == vec2_type) { - assert(ir->operands[1]->type == vec2_type); - ir_to_mesa_emit_op2(ir, OPCODE_DP2, - result_dst, - op[0], op[1]); - } - break; - case ir_unop_sqrt: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); - ir_to_mesa_emit_op1(ir, OPCODE_RCP, result_dst, result_src); - break; - case ir_unop_rsq: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); - break; - case ir_unop_i2f: - /* Mesa IR lacks types, ints are stored as truncated floats. */ - result_src = op[0]; - break; - case ir_unop_f2i: - ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); - break; - case ir_unop_f2b: - ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, - result_src, src_reg_for_float(0.0)); - break; - case ir_unop_trunc: - ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); - break; - case ir_unop_ceil: - op[0].negate = ~op[0].negate; - ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); - result_src.negate = ~result_src.negate; - break; - case ir_unop_floor: - ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); - break; - case ir_binop_min: - ir_to_mesa_emit_op2(ir, OPCODE_MIN, result_dst, op[0], op[1]); - break; - case ir_binop_max: - ir_to_mesa_emit_op2(ir, OPCODE_MAX, result_dst, op[0], op[1]); - break; - default: - ir_print_visitor v; - printf("Failed to get tree for expression:\n"); - ir->accept(&v); - exit(1); - break; - } - - this->result = result_src; -} - - -void -ir_to_mesa_visitor::visit(ir_swizzle *ir) -{ - ir_to_mesa_src_reg src_reg; - int i; - int swizzle[4]; - - /* Note that this is only swizzles in expressions, not those on the left - * hand side of an assignment, which do write masking. See ir_assignment - * for that. - */ - - ir->val->accept(this); - src_reg = this->result; - assert(src_reg.file != PROGRAM_UNDEFINED); - - for (i = 0; i < 4; i++) { - if (i < ir->type->vector_elements) { - switch (i) { - case 0: - swizzle[i] = ir->mask.x; - break; - case 1: - swizzle[i] = ir->mask.y; - break; - case 2: - swizzle[i] = ir->mask.z; - break; - case 3: - swizzle[i] = ir->mask.w; - break; - } - } else { - /* If the type is smaller than a vec4, replicate the last - * channel out. - */ - swizzle[i] = ir->type->vector_elements - 1; - } - } - - src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], - swizzle[1], - swizzle[2], - swizzle[3]); - - this->result = src_reg; -} - -void -ir_to_mesa_visitor::visit(ir_dereference_variable *ir) -{ - ir_to_mesa_src_reg src_reg; - temp_entry *entry = find_variable_storage(ir->var); - unsigned int i; - bool var_in; - - if (!entry) { - switch (ir->var->mode) { - case ir_var_uniform: - entry = new(ctx) temp_entry(ir->var, PROGRAM_UNIFORM, - this->next_uniform); - this->variable_storage.push_tail(entry); - - this->next_uniform += type_size(ir->var->type); - break; - case ir_var_in: - case ir_var_out: - case ir_var_inout: - var_in = (ir->var->mode == ir_var_in || - ir->var->mode == ir_var_inout); - - for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { - bool in = builtin_var_to_mesa_reg[i].file == PROGRAM_INPUT; - - if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0 && - !(var_in ^ in)) - break; - } - if (i == ARRAY_SIZE(builtin_var_to_mesa_reg)) { - printf("Failed to find builtin for %s variable %s\n", - var_in ? "in" : "out", - ir->var->name); - abort(); - } - entry = new(ctx) temp_entry(ir->var, - builtin_var_to_mesa_reg[i].file, - builtin_var_to_mesa_reg[i].index); - break; - case ir_var_auto: - entry = new(ctx) temp_entry(ir->var, PROGRAM_TEMPORARY, - this->next_temp); - this->variable_storage.push_tail(entry); - - next_temp += type_size(ir->var->type); - break; - } - - if (!entry) { - printf("Failed to make storage for %s\n", ir->var->name); - exit(1); - } - } - - src_reg.file = entry->file; - src_reg.index = entry->index; - /* If the type is smaller than a vec4, replicate the last channel out. */ - src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); - src_reg.reladdr = false; - src_reg.negate = 0; - - this->result = src_reg; -} - -void -ir_to_mesa_visitor::visit(ir_dereference_array *ir) -{ - ir_constant *index; - ir_to_mesa_src_reg src_reg; - - index = ir->array_index->constant_expression_value(); - - /* By the time we make it to this stage, matrices should be broken down - * to vectors. - */ - assert(!ir->type->is_matrix()); - - ir->array->accept(this); - src_reg = this->result; - - if (src_reg.file == PROGRAM_INPUT || - src_reg.file == PROGRAM_OUTPUT) { - assert(index); /* FINISHME: Handle variable indexing of builtins. */ - - src_reg.index += index->value.i[0]; - } else { - if (index) { - src_reg.index += index->value.i[0]; - } else { - ir_to_mesa_src_reg array_base = this->result; - /* Variable index array dereference. It eats the "vec4" of the - * base of the array and an index that offsets the Mesa register - * index. - */ - ir->array_index->accept(this); - - /* FINISHME: This doesn't work when we're trying to do the LHS - * of an assignment. - */ - src_reg.reladdr = true; - ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, - this->result); - - this->result = get_temp(ir->type); - ir_to_mesa_emit_op1(ir, OPCODE_MOV, - ir_to_mesa_dst_reg_from_src(this->result), - src_reg); - } - } - - /* If the type is smaller than a vec4, replicate the last channel out. */ - src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); - - this->result = src_reg; -} - -void -ir_to_mesa_visitor::visit(ir_dereference_record *ir) -{ - unsigned int i; - const glsl_type *struct_type = ir->record->type; - int offset = 0; - - ir->record->accept(this); - - for (i = 0; i < struct_type->length; i++) { - if (strcmp(struct_type->fields.structure[i].name, ir->field) == 0) - break; - offset += type_size(struct_type->fields.structure[i].type); - } - this->result.index += offset; -} - -/** - * We want to be careful in assignment setup to hit the actual storage - * instead of potentially using a temporary like we might with the - * ir_dereference handler. - * - * Thanks to ir_swizzle_swizzle, and ir_vec_index_to_swizzle, we - * should only see potentially one variable array index of a vector, - * and one swizzle, before getting to actual vec4 storage. So handle - * those, then go use ir_dereference to handle the rest. - */ -static struct ir_to_mesa_dst_reg -get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) -{ - struct ir_to_mesa_dst_reg dst_reg; - ir_dereference *deref; - ir_swizzle *swiz; - - /* Use the rvalue deref handler for the most part. We'll ignore - * swizzles in it and write swizzles using writemask, though. - */ - ir->accept(v); - dst_reg = ir_to_mesa_dst_reg_from_src(v->result); - - if ((deref = ir->as_dereference())) { - ir_dereference_array *deref_array = ir->as_dereference_array(); - assert(!deref_array || deref_array->array->type->is_array()); - - ir->accept(v); - } else if ((swiz = ir->as_swizzle())) { - dst_reg.writemask = 0; - if (swiz->mask.num_components >= 1) - dst_reg.writemask |= (1 << swiz->mask.x); - if (swiz->mask.num_components >= 2) - dst_reg.writemask |= (1 << swiz->mask.y); - if (swiz->mask.num_components >= 3) - dst_reg.writemask |= (1 << swiz->mask.z); - if (swiz->mask.num_components >= 4) - dst_reg.writemask |= (1 << swiz->mask.w); - } - - return dst_reg; -} - -void -ir_to_mesa_visitor::visit(ir_assignment *ir) -{ - struct ir_to_mesa_dst_reg l; - struct ir_to_mesa_src_reg r; - - assert(!ir->lhs->type->is_matrix()); - assert(!ir->lhs->type->is_array()); - assert(ir->lhs->type->base_type != GLSL_TYPE_STRUCT); - - l = get_assignment_lhs(ir->lhs, this); - - ir->rhs->accept(this); - r = this->result; - assert(l.file != PROGRAM_UNDEFINED); - assert(r.file != PROGRAM_UNDEFINED); - - if (ir->condition) { - ir_constant *condition_constant; - - condition_constant = ir->condition->constant_expression_value(); - - assert(condition_constant && condition_constant->value.b[0]); - } - - ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); -} - - -void -ir_to_mesa_visitor::visit(ir_constant *ir) -{ - ir_to_mesa_src_reg src_reg; - - assert(ir->type->base_type == GLSL_TYPE_FLOAT || - ir->type->base_type == GLSL_TYPE_UINT || - ir->type->base_type == GLSL_TYPE_INT || - ir->type->base_type == GLSL_TYPE_BOOL); - - /* FINISHME: This will end up being _mesa_add_unnamed_constant, - * which handles sharing values and sharing channels of vec4 - * constants for small values. - */ - /* FINISHME: Do something with the constant values for now. - */ - src_reg.file = PROGRAM_CONSTANT; - src_reg.index = this->next_constant; - src_reg.swizzle = SWIZZLE_NOOP; - src_reg.reladdr = false; - src_reg.negate = 0; - - this->next_constant += type_size(ir->type); - - this->result = src_reg; -} - - -void -ir_to_mesa_visitor::visit(ir_call *ir) -{ - printf("Can't support call to %s\n", ir->callee_name()); - exit(1); -} - - -void -ir_to_mesa_visitor::visit(ir_texture *ir) -{ - assert(0); - - ir->coordinate->accept(this); -} - -void -ir_to_mesa_visitor::visit(ir_return *ir) -{ - assert(0); - - ir->get_value()->accept(this); -} - - -void -ir_to_mesa_visitor::visit(ir_if *ir) -{ - ir_to_mesa_instruction *if_inst, *else_inst = NULL; - - ir->condition->accept(this); - assert(this->result.file != PROGRAM_UNDEFINED); - - if_inst = ir_to_mesa_emit_op1(ir->condition, - OPCODE_IF, ir_to_mesa_undef_dst, - this->result); - - this->instructions.push_tail(if_inst); - - visit_exec_list(&ir->then_instructions, this); - - if (!ir->else_instructions.is_empty()) { - else_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ELSE, - ir_to_mesa_undef_dst, - ir_to_mesa_undef); - visit_exec_list(&ir->then_instructions, this); - } - - if_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ENDIF, - ir_to_mesa_undef_dst, ir_to_mesa_undef); -} - -ir_to_mesa_visitor::ir_to_mesa_visitor() -{ - result.file = PROGRAM_UNDEFINED; - next_temp = 1; - next_constant = 0; - next_uniform = 0; -} - -static struct prog_src_register -mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) -{ - struct prog_src_register mesa_reg; - - mesa_reg.File = reg.file; - assert(reg.index < (1 << INST_INDEX_BITS) - 1); - mesa_reg.Index = reg.index; - mesa_reg.Swizzle = reg.swizzle; - mesa_reg.RelAddr = reg.reladdr; - - return mesa_reg; -} - -static void -set_branchtargets(struct prog_instruction *mesa_instructions, - int num_instructions) -{ - int if_count = 0, loop_count; - int *if_stack, *loop_stack; - int if_stack_pos = 0, loop_stack_pos = 0; - int i, j; - - for (i = 0; i < num_instructions; i++) { - switch (mesa_instructions[i].Opcode) { - case OPCODE_IF: - if_count++; - break; - case OPCODE_BGNLOOP: - loop_count++; - break; - case OPCODE_BRK: - case OPCODE_CONT: - mesa_instructions[i].BranchTarget = -1; - break; - default: - break; - } - } - - if_stack = (int *)calloc(if_count, sizeof(*if_stack)); - loop_stack = (int *)calloc(loop_count, sizeof(*loop_stack)); - - for (i = 0; i < num_instructions; i++) { - switch (mesa_instructions[i].Opcode) { - case OPCODE_IF: - if_stack[if_stack_pos] = i; - if_stack_pos++; - break; - case OPCODE_ELSE: - mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; - if_stack[if_stack_pos - 1] = i; - break; - case OPCODE_ENDIF: - mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; - if_stack_pos--; - break; - case OPCODE_BGNLOOP: - loop_stack[loop_stack_pos] = i; - loop_stack_pos++; - break; - case OPCODE_ENDLOOP: - loop_stack_pos--; - /* Rewrite any breaks/conts at this nesting level (haven't - * already had a BranchTarget assigned) to point to the end - * of the loop. - */ - for (j = loop_stack[loop_stack_pos]; j < i; j++) { - if (mesa_instructions[j].Opcode == OPCODE_BRK || - mesa_instructions[j].Opcode == OPCODE_CONT) { - if (mesa_instructions[j].BranchTarget == -1) { - mesa_instructions[j].BranchTarget = i; - } - } - } - /* The loop ends point at each other. */ - mesa_instructions[i].BranchTarget = loop_stack[loop_stack_pos]; - mesa_instructions[loop_stack[loop_stack_pos]].BranchTarget = i; - default: - break; - } - } - - free(if_stack); -} - -static void -print_program(struct prog_instruction *mesa_instructions, - ir_instruction **mesa_instruction_annotation, - int num_instructions) -{ - ir_instruction *last_ir = NULL; - int i; - - for (i = 0; i < num_instructions; i++) { - struct prog_instruction *mesa_inst = mesa_instructions + i; - ir_instruction *ir = mesa_instruction_annotation[i]; - - if (last_ir != ir && ir) { - ir_print_visitor print; - ir->accept(&print); - printf("\n"); - last_ir = ir; - } - - _mesa_print_instruction(mesa_inst); - } -} - -void -do_ir_to_mesa(exec_list *instructions) -{ - ir_to_mesa_visitor v; - struct prog_instruction *mesa_instructions, *mesa_inst; - ir_instruction **mesa_instruction_annotation; - int i; - - v.ctx = talloc_new(NULL); - visit_exec_list(instructions, &v); - - int num_instructions = 0; - foreach_iter(exec_list_iterator, iter, v.instructions) { - num_instructions++; - } - - mesa_instructions = - (struct prog_instruction *)calloc(num_instructions, - sizeof(*mesa_instructions)); - mesa_instruction_annotation = - (ir_instruction **)calloc(num_instructions, - sizeof(*mesa_instruction_annotation)); - - mesa_inst = mesa_instructions; - i = 0; - foreach_iter(exec_list_iterator, iter, v.instructions) { - ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); - - mesa_inst->Opcode = inst->op; - mesa_inst->DstReg.File = inst->dst_reg.file; - mesa_inst->DstReg.Index = inst->dst_reg.index; - mesa_inst->DstReg.CondMask = COND_TR; - mesa_inst->DstReg.WriteMask = inst->dst_reg.writemask; - mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); - mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); - mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); - mesa_instruction_annotation[i] = inst->ir; - - mesa_inst++; - i++; - } - - set_branchtargets(mesa_instructions, num_instructions); - print_program(mesa_instructions, mesa_instruction_annotation, num_instructions); - - free(mesa_instruction_annotation); - talloc_free(v.ctx); -} diff --git a/ir_validate.cpp b/ir_validate.cpp deleted file mode 100644 index 507e88993f2..00000000000 --- a/ir_validate.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_validate.cpp - * - * Attempts to verify that various invariants of the IR tree are true. - * - * In particular, at the moment it makes sure that no single - * ir_instruction node except for ir_variable appears multiple times - * in the ir tree. ir_variable does appear multiple times: Once as a - * declaration in an exec_list, and multiple times as the endpoint of - * a dereference chain. - */ - -#include -#include "ir.h" -#include "ir_hierarchical_visitor.h" -#include "hash_table.h" - -static unsigned int hash_func(const void *key) -{ - return (unsigned int)(uintptr_t)key; -} - -static int hash_compare_func(const void *key1, const void *key2) -{ - return key1 == key2 ? 0 : 1; -} - - -class ir_validate : public ir_hierarchical_visitor { -public: - ir_validate() - { - this->ht = hash_table_ctor(0, hash_func, hash_compare_func); - - this->callback = ir_validate::validate_ir; - this->data = ht; - } - - ~ir_validate() - { - hash_table_dtor(this->ht); - } - - virtual ir_visitor_status visit(ir_variable *v); - - static void validate_ir(ir_instruction *ir, void *data); - - struct hash_table *ht; -}; - -ir_visitor_status -ir_validate::visit(ir_variable *ir) -{ - /* An ir_variable is the one thing that can (and will) appear multiple times - * in an IR tree. - */ - (void) ir; - return visit_continue; -} - -void -ir_validate::validate_ir(ir_instruction *ir, void *data) -{ - struct hash_table *ht = (struct hash_table *) data; - - if (hash_table_find(ht, ir)) { - printf("Instruction node present twice in ir tree:\n"); - ir->print(); - printf("\n"); - abort(); - } - hash_table_insert(ht, ir, ir); -} - -void -validate_ir_tree(exec_list *instructions) -{ - ir_validate v; - - v.run(instructions); -} diff --git a/ir_variable.cpp b/ir_variable.cpp deleted file mode 100644 index 15a4a92f628..00000000000 --- a/ir_variable.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "ir.h" -#include "glsl_parser_extras.h" -#include "glsl_symbol_table.h" -#include "builtin_variables.h" - -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif - -static ir_variable * -add_variable(const char *name, enum ir_variable_mode mode, int slot, - const glsl_type *type, exec_list *instructions, - glsl_symbol_table *symtab) -{ - ir_variable *var = new(symtab) ir_variable(type, name); - - var->mode = mode; - switch (var->mode) { - case ir_var_in: - var->shader_in = true; - var->read_only = true; - break; - case ir_var_inout: - var->shader_in = true; - var->shader_out = true; - break; - case ir_var_out: - var->shader_out = true; - break; - case ir_var_uniform: - var->shader_in = true; - var->read_only = true; - break; - default: - assert(0); - break; - } - - var->location = slot; - - /* Once the variable is created an initialized, add it to the symbol table - * and add the declaration to the IR stream. - */ - instructions->push_tail(var); - - symtab->add_variable(var->name, var); - return var; -} - - -static void -add_builtin_variable(const builtin_variable *proto, exec_list *instructions, - glsl_symbol_table *symtab) -{ - /* Create a new variable declaration from the description supplied by - * the caller. - */ - const glsl_type *const type = symtab->get_type(proto->type); - - assert(type != NULL); - - add_variable(proto->name, proto->mode, proto->slot, type, instructions, - symtab); -} - - -static void -generate_110_uniforms(exec_list *instructions, - glsl_symbol_table *symtab) -{ - for (unsigned i = 0 - ; i < Elements(builtin_110_deprecated_uniforms) - ; i++) { - add_builtin_variable(& builtin_110_deprecated_uniforms[i], - instructions, symtab); - } - - /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports - * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 - * FINISHME: for now. - */ - const glsl_type *const mat4_array_type = - glsl_type::get_array_instance(symtab, glsl_type::mat4_type, 4); - - add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type, - instructions, symtab); - - /* FINISHME: Add support for gl_DepthRangeParameters */ - /* FINISHME: Add support for gl_ClipPlane[] */ - /* FINISHME: Add support for gl_PointParameters */ - - /* FINISHME: Add support for gl_MaterialParameters - * FINISHME: (glFrontMaterial, glBackMaterial) - */ - - /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_LIGHTS. GL_MAX_TEXTURE_LIGHTS must be - * FINISHME: at least 8, so hard-code 8 for now. - */ - const glsl_type *const light_source_array_type = - glsl_type::get_array_instance(symtab, - symtab->get_type("gl_LightSourceParameters"), 8); - - add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type, - instructions, symtab); - - /* FINISHME: Add support for gl_LightModel */ - /* FINISHME: Add support for gl_FrontLightProduct[], gl_BackLightProduct[] */ - /* FINISHME: Add support for gl_TextureEnvColor[] */ - /* FINISHME: Add support for gl_ObjectPlane*[], gl_EyePlane*[] */ - /* FINISHME: Add support for gl_Fog */ -} - -static void -generate_110_vs_variables(exec_list *instructions, - glsl_symbol_table *symtab) -{ - for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { - add_builtin_variable(& builtin_core_vs_variables[i], - instructions, symtab); - } - - for (unsigned i = 0 - ; i < Elements(builtin_110_deprecated_vs_variables) - ; i++) { - add_builtin_variable(& builtin_110_deprecated_vs_variables[i], - instructions, symtab); - } - generate_110_uniforms(instructions, symtab); - - /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports - * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 - * FINISHME: for now. - */ - const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 4); - - add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type, - instructions, symtab); -} - - -static void -generate_120_vs_variables(exec_list *instructions, - glsl_symbol_table *symtab) -{ - /* GLSL version 1.20 did not add any built-in variables in the vertex - * shader. - */ - generate_110_vs_variables(instructions, symtab); -} - - -static void -generate_130_vs_variables(exec_list *instructions, - glsl_symbol_table *symtab) -{ - void *ctx = symtab; - generate_120_vs_variables(instructions, symtab); - - for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { - add_builtin_variable(& builtin_130_vs_variables[i], - instructions, symtab); - } - - /* FINISHME: The size of this array is implementation dependent based on - * FINISHME: the value of GL_MAX_CLIP_DISTANCES. - */ - const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(ctx, glsl_type::float_type, 8); - - /* FINISHME: gl_ClipDistance needs a real location assigned. */ - add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type, - instructions, symtab); - -} - - -static void -initialize_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - - switch (state->language_version) { - case 110: - generate_110_vs_variables(instructions, state->symbols); - break; - case 120: - generate_120_vs_variables(instructions, state->symbols); - break; - case 130: - generate_130_vs_variables(instructions, state->symbols); - break; - } -} - -static void -generate_110_fs_variables(exec_list *instructions, - glsl_symbol_table *symtab) -{ - for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { - add_builtin_variable(& builtin_core_fs_variables[i], - instructions, symtab); - } - - for (unsigned i = 0 - ; i < Elements(builtin_110_deprecated_fs_variables) - ; i++) { - add_builtin_variable(& builtin_110_deprecated_fs_variables[i], - instructions, symtab); - } - generate_110_uniforms(instructions, symtab); - - /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports - * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 - * FINISHME: for now. - */ - const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 4); - - add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type, - instructions, symtab); -} - - -static void -generate_ARB_draw_buffers_fs_variables(exec_list *instructions, - glsl_symbol_table *symtab, bool warn) -{ - /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_DRAW_BUFFERS. GL_MAX_DRAW_BUFFERS must be - * FINISHME: at least 1, so hard-code 1 for now. - */ - const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 1); - - ir_variable *const fd = - add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0, - vec4_array_type, instructions, symtab); - - if (warn) - fd->warn_extension = "GL_ARB_draw_buffers"; -} - - -static void -generate_120_fs_variables(exec_list *instructions, - glsl_symbol_table *symtab) -{ - generate_110_fs_variables(instructions, symtab); - generate_ARB_draw_buffers_fs_variables(instructions, symtab, false); -} - -static void -generate_130_fs_variables(exec_list *instructions, - glsl_symbol_table *symtab) -{ - void *ctx = symtab; - generate_120_fs_variables(instructions, symtab); - - /* FINISHME: The size of this array is implementation dependent based on - * FINISHME: the value of GL_MAX_CLIP_DISTANCES. - */ - const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(ctx, glsl_type::float_type, 8); - - /* FINISHME: gl_ClipDistance needs a real location assigned. */ - add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type, - instructions, symtab); -} - -static void -initialize_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - - switch (state->language_version) { - case 110: - generate_110_fs_variables(instructions, state->symbols); - break; - case 120: - generate_120_fs_variables(instructions, state->symbols); - break; - case 130: - generate_130_fs_variables(instructions, state->symbols); - break; - } - - - /* Since GL_ARB_draw_buffers is included in GLSL 1.20 and later, we - * can basically ignore any extension settings for it. - */ - if (state->language_version < 120) { - if (state->ARB_draw_buffers_enable) { - generate_ARB_draw_buffers_fs_variables(instructions, state->symbols, - state->ARB_draw_buffers_warn); - } - } -} - -void -_mesa_glsl_initialize_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - switch (state->target) { - case vertex_shader: - initialize_vs_variables(instructions, state); - break; - case geometry_shader: - break; - case fragment_shader: - initialize_fs_variables(instructions, state); - break; - case ir_shader: - fprintf(stderr, "ir reader has no builtin variables"); - exit(1); - break; - } -} diff --git a/ir_vec_index_to_swizzle.cpp b/ir_vec_index_to_swizzle.cpp deleted file mode 100644 index abeb43cd68e..00000000000 --- a/ir_vec_index_to_swizzle.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_vec_index_to_swizzle.cpp - * - * Turns constant indexing into vector types to swizzles. This will - * let other swizzle-aware optimization passes catch these constructs, - * and codegen backends not have to worry about this case. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -/** - * Visitor class for replacing expressions with ir_constant values. - */ - -class ir_vec_index_to_swizzle_visitor : public ir_hierarchical_visitor { -public: - ir_vec_index_to_swizzle_visitor() - { - progress = false; - } - - ir_rvalue *convert_vec_index_to_swizzle(ir_rvalue *val); - - virtual ir_visitor_status visit_enter(ir_expression *); - virtual ir_visitor_status visit_enter(ir_swizzle *); - virtual ir_visitor_status visit_enter(ir_assignment *); - virtual ir_visitor_status visit_enter(ir_return *); - virtual ir_visitor_status visit_enter(ir_call *); - virtual ir_visitor_status visit_enter(ir_if *); - - bool progress; -}; - -ir_rvalue * -ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) -{ - ir_dereference_array *deref = ir->as_dereference_array(); - ir_constant *ir_constant; - - if (!deref) - return ir; - - if (deref->array->type->is_matrix() || deref->array->type->is_array()) - return ir; - - assert(deref->array_index->type->base_type == GLSL_TYPE_INT); - ir_constant = deref->array_index->constant_expression_value(); - if (!ir_constant) - return ir; - - void *ctx = talloc_parent(ir); - this->progress = true; - return new(ctx) ir_swizzle(deref->array, - ir_constant->value.i[0], 0, 0, 0, 1); -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_expression *ir) -{ - unsigned int i; - - for (i = 0; i < ir->get_num_operands(); i++) { - ir->operands[i] = convert_vec_index_to_swizzle(ir->operands[i]); - } - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_swizzle *ir) -{ - /* Can't be hit from normal GLSL, since you can't swizzle a scalar (which - * the result of indexing a vector is. But maybe at some point we'll end up - * using swizzling of scalars for vector construction. - */ - ir->val = convert_vec_index_to_swizzle(ir->val); - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_assignment *ir) -{ - ir->lhs = convert_vec_index_to_swizzle(ir->lhs); - ir->rhs = convert_vec_index_to_swizzle(ir->rhs); - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir) -{ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - ir_rvalue *new_param = convert_vec_index_to_swizzle(param); - - if (new_param != param) { - param->insert_before(new_param); - param->remove(); - } - } - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_return *ir) -{ - if (ir->value) { - ir->value = convert_vec_index_to_swizzle(ir->value); - } - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_if *ir) -{ - ir->condition = convert_vec_index_to_swizzle(ir->condition); - - return visit_continue; -} - -bool -do_vec_index_to_swizzle(exec_list *instructions) -{ - ir_vec_index_to_swizzle_visitor v; - - v.run(instructions); - - return false; -} diff --git a/ir_visitor.h b/ir_visitor.h deleted file mode 100644 index a6f9d2b7ee3..00000000000 --- a/ir_visitor.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef IR_VISITOR_H -#define IR_VISITOR_H - -/** - * Abstract base class of visitors of IR instruction trees - */ -class ir_visitor { -public: - virtual ~ir_visitor() - { - /* empty */ - } - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(class ir_variable *) = 0; - virtual void visit(class ir_function_signature *) = 0; - virtual void visit(class ir_function *) = 0; - virtual void visit(class ir_expression *) = 0; - virtual void visit(class ir_texture *) = 0; - virtual void visit(class ir_swizzle *) = 0; - virtual void visit(class ir_dereference_variable *) = 0; - virtual void visit(class ir_dereference_array *) = 0; - virtual void visit(class ir_dereference_record *) = 0; - virtual void visit(class ir_assignment *) = 0; - virtual void visit(class ir_constant *) = 0; - virtual void visit(class ir_call *) = 0; - virtual void visit(class ir_return *) = 0; - virtual void visit(class ir_if *) = 0; - virtual void visit(class ir_loop *) = 0; - virtual void visit(class ir_loop_jump *) = 0; - /*@}*/ -}; - -#endif /* IR_VISITOR_H */ diff --git a/linker.cpp b/linker.cpp deleted file mode 100644 index ba382fe8816..00000000000 --- a/linker.cpp +++ /dev/null @@ -1,871 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file linker.cpp - * GLSL linker implementation - * - * Given a set of shaders that are to be linked to generate a final program, - * there are three distinct stages. - * - * In the first stage shaders are partitioned into groups based on the shader - * type. All shaders of a particular type (e.g., vertex shaders) are linked - * together. - * - * - Undefined references in each shader are resolve to definitions in - * another shader. - * - Types and qualifiers of uniforms, outputs, and global variables defined - * in multiple shaders with the same name are verified to be the same. - * - Initializers for uniforms and global variables defined - * in multiple shaders with the same name are verified to be the same. - * - * The result, in the terminology of the GLSL spec, is a set of shader - * executables for each processing unit. - * - * After the first stage is complete, a series of semantic checks are performed - * on each of the shader executables. - * - * - Each shader executable must define a \c main function. - * - Each vertex shader executable must write to \c gl_Position. - * - Each fragment shader executable must write to either \c gl_FragData or - * \c gl_FragColor. - * - * In the final stage individual shader executables are linked to create a - * complete exectuable. - * - * - Types of uniforms defined in multiple shader stages with the same name - * are verified to be the same. - * - Initializers for uniforms defined in multiple shader stages with the - * same name are verified to be the same. - * - Types and qualifiers of outputs defined in one stage are verified to - * be the same as the types and qualifiers of inputs defined with the same - * name in a later stage. - * - * \author Ian Romanick - */ -#include -#include -#include - -extern "C" { -#include -} - -#include "main/mtypes.h" -#include "glsl_symbol_table.h" -#include "glsl_parser_extras.h" -#include "ir.h" -#include "ir_optimization.h" -#include "program.h" -#include "hash_table.h" - -/** - * Visitor that determines whether or not a variable is ever written. - */ -class find_assignment_visitor : public ir_hierarchical_visitor { -public: - find_assignment_visitor(const char *name) - : name(name), found(false) - { - /* empty */ - } - - virtual ir_visitor_status visit_enter(ir_assignment *ir) - { - ir_variable *const var = ir->lhs->variable_referenced(); - - if (strcmp(name, var->name) == 0) { - found = true; - return visit_stop; - } - - return visit_continue_with_parent; - } - - bool variable_found() - { - return found; - } - -private: - const char *name; /**< Find writes to a variable with this name. */ - bool found; /**< Was a write to the variable found? */ -}; - - -void -linker_error_printf(glsl_program *prog, const char *fmt, ...) -{ - va_list ap; - - prog->InfoLog = talloc_strdup_append(prog->InfoLog, "error: "); - va_start(ap, fmt); - prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, ap); - va_end(ap); -} - - -void -invalidate_variable_locations(glsl_shader *sh, enum ir_variable_mode mode, - int generic_base) -{ - foreach_list(node, &sh->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != (unsigned) mode)) - continue; - - /* Only assign locations for generic attributes / varyings / etc. - */ - if (var->location >= generic_base) - var->location = -1; - } -} - - -/** - * Determine the number of attribute slots required for a particular type - * - * This code is here because it implements the language rules of a specific - * GLSL version. Since it's a property of the language and not a property of - * types in general, it doesn't really belong in glsl_type. - */ -unsigned -count_attribute_slots(const glsl_type *t) -{ - /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: - * - * "A scalar input counts the same amount against this limit as a vec4, - * so applications may want to consider packing groups of four - * unrelated float inputs together into a vector to better utilize the - * capabilities of the underlying hardware. A matrix input will use up - * multiple locations. The number of locations used will equal the - * number of columns in the matrix." - * - * The spec does not explicitly say how arrays are counted. However, it - * should be safe to assume the total number of slots consumed by an array - * is the number of entries in the array multiplied by the number of slots - * consumed by a single element of the array. - */ - - if (t->is_array()) - return t->array_size() * count_attribute_slots(t->element_type()); - - if (t->is_matrix()) - return t->matrix_columns; - - return 1; -} - - -/** - * Verify that a vertex shader executable meets all semantic requirements - * - * \param shader Vertex shader executable to be verified - */ -bool -validate_vertex_shader_executable(struct glsl_program *prog, - struct glsl_shader *shader) -{ - if (shader == NULL) - return true; - - if (!shader->symbols->get_function("main")) { - linker_error_printf(prog, "vertex shader lacks `main'\n"); - return false; - } - - find_assignment_visitor find("gl_Position"); - find.run(&shader->ir); - if (!find.variable_found()) { - linker_error_printf(prog, - "vertex shader does not write to `gl_Position'\n"); - return false; - } - - return true; -} - - -/** - * Verify that a fragment shader executable meets all semantic requirements - * - * \param shader Fragment shader executable to be verified - */ -bool -validate_fragment_shader_executable(struct glsl_program *prog, - struct glsl_shader *shader) -{ - if (shader == NULL) - return true; - - if (!shader->symbols->get_function("main")) { - linker_error_printf(prog, "fragment shader lacks `main'\n"); - return false; - } - - find_assignment_visitor frag_color("gl_FragColor"); - find_assignment_visitor frag_data("gl_FragData"); - - frag_color.run(&shader->ir); - frag_data.run(&shader->ir); - - if (!frag_color.variable_found() && !frag_data.variable_found()) { - linker_error_printf(prog, "fragment shader does not write to " - "`gl_FragColor' or `gl_FragData'\n"); - return false; - } - - if (frag_color.variable_found() && frag_data.variable_found()) { - linker_error_printf(prog, "fragment shader writes to both " - "`gl_FragColor' and `gl_FragData'\n"); - return false; - } - - return true; -} - - -/** - * Perform validation of uniforms used across multiple shader stages - */ -bool -cross_validate_uniforms(struct glsl_program *prog) -{ - /* Examine all of the uniforms in all of the shaders and cross validate - * them. - */ - glsl_symbol_table uniforms; - for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { - foreach_list(node, &prog->_LinkedShaders[i]->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != ir_var_uniform)) - continue; - - /* If a uniform with this name has already been seen, verify that the - * new instance has the same type. In addition, if the uniforms have - * initializers, the values of the initializers must be the same. - */ - ir_variable *const existing = uniforms.get_variable(var->name); - if (existing != NULL) { - if (var->type != existing->type) { - linker_error_printf(prog, "uniform `%s' declared as type " - "`%s' and type `%s'\n", - var->name, var->type->name, - existing->type->name); - return false; - } - - if (var->constant_value != NULL) { - if (existing->constant_value != NULL) { - if (!var->constant_value->has_value(existing->constant_value)) { - linker_error_printf(prog, "initializers for uniform " - "`%s' have differing values\n", - var->name); - return false; - } - } else - /* If the first-seen instance of a particular uniform did not - * have an initializer but a later instance does, copy the - * initializer to the version stored in the symbol table. - */ - existing->constant_value = - (ir_constant *)var->constant_value->clone(NULL); - } - } else - uniforms.add_variable(var->name, var); - } - } - - return true; -} - - -/** - * Validate that outputs from one stage match inputs of another - */ -bool -cross_validate_outputs_to_inputs(struct glsl_program *prog, - glsl_shader *producer, glsl_shader *consumer) -{ - glsl_symbol_table parameters; - /* FINISHME: Figure these out dynamically. */ - const char *const producer_stage = "vertex"; - const char *const consumer_stage = "fragment"; - - /* Find all shader outputs in the "producer" stage. - */ - foreach_list(node, &producer->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - /* FINISHME: For geometry shaders, this should also look for inout - * FINISHME: variables. - */ - if ((var == NULL) || (var->mode != ir_var_out)) - continue; - - parameters.add_variable(var->name, var); - } - - - /* Find all shader inputs in the "consumer" stage. Any variables that have - * matching outputs already in the symbol table must have the same type and - * qualifiers. - */ - foreach_list(node, &consumer->ir) { - ir_variable *const input = ((ir_instruction *) node)->as_variable(); - - /* FINISHME: For geometry shaders, this should also look for inout - * FINISHME: variables. - */ - if ((input == NULL) || (input->mode != ir_var_in)) - continue; - - ir_variable *const output = parameters.get_variable(input->name); - if (output != NULL) { - /* Check that the types match between stages. - */ - if (input->type != output->type) { - linker_error_printf(prog, - "%s shader output `%s' delcared as " - "type `%s', but %s shader input declared " - "as type `%s'\n", - producer_stage, output->name, - output->type->name, - consumer_stage, input->type->name); - return false; - } - - /* Check that all of the qualifiers match between stages. - */ - if (input->centroid != output->centroid) { - linker_error_printf(prog, - "%s shader output `%s' %s centroid qualifier, " - "but %s shader input %s centroid qualifier\n", - producer_stage, - output->name, - (output->centroid) ? "has" : "lacks", - consumer_stage, - (input->centroid) ? "has" : "lacks"); - return false; - } - - if (input->invariant != output->invariant) { - linker_error_printf(prog, - "%s shader output `%s' %s invariant qualifier, " - "but %s shader input %s invariant qualifier\n", - producer_stage, - output->name, - (output->invariant) ? "has" : "lacks", - consumer_stage, - (input->invariant) ? "has" : "lacks"); - return false; - } - - if (input->interpolation != output->interpolation) { - linker_error_printf(prog, - "%s shader output `%s' specifies %s " - "interpolation qualifier, " - "but %s shader input specifies %s " - "interpolation qualifier\n", - producer_stage, - output->name, - output->interpolation_string(), - consumer_stage, - input->interpolation_string()); - return false; - } - } - } - - return true; -} - - -struct uniform_node { - exec_node link; - struct gl_uniform *u; - unsigned slots; -}; - -void -assign_uniform_locations(struct glsl_program *prog) -{ - /* */ - exec_list uniforms; - unsigned total_uniforms = 0; - hash_table *ht = hash_table_ctor(32, hash_table_string_hash, - hash_table_string_compare); - - for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { - unsigned next_position = 0; - - foreach_list(node, &prog->_LinkedShaders[i]->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != ir_var_uniform)) - continue; - - const unsigned vec4_slots = (var->component_slots() + 3) / 4; - assert(vec4_slots != 0); - - uniform_node *n = (uniform_node *) hash_table_find(ht, var->name); - if (n == NULL) { - n = (uniform_node *) calloc(1, sizeof(struct uniform_node)); - n->u = (gl_uniform *) calloc(vec4_slots, sizeof(struct gl_uniform)); - n->slots = vec4_slots; - - n->u[0].Name = strdup(var->name); - for (unsigned j = 1; j < vec4_slots; j++) - n->u[j].Name = n->u[0].Name; - - hash_table_insert(ht, n, n->u[0].Name); - uniforms.push_tail(& n->link); - total_uniforms += vec4_slots; - } - - if (var->constant_value != NULL) - for (unsigned j = 0; j < vec4_slots; j++) - n->u[j].Initialized = true; - - var->location = next_position; - - for (unsigned j = 0; j < vec4_slots; j++) { - switch (prog->_LinkedShaders[i]->Type) { - case GL_VERTEX_SHADER: - n->u[j].VertPos = next_position; - break; - case GL_FRAGMENT_SHADER: - n->u[j].FragPos = next_position; - break; - case GL_GEOMETRY_SHADER: - /* FINISHME: Support geometry shaders. */ - assert(prog->_LinkedShaders[i]->Type != GL_GEOMETRY_SHADER); - break; - } - - next_position++; - } - } - } - - gl_uniform_list *ul = (gl_uniform_list *) - calloc(1, sizeof(gl_uniform_list)); - - ul->Size = total_uniforms; - ul->NumUniforms = total_uniforms; - ul->Uniforms = (gl_uniform *) calloc(total_uniforms, sizeof(gl_uniform)); - - unsigned idx = 0; - uniform_node *next; - for (uniform_node *node = (uniform_node *) uniforms.head - ; node->link.next != NULL - ; node = next) { - next = (uniform_node *) node->link.next; - - node->link.remove(); - memcpy(&ul->Uniforms[idx], node->u, sizeof(gl_uniform) * node->slots); - idx += node->slots; - - free(node->u); - free(node); - } - - hash_table_dtor(ht); - - prog->Uniforms = ul; -} - - -/** - * Find a contiguous set of available bits in a bitmask - * - * \param used_mask Bits representing used (1) and unused (0) locations - * \param needed_count Number of contiguous bits needed. - * - * \return - * Base location of the available bits on success or -1 on failure. - */ -int -find_available_slots(unsigned used_mask, unsigned needed_count) -{ - unsigned needed_mask = (1 << needed_count) - 1; - const int max_bit_to_test = (8 * sizeof(used_mask)) - needed_count; - - /* The comparison to 32 is redundant, but without it GCC emits "warning: - * cannot optimize possibly infinite loops" for the loop below. - */ - if ((needed_count == 0) || (max_bit_to_test < 0) || (max_bit_to_test > 32)) - return -1; - - for (int i = 0; i <= max_bit_to_test; i++) { - if ((needed_mask & ~used_mask) == needed_mask) - return i; - - needed_mask <<= 1; - } - - return -1; -} - - -bool -assign_attribute_locations(glsl_program *prog, unsigned max_attribute_index) -{ - /* Mark invalid attribute locations as being used. - */ - unsigned used_locations = (max_attribute_index >= 32) - ? ~0 : ~((1 << max_attribute_index) - 1); - - glsl_shader *const sh = prog->_LinkedShaders[0]; - assert(sh->Type == GL_VERTEX_SHADER); - - /* Operate in a total of four passes. - * - * 1. Invalidate the location assignments for all vertex shader inputs. - * - * 2. Assign locations for inputs that have user-defined (via - * glBindVertexAttribLocation) locatoins. - * - * 3. Sort the attributes without assigned locations by number of slots - * required in decreasing order. Fragmentation caused by attribute - * locations assigned by the application may prevent large attributes - * from having enough contiguous space. - * - * 4. Assign locations to any inputs without assigned locations. - */ - - invalidate_variable_locations(sh, ir_var_in, VERT_ATTRIB_GENERIC0); - - if (prog->Attributes != NULL) { - for (unsigned i = 0; i < prog->Attributes->NumParameters; i++) { - ir_variable *const var = - sh->symbols->get_variable(prog->Attributes->Parameters[i].Name); - - /* Note: attributes that occupy multiple slots, such as arrays or - * matrices, may appear in the attrib array multiple times. - */ - if ((var == NULL) || (var->location != -1)) - continue; - - /* From page 61 of the OpenGL 4.0 spec: - * - * "LinkProgram will fail if the attribute bindings assigned by - * BindAttribLocation do not leave not enough space to assign a - * location for an active matrix attribute or an active attribute - * array, both of which require multiple contiguous generic - * attributes." - * - * Previous versions of the spec contain similar language but omit the - * bit about attribute arrays. - * - * Page 61 of the OpenGL 4.0 spec also says: - * - * "It is possible for an application to bind more than one - * attribute name to the same location. This is referred to as - * aliasing. This will only work if only one of the aliased - * attributes is active in the executable program, or if no path - * through the shader consumes more than one attribute of a set - * of attributes aliased to the same location. A link error can - * occur if the linker determines that every path through the - * shader consumes multiple aliased attributes, but - * implementations are not required to generate an error in this - * case." - * - * These two paragraphs are either somewhat contradictory, or I don't - * fully understand one or both of them. - */ - /* FINISHME: The code as currently written does not support attribute - * FINISHME: location aliasing (see comment above). - */ - const int attr = prog->Attributes->Parameters[i].StateIndexes[0]; - const unsigned slots = count_attribute_slots(var->type); - - /* Mask representing the contiguous slots that will be used by this - * attribute. - */ - const unsigned use_mask = (1 << slots) - 1; - - /* Generate a link error if the set of bits requested for this - * attribute overlaps any previously allocated bits. - */ - if ((~(use_mask << attr) & used_locations) != used_locations) { - linker_error_printf(prog, - "insufficient contiguous attribute locations " - "available for vertex shader input `%s'", - var->name); - return false; - } - - var->location = VERT_ATTRIB_GENERIC0 + attr; - used_locations |= (use_mask << attr); - } - } - - /* Temporary storage for the set of attributes that need locations assigned. - */ - struct temp_attr { - unsigned slots; - ir_variable *var; - - /* Used below in the call to qsort. */ - static int compare(const void *a, const void *b) - { - const temp_attr *const l = (const temp_attr *) a; - const temp_attr *const r = (const temp_attr *) b; - - /* Reversed because we want a descending order sort below. */ - return r->slots - l->slots; - } - } to_assign[16]; - - unsigned num_attr = 0; - - foreach_list(node, &sh->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != ir_var_in)) - continue; - - /* The location was explicitly assigned, nothing to do here. - */ - if (var->location != -1) - continue; - - to_assign[num_attr].slots = count_attribute_slots(var->type); - to_assign[num_attr].var = var; - num_attr++; - } - - /* If all of the attributes were assigned locations by the application (or - * are built-in attributes with fixed locations), return early. This should - * be the common case. - */ - if (num_attr == 0) - return true; - - qsort(to_assign, num_attr, sizeof(to_assign[0]), temp_attr::compare); - - for (unsigned i = 0; i < num_attr; i++) { - /* Mask representing the contiguous slots that will be used by this - * attribute. - */ - const unsigned use_mask = (1 << to_assign[i].slots) - 1; - - int location = find_available_slots(used_locations, to_assign[i].slots); - - if (location < 0) { - linker_error_printf(prog, - "insufficient contiguous attribute locations " - "available for vertex shader input `%s'", - to_assign[i].var->name); - return false; - } - - to_assign[i].var->location = VERT_ATTRIB_GENERIC0 + location; - used_locations |= (use_mask << location); - } - - return true; -} - - -void -assign_varying_locations(glsl_shader *producer, glsl_shader *consumer) -{ - /* FINISHME: Set dynamically when geometry shader support is added. */ - unsigned output_index = VERT_RESULT_VAR0; - unsigned input_index = FRAG_ATTRIB_VAR0; - - /* Operate in a total of three passes. - * - * 1. Assign locations for any matching inputs and outputs. - * - * 2. Mark output variables in the producer that do not have locations as - * not being outputs. This lets the optimizer eliminate them. - * - * 3. Mark input variables in the consumer that do not have locations as - * not being inputs. This lets the optimizer eliminate them. - */ - - invalidate_variable_locations(producer, ir_var_out, VERT_RESULT_VAR0); - invalidate_variable_locations(consumer, ir_var_in, FRAG_ATTRIB_VAR0); - - foreach_list(node, &producer->ir) { - ir_variable *const output_var = ((ir_instruction *) node)->as_variable(); - - if ((output_var == NULL) || (output_var->mode != ir_var_out) - || (output_var->location != -1)) - continue; - - ir_variable *const input_var = - consumer->symbols->get_variable(output_var->name); - - if ((input_var == NULL) || (input_var->mode != ir_var_in)) - continue; - - assert(input_var->location == -1); - - /* FINISHME: Location assignment will need some changes when arrays, - * FINISHME: matrices, and structures are allowed as shader inputs / - * FINISHME: outputs. - */ - output_var->location = output_index; - input_var->location = input_index; - - output_index++; - input_index++; - } - - foreach_list(node, &producer->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != ir_var_out)) - continue; - - /* An 'out' variable is only really a shader output if its value is read - * by the following stage. - */ - var->shader_out = (var->location != -1); - } - - foreach_list(node, &consumer->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != ir_var_in)) - continue; - - /* An 'in' variable is only really a shader input if its value is written - * by the previous stage. - */ - var->shader_in = (var->location != -1); - } -} - - -void -link_shaders(struct glsl_program *prog) -{ - prog->LinkStatus = false; - prog->Validated = false; - prog->_Used = false; - - if (prog->InfoLog != NULL) - talloc_free(prog->InfoLog); - - prog->InfoLog = talloc_strdup(NULL, ""); - - /* Separate the shaders into groups based on their type. - */ - struct glsl_shader **vert_shader_list; - unsigned num_vert_shaders = 0; - struct glsl_shader **frag_shader_list; - unsigned num_frag_shaders = 0; - - vert_shader_list = (struct glsl_shader **) - calloc(2 * prog->NumShaders, sizeof(struct glsl_shader *)); - frag_shader_list = &vert_shader_list[prog->NumShaders]; - - for (unsigned i = 0; i < prog->NumShaders; i++) { - switch (prog->Shaders[i]->Type) { - case GL_VERTEX_SHADER: - vert_shader_list[num_vert_shaders] = prog->Shaders[i]; - num_vert_shaders++; - break; - case GL_FRAGMENT_SHADER: - frag_shader_list[num_frag_shaders] = prog->Shaders[i]; - num_frag_shaders++; - break; - case GL_GEOMETRY_SHADER: - /* FINISHME: Support geometry shaders. */ - assert(prog->Shaders[i]->Type != GL_GEOMETRY_SHADER); - break; - } - } - - /* FINISHME: Implement intra-stage linking. */ - assert(num_vert_shaders <= 1); - assert(num_frag_shaders <= 1); - - /* Verify that each of the per-target executables is valid. - */ - if (!validate_vertex_shader_executable(prog, vert_shader_list[0]) - || !validate_fragment_shader_executable(prog, frag_shader_list[0])) - goto done; - - - prog->_LinkedShaders = (struct glsl_shader **) - calloc(2, sizeof(struct glsl_shader *)); - prog->_NumLinkedShaders = 0; - - if (num_vert_shaders > 0) { - prog->_LinkedShaders[prog->_NumLinkedShaders] = vert_shader_list[0]; - prog->_NumLinkedShaders++; - } - - if (num_frag_shaders > 0) { - prog->_LinkedShaders[prog->_NumLinkedShaders] = frag_shader_list[0]; - prog->_NumLinkedShaders++; - } - - /* Here begins the inter-stage linking phase. Some initial validation is - * performed, then locations are assigned for uniforms, attributes, and - * varyings. - */ - if (cross_validate_uniforms(prog)) { - /* Validate the inputs of each stage with the output of the preceeding - * stage. - */ - for (unsigned i = 1; i < prog->_NumLinkedShaders; i++) { - if (!cross_validate_outputs_to_inputs(prog, - prog->_LinkedShaders[i - 1], - prog->_LinkedShaders[i])) - goto done; - } - - prog->LinkStatus = true; - } - - /* FINISHME: Perform whole-program optimization here. */ - - assign_uniform_locations(prog); - - if (prog->_LinkedShaders[0]->Type == GL_VERTEX_SHADER) - /* FINISHME: The value of the max_attribute_index parameter is - * FINISHME: implementation dependent based on the value of - * FINISHME: GL_MAX_VERTEX_ATTRIBS. GL_MAX_VERTEX_ATTRIBS must be - * FINISHME: at least 16, so hardcode 16 for now. - */ - if (!assign_attribute_locations(prog, 16)) - goto done; - - for (unsigned i = 1; i < prog->_NumLinkedShaders; i++) - assign_varying_locations(prog->_LinkedShaders[i - 1], - prog->_LinkedShaders[i]); - - /* FINISHME: Assign fragment shader output locations. */ - -done: - free(vert_shader_list); -} diff --git a/list.h b/list.h deleted file mode 100644 index 7732d66d7a6..00000000000 --- a/list.h +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Copyright © 2008, 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file list.h - * \brief Doubly-linked list abstract container type. - * - * Each doubly-linked list has a sentinal head and tail node. These nodes - * contain no data. The head sentinal can be identified by its \c prev - * pointer being \c NULL. The tail sentinal can be identified by its - * \c next pointer being \c NULL. - * - * A list is empty if either the head sentinal's \c next pointer points to the - * tail sentinal or the tail sentinal's \c prev poiner points to the head - * sentinal. - * - * Instead of tracking two separate \c node structures and a \c list structure - * that points to them, the sentinal nodes are in a single structure. Noting - * that each sentinal node always has one \c NULL pointer, the \c NULL - * pointers occupy the same memory location. In the \c list structure - * contains a the following: - * - * - A \c head pointer that represents the \c next pointer of the - * head sentinal node. - * - A \c tail pointer that represents the \c prev pointer of the head - * sentinal node and the \c next pointer of the tail sentinal node. This - * pointer is \b always \c NULL. - * - A \c tail_prev pointer that represents the \c prev pointer of the - * tail sentinal node. - * - * Therefore, if \c head->next is \c NULL or \c tail_prev->prev is \c NULL, - * the list is empty. - * - * To anyone familiar with "exec lists" on the Amiga, this structure should - * be immediately recognizable. See the following link for the original Amiga - * operating system documentation on the subject. - * - * http://www.natami.net/dev/Libraries_Manual_guide/node02D7.html - * - * \author Ian Romanick - */ - -#pragma once -#ifndef LIST_CONTAINER_H -#define LIST_CONTAINER_H - -#ifndef __cplusplus -#include -#include -#else -extern "C" { -#include -} -#endif - -#include - -struct exec_node { - struct exec_node *next; - struct exec_node *prev; - -#ifdef __cplusplus - /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = talloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * talloc_free in that case. */ - static void operator delete(void *node) - { - talloc_free(node); - } - - exec_node() : next(NULL), prev(NULL) - { - /* empty */ - } - - const exec_node *get_next() const - { - return next; - } - - exec_node *get_next() - { - return next; - } - - const exec_node *get_prev() const - { - return prev; - } - - exec_node *get_prev() - { - return prev; - } - - void remove() - { - next->prev = prev; - prev->next = next; - next = NULL; - prev = NULL; - } - - /** - * Link a node with itself - * - * This creates a sort of degenerate list that is occasionally useful. - */ - void self_link() - { - next = this; - prev = this; - } - - /** - * Insert a node in the list after the current node - */ - void insert_after(exec_node *after) - { - after->next = this->next; - after->prev = this; - - this->next->prev = after; - this->next = after; - } - /** - * Insert a node in the list before the current node - */ - void insert_before(exec_node *before) - { - before->next = this; - before->prev = this->prev; - - this->prev->next = before; - this->prev = before; - } - - /** - * Is this the sentinal at the tail of the list? - */ - bool is_tail_sentinal() const - { - return this->next == NULL; - } - - /** - * Is this the sentinal at the head of the list? - */ - bool is_head_sentinal() const - { - return this->prev == NULL; - } -#endif -}; - - -#ifdef __cplusplus -/* This macro will not work correctly if `t' uses virtual inheritance. If you - * are using virtual inheritance, you deserve a slow and painful death. Enjoy! - */ -#define exec_list_offsetof(t, f, p) \ - (((char *) &((t *) p)->f) - ((char *) p)) -#else -#define exec_list_offsetof(t, f, p) offsetof(t, f) -#endif - -/** - * Get a pointer to the structure containing an exec_node - * - * Given a pointer to an \c exec_node embedded in a structure, get a pointer to - * the containing structure. - * - * \param type Base type of the structure containing the node - * \param node Pointer to the \c exec_node - * \param field Name of the field in \c type that is the embedded \c exec_node - */ -#define exec_node_data(type, node, field) \ - ((type *) (((char *) node) - exec_list_offsetof(type, field, node))) - -#ifdef __cplusplus -struct exec_node; - -class iterator { -public: - void next() - { - } - - void *get() - { - return NULL; - } - - bool has_next() const - { - return false; - } -}; - -class exec_list_iterator : public iterator { -public: - exec_list_iterator(exec_node *n) : node(n), _next(n->next) - { - /* empty */ - } - - void next() - { - node = _next; - _next = node->next; - } - - void remove() - { - node->remove(); - } - - exec_node *get() - { - return node; - } - - bool has_next() const - { - return _next != NULL; - } - -private: - exec_node *node; - exec_node *_next; -}; - -#define foreach_iter(iter_type, iter, container) \ - for (iter_type iter = (container) . iterator(); iter.has_next(); iter.next()) -#endif - - -struct exec_list { - struct exec_node *head; - struct exec_node *tail; - struct exec_node *tail_pred; - -#ifdef __cplusplus - exec_list() - { - make_empty(); - } - - void make_empty() - { - head = (exec_node *) & tail; - tail = NULL; - tail_pred = (exec_node *) & head; - } - - bool is_empty() const - { - /* There are three ways to test whether a list is empty or not. - * - * - Check to see if the \c head points to the \c tail. - * - Check to see if the \c tail_pred points to the \c head. - * - Check to see if the \c head is the sentinal node by test whether its - * \c next pointer is \c NULL. - * - * The first two methods tend to generate better code on modern systems - * because they save a pointer dereference. - */ - return head == (exec_node *) &tail; - } - - const exec_node *get_head() const - { - return !is_empty() ? head : NULL; - } - - exec_node *get_head() - { - return !is_empty() ? head : NULL; - } - - const exec_node *get_tail() const - { - return !is_empty() ? tail_pred : NULL; - } - - exec_node *get_tail() - { - return !is_empty() ? tail_pred : NULL; - } - - void push_head(exec_node *n) - { - n->next = head; - n->prev = (exec_node *) &head; - - n->next->prev = n; - head = n; - } - - void push_tail(exec_node *n) - { - n->next = (exec_node *) &tail; - n->prev = tail_pred; - - n->prev->next = n; - tail_pred = n; - } - - void push_degenerate_list_at_head(exec_node *n) - { - assert(n->prev->next == n); - - n->prev->next = head; - head->prev = n->prev; - n->prev = (exec_node *) &head; - head = n; - } - - /** - * Move all of the nodes from this list to the target list - */ - void move_nodes_to(exec_list *target) - { - if (is_empty()) { - target->make_empty(); - } else { - target->head = head; - target->tail = NULL; - target->tail_pred = tail_pred; - - target->head->prev = (exec_node *) &target->head; - target->tail_pred->next = (exec_node *) &target->tail; - - make_empty(); - } - } - - exec_list_iterator iterator() - { - return exec_list_iterator(head); - } - - exec_list_iterator iterator() const - { - return exec_list_iterator((exec_node *) head); - } -#endif -}; - -#define foreach_list(__node, __list) \ - for (exec_node * __node = (__list)->head \ - ; (__node)->next != NULL \ - ; (__node) = (__node)->next) - -#define foreach_list_const(__node, __list) \ - for (const exec_node * __node = (__list)->head \ - ; (__node)->next != NULL \ - ; (__node) = (__node)->next) - -#define foreach_list_typed(__type, __node, __field, __list) \ - for (__type * __node = \ - exec_node_data(__type, (__list)->head, __field); \ - (__node)->__field.next != NULL; \ - (__node) = exec_node_data(__type, (__node)->__field.next, __field)) - -#define foreach_list_typed_const(__type, __node, __field, __list) \ - for (const __type * __node = \ - exec_node_data(__type, (__list)->head, __field); \ - (__node)->__field.next != NULL; \ - (__node) = exec_node_data(__type, (__node)->__field.next, __field)) - -#endif /* LIST_CONTAINER_H */ diff --git a/main.cpp b/main.cpp deleted file mode 100644 index dcd9bd69c0c..00000000000 --- a/main.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include -#include - -#include -#include -#include -#include - -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_parser.h" -#include "ir_optimization.h" -#include "ir_print_visitor.h" -#include "program.h" - -/* Returned string will have 'ctx' as its talloc owner. */ -static char * -load_text_file(void *ctx, const char *file_name, size_t *size) -{ - char *text = NULL; - struct stat st; - ssize_t total_read = 0; - int fd = open(file_name, O_RDONLY); - - *size = 0; - if (fd < 0) { - 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'; - *size = total_read; - } - } - - close(fd); - - return text; -} - - -void -usage_fail(const char *name) -{ - printf("%s \n", name); - exit(EXIT_FAILURE); -} - - -int dump_ast = 0; -int dump_lir = 0; -int do_link = 0; - -const struct option compiler_opts[] = { - { "dump-ast", 0, &dump_ast, 1 }, - { "dump-lir", 0, &dump_lir, 1 }, - { "link", 0, &do_link, 1 }, - { NULL, 0, NULL, 0 } -}; - -void -compile_shader(struct glsl_shader *shader) -{ - struct _mesa_glsl_parse_state *state; - - state = talloc_zero(talloc_parent(shader), struct _mesa_glsl_parse_state); - - switch (shader->Type) { - case GL_VERTEX_SHADER: state->target = vertex_shader; break; - case GL_FRAGMENT_SHADER: state->target = fragment_shader; break; - case GL_GEOMETRY_SHADER: state->target = geometry_shader; break; - } - - state->scanner = NULL; - state->translation_unit.make_empty(); - state->symbols = new(shader) glsl_symbol_table; - state->info_log = talloc_strdup(shader, ""); - state->error = false; - state->temp_index = 0; - state->loop_or_switch_nesting = NULL; - state->ARB_texture_rectangle_enable = true; - - /* Create a new context for the preprocessor output. Ultimately, this - * should probably be the parser context, but there isn't one yet. - */ - const char *source = shader->Source; - state->error = preprocess(shader, &source, &state->info_log); - - if (!state->error) { - _mesa_glsl_lexer_ctor(state, source); - _mesa_glsl_parse(state); - _mesa_glsl_lexer_dtor(state); - } - - if (dump_ast) { - foreach_list_const(n, &state->translation_unit) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - printf("\n\n"); - } - - shader->ir.make_empty(); - if (!state->error && !state->translation_unit.is_empty()) - _mesa_ast_to_hir(&shader->ir, state); - - validate_ir_tree(&shader->ir); - - /* Optimization passes */ - if (!state->error && !shader->ir.is_empty()) { - bool progress; - do { - progress = false; - - progress = do_function_inlining(&shader->ir) || progress; - progress = do_if_simplification(&shader->ir) || progress; - progress = do_copy_propagation(&shader->ir) || progress; - progress = do_dead_code_local(&shader->ir) || progress; - progress = do_dead_code_unlinked(&shader->ir) || progress; - progress = do_constant_variable_unlinked(&shader->ir) || progress; - progress = do_constant_folding(&shader->ir) || progress; - progress = do_vec_index_to_swizzle(&shader->ir) || progress; - progress = do_swizzle_swizzle(&shader->ir) || progress; - } while (progress); - } - - validate_ir_tree(&shader->ir); - - /* Print out the resulting IR */ - if (!state->error && dump_lir) { - _mesa_print_ir(&shader->ir, state); - } - - shader->symbols = state->symbols; - shader->CompileStatus = !state->error; - - if (shader->InfoLog) - talloc_free(shader->InfoLog); - - shader->InfoLog = state->info_log; - - talloc_free(state); - - return; -} - -int -main(int argc, char **argv) -{ - int status = EXIT_SUCCESS; - - int c; - int idx = 0; - while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1) - /* empty */ ; - - - if (argc <= optind) - usage_fail(argv[0]); - - struct glsl_program *whole_program; - - whole_program = talloc_zero (NULL, struct glsl_program); - assert(whole_program != NULL); - - for (/* empty */; argc > optind; optind++) { - whole_program->Shaders = (struct glsl_shader **) - talloc_realloc(whole_program, whole_program->Shaders, - struct glsl_shader *, whole_program->NumShaders + 1); - assert(whole_program->Shaders != NULL); - - struct glsl_shader *shader = talloc_zero(whole_program, glsl_shader); - - whole_program->Shaders[whole_program->NumShaders] = shader; - whole_program->NumShaders++; - - const unsigned len = strlen(argv[optind]); - if (len < 6) - usage_fail(argv[0]); - - const char *const ext = & argv[optind][len - 5]; - if (strncmp(".vert", ext, 5) == 0) - shader->Type = GL_VERTEX_SHADER; - else if (strncmp(".geom", ext, 5) == 0) - shader->Type = GL_GEOMETRY_SHADER; - else if (strncmp(".frag", ext, 5) == 0) - shader->Type = GL_FRAGMENT_SHADER; - else - usage_fail(argv[0]); - - shader->Source = load_text_file(whole_program, - argv[optind], &shader->SourceLen); - if (shader->Source == NULL) { - printf("File \"%s\" does not exist.\n", argv[optind]); - exit(EXIT_FAILURE); - } - - compile_shader(shader); - - if (!shader->CompileStatus) { - printf("Info log for %s:\n%s\n", argv[optind], shader->InfoLog); - status = EXIT_FAILURE; - break; - } - } - - if ((status == EXIT_SUCCESS) && do_link) { - link_shaders(whole_program); - status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE; - } - - talloc_free(whole_program); - - return status; -} diff --git a/main/imports.h b/main/imports.h deleted file mode 100644 index d2197342c04..00000000000 --- a/main/imports.h +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -#define _mesa_malloc(x) malloc(x) -#define _mesa_free(x) free(x) -#define _mesa_calloc(x) calloc(1,x) diff --git a/main/mtypes.h b/main/mtypes.h deleted file mode 100644 index 06e2dd4b540..00000000000 --- a/main/mtypes.h +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file mtypes.h - * Main Mesa data structures. - * - * Please try to mark derived values with a leading underscore ('_'). - */ - -#ifndef MTYPES_H -#define MTYPES_H - -#define MAX_DRAW_BUFFERS 8 -#define MAX_VARYING 16 - -#include - -/** - * Indexes for vertex program attributes. - * GL_NV_vertex_program aliases generic attributes over the conventional - * attributes. In GL_ARB_vertex_program shader the aliasing is optional. - * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the - * generic attributes are distinct/separate). - */ -typedef enum -{ - VERT_ATTRIB_POS = 0, - VERT_ATTRIB_WEIGHT = 1, - VERT_ATTRIB_NORMAL = 2, - VERT_ATTRIB_COLOR0 = 3, - VERT_ATTRIB_COLOR1 = 4, - VERT_ATTRIB_FOG = 5, - VERT_ATTRIB_COLOR_INDEX = 6, - VERT_ATTRIB_POINT_SIZE = 6, /*alias*/ - VERT_ATTRIB_EDGEFLAG = 7, - VERT_ATTRIB_TEX0 = 8, - VERT_ATTRIB_TEX1 = 9, - VERT_ATTRIB_TEX2 = 10, - VERT_ATTRIB_TEX3 = 11, - VERT_ATTRIB_TEX4 = 12, - VERT_ATTRIB_TEX5 = 13, - VERT_ATTRIB_TEX6 = 14, - VERT_ATTRIB_TEX7 = 15, - VERT_ATTRIB_GENERIC0 = 16, - VERT_ATTRIB_GENERIC1 = 17, - VERT_ATTRIB_GENERIC2 = 18, - VERT_ATTRIB_GENERIC3 = 19, - VERT_ATTRIB_GENERIC4 = 20, - VERT_ATTRIB_GENERIC5 = 21, - VERT_ATTRIB_GENERIC6 = 22, - VERT_ATTRIB_GENERIC7 = 23, - VERT_ATTRIB_GENERIC8 = 24, - VERT_ATTRIB_GENERIC9 = 25, - VERT_ATTRIB_GENERIC10 = 26, - VERT_ATTRIB_GENERIC11 = 27, - VERT_ATTRIB_GENERIC12 = 28, - VERT_ATTRIB_GENERIC13 = 29, - VERT_ATTRIB_GENERIC14 = 30, - VERT_ATTRIB_GENERIC15 = 31, - VERT_ATTRIB_MAX = 32 -} gl_vert_attrib; - -/** - * Bitflags for vertex attributes. - * These are used in bitfields in many places. - */ -/*@{*/ -#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) -#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) -#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) -#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) -#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) -#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) -#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) -#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG) -#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) -#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) -#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) -#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) -#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) -#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) -#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) -#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) -#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) -#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) -#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) -#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) -#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) -#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) -#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) -#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) -#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) -#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) -#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) -#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) -#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) -#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) -#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) -#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) - -#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) -#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) -/*@}*/ - - -/** - * Indexes for vertex program result attributes - */ -typedef enum -{ - VERT_RESULT_HPOS = 0, - VERT_RESULT_COL0 = 1, - VERT_RESULT_COL1 = 2, - VERT_RESULT_FOGC = 3, - VERT_RESULT_TEX0 = 4, - VERT_RESULT_TEX1 = 5, - VERT_RESULT_TEX2 = 6, - VERT_RESULT_TEX3 = 7, - VERT_RESULT_TEX4 = 8, - VERT_RESULT_TEX5 = 9, - VERT_RESULT_TEX6 = 10, - VERT_RESULT_TEX7 = 11, - VERT_RESULT_PSIZ = 12, - VERT_RESULT_BFC0 = 13, - VERT_RESULT_BFC1 = 14, - VERT_RESULT_EDGE = 15, - VERT_RESULT_VAR0 = 16, /**< shader varying */ - VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) -} gl_vert_result; - - -/** - * Indexes for fragment program input attributes. - */ -typedef enum -{ - FRAG_ATTRIB_WPOS = 0, - FRAG_ATTRIB_COL0 = 1, - FRAG_ATTRIB_COL1 = 2, - FRAG_ATTRIB_FOGC = 3, - FRAG_ATTRIB_TEX0 = 4, - FRAG_ATTRIB_TEX1 = 5, - FRAG_ATTRIB_TEX2 = 6, - FRAG_ATTRIB_TEX3 = 7, - FRAG_ATTRIB_TEX4 = 8, - FRAG_ATTRIB_TEX5 = 9, - FRAG_ATTRIB_TEX6 = 10, - FRAG_ATTRIB_TEX7 = 11, - FRAG_ATTRIB_FACE = 12, /**< front/back face */ - FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ - FRAG_ATTRIB_VAR0 = 14, /**< shader varying */ - FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) -} gl_frag_attrib; - -/** - * Bitflags for fragment program input attributes. - */ -/*@{*/ -#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) -#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) -#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) -#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) -#define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE) -#define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC) -#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) -#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1) -#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2) -#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3) -#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4) -#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5) -#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6) -#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7) -#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0) - -#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U)) -#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V)) - -#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \ - FRAG_BIT_TEX1| \ - FRAG_BIT_TEX2| \ - FRAG_BIT_TEX3| \ - FRAG_BIT_TEX4| \ - FRAG_BIT_TEX5| \ - FRAG_BIT_TEX6| \ - FRAG_BIT_TEX7) -/*@}*/ - - -/** - * Fragment program results - */ -typedef enum -{ - FRAG_RESULT_DEPTH = 0, - FRAG_RESULT_COLOR = 1, - FRAG_RESULT_DATA0 = 2, - FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) -} gl_frag_result; - -/** - * Names of the various vertex/fragment program register files, etc. - * - * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) - * All values should fit in a 4-bit field. - * - * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, - * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to - * be "uniform" variables since they can only be set outside glBegin/End. - * They're also all stored in the same Parameters array. - */ -typedef enum -{ - PROGRAM_TEMPORARY, /**< machine->Temporary[] */ - PROGRAM_INPUT, /**< machine->Inputs[] */ - PROGRAM_OUTPUT, /**< machine->Outputs[] */ - PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */ - PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ - PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */ - PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ - PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ - PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ - PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ - PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ - PROGRAM_ADDRESS, /**< machine->AddressReg */ - PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ - PROGRAM_UNDEFINED, /**< Invalid/TBD value */ - PROGRAM_FILE_MAX -} gl_register_file; - -/** - * An index for each type of texture object. These correspond to the GL - * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. - * Note: the order is from highest priority to lowest priority. - */ -typedef enum -{ - TEXTURE_2D_ARRAY_INDEX, - TEXTURE_1D_ARRAY_INDEX, - TEXTURE_CUBE_INDEX, - TEXTURE_3D_INDEX, - TEXTURE_RECT_INDEX, - TEXTURE_2D_INDEX, - TEXTURE_1D_INDEX, - NUM_TEXTURE_TARGETS -} gl_texture_index; - -#endif /* MTYPES_H */ diff --git a/main/simple_list.h b/main/simple_list.h deleted file mode 100644 index 5ef39e14cc6..00000000000 --- a/main/simple_list.h +++ /dev/null @@ -1,235 +0,0 @@ -/** - * \file simple_list.h - * Simple macros for type-safe, intrusive lists. - * - * Intended to work with a list sentinal which is created as an empty - * list. Insert & delete are O(1). - * - * \author - * (C) 1997, Keith Whitwell - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _SIMPLE_LIST_H -#define _SIMPLE_LIST_H - -struct simple_node { - struct simple_node *next; - struct simple_node *prev; -}; - -/** - * Remove an element from list. - * - * \param elem element to remove. - */ -#define remove_from_list(elem) \ -do { \ - (elem)->next->prev = (elem)->prev; \ - (elem)->prev->next = (elem)->next; \ -} while (0) - -/** - * Insert an element to the list head. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_head(list, elem) \ -do { \ - (elem)->prev = list; \ - (elem)->next = (list)->next; \ - (list)->next->prev = elem; \ - (list)->next = elem; \ -} while(0) - -/** - * Insert an element to the list tail. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_tail(list, elem) \ -do { \ - (elem)->next = list; \ - (elem)->prev = (list)->prev; \ - (list)->prev->next = elem; \ - (list)->prev = elem; \ -} while(0) - -/** - * Move an element to the list head. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_head(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_head(list, elem); \ -} while (0) - -/** - * Move an element to the list tail. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_tail(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_tail(list, elem); \ -} while (0) - -/** - * Consatinate a cyclic list to a list - * - * Appends the sequence of nodes starting with \c tail to the list \c head. - * A "cyclic list" is a list that does not have a sentinal node. This means - * that the data pointed to by \c tail is an actual node, not a dataless - * sentinal. Note that if \c tail constist of a single node, this macro - * behaves identically to \c insert_at_tail - * - * \param head Head of the list to be appended to. This may or may not - * be a cyclic list. - * \param tail Head of the cyclic list to be appended to \c head. - * \param temp Temporary \c simple_list used by the macro - * - * \sa insert_at_tail - */ -#define concat_list_and_cycle(head, tail, temp) \ -do { \ - (head)->prev->next = (tail); \ - (tail)->prev->next = (head); \ - (temp) = (head)->prev; \ - (head)->prev = (tail)->prev; \ - (tail)->prev = (temp); \ -} while (0) - -#define concat_list(head, next_list) \ -do { \ - (next_list)->next->prev = (head)->prev; \ - (next_list)->prev->next = (head); \ - (head)->prev->next = (next_list)->next; \ - (head)->prev = (next_list)->prev; \ -} while (0) - -/** - * Make a empty list empty. - * - * \param sentinal list (sentinal element). - */ -#define make_empty_list(sentinal) \ -do { \ - (sentinal)->next = sentinal; \ - (sentinal)->prev = sentinal; \ -} while (0) - -/** - * Get list first element. - * - * \param list list. - * - * \return pointer to first element. - */ -#define first_elem(list) ((list)->next) - -/** - * Get list last element. - * - * \param list list. - * - * \return pointer to last element. - */ -#define last_elem(list) ((list)->prev) - -/** - * Get next element. - * - * \param elem element. - * - * \return pointer to next element. - */ -#define next_elem(elem) ((elem)->next) - -/** - * Get previous element. - * - * \param elem element. - * - * \return pointer to previous element. - */ -#define prev_elem(elem) ((elem)->prev) - -/** - * Test whether element is at end of the list. - * - * \param list list. - * \param elem element. - * - * \return non-zero if element is at end of list, or zero otherwise. - */ -#define at_end(list, elem) ((elem) == (list)) - -/** - * Test if a list is empty. - * - * \param list list. - * - * \return non-zero if list empty, or zero otherwise. - */ -#define is_empty_list(list) ((list)->next == (list)) - -/** - * Walk through the elements of a list. - * - * \param ptr pointer to the current element. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach(ptr, list) \ - for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) - -/** - * Walk through the elements of a list. - * - * Same as #foreach but lets you unlink the current value during a list - * traversal. Useful for freeing a list, element by element. - * - * \param ptr pointer to the current element. - * \param t temporary pointer. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach_s(ptr, t, list) \ - for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) - -#endif diff --git a/mesa/shader/prog_instruction.c b/mesa/shader/prog_instruction.c deleted file mode 100644 index fbcf868f509..00000000000 --- a/mesa/shader/prog_instruction.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#define _GNU_SOURCE -#include -#include -#include - -#if 0 -#include "main/glheader.h" -#else -#define _mesa_strdup strdup -#define _mesa_snprintf snprintf -#define ASSERT assert -#endif -#include "main/imports.h" -#include "main/mtypes.h" -#include "prog_instruction.h" - - -/** - * Initialize program instruction fields to defaults. - * \param inst first instruction to initialize - * \param count number of instructions to initialize - */ -void -_mesa_init_instructions(struct prog_instruction *inst, GLuint count) -{ - GLuint i; - - memset(inst, 0, count * sizeof(struct prog_instruction)); - - for (i = 0; i < count; i++) { - inst[i].SrcReg[0].File = PROGRAM_UNDEFINED; - inst[i].SrcReg[0].Swizzle = SWIZZLE_NOOP; - inst[i].SrcReg[1].File = PROGRAM_UNDEFINED; - inst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP; - inst[i].SrcReg[2].File = PROGRAM_UNDEFINED; - inst[i].SrcReg[2].Swizzle = SWIZZLE_NOOP; - - inst[i].DstReg.File = PROGRAM_UNDEFINED; - inst[i].DstReg.WriteMask = WRITEMASK_XYZW; - inst[i].DstReg.CondMask = COND_TR; - inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP; - - inst[i].SaturateMode = SATURATE_OFF; - inst[i].Precision = FLOAT32; - } -} - - -/** - * Allocate an array of program instructions. - * \param numInst number of instructions - * \return pointer to instruction memory - */ -struct prog_instruction * -_mesa_alloc_instructions(GLuint numInst) -{ - return (struct prog_instruction *) - calloc(1, numInst * sizeof(struct prog_instruction)); -} - - -/** - * Reallocate memory storing an array of program instructions. - * This is used when we need to append additional instructions onto an - * program. - * \param oldInst pointer to first of old/src instructions - * \param numOldInst number of instructions at - * \param numNewInst desired size of new instruction array. - * \return pointer to start of new instruction array. - */ -struct prog_instruction * -_mesa_realloc_instructions(struct prog_instruction *oldInst, - GLuint numOldInst, GLuint numNewInst) -{ - struct prog_instruction *newInst; - - (void)numOldInst; - newInst = (struct prog_instruction *) - realloc(oldInst, - numNewInst * sizeof(struct prog_instruction)); - - return newInst; -} - - -/** - * Copy an array of program instructions. - * \param dest pointer to destination. - * \param src pointer to source. - * \param n number of instructions to copy. - * \return pointer to destination. - */ -struct prog_instruction * -_mesa_copy_instructions(struct prog_instruction *dest, - const struct prog_instruction *src, GLuint n) -{ - GLuint i; - memcpy(dest, src, n * sizeof(struct prog_instruction)); - for (i = 0; i < n; i++) { - if (src[i].Comment) - dest[i].Comment = _mesa_strdup(src[i].Comment); - } - return dest; -} - - -/** - * Free an array of instructions - */ -void -_mesa_free_instructions(struct prog_instruction *inst, GLuint count) -{ - GLuint i; - for (i = 0; i < count; i++) { - if (inst[i].Data) - free(inst[i].Data); - if (inst[i].Comment) - free((char *) inst[i].Comment); - } - free(inst); -} - - -/** - * Basic info about each instruction - */ -struct instruction_info -{ - gl_inst_opcode Opcode; - const char *Name; - GLuint NumSrcRegs; - GLuint NumDstRegs; -}; - -/** - * Instruction info - * \note Opcode should equal array index! - */ -static const struct instruction_info InstInfo[MAX_OPCODE] = { - { OPCODE_NOP, "NOP", 0, 0 }, - { OPCODE_ABS, "ABS", 1, 1 }, - { OPCODE_ADD, "ADD", 2, 1 }, - { OPCODE_AND, "AND", 2, 1 }, - { OPCODE_ARA, "ARA", 1, 1 }, - { OPCODE_ARL, "ARL", 1, 1 }, - { OPCODE_ARL_NV, "ARL_NV", 1, 1 }, - { OPCODE_ARR, "ARL", 1, 1 }, - { OPCODE_BGNLOOP,"BGNLOOP", 0, 0 }, - { OPCODE_BGNSUB, "BGNSUB", 0, 0 }, - { OPCODE_BRA, "BRA", 0, 0 }, - { OPCODE_BRK, "BRK", 0, 0 }, - { OPCODE_CAL, "CAL", 0, 0 }, - { OPCODE_CMP, "CMP", 3, 1 }, - { OPCODE_CONT, "CONT", 0, 0 }, - { OPCODE_COS, "COS", 1, 1 }, - { OPCODE_DDX, "DDX", 1, 1 }, - { OPCODE_DDY, "DDY", 1, 1 }, - { OPCODE_DP2, "DP2", 2, 1 }, - { OPCODE_DP2A, "DP2A", 3, 1 }, - { OPCODE_DP3, "DP3", 2, 1 }, - { OPCODE_DP4, "DP4", 2, 1 }, - { OPCODE_DPH, "DPH", 2, 1 }, - { OPCODE_DST, "DST", 2, 1 }, - { OPCODE_ELSE, "ELSE", 0, 0 }, - { OPCODE_END, "END", 0, 0 }, - { OPCODE_ENDIF, "ENDIF", 0, 0 }, - { OPCODE_ENDLOOP,"ENDLOOP", 0, 0 }, - { OPCODE_ENDSUB, "ENDSUB", 0, 0 }, - { OPCODE_EX2, "EX2", 1, 1 }, - { OPCODE_EXP, "EXP", 1, 1 }, - { OPCODE_FLR, "FLR", 1, 1 }, - { OPCODE_FRC, "FRC", 1, 1 }, - { OPCODE_IF, "IF", 1, 0 }, - { OPCODE_KIL, "KIL", 1, 0 }, - { OPCODE_KIL_NV, "KIL_NV", 0, 0 }, - { OPCODE_LG2, "LG2", 1, 1 }, - { OPCODE_LIT, "LIT", 1, 1 }, - { OPCODE_LOG, "LOG", 1, 1 }, - { OPCODE_LRP, "LRP", 3, 1 }, - { OPCODE_MAD, "MAD", 3, 1 }, - { OPCODE_MAX, "MAX", 2, 1 }, - { OPCODE_MIN, "MIN", 2, 1 }, - { OPCODE_MOV, "MOV", 1, 1 }, - { OPCODE_MUL, "MUL", 2, 1 }, - { OPCODE_NOISE1, "NOISE1", 1, 1 }, - { OPCODE_NOISE2, "NOISE2", 1, 1 }, - { OPCODE_NOISE3, "NOISE3", 1, 1 }, - { OPCODE_NOISE4, "NOISE4", 1, 1 }, - { OPCODE_NOT, "NOT", 1, 1 }, - { OPCODE_NRM3, "NRM3", 1, 1 }, - { OPCODE_NRM4, "NRM4", 1, 1 }, - { OPCODE_OR, "OR", 2, 1 }, - { OPCODE_PK2H, "PK2H", 1, 1 }, - { OPCODE_PK2US, "PK2US", 1, 1 }, - { OPCODE_PK4B, "PK4B", 1, 1 }, - { OPCODE_PK4UB, "PK4UB", 1, 1 }, - { OPCODE_POW, "POW", 2, 1 }, - { OPCODE_POPA, "POPA", 0, 0 }, - { OPCODE_PRINT, "PRINT", 1, 0 }, - { OPCODE_PUSHA, "PUSHA", 0, 0 }, - { OPCODE_RCC, "RCC", 1, 1 }, - { OPCODE_RCP, "RCP", 1, 1 }, - { OPCODE_RET, "RET", 0, 0 }, - { OPCODE_RFL, "RFL", 1, 1 }, - { OPCODE_RSQ, "RSQ", 1, 1 }, - { OPCODE_SCS, "SCS", 1, 1 }, - { OPCODE_SEQ, "SEQ", 2, 1 }, - { OPCODE_SFL, "SFL", 0, 1 }, - { OPCODE_SGE, "SGE", 2, 1 }, - { OPCODE_SGT, "SGT", 2, 1 }, - { OPCODE_SIN, "SIN", 1, 1 }, - { OPCODE_SLE, "SLE", 2, 1 }, - { OPCODE_SLT, "SLT", 2, 1 }, - { OPCODE_SNE, "SNE", 2, 1 }, - { OPCODE_SSG, "SSG", 1, 1 }, - { OPCODE_STR, "STR", 0, 1 }, - { OPCODE_SUB, "SUB", 2, 1 }, - { OPCODE_SWZ, "SWZ", 1, 1 }, - { OPCODE_TEX, "TEX", 1, 1 }, - { OPCODE_TXB, "TXB", 1, 1 }, - { OPCODE_TXD, "TXD", 3, 1 }, - { OPCODE_TXL, "TXL", 1, 1 }, - { OPCODE_TXP, "TXP", 1, 1 }, - { OPCODE_TXP_NV, "TXP_NV", 1, 1 }, - { OPCODE_TRUNC, "TRUNC", 1, 1 }, - { OPCODE_UP2H, "UP2H", 1, 1 }, - { OPCODE_UP2US, "UP2US", 1, 1 }, - { OPCODE_UP4B, "UP4B", 1, 1 }, - { OPCODE_UP4UB, "UP4UB", 1, 1 }, - { OPCODE_X2D, "X2D", 3, 1 }, - { OPCODE_XOR, "XOR", 2, 1 }, - { OPCODE_XPD, "XPD", 2, 1 } -}; - - -/** - * Return the number of src registers for the given instruction/opcode. - */ -GLuint -_mesa_num_inst_src_regs(gl_inst_opcode opcode) -{ - ASSERT(opcode < MAX_OPCODE); - ASSERT(opcode == InstInfo[opcode].Opcode); - ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); - return InstInfo[opcode].NumSrcRegs; -} - - -/** - * Return the number of dst registers for the given instruction/opcode. - */ -GLuint -_mesa_num_inst_dst_regs(gl_inst_opcode opcode) -{ - ASSERT(opcode < MAX_OPCODE); - ASSERT(opcode == InstInfo[opcode].Opcode); - ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); - return InstInfo[opcode].NumDstRegs; -} - - -GLboolean -_mesa_is_tex_instruction(gl_inst_opcode opcode) -{ - return (opcode == OPCODE_TEX || - opcode == OPCODE_TXB || - opcode == OPCODE_TXD || - opcode == OPCODE_TXL || - opcode == OPCODE_TXP); -} - - -/** - * Check if there's a potential src/dst register data dependency when - * using SOA execution. - * Example: - * MOV T, T.yxwz; - * This would expand into: - * MOV t0, t1; - * MOV t1, t0; - * MOV t2, t3; - * MOV t3, t2; - * The second instruction will have the wrong value for t0 if executed as-is. - */ -GLboolean -_mesa_check_soa_dependencies(const struct prog_instruction *inst) -{ - GLuint i, chan; - - if (inst->DstReg.WriteMask == WRITEMASK_X || - inst->DstReg.WriteMask == WRITEMASK_Y || - inst->DstReg.WriteMask == WRITEMASK_Z || - inst->DstReg.WriteMask == WRITEMASK_W || - inst->DstReg.WriteMask == 0x0) { - /* no chance of data dependency */ - return GL_FALSE; - } - - /* loop over src regs */ - for (i = 0; i < 3; i++) { - if (inst->SrcReg[i].File == inst->DstReg.File && - inst->SrcReg[i].Index == inst->DstReg.Index) { - /* loop over dest channels */ - GLuint channelsWritten = 0x0; - for (chan = 0; chan < 4; chan++) { - if (inst->DstReg.WriteMask & (1 << chan)) { - /* check if we're reading a channel that's been written */ - GLuint swizzle = GET_SWZ(inst->SrcReg[i].Swizzle, chan); - if (swizzle <= SWIZZLE_W && - (channelsWritten & (1 << swizzle))) { - return GL_TRUE; - } - - channelsWritten |= (1 << chan); - } - } - } - } - return GL_FALSE; -} - - -/** - * Return string name for given program opcode. - */ -const char * -_mesa_opcode_string(gl_inst_opcode opcode) -{ - if (opcode < MAX_OPCODE) - return InstInfo[opcode].Name; - else { - static char s[20]; - _mesa_snprintf(s, sizeof(s), "OP%u", opcode); - return s; - } -} - diff --git a/mesa/shader/prog_instruction.h b/mesa/shader/prog_instruction.h deleted file mode 100644 index 2c95d274cab..00000000000 --- a/mesa/shader/prog_instruction.h +++ /dev/null @@ -1,437 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file prog_instruction.h - * - * Vertex/fragment program instruction datatypes and constants. - * - * \author Brian Paul - * \author Keith Whitwell - * \author Ian Romanick - */ - - -#ifndef PROG_INSTRUCTION_H -#define PROG_INSTRUCTION_H - - -#include "main/mtypes.h" - - -/** - * Swizzle indexes. - * Do not change! - */ -/*@{*/ -#define SWIZZLE_X 0 -#define SWIZZLE_Y 1 -#define SWIZZLE_Z 2 -#define SWIZZLE_W 3 -#define SWIZZLE_ZERO 4 /**< For SWZ instruction only */ -#define SWIZZLE_ONE 5 /**< For SWZ instruction only */ -#define SWIZZLE_NIL 7 /**< used during shader code gen (undefined value) */ -/*@}*/ - -#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9)) -#define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3) -#define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7) -#define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1) - -#define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) -#define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X) -#define SWIZZLE_YYYY MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y) -#define SWIZZLE_ZZZZ MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z) -#define SWIZZLE_WWWW MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W) - - -/** - * Writemask values, 1 bit per component. - */ -/*@{*/ -#define WRITEMASK_X 0x1 -#define WRITEMASK_Y 0x2 -#define WRITEMASK_XY 0x3 -#define WRITEMASK_Z 0x4 -#define WRITEMASK_XZ 0x5 -#define WRITEMASK_YZ 0x6 -#define WRITEMASK_XYZ 0x7 -#define WRITEMASK_W 0x8 -#define WRITEMASK_XW 0x9 -#define WRITEMASK_YW 0xa -#define WRITEMASK_XYW 0xb -#define WRITEMASK_ZW 0xc -#define WRITEMASK_XZW 0xd -#define WRITEMASK_YZW 0xe -#define WRITEMASK_XYZW 0xf -/*@}*/ - - -/** - * Condition codes - */ -/*@{*/ -#define COND_GT 1 /**< greater than zero */ -#define COND_EQ 2 /**< equal to zero */ -#define COND_LT 3 /**< less than zero */ -#define COND_UN 4 /**< unordered (NaN) */ -#define COND_GE 5 /**< greater than or equal to zero */ -#define COND_LE 6 /**< less than or equal to zero */ -#define COND_NE 7 /**< not equal to zero */ -#define COND_TR 8 /**< always true */ -#define COND_FL 9 /**< always false */ -/*@}*/ - - -/** - * Instruction precision for GL_NV_fragment_program - */ -/*@{*/ -#define FLOAT32 0x1 -#define FLOAT16 0x2 -#define FIXED12 0x4 -/*@}*/ - - -/** - * Saturation modes when storing values. - */ -/*@{*/ -#define SATURATE_OFF 0 -#define SATURATE_ZERO_ONE 1 -/*@}*/ - - -/** - * Per-component negation masks - */ -/*@{*/ -#define NEGATE_X 0x1 -#define NEGATE_Y 0x2 -#define NEGATE_Z 0x4 -#define NEGATE_W 0x8 -#define NEGATE_XYZ 0x7 -#define NEGATE_XYZW 0xf -#define NEGATE_NONE 0x0 -/*@}*/ - - -/** - * Program instruction opcodes, for both vertex and fragment programs. - * \note changes to this opcode list must be reflected in t_vb_arbprogram.c - */ -typedef enum prog_opcode { - /* ARB_vp ARB_fp NV_vp NV_fp GLSL */ - /*------------------------------------------*/ - OPCODE_NOP = 0, /* X */ - OPCODE_ABS, /* X X 1.1 X */ - OPCODE_ADD, /* X X X X X */ - OPCODE_AND, /* */ - OPCODE_ARA, /* 2 */ - OPCODE_ARL, /* X X */ - OPCODE_ARL_NV, /* 2 */ - OPCODE_ARR, /* 2 */ - OPCODE_BGNLOOP, /* opt */ - OPCODE_BGNSUB, /* opt */ - OPCODE_BRA, /* 2 X */ - OPCODE_BRK, /* 2 opt */ - OPCODE_CAL, /* 2 2 */ - OPCODE_CMP, /* X */ - OPCODE_CONT, /* opt */ - OPCODE_COS, /* X 2 X X */ - OPCODE_DDX, /* X X */ - OPCODE_DDY, /* X X */ - OPCODE_DP2, /* 2 */ - OPCODE_DP2A, /* 2 */ - OPCODE_DP3, /* X X X X X */ - OPCODE_DP4, /* X X X X X */ - OPCODE_DPH, /* X X 1.1 */ - OPCODE_DST, /* X X X X */ - OPCODE_ELSE, /* X */ - OPCODE_END, /* X X X X opt */ - OPCODE_ENDIF, /* opt */ - OPCODE_ENDLOOP, /* opt */ - OPCODE_ENDSUB, /* opt */ - OPCODE_EX2, /* X X 2 X X */ - OPCODE_EXP, /* X X X */ - OPCODE_FLR, /* X X 2 X X */ - OPCODE_FRC, /* X X 2 X X */ - OPCODE_IF, /* opt */ - OPCODE_KIL, /* X */ - OPCODE_KIL_NV, /* X X */ - OPCODE_LG2, /* X X 2 X X */ - OPCODE_LIT, /* X X X X */ - OPCODE_LOG, /* X X X */ - OPCODE_LRP, /* X X */ - OPCODE_MAD, /* X X X X X */ - OPCODE_MAX, /* X X X X X */ - OPCODE_MIN, /* X X X X X */ - OPCODE_MOV, /* X X X X X */ - OPCODE_MUL, /* X X X X X */ - OPCODE_NOISE1, /* X */ - OPCODE_NOISE2, /* X */ - OPCODE_NOISE3, /* X */ - OPCODE_NOISE4, /* X */ - OPCODE_NOT, /* */ - OPCODE_NRM3, /* */ - OPCODE_NRM4, /* */ - OPCODE_OR, /* */ - OPCODE_PK2H, /* X */ - OPCODE_PK2US, /* X */ - OPCODE_PK4B, /* X */ - OPCODE_PK4UB, /* X */ - OPCODE_POW, /* X X X X */ - OPCODE_POPA, /* 3 */ - OPCODE_PRINT, /* X X */ - OPCODE_PUSHA, /* 3 */ - OPCODE_RCC, /* 1.1 */ - OPCODE_RCP, /* X X X X X */ - OPCODE_RET, /* 2 2 */ - OPCODE_RFL, /* X X */ - OPCODE_RSQ, /* X X X X X */ - OPCODE_SCS, /* X */ - OPCODE_SEQ, /* 2 X X */ - OPCODE_SFL, /* 2 X */ - OPCODE_SGE, /* X X X X X */ - OPCODE_SGT, /* 2 X X */ - OPCODE_SIN, /* X 2 X X */ - OPCODE_SLE, /* 2 X X */ - OPCODE_SLT, /* X X X X X */ - OPCODE_SNE, /* 2 X X */ - OPCODE_SSG, /* 2 */ - OPCODE_STR, /* 2 X */ - OPCODE_SUB, /* X X 1.1 X X */ - OPCODE_SWZ, /* X X */ - OPCODE_TEX, /* X 3 X X */ - OPCODE_TXB, /* X 3 X */ - OPCODE_TXD, /* X X */ - OPCODE_TXL, /* 3 2 X */ - OPCODE_TXP, /* X X */ - OPCODE_TXP_NV, /* 3 X */ - OPCODE_TRUNC, /* X */ - OPCODE_UP2H, /* X */ - OPCODE_UP2US, /* X */ - OPCODE_UP4B, /* X */ - OPCODE_UP4UB, /* X */ - OPCODE_X2D, /* X */ - OPCODE_XOR, /* */ - OPCODE_XPD, /* X X X */ - MAX_OPCODE -} gl_inst_opcode; - - -/** - * Number of bits for the src/dst register Index field. - * This limits the size of temp/uniform register files. - */ -#define INST_INDEX_BITS 10 - - -/** - * Instruction source register. - */ -struct prog_src_register -{ - GLuint File:4; /**< One of the PROGRAM_* register file values. */ - GLint Index:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit. - * May be negative for relative addressing. - */ - GLuint Swizzle:12; - GLuint RelAddr:1; - - /** Take the component-wise absolute value */ - GLuint Abs:1; - - /** - * Post-Abs negation. - * This will either be NEGATE_NONE or NEGATE_XYZW, except for the SWZ - * instruction which allows per-component negation. - */ - GLuint Negate:4; -}; - - -/** - * Instruction destination register. - */ -struct prog_dst_register -{ - GLuint File:4; /**< One of the PROGRAM_* register file values */ - GLuint Index:INST_INDEX_BITS; /**< Unsigned, never negative */ - GLuint WriteMask:4; - GLuint RelAddr:1; - - /** - * \name Conditional destination update control. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, - * NV_vertex_program2_option. - */ - /*@{*/ - /** - * Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT, - * NE, TR, or UN). Dest reg is only written to if the matching - * (swizzled) condition code value passes. When a conditional update mask - * is not specified, this will be \c COND_TR. - */ - GLuint CondMask:4; - - /** - * Condition code swizzle value. - */ - GLuint CondSwizzle:12; - - /** - * Selects the condition code register to use for conditional destination - * update masking. In NV_fragmnet_program or NV_vertex_program2 mode, only - * condition code register 0 is available. In NV_vertex_program3 mode, - * condition code registers 0 and 1 are available. - */ - GLuint CondSrc:1; - /*@}*/ -}; - - -/** - * Vertex/fragment program instruction. - */ -struct prog_instruction -{ - gl_inst_opcode Opcode; - struct prog_src_register SrcReg[3]; - struct prog_dst_register DstReg; - - /** - * Indicates that the instruction should update the condition code - * register. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, - * NV_vertex_program2_option. - */ - GLuint CondUpdate:1; - - /** - * If prog_instruction::CondUpdate is \c GL_TRUE, this value selects the - * condition code register that is to be updated. - * - * In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition - * code register 0 is available. In GL_NV_vertex_program3 mode, condition - * code registers 0 and 1 are available. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, - * NV_vertex_program2_option. - */ - GLuint CondDst:1; - - /** - * Saturate each value of the vectored result to the range [0,1] or the - * range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is - * only available in NV_fragment_program2 mode. - * Value is one of the SATURATE_* tokens. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program3. - */ - GLuint SaturateMode:2; - - /** - * Per-instruction selectable precision: FLOAT32, FLOAT16, FIXED12. - * - * \since - * NV_fragment_program, NV_fragment_program_option. - */ - GLuint Precision:3; - - /** - * \name Extra fields for TEX, TXB, TXD, TXL, TXP instructions. - */ - /*@{*/ - /** Source texture unit. */ - GLuint TexSrcUnit:5; - - /** Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX */ - GLuint TexSrcTarget:3; - - /** True if tex instruction should do shadow comparison */ - GLuint TexShadow:1; - /*@}*/ - - /** - * For BRA and CAL instructions, the location to jump to. - * For BGNLOOP, points to ENDLOOP (and vice-versa). - * For BRK, points to BGNLOOP (which points to ENDLOOP). - * For IF, points to ELSE or ENDIF. - * For ELSE, points to ENDIF. - */ - GLint BranchTarget; - - /** for debugging purposes */ - const char *Comment; - - /** Arbitrary data. Used for OPCODE_PRINT and some drivers */ - void *Data; - - /** for driver use (try to remove someday) */ - GLint Aux; -}; - - -extern void -_mesa_init_instructions(struct prog_instruction *inst, GLuint count); - -extern struct prog_instruction * -_mesa_alloc_instructions(GLuint numInst); - -extern struct prog_instruction * -_mesa_realloc_instructions(struct prog_instruction *oldInst, - GLuint numOldInst, GLuint numNewInst); - -extern struct prog_instruction * -_mesa_copy_instructions(struct prog_instruction *dest, - const struct prog_instruction *src, GLuint n); - -extern void -_mesa_free_instructions(struct prog_instruction *inst, GLuint count); - -extern GLuint -_mesa_num_inst_src_regs(gl_inst_opcode opcode); - -extern GLuint -_mesa_num_inst_dst_regs(gl_inst_opcode opcode); - -extern GLboolean -_mesa_is_tex_instruction(gl_inst_opcode opcode); - -extern GLboolean -_mesa_check_soa_dependencies(const struct prog_instruction *inst); - -extern const char * -_mesa_opcode_string(gl_inst_opcode opcode); - - -#endif /* PROG_INSTRUCTION_H */ diff --git a/mesa/shader/prog_print.c b/mesa/shader/prog_print.c deleted file mode 100644 index 3f1cb48e4bf..00000000000 --- a/mesa/shader/prog_print.c +++ /dev/null @@ -1,1089 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file prog_print.c - * Print vertex/fragment programs - for debugging. - * \author Brian Paul - */ - -#if 0 -#include "main/glheader.h" -#include "main/context.h" -#include "main/imports.h" -#else - -#define _GNU_SOURCE - -#include -#include -#include -#include -struct gl_program { - int Target; -}; - -void _mesa_problem(void *ctx, char *msg) -{ - (void)ctx; - fprintf(stderr, "%s", msg); - exit(1); -} - -#endif - -#include "prog_instruction.h" -#include "prog_print.h" - - - -/** - * Return string name for given program/register file. - */ -static const char * -file_string(gl_register_file f, gl_prog_print_mode mode) -{ - (void)mode; - switch (f) { - case PROGRAM_TEMPORARY: - return "TEMP"; - case PROGRAM_LOCAL_PARAM: - return "LOCAL"; - case PROGRAM_ENV_PARAM: - return "ENV"; - case PROGRAM_STATE_VAR: - return "STATE"; - case PROGRAM_INPUT: - return "INPUT"; - case PROGRAM_OUTPUT: - return "OUTPUT"; - case PROGRAM_NAMED_PARAM: - return "NAMED"; - case PROGRAM_CONSTANT: - return "CONST"; - case PROGRAM_UNIFORM: - return "UNIFORM"; - case PROGRAM_VARYING: - return "VARYING"; - case PROGRAM_WRITE_ONLY: - return "WRITE_ONLY"; - case PROGRAM_ADDRESS: - return "ADDR"; - case PROGRAM_SAMPLER: - return "SAMPLER"; - case PROGRAM_UNDEFINED: - return "UNDEFINED"; - default: - { - static char s[20]; - snprintf(s, sizeof(s), "FILE%u", f); - return s; - } - } -} - - -/** - * Return ARB_v/f_prog-style input attrib string. - */ -static const char * -arb_input_attrib_string(GLint index, GLenum progType) -{ - /* - * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens. - */ - const char *vertAttribs[] = { - "vertex.position", - "vertex.weight", - "vertex.normal", - "vertex.color.primary", - "vertex.color.secondary", - "vertex.fogcoord", - "vertex.(six)", - "vertex.(seven)", - "vertex.texcoord[0]", - "vertex.texcoord[1]", - "vertex.texcoord[2]", - "vertex.texcoord[3]", - "vertex.texcoord[4]", - "vertex.texcoord[5]", - "vertex.texcoord[6]", - "vertex.texcoord[7]", - "vertex.attrib[0]", - "vertex.attrib[1]", - "vertex.attrib[2]", - "vertex.attrib[3]", - "vertex.attrib[4]", - "vertex.attrib[5]", - "vertex.attrib[6]", - "vertex.attrib[7]", - "vertex.attrib[8]", - "vertex.attrib[9]", - "vertex.attrib[10]", - "vertex.attrib[11]", - "vertex.attrib[12]", - "vertex.attrib[13]", - "vertex.attrib[14]", - "vertex.attrib[15]" - }; - const char *fragAttribs[] = { - "fragment.position", - "fragment.color.primary", - "fragment.color.secondary", - "fragment.fogcoord", - "fragment.texcoord[0]", - "fragment.texcoord[1]", - "fragment.texcoord[2]", - "fragment.texcoord[3]", - "fragment.texcoord[4]", - "fragment.texcoord[5]", - "fragment.texcoord[6]", - "fragment.texcoord[7]", - "fragment.varying[0]", - "fragment.varying[1]", - "fragment.varying[2]", - "fragment.varying[3]", - "fragment.varying[4]", - "fragment.varying[5]", - "fragment.varying[6]", - "fragment.varying[7]" - }; - - /* sanity checks */ - assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0); - assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0); - - if (progType == GL_VERTEX_PROGRAM_ARB) { - assert((unsigned int)index < sizeof(vertAttribs) / sizeof(vertAttribs[0])); - return vertAttribs[index]; - } - else { - assert((unsigned int)index < sizeof(fragAttribs) / sizeof(fragAttribs[0])); - return fragAttribs[index]; - } -} - - -/** - * Print a vertex program's InputsRead field in human-readable format. - * For debugging. - */ -void -_mesa_print_vp_inputs(GLbitfield inputs) -{ - printf("VP Inputs 0x%x: \n", inputs); - while (inputs) { - GLint attr = ffs(inputs) - 1; - const char *name = arb_input_attrib_string(attr, - GL_VERTEX_PROGRAM_ARB); - printf(" %d: %s\n", attr, name); - inputs &= ~(1 << attr); - } -} - - -/** - * Print a fragment program's InputsRead field in human-readable format. - * For debugging. - */ -void -_mesa_print_fp_inputs(GLbitfield inputs) -{ - printf("FP Inputs 0x%x: \n", inputs); - while (inputs) { - GLint attr = ffs(inputs) - 1; - const char *name = arb_input_attrib_string(attr, - GL_FRAGMENT_PROGRAM_ARB); - printf(" %d: %s\n", attr, name); - inputs &= ~(1 << attr); - } -} - - -#if 0 -/** - * Return ARB_v/f_prog-style output attrib string. - */ -static const char * -arb_output_attrib_string(GLint index, GLenum progType) -{ - /* - * These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens. - */ - const char *vertResults[] = { - "result.position", - "result.color.primary", - "result.color.secondary", - "result.fogcoord", - "result.texcoord[0]", - "result.texcoord[1]", - "result.texcoord[2]", - "result.texcoord[3]", - "result.texcoord[4]", - "result.texcoord[5]", - "result.texcoord[6]", - "result.texcoord[7]", - "result.varying[0]", - "result.varying[1]", - "result.varying[2]", - "result.varying[3]", - "result.varying[4]", - "result.varying[5]", - "result.varying[6]", - "result.varying[7]" - }; - const char *fragResults[] = { - "result.color", - "result.color(half)", - "result.depth", - "result.color[0]", - "result.color[1]", - "result.color[2]", - "result.color[3]" - }; - - if (progType == GL_VERTEX_PROGRAM_ARB) { - assert(index < sizeof(vertResults) / sizeof(vertResults[0])); - return vertResults[index]; - } - else { - assert(index < sizeof(fragResults) / sizeof(fragResults[0])); - return fragResults[index]; - } -} -#endif - -/** - * Return string representation of the given register. - * Note that some types of registers (like PROGRAM_UNIFORM) aren't defined - * by the ARB/NV program languages so we've taken some liberties here. - * \param f the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc) - * \param index number of the register in the register file - * \param mode the output format/mode/style - * \param prog pointer to containing program - */ -static const char * -reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, - GLboolean relAddr, const struct gl_program *prog) -{ - static char str[100]; - const char *addr = relAddr ? "ADDR+" : ""; - - str[0] = 0; - - switch (mode) { - case PROG_PRINT_DEBUG: - sprintf(str, "%s[%s%d]", file_string(f, mode), addr, index); - break; - case PROG_PRINT_ARB: -#if 0 - switch (f) { - case PROGRAM_INPUT: - sprintf(str, "%s", arb_input_attrib_string(index, prog->Target)); - break; - case PROGRAM_OUTPUT: - sprintf(str, "%s", arb_output_attrib_string(index, prog->Target)); - break; - case PROGRAM_TEMPORARY: - sprintf(str, "temp%d", index); - break; - case PROGRAM_ENV_PARAM: - sprintf(str, "program.env[%s%d]", addr, index); - break; - case PROGRAM_LOCAL_PARAM: - sprintf(str, "program.local[%s%d]", addr, index); - break; - case PROGRAM_VARYING: /* extension */ - sprintf(str, "varying[%s%d]", addr, index); - break; - case PROGRAM_CONSTANT: /* extension */ - sprintf(str, "constant[%s%d]", addr, index); - break; - case PROGRAM_UNIFORM: /* extension */ - sprintf(str, "uniform[%s%d]", addr, index); - break; - case PROGRAM_STATE_VAR: - { - struct gl_program_parameter *param - = prog->Parameters->Parameters + index; - char *state = _mesa_program_state_string(param->StateIndexes); - sprintf(str, "%s", state); - free(state); - } - break; - case PROGRAM_ADDRESS: - sprintf(str, "A%d", index); - break; - default: - _mesa_problem(NULL, "bad file in reg_string()"); - } - break; -#else - assert(0); - break; -#endif - - case PROG_PRINT_NV: - switch (f) { - case PROGRAM_INPUT: - if (prog->Target == GL_VERTEX_PROGRAM_ARB) - sprintf(str, "v[%d]", index); - else - sprintf(str, "f[%d]", index); - break; - case PROGRAM_OUTPUT: - sprintf(str, "o[%d]", index); - break; - case PROGRAM_TEMPORARY: - sprintf(str, "R%d", index); - break; - case PROGRAM_ENV_PARAM: - sprintf(str, "c[%d]", index); - break; - case PROGRAM_VARYING: /* extension */ - sprintf(str, "varying[%s%d]", addr, index); - break; - case PROGRAM_UNIFORM: /* extension */ - sprintf(str, "uniform[%s%d]", addr, index); - break; - case PROGRAM_CONSTANT: /* extension */ - sprintf(str, "constant[%s%d]", addr, index); - break; - case PROGRAM_STATE_VAR: /* extension */ - sprintf(str, "state[%s%d]", addr, index); - break; - default: - _mesa_problem(NULL, "bad file in reg_string()"); - } - break; - - default: - _mesa_problem(NULL, "bad mode in reg_string()"); - } - - return str; -} - - -/** - * Return a string representation of the given swizzle word. - * If extended is true, use extended (comma-separated) format. - * \param swizzle the swizzle field - * \param negateBase 4-bit negation vector - * \param extended if true, also allow 0, 1 values - */ -const char * -_mesa_swizzle_string(GLuint swizzle, GLuint negateMask, GLboolean extended) -{ - static const char swz[] = "xyzw01!?"; /* See SWIZZLE_x definitions */ - static char s[20]; - GLuint i = 0; - - if (!extended && swizzle == SWIZZLE_NOOP && negateMask == 0) - return ""; /* no swizzle/negation */ - - if (!extended) - s[i++] = '.'; - - if (negateMask & NEGATE_X) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 0)]; - - if (extended) { - s[i++] = ','; - } - - if (negateMask & NEGATE_Y) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 1)]; - - if (extended) { - s[i++] = ','; - } - - if (negateMask & NEGATE_Z) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 2)]; - - if (extended) { - s[i++] = ','; - } - - if (negateMask & NEGATE_W) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 3)]; - - s[i] = 0; - return s; -} - - -void -_mesa_print_swizzle(GLuint swizzle) -{ - if (swizzle == SWIZZLE_XYZW) { - printf(".xyzw\n"); - } - else { - const char *s = _mesa_swizzle_string(swizzle, 0, 0); - printf("%s\n", s); - } -} - - -const char * -_mesa_writemask_string(GLuint writeMask) -{ - static char s[10]; - GLuint i = 0; - - if (writeMask == WRITEMASK_XYZW) - return ""; - - s[i++] = '.'; - if (writeMask & WRITEMASK_X) - s[i++] = 'x'; - if (writeMask & WRITEMASK_Y) - s[i++] = 'y'; - if (writeMask & WRITEMASK_Z) - s[i++] = 'z'; - if (writeMask & WRITEMASK_W) - s[i++] = 'w'; - - s[i] = 0; - return s; -} - - -const char * -_mesa_condcode_string(GLuint condcode) -{ - switch (condcode) { - case COND_GT: return "GT"; - case COND_EQ: return "EQ"; - case COND_LT: return "LT"; - case COND_UN: return "UN"; - case COND_GE: return "GE"; - case COND_LE: return "LE"; - case COND_NE: return "NE"; - case COND_TR: return "TR"; - case COND_FL: return "FL"; - default: return "cond???"; - } -} - - -static void -fprint_dst_reg(FILE * f, - const struct prog_dst_register *dstReg, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - fprintf(f, "%s%s", - reg_string((gl_register_file) dstReg->File, - dstReg->Index, mode, dstReg->RelAddr, prog), - _mesa_writemask_string(dstReg->WriteMask)); - - if (dstReg->CondMask != COND_TR) { - fprintf(f, " (%s.%s)", - _mesa_condcode_string(dstReg->CondMask), - _mesa_swizzle_string(dstReg->CondSwizzle, - GL_FALSE, GL_FALSE)); - } - -#if 0 - fprintf(f, "%s[%d]%s", - file_string((gl_register_file) dstReg->File, mode), - dstReg->Index, - _mesa_writemask_string(dstReg->WriteMask)); -#endif -} - - -static void -fprint_src_reg(FILE *f, - const struct prog_src_register *srcReg, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - const char *abs = srcReg->Abs ? "|" : ""; - - fprintf(f, "%s%s%s%s", - abs, - reg_string((gl_register_file) srcReg->File, - srcReg->Index, mode, srcReg->RelAddr, prog), - _mesa_swizzle_string(srcReg->Swizzle, - srcReg->Negate, GL_FALSE), - abs); -#if 0 - fprintf(f, "%s[%d]%s", - file_string((gl_register_file) srcReg->File, mode), - srcReg->Index, - _mesa_swizzle_string(srcReg->Swizzle, - srcReg->Negate, GL_FALSE)); -#endif -} - - -static void -fprint_comment(FILE *f, const struct prog_instruction *inst) -{ - if (inst->Comment) - fprintf(f, "; # %s\n", inst->Comment); - else - fprintf(f, ";\n"); -} - - -static void -fprint_alu_instruction(FILE *f, - const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - GLuint j; - - fprintf(f, "%s", opcode_string); - if (inst->CondUpdate) - fprintf(f, ".C"); - - /* frag prog only */ - if (inst->SaturateMode == SATURATE_ZERO_ONE) - fprintf(f, "_SAT"); - - fprintf(f, " "); - if (inst->DstReg.File != PROGRAM_UNDEFINED) { - fprint_dst_reg(f, &inst->DstReg, mode, prog); - } - else { - fprintf(f, " ???"); - } - - if (numRegs > 0) - fprintf(f, ", "); - - for (j = 0; j < numRegs; j++) { - fprint_src_reg(f, inst->SrcReg + j, mode, prog); - if (j + 1 < numRegs) - fprintf(f, ", "); - } - - fprint_comment(f, inst); -} - - -void -_mesa_print_alu_instruction(const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs) -{ - fprint_alu_instruction(stderr, inst, opcode_string, - numRegs, PROG_PRINT_DEBUG, NULL); -} - - -/** - * Print a single vertex/fragment program instruction. - */ -GLint -_mesa_fprint_instruction_opt(FILE *f, - const struct prog_instruction *inst, - GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - GLint i; - - if (inst->Opcode == OPCODE_ELSE || - inst->Opcode == OPCODE_ENDIF || - inst->Opcode == OPCODE_ENDLOOP || - inst->Opcode == OPCODE_ENDSUB) { - indent -= 3; - } - for (i = 0; i < indent; i++) { - fprintf(f, " "); - } - - switch (inst->Opcode) { - case OPCODE_PRINT: - fprintf(f, "PRINT '%s'", (char *) inst->Data); - if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { - fprintf(f, ", "); - fprintf(f, "%s[%d]%s", - file_string((gl_register_file) inst->SrcReg[0].File, - mode), - inst->SrcReg[0].Index, - _mesa_swizzle_string(inst->SrcReg[0].Swizzle, - inst->SrcReg[0].Negate, GL_FALSE)); - } - if (inst->Comment) - fprintf(f, " # %s", inst->Comment); - fprint_comment(f, inst); - break; - case OPCODE_SWZ: - fprintf(f, "SWZ"); - if (inst->SaturateMode == SATURATE_ZERO_ONE) - fprintf(f, "_SAT"); - fprintf(f, " "); - fprint_dst_reg(f, &inst->DstReg, mode, prog); - fprintf(f, ", %s[%d], %s", - file_string((gl_register_file) inst->SrcReg[0].File, - mode), - inst->SrcReg[0].Index, - _mesa_swizzle_string(inst->SrcReg[0].Swizzle, - inst->SrcReg[0].Negate, GL_TRUE)); - fprint_comment(f, inst); - break; - case OPCODE_TEX: - case OPCODE_TXP: - case OPCODE_TXL: - case OPCODE_TXB: - fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - if (inst->SaturateMode == SATURATE_ZERO_ONE) - fprintf(f, "_SAT"); - fprintf(f, " "); - fprint_dst_reg(f, &inst->DstReg, mode, prog); - fprintf(f, ", "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprintf(f, ", texture[%d], ", inst->TexSrcUnit); - switch (inst->TexSrcTarget) { - case TEXTURE_1D_INDEX: fprintf(f, "1D"); break; - case TEXTURE_2D_INDEX: fprintf(f, "2D"); break; - case TEXTURE_3D_INDEX: fprintf(f, "3D"); break; - case TEXTURE_CUBE_INDEX: fprintf(f, "CUBE"); break; - case TEXTURE_RECT_INDEX: fprintf(f, "RECT"); break; - case TEXTURE_1D_ARRAY_INDEX: fprintf(f, "1D_ARRAY"); break; - case TEXTURE_2D_ARRAY_INDEX: fprintf(f, "2D_ARRAY"); break; - default: - ; - } - if (inst->TexShadow) - fprintf(f, " SHADOW"); - fprint_comment(f, inst); - break; - - case OPCODE_KIL: - fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - fprintf(f, " "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprint_comment(f, inst); - break; - case OPCODE_KIL_NV: - fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - fprintf(f, " "); - fprintf(f, "%s.%s", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, - GL_FALSE, GL_FALSE)); - fprint_comment(f, inst); - break; - - case OPCODE_ARL: - fprintf(f, "ARL "); - fprint_dst_reg(f, &inst->DstReg, mode, prog); - fprintf(f, ", "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprint_comment(f, inst); - break; - case OPCODE_BRA: - fprintf(f, "BRA %d (%s%s)", - inst->BranchTarget, - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); - fprint_comment(f, inst); - break; - case OPCODE_IF: - if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { - /* Use ordinary register */ - fprintf(f, "IF "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprintf(f, "; "); - } - else { - /* Use cond codes */ - fprintf(f, "IF (%s%s);", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, - 0, GL_FALSE)); - } - fprintf(f, " # (if false, goto %d)", inst->BranchTarget); - fprint_comment(f, inst); - return indent + 3; - case OPCODE_ELSE: - fprintf(f, "ELSE; # (goto %d)\n", inst->BranchTarget); - return indent + 3; - case OPCODE_ENDIF: - fprintf(f, "ENDIF;\n"); - break; - case OPCODE_BGNLOOP: - fprintf(f, "BGNLOOP; # (end at %d)\n", inst->BranchTarget); - return indent + 3; - case OPCODE_ENDLOOP: - fprintf(f, "ENDLOOP; # (goto %d)\n", inst->BranchTarget); - break; - case OPCODE_BRK: - case OPCODE_CONT: - fprintf(f, "%s (%s%s); # (goto %d)", - _mesa_opcode_string(inst->Opcode), - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), - inst->BranchTarget); - fprint_comment(f, inst); - break; - - case OPCODE_BGNSUB: - if (mode == PROG_PRINT_NV) { - fprintf(f, "%s:\n", inst->Comment); /* comment is label */ - return indent; - } - else { - fprintf(f, "BGNSUB"); - fprint_comment(f, inst); - return indent + 3; - } - case OPCODE_ENDSUB: - if (mode == PROG_PRINT_DEBUG) { - fprintf(f, "ENDSUB"); - fprint_comment(f, inst); - } - break; - case OPCODE_CAL: - if (mode == PROG_PRINT_NV) { - fprintf(f, "CAL %s; # (goto %d)\n", inst->Comment, inst->BranchTarget); - } - else { - fprintf(f, "CAL %u", inst->BranchTarget); - fprint_comment(f, inst); - } - break; - case OPCODE_RET: - fprintf(f, "RET (%s%s)", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); - fprint_comment(f, inst); - break; - - case OPCODE_END: - fprintf(f, "END\n"); - break; - case OPCODE_NOP: - if (mode == PROG_PRINT_DEBUG) { - fprintf(f, "NOP"); - fprint_comment(f, inst); - } - else if (inst->Comment) { - /* ARB/NV extensions don't have NOP instruction */ - fprintf(f, "# %s\n", inst->Comment); - } - break; - /* XXX may need other special-case instructions */ - default: - if (inst->Opcode < MAX_OPCODE) { - /* typical alu instruction */ - fprint_alu_instruction(f, inst, - _mesa_opcode_string(inst->Opcode), - _mesa_num_inst_src_regs(inst->Opcode), - mode, prog); - } - else { - fprint_alu_instruction(f, inst, - _mesa_opcode_string(inst->Opcode), - 3/*_mesa_num_inst_src_regs(inst->Opcode)*/, - mode, prog); - } - break; - } - return indent; -} - - -GLint -_mesa_print_instruction_opt(const struct prog_instruction *inst, - GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - return _mesa_fprint_instruction_opt(stderr, inst, indent, mode, prog); -} - - -void -_mesa_print_instruction(const struct prog_instruction *inst) -{ - /* note: 4th param should be ignored for PROG_PRINT_DEBUG */ - _mesa_fprint_instruction_opt(stdout, inst, 0, PROG_PRINT_DEBUG, NULL); -} - -#if 0 -/** - * Print program, with options. - */ -void -_mesa_fprint_program_opt(FILE *f, - const struct gl_program *prog, - gl_prog_print_mode mode, - GLboolean lineNumbers) -{ - GLuint i, indent = 0; - - switch (prog->Target) { - case GL_VERTEX_PROGRAM_ARB: - if (mode == PROG_PRINT_ARB) - fprintf(f, "!!ARBvp1.0\n"); - else if (mode == PROG_PRINT_NV) - fprintf(f, "!!VP1.0\n"); - else - fprintf(f, "# Vertex Program/Shader %u\n", prog->Id); - break; - case GL_FRAGMENT_PROGRAM_ARB: - case GL_FRAGMENT_PROGRAM_NV: - if (mode == PROG_PRINT_ARB) - fprintf(f, "!!ARBfp1.0\n"); - else if (mode == PROG_PRINT_NV) - fprintf(f, "!!FP1.0\n"); - else - fprintf(f, "# Fragment Program/Shader %u\n", prog->Id); - break; - } - - for (i = 0; i < prog->NumInstructions; i++) { - if (lineNumbers) - fprintf(f, "%3d: ", i); - indent = _mesa_fprint_instruction_opt(f, prog->Instructions + i, - indent, mode, prog); - } -} - - -/** - * Print program to stderr, default options. - */ -void -_mesa_print_program(const struct gl_program *prog) -{ - _mesa_fprint_program_opt(stderr, prog, PROG_PRINT_DEBUG, GL_TRUE); -} - -/** - * Return binary representation of 64-bit value (as a string). - * Insert a comma to separate each group of 8 bits. - * Note we return a pointer to local static storage so this is not - * re-entrant, etc. - * XXX move to imports.[ch] if useful elsewhere. - */ -static const char * -binary(GLbitfield64 val) -{ - static char buf[80]; - GLint i, len = 0; - for (i = 63; i >= 0; --i) { - if (val & (1ULL << i)) - buf[len++] = '1'; - else if (len > 0 || i == 0) - buf[len++] = '0'; - if (len > 0 && ((i-1) % 8) == 7) - buf[len++] = ','; - } - buf[len] = '\0'; - return buf; -} - - -/** - * Print all of a program's parameters/fields to given file. - */ -static void -_mesa_fprint_program_parameters(FILE *f, - GLcontext *ctx, - const struct gl_program *prog) -{ - GLuint i; - - fprintf(f, "InputsRead: 0x%x (0b%s)\n", - prog->InputsRead, binary(prog->InputsRead)); - fprintf(f, "OutputsWritten: 0x%llx (0b%s)\n", - prog->OutputsWritten, binary(prog->OutputsWritten)); - fprintf(f, "NumInstructions=%d\n", prog->NumInstructions); - fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries); - fprintf(f, "NumParameters=%d\n", prog->NumParameters); - fprintf(f, "NumAttributes=%d\n", prog->NumAttributes); - fprintf(f, "NumAddressRegs=%d\n", prog->NumAddressRegs); - fprintf(f, "SamplersUsed: 0x%x (0b%s)\n", - prog->SamplersUsed, binary(prog->SamplersUsed)); - fprintf(f, "Samplers=[ "); - for (i = 0; i < MAX_SAMPLERS; i++) { - fprintf(f, "%d ", prog->SamplerUnits[i]); - } - fprintf(f, "]\n"); - - _mesa_load_state_parameters(ctx, prog->Parameters); - -#if 0 - fprintf(f, "Local Params:\n"); - for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){ - const GLfloat *p = prog->LocalParams[i]; - fprintf(f, "%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]); - } -#endif - _mesa_print_parameter_list(prog->Parameters); -} - - -/** - * Print all of a program's parameters/fields to stderr. - */ -void -_mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog) -{ - _mesa_fprint_program_parameters(stderr, ctx, prog); -} - - -/** - * Print a program parameter list to given file. - */ -static void -_mesa_fprint_parameter_list(FILE *f, - const struct gl_program_parameter_list *list) -{ - const gl_prog_print_mode mode = PROG_PRINT_DEBUG; - GLuint i; - - if (!list) - return; - - if (0) - fprintf(f, "param list %p\n", (void *) list); - fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags); - for (i = 0; i < list->NumParameters; i++){ - struct gl_program_parameter *param = list->Parameters + i; - const GLfloat *v = list->ParameterValues[i]; - fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", - i, param->Size, - file_string(list->Parameters[i].Type, mode), - param->Name, v[0], v[1], v[2], v[3]); - if (param->Flags & PROG_PARAM_BIT_CENTROID) - fprintf(f, " Centroid"); - if (param->Flags & PROG_PARAM_BIT_INVARIANT) - fprintf(f, " Invariant"); - if (param->Flags & PROG_PARAM_BIT_FLAT) - fprintf(f, " Flat"); - if (param->Flags & PROG_PARAM_BIT_LINEAR) - fprintf(f, " Linear"); - fprintf(f, "\n"); - } -} - - -/** - * Print a program parameter list to stderr. - */ -void -_mesa_print_parameter_list(const struct gl_program_parameter_list *list) -{ - _mesa_fprint_parameter_list(stderr, list); -} - - -/** - * Write shader and associated info to a file. - */ -void -_mesa_write_shader_to_file(const struct gl_shader *shader) -{ - const char *type; - char filename[100]; - FILE *f; - - if (shader->Type == GL_FRAGMENT_SHADER) - type = "frag"; - else - type = "vert"; - - snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); - f = fopen(filename, "w"); - if (!f) { - fprintf(stderr, "Unable to open %s for writing\n", filename); - return; - } - - fprintf(f, "/* Shader %u source, checksum %u */\n", shader->Name, shader->SourceChecksum); - fputs(shader->Source, f); - fprintf(f, "\n"); - - fprintf(f, "/* Compile status: %s */\n", - shader->CompileStatus ? "ok" : "fail"); - if (!shader->CompileStatus) { - fprintf(f, "/* Log Info: */\n"); - fputs(shader->InfoLog, f); - } - else { - fprintf(f, "/* GPU code */\n"); - fprintf(f, "/*\n"); - _mesa_fprint_program_opt(f, shader->Program, PROG_PRINT_DEBUG, GL_TRUE); - fprintf(f, "*/\n"); - fprintf(f, "/* Parameters / constants */\n"); - fprintf(f, "/*\n"); - _mesa_fprint_parameter_list(f, shader->Program->Parameters); - fprintf(f, "*/\n"); - } - - fclose(f); -} - - -/** - * Append the shader's uniform info/values to the shader log file. - * The log file will typically have been created by the - * _mesa_write_shader_to_file function. - */ -void -_mesa_append_uniforms_to_file(const struct gl_shader *shader, - const struct gl_program *prog) -{ - const char *type; - char filename[100]; - FILE *f; - - if (shader->Type == GL_FRAGMENT_SHADER) - type = "frag"; - else - type = "vert"; - - snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); - f = fopen(filename, "a"); /* append */ - if (!f) { - fprintf(stderr, "Unable to open %s for appending\n", filename); - return; - } - - fprintf(f, "/* First-draw parameters / constants */\n"); - fprintf(f, "/*\n"); - _mesa_fprint_parameter_list(f, prog->Parameters); - fprintf(f, "*/\n"); - - fclose(f); -} -#endif diff --git a/mesa/shader/prog_print.h b/mesa/shader/prog_print.h deleted file mode 100644 index f0df77b5129..00000000000 --- a/mesa/shader/prog_print.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef PROG_PRINT_H -#define PROG_PRINT_H - - -/** - * The output style to use when printing programs. - */ -typedef enum { - PROG_PRINT_ARB, - PROG_PRINT_NV, - PROG_PRINT_DEBUG -} gl_prog_print_mode; - - -extern void -_mesa_print_vp_inputs(GLbitfield inputs); - -extern void -_mesa_print_fp_inputs(GLbitfield inputs); - -extern const char * -_mesa_condcode_string(GLuint condcode); - -extern const char * -_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended); - -const char * -_mesa_writemask_string(GLuint writeMask); - -extern void -_mesa_print_swizzle(GLuint swizzle); - -extern void -_mesa_print_alu_instruction(const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs); - -extern void -_mesa_print_instruction(const struct prog_instruction *inst); - -extern GLint -_mesa_fprint_instruction_opt(FILE *f, - const struct prog_instruction *inst, - GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog); - -extern GLint -_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog); - -extern void -_mesa_print_program(const struct gl_program *prog); - -extern void -_mesa_fprint_program_opt(FILE *f, - const struct gl_program *prog, gl_prog_print_mode mode, - GLboolean lineNumbers); - -#if 0 -extern void -_mesa_print_parameter_list(const struct gl_program_parameter_list *list); - -extern void -_mesa_write_shader_to_file(const struct gl_shader *shader); - -extern void -_mesa_append_uniforms_to_file(const struct gl_shader *shader, - const struct gl_program *prog); -#endif - - -#endif /* PROG_PRINT_H */ diff --git a/program.h b/program.h deleted file mode 100644 index d21b04344cd..00000000000 --- a/program.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include "main/mtypes.h" - -/** - * Based on gl_shader in Mesa's mtypes.h. - */ -struct glsl_shader { - GLenum Type; - GLuint Name; - GLint RefCount; - GLboolean DeletePending; - GLboolean CompileStatus; - const GLchar *Source; /**< Source code string */ - size_t SourceLen; - GLchar *InfoLog; - - struct exec_list ir; - struct glsl_symbol_table *symbols; -}; - - -typedef int gl_state_index; -#define STATE_LENGTH 5 - -/** - * Program parameter. - * Used by shaders/programs for uniforms, constants, varying vars, etc. - */ -struct gl_program_parameter -{ - const char *Name; /**< Null-terminated string */ - gl_register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */ - GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ - /** - * Number of components (1..4), or more. - * If the number of components is greater than 4, - * this parameter is part of a larger uniform like a GLSL matrix or array. - * The next program parameter's Size will be Size-4 of this parameter. - */ - GLuint Size; - GLboolean Used; /**< Helper flag for GLSL uniform tracking */ - GLboolean Initialized; /**< Has the ParameterValue[] been set? */ - GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ - /** - * A sequence of STATE_* tokens and integers to identify GL state. - */ - gl_state_index StateIndexes[STATE_LENGTH]; -}; - - -/** - * List of gl_program_parameter instances. - */ -struct gl_program_parameter_list -{ - GLuint Size; /**< allocated size of Parameters, ParameterValues */ - GLuint NumParameters; /**< number of parameters in arrays */ - struct gl_program_parameter *Parameters; /**< Array [Size] */ - GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */ - GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes - might invalidate ParameterValues[] */ -}; - - -/** - * Shader program uniform variable. - * The glGetUniformLocation() and glUniform() commands will use this - * information. - * Note that a uniform such as "binormal" might be used in both the - * vertex shader and the fragment shader. When glUniform() is called to - * set the uniform's value, it must be updated in both the vertex and - * fragment shaders. The uniform may be in different locations in the - * two shaders so we keep track of that here. - */ -struct gl_uniform -{ - const char *Name; /**< Null-terminated string */ - GLint VertPos; - GLint FragPos; - GLboolean Initialized; /**< For debug. Has this uniform been set? */ -#if 0 - GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ - GLuint Size; /**< Number of components (1..4) */ -#endif -}; - - -/** - * List of gl_uniforms - */ -struct gl_uniform_list -{ - GLuint Size; /**< allocated size of Uniforms array */ - GLuint NumUniforms; /**< number of uniforms in the array */ - struct gl_uniform *Uniforms; /**< Array [Size] */ -}; - - -/** - * Based on gl_shader_program in Mesa's mtypes.h. - */ -struct glsl_program { - GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ - GLuint Name; /**< aka handle or ID */ - GLint RefCount; /**< Reference count */ - GLboolean DeletePending; - - GLuint NumShaders; /**< number of attached shaders */ - struct glsl_shader **Shaders; /**< List of attached the shaders */ - - /** - * Per-stage shaders resulting from the first stage of linking. - */ - /*@{*/ - unsigned _NumLinkedShaders; - struct glsl_shader **_LinkedShaders; - /*@}*/ - - /** User-defined attribute bindings (glBindAttribLocation) */ - struct gl_program_parameter_list *Attributes; - - /* post-link info: */ - struct gl_uniform_list *Uniforms; - struct gl_program_parameter_list *Varying; - GLboolean LinkStatus; /**< GL_LINK_STATUS */ - GLboolean Validated; - GLboolean _Used; /**< Ever used for drawing? */ - GLchar *InfoLog; -}; - -extern void -link_shaders(struct glsl_program *prog); diff --git a/s_expression.cpp b/s_expression.cpp deleted file mode 100644 index 26be23ea8fa..00000000000 --- a/s_expression.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include "s_expression.h" - -s_symbol::s_symbol(const char *tmp) -{ - this->str = talloc_strdup (this, tmp); - assert(this->str != NULL); -} - -s_list::s_list() -{ -} - -unsigned -s_list::length() const -{ - unsigned i = 0; - foreach_iter(exec_list_iterator, it, this->subexpressions) { - i++; - } - return i; -} - -static s_expression * -read_atom(void *ctx, const char *& src) -{ - char buf[101]; - int n; - if (sscanf(src, " %100[^( \v\t\r\n)]%n", buf, &n) != 1) - return NULL; // no atom - src += n; - - // Check if the atom is a number. - char *float_end = NULL; - double f = strtod(buf, &float_end); - if (float_end != buf) { - char *int_end = NULL; - int i = strtol(buf, &int_end, 10); - // If strtod matched more characters, it must have a decimal part - if (float_end > int_end) - return new(ctx) s_float(f); - - return new(ctx) s_int(i); - } - // Not a number; return a symbol. - return new(ctx) s_symbol(buf); -} - -s_expression * -s_expression::read_expression(void *ctx, const char *&src) -{ - assert(src != NULL); - - s_expression *atom = read_atom(ctx, src); - if (atom != NULL) - return atom; - - char c; - int n; - if (sscanf(src, " %c%n", &c, &n) == 1 && c == '(') { - src += n; - - s_list *list = new(ctx) s_list; - s_expression *expr; - - while ((expr = read_expression(ctx, src)) != NULL) { - list->subexpressions.push_tail(expr); - } - if (sscanf(src, " %c%n", &c, &n) != 1 || c != ')') { - printf("Unclosed expression (check your parenthesis).\n"); - return NULL; - } - src += n; - return list; - } - return NULL; -} - -void s_int::print() -{ - printf("%d", this->val); -} - -void s_float::print() -{ - printf("%f", this->val); -} - -void s_symbol::print() -{ - printf("%s", this->str); -} - -void s_list::print() -{ - printf("("); - foreach_iter(exec_list_iterator, it, this->subexpressions) { - s_expression *expr = (s_expression*) it.get(); - expr->print(); - printf(" "); - } - printf(")"); -} - diff --git a/s_expression.h b/s_expression.h deleted file mode 100644 index 1a0c03c2189..00000000000 --- a/s_expression.h +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#pragma once -#ifndef S_EXPRESSION_H -#define S_EXPRESSION_H - -#include "list.h" - -#define SX_AS_(t,x) ((x) && ((s_expression*) x)->is_##t()) ? ((s_##t*) (x)) \ - : NULL -#define SX_AS_LIST(x) SX_AS_(list, x) -#define SX_AS_SYMBOL(x) SX_AS_(symbol, x) -#define SX_AS_NUMBER(x) SX_AS_(number, x) -#define SX_AS_INT(x) SX_AS_(int, x) - -/* For our purposes, S-Expressions are: - * - - * - - * - symbol - * - (expr1 expr2 ... exprN) where exprN is an S-Expression - * - * Unlike LISP/Scheme, we do not support (foo . bar) pairs. - */ -class s_expression : public exec_node -{ -public: - /** - * Read an S-Expression from the given string. - * Advances the supplied pointer to just after the expression read. - * - * Any allocation will be performed with 'ctx' as the talloc owner. - */ - static s_expression *read_expression(void *ctx, const char *&src); - - /** - * Print out an S-Expression. Useful for debugging. - */ - virtual void print() = 0; - - virtual bool is_list() const { return false; } - virtual bool is_symbol() const { return false; } - virtual bool is_number() const { return false; } - virtual bool is_int() const { return false; } - -protected: - s_expression() { } -}; - -/* Atoms */ - -class s_number : public s_expression -{ -public: - bool is_number() const { return true; } - - virtual float fvalue() = 0; - -protected: - s_number() { } -}; - -class s_int : public s_number -{ -public: - s_int(int x) : val(x) { } - - bool is_int() const { return true; } - - float fvalue() { return float(this->val); } - int value() { return this->val; } - - void print(); - -private: - int val; -}; - -class s_float : public s_number -{ -public: - s_float(float x) : val(x) { } - - float fvalue() { return this->val; } - - void print(); - -private: - float val; -}; - -class s_symbol : public s_expression -{ -public: - s_symbol(const char *); - - bool is_symbol() const { return true; } - - const char *value() { return this->str; } - - void print(); - -private: - char *str; -}; - -/* Lists of expressions: (expr1 ... exprN) */ -class s_list : public s_expression -{ -public: - s_list(); - - virtual bool is_list() const { return true; } - unsigned length() const; - - void print(); - - exec_list subexpressions; -}; - -#endif /* S_EXPRESSION_H */ diff --git a/src/glsl/.dir-locals.el b/src/glsl/.dir-locals.el new file mode 100644 index 00000000000..be19e29a5ab --- /dev/null +++ b/src/glsl/.dir-locals.el @@ -0,0 +1,3 @@ +((c-mode . ((c-basic-offset . 3))) + (c++-mode . ((c-basic-offset . 3))) +) diff --git a/src/glsl/.gitignore b/src/glsl/.gitignore new file mode 100644 index 00000000000..376aaeda13a --- /dev/null +++ b/src/glsl/.gitignore @@ -0,0 +1,25 @@ +.deps +COPYING +INSTALL +Makefile.in +aclocal.m4 +autom4te.cache +config.* +configure +depcomp +ylwrap +install-sh +missing +stamp-h1 +libtool +ltmain.sh +Makefile +*.o +*~ +glsl_lexer.cpp +glsl_parser.output +glsl_parser.cpp +glsl_parser.h +glsl +mesa_codegen.cpp +mesa_codegen.h diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am new file mode 100644 index 00000000000..c34f7d8abfb --- /dev/null +++ b/src/glsl/Makefile.am @@ -0,0 +1,79 @@ +# Copyright © 2010 Intel Corporation +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +# USE OR OTHER DEALINGS IN THE SOFTWARE. + +AUTOMAKE_OPTIONS = foreign +AM_CPPFLAGS = -I mesa + +SUBDIRS = glcpp + +bin_PROGRAMS = glsl + +glsl_LDADD = ./glcpp/libglcpp.la +glsl_LDFLAGS = @LDFLAGS@ $(talloc_LIBS) +glsl_SOURCES = \ + main.cpp \ + builtin_types.h \ + symbol_table.c hash_table.c glsl_types.cpp \ + glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ + ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \ + ir.cpp hir_field_selection.cpp builtin_function.cpp \ + ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \ + ir_basic_block.cpp \ + ir_basic_block.h \ + ir_clone.cpp \ + ir_constant_expression.cpp \ + ir_constant_folding.cpp \ + ir_constant_variable.cpp \ + ir_copy_propagation.cpp \ + ir_copy_propagation.h \ + ir_dead_code.cpp \ + ir_dead_code.h \ + ir_dead_code_local.cpp \ + ir_expression_flattening.cpp \ + ir_function_can_inline.cpp \ + ir_function_inlining.cpp \ + ir_if_simplification.cpp \ + ir_optimization.h \ + ir_reader.cpp s_expression.cpp \ + ir_hv_accept.cpp \ + ir_hierarchical_visitor.h \ + ir_hierarchical_visitor.cpp \ + ir_swizzle_swizzle.cpp \ + ir_to_mesa.cpp \ + ir_to_mesa.h \ + ir_validate.cpp \ + ir_vec_index_to_swizzle.cpp \ + linker.cpp \ + mesa/shader/prog_instruction.c \ + mesa/shader/prog_instruction.h \ + mesa/shader/prog_print.c \ + mesa/shader/prog_print.h + +BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp +CLEANFILES = $(BUILT_SOURCES) + +builtin_function.cpp: builtins/*/* + ./builtins/tools/generate_builtins.pl > builtin_function.cpp +glsl_parser.h: glsl_parser.cpp + +.lpp.cpp: + $(LEXCOMPILE) --outfile="$@" $< diff --git a/src/glsl/TODO b/src/glsl/TODO new file mode 100644 index 00000000000..193cfc767d8 --- /dev/null +++ b/src/glsl/TODO @@ -0,0 +1,84 @@ +- Implement AST-to-HIR conversion of discard instructions. + +- Handle constant expressions of (matrix {+,-,*,/} scalar) + +- Handle constant expressions of (vector {+,-,*,/} scalar) + +- Handle constant expressions of (matrix * vector) + +- Handle constant expressions of (matrix * matrix) + +- Handle currently unsupported constant expression types + - ir_unop_sign + - ir_unop_exp2 + - ir_unop_log2 + - ir_unop_u2f + - ir_unop_trunc + - ir_unop_ceil + - ir_unop_floor + - ir_unop_sin + - ir_unop_cos + - ir_binop_dot + - ir_binop_min + - ir_binop_max + - ir_binop_pow + +- Handle constant expressions of (struct == struct) + +- Handle constant expressions of (struct != struct) + +- Add support to ir_constant for array constants Arrays can only be + - declared 'const' in GLSL 1.20+. This is because there are no + array constructors in GLSL 1.10, and any variable declared as + 'const' must have an initializer. + +- Handle constant expressions of (array == array) + +- Handle constant expressions of (array != array) + +- Treat built-in functions with constant parameters as constant expressions. + - Rewrite all built-in functions return a single expression. + - Modify the HIR generator for functions to automatically inline built-in + functions durning translation. + - Care must be taken to handle both the 1.10 rules and the 1.20+ rules. In + 1.10, built-in functions cannot be constant expressions. + +- Detect non-void functions that lack a return statement + +- Detect return statements with a type not matching the funciton's + return type. + +- Handle over-riding built-in functions + - Is the overload per-compilation unit or per-linked shader? + +- Handle redeclaration of built-in variables + - Handle addition of qualifiers such as 'invariant' or 'centroid'. + - Handle resizing of arrays. + - Other? We'll have to look at the spec. + +- Improve handling of constants and their initializers. Constant initializers + should never generate any code. This is trival for scalar constants. It is + also trivial for arrays, matrices, and vectors that are accessed with + constant index values. For others it is more complicated. Perhaps these + cases should be silently converted to uniforms? + +1.30 features: + +- Implement AST-to-HIR conversion of bit-shift operators. + +- Implement AST-to-HIR conversion of bit-wise {&,|,^,!} operators. + +- Implement AST-to-HIR conversion of switch-statements + - switch + - case + - Update break to correcly handle mixed nexting of switch-statements + and loops. + +- Handle currently unsupported constant expression types + - ir_unop_bit_not + - ir_binop_mod + - ir_binop_lshift + - ir_binop_rshift + - ir_binop_bit_and + - ir_binop_bit_xor + - ir_binop_bit_or diff --git a/src/glsl/ast.h b/src/glsl/ast.h new file mode 100644 index 00000000000..de300e719c4 --- /dev/null +++ b/src/glsl/ast.h @@ -0,0 +1,651 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef AST_H +#define AST_H + +#include "list.h" +#include "glsl_parser_extras.h" + +struct ir_instruction; +struct _mesa_glsl_parse_state; + +struct YYLTYPE; + +class ast_node { +public: + /* Callers of this talloc-based new need not call delete. It's + * easier to just talloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *node; + + node = talloc_size(ctx, size); + assert(node != NULL); + + return node; + } + + /* If the user *does* call delete, that's OK, we will just + * talloc_free in that case. */ + static void operator delete(void *table) + { + talloc_free(table); + } + + virtual void print(void) const; + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + /** + * Retrieve the source location of an AST node + * + * This function is primarily used to get the source position of an AST node + * into a form that can be passed to \c _mesa_glsl_error. + * + * \sa _mesa_glsl_error, ast_node::set_location + */ + struct YYLTYPE get_location(void) const + { + struct YYLTYPE locp; + + locp.source = this->location.source; + locp.first_line = this->location.line; + locp.first_column = this->location.column; + locp.last_line = locp.first_line; + locp.last_column = locp.first_column; + + return locp; + } + + /** + * Set the source location of an AST node from a parser location + * + * \sa ast_node::get_location + */ + void set_location(const struct YYLTYPE &locp) + { + this->location.source = locp.source; + this->location.line = locp.first_line; + this->location.column = locp.first_column; + } + + struct { + unsigned source; + unsigned line; + unsigned column; + } location; + + exec_node link; + +protected: + ast_node(void); +}; + + +enum ast_operators { + ast_assign, + ast_plus, /**< Unary + operator. */ + ast_neg, + ast_add, + ast_sub, + ast_mul, + ast_div, + ast_mod, + ast_lshift, + ast_rshift, + ast_less, + ast_greater, + ast_lequal, + ast_gequal, + ast_equal, + ast_nequal, + ast_bit_and, + ast_bit_xor, + ast_bit_or, + ast_bit_not, + ast_logic_and, + ast_logic_xor, + ast_logic_or, + ast_logic_not, + + ast_mul_assign, + ast_div_assign, + ast_mod_assign, + ast_add_assign, + ast_sub_assign, + ast_ls_assign, + ast_rs_assign, + ast_and_assign, + ast_xor_assign, + ast_or_assign, + + ast_conditional, + + ast_pre_inc, + ast_pre_dec, + ast_post_inc, + ast_post_dec, + ast_field_selection, + ast_array_index, + + ast_function_call, + + ast_identifier, + ast_int_constant, + ast_uint_constant, + ast_float_constant, + ast_bool_constant, + + ast_sequence +}; + +class ast_expression : public ast_node { +public: + ast_expression(int oper, ast_expression *, + ast_expression *, ast_expression *); + + ast_expression(const char *identifier) : + oper(ast_identifier) + { + subexpressions[0] = NULL; + subexpressions[1] = NULL; + subexpressions[2] = NULL; + primary_expression.identifier = (char *) identifier; + } + + static const char *operator_string(enum ast_operators op); + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + virtual void print(void) const; + + enum ast_operators oper; + + ast_expression *subexpressions[3]; + + union { + char *identifier; + int int_constant; + float float_constant; + unsigned uint_constant; + int bool_constant; + } primary_expression; + + + /** + * List of expressions for an \c ast_sequence or parameters for an + * \c ast_function_call + */ + exec_list expressions; +}; + +class ast_expression_bin : public ast_expression { +public: + ast_expression_bin(int oper, ast_expression *, ast_expression *); + + virtual void print(void) const; +}; + +/** + * Subclass of expressions for function calls + */ +class ast_function_expression : public ast_expression { +public: + ast_function_expression(ast_expression *callee) + : ast_expression(ast_function_call, callee, + NULL, NULL), + cons(false) + { + /* empty */ + } + + ast_function_expression(class ast_type_specifier *type) + : ast_expression(ast_function_call, (ast_expression *) type, + NULL, NULL), + cons(true) + { + /* empty */ + } + + bool is_constructor() const + { + return cons; + } + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +private: + /** + * Is this function call actually a constructor? + */ + bool cons; +}; + + +/** + * Number of possible operators for an ast_expression + * + * This is done as a define instead of as an additional value in the enum so + * that the compiler won't generate spurious messages like "warning: + * enumeration value ‘ast_num_operators’ not handled in switch" + */ +#define AST_NUM_OPERATORS (ast_sequence + 1) + + +class ast_compound_statement : public ast_node { +public: + ast_compound_statement(int new_scope, ast_node *statements); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + int new_scope; + exec_list statements; +}; + +class ast_declaration : public ast_node { +public: + ast_declaration(char *identifier, int is_array, ast_expression *array_size, + ast_expression *initializer); + virtual void print(void) const; + + char *identifier; + + int is_array; + ast_expression *array_size; + + ast_expression *initializer; +}; + + +enum { + ast_precision_high = 0, /**< Default precision. */ + ast_precision_medium, + ast_precision_low +}; + +struct ast_type_qualifier { + unsigned invariant:1; + unsigned constant:1; + unsigned attribute:1; + unsigned varying:1; + unsigned in:1; + unsigned out:1; + unsigned centroid:1; + unsigned uniform:1; + unsigned smooth:1; + unsigned flat:1; + unsigned noperspective:1; +}; + +class ast_struct_specifier : public ast_node { +public: + ast_struct_specifier(char *identifier, ast_node *declarator_list); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + char *name; + exec_list declarations; +}; + + +enum ast_types { + ast_void, + ast_float, + ast_int, + ast_uint, + ast_bool, + ast_vec2, + ast_vec3, + ast_vec4, + ast_bvec2, + ast_bvec3, + ast_bvec4, + ast_ivec2, + ast_ivec3, + ast_ivec4, + ast_uvec2, + ast_uvec3, + ast_uvec4, + ast_mat2, + ast_mat2x3, + ast_mat2x4, + ast_mat3x2, + ast_mat3, + ast_mat3x4, + ast_mat4x2, + ast_mat4x3, + ast_mat4, + ast_sampler1d, + ast_sampler2d, + ast_sampler2drect, + ast_sampler3d, + ast_samplercube, + ast_sampler1dshadow, + ast_sampler2dshadow, + ast_sampler2drectshadow, + ast_samplercubeshadow, + ast_sampler1darray, + ast_sampler2darray, + ast_sampler1darrayshadow, + ast_sampler2darrayshadow, + ast_isampler1d, + ast_isampler2d, + ast_isampler3d, + ast_isamplercube, + ast_isampler1darray, + ast_isampler2darray, + ast_usampler1d, + ast_usampler2d, + ast_usampler3d, + ast_usamplercube, + ast_usampler1darray, + ast_usampler2darray, + + ast_struct, + ast_type_name +}; + + +class ast_type_specifier : public ast_node { +public: + ast_type_specifier(int specifier); + + /** Construct a type specifier from a type name */ + ast_type_specifier(const char *name) + : type_specifier(ast_type_name), type_name(name), structure(NULL), + is_array(false), array_size(NULL), precision(ast_precision_high) + { + /* empty */ + } + + /** Construct a type specifier from a structure definition */ + ast_type_specifier(ast_struct_specifier *s) + : type_specifier(ast_struct), type_name(s->name), structure(s), + is_array(false), array_size(NULL), precision(ast_precision_high) + { + /* empty */ + } + + const struct glsl_type *glsl_type(const char **name, + struct _mesa_glsl_parse_state *state) + const; + + virtual void print(void) const; + + ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); + + enum ast_types type_specifier; + + const char *type_name; + ast_struct_specifier *structure; + + int is_array; + ast_expression *array_size; + + unsigned precision:2; +}; + + +class ast_fully_specified_type : public ast_node { +public: + virtual void print(void) const; + + ast_type_qualifier qualifier; + ast_type_specifier *specifier; +}; + + +class ast_declarator_list : public ast_node { +public: + ast_declarator_list(ast_fully_specified_type *); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_fully_specified_type *type; + exec_list declarations; + + /** + * Special flag for vertex shader "invariant" declarations. + * + * Vertex shaders can contain "invariant" variable redeclarations that do + * not include a type. For example, "invariant gl_Position;". This flag + * is used to note these cases when no type is specified. + */ + int invariant; +}; + + +class ast_parameter_declarator : public ast_node { +public: + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_fully_specified_type *type; + char *identifier; + int is_array; + ast_expression *array_size; + + static void parameters_to_hir(exec_list *ast_parameters, + bool formal, exec_list *ir_parameters, + struct _mesa_glsl_parse_state *state); + +private: + /** Is this parameter declaration part of a formal parameter list? */ + bool formal_parameter; + + /** + * Is this parameter 'void' type? + * + * This field is set by \c ::hir. + */ + bool is_void; +}; + + +class ast_function : public ast_node { +public: + ast_function(void); + + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_fully_specified_type *return_type; + char *identifier; + + exec_list parameters; + +private: + /** + * Is this prototype part of the function definition? + * + * Used by ast_function_definition::hir to process the parameters, etc. + * of the function. + * + * \sa ::hir + */ + bool is_definition; + + /** + * Function signature corresponding to this function prototype instance + * + * Used by ast_function_definition::hir to process the parameters, etc. + * of the function. + * + * \sa ::hir + */ + class ir_function_signature *signature; + + friend class ast_function_definition; +}; + + +class ast_declaration_statement : public ast_node { +public: + ast_declaration_statement(void); + + enum { + ast_function, + ast_declaration, + ast_precision + } mode; + + union { + class ast_function *function; + ast_declarator_list *declarator; + ast_type_specifier *type; + ast_node *node; + } declaration; +}; + + +class ast_expression_statement : public ast_node { +public: + ast_expression_statement(ast_expression *); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_expression *expression; +}; + + +class ast_case_label : public ast_node { +public: + + /** + * An expression of NULL means 'default'. + */ + ast_expression *expression; +}; + +class ast_selection_statement : public ast_node { +public: + ast_selection_statement(ast_expression *condition, + ast_node *then_statement, + ast_node *else_statement); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_expression *condition; + ast_node *then_statement; + ast_node *else_statement; +}; + + +class ast_switch_statement : public ast_node { +public: + ast_expression *expression; + exec_list statements; +}; + +class ast_iteration_statement : public ast_node { +public: + ast_iteration_statement(int mode, ast_node *init, ast_node *condition, + ast_expression *rest_expression, ast_node *body); + + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); + + enum ast_iteration_modes { + ast_for, + ast_while, + ast_do_while + } mode; + + + ast_node *init_statement; + ast_node *condition; + ast_expression *rest_expression; + + ast_node *body; + +private: + /** + * Generate IR from the condition of a loop + * + * This is factored out of ::hir because some loops have the condition + * test at the top (for and while), and others have it at the end (do-while). + */ + void condition_to_hir(class ir_loop *, struct _mesa_glsl_parse_state *); +}; + + +class ast_jump_statement : public ast_node { +public: + ast_jump_statement(int mode, ast_expression *return_value); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + enum ast_jump_modes { + ast_continue, + ast_break, + ast_return, + ast_discard + } mode; + + ast_expression *opt_return_value; +}; + + +class ast_function_definition : public ast_node { +public: + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_function *prototype; + ast_compound_statement *body; +}; + + +extern void +_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); + +extern struct ir_rvalue * +_mesa_ast_field_selection_to_hir(const struct ast_expression *expr, + exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +#endif /* AST_H */ diff --git a/src/glsl/ast_expr.cpp b/src/glsl/ast_expr.cpp new file mode 100644 index 00000000000..4e83decb924 --- /dev/null +++ b/src/glsl/ast_expr.cpp @@ -0,0 +1,96 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include "ast.h" + +const char * +ast_expression::operator_string(enum ast_operators op) +{ + static const char *const operators[] = { + "=", + "+", + "-", + "+", + "-", + "*", + "/", + "%", + "<<", + ">>", + "<", + ">", + "<=", + ">=", + "==", + "!=", + "&", + "^", + "|", + "~", + "&&", + "^^", + "||", + "!", + + "*=", + "/=", + "%=", + "+=", + "-=", + "<<=", + ">>=", + "&=", + "^=", + "|=", + + "?:", + + "++", + "--", + "++", + "--", + ".", + }; + + assert((unsigned int)op < sizeof(operators) / sizeof(operators[0])); + + return operators[op]; +} + + +ast_expression_bin::ast_expression_bin(int oper, ast_expression *ex0, + ast_expression *ex1) : + ast_expression(oper, ex0, ex1, NULL) +{ + assert((oper >= ast_plus) && (oper <= ast_logic_not)); +} + + +void +ast_expression_bin::print(void) const +{ + subexpressions[0]->print(); + printf("%s ", operator_string(oper)); + subexpressions[1]->print(); +} diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp new file mode 100644 index 00000000000..761af00b95e --- /dev/null +++ b/src/glsl/ast_function.cpp @@ -0,0 +1,751 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "glsl_symbol_table.h" +#include "ast.h" +#include "glsl_types.h" +#include "ir.h" + +static unsigned +process_parameters(exec_list *instructions, exec_list *actual_parameters, + exec_list *parameters, + struct _mesa_glsl_parse_state *state) +{ + unsigned count = 0; + + foreach_list (n, parameters) { + ast_node *const ast = exec_node_data(ast_node, n, link); + ir_rvalue *result = ast->hir(instructions, state); + + ir_constant *const constant = result->constant_expression_value(); + if (constant != NULL) + result = constant; + + actual_parameters->push_tail(result); + count++; + } + + return count; +} + + +static ir_rvalue * +process_call(exec_list *instructions, ir_function *f, + YYLTYPE *loc, exec_list *actual_parameters, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + + const ir_function_signature *sig = + f->matching_signature(actual_parameters); + + /* The instructions param will be used when the FINISHMEs below are done */ + (void) instructions; + + if (sig != NULL) { + /* Verify that 'out' and 'inout' actual parameters are lvalues. This + * isn't done in ir_function::matching_signature because that function + * cannot generate the necessary diagnostics. + */ + exec_list_iterator actual_iter = actual_parameters->iterator(); + exec_list_iterator formal_iter = sig->parameters.iterator(); + + while (actual_iter.has_next()) { + ir_rvalue *actual = (ir_rvalue *) actual_iter.get(); + ir_variable *formal = (ir_variable *) formal_iter.get(); + + assert(actual != NULL); + assert(formal != NULL); + + if ((formal->mode == ir_var_out) + || (formal->mode == ir_var_inout)) { + if (! actual->is_lvalue()) { + /* FINISHME: Log a better diagnostic here. There is no way + * FINISHME: to tell the user which parameter is invalid. + */ + _mesa_glsl_error(loc, state, "`%s' parameter is not lvalue", + (formal->mode == ir_var_out) ? "out" : "inout"); + } + } + + actual_iter.next(); + formal_iter.next(); + } + + /* FINISHME: The list of actual parameters needs to be modified to + * FINISHME: include any necessary conversions. + */ + return new(ctx) ir_call(sig, actual_parameters); + } else { + /* FINISHME: Log a better error message here. G++ will show the types + * FINISHME: of the actual parameters and the set of candidate + * FINISHME: functions. A different error should also be logged when + * FINISHME: multiple functions match. + */ + _mesa_glsl_error(loc, state, "no matching function for call to `%s'", + f->name); + return ir_call::get_error_instruction(ctx); + } +} + + +static ir_rvalue * +match_function_by_name(exec_list *instructions, const char *name, + YYLTYPE *loc, exec_list *actual_parameters, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + ir_function *f = state->symbols->get_function(name); + + if (f == NULL) { + _mesa_glsl_error(loc, state, "function `%s' undeclared", name); + return ir_call::get_error_instruction(ctx); + } + + /* Once we've determined that the function being called might exist, try + * to find an overload of the function that matches the parameters. + */ + return process_call(instructions, f, loc, actual_parameters, state); +} + + +/** + * Perform automatic type conversion of constructor parameters + */ +static ir_rvalue * +convert_component(ir_rvalue *src, const glsl_type *desired_type) +{ + void *ctx = talloc_parent(src); + const unsigned a = desired_type->base_type; + const unsigned b = src->type->base_type; + ir_expression *result = NULL; + + if (src->type->is_error()) + return src; + + assert(a <= GLSL_TYPE_BOOL); + assert(b <= GLSL_TYPE_BOOL); + + if ((a == b) || (src->type->is_integer() && desired_type->is_integer())) + return src; + + switch (a) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + if (b == GLSL_TYPE_FLOAT) + result = new(ctx) ir_expression(ir_unop_f2i, desired_type, src, NULL); + else { + assert(b == GLSL_TYPE_BOOL); + result = new(ctx) ir_expression(ir_unop_b2i, desired_type, src, NULL); + } + break; + case GLSL_TYPE_FLOAT: + switch (b) { + case GLSL_TYPE_UINT: + result = new(ctx) ir_expression(ir_unop_u2f, desired_type, src, NULL); + break; + case GLSL_TYPE_INT: + result = new(ctx) ir_expression(ir_unop_i2f, desired_type, src, NULL); + break; + case GLSL_TYPE_BOOL: + result = new(ctx) ir_expression(ir_unop_b2f, desired_type, src, NULL); + break; + } + break; + case GLSL_TYPE_BOOL: { + ir_constant *zero = NULL; + + switch (b) { + case GLSL_TYPE_UINT: zero = new(ctx) ir_constant(unsigned(0)); break; + case GLSL_TYPE_INT: zero = new(ctx) ir_constant(int(0)); break; + case GLSL_TYPE_FLOAT: zero = new(ctx) ir_constant(0.0f); break; + } + + result = new(ctx) ir_expression(ir_binop_nequal, desired_type, src, zero); + } + } + + assert(result != NULL); + + ir_constant *const constant = result->constant_expression_value(); + return (constant != NULL) ? (ir_rvalue *) constant : (ir_rvalue *) result; +} + + +/** + * Dereference a specific component from a scalar, vector, or matrix + */ +static ir_rvalue * +dereference_component(ir_rvalue *src, unsigned component) +{ + void *ctx = talloc_parent(src); + assert(component < src->type->components()); + + /* If the source is a constant, just create a new constant instead of a + * dereference of the existing constant. + */ + ir_constant *constant = src->as_constant(); + if (constant) + return new(ctx) ir_constant(constant, component); + + if (src->type->is_scalar()) { + return src; + } else if (src->type->is_vector()) { + return new(ctx) ir_swizzle(src, component, 0, 0, 0, 1); + } else { + assert(src->type->is_matrix()); + + /* Dereference a row of the matrix, then call this function again to get + * a specific element from that row. + */ + const int c = component / src->type->column_type()->vector_elements; + const int r = component % src->type->column_type()->vector_elements; + ir_constant *const col_index = new(ctx) ir_constant(c); + ir_dereference *const col = new(ctx) ir_dereference_array(src, col_index); + + col->type = src->type->column_type(); + + return dereference_component(col, r); + } + + assert(!"Should not get here."); + return NULL; +} + + +static ir_rvalue * +process_array_constructor(exec_list *instructions, + const glsl_type *constructor_type, + YYLTYPE *loc, exec_list *parameters, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + /* Array constructors come in two forms: sized and unsized. Sized array + * constructors look like 'vec4[2](a, b)', where 'a' and 'b' are vec4 + * variables. In this case the number of parameters must exactly match the + * specified size of the array. + * + * Unsized array constructors look like 'vec4[](a, b)', where 'a' and 'b' + * are vec4 variables. In this case the size of the array being constructed + * is determined by the number of parameters. + * + * From page 52 (page 58 of the PDF) of the GLSL 1.50 spec: + * + * "There must be exactly the same number of arguments as the size of + * the array being constructed. If no size is present in the + * constructor, then the array is explicitly sized to the number of + * arguments provided. The arguments are assigned in order, starting at + * element 0, to the elements of the constructed array. Each argument + * must be the same type as the element type of the array, or be a type + * that can be converted to the element type of the array according to + * Section 4.1.10 "Implicit Conversions."" + */ + exec_list actual_parameters; + const unsigned parameter_count = + process_parameters(instructions, &actual_parameters, parameters, state); + + if ((parameter_count == 0) + || ((constructor_type->length != 0) + && (constructor_type->length != parameter_count))) { + const unsigned min_param = (constructor_type->length == 0) + ? 1 : constructor_type->length; + + _mesa_glsl_error(loc, state, "array constructor must have %s %u " + "parameter%s", + (constructor_type->length != 0) ? "at least" : "exactly", + min_param, (min_param <= 1) ? "" : "s"); + return ir_call::get_error_instruction(ctx); + } + + if (constructor_type->length == 0) { + constructor_type = + glsl_type::get_array_instance(state, + constructor_type->element_type(), + parameter_count); + assert(constructor_type != NULL); + assert(constructor_type->length == parameter_count); + } + + ir_function *f = state->symbols->get_function(constructor_type->name); + + /* If the constructor for this type of array does not exist, generate the + * prototype and add it to the symbol table. + */ + if (f == NULL) { + f = constructor_type->generate_constructor(state->symbols); + } + + ir_rvalue *const r = + process_call(instructions, f, loc, &actual_parameters, state); + + assert(r != NULL); + assert(r->type->is_error() || (r->type == constructor_type)); + + return r; +} + + +/** + * Try to convert a record constructor to a constant expression + */ +static ir_constant * +constant_record_constructor(const glsl_type *constructor_type, + YYLTYPE *loc, exec_list *parameters, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + bool all_parameters_are_constant = true; + + exec_node *node = parameters->head; + for (unsigned i = 0; i < constructor_type->length; i++) { + ir_instruction *ir = (ir_instruction *) node; + + if (node->is_tail_sentinal()) { + _mesa_glsl_error(loc, state, + "insufficient parameters to constructor for `%s'", + constructor_type->name); + return NULL; + } + + if (ir->type != constructor_type->fields.structure[i].type) { + _mesa_glsl_error(loc, state, + "parameter type mismatch in constructor for `%s' " + " (%s vs %s)", + constructor_type->name, + ir->type->name, + constructor_type->fields.structure[i].type->name); + return NULL; + } + + if (ir->as_constant() == NULL) + all_parameters_are_constant = false; + + node = node->next; + } + + if (!all_parameters_are_constant) + return NULL; + + return new(ctx) ir_constant(constructor_type, parameters); +} + + +/** + * Generate data for a constant matrix constructor w/a single scalar parameter + * + * Matrix constructors in GLSL can be passed a single scalar of the + * approriate type. In these cases, the resulting matrix is the identity + * matrix multipled by the specified scalar. This function generates data for + * that matrix. + * + * \param type Type of the desired matrix. + * \param initializer Scalar value used to initialize the matrix diagonal. + * \param data Location to store the resulting matrix. + */ +void +generate_constructor_matrix(const glsl_type *type, ir_constant *initializer, + ir_constant_data *data) +{ + switch (type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + for (unsigned i = 0; i < type->components(); i++) + data->u[i] = 0; + + for (unsigned i = 0; i < type->matrix_columns; i++) { + /* The array offset of the ith row and column of the matrix. + */ + const unsigned idx = (i * type->vector_elements) + i; + + data->u[idx] = initializer->value.u[0]; + } + break; + + case GLSL_TYPE_FLOAT: + for (unsigned i = 0; i < type->components(); i++) + data->f[i] = 0; + + for (unsigned i = 0; i < type->matrix_columns; i++) { + /* The array offset of the ith row and column of the matrix. + */ + const unsigned idx = (i * type->vector_elements) + i; + + data->f[idx] = initializer->value.f[0]; + } + + break; + + default: + assert(!"Should not get here."); + break; + } +} + + +/** + * Generate data for a constant vector constructor w/a single scalar parameter + * + * Vector constructors in GLSL can be passed a single scalar of the + * approriate type. In these cases, the resulting vector contains the specified + * value in all components. This function generates data for that vector. + * + * \param type Type of the desired vector. + * \param initializer Scalar value used to initialize the vector. + * \param data Location to store the resulting vector data. + */ +void +generate_constructor_vector(const glsl_type *type, ir_constant *initializer, + ir_constant_data *data) +{ + switch (type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + for (unsigned i = 0; i < type->components(); i++) + data->u[i] = initializer->value.u[0]; + + break; + + case GLSL_TYPE_FLOAT: + for (unsigned i = 0; i < type->components(); i++) + data->f[i] = initializer->value.f[0]; + + break; + + case GLSL_TYPE_BOOL: + for (unsigned i = 0; i < type->components(); i++) + data->b[i] = initializer->value.b[0]; + + break; + + default: + assert(!"Should not get here."); + break; + } +} + + +ir_rvalue * +ast_function_expression::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + /* There are three sorts of function calls. + * + * 1. contstructors - The first subexpression is an ast_type_specifier. + * 2. methods - Only the .length() method of array types. + * 3. functions - Calls to regular old functions. + * + * Method calls are actually detected when the ast_field_selection + * expression is handled. + */ + if (is_constructor()) { + const ast_type_specifier *type = (ast_type_specifier *) subexpressions[0]; + YYLTYPE loc = type->get_location(); + const char *name; + + const glsl_type *const constructor_type = type->glsl_type(& name, state); + + + /* Constructors for samplers are illegal. + */ + if (constructor_type->is_sampler()) { + _mesa_glsl_error(& loc, state, "cannot construct sampler type `%s'", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + if (constructor_type->is_array()) { + if (state->language_version <= 110) { + _mesa_glsl_error(& loc, state, + "array constructors forbidden in GLSL 1.10"); + return ir_call::get_error_instruction(ctx); + } + + return process_array_constructor(instructions, constructor_type, + & loc, &this->expressions, state); + } + + /* There are two kinds of constructor call. Constructors for built-in + * language types, such as mat4 and vec2, are free form. The only + * requirement is that the parameters must provide enough values of the + * correct scalar type. Constructors for arrays and structures must + * have the exact number of parameters with matching types in the + * correct order. These constructors follow essentially the same type + * matching rules as functions. + */ + if (constructor_type->is_numeric() || constructor_type->is_boolean()) { + /* Constructing a numeric type has a couple steps. First all values + * passed to the constructor are broken into individual parameters + * and type converted to the base type of the thing being constructed. + * + * At that point we have some number of values that match the base + * type of the thing being constructed. Now the constructor can be + * treated like a function call. Each numeric type has a small set + * of constructor functions. The set of new parameters will either + * match one of those functions or the original constructor is + * invalid. + */ + const glsl_type *const base_type = constructor_type->get_base_type(); + + /* Total number of components of the type being constructed. + */ + const unsigned type_components = constructor_type->components(); + + /* Number of components from parameters that have actually been + * consumed. This is used to perform several kinds of error checking. + */ + unsigned components_used = 0; + + unsigned matrix_parameters = 0; + unsigned nonmatrix_parameters = 0; + exec_list actual_parameters; + + bool all_parameters_are_constant = true; + + /* This handles invalid constructor calls such as 'vec4 v = vec4();' + */ + if (this->expressions.is_empty()) { + _mesa_glsl_error(& loc, state, "too few components to construct " + "`%s'", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + foreach_list (n, &this->expressions) { + ast_node *ast = exec_node_data(ast_node, n, link); + ir_rvalue *result = + ast->hir(instructions, state)->as_rvalue(); + ir_variable *result_var = NULL; + + /* Attempt to convert the parameter to a constant valued expression. + * After doing so, track whether or not all the parameters to the + * constructor are trivially constant valued expressions. + */ + ir_rvalue *const constant = + result->constant_expression_value(); + + if (constant != NULL) + result = constant; + else + all_parameters_are_constant = false; + + /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: + * + * "It is an error to provide extra arguments beyond this + * last used argument." + */ + if (components_used >= type_components) { + _mesa_glsl_error(& loc, state, "too many parameters to `%s' " + "constructor", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + if (!result->type->is_numeric() && !result->type->is_boolean()) { + _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " + "non-numeric data type", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + /* Count the number of matrix and nonmatrix parameters. This + * is used below to enforce some of the constructor rules. + */ + if (result->type->is_matrix()) + matrix_parameters++; + else + nonmatrix_parameters++; + + /* We can't use the same instruction node in the multiple + * swizzle dereferences that happen, so assign it to a + * variable and deref that. Plus it saves computation for + * complicated expressions and handles + * glsl-vs-constructor-call.shader_test. + */ + if (result->type->components() >= 1 && !result->as_constant()) { + result_var = new(ctx) ir_variable(result->type, + "constructor_tmp"); + ir_dereference_variable *lhs; + + lhs = new(ctx) ir_dereference_variable(result_var); + instructions->push_tail(new(ctx) ir_assignment(lhs, + result, NULL)); + } + + /* Process each of the components of the parameter. Dereference + * each component individually, perform any type conversions, and + * add it to the parameter list for the constructor. + */ + for (unsigned i = 0; i < result->type->components(); i++) { + if (components_used >= type_components) + break; + + ir_rvalue *component; + + if (result_var) { + ir_dereference *d = new(ctx) ir_dereference_variable(result_var); + component = dereference_component(d, i); + } else { + component = dereference_component(result, i); + } + component = convert_component(component, base_type); + + /* All cases that could result in component->type being the + * error type should have already been caught above. + */ + assert(component->type == base_type); + + if (component->as_constant() == NULL) + all_parameters_are_constant = false; + + /* Don't actually generate constructor calls for scalars. + * Instead, do the usual component selection and conversion, + * and return the single component. + */ + if (constructor_type->is_scalar()) + return component; + + actual_parameters.push_tail(component); + components_used++; + } + } + + /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: + * + * "It is an error to construct matrices from other matrices. This + * is reserved for future use." + */ + if ((state->language_version <= 110) && (matrix_parameters > 0) + && constructor_type->is_matrix()) { + _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " + "matrix in GLSL 1.10", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: + * + * "If a matrix argument is given to a matrix constructor, it is + * an error to have any other arguments." + */ + if ((matrix_parameters > 0) + && ((matrix_parameters + nonmatrix_parameters) > 1) + && constructor_type->is_matrix()) { + _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, " + "matrix must be only parameter", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: + * + * "In these cases, there must be enough components provided in the + * arguments to provide an initializer for every component in the + * constructed value." + */ + if ((components_used < type_components) && (components_used != 1)) { + _mesa_glsl_error(& loc, state, "too few components to construct " + "`%s'", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + ir_function *f = state->symbols->get_function(constructor_type->name); + if (f == NULL) { + _mesa_glsl_error(& loc, state, "no constructor for type `%s'", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + const ir_function_signature *sig = + f->matching_signature(& actual_parameters); + if (sig != NULL) { + /* If all of the parameters are trivially constant, create a + * constant representing the complete collection of parameters. + */ + if (all_parameters_are_constant) { + if (components_used >= type_components) + return new(ctx) ir_constant(sig->return_type, + & actual_parameters); + + assert(sig->return_type->is_vector() + || sig->return_type->is_matrix()); + + /* Constructors with exactly one component are special for + * vectors and matrices. For vectors it causes all elements of + * the vector to be filled with the value. For matrices it + * causes the matrix to be filled with 0 and the diagonal to be + * filled with the value. + */ + ir_constant_data data; + ir_constant *const initializer = + (ir_constant *) actual_parameters.head; + if (sig->return_type->is_matrix()) + generate_constructor_matrix(sig->return_type, initializer, + &data); + else + generate_constructor_vector(sig->return_type, initializer, + &data); + + return new(ctx) ir_constant(sig->return_type, &data); + } else + return new(ctx) ir_call(sig, & actual_parameters); + } else { + /* FINISHME: Log a better error message here. G++ will show the + * FINSIHME: types of the actual parameters and the set of + * FINSIHME: candidate functions. A different error should also be + * FINSIHME: logged when multiple functions match. + */ + _mesa_glsl_error(& loc, state, "no matching constructor for `%s'", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + } + + return ir_call::get_error_instruction(ctx); + } else { + const ast_expression *id = subexpressions[0]; + YYLTYPE loc = id->get_location(); + exec_list actual_parameters; + + process_parameters(instructions, &actual_parameters, &this->expressions, + state); + + const glsl_type *const type = + state->symbols->get_type(id->primary_expression.identifier); + + if ((type != NULL) && type->is_record()) { + ir_constant *constant = + constant_record_constructor(type, &loc, &actual_parameters, state); + + if (constant != NULL) + return constant; + } + + return match_function_by_name(instructions, + id->primary_expression.identifier, & loc, + &actual_parameters, state); + } + + return ir_call::get_error_instruction(ctx); +} diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp new file mode 100644 index 00000000000..33eb27533fd --- /dev/null +++ b/src/glsl/ast_to_hir.cpp @@ -0,0 +1,2453 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ast_to_hir.c + * Convert abstract syntax to to high-level intermediate reprensentation (HIR). + * + * During the conversion to HIR, the majority of the symantic checking is + * preformed on the program. This includes: + * + * * Symbol table management + * * Type checking + * * Function binding + * + * The majority of this work could be done during parsing, and the parser could + * probably generate HIR directly. However, this results in frequent changes + * to the parser code. Since we do not assume that every system this complier + * is built on will have Flex and Bison installed, we have to store the code + * generated by these tools in our version control system. In other parts of + * the system we've seen problems where a parser was changed but the generated + * code was not committed, merge conflicts where created because two developers + * had slightly different versions of Bison installed, etc. + * + * I have also noticed that running Bison generated parsers in GDB is very + * irritating. When you get a segfault on '$$ = $1->foo', you can't very + * well 'print $1' in GDB. + * + * As a result, my preference is to put as little C code as possible in the + * parser (and lexer) sources. + */ + +#include "main/imports.h" +#include "glsl_symbol_table.h" +#include "glsl_parser_extras.h" +#include "ast.h" +#include "glsl_types.h" +#include "ir.h" + +void +_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) +{ + _mesa_glsl_initialize_variables(instructions, state); + _mesa_glsl_initialize_constructors(instructions, state); + _mesa_glsl_initialize_functions(instructions, state); + + state->current_function = NULL; + + foreach_list_typed (ast_node, ast, link, & state->translation_unit) + ast->hir(instructions, state); +} + + +/** + * If a conversion is available, convert one operand to a different type + * + * The \c from \c ir_rvalue is converted "in place". + * + * \param to Type that the operand it to be converted to + * \param from Operand that is being converted + * \param state GLSL compiler state + * + * \return + * If a conversion is possible (or unnecessary), \c true is returned. + * Otherwise \c false is returned. + */ +static bool +apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + if (to->base_type == from->type->base_type) + return true; + + /* This conversion was added in GLSL 1.20. If the compilation mode is + * GLSL 1.10, the conversion is skipped. + */ + if (state->language_version < 120) + return false; + + /* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec: + * + * "There are no implicit array or structure conversions. For + * example, an array of int cannot be implicitly converted to an + * array of float. There are no implicit conversions between + * signed and unsigned integers." + */ + /* FINISHME: The above comment is partially a lie. There is int/uint + * FINISHME: conversion for immediate constants. + */ + if (!to->is_float() || !from->type->is_numeric()) + return false; + + switch (from->type->base_type) { + case GLSL_TYPE_INT: + from = new(ctx) ir_expression(ir_unop_i2f, to, from, NULL); + break; + case GLSL_TYPE_UINT: + from = new(ctx) ir_expression(ir_unop_u2f, to, from, NULL); + break; + case GLSL_TYPE_BOOL: + from = new(ctx) ir_expression(ir_unop_b2f, to, from, NULL); + break; + default: + assert(0); + } + + return true; +} + + +static const struct glsl_type * +arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, + bool multiply, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) +{ + const glsl_type *type_a = value_a->type; + const glsl_type *type_b = value_b->type; + + /* From GLSL 1.50 spec, page 56: + * + * "The arithmetic binary operators add (+), subtract (-), + * multiply (*), and divide (/) operate on integer and + * floating-point scalars, vectors, and matrices." + */ + if (!type_a->is_numeric() || !type_b->is_numeric()) { + _mesa_glsl_error(loc, state, + "Operands to arithmetic operators must be numeric"); + return glsl_type::error_type; + } + + + /* "If one operand is floating-point based and the other is + * not, then the conversions from Section 4.1.10 "Implicit + * Conversions" are applied to the non-floating-point-based operand." + */ + if (!apply_implicit_conversion(type_a, value_b, state) + && !apply_implicit_conversion(type_b, value_a, state)) { + _mesa_glsl_error(loc, state, + "Could not implicitly convert operands to " + "arithmetic operator"); + return glsl_type::error_type; + } + type_a = value_a->type; + type_b = value_b->type; + + /* "If the operands are integer types, they must both be signed or + * both be unsigned." + * + * From this rule and the preceeding conversion it can be inferred that + * both types must be GLSL_TYPE_FLOAT, or GLSL_TYPE_UINT, or GLSL_TYPE_INT. + * The is_numeric check above already filtered out the case where either + * type is not one of these, so now the base types need only be tested for + * equality. + */ + if (type_a->base_type != type_b->base_type) { + _mesa_glsl_error(loc, state, + "base type mismatch for arithmetic operator"); + return glsl_type::error_type; + } + + /* "All arithmetic binary operators result in the same fundamental type + * (signed integer, unsigned integer, or floating-point) as the + * operands they operate on, after operand type conversion. After + * conversion, the following cases are valid + * + * * The two operands are scalars. In this case the operation is + * applied, resulting in a scalar." + */ + if (type_a->is_scalar() && type_b->is_scalar()) + return type_a; + + /* "* One operand is a scalar, and the other is a vector or matrix. + * In this case, the scalar operation is applied independently to each + * component of the vector or matrix, resulting in the same size + * vector or matrix." + */ + if (type_a->is_scalar()) { + if (!type_b->is_scalar()) + return type_b; + } else if (type_b->is_scalar()) { + return type_a; + } + + /* All of the combinations of , , + * , , and have been + * handled. + */ + assert(!type_a->is_scalar()); + assert(!type_b->is_scalar()); + + /* "* The two operands are vectors of the same size. In this case, the + * operation is done component-wise resulting in the same size + * vector." + */ + if (type_a->is_vector() && type_b->is_vector()) { + if (type_a == type_b) { + return type_a; + } else { + _mesa_glsl_error(loc, state, + "vector size mismatch for arithmetic operator"); + return glsl_type::error_type; + } + } + + /* All of the combinations of , , + * , , , and + * have been handled. At least one of the operands must + * be matrix. Further, since there are no integer matrix types, the base + * type of both operands must be float. + */ + assert(type_a->is_matrix() || type_b->is_matrix()); + assert(type_a->base_type == GLSL_TYPE_FLOAT); + assert(type_b->base_type == GLSL_TYPE_FLOAT); + + /* "* The operator is add (+), subtract (-), or divide (/), and the + * operands are matrices with the same number of rows and the same + * number of columns. In this case, the operation is done component- + * wise resulting in the same size matrix." + * * The operator is multiply (*), where both operands are matrices or + * one operand is a vector and the other a matrix. A right vector + * operand is treated as a column vector and a left vector operand as a + * row vector. In all these cases, it is required that the number of + * columns of the left operand is equal to the number of rows of the + * right operand. Then, the multiply (*) operation does a linear + * algebraic multiply, yielding an object that has the same number of + * rows as the left operand and the same number of columns as the right + * operand. Section 5.10 "Vector and Matrix Operations" explains in + * more detail how vectors and matrices are operated on." + */ + if (! multiply) { + if (type_a == type_b) + return type_a; + } else { + if (type_a->is_matrix() && type_b->is_matrix()) { + /* Matrix multiply. The columns of A must match the rows of B. Given + * the other previously tested constraints, this means the vector type + * of a row from A must be the same as the vector type of a column from + * B. + */ + if (type_a->row_type() == type_b->column_type()) { + /* The resulting matrix has the number of columns of matrix B and + * the number of rows of matrix A. We get the row count of A by + * looking at the size of a vector that makes up a column. The + * transpose (size of a row) is done for B. + */ + const glsl_type *const type = + glsl_type::get_instance(type_a->base_type, + type_a->column_type()->vector_elements, + type_b->row_type()->vector_elements); + assert(type != glsl_type::error_type); + + return type; + } + } else if (type_a->is_matrix()) { + /* A is a matrix and B is a column vector. Columns of A must match + * rows of B. Given the other previously tested constraints, this + * means the vector type of a row from A must be the same as the + * vector the type of B. + */ + if (type_a->row_type() == type_b) + return type_b; + } else { + assert(type_b->is_matrix()); + + /* A is a row vector and B is a matrix. Columns of A must match rows + * of B. Given the other previously tested constraints, this means + * the type of A must be the same as the vector type of a column from + * B. + */ + if (type_a == type_b->column_type()) + return type_a; + } + + _mesa_glsl_error(loc, state, "size mismatch for matrix multiplication"); + return glsl_type::error_type; + } + + + /* "All other cases are illegal." + */ + _mesa_glsl_error(loc, state, "type mismatch"); + return glsl_type::error_type; +} + + +static const struct glsl_type * +unary_arithmetic_result_type(const struct glsl_type *type, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) +{ + /* From GLSL 1.50 spec, page 57: + * + * "The arithmetic unary operators negate (-), post- and pre-increment + * and decrement (-- and ++) operate on integer or floating-point + * values (including vectors and matrices). All unary operators work + * component-wise on their operands. These result with the same type + * they operated on." + */ + if (!type->is_numeric()) { + _mesa_glsl_error(loc, state, + "Operands to arithmetic operators must be numeric"); + return glsl_type::error_type; + } + + return type; +} + + +static const struct glsl_type * +modulus_result_type(const struct glsl_type *type_a, + const struct glsl_type *type_b, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) +{ + /* From GLSL 1.50 spec, page 56: + * "The operator modulus (%) operates on signed or unsigned integers or + * integer vectors. The operand types must both be signed or both be + * unsigned." + */ + if (!type_a->is_integer() || !type_b->is_integer() + || (type_a->base_type != type_b->base_type)) { + _mesa_glsl_error(loc, state, "type mismatch"); + return glsl_type::error_type; + } + + /* "The operands cannot be vectors of differing size. If one operand is + * a scalar and the other vector, then the scalar is applied component- + * wise to the vector, resulting in the same type as the vector. If both + * are vectors of the same size, the result is computed component-wise." + */ + if (type_a->is_vector()) { + if (!type_b->is_vector() + || (type_a->vector_elements == type_b->vector_elements)) + return type_a; + } else + return type_b; + + /* "The operator modulus (%) is not defined for any other data types + * (non-integer types)." + */ + _mesa_glsl_error(loc, state, "type mismatch"); + return glsl_type::error_type; +} + + +static const struct glsl_type * +relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) +{ + const glsl_type *type_a = value_a->type; + const glsl_type *type_b = value_b->type; + + /* From GLSL 1.50 spec, page 56: + * "The relational operators greater than (>), less than (<), greater + * than or equal (>=), and less than or equal (<=) operate only on + * scalar integer and scalar floating-point expressions." + */ + if (!type_a->is_numeric() + || !type_b->is_numeric() + || !type_a->is_scalar() + || !type_b->is_scalar()) { + _mesa_glsl_error(loc, state, + "Operands to relational operators must be scalar and " + "numeric"); + return glsl_type::error_type; + } + + /* "Either the operands' types must match, or the conversions from + * Section 4.1.10 "Implicit Conversions" will be applied to the integer + * operand, after which the types must match." + */ + if (!apply_implicit_conversion(type_a, value_b, state) + && !apply_implicit_conversion(type_b, value_a, state)) { + _mesa_glsl_error(loc, state, + "Could not implicitly convert operands to " + "relational operator"); + return glsl_type::error_type; + } + type_a = value_a->type; + type_b = value_b->type; + + if (type_a->base_type != type_b->base_type) { + _mesa_glsl_error(loc, state, "base type mismatch"); + return glsl_type::error_type; + } + + /* "The result is scalar Boolean." + */ + return glsl_type::bool_type; +} + + +/** + * Validates that a value can be assigned to a location with a specified type + * + * Validates that \c rhs can be assigned to some location. If the types are + * not an exact match but an automatic conversion is possible, \c rhs will be + * converted. + * + * \return + * \c NULL if \c rhs cannot be assigned to a location with type \c lhs_type. + * Otherwise the actual RHS to be assigned will be returned. This may be + * \c rhs, or it may be \c rhs after some type conversion. + * + * \note + * In addition to being used for assignments, this function is used to + * type-check return values. + */ +ir_rvalue * +validate_assignment(struct _mesa_glsl_parse_state *state, + const glsl_type *lhs_type, ir_rvalue *rhs) +{ + const glsl_type *rhs_type = rhs->type; + + /* If there is already some error in the RHS, just return it. Anything + * else will lead to an avalanche of error message back to the user. + */ + if (rhs_type->is_error()) + return rhs; + + /* If the types are identical, the assignment can trivially proceed. + */ + if (rhs_type == lhs_type) + return rhs; + + /* If the array element types are the same and the size of the LHS is zero, + * the assignment is okay. + * + * Note: Whole-array assignments are not permitted in GLSL 1.10, but this + * is handled by ir_dereference::is_lvalue. + */ + if (lhs_type->is_array() && rhs->type->is_array() + && (lhs_type->element_type() == rhs->type->element_type()) + && (lhs_type->array_size() == 0)) { + return rhs; + } + + /* Check for implicit conversion in GLSL 1.20 */ + if (apply_implicit_conversion(lhs_type, rhs, state)) { + rhs_type = rhs->type; + if (rhs_type == lhs_type) + return rhs; + } + + return NULL; +} + +ir_rvalue * +do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, + ir_rvalue *lhs, ir_rvalue *rhs, + YYLTYPE lhs_loc) +{ + void *ctx = talloc_parent(state); + bool error_emitted = (lhs->type->is_error() || rhs->type->is_error()); + + if (!error_emitted) { + /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */ + if (!lhs->is_lvalue()) { + _mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment"); + error_emitted = true; + } + } + + ir_rvalue *new_rhs = validate_assignment(state, lhs->type, rhs); + if (new_rhs == NULL) { + _mesa_glsl_error(& lhs_loc, state, "type mismatch"); + } else { + rhs = new_rhs; + + /* If the LHS array was not declared with a size, it takes it size from + * the RHS. If the LHS is an l-value and a whole array, it must be a + * dereference of a variable. Any other case would require that the LHS + * is either not an l-value or not a whole array. + */ + if (lhs->type->array_size() == 0) { + ir_dereference *const d = lhs->as_dereference(); + + assert(d != NULL); + + ir_variable *const var = d->variable_referenced(); + + assert(var != NULL); + + if (var->max_array_access >= unsigned(rhs->type->array_size())) { + /* FINISHME: This should actually log the location of the RHS. */ + _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due to " + "previous access", + var->max_array_access); + } + + var->type = glsl_type::get_array_instance(state, + lhs->type->element_type(), + rhs->type->array_size()); + } + } + + /* Most callers of do_assignment (assign, add_assign, pre_inc/dec, + * but not post_inc) need the converted assigned value as an rvalue + * to handle things like: + * + * i = j += 1; + * + * So we always just store the computed value being assigned to a + * temporary and return a deref of that temporary. If the rvalue + * ends up not being used, the temp will get copy-propagated out. + */ + ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp"); + ir_dereference_variable *deref_var = new(ctx) ir_dereference_variable(var); + instructions->push_tail(var); + instructions->push_tail(new(ctx) ir_assignment(deref_var, + rhs, + NULL)); + deref_var = new(ctx) ir_dereference_variable(var); + + instructions->push_tail(new(ctx) ir_assignment(lhs, + deref_var, + NULL)); + + return new(ctx) ir_dereference_variable(var); +} + + +/** + * Generate a new temporary and add its declaration to the instruction stream + */ +static ir_variable * +generate_temporary(const glsl_type *type, exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + char *name = (char *) malloc(sizeof(char) * 13); + + snprintf(name, 13, "tmp_%08X", state->temp_index); + state->temp_index++; + + ir_variable *const var = new(ctx) ir_variable(type, name); + instructions->push_tail(var); + + return var; +} + + +static ir_rvalue * +get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) +{ + void *ctx = talloc_parent(lvalue); + ir_variable *var; + + /* FINISHME: Give unique names to the temporaries. */ + var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp"); + var->mode = ir_var_auto; + + instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), + lvalue, NULL)); + + /* Once we've created this temporary, mark it read only so it's no + * longer considered an lvalue. + */ + var->read_only = true; + + return new(ctx) ir_dereference_variable(var); +} + + +ir_rvalue * +ast_node::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + (void) instructions; + (void) state; + + return NULL; +} + + +ir_rvalue * +ast_expression::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + static const int operations[AST_NUM_OPERATORS] = { + -1, /* ast_assign doesn't convert to ir_expression. */ + -1, /* ast_plus doesn't convert to ir_expression. */ + ir_unop_neg, + ir_binop_add, + ir_binop_sub, + ir_binop_mul, + ir_binop_div, + ir_binop_mod, + ir_binop_lshift, + ir_binop_rshift, + ir_binop_less, + ir_binop_greater, + ir_binop_lequal, + ir_binop_gequal, + ir_binop_equal, + ir_binop_nequal, + ir_binop_bit_and, + ir_binop_bit_xor, + ir_binop_bit_or, + ir_unop_bit_not, + ir_binop_logic_and, + ir_binop_logic_xor, + ir_binop_logic_or, + ir_unop_logic_not, + + /* Note: The following block of expression types actually convert + * to multiple IR instructions. + */ + ir_binop_mul, /* ast_mul_assign */ + ir_binop_div, /* ast_div_assign */ + ir_binop_mod, /* ast_mod_assign */ + ir_binop_add, /* ast_add_assign */ + ir_binop_sub, /* ast_sub_assign */ + ir_binop_lshift, /* ast_ls_assign */ + ir_binop_rshift, /* ast_rs_assign */ + ir_binop_bit_and, /* ast_and_assign */ + ir_binop_bit_xor, /* ast_xor_assign */ + ir_binop_bit_or, /* ast_or_assign */ + + -1, /* ast_conditional doesn't convert to ir_expression. */ + ir_binop_add, /* ast_pre_inc. */ + ir_binop_sub, /* ast_pre_dec. */ + ir_binop_add, /* ast_post_inc. */ + ir_binop_sub, /* ast_post_dec. */ + -1, /* ast_field_selection doesn't conv to ir_expression. */ + -1, /* ast_array_index doesn't convert to ir_expression. */ + -1, /* ast_function_call doesn't conv to ir_expression. */ + -1, /* ast_identifier doesn't convert to ir_expression. */ + -1, /* ast_int_constant doesn't convert to ir_expression. */ + -1, /* ast_uint_constant doesn't conv to ir_expression. */ + -1, /* ast_float_constant doesn't conv to ir_expression. */ + -1, /* ast_bool_constant doesn't conv to ir_expression. */ + -1, /* ast_sequence doesn't convert to ir_expression. */ + }; + ir_rvalue *result = NULL; + ir_rvalue *op[2]; + const struct glsl_type *type = glsl_type::error_type; + bool error_emitted = false; + YYLTYPE loc; + + loc = this->get_location(); + + switch (this->oper) { + case ast_assign: { + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + result = do_assignment(instructions, state, op[0], op[1], + this->subexpressions[0]->get_location()); + error_emitted = result->type->is_error(); + type = result->type; + break; + } + + case ast_plus: + op[0] = this->subexpressions[0]->hir(instructions, state); + + error_emitted = op[0]->type->is_error(); + if (type->is_error()) + op[0]->type = type; + + result = op[0]; + break; + + case ast_neg: + op[0] = this->subexpressions[0]->hir(instructions, state); + + type = unary_arithmetic_result_type(op[0]->type, state, & loc); + + error_emitted = type->is_error(); + + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], NULL); + break; + + case ast_add: + case ast_sub: + case ast_mul: + case ast_div: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = arithmetic_result_type(op[0], op[1], + (this->oper == ast_mul), + state, & loc); + error_emitted = type->is_error(); + + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + break; + + case ast_mod: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = modulus_result_type(op[0]->type, op[1]->type, state, & loc); + + assert(operations[this->oper] == ir_binop_mod); + + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + error_emitted = type->is_error(); + break; + + case ast_lshift: + case ast_rshift: + _mesa_glsl_error(& loc, state, "FINISHME: implement bit-shift operators"); + error_emitted = true; + break; + + case ast_less: + case ast_greater: + case ast_lequal: + case ast_gequal: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = relational_result_type(op[0], op[1], state, & loc); + + /* The relational operators must either generate an error or result + * in a scalar boolean. See page 57 of the GLSL 1.50 spec. + */ + assert(type->is_error() + || ((type->base_type == GLSL_TYPE_BOOL) + && type->is_scalar())); + + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + error_emitted = type->is_error(); + break; + + case ast_nequal: + case ast_equal: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + /* From page 58 (page 64 of the PDF) of the GLSL 1.50 spec: + * + * "The equality operators equal (==), and not equal (!=) + * operate on all types. They result in a scalar Boolean. If + * the operand types do not match, then there must be a + * conversion from Section 4.1.10 "Implicit Conversions" + * applied to one operand that can make them match, in which + * case this conversion is done." + */ + if ((!apply_implicit_conversion(op[0]->type, op[1], state) + && !apply_implicit_conversion(op[1]->type, op[0], state)) + || (op[0]->type != op[1]->type)) { + _mesa_glsl_error(& loc, state, "operands of `%s' must have the same " + "type", (this->oper == ast_equal) ? "==" : "!="); + error_emitted = true; + } else if ((state->language_version <= 110) + && (op[0]->type->is_array() || op[1]->type->is_array())) { + _mesa_glsl_error(& loc, state, "array comparisons forbidden in " + "GLSL 1.10"); + error_emitted = true; + } + + result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], op[1]); + type = glsl_type::bool_type; + + assert(result->type == glsl_type::bool_type); + break; + + case ast_bit_and: + case ast_bit_xor: + case ast_bit_or: + case ast_bit_not: + _mesa_glsl_error(& loc, state, "FINISHME: implement bit-wise operators"); + error_emitted = true; + break; + + case ast_logic_and: { + op[0] = this->subexpressions[0]->hir(instructions, state); + + if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[0]->get_location(); + + _mesa_glsl_error(& loc, state, "LHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } + + ir_constant *op0_const = op[0]->constant_expression_value(); + if (op0_const) { + if (op0_const->value.b[0]) { + op[1] = this->subexpressions[1]->hir(instructions, state); + + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[1]->get_location(); + + _mesa_glsl_error(& loc, state, + "RHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } + result = op[1]; + } else { + result = op0_const; + } + type = glsl_type::bool_type; + } else { + ir_if *const stmt = new(ctx) ir_if(op[0]); + instructions->push_tail(stmt); + + op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); + + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[1]->get_location(); + + _mesa_glsl_error(& loc, state, + "RHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } + + ir_variable *const tmp = generate_temporary(glsl_type::bool_type, + instructions, state); + + ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); + ir_assignment *const then_assign = + new(ctx) ir_assignment(then_deref, op[1], NULL); + stmt->then_instructions.push_tail(then_assign); + + ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp); + ir_assignment *const else_assign = + new(ctx) ir_assignment(else_deref, new(ctx) ir_constant(false), NULL); + stmt->else_instructions.push_tail(else_assign); + + result = new(ctx) ir_dereference_variable(tmp); + type = tmp->type; + } + break; + } + + case ast_logic_or: { + op[0] = this->subexpressions[0]->hir(instructions, state); + + if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[0]->get_location(); + + _mesa_glsl_error(& loc, state, "LHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } + + ir_constant *op0_const = op[0]->constant_expression_value(); + if (op0_const) { + if (op0_const->value.b[0]) { + result = op0_const; + } else { + op[1] = this->subexpressions[1]->hir(instructions, state); + + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[1]->get_location(); + + _mesa_glsl_error(& loc, state, + "RHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } + result = op[1]; + } + type = glsl_type::bool_type; + } else { + ir_if *const stmt = new(ctx) ir_if(op[0]); + instructions->push_tail(stmt); + + ir_variable *const tmp = generate_temporary(glsl_type::bool_type, + instructions, state); + + op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); + + if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[1]->get_location(); + + _mesa_glsl_error(& loc, state, "RHS of `%s' must be scalar boolean", + operator_string(this->oper)); + error_emitted = true; + } + + ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); + ir_assignment *const then_assign = + new(ctx) ir_assignment(then_deref, new(ctx) ir_constant(true), NULL); + stmt->then_instructions.push_tail(then_assign); + + ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp); + ir_assignment *const else_assign = + new(ctx) ir_assignment(else_deref, op[1], NULL); + stmt->else_instructions.push_tail(else_assign); + + result = new(ctx) ir_dereference_variable(tmp); + type = tmp->type; + } + break; + } + + case ast_logic_xor: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + + result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], op[1]); + type = glsl_type::bool_type; + break; + + case ast_logic_not: + op[0] = this->subexpressions[0]->hir(instructions, state); + + if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[0]->get_location(); + + _mesa_glsl_error(& loc, state, + "operand of `!' must be scalar boolean"); + error_emitted = true; + } + + result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], NULL); + type = glsl_type::bool_type; + break; + + case ast_mul_assign: + case ast_div_assign: + case ast_add_assign: + case ast_sub_assign: { + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = arithmetic_result_type(op[0], op[1], + (this->oper == ast_mul_assign), + state, & loc); + + ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + + result = do_assignment(instructions, state, + (ir_rvalue *)op[0]->clone(NULL), temp_rhs, + this->subexpressions[0]->get_location()); + type = result->type; + error_emitted = (op[0]->type->is_error()); + + /* GLSL 1.10 does not allow array assignment. However, we don't have to + * explicitly test for this because none of the binary expression + * operators allow array operands either. + */ + + break; + } + + case ast_mod_assign: { + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = modulus_result_type(op[0]->type, op[1]->type, state, & loc); + + assert(operations[this->oper] == ir_binop_mod); + + struct ir_rvalue *temp_rhs; + temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + + result = do_assignment(instructions, state, + (ir_rvalue *)op[0]->clone(NULL), temp_rhs, + this->subexpressions[0]->get_location()); + type = result->type; + error_emitted = type->is_error(); + break; + } + + case ast_ls_assign: + case ast_rs_assign: + _mesa_glsl_error(& loc, state, + "FINISHME: implement bit-shift assignment operators"); + error_emitted = true; + break; + + case ast_and_assign: + case ast_xor_assign: + case ast_or_assign: + _mesa_glsl_error(& loc, state, + "FINISHME: implement logic assignment operators"); + error_emitted = true; + break; + + case ast_conditional: { + op[0] = this->subexpressions[0]->hir(instructions, state); + + /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: + * + * "The ternary selection operator (?:). It operates on three + * expressions (exp1 ? exp2 : exp3). This operator evaluates the + * first expression, which must result in a scalar Boolean." + */ + if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) { + YYLTYPE loc = this->subexpressions[0]->get_location(); + + _mesa_glsl_error(& loc, state, "?: condition must be scalar boolean"); + error_emitted = true; + } + + /* The :? operator is implemented by generating an anonymous temporary + * followed by an if-statement. The last instruction in each branch of + * the if-statement assigns a value to the anonymous temporary. This + * temporary is the r-value of the expression. + */ + exec_list then_instructions; + exec_list else_instructions; + + op[1] = this->subexpressions[1]->hir(&then_instructions, state); + op[2] = this->subexpressions[2]->hir(&else_instructions, state); + + /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: + * + * "The second and third expressions can be any type, as + * long their types match, or there is a conversion in + * Section 4.1.10 "Implicit Conversions" that can be applied + * to one of the expressions to make their types match. This + * resulting matching type is the type of the entire + * expression." + */ + if ((!apply_implicit_conversion(op[1]->type, op[2], state) + && !apply_implicit_conversion(op[2]->type, op[1], state)) + || (op[1]->type != op[2]->type)) { + YYLTYPE loc = this->subexpressions[1]->get_location(); + + _mesa_glsl_error(& loc, state, "Second and third operands of ?: " + "operator must have matching types."); + error_emitted = true; + type = glsl_type::error_type; + } else { + type = op[1]->type; + } + + ir_constant *cond_val = op[0]->constant_expression_value(); + ir_constant *then_val = op[1]->constant_expression_value(); + ir_constant *else_val = op[2]->constant_expression_value(); + + if (then_instructions.is_empty() + && else_instructions.is_empty() + && (cond_val != NULL) && (then_val != NULL) && (else_val != NULL)) { + result = (cond_val->value.b[0]) ? then_val : else_val; + } else { + ir_variable *const tmp = generate_temporary(type, + instructions, state); + + ir_if *const stmt = new(ctx) ir_if(op[0]); + instructions->push_tail(stmt); + + then_instructions.move_nodes_to(& stmt->then_instructions); + ir_dereference *const then_deref = + new(ctx) ir_dereference_variable(tmp); + ir_assignment *const then_assign = + new(ctx) ir_assignment(then_deref, op[1], NULL); + stmt->then_instructions.push_tail(then_assign); + + else_instructions.move_nodes_to(& stmt->else_instructions); + ir_dereference *const else_deref = + new(ctx) ir_dereference_variable(tmp); + ir_assignment *const else_assign = + new(ctx) ir_assignment(else_deref, op[2], NULL); + stmt->else_instructions.push_tail(else_assign); + + result = new(ctx) ir_dereference_variable(tmp); + } + break; + } + + case ast_pre_inc: + case ast_pre_dec: { + op[0] = this->subexpressions[0]->hir(instructions, state); + if (op[0]->type->base_type == GLSL_TYPE_FLOAT) + op[1] = new(ctx) ir_constant(1.0f); + else + op[1] = new(ctx) ir_constant(1); + + type = arithmetic_result_type(op[0], op[1], false, state, & loc); + + struct ir_rvalue *temp_rhs; + temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + + result = do_assignment(instructions, state, + (ir_rvalue *)op[0]->clone(NULL), temp_rhs, + this->subexpressions[0]->get_location()); + type = result->type; + error_emitted = op[0]->type->is_error(); + break; + } + + case ast_post_inc: + case ast_post_dec: { + op[0] = this->subexpressions[0]->hir(instructions, state); + if (op[0]->type->base_type == GLSL_TYPE_FLOAT) + op[1] = new(ctx) ir_constant(1.0f); + else + op[1] = new(ctx) ir_constant(1); + + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + + type = arithmetic_result_type(op[0], op[1], false, state, & loc); + + struct ir_rvalue *temp_rhs; + temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + + /* Get a temporary of a copy of the lvalue before it's modified. + * This may get thrown away later. + */ + result = get_lvalue_copy(instructions, (ir_rvalue *)op[0]->clone(NULL)); + + (void)do_assignment(instructions, state, + (ir_rvalue *)op[0]->clone(NULL), temp_rhs, + this->subexpressions[0]->get_location()); + + type = result->type; + error_emitted = op[0]->type->is_error(); + break; + } + + case ast_field_selection: + result = _mesa_ast_field_selection_to_hir(this, instructions, state); + type = result->type; + break; + + case ast_array_index: { + YYLTYPE index_loc = subexpressions[1]->get_location(); + + op[0] = subexpressions[0]->hir(instructions, state); + op[1] = subexpressions[1]->hir(instructions, state); + + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + + ir_rvalue *const array = op[0]; + + result = new(ctx) ir_dereference_array(op[0], op[1]); + + /* Do not use op[0] after this point. Use array. + */ + op[0] = NULL; + + + if (error_emitted) + break; + + if (!array->type->is_array() + && !array->type->is_matrix() + && !array->type->is_vector()) { + _mesa_glsl_error(& index_loc, state, + "cannot dereference non-array / non-matrix / " + "non-vector"); + error_emitted = true; + } + + if (!op[1]->type->is_integer()) { + _mesa_glsl_error(& index_loc, state, + "array index must be integer type"); + error_emitted = true; + } else if (!op[1]->type->is_scalar()) { + _mesa_glsl_error(& index_loc, state, + "array index must be scalar"); + error_emitted = true; + } + + /* If the array index is a constant expression and the array has a + * declared size, ensure that the access is in-bounds. If the array + * index is not a constant expression, ensure that the array has a + * declared size. + */ + ir_constant *const const_index = op[1]->constant_expression_value(); + if (const_index != NULL) { + const int idx = const_index->value.i[0]; + const char *type_name; + unsigned bound = 0; + + if (array->type->is_matrix()) { + type_name = "matrix"; + } else if (array->type->is_vector()) { + type_name = "vector"; + } else { + type_name = "array"; + } + + /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec: + * + * "It is illegal to declare an array with a size, and then + * later (in the same shader) index the same array with an + * integral constant expression greater than or equal to the + * declared size. It is also illegal to index an array with a + * negative constant expression." + */ + if (array->type->is_matrix()) { + if (array->type->row_type()->vector_elements <= idx) { + bound = array->type->row_type()->vector_elements; + } + } else if (array->type->is_vector()) { + if (array->type->vector_elements <= idx) { + bound = array->type->vector_elements; + } + } else { + if ((array->type->array_size() > 0) + && (array->type->array_size() <= idx)) { + bound = array->type->array_size(); + } + } + + if (bound > 0) { + _mesa_glsl_error(& loc, state, "%s index must be < %u", + type_name, bound); + error_emitted = true; + } else if (idx < 0) { + _mesa_glsl_error(& loc, state, "%s index must be >= 0", + type_name); + error_emitted = true; + } + + if (array->type->is_array()) { + /* If the array is a variable dereference, it dereferences the + * whole array, by definition. Use this to get the variable. + * + * FINISHME: Should some methods for getting / setting / testing + * FINISHME: array access limits be added to ir_dereference? + */ + ir_variable *const v = array->whole_variable_referenced(); + if ((v != NULL) && (unsigned(idx) > v->max_array_access)) + v->max_array_access = idx; + } + } + + if (error_emitted) + result->type = glsl_type::error_type; + + type = result->type; + break; + } + + case ast_function_call: + /* Should *NEVER* get here. ast_function_call should always be handled + * by ast_function_expression::hir. + */ + assert(0); + break; + + case ast_identifier: { + /* ast_identifier can appear several places in a full abstract syntax + * tree. This particular use must be at location specified in the grammar + * as 'variable_identifier'. + */ + ir_variable *var = + state->symbols->get_variable(this->primary_expression.identifier); + + result = new(ctx) ir_dereference_variable(var); + + if (var != NULL) { + type = result->type; + } else { + _mesa_glsl_error(& loc, state, "`%s' undeclared", + this->primary_expression.identifier); + + error_emitted = true; + } + break; + } + + case ast_int_constant: + type = glsl_type::int_type; + result = new(ctx) ir_constant(this->primary_expression.int_constant); + break; + + case ast_uint_constant: + type = glsl_type::uint_type; + result = new(ctx) ir_constant(this->primary_expression.uint_constant); + break; + + case ast_float_constant: + type = glsl_type::float_type; + result = new(ctx) ir_constant(this->primary_expression.float_constant); + break; + + case ast_bool_constant: + type = glsl_type::bool_type; + result = new(ctx) ir_constant(bool(this->primary_expression.bool_constant)); + break; + + case ast_sequence: { + /* It should not be possible to generate a sequence in the AST without + * any expressions in it. + */ + assert(!this->expressions.is_empty()); + + /* The r-value of a sequence is the last expression in the sequence. If + * the other expressions in the sequence do not have side-effects (and + * therefore add instructions to the instruction list), they get dropped + * on the floor. + */ + foreach_list_typed (ast_node, ast, link, &this->expressions) + result = ast->hir(instructions, state); + + type = result->type; + + /* Any errors should have already been emitted in the loop above. + */ + error_emitted = true; + break; + } + } + + if (type->is_error() && !error_emitted) + _mesa_glsl_error(& loc, state, "type mismatch"); + + return result; +} + + +ir_rvalue * +ast_expression_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + /* It is possible to have expression statements that don't have an + * expression. This is the solitary semicolon: + * + * for (i = 0; i < 5; i++) + * ; + * + * In this case the expression will be NULL. Test for NULL and don't do + * anything in that case. + */ + if (expression != NULL) + expression->hir(instructions, state); + + /* Statements do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_compound_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + if (new_scope) + state->symbols->push_scope(); + + foreach_list_typed (ast_node, ast, link, &this->statements) + ast->hir(instructions, state); + + if (new_scope) + state->symbols->pop_scope(); + + /* Compound statements do not have r-values. + */ + return NULL; +} + + +static const glsl_type * +process_array_type(const glsl_type *base, ast_node *array_size, + struct _mesa_glsl_parse_state *state) +{ + unsigned length = 0; + + /* FINISHME: Reject delcarations of multidimensional arrays. */ + + if (array_size != NULL) { + exec_list dummy_instructions; + ir_rvalue *const ir = array_size->hir(& dummy_instructions, state); + YYLTYPE loc = array_size->get_location(); + + /* FINISHME: Verify that the grammar forbids side-effects in array + * FINISHME: sizes. i.e., 'vec4 [x = 12] data' + */ + assert(dummy_instructions.is_empty()); + + if (ir != NULL) { + if (!ir->type->is_integer()) { + _mesa_glsl_error(& loc, state, "array size must be integer type"); + } else if (!ir->type->is_scalar()) { + _mesa_glsl_error(& loc, state, "array size must be scalar type"); + } else { + ir_constant *const size = ir->constant_expression_value(); + + if (size == NULL) { + _mesa_glsl_error(& loc, state, "array size must be a " + "constant valued expression"); + } else if (size->value.i[0] <= 0) { + _mesa_glsl_error(& loc, state, "array size must be > 0"); + } else { + assert(size->type == ir->type); + length = size->value.u[0]; + } + } + } + } + + return glsl_type::get_array_instance(state, base, length); +} + + +const glsl_type * +ast_type_specifier::glsl_type(const char **name, + struct _mesa_glsl_parse_state *state) const +{ + const struct glsl_type *type; + + if ((this->type_specifier == ast_struct) && (this->type_name == NULL)) { + /* FINISHME: Handle annonymous structures. */ + type = NULL; + } else { + type = state->symbols->get_type(this->type_name); + *name = this->type_name; + + if (this->is_array) { + type = process_array_type(type, this->array_size, state); + } + } + + return type; +} + + +static void +apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, + struct ir_variable *var, + struct _mesa_glsl_parse_state *state, + YYLTYPE *loc) +{ + if (qual->invariant) + var->invariant = 1; + + /* FINISHME: Mark 'in' variables at global scope as read-only. */ + if (qual->constant || qual->attribute || qual->uniform + || (qual->varying && (state->target == fragment_shader))) + var->read_only = 1; + + if (qual->centroid) + var->centroid = 1; + + if (qual->attribute && state->target != vertex_shader) { + var->type = glsl_type::error_type; + _mesa_glsl_error(loc, state, + "`attribute' variables may not be declared in the " + "%s shader", + _mesa_glsl_shader_target_name(state->target)); + } + + /* From page 25 (page 31 of the PDF) of the GLSL 1.10 spec: + * + * "The varying qualifier can be used only with the data types + * float, vec2, vec3, vec4, mat2, mat3, and mat4, or arrays of + * these." + */ + if (qual->varying) { + const glsl_type *non_array_type; + + if (var->type && var->type->is_array()) + non_array_type = var->type->fields.array; + else + non_array_type = var->type; + + if (non_array_type && non_array_type->base_type != GLSL_TYPE_FLOAT) { + var->type = glsl_type::error_type; + _mesa_glsl_error(loc, state, + "varying variables must be of base type float"); + } + } + + if (qual->in && qual->out) + var->mode = ir_var_inout; + else if (qual->attribute || qual->in + || (qual->varying && (state->target == fragment_shader))) + var->mode = ir_var_in; + else if (qual->out || (qual->varying && (state->target == vertex_shader))) + var->mode = ir_var_out; + else if (qual->uniform) + var->mode = ir_var_uniform; + else + var->mode = ir_var_auto; + + if (qual->uniform) + var->shader_in = true; + + /* Any 'in' or 'inout' variables at global scope must be marked as being + * shader inputs. Likewise, any 'out' or 'inout' variables at global scope + * must be marked as being shader outputs. + */ + if (state->current_function == NULL) { + switch (var->mode) { + case ir_var_in: + case ir_var_uniform: + var->shader_in = true; + break; + case ir_var_out: + var->shader_out = true; + break; + case ir_var_inout: + var->shader_in = true; + var->shader_out = true; + break; + default: + break; + } + } + + if (qual->flat) + var->interpolation = ir_var_flat; + else if (qual->noperspective) + var->interpolation = ir_var_noperspective; + else + var->interpolation = ir_var_smooth; + + if (var->type->is_array() && (state->language_version >= 120)) { + var->array_lvalue = true; + } +} + + +ir_rvalue * +ast_declarator_list::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + const struct glsl_type *decl_type; + const char *type_name = NULL; + ir_rvalue *result = NULL; + YYLTYPE loc = this->get_location(); + + /* The type specifier may contain a structure definition. Process that + * before any of the variable declarations. + */ + (void) this->type->specifier->hir(instructions, state); + + /* FINISHME: Handle vertex shader "invariant" declarations that do not + * FINISHME: include a type. These re-declare built-in variables to be + * FINISHME: invariant. + */ + + decl_type = this->type->specifier->glsl_type(& type_name, state); + if (this->declarations.is_empty()) { + /* There are only two valid cases where the declaration list can be + * empty. + * + * 1. The declaration is setting the default precision of a built-in + * type (e.g., 'precision highp vec4;'). + * + * 2. Adding 'invariant' to an existing vertex shader output. + */ + + if (this->type->qualifier.invariant) { + } else if (decl_type != NULL) { + } else { + _mesa_glsl_error(& loc, state, "incomplete declaration"); + } + } + + foreach_list_typed (ast_declaration, decl, link, &this->declarations) { + const struct glsl_type *var_type; + struct ir_variable *var; + + /* FINISHME: Emit a warning if a variable declaration shadows a + * FINISHME: declaration at a higher scope. + */ + + if ((decl_type == NULL) || decl_type->is_void()) { + if (type_name != NULL) { + _mesa_glsl_error(& loc, state, + "invalid type `%s' in declaration of `%s'", + type_name, decl->identifier); + } else { + _mesa_glsl_error(& loc, state, + "invalid type in declaration of `%s'", + decl->identifier); + } + continue; + } + + if (decl->is_array) { + var_type = process_array_type(decl_type, decl->array_size, state); + } else { + var_type = decl_type; + } + + var = new(ctx) ir_variable(var_type, decl->identifier); + + /* From page 22 (page 28 of the PDF) of the GLSL 1.10 specification; + * + * "Global variables can only use the qualifiers const, + * attribute, uni form, or varying. Only one may be + * specified. + * + * Local variables can only use the qualifier const." + * + * This is relaxed in GLSL 1.30. + */ + if (state->language_version < 120) { + if (this->type->qualifier.out) { + _mesa_glsl_error(& loc, state, + "`out' qualifier in declaration of `%s' " + "only valid for function parameters in GLSL 1.10.", + decl->identifier); + } + if (this->type->qualifier.in) { + _mesa_glsl_error(& loc, state, + "`in' qualifier in declaration of `%s' " + "only valid for function parameters in GLSL 1.10.", + decl->identifier); + } + /* FINISHME: Test for other invalid qualifiers. */ + } + + apply_type_qualifier_to_variable(& this->type->qualifier, var, state, + & loc); + + /* Attempt to add the variable to the symbol table. If this fails, it + * means the variable has already been declared at this scope. Arrays + * fudge this rule a little bit. + * + * From page 24 (page 30 of the PDF) of the GLSL 1.50 spec, + * + * "It is legal to declare an array without a size and then + * later re-declare the same name as an array of the same + * type and specify a size." + */ + if (state->symbols->name_declared_this_scope(decl->identifier)) { + ir_variable *const earlier = + state->symbols->get_variable(decl->identifier); + + if ((earlier != NULL) + && (earlier->type->array_size() == 0) + && var->type->is_array() + && (var->type->element_type() == earlier->type->element_type())) { + /* FINISHME: This doesn't match the qualifiers on the two + * FINISHME: declarations. It's not 100% clear whether this is + * FINISHME: required or not. + */ + + if (var->type->array_size() <= (int)earlier->max_array_access) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "array size must be > %u due to " + "previous access", + earlier->max_array_access); + } + + earlier->type = var->type; + delete var; + var = NULL; + } else { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "`%s' redeclared", + decl->identifier); + } + + continue; + } + + /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec, + * + * "Identifiers starting with "gl_" are reserved for use by + * OpenGL, and may not be declared in a shader as either a + * variable or a function." + */ + if (strncmp(decl->identifier, "gl_", 3) == 0) { + /* FINISHME: This should only trigger if we're not redefining + * FINISHME: a builtin (to add a qualifier, for example). + */ + _mesa_glsl_error(& loc, state, + "identifier `%s' uses reserved `gl_' prefix", + decl->identifier); + } + + instructions->push_tail(var); + + if (state->current_function != NULL) { + const char *mode = NULL; + const char *extra = ""; + + /* There is no need to check for 'inout' here because the parser will + * only allow that in function parameter lists. + */ + if (this->type->qualifier.attribute) { + mode = "attribute"; + } else if (this->type->qualifier.uniform) { + mode = "uniform"; + } else if (this->type->qualifier.varying) { + mode = "varying"; + } else if (this->type->qualifier.in) { + mode = "in"; + extra = " or in function parameter list"; + } else if (this->type->qualifier.out) { + mode = "out"; + extra = " or in function parameter list"; + } + + if (mode) { + _mesa_glsl_error(& loc, state, + "%s variable `%s' must be declared at " + "global scope%s", + mode, var->name, extra); + } + } else if (var->mode == ir_var_in) { + if (state->target == vertex_shader) { + bool error_emitted = false; + + /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: + * + * "Vertex shader inputs can only be float, floating-point + * vectors, matrices, signed and unsigned integers and integer + * vectors. Vertex shader inputs can also form arrays of these + * types, but not structures." + * + * From page 31 (page 27 of the PDF) of the GLSL 1.30 spec: + * + * "Vertex shader inputs can only be float, floating-point + * vectors, matrices, signed and unsigned integers and integer + * vectors. They cannot be arrays or structures." + * + * From page 23 (page 29 of the PDF) of the GLSL 1.20 spec: + * + * "The attribute qualifier can be used only with float, + * floating-point vectors, and matrices. Attribute variables + * cannot be declared as arrays or structures." + */ + const glsl_type *check_type = var->type->is_array() + ? var->type->fields.array : var->type; + + switch (check_type->base_type) { + case GLSL_TYPE_FLOAT: + break; + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + if (state->language_version > 120) + break; + /* FALLTHROUGH */ + default: + _mesa_glsl_error(& loc, state, + "vertex shader input / attribute cannot have " + "type %s`%s'", + var->type->is_array() ? "array of " : "", + check_type->name); + error_emitted = true; + } + + if (!error_emitted && (state->language_version <= 130) + && var->type->is_array()) { + _mesa_glsl_error(& loc, state, + "vertex shader input / attribute cannot have " + "array type"); + error_emitted = true; + } + } + } + + if (decl->initializer != NULL) { + YYLTYPE initializer_loc = decl->initializer->get_location(); + + /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec: + * + * "All uniform variables are read-only and are initialized either + * directly by an application via API commands, or indirectly by + * OpenGL." + */ + if ((state->language_version <= 110) + && (var->mode == ir_var_uniform)) { + _mesa_glsl_error(& initializer_loc, state, + "cannot initialize uniforms in GLSL 1.10"); + } + + if (var->type->is_sampler()) { + _mesa_glsl_error(& initializer_loc, state, + "cannot initialize samplers"); + } + + if ((var->mode == ir_var_in) && (state->current_function == NULL)) { + _mesa_glsl_error(& initializer_loc, state, + "cannot initialize %s shader input / %s", + _mesa_glsl_shader_target_name(state->target), + (state->target == vertex_shader) + ? "attribute" : "varying"); + } + + ir_dereference *const lhs = new(ctx) ir_dereference_variable(var); + ir_rvalue *rhs = decl->initializer->hir(instructions, state); + + /* Calculate the constant value if this is a const or uniform + * declaration. + */ + if (this->type->qualifier.constant || this->type->qualifier.uniform) { + ir_constant *constant_value = rhs->constant_expression_value(); + if (!constant_value) { + _mesa_glsl_error(& initializer_loc, state, + "initializer of %s variable `%s' must be a " + "constant expression", + (this->type->qualifier.constant) + ? "const" : "uniform", + decl->identifier); + } else { + rhs = constant_value; + var->constant_value = constant_value; + } + } + + if (rhs && !rhs->type->is_error()) { + bool temp = var->read_only; + if (this->type->qualifier.constant) + var->read_only = false; + + /* Never emit code to initialize a uniform. + */ + if (!this->type->qualifier.uniform) + result = do_assignment(instructions, state, lhs, rhs, + this->get_location()); + var->read_only = temp; + } + } + + /* From page 23 (page 29 of the PDF) of the GLSL 1.10 spec: + * + * "It is an error to write to a const variable outside of + * its declaration, so they must be initialized when + * declared." + */ + if (this->type->qualifier.constant && decl->initializer == NULL) { + _mesa_glsl_error(& loc, state, + "const declaration of `%s' must be initialized"); + } + + /* Add the vairable to the symbol table after processing the initializer. + * This differs from most C-like languages, but it follows the GLSL + * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 + * spec: + * + * "Within a declaration, the scope of a name starts immediately + * after the initializer if present or immediately after the name + * being declared if not." + */ + const bool added_variable = + state->symbols->add_variable(decl->identifier, var); + assert(added_variable); + } + + + /* Generally, variable declarations do not have r-values. However, + * one is used for the declaration in + * + * while (bool b = some_condition()) { + * ... + * } + * + * so we return the rvalue from the last seen declaration here. + */ + return result; +} + + +ir_rvalue * +ast_parameter_declarator::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + const struct glsl_type *type; + const char *name = NULL; + YYLTYPE loc = this->get_location(); + + type = this->type->specifier->glsl_type(& name, state); + + if (type == NULL) { + if (name != NULL) { + _mesa_glsl_error(& loc, state, + "invalid type `%s' in declaration of `%s'", + name, this->identifier); + } else { + _mesa_glsl_error(& loc, state, + "invalid type in declaration of `%s'", + this->identifier); + } + + type = glsl_type::error_type; + } + + /* From page 62 (page 68 of the PDF) of the GLSL 1.50 spec: + * + * "Functions that accept no input arguments need not use void in the + * argument list because prototypes (or definitions) are required and + * therefore there is no ambiguity when an empty argument list "( )" is + * declared. The idiom "(void)" as a parameter list is provided for + * convenience." + * + * Placing this check here prevents a void parameter being set up + * for a function, which avoids tripping up checks for main taking + * parameters and lookups of an unnamed symbol. + */ + if (type->is_void()) { + if (this->identifier != NULL) + _mesa_glsl_error(& loc, state, + "named parameter cannot have type `void'"); + + is_void = true; + return NULL; + } + + if (formal_parameter && (this->identifier == NULL)) { + _mesa_glsl_error(& loc, state, "formal parameter lacks a name"); + return NULL; + } + + is_void = false; + ir_variable *var = new(ctx) ir_variable(type, this->identifier); + + /* FINISHME: Handle array declarations. Note that this requires + * FINISHME: complete handling of constant expressions. + */ + + /* Apply any specified qualifiers to the parameter declaration. Note that + * for function parameters the default mode is 'in'. + */ + apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc); + if (var->mode == ir_var_auto) + var->mode = ir_var_in; + + instructions->push_tail(var); + + /* Parameter declarations do not have r-values. + */ + return NULL; +} + + +void +ast_parameter_declarator::parameters_to_hir(exec_list *ast_parameters, + bool formal, + exec_list *ir_parameters, + _mesa_glsl_parse_state *state) +{ + ast_parameter_declarator *void_param = NULL; + unsigned count = 0; + + foreach_list_typed (ast_parameter_declarator, param, link, ast_parameters) { + param->formal_parameter = formal; + param->hir(ir_parameters, state); + + if (param->is_void) + void_param = param; + + count++; + } + + if ((void_param != NULL) && (count > 1)) { + YYLTYPE loc = void_param->get_location(); + + _mesa_glsl_error(& loc, state, + "`void' parameter must be only parameter"); + } +} + + +ir_rvalue * +ast_function::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + ir_function *f = NULL; + ir_function_signature *sig = NULL; + exec_list hir_parameters; + + + /* Convert the list of function parameters to HIR now so that they can be + * used below to compare this function's signature with previously seen + * signatures for functions with the same name. + */ + ast_parameter_declarator::parameters_to_hir(& this->parameters, + is_definition, + & hir_parameters, state); + + const char *return_type_name; + const glsl_type *return_type = + this->return_type->specifier->glsl_type(& return_type_name, state); + + assert(return_type != NULL); + + /* Verify that this function's signature either doesn't match a previously + * seen signature for a function with the same name, or, if a match is found, + * that the previously seen signature does not have an associated definition. + */ + const char *const name = identifier; + f = state->symbols->get_function(name); + if (f != NULL) { + ir_function_signature *sig = f->exact_matching_signature(&hir_parameters); + if (sig != NULL) { + const char *badvar = sig->qualifiers_match(&hir_parameters); + if (badvar != NULL) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(&loc, state, "function `%s' parameter `%s' " + "qualifiers don't match prototype", name, badvar); + } + + if (sig->return_type != return_type) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(&loc, state, "function `%s' return type doesn't " + "match prototype", name); + } + + if (is_definition && sig->is_defined) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "function `%s' redefined", name); + sig = NULL; + } + } + } else if (state->symbols->name_declared_this_scope(name)) { + /* This function name shadows a non-function use of the same name. + */ + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "function name `%s' conflicts with " + "non-function", name); + sig = NULL; + } else { + f = new(ctx) ir_function(name); + state->symbols->add_function(f->name, f); + + /* Emit the new function header */ + instructions->push_tail(f); + } + + /* Verify the return type of main() */ + if (strcmp(name, "main") == 0) { + if (! return_type->is_void()) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "main() must return void"); + } + + if (!hir_parameters.is_empty()) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "main() must not take any parameters"); + } + } + + /* Finish storing the information about this new function in its signature. + */ + if (sig == NULL) { + sig = new(ctx) ir_function_signature(return_type); + f->add_signature(sig); + } + + sig->replace_parameters(&hir_parameters); + signature = sig; + + /* Function declarations (prototypes) do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_function_definition::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + prototype->is_definition = true; + prototype->hir(instructions, state); + + ir_function_signature *signature = prototype->signature; + + assert(state->current_function == NULL); + state->current_function = signature; + + /* Duplicate parameters declared in the prototype as concrete variables. + * Add these to the symbol table. + */ + state->symbols->push_scope(); + foreach_iter(exec_list_iterator, iter, signature->parameters) { + ir_variable *const var = ((ir_instruction *) iter.get())->as_variable(); + + assert(var != NULL); + + /* The only way a parameter would "exist" is if two parameters have + * the same name. + */ + if (state->symbols->name_declared_this_scope(var->name)) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "parameter `%s' redeclared", var->name); + } else { + state->symbols->add_variable(var->name, var); + } + } + + /* Convert the body of the function to HIR. */ + this->body->hir(&signature->body, state); + signature->is_defined = true; + + state->symbols->pop_scope(); + + assert(state->current_function == signature); + state->current_function = NULL; + + /* Function definitions do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_jump_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + + switch (mode) { + case ast_return: { + ir_return *inst; + assert(state->current_function); + + if (opt_return_value) { + if (state->current_function->return_type->base_type == + GLSL_TYPE_VOID) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`return` with a value, in function `%s' " + "returning void", + state->current_function->function_name()); + } + + ir_expression *const ret = (ir_expression *) + opt_return_value->hir(instructions, state); + assert(ret != NULL); + + /* FINISHME: Make sure the type of the return value matches the return + * FINISHME: type of the enclosing function. + */ + + inst = new(ctx) ir_return(ret); + } else { + if (state->current_function->return_type->base_type != + GLSL_TYPE_VOID) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`return' with no value, in function %s returning " + "non-void", + state->current_function->function_name()); + } + inst = new(ctx) ir_return; + } + + instructions->push_tail(inst); + break; + } + + case ast_discard: + /* FINISHME: discard support */ + if (state->target != fragment_shader) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`discard' may only appear in a fragment shader"); + } + break; + + case ast_break: + case ast_continue: + /* FINISHME: Handle switch-statements. They cannot contain 'continue', + * FINISHME: and they use a different IR instruction for 'break'. + */ + /* FINISHME: Correctly handle the nesting. If a switch-statement is + * FINISHME: inside a loop, a 'continue' is valid and will bind to the + * FINISHME: loop. + */ + if (state->loop_or_switch_nesting == NULL) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`%s' may only appear in a loop", + (mode == ast_break) ? "break" : "continue"); + } else { + ir_loop *const loop = state->loop_or_switch_nesting->as_loop(); + + if (loop != NULL) { + ir_loop_jump *const jump = + new(ctx) ir_loop_jump((mode == ast_break) + ? ir_loop_jump::jump_break + : ir_loop_jump::jump_continue); + instructions->push_tail(jump); + } + } + + break; + } + + /* Jump instructions do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_selection_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + + ir_rvalue *const condition = this->condition->hir(instructions, state); + + /* From page 66 (page 72 of the PDF) of the GLSL 1.50 spec: + * + * "Any expression whose type evaluates to a Boolean can be used as the + * conditional expression bool-expression. Vector types are not accepted + * as the expression to if." + * + * The checks are separated so that higher quality diagnostics can be + * generated for cases where both rules are violated. + */ + if (!condition->type->is_boolean() || !condition->type->is_scalar()) { + YYLTYPE loc = this->condition->get_location(); + + _mesa_glsl_error(& loc, state, "if-statement condition must be scalar " + "boolean"); + } + + ir_if *const stmt = new(ctx) ir_if(condition); + + if (then_statement != NULL) + then_statement->hir(& stmt->then_instructions, state); + + if (else_statement != NULL) + else_statement->hir(& stmt->else_instructions, state); + + instructions->push_tail(stmt); + + /* if-statements do not have r-values. + */ + return NULL; +} + + +void +ast_iteration_statement::condition_to_hir(ir_loop *stmt, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + + if (condition != NULL) { + ir_rvalue *const cond = + condition->hir(& stmt->body_instructions, state); + + if ((cond == NULL) + || !cond->type->is_boolean() || !cond->type->is_scalar()) { + YYLTYPE loc = condition->get_location(); + + _mesa_glsl_error(& loc, state, + "loop condition must be scalar boolean"); + } else { + /* As the first code in the loop body, generate a block that looks + * like 'if (!condition) break;' as the loop termination condition. + */ + ir_rvalue *const not_cond = + new(ctx) ir_expression(ir_unop_logic_not, glsl_type::bool_type, cond, + NULL); + + ir_if *const if_stmt = new(ctx) ir_if(not_cond); + + ir_jump *const break_stmt = + new(ctx) ir_loop_jump(ir_loop_jump::jump_break); + + if_stmt->then_instructions.push_tail(break_stmt); + stmt->body_instructions.push_tail(if_stmt); + } + } +} + + +ir_rvalue * +ast_iteration_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + + /* For-loops and while-loops start a new scope, but do-while loops do not. + */ + if (mode != ast_do_while) + state->symbols->push_scope(); + + if (init_statement != NULL) + init_statement->hir(instructions, state); + + ir_loop *const stmt = new(ctx) ir_loop(); + instructions->push_tail(stmt); + + /* Track the current loop and / or switch-statement nesting. + */ + ir_instruction *const nesting = state->loop_or_switch_nesting; + state->loop_or_switch_nesting = stmt; + + if (mode != ast_do_while) + condition_to_hir(stmt, state); + + if (body != NULL) + body->hir(& stmt->body_instructions, state); + + if (rest_expression != NULL) + rest_expression->hir(& stmt->body_instructions, state); + + if (mode == ast_do_while) + condition_to_hir(stmt, state); + + if (mode != ast_do_while) + state->symbols->pop_scope(); + + /* Restore previous nesting before returning. + */ + state->loop_or_switch_nesting = nesting; + + /* Loops do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_type_specifier::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + if (this->structure != NULL) + return this->structure->hir(instructions, state); + + return NULL; +} + + +ir_rvalue * +ast_struct_specifier::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + unsigned decl_count = 0; + + /* Make an initial pass over the list of structure fields to determine how + * many there are. Each element in this list is an ast_declarator_list. + * This means that we actually need to count the number of elements in the + * 'declarations' list in each of the elements. + */ + foreach_list_typed (ast_declarator_list, decl_list, link, + &this->declarations) { + foreach_list_const (decl_ptr, & decl_list->declarations) { + decl_count++; + } + } + + + /* Allocate storage for the structure fields and process the field + * declarations. As the declarations are processed, try to also convert + * the types to HIR. This ensures that structure definitions embedded in + * other structure definitions are processed. + */ + glsl_struct_field *const fields = (glsl_struct_field *) + malloc(sizeof(*fields) * decl_count); + + unsigned i = 0; + foreach_list_typed (ast_declarator_list, decl_list, link, + &this->declarations) { + const char *type_name; + + decl_list->type->specifier->hir(instructions, state); + + const glsl_type *decl_type = + decl_list->type->specifier->glsl_type(& type_name, state); + + foreach_list_typed (ast_declaration, decl, link, + &decl_list->declarations) { + const struct glsl_type *const field_type = + (decl->is_array) + ? process_array_type(decl_type, decl->array_size, state) + : decl_type; + + fields[i].type = (field_type != NULL) + ? field_type : glsl_type::error_type; + fields[i].name = decl->identifier; + i++; + } + } + + assert(i == decl_count); + + const char *name; + if (this->name == NULL) { + static unsigned anon_count = 1; + char buf[32]; + + snprintf(buf, sizeof(buf), "#anon_struct_%04x", anon_count); + anon_count++; + + name = strdup(buf); + } else { + name = this->name; + } + + glsl_type *t = new(ctx) glsl_type(fields, decl_count, name); + + YYLTYPE loc = this->get_location(); + if (!state->symbols->add_type(name, t)) { + _mesa_glsl_error(& loc, state, "struct `%s' previously defined", name); + } else { + /* This logic is a bit tricky. It is an error to declare a structure at + * global scope if there is also a function with the same name. + */ + if ((state->current_function == NULL) + && (state->symbols->get_function(name) != NULL)) { + _mesa_glsl_error(& loc, state, "name `%s' previously defined", name); + } else { + t->generate_constructor(state->symbols); + } + + const glsl_type **s = (const glsl_type **) + realloc(state->user_structures, + sizeof(state->user_structures[0]) * + (state->num_user_structures + 1)); + if (s != NULL) { + s[state->num_user_structures] = t; + state->user_structures = s; + state->num_user_structures++; + } + } + + /* Structure type definitions do not have r-values. + */ + return NULL; +} diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp new file mode 100644 index 00000000000..cb0852bb773 --- /dev/null +++ b/src/glsl/ast_type.cpp @@ -0,0 +1,110 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "ast.h" +#include "symbol_table.h" + +void +ast_type_specifier::print(void) const +{ + if (type_specifier == ast_struct) { + structure->print(); + } else { + printf("%s ", type_name); + } + + if (is_array) { + printf("[ "); + + if (array_size) { + array_size->print(); + } + + printf("] "); + } +} + +ast_type_specifier::ast_type_specifier(int specifier) + : type_specifier(ast_types(specifier)), type_name(NULL), structure(NULL), + is_array(false), array_size(NULL), precision(ast_precision_high) +{ + static const char *const names[] = { + "void", + "float", + "int", + "uint", + "bool", + "vec2", + "vec3", + "vec4", + "bvec2", + "bvec3", + "bvec4", + "ivec2", + "ivec3", + "ivec4", + "uvec2", + "uvec3", + "uvec4", + "mat2", + "mat2x3", + "mat2x4", + "mat3x2", + "mat3", + "mat3x4", + "mat4x2", + "mat4x3", + "mat4", + "sampler1D", + "sampler2D", + "sampler2DRect", + "sampler3D", + "samplerCube", + "sampler1DShadow", + "sampler2DShadow", + "sampler2DRectShadow", + "samplerCubeShadow", + "sampler1DArray", + "sampler2DArray", + "sampler1DArrayShadow", + "sampler2DArrayShadow", + "isampler1D", + "isampler2D", + "isampler3D", + "isamplerCube", + "isampler1DArray", + "isampler2DArray", + "usampler1D", + "usampler2D", + "usampler3D", + "usamplerCube", + "usampler1DArray", + "usampler2DArray", + + NULL, /* ast_struct */ + NULL /* ast_type_name */ + }; + + type_name = names[specifier]; +} diff --git a/src/glsl/autogen.sh b/src/glsl/autogen.sh new file mode 100755 index 00000000000..904cd6746c8 --- /dev/null +++ b/src/glsl/autogen.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd $srcdir + +autoreconf -v --install || exit 1 +cd $ORIGDIR || exit $? + +$srcdir/configure --enable-maintainer-mode "$@" diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp new file mode 100644 index 00000000000..d248388a1ab --- /dev/null +++ b/src/glsl/builtin_function.cpp @@ -0,0 +1,5080 @@ +/* DO NOT MODIFY - automatically generated by generate_builtins.pl */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "glsl_parser_extras.h" +#include "ir_reader.h" + +void +read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, + const char **functions, unsigned count) +{ + if (st->error) + return; + + for (unsigned i = 0; i < count; i++) { + _mesa_glsl_read_ir(st, instructions, functions[i]); + + if (st->error) { + printf("error reading builtin: %.35s ...\n", functions[i]); + return; + } + } +} + +/* 110 builtins */ + +static const char *builtins_110_abs = { + "((function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float abs (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 abs (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 abs (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 abs (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_all = { + "((function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n" + "))\n" +}; + +static const char *builtins_110_any = { + "((function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n" + "))\n" +}; + +static const char *builtins_110_asin = { + "((function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float *\n" + " (expression float -\n" + " (expression float *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression float sqrt\n" + " (expression float -\n" + " (constant float (1.0))\n" + " (expression float abs (var_ref x)))))\n" + " (expression float +\n" + " (constant float (1.5707288))\n" + " (expression float *\n" + " (expression float abs (var_ref x))\n" + " (expression float +\n" + " (constant float (-0.2121144))\n" + " (expression float *\n" + " (constant float (0.0742610))\n" + " (expression float abs (var_ref x))))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 *\n" + " (expression float -\n" + " (expression float *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression vec2 sqrt\n" + " (expression vec2 -\n" + " (constant float (1.0))\n" + " (expression vec2 abs (var_ref x)))))\n" + " (expression vec2 +\n" + " (constant float (1.5707288))\n" + " (expression vec2 *\n" + " (expression vec2 abs (var_ref x))\n" + " (expression vec2 +\n" + " (constant float (-0.2121144))\n" + " (expression vec2 *\n" + " (constant float (0.0742610))\n" + " (expression vec2 abs (var_ref x))))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 *\n" + " (expression vec3 -\n" + " (expression float *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression vec3 sqrt\n" + " (expression vec3 -\n" + " (constant float (1.0))\n" + " (expression vec3 abs (var_ref x)))))\n" + " (expression vec3 +\n" + " (constant float (1.5707288))\n" + " (expression vec3 *\n" + " (expression vec3 abs (var_ref x))\n" + " (expression vec3 +\n" + " (constant float (-0.2121144))\n" + " (expression vec3 *\n" + " (constant float (0.0742610))\n" + " (expression vec3 abs (var_ref x))))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 *\n" + " (expression vec4 -\n" + " (expression float *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression vec4 sqrt\n" + " (expression vec4 -\n" + " (constant float (1.0))\n" + " (expression vec4 abs (var_ref x)))))\n" + " (expression vec4 +\n" + " (constant float (1.5707288))\n" + " (expression vec4 *\n" + " (expression vec4 abs (var_ref x))\n" + " (expression vec4 +\n" + " (constant float (-0.2121144))\n" + " (expression vec4 *\n" + " (constant float (0.0742610))\n" + " (expression vec4 abs (var_ref x))))))))))\n" + ")\n" + "\n" + " (function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + "))\n" +}; + +static const char *builtins_110_atan = { + "((function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (call asin ((expression float *\n" + " (var_ref x)\n" + " (expression float rsq\n" + " (expression float +\n" + " (expression float *\n" + " (var_ref x)\n" + " (var_ref x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y_over_x))\n" + " ((return (call asin ((expression vec2 *\n" + " (var_ref y_over_x)\n" + " (expression vec2 rsq\n" + " (expression vec2 +\n" + " (expression vec2 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y_over_x))\n" + " ((return (call asin ((expression vec3 *\n" + " (var_ref y_over_x)\n" + " (expression vec3 rsq\n" + " (expression vec3 +\n" + " (expression vec3 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y_over_x))\n" + " ((return (call asin ((expression vec4 *\n" + " (var_ref y_over_x)\n" + " (expression vec4 rsq\n" + " (expression vec4 +\n" + " (expression vec4 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y)\n" + " (declare (in) float x))\n" + " ((declare () float r)\n" + " (if (expression bool >\n" + " (expression float abs (var_ref x))\n" + " (constant float (.0001)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r) (call atan ((expression float /\n" + " (var_ref y)\n" + " (var_ref x)))))\n" + " (if (expression bool <\n" + " (var_ref x)\n" + " (constant float (0.0)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r)\n" + " (expression float +\n" + " (var_ref r)\n" + " (expression float *\n" + " (expression int sign (var_ref y))\n" + " (constant float (3.1415926))))))\n" + " ()))\n" + " ())\n" + " (return (var_ref r))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 r)\n" + " (if (expression bool >\n" + " (expression vec2 abs (var_ref x))\n" + " (constant float (.0001)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r) (call atan ((expression vec2 /\n" + " (var_ref y)\n" + " (var_ref x)))))\n" + " (if (expression bool <\n" + " (var_ref x)\n" + " (constant float (0.0)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r)\n" + " (expression vec2 +\n" + " (var_ref r)\n" + " (expression vec2 *\n" + " (expression int sign (var_ref y))\n" + " (constant float (3.1415926))))))\n" + " ()))\n" + " ())\n" + " (return (var_ref r))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 r)\n" + " (if (expression bool >\n" + " (expression vec3 abs (var_ref x))\n" + " (constant float (.0001)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r) (call atan ((expression vec3 /\n" + " (var_ref y)\n" + " (var_ref x)))))\n" + " (if (expression bool <\n" + " (var_ref x)\n" + " (constant float (0.0)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r)\n" + " (expression vec3 +\n" + " (var_ref r)\n" + " (expression vec3 *\n" + " (expression int sign (var_ref y))\n" + " (constant float (3.1415926))))))\n" + " ()))\n" + " ())\n" + " (return (var_ref r))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 r)\n" + " (if (expression bool >\n" + " (expression vec4 abs (var_ref x))\n" + " (constant float (.0001)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r) (call atan ((expression vec4 /\n" + " (var_ref y)\n" + " (var_ref x)))))\n" + " (if (expression bool <\n" + " (var_ref x)\n" + " (constant float (0.0)))\n" + " ((assign (constant bool (1))\n" + " (var_ref r)\n" + " (expression vec4 +\n" + " (var_ref r)\n" + " (expression vec4 *\n" + " (expression int sign (var_ref y))\n" + " (constant float (3.1415926))))))\n" + " ()))\n" + " ())\n" + " (return (var_ref r))))\n" + "\n" + "))\n" +}; + +static const char *builtins_110_ceil = { + "((function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float ceil (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 ceil (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 ceil (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 ceil (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_clamp = { + "((function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) vec2 arg2))\n" + " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) vec3 arg2))\n" + " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) vec4 arg2))\n" + " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((declare () vec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((declare () vec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((declare () vec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result)) (expression vec4 max (expression vec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "))\n" +}; + +static const char *builtins_110_cos = { + "((function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ((return (expression float cos (var_ref angle)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ((return (expression vec2 cos (var_ref angle)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ((return (expression vec3 cos (var_ref angle)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ((return (expression vec4 cos (var_ref angle)))))\n" + "))\n" +}; + +static const char *builtins_110_cross = { + "((function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float - (expression float * (swiz y (var_ref arg0)) (swiz z (var_ref arg1)))\n" + " (expression float * (swiz y (var_ref arg1)) (swiz z (var_ref arg0)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float - (expression float * (swiz z (var_ref arg0)) (swiz x (var_ref arg1)))\n" + " (expression float * (swiz z (var_ref arg1)) (swiz x (var_ref arg0)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float - (expression float * (swiz x (var_ref arg0)) (swiz y (var_ref arg1)))\n" + " (expression float * (swiz x (var_ref arg1)) (swiz y (var_ref arg0)))))\n" + " (return (var_ref t))))\n" + "))\n" +}; + +static const char *builtins_110_degrees = { + "((function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float * (var_ref arg0) (constant float (57.295780))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 * (var_ref arg0) (constant float (57.295780))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 * (var_ref arg0) (constant float (57.295780))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 * (var_ref arg0) (constant float (57.295780))))))\n" + "))\n" +}; + +static const char *builtins_110_distance = { + "((function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p0)\n" + " (declare (in) float p1))\n" + " ((declare () float p)\n" + " (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 p0)\n" + " (declare (in) vec2 p1))\n" + " ((declare () vec2 p)\n" + " (assign (constant bool (1)) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 p0)\n" + " (declare (in) vec3 p1))\n" + " ((declare () vec3 p)\n" + " (assign (constant bool (1)) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 p0)\n" + " (declare (in) vec4 p1))\n" + " ((declare () vec4 p)\n" + " (assign (constant bool (1)) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "))\n" +}; + +static const char *builtins_110_dot = { + "((function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "))\n" +}; + +static const char *builtins_110_equal = { + "((function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_exp = { + "((function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float exp (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 exp (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 exp (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 exp (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_exp2 = { + "((function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float exp2 (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 exp2 (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 exp2 (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 exp2 (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_faceforward = { + "((function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float N)\n" + " (declare (in) float I)\n" + " (declare (in) float Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression float neg (var_ref N)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 N)\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec2 neg (var_ref N)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 N)\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec3 neg (var_ref N)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 N)\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec4 neg (var_ref N)))))))\n" + "))\n" +}; + +static const char *builtins_110_floor = { + "((function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float floor (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 floor (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 floor (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 floor (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_fract = { + "((function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float - (var_ref x) (expression float floor (var_ref x))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x)))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x)))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float - (swiz w (var_ref x)) (expression float floor (swiz w (var_ref x)))))\n" + " (return (var_ref t))))\n" + "))\n" + "\n" +}; + +static const char *builtins_110_greaterThan = { + "((function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_greaterThanEqual = { + "((function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_inversesqrt = { + "((function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float rsq (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 rsq (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 rsq (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 rsq (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_length = { + "((function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "))\n" +}; + +static const char *builtins_110_lessThan = { + "((function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_lessThanEqual = { + "((function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_log = { + "((function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float log (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 log (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 log (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 log (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_log2 = { + "((function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float log2 (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 log2 (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 log2 (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 log2 (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_matrixCompMult = { + "((function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 x)\n" + " (declare (in) mat2 y))\n" + " ((declare () mat2 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 x)\n" + " (declare (in) mat3 y))\n" + " ((declare () mat3 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 x)\n" + " (declare (in) mat4 y))\n" + " ((declare () mat4 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "))\n" + "\n" +}; + +static const char *builtins_110_max = { + "((function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression float max (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "))\n" +}; + +static const char *builtins_110_min = { + "((function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression float min (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "))\n" +}; + +static const char *builtins_110_mix = { + "((function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) vec2 arg2))\n" + " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) vec3 arg2))\n" + " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) vec4 arg2))\n" + " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" + "))\n" +}; + +static const char *builtins_110_mod = { + "((function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float % (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((declare () vec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression float % (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression float % (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "))\n" +}; + +static const char *builtins_110_noise_fake = { + "((function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (constant float (0)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (constant float (0)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant float (0)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant float (0)))))\n" + " )\n" + "\n" + " (function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (constant vec2 (0 0)))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (constant vec2 (0 0)))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant vec2 (0 0)))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant vec2 (0 0)))))\n" + " )\n" + "\n" + " (function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " )\n" + "\n" + " (function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + " )\n" + ")\n" +}; + +static const char *builtins_110_normalize = { + "((function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "))\n" +}; + +static const char *builtins_110_not = { + "((function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bvec2 ! (var_ref arg0)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bvec3 ! (var_ref arg0)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bvec4 ! (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_notEqual = { + "((function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_110_pow = { + "((function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float pow (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 pow (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 pow (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 pow (var_ref arg0) (var_ref arg1)))))\n" + "))\n" +}; + +static const char *builtins_110_radians = { + "((function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float * (var_ref arg0) (constant float (0.017453))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 * (var_ref arg0) (constant float (0.017453))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 * (var_ref arg0) (constant float (0.017453))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 * (var_ref arg0) (constant float (0.017453))))))\n" + "))\n" +}; + +static const char *builtins_110_reflect = { + "((function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float i)\n" + " (declare (in) float n))\n" + " ((return (expression float -\n" + " (var_ref i)\n" + " (expression float *\n" + " (constant float (2.0))\n" + " (expression float *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 i)\n" + " (declare (in) vec2 n))\n" + " ((return (expression vec2 -\n" + " (var_ref i)\n" + " (expression vec2 *\n" + " (constant float (2.0))\n" + " (expression vec2 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 i)\n" + " (declare (in) vec3 n))\n" + " ((return (expression vec3 -\n" + " (var_ref i)\n" + " (expression vec3 *\n" + " (constant float (2.0))\n" + " (expression vec3 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 i)\n" + " (declare (in) vec4 n))\n" + " ((return (expression vec4 -\n" + " (var_ref i)\n" + " (expression vec4 *\n" + " (constant float (2.0))\n" + " (expression vec4 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + "))\n" +}; + +static const char *builtins_110_refract = { + "((function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float i)\n" + " (declare (in) float n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant float (0.0))))\n" + " ((return (expression float -\n" + " (expression float * (var_ref eta) (var_ref i))\n" + " (expression float *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 i)\n" + " (declare (in) vec2 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec2 (0.0 0.0))))\n" + " ((return (expression vec2 -\n" + " (expression vec2 * (var_ref eta) (var_ref i))\n" + " (expression vec2 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 i)\n" + " (declare (in) vec3 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec3 (0.0 0.0))))\n" + " ((return (expression vec3 -\n" + " (expression vec3 * (var_ref eta) (var_ref i))\n" + " (expression vec3 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 i)\n" + " (declare (in) vec4 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec4 (0.0 0.0))))\n" + " ((return (expression vec4 -\n" + " (expression vec4 * (var_ref eta) (var_ref i))\n" + " (expression vec4 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + "))\n" +}; + +static const char *builtins_110_sign = { + "((function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float sign (var_ref x)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float sign (swiz w (var_ref x))))\n" + " (return (var_ref t))))\n" + "))\n" + "\n" +}; + +static const char *builtins_110_sin = { + "((function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ((return (expression float sin (var_ref angle)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ((return (expression vec2 sin (var_ref angle)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ((return (expression vec3 sin (var_ref angle)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ((return (expression vec4 sin (var_ref angle)))))\n" + "))\n" +}; + +static const char *builtins_110_smoothstep = { + "((function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) float x))\n" + " ((declare () float t)\n" + "\n" + " (assign (constant bool (1)) (var_ref t)\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (declare () vec2 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (declare () vec3 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (declare () vec4 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz w (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge0)\n" + " (declare (in) vec2 edge1)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (declare () vec2 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge0)\n" + " (declare (in) vec3 edge1)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (declare () vec3 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge0)\n" + " (declare (in) vec4 edge1)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (declare () vec4 retval)\n" + "\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz w (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz w (var_ref x)) (swiz w (var_ref edge0))) (expression float - (swiz w (var_ref edge1)) (swiz w (var_ref edge0))))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" + "\n" + "))\n" + "\n" +}; + +static const char *builtins_110_sqrt = { + "((function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float sqrt (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 sqrt (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 sqrt (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 sqrt (var_ref arg0)))))\n" + "))\n" +}; + +static const char *builtins_110_step = { + "((function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) float x))\n" + " ((return (expression float b2f (expression bool < (var_ref x) (var_ref edge))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(swiz z (var_ref edge)))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz z (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(swiz w (var_ref edge)))))\n" + " (return (var_ref t))))\n" + "))\n" + "\n" +}; + +static const char *builtins_110_tan = { + "((function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ((return (expression float / (expression float sin (var_ref angle)) (expression vec2 cos (var_ref angle))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ((return (expression float / (expression float sin (var_ref angle)) (expression vec3 cos (var_ref angle))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ((return (expression float / (expression float sin (var_ref angle)) (expression vec4 cos (var_ref angle))))))\n" + "))\n" +}; + +static const char *builtins_110_textures = { + "((function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function texture1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + ")\n" + " (function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + "(function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + ")\n" + " (function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + ")\n" + " (function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" + "\n" + ")\n" + " (function shadow1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + ")\n" + " (function shadow1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" + "\n" + ")\n" + " (function shadow2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + ")\n" + " (function shadow2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_110 [] = { + builtins_110_abs, + builtins_110_all, + builtins_110_any, + builtins_110_asin, + builtins_110_atan, + builtins_110_ceil, + builtins_110_clamp, + builtins_110_cos, + builtins_110_cross, + builtins_110_degrees, + builtins_110_distance, + builtins_110_dot, + builtins_110_equal, + builtins_110_exp, + builtins_110_exp2, + builtins_110_faceforward, + builtins_110_floor, + builtins_110_fract, + builtins_110_greaterThan, + builtins_110_greaterThanEqual, + builtins_110_inversesqrt, + builtins_110_length, + builtins_110_lessThan, + builtins_110_lessThanEqual, + builtins_110_log, + builtins_110_log2, + builtins_110_matrixCompMult, + builtins_110_max, + builtins_110_min, + builtins_110_mix, + builtins_110_mod, + builtins_110_noise_fake, + builtins_110_normalize, + builtins_110_not, + builtins_110_notEqual, + builtins_110_pow, + builtins_110_radians, + builtins_110_reflect, + builtins_110_refract, + builtins_110_sign, + builtins_110_sin, + builtins_110_smoothstep, + builtins_110_sqrt, + builtins_110_step, + builtins_110_tan, + builtins_110_textures, +}; + +/* 110_fs builtins */ + +static const char *builtins_110_fs_derivatives = { + "((function dFdx\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ((return (expression float dFdx (var_ref p)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 dFdx (var_ref p)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 dFdx (var_ref p)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 dFdx (var_ref p)))))\n" + " )\n" + "\n" + " (function dFdy\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ((return (expression float dFdy (var_ref p)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 dFdy (var_ref p)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 dFdy (var_ref p)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 dFdy (var_ref p)))))\n" + " )\n" + "\n" + " (function fwidth\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ((return (expression float +\n" + " (expression float abs (expression float dFdx (var_ref p)))\n" + " (expression float abs (expression float dFdy (var_ref p)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 +\n" + " (expression vec2 abs (expression vec2 dFdx (var_ref p)))\n" + " (expression vec2 abs (expression vec2 dFdy (var_ref p)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 +\n" + " (expression vec3 abs (expression vec3 dFdx (var_ref p)))\n" + " (expression vec3 abs (expression vec3 dFdy (var_ref p)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 +\n" + " (expression vec4 abs (expression vec4 dFdx (var_ref p)))\n" + " (expression vec4 abs (expression vec4 dFdy (var_ref p)))))))\n" + "))\n" +}; + +static const char *builtins_110_fs_textures = { + "((function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + ")\n" + " (function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + ")\n" + " (function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + ")\n" + " (function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_110_fs [] = { + builtins_110_fs_derivatives, + builtins_110_fs_textures, +}; + +/* 110_vs builtins */ + +static const char *builtins_110_vs_ftransform = { + "((function ftransform\n" + " (signature vec4\n" + " (parameters)\n" + " ((return (expression vec4 *\n" + " (var_ref gl_ModelViewProjectionMatrix)\n" + " (var_ref gl_Vertex)))))\n" + "))\n" +}; + +static const char *functions_for_110_vs [] = { + builtins_110_vs_ftransform, +}; + +/* 120 builtins */ + +static const char *builtins_120_matrixCompMult = { + "((function matrixCompMult\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) mat2x3 x)\n" + " (declare (in) mat2x3 y))\n" + " ((declare () mat2x3 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) mat3x2 x)\n" + " (declare (in) mat3x2 y))\n" + " ((declare () mat3x2 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) mat2x4 x)\n" + " (declare (in) mat2x4 y))\n" + " ((declare () mat2x4 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) mat4x2 x)\n" + " (declare (in) mat4x2 y))\n" + " ((declare () mat4x2 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) mat3x4 x)\n" + " (declare (in) mat3x4 y))\n" + " ((declare () mat3x4 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) mat4x3 x)\n" + " (declare (in) mat4x3 y))\n" + " ((declare () mat4x3 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "))\n" +}; + +static const char *builtins_120_outerProduct = { + "((function outerProduct\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat2 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat2x3 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat2x4 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat3x2 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat3 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat3x4 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat4x2 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref v) (swiz w (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat4x3 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref v) (swiz w (var_ref u)))) \n" + "(return (var_ref m))))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat4 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) \n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref v) (swiz w (var_ref u)))) \n" + "(return (var_ref m))))\n" + "))\n" + "\n" +}; + +static const char *builtins_120_transpose = { + "((function transpose\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 m))\n" + " ((declare () mat2 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) mat2x3 m))\n" + " ((declare () mat3x2 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) mat2x4 m))\n" + " ((declare () mat4x2 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) mat3x2 m))\n" + " ((declare () mat2x3 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 m))\n" + " ((declare () mat3 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) mat3x4 m))\n" + " ((declare () mat4x3 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) mat4x2 m))\n" + " ((declare () mat2x4 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) mat4x3 m))\n" + " ((declare () mat3x4 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n" + "(return (var_ref t))))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 m))\n" + " ((declare () mat4 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (3))))) \n" + "(return (var_ref t))))\n" + ")\n" + "\n" + ")\n" + "\n" +}; + +static const char *functions_for_120 [] = { + builtins_120_matrixCompMult, + builtins_120_outerProduct, + builtins_120_transpose, +}; + +/* 130 builtins */ + +static const char *builtins_130_clamp = { + "((function clamp\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1)\n" + " (declare (in) ivec2 arg2))\n" + " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1)\n" + " (declare (in) ivec3 arg2))\n" + " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1)\n" + " (declare (in) ivec4 arg2))\n" + " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((declare () ivec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((declare () ivec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((declare () ivec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1)\n" + " (declare (in) uvec2 arg2))\n" + " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1)\n" + " (declare (in) uvec3 arg2))\n" + " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1)\n" + " (declare (in) uvec4 arg2))\n" + " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((declare () uvec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((declare () uvec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((declare () uvec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "))\n" +}; + +static const char *builtins_130_cosh = { + "((function cosh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float * (constant float (0.5))\n" + " (expression float +\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 * (constant vec2 (0.5))\n" + " (expression vec2 +\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 * (constant vec3 (0.5))\n" + " (expression vec3 +\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 * (constant vec4 (0.5))\n" + " (expression vec4 +\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" +}; + +static const char *builtins_130_equal = { + "((function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_greaterThan = { + "((function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_greaterThanEqual = { + "((function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_lessThan = { + "((function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_lessThanEqual = { + "((function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_max = { + "((function max\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression int max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression int max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression int max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression int max (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uint max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression uint max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression uint max (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression uint max (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "))\n" +}; + +static const char *builtins_130_min = { + "((function min\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression int min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression int min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1))\n" + " ((declare () ivec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression int min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression int min (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uint min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec2 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec3 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression uint min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1))\n" + " ((declare () uvec4 result)\n" + " (assign (constant bool (1)) (swiz x (var_ref result))\n" + " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz y (var_ref result))\n" + " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz z (var_ref result))\n" + " (expression uint min (swiz z (var_ref arg0)) (var_ref arg1)))\n" + " (assign (constant bool (1)) (swiz w (var_ref result))\n" + " (expression uint min (swiz w (var_ref arg0)) (var_ref arg1)))\n" + " (return (var_ref result))))\n" + "))\n" +}; + +static const char *builtins_130_notEqual = { + "((function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" +}; + +static const char *builtins_130_sign = { + "((function sign\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int x))\n" + " ((return (expression int / (var_ref x) (expression int abs (var_ref x))))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 x))\n" + " ((declare () ivec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 x))\n" + " ((declare () ivec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 x))\n" + " ((declare () ivec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression int sign (swiz w (var_ref x))))\n" + " (return (var_ref t))))\n" + "))\n" + "\n" +}; + +static const char *builtins_130_sinh = { + "((function sinh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float * (constant float (0.5))\n" + " (expression float -\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 * (constant vec2 (0.5))\n" + " (expression vec2 -\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 * (constant vec3 (0.5))\n" + " (expression vec3 -\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 * (constant vec4 (0.5))\n" + " (expression vec4 -\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" +}; + +static const char *builtins_130_tanh = { + "((function tanh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float /\n" + " (expression float -\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))\n" + " (expression float +\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 /\n" + " (expression vec2 -\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))\n" + " (expression vec2 +\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 /\n" + " (expression vec3 -\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))\n" + " (expression vec3 +\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 /\n" + " (expression vec4 -\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))\n" + " (expression vec4 +\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" +}; + +static const char *builtins_130_texelFetch = { + "((function texelFetch\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + "\n" + "))\n" +}; + +static const char *builtins_130_texture = { + "((function texture\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + "))\n" +}; + +static const char *builtins_130_textureGrad = { + "((function textureGrad\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + ")\n" + ")\n" +}; + +static const char *builtins_130_textureLod = { + "((function textureLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + "))\n" +}; + +static const char *builtins_130_textureProj = { + "((function textureProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + "))\n" +}; + +static const char *builtins_130_textureProjGrad = { + "((function textureLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" +}; + +static const char *builtins_130_textureProjLod = { + "((function textureLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_130 [] = { + builtins_130_clamp, + builtins_130_cosh, + builtins_130_equal, + builtins_130_greaterThan, + builtins_130_greaterThanEqual, + builtins_130_lessThan, + builtins_130_lessThanEqual, + builtins_130_max, + builtins_130_min, + builtins_130_notEqual, + builtins_130_sign, + builtins_130_sinh, + builtins_130_tanh, + builtins_130_texelFetch, + builtins_130_texture, + builtins_130_textureGrad, + builtins_130_textureLod, + builtins_130_textureProj, + builtins_130_textureProjGrad, + builtins_130_textureProjLod, +}; + +/* 130_fs builtins */ + +static const char *builtins_130_fs_texture = { + "((function texture\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + "))\n" +}; + +static const char *builtins_130_fs_textureProj = { + "((function textureProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_130_fs [] = { + builtins_130_fs_texture, + builtins_130_fs_textureProj, +}; + +/* ARB_texture_rectangle builtins */ + +static const char *builtins_ARB_texture_rectangle_textures = { + "((function texture2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function shadow2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_ARB_texture_rectangle [] = { + builtins_ARB_texture_rectangle_textures, +}; + +/* EXT_texture_array builtins */ + +static const char *builtins_EXT_texture_array_textures = { + "((function texture1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function texture1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function texture2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + ")\n" + " (function texture2DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" + "\n" + ")\n" + " (function shadow1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + ")\n" + " (function shadow2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArrayShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) 1 (swiz w (var_ref P)) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_EXT_texture_array [] = { + builtins_EXT_texture_array_textures, +}; + +/* EXT_texture_array_fs builtins */ + +static const char *builtins_EXT_texture_array_fs_textures = { + "((function texture1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function texture2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + ")\n" + " (function shadow1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" +}; + +static const char *functions_for_EXT_texture_array_fs [] = { + builtins_EXT_texture_array_fs_textures, +}; + +void +_mesa_glsl_initialize_functions(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + if (state->language_version >= 110) + read_builtins(state, instructions, + functions_for_110, + sizeof(functions_for_110) / sizeof(const char *)); + + if (state->target == fragment_shader && state->language_version >= 110) + read_builtins(state, instructions, + functions_for_110_fs, + sizeof(functions_for_110_fs) / sizeof(const char *)); + + if (state->target == vertex_shader && state->language_version >= 110) + read_builtins(state, instructions, + functions_for_110_vs, + sizeof(functions_for_110_vs) / sizeof(const char *)); + + if (state->language_version >= 120) + read_builtins(state, instructions, + functions_for_120, + sizeof(functions_for_120) / sizeof(const char *)); + + if (state->language_version >= 130) + read_builtins(state, instructions, + functions_for_130, + sizeof(functions_for_130) / sizeof(const char *)); + + if (state->target == fragment_shader && state->language_version >= 130) + read_builtins(state, instructions, + functions_for_130_fs, + sizeof(functions_for_130_fs) / sizeof(const char *)); + + if (state->ARB_texture_rectangle_enable) + read_builtins(state, instructions, + functions_for_ARB_texture_rectangle, + sizeof(functions_for_ARB_texture_rectangle) / sizeof(const char *)); + + if (state->EXT_texture_array_enable) + read_builtins(state, instructions, + functions_for_EXT_texture_array, + sizeof(functions_for_EXT_texture_array) / sizeof(const char *)); + + if (state->target == fragment_shader && state->EXT_texture_array_enable) + read_builtins(state, instructions, + functions_for_EXT_texture_array_fs, + sizeof(functions_for_EXT_texture_array_fs) / sizeof(const char *)); + +} diff --git a/src/glsl/builtin_types.h b/src/glsl/builtin_types.h new file mode 100644 index 00000000000..48202f56454 --- /dev/null +++ b/src/glsl/builtin_types.h @@ -0,0 +1,268 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef Elements +#define Elements(x) (sizeof(x)/sizeof(*(x))) +#endif + +static const struct glsl_type _error_type = + glsl_type(GLSL_TYPE_ERROR, 0, 0, ""); + +static const struct glsl_type void_type = + glsl_type(GLSL_TYPE_VOID, 0, 0, "void"); + +const glsl_type *const glsl_type::error_type = & _error_type; + +/** \name Core built-in types + * + * These types exist in all versions of GLSL. + */ +/*@{*/ + +static const struct glsl_type builtin_core_types[] = { + glsl_type( GLSL_TYPE_BOOL, 1, 1, "bool"), + glsl_type( GLSL_TYPE_BOOL, 2, 1, "bvec2"), + glsl_type( GLSL_TYPE_BOOL, 3, 1, "bvec3"), + glsl_type( GLSL_TYPE_BOOL, 4, 1, "bvec4"), + glsl_type( GLSL_TYPE_INT, 1, 1, "int"), + glsl_type( GLSL_TYPE_INT, 2, 1, "ivec2"), + glsl_type( GLSL_TYPE_INT, 3, 1, "ivec3"), + glsl_type( GLSL_TYPE_INT, 4, 1, "ivec4"), + glsl_type( GLSL_TYPE_FLOAT, 1, 1, "float"), + glsl_type( GLSL_TYPE_FLOAT, 2, 1, "vec2"), + glsl_type( GLSL_TYPE_FLOAT, 3, 1, "vec3"), + glsl_type( GLSL_TYPE_FLOAT, 4, 1, "vec4"), + glsl_type( GLSL_TYPE_FLOAT, 2, 2, "mat2"), + glsl_type( GLSL_TYPE_FLOAT, 3, 3, "mat3"), + glsl_type( GLSL_TYPE_FLOAT, 4, 4, "mat4"), + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT, "sampler1D"), + glsl_type( GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT, "sampler1DShadow"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT, "sampler2D"), + glsl_type( GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT, "sampler2DShadow"), + glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT, "sampler3D"), + glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT, "samplerCube"), +}; + +const glsl_type *const glsl_type::bool_type = & builtin_core_types[0]; +const glsl_type *const glsl_type::int_type = & builtin_core_types[4]; +const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7]; +const glsl_type *const glsl_type::float_type = & builtin_core_types[8]; +const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9]; +const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10]; +const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11]; +const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12]; +const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13]; +const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14]; +/*@}*/ + +/** \name GLSL structures that have not been deprecated. + */ +/*@{*/ + +static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = { + { glsl_type::float_type, "near" }, + { glsl_type::float_type, "far" }, + { glsl_type::float_type, "diff" }, +}; + +static const struct glsl_type builtin_structure_types[] = { + glsl_type(gl_DepthRangeParameters_fields, + Elements(gl_DepthRangeParameters_fields), + "gl_DepthRangeParameters"), +}; +/*@}*/ + +/** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30 + */ +/*@{*/ + +static const struct glsl_struct_field gl_PointParameters_fields[] = { + { glsl_type::float_type, "size" }, + { glsl_type::float_type, "sizeMin" }, + { glsl_type::float_type, "sizeMax" }, + { glsl_type::float_type, "fadeThresholdSize" }, + { glsl_type::float_type, "distanceConstantAttenuation" }, + { glsl_type::float_type, "distanceLinearAttenuation" }, + { glsl_type::float_type, "distanceQuadraticAttenuation" }, +}; + +static const struct glsl_struct_field gl_MaterialParameters_fields[] = { + { glsl_type::vec4_type, "emission" }, + { glsl_type::vec4_type, "ambient" }, + { glsl_type::vec4_type, "diffuse" }, + { glsl_type::vec4_type, "specular" }, + { glsl_type::float_type, "shininess" }, +}; + +static const struct glsl_struct_field gl_LightSourceParameters_fields[] = { + { glsl_type::vec4_type, "ambient" }, + { glsl_type::vec4_type, "diffuse" }, + { glsl_type::vec4_type, "specular" }, + { glsl_type::vec4_type, "position" }, + { glsl_type::vec4_type, "halfVector" }, + { glsl_type::vec3_type, "spotDirection" }, + { glsl_type::float_type, "spotExponent" }, + { glsl_type::float_type, "spotCutoff" }, + { glsl_type::float_type, "spotCosCutoff" }, + { glsl_type::float_type, "constantAttenuation" }, + { glsl_type::float_type, "linearAttenuation" }, + { glsl_type::float_type, "quadraticAttenuation" }, +}; + +static const struct glsl_struct_field gl_LightModelParameters_fields[] = { + { glsl_type::vec4_type, "ambient" }, +}; + +static const struct glsl_struct_field gl_LightModelProducts_fields[] = { + { glsl_type::vec4_type, "sceneColor" }, +}; + +static const struct glsl_struct_field gl_LightProducts_fields[] = { + { glsl_type::vec4_type, "ambient" }, + { glsl_type::vec4_type, "diffuse" }, + { glsl_type::vec4_type, "specular" }, +}; + +static const struct glsl_struct_field gl_FogParameters_fields[] = { + { glsl_type::vec4_type, "color" }, + { glsl_type::float_type, "density" }, + { glsl_type::float_type, "start" }, + { glsl_type::float_type, "end" }, + { glsl_type::float_type, "scale" }, +}; + +static const struct glsl_type builtin_110_deprecated_structure_types[] = { + glsl_type(gl_PointParameters_fields, + Elements(gl_PointParameters_fields), + "gl_PointParameters"), + glsl_type(gl_MaterialParameters_fields, + Elements(gl_MaterialParameters_fields), + "gl_MaterialParameters"), + glsl_type(gl_LightSourceParameters_fields, + Elements(gl_LightSourceParameters_fields), + "gl_LightSourceParameters"), + glsl_type(gl_LightModelParameters_fields, + Elements(gl_LightModelParameters_fields), + "gl_LightModelParameters"), + glsl_type(gl_LightModelProducts_fields, + Elements(gl_LightModelProducts_fields), + "gl_LightModelProducts"), + glsl_type(gl_LightProducts_fields, + Elements(gl_LightProducts_fields), + "gl_LightProducts"), + glsl_type(gl_FogParameters_fields, + Elements(gl_FogParameters_fields), + "gl_FogParameters"), +}; +/*@}*/ + +/** \name Types added in GLSL 1.20 + */ +/*@{*/ + +static const struct glsl_type builtin_120_types[] = { + glsl_type( GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), + glsl_type( GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), + glsl_type( GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), + glsl_type( GLSL_TYPE_FLOAT, 4, 3, "mat3x4"), + glsl_type( GLSL_TYPE_FLOAT, 2, 4, "mat4x2"), + glsl_type( GLSL_TYPE_FLOAT, 3, 4, "mat4x3"), +}; +const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0]; +const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1]; +const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2]; +const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3]; +const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4]; +const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5]; +/*@}*/ + +/** \name Types added in GLSL 1.30 + */ +/*@{*/ + +static const struct glsl_type builtin_130_types[] = { + glsl_type( GLSL_TYPE_UINT, 1, 1, "uint"), + glsl_type( GLSL_TYPE_UINT, 2, 1, "uvec2"), + glsl_type( GLSL_TYPE_UINT, 3, 1, "uvec3"), + glsl_type( GLSL_TYPE_UINT, 4, 1, "uvec4"), + + /* 1D and 2D texture arrays */ + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"), + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"), + glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"), + glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), + + /* cube shadow samplers */ + glsl_type(GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"), + + /* signed and unsigned integer samplers */ + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"), + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"), + glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"), + glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"), + glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"), + glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"), +}; + +const glsl_type *const glsl_type::uint_type = & builtin_130_types[0]; +const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3]; +/*@}*/ + +/** \name Sampler types added by GL_ARB_texture_rectangle + */ +/*@{*/ + +static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { + glsl_type(GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"), + glsl_type(GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"), +}; +/*@}*/ + +/** \name Sampler types added by GL_EXT_texture_array + */ +/*@{*/ + +static const struct glsl_type builtin_EXT_texture_array_types[] = { + glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), + glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), + glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), + glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), +}; +/*@}*/ + +/** \name Sampler types added by GL_EXT_texture_buffer_object + */ +/*@{*/ + +static const struct glsl_type builtin_EXT_texture_buffer_object_types[] = { + glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"), + glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"), + glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"), +}; +/*@}*/ diff --git a/src/glsl/builtin_variables.h b/src/glsl/builtin_variables.h new file mode 100644 index 00000000000..77f2fe55023 --- /dev/null +++ b/src/glsl/builtin_variables.h @@ -0,0 +1,93 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "main/mtypes.h" + +struct builtin_variable { + enum ir_variable_mode mode; + int slot; + const char *type; + const char *name; +}; + +static const builtin_variable builtin_core_vs_variables[] = { + { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_Position" }, + { ir_var_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" }, +}; + +static const builtin_variable builtin_core_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" }, + { ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" }, + { ir_var_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" }, + { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" }, +}; + +static const builtin_variable builtin_110_deprecated_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_COL0, "vec4", "gl_Color" }, + { ir_var_in, FRAG_ATTRIB_COL1, "vec4", "gl_SecondaryColor" }, + { ir_var_in, FRAG_ATTRIB_FOGC, "float", "gl_FogFragCoord" }, +}; + +static const builtin_variable builtin_110_deprecated_vs_variables[] = { + { ir_var_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" }, + { ir_var_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" }, + { ir_var_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" }, + { ir_var_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" }, + { ir_var_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" }, + { ir_var_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" }, + { ir_var_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" }, + { ir_var_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" }, + { ir_var_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" }, + { ir_var_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" }, + { ir_var_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" }, + { ir_var_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" }, + { ir_var_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" }, + { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_ClipVertex" }, + { ir_var_out, VERT_RESULT_COL0, "vec4", "gl_FrontColor" }, + { ir_var_out, VERT_RESULT_BFC0, "vec4", "gl_BackColor" }, + { ir_var_out, VERT_RESULT_COL1, "vec4", "gl_FrontSecondaryColor" }, + { ir_var_out, VERT_RESULT_BFC1, "vec4", "gl_BackSecondaryColor" }, + { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" }, +}; + +static const builtin_variable builtin_130_vs_variables[] = { + { ir_var_in, -1, "int", "gl_VertexID" }, +}; + +static const builtin_variable builtin_110_deprecated_uniforms[] = { + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" }, + { ir_var_uniform, -1, "mat3", "gl_NormalMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, + { ir_var_uniform, -1, "float", "gl_NormalScale" }, +}; + diff --git a/src/glsl/builtins/110/abs b/src/glsl/builtins/110/abs new file mode 100644 index 00000000000..904845307c4 --- /dev/null +++ b/src/glsl/builtins/110/abs @@ -0,0 +1,21 @@ +((function abs + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float abs (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 abs (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 abs (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 abs (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/110/all b/src/glsl/builtins/110/all new file mode 100644 index 00000000000..2cac0dfb684 --- /dev/null +++ b/src/glsl/builtins/110/all @@ -0,0 +1,16 @@ +((function all + (signature bool + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) +)) diff --git a/src/glsl/builtins/110/any b/src/glsl/builtins/110/any new file mode 100644 index 00000000000..f10e8a7b478 --- /dev/null +++ b/src/glsl/builtins/110/any @@ -0,0 +1,16 @@ +((function any + (signature bool + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) +)) diff --git a/src/glsl/builtins/110/asin b/src/glsl/builtins/110/asin new file mode 100644 index 00000000000..fe93337bffc --- /dev/null +++ b/src/glsl/builtins/110/asin @@ -0,0 +1,112 @@ +((function asin + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * + (expression float - + (expression float * + (constant float (3.1415926)) + (constant float (0.5))) + (expression float sqrt + (expression float - + (constant float (1.0)) + (expression float abs (var_ref x))))) + (expression float + + (constant float (1.5707288)) + (expression float * + (expression float abs (var_ref x)) + (expression float + + (constant float (-0.2121144)) + (expression float * + (constant float (0.0742610)) + (expression float abs (var_ref x)))))))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * + (expression float - + (expression float * + (constant float (3.1415926)) + (constant float (0.5))) + (expression vec2 sqrt + (expression vec2 - + (constant float (1.0)) + (expression vec2 abs (var_ref x))))) + (expression vec2 + + (constant float (1.5707288)) + (expression vec2 * + (expression vec2 abs (var_ref x)) + (expression vec2 + + (constant float (-0.2121144)) + (expression vec2 * + (constant float (0.0742610)) + (expression vec2 abs (var_ref x)))))))))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * + (expression vec3 - + (expression float * + (constant float (3.1415926)) + (constant float (0.5))) + (expression vec3 sqrt + (expression vec3 - + (constant float (1.0)) + (expression vec3 abs (var_ref x))))) + (expression vec3 + + (constant float (1.5707288)) + (expression vec3 * + (expression vec3 abs (var_ref x)) + (expression vec3 + + (constant float (-0.2121144)) + (expression vec3 * + (constant float (0.0742610)) + (expression vec3 abs (var_ref x)))))))))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * + (expression vec4 - + (expression float * + (constant float (3.1415926)) + (constant float (0.5))) + (expression vec4 sqrt + (expression vec4 - + (constant float (1.0)) + (expression vec4 abs (var_ref x))))) + (expression vec4 + + (constant float (1.5707288)) + (expression vec4 * + (expression vec4 abs (var_ref x)) + (expression vec4 + + (constant float (-0.2121144)) + (expression vec4 * + (constant float (0.0742610)) + (expression vec4 abs (var_ref x)))))))))) +) + + (function acos + (signature float + (parameters + (declare (in) float x)) + ((return (expression float - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) +)) diff --git a/src/glsl/builtins/110/atan b/src/glsl/builtins/110/atan new file mode 100644 index 00000000000..e5542350b51 --- /dev/null +++ b/src/glsl/builtins/110/atan @@ -0,0 +1,154 @@ +((function atan + (signature float + (parameters + (declare (in) float x)) + ((return (call asin ((expression float * + (var_ref x) + (expression float rsq + (expression float + + (expression float * + (var_ref x) + (var_ref x)) + (constant float (1.0)))))))))) + + (signature vec2 + (parameters + (declare (in) vec2 y_over_x)) + ((return (call asin ((expression vec2 * + (var_ref y_over_x) + (expression vec2 rsq + (expression vec2 + + (expression vec2 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature vec3 + (parameters + (declare (in) vec3 y_over_x)) + ((return (call asin ((expression vec3 * + (var_ref y_over_x) + (expression vec3 rsq + (expression vec3 + + (expression vec3 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature vec4 + (parameters + (declare (in) vec4 y_over_x)) + ((return (call asin ((expression vec4 * + (var_ref y_over_x) + (expression vec4 rsq + (expression vec4 + + (expression vec4 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature float + (parameters + (declare (in) float y) + (declare (in) float x)) + ((declare () float r) + (if (expression bool > + (expression float abs (var_ref x)) + (constant float (.0001))) + ((assign (constant bool (1)) + (var_ref r) (call atan ((expression float / + (var_ref y) + (var_ref x))))) + (if (expression bool < + (var_ref x) + (constant float (0.0))) + ((assign (constant bool (1)) + (var_ref r) + (expression float + + (var_ref r) + (expression float * + (expression int sign (var_ref y)) + (constant float (3.1415926)))))) + ())) + ()) + (return (var_ref r)))) + + (signature vec2 + (parameters + (declare (in) vec2 y) + (declare (in) vec2 x)) + ((declare () vec2 r) + (if (expression bool > + (expression vec2 abs (var_ref x)) + (constant float (.0001))) + ((assign (constant bool (1)) + (var_ref r) (call atan ((expression vec2 / + (var_ref y) + (var_ref x))))) + (if (expression bool < + (var_ref x) + (constant float (0.0))) + ((assign (constant bool (1)) + (var_ref r) + (expression vec2 + + (var_ref r) + (expression vec2 * + (expression int sign (var_ref y)) + (constant float (3.1415926)))))) + ())) + ()) + (return (var_ref r)))) + + (signature vec3 + (parameters + (declare (in) vec3 y) + (declare (in) vec3 x)) + ((declare () vec3 r) + (if (expression bool > + (expression vec3 abs (var_ref x)) + (constant float (.0001))) + ((assign (constant bool (1)) + (var_ref r) (call atan ((expression vec3 / + (var_ref y) + (var_ref x))))) + (if (expression bool < + (var_ref x) + (constant float (0.0))) + ((assign (constant bool (1)) + (var_ref r) + (expression vec3 + + (var_ref r) + (expression vec3 * + (expression int sign (var_ref y)) + (constant float (3.1415926)))))) + ())) + ()) + (return (var_ref r)))) + + (signature vec4 + (parameters + (declare (in) vec4 y) + (declare (in) vec4 x)) + ((declare () vec4 r) + (if (expression bool > + (expression vec4 abs (var_ref x)) + (constant float (.0001))) + ((assign (constant bool (1)) + (var_ref r) (call atan ((expression vec4 / + (var_ref y) + (var_ref x))))) + (if (expression bool < + (var_ref x) + (constant float (0.0))) + ((assign (constant bool (1)) + (var_ref r) + (expression vec4 + + (var_ref r) + (expression vec4 * + (expression int sign (var_ref y)) + (constant float (3.1415926)))))) + ())) + ()) + (return (var_ref r)))) + +)) diff --git a/src/glsl/builtins/110/ceil b/src/glsl/builtins/110/ceil new file mode 100644 index 00000000000..a26a7750493 --- /dev/null +++ b/src/glsl/builtins/110/ceil @@ -0,0 +1,21 @@ +((function ceil + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float ceil (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 ceil (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 ceil (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 ceil (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/110/clamp b/src/glsl/builtins/110/clamp new file mode 100644 index 00000000000..94c8e5ed168 --- /dev/null +++ b/src/glsl/builtins/110/clamp @@ -0,0 +1,62 @@ +((function clamp + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) vec2 arg2)) + ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) vec3 arg2)) + ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) vec4 arg2)) + ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((declare () vec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((declare () vec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((declare () vec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) (expression vec4 max (expression vec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) +)) diff --git a/src/glsl/builtins/110/cos b/src/glsl/builtins/110/cos new file mode 100644 index 00000000000..88f266eccbe --- /dev/null +++ b/src/glsl/builtins/110/cos @@ -0,0 +1,21 @@ +((function cos + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float cos (var_ref angle))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 cos (var_ref angle))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 cos (var_ref angle))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 cos (var_ref angle))))) +)) diff --git a/src/glsl/builtins/110/cross b/src/glsl/builtins/110/cross new file mode 100644 index 00000000000..deb2f952bfc --- /dev/null +++ b/src/glsl/builtins/110/cross @@ -0,0 +1,17 @@ +((function cross + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float - (expression float * (swiz y (var_ref arg0)) (swiz z (var_ref arg1))) + (expression float * (swiz y (var_ref arg1)) (swiz z (var_ref arg0))))) + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float - (expression float * (swiz z (var_ref arg0)) (swiz x (var_ref arg1))) + (expression float * (swiz z (var_ref arg1)) (swiz x (var_ref arg0))))) + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float - (expression float * (swiz x (var_ref arg0)) (swiz y (var_ref arg1))) + (expression float * (swiz x (var_ref arg1)) (swiz y (var_ref arg0))))) + (return (var_ref t)))) +)) diff --git a/src/glsl/builtins/110/degrees b/src/glsl/builtins/110/degrees new file mode 100644 index 00000000000..dc0d7b9e20d --- /dev/null +++ b/src/glsl/builtins/110/degrees @@ -0,0 +1,21 @@ +((function degrees + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (constant float (57.295780)))))) +)) diff --git a/src/glsl/builtins/110/distance b/src/glsl/builtins/110/distance new file mode 100644 index 00000000000..a2309c484f9 --- /dev/null +++ b/src/glsl/builtins/110/distance @@ -0,0 +1,33 @@ +((function distance + (signature float + (parameters + (declare (in) float p0) + (declare (in) float p1)) + ((declare () float p) + (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1))) + (return (expression float sqrt (expression float dot (var_ref p) (var_ref p)))))) + + (signature float + (parameters + (declare (in) vec2 p0) + (declare (in) vec2 p1)) + ((declare () vec2 p) + (assign (constant bool (1)) (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 + (parameters + (declare (in) vec3 p0) + (declare (in) vec3 p1)) + ((declare () vec3 p) + (assign (constant bool (1)) (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 + (parameters + (declare (in) vec4 p0) + (declare (in) vec4 p1)) + ((declare () vec4 p) + (assign (constant bool (1)) (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/110/dot b/src/glsl/builtins/110/dot new file mode 100644 index 00000000000..a91a6d2c56d --- /dev/null +++ b/src/glsl/builtins/110/dot @@ -0,0 +1,25 @@ +((function dot + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) +)) diff --git a/src/glsl/builtins/110/equal b/src/glsl/builtins/110/equal new file mode 100644 index 00000000000..ae7ddc53bdc --- /dev/null +++ b/src/glsl/builtins/110/equal @@ -0,0 +1,61 @@ +((function equal + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/110/exp b/src/glsl/builtins/110/exp new file mode 100644 index 00000000000..a73bd6a7f84 --- /dev/null +++ b/src/glsl/builtins/110/exp @@ -0,0 +1,21 @@ +((function exp + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float exp (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 exp (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 exp (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 exp (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/110/exp2 b/src/glsl/builtins/110/exp2 new file mode 100644 index 00000000000..a842d3fe65b --- /dev/null +++ b/src/glsl/builtins/110/exp2 @@ -0,0 +1,21 @@ +((function exp2 + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float exp2 (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 exp2 (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 exp2 (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 exp2 (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/110/faceforward b/src/glsl/builtins/110/faceforward new file mode 100644 index 00000000000..d1703972388 --- /dev/null +++ b/src/glsl/builtins/110/faceforward @@ -0,0 +1,37 @@ +((function faceforward + (signature float + (parameters + (declare (in) float N) + (declare (in) float I) + (declare (in) float Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression float neg (var_ref N))))))) + + (signature vec2 + (parameters + (declare (in) vec2 N) + (declare (in) vec2 I) + (declare (in) vec2 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec2 neg (var_ref N))))))) + + (signature vec3 + (parameters + (declare (in) vec3 N) + (declare (in) vec3 I) + (declare (in) vec3 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec3 neg (var_ref N))))))) + + (signature vec4 + (parameters + (declare (in) vec4 N) + (declare (in) vec4 I) + (declare (in) vec4 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec4 neg (var_ref N))))))) +)) diff --git a/src/glsl/builtins/110/floor b/src/glsl/builtins/110/floor new file mode 100644 index 00000000000..8dd8052799b --- /dev/null +++ b/src/glsl/builtins/110/floor @@ -0,0 +1,21 @@ +((function floor + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float floor (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 floor (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 floor (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 floor (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/110/fract b/src/glsl/builtins/110/fract new file mode 100644 index 00000000000..3995bfaf3f9 --- /dev/null +++ b/src/glsl/builtins/110/fract @@ -0,0 +1,34 @@ +((function fract + (signature float + (parameters + (declare (in) float x)) + ((return (expression float - (var_ref x) (expression float floor (var_ref x)))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) + (return (var_ref t)))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x))))) + (return (var_ref t)))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x))))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression float - (swiz w (var_ref x)) (expression float floor (swiz w (var_ref x))))) + (return (var_ref t)))) +)) + diff --git a/src/glsl/builtins/110/greaterThan b/src/glsl/builtins/110/greaterThan new file mode 100644 index 00000000000..ae03030e495 --- /dev/null +++ b/src/glsl/builtins/110/greaterThan @@ -0,0 +1,61 @@ +((function greaterThan + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/110/greaterThanEqual b/src/glsl/builtins/110/greaterThanEqual new file mode 100644 index 00000000000..204d5fd1439 --- /dev/null +++ b/src/glsl/builtins/110/greaterThanEqual @@ -0,0 +1,61 @@ +((function greaterThanEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/110/inversesqrt b/src/glsl/builtins/110/inversesqrt new file mode 100644 index 00000000000..5b66d2b3695 --- /dev/null +++ b/src/glsl/builtins/110/inversesqrt @@ -0,0 +1,21 @@ +((function inversesqrt + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float rsq (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 rsq (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 rsq (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 rsq (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/110/length b/src/glsl/builtins/110/length new file mode 100644 index 00000000000..89ff7f3ef12 --- /dev/null +++ b/src/glsl/builtins/110/length @@ -0,0 +1,21 @@ +((function length + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec2 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec3 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec4 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) +)) diff --git a/src/glsl/builtins/110/lessThan b/src/glsl/builtins/110/lessThan new file mode 100644 index 00000000000..5c4254165c7 --- /dev/null +++ b/src/glsl/builtins/110/lessThan @@ -0,0 +1,61 @@ +((function lessThan + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/110/lessThanEqual b/src/glsl/builtins/110/lessThanEqual new file mode 100644 index 00000000000..ccb955b8a76 --- /dev/null +++ b/src/glsl/builtins/110/lessThanEqual @@ -0,0 +1,61 @@ +((function lessThanEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/110/log b/src/glsl/builtins/110/log new file mode 100644 index 00000000000..d168abb5a73 --- /dev/null +++ b/src/glsl/builtins/110/log @@ -0,0 +1,21 @@ +((function log + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float log (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 log (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 log (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 log (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/110/log2 b/src/glsl/builtins/110/log2 new file mode 100644 index 00000000000..b96c6276f0a --- /dev/null +++ b/src/glsl/builtins/110/log2 @@ -0,0 +1,21 @@ +((function log2 + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float log2 (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 log2 (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 log2 (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 log2 (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/110/matrixCompMult b/src/glsl/builtins/110/matrixCompMult new file mode 100644 index 00000000000..cb5a2cb1f7b --- /dev/null +++ b/src/glsl/builtins/110/matrixCompMult @@ -0,0 +1,32 @@ +((function matrixCompMult + (signature mat2 + (parameters + (declare (in) mat2 x) + (declare (in) mat2 y)) + ((declare () mat2 z) + (assign (constant bool (1)) (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)) (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 + (parameters + (declare (in) mat3 x) + (declare (in) mat3 y)) + ((declare () mat3 z) + (assign (constant bool (1)) (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)) (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)) (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 + (parameters + (declare (in) mat4 x) + (declare (in) mat4 y)) + ((declare () mat4 z) + (assign (constant bool (1)) (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)) (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)) (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)) (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)))) +)) + diff --git a/src/glsl/builtins/110/max b/src/glsl/builtins/110/max new file mode 100644 index 00000000000..c05545f3d93 --- /dev/null +++ b/src/glsl/builtins/110/max @@ -0,0 +1,64 @@ +((function max + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float max (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 max (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 max (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((declare () vec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((declare () vec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float max (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((declare () vec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float max (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression float max (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) +)) diff --git a/src/glsl/builtins/110/min b/src/glsl/builtins/110/min new file mode 100644 index 00000000000..31e79489405 --- /dev/null +++ b/src/glsl/builtins/110/min @@ -0,0 +1,64 @@ +((function min + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float min (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 min (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 min (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((declare () vec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((declare () vec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float min (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((declare () vec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float min (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression float min (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) +)) diff --git a/src/glsl/builtins/110/mix b/src/glsl/builtins/110/mix new file mode 100644 index 00000000000..032f29e5fa8 --- /dev/null +++ b/src/glsl/builtins/110/mix @@ -0,0 +1,50 @@ +((function mix + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) vec2 arg2)) + ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) vec3 arg2)) + ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) vec4 arg2)) + ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) float arg2)) + ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) float arg2)) + ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) float arg2)) + ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) +)) diff --git a/src/glsl/builtins/110/mod b/src/glsl/builtins/110/mod new file mode 100644 index 00000000000..9e08bbc7ef4 --- /dev/null +++ b/src/glsl/builtins/110/mod @@ -0,0 +1,64 @@ +((function mod + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float % (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 % (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 % (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((declare () vec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((declare () vec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float % (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((declare () vec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression float % (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression float % (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) +)) diff --git a/src/glsl/builtins/110/noise_fake b/src/glsl/builtins/110/noise_fake new file mode 100644 index 00000000000..bcfb17b04b8 --- /dev/null +++ b/src/glsl/builtins/110/noise_fake @@ -0,0 +1,76 @@ +((function noise1 + (signature float + (parameters + (declare (in) float x)) + ((return (constant float (0))))) + (signature float + (parameters + (declare (in) vec2 x)) + ((return (constant float (0))))) + (signature float + (parameters + (declare (in) vec3 x)) + ((return (constant float (0))))) + (signature float + (parameters + (declare (in) vec4 x)) + ((return (constant float (0))))) + ) + + (function noise2 + (signature vec2 + (parameters + (declare (in) float x)) + ((return (constant vec2 (0 0))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (constant vec2 (0 0))))) + (signature vec2 + (parameters + (declare (in) vec3 x)) + ((return (constant vec2 (0 0))))) + (signature vec2 + (parameters + (declare (in) vec4 x)) + ((return (constant vec2 (0 0))))) + ) + + (function noise3 + (signature vec3 + (parameters + (declare (in) float x)) + ((return (constant vec3 (0 0 0))))) + (signature vec3 + (parameters + (declare (in) vec2 x)) + ((return (constant vec3 (0 0 0))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (constant vec3 (0 0 0))))) + (signature vec3 + (parameters + (declare (in) vec4 x)) + ((return (constant vec3 (0 0 0))))) + ) + + (function noise4 + (signature vec4 + (parameters + (declare (in) float x)) + ((return (constant vec4 (0 0 0 0))))) + (signature vec4 + (parameters + (declare (in) vec2 x)) + ((return (constant vec4 (0 0 0 0))))) + (signature vec4 + (parameters + (declare (in) vec3 x)) + ((return (constant vec4 (0 0 0 0))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (constant vec4 (0 0 0 0))))) + ) +) diff --git a/src/glsl/builtins/110/normalize b/src/glsl/builtins/110/normalize new file mode 100644 index 00000000000..be88a9830d1 --- /dev/null +++ b/src/glsl/builtins/110/normalize @@ -0,0 +1,21 @@ +((function normalize + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) +)) diff --git a/src/glsl/builtins/110/not b/src/glsl/builtins/110/not new file mode 100644 index 00000000000..b696b06557f --- /dev/null +++ b/src/glsl/builtins/110/not @@ -0,0 +1,16 @@ +((function not + (signature bvec2 + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bvec2 ! (var_ref arg0))))) + + (signature bvec3 + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bvec3 ! (var_ref arg0))))) + + (signature bvec4 + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bvec4 ! (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/110/notEqual b/src/glsl/builtins/110/notEqual new file mode 100644 index 00000000000..c87efa317f7 --- /dev/null +++ b/src/glsl/builtins/110/notEqual @@ -0,0 +1,61 @@ +((function notEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/110/pow b/src/glsl/builtins/110/pow new file mode 100644 index 00000000000..a61bc4418e3 --- /dev/null +++ b/src/glsl/builtins/110/pow @@ -0,0 +1,25 @@ +((function pow + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float pow (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 pow (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 pow (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 pow (var_ref arg0) (var_ref arg1))))) +)) diff --git a/src/glsl/builtins/110/radians b/src/glsl/builtins/110/radians new file mode 100644 index 00000000000..6a0f5d2e219 --- /dev/null +++ b/src/glsl/builtins/110/radians @@ -0,0 +1,21 @@ +((function radians + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (constant float (0.017453)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (constant float (0.017453)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (constant float (0.017453)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (constant float (0.017453)))))) +)) diff --git a/src/glsl/builtins/110/reflect b/src/glsl/builtins/110/reflect new file mode 100644 index 00000000000..8238fdc93fd --- /dev/null +++ b/src/glsl/builtins/110/reflect @@ -0,0 +1,58 @@ +((function reflect + (signature float + (parameters + (declare (in) float i) + (declare (in) float n)) + ((return (expression float - + (var_ref i) + (expression float * + (constant float (2.0)) + (expression float * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec2 + (parameters + (declare (in) vec2 i) + (declare (in) vec2 n)) + ((return (expression vec2 - + (var_ref i) + (expression vec2 * + (constant float (2.0)) + (expression vec2 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec3 + (parameters + (declare (in) vec3 i) + (declare (in) vec3 n)) + ((return (expression vec3 - + (var_ref i) + (expression vec3 * + (constant float (2.0)) + (expression vec3 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec4 + (parameters + (declare (in) vec4 i) + (declare (in) vec4 n)) + ((return (expression vec4 - + (var_ref i) + (expression vec4 * + (constant float (2.0)) + (expression vec4 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + +)) diff --git a/src/glsl/builtins/110/refract b/src/glsl/builtins/110/refract new file mode 100644 index 00000000000..e9b1475294a --- /dev/null +++ b/src/glsl/builtins/110/refract @@ -0,0 +1,102 @@ +((function refract + (signature float + (parameters + (declare (in) float i) + (declare (in) float n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant float (0.0)))) + ((return (expression float - + (expression float * (var_ref eta) (var_ref i)) + (expression float * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec2 + (parameters + (declare (in) vec2 i) + (declare (in) vec2 n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec2 (0.0 0.0)))) + ((return (expression vec2 - + (expression vec2 * (var_ref eta) (var_ref i)) + (expression vec2 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec3 + (parameters + (declare (in) vec3 i) + (declare (in) vec3 n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec3 (0.0 0.0)))) + ((return (expression vec3 - + (expression vec3 * (var_ref eta) (var_ref i)) + (expression vec3 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec4 + (parameters + (declare (in) vec4 i) + (declare (in) vec4 n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec4 (0.0 0.0)))) + ((return (expression vec4 - + (expression vec4 * (var_ref eta) (var_ref i)) + (expression vec4 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + +)) diff --git a/src/glsl/builtins/110/sign b/src/glsl/builtins/110/sign new file mode 100644 index 00000000000..7d540de405b --- /dev/null +++ b/src/glsl/builtins/110/sign @@ -0,0 +1,34 @@ +((function sign + (signature float + (parameters + (declare (in) float x)) + ((return (expression float sign (var_ref x))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) + (return (var_ref t)))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x)))) + (return (var_ref t)))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x)))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression float sign (swiz w (var_ref x)))) + (return (var_ref t)))) +)) + diff --git a/src/glsl/builtins/110/sin b/src/glsl/builtins/110/sin new file mode 100644 index 00000000000..e6009d8ef12 --- /dev/null +++ b/src/glsl/builtins/110/sin @@ -0,0 +1,21 @@ +((function sin + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float sin (var_ref angle))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 sin (var_ref angle))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 sin (var_ref angle))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 sin (var_ref angle))))) +)) diff --git a/src/glsl/builtins/110/smoothstep b/src/glsl/builtins/110/smoothstep new file mode 100644 index 00000000000..b4255ba78f1 --- /dev/null +++ b/src/glsl/builtins/110/smoothstep @@ -0,0 +1,224 @@ +((function smoothstep + (signature float + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) float x)) + ((declare () float t) + + (assign (constant bool (1)) (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))) + (constant float (1.0))) + (constant float (0.0)))) + (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t)))))))) + + (signature vec2 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec2 x)) + ((declare () vec2 t) + (declare () vec2 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + (return (var_ref retval)) + )) + + (signature vec3 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec3 x)) + ((declare () vec3 t) + (declare () vec3 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) + (return (var_ref retval)) + )) + + + (signature vec4 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec4 x)) + ((declare () vec4 t) + (declare () vec4 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) + + (assign (constant bool (1)) (swiz w (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t))))))) + (return (var_ref retval)) + )) + + (signature vec2 + (parameters + (declare (in) vec2 edge0) + (declare (in) vec2 edge1) + (declare (in) vec2 x)) + ((declare () vec2 t) + (declare () vec2 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + (return (var_ref retval)) + )) + + (signature vec3 + (parameters + (declare (in) vec3 edge0) + (declare (in) vec3 edge1) + (declare (in) vec3 x)) + ((declare () vec3 t) + (declare () vec3 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) + (return (var_ref retval)) + )) + + + (signature vec4 + (parameters + (declare (in) vec4 edge0) + (declare (in) vec4 edge1) + (declare (in) vec4 x)) + ((declare () vec4 t) + (declare () vec4 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) + + (assign (constant bool (1)) (swiz w (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz w (var_ref x)) (swiz w (var_ref edge0))) (expression float - (swiz w (var_ref edge1)) (swiz w (var_ref edge0)))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t))))))) + (return (var_ref retval)) + )) + +)) + diff --git a/src/glsl/builtins/110/sqrt b/src/glsl/builtins/110/sqrt new file mode 100644 index 00000000000..0302d164ae5 --- /dev/null +++ b/src/glsl/builtins/110/sqrt @@ -0,0 +1,21 @@ +((function sqrt + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float sqrt (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 sqrt (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 sqrt (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 sqrt (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/110/step b/src/glsl/builtins/110/step new file mode 100644 index 00000000000..1cc2b51f8fb --- /dev/null +++ b/src/glsl/builtins/110/step @@ -0,0 +1,68 @@ +((function step + (signature float + (parameters + (declare (in) float edge) + (declare (in) float x)) + ((return (expression float b2f (expression bool < (var_ref x) (var_ref edge)))))) + + (signature vec2 + (parameters + (declare (in) float edge) + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec3 + (parameters + (declare (in) float edge) + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec4 + (parameters + (declare (in) float edge) + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec2 + (parameters + (declare (in) vec2 edge) + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz 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 + (parameters + (declare (in) vec3 edge) + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (constant bool (1)) (swiz 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 + (parameters + (declare (in) vec4 edge) + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz z (var_ref edge))))) + (assign (constant bool (1)) (swiz 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/110/tan b/src/glsl/builtins/110/tan new file mode 100644 index 00000000000..3e04892a76c --- /dev/null +++ b/src/glsl/builtins/110/tan @@ -0,0 +1,21 @@ +((function tan + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle)))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression float / (expression float sin (var_ref angle)) (expression vec2 cos (var_ref angle)))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression float / (expression float sin (var_ref angle)) (expression vec3 cos (var_ref angle)))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression float / (expression float sin (var_ref angle)) (expression vec4 cos (var_ref angle)))))) +)) diff --git a/src/glsl/builtins/110/textures b/src/glsl/builtins/110/textures new file mode 100644 index 00000000000..c81b7e8ad49 --- /dev/null +++ b/src/glsl/builtins/110/textures @@ -0,0 +1,213 @@ +((function texture1D + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function texture1DLod + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function texture1DProj + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + +) + (function texture1DProjLod + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + +) + (function texture2D + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) +(function texture2DLod + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function texture2DProj + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + +) + (function texture2DProjLod + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + +) + (function texture3D + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function texture3DLod + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function texture3DProj + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + +) + (function texture3DProjLod + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + +) + (function textureCube + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function textureCubeLod + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function shadow1D + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) + +) + (function shadow1DLod + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) + +) + (function shadow1DProj + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) )))) + +) + (function shadow1DProjLod + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) )))) + +) + (function shadow2D + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) + +) + (function shadow2DLod + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) + +) + (function shadow2DProj + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) )))) + +) + (function shadow2DProjLod + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) )))) + +)) diff --git a/src/glsl/builtins/110_fs/derivatives b/src/glsl/builtins/110_fs/derivatives new file mode 100644 index 00000000000..b79852ee1ff --- /dev/null +++ b/src/glsl/builtins/110_fs/derivatives @@ -0,0 +1,73 @@ +((function dFdx + (signature float + (parameters + (declare (in) float p)) + ((return (expression float dFdx (var_ref p))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 dFdx (var_ref p))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 dFdx (var_ref p))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 dFdx (var_ref p))))) + ) + + (function dFdy + (signature float + (parameters + (declare (in) float p)) + ((return (expression float dFdy (var_ref p))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 dFdy (var_ref p))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 dFdy (var_ref p))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 dFdy (var_ref p))))) + ) + + (function fwidth + (signature float + (parameters + (declare (in) float p)) + ((return (expression float + + (expression float abs (expression float dFdx (var_ref p))) + (expression float abs (expression float dFdy (var_ref p))))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 + + (expression vec2 abs (expression vec2 dFdx (var_ref p))) + (expression vec2 abs (expression vec2 dFdy (var_ref p))))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 + + (expression vec3 abs (expression vec3 dFdx (var_ref p))) + (expression vec3 abs (expression vec3 dFdy (var_ref p))))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 + + (expression vec4 abs (expression vec4 dFdx (var_ref p))) + (expression vec4 abs (expression vec4 dFdy (var_ref p))))))) +)) diff --git a/src/glsl/builtins/110_fs/textures b/src/glsl/builtins/110_fs/textures new file mode 100644 index 00000000000..38f3787e9ef --- /dev/null +++ b/src/glsl/builtins/110_fs/textures @@ -0,0 +1,113 @@ +((function texture1D + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function texture1DProj + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + +) + (function texture2D + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function texture2DProj + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + +) + (function texture3D + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function texture3DProj + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + +) + (function textureCube + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function shadow1D + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) + +) + (function shadow1DProj + (signature vec4 + (parameters + (declare (in) sampler1DShadow sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) )))) + +) + (function shadow2D + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) + +) + (function shadow2DProj + (signature vec4 + (parameters + (declare (in) sampler2DShadow sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) )))) + +)) diff --git a/src/glsl/builtins/110_vs/ftransform b/src/glsl/builtins/110_vs/ftransform new file mode 100644 index 00000000000..3a5e8ccecfc --- /dev/null +++ b/src/glsl/builtins/110_vs/ftransform @@ -0,0 +1,7 @@ +((function ftransform + (signature vec4 + (parameters) + ((return (expression vec4 * + (var_ref gl_ModelViewProjectionMatrix) + (var_ref gl_Vertex))))) +)) diff --git a/src/glsl/builtins/120/matrixCompMult b/src/glsl/builtins/120/matrixCompMult new file mode 100644 index 00000000000..69331e26525 --- /dev/null +++ b/src/glsl/builtins/120/matrixCompMult @@ -0,0 +1,61 @@ +((function matrixCompMult + (signature mat2x3 + (parameters + (declare (in) mat2x3 x) + (declare (in) mat2x3 y)) + ((declare () mat2x3 z) + (assign (constant bool (1)) (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)) (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 + (parameters + (declare (in) mat3x2 x) + (declare (in) mat3x2 y)) + ((declare () mat3x2 z) + (assign (constant bool (1)) (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)) (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)) (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 + (parameters + (declare (in) mat2x4 x) + (declare (in) mat2x4 y)) + ((declare () mat2x4 z) + (assign (constant bool (1)) (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)) (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 + (parameters + (declare (in) mat4x2 x) + (declare (in) mat4x2 y)) + ((declare () mat4x2 z) + (assign (constant bool (1)) (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)) (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)) (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)) (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 + (parameters + (declare (in) mat3x4 x) + (declare (in) mat3x4 y)) + ((declare () mat3x4 z) + (assign (constant bool (1)) (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)) (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)) (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 + (parameters + (declare (in) mat4x3 x) + (declare (in) mat4x3 y)) + ((declare () mat4x3 z) + (assign (constant bool (1)) (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)) (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)) (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)) (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/120/outerProduct b/src/glsl/builtins/120/outerProduct new file mode 100644 index 00000000000..b401ba02337 --- /dev/null +++ b/src/glsl/builtins/120/outerProduct @@ -0,0 +1,92 @@ +((function outerProduct + (signature mat2 + (parameters + (declare (in) vec2 u) + (declare (in) vec2 v)) + ((declare () mat2 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) +(return (var_ref m)))) + + (signature mat2x3 + (parameters + (declare (in) vec2 u) + (declare (in) vec3 v)) + ((declare () mat2x3 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) +(return (var_ref m)))) + + (signature mat2x4 + (parameters + (declare (in) vec2 u) + (declare (in) vec4 v)) + ((declare () mat2x4 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) +(return (var_ref m)))) + + (signature mat3x2 + (parameters + (declare (in) vec3 u) + (declare (in) vec2 v)) + ((declare () mat3x2 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) +(return (var_ref m)))) + + (signature mat3 + (parameters + (declare (in) vec3 u) + (declare (in) vec3 v)) + ((declare () mat3 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) +(return (var_ref m)))) + + (signature mat3x4 + (parameters + (declare (in) vec3 u) + (declare (in) vec4 v)) + ((declare () mat3x4 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) +(return (var_ref m)))) + + (signature mat4x2 + (parameters + (declare (in) vec4 u) + (declare (in) vec2 v)) + ((declare () mat4x2 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref v) (swiz w (var_ref u)))) +(return (var_ref m)))) + + (signature mat4x3 + (parameters + (declare (in) vec4 u) + (declare (in) vec3 v)) + ((declare () mat4x3 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref v) (swiz w (var_ref u)))) +(return (var_ref m)))) + + (signature mat4 + (parameters + (declare (in) vec4 u) + (declare (in) vec4 v)) + ((declare () mat4 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref v) (swiz w (var_ref u)))) +(return (var_ref m)))) +)) + diff --git a/src/glsl/builtins/120/transpose b/src/glsl/builtins/120/transpose new file mode 100644 index 00000000000..416a0ee4677 --- /dev/null +++ b/src/glsl/builtins/120/transpose @@ -0,0 +1,139 @@ +((function transpose + (signature mat2 + (parameters + (declare (in) mat2 m)) + ((declare () mat2 t) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz 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/130/clamp b/src/glsl/builtins/130/clamp new file mode 100644 index 00000000000..3aed22c20df --- /dev/null +++ b/src/glsl/builtins/130/clamp @@ -0,0 +1,123 @@ +((function clamp + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1) + (declare (in) ivec2 arg2)) + ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1) + (declare (in) ivec3 arg2)) + ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1) + (declare (in) ivec4 arg2)) + ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((declare () ivec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((declare () ivec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((declare () ivec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1) + (declare (in) uvec2 arg2)) + ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1) + (declare (in) uvec3 arg2)) + ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1) + (declare (in) uvec4 arg2)) + ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((declare () uvec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((declare () uvec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((declare () uvec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) + (return (var_ref result)))) +)) diff --git a/src/glsl/builtins/130/cosh b/src/glsl/builtins/130/cosh new file mode 100644 index 00000000000..45e0ae427d6 --- /dev/null +++ b/src/glsl/builtins/130/cosh @@ -0,0 +1,30 @@ +((function cosh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * (constant float (0.5)) + (expression float + + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * (constant vec2 (0.5)) + (expression vec2 + + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * (constant vec3 (0.5)) + (expression vec3 + + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * (constant vec4 (0.5)) + (expression vec4 + + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/src/glsl/builtins/130/equal b/src/glsl/builtins/130/equal new file mode 100644 index 00000000000..079c3e97fb2 --- /dev/null +++ b/src/glsl/builtins/130/equal @@ -0,0 +1,31 @@ +((function equal + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/130/greaterThan b/src/glsl/builtins/130/greaterThan new file mode 100644 index 00000000000..a9fb7b3a43e --- /dev/null +++ b/src/glsl/builtins/130/greaterThan @@ -0,0 +1,31 @@ +((function greaterThan + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/130/greaterThanEqual b/src/glsl/builtins/130/greaterThanEqual new file mode 100644 index 00000000000..293c93c7cca --- /dev/null +++ b/src/glsl/builtins/130/greaterThanEqual @@ -0,0 +1,31 @@ +((function greaterThanEqual + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/130/lessThan b/src/glsl/builtins/130/lessThan new file mode 100644 index 00000000000..d9f693fd63f --- /dev/null +++ b/src/glsl/builtins/130/lessThan @@ -0,0 +1,31 @@ +((function lessThan + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/130/lessThanEqual b/src/glsl/builtins/130/lessThanEqual new file mode 100644 index 00000000000..494411b869a --- /dev/null +++ b/src/glsl/builtins/130/lessThanEqual @@ -0,0 +1,31 @@ +((function lessThanEqual + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/130/max b/src/glsl/builtins/130/max new file mode 100644 index 00000000000..45a6089c9f2 --- /dev/null +++ b/src/glsl/builtins/130/max @@ -0,0 +1,127 @@ +((function max + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1)) + ((return (expression int max (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression ivec2 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression ivec3 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression ivec4 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1)) + ((declare () ivec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1)) + ((declare () ivec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression int max (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1)) + ((declare () ivec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression int max (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression int max (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1)) + ((return (expression uint max (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression uvec2 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression uvec3 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression uvec4 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1)) + ((declare () uvec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1)) + ((declare () uvec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression uint max (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1)) + ((declare () uvec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression uint max (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression uint max (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) +)) diff --git a/src/glsl/builtins/130/min b/src/glsl/builtins/130/min new file mode 100644 index 00000000000..d98ec1e79da --- /dev/null +++ b/src/glsl/builtins/130/min @@ -0,0 +1,127 @@ +((function min + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1)) + ((return (expression int min (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression ivec2 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression ivec3 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression ivec4 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1)) + ((declare () ivec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1)) + ((declare () ivec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression int min (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1)) + ((declare () ivec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression int min (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression int min (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1)) + ((return (expression uint min (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression uvec2 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression uvec3 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression uvec4 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1)) + ((declare () uvec2 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1)) + ((declare () uvec3 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression uint min (swiz z (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1)) + ((declare () uvec4 result) + (assign (constant bool (1)) (swiz x (var_ref result)) + (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz y (var_ref result)) + (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz z (var_ref result)) + (expression uint min (swiz z (var_ref arg0)) (var_ref arg1))) + (assign (constant bool (1)) (swiz w (var_ref result)) + (expression uint min (swiz w (var_ref arg0)) (var_ref arg1))) + (return (var_ref result)))) +)) diff --git a/src/glsl/builtins/130/notEqual b/src/glsl/builtins/130/notEqual new file mode 100644 index 00000000000..81e6376bd9c --- /dev/null +++ b/src/glsl/builtins/130/notEqual @@ -0,0 +1,31 @@ +((function notEqual + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/130/sign b/src/glsl/builtins/130/sign new file mode 100644 index 00000000000..0bdc0e09d25 --- /dev/null +++ b/src/glsl/builtins/130/sign @@ -0,0 +1,34 @@ +((function sign + (signature int + (parameters + (declare (in) int x)) + ((return (expression int / (var_ref x) (expression int abs (var_ref x)))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 x)) + ((declare () ivec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) + (return (var_ref t)))) + + (signature ivec3 + (parameters + (declare (in) ivec3 x)) + ((declare () ivec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x)))) + (return (var_ref t)))) + + (signature ivec4 + (parameters + (declare (in) ivec4 x)) + ((declare () ivec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x)))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression int sign (swiz w (var_ref x)))) + (return (var_ref t)))) +)) + diff --git a/src/glsl/builtins/130/sinh b/src/glsl/builtins/130/sinh new file mode 100644 index 00000000000..7ad4f58e204 --- /dev/null +++ b/src/glsl/builtins/130/sinh @@ -0,0 +1,30 @@ +((function sinh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * (constant float (0.5)) + (expression float - + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * (constant vec2 (0.5)) + (expression vec2 - + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * (constant vec3 (0.5)) + (expression vec3 - + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * (constant vec4 (0.5)) + (expression vec4 - + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/src/glsl/builtins/130/tanh b/src/glsl/builtins/130/tanh new file mode 100644 index 00000000000..3b7271bf779 --- /dev/null +++ b/src/glsl/builtins/130/tanh @@ -0,0 +1,42 @@ +((function tanh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float / + (expression float - + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))) + (expression float + + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 / + (expression vec2 - + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))) + (expression vec2 + + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 / + (expression vec3 - + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))) + (expression vec3 + + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 / + (expression vec4 - + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))) + (expression vec4 + + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/src/glsl/builtins/130/texelFetch b/src/glsl/builtins/130/texelFetch new file mode 100644 index 00000000000..d51ce65a897 --- /dev/null +++ b/src/glsl/builtins/130/texelFetch @@ -0,0 +1,107 @@ +((function texelFetch + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) int P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) int P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) int P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1DArray sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1DArray sampler) + (declare (in) ivec2 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2DArray sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2DArray sampler) + (declare (in) ivec3 P) + (declare (in) int lod) ) + ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) + +)) diff --git a/src/glsl/builtins/130/texture b/src/glsl/builtins/130/texture new file mode 100644 index 00000000000..b170b583094 --- /dev/null +++ b/src/glsl/builtins/130/texture @@ -0,0 +1,110 @@ +((function texture + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) float P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) float P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isamplerCube sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usamplerCube sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isampler1DArray sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usampler1DArray sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature ivec4 + (parameters + (declare (in) isampler2DArray sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + + (signature uvec4 + (parameters + (declare (in) usampler2DArray sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +)) diff --git a/src/glsl/builtins/130/textureGrad b/src/glsl/builtins/130/textureGrad new file mode 100644 index 00000000000..0ef428c224a --- /dev/null +++ b/src/glsl/builtins/130/textureGrad @@ -0,0 +1,147 @@ +((function textureGrad + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) float P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) float P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isamplerCube sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usamplerCube sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) + +) +) diff --git a/src/glsl/builtins/130/textureLod b/src/glsl/builtins/130/textureLod new file mode 100644 index 00000000000..7d7059d848c --- /dev/null +++ b/src/glsl/builtins/130/textureLod @@ -0,0 +1,128 @@ +((function textureLod + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) float P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) float P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isamplerCube sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usamplerCube sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +)) diff --git a/src/glsl/builtins/130/textureProj b/src/glsl/builtins/130/textureProj new file mode 100644 index 00000000000..40ea1c2af68 --- /dev/null +++ b/src/glsl/builtins/130/textureProj @@ -0,0 +1,92 @@ +((function textureProj + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) + +)) diff --git a/src/glsl/builtins/130/textureProjGrad b/src/glsl/builtins/130/textureProjGrad new file mode 100644 index 00000000000..a0142c5e683 --- /dev/null +++ b/src/glsl/builtins/130/textureProjGrad @@ -0,0 +1,122 @@ +((function textureLod + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec2 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec2 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec4 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec4 P) + (declare (in) float dPdx) + (declare (in) float dPdy) ) + ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec3 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec3 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec4 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec4 P) + (declare (in) vec2 dPdx) + (declare (in) vec2 dPdy) ) + ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec4 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec4 P) + (declare (in) vec3 dPdx) + (declare (in) vec3 dPdy) ) + ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) + +)) diff --git a/src/glsl/builtins/130/textureProjLod b/src/glsl/builtins/130/textureProjLod new file mode 100644 index 00000000000..9f4ce1b493d --- /dev/null +++ b/src/glsl/builtins/130/textureProjLod @@ -0,0 +1,107 @@ +((function textureLod + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec4 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) + +)) diff --git a/src/glsl/builtins/130_fs/texture b/src/glsl/builtins/130_fs/texture new file mode 100644 index 00000000000..0de981397f0 --- /dev/null +++ b/src/glsl/builtins/130_fs/texture @@ -0,0 +1,128 @@ +((function texture + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) float P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) float P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) float P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) samplerCube sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isamplerCube sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usamplerCube sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +)) diff --git a/src/glsl/builtins/130_fs/textureProj b/src/glsl/builtins/130_fs/textureProj new file mode 100644 index 00000000000..b1d8f0a2f33 --- /dev/null +++ b/src/glsl/builtins/130_fs/textureProj @@ -0,0 +1,107 @@ +((function textureProj + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler1D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler1D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler1D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler2D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler2D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler2D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature vec4 + (parameters + (declare (in) sampler3D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature ivec4 + (parameters + (declare (in) isampler3D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + + (signature uvec4 + (parameters + (declare (in) usampler3D sampler) + (declare (in) vec4 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) + +)) diff --git a/src/glsl/builtins/ARB_texture_rectangle/textures b/src/glsl/builtins/ARB_texture_rectangle/textures new file mode 100644 index 00000000000..161d8c4a541 --- /dev/null +++ b/src/glsl/builtins/ARB_texture_rectangle/textures @@ -0,0 +1,16 @@ +((function texture2DRect + (signature vec4 + (parameters + (declare (in) sampler2DRect sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function shadow2DRect + (signature vec4 + (parameters + (declare (in) sampler2DRectShadow sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) + +)) diff --git a/src/glsl/builtins/EXT_texture_array/textures b/src/glsl/builtins/EXT_texture_array/textures new file mode 100644 index 00000000000..8a91f901401 --- /dev/null +++ b/src/glsl/builtins/EXT_texture_array/textures @@ -0,0 +1,59 @@ +((function texture1DArray + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function texture1DArrayLod + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function texture2DArray + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) + +) + (function texture2DArrayLod + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) + +) + (function shadow1DArray + (signature vec4 + (parameters + (declare (in) sampler1DArrayShadow sampler) + (declare (in) vec3 P) ) + ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) + +) + (function shadow1DArrayLod + (signature vec4 + (parameters + (declare (in) sampler1DArrayShadow sampler) + (declare (in) vec3 P) + (declare (in) float lod) ) + ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) + +) + (function shadow2DArray + (signature vec4 + (parameters + (declare (in) sampler2DArrayShadow sampler) + (declare (in) vec4 P) ) + ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) 1 (swiz w (var_ref P)) )))) + +)) diff --git a/src/glsl/builtins/EXT_texture_array_fs/textures b/src/glsl/builtins/EXT_texture_array_fs/textures new file mode 100644 index 00000000000..74e184387ac --- /dev/null +++ b/src/glsl/builtins/EXT_texture_array_fs/textures @@ -0,0 +1,27 @@ +((function texture1DArray + (signature vec4 + (parameters + (declare (in) sampler1DArray sampler) + (declare (in) vec2 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function texture2DArray + (signature vec4 + (parameters + (declare (in) sampler2DArray sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) + +) + (function shadow1DArray + (signature vec4 + (parameters + (declare (in) sampler1DArrayShadow sampler) + (declare (in) vec3 P) + (declare (in) float bias) ) + ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) + +)) diff --git a/src/glsl/builtins/tools/generate_builtins.pl b/src/glsl/builtins/tools/generate_builtins.pl new file mode 100755 index 00000000000..8b640ab8ff9 --- /dev/null +++ b/src/glsl/builtins/tools/generate_builtins.pl @@ -0,0 +1,123 @@ +#!/usr/bin/env perl + +sub process_version { + my ($version) = @_; + my @vars; + print "/* $version builtins */\n\n"; + + my @files = ; + foreach $file (@files) { + push(@vars, process_file($file)); + } + + print "static const char *functions_for_$version [] = {\n"; + foreach $var (@vars) { + print " $var,\n"; + } + print "};\n\n" +} + +sub process_file { + my ($file) = @_; + + # Change from builtins/110/foo to builtins_110_foo + my $var = $file; $var =~ s!/!_!g; + + print "static const char *$var = {\n"; + open SRC, "<", "$file" or die $!; + while () { + s/\\/\\\\/g; + s/\"/\\\"/g; + s/\n/\\n/g; + print " \"$_\"\n"; + } + print "};\n\n"; + close SRC or die $!; + return $var; +} + +print << 'EOF'; +/* DO NOT MODIFY - automatically generated by generate_builtins.pl */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "glsl_parser_extras.h" +#include "ir_reader.h" + +void +read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, + const char **functions, unsigned count) +{ + if (st->error) + return; + + for (unsigned i = 0; i < count; i++) { + _mesa_glsl_read_ir(st, instructions, functions[i]); + + if (st->error) { + printf("error reading builtin: %.35s ...\n", functions[i]); + return; + } + } +} + +EOF + +@versions = sort(); +foreach $version (@versions) { + $version =~ s!builtins/!!g; + process_version($version); +} + +print << 'EOF'; +void +_mesa_glsl_initialize_functions(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ +EOF + +foreach $version_xs (@versions) { + $check = ""; + if ($version_xs =~ /_vs/) { + $check = "state->target == vertex_shader && "; + } elsif ($version_xs =~ /_fs/) { + $check = "state->target == fragment_shader && "; + } + $version = $version_xs; + $version =~ s/_[vf]s//g; + + if ($version =~ /^[1-9][0-9][0-9]/) { + $check = "${check}state->language_version >= $version"; + } else { + # Not a version...an extension name + $check = "${check}state->${version}_enable"; + } + print " if ($check)\n"; + print " read_builtins(state, instructions,\n"; + print " functions_for_$version_xs,\n"; + print " sizeof(functions_for_$version_xs) / "; + print "sizeof(const char *));\n\n" +} + +print "}\n"; diff --git a/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py b/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py new file mode 100755 index 00000000000..391ad110d37 --- /dev/null +++ b/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +def gen_matrix(x, y = 0): + if y == 0: + y = x + type = "mat" + str(x) + if x != y: + type = type + "x" + str(y) + print type + " matrixCompMult(" + type + " x, " + type + " y)\n{" + print " " + type + " z;" + + for i in range(x): + print " z[" + str(i) + "] = x[" + str(i) + "] * y[" + str(i) + "];" + print " return z;\n}" + +print "#version 120" +# 1.10 +gen_matrix(2) +gen_matrix(3) +gen_matrix(4) + +# 1.20 +gen_matrix(2,3) # mat2x3 means 2 columns, 3 rows +gen_matrix(3,2) +gen_matrix(2,4) +gen_matrix(4,2) +gen_matrix(3,4) +gen_matrix(4,3) diff --git a/src/glsl/builtins/tools/generate_outerProductGLSL.py b/src/glsl/builtins/tools/generate_outerProductGLSL.py new file mode 100755 index 00000000000..48fb72197c3 --- /dev/null +++ b/src/glsl/builtins/tools/generate_outerProductGLSL.py @@ -0,0 +1,23 @@ +#!/usr/bin/python + +def gen(x, y): + type = "mat" + str(x) + if x != y: + type = type + "x" + str(y) + print type + " outerProduct(vec" + str(x) + " u, vec" + str(y) + " v)\n{" + print " " + type + " m;" + + for i in range(x): + print " m[" + str(i) + "] = v * u[" + str(i) + "];" + print " return m;\n}" + +print "#version 120" +gen(2,2) +gen(2,3) # mat2x3 means 2 columns, 3 rows +gen(2,4) +gen(3,2) +gen(3,3) +gen(3,4) +gen(4,2) +gen(4,3) +gen(4,4) diff --git a/src/glsl/builtins/tools/generate_transposeGLSL.py b/src/glsl/builtins/tools/generate_transposeGLSL.py new file mode 100755 index 00000000000..8f669ce9839 --- /dev/null +++ b/src/glsl/builtins/tools/generate_transposeGLSL.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +def gen(x, y): + origtype = "mat" + str(x) + trantype = "mat" + str(y) + if x != y: + origtype = origtype + "x" + str(y) + trantype = trantype + "x" + str(x) + print trantype + " transpose(" + origtype + " m)\n{" + print " " + trantype + " t;" + + # The obvious implementation of transpose + for i in range(x): + for j in range(y): + print " t[" + str(j) + "][" + str(i) + "] =", + print "m[" + str(i) + "][" + str(j) + "];" + print " return t;\n}" + +print "#version 120" +gen(2,2) +gen(2,3) # mat2x3 means 2 columns, 3 rows +gen(2,4) +gen(3,2) +gen(3,3) +gen(3,4) +gen(4,2) +gen(4,3) +gen(4,4) diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py new file mode 100755 index 00000000000..23d53149161 --- /dev/null +++ b/src/glsl/builtins/tools/texture_builtins.py @@ -0,0 +1,298 @@ +#!/usr/bin/python + +from os import path +import sys + +def vec_type(g, size): + if size == 1: + if g == "i": + return "int" + elif g == "u": + return "uint" + return "float" + return g + "vec" + str(size) + +# Get the base dimension - i.e. sampler3D gives 3 +# Array samplers also get +1 here since the layer is really an extra coordinate +def get_coord_dim(sampler_type): + if sampler_type[0].isdigit(): + coord_dim = int(sampler_type[0]) + elif sampler_type.startswith("Cube"): + coord_dim = 3 + else: + assert False ("coord_dim: invalid sampler_type: " + sampler_type) + + if sampler_type.find("Array") != -1: + coord_dim += 1 + return coord_dim + +# Get the number of extra vector components (i.e. shadow comparitor) +def get_extra_dim(sampler_type, use_proj, unused_fields): + extra_dim = unused_fields + if sampler_type.find("Shadow") != -1: + extra_dim += 1 + if use_proj: + extra_dim += 1 + return extra_dim + +def generate_sigs(g, tex_inst, sampler_type, use_proj = False, unused_fields = 0): + coord_dim = get_coord_dim(sampler_type) + extra_dim = get_extra_dim(sampler_type, use_proj, unused_fields) + + # Print parameters + print " (signature " + g + "vec4" + print " (parameters" + print " (declare (in) " + g + "sampler" + sampler_type + " sampler)" + print " (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)", + if tex_inst == "txb": + print "\n (declare (in) float bias)", + elif tex_inst == "txl": + print "\n (declare (in) float lod)", + elif tex_inst == "txf": + print "\n (declare (in) int lod)", + elif tex_inst == "txd": + grad_type = vec_type("", coord_dim) + print "\n (declare (in) " + grad_type + " dPdx)", + print "\n (declare (in) " + grad_type + " dPdy)", + + print ")\n ((return (" + tex_inst + " (var_ref sampler)", + + # Coordinate + if extra_dim > 0: + print "(swiz " + "xyzw"[:coord_dim] + " (var_ref P))", + else: + print "(var_ref P)", + + # Offset + print "(0 0 0)", + + if tex_inst != "txf": + # Projective divisor + if use_proj: + print "(swiz " + "xyzw"[coord_dim + extra_dim-1] + " (var_ref P))", + else: + print "1", + + # Shadow comparitor + if sampler_type == "2DArrayShadow": # a special case: + print "(swiz w (var_ref P))", # ...array layer is z; shadow is w + elif sampler_type.endswith("Shadow"): + print "(swiz z (var_ref P))", + else: + print "()", + + # Bias/explicit LOD/gradient: + if tex_inst == "txb": + print "(var_ref bias)", + elif tex_inst == "txl" or tex_inst == "txf": + print "(var_ref lod)", + elif tex_inst == "txd": + print "((var_ref dPdx) (var_ref dPdy))", + print "))))\n" + +def generate_fiu_sigs(tex_inst, sampler_type, use_proj = False, unused_fields = 0): + generate_sigs("", tex_inst, sampler_type, use_proj, unused_fields) + generate_sigs("i", tex_inst, sampler_type, use_proj, unused_fields) + generate_sigs("u", tex_inst, sampler_type, use_proj, unused_fields) + +builtins_dir = path.join(path.dirname(path.abspath(__file__)), "..") + +with open(path.join(builtins_dir, "130", "texture"), 'w') as sys.stdout: + print "((function texture" + generate_fiu_sigs("tex", "1D") + generate_fiu_sigs("tex", "2D") + generate_fiu_sigs("tex", "3D") + generate_fiu_sigs("tex", "Cube") + generate_fiu_sigs("tex", "1DArray") + generate_fiu_sigs("tex", "2DArray") + print "))" + +# txb variants are only allowed within a fragment shader (GLSL 1.30 p. 86) +with open(path.join(builtins_dir, "130_fs", "texture"), 'w') as sys.stdout: + print "((function texture" + generate_fiu_sigs("txb", "1D") + generate_fiu_sigs("txb", "2D") + generate_fiu_sigs("txb", "3D") + generate_fiu_sigs("txb", "Cube") + generate_fiu_sigs("txb", "1DArray") + generate_fiu_sigs("txb", "2DArray") + print "))" + +with open(path.join(builtins_dir, "130", "textureProj"), 'w') as sys.stdout: + print "((function textureProj" + generate_fiu_sigs("tex", "1D", True) + generate_fiu_sigs("tex", "1D", True, 2) + generate_fiu_sigs("tex", "2D", True) + generate_fiu_sigs("tex", "2D", True, 1) + generate_fiu_sigs("tex", "3D", True) + print "))" + +with open(path.join(builtins_dir, "130_fs", "textureProj"), 'w') as sys.stdout: + print "((function textureProj" + generate_fiu_sigs("txb", "1D", True) + generate_fiu_sigs("txb", "1D", True, 2) + generate_fiu_sigs("txb", "2D", True) + generate_fiu_sigs("txb", "2D", True, 1) + generate_fiu_sigs("txb", "3D", True) + print "))" + +with open(path.join(builtins_dir, "130", "textureLod"), 'w') as sys.stdout: + print "((function textureLod" + generate_fiu_sigs("txl", "1D") + generate_fiu_sigs("txl", "2D") + generate_fiu_sigs("txl", "3D") + generate_fiu_sigs("txl", "Cube") + generate_fiu_sigs("txl", "1DArray") + generate_fiu_sigs("txl", "2DArray") + print "))" + +with open(path.join(builtins_dir, "130", "texelFetch"), 'w') as sys.stdout: + print "((function texelFetch" + generate_fiu_sigs("txf", "1D") + generate_fiu_sigs("txf", "2D") + generate_fiu_sigs("txf", "3D") + generate_fiu_sigs("txf", "1DArray") + generate_fiu_sigs("txf", "2DArray") + print "))" + +with open(path.join(builtins_dir, "130", "textureProjLod"), 'w') as sys.stdout: + print "((function textureLod" + generate_fiu_sigs("txl", "1D", True) + generate_fiu_sigs("txl", "1D", True, 2) + generate_fiu_sigs("txl", "2D", True) + generate_fiu_sigs("txl", "2D", True, 1) + generate_fiu_sigs("txl", "3D", True) + print "))" + +with open(path.join(builtins_dir, "130", "textureGrad"), 'w') as sys.stdout: + print "((function textureGrad" + generate_fiu_sigs("txd", "1D") + generate_fiu_sigs("txd", "2D") + generate_fiu_sigs("txd", "3D") + generate_fiu_sigs("txd", "Cube") + generate_fiu_sigs("txd", "1DArray") + generate_fiu_sigs("txd", "2DArray") + print ")\n)" + +with open(path.join(builtins_dir, "130", "textureProjGrad"), 'w') as sys.stdout: + print "((function textureLod" + generate_fiu_sigs("txd", "1D", True) + generate_fiu_sigs("txd", "1D", True, 2) + generate_fiu_sigs("txd", "2D", True) + generate_fiu_sigs("txd", "2D", True, 1) + generate_fiu_sigs("txd", "3D", True) + print "))" + +# ARB_texture_rectangle extension +with open(path.join(builtins_dir, "ARB_texture_rectangle", "textures"), 'w') as sys.stdout: + print "((function texture2DRect" + generate_sigs("", "tex", "2DRect") + print ")\n (function shadow2DRect" + generate_sigs("", "tex", "2DRectShadow") + print "))" + +# EXT_texture_array extension +with open(path.join(builtins_dir, "EXT_texture_array", "textures"), 'w') as sys.stdout: + print "((function texture1DArray" + generate_sigs("", "tex", "1DArray") + print ")\n (function texture1DArrayLod" + generate_sigs("", "txl", "1DArray") + print ")\n (function texture2DArray" + generate_sigs("", "tex", "2DArray") + print ")\n (function texture2DArrayLod" + generate_sigs("", "txl", "2DArray") + print ")\n (function shadow1DArray" + generate_sigs("", "tex", "1DArrayShadow") + print ")\n (function shadow1DArrayLod" + generate_sigs("", "txl", "1DArrayShadow") + print ")\n (function shadow2DArray" + generate_sigs("", "tex", "2DArrayShadow") + print "))" + +with open(path.join(builtins_dir, "EXT_texture_array_fs", "textures"), 'w') as sys.stdout: + print "((function texture1DArray" + generate_sigs("", "txb", "1DArray") # MOVE TO _fs + print ")\n (function texture2DArray" + generate_sigs("", "txb", "2DArray") # MOVE TO _fs + print ")\n (function shadow1DArray" + generate_sigs("", "txb", "1DArrayShadow") + print "))" + +# Deprecated (110/120 style) functions with silly names: +with open(path.join(builtins_dir, "110", "textures"), 'w') as sys.stdout: + print "((function texture1D" + generate_sigs("", "tex", "1D") + print ")\n (function texture1DLod" + generate_sigs("", "txl", "1D") + print ")\n (function texture1DProj" + generate_sigs("", "tex", "1D", True) + generate_sigs("", "tex", "1D", True, 2) + print ")\n (function texture1DProjLod" + generate_sigs("", "txl", "1D", True) + generate_sigs("", "txl", "1D", True, 2) + print ")\n (function texture2D" + generate_sigs("", "tex", "2D") + print ")\n(function texture2DLod" + generate_sigs("", "txl", "2D") + print ")\n (function texture2DProj" + generate_sigs("", "tex", "2D", True) + generate_sigs("", "tex", "2D", True, 1) + print ")\n (function texture2DProjLod" + generate_sigs("", "txl", "2D", True) + generate_sigs("", "txl", "2D", True, 1) + print ")\n (function texture3D" + generate_sigs("", "tex", "3D") + print ")\n (function texture3DLod" + generate_sigs("", "txl", "3D") + print ")\n (function texture3DProj" + generate_sigs("", "tex", "3D", True) + print ")\n (function texture3DProjLod" + generate_sigs("", "txl", "3D", True) + print ")\n (function textureCube" + generate_sigs("", "tex", "Cube") + print ")\n (function textureCubeLod" + generate_sigs("", "txl", "Cube") + print ")\n (function shadow1D" + generate_sigs("", "tex", "1DShadow", False, 1) + print ")\n (function shadow1DLod" + generate_sigs("", "txl", "1DShadow", False, 1) + print ")\n (function shadow1DProj" + generate_sigs("", "tex", "1DShadow", True, 1) + print ")\n (function shadow1DProjLod" + generate_sigs("", "txl", "1DShadow", True, 1) + print ")\n (function shadow2D" + generate_sigs("", "tex", "2DShadow") + print ")\n (function shadow2DLod" + generate_sigs("", "txl", "2DShadow") + print ")\n (function shadow2DProj" + generate_sigs("", "tex", "2DShadow", True) + print ")\n (function shadow2DProjLod" + generate_sigs("", "txl", "2DShadow", True) + print "))" + +with open(path.join(builtins_dir, "110_fs", "textures"), 'w') as sys.stdout: + print "((function texture1D" + generate_sigs("", "txb", "1D") + print ")\n (function texture1DProj" + generate_sigs("", "txb", "1D", True) + generate_sigs("", "txb", "1D", True, 2) + print ")\n (function texture2D" + generate_sigs("", "txb", "2D") + print ")\n (function texture2DProj" + generate_sigs("", "txb", "2D", True) + generate_sigs("", "txb", "2D", True, 1) + print ")\n (function texture3D" + generate_sigs("", "txb", "3D") + print ")\n (function texture3DProj" + generate_sigs("", "txb", "3D", True) + print ")\n (function textureCube" + generate_sigs("", "txb", "Cube") + print ")\n (function shadow1D" + generate_sigs("", "txb", "1DShadow", False, 1) + print ")\n (function shadow1DProj" + generate_sigs("", "txb", "1DShadow", True, 1) + print ")\n (function shadow2D" + generate_sigs("", "txb", "2DShadow") + print ")\n (function shadow2DProj" + generate_sigs("", "txb", "2DShadow", True) + print "))" diff --git a/src/glsl/configure.ac b/src/glsl/configure.ac new file mode 100644 index 00000000000..73ce67de3d1 --- /dev/null +++ b/src/glsl/configure.ac @@ -0,0 +1,69 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT(glsl, XXXXX, idr@freedesktop.org, glsl) +AC_CONFIG_SRCDIR([Makefile.am]) +AM_CONFIG_HEADER([config.h]) +AC_CONFIG_FILES([glcpp/Makefile]) + +AM_INIT_AUTOMAKE +LT_INIT + +AM_MAINTAINER_MODE + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC +AC_PROG_MAKE_SET +AC_PROG_YACC +AC_PROG_LEX + +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +# Checks for libraries. + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. +AC_HEADER_STDC + +AH_TOP([#ifndef GLSL_CONFIG_H +#define GLSL_CONFIG_H]) +AH_BOTTOM([#endif /* GLSL_CONFIG_H */]) + +PKG_CHECK_MODULES([talloc], [talloc >= 2.0]) + +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], + [use debug compiler flags and macros @<:@default=disabled@:>@])], + [enable_debug="$enableval"], + [enable_debug=no] +) +if test "x$enable_debug" = xyes; then + DEFINES="$DEFINES -DDEBUG" + if test "x$GCC" = xyes; then + # Remove any -g or -O flags from the command line + CFLAGS=[`echo $CFLAGS | sed 's/-g[^ \t]*[ \t]*//g;s/-O[^ \t]*[ \t]*//g'`] + CFLAGS="$CFLAGS -O0 -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2" + fi + if test "x$GXX" = xyes; then + # Remove any -g flags from the command line + CXXFLAGS=[`echo $CXXFLAGS | sed 's/-g[^ \t]*[ \t]*//g;s/-O[^ \t]*[ \t]*//g'`] + CXXFLAGS="$CXXFLAGS -O0 -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2" + fi +fi + +if test "x$GXX" = xyes ; then + WARN="-Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector" +else + WARN="" +fi + +CFLAGS="$CFLAGS $WARN" +CXXFLAGS="$CXXFLAGS $WARN" +YFLAGS="-d -v" + +AC_OUTPUT([Makefile]) diff --git a/src/glsl/glcpp/.gitignore b/src/glsl/glcpp/.gitignore new file mode 100644 index 00000000000..c158dc8b862 --- /dev/null +++ b/src/glsl/glcpp/.gitignore @@ -0,0 +1,11 @@ +glcpp +glcpp-lex.c +glcpp-parse.c +glcpp-parse.h +glcpp-parse.output +*.o +*.lo +*.la +.libs +*~ +tests/*.out diff --git a/src/glsl/glcpp/Makefile.am b/src/glsl/glcpp/Makefile.am new file mode 100644 index 00000000000..a49fd615cda --- /dev/null +++ b/src/glsl/glcpp/Makefile.am @@ -0,0 +1,46 @@ +# Copyright © 2010 Intel Corporation +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +# USE OR OTHER DEALINGS IN THE SOFTWARE. + +noinst_LTLIBRARIES = libglcpp.la +libglcpp_la_SOURCES = \ + glcpp-lex.l \ + glcpp-parse.y \ + glcpp.h \ + hash_table.c \ + pp.c \ + xtalloc.c + +BUILT_SOURCES = glcpp-parse.h glcpp-parse.c glcpp-lex.c +CLEANFILES = $(BUILT_SOURCES) + +glcpp-parse.h: glcpp-parse.c + +bin_PROGRAMS = glcpp +glcpp_LDADD = libglcpp.la +glcpp_LDFLAGS = @LDFLAGS@ $(talloc_LIBS) +glcpp_SOURCES = glcpp.c + +.l.c: + $(LEXCOMPILE) --outfile="$@" $< + +test: glcpp + @(cd tests; ./glcpp-test) diff --git a/src/glsl/glcpp/README b/src/glsl/glcpp/README new file mode 100644 index 00000000000..ab42a3ffe12 --- /dev/null +++ b/src/glsl/glcpp/README @@ -0,0 +1,30 @@ +glcpp -- GLSL "C" preprocessor + +This is a simple preprocessor designed to provide the preprocessing +needs of the GLSL language. The requirements for this preprocessor are +specified in the GLSL 1.30 specification availble from: + +http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.30.08.pdf + +This specification is not precise on some semantics, (for example, +#define and #if), defining these merely "as is standard for C++ +preprocessors". To fill in these details, I've been using the C99 +standard (for which I had a convenient copy) as available from: + +http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf + +Known limitations +----------------- +Macro invocations cannot include embedded newlines. + +The __LINE__, __FILE__, and __VERSION__ macros are not yet supported. + +The argument of the 'defined' operator cannot yet include enclosing +parentheses. + +The #error, #pragma, #extension, #version, and #line macros are not +yet supported. + +A file that ends with a function-like macro name as the last +non-whitespace token will result in a parse error, (where it should be +passed through as is). \ No newline at end of file diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l new file mode 100644 index 00000000000..afddd7ddb32 --- /dev/null +++ b/src/glsl/glcpp/glcpp-lex.l @@ -0,0 +1,257 @@ +%{ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include + +#include "glcpp.h" +#include "glcpp-parse.h" + +#define YY_USER_ACTION \ + do { \ + yylloc->source = 0; \ + yylloc->first_column = yycolumn + 1; \ + yylloc->first_line = yylineno; \ + yycolumn += yyleng; \ + } while(0); +%} + +%option bison-bridge bison-locations reentrant noyywrap +%option extra-type="glcpp_parser_t *" +%option prefix="glcpp_" +%option stack + +%x DONE COMMENT + +SPACE [[:space:]] +NONSPACE [^[:space:]] +NEWLINE [\n] +HSPACE [ \t] +HASH ^{HSPACE}*#{HSPACE}* +IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* +PUNCTUATION [][(){}.&*~!/%<>^|;,=+-] +OTHER [^][(){}.&*~!/%<>^|;,=#[:space:]+-]+ + +DECIMAL_INTEGER [1-9][0-9]*[uU]? +OCTAL_INTEGER 0[0-7]*[uU]? +HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? + +%% + + /* Single-line comments */ +"//"[^\n]*\n { + yylineno++; + yycolumn = 0; + return NEWLINE; +} + + /* Multi-line comments */ +"/*" { yy_push_state(COMMENT, yyscanner); } +[^*\n]* +[^*\n]*\n { yylineno++; yycolumn = 0; } +"*"+[^*/\n]* +"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; } +"*"+"/" { + yy_pop_state(yyscanner); + if (yyextra->space_tokens) + return SPACE; +} + + /* glcpp doesn't handle #extension, #version, or #pragma directives. + * Simply pass them through to the main compiler's lexer/parser. */ +{HASH}(extension|version|pragma)[^\n]+ { + yylval->str = xtalloc_strdup (yyextra, yytext); + yylineno++; + yycolumn = 0; + return OTHER; +} + +{HASH}ifdef/.*\n { + yyextra->space_tokens = 0; + return HASH_IFDEF; +} + +{HASH}ifndef/.*\n { + yyextra->space_tokens = 0; + return HASH_IFNDEF; +} + +{HASH}if{HSPACE}/.*\n { + yyextra->lexing_if = 1; + yyextra->space_tokens = 0; + return HASH_IF; +} + +{HASH}elif/.*\n { + yyextra->lexing_if = 1; + yyextra->space_tokens = 0; + return HASH_ELIF; +} + +{HASH}else/.*\n { + yyextra->space_tokens = 0; + return HASH_ELSE; +} + +{HASH}endif/.*\n { + yyextra->space_tokens = 0; + return HASH_ENDIF; +} + + /* When skipping (due to an #if 0 or similar) consume anything + * up to a newline. We do this less priroty than any + * #if-related directive (#if, #elif, #else, #endif), but with + * more priority than any other directive or token to avoid + * any side-effects from skipped content. + * + * We use the lexing_if flag to avoid skipping any part of an + * if conditional expression. */ +[^\n]+/\n { + /* Since this rule always matches, YY_USER_ACTION gets called for it, + * wrongly incrementing yycolumn. We undo that effect here. */ + yycolumn -= yyleng; + if (yyextra->lexing_if || + yyextra->skip_stack == NULL || + yyextra->skip_stack->type == SKIP_NO_SKIP) + { + REJECT; + } +} + +{HASH}define{HSPACE}+/{IDENTIFIER}"(" { + yyextra->space_tokens = 0; + return HASH_DEFINE_FUNC; +} + +{HASH}define { + yyextra->space_tokens = 0; + return HASH_DEFINE_OBJ; +} + +{HASH}undef { + yyextra->space_tokens = 0; + return HASH_UNDEF; +} + +{HASH} { + yyextra->space_tokens = 0; + return HASH; +} + +{DECIMAL_INTEGER} { + yylval->str = xtalloc_strdup (yyextra, yytext); + return INTEGER_STRING; +} + +{OCTAL_INTEGER} { + yylval->str = xtalloc_strdup (yyextra, yytext); + return INTEGER_STRING; +} + +{HEXADECIMAL_INTEGER} { + yylval->str = xtalloc_strdup (yyextra, yytext); + return INTEGER_STRING; +} + +"<<" { + return LEFT_SHIFT; +} + +">>" { + return RIGHT_SHIFT; +} + +"<=" { + return LESS_OR_EQUAL; +} + +">=" { + return GREATER_OR_EQUAL; +} + +"==" { + return EQUAL; +} + +"!=" { + return NOT_EQUAL; +} + +"&&" { + return AND; +} + +"||" { + return OR; +} + +"##" { + return PASTE; +} + +"defined" { + return DEFINED; +} + +{IDENTIFIER} { + yylval->str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; +} + +{PUNCTUATION} { + return yytext[0]; +} + +{OTHER}+ { + yylval->str = xtalloc_strdup (yyextra, yytext); + return OTHER; +} + +{HSPACE}+ { + if (yyextra->space_tokens) { + return SPACE; + } +} + +\n { + yyextra->lexing_if = 0; + yylineno++; + yycolumn = 0; + return NEWLINE; +} + + /* Handle missing newline at EOF. */ +<> { + BEGIN DONE; /* Don't keep matching this rule forever. */ + yyextra->lexing_if = 0; + return NEWLINE; +} + +%% + +void +glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader) +{ + yy_scan_string(shader, parser->scanner); +} diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y new file mode 100644 index 00000000000..6beac18c65d --- /dev/null +++ b/src/glsl/glcpp/glcpp-parse.y @@ -0,0 +1,1611 @@ +%{ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include + +#include "glcpp.h" + +#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) +#define glcpp_printf(stream, fmt, args...) \ + stream = talloc_asprintf_append(stream, fmt, args) + +static void +yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error); + +static void +_define_object_macro (glcpp_parser_t *parser, + YYLTYPE *loc, + const char *macro, + token_list_t *replacements); + +static void +_define_function_macro (glcpp_parser_t *parser, + YYLTYPE *loc, + const char *macro, + string_list_t *parameters, + token_list_t *replacements); + +static string_list_t * +_string_list_create (void *ctx); + +static void +_string_list_append_item (string_list_t *list, const char *str); + +static int +_string_list_contains (string_list_t *list, const char *member, int *index); + +static int +_string_list_length (string_list_t *list); + +static argument_list_t * +_argument_list_create (void *ctx); + +static void +_argument_list_append (argument_list_t *list, token_list_t *argument); + +static int +_argument_list_length (argument_list_t *list); + +static token_list_t * +_argument_list_member_at (argument_list_t *list, int index); + +/* Note: This function talloc_steal()s the str pointer. */ +static token_t * +_token_create_str (void *ctx, int type, char *str); + +static token_t * +_token_create_ival (void *ctx, int type, int ival); + +static token_list_t * +_token_list_create (void *ctx); + +/* Note: This function adds a talloc_reference() to token. + * + * You may want to talloc_unlink any current reference if you no + * longer need it. */ +static void +_token_list_append (token_list_t *list, token_t *token); + +static void +_token_list_append_list (token_list_t *list, token_list_t *tail); + +static active_list_t * +_active_list_push (active_list_t *list, + const char *identifier, + token_node_t *marker); + +static active_list_t * +_active_list_pop (active_list_t *list); + +int +_active_list_contains (active_list_t *list, const char *identifier); + +static void +_glcpp_parser_expand_token_list (glcpp_parser_t *parser, + token_list_t *list); + +static void +_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, + token_list_t *list); + +static void +_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, + int condition); + +static void +_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, + const char *type, int condition); + +static void +_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc); + +#define yylex glcpp_parser_lex + +static int +glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser); + +static void +glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); + +%} + +%pure-parser +%error-verbose +%locations + +%parse-param {glcpp_parser_t *parser} +%lex-param {glcpp_parser_t *parser} + +%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING NEWLINE OTHER PLACEHOLDER SPACE +%token PASTE +%type expression INTEGER operator SPACE +%type IDENTIFIER INTEGER_STRING OTHER +%type identifier_list +%type preprocessing_token conditional_token +%type pp_tokens replacement_list text_line conditional_tokens +%left OR +%left AND +%left '|' +%left '^' +%left '&' +%left EQUAL NOT_EQUAL +%left '<' '>' LESS_OR_EQUAL GREATER_OR_EQUAL +%left LEFT_SHIFT RIGHT_SHIFT +%left '+' '-' +%left '*' '/' '%' +%right UNARY + +%% + +input: + /* empty */ +| input line +; + +line: + control_line { + glcpp_print(parser->output, "\n"); + } +| text_line { + _glcpp_parser_print_expanded_token_list (parser, $1); + glcpp_print(parser->output, "\n"); + talloc_free ($1); + } +| expanded_line +| HASH non_directive +; + +expanded_line: + IF_EXPANDED expression NEWLINE { + _glcpp_parser_skip_stack_push_if (parser, & @1, $2); + } +| ELIF_EXPANDED expression NEWLINE { + _glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2); + } +; + +control_line: + HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE { + _define_object_macro (parser, & @2, $2, $3); + } +| HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE { + _define_function_macro (parser, & @2, $2, NULL, $5); + } +| HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE { + _define_function_macro (parser, & @2, $2, $4, $6); + } +| HASH_UNDEF IDENTIFIER NEWLINE { + macro_t *macro = hash_table_find (parser->defines, $2); + if (macro) { + /* XXX: Need hash table to support a real way + * to remove an element rather than prefixing + * a new node with data of NULL like this. */ + hash_table_insert (parser->defines, NULL, $2); + talloc_free (macro); + } + talloc_free ($2); + } +| HASH_IF conditional_tokens NEWLINE { + token_list_t *expanded; + token_t *token; + + expanded = _token_list_create (parser); + token = _token_create_ival (parser, IF_EXPANDED, IF_EXPANDED); + _token_list_append (expanded, token); + talloc_unlink (parser, token); + _glcpp_parser_expand_token_list (parser, $2); + _token_list_append_list (expanded, $2); + glcpp_parser_lex_from (parser, expanded); + } +| HASH_IFDEF IDENTIFIER junk NEWLINE { + macro_t *macro = hash_table_find (parser->defines, $2); + talloc_free ($2); + _glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL); + } +| HASH_IFNDEF IDENTIFIER junk NEWLINE { + macro_t *macro = hash_table_find (parser->defines, $2); + talloc_free ($2); + _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); + } +| HASH_ELIF conditional_tokens NEWLINE { + token_list_t *expanded; + token_t *token; + + expanded = _token_list_create (parser); + token = _token_create_ival (parser, ELIF_EXPANDED, ELIF_EXPANDED); + _token_list_append (expanded, token); + talloc_unlink (parser, token); + _glcpp_parser_expand_token_list (parser, $2); + _token_list_append_list (expanded, $2); + glcpp_parser_lex_from (parser, expanded); + } +| HASH_ELIF NEWLINE { + /* #elif without an expression results in a warning if the + * condition doesn't matter (we just handled #if 1 or such) + * but an error otherwise. */ + if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) { + parser->skip_stack->type = SKIP_TO_ENDIF; + glcpp_warning(& @1, parser, "ignoring illegal #elif without expression"); + } else { + glcpp_error(& @1, parser, "#elif needs an expression"); + } + } +| HASH_ELSE NEWLINE { + _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1); + } +| HASH_ENDIF NEWLINE { + _glcpp_parser_skip_stack_pop (parser, & @1); + } +| HASH NEWLINE +; + +expression: + INTEGER_STRING { + if (strlen ($1) >= 3 && strncmp ($1, "0x", 2) == 0) { + $$ = strtoll ($1 + 2, NULL, 16); + } else if ($1[0] == '0') { + $$ = strtoll ($1, NULL, 8); + } else { + $$ = strtoll ($1, NULL, 10); + } + } +| INTEGER { + $$ = $1; + } +| expression OR expression { + $$ = $1 || $3; + } +| expression AND expression { + $$ = $1 && $3; + } +| expression '|' expression { + $$ = $1 | $3; + } +| expression '^' expression { + $$ = $1 ^ $3; + } +| expression '&' expression { + $$ = $1 & $3; + } +| expression NOT_EQUAL expression { + $$ = $1 != $3; + } +| expression EQUAL expression { + $$ = $1 == $3; + } +| expression GREATER_OR_EQUAL expression { + $$ = $1 >= $3; + } +| expression LESS_OR_EQUAL expression { + $$ = $1 <= $3; + } +| expression '>' expression { + $$ = $1 > $3; + } +| expression '<' expression { + $$ = $1 < $3; + } +| expression RIGHT_SHIFT expression { + $$ = $1 >> $3; + } +| expression LEFT_SHIFT expression { + $$ = $1 << $3; + } +| expression '-' expression { + $$ = $1 - $3; + } +| expression '+' expression { + $$ = $1 + $3; + } +| expression '%' expression { + $$ = $1 % $3; + } +| expression '/' expression { + $$ = $1 / $3; + } +| expression '*' expression { + $$ = $1 * $3; + } +| '!' expression %prec UNARY { + $$ = ! $2; + } +| '~' expression %prec UNARY { + $$ = ~ $2; + } +| '-' expression %prec UNARY { + $$ = - $2; + } +| '+' expression %prec UNARY { + $$ = + $2; + } +| '(' expression ')' { + $$ = $2; + } +; + +identifier_list: + IDENTIFIER { + $$ = _string_list_create (parser); + _string_list_append_item ($$, $1); + talloc_steal ($$, $1); + } +| identifier_list ',' IDENTIFIER { + $$ = $1; + _string_list_append_item ($$, $3); + talloc_steal ($$, $3); + } +; + +text_line: + NEWLINE { $$ = NULL; } +| pp_tokens NEWLINE +; + +non_directive: + pp_tokens NEWLINE { + yyerror (& @1, parser, "Invalid tokens after #"); + } +; + +replacement_list: + /* empty */ { $$ = NULL; } +| pp_tokens +; + +junk: + /* empty */ +| pp_tokens { + glcpp_warning(&@1, parser, "extra tokens at end of directive"); + } +; + +conditional_token: + /* Handle "defined" operator */ + DEFINED IDENTIFIER { + int v = hash_table_find (parser->defines, $2) ? 1 : 0; + $$ = _token_create_ival (parser, INTEGER, v); + } +| DEFINED '(' IDENTIFIER ')' { + int v = hash_table_find (parser->defines, $3) ? 1 : 0; + $$ = _token_create_ival (parser, INTEGER, v); + } +| preprocessing_token +; + +conditional_tokens: + /* Exactly the same as pp_tokens, but using conditional_token */ + conditional_token { + parser->space_tokens = 1; + $$ = _token_list_create (parser); + _token_list_append ($$, $1); + talloc_unlink (parser, $1); + } +| conditional_tokens conditional_token { + $$ = $1; + _token_list_append ($$, $2); + talloc_unlink (parser, $2); + } +; + +pp_tokens: + preprocessing_token { + parser->space_tokens = 1; + $$ = _token_list_create (parser); + _token_list_append ($$, $1); + talloc_unlink (parser, $1); + } +| pp_tokens preprocessing_token { + $$ = $1; + _token_list_append ($$, $2); + talloc_unlink (parser, $2); + } +; + +preprocessing_token: + IDENTIFIER { + $$ = _token_create_str (parser, IDENTIFIER, $1); + $$->location = yylloc; + } +| INTEGER_STRING { + $$ = _token_create_str (parser, INTEGER_STRING, $1); + $$->location = yylloc; + } +| operator { + $$ = _token_create_ival (parser, $1, $1); + $$->location = yylloc; + } +| OTHER { + $$ = _token_create_str (parser, OTHER, $1); + $$->location = yylloc; + } +| SPACE { + $$ = _token_create_ival (parser, SPACE, SPACE); + $$->location = yylloc; + } +; + +operator: + '[' { $$ = '['; } +| ']' { $$ = ']'; } +| '(' { $$ = '('; } +| ')' { $$ = ')'; } +| '{' { $$ = '{'; } +| '}' { $$ = '}'; } +| '.' { $$ = '.'; } +| '&' { $$ = '&'; } +| '*' { $$ = '*'; } +| '+' { $$ = '+'; } +| '-' { $$ = '-'; } +| '~' { $$ = '~'; } +| '!' { $$ = '!'; } +| '/' { $$ = '/'; } +| '%' { $$ = '%'; } +| LEFT_SHIFT { $$ = LEFT_SHIFT; } +| RIGHT_SHIFT { $$ = RIGHT_SHIFT; } +| '<' { $$ = '<'; } +| '>' { $$ = '>'; } +| LESS_OR_EQUAL { $$ = LESS_OR_EQUAL; } +| GREATER_OR_EQUAL { $$ = GREATER_OR_EQUAL; } +| EQUAL { $$ = EQUAL; } +| NOT_EQUAL { $$ = NOT_EQUAL; } +| '^' { $$ = '^'; } +| '|' { $$ = '|'; } +| AND { $$ = AND; } +| OR { $$ = OR; } +| ';' { $$ = ';'; } +| ',' { $$ = ','; } +| '=' { $$ = '='; } +| PASTE { $$ = PASTE; } +| DEFINED { $$ = DEFINED; } +; + +%% + +string_list_t * +_string_list_create (void *ctx) +{ + string_list_t *list; + + list = xtalloc (ctx, string_list_t); + list->head = NULL; + list->tail = NULL; + + return list; +} + +void +_string_list_append_item (string_list_t *list, const char *str) +{ + string_node_t *node; + + node = xtalloc (list, string_node_t); + node->str = xtalloc_strdup (node, str); + + node->next = NULL; + + if (list->head == NULL) { + list->head = node; + } else { + list->tail->next = node; + } + + list->tail = node; +} + +int +_string_list_contains (string_list_t *list, const char *member, int *index) +{ + string_node_t *node; + int i; + + if (list == NULL) + return 0; + + for (i = 0, node = list->head; node; i++, node = node->next) { + if (strcmp (node->str, member) == 0) { + if (index) + *index = i; + return 1; + } + } + + return 0; +} + +int +_string_list_length (string_list_t *list) +{ + int length = 0; + string_node_t *node; + + if (list == NULL) + return 0; + + for (node = list->head; node; node = node->next) + length++; + + return length; +} + +argument_list_t * +_argument_list_create (void *ctx) +{ + argument_list_t *list; + + list = xtalloc (ctx, argument_list_t); + list->head = NULL; + list->tail = NULL; + + return list; +} + +void +_argument_list_append (argument_list_t *list, token_list_t *argument) +{ + argument_node_t *node; + + node = xtalloc (list, argument_node_t); + node->argument = argument; + + node->next = NULL; + + if (list->head == NULL) { + list->head = node; + } else { + list->tail->next = node; + } + + list->tail = node; +} + +int +_argument_list_length (argument_list_t *list) +{ + int length = 0; + argument_node_t *node; + + if (list == NULL) + return 0; + + for (node = list->head; node; node = node->next) + length++; + + return length; +} + +token_list_t * +_argument_list_member_at (argument_list_t *list, int index) +{ + argument_node_t *node; + int i; + + if (list == NULL) + return NULL; + + node = list->head; + for (i = 0; i < index; i++) { + node = node->next; + if (node == NULL) + break; + } + + if (node) + return node->argument; + + return NULL; +} + +/* Note: This function talloc_steal()s the str pointer. */ +token_t * +_token_create_str (void *ctx, int type, char *str) +{ + token_t *token; + + token = xtalloc (ctx, token_t); + token->type = type; + token->value.str = talloc_steal (token, str); + + return token; +} + +token_t * +_token_create_ival (void *ctx, int type, int ival) +{ + token_t *token; + + token = xtalloc (ctx, token_t); + token->type = type; + token->value.ival = ival; + + return token; +} + +token_list_t * +_token_list_create (void *ctx) +{ + token_list_t *list; + + list = xtalloc (ctx, token_list_t); + list->head = NULL; + list->tail = NULL; + list->non_space_tail = NULL; + + return list; +} + +void +_token_list_append (token_list_t *list, token_t *token) +{ + token_node_t *node; + + node = xtalloc (list, token_node_t); + node->token = xtalloc_reference (list, token); + + node->next = NULL; + + if (list->head == NULL) { + list->head = node; + } else { + list->tail->next = node; + } + + list->tail = node; + if (token->type != SPACE) + list->non_space_tail = node; +} + +void +_token_list_append_list (token_list_t *list, token_list_t *tail) +{ + if (tail == NULL || tail->head == NULL) + return; + + if (list->head == NULL) { + list->head = tail->head; + } else { + list->tail->next = tail->head; + } + + list->tail = tail->tail; + list->non_space_tail = tail->non_space_tail; +} + +token_list_t * +_token_list_copy (void *ctx, token_list_t *other) +{ + token_list_t *copy; + token_node_t *node; + + if (other == NULL) + return NULL; + + copy = _token_list_create (ctx); + for (node = other->head; node; node = node->next) + _token_list_append (copy, node->token); + + return copy; +} + +void +_token_list_trim_trailing_space (token_list_t *list) +{ + token_node_t *tail, *next; + + if (list->non_space_tail) { + tail = list->non_space_tail->next; + list->non_space_tail->next = NULL; + list->tail = list->non_space_tail; + + while (tail) { + next = tail->next; + talloc_free (tail); + tail = next; + } + } +} + +static void +_token_print (char **out, token_t *token) +{ + if (token->type < 256) { + glcpp_printf (*out, "%c", token->type); + return; + } + + switch (token->type) { + case INTEGER: + glcpp_printf (*out, "%" PRIxMAX, token->value.ival); + break; + case IDENTIFIER: + case INTEGER_STRING: + case OTHER: + glcpp_print (*out, token->value.str); + break; + case SPACE: + glcpp_print (*out, " "); + break; + case LEFT_SHIFT: + glcpp_print (*out, "<<"); + break; + case RIGHT_SHIFT: + glcpp_print (*out, ">>"); + break; + case LESS_OR_EQUAL: + glcpp_print (*out, "<="); + break; + case GREATER_OR_EQUAL: + glcpp_print (*out, ">="); + break; + case EQUAL: + glcpp_print (*out, "=="); + break; + case NOT_EQUAL: + glcpp_print (*out, "!="); + break; + case AND: + glcpp_print (*out, "&&"); + break; + case OR: + glcpp_print (*out, "||"); + break; + case PASTE: + glcpp_print (*out, "##"); + break; + case COMMA_FINAL: + glcpp_print (*out, ","); + break; + case PLACEHOLDER: + /* Nothing to print. */ + break; + default: + assert(!"Error: Don't know how to print token."); + break; + } +} + +/* Return a new token (talloc()ed off of 'token') formed by pasting + * 'token' and 'other'. Note that this function may return 'token' or + * 'other' directly rather than allocating anything new. + * + * Caution: Only very cursory error-checking is performed to see if + * the final result is a valid single token. */ +static token_t * +_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) +{ + token_t *combined = NULL; + + /* Pasting a placeholder onto anything makes no change. */ + if (other->type == PLACEHOLDER) + return token; + + /* When 'token' is a placeholder, just return 'other'. */ + if (token->type == PLACEHOLDER) + return other; + + /* A very few single-character punctuators can be combined + * with another to form a multi-character punctuator. */ + switch (token->type) { + case '<': + if (other->type == '<') + combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT); + else if (other->type == '=') + combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL); + break; + case '>': + if (other->type == '>') + combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT); + else if (other->type == '=') + combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL); + break; + case '=': + if (other->type == '=') + combined = _token_create_ival (token, EQUAL, EQUAL); + break; + case '!': + if (other->type == '=') + combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL); + break; + case '&': + if (other->type == '&') + combined = _token_create_ival (token, AND, AND); + break; + case '|': + if (other->type == '|') + combined = _token_create_ival (token, OR, OR); + break; + } + + if (combined != NULL) { + /* Inherit the location from the first token */ + combined->location = token->location; + return combined; + } + + /* Two string-valued tokens can usually just be mashed + * together. + * + * XXX: This isn't actually legitimate. Several things here + * should result in a diagnostic since the result cannot be a + * valid, single pre-processing token. For example, pasting + * "123" and "abc" is not legal, but we don't catch that + * here. */ + if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) && + (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING)) + { + char *str; + + str = xtalloc_asprintf (token, "%s%s", + token->value.str, other->value.str); + combined = _token_create_str (token, token->type, str); + combined->location = token->location; + return combined; + } + + glcpp_error (&token->location, parser, ""); + glcpp_print (parser->info_log, "Pasting \""); + _token_print (&parser->info_log, token); + glcpp_print (parser->info_log, "\" and \""); + _token_print (&parser->info_log, other); + glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n"); + + return token; +} + +static void +_token_list_print (glcpp_parser_t *parser, token_list_t *list) +{ + token_node_t *node; + + if (list == NULL) + return; + + for (node = list->head; node; node = node->next) + _token_print (&parser->output, node->token); +} + +void +yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error) +{ + glcpp_error(locp, parser, "%s", error); +} + +glcpp_parser_t * +glcpp_parser_create (void) +{ + glcpp_parser_t *parser; + + parser = xtalloc (NULL, glcpp_parser_t); + + glcpp_lex_init_extra (parser, &parser->scanner); + parser->defines = hash_table_ctor (32, hash_table_string_hash, + hash_table_string_compare); + parser->active = NULL; + parser->lexing_if = 0; + parser->space_tokens = 1; + parser->newline_as_space = 0; + parser->in_control_line = 0; + parser->paren_count = 0; + + parser->skip_stack = NULL; + + parser->lex_from_list = NULL; + parser->lex_from_node = NULL; + + parser->output = talloc_strdup(parser, ""); + parser->info_log = talloc_strdup(parser, ""); + parser->error = 0; + + return parser; +} + +int +glcpp_parser_parse (glcpp_parser_t *parser) +{ + return yyparse (parser); +} + +void +glcpp_parser_destroy (glcpp_parser_t *parser) +{ + if (parser->skip_stack) + glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); + glcpp_lex_destroy (parser->scanner); + hash_table_dtor (parser->defines); + talloc_free (parser); +} + +typedef enum function_status +{ + FUNCTION_STATUS_SUCCESS, + FUNCTION_NOT_A_FUNCTION, + FUNCTION_UNBALANCED_PARENTHESES +} function_status_t; + +/* Find a set of function-like macro arguments by looking for a + * balanced set of parentheses. + * + * When called, 'node' should be the opening-parenthesis token, (or + * perhaps preceeding SPACE tokens). Upon successful return *last will + * be the last consumed node, (corresponding to the closing right + * parenthesis). + * + * Return values: + * + * FUNCTION_STATUS_SUCCESS: + * + * Successfully parsed a set of function arguments. + * + * FUNCTION_NOT_A_FUNCTION: + * + * Macro name not followed by a '('. This is not an error, but + * simply that the macro name should be treated as a non-macro. + * + * FUNCTION_UNBALANCED_PARENTHESES + * + * Macro name is not followed by a balanced set of parentheses. + */ +static function_status_t +_arguments_parse (argument_list_t *arguments, + token_node_t *node, + token_node_t **last) +{ + token_list_t *argument; + int paren_count; + + node = node->next; + + /* Ignore whitespace before first parenthesis. */ + while (node && node->token->type == SPACE) + node = node->next; + + if (node == NULL || node->token->type != '(') + return FUNCTION_NOT_A_FUNCTION; + + node = node->next; + + argument = _token_list_create (arguments); + _argument_list_append (arguments, argument); + + for (paren_count = 1; node; node = node->next) { + if (node->token->type == '(') + { + paren_count++; + } + else if (node->token->type == ')') + { + paren_count--; + if (paren_count == 0) + break; + } + + if (node->token->type == ',' && + paren_count == 1) + { + _token_list_trim_trailing_space (argument); + argument = _token_list_create (arguments); + _argument_list_append (arguments, argument); + } + else { + if (argument->head == NULL) { + /* Don't treat initial whitespace as + * part of the arguement. */ + if (node->token->type == SPACE) + continue; + } + _token_list_append (argument, node->token); + } + } + + if (paren_count) + return FUNCTION_UNBALANCED_PARENTHESES; + + *last = node; + + return FUNCTION_STATUS_SUCCESS; +} + +/* This is a helper function that's essentially part of the + * implementation of _glcpp_parser_expand_node. It shouldn't be called + * except for by that function. + * + * Returns NULL if node is a simple token with no expansion, (that is, + * although 'node' corresponds to an identifier defined as a + * function-like macro, it is not followed with a parenthesized + * argument list). + * + * Compute the complete expansion of node (which is a function-like + * macro) and subsequent nodes which are arguments. + * + * Returns the token list that results from the expansion and sets + * *last to the last node in the list that was consumed by the + * expansion. Specificallty, *last will be set as follows: as the + * token of the closing right parenthesis. + */ +static token_list_t * +_glcpp_parser_expand_function (glcpp_parser_t *parser, + token_node_t *node, + token_node_t **last) + +{ + macro_t *macro; + const char *identifier; + argument_list_t *arguments; + function_status_t status; + token_list_t *substituted; + int parameter_index; + + identifier = node->token->value.str; + + macro = hash_table_find (parser->defines, identifier); + + assert (macro->is_function); + + arguments = _argument_list_create (parser); + status = _arguments_parse (arguments, node, last); + + switch (status) { + case FUNCTION_STATUS_SUCCESS: + break; + case FUNCTION_NOT_A_FUNCTION: + return NULL; + case FUNCTION_UNBALANCED_PARENTHESES: + glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier); + return NULL; + } + + if (macro->replacements == NULL) { + talloc_free (arguments); + return _token_list_create (parser); + } + + if (! ((_argument_list_length (arguments) == + _string_list_length (macro->parameters)) || + (_string_list_length (macro->parameters) == 0 && + _argument_list_length (arguments) == 1 && + arguments->head->argument->head == NULL))) + { + glcpp_error (&node->token->location, parser, + "Error: macro %s invoked with %d arguments (expected %d)\n", + identifier, + _argument_list_length (arguments), + _string_list_length (macro->parameters)); + return NULL; + } + + /* Perform argument substitution on the replacement list. */ + substituted = _token_list_create (arguments); + + for (node = macro->replacements->head; node; node = node->next) + { + if (node->token->type == IDENTIFIER && + _string_list_contains (macro->parameters, + node->token->value.str, + ¶meter_index)) + { + token_list_t *argument; + argument = _argument_list_member_at (arguments, + parameter_index); + /* Before substituting, we expand the argument + * tokens, or append a placeholder token for + * an empty argument. */ + if (argument->head) { + _glcpp_parser_expand_token_list (parser, + argument); + _token_list_append_list (substituted, argument); + } else { + token_t *new_token; + + new_token = _token_create_ival (substituted, + PLACEHOLDER, + PLACEHOLDER); + _token_list_append (substituted, new_token); + } + } else { + _token_list_append (substituted, node->token); + } + } + + /* After argument substitution, and before further expansion + * below, implement token pasting. */ + + _token_list_trim_trailing_space (substituted); + + node = substituted->head; + while (node) + { + token_node_t *next_non_space; + + /* Look ahead for a PASTE token, skipping space. */ + next_non_space = node->next; + while (next_non_space && next_non_space->token->type == SPACE) + next_non_space = next_non_space->next; + + if (next_non_space == NULL) + break; + + if (next_non_space->token->type != PASTE) { + node = next_non_space; + continue; + } + + /* Now find the next non-space token after the PASTE. */ + next_non_space = next_non_space->next; + while (next_non_space && next_non_space->token->type == SPACE) + next_non_space = next_non_space->next; + + if (next_non_space == NULL) { + yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n"); + return NULL; + } + + node->token = _token_paste (parser, node->token, next_non_space->token); + node->next = next_non_space->next; + if (next_non_space == substituted->tail) + substituted->tail = node; + + node = node->next; + } + + substituted->non_space_tail = substituted->tail; + + return substituted; +} + +/* Compute the complete expansion of node, (and subsequent nodes after + * 'node' in the case that 'node' is a function-like macro and + * subsequent nodes are arguments). + * + * Returns NULL if node is a simple token with no expansion. + * + * Otherwise, returns the token list that results from the expansion + * and sets *last to the last node in the list that was consumed by + * the expansion. Specificallty, *last will be set as follows: + * + * As 'node' in the case of object-like macro expansion. + * + * As the token of the closing right parenthesis in the case of + * function-like macro expansion. + */ +static token_list_t * +_glcpp_parser_expand_node (glcpp_parser_t *parser, + token_node_t *node, + token_node_t **last) +{ + token_t *token = node->token; + const char *identifier; + macro_t *macro; + + /* We only expand identifiers */ + if (token->type != IDENTIFIER) { + /* We change any COMMA into a COMMA_FINAL to prevent + * it being mistaken for an argument separator + * later. */ + if (token->type == ',') { + token->type = COMMA_FINAL; + token->value.ival = COMMA_FINAL; + } + + return NULL; + } + + /* Look up this identifier in the hash table. */ + identifier = token->value.str; + macro = hash_table_find (parser->defines, identifier); + + /* Not a macro, so no expansion needed. */ + if (macro == NULL) + return NULL; + + /* Finally, don't expand this macro if we're already actively + * expanding it, (to avoid infinite recursion). */ + if (_active_list_contains (parser->active, identifier)) { + /* We change the token type here from IDENTIFIER to + * OTHER to prevent any future expansion of this + * unexpanded token. */ + char *str; + token_list_t *expansion; + token_t *final; + + str = xtalloc_strdup (parser, token->value.str); + final = _token_create_str (parser, OTHER, str); + expansion = _token_list_create (parser); + _token_list_append (expansion, final); + *last = node; + return expansion; + } + + if (! macro->is_function) + { + *last = node; + + if (macro->replacements == NULL) + return _token_list_create (parser); + + return _token_list_copy (parser, macro->replacements); + } + + return _glcpp_parser_expand_function (parser, node, last); +} + +/* Push a new identifier onto the active list, returning the new list. + * + * Here, 'marker' is the token node that appears in the list after the + * expansion of 'identifier'. That is, when the list iterator begins + * examinging 'marker', then it is time to pop this node from the + * active stack. + */ +active_list_t * +_active_list_push (active_list_t *list, + const char *identifier, + token_node_t *marker) +{ + active_list_t *node; + + node = xtalloc (list, active_list_t); + node->identifier = xtalloc_strdup (node, identifier); + node->marker = marker; + node->next = list; + + return node; +} + +active_list_t * +_active_list_pop (active_list_t *list) +{ + active_list_t *node = list; + + if (node == NULL) + return NULL; + + node = list->next; + talloc_free (list); + + return node; +} + +int +_active_list_contains (active_list_t *list, const char *identifier) +{ + active_list_t *node; + + if (list == NULL) + return 0; + + for (node = list; node; node = node->next) + if (strcmp (node->identifier, identifier) == 0) + return 1; + + return 0; +} + +/* Walk over the token list replacing nodes with their expansion. + * Whenever nodes are expanded the walking will walk over the new + * nodes, continuing to expand as necessary. The results are placed in + * 'list' itself; + */ +static void +_glcpp_parser_expand_token_list (glcpp_parser_t *parser, + token_list_t *list) +{ + token_node_t *node_prev; + token_node_t *node, *last = NULL; + token_list_t *expansion; + + if (list == NULL) + return; + + _token_list_trim_trailing_space (list); + + node_prev = NULL; + node = list->head; + + while (node) { + + while (parser->active && parser->active->marker == node) + parser->active = _active_list_pop (parser->active); + + /* Find the expansion for node, which will replace all + * nodes from node to last, inclusive. */ + expansion = _glcpp_parser_expand_node (parser, node, &last); + if (expansion) { + token_node_t *n; + + for (n = node; n != last->next; n = n->next) + while (parser->active && + parser->active->marker == n) + { + parser->active = _active_list_pop (parser->active); + } + + parser->active = _active_list_push (parser->active, + node->token->value.str, + last->next); + + /* Splice expansion into list, supporting a + * simple deletion if the expansion is + * empty. */ + if (expansion->head) { + if (node_prev) + node_prev->next = expansion->head; + else + list->head = expansion->head; + expansion->tail->next = last->next; + if (last == list->tail) + list->tail = expansion->tail; + } else { + if (node_prev) + node_prev->next = last->next; + else + list->head = last->next; + if (last == list->tail) + list->tail = NULL; + } + } else { + node_prev = node; + } + node = node_prev ? node_prev->next : list->head; + } + + while (parser->active) + parser->active = _active_list_pop (parser->active); + + list->non_space_tail = list->tail; +} + +void +_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, + token_list_t *list) +{ + if (list == NULL) + return; + + _glcpp_parser_expand_token_list (parser, list); + + _token_list_trim_trailing_space (list); + + _token_list_print (parser, list); +} + +void +_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc, + const char *identifier) +{ + /* According to the GLSL specification, macro names starting with "__" + * or "GL_" are reserved for future use. So, don't allow them. + */ + if (strncmp(identifier, "__", 2) == 0) { + glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n"); + } + if (strncmp(identifier, "GL_", 3) == 0) { + glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n"); + } +} + +void +_define_object_macro (glcpp_parser_t *parser, + YYLTYPE *loc, + const char *identifier, + token_list_t *replacements) +{ + macro_t *macro; + + _check_for_reserved_macro_name(parser, loc, identifier); + + macro = xtalloc (parser, macro_t); + + macro->is_function = 0; + macro->parameters = NULL; + macro->identifier = talloc_strdup (macro, identifier); + macro->replacements = talloc_steal (macro, replacements); + + hash_table_insert (parser->defines, macro, identifier); +} + +void +_define_function_macro (glcpp_parser_t *parser, + YYLTYPE *loc, + const char *identifier, + string_list_t *parameters, + token_list_t *replacements) +{ + macro_t *macro; + + _check_for_reserved_macro_name(parser, loc, identifier); + + macro = xtalloc (parser, macro_t); + + macro->is_function = 1; + macro->parameters = talloc_steal (macro, parameters); + macro->identifier = talloc_strdup (macro, identifier); + macro->replacements = talloc_steal (macro, replacements); + + hash_table_insert (parser->defines, macro, identifier); +} + +static int +glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser) +{ + token_node_t *node; + int ret; + + if (parser->lex_from_list == NULL) { + ret = glcpp_lex (yylval, yylloc, parser->scanner); + + /* XXX: This ugly block of code exists for the sole + * purpose of converting a NEWLINE token into a SPACE + * token, but only in the case where we have seen a + * function-like macro name, but have not yet seen its + * closing parenthesis. + * + * There's perhaps a more compact way to do this with + * mid-rule actions in the grammar. + * + * I'm definitely not pleased with the complexity of + * this code here. + */ + if (parser->newline_as_space) + { + if (ret == '(') { + parser->paren_count++; + } else if (ret == ')') { + parser->paren_count--; + if (parser->paren_count == 0) + parser->newline_as_space = 0; + } else if (ret == NEWLINE) { + ret = SPACE; + } else if (ret != SPACE) { + if (parser->paren_count == 0) + parser->newline_as_space = 0; + } + } + else if (parser->in_control_line) + { + if (ret == NEWLINE) + parser->in_control_line = 0; + } + else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC || + ret == HASH_UNDEF || ret == HASH_IF || + ret == HASH_IFDEF || ret == HASH_IFNDEF || + ret == HASH_ELIF || ret == HASH_ELSE || + ret == HASH_ENDIF || ret == HASH) + { + parser->in_control_line = 1; + } + else if (ret == IDENTIFIER) + { + macro_t *macro; + macro = hash_table_find (parser->defines, + yylval->str); + if (macro && macro->is_function) { + parser->newline_as_space = 1; + parser->paren_count = 0; + } + } + + return ret; + } + + node = parser->lex_from_node; + + if (node == NULL) { + talloc_free (parser->lex_from_list); + parser->lex_from_list = NULL; + return NEWLINE; + } + + *yylval = node->token->value; + ret = node->token->type; + + parser->lex_from_node = node->next; + + return ret; +} + +static void +glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list) +{ + token_node_t *node; + + assert (parser->lex_from_list == NULL); + + /* Copy list, eliminating any space tokens. */ + parser->lex_from_list = _token_list_create (parser); + + for (node = list->head; node; node = node->next) { + if (node->token->type == SPACE) + continue; + _token_list_append (parser->lex_from_list, node->token); + } + + talloc_free (list); + + parser->lex_from_node = parser->lex_from_list->head; + + /* It's possible the list consisted of nothing but whitespace. */ + if (parser->lex_from_node == NULL) { + talloc_free (parser->lex_from_list); + parser->lex_from_list = NULL; + } +} + +static void +_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, + int condition) +{ + skip_type_t current = SKIP_NO_SKIP; + skip_node_t *node; + + if (parser->skip_stack) + current = parser->skip_stack->type; + + node = xtalloc (parser, skip_node_t); + node->loc = *loc; + + if (current == SKIP_NO_SKIP) { + if (condition) + node->type = SKIP_NO_SKIP; + else + node->type = SKIP_TO_ELSE; + } else { + node->type = SKIP_TO_ENDIF; + } + + node->next = parser->skip_stack; + parser->skip_stack = node; +} + +static void +_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, + const char *type, int condition) +{ + if (parser->skip_stack == NULL) { + glcpp_error (loc, parser, "%s without #if\n", type); + return; + } + + if (parser->skip_stack->type == SKIP_TO_ELSE) { + if (condition) + parser->skip_stack->type = SKIP_NO_SKIP; + } else { + parser->skip_stack->type = SKIP_TO_ENDIF; + } +} + +static void +_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc) +{ + skip_node_t *node; + + if (parser->skip_stack == NULL) { + glcpp_error (loc, parser, "#endif without #if\n"); + return; + } + + node = parser->skip_stack; + parser->skip_stack = node->next; + talloc_free (node); +} diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c new file mode 100644 index 00000000000..cc87e14950b --- /dev/null +++ b/src/glsl/glcpp/glcpp.c @@ -0,0 +1,88 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include "glcpp.h" + +extern int yydebug; + +static char * +load_text_file(void *ctx, const char *file_name) +{ + char *text = NULL; + struct stat st; + ssize_t total_read = 0; + int fd = file_name == NULL ? STDIN_FILENO : open(file_name, O_RDONLY); + + if (fd < 0) { + 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) { + text = NULL; + break; + } + + if (bytes == 0) { + break; + } + + total_read += bytes; + } while (total_read < st.st_size); + + text[total_read] = '\0'; + } + } + + close(fd); + + return text; +} + +int +preprocess(void *talloc_ctx, const char **shader, char **info_log); + +int +main (void) +{ + void *ctx = talloc(NULL, void*); + const char *shader = load_text_file(ctx, NULL); + char *info_log = talloc_strdup(ctx, ""); + int ret = preprocess(ctx, &shader, &info_log); + + printf("%s", shader); + fprintf(stderr, "%s", info_log); + + talloc_free(ctx); + + return ret; +} diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h new file mode 100644 index 00000000000..2cfa98d2b1d --- /dev/null +++ b/src/glsl/glcpp/glcpp.h @@ -0,0 +1,224 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef GLCPP_H +#define GLCPP_H + +#include + +#include + +#include "hash_table.h" + +#define yyscan_t void* + +/* Some data types used for parser values. */ + +typedef struct string_node { + const char *str; + struct string_node *next; +} string_node_t; + +typedef struct string_list { + string_node_t *head; + string_node_t *tail; +} string_list_t; + +typedef struct token token_t; +typedef struct token_list token_list_t; + +typedef union YYSTYPE +{ + intmax_t ival; + char *str; + string_list_t *string_list; + token_t *token; + token_list_t *token_list; +} YYSTYPE; + +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 + +typedef struct YYLTYPE { + int first_line; + int first_column; + int last_line; + int last_column; + unsigned source; +} YYLTYPE; +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 + +struct token { + int type; + YYSTYPE value; + YYLTYPE location; +}; + +typedef struct token_node { + token_t *token; + struct token_node *next; +} token_node_t; + +struct token_list { + token_node_t *head; + token_node_t *tail; + token_node_t *non_space_tail; +}; + +typedef struct argument_node { + token_list_t *argument; + struct argument_node *next; +} argument_node_t; + +typedef struct argument_list { + argument_node_t *head; + argument_node_t *tail; +} argument_list_t; + +typedef struct glcpp_parser glcpp_parser_t; + +typedef enum { + TOKEN_CLASS_IDENTIFIER, + TOKEN_CLASS_IDENTIFIER_FINALIZED, + TOKEN_CLASS_FUNC_MACRO, + TOKEN_CLASS_OBJ_MACRO +} token_class_t; + +token_class_t +glcpp_parser_classify_token (glcpp_parser_t *parser, + const char *identifier, + int *parameter_index); + +typedef struct { + int is_function; + string_list_t *parameters; + const char *identifier; + token_list_t *replacements; +} macro_t; + +typedef struct expansion_node { + macro_t *macro; + token_node_t *replacements; + struct expansion_node *next; +} expansion_node_t; + +typedef enum skip_type { + SKIP_NO_SKIP, + SKIP_TO_ELSE, + SKIP_TO_ENDIF +} skip_type_t; + +typedef struct skip_node { + skip_type_t type; + YYLTYPE loc; /* location of the initial #if/#elif/... */ + struct skip_node *next; +} skip_node_t; + +typedef struct active_list { + const char *identifier; + token_node_t *marker; + struct active_list *next; +} active_list_t; + +struct glcpp_parser { + yyscan_t scanner; + struct hash_table *defines; + active_list_t *active; + int lexing_if; + int space_tokens; + int newline_as_space; + int in_control_line; + int paren_count; + skip_node_t *skip_stack; + token_list_t *lex_from_list; + token_node_t *lex_from_node; + char *output; + char *info_log; + int error; +}; + +glcpp_parser_t * +glcpp_parser_create (void); + +int +glcpp_parser_parse (glcpp_parser_t *parser); + +void +glcpp_parser_destroy (glcpp_parser_t *parser); + +int +preprocess(void *talloc_ctx, const char **shader, char **info_log); + +/* Functions for writing to the info log */ + +void +glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...); + +void +glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...); + +/* Generated by glcpp-lex.l to glcpp-lex.c */ + +int +glcpp_lex_init_extra (glcpp_parser_t *parser, yyscan_t* scanner); + +void +glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader); + +int +glcpp_lex (YYSTYPE *lvalp, YYLTYPE *llocp, yyscan_t scanner); + +int +glcpp_lex_destroy (yyscan_t scanner); + +/* Generated by glcpp-parse.y to glcpp-parse.c */ + +int +yyparse (glcpp_parser_t *parser); + +/* xtalloc - wrappers around talloc to check for out-of-memory */ + +#define xtalloc(ctx, type) (type *)xtalloc_named_const(ctx, sizeof(type), #type) + +#define xtalloc_size(ctx, size) xtalloc_named_const(ctx, size, __location__) + +void * +xtalloc_named_const (const void *context, size_t size, const char *name); + +char * +xtalloc_strdup (const void *t, const char *p); + +char * +xtalloc_strndup (const void *t, const char *p, size_t n); + +char * +xtalloc_asprintf (const void *t, const char *fmt, ...); + +void * +_xtalloc_reference_loc (const void *context, + const void *ptr, const char *location); + +#define xtalloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_xtalloc_reference_loc((ctx),(ptr), __location__) + +#endif diff --git a/src/glsl/glcpp/hash_table.c b/src/glsl/glcpp/hash_table.c new file mode 100644 index 00000000000..e89a2564d76 --- /dev/null +++ b/src/glsl/glcpp/hash_table.c @@ -0,0 +1,159 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file hash_table.c + * \brief Implementation of a generic, opaque hash table data type. + * + * \author Ian Romanick + */ + +#include "main/imports.h" +#include "main/simple_list.h" +#include "hash_table.h" + +struct node { + struct node *next; + struct node *prev; +}; + +struct hash_table { + hash_func_t hash; + hash_compare_func_t compare; + + unsigned num_buckets; + struct node buckets[1]; +}; + + +struct hash_node { + struct node link; + const void *key; + void *data; +}; + + +struct hash_table * +hash_table_ctor(unsigned num_buckets, hash_func_t hash, + hash_compare_func_t compare) +{ + struct hash_table *ht; + unsigned i; + + + if (num_buckets < 16) { + num_buckets = 16; + } + + ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1) + * sizeof(ht->buckets[0]))); + if (ht != NULL) { + ht->hash = hash; + ht->compare = compare; + ht->num_buckets = num_buckets; + + for (i = 0; i < num_buckets; i++) { + make_empty_list(& ht->buckets[i]); + } + } + + return ht; +} + + +void +hash_table_dtor(struct hash_table *ht) +{ + hash_table_clear(ht); + _mesa_free(ht); +} + + +void +hash_table_clear(struct hash_table *ht) +{ + struct node *node; + struct node *temp; + unsigned i; + + + for (i = 0; i < ht->num_buckets; i++) { + foreach_s(node, temp, & ht->buckets[i]) { + remove_from_list(node); + _mesa_free(node); + } + + assert(is_empty_list(& ht->buckets[i])); + } +} + + +void * +hash_table_find(struct hash_table *ht, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct node *node; + + foreach(node, & ht->buckets[bucket]) { + struct hash_node *hn = (struct hash_node *) node; + + if ((*ht->compare)(hn->key, key) == 0) { + return hn->data; + } + } + + return NULL; +} + + +void +hash_table_insert(struct hash_table *ht, void *data, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct hash_node *node; + + node = _mesa_calloc(sizeof(*node)); + + node->data = data; + node->key = key; + + insert_at_head(& ht->buckets[bucket], & node->link); +} + + +unsigned +hash_table_string_hash(const void *key) +{ + const char *str = (const char *) key; + unsigned hash = 5381; + + + while (*str != '\0') { + hash = (hash * 33) + *str; + str++; + } + + return hash; +} diff --git a/src/glsl/glcpp/hash_table.h b/src/glsl/glcpp/hash_table.h new file mode 100644 index 00000000000..b9dd343dee9 --- /dev/null +++ b/src/glsl/glcpp/hash_table.h @@ -0,0 +1,125 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file hash_table.h + * \brief Implementation of a generic, opaque hash table data type. + * + * \author Ian Romanick + */ + +#ifndef HASH_TABLE_H +#define HASH_TABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +struct hash_table; + +typedef unsigned (*hash_func_t)(const void *key); +typedef int (*hash_compare_func_t)(const void *key1, const void *key2); + +/** + * Hash table constructor + * + * Creates a hash table with the specified number of buckets. The supplied + * \c hash and \c compare routines are used when adding elements to the table + * and when searching for elements in the table. + * + * \param num_buckets Number of buckets (bins) in the hash table. + * \param hash Function used to compute hash value of input keys. + * \param compare Function used to compare keys. + */ +extern struct hash_table *hash_table_ctor(unsigned num_buckets, + hash_func_t hash, hash_compare_func_t compare); + + +/** + * Release all memory associated with a hash table + * + * \warning + * This function cannot release memory occupied either by keys or data. + */ +extern void hash_table_dtor(struct hash_table *ht); + + +/** + * Flush all entries from a hash table + * + * \param ht Table to be cleared of its entries. + */ +extern void hash_table_clear(struct hash_table *ht); + + +/** + * Search a hash table for a specific element + * + * \param ht Table to be searched + * \param key Key of the desired element + * + * \return + * The \c data value supplied to \c hash_table_insert when the element with + * the matching key was added. If no matching key exists in the table, + * \c NULL is returned. + */ +extern void *hash_table_find(struct hash_table *ht, const void *key); + + +/** + * Add an element to a hash table + */ +extern void hash_table_insert(struct hash_table *ht, void *data, + const void *key); + + +/** + * Compute hash value of a string + * + * Computes the hash value of a string using the DJB2 algorithm developed by + * Professor Daniel J. Bernstein. It was published on comp.lang.c once upon + * a time. I was unable to find the original posting in the archives. + * + * \param key Pointer to a NUL terminated string to be hashed. + * + * \sa hash_table_string_compare + */ +extern unsigned hash_table_string_hash(const void *key); + + +/** + * Compare two strings used as keys + * + * This is just a macro wrapper around \c strcmp. + * + * \sa hash_table_string_hash + */ +#define hash_table_string_compare ((hash_compare_func_t) strcmp) + +#ifdef __cplusplus +}; +#endif + +#endif /* HASH_TABLE_H */ diff --git a/src/glsl/glcpp/main/imports.h b/src/glsl/glcpp/main/imports.h new file mode 100644 index 00000000000..d2197342c04 --- /dev/null +++ b/src/glsl/glcpp/main/imports.h @@ -0,0 +1,6 @@ +#include +#include + +#define _mesa_malloc(x) malloc(x) +#define _mesa_free(x) free(x) +#define _mesa_calloc(x) calloc(1,x) diff --git a/src/glsl/glcpp/main/simple_list.h b/src/glsl/glcpp/main/simple_list.h new file mode 100644 index 00000000000..5ef39e14cc6 --- /dev/null +++ b/src/glsl/glcpp/main/simple_list.h @@ -0,0 +1,235 @@ +/** + * \file simple_list.h + * Simple macros for type-safe, intrusive lists. + * + * Intended to work with a list sentinal which is created as an empty + * list. Insert & delete are O(1). + * + * \author + * (C) 1997, Keith Whitwell + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _SIMPLE_LIST_H +#define _SIMPLE_LIST_H + +struct simple_node { + struct simple_node *next; + struct simple_node *prev; +}; + +/** + * Remove an element from list. + * + * \param elem element to remove. + */ +#define remove_from_list(elem) \ +do { \ + (elem)->next->prev = (elem)->prev; \ + (elem)->prev->next = (elem)->next; \ +} while (0) + +/** + * Insert an element to the list head. + * + * \param list list. + * \param elem element to insert. + */ +#define insert_at_head(list, elem) \ +do { \ + (elem)->prev = list; \ + (elem)->next = (list)->next; \ + (list)->next->prev = elem; \ + (list)->next = elem; \ +} while(0) + +/** + * Insert an element to the list tail. + * + * \param list list. + * \param elem element to insert. + */ +#define insert_at_tail(list, elem) \ +do { \ + (elem)->next = list; \ + (elem)->prev = (list)->prev; \ + (list)->prev->next = elem; \ + (list)->prev = elem; \ +} while(0) + +/** + * Move an element to the list head. + * + * \param list list. + * \param elem element to move. + */ +#define move_to_head(list, elem) \ +do { \ + remove_from_list(elem); \ + insert_at_head(list, elem); \ +} while (0) + +/** + * Move an element to the list tail. + * + * \param list list. + * \param elem element to move. + */ +#define move_to_tail(list, elem) \ +do { \ + remove_from_list(elem); \ + insert_at_tail(list, elem); \ +} while (0) + +/** + * Consatinate a cyclic list to a list + * + * Appends the sequence of nodes starting with \c tail to the list \c head. + * A "cyclic list" is a list that does not have a sentinal node. This means + * that the data pointed to by \c tail is an actual node, not a dataless + * sentinal. Note that if \c tail constist of a single node, this macro + * behaves identically to \c insert_at_tail + * + * \param head Head of the list to be appended to. This may or may not + * be a cyclic list. + * \param tail Head of the cyclic list to be appended to \c head. + * \param temp Temporary \c simple_list used by the macro + * + * \sa insert_at_tail + */ +#define concat_list_and_cycle(head, tail, temp) \ +do { \ + (head)->prev->next = (tail); \ + (tail)->prev->next = (head); \ + (temp) = (head)->prev; \ + (head)->prev = (tail)->prev; \ + (tail)->prev = (temp); \ +} while (0) + +#define concat_list(head, next_list) \ +do { \ + (next_list)->next->prev = (head)->prev; \ + (next_list)->prev->next = (head); \ + (head)->prev->next = (next_list)->next; \ + (head)->prev = (next_list)->prev; \ +} while (0) + +/** + * Make a empty list empty. + * + * \param sentinal list (sentinal element). + */ +#define make_empty_list(sentinal) \ +do { \ + (sentinal)->next = sentinal; \ + (sentinal)->prev = sentinal; \ +} while (0) + +/** + * Get list first element. + * + * \param list list. + * + * \return pointer to first element. + */ +#define first_elem(list) ((list)->next) + +/** + * Get list last element. + * + * \param list list. + * + * \return pointer to last element. + */ +#define last_elem(list) ((list)->prev) + +/** + * Get next element. + * + * \param elem element. + * + * \return pointer to next element. + */ +#define next_elem(elem) ((elem)->next) + +/** + * Get previous element. + * + * \param elem element. + * + * \return pointer to previous element. + */ +#define prev_elem(elem) ((elem)->prev) + +/** + * Test whether element is at end of the list. + * + * \param list list. + * \param elem element. + * + * \return non-zero if element is at end of list, or zero otherwise. + */ +#define at_end(list, elem) ((elem) == (list)) + +/** + * Test if a list is empty. + * + * \param list list. + * + * \return non-zero if list empty, or zero otherwise. + */ +#define is_empty_list(list) ((list)->next == (list)) + +/** + * Walk through the elements of a list. + * + * \param ptr pointer to the current element. + * \param list list. + * + * \note It should be followed by a { } block or a single statement, as in a \c + * for loop. + */ +#define foreach(ptr, list) \ + for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) + +/** + * Walk through the elements of a list. + * + * Same as #foreach but lets you unlink the current value during a list + * traversal. Useful for freeing a list, element by element. + * + * \param ptr pointer to the current element. + * \param t temporary pointer. + * \param list list. + * + * \note It should be followed by a { } block or a single statement, as in a \c + * for loop. + */ +#define foreach_s(ptr, t, list) \ + for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) + +#endif diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c new file mode 100644 index 00000000000..a25b7b72a6b --- /dev/null +++ b/src/glsl/glcpp/pp.c @@ -0,0 +1,155 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include "glcpp.h" + +void +glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) +{ + parser->error = 1; + parser->info_log = talloc_asprintf_append(parser->info_log, + "%u:%u(%u): " + "preprocessor error: ", + locp->source, + locp->first_line, + locp->first_column); + va_list ap; + va_start(ap, fmt); + parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap); + va_end(ap); + parser->info_log = talloc_strdup_append(parser->info_log, "\n"); +} + +void +glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) +{ + parser->info_log = talloc_asprintf_append(parser->info_log, + "%u:%u(%u): " + "preprocessor warning: ", + locp->source, + locp->first_line, + locp->first_column); + va_list ap; + va_start(ap, fmt); + parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap); + va_end(ap); + parser->info_log = talloc_strdup_append(parser->info_log, "\n"); +} + +/* Searches backwards for '^ *#' from a given starting point. */ +static int +in_directive(const char *shader, const char *ptr) +{ + assert(ptr >= shader); + + /* Search backwards for '#'. If we find a \n first, it doesn't count */ + for (; ptr >= shader && *ptr != '#'; ptr--) { + if (*ptr == '\n') + return 0; + } + if (ptr >= shader) { + /* Found '#'...look for spaces preceded by a newline */ + for (ptr--; ptr >= shader && isblank(*ptr); ptr--); + // FIXME: I don't think the '\n' case can happen + if (ptr < shader || *ptr == '\n') + return 1; + } + return 0; +} + +/* Remove any line continuation characters in preprocessing directives. + * However, ignore any in GLSL code, as "There is no line continuation + * character" (1.30 page 9) in GLSL. + */ +static char * +remove_line_continuations(glcpp_parser_t *ctx, const char *shader) +{ + int in_continued_line = 0; + int extra_newlines = 0; + char *clean = talloc_strdup(ctx, ""); + const char *search_start = shader; + const char *newline; + while ((newline = strchr(search_start, '\n')) != NULL) { + const char *backslash = NULL; + /* Find the preceding '\', if it exists */ + if (newline[-1] == '\\') { + backslash = newline - 1; + } else if (newline[-1] == '\r' && newline[-2] == '\\') { + backslash = newline - 2; + } + /* Double backslashes don't count (the backslash is escaped) */ + if (backslash != NULL && backslash[-1] == '\\') { + backslash = NULL; + } + + if (backslash != NULL) { + /* We found a line continuation, but do we care? */ + if (!in_continued_line) { + if (in_directive(shader, backslash)) { + in_continued_line = 1; + extra_newlines = 0; + } + } + if (in_continued_line) { + /* Copy everything before the \ */ + clean = talloc_strndup_append(clean, shader, backslash - shader); + shader = newline + 1; + extra_newlines++; + } + } else if (in_continued_line) { + /* Copy everything up to and including the \n */ + clean = talloc_strndup_append(clean, shader, newline - shader + 1); + shader = newline + 1; + /* Output extra newlines to make line numbers match */ + for (; extra_newlines > 0; extra_newlines--) + clean = talloc_strdup_append(clean, "\n"); + in_continued_line = 0; + } + search_start = newline + 1; + } + clean = talloc_strdup_append(clean, shader); + return clean; +} + +extern int +preprocess(void *talloc_ctx, const char **shader, char **info_log) +{ + int errors; + glcpp_parser_t *parser = glcpp_parser_create (); + *shader = remove_line_continuations(parser, *shader); + + glcpp_lex_set_source_string (parser, *shader); + + glcpp_parser_parse (parser); + + *info_log = talloc_strdup_append(*info_log, parser->info_log); + + talloc_steal(talloc_ctx, parser->output); + *shader = parser->output; + + errors = parser->error; + glcpp_parser_destroy (parser); + return errors; +} diff --git a/src/glsl/glcpp/tests/000-content-with-spaces.c b/src/glsl/glcpp/tests/000-content-with-spaces.c new file mode 100644 index 00000000000..696cb3a74fc --- /dev/null +++ b/src/glsl/glcpp/tests/000-content-with-spaces.c @@ -0,0 +1 @@ +this is four tokens diff --git a/src/glsl/glcpp/tests/000-content-with-spaces.c.expected b/src/glsl/glcpp/tests/000-content-with-spaces.c.expected new file mode 100644 index 00000000000..83f7834d547 --- /dev/null +++ b/src/glsl/glcpp/tests/000-content-with-spaces.c.expected @@ -0,0 +1,2 @@ +this is four tokens + diff --git a/src/glsl/glcpp/tests/001-define.c b/src/glsl/glcpp/tests/001-define.c new file mode 100644 index 00000000000..cbf2fee0e75 --- /dev/null +++ b/src/glsl/glcpp/tests/001-define.c @@ -0,0 +1,2 @@ +#define foo 1 +foo diff --git a/src/glsl/glcpp/tests/001-define.c.expected b/src/glsl/glcpp/tests/001-define.c.expected new file mode 100644 index 00000000000..878fd15d6f8 --- /dev/null +++ b/src/glsl/glcpp/tests/001-define.c.expected @@ -0,0 +1,3 @@ + +1 + diff --git a/src/glsl/glcpp/tests/002-define-chain.c b/src/glsl/glcpp/tests/002-define-chain.c new file mode 100644 index 00000000000..87d75c68751 --- /dev/null +++ b/src/glsl/glcpp/tests/002-define-chain.c @@ -0,0 +1,3 @@ +#define foo 1 +#define bar foo +bar diff --git a/src/glsl/glcpp/tests/002-define-chain.c.expected b/src/glsl/glcpp/tests/002-define-chain.c.expected new file mode 100644 index 00000000000..43d484d7131 --- /dev/null +++ b/src/glsl/glcpp/tests/002-define-chain.c.expected @@ -0,0 +1,4 @@ + + +1 + diff --git a/src/glsl/glcpp/tests/003-define-chain-reverse.c b/src/glsl/glcpp/tests/003-define-chain-reverse.c new file mode 100644 index 00000000000..a18b724eca0 --- /dev/null +++ b/src/glsl/glcpp/tests/003-define-chain-reverse.c @@ -0,0 +1,3 @@ +#define bar foo +#define foo 1 +bar diff --git a/src/glsl/glcpp/tests/003-define-chain-reverse.c.expected b/src/glsl/glcpp/tests/003-define-chain-reverse.c.expected new file mode 100644 index 00000000000..43d484d7131 --- /dev/null +++ b/src/glsl/glcpp/tests/003-define-chain-reverse.c.expected @@ -0,0 +1,4 @@ + + +1 + diff --git a/src/glsl/glcpp/tests/004-define-recursive.c b/src/glsl/glcpp/tests/004-define-recursive.c new file mode 100644 index 00000000000..2ac56ea3dcf --- /dev/null +++ b/src/glsl/glcpp/tests/004-define-recursive.c @@ -0,0 +1,6 @@ +#define foo bar +#define bar baz +#define baz foo +foo +bar +baz diff --git a/src/glsl/glcpp/tests/004-define-recursive.c.expected b/src/glsl/glcpp/tests/004-define-recursive.c.expected new file mode 100644 index 00000000000..4d2698b7a7f --- /dev/null +++ b/src/glsl/glcpp/tests/004-define-recursive.c.expected @@ -0,0 +1,7 @@ + + + +foo +bar +baz + diff --git a/src/glsl/glcpp/tests/005-define-composite-chain.c b/src/glsl/glcpp/tests/005-define-composite-chain.c new file mode 100644 index 00000000000..f5521df968d --- /dev/null +++ b/src/glsl/glcpp/tests/005-define-composite-chain.c @@ -0,0 +1,3 @@ +#define foo 1 +#define bar a foo +bar diff --git a/src/glsl/glcpp/tests/005-define-composite-chain.c.expected b/src/glsl/glcpp/tests/005-define-composite-chain.c.expected new file mode 100644 index 00000000000..c67358f4f69 --- /dev/null +++ b/src/glsl/glcpp/tests/005-define-composite-chain.c.expected @@ -0,0 +1,4 @@ + + +a 1 + diff --git a/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c b/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c new file mode 100644 index 00000000000..4bb91a1221a --- /dev/null +++ b/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c @@ -0,0 +1,3 @@ +#define bar a foo +#define foo 1 +bar diff --git a/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected b/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected new file mode 100644 index 00000000000..c67358f4f69 --- /dev/null +++ b/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected @@ -0,0 +1,4 @@ + + +a 1 + diff --git a/src/glsl/glcpp/tests/007-define-composite-recursive.c b/src/glsl/glcpp/tests/007-define-composite-recursive.c new file mode 100644 index 00000000000..5784565bdf3 --- /dev/null +++ b/src/glsl/glcpp/tests/007-define-composite-recursive.c @@ -0,0 +1,6 @@ +#define foo a bar +#define bar b baz +#define baz c foo +foo +bar +baz diff --git a/src/glsl/glcpp/tests/007-define-composite-recursive.c.expected b/src/glsl/glcpp/tests/007-define-composite-recursive.c.expected new file mode 100644 index 00000000000..30fe4dc1f62 --- /dev/null +++ b/src/glsl/glcpp/tests/007-define-composite-recursive.c.expected @@ -0,0 +1,7 @@ + + + +a b c foo +b c a bar +c a b baz + diff --git a/src/glsl/glcpp/tests/008-define-empty.c b/src/glsl/glcpp/tests/008-define-empty.c new file mode 100644 index 00000000000..b1bd17ec215 --- /dev/null +++ b/src/glsl/glcpp/tests/008-define-empty.c @@ -0,0 +1,2 @@ +#define foo +foo diff --git a/src/glsl/glcpp/tests/008-define-empty.c.expected b/src/glsl/glcpp/tests/008-define-empty.c.expected new file mode 100644 index 00000000000..b28b04f6431 --- /dev/null +++ b/src/glsl/glcpp/tests/008-define-empty.c.expected @@ -0,0 +1,3 @@ + + + diff --git a/src/glsl/glcpp/tests/009-undef.c b/src/glsl/glcpp/tests/009-undef.c new file mode 100644 index 00000000000..3fc1fb44243 --- /dev/null +++ b/src/glsl/glcpp/tests/009-undef.c @@ -0,0 +1,4 @@ +#define foo 1 +foo +#undef foo +foo diff --git a/src/glsl/glcpp/tests/009-undef.c.expected b/src/glsl/glcpp/tests/009-undef.c.expected new file mode 100644 index 00000000000..03a7061af03 --- /dev/null +++ b/src/glsl/glcpp/tests/009-undef.c.expected @@ -0,0 +1,5 @@ + +1 + +foo + diff --git a/src/glsl/glcpp/tests/010-undef-re-define.c b/src/glsl/glcpp/tests/010-undef-re-define.c new file mode 100644 index 00000000000..32ff73798b1 --- /dev/null +++ b/src/glsl/glcpp/tests/010-undef-re-define.c @@ -0,0 +1,6 @@ +#define foo 1 +foo +#undef foo +foo +#define foo 2 +foo diff --git a/src/glsl/glcpp/tests/010-undef-re-define.c.expected b/src/glsl/glcpp/tests/010-undef-re-define.c.expected new file mode 100644 index 00000000000..f4f7efdc2bf --- /dev/null +++ b/src/glsl/glcpp/tests/010-undef-re-define.c.expected @@ -0,0 +1,7 @@ + +1 + +foo + +2 + diff --git a/src/glsl/glcpp/tests/011-define-func-empty.c b/src/glsl/glcpp/tests/011-define-func-empty.c new file mode 100644 index 00000000000..d9ce13c2284 --- /dev/null +++ b/src/glsl/glcpp/tests/011-define-func-empty.c @@ -0,0 +1,2 @@ +#define foo() +foo() diff --git a/src/glsl/glcpp/tests/011-define-func-empty.c.expected b/src/glsl/glcpp/tests/011-define-func-empty.c.expected new file mode 100644 index 00000000000..b28b04f6431 --- /dev/null +++ b/src/glsl/glcpp/tests/011-define-func-empty.c.expected @@ -0,0 +1,3 @@ + + + diff --git a/src/glsl/glcpp/tests/012-define-func-no-args.c b/src/glsl/glcpp/tests/012-define-func-no-args.c new file mode 100644 index 00000000000..c2bb730b115 --- /dev/null +++ b/src/glsl/glcpp/tests/012-define-func-no-args.c @@ -0,0 +1,2 @@ +#define foo() bar +foo() diff --git a/src/glsl/glcpp/tests/012-define-func-no-args.c.expected b/src/glsl/glcpp/tests/012-define-func-no-args.c.expected new file mode 100644 index 00000000000..03537672974 --- /dev/null +++ b/src/glsl/glcpp/tests/012-define-func-no-args.c.expected @@ -0,0 +1,3 @@ + +bar + diff --git a/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c b/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c new file mode 100644 index 00000000000..f78fb8b118a --- /dev/null +++ b/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c @@ -0,0 +1,2 @@ +#define foo(x) 1 +foo(bar) diff --git a/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected b/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected new file mode 100644 index 00000000000..878fd15d6f8 --- /dev/null +++ b/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected @@ -0,0 +1,3 @@ + +1 + diff --git a/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c b/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c new file mode 100644 index 00000000000..11feb2624b7 --- /dev/null +++ b/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c @@ -0,0 +1,2 @@ +#define foo(x,y) 1 +foo(bar,baz) diff --git a/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected b/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected new file mode 100644 index 00000000000..878fd15d6f8 --- /dev/null +++ b/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected @@ -0,0 +1,3 @@ + +1 + diff --git a/src/glsl/glcpp/tests/015-define-object-with-parens.c b/src/glsl/glcpp/tests/015-define-object-with-parens.c new file mode 100644 index 00000000000..558da9c617b --- /dev/null +++ b/src/glsl/glcpp/tests/015-define-object-with-parens.c @@ -0,0 +1,4 @@ +#define foo ()1 +foo() +#define bar ()2 +bar() diff --git a/src/glsl/glcpp/tests/015-define-object-with-parens.c.expected b/src/glsl/glcpp/tests/015-define-object-with-parens.c.expected new file mode 100644 index 00000000000..d6f8cb9dc61 --- /dev/null +++ b/src/glsl/glcpp/tests/015-define-object-with-parens.c.expected @@ -0,0 +1,5 @@ + +()1() + +()2() + diff --git a/src/glsl/glcpp/tests/016-define-func-1-arg.c b/src/glsl/glcpp/tests/016-define-func-1-arg.c new file mode 100644 index 00000000000..a2e2404c7c1 --- /dev/null +++ b/src/glsl/glcpp/tests/016-define-func-1-arg.c @@ -0,0 +1,2 @@ +#define foo(x) ((x)+1) +foo(bar) diff --git a/src/glsl/glcpp/tests/016-define-func-1-arg.c.expected b/src/glsl/glcpp/tests/016-define-func-1-arg.c.expected new file mode 100644 index 00000000000..7f1828a3c61 --- /dev/null +++ b/src/glsl/glcpp/tests/016-define-func-1-arg.c.expected @@ -0,0 +1,3 @@ + +((bar)+1) + diff --git a/src/glsl/glcpp/tests/017-define-func-2-args.c b/src/glsl/glcpp/tests/017-define-func-2-args.c new file mode 100644 index 00000000000..c7253835278 --- /dev/null +++ b/src/glsl/glcpp/tests/017-define-func-2-args.c @@ -0,0 +1,2 @@ +#define foo(x,y) ((x)*(y)) +foo(bar,baz) diff --git a/src/glsl/glcpp/tests/017-define-func-2-args.c.expected b/src/glsl/glcpp/tests/017-define-func-2-args.c.expected new file mode 100644 index 00000000000..9f341dac00a --- /dev/null +++ b/src/glsl/glcpp/tests/017-define-func-2-args.c.expected @@ -0,0 +1,3 @@ + +((bar)*(baz)) + diff --git a/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c b/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c new file mode 100644 index 00000000000..668130b8f9b --- /dev/null +++ b/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c @@ -0,0 +1,3 @@ +#define x 0 +#define foo(x) x +foo(1) diff --git a/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected b/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected new file mode 100644 index 00000000000..43d484d7131 --- /dev/null +++ b/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected @@ -0,0 +1,4 @@ + + +1 + diff --git a/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c b/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c new file mode 100644 index 00000000000..c4e62b25508 --- /dev/null +++ b/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c @@ -0,0 +1,2 @@ +#define foo(x) (x) +foo(this is more than one word) diff --git a/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected b/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected new file mode 100644 index 00000000000..4314fc88d83 --- /dev/null +++ b/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected @@ -0,0 +1,3 @@ + +(this is more than one word) + diff --git a/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c b/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c new file mode 100644 index 00000000000..3049ad15465 --- /dev/null +++ b/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c @@ -0,0 +1,2 @@ +#define foo(x,y) x,two fish,red fish,y +foo(one fish, blue fish) diff --git a/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected b/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected new file mode 100644 index 00000000000..5648e4fb9d4 --- /dev/null +++ b/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected @@ -0,0 +1,3 @@ + +one fish,two fish,red fish,blue fish + diff --git a/src/glsl/glcpp/tests/021-define-func-compose.c b/src/glsl/glcpp/tests/021-define-func-compose.c new file mode 100644 index 00000000000..21ddd0e65f9 --- /dev/null +++ b/src/glsl/glcpp/tests/021-define-func-compose.c @@ -0,0 +1,3 @@ +#define bar(x) (1+(x)) +#define foo(y) (2*(y)) +foo(bar(3)) diff --git a/src/glsl/glcpp/tests/021-define-func-compose.c.expected b/src/glsl/glcpp/tests/021-define-func-compose.c.expected new file mode 100644 index 00000000000..1d62105de4c --- /dev/null +++ b/src/glsl/glcpp/tests/021-define-func-compose.c.expected @@ -0,0 +1,4 @@ + + +(2*((1+(3)))) + diff --git a/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c b/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c new file mode 100644 index 00000000000..c20d73a4a28 --- /dev/null +++ b/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c @@ -0,0 +1,2 @@ +#define foo(x) (x) +foo(argument(including parens)for the win) diff --git a/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected b/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected new file mode 100644 index 00000000000..66c16581758 --- /dev/null +++ b/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected @@ -0,0 +1,3 @@ + +(argument(including parens)for the win) + diff --git a/src/glsl/glcpp/tests/023-define-extra-whitespace.c b/src/glsl/glcpp/tests/023-define-extra-whitespace.c new file mode 100644 index 00000000000..7ebfed6516c --- /dev/null +++ b/src/glsl/glcpp/tests/023-define-extra-whitespace.c @@ -0,0 +1,8 @@ +#define noargs() 1 +# define onearg(foo) foo + # define twoargs( x , y ) x y + # define threeargs( a , b , c ) a b c +noargs ( ) +onearg ( 2 ) +twoargs ( 3 , 4 ) +threeargs ( 5 , 6 , 7 ) diff --git a/src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected b/src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected new file mode 100644 index 00000000000..573829c2d69 --- /dev/null +++ b/src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected @@ -0,0 +1,9 @@ + + + + +1 +2 +3 4 +5 6 7 + diff --git a/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c b/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c new file mode 100644 index 00000000000..e788adce30c --- /dev/null +++ b/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c @@ -0,0 +1,3 @@ +#define foo foo +#define bar foo +bar diff --git a/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected b/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected new file mode 100644 index 00000000000..ad955fce6ec --- /dev/null +++ b/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected @@ -0,0 +1,4 @@ + + +foo + diff --git a/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c b/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c new file mode 100644 index 00000000000..b433671d1bf --- /dev/null +++ b/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo bar diff --git a/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected b/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected new file mode 100644 index 00000000000..960f44511a9 --- /dev/null +++ b/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected @@ -0,0 +1,3 @@ + +foo bar + diff --git a/src/glsl/glcpp/tests/026-define-func-extra-newlines.c b/src/glsl/glcpp/tests/026-define-func-extra-newlines.c new file mode 100644 index 00000000000..0d837405309 --- /dev/null +++ b/src/glsl/glcpp/tests/026-define-func-extra-newlines.c @@ -0,0 +1,6 @@ +#define foo(a) bar + +foo +( +1 +) diff --git a/src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected b/src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected new file mode 100644 index 00000000000..f0888f21b94 --- /dev/null +++ b/src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected @@ -0,0 +1,4 @@ + + +bar + diff --git a/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c b/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c new file mode 100644 index 00000000000..5ccb52caba5 --- /dev/null +++ b/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c @@ -0,0 +1,3 @@ +#define failure() success +#define foo failure() +foo diff --git a/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected b/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected new file mode 100644 index 00000000000..aef762e1e69 --- /dev/null +++ b/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected @@ -0,0 +1,4 @@ + + +success + diff --git a/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c b/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c new file mode 100644 index 00000000000..44962a71876 --- /dev/null +++ b/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c @@ -0,0 +1,3 @@ +#define success() failure +#define foo success +foo diff --git a/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected b/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected new file mode 100644 index 00000000000..aef762e1e69 --- /dev/null +++ b/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected @@ -0,0 +1,4 @@ + + +success + diff --git a/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c b/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c new file mode 100644 index 00000000000..261f7d28fc2 --- /dev/null +++ b/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c @@ -0,0 +1,3 @@ +#define bar(failure) failure +#define foo bar(success) +foo diff --git a/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected b/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected new file mode 100644 index 00000000000..aef762e1e69 --- /dev/null +++ b/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected @@ -0,0 +1,4 @@ + + +success + diff --git a/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c b/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c new file mode 100644 index 00000000000..e56fbefd62d --- /dev/null +++ b/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c @@ -0,0 +1,4 @@ +#define baz(failure) failure +#define bar(failure) failure +#define foo bar(baz(success)) +foo diff --git a/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected b/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected new file mode 100644 index 00000000000..729bdd15f80 --- /dev/null +++ b/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected @@ -0,0 +1,5 @@ + + + +success + diff --git a/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c b/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c new file mode 100644 index 00000000000..3f4c8744dff --- /dev/null +++ b/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c @@ -0,0 +1,4 @@ +#define baz(failure) failure +#define bar(failure) failure +#define foo() bar(baz(success)) +foo() diff --git a/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected b/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected new file mode 100644 index 00000000000..729bdd15f80 --- /dev/null +++ b/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected @@ -0,0 +1,5 @@ + + + +success + diff --git a/src/glsl/glcpp/tests/032-define-func-self-recurse.c b/src/glsl/glcpp/tests/032-define-func-self-recurse.c new file mode 100644 index 00000000000..b3ac70f499c --- /dev/null +++ b/src/glsl/glcpp/tests/032-define-func-self-recurse.c @@ -0,0 +1,2 @@ +#define foo(a) foo(2*(a)) +foo(3) diff --git a/src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected b/src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected new file mode 100644 index 00000000000..541d44db7ab --- /dev/null +++ b/src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected @@ -0,0 +1,3 @@ + +foo(2*(3)) + diff --git a/src/glsl/glcpp/tests/033-define-func-self-compose.c b/src/glsl/glcpp/tests/033-define-func-self-compose.c new file mode 100644 index 00000000000..f65e48286cf --- /dev/null +++ b/src/glsl/glcpp/tests/033-define-func-self-compose.c @@ -0,0 +1,2 @@ +#define foo(a) foo(2*(a)) +foo(foo(3)) diff --git a/src/glsl/glcpp/tests/033-define-func-self-compose.c.expected b/src/glsl/glcpp/tests/033-define-func-self-compose.c.expected new file mode 100644 index 00000000000..6ea6905d80b --- /dev/null +++ b/src/glsl/glcpp/tests/033-define-func-self-compose.c.expected @@ -0,0 +1,3 @@ + +foo(2*(foo(2*(3)))) + diff --git a/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c b/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c new file mode 100644 index 00000000000..209a5f7e07c --- /dev/null +++ b/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo(foo) diff --git a/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected b/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected new file mode 100644 index 00000000000..24823b1b673 --- /dev/null +++ b/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected @@ -0,0 +1,3 @@ + +foo + diff --git a/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c b/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c new file mode 100644 index 00000000000..c307fbe830f --- /dev/null +++ b/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c @@ -0,0 +1,2 @@ +#define foo(bar) bar +foo(1+foo) diff --git a/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected b/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected new file mode 100644 index 00000000000..137a9ea2db8 --- /dev/null +++ b/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected @@ -0,0 +1,3 @@ + +1+foo + diff --git a/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c b/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c new file mode 100644 index 00000000000..b21ff336738 --- /dev/null +++ b/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c @@ -0,0 +1,3 @@ +#define bar success +#define foo(x) x +foo(more bar) diff --git a/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected b/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected new file mode 100644 index 00000000000..ff6360bfe4e --- /dev/null +++ b/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected @@ -0,0 +1,4 @@ + + +more success + diff --git a/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c b/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c new file mode 100644 index 00000000000..b3a2f37f1b9 --- /dev/null +++ b/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c @@ -0,0 +1,3 @@ +#define expand(x) expand(x once) +#define foo(x) x +foo(expand(just)) diff --git a/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected b/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected new file mode 100644 index 00000000000..cbadee848a5 --- /dev/null +++ b/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected @@ -0,0 +1,4 @@ + + +expand(just once) + diff --git a/src/glsl/glcpp/tests/038-func-arg-with-commas.c b/src/glsl/glcpp/tests/038-func-arg-with-commas.c new file mode 100644 index 00000000000..1407c7d6e3c --- /dev/null +++ b/src/glsl/glcpp/tests/038-func-arg-with-commas.c @@ -0,0 +1,2 @@ +#define foo(x) success +foo(argument (with,embedded , commas) -- tricky) diff --git a/src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected b/src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected new file mode 100644 index 00000000000..5a28fb3b66c --- /dev/null +++ b/src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected @@ -0,0 +1,3 @@ + +success + diff --git a/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c b/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c new file mode 100644 index 00000000000..0f7fe632b56 --- /dev/null +++ b/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c @@ -0,0 +1,3 @@ +#define foo(a) (a) +#define bar two,words +foo(bar) diff --git a/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected b/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected new file mode 100644 index 00000000000..b73869d0238 --- /dev/null +++ b/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected @@ -0,0 +1,4 @@ + + +(two,words) + diff --git a/src/glsl/glcpp/tests/040-token-pasting.c b/src/glsl/glcpp/tests/040-token-pasting.c new file mode 100644 index 00000000000..caab3ba7368 --- /dev/null +++ b/src/glsl/glcpp/tests/040-token-pasting.c @@ -0,0 +1,2 @@ +#define paste(a,b) a ## b +paste(one , token) diff --git a/src/glsl/glcpp/tests/040-token-pasting.c.expected b/src/glsl/glcpp/tests/040-token-pasting.c.expected new file mode 100644 index 00000000000..36f66992539 --- /dev/null +++ b/src/glsl/glcpp/tests/040-token-pasting.c.expected @@ -0,0 +1,3 @@ + +onetoken + diff --git a/src/glsl/glcpp/tests/041-if-0.c b/src/glsl/glcpp/tests/041-if-0.c new file mode 100644 index 00000000000..2cab677d3e8 --- /dev/null +++ b/src/glsl/glcpp/tests/041-if-0.c @@ -0,0 +1,5 @@ +success_1 +#if 0 +failure +#endif +success_2 diff --git a/src/glsl/glcpp/tests/041-if-0.c.expected b/src/glsl/glcpp/tests/041-if-0.c.expected new file mode 100644 index 00000000000..3800024c6ff --- /dev/null +++ b/src/glsl/glcpp/tests/041-if-0.c.expected @@ -0,0 +1,6 @@ +success_1 + + + +success_2 + diff --git a/src/glsl/glcpp/tests/042-if-1.c b/src/glsl/glcpp/tests/042-if-1.c new file mode 100644 index 00000000000..874a25cf41b --- /dev/null +++ b/src/glsl/glcpp/tests/042-if-1.c @@ -0,0 +1,5 @@ +success_1 +#if 1 +success_2 +#endif +success_3 diff --git a/src/glsl/glcpp/tests/042-if-1.c.expected b/src/glsl/glcpp/tests/042-if-1.c.expected new file mode 100644 index 00000000000..e591044adbb --- /dev/null +++ b/src/glsl/glcpp/tests/042-if-1.c.expected @@ -0,0 +1,6 @@ +success_1 + +success_2 + +success_3 + diff --git a/src/glsl/glcpp/tests/043-if-0-else.c b/src/glsl/glcpp/tests/043-if-0-else.c new file mode 100644 index 00000000000..323351f9dbf --- /dev/null +++ b/src/glsl/glcpp/tests/043-if-0-else.c @@ -0,0 +1,7 @@ +success_1 +#if 0 +failure +#else +success_2 +#endif +success_3 diff --git a/src/glsl/glcpp/tests/043-if-0-else.c.expected b/src/glsl/glcpp/tests/043-if-0-else.c.expected new file mode 100644 index 00000000000..ee9e677096e --- /dev/null +++ b/src/glsl/glcpp/tests/043-if-0-else.c.expected @@ -0,0 +1,8 @@ +success_1 + + + +success_2 + +success_3 + diff --git a/src/glsl/glcpp/tests/044-if-1-else.c b/src/glsl/glcpp/tests/044-if-1-else.c new file mode 100644 index 00000000000..28dfc25c6f0 --- /dev/null +++ b/src/glsl/glcpp/tests/044-if-1-else.c @@ -0,0 +1,7 @@ +success_1 +#if 1 +success_2 +#else +failure +#endif +success_3 diff --git a/src/glsl/glcpp/tests/044-if-1-else.c.expected b/src/glsl/glcpp/tests/044-if-1-else.c.expected new file mode 100644 index 00000000000..129f5c8542e --- /dev/null +++ b/src/glsl/glcpp/tests/044-if-1-else.c.expected @@ -0,0 +1,8 @@ +success_1 + +success_2 + + + +success_3 + diff --git a/src/glsl/glcpp/tests/045-if-0-elif.c b/src/glsl/glcpp/tests/045-if-0-elif.c new file mode 100644 index 00000000000..e50f686d461 --- /dev/null +++ b/src/glsl/glcpp/tests/045-if-0-elif.c @@ -0,0 +1,11 @@ +success_1 +#if 0 +failure_1 +#elif 0 +failure_2 +#elif 1 +success_3 +#elif 1 +failure_3 +#endif +success_4 diff --git a/src/glsl/glcpp/tests/045-if-0-elif.c.expected b/src/glsl/glcpp/tests/045-if-0-elif.c.expected new file mode 100644 index 00000000000..97a11b4472e --- /dev/null +++ b/src/glsl/glcpp/tests/045-if-0-elif.c.expected @@ -0,0 +1,12 @@ +success_1 + + + + + +success_3 + + + +success_4 + diff --git a/src/glsl/glcpp/tests/046-if-1-elsif.c b/src/glsl/glcpp/tests/046-if-1-elsif.c new file mode 100644 index 00000000000..130515a01ea --- /dev/null +++ b/src/glsl/glcpp/tests/046-if-1-elsif.c @@ -0,0 +1,11 @@ +success_1 +#if 1 +success_2 +#elif 0 +failure_1 +#elif 1 +failure_2 +#elif 0 +failure_3 +#endif +success_3 diff --git a/src/glsl/glcpp/tests/046-if-1-elsif.c.expected b/src/glsl/glcpp/tests/046-if-1-elsif.c.expected new file mode 100644 index 00000000000..b928b917e3d --- /dev/null +++ b/src/glsl/glcpp/tests/046-if-1-elsif.c.expected @@ -0,0 +1,12 @@ +success_1 + +success_2 + + + + + + + +success_3 + diff --git a/src/glsl/glcpp/tests/047-if-elif-else.c b/src/glsl/glcpp/tests/047-if-elif-else.c new file mode 100644 index 00000000000..e8f0838a9ed --- /dev/null +++ b/src/glsl/glcpp/tests/047-if-elif-else.c @@ -0,0 +1,11 @@ +success_1 +#if 0 +failure_1 +#elif 0 +failure_2 +#elif 0 +failure_3 +#else +success_2 +#endif +success_3 diff --git a/src/glsl/glcpp/tests/047-if-elif-else.c.expected b/src/glsl/glcpp/tests/047-if-elif-else.c.expected new file mode 100644 index 00000000000..e5b53a3fa59 --- /dev/null +++ b/src/glsl/glcpp/tests/047-if-elif-else.c.expected @@ -0,0 +1,12 @@ +success_1 + + + + + + + +success_2 + +success_3 + diff --git a/src/glsl/glcpp/tests/048-if-nested.c b/src/glsl/glcpp/tests/048-if-nested.c new file mode 100644 index 00000000000..fc4679c3be4 --- /dev/null +++ b/src/glsl/glcpp/tests/048-if-nested.c @@ -0,0 +1,11 @@ +success_1 +#if 0 +failure_1 +#if 1 +failure_2 +#else +failure_3 +#endif +failure_4 +#endif +success_2 diff --git a/src/glsl/glcpp/tests/048-if-nested.c.expected b/src/glsl/glcpp/tests/048-if-nested.c.expected new file mode 100644 index 00000000000..c61fd0b3159 --- /dev/null +++ b/src/glsl/glcpp/tests/048-if-nested.c.expected @@ -0,0 +1,12 @@ +success_1 + + + + + + + + + +success_2 + diff --git a/src/glsl/glcpp/tests/049-if-expression-precedence.c b/src/glsl/glcpp/tests/049-if-expression-precedence.c new file mode 100644 index 00000000000..833ea03882a --- /dev/null +++ b/src/glsl/glcpp/tests/049-if-expression-precedence.c @@ -0,0 +1,5 @@ +#if 1 + 2 * 3 + - (25 % 17 - + 1) +failure with operator precedence +#else +success +#endif diff --git a/src/glsl/glcpp/tests/049-if-expression-precedence.c.expected b/src/glsl/glcpp/tests/049-if-expression-precedence.c.expected new file mode 100644 index 00000000000..569debb0bb6 --- /dev/null +++ b/src/glsl/glcpp/tests/049-if-expression-precedence.c.expected @@ -0,0 +1,6 @@ + + + +success + + diff --git a/src/glsl/glcpp/tests/050-if-defined.c b/src/glsl/glcpp/tests/050-if-defined.c new file mode 100644 index 00000000000..34f0f95140e --- /dev/null +++ b/src/glsl/glcpp/tests/050-if-defined.c @@ -0,0 +1,17 @@ +#if defined foo +failure_1 +#else +success_1 +#endif +#define foo +#if defined foo +success_2 +#else +failure_2 +#endif +#undef foo +#if defined foo +failure_3 +#else +success_3 +#endif diff --git a/src/glsl/glcpp/tests/050-if-defined.c.expected b/src/glsl/glcpp/tests/050-if-defined.c.expected new file mode 100644 index 00000000000..3f01955ee40 --- /dev/null +++ b/src/glsl/glcpp/tests/050-if-defined.c.expected @@ -0,0 +1,18 @@ + + + +success_1 + + + +success_2 + + + + + + + +success_3 + + diff --git a/src/glsl/glcpp/tests/051-if-relational.c b/src/glsl/glcpp/tests/051-if-relational.c new file mode 100644 index 00000000000..c3db488e0de --- /dev/null +++ b/src/glsl/glcpp/tests/051-if-relational.c @@ -0,0 +1,35 @@ +#if 3 < 2 +failure_1 +#else +success_1 +#endif + +#if 3 >= 2 +success_2 +#else +failure_2 +#endif + +#if 2 + 3 <= 5 +success_3 +#else +failure_3 +#endif + +#if 3 - 2 == 1 +success_3 +#else +failure_3 +#endif + +#if 1 > 3 +failure_4 +#else +success_4 +#endif + +#if 1 != 5 +success_5 +#else +failure_5 +#endif diff --git a/src/glsl/glcpp/tests/051-if-relational.c.expected b/src/glsl/glcpp/tests/051-if-relational.c.expected new file mode 100644 index 00000000000..d2b76f14576 --- /dev/null +++ b/src/glsl/glcpp/tests/051-if-relational.c.expected @@ -0,0 +1,36 @@ + + + +success_1 + + + +success_2 + + + + + +success_3 + + + + + +success_3 + + + + + + + +success_4 + + + +success_5 + + + + diff --git a/src/glsl/glcpp/tests/052-if-bitwise.c b/src/glsl/glcpp/tests/052-if-bitwise.c new file mode 100644 index 00000000000..2d8e45eb61e --- /dev/null +++ b/src/glsl/glcpp/tests/052-if-bitwise.c @@ -0,0 +1,20 @@ +#if (0xaaaaaaaa | 0x55555555) != 4294967295 +failure_1 +#else +success_1 +#endif +#if (0x12345678 ^ 0xfdecba98) == 4023971040 +success_2 +#else +failure_2 +#endif +#if (~ 0xdeadbeef) != -3735928560 +failure_3 +#else +success_3 +#endif +#if (0667 & 0733) == 403 +success_4 +#else +failure_4 +#endif diff --git a/src/glsl/glcpp/tests/052-if-bitwise.c.expected b/src/glsl/glcpp/tests/052-if-bitwise.c.expected new file mode 100644 index 00000000000..bb5d92e8d92 --- /dev/null +++ b/src/glsl/glcpp/tests/052-if-bitwise.c.expected @@ -0,0 +1,21 @@ + + + +success_1 + + +success_2 + + + + + + +success_3 + + +success_4 + + + + diff --git a/src/glsl/glcpp/tests/053-if-divide-and-shift.c b/src/glsl/glcpp/tests/053-if-divide-and-shift.c new file mode 100644 index 00000000000..d24c54a88d1 --- /dev/null +++ b/src/glsl/glcpp/tests/053-if-divide-and-shift.c @@ -0,0 +1,15 @@ +#if (15 / 2) != 7 +failure_1 +#else +success_1 +#endif +#if (1 << 12) == 4096 +success_2 +#else +failure_2 +#endif +#if (31762 >> 8) != 124 +failure_3 +#else +success_3 +#endif diff --git a/src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected b/src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected new file mode 100644 index 00000000000..f97e93673cc --- /dev/null +++ b/src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected @@ -0,0 +1,16 @@ + + + +success_1 + + +success_2 + + + + + + +success_3 + + diff --git a/src/glsl/glcpp/tests/054-if-with-macros.c b/src/glsl/glcpp/tests/054-if-with-macros.c new file mode 100644 index 00000000000..3da79a0d96e --- /dev/null +++ b/src/glsl/glcpp/tests/054-if-with-macros.c @@ -0,0 +1,34 @@ +#define one 1 +#define two 2 +#define three 3 +#define five 5 +#if five < two +failure_1 +#else +success_1 +#endif +#if three >= two +success_2 +#else +failure_2 +#endif +#if two + three <= five +success_3 +#else +failure_3 +#endif +#if five - two == three +success_4 +#else +failure_4 +#endif +#if one > three +failure_5 +#else +success_5 +#endif +#if one != five +success_6 +#else +failure_6 +#endif diff --git a/src/glsl/glcpp/tests/054-if-with-macros.c.expected b/src/glsl/glcpp/tests/054-if-with-macros.c.expected new file mode 100644 index 00000000000..27ea4969628 --- /dev/null +++ b/src/glsl/glcpp/tests/054-if-with-macros.c.expected @@ -0,0 +1,35 @@ + + + + + + + +success_1 + + +success_2 + + + + +success_3 + + + + +success_4 + + + + + + +success_5 + + +success_6 + + + + diff --git a/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c b/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c new file mode 100644 index 00000000000..00f2c2346d6 --- /dev/null +++ b/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c @@ -0,0 +1,3 @@ +#define failure() success +#define foo failure +foo() diff --git a/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected b/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected new file mode 100644 index 00000000000..aef762e1e69 --- /dev/null +++ b/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected @@ -0,0 +1,4 @@ + + +success + diff --git a/src/glsl/glcpp/tests/056-macro-argument-with-comma.c b/src/glsl/glcpp/tests/056-macro-argument-with-comma.c new file mode 100644 index 00000000000..58701d1f25b --- /dev/null +++ b/src/glsl/glcpp/tests/056-macro-argument-with-comma.c @@ -0,0 +1,4 @@ +#define bar with,embedded,commas +#define function(x) success +#define foo function +foo(bar) diff --git a/src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected b/src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected new file mode 100644 index 00000000000..729bdd15f80 --- /dev/null +++ b/src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected @@ -0,0 +1,5 @@ + + + +success + diff --git a/src/glsl/glcpp/tests/057-empty-arguments.c b/src/glsl/glcpp/tests/057-empty-arguments.c new file mode 100644 index 00000000000..6140232865d --- /dev/null +++ b/src/glsl/glcpp/tests/057-empty-arguments.c @@ -0,0 +1,6 @@ +#define zero() success +zero() +#define one(x) success +one() +#define two(x,y) success +two(,) diff --git a/src/glsl/glcpp/tests/057-empty-arguments.c.expected b/src/glsl/glcpp/tests/057-empty-arguments.c.expected new file mode 100644 index 00000000000..4e3aad52173 --- /dev/null +++ b/src/glsl/glcpp/tests/057-empty-arguments.c.expected @@ -0,0 +1,7 @@ + +success + +success + +success + diff --git a/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c b/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c new file mode 100644 index 00000000000..8ac260c76b6 --- /dev/null +++ b/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c @@ -0,0 +1,5 @@ +#define paste(x,y) x ## y +paste(a,b) +paste(a,) +paste(,b) +paste(,) diff --git a/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected b/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected new file mode 100644 index 00000000000..a1c34e5c1f8 --- /dev/null +++ b/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected @@ -0,0 +1,6 @@ + +ab +a +b + + diff --git a/src/glsl/glcpp/tests/059-token-pasting-integer.c b/src/glsl/glcpp/tests/059-token-pasting-integer.c new file mode 100644 index 00000000000..37b895a4237 --- /dev/null +++ b/src/glsl/glcpp/tests/059-token-pasting-integer.c @@ -0,0 +1,4 @@ +#define paste(x,y) x ## y +paste(1,2) +paste(1,000) +paste(identifier,2) diff --git a/src/glsl/glcpp/tests/059-token-pasting-integer.c.expected b/src/glsl/glcpp/tests/059-token-pasting-integer.c.expected new file mode 100644 index 00000000000..f1a2cd21c13 --- /dev/null +++ b/src/glsl/glcpp/tests/059-token-pasting-integer.c.expected @@ -0,0 +1,5 @@ + +12 +1000 +identifier2 + diff --git a/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c b/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c new file mode 100644 index 00000000000..ed80ea879ce --- /dev/null +++ b/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c @@ -0,0 +1,3 @@ +#define double(a) a*2 +#define foo double( +foo 5) diff --git a/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected b/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected new file mode 100644 index 00000000000..c1f0d24a144 --- /dev/null +++ b/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected @@ -0,0 +1,4 @@ + + +5*2 + diff --git a/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c b/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c new file mode 100644 index 00000000000..6dbfd1f62d1 --- /dev/null +++ b/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c @@ -0,0 +1,5 @@ +#define foo(x) success +#define bar foo +#define baz bar +#define joe baz +joe (failure) diff --git a/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected b/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected new file mode 100644 index 00000000000..111f7d10634 --- /dev/null +++ b/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected @@ -0,0 +1,6 @@ + + + + +success + diff --git a/src/glsl/glcpp/tests/062-if-0-skips-garbage.c b/src/glsl/glcpp/tests/062-if-0-skips-garbage.c new file mode 100644 index 00000000000..d9e439bb890 --- /dev/null +++ b/src/glsl/glcpp/tests/062-if-0-skips-garbage.c @@ -0,0 +1,5 @@ +#define foo(a,b) +#if 0 +foo(bar) +foo( +#endif diff --git a/src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected b/src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected new file mode 100644 index 00000000000..6fb66a5e2f0 --- /dev/null +++ b/src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/glsl/glcpp/tests/063-comments.c b/src/glsl/glcpp/tests/063-comments.c new file mode 100644 index 00000000000..e641d2f0f9e --- /dev/null +++ b/src/glsl/glcpp/tests/063-comments.c @@ -0,0 +1,20 @@ +/* this is a comment */ +// so is this +// */ +f = g/**//h; +/*//*/l(); +m = n//**/o ++ p; +/* this +comment spans +multiple lines and +contains *** stars +and slashes / *** / +and other stuff. +****/ +more code here +/* Test that /* nested + comments */ +are not treated like comments. +/*/ this is a comment */ +/*/*/ diff --git a/src/glsl/glcpp/tests/063-comments.c.expected b/src/glsl/glcpp/tests/063-comments.c.expected new file mode 100644 index 00000000000..ed4feedd457 --- /dev/null +++ b/src/glsl/glcpp/tests/063-comments.c.expected @@ -0,0 +1,14 @@ + + + +f = g /h; + l(); +m = n ++ p; + +more code here + +are not treated like comments. + + + diff --git a/src/glsl/glcpp/tests/064-version.c b/src/glsl/glcpp/tests/064-version.c new file mode 100644 index 00000000000..21326481b87 --- /dev/null +++ b/src/glsl/glcpp/tests/064-version.c @@ -0,0 +1,2 @@ +#version 130 +#define FOO diff --git a/src/glsl/glcpp/tests/064-version.c.expected b/src/glsl/glcpp/tests/064-version.c.expected new file mode 100644 index 00000000000..3af71113c8c --- /dev/null +++ b/src/glsl/glcpp/tests/064-version.c.expected @@ -0,0 +1,3 @@ +#version 130 + + diff --git a/src/glsl/glcpp/tests/065-if-defined-parens.c b/src/glsl/glcpp/tests/065-if-defined-parens.c new file mode 100644 index 00000000000..48aa0f8c3ef --- /dev/null +++ b/src/glsl/glcpp/tests/065-if-defined-parens.c @@ -0,0 +1,17 @@ +#if defined(foo) +failure_1 +#else +success_1 +#endif +#define foo +#if defined ( foo ) +success_2 +#else +failure_2 +#endif +#undef foo +#if defined (foo) +failure_3 +#else +success_3 +#endif diff --git a/src/glsl/glcpp/tests/065-if-defined-parens.c.expected b/src/glsl/glcpp/tests/065-if-defined-parens.c.expected new file mode 100644 index 00000000000..3f01955ee40 --- /dev/null +++ b/src/glsl/glcpp/tests/065-if-defined-parens.c.expected @@ -0,0 +1,18 @@ + + + +success_1 + + + +success_2 + + + + + + + +success_3 + + diff --git a/src/glsl/glcpp/tests/071-punctuator.c b/src/glsl/glcpp/tests/071-punctuator.c new file mode 100644 index 00000000000..959d6825988 --- /dev/null +++ b/src/glsl/glcpp/tests/071-punctuator.c @@ -0,0 +1 @@ +a = b diff --git a/src/glsl/glcpp/tests/071-punctuator.c.expected b/src/glsl/glcpp/tests/071-punctuator.c.expected new file mode 100644 index 00000000000..fee253b7452 --- /dev/null +++ b/src/glsl/glcpp/tests/071-punctuator.c.expected @@ -0,0 +1,2 @@ +a = b + diff --git a/src/glsl/glcpp/tests/072-token-pasting-same-line.c b/src/glsl/glcpp/tests/072-token-pasting-same-line.c new file mode 100644 index 00000000000..e421e9d5e29 --- /dev/null +++ b/src/glsl/glcpp/tests/072-token-pasting-same-line.c @@ -0,0 +1,2 @@ +#define paste(x) success_ ## x +paste(1) paste(2) paste(3) diff --git a/src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected b/src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected new file mode 100644 index 00000000000..c780b43d70f --- /dev/null +++ b/src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected @@ -0,0 +1,3 @@ + +success_1 success_2 success_3 + diff --git a/src/glsl/glcpp/tests/099-c99-example.c b/src/glsl/glcpp/tests/099-c99-example.c new file mode 100644 index 00000000000..d1976b1f265 --- /dev/null +++ b/src/glsl/glcpp/tests/099-c99-example.c @@ -0,0 +1,17 @@ +#define x 3 +#define f(a) f(x * (a)) +#undef x +#define x 2 +#define g f +#define z z[0] +#define h g(~ +#define m(a) a(w) +#define w 0,1 +#define t(a) a +#define p() int +#define q(x) x +#define r(x,y) x ## y +f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); +g(x +(3,4)-w) | h 5) & m + (f)^m(m); +p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,)}; diff --git a/src/glsl/glcpp/tests/099-c99-example.c.expected b/src/glsl/glcpp/tests/099-c99-example.c.expected new file mode 100644 index 00000000000..19be7505552 --- /dev/null +++ b/src/glsl/glcpp/tests/099-c99-example.c.expected @@ -0,0 +1,17 @@ + + + + + + + + + + + + + +f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); +f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); +int i[] = { 1, 23, 4, 5, }; + diff --git a/src/glsl/glcpp/tests/glcpp-test b/src/glsl/glcpp/tests/glcpp-test new file mode 100755 index 00000000000..396f6e175e8 --- /dev/null +++ b/src/glsl/glcpp/tests/glcpp-test @@ -0,0 +1,7 @@ +#!/bin/sh + +for test in *.c; do + echo "Testing $test" + ../glcpp < $test > $test.out + diff -u $test.expected $test.out +done diff --git a/src/glsl/glcpp/xtalloc.c b/src/glsl/glcpp/xtalloc.c new file mode 100644 index 00000000000..656ac2d6cb5 --- /dev/null +++ b/src/glsl/glcpp/xtalloc.c @@ -0,0 +1,99 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include + +void * +xtalloc_named_const (const void *context, size_t size, const char *name) +{ + void *ret; + + ret = talloc_named_const (context, size, name); + if (ret == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + return ret; +} + +char * +xtalloc_strdup (const void *t, const char *p) +{ + char *ret; + + ret = talloc_strdup (t, p); + if (ret == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + return ret; +} + +char * +xtalloc_strndup (const void *t, const char *p, size_t n) +{ + char *ret; + + ret = talloc_strndup (t, p, n); + if (ret == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + return ret; +} + +char * +xtalloc_asprintf (const void *t, const char *fmt, ...) +{ + va_list ap; + char *ret; + + va_start(ap, fmt); + + ret = talloc_vasprintf(t, fmt, ap); + if (ret == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + va_end(ap); + return ret; +} + +void * +_xtalloc_reference_loc (const void *context, + const void *ptr, const char *location) +{ + void *ret; + + ret = _talloc_reference_loc (context, ptr, location); + if (ret == NULL) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + + return ret; +} diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp new file mode 100644 index 00000000000..fa439f12787 --- /dev/null +++ b/src/glsl/glsl_lexer.lpp @@ -0,0 +1,336 @@ +%{ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" + +#define YY_USER_ACTION \ + do { \ + yylloc->source = 0; \ + yylloc->first_column = yycolumn + 1; \ + yylloc->first_line = yylineno + 1; \ + yycolumn += yyleng; \ + } while(0); + +%} + +%option bison-bridge bison-locations reentrant noyywrap +%option nounput noyy_top_state +%option never-interactive +%option prefix="_mesa_glsl_" +%option extra-type="struct _mesa_glsl_parse_state *" + +%x PP + +DEC_INT [1-9][0-9]* +HEX_INT 0[xX][0-9a-fA-F]+ +OCT_INT 0[0-7]* +INT ({DEC_INT}|{HEX_INT}|{OCT_INT}) +SPC [ \t]* +SPCP [ \t]+ +HASH ^{SPC}#{SPC} +%% + +[ \r\t]+ ; + + /* Preprocessor tokens. */ +^[ \t]*#[ \t]*$ ; +^[ \t]*#[ \t]*version { BEGIN PP; return VERSION; } +^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; } +{HASH}line{SPCP}{INT}{SPCP}{INT}{SPC}$ { + /* Eat characters until the first digit is + * encountered + */ + char *ptr = yytext; + while (!isdigit(*ptr)) + ptr++; + + /* Subtract one from the line number because + * yylineno is zero-based instead of + * one-based. + */ + yylineno = strtol(ptr, &ptr, 0) - 1; + yylloc->source = strtol(ptr, NULL, 0); + } +{HASH}line{SPCP}{INT}{SPC}$ { + /* Eat characters until the first digit is + * encountered + */ + char *ptr = yytext; + while (!isdigit(*ptr)) + ptr++; + + /* Subtract one from the line number because + * yylineno is zero-based instead of + * one-based. + */ + yylineno = strtol(ptr, &ptr, 0) - 1; + } +^[ \t]*#[ \t]*pragma { BEGIN PP; return PRAGMA; } +\/\/[^\n]* { } +[ \t\r]* { } +: return COLON; +[_a-zA-Z][_a-zA-Z0-9]* { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } +[1-9][0-9]* { + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } +\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } + +\n { yylineno++; yycolumn = 0; } + +attribute return ATTRIBUTE; +const return CONST; +bool return BOOL; +float return FLOAT; +int return INT; + +break return BREAK; +continue return CONTINUE; +do return DO; +while return WHILE; +else return ELSE; +for return FOR; +if return IF; +discard return DISCARD; +return return RETURN; + +bvec2 return BVEC2; +bvec3 return BVEC3; +bvec4 return BVEC4; +ivec2 return IVEC2; +ivec3 return IVEC3; +ivec4 return IVEC4; +vec2 return VEC2; +vec3 return VEC3; +vec4 return VEC4; +mat2 return MAT2; +mat3 return MAT3; +mat4 return MAT4; +mat2x2 return MAT2X2; +mat2x3 return MAT2X3; +mat2x4 return MAT2X4; +mat3x2 return MAT3X2; +mat3x3 return MAT3X3; +mat3x4 return MAT3X4; +mat4x2 return MAT4X2; +mat4x3 return MAT4X3; +mat4x4 return MAT4X4; + +in return IN; +out return OUT; +inout return INOUT; +uniform return UNIFORM; +varying return VARYING; +centroid { + if (yyextra->language_version >= 120) { + return CENTROID; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } +invariant { + if (yyextra->language_version >= 120) { + return INVARIANT; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + +flat { + if (yyextra->language_version >= 130) { + return FLAT; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } +smooth { + if (yyextra->language_version >= 130) { + return SMOOTH; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } +noperspective { + if (yyextra->language_version >= 130) { + return NOPERSPECTIVE; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + +sampler1D return SAMPLER1D; +sampler2D return SAMPLER2D; +sampler3D return SAMPLER3D; +samplerCube return SAMPLERCUBE; +sampler1DShadow return SAMPLER1DSHADOW; +sampler2DShadow return SAMPLER2DSHADOW; + +struct return STRUCT; +void return VOID; + +\+\+ return INC_OP; +-- return DEC_OP; +\<= return LE_OP; +>= return GE_OP; +== return EQ_OP; +!= return NE_OP; +&& return AND_OP; +\|\| return OR_OP; +"^^" return XOR_OP; + +\*= return MUL_ASSIGN; +\/= return DIV_ASSIGN; +\+= return ADD_ASSIGN; +\%= return MOD_ASSIGN; +\<\<= return LEFT_ASSIGN; +>>= return RIGHT_ASSIGN; +&= return AND_ASSIGN; +^= return XOR_ASSIGN; +\|= return OR_ASSIGN; +-= return SUB_ASSIGN; + +[1-9][0-9]* { + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } +0[xX][0-9a-fA-F]+ { + yylval->n = strtol(yytext + 2, NULL, 16); + return INTCONSTANT; + } +0[0-7]* { + yylval->n = strtol(yytext + 2, NULL, 8); + return INTCONSTANT; + } + +[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } +\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } +[0-9]+\.([eE][+-]?[0-9]+)?[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } +[0-9]+[eE][+-]?[0-9]+[fF]? { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } + +true { + yylval->n = 1; + return BOOLCONSTANT; + } +false { + yylval->n = 0; + return BOOLCONSTANT; + } + + + /* Reserved words in GLSL 1.10. */ +asm return ASM; +class return CLASS; +union return UNION; +enum return ENUM; +typedef return TYPEDEF; +template return TEMPLATE; +this return THIS; +packed return PACKED; +goto return GOTO; +switch return SWITCH; +default return DEFAULT; +inline return INLINE; +noinline return NOINLINE; +volatile return VOLATILE; +public return PUBLIC; +static return STATIC; +extern return EXTERN; +external return EXTERNAL; +interface return INTERFACE; +long return LONG; +short return SHORT; +double return DOUBLE; +half return HALF; +fixed return FIXED; +unsigned return UNSIGNED; +input return INPUT; +output return OUTPUT; +hvec2 return HVEC2; +hvec3 return HVEC3; +hvec4 return HVEC4; +dvec2 return DVEC2; +dvec3 return DVEC3; +dvec4 return DVEC4; +fvec2 return FVEC2; +fvec3 return FVEC3; +fvec4 return FVEC4; +sampler2DRect return SAMPLER2DRECT; +sampler3DRect return SAMPLER3DRECT; +sampler2DRectShadow return SAMPLER2DRECTSHADOW; +sizeof return SIZEOF; +cast return CAST; +namespace return NAMESPACE; +using return USING; + + /* Additional reserved words in GLSL 1.20. */ +lowp return LOWP; +mediump return MEDIUMP; +highp return HIGHP; +precision return PRECISION; + +[_a-zA-Z][_a-zA-Z0-9]* { + struct _mesa_glsl_parse_state *state = yyextra; + void *ctx = talloc_parent(state); + yylval->identifier = talloc_strdup(ctx, yytext); + return IDENTIFIER; + } + +. { return yytext[0]; } + +%% + +void +_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) +{ + yylex_init_extra(state, & state->scanner); + yy_scan_string(string, state->scanner); +} + +void +_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) +{ + yylex_destroy(state->scanner); +} diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp new file mode 100644 index 00000000000..4132495f403 --- /dev/null +++ b/src/glsl/glsl_parser.ypp @@ -0,0 +1,1444 @@ +%{ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" + +#define YYLEX_PARAM state->scanner + +%} + +%pure-parser +%locations +%error-verbose + +%lex-param {void *scanner} +%parse-param {struct _mesa_glsl_parse_state *state} +%name-prefix "_mesa_glsl_" + +%union { + int n; + float real; + char *identifier; + + union { + struct ast_type_qualifier q; + unsigned i; + } type_qualifier; + + struct ast_node *node; + struct ast_type_specifier *type_specifier; + struct ast_fully_specified_type *fully_specified_type; + struct ast_function *function; + struct ast_parameter_declarator *parameter_declarator; + struct ast_function_definition *function_definition; + struct ast_compound_statement *compound_statement; + struct ast_expression *expression; + struct ast_declarator_list *declarator_list; + struct ast_struct_specifier *struct_specifier; + struct ast_declaration *declaration; + + struct { + struct ast_node *cond; + struct ast_expression *rest; + } for_rest_statement; +} + +%token ATTRIBUTE CONST BOOL FLOAT INT UINT +%token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT +%token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 +%token MAT2 MAT3 MAT4 CENTROID IN OUT INOUT UNIFORM VARYING +%token NOPERSPECTIVE FLAT SMOOTH +%token MAT2X2 MAT2X3 MAT2X4 +%token MAT3X2 MAT3X3 MAT3X4 +%token MAT4X2 MAT4X3 MAT4X4 +%token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW +%token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW +%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE +%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D +%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY +%token STRUCT VOID WHILE +%token IDENTIFIER +%token FLOATCONSTANT +%token INTCONSTANT UINTCONSTANT BOOLCONSTANT +%token FIELD_SELECTION +%token LEFT_OP RIGHT_OP +%token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP +%token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN +%token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN +%token SUB_ASSIGN +%token INVARIANT +%token LOWP MEDIUMP HIGHP PRECISION + +%token VERSION EXTENSION LINE PRAGMA COLON EOL INTERFACE OUTPUT + + /* Reserved words that are not actually used in the grammar. + */ +%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED GOTO +%token INLINE NOINLINE VOLATILE PUBLIC STATIC EXTERN EXTERNAL +%token LONG SHORT DOUBLE HALF FIXED UNSIGNED INPUT OUPTUT +%token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 +%token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW +%token SIZEOF CAST NAMESPACE USING + +%type variable_identifier +%type statement +%type statement_list +%type simple_statement +%type statement_matched +%type statement_unmatched +%type precision_qualifier +%type type_qualifier +%type storage_qualifier +%type interpolation_qualifier +%type type_specifier +%type type_specifier_no_prec +%type type_specifier_nonarray +%type basic_type_specifier_nonarray +%type fully_specified_type +%type function_prototype +%type function_header +%type function_header_with_parameters +%type function_declarator +%type parameter_declarator +%type parameter_declaration +%type parameter_qualifier +%type parameter_type_qualifier +%type parameter_type_specifier +%type function_definition +%type compound_statement_no_new_scope +%type compound_statement +%type statement_no_new_scope +%type expression_statement +%type expression +%type primary_expression +%type assignment_expression +%type conditional_expression +%type logical_or_expression +%type logical_xor_expression +%type logical_and_expression +%type inclusive_or_expression +%type exclusive_or_expression +%type and_expression +%type equality_expression +%type relational_expression +%type shift_expression +%type additive_expression +%type multiplicative_expression +%type unary_expression +%type constant_expression +%type integer_expression +%type postfix_expression +%type function_call_header_with_parameters +%type function_call_header_no_parameters +%type function_call_header +%type function_call_generic +%type function_call_or_method +%type function_call +%type assignment_operator +%type unary_operator +%type function_identifier +%type external_declaration +%type init_declarator_list +%type single_declaration +%type initializer +%type declaration +%type declaration_statement +%type jump_statement +%type struct_specifier +%type struct_declaration_list +%type struct_declaration +%type struct_declarator +%type struct_declarator_list +%type selection_statement_matched +%type selection_statement_unmatched +%type iteration_statement +%type condition +%type conditionopt +%type for_init_statement +%type for_rest_statement +%% + +translation_unit: + version_statement extension_statement_list + { + _mesa_glsl_initialize_types(state); + } + external_declaration_list + ; + +version_statement: + /* blank - no #version specified */ + { + state->language_version = 110; + } + | VERSION INTCONSTANT EOL + { + switch ($2) { + case 110: + case 120: + case 130: + /* FINISHME: Check against implementation support versions. */ + state->language_version = $2; + break; + default: + _mesa_glsl_error(& @2, state, "Shading language version" + "%u is not supported\n", $2); + break; + } + } + ; + +extension_statement_list: + + | extension_statement_list extension_statement + ; + +extension_statement: + EXTENSION IDENTIFIER COLON IDENTIFIER EOL + { + if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) { + YYERROR; + } + } + ; + +external_declaration_list: + external_declaration + { + /* FINISHME: The NULL test is only required because 'precision' + * FINISHME: statements are not yet supported. + */ + if ($1 != NULL) + state->translation_unit.push_tail(& $1->link); + } + | external_declaration_list external_declaration + { + /* FINISHME: The NULL test is only required because 'precision' + * FINISHME: statements are not yet supported. + */ + if ($2 != NULL) + state->translation_unit.push_tail(& $2->link); + } + ; + +variable_identifier: + IDENTIFIER + ; + +primary_expression: + variable_identifier + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.identifier = $1; + } + | INTCONSTANT + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.int_constant = $1; + } + | UINTCONSTANT + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.uint_constant = $1; + } + | FLOATCONSTANT + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.float_constant = $1; + } + | BOOLCONSTANT + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.bool_constant = $1; + } + | '(' expression ')' + { + $$ = $2; + } + ; + +postfix_expression: + primary_expression + | postfix_expression '[' integer_expression ']' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL); + $$->set_location(yylloc); + } + | function_call + { + /* Function call parameters used to be stored as a circular list in + * subexpressions[1]. They are now stored as a regular list in + * expressions. This assertion validates that the old code was + * correctly converted. It can eventually be removed. + */ + assert($1->subexpressions[1] == NULL); + $$ = $1; + } + | postfix_expression '.' IDENTIFIER + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.identifier = $3; + } + | postfix_expression INC_OP + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL); + $$->set_location(yylloc); + } + | postfix_expression DEC_OP + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL); + $$->set_location(yylloc); + } + ; + +integer_expression: + expression + ; + +function_call: + function_call_or_method + ; + +function_call_or_method: + function_call_generic + | postfix_expression '.' function_call_generic + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL); + $$->set_location(yylloc); + } + ; + +function_call_generic: + function_call_header_with_parameters ')' + | function_call_header_no_parameters ')' + ; + +function_call_header_no_parameters: + function_call_header VOID + | function_call_header + ; + +function_call_header_with_parameters: + function_call_header assignment_expression + { + $$ = $1; + $$->set_location(yylloc); + $$->expressions.push_tail(& $2->link); + } + | function_call_header_with_parameters ',' assignment_expression + { + $$ = $1; + $$->set_location(yylloc); + $$->expressions.push_tail(& $3->link); + } + ; + + // Grammar Note: Constructors look like functions, but lexical + // analysis recognized most of them as keywords. They are now + // recognized through "type_specifier". +function_call_header: + function_identifier '(' + ; + +function_identifier: + type_specifier + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_function_expression($1); + $$->set_location(yylloc); + } + | IDENTIFIER + { + void *ctx = talloc_parent(state); + ast_expression *callee = new(ctx) ast_expression($1); + $$ = new(ctx) ast_function_expression(callee); + $$->set_location(yylloc); + } + | FIELD_SELECTION + { + void *ctx = talloc_parent(state); + ast_expression *callee = new(ctx) ast_expression($1); + $$ = new(ctx) ast_function_expression(callee); + $$->set_location(yylloc); + } + ; + + // Grammar Note: No traditional style type casts. +unary_expression: + postfix_expression + | INC_OP unary_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL); + $$->set_location(yylloc); + } + | DEC_OP unary_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL); + $$->set_location(yylloc); + } + | unary_operator unary_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression($1, $2, NULL, NULL); + $$->set_location(yylloc); + } + ; + + // Grammar Note: No '*' or '&' unary ops. Pointers are not supported. +unary_operator: + '+' { $$ = ast_plus; } + | '-' { $$ = ast_neg; } + | '!' { $$ = ast_logic_not; } + | '~' { $$ = ast_bit_not; } + ; + +multiplicative_expression: + unary_expression + | multiplicative_expression '*' unary_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3); + $$->set_location(yylloc); + } + | multiplicative_expression '/' unary_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_div, $1, $3); + $$->set_location(yylloc); + } + | multiplicative_expression '%' unary_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3); + $$->set_location(yylloc); + } + ; + +additive_expression: + multiplicative_expression + | additive_expression '+' multiplicative_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_add, $1, $3); + $$->set_location(yylloc); + } + | additive_expression '-' multiplicative_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3); + $$->set_location(yylloc); + } + ; + +shift_expression: + additive_expression + | shift_expression LEFT_OP additive_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3); + $$->set_location(yylloc); + } + | shift_expression RIGHT_OP additive_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3); + $$->set_location(yylloc); + } + ; + +relational_expression: + shift_expression + | relational_expression '<' shift_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_less, $1, $3); + $$->set_location(yylloc); + } + | relational_expression '>' shift_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3); + $$->set_location(yylloc); + } + | relational_expression LE_OP shift_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3); + $$->set_location(yylloc); + } + | relational_expression GE_OP shift_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3); + $$->set_location(yylloc); + } + ; + +equality_expression: + relational_expression + | equality_expression EQ_OP relational_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3); + $$->set_location(yylloc); + } + | equality_expression NE_OP relational_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3); + $$->set_location(yylloc); + } + ; + +and_expression: + equality_expression + | and_expression '&' equality_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); + $$->set_location(yylloc); + } + ; + +exclusive_or_expression: + and_expression + | exclusive_or_expression '^' and_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3); + $$->set_location(yylloc); + } + ; + +inclusive_or_expression: + exclusive_or_expression + | inclusive_or_expression '|' exclusive_or_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); + $$->set_location(yylloc); + } + ; + +logical_and_expression: + inclusive_or_expression + | logical_and_expression AND_OP inclusive_or_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3); + $$->set_location(yylloc); + } + ; + +logical_xor_expression: + logical_and_expression + | logical_xor_expression XOR_OP logical_and_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3); + $$->set_location(yylloc); + } + ; + +logical_or_expression: + logical_xor_expression + | logical_or_expression OR_OP logical_xor_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3); + $$->set_location(yylloc); + } + ; + +conditional_expression: + logical_or_expression + | logical_or_expression '?' expression ':' assignment_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5); + $$->set_location(yylloc); + } + ; + +assignment_expression: + conditional_expression + | unary_expression assignment_operator assignment_expression + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression($2, $1, $3, NULL); + $$->set_location(yylloc); + } + ; + +assignment_operator: + '=' { $$ = ast_assign; } + | MUL_ASSIGN { $$ = ast_mul_assign; } + | DIV_ASSIGN { $$ = ast_div_assign; } + | MOD_ASSIGN { $$ = ast_mod_assign; } + | ADD_ASSIGN { $$ = ast_add_assign; } + | SUB_ASSIGN { $$ = ast_sub_assign; } + | LEFT_ASSIGN { $$ = ast_ls_assign; } + | RIGHT_ASSIGN { $$ = ast_rs_assign; } + | AND_ASSIGN { $$ = ast_and_assign; } + | XOR_ASSIGN { $$ = ast_xor_assign; } + | OR_ASSIGN { $$ = ast_or_assign; } + ; + +expression: + assignment_expression + { + $$ = $1; + } + | expression ',' assignment_expression + { + void *ctx = talloc_parent(state); + if ($1->oper != ast_sequence) { + $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->expressions.push_tail(& $1->link); + } else { + $$ = $1; + } + + $$->expressions.push_tail(& $3->link); + } + ; + +constant_expression: + conditional_expression + ; + +declaration: + function_prototype ';' + { + $$ = $1; + } + | init_declarator_list ';' + { + $$ = $1; + } + | PRECISION precision_qualifier type_specifier_no_prec ';' + { + if (($3->type_specifier != ast_float) + && ($3->type_specifier != ast_int)) { + _mesa_glsl_error(& @3, state, "global precision qualifier can " + "only be applied to `int' or `float'\n"); + YYERROR; + } + + $$ = NULL; /* FINISHME */ + } + ; + +function_prototype: + function_declarator ')' + ; + +function_declarator: + function_header + | function_header_with_parameters + ; + +function_header_with_parameters: + function_header parameter_declaration + { + $$ = $1; + $$->parameters.push_tail(& $2->link); + } + | function_header_with_parameters ',' parameter_declaration + { + $$ = $1; + $$->parameters.push_tail(& $3->link); + } + ; + +function_header: + fully_specified_type IDENTIFIER '(' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_function(); + $$->set_location(yylloc); + $$->return_type = $1; + $$->identifier = $2; + } + ; + +parameter_declarator: + type_specifier IDENTIFIER + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_parameter_declarator(); + $$->set_location(yylloc); + $$->type = new(ctx) ast_fully_specified_type(); + $$->type->set_location(yylloc); + $$->type->specifier = $1; + $$->identifier = $2; + } + | type_specifier IDENTIFIER '[' constant_expression ']' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_parameter_declarator(); + $$->set_location(yylloc); + $$->type = new(ctx) ast_fully_specified_type(); + $$->type->set_location(yylloc); + $$->type->specifier = $1; + $$->identifier = $2; + $$->is_array = true; + $$->array_size = $4; + } + ; + +parameter_declaration: + parameter_type_qualifier parameter_qualifier parameter_declarator + { + $1.i |= $2.i; + + $$ = $3; + $$->type->qualifier = $1.q; + } + | parameter_qualifier parameter_declarator + { + $$ = $2; + $$->type->qualifier = $1.q; + } + | parameter_type_qualifier parameter_qualifier parameter_type_specifier + { + void *ctx = talloc_parent(state); + $1.i |= $2.i; + + $$ = new(ctx) ast_parameter_declarator(); + $$->set_location(yylloc); + $$->type = new(ctx) ast_fully_specified_type(); + $$->type->qualifier = $1.q; + $$->type->specifier = $3; + } + | parameter_qualifier parameter_type_specifier + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_parameter_declarator(); + $$->set_location(yylloc); + $$->type = new(ctx) ast_fully_specified_type(); + $$->type->qualifier = $1.q; + $$->type->specifier = $2; + } + ; + +parameter_qualifier: + /* empty */ { $$.i = 0; } + | IN { $$.i = 0; $$.q.in = 1; } + | OUT { $$.i = 0; $$.q.out = 1; } + | INOUT { $$.i = 0; $$.q.in = 1; $$.q.out = 1; } + ; + +parameter_type_specifier: + type_specifier + ; + +init_declarator_list: + single_declaration + | init_declarator_list ',' IDENTIFIER + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + } + | init_declarator_list ',' IDENTIFIER '[' ']' + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + } + | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + } + | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + } + | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + } + | init_declarator_list ',' IDENTIFIER '=' initializer + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + } + ; + + // Grammar Note: No 'enum', or 'typedef'. +single_declaration: + fully_specified_type + { + void *ctx = talloc_parent(state); + if ($1->specifier->type_specifier != ast_struct) { + _mesa_glsl_error(& @1, state, "empty declaration list\n"); + YYERROR; + } else { + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + } + } + | fully_specified_type IDENTIFIER + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | fully_specified_type IDENTIFIER '[' ']' + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | fully_specified_type IDENTIFIER '[' constant_expression ']' + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | fully_specified_type IDENTIFIER '[' ']' '=' initializer + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | fully_specified_type IDENTIFIER '=' initializer + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | INVARIANT IDENTIFIER // Vertex only. + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); + + $$ = new(ctx) ast_declarator_list(NULL); + $$->set_location(yylloc); + $$->invariant = true; + + $$->declarations.push_tail(&decl->link); + } + ; + +fully_specified_type: + type_specifier + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_fully_specified_type(); + $$->set_location(yylloc); + $$->specifier = $1; + } + | type_qualifier type_specifier + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_fully_specified_type(); + $$->set_location(yylloc); + $$->qualifier = $1.q; + $$->specifier = $2; + } + ; + +interpolation_qualifier: + SMOOTH { $$.i = 0; $$.q.smooth = 1; } + | FLAT { $$.i = 0; $$.q.flat = 1; } + | NOPERSPECTIVE { $$.i = 0; $$.q.noperspective = 1; } + ; + +parameter_type_qualifier: + CONST { $$.i = 0; $$.q.constant = 1; } + ; + +type_qualifier: + storage_qualifier + | interpolation_qualifier type_qualifier + { + $$.i = $1.i | $2.i; + } + | INVARIANT type_qualifier + { + $$ = $2; + $$.q.invariant = 1; + } + ; + +storage_qualifier: + CONST { $$.i = 0; $$.q.constant = 1; } + | ATTRIBUTE { $$.i = 0; $$.q.attribute = 1; } + | VARYING { $$.i = 0; $$.q.varying = 1; } + | CENTROID VARYING { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; } + | IN { $$.i = 0; $$.q.in = 1; } + | OUT { $$.i = 0; $$.q.out = 1; } + | CENTROID IN { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; } + | CENTROID OUT { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; } + | UNIFORM { $$.i = 0; $$.q.uniform = 1; } + ; + +type_specifier: + type_specifier_no_prec + | precision_qualifier type_specifier_no_prec + { + $$ = $2; + $$->precision = $1; + } + ; + +type_specifier_no_prec: + type_specifier_nonarray + | type_specifier_nonarray '[' ']' + { + $$ = $1; + $$->is_array = true; + $$->array_size = NULL; + } + | type_specifier_nonarray '[' constant_expression ']' + { + $$ = $1; + $$->is_array = true; + $$->array_size = $3; + } + ; + +type_specifier_nonarray: + basic_type_specifier_nonarray + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_type_specifier($1); + $$->set_location(yylloc); + } + | struct_specifier + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_type_specifier($1); + $$->set_location(yylloc); + } + | IDENTIFIER + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_type_specifier($1); + $$->set_location(yylloc); + } + ; + +basic_type_specifier_nonarray: + VOID { $$ = ast_void; } + | FLOAT { $$ = ast_float; } + | INT { $$ = ast_int; } + | UINT { $$ = ast_uint; } + | BOOL { $$ = ast_bool; } + | VEC2 { $$ = ast_vec2; } + | VEC3 { $$ = ast_vec3; } + | VEC4 { $$ = ast_vec4; } + | BVEC2 { $$ = ast_bvec2; } + | BVEC3 { $$ = ast_bvec3; } + | BVEC4 { $$ = ast_bvec4; } + | IVEC2 { $$ = ast_ivec2; } + | IVEC3 { $$ = ast_ivec3; } + | IVEC4 { $$ = ast_ivec4; } + | UVEC2 { $$ = ast_uvec2; } + | UVEC3 { $$ = ast_uvec3; } + | UVEC4 { $$ = ast_uvec4; } + | MAT2 { $$ = ast_mat2; } + | MAT3 { $$ = ast_mat3; } + | MAT4 { $$ = ast_mat4; } + | MAT2X2 { $$ = ast_mat2; } + | MAT2X3 { $$ = ast_mat2x3; } + | MAT2X4 { $$ = ast_mat2x4; } + | MAT3X2 { $$ = ast_mat3x2; } + | MAT3X3 { $$ = ast_mat3; } + | MAT3X4 { $$ = ast_mat3x4; } + | MAT4X2 { $$ = ast_mat4x2; } + | MAT4X3 { $$ = ast_mat4x3; } + | MAT4X4 { $$ = ast_mat4; } + | SAMPLER1D { $$ = ast_sampler1d; } + | SAMPLER2D { $$ = ast_sampler2d; } + | SAMPLER2DRECT { $$ = ast_sampler2drect; } + | SAMPLER3D { $$ = ast_sampler3d; } + | SAMPLERCUBE { $$ = ast_samplercube; } + | SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; } + | SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; } + | SAMPLER2DRECTSHADOW { $$ = ast_sampler2drectshadow; } + | SAMPLERCUBESHADOW { $$ = ast_samplercubeshadow; } + | SAMPLER1DARRAY { $$ = ast_sampler1darray; } + | SAMPLER2DARRAY { $$ = ast_sampler2darray; } + | SAMPLER1DARRAYSHADOW { $$ = ast_sampler1darrayshadow; } + | SAMPLER2DARRAYSHADOW { $$ = ast_sampler2darrayshadow; } + | ISAMPLER1D { $$ = ast_isampler1d; } + | ISAMPLER2D { $$ = ast_isampler2d; } + | ISAMPLER3D { $$ = ast_isampler3d; } + | ISAMPLERCUBE { $$ = ast_isamplercube; } + | ISAMPLER1DARRAY { $$ = ast_isampler1darray; } + | ISAMPLER2DARRAY { $$ = ast_isampler2darray; } + | USAMPLER1D { $$ = ast_usampler1d; } + | USAMPLER2D { $$ = ast_usampler2d; } + | USAMPLER3D { $$ = ast_usampler3d; } + | USAMPLERCUBE { $$ = ast_usamplercube; } + | USAMPLER1DARRAY { $$ = ast_usampler1darray; } + | USAMPLER2DARRAY { $$ = ast_usampler2darray; } + ; + +precision_qualifier: + HIGHP { + if (state->language_version < 130) + _mesa_glsl_error(& @1, state, + "precission qualifier forbidden " + "in GLSL %d.%d (1.30 or later " + "required)\n", + state->language_version / 100, + state->language_version % 100); + + $$ = ast_precision_high; + } + | MEDIUMP { + if (state->language_version < 130) + _mesa_glsl_error(& @1, state, + "precission qualifier forbidden " + "in GLSL %d.%d (1.30 or later " + "required)\n", + state->language_version / 100, + state->language_version % 100); + + $$ = ast_precision_medium; + } + | LOWP { + if (state->language_version < 130) + _mesa_glsl_error(& @1, state, + "precission qualifier forbidden " + "in GLSL %d.%d (1.30 or later " + "required)\n", + state->language_version / 100, + state->language_version % 100); + + $$ = ast_precision_low; + } + ; + +struct_specifier: + STRUCT IDENTIFIER '{' struct_declaration_list '}' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_struct_specifier($2, $4); + $$->set_location(yylloc); + } + | STRUCT '{' struct_declaration_list '}' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_struct_specifier(NULL, $3); + $$->set_location(yylloc); + } + ; + +struct_declaration_list: + struct_declaration + { + $$ = (struct ast_node *) $1; + $1->link.self_link(); + } + | struct_declaration_list struct_declaration + { + $$ = (struct ast_node *) $1; + $$->link.insert_before(& $2->link); + } + ; + +struct_declaration: + type_specifier struct_declarator_list ';' + { + void *ctx = talloc_parent(state); + ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); + type->set_location(yylloc); + + type->specifier = $1; + $$ = new(ctx) ast_declarator_list(type); + $$->set_location(yylloc); + + $$->declarations.push_degenerate_list_at_head(& $2->link); + } + ; + +struct_declarator_list: + struct_declarator + { + $$ = $1; + $1->link.self_link(); + } + | struct_declarator_list ',' struct_declarator + { + $$ = $1; + $$->link.insert_before(& $3->link); + } + ; + +struct_declarator: + IDENTIFIER + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_declaration($1, false, NULL, NULL); + $$->set_location(yylloc); + } + | IDENTIFIER '[' constant_expression ']' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_declaration($1, true, $3, NULL); + $$->set_location(yylloc); + } + ; + +initializer: + assignment_expression + ; + +declaration_statement: + declaration + ; + + // Grammar Note: labeled statements for SWITCH only; 'goto' is not + // supported. +statement: + statement_matched + | statement_unmatched + ; + +statement_matched: + compound_statement { $$ = (struct ast_node *) $1; } + | simple_statement + ; + +statement_unmatched: + selection_statement_unmatched + ; + +simple_statement: + declaration_statement + | expression_statement + | selection_statement_matched + | switch_statement { $$ = NULL; } + | case_label { $$ = NULL; } + | iteration_statement + | jump_statement + ; + +compound_statement: + '{' '}' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_compound_statement(true, NULL); + $$->set_location(yylloc); + } + | '{' statement_list '}' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_compound_statement(true, $2); + $$->set_location(yylloc); + } + ; + +statement_no_new_scope: + compound_statement_no_new_scope { $$ = (struct ast_node *) $1; } + | simple_statement + ; + +compound_statement_no_new_scope: + '{' '}' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_compound_statement(false, NULL); + $$->set_location(yylloc); + } + | '{' statement_list '}' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_compound_statement(false, $2); + $$->set_location(yylloc); + } + ; + +statement_list: + statement + { + if ($1 == NULL) { + _mesa_glsl_error(& @1, state, " statement\n"); + assert($1 != NULL); + } + + $$ = $1; + $$->link.self_link(); + } + | statement_list statement + { + if ($2 == NULL) { + _mesa_glsl_error(& @2, state, " statement\n"); + assert($2 != NULL); + } + $$ = $1; + $$->link.insert_before(& $2->link); + } + ; + +expression_statement: + ';' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_statement(NULL); + $$->set_location(yylloc); + } + | expression ';' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_expression_statement($1); + $$->set_location(yylloc); + } + ; + +selection_statement_matched: + IF '(' expression ')' statement_matched ELSE statement_matched + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_selection_statement($3, $5, $7); + $$->set_location(yylloc); + } + ; + +selection_statement_unmatched: + IF '(' expression ')' statement_matched + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_selection_statement($3, $5, NULL); + $$->set_location(yylloc); + } + | IF '(' expression ')' statement_unmatched + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_selection_statement($3, $5, NULL); + $$->set_location(yylloc); + } + | IF '(' expression ')' statement_matched ELSE statement_unmatched + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_selection_statement($3, $5, $7); + $$->set_location(yylloc); + } + ; + +condition: + expression + { + $$ = (struct ast_node *) $1; + } + | fully_specified_type IDENTIFIER '=' initializer + { + void *ctx = talloc_parent(state); + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); + ast_declarator_list *declarator = new(ctx) ast_declarator_list($1); + decl->set_location(yylloc); + declarator->set_location(yylloc); + + declarator->declarations.push_tail(&decl->link); + $$ = declarator; + } + ; + +switch_statement: + SWITCH '(' expression ')' compound_statement + ; + +case_label: + CASE expression ':' + | DEFAULT ':' + ; + +iteration_statement: + WHILE '(' condition ')' statement_no_new_scope + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, + NULL, $3, NULL, $5); + $$->set_location(yylloc); + } + | DO statement WHILE '(' expression ')' ';' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, + NULL, $5, NULL, $2); + $$->set_location(yylloc); + } + | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, + $3, $4.cond, $4.rest, $6); + $$->set_location(yylloc); + } + ; + +for_init_statement: + expression_statement + | declaration_statement + ; + +conditionopt: + condition + | /* empty */ + { + $$ = NULL; + } + ; + +for_rest_statement: + conditionopt ';' + { + $$.cond = $1; + $$.rest = NULL; + } + | conditionopt ';' expression + { + $$.cond = $1; + $$.rest = $3; + } + ; + + // Grammar Note: No 'goto'. Gotos are not supported. +jump_statement: + CONTINUE ';' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); + $$->set_location(yylloc); + } + | BREAK ';' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); + $$->set_location(yylloc); + } + | RETURN ';' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); + $$->set_location(yylloc); + } + | RETURN expression ';' + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2); + $$->set_location(yylloc); + } + | DISCARD ';' // Fragment shader only. + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); + $$->set_location(yylloc); + } + ; + +external_declaration: + function_definition { $$ = $1; } + | declaration { $$ = $1; } + ; + +function_definition: + function_prototype compound_statement_no_new_scope + { + void *ctx = talloc_parent(state); + $$ = new(ctx) ast_function_definition(); + $$->set_location(yylloc); + $$->prototype = $1; + $$->body = $2; + } + ; diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp new file mode 100644 index 00000000000..1d16ef55f57 --- /dev/null +++ b/src/glsl/glsl_parser_extras.cpp @@ -0,0 +1,621 @@ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include + +extern "C" { +#include +} + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" + +const char * +_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) +{ + switch (target) { + case vertex_shader: return "vertex"; + case fragment_shader: return "fragment"; + case geometry_shader: return "geometry"; + case ir_shader: break; + } + + assert(!"Should not get here."); +} + + +void +_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, + const char *fmt, ...) +{ + va_list ap; + + state->error = true; + + assert(state->info_log != NULL); + state->info_log = talloc_asprintf_append(state->info_log, + "%u:%u(%u): error: ", + locp->source, + locp->first_line, + locp->first_column); + va_start(ap, fmt); + state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); + va_end(ap); + state->info_log = talloc_strdup_append(state->info_log, "\n"); +} + + +void +_mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, + const char *fmt, ...) +{ + va_list ap; + + assert(state->info_log != NULL); + state->info_log = talloc_asprintf_append(state->info_log, + "%u:%u(%u): warning: ", + locp->source, + locp->first_line, + locp->first_column); + va_start(ap, fmt); + state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); + va_end(ap); + state->info_log = talloc_strdup_append(state->info_log, "\n"); +} + + +bool +_mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, + const char *behavior, YYLTYPE *behavior_locp, + _mesa_glsl_parse_state *state) +{ + enum { + extension_disable, + extension_enable, + extension_require, + extension_warn + } ext_mode; + + if (strcmp(behavior, "warn") == 0) { + ext_mode = extension_warn; + } else if (strcmp(behavior, "require") == 0) { + ext_mode = extension_require; + } else if (strcmp(behavior, "enable") == 0) { + ext_mode = extension_enable; + } else if (strcmp(behavior, "disable") == 0) { + ext_mode = extension_disable; + } else { + _mesa_glsl_error(behavior_locp, state, + "Unknown extension behavior `%s'", + behavior); + return false; + } + + bool unsupported = false; + + if (strcmp(name, "all") == 0) { + if ((ext_mode == extension_enable) || (ext_mode == extension_require)) { + _mesa_glsl_error(name_locp, state, "Cannot %s all extensions", + (ext_mode == extension_enable) + ? "enable" : "require"); + return false; + } + } else if (strcmp(name, "GL_ARB_draw_buffers") == 0) { + /* This extension is only supported in fragment shaders. + */ + if (state->target != fragment_shader) { + unsupported = true; + } else { + state->ARB_draw_buffers_enable = (ext_mode != extension_disable); + state->ARB_draw_buffers_warn = (ext_mode == extension_warn); + } + } else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) { + state->ARB_texture_rectangle_enable = (ext_mode != extension_disable); + state->ARB_texture_rectangle_warn = (ext_mode == extension_warn); + } else { + unsupported = true; + } + + if (unsupported) { + static const char *const fmt = "extension `%s' unsupported in %s shader"; + + if (ext_mode == extension_require) { + _mesa_glsl_error(name_locp, state, fmt, + name, _mesa_glsl_shader_target_name(state->target)); + return false; + } else { + _mesa_glsl_warning(name_locp, state, fmt, + name, _mesa_glsl_shader_target_name(state->target)); + } + } + + return true; +} + +void +_mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q) +{ + if (q->constant) + printf("const "); + + if (q->invariant) + printf("invariant "); + + if (q->attribute) + printf("attribute "); + + if (q->varying) + printf("varying "); + + if (q->in && q->out) + printf("inout "); + else { + if (q->in) + printf("in "); + + if (q->out) + printf("out "); + } + + if (q->centroid) + printf("centroid "); + if (q->uniform) + printf("uniform "); + if (q->smooth) + printf("smooth "); + if (q->flat) + printf("flat "); + if (q->noperspective) + printf("noperspective "); +} + + +void +ast_node::print(void) const +{ + printf("unhandled node "); +} + + +ast_node::ast_node(void) +{ + /* empty */ +} + + +static void +ast_opt_array_size_print(bool is_array, const ast_expression *array_size) +{ + if (is_array) { + printf("[ "); + + if (array_size) + array_size->print(); + + printf("] "); + } +} + + +void +ast_compound_statement::print(void) const +{ + printf("{\n"); + + foreach_list_const(n, &this->statements) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + + printf("}\n"); +} + + +ast_compound_statement::ast_compound_statement(int new_scope, + ast_node *statements) +{ + this->new_scope = new_scope; + + if (statements != NULL) { + this->statements.push_degenerate_list_at_head(&statements->link); + } +} + + +void +ast_expression::print(void) const +{ + switch (oper) { + case ast_assign: + case ast_mul_assign: + case ast_div_assign: + case ast_mod_assign: + case ast_add_assign: + case ast_sub_assign: + case ast_ls_assign: + case ast_rs_assign: + case ast_and_assign: + case ast_xor_assign: + case ast_or_assign: + subexpressions[0]->print(); + printf("%s ", operator_string(oper)); + subexpressions[1]->print(); + break; + + case ast_field_selection: + subexpressions[0]->print(); + printf(". %s ", primary_expression.identifier); + break; + + case ast_plus: + case ast_neg: + case ast_bit_not: + case ast_logic_not: + case ast_pre_inc: + case ast_pre_dec: + printf("%s ", operator_string(oper)); + subexpressions[0]->print(); + break; + + case ast_post_inc: + case ast_post_dec: + subexpressions[0]->print(); + printf("%s ", operator_string(oper)); + break; + + case ast_conditional: + subexpressions[0]->print(); + printf("? "); + subexpressions[1]->print(); + printf(": "); + subexpressions[1]->print(); + break; + + case ast_array_index: + subexpressions[0]->print(); + printf("[ "); + subexpressions[1]->print(); + printf("] "); + break; + + case ast_function_call: { + subexpressions[0]->print(); + printf("( "); + + foreach_list_const (n, &this->expressions) { + if (n != this->expressions.get_head()) + printf(", "); + + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + + printf(") "); + break; + } + + case ast_identifier: + printf("%s ", primary_expression.identifier); + break; + + case ast_int_constant: + printf("%d ", primary_expression.int_constant); + break; + + case ast_uint_constant: + printf("%u ", primary_expression.uint_constant); + break; + + case ast_float_constant: + printf("%f ", primary_expression.float_constant); + break; + + case ast_bool_constant: + printf("%s ", + primary_expression.bool_constant + ? "true" : "false"); + break; + + case ast_sequence: { + printf("( "); + foreach_list_const(n, & this->expressions) { + if (n != this->expressions.get_head()) + printf(", "); + + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + printf(") "); + break; + } + + default: + assert(0); + break; + } +} + +ast_expression::ast_expression(int oper, + ast_expression *ex0, + ast_expression *ex1, + ast_expression *ex2) +{ + this->oper = ast_operators(oper); + this->subexpressions[0] = ex0; + this->subexpressions[1] = ex1; + this->subexpressions[2] = ex2; +} + + +void +ast_expression_statement::print(void) const +{ + if (expression) + expression->print(); + + printf("; "); +} + + +ast_expression_statement::ast_expression_statement(ast_expression *ex) : + expression(ex) +{ + /* empty */ +} + + +void +ast_function::print(void) const +{ + return_type->print(); + printf(" %s (", identifier); + + foreach_list_const(n, & this->parameters) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + + printf(")"); +} + + +ast_function::ast_function(void) + : is_definition(false), signature(NULL) +{ + /* empty */ +} + + +void +ast_fully_specified_type::print(void) const +{ + _mesa_ast_type_qualifier_print(& qualifier); + specifier->print(); +} + + +void +ast_parameter_declarator::print(void) const +{ + type->print(); + if (identifier) + printf("%s ", identifier); + ast_opt_array_size_print(is_array, array_size); +} + + +void +ast_function_definition::print(void) const +{ + prototype->print(); + body->print(); +} + + +void +ast_declaration::print(void) const +{ + printf("%s ", identifier); + ast_opt_array_size_print(is_array, array_size); + + if (initializer) { + printf("= "); + initializer->print(); + } +} + + +ast_declaration::ast_declaration(char *identifier, int is_array, + ast_expression *array_size, + ast_expression *initializer) +{ + this->identifier = identifier; + this->is_array = is_array; + this->array_size = array_size; + this->initializer = initializer; +} + + +void +ast_declarator_list::print(void) const +{ + assert(type || invariant); + + if (type) + type->print(); + else + printf("invariant "); + + foreach_list_const (ptr, & this->declarations) { + if (ptr != this->declarations.get_head()) + printf(", "); + + ast_node *ast = exec_node_data(ast_node, ptr, link); + ast->print(); + } + + printf("; "); +} + + +ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type) +{ + this->type = type; +} + +void +ast_jump_statement::print(void) const +{ + switch (mode) { + case ast_continue: + printf("continue; "); + break; + case ast_break: + printf("break; "); + break; + case ast_return: + printf("return "); + if (opt_return_value) + opt_return_value->print(); + + printf("; "); + break; + case ast_discard: + printf("discard; "); + break; + } +} + + +ast_jump_statement::ast_jump_statement(int mode, ast_expression *return_value) +{ + this->mode = ast_jump_modes(mode); + + if (mode == ast_return) + opt_return_value = return_value; +} + + +void +ast_selection_statement::print(void) const +{ + printf("if ( "); + condition->print(); + printf(") "); + + then_statement->print(); + + if (else_statement) { + printf("else "); + else_statement->print(); + } + +} + + +ast_selection_statement::ast_selection_statement(ast_expression *condition, + ast_node *then_statement, + ast_node *else_statement) +{ + this->condition = condition; + this->then_statement = then_statement; + this->else_statement = else_statement; +} + + +void +ast_iteration_statement::print(void) const +{ + switch (mode) { + case ast_for: + printf("for( "); + if (init_statement) + init_statement->print(); + printf("; "); + + if (condition) + condition->print(); + printf("; "); + + if (rest_expression) + rest_expression->print(); + printf(") "); + + body->print(); + break; + + case ast_while: + printf("while ( "); + if (condition) + condition->print(); + printf(") "); + body->print(); + break; + + case ast_do_while: + printf("do "); + body->print(); + printf("while ( "); + if (condition) + condition->print(); + printf("); "); + break; + } +} + + +ast_iteration_statement::ast_iteration_statement(int mode, + ast_node *init, + ast_node *condition, + ast_expression *rest_expression, + ast_node *body) +{ + this->mode = ast_iteration_modes(mode); + this->init_statement = init; + this->condition = condition; + this->rest_expression = rest_expression; + this->body = body; +} + + +void +ast_struct_specifier::print(void) const +{ + printf("struct %s { ", name); + foreach_list_const(n, &this->declarations) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + printf("} "); +} + + +ast_struct_specifier::ast_struct_specifier(char *identifier, + ast_node *declarator_list) +{ + name = identifier; + this->declarations.push_degenerate_list_at_head(&declarator_list->link); +} diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h new file mode 100644 index 00000000000..cfe02e3b0c1 --- /dev/null +++ b/src/glsl/glsl_parser_extras.h @@ -0,0 +1,139 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_PARSER_EXTRAS_H +#define GLSL_PARSER_EXTRAS_H + +#include +#include "glsl_symbol_table.h" + +enum _mesa_glsl_parser_targets { + vertex_shader, + geometry_shader, + fragment_shader, + ir_shader +}; + +struct _mesa_glsl_parse_state { + void *scanner; + exec_list translation_unit; + glsl_symbol_table *symbols; + + unsigned language_version; + enum _mesa_glsl_parser_targets target; + + /** + * During AST to IR conversion, pointer to current IR function + * + * Will be \c NULL whenever the AST to IR conversion is not inside a + * function definition. + */ + class ir_function_signature *current_function; + + /** Was there an error during compilation? */ + bool error; + + /** Index of last generated anonymous temporary. */ + unsigned temp_index; + + /** Loop or switch statement containing the current instructions. */ + class ir_instruction *loop_or_switch_nesting; + + /** List of structures defined in user code. */ + const glsl_type **user_structures; + unsigned num_user_structures; + + char *info_log; + + /** + * \name Enable bits for GLSL extensions + */ + /*@{*/ + unsigned ARB_draw_buffers_enable:1; + unsigned ARB_draw_buffers_warn:1; + unsigned ARB_texture_rectangle_enable:1; + unsigned ARB_texture_rectangle_warn:1; + unsigned EXT_texture_array_enable:1; + unsigned EXT_texture_array_warn:1; + /*@}*/ +}; + +typedef struct YYLTYPE { + int first_line; + int first_column; + int last_line; + int last_column; + unsigned source; +} YYLTYPE; +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 + +extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, + const char *fmt, ...); + +/** + * Emit a warning to the shader log + * + * \sa _mesa_glsl_error + */ +extern void _mesa_glsl_warning(const YYLTYPE *locp, + _mesa_glsl_parse_state *state, + const char *fmt, ...); + +extern "C" { +extern int preprocess(void *ctx, const char **shader, char **info_log); +} + +extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, + const char *string); + +extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state); + +union YYSTYPE; +extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc, + void *scanner); + +extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *); + +/** + * Process elements of the #extension directive + * + * \return + * If \c name and \c behavior are valid, \c true is returned. Otherwise + * \c false is returned. + */ +extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, + const char *behavior, + YYLTYPE *behavior_locp, + _mesa_glsl_parse_state *state); + +/** + * Get the textual name of the specified shader target + */ +extern const char * +_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target); + +void do_ir_to_mesa(exec_list *instructions); + +#endif /* GLSL_PARSER_EXTRAS_H */ diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h new file mode 100644 index 00000000000..ae2fd3f4f1f --- /dev/null +++ b/src/glsl/glsl_symbol_table.h @@ -0,0 +1,163 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_SYMBOL_TABLE +#define GLSL_SYMBOL_TABLE + +#include + +#include "symbol_table.h" +#include "ir.h" +#include "glsl_types.h" + +/** + * Facade class for _mesa_symbol_table + * + * Wraps the existing \c _mesa_symbol_table data structure to enforce some + * type safe and some symbol table invariants. + */ +class glsl_symbol_table { +private: + enum glsl_symbol_name_space { + glsl_variable_name_space = 0, + glsl_type_name_space = 1, + glsl_function_name_space = 2 + }; + + static int + _glsl_symbol_table_destructor (glsl_symbol_table *table) + { + table->~glsl_symbol_table(); + + return 0; + } + +public: + /* Callers of this talloc-based new need not call delete. It's + * easier to just talloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *table; + + table = talloc_size(ctx, size); + assert(table != NULL); + + talloc_set_destructor(table, (int (*)(void*)) _glsl_symbol_table_destructor); + + return table; + } + + /* If the user *does* call delete, that's OK, we will just + * talloc_free in that case. Here, C++ will have already called the + * destructor so tell talloc not to do that again. */ + static void operator delete(void *table) + { + talloc_set_destructor(table, NULL); + talloc_free(table); + } + + glsl_symbol_table() + { + table = _mesa_symbol_table_ctor(); + } + + ~glsl_symbol_table() + { + _mesa_symbol_table_dtor(table); + } + + void push_scope() + { + _mesa_symbol_table_push_scope(table); + } + + void pop_scope() + { + _mesa_symbol_table_pop_scope(table); + } + + /** + * Determine whether a name was declared at the current scope + */ + bool name_declared_this_scope(const char *name) + { + return _mesa_symbol_table_symbol_scope(table, -1, name) == 0; + } + + /** + * \name Methods to add symbols to the table + * + * There is some temptation to rename all these functions to \c add_symbol + * or similar. However, this breaks symmetry with the getter functions and + * reduces the clarity of the intention of code that uses these methods. + */ + /*@{*/ + bool add_variable(const char *name, ir_variable *v) + { + return _mesa_symbol_table_add_symbol(table, glsl_variable_name_space, + name, v) == 0; + } + + bool add_type(const char *name, const glsl_type *t) + { + return _mesa_symbol_table_add_symbol(table, glsl_type_name_space, + name, (void *) t) == 0; + } + + bool add_function(const char *name, ir_function *f) + { + return _mesa_symbol_table_add_symbol(table, glsl_function_name_space, + name, f) == 0; + } + /*@}*/ + + /** + * \name Methods to get symbols from the table + */ + /*@{*/ + ir_variable *get_variable(const char *name) + { + return (ir_variable *) + _mesa_symbol_table_find_symbol(table, glsl_variable_name_space, name); + } + + glsl_type *get_type(const char *name) + { + return (glsl_type *) + _mesa_symbol_table_find_symbol(table, glsl_type_name_space, name); + } + + ir_function *get_function(const char *name) + { + return (ir_function *) + _mesa_symbol_table_find_symbol(table, glsl_function_name_space, name); + } + /*@}*/ + +private: + struct _mesa_symbol_table *table; +}; + +#endif /* GLSL_SYMBOL_TABLE */ diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp new file mode 100644 index 00000000000..bef267fa6be --- /dev/null +++ b/src/glsl/glsl_types.cpp @@ -0,0 +1,773 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include "glsl_symbol_table.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" +#include "builtin_types.h" +#include "hash_table.h" + + +hash_table *glsl_type::array_types = NULL; + +static void +add_types_to_symbol_table(glsl_symbol_table *symtab, + const struct glsl_type *types, + unsigned num_types, bool warn) +{ + (void) warn; + + for (unsigned i = 0; i < num_types; i++) { + symtab->add_type(types[i].name, & types[i]); + } +} + + +static void +generate_110_types(glsl_symbol_table *symtab) +{ + add_types_to_symbol_table(symtab, builtin_core_types, + Elements(builtin_core_types), + false); + add_types_to_symbol_table(symtab, builtin_structure_types, + Elements(builtin_structure_types), + false); + add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types, + Elements(builtin_110_deprecated_structure_types), + false); + add_types_to_symbol_table(symtab, & void_type, 1, false); +} + + +static void +generate_120_types(glsl_symbol_table *symtab) +{ + generate_110_types(symtab); + + add_types_to_symbol_table(symtab, builtin_120_types, + Elements(builtin_120_types), false); +} + + +static void +generate_130_types(glsl_symbol_table *symtab) +{ + generate_120_types(symtab); + + add_types_to_symbol_table(symtab, builtin_130_types, + Elements(builtin_130_types), false); +} + + +static void +generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, bool warn) +{ + add_types_to_symbol_table(symtab, builtin_ARB_texture_rectangle_types, + Elements(builtin_ARB_texture_rectangle_types), + warn); +} + + +static void +generate_EXT_texture_array_types(glsl_symbol_table *symtab, bool warn) +{ + add_types_to_symbol_table(symtab, builtin_EXT_texture_array_types, + Elements(builtin_EXT_texture_array_types), + warn); +} + + +void +_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) +{ + switch (state->language_version) { + case 110: + generate_110_types(state->symbols); + break; + case 120: + generate_120_types(state->symbols); + break; + case 130: + generate_130_types(state->symbols); + break; + default: + /* error */ + break; + } + + if (state->ARB_texture_rectangle_enable) { + generate_ARB_texture_rectangle_types(state->symbols, + state->ARB_texture_rectangle_warn); + } + + if (state->EXT_texture_array_enable && state->language_version < 130) { + // These are already included in 130; don't create twice. + generate_EXT_texture_array_types(state->symbols, + state->EXT_texture_array_warn); + } +} + + +const glsl_type *glsl_type::get_base_type() const +{ + switch (base_type) { + case GLSL_TYPE_UINT: + return uint_type; + case GLSL_TYPE_INT: + return int_type; + case GLSL_TYPE_FLOAT: + return float_type; + case GLSL_TYPE_BOOL: + return bool_type; + default: + return error_type; + } +} + + +ir_function * +glsl_type::generate_constructor(glsl_symbol_table *symtab) const +{ + void *ctx = symtab; + + /* Generate the function name and add it to the symbol table. + */ + ir_function *const f = new(ctx) ir_function(name); + + bool added = symtab->add_function(name, f); + assert(added); + + ir_function_signature *const sig = new(ctx) ir_function_signature(this); + f->add_signature(sig); + + ir_variable **declarations = + (ir_variable **) malloc(sizeof(ir_variable *) * this->length); + for (unsigned i = 0; i < length; i++) { + char *const param_name = (char *) malloc(10); + + snprintf(param_name, 10, "p%08X", i); + + ir_variable *var = (this->base_type == GLSL_TYPE_ARRAY) + ? new(ctx) ir_variable(fields.array, param_name) + : new(ctx) ir_variable(fields.structure[i].type, param_name); + + var->mode = ir_var_in; + declarations[i] = var; + sig->parameters.push_tail(var); + } + + /* Generate the body of the constructor. The body assigns each of the + * parameters to a portion of a local variable called __retval that has + * the same type as the constructor. After initializing __retval, + * __retval is returned. + */ + ir_variable *retval = new(ctx) ir_variable(this, "__retval"); + sig->body.push_tail(retval); + + for (unsigned i = 0; i < length; i++) { + ir_dereference *const lhs = (this->base_type == GLSL_TYPE_ARRAY) + ? (ir_dereference *) new(ctx) ir_dereference_array(retval, + new(ctx) ir_constant(i)) + : (ir_dereference *) new(ctx) ir_dereference_record(retval, + fields.structure[i].name); + + ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[i]); + ir_instruction *const assign = new(ctx) ir_assignment(lhs, rhs, NULL); + + sig->body.push_tail(assign); + } + + free(declarations); + + ir_dereference *const retref = new(ctx) ir_dereference_variable(retval); + ir_instruction *const inst = new(ctx) ir_return(retref); + sig->body.push_tail(inst); + + return f; +} + + +/** + * Generate the function intro for a constructor + * + * \param type Data type to be constructed + * \param count Number of parameters to this concrete constructor. Most + * types have at least two constructors. One will take a + * single scalar parameter and the other will take "N" + * scalar parameters. + * \param parameters Storage for the list of parameters. These are + * typically stored in an \c ir_function_signature. + * \param declarations Pointers to the variable declarations for the function + * parameters. These are used later to avoid having to use + * the symbol table. + */ +static ir_function_signature * +generate_constructor_intro(void *ctx, + const glsl_type *type, unsigned parameter_count, + ir_variable **declarations) +{ + /* Names of parameters used in vector and matrix constructors + */ + static const char *const names[] = { + "a", "b", "c", "d", "e", "f", "g", "h", + "i", "j", "k", "l", "m", "n", "o", "p", + }; + + assert(parameter_count <= Elements(names)); + + const glsl_type *const parameter_type = type->get_base_type(); + + ir_function_signature *const signature = new(ctx) ir_function_signature(type); + + for (unsigned i = 0; i < parameter_count; i++) { + ir_variable *var = new(ctx) ir_variable(parameter_type, names[i]); + + var->mode = ir_var_in; + signature->parameters.push_tail(var); + + declarations[i] = var; + } + + ir_variable *retval = new(ctx) ir_variable(type, "__retval"); + signature->body.push_tail(retval); + + declarations[16] = retval; + return signature; +} + + +/** + * Generate the body of a vector constructor that takes a single scalar + */ +static void +generate_vec_body_from_scalar(void *ctx, + exec_list *instructions, + ir_variable **declarations) +{ + ir_instruction *inst; + + /* Generate a single assignment of the parameter to __retval.x and return + * __retval.xxxx for however many vector components there are. + */ + ir_dereference *const lhs_ref = + new(ctx) ir_dereference_variable(declarations[16]); + ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[0]); + + ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); + + inst = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + + ir_dereference *const retref = new(ctx) ir_dereference_variable(declarations[16]); + + ir_swizzle *retval = new(ctx) ir_swizzle(retref, 0, 0, 0, 0, + declarations[16]->type->vector_elements); + + inst = new(ctx) ir_return(retval); + instructions->push_tail(inst); +} + + +/** + * Generate the body of a vector constructor that takes multiple scalars + */ +static void +generate_vec_body_from_N_scalars(void *ctx, + exec_list *instructions, + ir_variable **declarations) +{ + ir_instruction *inst; + const glsl_type *const vec_type = declarations[16]->type; + + /* Generate an assignment of each parameter to a single component of + * __retval.x and return __retval. + */ + for (unsigned i = 0; i < vec_type->vector_elements; i++) { + ir_dereference *const lhs_ref = + new(ctx) ir_dereference_variable(declarations[16]); + ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[i]); + + ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, i, 0, 0, 0, 1); + + inst = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + } + + ir_dereference *retval = new(ctx) ir_dereference_variable(declarations[16]); + + inst = new(ctx) ir_return(retval); + instructions->push_tail(inst); +} + + +/** + * Generate the body of a matrix constructor that takes a single scalar + */ +static void +generate_mat_body_from_scalar(void *ctx, + exec_list *instructions, + ir_variable **declarations) +{ + ir_instruction *inst; + + /* Generate an assignment of the parameter to the X component of a + * temporary vector. Set the remaining fields of the vector to 0. The + * size of the vector is equal to the number of rows of the matrix. + * + * Set each column of the matrix to a successive "rotation" of the + * temporary vector. This fills the matrix with 0s, but writes the single + * scalar along the matrix's diagonal. + * + * For a mat4x3, this is equivalent to: + * + * vec3 tmp; + * mat4x3 __retval; + * tmp.x = a; + * tmp.y = 0.0; + * tmp.z = 0.0; + * __retval[0] = tmp.xyy; + * __retval[1] = tmp.yxy; + * __retval[2] = tmp.yyx; + * __retval[3] = tmp.yyy; + */ + const glsl_type *const column_type = declarations[16]->type->column_type(); + const glsl_type *const row_type = declarations[16]->type->row_type(); + + ir_variable *const column = new(ctx) ir_variable(column_type, "v"); + + instructions->push_tail(column); + + ir_dereference *const lhs_ref = new(ctx) ir_dereference_variable(column); + ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[0]); + + ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); + + inst = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + + for (unsigned i = 1; i < column_type->vector_elements; i++) { + ir_dereference *const lhs_ref = new(ctx) ir_dereference_variable(column); + ir_constant *const zero = new(ctx) ir_constant(0.0f); + + ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, i, 0, 0, 0, 1); + + inst = new(ctx) ir_assignment(lhs, zero, NULL); + instructions->push_tail(inst); + } + + + for (unsigned i = 0; i < row_type->vector_elements; i++) { + static const unsigned swiz[] = { 1, 1, 1, 0, 1, 1, 1 }; + ir_dereference *const rhs_ref = new(ctx) ir_dereference_variable(column); + + /* This will be .xyyy when i=0, .yxyy when i=1, etc. + */ + ir_swizzle *rhs = new(ctx) ir_swizzle(rhs_ref, swiz[3 - i], swiz[4 - i], + swiz[5 - i], swiz[6 - i], + column_type->vector_elements); + + ir_constant *const idx = new(ctx) ir_constant(int(i)); + ir_dereference *const lhs = + new(ctx) ir_dereference_array(declarations[16], idx); + + inst = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + } + + ir_dereference *const retval = new(ctx) ir_dereference_variable(declarations[16]); + inst = new(ctx) ir_return(retval); + instructions->push_tail(inst); +} + + +/** + * Generate the body of a vector constructor that takes multiple scalars + */ +static void +generate_mat_body_from_N_scalars(void *ctx, + exec_list *instructions, + ir_variable **declarations) +{ + ir_instruction *inst; + const glsl_type *const row_type = declarations[16]->type->row_type(); + const glsl_type *const column_type = declarations[16]->type->column_type(); + + /* Generate an assignment of each parameter to a single component of + * of a particular column of __retval and return __retval. + */ + for (unsigned i = 0; i < column_type->vector_elements; i++) { + for (unsigned j = 0; j < row_type->vector_elements; j++) { + ir_constant *row_index = new(ctx) ir_constant(int(i)); + ir_dereference *const row_access = + new(ctx) ir_dereference_array(declarations[16], row_index); + + ir_swizzle *component_access = new(ctx) ir_swizzle(row_access, + j, 0, 0, 0, 1); + + const unsigned param = (i * row_type->vector_elements) + j; + ir_dereference *const rhs = + new(ctx) ir_dereference_variable(declarations[param]); + + inst = new(ctx) ir_assignment(component_access, rhs, NULL); + instructions->push_tail(inst); + } + } + + ir_dereference *retval = new(ctx) ir_dereference_variable(declarations[16]); + + inst = new(ctx) ir_return(retval); + instructions->push_tail(inst); +} + + +/** + * Generate the constructors for a set of GLSL types + * + * Constructor implementations are added to \c instructions, and the symbols + * are added to \c symtab. + */ +static void +generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, + unsigned num_types, exec_list *instructions) +{ + void *ctx = symtab; + ir_variable *declarations[17]; + + for (unsigned i = 0; i < num_types; i++) { + /* Only numeric and boolean vectors and matrices get constructors here. + * Structures need to be handled elsewhere. It is expected that scalar + * constructors are never actually called, so they are not generated. + */ + if (!types[i].is_numeric() && !types[i].is_boolean()) + continue; + + if (types[i].is_scalar()) + continue; + + /* Generate the function block, add it to the symbol table, and emit it. + */ + ir_function *const f = new(ctx) ir_function(types[i].name); + + bool added = symtab->add_function(types[i].name, f); + assert(added); + + instructions->push_tail(f); + + /* Each type has several basic constructors. The total number of forms + * depends on the derived type. + * + * Vectors: 1 scalar, N scalars + * Matrices: 1 scalar, NxM scalars + * + * Several possible types of constructors are not included in this list. + * + * Scalar constructors are not included. The expectation is that the + * IR generator won't actually generate these as constructor calls. The + * expectation is that it will just generate the necessary type + * conversion. + * + * Matrix contructors from matrices are also not included. The + * expectation is that the IR generator will generate a call to the + * appropriate from-scalars constructor. + */ + ir_function_signature *const sig = + generate_constructor_intro(ctx, &types[i], 1, declarations); + f->add_signature(sig); + + if (types[i].is_vector()) { + generate_vec_body_from_scalar(ctx, &sig->body, declarations); + + ir_function_signature *const vec_sig = + generate_constructor_intro(ctx, + &types[i], types[i].vector_elements, + declarations); + f->add_signature(vec_sig); + + generate_vec_body_from_N_scalars(ctx, &vec_sig->body, declarations); + } else { + assert(types[i].is_matrix()); + + generate_mat_body_from_scalar(ctx, &sig->body, declarations); + + ir_function_signature *const mat_sig = + generate_constructor_intro(ctx, + &types[i], + (types[i].vector_elements + * types[i].matrix_columns), + declarations); + f->add_signature(mat_sig); + + generate_mat_body_from_N_scalars(ctx, &mat_sig->body, declarations); + } + } +} + + +void +generate_110_constructors(glsl_symbol_table *symtab, exec_list *instructions) +{ + generate_constructor(symtab, builtin_core_types, + Elements(builtin_core_types), instructions); +} + + +void +generate_120_constructors(glsl_symbol_table *symtab, exec_list *instructions) +{ + generate_110_constructors(symtab, instructions); + + generate_constructor(symtab, builtin_120_types, + Elements(builtin_120_types), instructions); +} + + +void +generate_130_constructors(glsl_symbol_table *symtab, exec_list *instructions) +{ + generate_120_constructors(symtab, instructions); + + generate_constructor(symtab, builtin_130_types, + Elements(builtin_130_types), instructions); +} + + +void +_mesa_glsl_initialize_constructors(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + switch (state->language_version) { + case 110: + generate_110_constructors(state->symbols, instructions); + break; + case 120: + generate_120_constructors(state->symbols, instructions); + break; + case 130: + generate_130_constructors(state->symbols, instructions); + break; + default: + /* error */ + break; + } +} + + +glsl_type::glsl_type(void *ctx, const glsl_type *array, unsigned length) : + base_type(GLSL_TYPE_ARRAY), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(0), matrix_columns(0), + name(NULL), length(length) +{ + this->fields.array = array; + + /* Allow a maximum of 10 characters for the array size. This is enough + * for 32-bits of ~0. The extra 3 are for the '[', ']', and terminating + * NUL. + */ + const unsigned name_length = strlen(array->name) + 10 + 3; + char *const n = (char *) talloc_size(ctx, name_length); + + if (length == 0) + snprintf(n, name_length, "%s[]", array->name); + else + snprintf(n, name_length, "%s[%u]", array->name, length); + + this->name = n; +} + + +const glsl_type * +glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) +{ + if (base_type == GLSL_TYPE_VOID) + return &void_type; + + if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4)) + return error_type; + + /* Treat GLSL vectors as Nx1 matrices. + */ + if (columns == 1) { + switch (base_type) { + case GLSL_TYPE_UINT: + return uint_type + (rows - 1); + case GLSL_TYPE_INT: + return int_type + (rows - 1); + case GLSL_TYPE_FLOAT: + return float_type + (rows - 1); + case GLSL_TYPE_BOOL: + return bool_type + (rows - 1); + default: + return error_type; + } + } else { + if ((base_type != GLSL_TYPE_FLOAT) || (rows == 1)) + return error_type; + + /* GLSL matrix types are named mat{COLUMNS}x{ROWS}. Only the following + * combinations are valid: + * + * 1 2 3 4 + * 1 + * 2 x x x + * 3 x x x + * 4 x x x + */ +#define IDX(c,r) (((c-1)*3) + (r-1)) + + switch (IDX(columns, rows)) { + case IDX(2,2): return mat2_type; + case IDX(2,3): return mat2x3_type; + case IDX(2,4): return mat2x4_type; + case IDX(3,2): return mat3x2_type; + case IDX(3,3): return mat3_type; + case IDX(3,4): return mat3x4_type; + case IDX(4,2): return mat4x2_type; + case IDX(4,3): return mat4x3_type; + case IDX(4,4): return mat4_type; + default: return error_type; + } + } + + assert(!"Should not get here."); + return error_type; +} + + +int +glsl_type::array_key_compare(const void *a, const void *b) +{ + const glsl_type *const key1 = (glsl_type *) a; + const glsl_type *const key2 = (glsl_type *) b; + + /* Return zero is the types match (there is zero difference) or non-zero + * otherwise. + */ + return ((key1->fields.array == key2->fields.array) + && (key1->length == key2->length)) ? 0 : 1; +} + + +unsigned +glsl_type::array_key_hash(const void *a) +{ + const glsl_type *const key = (glsl_type *) a; + + const struct { + const glsl_type *t; + unsigned l; + char nul; + } hash_key = { + key->fields.array, + key->length, + '\0' + }; + + return hash_table_string_hash(& hash_key); +} + + +const glsl_type * +glsl_type::get_array_instance(void *ctx, const glsl_type *base, + unsigned array_size) +{ + const glsl_type key(ctx, base, array_size); + + if (array_types == NULL) { + array_types = hash_table_ctor(64, array_key_hash, array_key_compare); + } + + const glsl_type *t = (glsl_type *) hash_table_find(array_types, & key); + if (t == NULL) { + t = new(ctx) glsl_type(ctx, base, array_size); + + hash_table_insert(array_types, (void *) t, t); + } + + assert(t->base_type == GLSL_TYPE_ARRAY); + assert(t->length == array_size); + assert(t->fields.array == base); + + return t; +} + + +const glsl_type * +glsl_type::field_type(const char *name) const +{ + if (this->base_type != GLSL_TYPE_STRUCT) + return error_type; + + for (unsigned i = 0; i < this->length; i++) { + if (strcmp(name, this->fields.structure[i].name) == 0) + return this->fields.structure[i].type; + } + + return error_type; +} + + +int +glsl_type::field_index(const char *name) const +{ + if (this->base_type != GLSL_TYPE_STRUCT) + return -1; + + for (unsigned i = 0; i < this->length; i++) { + if (strcmp(name, this->fields.structure[i].name) == 0) + return i; + } + + return -1; +} + + +unsigned +glsl_type::component_slots() const +{ + switch (this->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + return this->components(); + + case GLSL_TYPE_STRUCT: { + unsigned size = 0; + + for (unsigned i = 0; i < this->length; i++) + size += this->fields.structure[i].type->component_slots(); + + return size; + } + + case GLSL_TYPE_ARRAY: + return this->length * this->fields.array->component_slots(); + + default: + return 0; + } +} diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h new file mode 100644 index 00000000000..39e6ac970aa --- /dev/null +++ b/src/glsl/glsl_types.h @@ -0,0 +1,445 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_TYPES_H +#define GLSL_TYPES_H + +#include +#include + +extern "C" { +#include +} + +#define GLSL_TYPE_UINT 0 +#define GLSL_TYPE_INT 1 +#define GLSL_TYPE_FLOAT 2 +#define GLSL_TYPE_BOOL 3 +#define GLSL_TYPE_SAMPLER 4 +#define GLSL_TYPE_STRUCT 5 +#define GLSL_TYPE_ARRAY 6 +#define GLSL_TYPE_FUNCTION 7 +#define GLSL_TYPE_VOID 8 +#define GLSL_TYPE_ERROR 9 + +enum glsl_sampler_dim { + GLSL_SAMPLER_DIM_1D = 0, + GLSL_SAMPLER_DIM_2D, + GLSL_SAMPLER_DIM_3D, + GLSL_SAMPLER_DIM_CUBE, + GLSL_SAMPLER_DIM_RECT, + GLSL_SAMPLER_DIM_BUF +}; + + +struct glsl_type { + unsigned base_type:4; + + unsigned sampler_dimensionality:3; + unsigned sampler_shadow:1; + unsigned sampler_array:1; + unsigned sampler_type:2; /**< Type of data returned using this sampler. + * only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT, + * and \c GLSL_TYPE_UINT are valid. + */ + + /* Callers of this talloc-based new need not call delete. It's + * easier to just talloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *type; + + type = talloc_size(ctx, size); + assert(type != NULL); + + return type; + } + + /* If the user *does* call delete, that's OK, we will just + * talloc_free in that case. */ + static void operator delete(void *type) + { + talloc_free(type); + } + + /** + * \name Vector and matrix element counts + * + * For scalars, each of these values will be 1. For non-numeric types + * these will be 0. + */ + /*@{*/ + unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */ + unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */ + /*@}*/ + + /** + * Name of the data type + * + * This may be \c NULL for anonymous structures, for arrays, or for + * function types. + */ + const char *name; + + /** + * For \c GLSL_TYPE_ARRAY, this is the length of the array. For + * \c GLSL_TYPE_STRUCT, it is the number of elements in the structure and + * the number of values pointed to by \c fields.structure (below). + * + * For \c GLSL_TYPE_FUNCTION, it is the number of parameters to the + * function. The return value from a function is implicitly the first + * parameter. The types of the parameters are stored in + * \c fields.parameters (below). + */ + unsigned length; + + /** + * Subtype of composite data types. + */ + union { + const struct glsl_type *array; /**< Type of array elements. */ + const struct glsl_type *parameters; /**< Parameters to function. */ + const struct glsl_struct_field *structure;/**< List of struct fields. */ + } fields; + + + /** + * \name Pointers to various public type singletons + */ + /*@{*/ + static const glsl_type *const error_type; + static const glsl_type *const int_type; + static const glsl_type *const ivec4_type; + static const glsl_type *const uint_type; + static const glsl_type *const uvec4_type; + static const glsl_type *const float_type; + static const glsl_type *const vec2_type; + static const glsl_type *const vec3_type; + static const glsl_type *const vec4_type; + static const glsl_type *const bool_type; + static const glsl_type *const mat2_type; + static const glsl_type *const mat2x3_type; + static const glsl_type *const mat2x4_type; + static const glsl_type *const mat3x2_type; + static const glsl_type *const mat3_type; + static const glsl_type *const mat3x4_type; + static const glsl_type *const mat4x2_type; + static const glsl_type *const mat4x3_type; + static const glsl_type *const mat4_type; + /*@}*/ + + + glsl_type(unsigned base_type, unsigned vector_elements, + unsigned matrix_columns, const char *name) : + base_type(base_type), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(vector_elements), matrix_columns(matrix_columns), + name(name), + length(0) + { + /* Neither dimension is zero or both dimensions are zero. + */ + assert((vector_elements == 0) == (matrix_columns == 0)); + memset(& fields, 0, sizeof(fields)); + } + + glsl_type(enum glsl_sampler_dim dim, bool shadow, bool array, + unsigned type, const char *name) : + base_type(GLSL_TYPE_SAMPLER), + sampler_dimensionality(dim), sampler_shadow(shadow), + sampler_array(array), sampler_type(type), + vector_elements(0), matrix_columns(0), + name(name), + length(0) + { + memset(& fields, 0, sizeof(fields)); + } + + glsl_type(const glsl_struct_field *fields, unsigned num_fields, + const char *name) : + base_type(GLSL_TYPE_STRUCT), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(0), matrix_columns(0), + name(name), + length(num_fields) + { + this->fields.structure = fields; + } + + /** + * For numeric and boolean derrived types returns the basic scalar type + * + * If the type is a numeric or boolean scalar, vector, or matrix type, + * this function gets the scalar type of the individual components. For + * all other types, including arrays of numeric or boolean types, the + * error type is returned. + */ + const glsl_type *get_base_type() const; + + /** + * Query the type of elements in an array + * + * \return + * Pointer to the type of elements in the array for array types, or \c NULL + * for non-array types. + */ + const glsl_type *element_type() const + { + return is_array() ? fields.array : NULL; + } + + /** + * Get the instance of a built-in scalar, vector, or matrix type + */ + static const glsl_type *get_instance(unsigned base_type, unsigned rows, + unsigned columns); + + /** + * Get the instance of an array type + */ + static const glsl_type *get_array_instance(void *ctx, + const glsl_type *base, + unsigned elements); + + /** + * Generate the constructor for this type and add it to the symbol table + */ + class ir_function *generate_constructor(class glsl_symbol_table *) const; + + /** + * Query the total number of scalars that make up a scalar, vector or matrix + */ + unsigned components() const + { + return vector_elements * matrix_columns; + } + + /** + * Calculate the number of components slots required to hold this type + * + * This is used to determine how many uniform or varying locations a type + * might occupy. + */ + unsigned component_slots() const; + + + /** + * Query whether or not a type is a scalar (non-vector and non-matrix). + */ + bool is_scalar() const + { + return (vector_elements == 1) + && (base_type >= GLSL_TYPE_UINT) + && (base_type <= GLSL_TYPE_BOOL); + } + + /** + * Query whether or not a type is a vector + */ + bool is_vector() const + { + return (vector_elements > 1) + && (matrix_columns == 1) + && (base_type >= GLSL_TYPE_UINT) + && (base_type <= GLSL_TYPE_BOOL); + } + + /** + * Query whether or not a type is a matrix + */ + bool is_matrix() const + { + /* GLSL only has float matrices. */ + return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT); + } + + /** + * Query whether or not a type is a non-array numeric type + */ + bool is_numeric() const + { + return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_FLOAT); + } + + /** + * Query whether or not a type is an integral type + */ + bool is_integer() const + { + return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT); + } + + /** + * Query whether or not a type is a float type + */ + bool is_float() const + { + return base_type == GLSL_TYPE_FLOAT; + } + + /** + * Query whether or not a type is a non-array boolean type + */ + bool is_boolean() const + { + return base_type == GLSL_TYPE_BOOL; + } + + /** + * Query whether or not a type is a sampler + */ + bool is_sampler() const + { + return base_type == GLSL_TYPE_SAMPLER; + } + + /** + * Query whether or not a type is an array + */ + bool is_array() const + { + return base_type == GLSL_TYPE_ARRAY; + } + + /** + * Query whether or not a type is a record + */ + bool is_record() const + { + return base_type == GLSL_TYPE_STRUCT; + } + + /** + * Query whether or not a type is the void type singleton. + */ + bool is_void() const + { + return base_type == GLSL_TYPE_VOID; + } + + /** + * Query whether or not a type is the error type singleton. + */ + bool is_error() const + { + return base_type == GLSL_TYPE_ERROR; + } + + /** + * Query the full type of a matrix row + * + * \return + * If the type is not a matrix, \c glsl_type::error_type is returned. + * Otherwise a type matching the rows of the matrix is returned. + */ + const glsl_type *row_type() const + { + return is_matrix() + ? get_instance(base_type, matrix_columns, 1) + : error_type; + } + + /** + * Query the full type of a matrix column + * + * \return + * If the type is not a matrix, \c glsl_type::error_type is returned. + * Otherwise a type matching the columns of the matrix is returned. + */ + const glsl_type *column_type() const + { + return is_matrix() + ? get_instance(base_type, vector_elements, 1) + : error_type; + } + + + /** + * Get the type of a structure field + * + * \return + * Pointer to the type of the named field. If the type is not a structure + * or the named field does not exist, \c glsl_type::error_type is returned. + */ + const glsl_type *field_type(const char *name) const; + + + /** + * Get the location of a filed within a record type + */ + int field_index(const char *name) const; + + + /** + * Query the number of elements in an array type + * + * \return + * The number of elements in the array for array types or -1 for non-array + * types. If the number of elements in the array has not yet been declared, + * zero is returned. + */ + int array_size() const + { + return is_array() ? length : -1; + } + +private: + /** + * Constructor for array types + */ + glsl_type(void *ctx, const glsl_type *array, unsigned length); + + /** Hash table containing the known array types. */ + static struct hash_table *array_types; + + static int array_key_compare(const void *a, const void *b); + static unsigned array_key_hash(const void *key); +}; + +struct glsl_struct_field { + const struct glsl_type *type; + const char *name; +}; + +struct _mesa_glsl_parse_state; + +#ifdef __cplusplus +extern "C" { +#endif + +extern void +_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); + +extern void +_mesa_glsl_initialize_constructors(struct exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +#ifdef __cplusplus +} +#endif + +#endif /* GLSL_TYPES_H */ diff --git a/src/glsl/hash_table.c b/src/glsl/hash_table.c new file mode 100644 index 00000000000..e89a2564d76 --- /dev/null +++ b/src/glsl/hash_table.c @@ -0,0 +1,159 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file hash_table.c + * \brief Implementation of a generic, opaque hash table data type. + * + * \author Ian Romanick + */ + +#include "main/imports.h" +#include "main/simple_list.h" +#include "hash_table.h" + +struct node { + struct node *next; + struct node *prev; +}; + +struct hash_table { + hash_func_t hash; + hash_compare_func_t compare; + + unsigned num_buckets; + struct node buckets[1]; +}; + + +struct hash_node { + struct node link; + const void *key; + void *data; +}; + + +struct hash_table * +hash_table_ctor(unsigned num_buckets, hash_func_t hash, + hash_compare_func_t compare) +{ + struct hash_table *ht; + unsigned i; + + + if (num_buckets < 16) { + num_buckets = 16; + } + + ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1) + * sizeof(ht->buckets[0]))); + if (ht != NULL) { + ht->hash = hash; + ht->compare = compare; + ht->num_buckets = num_buckets; + + for (i = 0; i < num_buckets; i++) { + make_empty_list(& ht->buckets[i]); + } + } + + return ht; +} + + +void +hash_table_dtor(struct hash_table *ht) +{ + hash_table_clear(ht); + _mesa_free(ht); +} + + +void +hash_table_clear(struct hash_table *ht) +{ + struct node *node; + struct node *temp; + unsigned i; + + + for (i = 0; i < ht->num_buckets; i++) { + foreach_s(node, temp, & ht->buckets[i]) { + remove_from_list(node); + _mesa_free(node); + } + + assert(is_empty_list(& ht->buckets[i])); + } +} + + +void * +hash_table_find(struct hash_table *ht, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct node *node; + + foreach(node, & ht->buckets[bucket]) { + struct hash_node *hn = (struct hash_node *) node; + + if ((*ht->compare)(hn->key, key) == 0) { + return hn->data; + } + } + + return NULL; +} + + +void +hash_table_insert(struct hash_table *ht, void *data, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct hash_node *node; + + node = _mesa_calloc(sizeof(*node)); + + node->data = data; + node->key = key; + + insert_at_head(& ht->buckets[bucket], & node->link); +} + + +unsigned +hash_table_string_hash(const void *key) +{ + const char *str = (const char *) key; + unsigned hash = 5381; + + + while (*str != '\0') { + hash = (hash * 33) + *str; + str++; + } + + return hash; +} diff --git a/src/glsl/hash_table.h b/src/glsl/hash_table.h new file mode 100644 index 00000000000..b9dd343dee9 --- /dev/null +++ b/src/glsl/hash_table.h @@ -0,0 +1,125 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file hash_table.h + * \brief Implementation of a generic, opaque hash table data type. + * + * \author Ian Romanick + */ + +#ifndef HASH_TABLE_H +#define HASH_TABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +struct hash_table; + +typedef unsigned (*hash_func_t)(const void *key); +typedef int (*hash_compare_func_t)(const void *key1, const void *key2); + +/** + * Hash table constructor + * + * Creates a hash table with the specified number of buckets. The supplied + * \c hash and \c compare routines are used when adding elements to the table + * and when searching for elements in the table. + * + * \param num_buckets Number of buckets (bins) in the hash table. + * \param hash Function used to compute hash value of input keys. + * \param compare Function used to compare keys. + */ +extern struct hash_table *hash_table_ctor(unsigned num_buckets, + hash_func_t hash, hash_compare_func_t compare); + + +/** + * Release all memory associated with a hash table + * + * \warning + * This function cannot release memory occupied either by keys or data. + */ +extern void hash_table_dtor(struct hash_table *ht); + + +/** + * Flush all entries from a hash table + * + * \param ht Table to be cleared of its entries. + */ +extern void hash_table_clear(struct hash_table *ht); + + +/** + * Search a hash table for a specific element + * + * \param ht Table to be searched + * \param key Key of the desired element + * + * \return + * The \c data value supplied to \c hash_table_insert when the element with + * the matching key was added. If no matching key exists in the table, + * \c NULL is returned. + */ +extern void *hash_table_find(struct hash_table *ht, const void *key); + + +/** + * Add an element to a hash table + */ +extern void hash_table_insert(struct hash_table *ht, void *data, + const void *key); + + +/** + * Compute hash value of a string + * + * Computes the hash value of a string using the DJB2 algorithm developed by + * Professor Daniel J. Bernstein. It was published on comp.lang.c once upon + * a time. I was unable to find the original posting in the archives. + * + * \param key Pointer to a NUL terminated string to be hashed. + * + * \sa hash_table_string_compare + */ +extern unsigned hash_table_string_hash(const void *key); + + +/** + * Compare two strings used as keys + * + * This is just a macro wrapper around \c strcmp. + * + * \sa hash_table_string_hash + */ +#define hash_table_string_compare ((hash_compare_func_t) strcmp) + +#ifdef __cplusplus +}; +#endif + +#endif /* HASH_TABLE_H */ diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp new file mode 100644 index 00000000000..e2efff60d34 --- /dev/null +++ b/src/glsl/hir_field_selection.cpp @@ -0,0 +1,81 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" +#include "main/imports.h" +#include "symbol_table.h" +#include "glsl_parser_extras.h" +#include "ast.h" +#include "glsl_types.h" + +struct ir_rvalue * +_mesa_ast_field_selection_to_hir(const ast_expression *expr, + exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + ir_rvalue *result = NULL; + ir_rvalue *op; + + op = expr->subexpressions[0]->hir(instructions, state); + + /* There are two kinds of field selection. There is the selection of a + * specific field from a structure, and there is the selection of a + * swizzle / mask from a vector. Which is which is determined entirely + * by the base type of the thing to which the field selection operator is + * being applied. + */ + YYLTYPE loc = expr->get_location(); + if (op->type->is_error()) { + /* silently propagate the error */ + } else if (op->type->is_vector()) { + ir_swizzle *swiz = ir_swizzle::create(op, + expr->primary_expression.identifier, + op->type->vector_elements); + if (swiz != NULL) { + result = swiz; + } else { + /* FINISHME: Logging of error messages should be moved into + * FINISHME: ir_swizzle::create. This allows the generation of more + * FINISHME: specific error messages. + */ + _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'", + expr->primary_expression.identifier); + } + } else if (op->type->base_type == GLSL_TYPE_STRUCT) { + result = new(ctx) ir_dereference_record(op, + expr->primary_expression.identifier); + + if (result->type->is_error()) { + _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " + "structure", + expr->primary_expression.identifier); + } + } else { + _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " + "non-structure / non-vector.", + expr->primary_expression.identifier); + } + + return result ? result : ir_call::get_error_instruction(ctx); +} diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp new file mode 100644 index 00000000000..2756752ba49 --- /dev/null +++ b/src/glsl/ir.cpp @@ -0,0 +1,818 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "main/imports.h" +#include "ir.h" +#include "ir_visitor.h" +#include "glsl_types.h" + +ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, + ir_rvalue *condition) +{ + this->lhs = lhs; + this->rhs = rhs; + this->condition = condition; +} + + +ir_expression::ir_expression(int op, const struct glsl_type *type, + ir_rvalue *op0, ir_rvalue *op1) +{ + this->type = type; + this->operation = ir_expression_operation(op); + this->operands[0] = op0; + this->operands[1] = op1; +} + +unsigned int +ir_expression::get_num_operands(ir_expression_operation op) +{ +/* Update ir_print_visitor.cpp when updating this list. */ + const int num_operands[] = { + 1, /* ir_unop_bit_not */ + 1, /* ir_unop_logic_not */ + 1, /* ir_unop_neg */ + 1, /* ir_unop_abs */ + 1, /* ir_unop_sign */ + 1, /* ir_unop_rcp */ + 1, /* ir_unop_rsq */ + 1, /* ir_unop_sqrt */ + 1, /* ir_unop_exp */ + 1, /* ir_unop_log */ + 1, /* ir_unop_exp2 */ + 1, /* ir_unop_log2 */ + 1, /* ir_unop_f2i */ + 1, /* ir_unop_i2f */ + 1, /* ir_unop_f2b */ + 1, /* ir_unop_b2f */ + 1, /* ir_unop_i2b */ + 1, /* ir_unop_b2i */ + 1, /* ir_unop_u2f */ + + 1, /* ir_unop_trunc */ + 1, /* ir_unop_ceil */ + 1, /* ir_unop_floor */ + + 1, /* ir_unop_sin */ + 1, /* ir_unop_cos */ + + 1, /* ir_unop_dFdx */ + 1, /* ir_unop_dFdy */ + + 2, /* ir_binop_add */ + 2, /* ir_binop_sub */ + 2, /* ir_binop_mul */ + 2, /* ir_binop_div */ + 2, /* ir_binop_mod */ + + 2, /* ir_binop_less */ + 2, /* ir_binop_greater */ + 2, /* ir_binop_lequal */ + 2, /* ir_binop_gequal */ + 2, /* ir_binop_equal */ + 2, /* ir_binop_nequal */ + + 2, /* ir_binop_lshift */ + 2, /* ir_binop_rshift */ + 2, /* ir_binop_bit_and */ + 2, /* ir_binop_bit_xor */ + 2, /* ir_binop_bit_or */ + + 2, /* ir_binop_logic_and */ + 2, /* ir_binop_logic_xor */ + 2, /* ir_binop_logic_or */ + + 2, /* ir_binop_dot */ + 2, /* ir_binop_min */ + 2, /* ir_binop_max */ + + 2, /* ir_binop_pow */ + }; + + assert(sizeof(num_operands) / sizeof(num_operands[0]) == ir_binop_pow + 1); + + return num_operands[op]; +} + +static const char *const operator_strs[] = { + "~", + "!", + "neg", + "abs", + "sign", + "rcp", + "rsq", + "sqrt", + "exp", + "log", + "exp2", + "log2", + "f2i", + "i2f", + "f2b", + "b2f", + "i2b", + "b2i", + "u2f", + "trunc", + "ceil", + "floor", + "sin", + "cos", + "dFdx", + "dFdy", + "+", + "-", + "*", + "/", + "%", + "<", + ">", + "<=", + ">=", + "==", + "!=", + "<<", + ">>", + "&", + "^", + "|", + "&&", + "^^", + "||", + "dot", + "min", + "max", + "pow", +}; + +const char *ir_expression::operator_string() +{ + assert((unsigned int) operation <= + sizeof(operator_strs) / sizeof(operator_strs[0])); + return operator_strs[operation]; +} + +ir_expression_operation +ir_expression::get_operator(const char *str) +{ + const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]); + for (int op = 0; op < operator_count; op++) { + if (strcmp(str, operator_strs[op]) == 0) + return (ir_expression_operation) op; + } + return (ir_expression_operation) -1; +} + +ir_constant::ir_constant() +{ + /* empty */ +} + +ir_constant::ir_constant(const struct glsl_type *type, + const ir_constant_data *data) +{ + assert((type->base_type >= GLSL_TYPE_UINT) + && (type->base_type <= GLSL_TYPE_BOOL)); + + this->type = type; + memcpy(& this->value, data, sizeof(this->value)); +} + +ir_constant::ir_constant(float f) +{ + this->type = glsl_type::float_type; + this->value.f[0] = f; +} + +ir_constant::ir_constant(unsigned int u) +{ + this->type = glsl_type::uint_type; + this->value.u[0] = u; +} + +ir_constant::ir_constant(int i) +{ + this->type = glsl_type::int_type; + this->value.i[0] = i; +} + +ir_constant::ir_constant(bool b) +{ + this->type = glsl_type::bool_type; + this->value.b[0] = b; +} + +ir_constant::ir_constant(const ir_constant *c, unsigned i) +{ + this->type = c->type->get_base_type(); + + switch (this->type->base_type) { + case GLSL_TYPE_UINT: this->value.u[0] = c->value.u[i]; break; + case GLSL_TYPE_INT: this->value.i[0] = c->value.i[i]; break; + case GLSL_TYPE_FLOAT: this->value.f[0] = c->value.f[i]; break; + case GLSL_TYPE_BOOL: this->value.b[0] = c->value.b[i]; break; + default: assert(!"Should not get here."); break; + } +} + +ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) +{ + this->type = type; + + /* FINISHME: Support array types. */ + assert(type->is_scalar() || type->is_vector() || type->is_matrix() + || type->is_record()); + + /* If the constant is a record, the types of each of the entries in + * value_list must be a 1-for-1 match with the structure components. Each + * entry must also be a constant. Just move the nodes from the value_list + * to the list in the ir_constant. + */ + /* FINISHME: Should there be some type checking and / or assertions here? */ + /* FINISHME: Should the new constant take ownership of the nodes from + * FINISHME: value_list, or should it make copies? + */ + if (type->is_record()) { + value_list->move_nodes_to(& this->components); + return; + } + + + ir_constant *value = (ir_constant *) (value_list->head); + + /* Use each component from each entry in the value_list to initialize one + * component of the constant being constructed. + */ + for (unsigned i = 0; i < type->components(); /* empty */) { + assert(value->as_constant() != NULL); + assert(!value->is_tail_sentinal()); + + for (unsigned j = 0; j < value->type->components(); j++) { + switch (type->base_type) { + case GLSL_TYPE_UINT: + this->value.u[i] = value->get_uint_component(j); + break; + case GLSL_TYPE_INT: + this->value.i[i] = value->get_int_component(j); + break; + case GLSL_TYPE_FLOAT: + this->value.f[i] = value->get_float_component(j); + break; + case GLSL_TYPE_BOOL: + this->value.b[i] = value->get_bool_component(j); + break; + default: + /* FINISHME: What to do? Exceptions are not the answer. + */ + break; + } + + i++; + if (i >= type->components()) + break; + } + + value = (ir_constant *) value->next; + } +} + +bool +ir_constant::get_bool_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return this->value.u[i] != 0; + case GLSL_TYPE_INT: return this->value.i[i] != 0; + case GLSL_TYPE_FLOAT: return ((int)this->value.f[i]) != 0; + case GLSL_TYPE_BOOL: return this->value.b[i]; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return false; +} + +float +ir_constant::get_float_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return (float) this->value.u[i]; + case GLSL_TYPE_INT: return (float) this->value.i[i]; + case GLSL_TYPE_FLOAT: return this->value.f[i]; + case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0 : 0.0; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return 0.0; +} + +int +ir_constant::get_int_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return this->value.u[i]; + case GLSL_TYPE_INT: return this->value.i[i]; + case GLSL_TYPE_FLOAT: return (int) this->value.f[i]; + case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return 0; +} + +unsigned +ir_constant::get_uint_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return this->value.u[i]; + case GLSL_TYPE_INT: return this->value.i[i]; + case GLSL_TYPE_FLOAT: return (unsigned) this->value.f[i]; + case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return 0; +} + + +ir_constant * +ir_constant::get_record_field(const char *name) +{ + int idx = this->type->field_index(name); + + if (idx < 0) + return NULL; + + if (this->components.is_empty()) + return NULL; + + exec_node *node = this->components.head; + for (int i = 0; i < idx; i++) { + node = node->next; + + /* If the end of the list is encountered before the element matching the + * requested field is found, return NULL. + */ + if (node->is_tail_sentinal()) + return NULL; + } + + return (ir_constant *) node; +} + + +bool +ir_constant::has_value(const ir_constant *c) const +{ + if (this->type != c->type) + return false; + + /* FINISHME: This will probably also handle constant arrays as soon as those + * FINISHME: are supported. + */ + if (this->type->base_type == GLSL_TYPE_STRUCT) { + const exec_node *a_node = this->components.head; + const exec_node *b_node = c->components.head; + + while (!a_node->is_tail_sentinal()) { + assert(!b_node->is_tail_sentinal()); + + const ir_constant *const a_field = (ir_constant *) a_node; + const ir_constant *const b_field = (ir_constant *) b_node; + + if (!a_field->has_value(b_field)) + return false; + + a_node = a_node->next; + b_node = b_node->next; + } + + return true; + } + + for (unsigned i = 0; i < this->type->components(); i++) { + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + if (this->value.u[i] != c->value.u[i]) + return false; + break; + case GLSL_TYPE_INT: + if (this->value.i[i] != c->value.i[i]) + return false; + break; + case GLSL_TYPE_FLOAT: + if (this->value.f[i] != c->value.f[i]) + return false; + break; + case GLSL_TYPE_BOOL: + if (this->value.b[i] != c->value.b[i]) + return false; + break; + default: + assert(!"Should not get here."); + return false; + } + } + + return true; +} + +ir_dereference_variable::ir_dereference_variable(ir_variable *var) +{ + this->var = var; + this->type = (var != NULL) ? var->type : glsl_type::error_type; +} + + +ir_dereference_array::ir_dereference_array(ir_rvalue *value, + ir_rvalue *array_index) +{ + this->array_index = array_index; + this->set_array(value); +} + + +ir_dereference_array::ir_dereference_array(ir_variable *var, + ir_rvalue *array_index) +{ + void *ctx = talloc_parent(var); + + this->array_index = array_index; + this->set_array(new(ctx) ir_dereference_variable(var)); +} + + +void +ir_dereference_array::set_array(ir_rvalue *value) +{ + this->array = value; + this->type = glsl_type::error_type; + + if (this->array != NULL) { + const glsl_type *const vt = this->array->type; + + if (vt->is_array()) { + type = vt->element_type(); + } else if (vt->is_matrix()) { + type = vt->column_type(); + } else if (vt->is_vector()) { + type = vt->get_base_type(); + } + } +} + + +ir_dereference_record::ir_dereference_record(ir_rvalue *value, + const char *field) +{ + this->record = value; + this->field = field; + this->type = (this->record != NULL) + ? this->record->type->field_type(field) : glsl_type::error_type; +} + + +ir_dereference_record::ir_dereference_record(ir_variable *var, + const char *field) +{ + void *ctx = talloc_parent(var); + + this->record = new(ctx) ir_dereference_variable(var); + this->field = field; + this->type = (this->record != NULL) + ? this->record->type->field_type(field) : glsl_type::error_type; +} + + +bool +ir_dereference::is_lvalue() +{ + ir_variable *var = this->variable_referenced(); + + /* Every l-value derference chain eventually ends in a variable. + */ + if ((var == NULL) || var->read_only) + return false; + + if (this->type->is_array() && !var->array_lvalue) + return false; + + return true; +} + + +const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf" }; + +const char *ir_texture::opcode_string() +{ + assert((unsigned int) op <= + sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0])); + return tex_opcode_strs[op]; +} + +ir_texture_opcode +ir_texture::get_opcode(const char *str) +{ + const int count = sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]); + for (int op = 0; op < count; op++) { + if (strcmp(str, tex_opcode_strs[op]) == 0) + return (ir_texture_opcode) op; + } + return (ir_texture_opcode) -1; +} + + +void +ir_texture::set_sampler(ir_dereference *sampler) +{ + assert(sampler != NULL); + this->sampler = sampler; + + switch (sampler->type->sampler_type) { + case GLSL_TYPE_FLOAT: + this->type = glsl_type::vec4_type; + break; + case GLSL_TYPE_INT: + this->type = glsl_type::ivec4_type; + break; + case GLSL_TYPE_UINT: + this->type = glsl_type::uvec4_type; + break; + } +} + + +ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, + unsigned w, unsigned count) + : val(val) +{ + assert((count >= 1) && (count <= 4)); + + const unsigned dup_mask = 0 + | ((count > 1) ? ((1U << y) & ((1U << x) )) : 0) + | ((count > 2) ? ((1U << z) & ((1U << x) | (1U << y) )) : 0) + | ((count > 3) ? ((1U << w) & ((1U << x) | (1U << y) | (1U << z))) : 0); + + assert(x <= 3); + assert(y <= 3); + assert(z <= 3); + assert(w <= 3); + + mask.x = x; + mask.y = y; + mask.z = z; + mask.w = w; + mask.num_components = count; + mask.has_duplicates = dup_mask != 0; + + /* Based on the number of elements in the swizzle and the base type + * (i.e., float, int, unsigned, or bool) of the vector being swizzled, + * generate the type of the resulting value. + */ + type = glsl_type::get_instance(val->type->base_type, mask.num_components, 1); +} + +ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) +{ + this->val = val; + this->mask = mask; + this->type = glsl_type::get_instance(val->type->base_type, + mask.num_components, 1); +} + +#define X 1 +#define R 5 +#define S 9 +#define I 13 + +ir_swizzle * +ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) +{ + void *ctx = talloc_parent(val); + + /* For each possible swizzle character, this table encodes the value in + * \c idx_map that represents the 0th element of the vector. For invalid + * swizzle characters (e.g., 'k'), a special value is used that will allow + * detection of errors. + */ + static const unsigned char base_idx[26] = { + /* a b c d e f g h i j k l m */ + R, R, I, I, I, I, R, I, I, I, I, I, I, + /* n o p q r s t u v w x y z */ + I, I, S, S, R, S, S, I, I, X, X, X, X + }; + + /* Each valid swizzle character has an entry in the previous table. This + * table encodes the base index encoded in the previous table plus the actual + * index of the swizzle character. When processing swizzles, the first + * character in the string is indexed in the previous table. Each character + * in the string is indexed in this table, and the value found there has the + * value form the first table subtracted. The result must be on the range + * [0,3]. + * + * For example, the string "wzyx" will get X from the first table. Each of + * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After + * subtraction, the swizzle values are { 3, 2, 1, 0 }. + * + * The string "wzrg" will get X from the first table. Each of the characters + * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the + * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range + * [0,3], the error is detected. + */ + static const unsigned char idx_map[26] = { + /* a b c d e f g h i j k l m */ + R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, + /* n o p q r s t u v w x y z */ + 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2 + }; + + int swiz_idx[4] = { 0, 0, 0, 0 }; + unsigned i; + + + /* Validate the first character in the swizzle string and look up the base + * index value as described above. + */ + if ((str[0] < 'a') || (str[0] > 'z')) + return NULL; + + const unsigned base = base_idx[str[0] - 'a']; + + + for (i = 0; (i < 4) && (str[i] != '\0'); i++) { + /* Validate the next character, and, as described above, convert it to a + * swizzle index. + */ + if ((str[i] < 'a') || (str[i] > 'z')) + return NULL; + + swiz_idx[i] = idx_map[str[i] - 'a'] - base; + if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) + return NULL; + } + + if (str[i] != '\0') + return NULL; + + return new(ctx) ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2], + swiz_idx[3], i); +} + +#undef X +#undef R +#undef S +#undef I + +ir_variable * +ir_swizzle::variable_referenced() +{ + return this->val->variable_referenced(); +} + +ir_variable::ir_variable(const struct glsl_type *type, const char *name) + : max_array_access(0), read_only(false), centroid(false), invariant(false), + shader_in(false), shader_out(false), + mode(ir_var_auto), interpolation(ir_var_smooth), array_lvalue(false) +{ + this->type = type; + this->name = name; + this->location = -1; + this->warn_extension = NULL; + this->constant_value = NULL; + + if (type && type->base_type == GLSL_TYPE_SAMPLER) + this->read_only = true; +} + + +const char * +ir_variable::interpolation_string() const +{ + if (!this->shader_in && !this->shader_out) + return ""; + + switch (this->interpolation) { + case ir_var_smooth: return "smooth"; + case ir_var_flat: return "flat"; + case ir_var_noperspective: return "noperspective"; + } + + assert(!"Should not get here."); + return ""; +} + + +unsigned +ir_variable::component_slots() const +{ + /* FINISHME: Sparsely accessed arrays require fewer slots. */ + return this->type->component_slots(); +} + + +ir_function_signature::ir_function_signature(const glsl_type *return_type) + : return_type(return_type), is_defined(false) +{ + /* empty */ +} + + +const char * +ir_function_signature::qualifiers_match(exec_list *params) +{ + exec_list_iterator iter_a = parameters.iterator(); + exec_list_iterator iter_b = params->iterator(); + + /* check that the qualifiers match. */ + while (iter_a.has_next()) { + ir_variable *a = (ir_variable *)iter_a.get(); + ir_variable *b = (ir_variable *)iter_b.get(); + + if (a->read_only != b->read_only || + a->mode != b->mode || + a->interpolation != b->interpolation || + a->centroid != b->centroid) { + + /* parameter a's qualifiers don't match */ + return a->name; + } + + iter_a.next(); + iter_b.next(); + } + return NULL; +} + + +void +ir_function_signature::replace_parameters(exec_list *new_params) +{ + /* Destroy all of the previous parameter information. If the previous + * parameter information comes from the function prototype, it may either + * specify incorrect parameter names or not have names at all. + */ + foreach_iter(exec_list_iterator, iter, parameters) { + assert(((ir_instruction *) iter.get())->as_variable() != NULL); + + iter.remove(); + } + + new_params->move_nodes_to(¶meters); +} + + +ir_function::ir_function(const char *name) + : name(name) +{ + /* empty */ +} + + +ir_call * +ir_call::get_error_instruction(void *ctx) +{ + ir_call *call = new(ctx) ir_call; + + call->type = glsl_type::error_type; + return call; +} + +void +visit_exec_list(exec_list *list, ir_visitor *visitor) +{ + foreach_iter(exec_list_iterator, iter, *list) { + ((ir_instruction *)iter.get())->accept(visitor); + } +} + diff --git a/src/glsl/ir.h b/src/glsl/ir.h new file mode 100644 index 00000000000..3d2c7ff5cf5 --- /dev/null +++ b/src/glsl/ir.h @@ -0,0 +1,1178 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_H +#define IR_H + +#include +#include + +extern "C" { +#include +} + +#include "list.h" +#include "ir_visitor.h" +#include "ir_hierarchical_visitor.h" + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + +struct ir_program { + void *bong_hits; +}; + +/** + * Base class of all IR instructions + */ +class ir_instruction : public exec_node { +public: + const struct glsl_type *type; + + class ir_constant *constant_expression_value(); + + /** ir_print_visitor helper for debugging. */ + void print(void) const; + + virtual void accept(ir_visitor *) = 0; + virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0; + virtual ir_instruction *clone(struct hash_table *ht) const = 0; + + /** + * \name IR instruction downcast functions + * + * These functions either cast the object to a derived class or return + * \c NULL if the object's type does not match the specified derived class. + * Additional downcast functions will be added as needed. + */ + /*@{*/ + virtual class ir_variable * as_variable() { return NULL; } + virtual class ir_function * as_function() { return NULL; } + virtual class ir_dereference * as_dereference() { return NULL; } + virtual class ir_dereference_array * as_dereference_array() { return NULL; } + virtual class ir_rvalue * as_rvalue() { return NULL; } + virtual class ir_loop * as_loop() { return NULL; } + virtual class ir_assignment * as_assignment() { return NULL; } + virtual class ir_call * as_call() { return NULL; } + virtual class ir_return * as_return() { return NULL; } + virtual class ir_if * as_if() { return NULL; } + virtual class ir_swizzle * as_swizzle() { return NULL; } + virtual class ir_constant * as_constant() { return NULL; } + /*@}*/ + +protected: + ir_instruction() + { + /* empty */ + } +}; + + +class ir_rvalue : public ir_instruction { +public: + virtual ir_rvalue * as_rvalue() + { + return this; + } + + virtual bool is_lvalue() + { + return false; + } + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() + { + return NULL; + } + + + /** + * If an r-value is a reference to a whole variable, get that variable + * + * \return + * Pointer to a variable that is completely dereferenced by the r-value. If + * the r-value is not a dereference or the dereference does not access the + * entire variable (i.e., it's just one array element, struct field), \c NULL + * is returned. + */ + virtual ir_variable *whole_variable_referenced() + { + return NULL; + } + +protected: + ir_rvalue() + { + /* empty */ + } +}; + + +enum ir_variable_mode { + ir_var_auto = 0, + ir_var_uniform, + ir_var_in, + ir_var_out, + ir_var_inout +}; + +enum ir_variable_interpolation { + ir_var_smooth = 0, + ir_var_flat, + ir_var_noperspective +}; + + +class ir_variable : public ir_instruction { +public: + ir_variable(const struct glsl_type *, const char *); + + virtual ir_instruction *clone(struct hash_table *ht) const; + + virtual ir_variable *as_variable() + { + return this; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + + /** + * Get the string value for the interpolation qualifier + * + * \return + * If none of \c shader_in or \c shader_out is set, an empty string will + * be returned. Otherwise the string that would be used in a shader to + * specify \c mode will be returned. + */ + const char *interpolation_string() const; + + /** + * Calculate the number of slots required to hold this variable + * + * This is used to determine how many uniform or varying locations a variable + * occupies. The count is in units of floating point components. + */ + unsigned component_slots() const; + + const char *name; + + /** + * Highest element accessed with a constant expression array index + * + * Not used for non-array variables. + */ + unsigned max_array_access; + + unsigned read_only:1; + unsigned centroid:1; + unsigned invariant:1; + /** If the variable is initialized outside of the scope of the shader */ + unsigned shader_in:1; + /** + * If the variable value is later used outside of the scope of the shader. + */ + unsigned shader_out:1; + + unsigned mode:3; + unsigned interpolation:2; + + /** + * Flag that the whole array is assignable + * + * In GLSL 1.20 and later whole arrays are assignable (and comparable for + * equality). This flag enables this behavior. + */ + unsigned array_lvalue:1; + + /** + * Storage location of the base of this variable + * + * The precise meaning of this field depends on the nature of the variable. + * + * - Vertex shader input: one of the values from \c gl_vert_attrib. + * - Vertex shader output: one of the values from \c gl_vert_result. + * - Fragment shader input: one of the values from \c gl_frag_attrib. + * - Fragment shader output: one of the values from \c gl_frag_result. + * - Uniforms: Per-stage uniform slot number. + * - Other: This field is not currently used. + * + * If the variable is a uniform, shader input, or shader output, and the + * slot has not been assigned, the value will be -1. + */ + int location; + + /** + * Emit a warning if this variable is accessed. + */ + const char *warn_extension; + + /** + * Value assigned in the initializer of a variable declared "const" + */ + ir_constant *constant_value; +}; + + +/*@{*/ +/** + * The representation of a function instance; may be the full definition or + * simply a prototype. + */ +class ir_function_signature : public ir_instruction { + /* An ir_function_signature will be part of the list of signatures in + * an ir_function. + */ +public: + ir_function_signature(const glsl_type *return_type); + + virtual ir_instruction *clone(struct hash_table *ht) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Get the name of the function for which this is a signature + */ + const char *function_name() const; + + /** + * Check whether the qualifiers match between this signature's parameters + * and the supplied parameter list. If not, returns the name of the first + * parameter with mismatched qualifiers (for use in error messages). + */ + const char *qualifiers_match(exec_list *params); + + /** + * Replace the current parameter list with the given one. This is useful + * if the current information came from a prototype, and either has invalid + * or missing parameter names. + */ + void replace_parameters(exec_list *new_params); + + /** + * Function return type. + * + * \note This discards the optional precision qualifier. + */ + const struct glsl_type *return_type; + + /** + * List of ir_variable of function parameters. + * + * This represents the storage. The paramaters passed in a particular + * call will be in ir_call::actual_paramaters. + */ + struct exec_list parameters; + + /** Whether or not this function has a body (which may be empty). */ + unsigned is_defined:1; + + /** Body of instructions in the function. */ + struct exec_list body; + +private: + /** Function of which this signature is one overload. */ + class ir_function *function; + + friend class ir_function; +}; + + +/** + * Header for tracking multiple overloaded functions with the same name. + * Contains a list of ir_function_signatures representing each of the + * actual functions. + */ +class ir_function : public ir_instruction { +public: + ir_function(const char *name); + + virtual ir_instruction *clone(struct hash_table *ht) const; + + virtual ir_function *as_function() + { + return this; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + void add_signature(ir_function_signature *sig) + { + sig->function = this; + signatures.push_tail(sig); + } + + /** + * Get an iterator for the set of function signatures + */ + exec_list_iterator iterator() + { + return signatures.iterator(); + } + + /** + * Find a signature that matches a set of actual parameters, taking implicit + * conversions into account. + */ + const ir_function_signature *matching_signature(exec_list *actual_param); + + /** + * Find a signature that exactly matches a set of actual parameters without + * any implicit type conversions. + */ + ir_function_signature *exact_matching_signature(exec_list *actual_ps); + + /** + * Name of the function. + */ + const char *name; + +private: + /** + * List of ir_function_signature for each overloaded function with this name. + */ + struct exec_list signatures; +}; + +inline const char *ir_function_signature::function_name() const +{ + return function->name; +} +/*@}*/ + + +/** + * IR instruction representing high-level if-statements + */ +class ir_if : public ir_instruction { +public: + ir_if(ir_rvalue *condition) + : condition(condition) + { + /* empty */ + } + + virtual ir_instruction *clone(struct hash_table *ht) const; + + virtual ir_if *as_if() + { + return this; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_rvalue *condition; + /** List of ir_instruction for the body of the then branch */ + exec_list then_instructions; + /** List of ir_instruction for the body of the else branch */ + exec_list else_instructions; +}; + + +/** + * IR instruction representing a high-level loop structure. + */ +class ir_loop : public ir_instruction { +public: + ir_loop() : from(NULL), to(NULL), increment(NULL), counter(NULL) + { + /* empty */ + } + + virtual ir_instruction *clone(struct hash_table *ht) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + virtual ir_loop *as_loop() + { + return this; + } + + /** + * Get an iterator for the instructions of the loop body + */ + exec_list_iterator iterator() + { + return body_instructions.iterator(); + } + + /** List of ir_instruction that make up the body of the loop. */ + exec_list body_instructions; + + /** + * \name Loop counter and controls + */ + /*@{*/ + ir_rvalue *from; + ir_rvalue *to; + ir_rvalue *increment; + ir_variable *counter; + /*@}*/ +}; + + +class ir_assignment : public ir_rvalue { +public: + ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); + + virtual ir_instruction *clone(struct hash_table *ht) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + virtual ir_assignment * as_assignment() + { + return this; + } + + /** + * Left-hand side of the assignment. + */ + ir_rvalue *lhs; + + /** + * Value being assigned + */ + ir_rvalue *rhs; + + /** + * Optional condition for the assignment. + */ + ir_rvalue *condition; +}; + +/* Update ir_expression::num_operands() and operator_strs when + * updating this list. + */ +enum ir_expression_operation { + ir_unop_bit_not, + ir_unop_logic_not, + ir_unop_neg, + ir_unop_abs, + ir_unop_sign, + ir_unop_rcp, + ir_unop_rsq, + ir_unop_sqrt, + ir_unop_exp, + ir_unop_log, + ir_unop_exp2, + ir_unop_log2, + ir_unop_f2i, /**< Float-to-integer conversion. */ + ir_unop_i2f, /**< Integer-to-float conversion. */ + ir_unop_f2b, /**< Float-to-boolean conversion */ + ir_unop_b2f, /**< Boolean-to-float conversion */ + ir_unop_i2b, /**< int-to-boolean conversion */ + ir_unop_b2i, /**< Boolean-to-int conversion */ + ir_unop_u2f, /**< Unsigned-to-float conversion. */ + + /** + * \name Unary floating-point rounding operations. + */ + /*@{*/ + ir_unop_trunc, + ir_unop_ceil, + ir_unop_floor, + /*@}*/ + + /** + * \name Trigonometric operations. + */ + /*@{*/ + ir_unop_sin, + ir_unop_cos, + /*@}*/ + + /** + * \name Partial derivatives. + */ + /*@{*/ + ir_unop_dFdx, + ir_unop_dFdy, + /*@}*/ + + ir_binop_add, + ir_binop_sub, + ir_binop_mul, + ir_binop_div, + ir_binop_mod, + + /** + * \name Binary comparison operators + */ + /*@{*/ + ir_binop_less, + ir_binop_greater, + ir_binop_lequal, + ir_binop_gequal, + ir_binop_equal, + ir_binop_nequal, + /*@}*/ + + /** + * \name Bit-wise binary operations. + */ + /*@{*/ + ir_binop_lshift, + ir_binop_rshift, + ir_binop_bit_and, + ir_binop_bit_xor, + ir_binop_bit_or, + /*@}*/ + + ir_binop_logic_and, + ir_binop_logic_xor, + ir_binop_logic_or, + + ir_binop_dot, + ir_binop_min, + ir_binop_max, + + ir_binop_pow +}; + +class ir_expression : public ir_rvalue { +public: + ir_expression(int op, const struct glsl_type *type, + ir_rvalue *, ir_rvalue *); + + virtual ir_instruction *clone(struct hash_table *ht) const; + + static unsigned int get_num_operands(ir_expression_operation); + unsigned int get_num_operands() const + { + return get_num_operands(operation); + } + + /** + * Return a string representing this expression's operator. + */ + const char *operator_string(); + + /** + * Do a reverse-lookup to translate the given string into an operator. + */ + static ir_expression_operation get_operator(const char *); + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_expression_operation operation; + ir_rvalue *operands[2]; +}; + + +/** + * IR instruction representing a function call + */ +class ir_call : public ir_rvalue { +public: + ir_call(const ir_function_signature *callee, exec_list *actual_parameters) + : callee(callee) + { + assert(callee->return_type != NULL); + type = callee->return_type; + actual_parameters->move_nodes_to(& this->actual_parameters); + } + + virtual ir_instruction *clone(struct hash_table *ht) const; + + virtual ir_call *as_call() + { + return this; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Get a generic ir_call object when an error occurs + * + * Any allocation will be performed with 'ctx' as talloc owner. + */ + static ir_call *get_error_instruction(void *ctx); + + /** + * Get an iterator for the set of acutal parameters + */ + exec_list_iterator iterator() + { + return actual_parameters.iterator(); + } + + /** + * Get the name of the function being called. + */ + const char *callee_name() const + { + return callee->function_name(); + } + + const ir_function_signature *get_callee() + { + return callee; + } + + /** + * Generates an inline version of the function before @ir, + * returning the return value of the function. + */ + ir_rvalue *generate_inline(ir_instruction *ir); + +private: + ir_call() + : callee(NULL) + { + /* empty */ + } + + const ir_function_signature *callee; + + /* List of ir_rvalue of paramaters passed in this call. */ + exec_list actual_parameters; +}; + + +/** + * \name Jump-like IR instructions. + * + * These include \c break, \c continue, \c return, and \c discard. + */ +/*@{*/ +class ir_jump : public ir_instruction { +protected: + ir_jump() + { + /* empty */ + } +}; + +class ir_return : public ir_jump { +public: + ir_return() + : value(NULL) + { + /* empty */ + } + + ir_return(ir_rvalue *value) + : value(value) + { + /* empty */ + } + + virtual ir_instruction *clone(struct hash_table *) const; + + virtual ir_return *as_return() + { + return this; + } + + ir_rvalue *get_value() const + { + return value; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_rvalue *value; +}; + + +/** + * Jump instructions used inside loops + * + * These include \c break and \c continue. The \c break within a loop is + * different from the \c break within a switch-statement. + * + * \sa ir_switch_jump + */ +class ir_loop_jump : public ir_jump { +public: + enum jump_mode { + jump_break, + jump_continue + }; + + ir_loop_jump(jump_mode mode) + { + this->mode = mode; + this->loop = loop; + } + + virtual ir_instruction *clone(struct hash_table *) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + bool is_break() const + { + return mode == jump_break; + } + + bool is_continue() const + { + return mode == jump_continue; + } + + /** Mode selector for the jump instruction. */ + enum jump_mode mode; +private: + /** Loop containing this break instruction. */ + ir_loop *loop; +}; +/*@}*/ + + +/** + * Texture sampling opcodes used in ir_texture + */ +enum ir_texture_opcode { + ir_tex, /* Regular texture look-up */ + ir_txb, /* Texture look-up with LOD bias */ + ir_txl, /* Texture look-up with explicit LOD */ + ir_txd, /* Texture look-up with partial derivatvies */ + ir_txf /* Texel fetch with explicit LOD */ +}; + + +/** + * IR instruction to sample a texture + * + * The specific form of the IR instruction depends on the \c mode value + * selected from \c ir_texture_opcodes. In the printed IR, these will + * appear as: + * + * Texel offset + * | Projection divisor + * | | Shadow comparitor + * | | | + * v v v + * (tex (sampler) (coordinate) (0 0 0) (1) ( )) + * (txb (sampler) (coordinate) (0 0 0) (1) ( ) (bias)) + * (txl (sampler) (coordinate) (0 0 0) (1) ( ) (lod)) + * (txd (sampler) (coordinate) (0 0 0) (1) ( ) (dPdx dPdy)) + * (txf (sampler) (coordinate) (0 0 0) (lod)) + */ +class ir_texture : public ir_rvalue { +public: + ir_texture(enum ir_texture_opcode op) + : op(op), projector(NULL), shadow_comparitor(NULL) + { + /* empty */ + } + + virtual ir_instruction *clone(struct hash_table *) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Return a string representing the ir_texture_opcode. + */ + const char *opcode_string(); + + /** Set the sampler and infer the type. */ + void set_sampler(ir_dereference *sampler); + + /** + * Do a reverse-lookup to translate a string into an ir_texture_opcode. + */ + static ir_texture_opcode get_opcode(const char *); + + enum ir_texture_opcode op; + + /** Sampler to use for the texture access. */ + ir_dereference *sampler; + + /** Texture coordinate to sample */ + ir_rvalue *coordinate; + + /** + * Value used for projective divide. + * + * If there is no projective divide (the common case), this will be + * \c NULL. Optimization passes should check for this to point to a constant + * of 1.0 and replace that with \c NULL. + */ + ir_rvalue *projector; + + /** + * Coordinate used for comparison on shadow look-ups. + * + * If there is no shadow comparison, this will be \c NULL. For the + * \c ir_txf opcode, this *must* be \c NULL. + */ + ir_rvalue *shadow_comparitor; + + /** Explicit texel offsets. */ + signed char offsets[3]; + + union { + ir_rvalue *lod; /**< Floating point LOD */ + ir_rvalue *bias; /**< Floating point LOD bias */ + struct { + ir_rvalue *dPdx; /**< Partial derivative of coordinate wrt X */ + ir_rvalue *dPdy; /**< Partial derivative of coordinate wrt Y */ + } grad; + } lod_info; +}; + + +struct ir_swizzle_mask { + unsigned x:2; + unsigned y:2; + unsigned z:2; + unsigned w:2; + + /** + * Number of components in the swizzle. + */ + unsigned num_components:3; + + /** + * Does the swizzle contain duplicate components? + * + * L-value swizzles cannot contain duplicate components. + */ + unsigned has_duplicates:1; +}; + + +class ir_swizzle : public ir_rvalue { +public: + ir_swizzle(ir_rvalue *, unsigned x, unsigned y, unsigned z, unsigned w, + unsigned count); + ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask); + + virtual ir_instruction *clone(struct hash_table *) const; + + virtual ir_swizzle *as_swizzle() + { + return this; + } + + /** + * Construct an ir_swizzle from the textual representation. Can fail. + */ + static ir_swizzle *create(ir_rvalue *, const char *, unsigned vector_length); + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + bool is_lvalue() + { + return val->is_lvalue() && !mask.has_duplicates; + } + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced(); + + ir_rvalue *val; + ir_swizzle_mask mask; +}; + + +class ir_dereference : public ir_rvalue { +public: + virtual ir_dereference *as_dereference() + { + return this; + } + + bool is_lvalue(); + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() = 0; +}; + + +class ir_dereference_variable : public ir_dereference { +public: + ir_dereference_variable(ir_variable *var); + + virtual ir_instruction *clone(struct hash_table *) const; + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() + { + return this->var; + } + + virtual ir_variable *whole_variable_referenced() + { + /* ir_dereference_variable objects always dereference the entire + * variable. However, if this dereference is dereferenced by anything + * else, the complete deferefernce chain is not a whole-variable + * dereference. This method should only be called on the top most + * ir_rvalue in a dereference chain. + */ + return this->var; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Object being dereferenced. + */ + ir_variable *var; +}; + + +class ir_dereference_array : public ir_dereference { +public: + ir_dereference_array(ir_rvalue *value, ir_rvalue *array_index); + + ir_dereference_array(ir_variable *var, ir_rvalue *array_index); + + virtual ir_instruction *clone(struct hash_table *) const; + + virtual ir_dereference_array *as_dereference_array() + { + return this; + } + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() + { + return this->array->variable_referenced(); + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_rvalue *array; + ir_rvalue *array_index; + +private: + void set_array(ir_rvalue *value); +}; + + +class ir_dereference_record : public ir_dereference { +public: + ir_dereference_record(ir_rvalue *value, const char *field); + + ir_dereference_record(ir_variable *var, const char *field); + + virtual ir_instruction *clone(struct hash_table *) const; + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() + { + return this->record->variable_referenced(); + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_rvalue *record; + const char *field; +}; + + +/** + * Data stored in an ir_constant + */ +union ir_constant_data { + unsigned u[16]; + int i[16]; + float f[16]; + bool b[16]; +}; + + +class ir_constant : public ir_rvalue { +public: + ir_constant(const struct glsl_type *type, const ir_constant_data *data); + ir_constant(bool b); + ir_constant(unsigned int u); + ir_constant(int i); + ir_constant(float f); + + /** + * Construct an ir_constant from a list of ir_constant values + */ + ir_constant(const struct glsl_type *type, exec_list *values); + + /** + * Construct an ir_constant from a scalar component of another ir_constant + * + * The new \c ir_constant inherits the type of the component from the + * source constant. + * + * \note + * In the case of a matrix constant, the new constant is a scalar, \b not + * a vector. + */ + ir_constant(const ir_constant *c, unsigned i); + + virtual ir_instruction *clone(struct hash_table *) const; + + virtual ir_constant *as_constant() + { + return this; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Get a particular component of a constant as a specific type + * + * This is useful, for example, to get a value from an integer constant + * as a float or bool. This appears frequently when constructors are + * called with all constant parameters. + */ + /*@{*/ + bool get_bool_component(unsigned i) const; + float get_float_component(unsigned i) const; + int get_int_component(unsigned i) const; + unsigned get_uint_component(unsigned i) const; + /*@}*/ + + ir_constant *get_record_field(const char *name); + + /** + * Determine whether a constant has the same value as another constant + */ + bool has_value(const ir_constant *) const; + + /** + * Value of the constant. + * + * The field used to back the values supplied by the constant is determined + * by the type associated with the \c ir_instruction. Constants may be + * scalars, vectors, or matrices. + */ + union ir_constant_data value; + + exec_list components; + +private: + /** + * Parameterless constructor only used by the clone method + */ + ir_constant(void); +}; + +void +visit_exec_list(exec_list *list, ir_visitor *visitor); + +void validate_ir_tree(exec_list *instructions); + +extern void +_mesa_glsl_initialize_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +extern void +_mesa_glsl_initialize_functions(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +#endif /* IR_H */ diff --git a/src/glsl/ir_basic_block.cpp b/src/glsl/ir_basic_block.cpp new file mode 100644 index 00000000000..f9953ea42da --- /dev/null +++ b/src/glsl/ir_basic_block.cpp @@ -0,0 +1,144 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_basic_block.cpp + * + * Basic block analysis of instruction streams. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_basic_block.h" +#include "glsl_types.h" + +class ir_has_call_visitor : public ir_hierarchical_visitor { +public: + ir_has_call_visitor() + { + has_call = false; + } + + virtual ir_visitor_status visit_enter(ir_call *ir) + { + (void) ir; + has_call = true; + return visit_stop; + } + + bool has_call; +}; + +/** + * Calls a user function for every basic block in the instruction stream. + * + * Basic block analysis is pretty easy in our IR thanks to the lack of + * unstructured control flow. We've got: + * + * ir_loop (for () {}, while () {}, do {} while ()) + * ir_loop_jump ( + * ir_if () {} + * ir_return + * ir_call() + * + * Note that the basic blocks returned by this don't encompass all + * operations performed by the program -- for example, if conditions + * don't get returned, nor do the assignments that will be generated + * for ir_call parameters. + */ +void call_for_basic_blocks(exec_list *instructions, + void (*callback)(ir_instruction *first, + ir_instruction *last, + void *data), + void *data) +{ + ir_instruction *leader = NULL; + ir_instruction *last = NULL; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_if *ir_if; + ir_loop *ir_loop; + ir_function *ir_function; + + if (!leader) + leader = ir; + + if ((ir_if = ir->as_if())) { + callback(leader, ir, data); + leader = NULL; + + call_for_basic_blocks(&ir_if->then_instructions, callback, data); + call_for_basic_blocks(&ir_if->else_instructions, callback, data); + } else if ((ir_loop = ir->as_loop())) { + callback(leader, ir, data); + leader = NULL; + call_for_basic_blocks(&ir_loop->body_instructions, callback, data); + } else if (ir->as_return() || ir->as_call()) { + callback(leader, ir, data); + leader = NULL; + } else if ((ir_function = ir->as_function())) { + /* A function definition doesn't interrupt our basic block + * since execution doesn't go into it. We should process the + * bodies of its signatures for BBs, though. + * + * Note that we miss an opportunity for producing more + * maximal BBs between the instructions that precede main() + * and the body of main(). Perhaps those instructions ought + * to live inside of main(). + */ + foreach_iter(exec_list_iterator, fun_iter, *ir_function) { + ir_function_signature *ir_sig; + + ir_sig = (ir_function_signature *)fun_iter.get(); + + call_for_basic_blocks(&ir_sig->body, callback, data); + } + } else if (ir->as_assignment()) { + ir_has_call_visitor v; + + /* If there's a call in the expression tree being assigned, + * then that ends the BB too. + * + * The assumption is that any consumer of the basic block + * walker is fine with the fact that the call is somewhere in + * the tree even if portions of the tree may be evaluated + * after the call. + * + * A consumer that has an issue with this could not process + * the last instruction of the basic block. If doing so, + * expression flattener may be useful before using the basic + * block finder to get more maximal basic blocks out. + */ + ir->accept(&v); + if (v.has_call) { + callback(leader, ir, data); + leader = NULL; + } + } + last = ir; + } + if (leader) { + callback(leader, last, data); + } +} diff --git a/src/glsl/ir_basic_block.h b/src/glsl/ir_basic_block.h new file mode 100644 index 00000000000..dbd678b5c4f --- /dev/null +++ b/src/glsl/ir_basic_block.h @@ -0,0 +1,28 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +void call_for_basic_blocks(exec_list *instructions, + void (*callback)(ir_instruction *first, + ir_instruction *last, + void *data), + void *data); diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp new file mode 100644 index 00000000000..84176383fca --- /dev/null +++ b/src/glsl/ir_clone.cpp @@ -0,0 +1,287 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "ir.h" +#include "glsl_types.h" +#include "hash_table.h" + +/** + * Duplicate an IR variable + * + * \note + * This will probably be made \c virtual and moved to the base class + * eventually. + */ +ir_instruction * +ir_variable::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + ir_variable *var = new(ctx) ir_variable(type, name); + + var->max_array_access = this->max_array_access; + var->read_only = this->read_only; + var->centroid = this->centroid; + var->invariant = this->invariant; + var->mode = this->mode; + var->interpolation = this->interpolation; + + if (ht) { + hash_table_insert(ht, var, (void *)const_cast(this)); + } + + return var; +} + +ir_instruction * +ir_swizzle::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + return new(ctx) ir_swizzle((ir_rvalue *)this->val->clone(ht), this->mask); +} + +ir_instruction * +ir_return::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + ir_rvalue *new_value = NULL; + + if (this->value) + new_value = (ir_rvalue *)this->value->clone(ht); + + return new(ctx) ir_return(new_value); +} + +ir_instruction * +ir_loop_jump::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + (void)ht; + + return new(ctx) ir_loop_jump(this->mode); +} + +ir_instruction * +ir_if::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + ir_if *new_if = new(ctx) ir_if((ir_rvalue *)this->condition->clone(ht)); + + foreach_iter(exec_list_iterator, iter, this->then_instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_if->then_instructions.push_tail(ir->clone(ht)); + } + + foreach_iter(exec_list_iterator, iter, this->else_instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_if->else_instructions.push_tail(ir->clone(ht)); + } + + return new_if; +} + +ir_instruction * +ir_loop::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + ir_loop *new_loop = new(ctx) ir_loop(); + + if (this->from) + new_loop->from = (ir_rvalue *)this->from->clone(ht); + if (this->to) + new_loop->to = (ir_rvalue *)this->to->clone(ht); + if (this->increment) + new_loop->increment = (ir_rvalue *)this->increment->clone(ht); + new_loop->counter = counter; + + foreach_iter(exec_list_iterator, iter, this->body_instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_loop->body_instructions.push_tail(ir->clone(ht)); + } + + return new_loop; +} + +ir_instruction * +ir_call::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + exec_list new_parameters; + + foreach_iter(exec_list_iterator, iter, this->actual_parameters) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_parameters.push_tail(ir->clone(ht)); + } + + return new(ctx) ir_call(this->callee, &new_parameters); +} + +ir_instruction * +ir_expression::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + ir_rvalue *op[2] = {NULL, NULL}; + unsigned int i; + + for (i = 0; i < get_num_operands(); i++) { + op[i] = (ir_rvalue *)this->operands[i]->clone(ht); + } + + return new(ctx) ir_expression(this->operation, this->type, op[0], op[1]); +} + +ir_instruction * +ir_dereference_variable::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + ir_variable *new_var; + + if (ht) { + new_var = (ir_variable *)hash_table_find(ht, this->var); + if (!new_var) + new_var = this->var; + } else { + new_var = this->var; + } + + return new(ctx) ir_dereference_variable(new_var); +} + +ir_instruction * +ir_dereference_array::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + return new(ctx) ir_dereference_array((ir_rvalue *)this->array->clone(ht), + (ir_rvalue *)this->array_index->clone(ht)); +} + +ir_instruction * +ir_dereference_record::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + return new(ctx) ir_dereference_record((ir_rvalue *)this->record->clone(ht), + this->field); +} + +ir_instruction * +ir_texture::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + ir_texture *new_tex = new(ctx) ir_texture(this->op); + + new_tex->sampler = (ir_dereference *)this->sampler->clone(ht); + new_tex->coordinate = (ir_rvalue *)this->coordinate->clone(ht); + if (this->projector) + new_tex->projector = (ir_rvalue *)this->projector->clone(ht); + if (this->shadow_comparitor) { + new_tex->shadow_comparitor = + (ir_rvalue *)this->shadow_comparitor->clone(ht); + } + + for (int i = 0; i < 3; i++) + new_tex->offsets[i] = this->offsets[i]; + + switch (this->op) { + case ir_tex: + break; + case ir_txb: + new_tex->lod_info.bias = (ir_rvalue *)this->lod_info.bias->clone(ht); + break; + case ir_txl: + case ir_txf: + new_tex->lod_info.lod = (ir_rvalue *)this->lod_info.lod->clone(ht); + break; + case ir_txd: + new_tex->lod_info.grad.dPdx = + (ir_rvalue *)this->lod_info.grad.dPdx->clone(ht); + new_tex->lod_info.grad.dPdy = + (ir_rvalue *)this->lod_info.grad.dPdy->clone(ht); + break; + } + + return new_tex; +} + +ir_instruction * +ir_assignment::clone(struct hash_table *ht) const +{ + ir_rvalue *new_condition = NULL; + + if (this->condition) + new_condition = (ir_rvalue *)this->condition->clone(ht); + + void *ctx = talloc_parent(this); + return new(ctx) ir_assignment((ir_rvalue *)this->lhs->clone(ht), + (ir_rvalue *)this->rhs->clone(ht), + new_condition); +} + +ir_instruction * +ir_function::clone(struct hash_table *ht) const +{ + (void)ht; + /* FINISHME */ + abort(); +} + +ir_instruction * +ir_function_signature::clone(struct hash_table *ht) const +{ + (void)ht; + /* FINISHME */ + abort(); +} + +ir_instruction * +ir_constant::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + (void)ht; + + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + return new(ctx) ir_constant(this->type, &this->value); + + case GLSL_TYPE_STRUCT: { + ir_constant *c = new(ctx) ir_constant; + + c->type = this->type; + for (exec_node *node = this->components.head + ; !node->is_tail_sentinal() + ; node = node->next) { + ir_constant *const orig = (ir_constant *) node; + + c->components.push_tail(orig->clone(NULL)); + } + + return c; + } + + default: + assert(!"Should not get here."); break; + return NULL; + } +} diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp new file mode 100644 index 00000000000..3408f5256a7 --- /dev/null +++ b/src/glsl/ir_constant_expression.cpp @@ -0,0 +1,671 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_constant_expression.cpp + * Evaluate and process constant valued expressions + * + * In GLSL, constant valued expressions are used in several places. These + * must be processed and evaluated very early in the compilation process. + * + * * Sizes of arrays + * * Initializers for uniforms + * * Initializers for \c const variables + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "glsl_types.h" + +/** + * Visitor class for evaluating constant expressions + */ +class ir_constant_visitor : public ir_visitor { +public: + ir_constant_visitor() + : value(NULL) + { + /* empty */ + } + + virtual ~ir_constant_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_texture *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + /*@}*/ + + /** + * Value of the constant expression. + * + * \note + * This field will be \c NULL if the expression is not constant valued. + */ + /* FINIHSME: This cannot hold values for constant arrays or structures. */ + ir_constant *value; +}; + + +ir_constant * +ir_instruction::constant_expression_value() +{ + ir_constant_visitor visitor; + + this->accept(& visitor); + return visitor.value; +} + + +void +ir_constant_visitor::visit(ir_variable *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_function_signature *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_function *ir) +{ + (void) ir; + value = NULL; +} + +void +ir_constant_visitor::visit(ir_expression *ir) +{ + value = NULL; + ir_constant *op[2]; + unsigned int operand, c; + ir_constant_data data; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + op[operand] = ir->operands[operand]->constant_expression_value(); + if (!op[operand]) + return; + } + + switch (ir->operation) { + case ir_unop_logic_not: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (c = 0; c < ir->operands[0]->type->components(); c++) + data.b[c] = !op[0]->value.b[c]; + break; + + case ir_unop_f2i: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + data.i[c] = op[0]->value.f[c]; + } + break; + case ir_unop_i2f: + assert(op[0]->type->base_type == GLSL_TYPE_UINT || + op[0]->type->base_type == GLSL_TYPE_INT); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + if (op[0]->type->base_type == GLSL_TYPE_INT) + data.f[c] = op[0]->value.i[c]; + else + data.f[c] = op[0]->value.u[c]; + } + break; + case ir_unop_b2f: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = op[0]->value.b[c] ? 1.0 : 0.0; + } + break; + case ir_unop_f2b: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + data.b[c] = bool(op[0]->value.f[c]); + } + break; + case ir_unop_b2i: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + data.u[c] = op[0]->value.b[c] ? 1 : 0; + } + break; + case ir_unop_i2b: + assert(op[0]->type->is_integer()); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + data.b[c] = bool(op[0]->value.u[c]); + } + break; + + case ir_unop_neg: + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = -op[0]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.i[c] = -op[0]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = -op[0]->value.f[c]; + break; + default: + assert(0); + } + } + break; + + case ir_unop_abs: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c]; + if (data.i[c] < 0) + data.i[c] = -data.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = fabs(op[0]->value.f[c]); + break; + default: + assert(0); + } + } + break; + + case ir_unop_rcp: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->type->base_type) { + case GLSL_TYPE_UINT: + if (op[0]->value.u[c] != 0.0) + data.u[c] = 1 / op[0]->value.u[c]; + break; + case GLSL_TYPE_INT: + if (op[0]->value.i[c] != 0.0) + data.i[c] = 1 / op[0]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + if (op[0]->value.f[c] != 0.0) + data.f[c] = 1.0 / op[0]->value.f[c]; + break; + default: + assert(0); + } + } + break; + + case ir_unop_rsq: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = 1.0 / sqrtf(op[0]->value.f[c]); + } + break; + + case ir_unop_sqrt: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = sqrtf(op[0]->value.f[c]); + } + break; + + case ir_unop_exp: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = expf(op[0]->value.f[c]); + } + break; + + case ir_unop_log: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = logf(op[0]->value.f[c]); + } + break; + + case ir_unop_dFdx: + case ir_unop_dFdy: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = 0.0; + } + break; + + case ir_binop_add: + if (ir->operands[0]->type == ir->operands[1]->type) { + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c] + op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c] + op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c] + op[1]->value.f[c]; + break; + default: + assert(0); + } + } + } else + /* FINISHME: Support operations with non-equal types. */ + return; + + break; + case ir_binop_sub: + if (ir->operands[0]->type == ir->operands[1]->type) { + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c] - op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c] - op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c] - op[1]->value.f[c]; + break; + default: + assert(0); + } + } + } else + /* FINISHME: Support operations with non-equal types. */ + return; + + break; + case ir_binop_mul: + if (ir->operands[0]->type == ir->operands[1]->type && + !ir->operands[0]->type->is_matrix()) { + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c] * op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c] * op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c] * op[1]->value.f[c]; + break; + default: + assert(0); + } + } + } else + /* FINISHME: Support operations with non-equal types. */ + return; + + break; + case ir_binop_div: + if (ir->operands[0]->type == ir->operands[1]->type) { + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c] / op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c] / op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c] / op[1]->value.f[c]; + break; + default: + assert(0); + } + } + } else + /* FINISHME: Support operations with non-equal types. */ + return; + + break; + case ir_binop_logic_and: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (c = 0; c < ir->operands[0]->type->components(); c++) + data.b[c] = op[0]->value.b[c] && op[1]->value.b[c]; + break; + case ir_binop_logic_xor: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (c = 0; c < ir->operands[0]->type->components(); c++) + data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c]; + break; + case ir_binop_logic_or: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (c = 0; c < ir->operands[0]->type->components(); c++) + data.b[c] = op[0]->value.b[c] || op[1]->value.b[c]; + break; + + case ir_binop_less: + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = op[0]->value.u[0] < op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + data.b[0] = op[0]->value.i[0] < op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = op[0]->value.f[0] < op[1]->value.f[0]; + break; + default: + assert(0); + } + break; + case ir_binop_greater: + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = op[0]->value.u[0] > op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + data.b[0] = op[0]->value.i[0] > op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = op[0]->value.f[0] > op[1]->value.f[0]; + break; + default: + assert(0); + } + break; + case ir_binop_lequal: + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + data.b[0] = op[0]->value.i[0] <= op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = op[0]->value.f[0] <= op[1]->value.f[0]; + break; + default: + assert(0); + } + break; + case ir_binop_gequal: + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + data.b[0] = op[0]->value.i[0] >= op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = op[0]->value.f[0] >= op[1]->value.f[0]; + break; + default: + assert(0); + } + break; + + case ir_binop_equal: + data.b[0] = true; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = data.b[0] && op[0]->value.u[c] == op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[0] = data.b[0] && op[0]->value.i[c] == op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = data.b[0] && op[0]->value.f[c] == op[1]->value.f[c]; + break; + case GLSL_TYPE_BOOL: + data.b[0] = data.b[0] && op[0]->value.b[c] == op[1]->value.b[c]; + break; + default: + assert(0); + } + } + break; + case ir_binop_nequal: + data.b[0] = false; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = data.b[0] || op[0]->value.u[c] != op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[0] = data.b[0] || op[0]->value.i[c] != op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = data.b[0] || op[0]->value.f[c] != op[1]->value.f[c]; + break; + case GLSL_TYPE_BOOL: + data.b[0] = data.b[0] || op[0]->value.b[c] != op[1]->value.b[c]; + break; + default: + assert(0); + } + } + break; + + default: + /* FINISHME: Should handle all expression types. */ + return; + } + + void *ctx = talloc_parent(ir); + this->value = new(ctx) ir_constant(ir->type, &data); +} + + +void +ir_constant_visitor::visit(ir_texture *ir) +{ + // FINISHME: Do stuff with texture lookups + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_swizzle *ir) +{ + ir_constant *v = ir->val->constant_expression_value(); + + this->value = NULL; + + if (v != NULL) { + ir_constant_data data; + + const unsigned swiz_idx[4] = { + ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w + }; + + for (unsigned i = 0; i < ir->mask.num_components; i++) { + switch (v->type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break; + case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break; + case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break; + default: assert(!"Should not get here."); break; + } + } + + void *ctx = talloc_parent(ir); + this->value = new(ctx) ir_constant(ir->type, &data); + } +} + + +void +ir_constant_visitor::visit(ir_dereference_variable *ir) +{ + value = NULL; + + ir_variable *var = ir->variable_referenced(); + if (var && var->constant_value) + value = (ir_constant *)var->constant_value->clone(NULL); +} + + +void +ir_constant_visitor::visit(ir_dereference_array *ir) +{ + void *ctx = talloc_parent(ir); + ir_constant *array = ir->array->constant_expression_value(); + ir_constant *idx = ir->array_index->constant_expression_value(); + + this->value = NULL; + + if ((array != NULL) && (idx != NULL)) { + if (array->type->is_matrix()) { + /* Array access of a matrix results in a vector. + */ + const unsigned column = idx->value.u[0]; + + const glsl_type *const column_type = array->type->column_type(); + + /* Offset in the constant matrix to the first element of the column + * to be extracted. + */ + const unsigned mat_idx = column * column_type->vector_elements; + + ir_constant_data data; + + switch (column_type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + for (unsigned i = 0; i < column_type->vector_elements; i++) + data.u[i] = array->value.u[mat_idx + i]; + + break; + + case GLSL_TYPE_FLOAT: + for (unsigned i = 0; i < column_type->vector_elements; i++) + data.f[i] = array->value.f[mat_idx + i]; + + break; + + default: + assert(!"Should not get here."); + break; + } + + this->value = new(ctx) ir_constant(column_type, &data); + } else if (array->type->is_vector()) { + const unsigned component = idx->value.u[0]; + + this->value = new(ctx) ir_constant(array, component); + } else { + /* FINISHME: Handle access of constant arrays. */ + } + } +} + + +void +ir_constant_visitor::visit(ir_dereference_record *ir) +{ + ir_constant *v = ir->record->constant_expression_value(); + + this->value = (v != NULL) ? v->get_record_field(ir->field) : NULL; +} + + +void +ir_constant_visitor::visit(ir_assignment *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_constant *ir) +{ + value = ir; +} + + +void +ir_constant_visitor::visit(ir_call *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_return *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_if *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_loop *ir) +{ + (void) ir; + value = NULL; +} + + +void +ir_constant_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; + value = NULL; +} diff --git a/src/glsl/ir_constant_folding.cpp b/src/glsl/ir_constant_folding.cpp new file mode 100644 index 00000000000..342d027bbe8 --- /dev/null +++ b/src/glsl/ir_constant_folding.cpp @@ -0,0 +1,229 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_constant_folding.cpp + * Replace constant-valued expressions with references to constant values. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +class ir_constant_folding_visitor : public ir_visitor { +public: + ir_constant_folding_visitor() + { + /* empty */ + } + + virtual ~ir_constant_folding_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_texture *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + /*@}*/ +}; + +void +ir_constant_folding_visitor::visit(ir_variable *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_function_signature *ir) +{ + visit_exec_list(&ir->body, this); +} + + +void +ir_constant_folding_visitor::visit(ir_function *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_function_signature *const sig = (ir_function_signature *) iter.get(); + sig->accept(this); + } +} + +void +ir_constant_folding_visitor::visit(ir_expression *ir) +{ + ir_constant *op[2]; + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + op[operand] = ir->operands[operand]->constant_expression_value(); + if (op[operand]) { + ir->operands[operand] = op[operand]; + } else { + ir->operands[operand]->accept(this); + } + } +} + + +void +ir_constant_folding_visitor::visit(ir_texture *ir) +{ + // FINISHME: Do stuff with texture lookups + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_swizzle *ir) +{ + ir->val->accept(this); +} + + +void +ir_constant_folding_visitor::visit(ir_dereference_variable *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_dereference_array *ir) +{ + ir_constant *const_val = + ir->array_index->constant_expression_value(); + + if (const_val) + ir->array_index = const_val; + else + ir->array_index->accept(this); + + ir->array->accept(this); +} + + +void +ir_constant_folding_visitor::visit(ir_dereference_record *ir) +{ + ir->record->accept(this); +} + + +void +ir_constant_folding_visitor::visit(ir_assignment *ir) +{ + ir_constant *const_val = ir->rhs->constant_expression_value(); + if (const_val) + ir->rhs = const_val; + else + ir->rhs->accept(this); +} + + +void +ir_constant_folding_visitor::visit(ir_constant *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_call *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_return *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_if *ir) +{ + ir_constant *const_val = ir->condition->constant_expression_value(); + if (const_val) + ir->condition = const_val; + else + ir->condition->accept(this); + + visit_exec_list(&ir->then_instructions, this); + visit_exec_list(&ir->else_instructions, this); +} + + +void +ir_constant_folding_visitor::visit(ir_loop *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_loop_jump *ir) +{ + (void) ir; +} + +bool +do_constant_folding(exec_list *instructions) +{ + ir_constant_folding_visitor constant_folding; + + visit_exec_list(instructions, &constant_folding); + + /* FINISHME: Return real progress. */ + return false; +} diff --git a/src/glsl/ir_constant_variable.cpp b/src/glsl/ir_constant_variable.cpp new file mode 100644 index 00000000000..ef5e1e418e5 --- /dev/null +++ b/src/glsl/ir_constant_variable.cpp @@ -0,0 +1,156 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_constant_variable.cpp + * + * Marks variables assigned a single constant value over the course + * of the program as constant. + * + * The goal here is to trigger further constant folding and then dead + * code elimination. This is common with vector/matrix constructors + * and calls to builtin functions. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +struct assignment_entry { + exec_node link; + int assignment_count; + ir_variable *var; + ir_constant *constval; +}; + +class ir_constant_variable_visitor : public ir_hierarchical_visitor { +public: + virtual ir_visitor_status visit_enter(ir_assignment *); + + exec_list list; +}; + +static struct assignment_entry * +get_assignment_entry(ir_variable *var, exec_list *list) +{ + struct assignment_entry *entry; + + foreach_list_typed(struct assignment_entry, entry, link, list) { + if (entry->var == var) + return entry; + } + + entry = (struct assignment_entry *)calloc(1, sizeof(*entry)); + entry->var = var; + list->push_head(&entry->link); + return entry; +} + +ir_visitor_status +ir_constant_variable_visitor::visit_enter(ir_assignment *ir) +{ + ir_constant *constval; + struct assignment_entry *entry; + + entry = get_assignment_entry(ir->lhs->variable_referenced(), &this->list); + assert(entry); + entry->assignment_count++; + + /* If it's already constant, don't do the work. */ + if (entry->var->constant_value) + return visit_continue; + + /* OK, now find if we actually have all the right conditions for + * this to be a constant value assigned to the var. + */ + if (ir->condition) { + constval = ir->condition->constant_expression_value(); + if (!constval || !constval->value.b[0]) + return visit_continue; + } + + ir_variable *var = ir->lhs->whole_variable_referenced(); + if (!var) + return visit_continue; + + constval = ir->rhs->constant_expression_value(); + if (!constval) + return visit_continue; + + /* Mark this entry as having a constant assignment (if the + * assignment count doesn't go >1). do_constant_variable will fix + * up the variable with the constant value later. + */ + entry->constval = constval; + + return visit_continue; +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_constant_variable(exec_list *instructions) +{ + bool progress = false; + ir_constant_variable_visitor v; + + v.run(instructions); + + while (!v.list.is_empty()) { + + struct assignment_entry *entry; + entry = exec_node_data(struct assignment_entry, v.list.head, link); + + if (entry->assignment_count == 1 && entry->constval) { + entry->var->constant_value = entry->constval; + progress = true; + } + entry->link.remove(); + free(entry); + } + + return progress; +} + +bool +do_constant_variable_unlinked(exec_list *instructions) +{ + bool progress = false; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_function *f = ir->as_function(); + if (f) { + foreach_iter(exec_list_iterator, sigiter, *f) { + ir_function_signature *sig = + (ir_function_signature *) sigiter.get(); + if (do_constant_variable(&sig->body)) + progress = true; + } + } + } + + return progress; +} diff --git a/src/glsl/ir_copy_propagation.cpp b/src/glsl/ir_copy_propagation.cpp new file mode 100644 index 00000000000..46ef6679d9f --- /dev/null +++ b/src/glsl/ir_copy_propagation.cpp @@ -0,0 +1,256 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_copy_propagation.cpp + * + * Moves usage of recently-copied variables to the previous copy of + * the variable within basic blocks. + * + * This should reduce the number of MOV instructions in the generated + * programs unless copy propagation is also done on the LIR, and may + * help anyway by triggering other optimizations that live in the HIR. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_basic_block.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +class acp_entry : public exec_node +{ +public: + acp_entry(ir_variable *lhs, ir_variable *rhs) + { + assert(lhs); + assert(rhs); + this->lhs = lhs; + this->rhs = rhs; + } + + ir_variable *lhs; + ir_variable *rhs; +}; + +class ir_copy_propagation_visitor : public ir_hierarchical_visitor { +public: + ir_copy_propagation_visitor(exec_list *acp) + { + progress = false; + in_lhs = false; + this->acp = acp; + } + + virtual ir_visitor_status visit(class ir_dereference_variable *); + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_enter(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_if *); + + /** List of acp_entry */ + exec_list *acp; + bool progress; + + /** Currently in the LHS of an assignment? */ + bool in_lhs; +}; + + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_loop *ir) +{ + (void)ir; + return visit_continue_with_parent; +} + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir) +{ + (void)ir; + return visit_continue_with_parent; +} + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_assignment *ir) +{ + (void) ir; + this->in_lhs = true; + return visit_continue; +} + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_function *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + +/** + * Replaces dereferences of ACP RHS variables with ACP LHS variables. + * + * This is where the actual copy propagation occurs. Note that the + * rewriting of ir_dereference means that the ir_dereference instance + * must not be shared by multiple IR operations! + */ +ir_visitor_status +ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) +{ + /* Ignores the LHS. Don't want to rewrite the LHS to point at some + * other storage! + */ + if (this->in_lhs) { + this->in_lhs = false; + return visit_continue; + } + + ir_variable *var = ir->variable_referenced(); + + foreach_iter(exec_list_iterator, iter, *this->acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (var == entry->lhs) { + ir->var = entry->rhs; + this->progress = true; + break; + } + } + + return visit_continue; +} + + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_call *ir) +{ + (void)ir; + + /* Note, if we were to do copy propagation to parameters of calls, we'd + * have to be careful about out params. + */ + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_if *ir) +{ + ir->condition->accept(this); + + /* Do not traverse into the body of the if-statement since that is a + * different basic block. + */ + return visit_continue_with_parent; +} + +static bool +propagate_copies(ir_instruction *ir, exec_list *acp) +{ + ir_copy_propagation_visitor v(acp); + + ir->accept(&v); + + return v.progress; +} + +static void +kill_invalidated_copies(ir_assignment *ir, exec_list *acp) +{ + ir_variable *var = ir->lhs->variable_referenced(); + assert(var != NULL); + + foreach_iter(exec_list_iterator, iter, *acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (entry->lhs == var || entry->rhs == var) { + entry->remove(); + } + } +} + +/** + * Adds an entry to the available copy list if it's a plain assignment + * of a variable to a variable. + */ +static void +add_copy(ir_assignment *ir, exec_list *acp) +{ + void *ctx = talloc_parent(ir); + acp_entry *entry; + + if (ir->condition) { + ir_constant *condition = ir->condition->as_constant(); + if (!condition || !condition->value.b[0]) + return; + } + + ir_variable *lhs_var = ir->lhs->whole_variable_referenced(); + ir_variable *rhs_var = ir->rhs->whole_variable_referenced(); + + if ((lhs_var != NULL) && (rhs_var != NULL)) { + entry = new(ctx) acp_entry(lhs_var, rhs_var); + acp->push_tail(entry); + } +} + +static void +copy_propagation_basic_block(ir_instruction *first, + ir_instruction *last, + void *data) +{ + ir_instruction *ir; + /* List of avaialble_copy */ + exec_list acp; + bool *out_progress = (bool *)data; + bool progress = false; + + for (ir = first;; ir = (ir_instruction *)ir->next) { + ir_assignment *ir_assign = ir->as_assignment(); + + progress = propagate_copies(ir, &acp) || progress; + + if (ir_assign) { + kill_invalidated_copies(ir_assign, &acp); + + add_copy(ir_assign, &acp); + } + if (ir == last) + break; + } + *out_progress = progress; +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_copy_propagation(exec_list *instructions) +{ + bool progress = false; + + call_for_basic_blocks(instructions, copy_propagation_basic_block, &progress); + + return progress; +} diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp new file mode 100644 index 00000000000..88213046825 --- /dev/null +++ b/src/glsl/ir_dead_code.cpp @@ -0,0 +1,219 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_dead_code.cpp + * + * Eliminates dead assignments and variable declarations from the code. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +class variable_entry : public exec_node +{ +public: + variable_entry(ir_variable *var) + { + this->var = var; + assign = NULL; + referenced_count = 0; + assigned_count = 0; + declaration = false; + } + + ir_variable *var; /* The key: the variable's pointer. */ + ir_assignment *assign; /* An assignment to the variable, if any */ + + /** Number of times the variable is referenced, including assignments. */ + unsigned referenced_count; + + /** Number of times the variable is assignmened. */ + unsigned assigned_count; + + bool declaration; /* If the variable had a decl in the instruction stream */ +}; + +class ir_dead_code_visitor : public ir_hierarchical_visitor { +public: + virtual ir_visitor_status visit(ir_variable *); + virtual ir_visitor_status visit(ir_dereference_variable *); + + virtual ir_visitor_status visit_enter(ir_function *); + virtual ir_visitor_status visit_leave(ir_assignment *); + + variable_entry *get_variable_entry(ir_variable *var); + + bool (*predicate)(ir_instruction *ir); + ir_instruction *base_ir; + + /* List of variable_entry */ + exec_list variable_list; +}; + + +variable_entry * +ir_dead_code_visitor::get_variable_entry(ir_variable *var) +{ + assert(var); + foreach_iter(exec_list_iterator, iter, this->variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + if (entry->var == var) + return entry; + } + + void *ctx = talloc_parent(var); + + variable_entry *entry = new(ctx) variable_entry(var); + this->variable_list.push_tail(entry); + return entry; +} + + +ir_visitor_status +ir_dead_code_visitor::visit(ir_variable *ir) +{ + variable_entry *entry = this->get_variable_entry(ir); + if (entry) + entry->declaration = true; + + return visit_continue; +} + + +ir_visitor_status +ir_dead_code_visitor::visit(ir_dereference_variable *ir) +{ + ir_variable *const var = ir->variable_referenced(); + variable_entry *entry = this->get_variable_entry(var); + + if (entry) + entry->referenced_count++; + + return visit_continue; +} + + +ir_visitor_status +ir_dead_code_visitor::visit_enter(ir_function *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_dead_code_visitor::visit_leave(ir_assignment *ir) +{ + variable_entry *entry; + entry = this->get_variable_entry(ir->lhs->variable_referenced()); + if (entry) { + entry->assigned_count++; + if (entry->assign == NULL) + entry->assign = ir; + } + + return visit_continue; +} + + +/** + * Do a dead code pass over instructions and everything that instructions + * references. + * + * Note that this will remove assignments to globals, so it is not suitable + * for usage on an unlinked instruction stream. + */ +bool +do_dead_code(exec_list *instructions) +{ + ir_dead_code_visitor v; + bool progress = false; + + v.run(instructions); + + foreach_iter(exec_list_iterator, iter, v.variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + + /* Since each assignment is a reference, the refereneced count must be + * greater than or equal to the assignment count. If they are equal, + * then all of the references are assignments, and the variable is + * dead. + * + * Note that if the variable is neither assigned nor referenced, both + * counts will be zero and will be caught by the equality test. + */ + assert(entry->referenced_count >= entry->assigned_count); + + if ((entry->referenced_count > entry->assigned_count) + || !entry->declaration) + continue; + + if (entry->assign) { + /* Remove a single dead assignment to the variable we found. + * Don't do so if it's a shader output, though. + */ + if (!entry->var->shader_out) { + entry->assign->remove(); + progress = true; + } + } else { + /* If there are no assignments or references to the variable left, + * then we can remove its declaration. + */ + entry->var->remove(); + progress = true; + } + } + return progress; +} + +/** + * Does a dead code pass on the functions present in the instruction stream. + * + * This is suitable for use while the program is not linked, as it will + * ignore variable declarations (and the assignments to them) for variables + * with global scope. + */ +bool +do_dead_code_unlinked(exec_list *instructions) +{ + bool progress = false; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_function *f = ir->as_function(); + if (f) { + foreach_iter(exec_list_iterator, sigiter, *f) { + ir_function_signature *sig = + (ir_function_signature *) sigiter.get(); + if (do_dead_code(&sig->body)) + progress = true; + } + } + } + + return progress; +} diff --git a/src/glsl/ir_dead_code_local.cpp b/src/glsl/ir_dead_code_local.cpp new file mode 100644 index 00000000000..e01877077c9 --- /dev/null +++ b/src/glsl/ir_dead_code_local.cpp @@ -0,0 +1,223 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_dead_code_local.cpp + * + * Eliminates local dead assignments from the code. + * + * This operates on basic blocks, tracking assignments and finding if + * they're used before the variable is completely reassigned. + * + * Compare this to ir_dead_code.cpp, which operates globally looking + * for assignments to variables that are never read. + */ + +#include "ir.h" +#include "ir_basic_block.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +static bool debug = false; + +class assignment_entry : public exec_node +{ +public: + assignment_entry(ir_variable *lhs, ir_instruction *ir) + { + assert(lhs); + assert(ir); + this->lhs = lhs; + this->ir = ir; + } + + ir_variable *lhs; + ir_instruction *ir; +}; + +class kill_for_derefs_visitor : public ir_hierarchical_visitor { +public: + kill_for_derefs_visitor(exec_list *assignments) + { + this->assignments = assignments; + } + + virtual ir_visitor_status visit(ir_dereference_variable *ir) + { + ir_variable *const var = ir->variable_referenced(); + + foreach_iter(exec_list_iterator, iter, *this->assignments) { + assignment_entry *entry = (assignment_entry *)iter.get(); + + if (entry->lhs == var) { + if (debug) + printf("kill %s\n", entry->lhs->name); + entry->remove(); + } + } + + return visit_continue; + } + +private: + exec_list *assignments; +}; + +class array_index_visit : public ir_hierarchical_visitor { +public: + array_index_visit(ir_hierarchical_visitor *v) + { + this->visitor = v; + } + + virtual ir_visitor_status visit_enter(class ir_dereference_array *ir) + { + ir->array_index->accept(visitor); + return visit_continue; + } + + static void run(ir_instruction *ir, ir_hierarchical_visitor *v) + { + array_index_visit top_visit(v); + ir->accept(& top_visit); + } + + ir_hierarchical_visitor *visitor; +}; + + +/** + * Adds an entry to the available copy list if it's a plain assignment + * of a variable to a variable. + */ +static bool +process_assignment(ir_assignment *ir, exec_list *assignments) +{ + void *ctx = talloc_parent(ir); + ir_variable *var = NULL; + bool progress = false; + kill_for_derefs_visitor v(assignments); + + /* Kill assignment entries for things used to produce this assignment. */ + ir->rhs->accept(&v); + if (ir->condition) { + ir->condition->accept(&v); + } + + /* Kill assignment enties used as array indices. + */ + array_index_visit::run(ir->lhs, &v); + var = ir->lhs->variable_referenced(); + assert(var); + + bool always_assign = true; + if (ir->condition) { + ir_constant *condition = ir->condition->as_constant(); + if (!condition || !condition->value.b[0]) + always_assign = false; + } + + /* Now, check if we did a whole-variable assignment. */ + if (always_assign && (ir->lhs->whole_variable_referenced() != NULL)) { + /* We did a whole-variable assignment. So, any instruction in + * the assignment list with the same LHS is dead. + */ + if (debug) + printf("looking for %s to remove\n", var->name); + foreach_iter(exec_list_iterator, iter, *assignments) { + assignment_entry *entry = (assignment_entry *)iter.get(); + + if (entry->lhs == var) { + if (debug) + printf("removing %s\n", var->name); + entry->ir->remove(); + entry->remove(); + progress = true; + } + } + } + + /* Add this instruction to the assignment list. */ + assignment_entry *entry = new(ctx) assignment_entry(var, ir); + assignments->push_tail(entry); + + if (debug) { + printf("add %s\n", var->name); + + printf("current entries\n"); + foreach_iter(exec_list_iterator, iter, *assignments) { + assignment_entry *entry = (assignment_entry *)iter.get(); + + printf(" %s\n", entry->lhs->name); + } + } + + return progress; +} + +static void +dead_code_local_basic_block(ir_instruction *first, + ir_instruction *last, + void *data) +{ + ir_instruction *ir, *ir_next; + /* List of avaialble_copy */ + exec_list assignments; + bool *out_progress = (bool *)data; + bool progress = false; + + /* Safe looping, since process_assignment */ + for (ir = first, ir_next = (ir_instruction *)first->next;; + ir = ir_next, ir_next = (ir_instruction *)ir->next) { + ir_assignment *ir_assign = ir->as_assignment(); + + if (debug) { + ir->print(); + printf("\n"); + } + + if (ir_assign) { + progress = process_assignment(ir_assign, &assignments) || progress; + } else { + kill_for_derefs_visitor kill(&assignments); + ir->accept(&kill); + } + + if (ir == last) + break; + } + *out_progress = progress; +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_dead_code_local(exec_list *instructions) +{ + bool progress = false; + + call_for_basic_blocks(instructions, dead_code_local_basic_block, &progress); + + return progress; +} diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp new file mode 100644 index 00000000000..5ba24e390b4 --- /dev/null +++ b/src/glsl/ir_expression_flattening.cpp @@ -0,0 +1,172 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_expression_flattening.cpp + * + * Takes the leaves of expression trees and makes them dereferences of + * assignments of the leaves to temporaries, according to a predicate. + * + * This is used for automatic function inlining, where we want to take + * an expression containing a call and move the call out to its own + * assignment so that we can inline it at the appropriate place in the + * instruction stream. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +class ir_expression_flattening_visitor : public ir_hierarchical_visitor { +public: + ir_expression_flattening_visitor(ir_instruction *base_ir, + bool (*predicate)(ir_instruction *ir)) + { + this->base_ir = base_ir; + this->predicate = predicate; + } + + virtual ~ir_expression_flattening_visitor() + { + /* empty */ + } + + virtual ir_visitor_status visit_enter(ir_call *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_function_signature *); + virtual ir_visitor_status visit_enter(ir_if *); + virtual ir_visitor_status visit_enter(ir_loop *); + virtual ir_visitor_status visit_leave(ir_expression *); + virtual ir_visitor_status visit_leave(ir_swizzle *); + + bool (*predicate)(ir_instruction *ir); + ir_instruction *base_ir; +}; + +void +do_expression_flattening(exec_list *instructions, + bool (*predicate)(ir_instruction *ir)) +{ + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + ir_expression_flattening_visitor v(ir, predicate); + ir->accept(&v); + } +} + + +static ir_rvalue * +operand_to_temp(ir_instruction *base_ir, ir_rvalue *ir) +{ + void *ctx = talloc_parent(base_ir); + ir_variable *var; + ir_assignment *assign; + + var = new(ctx) ir_variable(ir->type, "flattening_tmp"); + base_ir->insert_before(var); + + assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), + ir, + NULL); + base_ir->insert_before(assign); + + return new(ctx) ir_dereference_variable(var); +} + +ir_visitor_status +ir_expression_flattening_visitor::visit_enter(ir_function_signature *ir) +{ + do_expression_flattening(&ir->body, this->predicate); + + return visit_continue_with_parent; +} + +ir_visitor_status +ir_expression_flattening_visitor::visit_enter(ir_loop *ir) +{ + do_expression_flattening(&ir->body_instructions, this->predicate); + + return visit_continue_with_parent; +} + +ir_visitor_status +ir_expression_flattening_visitor::visit_enter(ir_if *ir) +{ + ir->condition->accept(this); + + do_expression_flattening(&ir->then_instructions, this->predicate); + do_expression_flattening(&ir->else_instructions, this->predicate); + + return visit_continue_with_parent; +} + +ir_visitor_status +ir_expression_flattening_visitor::visit_leave(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + /* If the operand matches the predicate, then we'll assign its + * value to a temporary and deref the temporary as the operand. + */ + if (this->predicate(ir->operands[operand])) { + ir->operands[operand] = operand_to_temp(base_ir, + ir->operands[operand]); + } + } + + return visit_continue; +} + +ir_visitor_status +ir_expression_flattening_visitor::visit_leave(ir_swizzle *ir) +{ + if (this->predicate(ir->val)) { + ir->val = operand_to_temp(this->base_ir, ir->val); + } + + return visit_continue; +} + +ir_visitor_status +ir_expression_flattening_visitor::visit_enter(ir_call *ir) +{ + /* FINISHME: Why not process the call parameters? (Same behavior as original + * FINISHME: code.) + */ + (void) ir; + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_expression_flattening_visitor::visit_enter(ir_return *ir) +{ + /* FINISHME: Why not process the return value? (Same behavior as original + * FINISHME: code.) + */ + (void) ir; + return visit_continue_with_parent; +} diff --git a/src/glsl/ir_expression_flattening.h b/src/glsl/ir_expression_flattening.h new file mode 100644 index 00000000000..2eda1590001 --- /dev/null +++ b/src/glsl/ir_expression_flattening.h @@ -0,0 +1,38 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file ir_expression_flattening.h + * + * Takes the leaves of expression trees and makes them dereferences of + * assignments of the leaves to temporaries, according to a predicate. + * + * This is used for automatic function inlining, where we want to take + * an expression containing a call and move the call out to its own + * assignment so that we can inline it at the appropriate place in the + * instruction stream. + */ + +void do_expression_flattening(exec_list *instructions, + bool (*predicate)(ir_instruction *ir)); diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp new file mode 100644 index 00000000000..5db93f67fb8 --- /dev/null +++ b/src/glsl/ir_function.cpp @@ -0,0 +1,225 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "glsl_types.h" +#include "ir.h" + +int +type_compare(const glsl_type *a, const glsl_type *b) +{ + /* If the types are the same, they trivially match. + */ + if (a == b) + return 0; + + switch (a->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_BOOL: + /* There is no implicit conversion to or from integer types or bool. + */ + if ((a->is_integer() != b->is_integer()) + || (a->is_boolean() != b->is_boolean())) + return -1; + + /* FALLTHROUGH */ + + case GLSL_TYPE_FLOAT: + if ((a->vector_elements != b->vector_elements) + || (a->matrix_columns != b->matrix_columns)) + return -1; + + return 1; + + case GLSL_TYPE_SAMPLER: + case GLSL_TYPE_STRUCT: + /* Samplers and structures must match exactly. + */ + return -1; + + case GLSL_TYPE_ARRAY: + if ((b->base_type != GLSL_TYPE_ARRAY) + || (a->length != b->length)) + return -1; + + /* From GLSL 1.50 spec, page 27 (page 33 of the PDF): + * "There are no implicit array or structure conversions." + * + * If the comparison of the array element types detects that a conversion + * would be required, the array types do not match. + */ + return (type_compare(a->fields.array, b->fields.array) == 0) ? 0 : -1; + + case GLSL_TYPE_FUNCTION: + case GLSL_TYPE_VOID: + case GLSL_TYPE_ERROR: + default: + /* These are all error conditions. It is invalid for a parameter to + * a function to be declared as error, void, or a function. + */ + return -1; + } + + /* This point should be unreachable. + */ + assert(0); +} + + +static int +parameter_lists_match(exec_list *list_a, exec_list *list_b) +{ + exec_list_iterator iter_a = list_a->iterator(); + exec_list_iterator iter_b = list_b->iterator(); + int total_score = 0; + + for (/* empty */ ; iter_a.has_next(); iter_a.next(), iter_b.next()) { + /* If all of the parameters from the other parameter list have been + * exhausted, the lists have different length and, by definition, + * do not match. + */ + if (!iter_b.has_next()) + return -1; + + + const ir_variable *const param = (ir_variable *) iter_a.get(); + const ir_instruction *const actual = (ir_instruction *) iter_b.get(); + + /* Determine whether or not the types match. If the types are an + * exact match, the match score is zero. If the types don't match + * but the actual parameter can be coerced to the type of the declared + * parameter, the match score is one. + */ + int score; + switch ((enum ir_variable_mode)(param->mode)) { + case ir_var_auto: + case ir_var_uniform: + /* These are all error conditions. It is invalid for a parameter to + * a function to be declared as auto (not in, out, or inout) or + * as uniform. + */ + assert(0); + return -1; + + case ir_var_in: + score = type_compare(param->type, actual->type); + break; + + case ir_var_out: + score = type_compare(actual->type, param->type); + break; + + case ir_var_inout: + /* Since there are no bi-directional automatic conversions (e.g., + * there is int -> float but no float -> int), inout parameters must + * be exact matches. + */ + score = (type_compare(actual->type, param->type) == 0) ? 0 : -1; + break; + } + + if (score < 0) + return -1; + + total_score += score; + } + + /* If all of the parameters from the other parameter list have been + * exhausted, the lists have different length and, by definition, do not + * match. + */ + if (iter_b.has_next()) + return -1; + + return total_score; +} + + +const ir_function_signature * +ir_function::matching_signature(exec_list *actual_parameters) +{ + ir_function_signature *match = NULL; + + foreach_iter(exec_list_iterator, iter, signatures) { + ir_function_signature *const sig = + (ir_function_signature *) iter.get(); + + const int score = parameter_lists_match(& sig->parameters, + actual_parameters); + + if (score == 0) + return sig; + + if (score > 0) { + if (match != NULL) + return NULL; + + match = sig; + } + } + + return match; +} + + +static bool +parameter_lists_match_exact(exec_list *list_a, exec_list *list_b) +{ + exec_list_iterator iter_a = list_a->iterator(); + exec_list_iterator iter_b = list_b->iterator(); + + while (iter_a.has_next() && iter_b.has_next()) { + ir_variable *a = (ir_variable *)iter_a.get(); + ir_variable *b = (ir_variable *)iter_b.get(); + + /* If the types of the parameters do not match, the parameters lists + * are different. + */ + if (a->type != b->type) + return false; + + iter_a.next(); + iter_b.next(); + } + + /* Unless both lists are exhausted, they differ in length and, by + * definition, do not match. + */ + if (iter_a.has_next() != iter_b.has_next()) + return false; + + return true; +} + +ir_function_signature * +ir_function::exact_matching_signature(exec_list *actual_parameters) +{ + foreach_iter(exec_list_iterator, iter, signatures) { + ir_function_signature *const sig = + (ir_function_signature *) iter.get(); + + if (parameter_lists_match_exact(&sig->parameters, actual_parameters)) + return sig; + } + return NULL; +} diff --git a/src/glsl/ir_function_can_inline.cpp b/src/glsl/ir_function_can_inline.cpp new file mode 100644 index 00000000000..8bb8e0d9ed7 --- /dev/null +++ b/src/glsl/ir_function_can_inline.cpp @@ -0,0 +1,71 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_can_inline.cpp + * + * Determines if we can inline a function call using ir_function_inlining.cpp. + * + * The primary restriction is that we can't return from the function + * other than as the last instruction. We could potentially work + * around this for some constructs by flattening control flow and + * moving the return to the end, or by using breaks from a do {} while + * (0) loop surrounding the function body. + */ + +#include "ir.h" + +class ir_function_can_inline_visitor : public ir_hierarchical_visitor { +public: + ir_function_can_inline_visitor() + { + this->num_returns = 0; + } + + virtual ir_visitor_status visit_enter(ir_return *); + + int num_returns; +}; + +ir_visitor_status +ir_function_can_inline_visitor::visit_enter(ir_return *ir) +{ + (void) ir; + this->num_returns++; + return visit_continue; +} + +bool +can_inline(ir_call *call) +{ + ir_function_can_inline_visitor v; + const ir_function_signature *callee = call->get_callee(); + + v.run((exec_list *) &callee->body); + + ir_instruction *last = (ir_instruction *)callee->body.get_tail(); + if (last && !last->as_return()) + v.num_returns++; + + return v.num_returns == 1; +} diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp new file mode 100644 index 00000000000..e55780c940e --- /dev/null +++ b/src/glsl/ir_function_inlining.cpp @@ -0,0 +1,272 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_inlining.cpp + * + * Replaces calls to functions with the body of the function. + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "ir_function_inlining.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" +#include "hash_table.h" + +class ir_function_inlining_visitor : public ir_hierarchical_visitor { +public: + ir_function_inlining_visitor() + { + progress = false; + } + + virtual ~ir_function_inlining_visitor() + { + /* empty */ + } + + virtual ir_visitor_status visit_enter(ir_expression *); + virtual ir_visitor_status visit_enter(ir_call *); + virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_texture *); + virtual ir_visitor_status visit_enter(ir_swizzle *); + + bool progress; +}; + + +unsigned int hash_func(const void *key) +{ + return (unsigned int)(uintptr_t)key; +} + +int hash_compare_func(const void *key1, const void *key2) +{ + return key1 == key2 ? 0 : 1; +} + +bool +automatic_inlining_predicate(ir_instruction *ir) +{ + ir_call *call = ir->as_call(); + + if (call && can_inline(call)) + return true; + + return false; +} + +bool +do_function_inlining(exec_list *instructions) +{ + ir_function_inlining_visitor v; + + do_expression_flattening(instructions, automatic_inlining_predicate); + + v.run(instructions); + + return v.progress; +} + +static void +replace_return_with_assignment(ir_instruction *ir, void *data) +{ + void *ctx = talloc_parent(ir); + ir_variable *retval = (ir_variable *)data; + ir_return *ret = ir->as_return(); + + if (ret) { + if (ret->value) { + ir_rvalue *lhs = new(ctx) ir_dereference_variable(retval); + ret->insert_before(new(ctx) ir_assignment(lhs, ret->value, NULL)); + ret->remove(); + } else { + /* un-valued return has to be the last return, or we shouldn't + * have reached here. (see can_inline()). + */ + assert(!ret->next->is_tail_sentinal()); + } + } +} + +ir_rvalue * +ir_call::generate_inline(ir_instruction *next_ir) +{ + void *ctx = talloc_parent(this); + ir_variable **parameters; + int num_parameters; + int i; + ir_variable *retval = NULL; + struct hash_table *ht; + + ht = hash_table_ctor(0, hash_func, hash_compare_func); + + num_parameters = 0; + foreach_iter(exec_list_iterator, iter_sig, this->callee->parameters) + num_parameters++; + + parameters = new ir_variable *[num_parameters]; + + /* Generate storage for the return value. */ + if (this->callee->return_type) { + retval = new(ctx) ir_variable(this->callee->return_type, "__retval"); + next_ir->insert_before(retval); + } + + /* Generate the declarations for the parameters to our inlined code, + * and set up the mapping of real function body variables to ours. + */ + i = 0; + exec_list_iterator sig_param_iter = this->callee->parameters.iterator(); + exec_list_iterator param_iter = this->actual_parameters.iterator(); + for (i = 0; i < num_parameters; i++) { + const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get(); + ir_rvalue *param = (ir_rvalue *) param_iter.get(); + + /* Generate a new variable for the parameter. */ + parameters[i] = (ir_variable *)sig_param->clone(ht); + parameters[i]->mode = ir_var_auto; + next_ir->insert_before(parameters[i]); + + /* Move the actual param into our param variable if it's an 'in' type. */ + if (sig_param->mode == ir_var_in || + sig_param->mode == ir_var_inout) { + ir_assignment *assign; + + assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]), + param, NULL); + next_ir->insert_before(assign); + } + + sig_param_iter.next(); + param_iter.next(); + } + + /* Generate the inlined body of the function. */ + foreach_iter(exec_list_iterator, iter, callee->body) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_instruction *new_ir = ir->clone(ht); + + next_ir->insert_before(new_ir); + visit_tree(new_ir, replace_return_with_assignment, retval); + } + + /* Copy back the value of any 'out' parameters from the function body + * variables to our own. + */ + i = 0; + param_iter = this->actual_parameters.iterator(); + for (i = 0; i < num_parameters; i++) { + ir_instruction *const param = (ir_instruction *) param_iter.get(); + + /* Move our param variable into the actual param if it's an 'out' type. */ + if (parameters[i]->mode == ir_var_out || + parameters[i]->mode == ir_var_inout) { + ir_assignment *assign; + + assign = new(ctx) ir_assignment(param->as_rvalue(), + new(ctx) ir_dereference_variable(parameters[i]), + NULL); + next_ir->insert_before(assign); + } + + param_iter.next(); + } + + delete [] parameters; + + hash_table_dtor(ht); + + if (retval) + return new(ctx) ir_dereference_variable(retval); + else + return NULL; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_expression *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_return *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_texture *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_swizzle *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_call *ir) +{ + if (can_inline(ir)) { + (void) ir->generate_inline(ir); + ir->remove(); + this->progress = true; + } + + return visit_continue; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_assignment *ir) +{ + ir_call *call = ir->rhs->as_call(); + if (!call || !can_inline(call)) + return visit_continue; + + /* generates the parameter setup, function body, and returns the return + * value of the function + */ + ir_rvalue *rhs = call->generate_inline(ir); + assert(rhs); + + ir->rhs = rhs; + this->progress = true; + + return visit_continue; +} diff --git a/src/glsl/ir_function_inlining.h b/src/glsl/ir_function_inlining.h new file mode 100644 index 00000000000..6db011bbcae --- /dev/null +++ b/src/glsl/ir_function_inlining.h @@ -0,0 +1,30 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_inlining.h + * + * Replaces calls to functions with the body of the function. + */ + +bool can_inline(ir_call *call); diff --git a/src/glsl/ir_hierarchical_visitor.cpp b/src/glsl/ir_hierarchical_visitor.cpp new file mode 100644 index 00000000000..0d520b127f2 --- /dev/null +++ b/src/glsl/ir_hierarchical_visitor.cpp @@ -0,0 +1,284 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" +#include "ir_hierarchical_visitor.h" + +ir_hierarchical_visitor::ir_hierarchical_visitor() +{ + this->callback = NULL; + this->data = NULL; +} + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_variable *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_constant *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_loop_jump *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_dereference_variable *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_loop *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_loop *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_function_signature *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_function_signature *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_function *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_function *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_expression *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_expression *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_texture *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_texture *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_swizzle *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_swizzle *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_dereference_array *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_dereference_record *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_assignment *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_assignment *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_call *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_call *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_return *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_return *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_if *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_if *ir) +{ + (void) ir; + return visit_continue; +} + +void +ir_hierarchical_visitor::run(exec_list *instructions) +{ + foreach_list(n, instructions) { + ir_instruction *ir = (ir_instruction *) n; + + if (ir->accept(this) != visit_continue) + break; + } +} + + +void +visit_tree(ir_instruction *ir, + void (*callback)(class ir_instruction *ir, void *data), + void *data) +{ + ir_hierarchical_visitor v; + + v.callback = callback; + v.data = data; + + ir->accept(&v); +} diff --git a/src/glsl/ir_hierarchical_visitor.h b/src/glsl/ir_hierarchical_visitor.h new file mode 100644 index 00000000000..8b9e49dab13 --- /dev/null +++ b/src/glsl/ir_hierarchical_visitor.h @@ -0,0 +1,162 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_HIERARCHICAL_VISITOR_H +#define IR_HIERARCHICAL_VISITOR_H + +/** + * Enumeration values returned by visit methods to guide processing + */ +enum ir_visitor_status { + visit_continue, /**< Continue visiting as normal. */ + visit_continue_with_parent, /**< Don't visit siblings, continue w/parent. */ + visit_stop /**< Stop visiting immediately. */ +}; + + +/** + * Base class of hierarchical visitors of IR instruction trees + * + * Hierarchical visitors differ from traditional visitors in a couple of + * important ways. Rather than having a single \c visit method for each + * subclass in the composite, there are three kinds of visit methods. + * Leaf-node classes have a traditional \c visit method. Internal-node + * classes have a \c visit_enter method, which is invoked just before + * processing child nodes, and a \c visit_leave method which is invoked just + * after processing child nodes. + * + * In addition, each visit method and the \c accept methods in the composite + * have a return value which guides the navigation. Any of the visit methods + * can choose to continue visiting the tree as normal (by returning \c + * visit_continue), terminate visiting any further nodes immediately (by + * returning \c visit_stop), or stop visiting sibling nodes (by returning \c + * visit_continue_with_parent). + * + * These two changes combine to allow nagivation of children to be implemented + * in the composite's \c accept method. The \c accept method for a leaf-node + * class will simply call the \c visit method, as usual, and pass its return + * value on. The \c accept method for internal-node classes will call the \c + * visit_enter method, call the \c accpet method of each child node, and, + * finally, call the \c visit_leave method. If any of these return a value + * other that \c visit_continue, the correct action must be taken. + * + * The final benefit is that the hierarchical visitor base class need not be + * abstract. Default implementations of every \c visit, \c visit_enter, and + * \c visit_leave method can be provided. By default each of these methods + * simply returns \c visit_continue. This allows a significant reduction in + * derived class code. + * + * For more information about hierarchical visitors, see: + * + * http://c2.com/cgi/wiki?HierarchicalVisitorPattern + * http://c2.com/cgi/wiki?HierarchicalVisitorDiscussion + */ + +class ir_hierarchical_visitor { +public: + ir_hierarchical_visitor(); + + /** + * \name Visit methods for leaf-node classes + */ + /*@{*/ + virtual ir_visitor_status visit(class ir_variable *); + virtual ir_visitor_status visit(class ir_constant *); + virtual ir_visitor_status visit(class ir_loop_jump *); + + /** + * ir_dereference_variable isn't technically a leaf, but it is treated as a + * leaf here for a couple reasons. By not automatically visiting the one + * child ir_variable node from the ir_dereference_variable, ir_variable + * nodes can always be handled as variable declarations. Code that used + * non-hierarchical visitors had to set an "in a dereference" flag to + * determine how to handle an ir_variable. By forcing the visitor to + * handle the ir_variable within the ir_dereference_variable visitor, this + * kludge can be avoided. + * + * In addition, I can envision no use for having separate enter and leave + * methods. Anything that could be done in the enter and leave methods + * that couldn't just be done in the visit method. + */ + virtual ir_visitor_status visit(class ir_dereference_variable *); + /*@}*/ + + /** + * \name Visit methods for internal-node classes + */ + /*@{*/ + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_leave(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_leave(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_leave(class ir_function *); + virtual ir_visitor_status visit_enter(class ir_expression *); + virtual ir_visitor_status visit_leave(class ir_expression *); + virtual ir_visitor_status visit_enter(class ir_texture *); + virtual ir_visitor_status visit_leave(class ir_texture *); + virtual ir_visitor_status visit_enter(class ir_swizzle *); + virtual ir_visitor_status visit_leave(class ir_swizzle *); + virtual ir_visitor_status visit_enter(class ir_dereference_array *); + virtual ir_visitor_status visit_leave(class ir_dereference_array *); + virtual ir_visitor_status visit_enter(class ir_dereference_record *); + virtual ir_visitor_status visit_leave(class ir_dereference_record *); + virtual ir_visitor_status visit_enter(class ir_assignment *); + virtual ir_visitor_status visit_leave(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_leave(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_return *); + virtual ir_visitor_status visit_leave(class ir_return *); + virtual ir_visitor_status visit_enter(class ir_if *); + virtual ir_visitor_status visit_leave(class ir_if *); + /*@}*/ + + + /** + * Utility function to process a linked list of instructions with a visitor + */ + void run(struct exec_list *instructions); + + /** + * Callback function that is invoked on entry to each node visited. + * + * \warning + * Visitor classes derived from \c ir_hierarchical_visitor \b may \b not + * invoke this function. This can be used, for example, to cause the + * callback to be invoked on every node type execpt one. + */ + void (*callback)(class ir_instruction *ir, void *data); + + /** + * Extra data parameter passed to the per-node callback function + */ + void *data; +}; + +void visit_tree(ir_instruction *ir, + void (*callback)(class ir_instruction *ir, void *data), + void *data); + +#endif /* IR_HIERARCHICAL_VISITOR_H */ diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp new file mode 100644 index 00000000000..f936b3500eb --- /dev/null +++ b/src/glsl/ir_hv_accept.cpp @@ -0,0 +1,348 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" + +/** + * \file ir_hv_accept.cpp + * Implementations of all hierarchical visitor accept methods for IR + * instructions. + */ + +/** + * Process a list of nodes using a hierarchical vistor + * + * \warning + * This function will operate correctly if a node being processed is removed + * from list. However, if nodes are added to the list after the node being + * processed, some of the added noded may not be processed. + */ +static ir_visitor_status +visit_list_elements(ir_hierarchical_visitor *v, exec_list *l) +{ + exec_node *next; + + for (exec_node *n = l->head; n->next != NULL; n = next) { + next = n->next; + + ir_instruction *const ir = (ir_instruction *) n; + ir_visitor_status s = ir->accept(v); + + if (s != visit_continue) + return s; + } + + return visit_continue; +} + + +ir_visitor_status +ir_variable::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_loop::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->body_instructions); + if (s == visit_stop) + return s; + + if (s != visit_continue_with_parent) { + if (this->from) { + s = this->from->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + if (this->to) { + s = this->to->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + if (this->increment) { + s = this->increment->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + } + + return v->visit_leave(this); +} + + +ir_visitor_status +ir_loop_jump::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_function_signature::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->body); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_function::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->signatures); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_expression::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + for (unsigned i = 0; i < this->get_num_operands(); i++) { + switch (this->operands[i]->accept(v)) { + case visit_continue: + break; + + case visit_continue_with_parent: + // I wish for Java's labeled break-statement here. + goto done; + + case visit_stop: + return s; + } + } + +done: + return v->visit_leave(this); +} + +ir_visitor_status +ir_texture::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->sampler->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->coordinate->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (this->projector) { + s = this->projector->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + if (this->shadow_comparitor) { + s = this->shadow_comparitor->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + switch (this->op) { + case ir_tex: + break; + case ir_txb: + s = this->lod_info.bias->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + break; + case ir_txl: + case ir_txf: + s = this->lod_info.lod->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + break; + case ir_txd: + s = this->lod_info.grad.dPdx->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->lod_info.grad.dPdy->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + break; + } + + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_swizzle::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->val->accept(v); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_dereference_variable::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_dereference_array::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->array_index->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->array->accept(v); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_dereference_record::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->record->accept(v); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_assignment::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->lhs->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->rhs->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (this->condition) + s = this->condition->accept(v); + + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_constant::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_call::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->actual_parameters); + if (s == visit_stop) + return s; + + return v->visit_leave(this); +} + + +ir_visitor_status +ir_return::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + ir_rvalue *val = this->get_value(); + if (val) { + s = val->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + return v->visit_leave(this); +} + + +ir_visitor_status +ir_if::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->condition->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (s != visit_continue_with_parent) { + s = visit_list_elements(v, &this->then_instructions); + if (s == visit_stop) + return s; + } + + if (s != visit_continue_with_parent) { + s = visit_list_elements(v, &this->else_instructions); + if (s == visit_stop) + return s; + } + + return v->visit_leave(this); +} diff --git a/src/glsl/ir_if_simplification.cpp b/src/glsl/ir_if_simplification.cpp new file mode 100644 index 00000000000..6882ef72b95 --- /dev/null +++ b/src/glsl/ir_if_simplification.cpp @@ -0,0 +1,84 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_inlining.cpp + * + * Moves constant branches of if statements out to the surrounding + * instruction stream. + */ + +#include "ir.h" + +class ir_if_simplification_visitor : public ir_hierarchical_visitor { +public: + ir_if_simplification_visitor() + { + this->made_progress = false; + } + + ir_visitor_status visit_leave(ir_if *); + + bool made_progress; +}; + +bool +do_if_simplification(exec_list *instructions) +{ + ir_if_simplification_visitor v; + + v.run(instructions); + return v.made_progress; +} + + +ir_visitor_status +ir_if_simplification_visitor::visit_leave(ir_if *ir) +{ + /* FINISHME: Ideally there would be a way to note that the condition results + * FINISHME: in a constant before processing both of the other subtrees. + * FINISHME: This can probably be done with some flags, but it would take + * FINISHME: some work to get right. + */ + ir_constant *condition_constant = ir->condition->constant_expression_value(); + if (condition_constant) { + /* Move the contents of the one branch of the conditional + * that matters out. + */ + if (condition_constant->value.b[0]) { + foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { + ir_instruction *then_ir = (ir_instruction *)then_iter.get(); + ir->insert_before(then_ir); + } + } else { + foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { + ir_instruction *else_ir = (ir_instruction *)else_iter.get(); + ir->insert_before(else_ir); + } + } + ir->remove(); + this->made_progress = true; + } + + return visit_continue; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h new file mode 100644 index 00000000000..432a33458c2 --- /dev/null +++ b/src/glsl/ir_optimization.h @@ -0,0 +1,41 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file ir_dead_code.h + * + * Prototypes for optimization passes to be called by the compiler and drivers. + */ + +bool do_constant_folding(exec_list *instructions); +bool do_constant_variable(exec_list *instructions); +bool do_constant_variable_unlinked(exec_list *instructions); +bool do_copy_propagation(exec_list *instructions); +bool do_dead_code(exec_list *instructions); +bool do_dead_code_local(exec_list *instructions); +bool do_dead_code_unlinked(exec_list *instructions); +bool do_function_inlining(exec_list *instructions); +bool do_if_simplification(exec_list *instructions); +bool do_swizzle_swizzle(exec_list *instructions); +bool do_vec_index_to_swizzle(exec_list *instructions); diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp new file mode 100644 index 00000000000..be5a843f67d --- /dev/null +++ b/src/glsl/ir_print_visitor.cpp @@ -0,0 +1,373 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir_print_visitor.h" +#include "glsl_types.h" +#include "glsl_parser_extras.h" + +static void print_type(const glsl_type *t); + +void +ir_instruction::print(void) const +{ + ir_instruction *deconsted = const_cast(this); + + ir_print_visitor v; + deconsted->accept(&v); +} + +void +_mesa_print_ir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + for (unsigned i = 0; i < state->num_user_structures; i++) { + const glsl_type *const s = state->user_structures[i]; + + printf("(structure (%s) (%s@%p) (%u) (\n", + s->name, s->name, s, s->length); + + for (unsigned j = 0; j < s->length; j++) { + printf("\t(("); + print_type(s->fields.structure[j].type); + printf(")(%s))\n", s->fields.structure[j].name); + } + + printf(")\n"); + } + + printf("(\n"); + foreach_iter(exec_list_iterator, iter, *instructions) { + ((ir_instruction *)iter.get())->print(); + printf("\n"); + } + printf("\n)"); +} + +static void +print_type(const glsl_type *t) +{ + if (t->base_type == GLSL_TYPE_ARRAY) { + printf("(array "); + print_type(t->fields.array); + printf(" %u)", t->length); + } else if ((t->base_type == GLSL_TYPE_STRUCT) + && (strncmp("gl_", t->name, 3) != 0)) { + printf("%s@%p", t->name, t); + } else { + printf("%s", t->name); + } +} + + +void ir_print_visitor::visit(ir_variable *ir) +{ + printf("(declare "); + + const char *const cent = (ir->centroid) ? "centroid " : ""; + const char *const inv = (ir->invariant) ? "invariant " : ""; + const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " }; + const char *const interp[] = { "", "flat", "noperspective" }; + + printf("(%s%s%s%s) ", + cent, inv, mode[ir->mode], interp[ir->interpolation]); + + print_type(ir->type); + printf(" %s@%p)", ir->name, ir); +} + + +void ir_print_visitor::visit(ir_function_signature *ir) +{ + printf("(signature "); + print_type(ir->return_type); + printf("\n (parameters\n"); + foreach_iter(exec_list_iterator, iter, ir->parameters) { + ir_variable *const inst = (ir_variable *) iter.get(); + + inst->accept(this); + printf("\n"); + } + printf(" )\n("); + + foreach_iter(exec_list_iterator, iter, ir->body) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + inst->accept(this); + printf("\n"); + } + printf("))\n"); +} + + +void ir_print_visitor::visit(ir_function *ir) +{ + printf("(function %s\n", ir->name); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_function_signature *const sig = (ir_function_signature *) iter.get(); + + sig->accept(this); + printf("\n"); + } + + printf(")\n"); +} + + +void ir_print_visitor::visit(ir_expression *ir) +{ + printf("(expression "); + + print_type(ir->type); + + printf(" %s ", ir->operator_string()); + + if (ir->operands[0]) + ir->operands[0]->accept(this); + + if (ir->operands[1]) + ir->operands[1]->accept(this); + printf(") "); +} + + +void ir_print_visitor::visit(ir_texture *ir) +{ + printf("(%s ", ir->opcode_string()); + + ir->sampler->accept(this); + printf(" "); + + ir->coordinate->accept(this); + + printf(" (%d %d %d) ", ir->offsets[0], ir->offsets[1], ir->offsets[2]); + + if (ir->op != ir_txf) { + if (ir->projector) + ir->projector->accept(this); + else + printf("1"); + + if (ir->shadow_comparitor) { + printf(" "); + ir->shadow_comparitor->accept(this); + } else { + printf(" ()"); + } + } + + printf(" "); + switch (ir->op) + { + case ir_tex: + break; + case ir_txb: + ir->lod_info.bias->accept(this); + break; + case ir_txl: + case ir_txf: + ir->lod_info.lod->accept(this); + break; + case ir_txd: + printf("("); + ir->lod_info.grad.dPdx->accept(this); + printf(" "); + ir->lod_info.grad.dPdy->accept(this); + printf(")"); + break; + }; + printf(")"); +} + + +void ir_print_visitor::visit(ir_swizzle *ir) +{ + const unsigned swiz[4] = { + ir->mask.x, + ir->mask.y, + ir->mask.z, + ir->mask.w, + }; + + printf("(swiz "); + for (unsigned i = 0; i < ir->mask.num_components; i++) { + printf("%c", "xyzw"[swiz[i]]); + } + printf(" "); + ir->val->accept(this); + printf(")"); +} + + +void ir_print_visitor::visit(ir_dereference_variable *ir) +{ + ir_variable *var = ir->variable_referenced(); + printf("(var_ref %s@%p) ", var->name, var); +} + + +void ir_print_visitor::visit(ir_dereference_array *ir) +{ + printf("(array_ref "); + ir->array->accept(this); + ir->array_index->accept(this); + printf(") "); +} + + +void ir_print_visitor::visit(ir_dereference_record *ir) +{ + printf("(record_ref "); + ir->record->accept(this); + printf(" %s) ", ir->field); +} + + +void ir_print_visitor::visit(ir_assignment *ir) +{ + printf("(assign "); + + if (ir->condition) + ir->condition->accept(this); + else + printf("(constant bool (1))"); + + printf(" "); + + ir->lhs->accept(this); + + printf(" "); + + ir->rhs->accept(this); + printf(") "); +} + + +void ir_print_visitor::visit(ir_constant *ir) +{ + const glsl_type *const base_type = ir->type->get_base_type(); + + printf("(constant "); + print_type(ir->type); + printf(" ("); + + for (unsigned i = 0; i < ir->type->components(); i++) { + if (i != 0) + printf(", "); + + switch (base_type->base_type) { + case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break; + case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break; + case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break; + case GLSL_TYPE_BOOL: printf("%d", ir->value.b[i]); break; + default: assert(0); + } + } + printf(")) "); +} + + +void +ir_print_visitor::visit(ir_call *ir) +{ + printf("(call %s (", ir->callee_name()); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + inst->accept(this); + } + printf("))\n"); +} + + +void +ir_print_visitor::visit(ir_return *ir) +{ + printf("(return"); + + ir_rvalue *const value = ir->get_value(); + if (value) { + printf(" "); + value->accept(this); + } + + printf(")"); +} + + +void +ir_print_visitor::visit(ir_if *ir) +{ + printf("(if "); + ir->condition->accept(this); + + printf("(\n"); + foreach_iter(exec_list_iterator, iter, ir->then_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + inst->accept(this); + printf("\n"); + } + printf(")\n"); + + printf("(\n"); + foreach_iter(exec_list_iterator, iter, ir->else_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + inst->accept(this); + printf("\n"); + } + printf("))\n"); +} + + +void +ir_print_visitor::visit(ir_loop *ir) +{ + printf("(loop ("); + if (ir->counter != NULL) + ir->counter->accept(this); + printf(") ("); + if (ir->from != NULL) + ir->from->accept(this); + printf(") ("); + if (ir->to != NULL) + ir->to->accept(this); + printf(") ("); + if (ir->increment != NULL) + ir->increment->accept(this); + printf(") (\n"); + foreach_iter(exec_list_iterator, iter, ir->body_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + inst->accept(this); + printf("\n"); + } + printf("))\n"); +} + + +void +ir_print_visitor::visit(ir_loop_jump *ir) +{ + printf("%s", ir->is_break() ? "break" : "continue"); +} diff --git a/src/glsl/ir_print_visitor.h b/src/glsl/ir_print_visitor.h new file mode 100644 index 00000000000..e97b823522a --- /dev/null +++ b/src/glsl/ir_print_visitor.h @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_PRINT_VISITOR_H +#define IR_PRINT_VISITOR_H + +#include "ir.h" +#include "ir_visitor.h" + +extern void _mesa_print_ir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +/** + * Abstract base class of visitors of IR instruction trees + */ +class ir_print_visitor : public ir_visitor { +public: + ir_print_visitor() + : deref_depth(0) + { + /* empty */ + } + + virtual ~ir_print_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_texture *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + /*@}*/ + +private: + int deref_depth; +}; + +#endif /* IR_PRINT_VISITOR_H */ diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp new file mode 100644 index 00000000000..7383c42cbc7 --- /dev/null +++ b/src/glsl/ir_reader.cpp @@ -0,0 +1,1053 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include + +extern "C" { +#include +} + +#include "ir_reader.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" +#include "s_expression.h" + +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 *read_var_ref(_mesa_glsl_parse_state *, s_list *); +static ir_dereference *read_array_ref(_mesa_glsl_parse_state *, s_list *); +static ir_dereference *read_record_ref(_mesa_glsl_parse_state *, s_list *); + +void +_mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, + const char *src) +{ + void *ctx = talloc_parent(state); + s_expression *expr = s_expression::read_expression(ctx, src); + if (expr == NULL) { + ir_read_error(state, NULL, "couldn't parse S-Expression."); + return; + } + + scan_for_prototypes(state, instructions, expr); + if (state->error) + return; + + read_instructions(state, instructions, expr, NULL); +} + +static void +ir_read_error(_mesa_glsl_parse_state *state, s_expression *expr, + const char *fmt, ...) +{ + va_list ap; + + state->error = true; + + state->info_log = talloc_strdup_append(state->info_log, "error: "); + + va_start(ap, fmt); + state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap); + va_end(ap); + state->info_log = talloc_strdup_append(state->info_log, "\n"); + + if (expr != NULL) { + state->info_log = talloc_strdup_append(state->info_log, + "...in this context:\n "); + expr->print(); + state->info_log = talloc_strdup_append(state->info_log, "\n\n"); + } +} + +static const glsl_type * +read_type(_mesa_glsl_parse_state *st, 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 ...)"); + return NULL; + } + if (strcmp(type_sym->value(), "array") == 0) { + if (list->length() != 3) { + ir_read_error(st, expr, "expected type (array )"); + 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(st, 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; + } + } + + s_symbol *type_sym = SX_AS_SYMBOL(expr); + if (type_sym == NULL) { + ir_read_error(st, expr, "expected (symbol or list)"); + return NULL; + } + + const glsl_type *type = st->symbols->get_type(type_sym->value()); + if (type == NULL) + ir_read_error(st, 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) +{ + s_list *list = SX_AS_LIST(expr); + if (list == NULL) { + ir_read_error(st, expr, "Expected ( ...); found an atom."); + return; + } + + foreach_iter(exec_list_iterator, it, list->subexpressions) { + s_list *sub = SX_AS_LIST(it.get()); + if (sub == NULL) + continue; // not a (function ...); ignore it. + + s_symbol *tag = SX_AS_SYMBOL(sub->subexpressions.get_head()); + if (tag == NULL || strcmp(tag->value(), "function") != 0) + continue; // not a (function ...); ignore it. + + ir_function *f = read_function(st, 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) +{ + void *ctx = talloc_parent(st); + if (list->length() < 3) { + ir_read_error(st, list, "Expected (function (signature ...) ...)"); + return NULL; + } + + s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next); + if (name == NULL) { + ir_read_error(st, list, "Expected (function ...)"); + return NULL; + } + + ir_function *f = st->symbols->get_function(name->value()); + if (f == NULL) { + f = new(ctx) ir_function(name->value()); + bool added = st->symbols->add_function(name->value(), f); + assert(added); + } + + exec_list_iterator it = list->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); + } + return f; +} + +static void +read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list, + bool skip_body) +{ + void *ctx = talloc_parent(st); + if (list->length() != 4) { + ir_read_error(st, list, "Expected (signature (parameters ...) " + "( ...))"); + return; + } + + s_expression *type_expr = (s_expression*) list->subexpressions.head->next; + const glsl_type *return_type = read_type(st, type_expr); + if (return_type == NULL) + return; + + s_list *paramlist = SX_AS_LIST(type_expr->next); + s_list *body_list = SX_AS_LIST(paramlist->next); + if (paramlist == NULL || body_list == NULL) { + ir_read_error(st, list, "Expected (signature (parameters ...) " + "( ...))"); + 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 ...)"); + return; + } + + // Read the parameters list into a temporary place. + exec_list hir_parameters; + st->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); + if (var == NULL) + return; + + hir_parameters.push_tail(var); + } + + ir_function_signature *sig = f->exact_matching_signature(&hir_parameters); + if (sig != NULL) { + const char *badvar = sig->qualifiers_match(&hir_parameters); + if (badvar != NULL) { + ir_read_error(st, list, "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 " + "match prototype", f->name); + return; + } + } else { + sig = new(ctx) ir_function_signature(return_type); + f->add_signature(sig); + } + + sig->replace_parameters(&hir_parameters); + + if (!skip_body) { + if (sig->is_defined) { + ir_read_error(st, list, "function %s redefined", f->name); + return; + } + read_instructions(st, &sig->body, body_list, NULL); + sig->is_defined = true; + } + + st->symbols->pop_scope(); +} + +static void +read_instructions(_mesa_glsl_parse_state *st, 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 ( ...); 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); + if (ir == NULL) { + ir_read_error(st, sub, "Invalid instruction.\n"); + return; + } + instructions->push_tail(ir); + } +} + + +static ir_instruction * +read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, + ir_loop *loop_ctx) +{ + void *ctx = talloc_parent(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); + if (strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL) + return new(ctx) ir_loop_jump(ir_loop_jump::jump_continue); + } + + s_list *list = SX_AS_LIST(expr); + if (list == NULL || list->subexpressions.is_empty()) + return NULL; + + s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head()); + if (tag == NULL) { + ir_read_error(st, expr, "expected instruction tag"); + return NULL; + } + + ir_instruction *inst = NULL; + if (strcmp(tag->value(), "declare") == 0) { + inst = read_declaration(st, list); + } else if (strcmp(tag->value(), "if") == 0) { + inst = read_if(st, list, loop_ctx); + } else if (strcmp(tag->value(), "loop") == 0) { + inst = read_loop(st, list); + } else if (strcmp(tag->value(), "return") == 0) { + inst = read_return(st, list); + } else if (strcmp(tag->value(), "function") == 0) { + inst = read_function(st, list, false); + } else { + inst = read_rvalue(st, list); + if (inst == NULL) + ir_read_error(st, NULL, "when reading instruction"); + } + return inst; +} + + +static ir_variable * +read_declaration(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(st); + if (list->length() != 4) { + ir_read_error(st, list, "expected (declare () " + ")"); + return NULL; + } + + s_list *quals = SX_AS_LIST(list->subexpressions.head->next); + if (quals == NULL) { + ir_read_error(st, list, "expected a list of variable qualifiers"); + return NULL; + } + + s_expression *type_expr = (s_expression*) quals->next; + const glsl_type *type = read_type(st, type_expr); + 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()); + + foreach_iter(exec_list_iterator, it, 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; + return NULL; + } + + // FINISHME: Check for duplicate/conflicting qualifiers. + if (strcmp(qualifier->value(), "centroid") == 0) { + var->centroid = 1; + } else if (strcmp(qualifier->value(), "invariant") == 0) { + var->invariant = 1; + } else if (strcmp(qualifier->value(), "uniform") == 0) { + var->mode = ir_var_uniform; + } else if (strcmp(qualifier->value(), "auto") == 0) { + var->mode = ir_var_auto; + } else if (strcmp(qualifier->value(), "in") == 0) { + var->mode = ir_var_in; + } else if (strcmp(qualifier->value(), "out") == 0) { + var->mode = ir_var_out; + } else if (strcmp(qualifier->value(), "inout") == 0) { + var->mode = ir_var_inout; + } else if (strcmp(qualifier->value(), "smooth") == 0) { + var->interpolation = ir_var_smooth; + } else if (strcmp(qualifier->value(), "flat") == 0) { + var->interpolation = ir_var_flat; + } 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; + return NULL; + } + } + + // Add the variable to the symbol table + st->symbols->add_variable(var_name->value(), var); + + return var; +} + + +static ir_if * +read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx) +{ + void *ctx = talloc_parent(st); + if (list->length() != 4) { + ir_read_error(st, list, "expected (if ( ...) " + "( ...))"); + return NULL; + } + + s_expression *cond_expr = (s_expression*) list->subexpressions.head->next; + ir_rvalue *condition = read_rvalue(st, cond_expr); + if (condition == NULL) { + ir_read_error(st, 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(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) { + delete iff; + iff = NULL; + } + return iff; +} + + +static ir_loop * +read_loop(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(st); + if (list->length() != 6) { + ir_read_error(st, list, "expected (loop " + " )"); + 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) { + delete loop; + loop = NULL; + } + return loop; +} + + +static ir_return * +read_return(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(st); + if (list->length() != 2) { + ir_read_error(st, list, "expected (return )"); + return NULL; + } + + s_expression *expr = (s_expression*) list->subexpressions.head->next; + + ir_rvalue *retval = read_rvalue(st, expr); + if (retval == NULL) { + ir_read_error(st, NULL, "when reading return value"); + return NULL; + } + + return new(ctx) ir_return(retval); +} + + +static ir_rvalue * +read_rvalue(_mesa_glsl_parse_state *st, 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.get_head()); + if (tag == NULL) { + ir_read_error(st, expr, "expected rvalue tag"); + return NULL; + } + + ir_rvalue *rvalue = read_dereference(st, list); + if (rvalue != NULL || st->error) + return rvalue; + else if (strcmp(tag->value(), "swiz") == 0) { + rvalue = read_swizzle(st, list); + } else if (strcmp(tag->value(), "assign") == 0) { + rvalue = read_assignment(st, list); + } else if (strcmp(tag->value(), "expression") == 0) { + rvalue = read_expression(st, list); + } else if (strcmp(tag->value(), "call") == 0) { + rvalue = read_call(st, list); + } else if (strcmp(tag->value(), "constant") == 0) { + rvalue = read_constant(st, list); + } else { + rvalue = read_texture(st, list); + if (rvalue == NULL && !st->error) + ir_read_error(st, expr, "unrecognized rvalue tag: %s", tag->value()); + } + + return rvalue; +} + +static ir_assignment * +read_assignment(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(st); + if (list->length() != 4) { + ir_read_error(st, list, "expected (assign )"); + return NULL; + } + + s_expression *cond_expr = (s_expression*) list->subexpressions.head->next; + s_expression *lhs_expr = (s_expression*) cond_expr->next; + s_expression *rhs_expr = (s_expression*) lhs_expr->next; + + // FINISHME: Deal with "true" condition + ir_rvalue *condition = read_rvalue(st, cond_expr); + if (condition == NULL) { + ir_read_error(st, NULL, "when reading condition of assignment"); + return NULL; + } + + ir_rvalue *lhs = read_rvalue(st, lhs_expr); + if (lhs == NULL) { + ir_read_error(st, NULL, "when reading left-hand side of assignment"); + return NULL; + } + + ir_rvalue *rhs = read_rvalue(st, rhs_expr); + if (rhs == NULL) { + ir_read_error(st, NULL, "when reading right-hand side of assignment"); + return NULL; + } + + return new(ctx) ir_assignment(lhs, rhs, condition); +} + +static ir_call * +read_call(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(st); + if (list->length() != 3) { + ir_read_error(st, list, "expected (call ( ...))"); + return NULL; + } + + s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next); + s_list *params = SX_AS_LIST(name->next); + if (name == NULL || params == NULL) { + ir_read_error(st, list, "expected (call ( ...))"); + return NULL; + } + + exec_list parameters; + + foreach_iter(exec_list_iterator, it, params->subexpressions) { + s_expression *expr = (s_expression*) it.get(); + ir_rvalue *param = read_rvalue(st, expr); + if (param == NULL) { + ir_read_error(st, list, "when reading parameter to function call"); + return NULL; + } + parameters.push_tail(param); + } + + ir_function *f = st->symbols->get_function(name->value()); + if (f == NULL) { + ir_read_error(st, list, "found call to undefined function %s", + name->value()); + return NULL; + } + + const ir_function_signature *callee = f->matching_signature(¶meters); + if (callee == NULL) { + ir_read_error(st, list, "couldn't find matching signature for function " + "%s", name->value()); + return NULL; + } + + return new(ctx) ir_call(callee, ¶meters); +} + +static ir_expression * +read_expression(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(st); + const unsigned list_length = list->length(); + if (list_length < 4) { + ir_read_error(st, list, "expected (expression " + " [])"); + return NULL; + } + + s_expression *type_expr = (s_expression*) list->subexpressions.head->next; + const glsl_type *type = read_type(st, type_expr); + 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()); + if (op == (ir_expression_operation) -1) { + ir_read_error(st, list, "invalid operator: %s", op_sym->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 %s " + " )", op_sym->value()); + return NULL; + } + } else { + if (list_length != 4) { + ir_read_error(st, list, "expected (expression %s )", + op_sym->value()); + return NULL; + } + } + + s_expression *exp1 = (s_expression*) (op_sym->next); + ir_rvalue *arg1 = read_rvalue(st, exp1); + if (arg1 == NULL) { + ir_read_error(st, NULL, "when reading first operand of %s", + op_sym->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 (arg2 == NULL) { + ir_read_error(st, NULL, "when reading second operand of %s", + op_sym->value()); + return NULL; + } + } + + return new(ctx) ir_expression(op, type, arg1, arg2); +} + +static ir_swizzle * +read_swizzle(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 3) { + ir_read_error(st, list, "expected (swiz )"); + return NULL; + } + + 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"); + return NULL; + } + + if (strlen(swiz->value()) > 4) { + ir_read_error(st, list, "expected a valid swizzle; found %s", + swiz->value()); + return NULL; + } + + s_expression *sub = (s_expression*) swiz->next; + if (sub == NULL) { + ir_read_error(st, list, "expected rvalue: (swizzle %s )", + swiz->value()); + return NULL; + } + + ir_rvalue *rvalue = read_rvalue(st, 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"); + + return ir; +} + +static ir_constant * +read_constant(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(st); + if (list->length() != 3) { + ir_read_error(st, list, "expected (constant ( ... ))"); + return NULL; + } + + s_expression *type_expr = (s_expression*) list->subexpressions.head->next; + const glsl_type *type = read_type(st, 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 ( ... ))"); + return NULL; + } + + const glsl_type *const base_type = type->get_base_type(); + + ir_constant_data data; + + // Read in list of values (at most 16). + int k = 0; + foreach_iter(exec_list_iterator, it, values->subexpressions) { + if (k >= 16) { + ir_read_error(st, values, "expected at most 16 numbers"); + return NULL; + } + + s_expression *expr = (s_expression*) it.get(); + + 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"); + 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"); + return NULL; + } + + switch (base_type->base_type) { + case GLSL_TYPE_UINT: { + data.u[k] = value->value(); + break; + } + case GLSL_TYPE_INT: { + data.i[k] = value->value(); + break; + } + case GLSL_TYPE_BOOL: { + data.b[k] = value->value(); + break; + } + default: + ir_read_error(st, values, "unsupported constant type"); + return NULL; + } + } + ++k; + } + + return new(ctx) ir_constant(type, &data); +} + +static ir_dereference * +read_dereference(_mesa_glsl_parse_state *st, 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 * +read_var_ref(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(st); + if (list->length() != 2) { + ir_read_error(st, list, "expected (var_ref )"); + 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 )"); + 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 * +read_array_ref(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(st); + if (list->length() != 3) { + ir_read_error(st, list, "expected (array_ref )"); + 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 * +read_record_ref(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(st); + if (list->length() != 3) { + ir_read_error(st, list, "expected (record_ref )"); + 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 *field = SX_AS_SYMBOL(subj_expr->next); + if (field == NULL) { + ir_read_error(st, list, "expected (record_ref ... )"); + return NULL; + } + 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; +} + +static ir_texture * +read_texture(_mesa_glsl_parse_state *st, s_list *list) +{ + void *ctx = talloc_parent(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; + } + + ir_texture *tex = new(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); + if (sampler == NULL) { + ir_read_error(st, NULL, "when reading sampler in (%s ...)", tag->value()); + 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); + if (tex->coordinate == NULL) { + ir_read_error(st, NULL, "when reading coordinate in (%s ...)", + tag->value()); + 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 ( )"); + return NULL; + } + s_int *offset_x = SX_AS_INT(offset_list->subexpressions.head); + s_int *offset_y = SX_AS_INT(offset_x->next); + s_int *offset_z = SX_AS_INT(offset_y->next); + if (offset_x == NULL || offset_y == NULL || offset_z == NULL) { + ir_read_error(st, offset_list, "expected ( )"); + 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 (proj_as_int && proj_as_int->value() == 1) { + tex->projector = NULL; + } else { + tex->projector = read_rvalue(st, proj_expr); + if (tex->projector == NULL) { + ir_read_error(st, NULL, "when reading projective divide in (%s ..)", + tag->value()); + 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; + } else { + tex->shadow_comparitor = read_rvalue(st, shadow_list); + if (tex->shadow_comparitor == NULL) { + ir_read_error(st, NULL, "when reading shadow comparitor in (%s ..)", + tag->value()); + 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; + } + default: + // tex doesn't have any extra parameters and txf was handled earlier. + break; + }; + } + return tex; +} diff --git a/src/glsl/ir_reader.h b/src/glsl/ir_reader.h new file mode 100644 index 00000000000..b6afdc81ab1 --- /dev/null +++ b/src/glsl/ir_reader.h @@ -0,0 +1,34 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_READER_H +#define IR_READER_H + +#include "ir.h" + +void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, + const char *src); + +#endif /* IR_READER_H */ diff --git a/src/glsl/ir_swizzle_swizzle.cpp b/src/glsl/ir_swizzle_swizzle.cpp new file mode 100644 index 00000000000..0ffb4fa3133 --- /dev/null +++ b/src/glsl/ir_swizzle_swizzle.cpp @@ -0,0 +1,93 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_swizzle_swizzle.cpp + * + * Eliminates the second swizzle in a swizzle chain. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +class ir_swizzle_swizzle_visitor : public ir_hierarchical_visitor { +public: + ir_swizzle_swizzle_visitor() + { + progress = false; + } + + virtual ir_visitor_status visit_enter(ir_swizzle *); + + bool progress; +}; + +ir_visitor_status +ir_swizzle_swizzle_visitor::visit_enter(ir_swizzle *ir) +{ + int mask2[4]; + + ir_swizzle *swiz2 = ir->val->as_swizzle(); + if (!swiz2) + return visit_continue; + + memset(&mask2, 0, sizeof(mask2)); + if (swiz2->mask.num_components >= 1) + mask2[0] = swiz2->mask.x; + if (swiz2->mask.num_components >= 2) + mask2[1] = swiz2->mask.y; + if (swiz2->mask.num_components >= 3) + mask2[2] = swiz2->mask.z; + if (swiz2->mask.num_components >= 4) + mask2[3] = swiz2->mask.w; + + if (ir->mask.num_components >= 1) + ir->mask.x = mask2[ir->mask.x]; + if (ir->mask.num_components >= 2) + ir->mask.y = mask2[ir->mask.y]; + if (ir->mask.num_components >= 3) + ir->mask.z = mask2[ir->mask.z]; + if (ir->mask.num_components >= 4) + ir->mask.w = mask2[ir->mask.w]; + + ir->val = swiz2->val; + + this->progress = true; + + return visit_continue; +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_swizzle_swizzle(exec_list *instructions) +{ + ir_swizzle_swizzle_visitor v; + + v.run(instructions); + + return v.progress; +} diff --git a/src/glsl/ir_to_mesa.cpp b/src/glsl/ir_to_mesa.cpp new file mode 100644 index 00000000000..26449c5a5c4 --- /dev/null +++ b/src/glsl/ir_to_mesa.cpp @@ -0,0 +1,1211 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_to_mesa.cpp + * + * Translates the IR to ARB_fragment_program text if possible, + * printing the result + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "ir_print_visitor.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +extern "C" { +#include "shader/prog_instruction.h" +#include "shader/prog_print.h" +} + +/** + * This struct is a corresponding struct to Mesa prog_src_register, with + * wider fields. + */ +typedef struct ir_to_mesa_src_reg { + int file; /**< PROGRAM_* from Mesa */ + int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ + int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ + int negate; /**< NEGATE_XYZW mask from mesa */ + bool reladdr; /**< Register index should be offset by address reg. */ +} ir_to_mesa_src_reg; + +typedef struct ir_to_mesa_dst_reg { + int file; /**< PROGRAM_* from Mesa */ + int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ + int writemask; /**< Bitfield of WRITEMASK_[XYZW] */ +} ir_to_mesa_dst_reg; + +extern ir_to_mesa_src_reg ir_to_mesa_undef; + +class ir_to_mesa_instruction : public exec_node { +public: + enum prog_opcode op; + ir_to_mesa_dst_reg dst_reg; + ir_to_mesa_src_reg src_reg[3]; + /** Pointer to the ir source this tree came from for debugging */ + ir_instruction *ir; +}; + +class temp_entry : public exec_node { +public: + temp_entry(ir_variable *var, int file, int index) + : file(file), index(index), var(var) + { + /* empty */ + } + + int file; + int index; + ir_variable *var; /* variable that maps to this, if any */ +}; + +class ir_to_mesa_visitor : public ir_visitor { +public: + ir_to_mesa_visitor(); + + int next_temp; + int next_constant; + int next_uniform; + + temp_entry *find_variable_storage(ir_variable *var); + + ir_to_mesa_src_reg get_temp(const glsl_type *type); + + struct ir_to_mesa_src_reg src_reg_for_float(float val); + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_texture *); + virtual void visit(ir_if *); + /*@}*/ + + struct ir_to_mesa_src_reg result; + + /** List of temp_entry */ + exec_list variable_storage; + + /** List of ir_to_mesa_instruction */ + exec_list instructions; + + ir_to_mesa_instruction *ir_to_mesa_emit_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); + + ir_to_mesa_instruction *ir_to_mesa_emit_op2(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1); + + ir_to_mesa_instruction *ir_to_mesa_emit_op3(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1, + ir_to_mesa_src_reg src2); + + void ir_to_mesa_emit_scalar_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); + + /* talloc context (the ) */ + void *ctx; +}; + +ir_to_mesa_src_reg ir_to_mesa_undef = { + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, NEGATE_NONE, false, +}; + +ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP +}; + +ir_to_mesa_dst_reg ir_to_mesa_address_reg = { + PROGRAM_ADDRESS, 0, WRITEMASK_X +}; + +static int swizzle_for_size(int size) +{ + int size_swizzles[4] = { + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), + }; + + return size_swizzles[size - 1]; +} + +/* This list should match up with builtin_variables.h */ +static const struct { + const char *name; + int file; + int index; +} builtin_var_to_mesa_reg[] = { + /* core_vs */ + {"gl_Position", PROGRAM_OUTPUT, VERT_RESULT_HPOS}, + {"gl_PointSize", PROGRAM_OUTPUT, VERT_RESULT_PSIZ}, + + /* core_fs */ + {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS}, + {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE}, + {"gl_FragColor", PROGRAM_OUTPUT, FRAG_ATTRIB_COL0}, + {"gl_FragDepth", PROGRAM_UNDEFINED, FRAG_ATTRIB_WPOS}, /* FINISHME: WPOS.z */ + + /* 110_deprecated_fs */ + {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, + {"gl_SecondaryColor", PROGRAM_INPUT, FRAG_ATTRIB_COL1}, + {"gl_FogFragCoord", PROGRAM_INPUT, FRAG_ATTRIB_FOGC}, + {"gl_TexCoord", PROGRAM_INPUT, FRAG_ATTRIB_TEX0}, /* array */ + + /* 110_deprecated_vs */ + {"gl_Vertex", PROGRAM_INPUT, VERT_ATTRIB_POS}, + {"gl_Normal", PROGRAM_INPUT, VERT_ATTRIB_NORMAL}, + {"gl_Color", PROGRAM_INPUT, VERT_ATTRIB_COLOR0}, + {"gl_SecondaryColor", PROGRAM_INPUT, VERT_ATTRIB_COLOR1}, + {"gl_MultiTexCoord0", PROGRAM_INPUT, VERT_ATTRIB_TEX0}, + {"gl_MultiTexCoord1", PROGRAM_INPUT, VERT_ATTRIB_TEX1}, + {"gl_MultiTexCoord2", PROGRAM_INPUT, VERT_ATTRIB_TEX2}, + {"gl_MultiTexCoord3", PROGRAM_INPUT, VERT_ATTRIB_TEX3}, + {"gl_MultiTexCoord4", PROGRAM_INPUT, VERT_ATTRIB_TEX4}, + {"gl_MultiTexCoord5", PROGRAM_INPUT, VERT_ATTRIB_TEX5}, + {"gl_MultiTexCoord6", PROGRAM_INPUT, VERT_ATTRIB_TEX6}, + {"gl_MultiTexCoord7", PROGRAM_INPUT, VERT_ATTRIB_TEX7}, + {"gl_TexCoord", PROGRAM_OUTPUT, VERT_RESULT_TEX0}, /* array */ + {"gl_FogCoord", PROGRAM_INPUT, VERT_RESULT_FOGC}, + /*{"gl_ClipVertex", PROGRAM_OUTPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ + {"gl_FrontColor", PROGRAM_OUTPUT, VERT_RESULT_COL0}, + {"gl_BackColor", PROGRAM_OUTPUT, VERT_RESULT_BFC0}, + {"gl_FrontSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_COL1}, + {"gl_BackSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_BFC1}, + {"gl_FogFragCoord", PROGRAM_OUTPUT, VERT_RESULT_FOGC}, + + /* 130_vs */ + /*{"gl_VertexID", PROGRAM_INPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ + + {"gl_FragData", PROGRAM_OUTPUT, FRAG_RESULT_DATA0}, /* array */ +}; + +ir_to_mesa_instruction * +ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1, + ir_to_mesa_src_reg src2) +{ + ir_to_mesa_instruction *inst = new(ctx) ir_to_mesa_instruction(); + + inst->op = op; + inst->dst_reg = dst; + inst->src_reg[0] = src0; + inst->src_reg[1] = src1; + inst->src_reg[2] = src2; + inst->ir = ir; + + this->instructions.push_tail(inst); + + return inst; +} + + +ir_to_mesa_instruction * +ir_to_mesa_visitor::ir_to_mesa_emit_op2(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1) +{ + return ir_to_mesa_emit_op3(ir, op, dst, src0, src1, ir_to_mesa_undef); +} + +ir_to_mesa_instruction * +ir_to_mesa_visitor::ir_to_mesa_emit_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0) +{ + return ir_to_mesa_emit_op3(ir, op, dst, + src0, ir_to_mesa_undef, ir_to_mesa_undef); +} + +inline ir_to_mesa_dst_reg +ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) +{ + ir_to_mesa_dst_reg dst_reg; + + dst_reg.file = reg.file; + dst_reg.index = reg.index; + dst_reg.writemask = WRITEMASK_XYZW; + + return dst_reg; +} + +/** + * Emits Mesa scalar opcodes to produce unique answers across channels. + * + * Some Mesa opcodes are scalar-only, like ARB_fp/vp. The src X + * channel determines the result across all channels. So to do a vec4 + * of this operation, we want to emit a scalar per source channel used + * to produce dest channels. + */ +void +ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0) +{ + int i, j; + int done_mask = ~dst.writemask; + + /* Mesa RCP is a scalar operation splatting results to all channels, + * like ARB_fp/vp. So emit as many RCPs as necessary to cover our + * dst channels. + */ + for (i = 0; i < 4; i++) { + int this_mask = (1 << i); + ir_to_mesa_instruction *inst; + ir_to_mesa_src_reg src = src0; + + if (done_mask & this_mask) + continue; + + int src_swiz = GET_SWZ(src.swizzle, i); + for (j = i + 1; j < 4; j++) { + if (!(done_mask & (1 << j)) && GET_SWZ(src.swizzle, j) == src_swiz) { + this_mask |= (1 << j); + } + } + src.swizzle = MAKE_SWIZZLE4(src_swiz, src_swiz, + src_swiz, src_swiz); + + inst = ir_to_mesa_emit_op1(ir, op, + dst, + src); + inst->dst_reg.writemask = this_mask; + done_mask |= this_mask; + } +} + +struct ir_to_mesa_src_reg +ir_to_mesa_visitor::src_reg_for_float(float val) +{ + ir_to_mesa_src_reg src_reg; + + /* FINISHME: This will end up being _mesa_add_unnamed_constant, + * which handles sharing values and sharing channels of vec4 + * constants for small values. + */ + /* FINISHME: Do something with the constant values for now. + */ + (void)val; + src_reg.file = PROGRAM_CONSTANT; + src_reg.index = this->next_constant++; + src_reg.swizzle = SWIZZLE_NOOP; + + return src_reg; +} + +/** + * In the initial pass of codegen, we assign temporary numbers to + * intermediate results. (not SSA -- variable assignments will reuse + * storage). Actual register allocation for the Mesa VM occurs in a + * pass over the Mesa IR later. + */ +ir_to_mesa_src_reg +ir_to_mesa_visitor::get_temp(const glsl_type *type) +{ + ir_to_mesa_src_reg src_reg; + int swizzle[4]; + int i; + + assert(!type->is_array()); + + src_reg.file = PROGRAM_TEMPORARY; + src_reg.index = type->matrix_columns; + src_reg.reladdr = false; + + for (i = 0; i < type->vector_elements; i++) + swizzle[i] = i; + for (; i < 4; i++) + swizzle[i] = type->vector_elements - 1; + src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], + swizzle[2], swizzle[3]); + + return src_reg; +} + +static int +type_size(const struct glsl_type *type) +{ + unsigned int i; + int size; + + switch (type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + if (type->is_matrix()) { + return 4; /* FINISHME: Not all matrices are 4x4. */ + } else { + /* Regardless of size of vector, it gets a vec4. This is bad + * packing for things like floats, but otherwise arrays become a + * mess. Hopefully a later pass over the code can pack scalars + * down if appropriate. + */ + return 1; + } + case GLSL_TYPE_ARRAY: + return type_size(type->fields.array) * type->length; + case GLSL_TYPE_STRUCT: + size = 0; + for (i = 0; i < type->length; i++) { + size += type_size(type->fields.structure[i].type); + } + return size; + default: + assert(0); + } +} + +temp_entry * +ir_to_mesa_visitor::find_variable_storage(ir_variable *var) +{ + + temp_entry *entry; + + foreach_iter(exec_list_iterator, iter, this->variable_storage) { + entry = (temp_entry *)iter.get(); + + if (entry->var == var) + return entry; + } + + return NULL; +} + +void +ir_to_mesa_visitor::visit(ir_variable *ir) +{ + (void)ir; +} + +void +ir_to_mesa_visitor::visit(ir_loop *ir) +{ + assert(!ir->from); + assert(!ir->to); + assert(!ir->increment); + assert(!ir->counter); + + ir_to_mesa_emit_op1(NULL, OPCODE_BGNLOOP, + ir_to_mesa_undef_dst, ir_to_mesa_undef); + + visit_exec_list(&ir->body_instructions, this); + + ir_to_mesa_emit_op1(NULL, OPCODE_ENDLOOP, + ir_to_mesa_undef_dst, ir_to_mesa_undef); +} + +void +ir_to_mesa_visitor::visit(ir_loop_jump *ir) +{ + switch (ir->mode) { + case ir_loop_jump::jump_break: + ir_to_mesa_emit_op1(NULL, OPCODE_BRK, + ir_to_mesa_undef_dst, ir_to_mesa_undef); + break; + case ir_loop_jump::jump_continue: + ir_to_mesa_emit_op1(NULL, OPCODE_CONT, + ir_to_mesa_undef_dst, ir_to_mesa_undef); + break; + } +} + + +void +ir_to_mesa_visitor::visit(ir_function_signature *ir) +{ + assert(0); + (void)ir; +} + +void +ir_to_mesa_visitor::visit(ir_function *ir) +{ + /* Ignore function bodies other than main() -- we shouldn't see calls to + * them since they should all be inlined before we get to ir_to_mesa. + */ + if (strcmp(ir->name, "main") == 0) { + const ir_function_signature *sig; + exec_list empty; + + sig = ir->matching_signature(&empty); + + assert(sig); + + foreach_iter(exec_list_iterator, iter, sig->body) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + ir->accept(this); + } + } +} + +void +ir_to_mesa_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + struct ir_to_mesa_src_reg op[2]; + struct ir_to_mesa_src_reg result_src; + struct ir_to_mesa_dst_reg result_dst; + const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); + const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); + const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + this->result.file = PROGRAM_UNDEFINED; + ir->operands[operand]->accept(this); + if (this->result.file == PROGRAM_UNDEFINED) { + ir_print_visitor v; + printf("Failed to get tree for expression operand:\n"); + ir->operands[operand]->accept(&v); + exit(1); + } + op[operand] = this->result; + + /* Only expression implemented for matrices yet */ + assert(!ir->operands[operand]->type->is_matrix() || + ir->operation == ir_binop_mul); + } + + this->result.file = PROGRAM_UNDEFINED; + + /* Storage for our result. Ideally for an assignment we'd be using + * the actual storage for the result here, instead. + */ + result_src = get_temp(ir->type); + /* convenience for the emit functions below. */ + result_dst = ir_to_mesa_dst_reg_from_src(result_src); + /* Limit writes to the channels that will be used by result_src later. + * This does limit this temp's use as a temporary for multi-instruction + * sequences. + */ + result_dst.writemask = (1 << ir->type->vector_elements) - 1; + + switch (ir->operation) { + case ir_unop_logic_not: + ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, + op[0], src_reg_for_float(0.0)); + break; + case ir_unop_neg: + op[0].negate = ~op[0].negate; + result_src = op[0]; + break; + case ir_unop_exp: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_EXP, result_dst, op[0]); + break; + case ir_unop_exp2: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_EX2, result_dst, op[0]); + break; + case ir_unop_log: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_LOG, result_dst, op[0]); + break; + case ir_unop_log2: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_LG2, result_dst, op[0]); + break; + case ir_unop_sin: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_SIN, result_dst, op[0]); + break; + case ir_unop_cos: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_COS, result_dst, op[0]); + break; + case ir_binop_add: + ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]); + break; + case ir_binop_sub: + ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); + break; + case ir_binop_mul: + if (ir->operands[0]->type->is_matrix() && + !ir->operands[1]->type->is_matrix()) { + if (ir->operands[0]->type->is_scalar()) { + ir_to_mesa_dst_reg dst_column = result_dst; + ir_to_mesa_src_reg src_column = op[0]; + for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + dst_column, src_column, op[1]); + dst_column.index++; + src_column.index++; + } + } else { + ir_to_mesa_dst_reg dst_chan = result_dst; + ir_to_mesa_src_reg src_column = op[0]; + ir_to_mesa_src_reg src_chan = op[1]; + for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { + dst_chan.writemask = (1 << i); + src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + dst_chan, src_column, src_chan); + src_column.index++; + } + } + } else { + assert(!ir->operands[0]->type->is_matrix()); + assert(!ir->operands[1]->type->is_matrix()); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], op[1]); + } + break; + case ir_binop_div: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], result_src); + break; + + case ir_binop_less: + ir_to_mesa_emit_op2(ir, OPCODE_SLT, result_dst, op[0], op[1]); + break; + case ir_binop_greater: + ir_to_mesa_emit_op2(ir, OPCODE_SGT, result_dst, op[0], op[1]); + break; + case ir_binop_lequal: + ir_to_mesa_emit_op2(ir, OPCODE_SLE, result_dst, op[0], op[1]); + break; + case ir_binop_gequal: + ir_to_mesa_emit_op2(ir, OPCODE_SGE, result_dst, op[0], op[1]); + break; + case ir_binop_equal: + ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, op[0], op[1]); + break; + case ir_binop_logic_xor: + case ir_binop_nequal: + ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, op[0], op[1]); + break; + + case ir_binop_logic_or: + /* This could be a saturated add and skip the SNE. */ + ir_to_mesa_emit_op2(ir, OPCODE_ADD, + result_dst, + op[0], op[1]); + + ir_to_mesa_emit_op2(ir, OPCODE_SNE, + result_dst, + result_src, src_reg_for_float(0.0)); + break; + + case ir_binop_logic_and: + /* the bool args are stored as float 0.0 or 1.0, so "mul" gives us "and". */ + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + result_dst, + op[0], op[1]); + break; + + case ir_binop_dot: + if (ir->operands[0]->type == vec4_type) { + assert(ir->operands[1]->type == vec4_type); + ir_to_mesa_emit_op2(ir, OPCODE_DP4, + result_dst, + op[0], op[1]); + } else if (ir->operands[0]->type == vec3_type) { + assert(ir->operands[1]->type == vec3_type); + ir_to_mesa_emit_op2(ir, OPCODE_DP3, + result_dst, + op[0], op[1]); + } else if (ir->operands[0]->type == vec2_type) { + assert(ir->operands[1]->type == vec2_type); + ir_to_mesa_emit_op2(ir, OPCODE_DP2, + result_dst, + op[0], op[1]); + } + break; + case ir_unop_sqrt: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); + ir_to_mesa_emit_op1(ir, OPCODE_RCP, result_dst, result_src); + break; + case ir_unop_rsq: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); + break; + case ir_unop_i2f: + /* Mesa IR lacks types, ints are stored as truncated floats. */ + result_src = op[0]; + break; + case ir_unop_f2i: + ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); + break; + case ir_unop_f2b: + ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, + result_src, src_reg_for_float(0.0)); + break; + case ir_unop_trunc: + ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); + break; + case ir_unop_ceil: + op[0].negate = ~op[0].negate; + ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); + result_src.negate = ~result_src.negate; + break; + case ir_unop_floor: + ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); + break; + case ir_binop_min: + ir_to_mesa_emit_op2(ir, OPCODE_MIN, result_dst, op[0], op[1]); + break; + case ir_binop_max: + ir_to_mesa_emit_op2(ir, OPCODE_MAX, result_dst, op[0], op[1]); + break; + default: + ir_print_visitor v; + printf("Failed to get tree for expression:\n"); + ir->accept(&v); + exit(1); + break; + } + + this->result = result_src; +} + + +void +ir_to_mesa_visitor::visit(ir_swizzle *ir) +{ + ir_to_mesa_src_reg src_reg; + int i; + int swizzle[4]; + + /* Note that this is only swizzles in expressions, not those on the left + * hand side of an assignment, which do write masking. See ir_assignment + * for that. + */ + + ir->val->accept(this); + src_reg = this->result; + assert(src_reg.file != PROGRAM_UNDEFINED); + + for (i = 0; i < 4; i++) { + if (i < ir->type->vector_elements) { + switch (i) { + case 0: + swizzle[i] = ir->mask.x; + break; + case 1: + swizzle[i] = ir->mask.y; + break; + case 2: + swizzle[i] = ir->mask.z; + break; + case 3: + swizzle[i] = ir->mask.w; + break; + } + } else { + /* If the type is smaller than a vec4, replicate the last + * channel out. + */ + swizzle[i] = ir->type->vector_elements - 1; + } + } + + src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], + swizzle[1], + swizzle[2], + swizzle[3]); + + this->result = src_reg; +} + +void +ir_to_mesa_visitor::visit(ir_dereference_variable *ir) +{ + ir_to_mesa_src_reg src_reg; + temp_entry *entry = find_variable_storage(ir->var); + unsigned int i; + bool var_in; + + if (!entry) { + switch (ir->var->mode) { + case ir_var_uniform: + entry = new(ctx) temp_entry(ir->var, PROGRAM_UNIFORM, + this->next_uniform); + this->variable_storage.push_tail(entry); + + this->next_uniform += type_size(ir->var->type); + break; + case ir_var_in: + case ir_var_out: + case ir_var_inout: + var_in = (ir->var->mode == ir_var_in || + ir->var->mode == ir_var_inout); + + for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { + bool in = builtin_var_to_mesa_reg[i].file == PROGRAM_INPUT; + + if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0 && + !(var_in ^ in)) + break; + } + if (i == ARRAY_SIZE(builtin_var_to_mesa_reg)) { + printf("Failed to find builtin for %s variable %s\n", + var_in ? "in" : "out", + ir->var->name); + abort(); + } + entry = new(ctx) temp_entry(ir->var, + builtin_var_to_mesa_reg[i].file, + builtin_var_to_mesa_reg[i].index); + break; + case ir_var_auto: + entry = new(ctx) temp_entry(ir->var, PROGRAM_TEMPORARY, + this->next_temp); + this->variable_storage.push_tail(entry); + + next_temp += type_size(ir->var->type); + break; + } + + if (!entry) { + printf("Failed to make storage for %s\n", ir->var->name); + exit(1); + } + } + + src_reg.file = entry->file; + src_reg.index = entry->index; + /* If the type is smaller than a vec4, replicate the last channel out. */ + src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); + src_reg.reladdr = false; + src_reg.negate = 0; + + this->result = src_reg; +} + +void +ir_to_mesa_visitor::visit(ir_dereference_array *ir) +{ + ir_constant *index; + ir_to_mesa_src_reg src_reg; + + index = ir->array_index->constant_expression_value(); + + /* By the time we make it to this stage, matrices should be broken down + * to vectors. + */ + assert(!ir->type->is_matrix()); + + ir->array->accept(this); + src_reg = this->result; + + if (src_reg.file == PROGRAM_INPUT || + src_reg.file == PROGRAM_OUTPUT) { + assert(index); /* FINISHME: Handle variable indexing of builtins. */ + + src_reg.index += index->value.i[0]; + } else { + if (index) { + src_reg.index += index->value.i[0]; + } else { + ir_to_mesa_src_reg array_base = this->result; + /* Variable index array dereference. It eats the "vec4" of the + * base of the array and an index that offsets the Mesa register + * index. + */ + ir->array_index->accept(this); + + /* FINISHME: This doesn't work when we're trying to do the LHS + * of an assignment. + */ + src_reg.reladdr = true; + ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, + this->result); + + this->result = get_temp(ir->type); + ir_to_mesa_emit_op1(ir, OPCODE_MOV, + ir_to_mesa_dst_reg_from_src(this->result), + src_reg); + } + } + + /* If the type is smaller than a vec4, replicate the last channel out. */ + src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); + + this->result = src_reg; +} + +void +ir_to_mesa_visitor::visit(ir_dereference_record *ir) +{ + unsigned int i; + const glsl_type *struct_type = ir->record->type; + int offset = 0; + + ir->record->accept(this); + + for (i = 0; i < struct_type->length; i++) { + if (strcmp(struct_type->fields.structure[i].name, ir->field) == 0) + break; + offset += type_size(struct_type->fields.structure[i].type); + } + this->result.index += offset; +} + +/** + * We want to be careful in assignment setup to hit the actual storage + * instead of potentially using a temporary like we might with the + * ir_dereference handler. + * + * Thanks to ir_swizzle_swizzle, and ir_vec_index_to_swizzle, we + * should only see potentially one variable array index of a vector, + * and one swizzle, before getting to actual vec4 storage. So handle + * those, then go use ir_dereference to handle the rest. + */ +static struct ir_to_mesa_dst_reg +get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) +{ + struct ir_to_mesa_dst_reg dst_reg; + ir_dereference *deref; + ir_swizzle *swiz; + + /* Use the rvalue deref handler for the most part. We'll ignore + * swizzles in it and write swizzles using writemask, though. + */ + ir->accept(v); + dst_reg = ir_to_mesa_dst_reg_from_src(v->result); + + if ((deref = ir->as_dereference())) { + ir_dereference_array *deref_array = ir->as_dereference_array(); + assert(!deref_array || deref_array->array->type->is_array()); + + ir->accept(v); + } else if ((swiz = ir->as_swizzle())) { + dst_reg.writemask = 0; + if (swiz->mask.num_components >= 1) + dst_reg.writemask |= (1 << swiz->mask.x); + if (swiz->mask.num_components >= 2) + dst_reg.writemask |= (1 << swiz->mask.y); + if (swiz->mask.num_components >= 3) + dst_reg.writemask |= (1 << swiz->mask.z); + if (swiz->mask.num_components >= 4) + dst_reg.writemask |= (1 << swiz->mask.w); + } + + return dst_reg; +} + +void +ir_to_mesa_visitor::visit(ir_assignment *ir) +{ + struct ir_to_mesa_dst_reg l; + struct ir_to_mesa_src_reg r; + + assert(!ir->lhs->type->is_matrix()); + assert(!ir->lhs->type->is_array()); + assert(ir->lhs->type->base_type != GLSL_TYPE_STRUCT); + + l = get_assignment_lhs(ir->lhs, this); + + ir->rhs->accept(this); + r = this->result; + assert(l.file != PROGRAM_UNDEFINED); + assert(r.file != PROGRAM_UNDEFINED); + + if (ir->condition) { + ir_constant *condition_constant; + + condition_constant = ir->condition->constant_expression_value(); + + assert(condition_constant && condition_constant->value.b[0]); + } + + ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); +} + + +void +ir_to_mesa_visitor::visit(ir_constant *ir) +{ + ir_to_mesa_src_reg src_reg; + + assert(ir->type->base_type == GLSL_TYPE_FLOAT || + ir->type->base_type == GLSL_TYPE_UINT || + ir->type->base_type == GLSL_TYPE_INT || + ir->type->base_type == GLSL_TYPE_BOOL); + + /* FINISHME: This will end up being _mesa_add_unnamed_constant, + * which handles sharing values and sharing channels of vec4 + * constants for small values. + */ + /* FINISHME: Do something with the constant values for now. + */ + src_reg.file = PROGRAM_CONSTANT; + src_reg.index = this->next_constant; + src_reg.swizzle = SWIZZLE_NOOP; + src_reg.reladdr = false; + src_reg.negate = 0; + + this->next_constant += type_size(ir->type); + + this->result = src_reg; +} + + +void +ir_to_mesa_visitor::visit(ir_call *ir) +{ + printf("Can't support call to %s\n", ir->callee_name()); + exit(1); +} + + +void +ir_to_mesa_visitor::visit(ir_texture *ir) +{ + assert(0); + + ir->coordinate->accept(this); +} + +void +ir_to_mesa_visitor::visit(ir_return *ir) +{ + assert(0); + + ir->get_value()->accept(this); +} + + +void +ir_to_mesa_visitor::visit(ir_if *ir) +{ + ir_to_mesa_instruction *if_inst, *else_inst = NULL; + + ir->condition->accept(this); + assert(this->result.file != PROGRAM_UNDEFINED); + + if_inst = ir_to_mesa_emit_op1(ir->condition, + OPCODE_IF, ir_to_mesa_undef_dst, + this->result); + + this->instructions.push_tail(if_inst); + + visit_exec_list(&ir->then_instructions, this); + + if (!ir->else_instructions.is_empty()) { + else_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ELSE, + ir_to_mesa_undef_dst, + ir_to_mesa_undef); + visit_exec_list(&ir->then_instructions, this); + } + + if_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ENDIF, + ir_to_mesa_undef_dst, ir_to_mesa_undef); +} + +ir_to_mesa_visitor::ir_to_mesa_visitor() +{ + result.file = PROGRAM_UNDEFINED; + next_temp = 1; + next_constant = 0; + next_uniform = 0; +} + +static struct prog_src_register +mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) +{ + struct prog_src_register mesa_reg; + + mesa_reg.File = reg.file; + assert(reg.index < (1 << INST_INDEX_BITS) - 1); + mesa_reg.Index = reg.index; + mesa_reg.Swizzle = reg.swizzle; + mesa_reg.RelAddr = reg.reladdr; + + return mesa_reg; +} + +static void +set_branchtargets(struct prog_instruction *mesa_instructions, + int num_instructions) +{ + int if_count = 0, loop_count; + int *if_stack, *loop_stack; + int if_stack_pos = 0, loop_stack_pos = 0; + int i, j; + + for (i = 0; i < num_instructions; i++) { + switch (mesa_instructions[i].Opcode) { + case OPCODE_IF: + if_count++; + break; + case OPCODE_BGNLOOP: + loop_count++; + break; + case OPCODE_BRK: + case OPCODE_CONT: + mesa_instructions[i].BranchTarget = -1; + break; + default: + break; + } + } + + if_stack = (int *)calloc(if_count, sizeof(*if_stack)); + loop_stack = (int *)calloc(loop_count, sizeof(*loop_stack)); + + for (i = 0; i < num_instructions; i++) { + switch (mesa_instructions[i].Opcode) { + case OPCODE_IF: + if_stack[if_stack_pos] = i; + if_stack_pos++; + break; + case OPCODE_ELSE: + mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; + if_stack[if_stack_pos - 1] = i; + break; + case OPCODE_ENDIF: + mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; + if_stack_pos--; + break; + case OPCODE_BGNLOOP: + loop_stack[loop_stack_pos] = i; + loop_stack_pos++; + break; + case OPCODE_ENDLOOP: + loop_stack_pos--; + /* Rewrite any breaks/conts at this nesting level (haven't + * already had a BranchTarget assigned) to point to the end + * of the loop. + */ + for (j = loop_stack[loop_stack_pos]; j < i; j++) { + if (mesa_instructions[j].Opcode == OPCODE_BRK || + mesa_instructions[j].Opcode == OPCODE_CONT) { + if (mesa_instructions[j].BranchTarget == -1) { + mesa_instructions[j].BranchTarget = i; + } + } + } + /* The loop ends point at each other. */ + mesa_instructions[i].BranchTarget = loop_stack[loop_stack_pos]; + mesa_instructions[loop_stack[loop_stack_pos]].BranchTarget = i; + default: + break; + } + } + + free(if_stack); +} + +static void +print_program(struct prog_instruction *mesa_instructions, + ir_instruction **mesa_instruction_annotation, + int num_instructions) +{ + ir_instruction *last_ir = NULL; + int i; + + for (i = 0; i < num_instructions; i++) { + struct prog_instruction *mesa_inst = mesa_instructions + i; + ir_instruction *ir = mesa_instruction_annotation[i]; + + if (last_ir != ir && ir) { + ir_print_visitor print; + ir->accept(&print); + printf("\n"); + last_ir = ir; + } + + _mesa_print_instruction(mesa_inst); + } +} + +void +do_ir_to_mesa(exec_list *instructions) +{ + ir_to_mesa_visitor v; + struct prog_instruction *mesa_instructions, *mesa_inst; + ir_instruction **mesa_instruction_annotation; + int i; + + v.ctx = talloc_new(NULL); + visit_exec_list(instructions, &v); + + int num_instructions = 0; + foreach_iter(exec_list_iterator, iter, v.instructions) { + num_instructions++; + } + + mesa_instructions = + (struct prog_instruction *)calloc(num_instructions, + sizeof(*mesa_instructions)); + mesa_instruction_annotation = + (ir_instruction **)calloc(num_instructions, + sizeof(*mesa_instruction_annotation)); + + mesa_inst = mesa_instructions; + i = 0; + foreach_iter(exec_list_iterator, iter, v.instructions) { + ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); + + mesa_inst->Opcode = inst->op; + mesa_inst->DstReg.File = inst->dst_reg.file; + mesa_inst->DstReg.Index = inst->dst_reg.index; + mesa_inst->DstReg.CondMask = COND_TR; + mesa_inst->DstReg.WriteMask = inst->dst_reg.writemask; + mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); + mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); + mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); + mesa_instruction_annotation[i] = inst->ir; + + mesa_inst++; + i++; + } + + set_branchtargets(mesa_instructions, num_instructions); + print_program(mesa_instructions, mesa_instruction_annotation, num_instructions); + + free(mesa_instruction_annotation); + talloc_free(v.ctx); +} diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp new file mode 100644 index 00000000000..507e88993f2 --- /dev/null +++ b/src/glsl/ir_validate.cpp @@ -0,0 +1,104 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_validate.cpp + * + * Attempts to verify that various invariants of the IR tree are true. + * + * In particular, at the moment it makes sure that no single + * ir_instruction node except for ir_variable appears multiple times + * in the ir tree. ir_variable does appear multiple times: Once as a + * declaration in an exec_list, and multiple times as the endpoint of + * a dereference chain. + */ + +#include +#include "ir.h" +#include "ir_hierarchical_visitor.h" +#include "hash_table.h" + +static unsigned int hash_func(const void *key) +{ + return (unsigned int)(uintptr_t)key; +} + +static int hash_compare_func(const void *key1, const void *key2) +{ + return key1 == key2 ? 0 : 1; +} + + +class ir_validate : public ir_hierarchical_visitor { +public: + ir_validate() + { + this->ht = hash_table_ctor(0, hash_func, hash_compare_func); + + this->callback = ir_validate::validate_ir; + this->data = ht; + } + + ~ir_validate() + { + hash_table_dtor(this->ht); + } + + virtual ir_visitor_status visit(ir_variable *v); + + static void validate_ir(ir_instruction *ir, void *data); + + struct hash_table *ht; +}; + +ir_visitor_status +ir_validate::visit(ir_variable *ir) +{ + /* An ir_variable is the one thing that can (and will) appear multiple times + * in an IR tree. + */ + (void) ir; + return visit_continue; +} + +void +ir_validate::validate_ir(ir_instruction *ir, void *data) +{ + struct hash_table *ht = (struct hash_table *) data; + + if (hash_table_find(ht, ir)) { + printf("Instruction node present twice in ir tree:\n"); + ir->print(); + printf("\n"); + abort(); + } + hash_table_insert(ht, ir, ir); +} + +void +validate_ir_tree(exec_list *instructions) +{ + ir_validate v; + + v.run(instructions); +} diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp new file mode 100644 index 00000000000..15a4a92f628 --- /dev/null +++ b/src/glsl/ir_variable.cpp @@ -0,0 +1,345 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" +#include "glsl_parser_extras.h" +#include "glsl_symbol_table.h" +#include "builtin_variables.h" + +#ifndef Elements +#define Elements(x) (sizeof(x)/sizeof(*(x))) +#endif + +static ir_variable * +add_variable(const char *name, enum ir_variable_mode mode, int slot, + const glsl_type *type, exec_list *instructions, + glsl_symbol_table *symtab) +{ + ir_variable *var = new(symtab) ir_variable(type, name); + + var->mode = mode; + switch (var->mode) { + case ir_var_in: + var->shader_in = true; + var->read_only = true; + break; + case ir_var_inout: + var->shader_in = true; + var->shader_out = true; + break; + case ir_var_out: + var->shader_out = true; + break; + case ir_var_uniform: + var->shader_in = true; + var->read_only = true; + break; + default: + assert(0); + break; + } + + var->location = slot; + + /* Once the variable is created an initialized, add it to the symbol table + * and add the declaration to the IR stream. + */ + instructions->push_tail(var); + + symtab->add_variable(var->name, var); + return var; +} + + +static void +add_builtin_variable(const builtin_variable *proto, exec_list *instructions, + glsl_symbol_table *symtab) +{ + /* Create a new variable declaration from the description supplied by + * the caller. + */ + const glsl_type *const type = symtab->get_type(proto->type); + + assert(type != NULL); + + add_variable(proto->name, proto->mode, proto->slot, type, instructions, + symtab); +} + + +static void +generate_110_uniforms(exec_list *instructions, + glsl_symbol_table *symtab) +{ + for (unsigned i = 0 + ; i < Elements(builtin_110_deprecated_uniforms) + ; i++) { + add_builtin_variable(& builtin_110_deprecated_uniforms[i], + instructions, symtab); + } + + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports + * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 + * FINISHME: for now. + */ + const glsl_type *const mat4_array_type = + glsl_type::get_array_instance(symtab, glsl_type::mat4_type, 4); + + add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type, + instructions, symtab); + + /* FINISHME: Add support for gl_DepthRangeParameters */ + /* FINISHME: Add support for gl_ClipPlane[] */ + /* FINISHME: Add support for gl_PointParameters */ + + /* FINISHME: Add support for gl_MaterialParameters + * FINISHME: (glFrontMaterial, glBackMaterial) + */ + + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_TEXTURE_LIGHTS. GL_MAX_TEXTURE_LIGHTS must be + * FINISHME: at least 8, so hard-code 8 for now. + */ + const glsl_type *const light_source_array_type = + glsl_type::get_array_instance(symtab, + symtab->get_type("gl_LightSourceParameters"), 8); + + add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type, + instructions, symtab); + + /* FINISHME: Add support for gl_LightModel */ + /* FINISHME: Add support for gl_FrontLightProduct[], gl_BackLightProduct[] */ + /* FINISHME: Add support for gl_TextureEnvColor[] */ + /* FINISHME: Add support for gl_ObjectPlane*[], gl_EyePlane*[] */ + /* FINISHME: Add support for gl_Fog */ +} + +static void +generate_110_vs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { + add_builtin_variable(& builtin_core_vs_variables[i], + instructions, symtab); + } + + for (unsigned i = 0 + ; i < Elements(builtin_110_deprecated_vs_variables) + ; i++) { + add_builtin_variable(& builtin_110_deprecated_vs_variables[i], + instructions, symtab); + } + generate_110_uniforms(instructions, symtab); + + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports + * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 + * FINISHME: for now. + */ + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 4); + + add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type, + instructions, symtab); +} + + +static void +generate_120_vs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + /* GLSL version 1.20 did not add any built-in variables in the vertex + * shader. + */ + generate_110_vs_variables(instructions, symtab); +} + + +static void +generate_130_vs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + void *ctx = symtab; + generate_120_vs_variables(instructions, symtab); + + for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { + add_builtin_variable(& builtin_130_vs_variables[i], + instructions, symtab); + } + + /* FINISHME: The size of this array is implementation dependent based on + * FINISHME: the value of GL_MAX_CLIP_DISTANCES. + */ + const glsl_type *const clip_distance_array_type = + glsl_type::get_array_instance(ctx, glsl_type::float_type, 8); + + /* FINISHME: gl_ClipDistance needs a real location assigned. */ + add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type, + instructions, symtab); + +} + + +static void +initialize_vs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + + switch (state->language_version) { + case 110: + generate_110_vs_variables(instructions, state->symbols); + break; + case 120: + generate_120_vs_variables(instructions, state->symbols); + break; + case 130: + generate_130_vs_variables(instructions, state->symbols); + break; + } +} + +static void +generate_110_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { + add_builtin_variable(& builtin_core_fs_variables[i], + instructions, symtab); + } + + for (unsigned i = 0 + ; i < Elements(builtin_110_deprecated_fs_variables) + ; i++) { + add_builtin_variable(& builtin_110_deprecated_fs_variables[i], + instructions, symtab); + } + generate_110_uniforms(instructions, symtab); + + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports + * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 + * FINISHME: for now. + */ + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 4); + + add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type, + instructions, symtab); +} + + +static void +generate_ARB_draw_buffers_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab, bool warn) +{ + /* FINISHME: The size of this array is implementation dependent based on the + * FINISHME: value of GL_MAX_DRAW_BUFFERS. GL_MAX_DRAW_BUFFERS must be + * FINISHME: at least 1, so hard-code 1 for now. + */ + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 1); + + ir_variable *const fd = + add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0, + vec4_array_type, instructions, symtab); + + if (warn) + fd->warn_extension = "GL_ARB_draw_buffers"; +} + + +static void +generate_120_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + generate_110_fs_variables(instructions, symtab); + generate_ARB_draw_buffers_fs_variables(instructions, symtab, false); +} + +static void +generate_130_fs_variables(exec_list *instructions, + glsl_symbol_table *symtab) +{ + void *ctx = symtab; + generate_120_fs_variables(instructions, symtab); + + /* FINISHME: The size of this array is implementation dependent based on + * FINISHME: the value of GL_MAX_CLIP_DISTANCES. + */ + const glsl_type *const clip_distance_array_type = + glsl_type::get_array_instance(ctx, glsl_type::float_type, 8); + + /* FINISHME: gl_ClipDistance needs a real location assigned. */ + add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type, + instructions, symtab); +} + +static void +initialize_fs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + + switch (state->language_version) { + case 110: + generate_110_fs_variables(instructions, state->symbols); + break; + case 120: + generate_120_fs_variables(instructions, state->symbols); + break; + case 130: + generate_130_fs_variables(instructions, state->symbols); + break; + } + + + /* Since GL_ARB_draw_buffers is included in GLSL 1.20 and later, we + * can basically ignore any extension settings for it. + */ + if (state->language_version < 120) { + if (state->ARB_draw_buffers_enable) { + generate_ARB_draw_buffers_fs_variables(instructions, state->symbols, + state->ARB_draw_buffers_warn); + } + } +} + +void +_mesa_glsl_initialize_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + switch (state->target) { + case vertex_shader: + initialize_vs_variables(instructions, state); + break; + case geometry_shader: + break; + case fragment_shader: + initialize_fs_variables(instructions, state); + break; + case ir_shader: + fprintf(stderr, "ir reader has no builtin variables"); + exit(1); + break; + } +} diff --git a/src/glsl/ir_vec_index_to_swizzle.cpp b/src/glsl/ir_vec_index_to_swizzle.cpp new file mode 100644 index 00000000000..abeb43cd68e --- /dev/null +++ b/src/glsl/ir_vec_index_to_swizzle.cpp @@ -0,0 +1,158 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_vec_index_to_swizzle.cpp + * + * Turns constant indexing into vector types to swizzles. This will + * let other swizzle-aware optimization passes catch these constructs, + * and codegen backends not have to worry about this case. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +class ir_vec_index_to_swizzle_visitor : public ir_hierarchical_visitor { +public: + ir_vec_index_to_swizzle_visitor() + { + progress = false; + } + + ir_rvalue *convert_vec_index_to_swizzle(ir_rvalue *val); + + virtual ir_visitor_status visit_enter(ir_expression *); + virtual ir_visitor_status visit_enter(ir_swizzle *); + virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_call *); + virtual ir_visitor_status visit_enter(ir_if *); + + bool progress; +}; + +ir_rvalue * +ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) +{ + ir_dereference_array *deref = ir->as_dereference_array(); + ir_constant *ir_constant; + + if (!deref) + return ir; + + if (deref->array->type->is_matrix() || deref->array->type->is_array()) + return ir; + + assert(deref->array_index->type->base_type == GLSL_TYPE_INT); + ir_constant = deref->array_index->constant_expression_value(); + if (!ir_constant) + return ir; + + void *ctx = talloc_parent(ir); + this->progress = true; + return new(ctx) ir_swizzle(deref->array, + ir_constant->value.i[0], 0, 0, 0, 1); +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_expression *ir) +{ + unsigned int i; + + for (i = 0; i < ir->get_num_operands(); i++) { + ir->operands[i] = convert_vec_index_to_swizzle(ir->operands[i]); + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_swizzle *ir) +{ + /* Can't be hit from normal GLSL, since you can't swizzle a scalar (which + * the result of indexing a vector is. But maybe at some point we'll end up + * using swizzling of scalars for vector construction. + */ + ir->val = convert_vec_index_to_swizzle(ir->val); + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_assignment *ir) +{ + ir->lhs = convert_vec_index_to_swizzle(ir->lhs); + ir->rhs = convert_vec_index_to_swizzle(ir->rhs); + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = convert_vec_index_to_swizzle(param); + + if (new_param != param) { + param->insert_before(new_param); + param->remove(); + } + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_return *ir) +{ + if (ir->value) { + ir->value = convert_vec_index_to_swizzle(ir->value); + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_if *ir) +{ + ir->condition = convert_vec_index_to_swizzle(ir->condition); + + return visit_continue; +} + +bool +do_vec_index_to_swizzle(exec_list *instructions) +{ + ir_vec_index_to_swizzle_visitor v; + + v.run(instructions); + + return false; +} diff --git a/src/glsl/ir_visitor.h b/src/glsl/ir_visitor.h new file mode 100644 index 00000000000..a6f9d2b7ee3 --- /dev/null +++ b/src/glsl/ir_visitor.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_VISITOR_H +#define IR_VISITOR_H + +/** + * Abstract base class of visitors of IR instruction trees + */ +class ir_visitor { +public: + virtual ~ir_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(class ir_variable *) = 0; + virtual void visit(class ir_function_signature *) = 0; + virtual void visit(class ir_function *) = 0; + virtual void visit(class ir_expression *) = 0; + virtual void visit(class ir_texture *) = 0; + virtual void visit(class ir_swizzle *) = 0; + virtual void visit(class ir_dereference_variable *) = 0; + virtual void visit(class ir_dereference_array *) = 0; + virtual void visit(class ir_dereference_record *) = 0; + virtual void visit(class ir_assignment *) = 0; + virtual void visit(class ir_constant *) = 0; + virtual void visit(class ir_call *) = 0; + virtual void visit(class ir_return *) = 0; + virtual void visit(class ir_if *) = 0; + virtual void visit(class ir_loop *) = 0; + virtual void visit(class ir_loop_jump *) = 0; + /*@}*/ +}; + +#endif /* IR_VISITOR_H */ diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp new file mode 100644 index 00000000000..ba382fe8816 --- /dev/null +++ b/src/glsl/linker.cpp @@ -0,0 +1,871 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file linker.cpp + * GLSL linker implementation + * + * Given a set of shaders that are to be linked to generate a final program, + * there are three distinct stages. + * + * In the first stage shaders are partitioned into groups based on the shader + * type. All shaders of a particular type (e.g., vertex shaders) are linked + * together. + * + * - Undefined references in each shader are resolve to definitions in + * another shader. + * - Types and qualifiers of uniforms, outputs, and global variables defined + * in multiple shaders with the same name are verified to be the same. + * - Initializers for uniforms and global variables defined + * in multiple shaders with the same name are verified to be the same. + * + * The result, in the terminology of the GLSL spec, is a set of shader + * executables for each processing unit. + * + * After the first stage is complete, a series of semantic checks are performed + * on each of the shader executables. + * + * - Each shader executable must define a \c main function. + * - Each vertex shader executable must write to \c gl_Position. + * - Each fragment shader executable must write to either \c gl_FragData or + * \c gl_FragColor. + * + * In the final stage individual shader executables are linked to create a + * complete exectuable. + * + * - Types of uniforms defined in multiple shader stages with the same name + * are verified to be the same. + * - Initializers for uniforms defined in multiple shader stages with the + * same name are verified to be the same. + * - Types and qualifiers of outputs defined in one stage are verified to + * be the same as the types and qualifiers of inputs defined with the same + * name in a later stage. + * + * \author Ian Romanick + */ +#include +#include +#include + +extern "C" { +#include +} + +#include "main/mtypes.h" +#include "glsl_symbol_table.h" +#include "glsl_parser_extras.h" +#include "ir.h" +#include "ir_optimization.h" +#include "program.h" +#include "hash_table.h" + +/** + * Visitor that determines whether or not a variable is ever written. + */ +class find_assignment_visitor : public ir_hierarchical_visitor { +public: + find_assignment_visitor(const char *name) + : name(name), found(false) + { + /* empty */ + } + + virtual ir_visitor_status visit_enter(ir_assignment *ir) + { + ir_variable *const var = ir->lhs->variable_referenced(); + + if (strcmp(name, var->name) == 0) { + found = true; + return visit_stop; + } + + return visit_continue_with_parent; + } + + bool variable_found() + { + return found; + } + +private: + const char *name; /**< Find writes to a variable with this name. */ + bool found; /**< Was a write to the variable found? */ +}; + + +void +linker_error_printf(glsl_program *prog, const char *fmt, ...) +{ + va_list ap; + + prog->InfoLog = talloc_strdup_append(prog->InfoLog, "error: "); + va_start(ap, fmt); + prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, ap); + va_end(ap); +} + + +void +invalidate_variable_locations(glsl_shader *sh, enum ir_variable_mode mode, + int generic_base) +{ + foreach_list(node, &sh->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != (unsigned) mode)) + continue; + + /* Only assign locations for generic attributes / varyings / etc. + */ + if (var->location >= generic_base) + var->location = -1; + } +} + + +/** + * Determine the number of attribute slots required for a particular type + * + * This code is here because it implements the language rules of a specific + * GLSL version. Since it's a property of the language and not a property of + * types in general, it doesn't really belong in glsl_type. + */ +unsigned +count_attribute_slots(const glsl_type *t) +{ + /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: + * + * "A scalar input counts the same amount against this limit as a vec4, + * so applications may want to consider packing groups of four + * unrelated float inputs together into a vector to better utilize the + * capabilities of the underlying hardware. A matrix input will use up + * multiple locations. The number of locations used will equal the + * number of columns in the matrix." + * + * The spec does not explicitly say how arrays are counted. However, it + * should be safe to assume the total number of slots consumed by an array + * is the number of entries in the array multiplied by the number of slots + * consumed by a single element of the array. + */ + + if (t->is_array()) + return t->array_size() * count_attribute_slots(t->element_type()); + + if (t->is_matrix()) + return t->matrix_columns; + + return 1; +} + + +/** + * Verify that a vertex shader executable meets all semantic requirements + * + * \param shader Vertex shader executable to be verified + */ +bool +validate_vertex_shader_executable(struct glsl_program *prog, + struct glsl_shader *shader) +{ + if (shader == NULL) + return true; + + if (!shader->symbols->get_function("main")) { + linker_error_printf(prog, "vertex shader lacks `main'\n"); + return false; + } + + find_assignment_visitor find("gl_Position"); + find.run(&shader->ir); + if (!find.variable_found()) { + linker_error_printf(prog, + "vertex shader does not write to `gl_Position'\n"); + return false; + } + + return true; +} + + +/** + * Verify that a fragment shader executable meets all semantic requirements + * + * \param shader Fragment shader executable to be verified + */ +bool +validate_fragment_shader_executable(struct glsl_program *prog, + struct glsl_shader *shader) +{ + if (shader == NULL) + return true; + + if (!shader->symbols->get_function("main")) { + linker_error_printf(prog, "fragment shader lacks `main'\n"); + return false; + } + + find_assignment_visitor frag_color("gl_FragColor"); + find_assignment_visitor frag_data("gl_FragData"); + + frag_color.run(&shader->ir); + frag_data.run(&shader->ir); + + if (!frag_color.variable_found() && !frag_data.variable_found()) { + linker_error_printf(prog, "fragment shader does not write to " + "`gl_FragColor' or `gl_FragData'\n"); + return false; + } + + if (frag_color.variable_found() && frag_data.variable_found()) { + linker_error_printf(prog, "fragment shader writes to both " + "`gl_FragColor' and `gl_FragData'\n"); + return false; + } + + return true; +} + + +/** + * Perform validation of uniforms used across multiple shader stages + */ +bool +cross_validate_uniforms(struct glsl_program *prog) +{ + /* Examine all of the uniforms in all of the shaders and cross validate + * them. + */ + glsl_symbol_table uniforms; + for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { + foreach_list(node, &prog->_LinkedShaders[i]->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_uniform)) + continue; + + /* If a uniform with this name has already been seen, verify that the + * new instance has the same type. In addition, if the uniforms have + * initializers, the values of the initializers must be the same. + */ + ir_variable *const existing = uniforms.get_variable(var->name); + if (existing != NULL) { + if (var->type != existing->type) { + linker_error_printf(prog, "uniform `%s' declared as type " + "`%s' and type `%s'\n", + var->name, var->type->name, + existing->type->name); + return false; + } + + if (var->constant_value != NULL) { + if (existing->constant_value != NULL) { + if (!var->constant_value->has_value(existing->constant_value)) { + linker_error_printf(prog, "initializers for uniform " + "`%s' have differing values\n", + var->name); + return false; + } + } else + /* If the first-seen instance of a particular uniform did not + * have an initializer but a later instance does, copy the + * initializer to the version stored in the symbol table. + */ + existing->constant_value = + (ir_constant *)var->constant_value->clone(NULL); + } + } else + uniforms.add_variable(var->name, var); + } + } + + return true; +} + + +/** + * Validate that outputs from one stage match inputs of another + */ +bool +cross_validate_outputs_to_inputs(struct glsl_program *prog, + glsl_shader *producer, glsl_shader *consumer) +{ + glsl_symbol_table parameters; + /* FINISHME: Figure these out dynamically. */ + const char *const producer_stage = "vertex"; + const char *const consumer_stage = "fragment"; + + /* Find all shader outputs in the "producer" stage. + */ + foreach_list(node, &producer->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + /* FINISHME: For geometry shaders, this should also look for inout + * FINISHME: variables. + */ + if ((var == NULL) || (var->mode != ir_var_out)) + continue; + + parameters.add_variable(var->name, var); + } + + + /* Find all shader inputs in the "consumer" stage. Any variables that have + * matching outputs already in the symbol table must have the same type and + * qualifiers. + */ + foreach_list(node, &consumer->ir) { + ir_variable *const input = ((ir_instruction *) node)->as_variable(); + + /* FINISHME: For geometry shaders, this should also look for inout + * FINISHME: variables. + */ + if ((input == NULL) || (input->mode != ir_var_in)) + continue; + + ir_variable *const output = parameters.get_variable(input->name); + if (output != NULL) { + /* Check that the types match between stages. + */ + if (input->type != output->type) { + linker_error_printf(prog, + "%s shader output `%s' delcared as " + "type `%s', but %s shader input declared " + "as type `%s'\n", + producer_stage, output->name, + output->type->name, + consumer_stage, input->type->name); + return false; + } + + /* Check that all of the qualifiers match between stages. + */ + if (input->centroid != output->centroid) { + linker_error_printf(prog, + "%s shader output `%s' %s centroid qualifier, " + "but %s shader input %s centroid qualifier\n", + producer_stage, + output->name, + (output->centroid) ? "has" : "lacks", + consumer_stage, + (input->centroid) ? "has" : "lacks"); + return false; + } + + if (input->invariant != output->invariant) { + linker_error_printf(prog, + "%s shader output `%s' %s invariant qualifier, " + "but %s shader input %s invariant qualifier\n", + producer_stage, + output->name, + (output->invariant) ? "has" : "lacks", + consumer_stage, + (input->invariant) ? "has" : "lacks"); + return false; + } + + if (input->interpolation != output->interpolation) { + linker_error_printf(prog, + "%s shader output `%s' specifies %s " + "interpolation qualifier, " + "but %s shader input specifies %s " + "interpolation qualifier\n", + producer_stage, + output->name, + output->interpolation_string(), + consumer_stage, + input->interpolation_string()); + return false; + } + } + } + + return true; +} + + +struct uniform_node { + exec_node link; + struct gl_uniform *u; + unsigned slots; +}; + +void +assign_uniform_locations(struct glsl_program *prog) +{ + /* */ + exec_list uniforms; + unsigned total_uniforms = 0; + hash_table *ht = hash_table_ctor(32, hash_table_string_hash, + hash_table_string_compare); + + for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { + unsigned next_position = 0; + + foreach_list(node, &prog->_LinkedShaders[i]->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_uniform)) + continue; + + const unsigned vec4_slots = (var->component_slots() + 3) / 4; + assert(vec4_slots != 0); + + uniform_node *n = (uniform_node *) hash_table_find(ht, var->name); + if (n == NULL) { + n = (uniform_node *) calloc(1, sizeof(struct uniform_node)); + n->u = (gl_uniform *) calloc(vec4_slots, sizeof(struct gl_uniform)); + n->slots = vec4_slots; + + n->u[0].Name = strdup(var->name); + for (unsigned j = 1; j < vec4_slots; j++) + n->u[j].Name = n->u[0].Name; + + hash_table_insert(ht, n, n->u[0].Name); + uniforms.push_tail(& n->link); + total_uniforms += vec4_slots; + } + + if (var->constant_value != NULL) + for (unsigned j = 0; j < vec4_slots; j++) + n->u[j].Initialized = true; + + var->location = next_position; + + for (unsigned j = 0; j < vec4_slots; j++) { + switch (prog->_LinkedShaders[i]->Type) { + case GL_VERTEX_SHADER: + n->u[j].VertPos = next_position; + break; + case GL_FRAGMENT_SHADER: + n->u[j].FragPos = next_position; + break; + case GL_GEOMETRY_SHADER: + /* FINISHME: Support geometry shaders. */ + assert(prog->_LinkedShaders[i]->Type != GL_GEOMETRY_SHADER); + break; + } + + next_position++; + } + } + } + + gl_uniform_list *ul = (gl_uniform_list *) + calloc(1, sizeof(gl_uniform_list)); + + ul->Size = total_uniforms; + ul->NumUniforms = total_uniforms; + ul->Uniforms = (gl_uniform *) calloc(total_uniforms, sizeof(gl_uniform)); + + unsigned idx = 0; + uniform_node *next; + for (uniform_node *node = (uniform_node *) uniforms.head + ; node->link.next != NULL + ; node = next) { + next = (uniform_node *) node->link.next; + + node->link.remove(); + memcpy(&ul->Uniforms[idx], node->u, sizeof(gl_uniform) * node->slots); + idx += node->slots; + + free(node->u); + free(node); + } + + hash_table_dtor(ht); + + prog->Uniforms = ul; +} + + +/** + * Find a contiguous set of available bits in a bitmask + * + * \param used_mask Bits representing used (1) and unused (0) locations + * \param needed_count Number of contiguous bits needed. + * + * \return + * Base location of the available bits on success or -1 on failure. + */ +int +find_available_slots(unsigned used_mask, unsigned needed_count) +{ + unsigned needed_mask = (1 << needed_count) - 1; + const int max_bit_to_test = (8 * sizeof(used_mask)) - needed_count; + + /* The comparison to 32 is redundant, but without it GCC emits "warning: + * cannot optimize possibly infinite loops" for the loop below. + */ + if ((needed_count == 0) || (max_bit_to_test < 0) || (max_bit_to_test > 32)) + return -1; + + for (int i = 0; i <= max_bit_to_test; i++) { + if ((needed_mask & ~used_mask) == needed_mask) + return i; + + needed_mask <<= 1; + } + + return -1; +} + + +bool +assign_attribute_locations(glsl_program *prog, unsigned max_attribute_index) +{ + /* Mark invalid attribute locations as being used. + */ + unsigned used_locations = (max_attribute_index >= 32) + ? ~0 : ~((1 << max_attribute_index) - 1); + + glsl_shader *const sh = prog->_LinkedShaders[0]; + assert(sh->Type == GL_VERTEX_SHADER); + + /* Operate in a total of four passes. + * + * 1. Invalidate the location assignments for all vertex shader inputs. + * + * 2. Assign locations for inputs that have user-defined (via + * glBindVertexAttribLocation) locatoins. + * + * 3. Sort the attributes without assigned locations by number of slots + * required in decreasing order. Fragmentation caused by attribute + * locations assigned by the application may prevent large attributes + * from having enough contiguous space. + * + * 4. Assign locations to any inputs without assigned locations. + */ + + invalidate_variable_locations(sh, ir_var_in, VERT_ATTRIB_GENERIC0); + + if (prog->Attributes != NULL) { + for (unsigned i = 0; i < prog->Attributes->NumParameters; i++) { + ir_variable *const var = + sh->symbols->get_variable(prog->Attributes->Parameters[i].Name); + + /* Note: attributes that occupy multiple slots, such as arrays or + * matrices, may appear in the attrib array multiple times. + */ + if ((var == NULL) || (var->location != -1)) + continue; + + /* From page 61 of the OpenGL 4.0 spec: + * + * "LinkProgram will fail if the attribute bindings assigned by + * BindAttribLocation do not leave not enough space to assign a + * location for an active matrix attribute or an active attribute + * array, both of which require multiple contiguous generic + * attributes." + * + * Previous versions of the spec contain similar language but omit the + * bit about attribute arrays. + * + * Page 61 of the OpenGL 4.0 spec also says: + * + * "It is possible for an application to bind more than one + * attribute name to the same location. This is referred to as + * aliasing. This will only work if only one of the aliased + * attributes is active in the executable program, or if no path + * through the shader consumes more than one attribute of a set + * of attributes aliased to the same location. A link error can + * occur if the linker determines that every path through the + * shader consumes multiple aliased attributes, but + * implementations are not required to generate an error in this + * case." + * + * These two paragraphs are either somewhat contradictory, or I don't + * fully understand one or both of them. + */ + /* FINISHME: The code as currently written does not support attribute + * FINISHME: location aliasing (see comment above). + */ + const int attr = prog->Attributes->Parameters[i].StateIndexes[0]; + const unsigned slots = count_attribute_slots(var->type); + + /* Mask representing the contiguous slots that will be used by this + * attribute. + */ + const unsigned use_mask = (1 << slots) - 1; + + /* Generate a link error if the set of bits requested for this + * attribute overlaps any previously allocated bits. + */ + if ((~(use_mask << attr) & used_locations) != used_locations) { + linker_error_printf(prog, + "insufficient contiguous attribute locations " + "available for vertex shader input `%s'", + var->name); + return false; + } + + var->location = VERT_ATTRIB_GENERIC0 + attr; + used_locations |= (use_mask << attr); + } + } + + /* Temporary storage for the set of attributes that need locations assigned. + */ + struct temp_attr { + unsigned slots; + ir_variable *var; + + /* Used below in the call to qsort. */ + static int compare(const void *a, const void *b) + { + const temp_attr *const l = (const temp_attr *) a; + const temp_attr *const r = (const temp_attr *) b; + + /* Reversed because we want a descending order sort below. */ + return r->slots - l->slots; + } + } to_assign[16]; + + unsigned num_attr = 0; + + foreach_list(node, &sh->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_in)) + continue; + + /* The location was explicitly assigned, nothing to do here. + */ + if (var->location != -1) + continue; + + to_assign[num_attr].slots = count_attribute_slots(var->type); + to_assign[num_attr].var = var; + num_attr++; + } + + /* If all of the attributes were assigned locations by the application (or + * are built-in attributes with fixed locations), return early. This should + * be the common case. + */ + if (num_attr == 0) + return true; + + qsort(to_assign, num_attr, sizeof(to_assign[0]), temp_attr::compare); + + for (unsigned i = 0; i < num_attr; i++) { + /* Mask representing the contiguous slots that will be used by this + * attribute. + */ + const unsigned use_mask = (1 << to_assign[i].slots) - 1; + + int location = find_available_slots(used_locations, to_assign[i].slots); + + if (location < 0) { + linker_error_printf(prog, + "insufficient contiguous attribute locations " + "available for vertex shader input `%s'", + to_assign[i].var->name); + return false; + } + + to_assign[i].var->location = VERT_ATTRIB_GENERIC0 + location; + used_locations |= (use_mask << location); + } + + return true; +} + + +void +assign_varying_locations(glsl_shader *producer, glsl_shader *consumer) +{ + /* FINISHME: Set dynamically when geometry shader support is added. */ + unsigned output_index = VERT_RESULT_VAR0; + unsigned input_index = FRAG_ATTRIB_VAR0; + + /* Operate in a total of three passes. + * + * 1. Assign locations for any matching inputs and outputs. + * + * 2. Mark output variables in the producer that do not have locations as + * not being outputs. This lets the optimizer eliminate them. + * + * 3. Mark input variables in the consumer that do not have locations as + * not being inputs. This lets the optimizer eliminate them. + */ + + invalidate_variable_locations(producer, ir_var_out, VERT_RESULT_VAR0); + invalidate_variable_locations(consumer, ir_var_in, FRAG_ATTRIB_VAR0); + + foreach_list(node, &producer->ir) { + ir_variable *const output_var = ((ir_instruction *) node)->as_variable(); + + if ((output_var == NULL) || (output_var->mode != ir_var_out) + || (output_var->location != -1)) + continue; + + ir_variable *const input_var = + consumer->symbols->get_variable(output_var->name); + + if ((input_var == NULL) || (input_var->mode != ir_var_in)) + continue; + + assert(input_var->location == -1); + + /* FINISHME: Location assignment will need some changes when arrays, + * FINISHME: matrices, and structures are allowed as shader inputs / + * FINISHME: outputs. + */ + output_var->location = output_index; + input_var->location = input_index; + + output_index++; + input_index++; + } + + foreach_list(node, &producer->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_out)) + continue; + + /* An 'out' variable is only really a shader output if its value is read + * by the following stage. + */ + var->shader_out = (var->location != -1); + } + + foreach_list(node, &consumer->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_in)) + continue; + + /* An 'in' variable is only really a shader input if its value is written + * by the previous stage. + */ + var->shader_in = (var->location != -1); + } +} + + +void +link_shaders(struct glsl_program *prog) +{ + prog->LinkStatus = false; + prog->Validated = false; + prog->_Used = false; + + if (prog->InfoLog != NULL) + talloc_free(prog->InfoLog); + + prog->InfoLog = talloc_strdup(NULL, ""); + + /* Separate the shaders into groups based on their type. + */ + struct glsl_shader **vert_shader_list; + unsigned num_vert_shaders = 0; + struct glsl_shader **frag_shader_list; + unsigned num_frag_shaders = 0; + + vert_shader_list = (struct glsl_shader **) + calloc(2 * prog->NumShaders, sizeof(struct glsl_shader *)); + frag_shader_list = &vert_shader_list[prog->NumShaders]; + + for (unsigned i = 0; i < prog->NumShaders; i++) { + switch (prog->Shaders[i]->Type) { + case GL_VERTEX_SHADER: + vert_shader_list[num_vert_shaders] = prog->Shaders[i]; + num_vert_shaders++; + break; + case GL_FRAGMENT_SHADER: + frag_shader_list[num_frag_shaders] = prog->Shaders[i]; + num_frag_shaders++; + break; + case GL_GEOMETRY_SHADER: + /* FINISHME: Support geometry shaders. */ + assert(prog->Shaders[i]->Type != GL_GEOMETRY_SHADER); + break; + } + } + + /* FINISHME: Implement intra-stage linking. */ + assert(num_vert_shaders <= 1); + assert(num_frag_shaders <= 1); + + /* Verify that each of the per-target executables is valid. + */ + if (!validate_vertex_shader_executable(prog, vert_shader_list[0]) + || !validate_fragment_shader_executable(prog, frag_shader_list[0])) + goto done; + + + prog->_LinkedShaders = (struct glsl_shader **) + calloc(2, sizeof(struct glsl_shader *)); + prog->_NumLinkedShaders = 0; + + if (num_vert_shaders > 0) { + prog->_LinkedShaders[prog->_NumLinkedShaders] = vert_shader_list[0]; + prog->_NumLinkedShaders++; + } + + if (num_frag_shaders > 0) { + prog->_LinkedShaders[prog->_NumLinkedShaders] = frag_shader_list[0]; + prog->_NumLinkedShaders++; + } + + /* Here begins the inter-stage linking phase. Some initial validation is + * performed, then locations are assigned for uniforms, attributes, and + * varyings. + */ + if (cross_validate_uniforms(prog)) { + /* Validate the inputs of each stage with the output of the preceeding + * stage. + */ + for (unsigned i = 1; i < prog->_NumLinkedShaders; i++) { + if (!cross_validate_outputs_to_inputs(prog, + prog->_LinkedShaders[i - 1], + prog->_LinkedShaders[i])) + goto done; + } + + prog->LinkStatus = true; + } + + /* FINISHME: Perform whole-program optimization here. */ + + assign_uniform_locations(prog); + + if (prog->_LinkedShaders[0]->Type == GL_VERTEX_SHADER) + /* FINISHME: The value of the max_attribute_index parameter is + * FINISHME: implementation dependent based on the value of + * FINISHME: GL_MAX_VERTEX_ATTRIBS. GL_MAX_VERTEX_ATTRIBS must be + * FINISHME: at least 16, so hardcode 16 for now. + */ + if (!assign_attribute_locations(prog, 16)) + goto done; + + for (unsigned i = 1; i < prog->_NumLinkedShaders; i++) + assign_varying_locations(prog->_LinkedShaders[i - 1], + prog->_LinkedShaders[i]); + + /* FINISHME: Assign fragment shader output locations. */ + +done: + free(vert_shader_list); +} diff --git a/src/glsl/list.h b/src/glsl/list.h new file mode 100644 index 00000000000..7732d66d7a6 --- /dev/null +++ b/src/glsl/list.h @@ -0,0 +1,403 @@ +/* + * Copyright © 2008, 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file list.h + * \brief Doubly-linked list abstract container type. + * + * Each doubly-linked list has a sentinal head and tail node. These nodes + * contain no data. The head sentinal can be identified by its \c prev + * pointer being \c NULL. The tail sentinal can be identified by its + * \c next pointer being \c NULL. + * + * A list is empty if either the head sentinal's \c next pointer points to the + * tail sentinal or the tail sentinal's \c prev poiner points to the head + * sentinal. + * + * Instead of tracking two separate \c node structures and a \c list structure + * that points to them, the sentinal nodes are in a single structure. Noting + * that each sentinal node always has one \c NULL pointer, the \c NULL + * pointers occupy the same memory location. In the \c list structure + * contains a the following: + * + * - A \c head pointer that represents the \c next pointer of the + * head sentinal node. + * - A \c tail pointer that represents the \c prev pointer of the head + * sentinal node and the \c next pointer of the tail sentinal node. This + * pointer is \b always \c NULL. + * - A \c tail_prev pointer that represents the \c prev pointer of the + * tail sentinal node. + * + * Therefore, if \c head->next is \c NULL or \c tail_prev->prev is \c NULL, + * the list is empty. + * + * To anyone familiar with "exec lists" on the Amiga, this structure should + * be immediately recognizable. See the following link for the original Amiga + * operating system documentation on the subject. + * + * http://www.natami.net/dev/Libraries_Manual_guide/node02D7.html + * + * \author Ian Romanick + */ + +#pragma once +#ifndef LIST_CONTAINER_H +#define LIST_CONTAINER_H + +#ifndef __cplusplus +#include +#include +#else +extern "C" { +#include +} +#endif + +#include + +struct exec_node { + struct exec_node *next; + struct exec_node *prev; + +#ifdef __cplusplus + /* Callers of this talloc-based new need not call delete. It's + * easier to just talloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *node; + + node = talloc_size(ctx, size); + assert(node != NULL); + + return node; + } + + /* If the user *does* call delete, that's OK, we will just + * talloc_free in that case. */ + static void operator delete(void *node) + { + talloc_free(node); + } + + exec_node() : next(NULL), prev(NULL) + { + /* empty */ + } + + const exec_node *get_next() const + { + return next; + } + + exec_node *get_next() + { + return next; + } + + const exec_node *get_prev() const + { + return prev; + } + + exec_node *get_prev() + { + return prev; + } + + void remove() + { + next->prev = prev; + prev->next = next; + next = NULL; + prev = NULL; + } + + /** + * Link a node with itself + * + * This creates a sort of degenerate list that is occasionally useful. + */ + void self_link() + { + next = this; + prev = this; + } + + /** + * Insert a node in the list after the current node + */ + void insert_after(exec_node *after) + { + after->next = this->next; + after->prev = this; + + this->next->prev = after; + this->next = after; + } + /** + * Insert a node in the list before the current node + */ + void insert_before(exec_node *before) + { + before->next = this; + before->prev = this->prev; + + this->prev->next = before; + this->prev = before; + } + + /** + * Is this the sentinal at the tail of the list? + */ + bool is_tail_sentinal() const + { + return this->next == NULL; + } + + /** + * Is this the sentinal at the head of the list? + */ + bool is_head_sentinal() const + { + return this->prev == NULL; + } +#endif +}; + + +#ifdef __cplusplus +/* This macro will not work correctly if `t' uses virtual inheritance. If you + * are using virtual inheritance, you deserve a slow and painful death. Enjoy! + */ +#define exec_list_offsetof(t, f, p) \ + (((char *) &((t *) p)->f) - ((char *) p)) +#else +#define exec_list_offsetof(t, f, p) offsetof(t, f) +#endif + +/** + * Get a pointer to the structure containing an exec_node + * + * Given a pointer to an \c exec_node embedded in a structure, get a pointer to + * the containing structure. + * + * \param type Base type of the structure containing the node + * \param node Pointer to the \c exec_node + * \param field Name of the field in \c type that is the embedded \c exec_node + */ +#define exec_node_data(type, node, field) \ + ((type *) (((char *) node) - exec_list_offsetof(type, field, node))) + +#ifdef __cplusplus +struct exec_node; + +class iterator { +public: + void next() + { + } + + void *get() + { + return NULL; + } + + bool has_next() const + { + return false; + } +}; + +class exec_list_iterator : public iterator { +public: + exec_list_iterator(exec_node *n) : node(n), _next(n->next) + { + /* empty */ + } + + void next() + { + node = _next; + _next = node->next; + } + + void remove() + { + node->remove(); + } + + exec_node *get() + { + return node; + } + + bool has_next() const + { + return _next != NULL; + } + +private: + exec_node *node; + exec_node *_next; +}; + +#define foreach_iter(iter_type, iter, container) \ + for (iter_type iter = (container) . iterator(); iter.has_next(); iter.next()) +#endif + + +struct exec_list { + struct exec_node *head; + struct exec_node *tail; + struct exec_node *tail_pred; + +#ifdef __cplusplus + exec_list() + { + make_empty(); + } + + void make_empty() + { + head = (exec_node *) & tail; + tail = NULL; + tail_pred = (exec_node *) & head; + } + + bool is_empty() const + { + /* There are three ways to test whether a list is empty or not. + * + * - Check to see if the \c head points to the \c tail. + * - Check to see if the \c tail_pred points to the \c head. + * - Check to see if the \c head is the sentinal node by test whether its + * \c next pointer is \c NULL. + * + * The first two methods tend to generate better code on modern systems + * because they save a pointer dereference. + */ + return head == (exec_node *) &tail; + } + + const exec_node *get_head() const + { + return !is_empty() ? head : NULL; + } + + exec_node *get_head() + { + return !is_empty() ? head : NULL; + } + + const exec_node *get_tail() const + { + return !is_empty() ? tail_pred : NULL; + } + + exec_node *get_tail() + { + return !is_empty() ? tail_pred : NULL; + } + + void push_head(exec_node *n) + { + n->next = head; + n->prev = (exec_node *) &head; + + n->next->prev = n; + head = n; + } + + void push_tail(exec_node *n) + { + n->next = (exec_node *) &tail; + n->prev = tail_pred; + + n->prev->next = n; + tail_pred = n; + } + + void push_degenerate_list_at_head(exec_node *n) + { + assert(n->prev->next == n); + + n->prev->next = head; + head->prev = n->prev; + n->prev = (exec_node *) &head; + head = n; + } + + /** + * Move all of the nodes from this list to the target list + */ + void move_nodes_to(exec_list *target) + { + if (is_empty()) { + target->make_empty(); + } else { + target->head = head; + target->tail = NULL; + target->tail_pred = tail_pred; + + target->head->prev = (exec_node *) &target->head; + target->tail_pred->next = (exec_node *) &target->tail; + + make_empty(); + } + } + + exec_list_iterator iterator() + { + return exec_list_iterator(head); + } + + exec_list_iterator iterator() const + { + return exec_list_iterator((exec_node *) head); + } +#endif +}; + +#define foreach_list(__node, __list) \ + for (exec_node * __node = (__list)->head \ + ; (__node)->next != NULL \ + ; (__node) = (__node)->next) + +#define foreach_list_const(__node, __list) \ + for (const exec_node * __node = (__list)->head \ + ; (__node)->next != NULL \ + ; (__node) = (__node)->next) + +#define foreach_list_typed(__type, __node, __field, __list) \ + for (__type * __node = \ + exec_node_data(__type, (__list)->head, __field); \ + (__node)->__field.next != NULL; \ + (__node) = exec_node_data(__type, (__node)->__field.next, __field)) + +#define foreach_list_typed_const(__type, __node, __field, __list) \ + for (const __type * __node = \ + exec_node_data(__type, (__list)->head, __field); \ + (__node)->__field.next != NULL; \ + (__node) = exec_node_data(__type, (__node)->__field.next, __field)) + +#endif /* LIST_CONTAINER_H */ diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp new file mode 100644 index 00000000000..dcd9bd69c0c --- /dev/null +++ b/src/glsl/main.cpp @@ -0,0 +1,256 @@ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include + +#include +#include +#include +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" +#include "ir_optimization.h" +#include "ir_print_visitor.h" +#include "program.h" + +/* Returned string will have 'ctx' as its talloc owner. */ +static char * +load_text_file(void *ctx, const char *file_name, size_t *size) +{ + char *text = NULL; + struct stat st; + ssize_t total_read = 0; + int fd = open(file_name, O_RDONLY); + + *size = 0; + if (fd < 0) { + 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'; + *size = total_read; + } + } + + close(fd); + + return text; +} + + +void +usage_fail(const char *name) +{ + printf("%s \n", name); + exit(EXIT_FAILURE); +} + + +int dump_ast = 0; +int dump_lir = 0; +int do_link = 0; + +const struct option compiler_opts[] = { + { "dump-ast", 0, &dump_ast, 1 }, + { "dump-lir", 0, &dump_lir, 1 }, + { "link", 0, &do_link, 1 }, + { NULL, 0, NULL, 0 } +}; + +void +compile_shader(struct glsl_shader *shader) +{ + struct _mesa_glsl_parse_state *state; + + state = talloc_zero(talloc_parent(shader), struct _mesa_glsl_parse_state); + + switch (shader->Type) { + case GL_VERTEX_SHADER: state->target = vertex_shader; break; + case GL_FRAGMENT_SHADER: state->target = fragment_shader; break; + case GL_GEOMETRY_SHADER: state->target = geometry_shader; break; + } + + state->scanner = NULL; + state->translation_unit.make_empty(); + state->symbols = new(shader) glsl_symbol_table; + state->info_log = talloc_strdup(shader, ""); + state->error = false; + state->temp_index = 0; + state->loop_or_switch_nesting = NULL; + state->ARB_texture_rectangle_enable = true; + + /* Create a new context for the preprocessor output. Ultimately, this + * should probably be the parser context, but there isn't one yet. + */ + const char *source = shader->Source; + state->error = preprocess(shader, &source, &state->info_log); + + if (!state->error) { + _mesa_glsl_lexer_ctor(state, source); + _mesa_glsl_parse(state); + _mesa_glsl_lexer_dtor(state); + } + + if (dump_ast) { + foreach_list_const(n, &state->translation_unit) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + printf("\n\n"); + } + + shader->ir.make_empty(); + if (!state->error && !state->translation_unit.is_empty()) + _mesa_ast_to_hir(&shader->ir, state); + + validate_ir_tree(&shader->ir); + + /* Optimization passes */ + if (!state->error && !shader->ir.is_empty()) { + bool progress; + do { + progress = false; + + progress = do_function_inlining(&shader->ir) || progress; + progress = do_if_simplification(&shader->ir) || progress; + progress = do_copy_propagation(&shader->ir) || progress; + progress = do_dead_code_local(&shader->ir) || progress; + progress = do_dead_code_unlinked(&shader->ir) || progress; + progress = do_constant_variable_unlinked(&shader->ir) || progress; + progress = do_constant_folding(&shader->ir) || progress; + progress = do_vec_index_to_swizzle(&shader->ir) || progress; + progress = do_swizzle_swizzle(&shader->ir) || progress; + } while (progress); + } + + validate_ir_tree(&shader->ir); + + /* Print out the resulting IR */ + if (!state->error && dump_lir) { + _mesa_print_ir(&shader->ir, state); + } + + shader->symbols = state->symbols; + shader->CompileStatus = !state->error; + + if (shader->InfoLog) + talloc_free(shader->InfoLog); + + shader->InfoLog = state->info_log; + + talloc_free(state); + + return; +} + +int +main(int argc, char **argv) +{ + int status = EXIT_SUCCESS; + + int c; + int idx = 0; + while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1) + /* empty */ ; + + + if (argc <= optind) + usage_fail(argv[0]); + + struct glsl_program *whole_program; + + whole_program = talloc_zero (NULL, struct glsl_program); + assert(whole_program != NULL); + + for (/* empty */; argc > optind; optind++) { + whole_program->Shaders = (struct glsl_shader **) + talloc_realloc(whole_program, whole_program->Shaders, + struct glsl_shader *, whole_program->NumShaders + 1); + assert(whole_program->Shaders != NULL); + + struct glsl_shader *shader = talloc_zero(whole_program, glsl_shader); + + whole_program->Shaders[whole_program->NumShaders] = shader; + whole_program->NumShaders++; + + const unsigned len = strlen(argv[optind]); + if (len < 6) + usage_fail(argv[0]); + + const char *const ext = & argv[optind][len - 5]; + if (strncmp(".vert", ext, 5) == 0) + shader->Type = GL_VERTEX_SHADER; + else if (strncmp(".geom", ext, 5) == 0) + shader->Type = GL_GEOMETRY_SHADER; + else if (strncmp(".frag", ext, 5) == 0) + shader->Type = GL_FRAGMENT_SHADER; + else + usage_fail(argv[0]); + + shader->Source = load_text_file(whole_program, + argv[optind], &shader->SourceLen); + if (shader->Source == NULL) { + printf("File \"%s\" does not exist.\n", argv[optind]); + exit(EXIT_FAILURE); + } + + compile_shader(shader); + + if (!shader->CompileStatus) { + printf("Info log for %s:\n%s\n", argv[optind], shader->InfoLog); + status = EXIT_FAILURE; + break; + } + } + + if ((status == EXIT_SUCCESS) && do_link) { + link_shaders(whole_program); + status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE; + } + + talloc_free(whole_program); + + return status; +} diff --git a/src/glsl/main/imports.h b/src/glsl/main/imports.h new file mode 100644 index 00000000000..d2197342c04 --- /dev/null +++ b/src/glsl/main/imports.h @@ -0,0 +1,6 @@ +#include +#include + +#define _mesa_malloc(x) malloc(x) +#define _mesa_free(x) free(x) +#define _mesa_calloc(x) calloc(1,x) diff --git a/src/glsl/main/mtypes.h b/src/glsl/main/mtypes.h new file mode 100644 index 00000000000..06e2dd4b540 --- /dev/null +++ b/src/glsl/main/mtypes.h @@ -0,0 +1,270 @@ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file mtypes.h + * Main Mesa data structures. + * + * Please try to mark derived values with a leading underscore ('_'). + */ + +#ifndef MTYPES_H +#define MTYPES_H + +#define MAX_DRAW_BUFFERS 8 +#define MAX_VARYING 16 + +#include + +/** + * Indexes for vertex program attributes. + * GL_NV_vertex_program aliases generic attributes over the conventional + * attributes. In GL_ARB_vertex_program shader the aliasing is optional. + * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the + * generic attributes are distinct/separate). + */ +typedef enum +{ + VERT_ATTRIB_POS = 0, + VERT_ATTRIB_WEIGHT = 1, + VERT_ATTRIB_NORMAL = 2, + VERT_ATTRIB_COLOR0 = 3, + VERT_ATTRIB_COLOR1 = 4, + VERT_ATTRIB_FOG = 5, + VERT_ATTRIB_COLOR_INDEX = 6, + VERT_ATTRIB_POINT_SIZE = 6, /*alias*/ + VERT_ATTRIB_EDGEFLAG = 7, + VERT_ATTRIB_TEX0 = 8, + VERT_ATTRIB_TEX1 = 9, + VERT_ATTRIB_TEX2 = 10, + VERT_ATTRIB_TEX3 = 11, + VERT_ATTRIB_TEX4 = 12, + VERT_ATTRIB_TEX5 = 13, + VERT_ATTRIB_TEX6 = 14, + VERT_ATTRIB_TEX7 = 15, + VERT_ATTRIB_GENERIC0 = 16, + VERT_ATTRIB_GENERIC1 = 17, + VERT_ATTRIB_GENERIC2 = 18, + VERT_ATTRIB_GENERIC3 = 19, + VERT_ATTRIB_GENERIC4 = 20, + VERT_ATTRIB_GENERIC5 = 21, + VERT_ATTRIB_GENERIC6 = 22, + VERT_ATTRIB_GENERIC7 = 23, + VERT_ATTRIB_GENERIC8 = 24, + VERT_ATTRIB_GENERIC9 = 25, + VERT_ATTRIB_GENERIC10 = 26, + VERT_ATTRIB_GENERIC11 = 27, + VERT_ATTRIB_GENERIC12 = 28, + VERT_ATTRIB_GENERIC13 = 29, + VERT_ATTRIB_GENERIC14 = 30, + VERT_ATTRIB_GENERIC15 = 31, + VERT_ATTRIB_MAX = 32 +} gl_vert_attrib; + +/** + * Bitflags for vertex attributes. + * These are used in bitfields in many places. + */ +/*@{*/ +#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) +#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) +#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) +#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) +#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) +#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) +#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) +#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG) +#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) +#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) +#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) +#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) +#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) +#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) +#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) +#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) +#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) +#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) +#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) +#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) +#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) +#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) +#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) +#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) +#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) +#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) +#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) +#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) +#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) +#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) +#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) +#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) + +#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) +#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) +/*@}*/ + + +/** + * Indexes for vertex program result attributes + */ +typedef enum +{ + VERT_RESULT_HPOS = 0, + VERT_RESULT_COL0 = 1, + VERT_RESULT_COL1 = 2, + VERT_RESULT_FOGC = 3, + VERT_RESULT_TEX0 = 4, + VERT_RESULT_TEX1 = 5, + VERT_RESULT_TEX2 = 6, + VERT_RESULT_TEX3 = 7, + VERT_RESULT_TEX4 = 8, + VERT_RESULT_TEX5 = 9, + VERT_RESULT_TEX6 = 10, + VERT_RESULT_TEX7 = 11, + VERT_RESULT_PSIZ = 12, + VERT_RESULT_BFC0 = 13, + VERT_RESULT_BFC1 = 14, + VERT_RESULT_EDGE = 15, + VERT_RESULT_VAR0 = 16, /**< shader varying */ + VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) +} gl_vert_result; + + +/** + * Indexes for fragment program input attributes. + */ +typedef enum +{ + FRAG_ATTRIB_WPOS = 0, + FRAG_ATTRIB_COL0 = 1, + FRAG_ATTRIB_COL1 = 2, + FRAG_ATTRIB_FOGC = 3, + FRAG_ATTRIB_TEX0 = 4, + FRAG_ATTRIB_TEX1 = 5, + FRAG_ATTRIB_TEX2 = 6, + FRAG_ATTRIB_TEX3 = 7, + FRAG_ATTRIB_TEX4 = 8, + FRAG_ATTRIB_TEX5 = 9, + FRAG_ATTRIB_TEX6 = 10, + FRAG_ATTRIB_TEX7 = 11, + FRAG_ATTRIB_FACE = 12, /**< front/back face */ + FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ + FRAG_ATTRIB_VAR0 = 14, /**< shader varying */ + FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) +} gl_frag_attrib; + +/** + * Bitflags for fragment program input attributes. + */ +/*@{*/ +#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) +#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) +#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) +#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) +#define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE) +#define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC) +#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) +#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1) +#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2) +#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3) +#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4) +#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5) +#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6) +#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7) +#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0) + +#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U)) +#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V)) + +#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \ + FRAG_BIT_TEX1| \ + FRAG_BIT_TEX2| \ + FRAG_BIT_TEX3| \ + FRAG_BIT_TEX4| \ + FRAG_BIT_TEX5| \ + FRAG_BIT_TEX6| \ + FRAG_BIT_TEX7) +/*@}*/ + + +/** + * Fragment program results + */ +typedef enum +{ + FRAG_RESULT_DEPTH = 0, + FRAG_RESULT_COLOR = 1, + FRAG_RESULT_DATA0 = 2, + FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) +} gl_frag_result; + +/** + * Names of the various vertex/fragment program register files, etc. + * + * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) + * All values should fit in a 4-bit field. + * + * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, + * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to + * be "uniform" variables since they can only be set outside glBegin/End. + * They're also all stored in the same Parameters array. + */ +typedef enum +{ + PROGRAM_TEMPORARY, /**< machine->Temporary[] */ + PROGRAM_INPUT, /**< machine->Inputs[] */ + PROGRAM_OUTPUT, /**< machine->Outputs[] */ + PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */ + PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ + PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */ + PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ + PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ + PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ + PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ + PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ + PROGRAM_ADDRESS, /**< machine->AddressReg */ + PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ + PROGRAM_UNDEFINED, /**< Invalid/TBD value */ + PROGRAM_FILE_MAX +} gl_register_file; + +/** + * An index for each type of texture object. These correspond to the GL + * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. + * Note: the order is from highest priority to lowest priority. + */ +typedef enum +{ + TEXTURE_2D_ARRAY_INDEX, + TEXTURE_1D_ARRAY_INDEX, + TEXTURE_CUBE_INDEX, + TEXTURE_3D_INDEX, + TEXTURE_RECT_INDEX, + TEXTURE_2D_INDEX, + TEXTURE_1D_INDEX, + NUM_TEXTURE_TARGETS +} gl_texture_index; + +#endif /* MTYPES_H */ diff --git a/src/glsl/main/simple_list.h b/src/glsl/main/simple_list.h new file mode 100644 index 00000000000..5ef39e14cc6 --- /dev/null +++ b/src/glsl/main/simple_list.h @@ -0,0 +1,235 @@ +/** + * \file simple_list.h + * Simple macros for type-safe, intrusive lists. + * + * Intended to work with a list sentinal which is created as an empty + * list. Insert & delete are O(1). + * + * \author + * (C) 1997, Keith Whitwell + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _SIMPLE_LIST_H +#define _SIMPLE_LIST_H + +struct simple_node { + struct simple_node *next; + struct simple_node *prev; +}; + +/** + * Remove an element from list. + * + * \param elem element to remove. + */ +#define remove_from_list(elem) \ +do { \ + (elem)->next->prev = (elem)->prev; \ + (elem)->prev->next = (elem)->next; \ +} while (0) + +/** + * Insert an element to the list head. + * + * \param list list. + * \param elem element to insert. + */ +#define insert_at_head(list, elem) \ +do { \ + (elem)->prev = list; \ + (elem)->next = (list)->next; \ + (list)->next->prev = elem; \ + (list)->next = elem; \ +} while(0) + +/** + * Insert an element to the list tail. + * + * \param list list. + * \param elem element to insert. + */ +#define insert_at_tail(list, elem) \ +do { \ + (elem)->next = list; \ + (elem)->prev = (list)->prev; \ + (list)->prev->next = elem; \ + (list)->prev = elem; \ +} while(0) + +/** + * Move an element to the list head. + * + * \param list list. + * \param elem element to move. + */ +#define move_to_head(list, elem) \ +do { \ + remove_from_list(elem); \ + insert_at_head(list, elem); \ +} while (0) + +/** + * Move an element to the list tail. + * + * \param list list. + * \param elem element to move. + */ +#define move_to_tail(list, elem) \ +do { \ + remove_from_list(elem); \ + insert_at_tail(list, elem); \ +} while (0) + +/** + * Consatinate a cyclic list to a list + * + * Appends the sequence of nodes starting with \c tail to the list \c head. + * A "cyclic list" is a list that does not have a sentinal node. This means + * that the data pointed to by \c tail is an actual node, not a dataless + * sentinal. Note that if \c tail constist of a single node, this macro + * behaves identically to \c insert_at_tail + * + * \param head Head of the list to be appended to. This may or may not + * be a cyclic list. + * \param tail Head of the cyclic list to be appended to \c head. + * \param temp Temporary \c simple_list used by the macro + * + * \sa insert_at_tail + */ +#define concat_list_and_cycle(head, tail, temp) \ +do { \ + (head)->prev->next = (tail); \ + (tail)->prev->next = (head); \ + (temp) = (head)->prev; \ + (head)->prev = (tail)->prev; \ + (tail)->prev = (temp); \ +} while (0) + +#define concat_list(head, next_list) \ +do { \ + (next_list)->next->prev = (head)->prev; \ + (next_list)->prev->next = (head); \ + (head)->prev->next = (next_list)->next; \ + (head)->prev = (next_list)->prev; \ +} while (0) + +/** + * Make a empty list empty. + * + * \param sentinal list (sentinal element). + */ +#define make_empty_list(sentinal) \ +do { \ + (sentinal)->next = sentinal; \ + (sentinal)->prev = sentinal; \ +} while (0) + +/** + * Get list first element. + * + * \param list list. + * + * \return pointer to first element. + */ +#define first_elem(list) ((list)->next) + +/** + * Get list last element. + * + * \param list list. + * + * \return pointer to last element. + */ +#define last_elem(list) ((list)->prev) + +/** + * Get next element. + * + * \param elem element. + * + * \return pointer to next element. + */ +#define next_elem(elem) ((elem)->next) + +/** + * Get previous element. + * + * \param elem element. + * + * \return pointer to previous element. + */ +#define prev_elem(elem) ((elem)->prev) + +/** + * Test whether element is at end of the list. + * + * \param list list. + * \param elem element. + * + * \return non-zero if element is at end of list, or zero otherwise. + */ +#define at_end(list, elem) ((elem) == (list)) + +/** + * Test if a list is empty. + * + * \param list list. + * + * \return non-zero if list empty, or zero otherwise. + */ +#define is_empty_list(list) ((list)->next == (list)) + +/** + * Walk through the elements of a list. + * + * \param ptr pointer to the current element. + * \param list list. + * + * \note It should be followed by a { } block or a single statement, as in a \c + * for loop. + */ +#define foreach(ptr, list) \ + for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) + +/** + * Walk through the elements of a list. + * + * Same as #foreach but lets you unlink the current value during a list + * traversal. Useful for freeing a list, element by element. + * + * \param ptr pointer to the current element. + * \param t temporary pointer. + * \param list list. + * + * \note It should be followed by a { } block or a single statement, as in a \c + * for loop. + */ +#define foreach_s(ptr, t, list) \ + for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) + +#endif diff --git a/src/glsl/mesa/shader/prog_instruction.c b/src/glsl/mesa/shader/prog_instruction.c new file mode 100644 index 00000000000..fbcf868f509 --- /dev/null +++ b/src/glsl/mesa/shader/prog_instruction.c @@ -0,0 +1,363 @@ +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#define _GNU_SOURCE +#include +#include +#include + +#if 0 +#include "main/glheader.h" +#else +#define _mesa_strdup strdup +#define _mesa_snprintf snprintf +#define ASSERT assert +#endif +#include "main/imports.h" +#include "main/mtypes.h" +#include "prog_instruction.h" + + +/** + * Initialize program instruction fields to defaults. + * \param inst first instruction to initialize + * \param count number of instructions to initialize + */ +void +_mesa_init_instructions(struct prog_instruction *inst, GLuint count) +{ + GLuint i; + + memset(inst, 0, count * sizeof(struct prog_instruction)); + + for (i = 0; i < count; i++) { + inst[i].SrcReg[0].File = PROGRAM_UNDEFINED; + inst[i].SrcReg[0].Swizzle = SWIZZLE_NOOP; + inst[i].SrcReg[1].File = PROGRAM_UNDEFINED; + inst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP; + inst[i].SrcReg[2].File = PROGRAM_UNDEFINED; + inst[i].SrcReg[2].Swizzle = SWIZZLE_NOOP; + + inst[i].DstReg.File = PROGRAM_UNDEFINED; + inst[i].DstReg.WriteMask = WRITEMASK_XYZW; + inst[i].DstReg.CondMask = COND_TR; + inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP; + + inst[i].SaturateMode = SATURATE_OFF; + inst[i].Precision = FLOAT32; + } +} + + +/** + * Allocate an array of program instructions. + * \param numInst number of instructions + * \return pointer to instruction memory + */ +struct prog_instruction * +_mesa_alloc_instructions(GLuint numInst) +{ + return (struct prog_instruction *) + calloc(1, numInst * sizeof(struct prog_instruction)); +} + + +/** + * Reallocate memory storing an array of program instructions. + * This is used when we need to append additional instructions onto an + * program. + * \param oldInst pointer to first of old/src instructions + * \param numOldInst number of instructions at + * \param numNewInst desired size of new instruction array. + * \return pointer to start of new instruction array. + */ +struct prog_instruction * +_mesa_realloc_instructions(struct prog_instruction *oldInst, + GLuint numOldInst, GLuint numNewInst) +{ + struct prog_instruction *newInst; + + (void)numOldInst; + newInst = (struct prog_instruction *) + realloc(oldInst, + numNewInst * sizeof(struct prog_instruction)); + + return newInst; +} + + +/** + * Copy an array of program instructions. + * \param dest pointer to destination. + * \param src pointer to source. + * \param n number of instructions to copy. + * \return pointer to destination. + */ +struct prog_instruction * +_mesa_copy_instructions(struct prog_instruction *dest, + const struct prog_instruction *src, GLuint n) +{ + GLuint i; + memcpy(dest, src, n * sizeof(struct prog_instruction)); + for (i = 0; i < n; i++) { + if (src[i].Comment) + dest[i].Comment = _mesa_strdup(src[i].Comment); + } + return dest; +} + + +/** + * Free an array of instructions + */ +void +_mesa_free_instructions(struct prog_instruction *inst, GLuint count) +{ + GLuint i; + for (i = 0; i < count; i++) { + if (inst[i].Data) + free(inst[i].Data); + if (inst[i].Comment) + free((char *) inst[i].Comment); + } + free(inst); +} + + +/** + * Basic info about each instruction + */ +struct instruction_info +{ + gl_inst_opcode Opcode; + const char *Name; + GLuint NumSrcRegs; + GLuint NumDstRegs; +}; + +/** + * Instruction info + * \note Opcode should equal array index! + */ +static const struct instruction_info InstInfo[MAX_OPCODE] = { + { OPCODE_NOP, "NOP", 0, 0 }, + { OPCODE_ABS, "ABS", 1, 1 }, + { OPCODE_ADD, "ADD", 2, 1 }, + { OPCODE_AND, "AND", 2, 1 }, + { OPCODE_ARA, "ARA", 1, 1 }, + { OPCODE_ARL, "ARL", 1, 1 }, + { OPCODE_ARL_NV, "ARL_NV", 1, 1 }, + { OPCODE_ARR, "ARL", 1, 1 }, + { OPCODE_BGNLOOP,"BGNLOOP", 0, 0 }, + { OPCODE_BGNSUB, "BGNSUB", 0, 0 }, + { OPCODE_BRA, "BRA", 0, 0 }, + { OPCODE_BRK, "BRK", 0, 0 }, + { OPCODE_CAL, "CAL", 0, 0 }, + { OPCODE_CMP, "CMP", 3, 1 }, + { OPCODE_CONT, "CONT", 0, 0 }, + { OPCODE_COS, "COS", 1, 1 }, + { OPCODE_DDX, "DDX", 1, 1 }, + { OPCODE_DDY, "DDY", 1, 1 }, + { OPCODE_DP2, "DP2", 2, 1 }, + { OPCODE_DP2A, "DP2A", 3, 1 }, + { OPCODE_DP3, "DP3", 2, 1 }, + { OPCODE_DP4, "DP4", 2, 1 }, + { OPCODE_DPH, "DPH", 2, 1 }, + { OPCODE_DST, "DST", 2, 1 }, + { OPCODE_ELSE, "ELSE", 0, 0 }, + { OPCODE_END, "END", 0, 0 }, + { OPCODE_ENDIF, "ENDIF", 0, 0 }, + { OPCODE_ENDLOOP,"ENDLOOP", 0, 0 }, + { OPCODE_ENDSUB, "ENDSUB", 0, 0 }, + { OPCODE_EX2, "EX2", 1, 1 }, + { OPCODE_EXP, "EXP", 1, 1 }, + { OPCODE_FLR, "FLR", 1, 1 }, + { OPCODE_FRC, "FRC", 1, 1 }, + { OPCODE_IF, "IF", 1, 0 }, + { OPCODE_KIL, "KIL", 1, 0 }, + { OPCODE_KIL_NV, "KIL_NV", 0, 0 }, + { OPCODE_LG2, "LG2", 1, 1 }, + { OPCODE_LIT, "LIT", 1, 1 }, + { OPCODE_LOG, "LOG", 1, 1 }, + { OPCODE_LRP, "LRP", 3, 1 }, + { OPCODE_MAD, "MAD", 3, 1 }, + { OPCODE_MAX, "MAX", 2, 1 }, + { OPCODE_MIN, "MIN", 2, 1 }, + { OPCODE_MOV, "MOV", 1, 1 }, + { OPCODE_MUL, "MUL", 2, 1 }, + { OPCODE_NOISE1, "NOISE1", 1, 1 }, + { OPCODE_NOISE2, "NOISE2", 1, 1 }, + { OPCODE_NOISE3, "NOISE3", 1, 1 }, + { OPCODE_NOISE4, "NOISE4", 1, 1 }, + { OPCODE_NOT, "NOT", 1, 1 }, + { OPCODE_NRM3, "NRM3", 1, 1 }, + { OPCODE_NRM4, "NRM4", 1, 1 }, + { OPCODE_OR, "OR", 2, 1 }, + { OPCODE_PK2H, "PK2H", 1, 1 }, + { OPCODE_PK2US, "PK2US", 1, 1 }, + { OPCODE_PK4B, "PK4B", 1, 1 }, + { OPCODE_PK4UB, "PK4UB", 1, 1 }, + { OPCODE_POW, "POW", 2, 1 }, + { OPCODE_POPA, "POPA", 0, 0 }, + { OPCODE_PRINT, "PRINT", 1, 0 }, + { OPCODE_PUSHA, "PUSHA", 0, 0 }, + { OPCODE_RCC, "RCC", 1, 1 }, + { OPCODE_RCP, "RCP", 1, 1 }, + { OPCODE_RET, "RET", 0, 0 }, + { OPCODE_RFL, "RFL", 1, 1 }, + { OPCODE_RSQ, "RSQ", 1, 1 }, + { OPCODE_SCS, "SCS", 1, 1 }, + { OPCODE_SEQ, "SEQ", 2, 1 }, + { OPCODE_SFL, "SFL", 0, 1 }, + { OPCODE_SGE, "SGE", 2, 1 }, + { OPCODE_SGT, "SGT", 2, 1 }, + { OPCODE_SIN, "SIN", 1, 1 }, + { OPCODE_SLE, "SLE", 2, 1 }, + { OPCODE_SLT, "SLT", 2, 1 }, + { OPCODE_SNE, "SNE", 2, 1 }, + { OPCODE_SSG, "SSG", 1, 1 }, + { OPCODE_STR, "STR", 0, 1 }, + { OPCODE_SUB, "SUB", 2, 1 }, + { OPCODE_SWZ, "SWZ", 1, 1 }, + { OPCODE_TEX, "TEX", 1, 1 }, + { OPCODE_TXB, "TXB", 1, 1 }, + { OPCODE_TXD, "TXD", 3, 1 }, + { OPCODE_TXL, "TXL", 1, 1 }, + { OPCODE_TXP, "TXP", 1, 1 }, + { OPCODE_TXP_NV, "TXP_NV", 1, 1 }, + { OPCODE_TRUNC, "TRUNC", 1, 1 }, + { OPCODE_UP2H, "UP2H", 1, 1 }, + { OPCODE_UP2US, "UP2US", 1, 1 }, + { OPCODE_UP4B, "UP4B", 1, 1 }, + { OPCODE_UP4UB, "UP4UB", 1, 1 }, + { OPCODE_X2D, "X2D", 3, 1 }, + { OPCODE_XOR, "XOR", 2, 1 }, + { OPCODE_XPD, "XPD", 2, 1 } +}; + + +/** + * Return the number of src registers for the given instruction/opcode. + */ +GLuint +_mesa_num_inst_src_regs(gl_inst_opcode opcode) +{ + ASSERT(opcode < MAX_OPCODE); + ASSERT(opcode == InstInfo[opcode].Opcode); + ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); + return InstInfo[opcode].NumSrcRegs; +} + + +/** + * Return the number of dst registers for the given instruction/opcode. + */ +GLuint +_mesa_num_inst_dst_regs(gl_inst_opcode opcode) +{ + ASSERT(opcode < MAX_OPCODE); + ASSERT(opcode == InstInfo[opcode].Opcode); + ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); + return InstInfo[opcode].NumDstRegs; +} + + +GLboolean +_mesa_is_tex_instruction(gl_inst_opcode opcode) +{ + return (opcode == OPCODE_TEX || + opcode == OPCODE_TXB || + opcode == OPCODE_TXD || + opcode == OPCODE_TXL || + opcode == OPCODE_TXP); +} + + +/** + * Check if there's a potential src/dst register data dependency when + * using SOA execution. + * Example: + * MOV T, T.yxwz; + * This would expand into: + * MOV t0, t1; + * MOV t1, t0; + * MOV t2, t3; + * MOV t3, t2; + * The second instruction will have the wrong value for t0 if executed as-is. + */ +GLboolean +_mesa_check_soa_dependencies(const struct prog_instruction *inst) +{ + GLuint i, chan; + + if (inst->DstReg.WriteMask == WRITEMASK_X || + inst->DstReg.WriteMask == WRITEMASK_Y || + inst->DstReg.WriteMask == WRITEMASK_Z || + inst->DstReg.WriteMask == WRITEMASK_W || + inst->DstReg.WriteMask == 0x0) { + /* no chance of data dependency */ + return GL_FALSE; + } + + /* loop over src regs */ + for (i = 0; i < 3; i++) { + if (inst->SrcReg[i].File == inst->DstReg.File && + inst->SrcReg[i].Index == inst->DstReg.Index) { + /* loop over dest channels */ + GLuint channelsWritten = 0x0; + for (chan = 0; chan < 4; chan++) { + if (inst->DstReg.WriteMask & (1 << chan)) { + /* check if we're reading a channel that's been written */ + GLuint swizzle = GET_SWZ(inst->SrcReg[i].Swizzle, chan); + if (swizzle <= SWIZZLE_W && + (channelsWritten & (1 << swizzle))) { + return GL_TRUE; + } + + channelsWritten |= (1 << chan); + } + } + } + } + return GL_FALSE; +} + + +/** + * Return string name for given program opcode. + */ +const char * +_mesa_opcode_string(gl_inst_opcode opcode) +{ + if (opcode < MAX_OPCODE) + return InstInfo[opcode].Name; + else { + static char s[20]; + _mesa_snprintf(s, sizeof(s), "OP%u", opcode); + return s; + } +} + diff --git a/src/glsl/mesa/shader/prog_instruction.h b/src/glsl/mesa/shader/prog_instruction.h new file mode 100644 index 00000000000..2c95d274cab --- /dev/null +++ b/src/glsl/mesa/shader/prog_instruction.h @@ -0,0 +1,437 @@ +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file prog_instruction.h + * + * Vertex/fragment program instruction datatypes and constants. + * + * \author Brian Paul + * \author Keith Whitwell + * \author Ian Romanick + */ + + +#ifndef PROG_INSTRUCTION_H +#define PROG_INSTRUCTION_H + + +#include "main/mtypes.h" + + +/** + * Swizzle indexes. + * Do not change! + */ +/*@{*/ +#define SWIZZLE_X 0 +#define SWIZZLE_Y 1 +#define SWIZZLE_Z 2 +#define SWIZZLE_W 3 +#define SWIZZLE_ZERO 4 /**< For SWZ instruction only */ +#define SWIZZLE_ONE 5 /**< For SWZ instruction only */ +#define SWIZZLE_NIL 7 /**< used during shader code gen (undefined value) */ +/*@}*/ + +#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9)) +#define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3) +#define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7) +#define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1) + +#define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) +#define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X) +#define SWIZZLE_YYYY MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y) +#define SWIZZLE_ZZZZ MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z) +#define SWIZZLE_WWWW MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W) + + +/** + * Writemask values, 1 bit per component. + */ +/*@{*/ +#define WRITEMASK_X 0x1 +#define WRITEMASK_Y 0x2 +#define WRITEMASK_XY 0x3 +#define WRITEMASK_Z 0x4 +#define WRITEMASK_XZ 0x5 +#define WRITEMASK_YZ 0x6 +#define WRITEMASK_XYZ 0x7 +#define WRITEMASK_W 0x8 +#define WRITEMASK_XW 0x9 +#define WRITEMASK_YW 0xa +#define WRITEMASK_XYW 0xb +#define WRITEMASK_ZW 0xc +#define WRITEMASK_XZW 0xd +#define WRITEMASK_YZW 0xe +#define WRITEMASK_XYZW 0xf +/*@}*/ + + +/** + * Condition codes + */ +/*@{*/ +#define COND_GT 1 /**< greater than zero */ +#define COND_EQ 2 /**< equal to zero */ +#define COND_LT 3 /**< less than zero */ +#define COND_UN 4 /**< unordered (NaN) */ +#define COND_GE 5 /**< greater than or equal to zero */ +#define COND_LE 6 /**< less than or equal to zero */ +#define COND_NE 7 /**< not equal to zero */ +#define COND_TR 8 /**< always true */ +#define COND_FL 9 /**< always false */ +/*@}*/ + + +/** + * Instruction precision for GL_NV_fragment_program + */ +/*@{*/ +#define FLOAT32 0x1 +#define FLOAT16 0x2 +#define FIXED12 0x4 +/*@}*/ + + +/** + * Saturation modes when storing values. + */ +/*@{*/ +#define SATURATE_OFF 0 +#define SATURATE_ZERO_ONE 1 +/*@}*/ + + +/** + * Per-component negation masks + */ +/*@{*/ +#define NEGATE_X 0x1 +#define NEGATE_Y 0x2 +#define NEGATE_Z 0x4 +#define NEGATE_W 0x8 +#define NEGATE_XYZ 0x7 +#define NEGATE_XYZW 0xf +#define NEGATE_NONE 0x0 +/*@}*/ + + +/** + * Program instruction opcodes, for both vertex and fragment programs. + * \note changes to this opcode list must be reflected in t_vb_arbprogram.c + */ +typedef enum prog_opcode { + /* ARB_vp ARB_fp NV_vp NV_fp GLSL */ + /*------------------------------------------*/ + OPCODE_NOP = 0, /* X */ + OPCODE_ABS, /* X X 1.1 X */ + OPCODE_ADD, /* X X X X X */ + OPCODE_AND, /* */ + OPCODE_ARA, /* 2 */ + OPCODE_ARL, /* X X */ + OPCODE_ARL_NV, /* 2 */ + OPCODE_ARR, /* 2 */ + OPCODE_BGNLOOP, /* opt */ + OPCODE_BGNSUB, /* opt */ + OPCODE_BRA, /* 2 X */ + OPCODE_BRK, /* 2 opt */ + OPCODE_CAL, /* 2 2 */ + OPCODE_CMP, /* X */ + OPCODE_CONT, /* opt */ + OPCODE_COS, /* X 2 X X */ + OPCODE_DDX, /* X X */ + OPCODE_DDY, /* X X */ + OPCODE_DP2, /* 2 */ + OPCODE_DP2A, /* 2 */ + OPCODE_DP3, /* X X X X X */ + OPCODE_DP4, /* X X X X X */ + OPCODE_DPH, /* X X 1.1 */ + OPCODE_DST, /* X X X X */ + OPCODE_ELSE, /* X */ + OPCODE_END, /* X X X X opt */ + OPCODE_ENDIF, /* opt */ + OPCODE_ENDLOOP, /* opt */ + OPCODE_ENDSUB, /* opt */ + OPCODE_EX2, /* X X 2 X X */ + OPCODE_EXP, /* X X X */ + OPCODE_FLR, /* X X 2 X X */ + OPCODE_FRC, /* X X 2 X X */ + OPCODE_IF, /* opt */ + OPCODE_KIL, /* X */ + OPCODE_KIL_NV, /* X X */ + OPCODE_LG2, /* X X 2 X X */ + OPCODE_LIT, /* X X X X */ + OPCODE_LOG, /* X X X */ + OPCODE_LRP, /* X X */ + OPCODE_MAD, /* X X X X X */ + OPCODE_MAX, /* X X X X X */ + OPCODE_MIN, /* X X X X X */ + OPCODE_MOV, /* X X X X X */ + OPCODE_MUL, /* X X X X X */ + OPCODE_NOISE1, /* X */ + OPCODE_NOISE2, /* X */ + OPCODE_NOISE3, /* X */ + OPCODE_NOISE4, /* X */ + OPCODE_NOT, /* */ + OPCODE_NRM3, /* */ + OPCODE_NRM4, /* */ + OPCODE_OR, /* */ + OPCODE_PK2H, /* X */ + OPCODE_PK2US, /* X */ + OPCODE_PK4B, /* X */ + OPCODE_PK4UB, /* X */ + OPCODE_POW, /* X X X X */ + OPCODE_POPA, /* 3 */ + OPCODE_PRINT, /* X X */ + OPCODE_PUSHA, /* 3 */ + OPCODE_RCC, /* 1.1 */ + OPCODE_RCP, /* X X X X X */ + OPCODE_RET, /* 2 2 */ + OPCODE_RFL, /* X X */ + OPCODE_RSQ, /* X X X X X */ + OPCODE_SCS, /* X */ + OPCODE_SEQ, /* 2 X X */ + OPCODE_SFL, /* 2 X */ + OPCODE_SGE, /* X X X X X */ + OPCODE_SGT, /* 2 X X */ + OPCODE_SIN, /* X 2 X X */ + OPCODE_SLE, /* 2 X X */ + OPCODE_SLT, /* X X X X X */ + OPCODE_SNE, /* 2 X X */ + OPCODE_SSG, /* 2 */ + OPCODE_STR, /* 2 X */ + OPCODE_SUB, /* X X 1.1 X X */ + OPCODE_SWZ, /* X X */ + OPCODE_TEX, /* X 3 X X */ + OPCODE_TXB, /* X 3 X */ + OPCODE_TXD, /* X X */ + OPCODE_TXL, /* 3 2 X */ + OPCODE_TXP, /* X X */ + OPCODE_TXP_NV, /* 3 X */ + OPCODE_TRUNC, /* X */ + OPCODE_UP2H, /* X */ + OPCODE_UP2US, /* X */ + OPCODE_UP4B, /* X */ + OPCODE_UP4UB, /* X */ + OPCODE_X2D, /* X */ + OPCODE_XOR, /* */ + OPCODE_XPD, /* X X X */ + MAX_OPCODE +} gl_inst_opcode; + + +/** + * Number of bits for the src/dst register Index field. + * This limits the size of temp/uniform register files. + */ +#define INST_INDEX_BITS 10 + + +/** + * Instruction source register. + */ +struct prog_src_register +{ + GLuint File:4; /**< One of the PROGRAM_* register file values. */ + GLint Index:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit. + * May be negative for relative addressing. + */ + GLuint Swizzle:12; + GLuint RelAddr:1; + + /** Take the component-wise absolute value */ + GLuint Abs:1; + + /** + * Post-Abs negation. + * This will either be NEGATE_NONE or NEGATE_XYZW, except for the SWZ + * instruction which allows per-component negation. + */ + GLuint Negate:4; +}; + + +/** + * Instruction destination register. + */ +struct prog_dst_register +{ + GLuint File:4; /**< One of the PROGRAM_* register file values */ + GLuint Index:INST_INDEX_BITS; /**< Unsigned, never negative */ + GLuint WriteMask:4; + GLuint RelAddr:1; + + /** + * \name Conditional destination update control. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, + * NV_vertex_program2_option. + */ + /*@{*/ + /** + * Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT, + * NE, TR, or UN). Dest reg is only written to if the matching + * (swizzled) condition code value passes. When a conditional update mask + * is not specified, this will be \c COND_TR. + */ + GLuint CondMask:4; + + /** + * Condition code swizzle value. + */ + GLuint CondSwizzle:12; + + /** + * Selects the condition code register to use for conditional destination + * update masking. In NV_fragmnet_program or NV_vertex_program2 mode, only + * condition code register 0 is available. In NV_vertex_program3 mode, + * condition code registers 0 and 1 are available. + */ + GLuint CondSrc:1; + /*@}*/ +}; + + +/** + * Vertex/fragment program instruction. + */ +struct prog_instruction +{ + gl_inst_opcode Opcode; + struct prog_src_register SrcReg[3]; + struct prog_dst_register DstReg; + + /** + * Indicates that the instruction should update the condition code + * register. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, + * NV_vertex_program2_option. + */ + GLuint CondUpdate:1; + + /** + * If prog_instruction::CondUpdate is \c GL_TRUE, this value selects the + * condition code register that is to be updated. + * + * In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition + * code register 0 is available. In GL_NV_vertex_program3 mode, condition + * code registers 0 and 1 are available. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, + * NV_vertex_program2_option. + */ + GLuint CondDst:1; + + /** + * Saturate each value of the vectored result to the range [0,1] or the + * range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is + * only available in NV_fragment_program2 mode. + * Value is one of the SATURATE_* tokens. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program3. + */ + GLuint SaturateMode:2; + + /** + * Per-instruction selectable precision: FLOAT32, FLOAT16, FIXED12. + * + * \since + * NV_fragment_program, NV_fragment_program_option. + */ + GLuint Precision:3; + + /** + * \name Extra fields for TEX, TXB, TXD, TXL, TXP instructions. + */ + /*@{*/ + /** Source texture unit. */ + GLuint TexSrcUnit:5; + + /** Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX */ + GLuint TexSrcTarget:3; + + /** True if tex instruction should do shadow comparison */ + GLuint TexShadow:1; + /*@}*/ + + /** + * For BRA and CAL instructions, the location to jump to. + * For BGNLOOP, points to ENDLOOP (and vice-versa). + * For BRK, points to BGNLOOP (which points to ENDLOOP). + * For IF, points to ELSE or ENDIF. + * For ELSE, points to ENDIF. + */ + GLint BranchTarget; + + /** for debugging purposes */ + const char *Comment; + + /** Arbitrary data. Used for OPCODE_PRINT and some drivers */ + void *Data; + + /** for driver use (try to remove someday) */ + GLint Aux; +}; + + +extern void +_mesa_init_instructions(struct prog_instruction *inst, GLuint count); + +extern struct prog_instruction * +_mesa_alloc_instructions(GLuint numInst); + +extern struct prog_instruction * +_mesa_realloc_instructions(struct prog_instruction *oldInst, + GLuint numOldInst, GLuint numNewInst); + +extern struct prog_instruction * +_mesa_copy_instructions(struct prog_instruction *dest, + const struct prog_instruction *src, GLuint n); + +extern void +_mesa_free_instructions(struct prog_instruction *inst, GLuint count); + +extern GLuint +_mesa_num_inst_src_regs(gl_inst_opcode opcode); + +extern GLuint +_mesa_num_inst_dst_regs(gl_inst_opcode opcode); + +extern GLboolean +_mesa_is_tex_instruction(gl_inst_opcode opcode); + +extern GLboolean +_mesa_check_soa_dependencies(const struct prog_instruction *inst); + +extern const char * +_mesa_opcode_string(gl_inst_opcode opcode); + + +#endif /* PROG_INSTRUCTION_H */ diff --git a/src/glsl/mesa/shader/prog_print.c b/src/glsl/mesa/shader/prog_print.c new file mode 100644 index 00000000000..3f1cb48e4bf --- /dev/null +++ b/src/glsl/mesa/shader/prog_print.c @@ -0,0 +1,1089 @@ +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file prog_print.c + * Print vertex/fragment programs - for debugging. + * \author Brian Paul + */ + +#if 0 +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" +#else + +#define _GNU_SOURCE + +#include +#include +#include +#include +struct gl_program { + int Target; +}; + +void _mesa_problem(void *ctx, char *msg) +{ + (void)ctx; + fprintf(stderr, "%s", msg); + exit(1); +} + +#endif + +#include "prog_instruction.h" +#include "prog_print.h" + + + +/** + * Return string name for given program/register file. + */ +static const char * +file_string(gl_register_file f, gl_prog_print_mode mode) +{ + (void)mode; + switch (f) { + case PROGRAM_TEMPORARY: + return "TEMP"; + case PROGRAM_LOCAL_PARAM: + return "LOCAL"; + case PROGRAM_ENV_PARAM: + return "ENV"; + case PROGRAM_STATE_VAR: + return "STATE"; + case PROGRAM_INPUT: + return "INPUT"; + case PROGRAM_OUTPUT: + return "OUTPUT"; + case PROGRAM_NAMED_PARAM: + return "NAMED"; + case PROGRAM_CONSTANT: + return "CONST"; + case PROGRAM_UNIFORM: + return "UNIFORM"; + case PROGRAM_VARYING: + return "VARYING"; + case PROGRAM_WRITE_ONLY: + return "WRITE_ONLY"; + case PROGRAM_ADDRESS: + return "ADDR"; + case PROGRAM_SAMPLER: + return "SAMPLER"; + case PROGRAM_UNDEFINED: + return "UNDEFINED"; + default: + { + static char s[20]; + snprintf(s, sizeof(s), "FILE%u", f); + return s; + } + } +} + + +/** + * Return ARB_v/f_prog-style input attrib string. + */ +static const char * +arb_input_attrib_string(GLint index, GLenum progType) +{ + /* + * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens. + */ + const char *vertAttribs[] = { + "vertex.position", + "vertex.weight", + "vertex.normal", + "vertex.color.primary", + "vertex.color.secondary", + "vertex.fogcoord", + "vertex.(six)", + "vertex.(seven)", + "vertex.texcoord[0]", + "vertex.texcoord[1]", + "vertex.texcoord[2]", + "vertex.texcoord[3]", + "vertex.texcoord[4]", + "vertex.texcoord[5]", + "vertex.texcoord[6]", + "vertex.texcoord[7]", + "vertex.attrib[0]", + "vertex.attrib[1]", + "vertex.attrib[2]", + "vertex.attrib[3]", + "vertex.attrib[4]", + "vertex.attrib[5]", + "vertex.attrib[6]", + "vertex.attrib[7]", + "vertex.attrib[8]", + "vertex.attrib[9]", + "vertex.attrib[10]", + "vertex.attrib[11]", + "vertex.attrib[12]", + "vertex.attrib[13]", + "vertex.attrib[14]", + "vertex.attrib[15]" + }; + const char *fragAttribs[] = { + "fragment.position", + "fragment.color.primary", + "fragment.color.secondary", + "fragment.fogcoord", + "fragment.texcoord[0]", + "fragment.texcoord[1]", + "fragment.texcoord[2]", + "fragment.texcoord[3]", + "fragment.texcoord[4]", + "fragment.texcoord[5]", + "fragment.texcoord[6]", + "fragment.texcoord[7]", + "fragment.varying[0]", + "fragment.varying[1]", + "fragment.varying[2]", + "fragment.varying[3]", + "fragment.varying[4]", + "fragment.varying[5]", + "fragment.varying[6]", + "fragment.varying[7]" + }; + + /* sanity checks */ + assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0); + assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0); + + if (progType == GL_VERTEX_PROGRAM_ARB) { + assert((unsigned int)index < sizeof(vertAttribs) / sizeof(vertAttribs[0])); + return vertAttribs[index]; + } + else { + assert((unsigned int)index < sizeof(fragAttribs) / sizeof(fragAttribs[0])); + return fragAttribs[index]; + } +} + + +/** + * Print a vertex program's InputsRead field in human-readable format. + * For debugging. + */ +void +_mesa_print_vp_inputs(GLbitfield inputs) +{ + printf("VP Inputs 0x%x: \n", inputs); + while (inputs) { + GLint attr = ffs(inputs) - 1; + const char *name = arb_input_attrib_string(attr, + GL_VERTEX_PROGRAM_ARB); + printf(" %d: %s\n", attr, name); + inputs &= ~(1 << attr); + } +} + + +/** + * Print a fragment program's InputsRead field in human-readable format. + * For debugging. + */ +void +_mesa_print_fp_inputs(GLbitfield inputs) +{ + printf("FP Inputs 0x%x: \n", inputs); + while (inputs) { + GLint attr = ffs(inputs) - 1; + const char *name = arb_input_attrib_string(attr, + GL_FRAGMENT_PROGRAM_ARB); + printf(" %d: %s\n", attr, name); + inputs &= ~(1 << attr); + } +} + + +#if 0 +/** + * Return ARB_v/f_prog-style output attrib string. + */ +static const char * +arb_output_attrib_string(GLint index, GLenum progType) +{ + /* + * These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens. + */ + const char *vertResults[] = { + "result.position", + "result.color.primary", + "result.color.secondary", + "result.fogcoord", + "result.texcoord[0]", + "result.texcoord[1]", + "result.texcoord[2]", + "result.texcoord[3]", + "result.texcoord[4]", + "result.texcoord[5]", + "result.texcoord[6]", + "result.texcoord[7]", + "result.varying[0]", + "result.varying[1]", + "result.varying[2]", + "result.varying[3]", + "result.varying[4]", + "result.varying[5]", + "result.varying[6]", + "result.varying[7]" + }; + const char *fragResults[] = { + "result.color", + "result.color(half)", + "result.depth", + "result.color[0]", + "result.color[1]", + "result.color[2]", + "result.color[3]" + }; + + if (progType == GL_VERTEX_PROGRAM_ARB) { + assert(index < sizeof(vertResults) / sizeof(vertResults[0])); + return vertResults[index]; + } + else { + assert(index < sizeof(fragResults) / sizeof(fragResults[0])); + return fragResults[index]; + } +} +#endif + +/** + * Return string representation of the given register. + * Note that some types of registers (like PROGRAM_UNIFORM) aren't defined + * by the ARB/NV program languages so we've taken some liberties here. + * \param f the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc) + * \param index number of the register in the register file + * \param mode the output format/mode/style + * \param prog pointer to containing program + */ +static const char * +reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, + GLboolean relAddr, const struct gl_program *prog) +{ + static char str[100]; + const char *addr = relAddr ? "ADDR+" : ""; + + str[0] = 0; + + switch (mode) { + case PROG_PRINT_DEBUG: + sprintf(str, "%s[%s%d]", file_string(f, mode), addr, index); + break; + case PROG_PRINT_ARB: +#if 0 + switch (f) { + case PROGRAM_INPUT: + sprintf(str, "%s", arb_input_attrib_string(index, prog->Target)); + break; + case PROGRAM_OUTPUT: + sprintf(str, "%s", arb_output_attrib_string(index, prog->Target)); + break; + case PROGRAM_TEMPORARY: + sprintf(str, "temp%d", index); + break; + case PROGRAM_ENV_PARAM: + sprintf(str, "program.env[%s%d]", addr, index); + break; + case PROGRAM_LOCAL_PARAM: + sprintf(str, "program.local[%s%d]", addr, index); + break; + case PROGRAM_VARYING: /* extension */ + sprintf(str, "varying[%s%d]", addr, index); + break; + case PROGRAM_CONSTANT: /* extension */ + sprintf(str, "constant[%s%d]", addr, index); + break; + case PROGRAM_UNIFORM: /* extension */ + sprintf(str, "uniform[%s%d]", addr, index); + break; + case PROGRAM_STATE_VAR: + { + struct gl_program_parameter *param + = prog->Parameters->Parameters + index; + char *state = _mesa_program_state_string(param->StateIndexes); + sprintf(str, "%s", state); + free(state); + } + break; + case PROGRAM_ADDRESS: + sprintf(str, "A%d", index); + break; + default: + _mesa_problem(NULL, "bad file in reg_string()"); + } + break; +#else + assert(0); + break; +#endif + + case PROG_PRINT_NV: + switch (f) { + case PROGRAM_INPUT: + if (prog->Target == GL_VERTEX_PROGRAM_ARB) + sprintf(str, "v[%d]", index); + else + sprintf(str, "f[%d]", index); + break; + case PROGRAM_OUTPUT: + sprintf(str, "o[%d]", index); + break; + case PROGRAM_TEMPORARY: + sprintf(str, "R%d", index); + break; + case PROGRAM_ENV_PARAM: + sprintf(str, "c[%d]", index); + break; + case PROGRAM_VARYING: /* extension */ + sprintf(str, "varying[%s%d]", addr, index); + break; + case PROGRAM_UNIFORM: /* extension */ + sprintf(str, "uniform[%s%d]", addr, index); + break; + case PROGRAM_CONSTANT: /* extension */ + sprintf(str, "constant[%s%d]", addr, index); + break; + case PROGRAM_STATE_VAR: /* extension */ + sprintf(str, "state[%s%d]", addr, index); + break; + default: + _mesa_problem(NULL, "bad file in reg_string()"); + } + break; + + default: + _mesa_problem(NULL, "bad mode in reg_string()"); + } + + return str; +} + + +/** + * Return a string representation of the given swizzle word. + * If extended is true, use extended (comma-separated) format. + * \param swizzle the swizzle field + * \param negateBase 4-bit negation vector + * \param extended if true, also allow 0, 1 values + */ +const char * +_mesa_swizzle_string(GLuint swizzle, GLuint negateMask, GLboolean extended) +{ + static const char swz[] = "xyzw01!?"; /* See SWIZZLE_x definitions */ + static char s[20]; + GLuint i = 0; + + if (!extended && swizzle == SWIZZLE_NOOP && negateMask == 0) + return ""; /* no swizzle/negation */ + + if (!extended) + s[i++] = '.'; + + if (negateMask & NEGATE_X) + s[i++] = '-'; + s[i++] = swz[GET_SWZ(swizzle, 0)]; + + if (extended) { + s[i++] = ','; + } + + if (negateMask & NEGATE_Y) + s[i++] = '-'; + s[i++] = swz[GET_SWZ(swizzle, 1)]; + + if (extended) { + s[i++] = ','; + } + + if (negateMask & NEGATE_Z) + s[i++] = '-'; + s[i++] = swz[GET_SWZ(swizzle, 2)]; + + if (extended) { + s[i++] = ','; + } + + if (negateMask & NEGATE_W) + s[i++] = '-'; + s[i++] = swz[GET_SWZ(swizzle, 3)]; + + s[i] = 0; + return s; +} + + +void +_mesa_print_swizzle(GLuint swizzle) +{ + if (swizzle == SWIZZLE_XYZW) { + printf(".xyzw\n"); + } + else { + const char *s = _mesa_swizzle_string(swizzle, 0, 0); + printf("%s\n", s); + } +} + + +const char * +_mesa_writemask_string(GLuint writeMask) +{ + static char s[10]; + GLuint i = 0; + + if (writeMask == WRITEMASK_XYZW) + return ""; + + s[i++] = '.'; + if (writeMask & WRITEMASK_X) + s[i++] = 'x'; + if (writeMask & WRITEMASK_Y) + s[i++] = 'y'; + if (writeMask & WRITEMASK_Z) + s[i++] = 'z'; + if (writeMask & WRITEMASK_W) + s[i++] = 'w'; + + s[i] = 0; + return s; +} + + +const char * +_mesa_condcode_string(GLuint condcode) +{ + switch (condcode) { + case COND_GT: return "GT"; + case COND_EQ: return "EQ"; + case COND_LT: return "LT"; + case COND_UN: return "UN"; + case COND_GE: return "GE"; + case COND_LE: return "LE"; + case COND_NE: return "NE"; + case COND_TR: return "TR"; + case COND_FL: return "FL"; + default: return "cond???"; + } +} + + +static void +fprint_dst_reg(FILE * f, + const struct prog_dst_register *dstReg, + gl_prog_print_mode mode, + const struct gl_program *prog) +{ + fprintf(f, "%s%s", + reg_string((gl_register_file) dstReg->File, + dstReg->Index, mode, dstReg->RelAddr, prog), + _mesa_writemask_string(dstReg->WriteMask)); + + if (dstReg->CondMask != COND_TR) { + fprintf(f, " (%s.%s)", + _mesa_condcode_string(dstReg->CondMask), + _mesa_swizzle_string(dstReg->CondSwizzle, + GL_FALSE, GL_FALSE)); + } + +#if 0 + fprintf(f, "%s[%d]%s", + file_string((gl_register_file) dstReg->File, mode), + dstReg->Index, + _mesa_writemask_string(dstReg->WriteMask)); +#endif +} + + +static void +fprint_src_reg(FILE *f, + const struct prog_src_register *srcReg, + gl_prog_print_mode mode, + const struct gl_program *prog) +{ + const char *abs = srcReg->Abs ? "|" : ""; + + fprintf(f, "%s%s%s%s", + abs, + reg_string((gl_register_file) srcReg->File, + srcReg->Index, mode, srcReg->RelAddr, prog), + _mesa_swizzle_string(srcReg->Swizzle, + srcReg->Negate, GL_FALSE), + abs); +#if 0 + fprintf(f, "%s[%d]%s", + file_string((gl_register_file) srcReg->File, mode), + srcReg->Index, + _mesa_swizzle_string(srcReg->Swizzle, + srcReg->Negate, GL_FALSE)); +#endif +} + + +static void +fprint_comment(FILE *f, const struct prog_instruction *inst) +{ + if (inst->Comment) + fprintf(f, "; # %s\n", inst->Comment); + else + fprintf(f, ";\n"); +} + + +static void +fprint_alu_instruction(FILE *f, + const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs, + gl_prog_print_mode mode, + const struct gl_program *prog) +{ + GLuint j; + + fprintf(f, "%s", opcode_string); + if (inst->CondUpdate) + fprintf(f, ".C"); + + /* frag prog only */ + if (inst->SaturateMode == SATURATE_ZERO_ONE) + fprintf(f, "_SAT"); + + fprintf(f, " "); + if (inst->DstReg.File != PROGRAM_UNDEFINED) { + fprint_dst_reg(f, &inst->DstReg, mode, prog); + } + else { + fprintf(f, " ???"); + } + + if (numRegs > 0) + fprintf(f, ", "); + + for (j = 0; j < numRegs; j++) { + fprint_src_reg(f, inst->SrcReg + j, mode, prog); + if (j + 1 < numRegs) + fprintf(f, ", "); + } + + fprint_comment(f, inst); +} + + +void +_mesa_print_alu_instruction(const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs) +{ + fprint_alu_instruction(stderr, inst, opcode_string, + numRegs, PROG_PRINT_DEBUG, NULL); +} + + +/** + * Print a single vertex/fragment program instruction. + */ +GLint +_mesa_fprint_instruction_opt(FILE *f, + const struct prog_instruction *inst, + GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog) +{ + GLint i; + + if (inst->Opcode == OPCODE_ELSE || + inst->Opcode == OPCODE_ENDIF || + inst->Opcode == OPCODE_ENDLOOP || + inst->Opcode == OPCODE_ENDSUB) { + indent -= 3; + } + for (i = 0; i < indent; i++) { + fprintf(f, " "); + } + + switch (inst->Opcode) { + case OPCODE_PRINT: + fprintf(f, "PRINT '%s'", (char *) inst->Data); + if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { + fprintf(f, ", "); + fprintf(f, "%s[%d]%s", + file_string((gl_register_file) inst->SrcReg[0].File, + mode), + inst->SrcReg[0].Index, + _mesa_swizzle_string(inst->SrcReg[0].Swizzle, + inst->SrcReg[0].Negate, GL_FALSE)); + } + if (inst->Comment) + fprintf(f, " # %s", inst->Comment); + fprint_comment(f, inst); + break; + case OPCODE_SWZ: + fprintf(f, "SWZ"); + if (inst->SaturateMode == SATURATE_ZERO_ONE) + fprintf(f, "_SAT"); + fprintf(f, " "); + fprint_dst_reg(f, &inst->DstReg, mode, prog); + fprintf(f, ", %s[%d], %s", + file_string((gl_register_file) inst->SrcReg[0].File, + mode), + inst->SrcReg[0].Index, + _mesa_swizzle_string(inst->SrcReg[0].Swizzle, + inst->SrcReg[0].Negate, GL_TRUE)); + fprint_comment(f, inst); + break; + case OPCODE_TEX: + case OPCODE_TXP: + case OPCODE_TXL: + case OPCODE_TXB: + fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); + if (inst->SaturateMode == SATURATE_ZERO_ONE) + fprintf(f, "_SAT"); + fprintf(f, " "); + fprint_dst_reg(f, &inst->DstReg, mode, prog); + fprintf(f, ", "); + fprint_src_reg(f, &inst->SrcReg[0], mode, prog); + fprintf(f, ", texture[%d], ", inst->TexSrcUnit); + switch (inst->TexSrcTarget) { + case TEXTURE_1D_INDEX: fprintf(f, "1D"); break; + case TEXTURE_2D_INDEX: fprintf(f, "2D"); break; + case TEXTURE_3D_INDEX: fprintf(f, "3D"); break; + case TEXTURE_CUBE_INDEX: fprintf(f, "CUBE"); break; + case TEXTURE_RECT_INDEX: fprintf(f, "RECT"); break; + case TEXTURE_1D_ARRAY_INDEX: fprintf(f, "1D_ARRAY"); break; + case TEXTURE_2D_ARRAY_INDEX: fprintf(f, "2D_ARRAY"); break; + default: + ; + } + if (inst->TexShadow) + fprintf(f, " SHADOW"); + fprint_comment(f, inst); + break; + + case OPCODE_KIL: + fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); + fprintf(f, " "); + fprint_src_reg(f, &inst->SrcReg[0], mode, prog); + fprint_comment(f, inst); + break; + case OPCODE_KIL_NV: + fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); + fprintf(f, " "); + fprintf(f, "%s.%s", + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, + GL_FALSE, GL_FALSE)); + fprint_comment(f, inst); + break; + + case OPCODE_ARL: + fprintf(f, "ARL "); + fprint_dst_reg(f, &inst->DstReg, mode, prog); + fprintf(f, ", "); + fprint_src_reg(f, &inst->SrcReg[0], mode, prog); + fprint_comment(f, inst); + break; + case OPCODE_BRA: + fprintf(f, "BRA %d (%s%s)", + inst->BranchTarget, + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); + fprint_comment(f, inst); + break; + case OPCODE_IF: + if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { + /* Use ordinary register */ + fprintf(f, "IF "); + fprint_src_reg(f, &inst->SrcReg[0], mode, prog); + fprintf(f, "; "); + } + else { + /* Use cond codes */ + fprintf(f, "IF (%s%s);", + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, + 0, GL_FALSE)); + } + fprintf(f, " # (if false, goto %d)", inst->BranchTarget); + fprint_comment(f, inst); + return indent + 3; + case OPCODE_ELSE: + fprintf(f, "ELSE; # (goto %d)\n", inst->BranchTarget); + return indent + 3; + case OPCODE_ENDIF: + fprintf(f, "ENDIF;\n"); + break; + case OPCODE_BGNLOOP: + fprintf(f, "BGNLOOP; # (end at %d)\n", inst->BranchTarget); + return indent + 3; + case OPCODE_ENDLOOP: + fprintf(f, "ENDLOOP; # (goto %d)\n", inst->BranchTarget); + break; + case OPCODE_BRK: + case OPCODE_CONT: + fprintf(f, "%s (%s%s); # (goto %d)", + _mesa_opcode_string(inst->Opcode), + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), + inst->BranchTarget); + fprint_comment(f, inst); + break; + + case OPCODE_BGNSUB: + if (mode == PROG_PRINT_NV) { + fprintf(f, "%s:\n", inst->Comment); /* comment is label */ + return indent; + } + else { + fprintf(f, "BGNSUB"); + fprint_comment(f, inst); + return indent + 3; + } + case OPCODE_ENDSUB: + if (mode == PROG_PRINT_DEBUG) { + fprintf(f, "ENDSUB"); + fprint_comment(f, inst); + } + break; + case OPCODE_CAL: + if (mode == PROG_PRINT_NV) { + fprintf(f, "CAL %s; # (goto %d)\n", inst->Comment, inst->BranchTarget); + } + else { + fprintf(f, "CAL %u", inst->BranchTarget); + fprint_comment(f, inst); + } + break; + case OPCODE_RET: + fprintf(f, "RET (%s%s)", + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); + fprint_comment(f, inst); + break; + + case OPCODE_END: + fprintf(f, "END\n"); + break; + case OPCODE_NOP: + if (mode == PROG_PRINT_DEBUG) { + fprintf(f, "NOP"); + fprint_comment(f, inst); + } + else if (inst->Comment) { + /* ARB/NV extensions don't have NOP instruction */ + fprintf(f, "# %s\n", inst->Comment); + } + break; + /* XXX may need other special-case instructions */ + default: + if (inst->Opcode < MAX_OPCODE) { + /* typical alu instruction */ + fprint_alu_instruction(f, inst, + _mesa_opcode_string(inst->Opcode), + _mesa_num_inst_src_regs(inst->Opcode), + mode, prog); + } + else { + fprint_alu_instruction(f, inst, + _mesa_opcode_string(inst->Opcode), + 3/*_mesa_num_inst_src_regs(inst->Opcode)*/, + mode, prog); + } + break; + } + return indent; +} + + +GLint +_mesa_print_instruction_opt(const struct prog_instruction *inst, + GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog) +{ + return _mesa_fprint_instruction_opt(stderr, inst, indent, mode, prog); +} + + +void +_mesa_print_instruction(const struct prog_instruction *inst) +{ + /* note: 4th param should be ignored for PROG_PRINT_DEBUG */ + _mesa_fprint_instruction_opt(stdout, inst, 0, PROG_PRINT_DEBUG, NULL); +} + +#if 0 +/** + * Print program, with options. + */ +void +_mesa_fprint_program_opt(FILE *f, + const struct gl_program *prog, + gl_prog_print_mode mode, + GLboolean lineNumbers) +{ + GLuint i, indent = 0; + + switch (prog->Target) { + case GL_VERTEX_PROGRAM_ARB: + if (mode == PROG_PRINT_ARB) + fprintf(f, "!!ARBvp1.0\n"); + else if (mode == PROG_PRINT_NV) + fprintf(f, "!!VP1.0\n"); + else + fprintf(f, "# Vertex Program/Shader %u\n", prog->Id); + break; + case GL_FRAGMENT_PROGRAM_ARB: + case GL_FRAGMENT_PROGRAM_NV: + if (mode == PROG_PRINT_ARB) + fprintf(f, "!!ARBfp1.0\n"); + else if (mode == PROG_PRINT_NV) + fprintf(f, "!!FP1.0\n"); + else + fprintf(f, "# Fragment Program/Shader %u\n", prog->Id); + break; + } + + for (i = 0; i < prog->NumInstructions; i++) { + if (lineNumbers) + fprintf(f, "%3d: ", i); + indent = _mesa_fprint_instruction_opt(f, prog->Instructions + i, + indent, mode, prog); + } +} + + +/** + * Print program to stderr, default options. + */ +void +_mesa_print_program(const struct gl_program *prog) +{ + _mesa_fprint_program_opt(stderr, prog, PROG_PRINT_DEBUG, GL_TRUE); +} + +/** + * Return binary representation of 64-bit value (as a string). + * Insert a comma to separate each group of 8 bits. + * Note we return a pointer to local static storage so this is not + * re-entrant, etc. + * XXX move to imports.[ch] if useful elsewhere. + */ +static const char * +binary(GLbitfield64 val) +{ + static char buf[80]; + GLint i, len = 0; + for (i = 63; i >= 0; --i) { + if (val & (1ULL << i)) + buf[len++] = '1'; + else if (len > 0 || i == 0) + buf[len++] = '0'; + if (len > 0 && ((i-1) % 8) == 7) + buf[len++] = ','; + } + buf[len] = '\0'; + return buf; +} + + +/** + * Print all of a program's parameters/fields to given file. + */ +static void +_mesa_fprint_program_parameters(FILE *f, + GLcontext *ctx, + const struct gl_program *prog) +{ + GLuint i; + + fprintf(f, "InputsRead: 0x%x (0b%s)\n", + prog->InputsRead, binary(prog->InputsRead)); + fprintf(f, "OutputsWritten: 0x%llx (0b%s)\n", + prog->OutputsWritten, binary(prog->OutputsWritten)); + fprintf(f, "NumInstructions=%d\n", prog->NumInstructions); + fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries); + fprintf(f, "NumParameters=%d\n", prog->NumParameters); + fprintf(f, "NumAttributes=%d\n", prog->NumAttributes); + fprintf(f, "NumAddressRegs=%d\n", prog->NumAddressRegs); + fprintf(f, "SamplersUsed: 0x%x (0b%s)\n", + prog->SamplersUsed, binary(prog->SamplersUsed)); + fprintf(f, "Samplers=[ "); + for (i = 0; i < MAX_SAMPLERS; i++) { + fprintf(f, "%d ", prog->SamplerUnits[i]); + } + fprintf(f, "]\n"); + + _mesa_load_state_parameters(ctx, prog->Parameters); + +#if 0 + fprintf(f, "Local Params:\n"); + for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){ + const GLfloat *p = prog->LocalParams[i]; + fprintf(f, "%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]); + } +#endif + _mesa_print_parameter_list(prog->Parameters); +} + + +/** + * Print all of a program's parameters/fields to stderr. + */ +void +_mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog) +{ + _mesa_fprint_program_parameters(stderr, ctx, prog); +} + + +/** + * Print a program parameter list to given file. + */ +static void +_mesa_fprint_parameter_list(FILE *f, + const struct gl_program_parameter_list *list) +{ + const gl_prog_print_mode mode = PROG_PRINT_DEBUG; + GLuint i; + + if (!list) + return; + + if (0) + fprintf(f, "param list %p\n", (void *) list); + fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags); + for (i = 0; i < list->NumParameters; i++){ + struct gl_program_parameter *param = list->Parameters + i; + const GLfloat *v = list->ParameterValues[i]; + fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", + i, param->Size, + file_string(list->Parameters[i].Type, mode), + param->Name, v[0], v[1], v[2], v[3]); + if (param->Flags & PROG_PARAM_BIT_CENTROID) + fprintf(f, " Centroid"); + if (param->Flags & PROG_PARAM_BIT_INVARIANT) + fprintf(f, " Invariant"); + if (param->Flags & PROG_PARAM_BIT_FLAT) + fprintf(f, " Flat"); + if (param->Flags & PROG_PARAM_BIT_LINEAR) + fprintf(f, " Linear"); + fprintf(f, "\n"); + } +} + + +/** + * Print a program parameter list to stderr. + */ +void +_mesa_print_parameter_list(const struct gl_program_parameter_list *list) +{ + _mesa_fprint_parameter_list(stderr, list); +} + + +/** + * Write shader and associated info to a file. + */ +void +_mesa_write_shader_to_file(const struct gl_shader *shader) +{ + const char *type; + char filename[100]; + FILE *f; + + if (shader->Type == GL_FRAGMENT_SHADER) + type = "frag"; + else + type = "vert"; + + snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + f = fopen(filename, "w"); + if (!f) { + fprintf(stderr, "Unable to open %s for writing\n", filename); + return; + } + + fprintf(f, "/* Shader %u source, checksum %u */\n", shader->Name, shader->SourceChecksum); + fputs(shader->Source, f); + fprintf(f, "\n"); + + fprintf(f, "/* Compile status: %s */\n", + shader->CompileStatus ? "ok" : "fail"); + if (!shader->CompileStatus) { + fprintf(f, "/* Log Info: */\n"); + fputs(shader->InfoLog, f); + } + else { + fprintf(f, "/* GPU code */\n"); + fprintf(f, "/*\n"); + _mesa_fprint_program_opt(f, shader->Program, PROG_PRINT_DEBUG, GL_TRUE); + fprintf(f, "*/\n"); + fprintf(f, "/* Parameters / constants */\n"); + fprintf(f, "/*\n"); + _mesa_fprint_parameter_list(f, shader->Program->Parameters); + fprintf(f, "*/\n"); + } + + fclose(f); +} + + +/** + * Append the shader's uniform info/values to the shader log file. + * The log file will typically have been created by the + * _mesa_write_shader_to_file function. + */ +void +_mesa_append_uniforms_to_file(const struct gl_shader *shader, + const struct gl_program *prog) +{ + const char *type; + char filename[100]; + FILE *f; + + if (shader->Type == GL_FRAGMENT_SHADER) + type = "frag"; + else + type = "vert"; + + snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + f = fopen(filename, "a"); /* append */ + if (!f) { + fprintf(stderr, "Unable to open %s for appending\n", filename); + return; + } + + fprintf(f, "/* First-draw parameters / constants */\n"); + fprintf(f, "/*\n"); + _mesa_fprint_parameter_list(f, prog->Parameters); + fprintf(f, "*/\n"); + + fclose(f); +} +#endif diff --git a/src/glsl/mesa/shader/prog_print.h b/src/glsl/mesa/shader/prog_print.h new file mode 100644 index 00000000000..f0df77b5129 --- /dev/null +++ b/src/glsl/mesa/shader/prog_print.h @@ -0,0 +1,98 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef PROG_PRINT_H +#define PROG_PRINT_H + + +/** + * The output style to use when printing programs. + */ +typedef enum { + PROG_PRINT_ARB, + PROG_PRINT_NV, + PROG_PRINT_DEBUG +} gl_prog_print_mode; + + +extern void +_mesa_print_vp_inputs(GLbitfield inputs); + +extern void +_mesa_print_fp_inputs(GLbitfield inputs); + +extern const char * +_mesa_condcode_string(GLuint condcode); + +extern const char * +_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended); + +const char * +_mesa_writemask_string(GLuint writeMask); + +extern void +_mesa_print_swizzle(GLuint swizzle); + +extern void +_mesa_print_alu_instruction(const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs); + +extern void +_mesa_print_instruction(const struct prog_instruction *inst); + +extern GLint +_mesa_fprint_instruction_opt(FILE *f, + const struct prog_instruction *inst, + GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog); + +extern GLint +_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog); + +extern void +_mesa_print_program(const struct gl_program *prog); + +extern void +_mesa_fprint_program_opt(FILE *f, + const struct gl_program *prog, gl_prog_print_mode mode, + GLboolean lineNumbers); + +#if 0 +extern void +_mesa_print_parameter_list(const struct gl_program_parameter_list *list); + +extern void +_mesa_write_shader_to_file(const struct gl_shader *shader); + +extern void +_mesa_append_uniforms_to_file(const struct gl_shader *shader, + const struct gl_program *prog); +#endif + + +#endif /* PROG_PRINT_H */ diff --git a/src/glsl/program.h b/src/glsl/program.h new file mode 100644 index 00000000000..d21b04344cd --- /dev/null +++ b/src/glsl/program.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include "main/mtypes.h" + +/** + * Based on gl_shader in Mesa's mtypes.h. + */ +struct glsl_shader { + GLenum Type; + GLuint Name; + GLint RefCount; + GLboolean DeletePending; + GLboolean CompileStatus; + const GLchar *Source; /**< Source code string */ + size_t SourceLen; + GLchar *InfoLog; + + struct exec_list ir; + struct glsl_symbol_table *symbols; +}; + + +typedef int gl_state_index; +#define STATE_LENGTH 5 + +/** + * Program parameter. + * Used by shaders/programs for uniforms, constants, varying vars, etc. + */ +struct gl_program_parameter +{ + const char *Name; /**< Null-terminated string */ + gl_register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */ + GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ + /** + * Number of components (1..4), or more. + * If the number of components is greater than 4, + * this parameter is part of a larger uniform like a GLSL matrix or array. + * The next program parameter's Size will be Size-4 of this parameter. + */ + GLuint Size; + GLboolean Used; /**< Helper flag for GLSL uniform tracking */ + GLboolean Initialized; /**< Has the ParameterValue[] been set? */ + GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ + /** + * A sequence of STATE_* tokens and integers to identify GL state. + */ + gl_state_index StateIndexes[STATE_LENGTH]; +}; + + +/** + * List of gl_program_parameter instances. + */ +struct gl_program_parameter_list +{ + GLuint Size; /**< allocated size of Parameters, ParameterValues */ + GLuint NumParameters; /**< number of parameters in arrays */ + struct gl_program_parameter *Parameters; /**< Array [Size] */ + GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */ + GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes + might invalidate ParameterValues[] */ +}; + + +/** + * Shader program uniform variable. + * The glGetUniformLocation() and glUniform() commands will use this + * information. + * Note that a uniform such as "binormal" might be used in both the + * vertex shader and the fragment shader. When glUniform() is called to + * set the uniform's value, it must be updated in both the vertex and + * fragment shaders. The uniform may be in different locations in the + * two shaders so we keep track of that here. + */ +struct gl_uniform +{ + const char *Name; /**< Null-terminated string */ + GLint VertPos; + GLint FragPos; + GLboolean Initialized; /**< For debug. Has this uniform been set? */ +#if 0 + GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ + GLuint Size; /**< Number of components (1..4) */ +#endif +}; + + +/** + * List of gl_uniforms + */ +struct gl_uniform_list +{ + GLuint Size; /**< allocated size of Uniforms array */ + GLuint NumUniforms; /**< number of uniforms in the array */ + struct gl_uniform *Uniforms; /**< Array [Size] */ +}; + + +/** + * Based on gl_shader_program in Mesa's mtypes.h. + */ +struct glsl_program { + GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ + GLuint Name; /**< aka handle or ID */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; + + GLuint NumShaders; /**< number of attached shaders */ + struct glsl_shader **Shaders; /**< List of attached the shaders */ + + /** + * Per-stage shaders resulting from the first stage of linking. + */ + /*@{*/ + unsigned _NumLinkedShaders; + struct glsl_shader **_LinkedShaders; + /*@}*/ + + /** User-defined attribute bindings (glBindAttribLocation) */ + struct gl_program_parameter_list *Attributes; + + /* post-link info: */ + struct gl_uniform_list *Uniforms; + struct gl_program_parameter_list *Varying; + GLboolean LinkStatus; /**< GL_LINK_STATUS */ + GLboolean Validated; + GLboolean _Used; /**< Ever used for drawing? */ + GLchar *InfoLog; +}; + +extern void +link_shaders(struct glsl_program *prog); diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp new file mode 100644 index 00000000000..26be23ea8fa --- /dev/null +++ b/src/glsl/s_expression.cpp @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include "s_expression.h" + +s_symbol::s_symbol(const char *tmp) +{ + this->str = talloc_strdup (this, tmp); + assert(this->str != NULL); +} + +s_list::s_list() +{ +} + +unsigned +s_list::length() const +{ + unsigned i = 0; + foreach_iter(exec_list_iterator, it, this->subexpressions) { + i++; + } + return i; +} + +static s_expression * +read_atom(void *ctx, const char *& src) +{ + char buf[101]; + int n; + if (sscanf(src, " %100[^( \v\t\r\n)]%n", buf, &n) != 1) + return NULL; // no atom + src += n; + + // Check if the atom is a number. + char *float_end = NULL; + double f = strtod(buf, &float_end); + if (float_end != buf) { + char *int_end = NULL; + int i = strtol(buf, &int_end, 10); + // If strtod matched more characters, it must have a decimal part + if (float_end > int_end) + return new(ctx) s_float(f); + + return new(ctx) s_int(i); + } + // Not a number; return a symbol. + return new(ctx) s_symbol(buf); +} + +s_expression * +s_expression::read_expression(void *ctx, const char *&src) +{ + assert(src != NULL); + + s_expression *atom = read_atom(ctx, src); + if (atom != NULL) + return atom; + + char c; + int n; + if (sscanf(src, " %c%n", &c, &n) == 1 && c == '(') { + src += n; + + s_list *list = new(ctx) s_list; + s_expression *expr; + + while ((expr = read_expression(ctx, src)) != NULL) { + list->subexpressions.push_tail(expr); + } + if (sscanf(src, " %c%n", &c, &n) != 1 || c != ')') { + printf("Unclosed expression (check your parenthesis).\n"); + return NULL; + } + src += n; + return list; + } + return NULL; +} + +void s_int::print() +{ + printf("%d", this->val); +} + +void s_float::print() +{ + printf("%f", this->val); +} + +void s_symbol::print() +{ + printf("%s", this->str); +} + +void s_list::print() +{ + printf("("); + foreach_iter(exec_list_iterator, it, this->subexpressions) { + s_expression *expr = (s_expression*) it.get(); + expr->print(); + printf(" "); + } + printf(")"); +} + diff --git a/src/glsl/s_expression.h b/src/glsl/s_expression.h new file mode 100644 index 00000000000..1a0c03c2189 --- /dev/null +++ b/src/glsl/s_expression.h @@ -0,0 +1,142 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef S_EXPRESSION_H +#define S_EXPRESSION_H + +#include "list.h" + +#define SX_AS_(t,x) ((x) && ((s_expression*) x)->is_##t()) ? ((s_##t*) (x)) \ + : NULL +#define SX_AS_LIST(x) SX_AS_(list, x) +#define SX_AS_SYMBOL(x) SX_AS_(symbol, x) +#define SX_AS_NUMBER(x) SX_AS_(number, x) +#define SX_AS_INT(x) SX_AS_(int, x) + +/* For our purposes, S-Expressions are: + * - + * - + * - symbol + * - (expr1 expr2 ... exprN) where exprN is an S-Expression + * + * Unlike LISP/Scheme, we do not support (foo . bar) pairs. + */ +class s_expression : public exec_node +{ +public: + /** + * Read an S-Expression from the given string. + * Advances the supplied pointer to just after the expression read. + * + * Any allocation will be performed with 'ctx' as the talloc owner. + */ + static s_expression *read_expression(void *ctx, const char *&src); + + /** + * Print out an S-Expression. Useful for debugging. + */ + virtual void print() = 0; + + virtual bool is_list() const { return false; } + virtual bool is_symbol() const { return false; } + virtual bool is_number() const { return false; } + virtual bool is_int() const { return false; } + +protected: + s_expression() { } +}; + +/* Atoms */ + +class s_number : public s_expression +{ +public: + bool is_number() const { return true; } + + virtual float fvalue() = 0; + +protected: + s_number() { } +}; + +class s_int : public s_number +{ +public: + s_int(int x) : val(x) { } + + bool is_int() const { return true; } + + float fvalue() { return float(this->val); } + int value() { return this->val; } + + void print(); + +private: + int val; +}; + +class s_float : public s_number +{ +public: + s_float(float x) : val(x) { } + + float fvalue() { return this->val; } + + void print(); + +private: + float val; +}; + +class s_symbol : public s_expression +{ +public: + s_symbol(const char *); + + bool is_symbol() const { return true; } + + const char *value() { return this->str; } + + void print(); + +private: + char *str; +}; + +/* Lists of expressions: (expr1 ... exprN) */ +class s_list : public s_expression +{ +public: + s_list(); + + virtual bool is_list() const { return true; } + unsigned length() const; + + void print(); + + exec_list subexpressions; +}; + +#endif /* S_EXPRESSION_H */ diff --git a/src/glsl/symbol_table.c b/src/glsl/symbol_table.c new file mode 100644 index 00000000000..0f0df7a261b --- /dev/null +++ b/src/glsl/symbol_table.c @@ -0,0 +1,413 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "main/imports.h" +#include "symbol_table.h" +#include "hash_table.h" + +struct symbol { + /** + * Link to the next symbol in the table with the same name + * + * The linked list of symbols with the same name is ordered by scope + * from inner-most to outer-most. + */ + struct symbol *next_with_same_name; + + + /** + * Link to the next symbol in the table with the same scope + * + * The linked list of symbols with the same scope is unordered. Symbols + * in this list my have unique names. + */ + struct symbol *next_with_same_scope; + + + /** + * Header information for the list of symbols with the same name. + */ + struct symbol_header *hdr; + + + /** + * Name space of the symbol + * + * Name space are arbitrary user assigned integers. No two symbols can + * exist in the same name space at the same scope level. + */ + int name_space; + + + /** + * Arbitrary user supplied data. + */ + void *data; + + /** Scope depth where this symbol was defined. */ + unsigned depth; +}; + + +/** + */ +struct symbol_header { + /** Linkage in list of all headers in a given symbol table. */ + struct symbol_header *next; + + /** Symbol name. */ + const char *name; + + /** Linked list of symbols with the same name. */ + struct symbol *symbols; +}; + + +/** + * Element of the scope stack. + */ +struct scope_level { + /** Link to next (inner) scope level. */ + struct scope_level *next; + + /** Linked list of symbols with the same scope. */ + struct symbol *symbols; +}; + + +/** + * + */ +struct _mesa_symbol_table { + /** Hash table containing all symbols in the symbol table. */ + struct hash_table *ht; + + /** Top of scope stack. */ + struct scope_level *current_scope; + + /** List of all symbol headers in the table. */ + struct symbol_header *hdr; + + /** Current scope depth. */ + unsigned depth; +}; + + +struct _mesa_symbol_table_iterator { + /** + * Name space of symbols returned by this iterator. + */ + int name_space; + + + /** + * Currently iterated symbol + * + * The next call to \c _mesa_symbol_table_iterator_get will return this + * value. It will also update this value to the value that should be + * returned by the next call. + */ + struct symbol *curr; +}; + + +static void +check_symbol_table(struct _mesa_symbol_table *table) +{ +#if 1 + struct scope_level *scope; + + for (scope = table->current_scope; scope != NULL; scope = scope->next) { + struct symbol *sym; + + for (sym = scope->symbols + ; sym != NULL + ; sym = sym->next_with_same_name) { + const struct symbol_header *const hdr = sym->hdr; + struct symbol *sym2; + + for (sym2 = hdr->symbols + ; sym2 != NULL + ; sym2 = sym2->next_with_same_name) { + assert(sym2->hdr == hdr); + } + } + } +#endif +} + +void +_mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table) +{ + struct scope_level *const scope = table->current_scope; + struct symbol *sym = scope->symbols; + + table->current_scope = scope->next; + table->depth--; + + free(scope); + + while (sym != NULL) { + struct symbol *const next = sym->next_with_same_scope; + struct symbol_header *const hdr = sym->hdr; + + assert(hdr->symbols == sym); + + hdr->symbols = sym->next_with_same_name; + + free(sym); + + sym = next; + } + + check_symbol_table(table); +} + + +void +_mesa_symbol_table_push_scope(struct _mesa_symbol_table *table) +{ + struct scope_level *const scope = calloc(1, sizeof(*scope)); + + scope->next = table->current_scope; + table->current_scope = scope; + table->depth++; +} + + +static struct symbol_header * +find_symbol(struct _mesa_symbol_table *table, const char *name) +{ + return (struct symbol_header *) hash_table_find(table->ht, name); +} + + +struct _mesa_symbol_table_iterator * +_mesa_symbol_table_iterator_ctor(struct _mesa_symbol_table *table, + int name_space, const char *name) +{ + struct _mesa_symbol_table_iterator *iter = calloc(1, sizeof(*iter)); + struct symbol_header *const hdr = find_symbol(table, name); + + iter->name_space = name_space; + + if (hdr != NULL) { + struct symbol *sym; + + for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { + assert(sym->hdr == hdr); + + if ((name_space == -1) || (sym->name_space == name_space)) { + iter->curr = sym; + break; + } + } + } + + return iter; +} + + +void +_mesa_symbol_table_iterator_dtor(struct _mesa_symbol_table_iterator *iter) +{ + free(iter); +} + + +void * +_mesa_symbol_table_iterator_get(struct _mesa_symbol_table_iterator *iter) +{ + return (iter->curr == NULL) ? NULL : iter->curr->data; +} + + +int +_mesa_symbol_table_iterator_next(struct _mesa_symbol_table_iterator *iter) +{ + struct symbol_header *hdr; + + if (iter->curr == NULL) { + return 0; + } + + hdr = iter->curr->hdr; + iter->curr = iter->curr->next_with_same_name; + + while (iter->curr != NULL) { + assert(iter->curr->hdr == hdr); + + if ((iter->name_space == -1) + || (iter->curr->name_space == iter->name_space)) { + return 1; + } + + iter->curr = iter->curr->next_with_same_name; + } + + return 0; +} + + +/** + * Determine the scope "distance" of a symbol from the current scope + * + * \return + * A non-negative number for the number of scopes between the current scope + * and the scope where a symbol was defined. A value of zero means the current + * scope. A negative number if the symbol does not exist. + */ +int +_mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, + int name_space, const char *name) +{ + struct symbol_header *const hdr = find_symbol(table, name); + struct symbol *sym; + + if (hdr != NULL) { + for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { + assert(sym->hdr == hdr); + + if ((name_space == -1) || (sym->name_space == name_space)) { + assert(sym->depth <= table->depth); + return sym->depth - table->depth; + } + } + } + + return -1; +} + + +void * +_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table, + int name_space, const char *name) +{ + struct symbol_header *const hdr = find_symbol(table, name); + + if (hdr != NULL) { + struct symbol *sym; + + + for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { + assert(sym->hdr == hdr); + + if ((name_space == -1) || (sym->name_space == name_space)) { + return sym->data; + } + } + } + + return NULL; +} + + +int +_mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, + int name_space, const char *name, + void *declaration) +{ + struct symbol_header *hdr; + struct symbol *sym; + + check_symbol_table(table); + + hdr = find_symbol(table, name); + + check_symbol_table(table); + + if (hdr == NULL) { + hdr = calloc(1, sizeof(*hdr)); + hdr->name = name; + + hash_table_insert(table->ht, hdr, name); + hdr->next = table->hdr; + table->hdr = hdr; + } + + check_symbol_table(table); + + /* If the symbol already exists in this namespace at this scope, it cannot + * be added to the table. + */ + for (sym = hdr->symbols + ; (sym != NULL) && (sym->name_space != name_space) + ; sym = sym->next_with_same_name) { + /* empty */ + } + + if (sym && (sym->depth == table->depth)) + return -1; + + sym = calloc(1, sizeof(*sym)); + sym->next_with_same_name = hdr->symbols; + sym->next_with_same_scope = table->current_scope->symbols; + sym->hdr = hdr; + sym->name_space = name_space; + sym->data = declaration; + sym->depth = table->depth; + + assert(sym->hdr == hdr); + + hdr->symbols = sym; + table->current_scope->symbols = sym; + + check_symbol_table(table); + return 0; +} + + +struct _mesa_symbol_table * +_mesa_symbol_table_ctor(void) +{ + struct _mesa_symbol_table *table = calloc(1, sizeof(*table)); + + if (table != NULL) { + table->ht = hash_table_ctor(32, hash_table_string_hash, + hash_table_string_compare); + + _mesa_symbol_table_push_scope(table); + } + + return table; +} + + +void +_mesa_symbol_table_dtor(struct _mesa_symbol_table *table) +{ + struct symbol_header *hdr; + struct symbol_header *next; + + while (table->current_scope != NULL) { + _mesa_symbol_table_pop_scope(table); + } + + for (hdr = table->hdr; hdr != NULL; hdr = next) { + next = hdr->next; + _mesa_free(hdr); + } + + hash_table_dtor(table->ht); + free(table); +} diff --git a/src/glsl/symbol_table.h b/src/glsl/symbol_table.h new file mode 100644 index 00000000000..3a9994c1ac9 --- /dev/null +++ b/src/glsl/symbol_table.h @@ -0,0 +1,66 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#ifndef MESA_SYMBOL_TABLE_H +#define MESA_SYMBOL_TABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct _mesa_symbol_table; +struct _mesa_symbol_table_iterator; + +extern void _mesa_symbol_table_push_scope(struct _mesa_symbol_table *table); + +extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table); + +extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, + int name_space, const char *name, void *declaration); + +extern int _mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, + int name_space, const char *name); + +extern void *_mesa_symbol_table_find_symbol( + struct _mesa_symbol_table *symtab, int name_space, const char *name); + +extern struct _mesa_symbol_table *_mesa_symbol_table_ctor(void); + +extern void _mesa_symbol_table_dtor(struct _mesa_symbol_table *); + +extern struct _mesa_symbol_table_iterator *_mesa_symbol_table_iterator_ctor( + struct _mesa_symbol_table *table, int name_space, const char *name); + +extern void _mesa_symbol_table_iterator_dtor( + struct _mesa_symbol_table_iterator *); + +extern void *_mesa_symbol_table_iterator_get( + struct _mesa_symbol_table_iterator *iter); + +extern int _mesa_symbol_table_iterator_next( + struct _mesa_symbol_table_iterator *iter); + +#ifdef __cplusplus +} +#endif + +#endif /* MESA_SYMBOL_TABLE_H */ diff --git a/src/glsl/tests/array-01.glsl b/src/glsl/tests/array-01.glsl new file mode 100644 index 00000000000..d14135fb3a8 --- /dev/null +++ b/src/glsl/tests/array-01.glsl @@ -0,0 +1,3 @@ +#version 120 +/* FAIL - array size type must be int */ +uniform vec4 [3.2] a; diff --git a/src/glsl/tests/array-02.glsl b/src/glsl/tests/array-02.glsl new file mode 100644 index 00000000000..d743617158d --- /dev/null +++ b/src/glsl/tests/array-02.glsl @@ -0,0 +1,3 @@ +#version 120 +/* FAIL - array size type must be scalar */ +uniform vec4 [ivec4(3)] a; diff --git a/src/glsl/tests/array-03.glsl b/src/glsl/tests/array-03.glsl new file mode 100644 index 00000000000..0026913f019 --- /dev/null +++ b/src/glsl/tests/array-03.glsl @@ -0,0 +1,3 @@ +#version 120 +/* PASS */ +uniform vec4 [3] a; diff --git a/src/glsl/tests/array-04.glsl b/src/glsl/tests/array-04.glsl new file mode 100644 index 00000000000..70f434d8ab6 --- /dev/null +++ b/src/glsl/tests/array-04.glsl @@ -0,0 +1,2 @@ +/* FAIL - array size type must be int */ +uniform vec4 a[3.2]; diff --git a/src/glsl/tests/array-05.glsl b/src/glsl/tests/array-05.glsl new file mode 100644 index 00000000000..168704096b0 --- /dev/null +++ b/src/glsl/tests/array-05.glsl @@ -0,0 +1,2 @@ +/* FAIL - array size type must be scalar */ +uniform vec4 a[ivec4(3)]; diff --git a/src/glsl/tests/array-06.glsl b/src/glsl/tests/array-06.glsl new file mode 100644 index 00000000000..46b43795be1 --- /dev/null +++ b/src/glsl/tests/array-06.glsl @@ -0,0 +1,2 @@ +/* PASS */ +uniform vec4 a[3]; diff --git a/src/glsl/tests/array-07.glsl b/src/glsl/tests/array-07.glsl new file mode 100644 index 00000000000..161ffbf2f2e --- /dev/null +++ b/src/glsl/tests/array-07.glsl @@ -0,0 +1,2 @@ +/* FAIL - array size must be > 0 */ +uniform vec4 a[0]; diff --git a/src/glsl/tests/array-08.glsl b/src/glsl/tests/array-08.glsl new file mode 100644 index 00000000000..4bf0c6bd513 --- /dev/null +++ b/src/glsl/tests/array-08.glsl @@ -0,0 +1,2 @@ +/* FAIL - array size must be > 0 */ +uniform vec4 a[-1]; diff --git a/src/glsl/tests/array-09.glsl b/src/glsl/tests/array-09.glsl new file mode 100644 index 00000000000..cad6d0e54ec --- /dev/null +++ b/src/glsl/tests/array-09.glsl @@ -0,0 +1,9 @@ +#version 120 +/* PASS */ + +void main() +{ + vec4 a[2] = vec4 [2] (vec4(1.0), vec4(2.0)); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/array-10.glsl b/src/glsl/tests/array-10.glsl new file mode 100644 index 00000000000..019aa21150f --- /dev/null +++ b/src/glsl/tests/array-10.glsl @@ -0,0 +1,11 @@ +/* FAIL - array constructors forbidden in GLSL 1.10 + * + * This can also generate an error because the 'vec4[]' style syntax is + * illegal in GLSL 1.10. + */ +void main() +{ + vec4 a[2] = vec4 [2] (vec4(1.0), vec4(2.0)); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/array-11.glsl b/src/glsl/tests/array-11.glsl new file mode 100644 index 00000000000..51d94e94773 --- /dev/null +++ b/src/glsl/tests/array-11.glsl @@ -0,0 +1,9 @@ +#version 120 +/* PASS */ + +void main() +{ + vec4 a[] = vec4 [] (vec4(1.0), vec4(2.0)); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/array-12.glsl b/src/glsl/tests/array-12.glsl new file mode 100644 index 00000000000..7fc9579452f --- /dev/null +++ b/src/glsl/tests/array-12.glsl @@ -0,0 +1,11 @@ +#version 120 +/* FAIL - array must have an implicit or explicit size */ + +void main() +{ + vec4 a[]; + + a = vec4 [2] (vec4(1.0), vec4(2.0)); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/array-13.glsl b/src/glsl/tests/array-13.glsl new file mode 100644 index 00000000000..cc7e29a5f76 --- /dev/null +++ b/src/glsl/tests/array-13.glsl @@ -0,0 +1,11 @@ +#version 120 +/* PASS */ + +void main() +{ + vec4 a[2]; + + a = vec4 [] (vec4(1.0), vec4(2.0)); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/attribute-01.glsl b/src/glsl/tests/attribute-01.glsl new file mode 100644 index 00000000000..18e9e4468aa --- /dev/null +++ b/src/glsl/tests/attribute-01.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type int */ +attribute int i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/attribute-02.glsl b/src/glsl/tests/attribute-02.glsl new file mode 100644 index 00000000000..6b6df74d252 --- /dev/null +++ b/src/glsl/tests/attribute-02.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type ivec2 */ +attribute ivec2 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/attribute-03.glsl b/src/glsl/tests/attribute-03.glsl new file mode 100644 index 00000000000..870de9e8148 --- /dev/null +++ b/src/glsl/tests/attribute-03.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type ivec3 */ +attribute ivec3 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/attribute-04.glsl b/src/glsl/tests/attribute-04.glsl new file mode 100644 index 00000000000..14af2fcaadd --- /dev/null +++ b/src/glsl/tests/attribute-04.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type ivec4 */ +attribute ivec4 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/attribute-05.glsl b/src/glsl/tests/attribute-05.glsl new file mode 100644 index 00000000000..18822c78541 --- /dev/null +++ b/src/glsl/tests/attribute-05.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type bool */ +attribute bool i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/attribute-06.glsl b/src/glsl/tests/attribute-06.glsl new file mode 100644 index 00000000000..f18027b81af --- /dev/null +++ b/src/glsl/tests/attribute-06.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type bvec2 */ +attribute bvec2 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/attribute-07.glsl b/src/glsl/tests/attribute-07.glsl new file mode 100644 index 00000000000..0af13ba84bf --- /dev/null +++ b/src/glsl/tests/attribute-07.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type bvec3 */ +attribute bvec3 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/attribute-08.glsl b/src/glsl/tests/attribute-08.glsl new file mode 100644 index 00000000000..b069c04d1b4 --- /dev/null +++ b/src/glsl/tests/attribute-08.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have type bvec4 */ +attribute bvec4 i; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/attribute-09.glsl b/src/glsl/tests/attribute-09.glsl new file mode 100644 index 00000000000..6a607244b9a --- /dev/null +++ b/src/glsl/tests/attribute-09.glsl @@ -0,0 +1,7 @@ +/* FAIL - attribute cannot have array type in GLSL 1.10 */ +attribute vec4 i[10]; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/attribute-10.glsl b/src/glsl/tests/attribute-10.glsl new file mode 100644 index 00000000000..6f5ef63a015 --- /dev/null +++ b/src/glsl/tests/attribute-10.glsl @@ -0,0 +1,8 @@ +#version 120 +/* FAIL - attribute cannot have array type in GLSL 1.20 */ +attribute vec4 i[10]; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/attribute-11.glsl b/src/glsl/tests/attribute-11.glsl new file mode 100644 index 00000000000..47cb5a05833 --- /dev/null +++ b/src/glsl/tests/attribute-11.glsl @@ -0,0 +1,8 @@ +#version 130 +/* FAIL - attribute cannot have array type in GLSL 1.30 */ +attribute vec4 i[10]; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/src/glsl/tests/condition-01.glsl b/src/glsl/tests/condition-01.glsl new file mode 100644 index 00000000000..d89c313117e --- /dev/null +++ b/src/glsl/tests/condition-01.glsl @@ -0,0 +1,8 @@ +/* FAIL - :? condition is not bool scalar */ + +uniform bvec4 a; + +void main() +{ + gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/src/glsl/tests/condition-02.glsl b/src/glsl/tests/condition-02.glsl new file mode 100644 index 00000000000..cbd0e18d9a8 --- /dev/null +++ b/src/glsl/tests/condition-02.glsl @@ -0,0 +1,8 @@ +/* FAIL - :? condition is not bool scalar */ + +uniform float a; + +void main() +{ + gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/src/glsl/tests/condition-03.glsl b/src/glsl/tests/condition-03.glsl new file mode 100644 index 00000000000..9af5d7aa470 --- /dev/null +++ b/src/glsl/tests/condition-03.glsl @@ -0,0 +1,8 @@ +/* PASS */ + +uniform bool a; + +void main() +{ + gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/src/glsl/tests/condition-04.glsl b/src/glsl/tests/condition-04.glsl new file mode 100644 index 00000000000..f440b7e9955 --- /dev/null +++ b/src/glsl/tests/condition-04.glsl @@ -0,0 +1,8 @@ +/* FAIL - type of second two operands must match */ + +uniform bool a; + +void main() +{ + gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0); +} diff --git a/src/glsl/tests/condition-05.glsl b/src/glsl/tests/condition-05.glsl new file mode 100644 index 00000000000..3dff18f519d --- /dev/null +++ b/src/glsl/tests/condition-05.glsl @@ -0,0 +1,13 @@ +#version 120 +/* PASS */ + +uniform bool a; +uniform int b; + +void main() +{ + float x; + + x = (a) ? 2.0 : b; + gl_Position = vec4(x); +} diff --git a/src/glsl/tests/constructor-01.glsl b/src/glsl/tests/constructor-01.glsl new file mode 100644 index 00000000000..fdfaf898663 --- /dev/null +++ b/src/glsl/tests/constructor-01.glsl @@ -0,0 +1,6 @@ +/* PASS */ + +void main() +{ + gl_Position = vec4(1.0, 1.0, 1.0, 0.0);; +} diff --git a/src/glsl/tests/constructor-02.glsl b/src/glsl/tests/constructor-02.glsl new file mode 100644 index 00000000000..47acbe9db14 --- /dev/null +++ b/src/glsl/tests/constructor-02.glsl @@ -0,0 +1,7 @@ +/* FAIL - cannot construct samplers */ +void main() +{ + int i; + + i = sampler2D(0); +} diff --git a/src/glsl/tests/constructor-03.glsl b/src/glsl/tests/constructor-03.glsl new file mode 100644 index 00000000000..07ec225633a --- /dev/null +++ b/src/glsl/tests/constructor-03.glsl @@ -0,0 +1,12 @@ +/* FAIL - cannot construct a matrix from a matrix in GLSL 1.10 */ + +uniform mat2 a; + +void main() +{ + mat2 b; + + b = mat2(a); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/constructor-04.glsl b/src/glsl/tests/constructor-04.glsl new file mode 100644 index 00000000000..19d5e011dea --- /dev/null +++ b/src/glsl/tests/constructor-04.glsl @@ -0,0 +1,14 @@ +#version 120 +/* FAIL - matrix must be only parameter to matrix constructor */ + +uniform mat2 a; +uniform float x; + +void main() +{ + mat2 b; + + b = mat2(a, x); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/constructor-05.glsl b/src/glsl/tests/constructor-05.glsl new file mode 100644 index 00000000000..9c74f75a404 --- /dev/null +++ b/src/glsl/tests/constructor-05.glsl @@ -0,0 +1,13 @@ +/* FAIL - too few components supplied to constructor */ + +uniform vec2 a; +uniform float x; + +void main() +{ + mat2 b; + + b = mat2(a, x); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/constructor-06.glsl b/src/glsl/tests/constructor-06.glsl new file mode 100644 index 00000000000..d77a5f9e892 --- /dev/null +++ b/src/glsl/tests/constructor-06.glsl @@ -0,0 +1,13 @@ +#version 120 +/* PASS */ + +uniform mat2 a; + +void main() +{ + mat2 b; + + b = mat2(a); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/constructor-07.glsl b/src/glsl/tests/constructor-07.glsl new file mode 100644 index 00000000000..92322506ed1 --- /dev/null +++ b/src/glsl/tests/constructor-07.glsl @@ -0,0 +1,13 @@ +/* PASS */ + +uniform ivec2 a; +uniform ivec2 b; + +void main() +{ + mat2 c; + + c = mat2(a, b); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/constructor-08.glsl b/src/glsl/tests/constructor-08.glsl new file mode 100644 index 00000000000..27153f0cda1 --- /dev/null +++ b/src/glsl/tests/constructor-08.glsl @@ -0,0 +1,13 @@ +/* PASS */ + +uniform float a; +uniform float b; + +void main() +{ + ivec2 c; + + c = ivec2(a, b); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/constructor-09.glsl b/src/glsl/tests/constructor-09.glsl new file mode 100644 index 00000000000..1985699b305 --- /dev/null +++ b/src/glsl/tests/constructor-09.glsl @@ -0,0 +1,26 @@ +/* PASS */ + +uniform int a; +uniform float b; +uniform bool c; + +void main() +{ + float x; + int y; + bool z; + + x = float(a); + x = float(b); + x = float(c); + + y = int(a); + y = int(b); + y = int(c); + + z = bool(a); + z = bool(b); + z = bool(c); + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/function-01.glsl b/src/glsl/tests/function-01.glsl new file mode 100644 index 00000000000..0eaa2397ab6 --- /dev/null +++ b/src/glsl/tests/function-01.glsl @@ -0,0 +1,16 @@ +/* FAIL - no function named 'foo' exists */ + +vec4 bar(float x, float y, float z, float w) +{ + vec4 v; + v.x = x; + v.y = y; + v.z = z; + v.w = w; + return v; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0, 0.0); +} diff --git a/src/glsl/tests/function-02.glsl b/src/glsl/tests/function-02.glsl new file mode 100644 index 00000000000..941fcc1ef7b --- /dev/null +++ b/src/glsl/tests/function-02.glsl @@ -0,0 +1,16 @@ +/* FAIL - no version of 'foo' matches the call to 'foo' */ + +vec4 foo(float x, float y, float z, float w) +{ + vec4 v; + v.x = x; + v.y = y; + v.z = z; + v.w = w; + return v; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0); +} diff --git a/src/glsl/tests/function-03.glsl b/src/glsl/tests/function-03.glsl new file mode 100644 index 00000000000..b0da42f8e96 --- /dev/null +++ b/src/glsl/tests/function-03.glsl @@ -0,0 +1,16 @@ +/* PASS */ + +vec4 foo(in float x, in float y, float z, float w) +{ + vec4 v; + v.x = x; + v.y = y; + v.z = z; + v.w = w; + return v; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0, 0.0); +} diff --git a/src/glsl/tests/function-04.glsl b/src/glsl/tests/function-04.glsl new file mode 100644 index 00000000000..dfc0d2b7a6c --- /dev/null +++ b/src/glsl/tests/function-04.glsl @@ -0,0 +1,15 @@ +/* FAIL - type mismatch in assignment */ + +vec3 foo(float x, float y, float z) +{ + vec3 v; + v.x = x; + v.y = y; + v.z = z; + return v; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0); +} diff --git a/src/glsl/tests/function-05.glsl b/src/glsl/tests/function-05.glsl new file mode 100644 index 00000000000..43365bf6062 --- /dev/null +++ b/src/glsl/tests/function-05.glsl @@ -0,0 +1,26 @@ +/* PASS */ + +vec4 foo(in float x, in float y, float z, float w) +{ + vec4 v; + v.x = x; + v.y = y; + v.z = z; + v.w = w; + return v; +} + +vec4 foo(in float x) +{ + vec4 v; + v.x = x; + v.y = x; + v.z = x; + v.w = x; +} + +void main() +{ + gl_Position = foo(1.0, 1.0, 1.0, 0.0); + gl_Position = foo(2.0); +} diff --git a/src/glsl/tests/if-01.glsl b/src/glsl/tests/if-01.glsl new file mode 100644 index 00000000000..ca9abd54f75 --- /dev/null +++ b/src/glsl/tests/if-01.glsl @@ -0,0 +1,11 @@ +/* FAIL - if-statement condition is not bool scalar */ + +uniform bvec4 a; + +void main() +{ + if (a) + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); + else + gl_Position = vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/src/glsl/tests/if-02.glsl b/src/glsl/tests/if-02.glsl new file mode 100644 index 00000000000..7adccea0432 --- /dev/null +++ b/src/glsl/tests/if-02.glsl @@ -0,0 +1,11 @@ +/* FAIL - if-statement condition is not bool scalar */ + +uniform float a; + +void main() +{ + if (a) + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); + else + gl_Position = vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/src/glsl/tests/if-03.glsl b/src/glsl/tests/if-03.glsl new file mode 100644 index 00000000000..179618c716e --- /dev/null +++ b/src/glsl/tests/if-03.glsl @@ -0,0 +1,11 @@ +/* PASS */ + +uniform bool a; + +void main() +{ + if (a) + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); + else + gl_Position = vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/src/glsl/tests/if-04.glsl b/src/glsl/tests/if-04.glsl new file mode 100644 index 00000000000..7b711fb7edf --- /dev/null +++ b/src/glsl/tests/if-04.glsl @@ -0,0 +1,11 @@ +/* PASS */ + +uniform bvec4 a; + +void main() +{ + if (a.x) + gl_Position = vec4(1.0, 0.0, 0.0, 1.0); + else + gl_Position = vec4(0.0, 1.0, 0.0, 1.0); +} diff --git a/src/glsl/tests/matrix-01.glsl b/src/glsl/tests/matrix-01.glsl new file mode 100644 index 00000000000..f46416c8f67 --- /dev/null +++ b/src/glsl/tests/matrix-01.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat2x3 m; +} diff --git a/src/glsl/tests/matrix-02.glsl b/src/glsl/tests/matrix-02.glsl new file mode 100644 index 00000000000..0630722b795 --- /dev/null +++ b/src/glsl/tests/matrix-02.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat2x4 m; +} diff --git a/src/glsl/tests/matrix-03.glsl b/src/glsl/tests/matrix-03.glsl new file mode 100644 index 00000000000..925dc806258 --- /dev/null +++ b/src/glsl/tests/matrix-03.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat3x2 m; +} diff --git a/src/glsl/tests/matrix-04.glsl b/src/glsl/tests/matrix-04.glsl new file mode 100644 index 00000000000..5275619b319 --- /dev/null +++ b/src/glsl/tests/matrix-04.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat3x4 m; +} diff --git a/src/glsl/tests/matrix-05.glsl b/src/glsl/tests/matrix-05.glsl new file mode 100644 index 00000000000..74e1fd25148 --- /dev/null +++ b/src/glsl/tests/matrix-05.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat4x2 m; +} diff --git a/src/glsl/tests/matrix-06.glsl b/src/glsl/tests/matrix-06.glsl new file mode 100644 index 00000000000..0a512b85234 --- /dev/null +++ b/src/glsl/tests/matrix-06.glsl @@ -0,0 +1,6 @@ +/* FAIL - non-square matrices are not available in GLSL 1.10 */ + +void main() +{ + mat4x3 m; +} diff --git a/src/glsl/tests/matrix-07.glsl b/src/glsl/tests/matrix-07.glsl new file mode 100644 index 00000000000..0b59aa69d50 --- /dev/null +++ b/src/glsl/tests/matrix-07.glsl @@ -0,0 +1,27 @@ +/* PASS */ + +uniform mat2 a; +uniform mat2 b; +uniform mat2 c; +uniform mat2 d; +uniform mat3 e; +uniform mat3 f; +uniform mat3 g; +uniform mat3 h; +uniform mat4 i; +uniform mat4 j; +uniform mat4 k; +uniform mat4 l; + +void main() +{ + mat2 x; + mat3 y; + mat4 z; + + x = a * b + c / d; + y = e * f + g / h; + z = i * j + k / l; + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/matrix-08.glsl b/src/glsl/tests/matrix-08.glsl new file mode 100644 index 00000000000..38138d22de4 --- /dev/null +++ b/src/glsl/tests/matrix-08.glsl @@ -0,0 +1,19 @@ +#version 120 +/* PASS */ + +uniform mat2x3 a; +uniform mat3x2 b; +uniform mat3x3 c; +uniform mat3x3 d; + +void main() +{ + mat3x3 x; + + /* Multiplying a 2 column, 3 row matrix with a 3 column, 2 row matrix + * results in a 3 column, 3 row matrix. + */ + x = (a * b) + c / d; + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/matrix-09.glsl b/src/glsl/tests/matrix-09.glsl new file mode 100644 index 00000000000..18afbcacea7 --- /dev/null +++ b/src/glsl/tests/matrix-09.glsl @@ -0,0 +1,11 @@ +/* FAIL - matrix-to-matrix constructors are not available in GLSL 1.10 */ + +uniform mat3 a; + +void main() +{ + mat2 m; + + m = mat2(a); + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/matrix-10.glsl b/src/glsl/tests/matrix-10.glsl new file mode 100644 index 00000000000..20b55180cbb --- /dev/null +++ b/src/glsl/tests/matrix-10.glsl @@ -0,0 +1,12 @@ +#version 120 +/* PASS */ + +uniform mat3 a; + +void main() +{ + mat2 m; + + m = mat2(a); + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/parameters-01.glsl b/src/glsl/tests/parameters-01.glsl new file mode 100644 index 00000000000..b485106e9d7 --- /dev/null +++ b/src/glsl/tests/parameters-01.glsl @@ -0,0 +1,11 @@ +/* FAIL: redefinition of a() */ + +void a() +{ + ; +} + +void a() +{ + ; +} diff --git a/src/glsl/tests/parameters-02.glsl b/src/glsl/tests/parameters-02.glsl new file mode 100644 index 00000000000..7ff5f59ab79 --- /dev/null +++ b/src/glsl/tests/parameters-02.glsl @@ -0,0 +1,11 @@ +/* PASS */ + +void a() +{ + ; +} + +void a(float x) +{ + ; +} diff --git a/src/glsl/tests/parameters-03.glsl b/src/glsl/tests/parameters-03.glsl new file mode 100644 index 00000000000..7ec30f80cc6 --- /dev/null +++ b/src/glsl/tests/parameters-03.glsl @@ -0,0 +1,9 @@ +/* FAIL - x is redeclared in the function body at the same scope as the + * parameter + */ +void a(float x, float y) +{ + float x; + + x = y; +} diff --git a/src/glsl/tests/qualifier-01.glsl b/src/glsl/tests/qualifier-01.glsl new file mode 100644 index 00000000000..54ec3572a24 --- /dev/null +++ b/src/glsl/tests/qualifier-01.glsl @@ -0,0 +1,3 @@ +#version 130 +/* FAIL - inout only allowed in parameter list */ +inout vec4 foo; diff --git a/src/glsl/tests/qualifier-02.glsl b/src/glsl/tests/qualifier-02.glsl new file mode 100644 index 00000000000..b635d52aa2a --- /dev/null +++ b/src/glsl/tests/qualifier-02.glsl @@ -0,0 +1,2 @@ +/* FAIL - in only allowed in parameter list in GLSL 1.10 */ +in foo; diff --git a/src/glsl/tests/qualifier-03.glsl b/src/glsl/tests/qualifier-03.glsl new file mode 100644 index 00000000000..7e448034a7c --- /dev/null +++ b/src/glsl/tests/qualifier-03.glsl @@ -0,0 +1,2 @@ +/* FAIL - out only allowed in parameter list in GLSL 1.10 */ +out vec4 foo; diff --git a/src/glsl/tests/qualifier-04.glsl b/src/glsl/tests/qualifier-04.glsl new file mode 100644 index 00000000000..d03cafc1db2 --- /dev/null +++ b/src/glsl/tests/qualifier-04.glsl @@ -0,0 +1,3 @@ +#version 130 +/* PASS */ +in vec4 foo; diff --git a/src/glsl/tests/qualifier-05.glsl b/src/glsl/tests/qualifier-05.glsl new file mode 100644 index 00000000000..15281f33840 --- /dev/null +++ b/src/glsl/tests/qualifier-05.glsl @@ -0,0 +1,3 @@ +#version 130 +/* PASS */ +out vec4 foo; diff --git a/src/glsl/tests/qualifier-06.glsl b/src/glsl/tests/qualifier-06.glsl new file mode 100644 index 00000000000..1907a087c8e --- /dev/null +++ b/src/glsl/tests/qualifier-06.glsl @@ -0,0 +1,7 @@ +/* FAIL - in only allowed in parameter list in GLSL 1.10 */ +void main() +{ + in vec4 foo; + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/qualifier-07.glsl b/src/glsl/tests/qualifier-07.glsl new file mode 100644 index 00000000000..12568a57dbc --- /dev/null +++ b/src/glsl/tests/qualifier-07.glsl @@ -0,0 +1,7 @@ +/* FAIL - out only allowed in parameter list in GLSL 1.10 */ +void main() +{ + out vec4 foo; + + gl_Position = gl_Vertex; +} diff --git a/src/glsl/tests/swiz-01.glsl b/src/glsl/tests/swiz-01.glsl new file mode 100644 index 00000000000..3268fa178c1 --- /dev/null +++ b/src/glsl/tests/swiz-01.glsl @@ -0,0 +1,11 @@ +/* PASS */ +#version 120 + +void main() +{ + float a; + vec4 b; + + b.x = 6.0; + a = b.x; +} diff --git a/src/glsl/tests/swiz-02.glsl b/src/glsl/tests/swiz-02.glsl new file mode 100644 index 00000000000..e3f043c47bd --- /dev/null +++ b/src/glsl/tests/swiz-02.glsl @@ -0,0 +1,11 @@ +/* FAIL: assignment of a vec2 to a float */ +#version 120 + +void main() +{ + float a; + vec4 b; + + b.x = 6.0; + a = b.xy; +} diff --git a/src/glsl/tests/void-01.glsl b/src/glsl/tests/void-01.glsl new file mode 100644 index 00000000000..5719edc0b6c --- /dev/null +++ b/src/glsl/tests/void-01.glsl @@ -0,0 +1,2 @@ +/* FAIL - cannot declare a variable as having type `void' */ +void foo; diff --git a/symbol_table.c b/symbol_table.c deleted file mode 100644 index 0f0df7a261b..00000000000 --- a/symbol_table.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "main/imports.h" -#include "symbol_table.h" -#include "hash_table.h" - -struct symbol { - /** - * Link to the next symbol in the table with the same name - * - * The linked list of symbols with the same name is ordered by scope - * from inner-most to outer-most. - */ - struct symbol *next_with_same_name; - - - /** - * Link to the next symbol in the table with the same scope - * - * The linked list of symbols with the same scope is unordered. Symbols - * in this list my have unique names. - */ - struct symbol *next_with_same_scope; - - - /** - * Header information for the list of symbols with the same name. - */ - struct symbol_header *hdr; - - - /** - * Name space of the symbol - * - * Name space are arbitrary user assigned integers. No two symbols can - * exist in the same name space at the same scope level. - */ - int name_space; - - - /** - * Arbitrary user supplied data. - */ - void *data; - - /** Scope depth where this symbol was defined. */ - unsigned depth; -}; - - -/** - */ -struct symbol_header { - /** Linkage in list of all headers in a given symbol table. */ - struct symbol_header *next; - - /** Symbol name. */ - const char *name; - - /** Linked list of symbols with the same name. */ - struct symbol *symbols; -}; - - -/** - * Element of the scope stack. - */ -struct scope_level { - /** Link to next (inner) scope level. */ - struct scope_level *next; - - /** Linked list of symbols with the same scope. */ - struct symbol *symbols; -}; - - -/** - * - */ -struct _mesa_symbol_table { - /** Hash table containing all symbols in the symbol table. */ - struct hash_table *ht; - - /** Top of scope stack. */ - struct scope_level *current_scope; - - /** List of all symbol headers in the table. */ - struct symbol_header *hdr; - - /** Current scope depth. */ - unsigned depth; -}; - - -struct _mesa_symbol_table_iterator { - /** - * Name space of symbols returned by this iterator. - */ - int name_space; - - - /** - * Currently iterated symbol - * - * The next call to \c _mesa_symbol_table_iterator_get will return this - * value. It will also update this value to the value that should be - * returned by the next call. - */ - struct symbol *curr; -}; - - -static void -check_symbol_table(struct _mesa_symbol_table *table) -{ -#if 1 - struct scope_level *scope; - - for (scope = table->current_scope; scope != NULL; scope = scope->next) { - struct symbol *sym; - - for (sym = scope->symbols - ; sym != NULL - ; sym = sym->next_with_same_name) { - const struct symbol_header *const hdr = sym->hdr; - struct symbol *sym2; - - for (sym2 = hdr->symbols - ; sym2 != NULL - ; sym2 = sym2->next_with_same_name) { - assert(sym2->hdr == hdr); - } - } - } -#endif -} - -void -_mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table) -{ - struct scope_level *const scope = table->current_scope; - struct symbol *sym = scope->symbols; - - table->current_scope = scope->next; - table->depth--; - - free(scope); - - while (sym != NULL) { - struct symbol *const next = sym->next_with_same_scope; - struct symbol_header *const hdr = sym->hdr; - - assert(hdr->symbols == sym); - - hdr->symbols = sym->next_with_same_name; - - free(sym); - - sym = next; - } - - check_symbol_table(table); -} - - -void -_mesa_symbol_table_push_scope(struct _mesa_symbol_table *table) -{ - struct scope_level *const scope = calloc(1, sizeof(*scope)); - - scope->next = table->current_scope; - table->current_scope = scope; - table->depth++; -} - - -static struct symbol_header * -find_symbol(struct _mesa_symbol_table *table, const char *name) -{ - return (struct symbol_header *) hash_table_find(table->ht, name); -} - - -struct _mesa_symbol_table_iterator * -_mesa_symbol_table_iterator_ctor(struct _mesa_symbol_table *table, - int name_space, const char *name) -{ - struct _mesa_symbol_table_iterator *iter = calloc(1, sizeof(*iter)); - struct symbol_header *const hdr = find_symbol(table, name); - - iter->name_space = name_space; - - if (hdr != NULL) { - struct symbol *sym; - - for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { - assert(sym->hdr == hdr); - - if ((name_space == -1) || (sym->name_space == name_space)) { - iter->curr = sym; - break; - } - } - } - - return iter; -} - - -void -_mesa_symbol_table_iterator_dtor(struct _mesa_symbol_table_iterator *iter) -{ - free(iter); -} - - -void * -_mesa_symbol_table_iterator_get(struct _mesa_symbol_table_iterator *iter) -{ - return (iter->curr == NULL) ? NULL : iter->curr->data; -} - - -int -_mesa_symbol_table_iterator_next(struct _mesa_symbol_table_iterator *iter) -{ - struct symbol_header *hdr; - - if (iter->curr == NULL) { - return 0; - } - - hdr = iter->curr->hdr; - iter->curr = iter->curr->next_with_same_name; - - while (iter->curr != NULL) { - assert(iter->curr->hdr == hdr); - - if ((iter->name_space == -1) - || (iter->curr->name_space == iter->name_space)) { - return 1; - } - - iter->curr = iter->curr->next_with_same_name; - } - - return 0; -} - - -/** - * Determine the scope "distance" of a symbol from the current scope - * - * \return - * A non-negative number for the number of scopes between the current scope - * and the scope where a symbol was defined. A value of zero means the current - * scope. A negative number if the symbol does not exist. - */ -int -_mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, - int name_space, const char *name) -{ - struct symbol_header *const hdr = find_symbol(table, name); - struct symbol *sym; - - if (hdr != NULL) { - for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { - assert(sym->hdr == hdr); - - if ((name_space == -1) || (sym->name_space == name_space)) { - assert(sym->depth <= table->depth); - return sym->depth - table->depth; - } - } - } - - return -1; -} - - -void * -_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table, - int name_space, const char *name) -{ - struct symbol_header *const hdr = find_symbol(table, name); - - if (hdr != NULL) { - struct symbol *sym; - - - for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { - assert(sym->hdr == hdr); - - if ((name_space == -1) || (sym->name_space == name_space)) { - return sym->data; - } - } - } - - return NULL; -} - - -int -_mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, - int name_space, const char *name, - void *declaration) -{ - struct symbol_header *hdr; - struct symbol *sym; - - check_symbol_table(table); - - hdr = find_symbol(table, name); - - check_symbol_table(table); - - if (hdr == NULL) { - hdr = calloc(1, sizeof(*hdr)); - hdr->name = name; - - hash_table_insert(table->ht, hdr, name); - hdr->next = table->hdr; - table->hdr = hdr; - } - - check_symbol_table(table); - - /* If the symbol already exists in this namespace at this scope, it cannot - * be added to the table. - */ - for (sym = hdr->symbols - ; (sym != NULL) && (sym->name_space != name_space) - ; sym = sym->next_with_same_name) { - /* empty */ - } - - if (sym && (sym->depth == table->depth)) - return -1; - - sym = calloc(1, sizeof(*sym)); - sym->next_with_same_name = hdr->symbols; - sym->next_with_same_scope = table->current_scope->symbols; - sym->hdr = hdr; - sym->name_space = name_space; - sym->data = declaration; - sym->depth = table->depth; - - assert(sym->hdr == hdr); - - hdr->symbols = sym; - table->current_scope->symbols = sym; - - check_symbol_table(table); - return 0; -} - - -struct _mesa_symbol_table * -_mesa_symbol_table_ctor(void) -{ - struct _mesa_symbol_table *table = calloc(1, sizeof(*table)); - - if (table != NULL) { - table->ht = hash_table_ctor(32, hash_table_string_hash, - hash_table_string_compare); - - _mesa_symbol_table_push_scope(table); - } - - return table; -} - - -void -_mesa_symbol_table_dtor(struct _mesa_symbol_table *table) -{ - struct symbol_header *hdr; - struct symbol_header *next; - - while (table->current_scope != NULL) { - _mesa_symbol_table_pop_scope(table); - } - - for (hdr = table->hdr; hdr != NULL; hdr = next) { - next = hdr->next; - _mesa_free(hdr); - } - - hash_table_dtor(table->ht); - free(table); -} diff --git a/symbol_table.h b/symbol_table.h deleted file mode 100644 index 3a9994c1ac9..00000000000 --- a/symbol_table.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#ifndef MESA_SYMBOL_TABLE_H -#define MESA_SYMBOL_TABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct _mesa_symbol_table; -struct _mesa_symbol_table_iterator; - -extern void _mesa_symbol_table_push_scope(struct _mesa_symbol_table *table); - -extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table); - -extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, - int name_space, const char *name, void *declaration); - -extern int _mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, - int name_space, const char *name); - -extern void *_mesa_symbol_table_find_symbol( - struct _mesa_symbol_table *symtab, int name_space, const char *name); - -extern struct _mesa_symbol_table *_mesa_symbol_table_ctor(void); - -extern void _mesa_symbol_table_dtor(struct _mesa_symbol_table *); - -extern struct _mesa_symbol_table_iterator *_mesa_symbol_table_iterator_ctor( - struct _mesa_symbol_table *table, int name_space, const char *name); - -extern void _mesa_symbol_table_iterator_dtor( - struct _mesa_symbol_table_iterator *); - -extern void *_mesa_symbol_table_iterator_get( - struct _mesa_symbol_table_iterator *iter); - -extern int _mesa_symbol_table_iterator_next( - struct _mesa_symbol_table_iterator *iter); - -#ifdef __cplusplus -} -#endif - -#endif /* MESA_SYMBOL_TABLE_H */ diff --git a/tests/array-01.glsl b/tests/array-01.glsl deleted file mode 100644 index d14135fb3a8..00000000000 --- a/tests/array-01.glsl +++ /dev/null @@ -1,3 +0,0 @@ -#version 120 -/* FAIL - array size type must be int */ -uniform vec4 [3.2] a; diff --git a/tests/array-02.glsl b/tests/array-02.glsl deleted file mode 100644 index d743617158d..00000000000 --- a/tests/array-02.glsl +++ /dev/null @@ -1,3 +0,0 @@ -#version 120 -/* FAIL - array size type must be scalar */ -uniform vec4 [ivec4(3)] a; diff --git a/tests/array-03.glsl b/tests/array-03.glsl deleted file mode 100644 index 0026913f019..00000000000 --- a/tests/array-03.glsl +++ /dev/null @@ -1,3 +0,0 @@ -#version 120 -/* PASS */ -uniform vec4 [3] a; diff --git a/tests/array-04.glsl b/tests/array-04.glsl deleted file mode 100644 index 70f434d8ab6..00000000000 --- a/tests/array-04.glsl +++ /dev/null @@ -1,2 +0,0 @@ -/* FAIL - array size type must be int */ -uniform vec4 a[3.2]; diff --git a/tests/array-05.glsl b/tests/array-05.glsl deleted file mode 100644 index 168704096b0..00000000000 --- a/tests/array-05.glsl +++ /dev/null @@ -1,2 +0,0 @@ -/* FAIL - array size type must be scalar */ -uniform vec4 a[ivec4(3)]; diff --git a/tests/array-06.glsl b/tests/array-06.glsl deleted file mode 100644 index 46b43795be1..00000000000 --- a/tests/array-06.glsl +++ /dev/null @@ -1,2 +0,0 @@ -/* PASS */ -uniform vec4 a[3]; diff --git a/tests/array-07.glsl b/tests/array-07.glsl deleted file mode 100644 index 161ffbf2f2e..00000000000 --- a/tests/array-07.glsl +++ /dev/null @@ -1,2 +0,0 @@ -/* FAIL - array size must be > 0 */ -uniform vec4 a[0]; diff --git a/tests/array-08.glsl b/tests/array-08.glsl deleted file mode 100644 index 4bf0c6bd513..00000000000 --- a/tests/array-08.glsl +++ /dev/null @@ -1,2 +0,0 @@ -/* FAIL - array size must be > 0 */ -uniform vec4 a[-1]; diff --git a/tests/array-09.glsl b/tests/array-09.glsl deleted file mode 100644 index cad6d0e54ec..00000000000 --- a/tests/array-09.glsl +++ /dev/null @@ -1,9 +0,0 @@ -#version 120 -/* PASS */ - -void main() -{ - vec4 a[2] = vec4 [2] (vec4(1.0), vec4(2.0)); - - gl_Position = gl_Vertex; -} diff --git a/tests/array-10.glsl b/tests/array-10.glsl deleted file mode 100644 index 019aa21150f..00000000000 --- a/tests/array-10.glsl +++ /dev/null @@ -1,11 +0,0 @@ -/* FAIL - array constructors forbidden in GLSL 1.10 - * - * This can also generate an error because the 'vec4[]' style syntax is - * illegal in GLSL 1.10. - */ -void main() -{ - vec4 a[2] = vec4 [2] (vec4(1.0), vec4(2.0)); - - gl_Position = gl_Vertex; -} diff --git a/tests/array-11.glsl b/tests/array-11.glsl deleted file mode 100644 index 51d94e94773..00000000000 --- a/tests/array-11.glsl +++ /dev/null @@ -1,9 +0,0 @@ -#version 120 -/* PASS */ - -void main() -{ - vec4 a[] = vec4 [] (vec4(1.0), vec4(2.0)); - - gl_Position = gl_Vertex; -} diff --git a/tests/array-12.glsl b/tests/array-12.glsl deleted file mode 100644 index 7fc9579452f..00000000000 --- a/tests/array-12.glsl +++ /dev/null @@ -1,11 +0,0 @@ -#version 120 -/* FAIL - array must have an implicit or explicit size */ - -void main() -{ - vec4 a[]; - - a = vec4 [2] (vec4(1.0), vec4(2.0)); - - gl_Position = gl_Vertex; -} diff --git a/tests/array-13.glsl b/tests/array-13.glsl deleted file mode 100644 index cc7e29a5f76..00000000000 --- a/tests/array-13.glsl +++ /dev/null @@ -1,11 +0,0 @@ -#version 120 -/* PASS */ - -void main() -{ - vec4 a[2]; - - a = vec4 [] (vec4(1.0), vec4(2.0)); - - gl_Position = gl_Vertex; -} diff --git a/tests/attribute-01.glsl b/tests/attribute-01.glsl deleted file mode 100644 index 18e9e4468aa..00000000000 --- a/tests/attribute-01.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - attribute cannot have type int */ -attribute int i; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/attribute-02.glsl b/tests/attribute-02.glsl deleted file mode 100644 index 6b6df74d252..00000000000 --- a/tests/attribute-02.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - attribute cannot have type ivec2 */ -attribute ivec2 i; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/attribute-03.glsl b/tests/attribute-03.glsl deleted file mode 100644 index 870de9e8148..00000000000 --- a/tests/attribute-03.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - attribute cannot have type ivec3 */ -attribute ivec3 i; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/attribute-04.glsl b/tests/attribute-04.glsl deleted file mode 100644 index 14af2fcaadd..00000000000 --- a/tests/attribute-04.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - attribute cannot have type ivec4 */ -attribute ivec4 i; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/attribute-05.glsl b/tests/attribute-05.glsl deleted file mode 100644 index 18822c78541..00000000000 --- a/tests/attribute-05.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - attribute cannot have type bool */ -attribute bool i; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/attribute-06.glsl b/tests/attribute-06.glsl deleted file mode 100644 index f18027b81af..00000000000 --- a/tests/attribute-06.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - attribute cannot have type bvec2 */ -attribute bvec2 i; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/attribute-07.glsl b/tests/attribute-07.glsl deleted file mode 100644 index 0af13ba84bf..00000000000 --- a/tests/attribute-07.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - attribute cannot have type bvec3 */ -attribute bvec3 i; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/attribute-08.glsl b/tests/attribute-08.glsl deleted file mode 100644 index b069c04d1b4..00000000000 --- a/tests/attribute-08.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - attribute cannot have type bvec4 */ -attribute bvec4 i; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/attribute-09.glsl b/tests/attribute-09.glsl deleted file mode 100644 index 6a607244b9a..00000000000 --- a/tests/attribute-09.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - attribute cannot have array type in GLSL 1.10 */ -attribute vec4 i[10]; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/attribute-10.glsl b/tests/attribute-10.glsl deleted file mode 100644 index 6f5ef63a015..00000000000 --- a/tests/attribute-10.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#version 120 -/* FAIL - attribute cannot have array type in GLSL 1.20 */ -attribute vec4 i[10]; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/attribute-11.glsl b/tests/attribute-11.glsl deleted file mode 100644 index 47cb5a05833..00000000000 --- a/tests/attribute-11.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#version 130 -/* FAIL - attribute cannot have array type in GLSL 1.30 */ -attribute vec4 i[10]; - -void main() -{ - gl_Position = vec4(1.0); -} diff --git a/tests/condition-01.glsl b/tests/condition-01.glsl deleted file mode 100644 index d89c313117e..00000000000 --- a/tests/condition-01.glsl +++ /dev/null @@ -1,8 +0,0 @@ -/* FAIL - :? condition is not bool scalar */ - -uniform bvec4 a; - -void main() -{ - gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0); -} diff --git a/tests/condition-02.glsl b/tests/condition-02.glsl deleted file mode 100644 index cbd0e18d9a8..00000000000 --- a/tests/condition-02.glsl +++ /dev/null @@ -1,8 +0,0 @@ -/* FAIL - :? condition is not bool scalar */ - -uniform float a; - -void main() -{ - gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0); -} diff --git a/tests/condition-03.glsl b/tests/condition-03.glsl deleted file mode 100644 index 9af5d7aa470..00000000000 --- a/tests/condition-03.glsl +++ /dev/null @@ -1,8 +0,0 @@ -/* PASS */ - -uniform bool a; - -void main() -{ - gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0); -} diff --git a/tests/condition-04.glsl b/tests/condition-04.glsl deleted file mode 100644 index f440b7e9955..00000000000 --- a/tests/condition-04.glsl +++ /dev/null @@ -1,8 +0,0 @@ -/* FAIL - type of second two operands must match */ - -uniform bool a; - -void main() -{ - gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0); -} diff --git a/tests/condition-05.glsl b/tests/condition-05.glsl deleted file mode 100644 index 3dff18f519d..00000000000 --- a/tests/condition-05.glsl +++ /dev/null @@ -1,13 +0,0 @@ -#version 120 -/* PASS */ - -uniform bool a; -uniform int b; - -void main() -{ - float x; - - x = (a) ? 2.0 : b; - gl_Position = vec4(x); -} diff --git a/tests/constructor-01.glsl b/tests/constructor-01.glsl deleted file mode 100644 index fdfaf898663..00000000000 --- a/tests/constructor-01.glsl +++ /dev/null @@ -1,6 +0,0 @@ -/* PASS */ - -void main() -{ - gl_Position = vec4(1.0, 1.0, 1.0, 0.0);; -} diff --git a/tests/constructor-02.glsl b/tests/constructor-02.glsl deleted file mode 100644 index 47acbe9db14..00000000000 --- a/tests/constructor-02.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - cannot construct samplers */ -void main() -{ - int i; - - i = sampler2D(0); -} diff --git a/tests/constructor-03.glsl b/tests/constructor-03.glsl deleted file mode 100644 index 07ec225633a..00000000000 --- a/tests/constructor-03.glsl +++ /dev/null @@ -1,12 +0,0 @@ -/* FAIL - cannot construct a matrix from a matrix in GLSL 1.10 */ - -uniform mat2 a; - -void main() -{ - mat2 b; - - b = mat2(a); - - gl_Position = gl_Vertex; -} diff --git a/tests/constructor-04.glsl b/tests/constructor-04.glsl deleted file mode 100644 index 19d5e011dea..00000000000 --- a/tests/constructor-04.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#version 120 -/* FAIL - matrix must be only parameter to matrix constructor */ - -uniform mat2 a; -uniform float x; - -void main() -{ - mat2 b; - - b = mat2(a, x); - - gl_Position = gl_Vertex; -} diff --git a/tests/constructor-05.glsl b/tests/constructor-05.glsl deleted file mode 100644 index 9c74f75a404..00000000000 --- a/tests/constructor-05.glsl +++ /dev/null @@ -1,13 +0,0 @@ -/* FAIL - too few components supplied to constructor */ - -uniform vec2 a; -uniform float x; - -void main() -{ - mat2 b; - - b = mat2(a, x); - - gl_Position = gl_Vertex; -} diff --git a/tests/constructor-06.glsl b/tests/constructor-06.glsl deleted file mode 100644 index d77a5f9e892..00000000000 --- a/tests/constructor-06.glsl +++ /dev/null @@ -1,13 +0,0 @@ -#version 120 -/* PASS */ - -uniform mat2 a; - -void main() -{ - mat2 b; - - b = mat2(a); - - gl_Position = gl_Vertex; -} diff --git a/tests/constructor-07.glsl b/tests/constructor-07.glsl deleted file mode 100644 index 92322506ed1..00000000000 --- a/tests/constructor-07.glsl +++ /dev/null @@ -1,13 +0,0 @@ -/* PASS */ - -uniform ivec2 a; -uniform ivec2 b; - -void main() -{ - mat2 c; - - c = mat2(a, b); - - gl_Position = gl_Vertex; -} diff --git a/tests/constructor-08.glsl b/tests/constructor-08.glsl deleted file mode 100644 index 27153f0cda1..00000000000 --- a/tests/constructor-08.glsl +++ /dev/null @@ -1,13 +0,0 @@ -/* PASS */ - -uniform float a; -uniform float b; - -void main() -{ - ivec2 c; - - c = ivec2(a, b); - - gl_Position = gl_Vertex; -} diff --git a/tests/constructor-09.glsl b/tests/constructor-09.glsl deleted file mode 100644 index 1985699b305..00000000000 --- a/tests/constructor-09.glsl +++ /dev/null @@ -1,26 +0,0 @@ -/* PASS */ - -uniform int a; -uniform float b; -uniform bool c; - -void main() -{ - float x; - int y; - bool z; - - x = float(a); - x = float(b); - x = float(c); - - y = int(a); - y = int(b); - y = int(c); - - z = bool(a); - z = bool(b); - z = bool(c); - - gl_Position = gl_Vertex; -} diff --git a/tests/function-01.glsl b/tests/function-01.glsl deleted file mode 100644 index 0eaa2397ab6..00000000000 --- a/tests/function-01.glsl +++ /dev/null @@ -1,16 +0,0 @@ -/* FAIL - no function named 'foo' exists */ - -vec4 bar(float x, float y, float z, float w) -{ - vec4 v; - v.x = x; - v.y = y; - v.z = z; - v.w = w; - return v; -} - -void main() -{ - gl_Position = foo(1.0, 1.0, 1.0, 0.0); -} diff --git a/tests/function-02.glsl b/tests/function-02.glsl deleted file mode 100644 index 941fcc1ef7b..00000000000 --- a/tests/function-02.glsl +++ /dev/null @@ -1,16 +0,0 @@ -/* FAIL - no version of 'foo' matches the call to 'foo' */ - -vec4 foo(float x, float y, float z, float w) -{ - vec4 v; - v.x = x; - v.y = y; - v.z = z; - v.w = w; - return v; -} - -void main() -{ - gl_Position = foo(1.0, 1.0, 1.0); -} diff --git a/tests/function-03.glsl b/tests/function-03.glsl deleted file mode 100644 index b0da42f8e96..00000000000 --- a/tests/function-03.glsl +++ /dev/null @@ -1,16 +0,0 @@ -/* PASS */ - -vec4 foo(in float x, in float y, float z, float w) -{ - vec4 v; - v.x = x; - v.y = y; - v.z = z; - v.w = w; - return v; -} - -void main() -{ - gl_Position = foo(1.0, 1.0, 1.0, 0.0); -} diff --git a/tests/function-04.glsl b/tests/function-04.glsl deleted file mode 100644 index dfc0d2b7a6c..00000000000 --- a/tests/function-04.glsl +++ /dev/null @@ -1,15 +0,0 @@ -/* FAIL - type mismatch in assignment */ - -vec3 foo(float x, float y, float z) -{ - vec3 v; - v.x = x; - v.y = y; - v.z = z; - return v; -} - -void main() -{ - gl_Position = foo(1.0, 1.0, 1.0); -} diff --git a/tests/function-05.glsl b/tests/function-05.glsl deleted file mode 100644 index 43365bf6062..00000000000 --- a/tests/function-05.glsl +++ /dev/null @@ -1,26 +0,0 @@ -/* PASS */ - -vec4 foo(in float x, in float y, float z, float w) -{ - vec4 v; - v.x = x; - v.y = y; - v.z = z; - v.w = w; - return v; -} - -vec4 foo(in float x) -{ - vec4 v; - v.x = x; - v.y = x; - v.z = x; - v.w = x; -} - -void main() -{ - gl_Position = foo(1.0, 1.0, 1.0, 0.0); - gl_Position = foo(2.0); -} diff --git a/tests/if-01.glsl b/tests/if-01.glsl deleted file mode 100644 index ca9abd54f75..00000000000 --- a/tests/if-01.glsl +++ /dev/null @@ -1,11 +0,0 @@ -/* FAIL - if-statement condition is not bool scalar */ - -uniform bvec4 a; - -void main() -{ - if (a) - gl_Position = vec4(1.0, 0.0, 0.0, 1.0); - else - gl_Position = vec4(0.0, 1.0, 0.0, 1.0); -} diff --git a/tests/if-02.glsl b/tests/if-02.glsl deleted file mode 100644 index 7adccea0432..00000000000 --- a/tests/if-02.glsl +++ /dev/null @@ -1,11 +0,0 @@ -/* FAIL - if-statement condition is not bool scalar */ - -uniform float a; - -void main() -{ - if (a) - gl_Position = vec4(1.0, 0.0, 0.0, 1.0); - else - gl_Position = vec4(0.0, 1.0, 0.0, 1.0); -} diff --git a/tests/if-03.glsl b/tests/if-03.glsl deleted file mode 100644 index 179618c716e..00000000000 --- a/tests/if-03.glsl +++ /dev/null @@ -1,11 +0,0 @@ -/* PASS */ - -uniform bool a; - -void main() -{ - if (a) - gl_Position = vec4(1.0, 0.0, 0.0, 1.0); - else - gl_Position = vec4(0.0, 1.0, 0.0, 1.0); -} diff --git a/tests/if-04.glsl b/tests/if-04.glsl deleted file mode 100644 index 7b711fb7edf..00000000000 --- a/tests/if-04.glsl +++ /dev/null @@ -1,11 +0,0 @@ -/* PASS */ - -uniform bvec4 a; - -void main() -{ - if (a.x) - gl_Position = vec4(1.0, 0.0, 0.0, 1.0); - else - gl_Position = vec4(0.0, 1.0, 0.0, 1.0); -} diff --git a/tests/matrix-01.glsl b/tests/matrix-01.glsl deleted file mode 100644 index f46416c8f67..00000000000 --- a/tests/matrix-01.glsl +++ /dev/null @@ -1,6 +0,0 @@ -/* FAIL - non-square matrices are not available in GLSL 1.10 */ - -void main() -{ - mat2x3 m; -} diff --git a/tests/matrix-02.glsl b/tests/matrix-02.glsl deleted file mode 100644 index 0630722b795..00000000000 --- a/tests/matrix-02.glsl +++ /dev/null @@ -1,6 +0,0 @@ -/* FAIL - non-square matrices are not available in GLSL 1.10 */ - -void main() -{ - mat2x4 m; -} diff --git a/tests/matrix-03.glsl b/tests/matrix-03.glsl deleted file mode 100644 index 925dc806258..00000000000 --- a/tests/matrix-03.glsl +++ /dev/null @@ -1,6 +0,0 @@ -/* FAIL - non-square matrices are not available in GLSL 1.10 */ - -void main() -{ - mat3x2 m; -} diff --git a/tests/matrix-04.glsl b/tests/matrix-04.glsl deleted file mode 100644 index 5275619b319..00000000000 --- a/tests/matrix-04.glsl +++ /dev/null @@ -1,6 +0,0 @@ -/* FAIL - non-square matrices are not available in GLSL 1.10 */ - -void main() -{ - mat3x4 m; -} diff --git a/tests/matrix-05.glsl b/tests/matrix-05.glsl deleted file mode 100644 index 74e1fd25148..00000000000 --- a/tests/matrix-05.glsl +++ /dev/null @@ -1,6 +0,0 @@ -/* FAIL - non-square matrices are not available in GLSL 1.10 */ - -void main() -{ - mat4x2 m; -} diff --git a/tests/matrix-06.glsl b/tests/matrix-06.glsl deleted file mode 100644 index 0a512b85234..00000000000 --- a/tests/matrix-06.glsl +++ /dev/null @@ -1,6 +0,0 @@ -/* FAIL - non-square matrices are not available in GLSL 1.10 */ - -void main() -{ - mat4x3 m; -} diff --git a/tests/matrix-07.glsl b/tests/matrix-07.glsl deleted file mode 100644 index 0b59aa69d50..00000000000 --- a/tests/matrix-07.glsl +++ /dev/null @@ -1,27 +0,0 @@ -/* PASS */ - -uniform mat2 a; -uniform mat2 b; -uniform mat2 c; -uniform mat2 d; -uniform mat3 e; -uniform mat3 f; -uniform mat3 g; -uniform mat3 h; -uniform mat4 i; -uniform mat4 j; -uniform mat4 k; -uniform mat4 l; - -void main() -{ - mat2 x; - mat3 y; - mat4 z; - - x = a * b + c / d; - y = e * f + g / h; - z = i * j + k / l; - - gl_Position = gl_Vertex; -} diff --git a/tests/matrix-08.glsl b/tests/matrix-08.glsl deleted file mode 100644 index 38138d22de4..00000000000 --- a/tests/matrix-08.glsl +++ /dev/null @@ -1,19 +0,0 @@ -#version 120 -/* PASS */ - -uniform mat2x3 a; -uniform mat3x2 b; -uniform mat3x3 c; -uniform mat3x3 d; - -void main() -{ - mat3x3 x; - - /* Multiplying a 2 column, 3 row matrix with a 3 column, 2 row matrix - * results in a 3 column, 3 row matrix. - */ - x = (a * b) + c / d; - - gl_Position = gl_Vertex; -} diff --git a/tests/matrix-09.glsl b/tests/matrix-09.glsl deleted file mode 100644 index 18afbcacea7..00000000000 --- a/tests/matrix-09.glsl +++ /dev/null @@ -1,11 +0,0 @@ -/* FAIL - matrix-to-matrix constructors are not available in GLSL 1.10 */ - -uniform mat3 a; - -void main() -{ - mat2 m; - - m = mat2(a); - gl_Position = gl_Vertex; -} diff --git a/tests/matrix-10.glsl b/tests/matrix-10.glsl deleted file mode 100644 index 20b55180cbb..00000000000 --- a/tests/matrix-10.glsl +++ /dev/null @@ -1,12 +0,0 @@ -#version 120 -/* PASS */ - -uniform mat3 a; - -void main() -{ - mat2 m; - - m = mat2(a); - gl_Position = gl_Vertex; -} diff --git a/tests/parameters-01.glsl b/tests/parameters-01.glsl deleted file mode 100644 index b485106e9d7..00000000000 --- a/tests/parameters-01.glsl +++ /dev/null @@ -1,11 +0,0 @@ -/* FAIL: redefinition of a() */ - -void a() -{ - ; -} - -void a() -{ - ; -} diff --git a/tests/parameters-02.glsl b/tests/parameters-02.glsl deleted file mode 100644 index 7ff5f59ab79..00000000000 --- a/tests/parameters-02.glsl +++ /dev/null @@ -1,11 +0,0 @@ -/* PASS */ - -void a() -{ - ; -} - -void a(float x) -{ - ; -} diff --git a/tests/parameters-03.glsl b/tests/parameters-03.glsl deleted file mode 100644 index 7ec30f80cc6..00000000000 --- a/tests/parameters-03.glsl +++ /dev/null @@ -1,9 +0,0 @@ -/* FAIL - x is redeclared in the function body at the same scope as the - * parameter - */ -void a(float x, float y) -{ - float x; - - x = y; -} diff --git a/tests/qualifier-01.glsl b/tests/qualifier-01.glsl deleted file mode 100644 index 54ec3572a24..00000000000 --- a/tests/qualifier-01.glsl +++ /dev/null @@ -1,3 +0,0 @@ -#version 130 -/* FAIL - inout only allowed in parameter list */ -inout vec4 foo; diff --git a/tests/qualifier-02.glsl b/tests/qualifier-02.glsl deleted file mode 100644 index b635d52aa2a..00000000000 --- a/tests/qualifier-02.glsl +++ /dev/null @@ -1,2 +0,0 @@ -/* FAIL - in only allowed in parameter list in GLSL 1.10 */ -in foo; diff --git a/tests/qualifier-03.glsl b/tests/qualifier-03.glsl deleted file mode 100644 index 7e448034a7c..00000000000 --- a/tests/qualifier-03.glsl +++ /dev/null @@ -1,2 +0,0 @@ -/* FAIL - out only allowed in parameter list in GLSL 1.10 */ -out vec4 foo; diff --git a/tests/qualifier-04.glsl b/tests/qualifier-04.glsl deleted file mode 100644 index d03cafc1db2..00000000000 --- a/tests/qualifier-04.glsl +++ /dev/null @@ -1,3 +0,0 @@ -#version 130 -/* PASS */ -in vec4 foo; diff --git a/tests/qualifier-05.glsl b/tests/qualifier-05.glsl deleted file mode 100644 index 15281f33840..00000000000 --- a/tests/qualifier-05.glsl +++ /dev/null @@ -1,3 +0,0 @@ -#version 130 -/* PASS */ -out vec4 foo; diff --git a/tests/qualifier-06.glsl b/tests/qualifier-06.glsl deleted file mode 100644 index 1907a087c8e..00000000000 --- a/tests/qualifier-06.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - in only allowed in parameter list in GLSL 1.10 */ -void main() -{ - in vec4 foo; - - gl_Position = gl_Vertex; -} diff --git a/tests/qualifier-07.glsl b/tests/qualifier-07.glsl deleted file mode 100644 index 12568a57dbc..00000000000 --- a/tests/qualifier-07.glsl +++ /dev/null @@ -1,7 +0,0 @@ -/* FAIL - out only allowed in parameter list in GLSL 1.10 */ -void main() -{ - out vec4 foo; - - gl_Position = gl_Vertex; -} diff --git a/tests/swiz-01.glsl b/tests/swiz-01.glsl deleted file mode 100644 index 3268fa178c1..00000000000 --- a/tests/swiz-01.glsl +++ /dev/null @@ -1,11 +0,0 @@ -/* PASS */ -#version 120 - -void main() -{ - float a; - vec4 b; - - b.x = 6.0; - a = b.x; -} diff --git a/tests/swiz-02.glsl b/tests/swiz-02.glsl deleted file mode 100644 index e3f043c47bd..00000000000 --- a/tests/swiz-02.glsl +++ /dev/null @@ -1,11 +0,0 @@ -/* FAIL: assignment of a vec2 to a float */ -#version 120 - -void main() -{ - float a; - vec4 b; - - b.x = 6.0; - a = b.xy; -} diff --git a/tests/void-01.glsl b/tests/void-01.glsl deleted file mode 100644 index 5719edc0b6c..00000000000 --- a/tests/void-01.glsl +++ /dev/null @@ -1,2 +0,0 @@ -/* FAIL - cannot declare a variable as having type `void' */ -void foo; -- cgit v1.2.3 From e5cf3aadb8d57dcc70b597092ecac276042f73cb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 15:41:40 -0700 Subject: glsl2: Add a README file for the new compiler. --- src/glsl/README | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 src/glsl/README diff --git a/src/glsl/README b/src/glsl/README new file mode 100644 index 00000000000..8b6162ab672 --- /dev/null +++ b/src/glsl/README @@ -0,0 +1,153 @@ +Welcome to Mesa's GLSL compiler. A brief overview of how things flow: + +1) lex and yacc-based preprocessor takes the incoming shader string +and produces a new string containing the preprocessed shader. This +takes care of things like #if, #ifdef, #define, and preprocessor macro +invocations. Note that #version, #extension, and some others are +passed straight through. See glcpp/* + +2) lex and yacc-based parser takes the preprocessed string and +generates the AST (abstract syntax tree). Almost no checking is +performed in this stage. See glsl_lexer.lpp and glsl_parser.ypp. + +3) The AST is converted to "HIR". This is the intermediate +representation of the compiler. Constructors are generated, function +calls are resolved to particular function signatures, and all the +semantic checking is performed. See ast_*.cpp for the conversion, and +ir.h for the IR structures. + +4) The driver (Mesa, or main.cpp for the standalone binary) performs +optimizations. These include copy propagation, dead code elimination, +constant folding, and others. Generally the driver will call +optimizations in a loop, as each may open up opportunities for other +optimizations to do additional work. See most files called ir_*.cpp + +5) linking is performed. This does checking to ensure that the +outputs of the vertex shader match the inputs of the fragment shader, +and assigns locations to uniforms, attributes, and varyings. See +linker.cpp. + +6) The driver may perform additional optimization at this point, as +for example dead code elimination previously couldn't remove functions +or global variable usage when we didn't know what other code would be +linked in. + +7) The driver performs code generation out of the IR, taking a linked +shader program and producing a compiled program for each stage. See +ir_to_mesa.cpp for Mesa IR code generation. + +FAQ: + +Q: What is HIR versus IR versus LIR? + +A: The idea behind the naming was that ast_to_hir would produce a +high-level IR ("HIR"), with things like matrix operations, structure +assignments, etc., present. A series of lowering passes would occur +that do things like break matrix multiplication into a series of dot +products/MADs, make structure assignment be a series of assignment of +components, flatten if statements into conditional moves, and such, +producing a low level IR ("LIR"). + +However, it now appears that each driver will have different +requirements from a LIR. A 915-generation chipset wants all functions +inlined, all loops unrolled, all ifs flattened, no variable array +accesses, and matrix multiplication broken down. The Mesa IR backend +for swrast would like matrices and structure assignment broken down, +but it can support function calls and dynamic branching. A 965 vertex +shader IR backend could potentially even handle some matrix operations +without breaking them down, but the 965 fragment shader IR backend +would want to break to have (almost) all operations down channel-wise +and perform optimization on that. As a result, there's no single +low-level IR that will make everyone happy. So that usage has fallen +out of favor, and each driver will perform a series of lowering passes +to take the HIR down to whatever restrictions it wants to impose +before doing codegen. + +Q: How is the IR structured? + +A: The best way to get started seeing it would be to run the +standalone compiler against a shader: + +./glsl --dump-lir ~/src/piglit/tests/shaders/glsl-orangebook-ch06-bump.frag + +So for example one of the ir_instructions in main() contains: + +(assign (constant bool (1)) (var_ref litColor) (expression vec3 * (var_ref Surf +aceColor) (var_ref __retval) ) ) + +Or more visually: + (assign) + / | \ + (var_ref) (expression *) (constant bool 1) + / / \ +(litColor) (var_ref) (var_ref) + / \ + (SurfaceColor) (__retval) + +which came from: + +litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0); + +(the max call is not represented in this expression tree, as it was a +function call that got inlined but not brought into this expression +tree) + +Each of those nodes is a subclass of ir_instruction. A particular +ir_instruction instance may only appear once in the whole IR tree with +the exception of ir_variables, which appear once as variable +declarations: + +(declare () vec3 normDelta) + +and multiple times as the targets of variable dereferences: +... +(assign (constant bool (1)) (var_ref __retval) (expression float dot + (var_ref normDelta) (var_ref LightDir) ) ) +... +(assign (constant bool (1)) (var_ref __retval) (expression vec3 - + (var_ref LightDir) (expression vec3 * (constant float (2.000000)) + (expression vec3 * (expression float dot (var_ref normDelta) (var_ref + LightDir) ) (var_ref normDelta) ) ) ) ) +... + +Each node has a type. Expressions may involve several different types: +(declare (uniform ) mat4 gl_ModelViewMatrix) +((assign (constant bool (1)) (var_ref constructor_tmp) (expression + vec4 * (var_ref gl_ModelViewMatrix) (var_ref gl_Vertex) ) ) + +An expression tree can be arbitrarily deep, and the compiler tries to +keep them structured like that so that things like algebraic +optimizations ((color * 1.0 == color) and ((mat1 * mat2) * vec == mat1 +* (mat2 * vec))) or recognizing operation patterns for code generation +(vec1 * vec2 + vec3 == mad(vec1, vec2, vec3)) are easier. This comes +at the expense of additional trickery in implementing some +optimizations like CSE where one must navigate an expression tree. + +Q: Why no SSA representation? + +A: Converting an IR tree to SSA form makes dead code elmimination, +common subexpression elimination, and many other optimizations much +easier. However, in our primarily vector-based language, there's some +major questions as to how it would work. Do we do SSA on the scalar +or vector level? If we do it at the vector level, we're going to end +up with many different versions of the variable when encountering code +like: + +(assign (constant bool (1)) (swiz x (var_ref __retval) ) (var_ref a) ) +(assign (constant bool (1)) (swiz y (var_ref __retval) ) (var_ref b) ) +(assign (constant bool (1)) (swiz z (var_ref __retval) ) (var_ref c) ) + +If every masked update of a component relies on the previous value of +the variable, then we're probably going to be quite limited in our +dead code elimination wins, and recognizing common expressions may +just not happen. On the other hand, if we operate channel-wise, then +we'll be prone to optimizing the operation on one of the channels at +the expense of making its instruction flow different from the other +channels, and a vector-based GPU would end up with worse code than if +we didn't optimize operations on that channel! + +Once again, it appears that our optimization requirements are driven +significantly by the target architecture. For now, targeting the Mesa +IR backend, SSA does not appear to be that important to producing +excellent code, but we do expect to do some SSA-based optimizations +for the 965 fragment shader backend when that is developed. -- cgit v1.2.3 From 9aa0b6d728dafc40a65d1a45aa0830f87d76cb23 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 15:49:18 -0700 Subject: glsl2: Move the Mesa IR codegen into mesa/shader/ --- src/glsl/ir_to_mesa.cpp | 1211 ---------------------------------------- src/mesa/shader/ir_to_mesa.cpp | 1211 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1211 insertions(+), 1211 deletions(-) delete mode 100644 src/glsl/ir_to_mesa.cpp create mode 100644 src/mesa/shader/ir_to_mesa.cpp diff --git a/src/glsl/ir_to_mesa.cpp b/src/glsl/ir_to_mesa.cpp deleted file mode 100644 index 26449c5a5c4..00000000000 --- a/src/glsl/ir_to_mesa.cpp +++ /dev/null @@ -1,1211 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_to_mesa.cpp - * - * Translates the IR to ARB_fragment_program text if possible, - * printing the result - */ - -#include -#include "ir.h" -#include "ir_visitor.h" -#include "ir_print_visitor.h" -#include "ir_expression_flattening.h" -#include "glsl_types.h" - -extern "C" { -#include "shader/prog_instruction.h" -#include "shader/prog_print.h" -} - -/** - * This struct is a corresponding struct to Mesa prog_src_register, with - * wider fields. - */ -typedef struct ir_to_mesa_src_reg { - int file; /**< PROGRAM_* from Mesa */ - int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ - int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ - int negate; /**< NEGATE_XYZW mask from mesa */ - bool reladdr; /**< Register index should be offset by address reg. */ -} ir_to_mesa_src_reg; - -typedef struct ir_to_mesa_dst_reg { - int file; /**< PROGRAM_* from Mesa */ - int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ - int writemask; /**< Bitfield of WRITEMASK_[XYZW] */ -} ir_to_mesa_dst_reg; - -extern ir_to_mesa_src_reg ir_to_mesa_undef; - -class ir_to_mesa_instruction : public exec_node { -public: - enum prog_opcode op; - ir_to_mesa_dst_reg dst_reg; - ir_to_mesa_src_reg src_reg[3]; - /** Pointer to the ir source this tree came from for debugging */ - ir_instruction *ir; -}; - -class temp_entry : public exec_node { -public: - temp_entry(ir_variable *var, int file, int index) - : file(file), index(index), var(var) - { - /* empty */ - } - - int file; - int index; - ir_variable *var; /* variable that maps to this, if any */ -}; - -class ir_to_mesa_visitor : public ir_visitor { -public: - ir_to_mesa_visitor(); - - int next_temp; - int next_constant; - int next_uniform; - - temp_entry *find_variable_storage(ir_variable *var); - - ir_to_mesa_src_reg get_temp(const glsl_type *type); - - struct ir_to_mesa_src_reg src_reg_for_float(float val); - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_texture *); - virtual void visit(ir_if *); - /*@}*/ - - struct ir_to_mesa_src_reg result; - - /** List of temp_entry */ - exec_list variable_storage; - - /** List of ir_to_mesa_instruction */ - exec_list instructions; - - ir_to_mesa_instruction *ir_to_mesa_emit_op1(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0); - - ir_to_mesa_instruction *ir_to_mesa_emit_op2(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1); - - ir_to_mesa_instruction *ir_to_mesa_emit_op3(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1, - ir_to_mesa_src_reg src2); - - void ir_to_mesa_emit_scalar_op1(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0); - - /* talloc context (the ) */ - void *ctx; -}; - -ir_to_mesa_src_reg ir_to_mesa_undef = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, NEGATE_NONE, false, -}; - -ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP -}; - -ir_to_mesa_dst_reg ir_to_mesa_address_reg = { - PROGRAM_ADDRESS, 0, WRITEMASK_X -}; - -static int swizzle_for_size(int size) -{ - int size_swizzles[4] = { - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), - }; - - return size_swizzles[size - 1]; -} - -/* This list should match up with builtin_variables.h */ -static const struct { - const char *name; - int file; - int index; -} builtin_var_to_mesa_reg[] = { - /* core_vs */ - {"gl_Position", PROGRAM_OUTPUT, VERT_RESULT_HPOS}, - {"gl_PointSize", PROGRAM_OUTPUT, VERT_RESULT_PSIZ}, - - /* core_fs */ - {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS}, - {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE}, - {"gl_FragColor", PROGRAM_OUTPUT, FRAG_ATTRIB_COL0}, - {"gl_FragDepth", PROGRAM_UNDEFINED, FRAG_ATTRIB_WPOS}, /* FINISHME: WPOS.z */ - - /* 110_deprecated_fs */ - {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, - {"gl_SecondaryColor", PROGRAM_INPUT, FRAG_ATTRIB_COL1}, - {"gl_FogFragCoord", PROGRAM_INPUT, FRAG_ATTRIB_FOGC}, - {"gl_TexCoord", PROGRAM_INPUT, FRAG_ATTRIB_TEX0}, /* array */ - - /* 110_deprecated_vs */ - {"gl_Vertex", PROGRAM_INPUT, VERT_ATTRIB_POS}, - {"gl_Normal", PROGRAM_INPUT, VERT_ATTRIB_NORMAL}, - {"gl_Color", PROGRAM_INPUT, VERT_ATTRIB_COLOR0}, - {"gl_SecondaryColor", PROGRAM_INPUT, VERT_ATTRIB_COLOR1}, - {"gl_MultiTexCoord0", PROGRAM_INPUT, VERT_ATTRIB_TEX0}, - {"gl_MultiTexCoord1", PROGRAM_INPUT, VERT_ATTRIB_TEX1}, - {"gl_MultiTexCoord2", PROGRAM_INPUT, VERT_ATTRIB_TEX2}, - {"gl_MultiTexCoord3", PROGRAM_INPUT, VERT_ATTRIB_TEX3}, - {"gl_MultiTexCoord4", PROGRAM_INPUT, VERT_ATTRIB_TEX4}, - {"gl_MultiTexCoord5", PROGRAM_INPUT, VERT_ATTRIB_TEX5}, - {"gl_MultiTexCoord6", PROGRAM_INPUT, VERT_ATTRIB_TEX6}, - {"gl_MultiTexCoord7", PROGRAM_INPUT, VERT_ATTRIB_TEX7}, - {"gl_TexCoord", PROGRAM_OUTPUT, VERT_RESULT_TEX0}, /* array */ - {"gl_FogCoord", PROGRAM_INPUT, VERT_RESULT_FOGC}, - /*{"gl_ClipVertex", PROGRAM_OUTPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ - {"gl_FrontColor", PROGRAM_OUTPUT, VERT_RESULT_COL0}, - {"gl_BackColor", PROGRAM_OUTPUT, VERT_RESULT_BFC0}, - {"gl_FrontSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_COL1}, - {"gl_BackSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_BFC1}, - {"gl_FogFragCoord", PROGRAM_OUTPUT, VERT_RESULT_FOGC}, - - /* 130_vs */ - /*{"gl_VertexID", PROGRAM_INPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ - - {"gl_FragData", PROGRAM_OUTPUT, FRAG_RESULT_DATA0}, /* array */ -}; - -ir_to_mesa_instruction * -ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1, - ir_to_mesa_src_reg src2) -{ - ir_to_mesa_instruction *inst = new(ctx) ir_to_mesa_instruction(); - - inst->op = op; - inst->dst_reg = dst; - inst->src_reg[0] = src0; - inst->src_reg[1] = src1; - inst->src_reg[2] = src2; - inst->ir = ir; - - this->instructions.push_tail(inst); - - return inst; -} - - -ir_to_mesa_instruction * -ir_to_mesa_visitor::ir_to_mesa_emit_op2(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0, - ir_to_mesa_src_reg src1) -{ - return ir_to_mesa_emit_op3(ir, op, dst, src0, src1, ir_to_mesa_undef); -} - -ir_to_mesa_instruction * -ir_to_mesa_visitor::ir_to_mesa_emit_op1(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0) -{ - return ir_to_mesa_emit_op3(ir, op, dst, - src0, ir_to_mesa_undef, ir_to_mesa_undef); -} - -inline ir_to_mesa_dst_reg -ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) -{ - ir_to_mesa_dst_reg dst_reg; - - dst_reg.file = reg.file; - dst_reg.index = reg.index; - dst_reg.writemask = WRITEMASK_XYZW; - - return dst_reg; -} - -/** - * Emits Mesa scalar opcodes to produce unique answers across channels. - * - * Some Mesa opcodes are scalar-only, like ARB_fp/vp. The src X - * channel determines the result across all channels. So to do a vec4 - * of this operation, we want to emit a scalar per source channel used - * to produce dest channels. - */ -void -ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, - enum prog_opcode op, - ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0) -{ - int i, j; - int done_mask = ~dst.writemask; - - /* Mesa RCP is a scalar operation splatting results to all channels, - * like ARB_fp/vp. So emit as many RCPs as necessary to cover our - * dst channels. - */ - for (i = 0; i < 4; i++) { - int this_mask = (1 << i); - ir_to_mesa_instruction *inst; - ir_to_mesa_src_reg src = src0; - - if (done_mask & this_mask) - continue; - - int src_swiz = GET_SWZ(src.swizzle, i); - for (j = i + 1; j < 4; j++) { - if (!(done_mask & (1 << j)) && GET_SWZ(src.swizzle, j) == src_swiz) { - this_mask |= (1 << j); - } - } - src.swizzle = MAKE_SWIZZLE4(src_swiz, src_swiz, - src_swiz, src_swiz); - - inst = ir_to_mesa_emit_op1(ir, op, - dst, - src); - inst->dst_reg.writemask = this_mask; - done_mask |= this_mask; - } -} - -struct ir_to_mesa_src_reg -ir_to_mesa_visitor::src_reg_for_float(float val) -{ - ir_to_mesa_src_reg src_reg; - - /* FINISHME: This will end up being _mesa_add_unnamed_constant, - * which handles sharing values and sharing channels of vec4 - * constants for small values. - */ - /* FINISHME: Do something with the constant values for now. - */ - (void)val; - src_reg.file = PROGRAM_CONSTANT; - src_reg.index = this->next_constant++; - src_reg.swizzle = SWIZZLE_NOOP; - - return src_reg; -} - -/** - * In the initial pass of codegen, we assign temporary numbers to - * intermediate results. (not SSA -- variable assignments will reuse - * storage). Actual register allocation for the Mesa VM occurs in a - * pass over the Mesa IR later. - */ -ir_to_mesa_src_reg -ir_to_mesa_visitor::get_temp(const glsl_type *type) -{ - ir_to_mesa_src_reg src_reg; - int swizzle[4]; - int i; - - assert(!type->is_array()); - - src_reg.file = PROGRAM_TEMPORARY; - src_reg.index = type->matrix_columns; - src_reg.reladdr = false; - - for (i = 0; i < type->vector_elements; i++) - swizzle[i] = i; - for (; i < 4; i++) - swizzle[i] = type->vector_elements - 1; - src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], - swizzle[2], swizzle[3]); - - return src_reg; -} - -static int -type_size(const struct glsl_type *type) -{ - unsigned int i; - int size; - - switch (type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_BOOL: - if (type->is_matrix()) { - return 4; /* FINISHME: Not all matrices are 4x4. */ - } else { - /* Regardless of size of vector, it gets a vec4. This is bad - * packing for things like floats, but otherwise arrays become a - * mess. Hopefully a later pass over the code can pack scalars - * down if appropriate. - */ - return 1; - } - case GLSL_TYPE_ARRAY: - return type_size(type->fields.array) * type->length; - case GLSL_TYPE_STRUCT: - size = 0; - for (i = 0; i < type->length; i++) { - size += type_size(type->fields.structure[i].type); - } - return size; - default: - assert(0); - } -} - -temp_entry * -ir_to_mesa_visitor::find_variable_storage(ir_variable *var) -{ - - temp_entry *entry; - - foreach_iter(exec_list_iterator, iter, this->variable_storage) { - entry = (temp_entry *)iter.get(); - - if (entry->var == var) - return entry; - } - - return NULL; -} - -void -ir_to_mesa_visitor::visit(ir_variable *ir) -{ - (void)ir; -} - -void -ir_to_mesa_visitor::visit(ir_loop *ir) -{ - assert(!ir->from); - assert(!ir->to); - assert(!ir->increment); - assert(!ir->counter); - - ir_to_mesa_emit_op1(NULL, OPCODE_BGNLOOP, - ir_to_mesa_undef_dst, ir_to_mesa_undef); - - visit_exec_list(&ir->body_instructions, this); - - ir_to_mesa_emit_op1(NULL, OPCODE_ENDLOOP, - ir_to_mesa_undef_dst, ir_to_mesa_undef); -} - -void -ir_to_mesa_visitor::visit(ir_loop_jump *ir) -{ - switch (ir->mode) { - case ir_loop_jump::jump_break: - ir_to_mesa_emit_op1(NULL, OPCODE_BRK, - ir_to_mesa_undef_dst, ir_to_mesa_undef); - break; - case ir_loop_jump::jump_continue: - ir_to_mesa_emit_op1(NULL, OPCODE_CONT, - ir_to_mesa_undef_dst, ir_to_mesa_undef); - break; - } -} - - -void -ir_to_mesa_visitor::visit(ir_function_signature *ir) -{ - assert(0); - (void)ir; -} - -void -ir_to_mesa_visitor::visit(ir_function *ir) -{ - /* Ignore function bodies other than main() -- we shouldn't see calls to - * them since they should all be inlined before we get to ir_to_mesa. - */ - if (strcmp(ir->name, "main") == 0) { - const ir_function_signature *sig; - exec_list empty; - - sig = ir->matching_signature(&empty); - - assert(sig); - - foreach_iter(exec_list_iterator, iter, sig->body) { - ir_instruction *ir = (ir_instruction *)iter.get(); - - ir->accept(this); - } - } -} - -void -ir_to_mesa_visitor::visit(ir_expression *ir) -{ - unsigned int operand; - struct ir_to_mesa_src_reg op[2]; - struct ir_to_mesa_src_reg result_src; - struct ir_to_mesa_dst_reg result_dst; - const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); - const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); - const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - this->result.file = PROGRAM_UNDEFINED; - ir->operands[operand]->accept(this); - if (this->result.file == PROGRAM_UNDEFINED) { - ir_print_visitor v; - printf("Failed to get tree for expression operand:\n"); - ir->operands[operand]->accept(&v); - exit(1); - } - op[operand] = this->result; - - /* Only expression implemented for matrices yet */ - assert(!ir->operands[operand]->type->is_matrix() || - ir->operation == ir_binop_mul); - } - - this->result.file = PROGRAM_UNDEFINED; - - /* Storage for our result. Ideally for an assignment we'd be using - * the actual storage for the result here, instead. - */ - result_src = get_temp(ir->type); - /* convenience for the emit functions below. */ - result_dst = ir_to_mesa_dst_reg_from_src(result_src); - /* Limit writes to the channels that will be used by result_src later. - * This does limit this temp's use as a temporary for multi-instruction - * sequences. - */ - result_dst.writemask = (1 << ir->type->vector_elements) - 1; - - switch (ir->operation) { - case ir_unop_logic_not: - ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, - op[0], src_reg_for_float(0.0)); - break; - case ir_unop_neg: - op[0].negate = ~op[0].negate; - result_src = op[0]; - break; - case ir_unop_exp: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_EXP, result_dst, op[0]); - break; - case ir_unop_exp2: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_EX2, result_dst, op[0]); - break; - case ir_unop_log: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_LOG, result_dst, op[0]); - break; - case ir_unop_log2: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_LG2, result_dst, op[0]); - break; - case ir_unop_sin: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_SIN, result_dst, op[0]); - break; - case ir_unop_cos: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_COS, result_dst, op[0]); - break; - case ir_binop_add: - ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]); - break; - case ir_binop_sub: - ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); - break; - case ir_binop_mul: - if (ir->operands[0]->type->is_matrix() && - !ir->operands[1]->type->is_matrix()) { - if (ir->operands[0]->type->is_scalar()) { - ir_to_mesa_dst_reg dst_column = result_dst; - ir_to_mesa_src_reg src_column = op[0]; - for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - dst_column, src_column, op[1]); - dst_column.index++; - src_column.index++; - } - } else { - ir_to_mesa_dst_reg dst_chan = result_dst; - ir_to_mesa_src_reg src_column = op[0]; - ir_to_mesa_src_reg src_chan = op[1]; - for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { - dst_chan.writemask = (1 << i); - src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - dst_chan, src_column, src_chan); - src_column.index++; - } - } - } else { - assert(!ir->operands[0]->type->is_matrix()); - assert(!ir->operands[1]->type->is_matrix()); - ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], op[1]); - } - break; - case ir_binop_div: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[1]); - ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], result_src); - break; - - case ir_binop_less: - ir_to_mesa_emit_op2(ir, OPCODE_SLT, result_dst, op[0], op[1]); - break; - case ir_binop_greater: - ir_to_mesa_emit_op2(ir, OPCODE_SGT, result_dst, op[0], op[1]); - break; - case ir_binop_lequal: - ir_to_mesa_emit_op2(ir, OPCODE_SLE, result_dst, op[0], op[1]); - break; - case ir_binop_gequal: - ir_to_mesa_emit_op2(ir, OPCODE_SGE, result_dst, op[0], op[1]); - break; - case ir_binop_equal: - ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, op[0], op[1]); - break; - case ir_binop_logic_xor: - case ir_binop_nequal: - ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, op[0], op[1]); - break; - - case ir_binop_logic_or: - /* This could be a saturated add and skip the SNE. */ - ir_to_mesa_emit_op2(ir, OPCODE_ADD, - result_dst, - op[0], op[1]); - - ir_to_mesa_emit_op2(ir, OPCODE_SNE, - result_dst, - result_src, src_reg_for_float(0.0)); - break; - - case ir_binop_logic_and: - /* the bool args are stored as float 0.0 or 1.0, so "mul" gives us "and". */ - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - result_dst, - op[0], op[1]); - break; - - case ir_binop_dot: - if (ir->operands[0]->type == vec4_type) { - assert(ir->operands[1]->type == vec4_type); - ir_to_mesa_emit_op2(ir, OPCODE_DP4, - result_dst, - op[0], op[1]); - } else if (ir->operands[0]->type == vec3_type) { - assert(ir->operands[1]->type == vec3_type); - ir_to_mesa_emit_op2(ir, OPCODE_DP3, - result_dst, - op[0], op[1]); - } else if (ir->operands[0]->type == vec2_type) { - assert(ir->operands[1]->type == vec2_type); - ir_to_mesa_emit_op2(ir, OPCODE_DP2, - result_dst, - op[0], op[1]); - } - break; - case ir_unop_sqrt: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); - ir_to_mesa_emit_op1(ir, OPCODE_RCP, result_dst, result_src); - break; - case ir_unop_rsq: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); - break; - case ir_unop_i2f: - /* Mesa IR lacks types, ints are stored as truncated floats. */ - result_src = op[0]; - break; - case ir_unop_f2i: - ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); - break; - case ir_unop_f2b: - ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, - result_src, src_reg_for_float(0.0)); - break; - case ir_unop_trunc: - ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); - break; - case ir_unop_ceil: - op[0].negate = ~op[0].negate; - ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); - result_src.negate = ~result_src.negate; - break; - case ir_unop_floor: - ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); - break; - case ir_binop_min: - ir_to_mesa_emit_op2(ir, OPCODE_MIN, result_dst, op[0], op[1]); - break; - case ir_binop_max: - ir_to_mesa_emit_op2(ir, OPCODE_MAX, result_dst, op[0], op[1]); - break; - default: - ir_print_visitor v; - printf("Failed to get tree for expression:\n"); - ir->accept(&v); - exit(1); - break; - } - - this->result = result_src; -} - - -void -ir_to_mesa_visitor::visit(ir_swizzle *ir) -{ - ir_to_mesa_src_reg src_reg; - int i; - int swizzle[4]; - - /* Note that this is only swizzles in expressions, not those on the left - * hand side of an assignment, which do write masking. See ir_assignment - * for that. - */ - - ir->val->accept(this); - src_reg = this->result; - assert(src_reg.file != PROGRAM_UNDEFINED); - - for (i = 0; i < 4; i++) { - if (i < ir->type->vector_elements) { - switch (i) { - case 0: - swizzle[i] = ir->mask.x; - break; - case 1: - swizzle[i] = ir->mask.y; - break; - case 2: - swizzle[i] = ir->mask.z; - break; - case 3: - swizzle[i] = ir->mask.w; - break; - } - } else { - /* If the type is smaller than a vec4, replicate the last - * channel out. - */ - swizzle[i] = ir->type->vector_elements - 1; - } - } - - src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], - swizzle[1], - swizzle[2], - swizzle[3]); - - this->result = src_reg; -} - -void -ir_to_mesa_visitor::visit(ir_dereference_variable *ir) -{ - ir_to_mesa_src_reg src_reg; - temp_entry *entry = find_variable_storage(ir->var); - unsigned int i; - bool var_in; - - if (!entry) { - switch (ir->var->mode) { - case ir_var_uniform: - entry = new(ctx) temp_entry(ir->var, PROGRAM_UNIFORM, - this->next_uniform); - this->variable_storage.push_tail(entry); - - this->next_uniform += type_size(ir->var->type); - break; - case ir_var_in: - case ir_var_out: - case ir_var_inout: - var_in = (ir->var->mode == ir_var_in || - ir->var->mode == ir_var_inout); - - for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { - bool in = builtin_var_to_mesa_reg[i].file == PROGRAM_INPUT; - - if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0 && - !(var_in ^ in)) - break; - } - if (i == ARRAY_SIZE(builtin_var_to_mesa_reg)) { - printf("Failed to find builtin for %s variable %s\n", - var_in ? "in" : "out", - ir->var->name); - abort(); - } - entry = new(ctx) temp_entry(ir->var, - builtin_var_to_mesa_reg[i].file, - builtin_var_to_mesa_reg[i].index); - break; - case ir_var_auto: - entry = new(ctx) temp_entry(ir->var, PROGRAM_TEMPORARY, - this->next_temp); - this->variable_storage.push_tail(entry); - - next_temp += type_size(ir->var->type); - break; - } - - if (!entry) { - printf("Failed to make storage for %s\n", ir->var->name); - exit(1); - } - } - - src_reg.file = entry->file; - src_reg.index = entry->index; - /* If the type is smaller than a vec4, replicate the last channel out. */ - src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); - src_reg.reladdr = false; - src_reg.negate = 0; - - this->result = src_reg; -} - -void -ir_to_mesa_visitor::visit(ir_dereference_array *ir) -{ - ir_constant *index; - ir_to_mesa_src_reg src_reg; - - index = ir->array_index->constant_expression_value(); - - /* By the time we make it to this stage, matrices should be broken down - * to vectors. - */ - assert(!ir->type->is_matrix()); - - ir->array->accept(this); - src_reg = this->result; - - if (src_reg.file == PROGRAM_INPUT || - src_reg.file == PROGRAM_OUTPUT) { - assert(index); /* FINISHME: Handle variable indexing of builtins. */ - - src_reg.index += index->value.i[0]; - } else { - if (index) { - src_reg.index += index->value.i[0]; - } else { - ir_to_mesa_src_reg array_base = this->result; - /* Variable index array dereference. It eats the "vec4" of the - * base of the array and an index that offsets the Mesa register - * index. - */ - ir->array_index->accept(this); - - /* FINISHME: This doesn't work when we're trying to do the LHS - * of an assignment. - */ - src_reg.reladdr = true; - ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, - this->result); - - this->result = get_temp(ir->type); - ir_to_mesa_emit_op1(ir, OPCODE_MOV, - ir_to_mesa_dst_reg_from_src(this->result), - src_reg); - } - } - - /* If the type is smaller than a vec4, replicate the last channel out. */ - src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); - - this->result = src_reg; -} - -void -ir_to_mesa_visitor::visit(ir_dereference_record *ir) -{ - unsigned int i; - const glsl_type *struct_type = ir->record->type; - int offset = 0; - - ir->record->accept(this); - - for (i = 0; i < struct_type->length; i++) { - if (strcmp(struct_type->fields.structure[i].name, ir->field) == 0) - break; - offset += type_size(struct_type->fields.structure[i].type); - } - this->result.index += offset; -} - -/** - * We want to be careful in assignment setup to hit the actual storage - * instead of potentially using a temporary like we might with the - * ir_dereference handler. - * - * Thanks to ir_swizzle_swizzle, and ir_vec_index_to_swizzle, we - * should only see potentially one variable array index of a vector, - * and one swizzle, before getting to actual vec4 storage. So handle - * those, then go use ir_dereference to handle the rest. - */ -static struct ir_to_mesa_dst_reg -get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) -{ - struct ir_to_mesa_dst_reg dst_reg; - ir_dereference *deref; - ir_swizzle *swiz; - - /* Use the rvalue deref handler for the most part. We'll ignore - * swizzles in it and write swizzles using writemask, though. - */ - ir->accept(v); - dst_reg = ir_to_mesa_dst_reg_from_src(v->result); - - if ((deref = ir->as_dereference())) { - ir_dereference_array *deref_array = ir->as_dereference_array(); - assert(!deref_array || deref_array->array->type->is_array()); - - ir->accept(v); - } else if ((swiz = ir->as_swizzle())) { - dst_reg.writemask = 0; - if (swiz->mask.num_components >= 1) - dst_reg.writemask |= (1 << swiz->mask.x); - if (swiz->mask.num_components >= 2) - dst_reg.writemask |= (1 << swiz->mask.y); - if (swiz->mask.num_components >= 3) - dst_reg.writemask |= (1 << swiz->mask.z); - if (swiz->mask.num_components >= 4) - dst_reg.writemask |= (1 << swiz->mask.w); - } - - return dst_reg; -} - -void -ir_to_mesa_visitor::visit(ir_assignment *ir) -{ - struct ir_to_mesa_dst_reg l; - struct ir_to_mesa_src_reg r; - - assert(!ir->lhs->type->is_matrix()); - assert(!ir->lhs->type->is_array()); - assert(ir->lhs->type->base_type != GLSL_TYPE_STRUCT); - - l = get_assignment_lhs(ir->lhs, this); - - ir->rhs->accept(this); - r = this->result; - assert(l.file != PROGRAM_UNDEFINED); - assert(r.file != PROGRAM_UNDEFINED); - - if (ir->condition) { - ir_constant *condition_constant; - - condition_constant = ir->condition->constant_expression_value(); - - assert(condition_constant && condition_constant->value.b[0]); - } - - ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); -} - - -void -ir_to_mesa_visitor::visit(ir_constant *ir) -{ - ir_to_mesa_src_reg src_reg; - - assert(ir->type->base_type == GLSL_TYPE_FLOAT || - ir->type->base_type == GLSL_TYPE_UINT || - ir->type->base_type == GLSL_TYPE_INT || - ir->type->base_type == GLSL_TYPE_BOOL); - - /* FINISHME: This will end up being _mesa_add_unnamed_constant, - * which handles sharing values and sharing channels of vec4 - * constants for small values. - */ - /* FINISHME: Do something with the constant values for now. - */ - src_reg.file = PROGRAM_CONSTANT; - src_reg.index = this->next_constant; - src_reg.swizzle = SWIZZLE_NOOP; - src_reg.reladdr = false; - src_reg.negate = 0; - - this->next_constant += type_size(ir->type); - - this->result = src_reg; -} - - -void -ir_to_mesa_visitor::visit(ir_call *ir) -{ - printf("Can't support call to %s\n", ir->callee_name()); - exit(1); -} - - -void -ir_to_mesa_visitor::visit(ir_texture *ir) -{ - assert(0); - - ir->coordinate->accept(this); -} - -void -ir_to_mesa_visitor::visit(ir_return *ir) -{ - assert(0); - - ir->get_value()->accept(this); -} - - -void -ir_to_mesa_visitor::visit(ir_if *ir) -{ - ir_to_mesa_instruction *if_inst, *else_inst = NULL; - - ir->condition->accept(this); - assert(this->result.file != PROGRAM_UNDEFINED); - - if_inst = ir_to_mesa_emit_op1(ir->condition, - OPCODE_IF, ir_to_mesa_undef_dst, - this->result); - - this->instructions.push_tail(if_inst); - - visit_exec_list(&ir->then_instructions, this); - - if (!ir->else_instructions.is_empty()) { - else_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ELSE, - ir_to_mesa_undef_dst, - ir_to_mesa_undef); - visit_exec_list(&ir->then_instructions, this); - } - - if_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ENDIF, - ir_to_mesa_undef_dst, ir_to_mesa_undef); -} - -ir_to_mesa_visitor::ir_to_mesa_visitor() -{ - result.file = PROGRAM_UNDEFINED; - next_temp = 1; - next_constant = 0; - next_uniform = 0; -} - -static struct prog_src_register -mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) -{ - struct prog_src_register mesa_reg; - - mesa_reg.File = reg.file; - assert(reg.index < (1 << INST_INDEX_BITS) - 1); - mesa_reg.Index = reg.index; - mesa_reg.Swizzle = reg.swizzle; - mesa_reg.RelAddr = reg.reladdr; - - return mesa_reg; -} - -static void -set_branchtargets(struct prog_instruction *mesa_instructions, - int num_instructions) -{ - int if_count = 0, loop_count; - int *if_stack, *loop_stack; - int if_stack_pos = 0, loop_stack_pos = 0; - int i, j; - - for (i = 0; i < num_instructions; i++) { - switch (mesa_instructions[i].Opcode) { - case OPCODE_IF: - if_count++; - break; - case OPCODE_BGNLOOP: - loop_count++; - break; - case OPCODE_BRK: - case OPCODE_CONT: - mesa_instructions[i].BranchTarget = -1; - break; - default: - break; - } - } - - if_stack = (int *)calloc(if_count, sizeof(*if_stack)); - loop_stack = (int *)calloc(loop_count, sizeof(*loop_stack)); - - for (i = 0; i < num_instructions; i++) { - switch (mesa_instructions[i].Opcode) { - case OPCODE_IF: - if_stack[if_stack_pos] = i; - if_stack_pos++; - break; - case OPCODE_ELSE: - mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; - if_stack[if_stack_pos - 1] = i; - break; - case OPCODE_ENDIF: - mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; - if_stack_pos--; - break; - case OPCODE_BGNLOOP: - loop_stack[loop_stack_pos] = i; - loop_stack_pos++; - break; - case OPCODE_ENDLOOP: - loop_stack_pos--; - /* Rewrite any breaks/conts at this nesting level (haven't - * already had a BranchTarget assigned) to point to the end - * of the loop. - */ - for (j = loop_stack[loop_stack_pos]; j < i; j++) { - if (mesa_instructions[j].Opcode == OPCODE_BRK || - mesa_instructions[j].Opcode == OPCODE_CONT) { - if (mesa_instructions[j].BranchTarget == -1) { - mesa_instructions[j].BranchTarget = i; - } - } - } - /* The loop ends point at each other. */ - mesa_instructions[i].BranchTarget = loop_stack[loop_stack_pos]; - mesa_instructions[loop_stack[loop_stack_pos]].BranchTarget = i; - default: - break; - } - } - - free(if_stack); -} - -static void -print_program(struct prog_instruction *mesa_instructions, - ir_instruction **mesa_instruction_annotation, - int num_instructions) -{ - ir_instruction *last_ir = NULL; - int i; - - for (i = 0; i < num_instructions; i++) { - struct prog_instruction *mesa_inst = mesa_instructions + i; - ir_instruction *ir = mesa_instruction_annotation[i]; - - if (last_ir != ir && ir) { - ir_print_visitor print; - ir->accept(&print); - printf("\n"); - last_ir = ir; - } - - _mesa_print_instruction(mesa_inst); - } -} - -void -do_ir_to_mesa(exec_list *instructions) -{ - ir_to_mesa_visitor v; - struct prog_instruction *mesa_instructions, *mesa_inst; - ir_instruction **mesa_instruction_annotation; - int i; - - v.ctx = talloc_new(NULL); - visit_exec_list(instructions, &v); - - int num_instructions = 0; - foreach_iter(exec_list_iterator, iter, v.instructions) { - num_instructions++; - } - - mesa_instructions = - (struct prog_instruction *)calloc(num_instructions, - sizeof(*mesa_instructions)); - mesa_instruction_annotation = - (ir_instruction **)calloc(num_instructions, - sizeof(*mesa_instruction_annotation)); - - mesa_inst = mesa_instructions; - i = 0; - foreach_iter(exec_list_iterator, iter, v.instructions) { - ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); - - mesa_inst->Opcode = inst->op; - mesa_inst->DstReg.File = inst->dst_reg.file; - mesa_inst->DstReg.Index = inst->dst_reg.index; - mesa_inst->DstReg.CondMask = COND_TR; - mesa_inst->DstReg.WriteMask = inst->dst_reg.writemask; - mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); - mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); - mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); - mesa_instruction_annotation[i] = inst->ir; - - mesa_inst++; - i++; - } - - set_branchtargets(mesa_instructions, num_instructions); - print_program(mesa_instructions, mesa_instruction_annotation, num_instructions); - - free(mesa_instruction_annotation); - talloc_free(v.ctx); -} diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp new file mode 100644 index 00000000000..26449c5a5c4 --- /dev/null +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -0,0 +1,1211 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_to_mesa.cpp + * + * Translates the IR to ARB_fragment_program text if possible, + * printing the result + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "ir_print_visitor.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +extern "C" { +#include "shader/prog_instruction.h" +#include "shader/prog_print.h" +} + +/** + * This struct is a corresponding struct to Mesa prog_src_register, with + * wider fields. + */ +typedef struct ir_to_mesa_src_reg { + int file; /**< PROGRAM_* from Mesa */ + int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ + int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ + int negate; /**< NEGATE_XYZW mask from mesa */ + bool reladdr; /**< Register index should be offset by address reg. */ +} ir_to_mesa_src_reg; + +typedef struct ir_to_mesa_dst_reg { + int file; /**< PROGRAM_* from Mesa */ + int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ + int writemask; /**< Bitfield of WRITEMASK_[XYZW] */ +} ir_to_mesa_dst_reg; + +extern ir_to_mesa_src_reg ir_to_mesa_undef; + +class ir_to_mesa_instruction : public exec_node { +public: + enum prog_opcode op; + ir_to_mesa_dst_reg dst_reg; + ir_to_mesa_src_reg src_reg[3]; + /** Pointer to the ir source this tree came from for debugging */ + ir_instruction *ir; +}; + +class temp_entry : public exec_node { +public: + temp_entry(ir_variable *var, int file, int index) + : file(file), index(index), var(var) + { + /* empty */ + } + + int file; + int index; + ir_variable *var; /* variable that maps to this, if any */ +}; + +class ir_to_mesa_visitor : public ir_visitor { +public: + ir_to_mesa_visitor(); + + int next_temp; + int next_constant; + int next_uniform; + + temp_entry *find_variable_storage(ir_variable *var); + + ir_to_mesa_src_reg get_temp(const glsl_type *type); + + struct ir_to_mesa_src_reg src_reg_for_float(float val); + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_texture *); + virtual void visit(ir_if *); + /*@}*/ + + struct ir_to_mesa_src_reg result; + + /** List of temp_entry */ + exec_list variable_storage; + + /** List of ir_to_mesa_instruction */ + exec_list instructions; + + ir_to_mesa_instruction *ir_to_mesa_emit_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); + + ir_to_mesa_instruction *ir_to_mesa_emit_op2(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1); + + ir_to_mesa_instruction *ir_to_mesa_emit_op3(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1, + ir_to_mesa_src_reg src2); + + void ir_to_mesa_emit_scalar_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0); + + /* talloc context (the ) */ + void *ctx; +}; + +ir_to_mesa_src_reg ir_to_mesa_undef = { + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, NEGATE_NONE, false, +}; + +ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP +}; + +ir_to_mesa_dst_reg ir_to_mesa_address_reg = { + PROGRAM_ADDRESS, 0, WRITEMASK_X +}; + +static int swizzle_for_size(int size) +{ + int size_swizzles[4] = { + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), + MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), + }; + + return size_swizzles[size - 1]; +} + +/* This list should match up with builtin_variables.h */ +static const struct { + const char *name; + int file; + int index; +} builtin_var_to_mesa_reg[] = { + /* core_vs */ + {"gl_Position", PROGRAM_OUTPUT, VERT_RESULT_HPOS}, + {"gl_PointSize", PROGRAM_OUTPUT, VERT_RESULT_PSIZ}, + + /* core_fs */ + {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS}, + {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE}, + {"gl_FragColor", PROGRAM_OUTPUT, FRAG_ATTRIB_COL0}, + {"gl_FragDepth", PROGRAM_UNDEFINED, FRAG_ATTRIB_WPOS}, /* FINISHME: WPOS.z */ + + /* 110_deprecated_fs */ + {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, + {"gl_SecondaryColor", PROGRAM_INPUT, FRAG_ATTRIB_COL1}, + {"gl_FogFragCoord", PROGRAM_INPUT, FRAG_ATTRIB_FOGC}, + {"gl_TexCoord", PROGRAM_INPUT, FRAG_ATTRIB_TEX0}, /* array */ + + /* 110_deprecated_vs */ + {"gl_Vertex", PROGRAM_INPUT, VERT_ATTRIB_POS}, + {"gl_Normal", PROGRAM_INPUT, VERT_ATTRIB_NORMAL}, + {"gl_Color", PROGRAM_INPUT, VERT_ATTRIB_COLOR0}, + {"gl_SecondaryColor", PROGRAM_INPUT, VERT_ATTRIB_COLOR1}, + {"gl_MultiTexCoord0", PROGRAM_INPUT, VERT_ATTRIB_TEX0}, + {"gl_MultiTexCoord1", PROGRAM_INPUT, VERT_ATTRIB_TEX1}, + {"gl_MultiTexCoord2", PROGRAM_INPUT, VERT_ATTRIB_TEX2}, + {"gl_MultiTexCoord3", PROGRAM_INPUT, VERT_ATTRIB_TEX3}, + {"gl_MultiTexCoord4", PROGRAM_INPUT, VERT_ATTRIB_TEX4}, + {"gl_MultiTexCoord5", PROGRAM_INPUT, VERT_ATTRIB_TEX5}, + {"gl_MultiTexCoord6", PROGRAM_INPUT, VERT_ATTRIB_TEX6}, + {"gl_MultiTexCoord7", PROGRAM_INPUT, VERT_ATTRIB_TEX7}, + {"gl_TexCoord", PROGRAM_OUTPUT, VERT_RESULT_TEX0}, /* array */ + {"gl_FogCoord", PROGRAM_INPUT, VERT_RESULT_FOGC}, + /*{"gl_ClipVertex", PROGRAM_OUTPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ + {"gl_FrontColor", PROGRAM_OUTPUT, VERT_RESULT_COL0}, + {"gl_BackColor", PROGRAM_OUTPUT, VERT_RESULT_BFC0}, + {"gl_FrontSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_COL1}, + {"gl_BackSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_BFC1}, + {"gl_FogFragCoord", PROGRAM_OUTPUT, VERT_RESULT_FOGC}, + + /* 130_vs */ + /*{"gl_VertexID", PROGRAM_INPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ + + {"gl_FragData", PROGRAM_OUTPUT, FRAG_RESULT_DATA0}, /* array */ +}; + +ir_to_mesa_instruction * +ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1, + ir_to_mesa_src_reg src2) +{ + ir_to_mesa_instruction *inst = new(ctx) ir_to_mesa_instruction(); + + inst->op = op; + inst->dst_reg = dst; + inst->src_reg[0] = src0; + inst->src_reg[1] = src1; + inst->src_reg[2] = src2; + inst->ir = ir; + + this->instructions.push_tail(inst); + + return inst; +} + + +ir_to_mesa_instruction * +ir_to_mesa_visitor::ir_to_mesa_emit_op2(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1) +{ + return ir_to_mesa_emit_op3(ir, op, dst, src0, src1, ir_to_mesa_undef); +} + +ir_to_mesa_instruction * +ir_to_mesa_visitor::ir_to_mesa_emit_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0) +{ + return ir_to_mesa_emit_op3(ir, op, dst, + src0, ir_to_mesa_undef, ir_to_mesa_undef); +} + +inline ir_to_mesa_dst_reg +ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) +{ + ir_to_mesa_dst_reg dst_reg; + + dst_reg.file = reg.file; + dst_reg.index = reg.index; + dst_reg.writemask = WRITEMASK_XYZW; + + return dst_reg; +} + +/** + * Emits Mesa scalar opcodes to produce unique answers across channels. + * + * Some Mesa opcodes are scalar-only, like ARB_fp/vp. The src X + * channel determines the result across all channels. So to do a vec4 + * of this operation, we want to emit a scalar per source channel used + * to produce dest channels. + */ +void +ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0) +{ + int i, j; + int done_mask = ~dst.writemask; + + /* Mesa RCP is a scalar operation splatting results to all channels, + * like ARB_fp/vp. So emit as many RCPs as necessary to cover our + * dst channels. + */ + for (i = 0; i < 4; i++) { + int this_mask = (1 << i); + ir_to_mesa_instruction *inst; + ir_to_mesa_src_reg src = src0; + + if (done_mask & this_mask) + continue; + + int src_swiz = GET_SWZ(src.swizzle, i); + for (j = i + 1; j < 4; j++) { + if (!(done_mask & (1 << j)) && GET_SWZ(src.swizzle, j) == src_swiz) { + this_mask |= (1 << j); + } + } + src.swizzle = MAKE_SWIZZLE4(src_swiz, src_swiz, + src_swiz, src_swiz); + + inst = ir_to_mesa_emit_op1(ir, op, + dst, + src); + inst->dst_reg.writemask = this_mask; + done_mask |= this_mask; + } +} + +struct ir_to_mesa_src_reg +ir_to_mesa_visitor::src_reg_for_float(float val) +{ + ir_to_mesa_src_reg src_reg; + + /* FINISHME: This will end up being _mesa_add_unnamed_constant, + * which handles sharing values and sharing channels of vec4 + * constants for small values. + */ + /* FINISHME: Do something with the constant values for now. + */ + (void)val; + src_reg.file = PROGRAM_CONSTANT; + src_reg.index = this->next_constant++; + src_reg.swizzle = SWIZZLE_NOOP; + + return src_reg; +} + +/** + * In the initial pass of codegen, we assign temporary numbers to + * intermediate results. (not SSA -- variable assignments will reuse + * storage). Actual register allocation for the Mesa VM occurs in a + * pass over the Mesa IR later. + */ +ir_to_mesa_src_reg +ir_to_mesa_visitor::get_temp(const glsl_type *type) +{ + ir_to_mesa_src_reg src_reg; + int swizzle[4]; + int i; + + assert(!type->is_array()); + + src_reg.file = PROGRAM_TEMPORARY; + src_reg.index = type->matrix_columns; + src_reg.reladdr = false; + + for (i = 0; i < type->vector_elements; i++) + swizzle[i] = i; + for (; i < 4; i++) + swizzle[i] = type->vector_elements - 1; + src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], + swizzle[2], swizzle[3]); + + return src_reg; +} + +static int +type_size(const struct glsl_type *type) +{ + unsigned int i; + int size; + + switch (type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + if (type->is_matrix()) { + return 4; /* FINISHME: Not all matrices are 4x4. */ + } else { + /* Regardless of size of vector, it gets a vec4. This is bad + * packing for things like floats, but otherwise arrays become a + * mess. Hopefully a later pass over the code can pack scalars + * down if appropriate. + */ + return 1; + } + case GLSL_TYPE_ARRAY: + return type_size(type->fields.array) * type->length; + case GLSL_TYPE_STRUCT: + size = 0; + for (i = 0; i < type->length; i++) { + size += type_size(type->fields.structure[i].type); + } + return size; + default: + assert(0); + } +} + +temp_entry * +ir_to_mesa_visitor::find_variable_storage(ir_variable *var) +{ + + temp_entry *entry; + + foreach_iter(exec_list_iterator, iter, this->variable_storage) { + entry = (temp_entry *)iter.get(); + + if (entry->var == var) + return entry; + } + + return NULL; +} + +void +ir_to_mesa_visitor::visit(ir_variable *ir) +{ + (void)ir; +} + +void +ir_to_mesa_visitor::visit(ir_loop *ir) +{ + assert(!ir->from); + assert(!ir->to); + assert(!ir->increment); + assert(!ir->counter); + + ir_to_mesa_emit_op1(NULL, OPCODE_BGNLOOP, + ir_to_mesa_undef_dst, ir_to_mesa_undef); + + visit_exec_list(&ir->body_instructions, this); + + ir_to_mesa_emit_op1(NULL, OPCODE_ENDLOOP, + ir_to_mesa_undef_dst, ir_to_mesa_undef); +} + +void +ir_to_mesa_visitor::visit(ir_loop_jump *ir) +{ + switch (ir->mode) { + case ir_loop_jump::jump_break: + ir_to_mesa_emit_op1(NULL, OPCODE_BRK, + ir_to_mesa_undef_dst, ir_to_mesa_undef); + break; + case ir_loop_jump::jump_continue: + ir_to_mesa_emit_op1(NULL, OPCODE_CONT, + ir_to_mesa_undef_dst, ir_to_mesa_undef); + break; + } +} + + +void +ir_to_mesa_visitor::visit(ir_function_signature *ir) +{ + assert(0); + (void)ir; +} + +void +ir_to_mesa_visitor::visit(ir_function *ir) +{ + /* Ignore function bodies other than main() -- we shouldn't see calls to + * them since they should all be inlined before we get to ir_to_mesa. + */ + if (strcmp(ir->name, "main") == 0) { + const ir_function_signature *sig; + exec_list empty; + + sig = ir->matching_signature(&empty); + + assert(sig); + + foreach_iter(exec_list_iterator, iter, sig->body) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + ir->accept(this); + } + } +} + +void +ir_to_mesa_visitor::visit(ir_expression *ir) +{ + unsigned int operand; + struct ir_to_mesa_src_reg op[2]; + struct ir_to_mesa_src_reg result_src; + struct ir_to_mesa_dst_reg result_dst; + const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); + const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); + const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + this->result.file = PROGRAM_UNDEFINED; + ir->operands[operand]->accept(this); + if (this->result.file == PROGRAM_UNDEFINED) { + ir_print_visitor v; + printf("Failed to get tree for expression operand:\n"); + ir->operands[operand]->accept(&v); + exit(1); + } + op[operand] = this->result; + + /* Only expression implemented for matrices yet */ + assert(!ir->operands[operand]->type->is_matrix() || + ir->operation == ir_binop_mul); + } + + this->result.file = PROGRAM_UNDEFINED; + + /* Storage for our result. Ideally for an assignment we'd be using + * the actual storage for the result here, instead. + */ + result_src = get_temp(ir->type); + /* convenience for the emit functions below. */ + result_dst = ir_to_mesa_dst_reg_from_src(result_src); + /* Limit writes to the channels that will be used by result_src later. + * This does limit this temp's use as a temporary for multi-instruction + * sequences. + */ + result_dst.writemask = (1 << ir->type->vector_elements) - 1; + + switch (ir->operation) { + case ir_unop_logic_not: + ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, + op[0], src_reg_for_float(0.0)); + break; + case ir_unop_neg: + op[0].negate = ~op[0].negate; + result_src = op[0]; + break; + case ir_unop_exp: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_EXP, result_dst, op[0]); + break; + case ir_unop_exp2: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_EX2, result_dst, op[0]); + break; + case ir_unop_log: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_LOG, result_dst, op[0]); + break; + case ir_unop_log2: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_LG2, result_dst, op[0]); + break; + case ir_unop_sin: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_SIN, result_dst, op[0]); + break; + case ir_unop_cos: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_COS, result_dst, op[0]); + break; + case ir_binop_add: + ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]); + break; + case ir_binop_sub: + ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); + break; + case ir_binop_mul: + if (ir->operands[0]->type->is_matrix() && + !ir->operands[1]->type->is_matrix()) { + if (ir->operands[0]->type->is_scalar()) { + ir_to_mesa_dst_reg dst_column = result_dst; + ir_to_mesa_src_reg src_column = op[0]; + for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + dst_column, src_column, op[1]); + dst_column.index++; + src_column.index++; + } + } else { + ir_to_mesa_dst_reg dst_chan = result_dst; + ir_to_mesa_src_reg src_column = op[0]; + ir_to_mesa_src_reg src_chan = op[1]; + for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { + dst_chan.writemask = (1 << i); + src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + dst_chan, src_column, src_chan); + src_column.index++; + } + } + } else { + assert(!ir->operands[0]->type->is_matrix()); + assert(!ir->operands[1]->type->is_matrix()); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], op[1]); + } + break; + case ir_binop_div: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], result_src); + break; + + case ir_binop_less: + ir_to_mesa_emit_op2(ir, OPCODE_SLT, result_dst, op[0], op[1]); + break; + case ir_binop_greater: + ir_to_mesa_emit_op2(ir, OPCODE_SGT, result_dst, op[0], op[1]); + break; + case ir_binop_lequal: + ir_to_mesa_emit_op2(ir, OPCODE_SLE, result_dst, op[0], op[1]); + break; + case ir_binop_gequal: + ir_to_mesa_emit_op2(ir, OPCODE_SGE, result_dst, op[0], op[1]); + break; + case ir_binop_equal: + ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, op[0], op[1]); + break; + case ir_binop_logic_xor: + case ir_binop_nequal: + ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, op[0], op[1]); + break; + + case ir_binop_logic_or: + /* This could be a saturated add and skip the SNE. */ + ir_to_mesa_emit_op2(ir, OPCODE_ADD, + result_dst, + op[0], op[1]); + + ir_to_mesa_emit_op2(ir, OPCODE_SNE, + result_dst, + result_src, src_reg_for_float(0.0)); + break; + + case ir_binop_logic_and: + /* the bool args are stored as float 0.0 or 1.0, so "mul" gives us "and". */ + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + result_dst, + op[0], op[1]); + break; + + case ir_binop_dot: + if (ir->operands[0]->type == vec4_type) { + assert(ir->operands[1]->type == vec4_type); + ir_to_mesa_emit_op2(ir, OPCODE_DP4, + result_dst, + op[0], op[1]); + } else if (ir->operands[0]->type == vec3_type) { + assert(ir->operands[1]->type == vec3_type); + ir_to_mesa_emit_op2(ir, OPCODE_DP3, + result_dst, + op[0], op[1]); + } else if (ir->operands[0]->type == vec2_type) { + assert(ir->operands[1]->type == vec2_type); + ir_to_mesa_emit_op2(ir, OPCODE_DP2, + result_dst, + op[0], op[1]); + } + break; + case ir_unop_sqrt: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); + ir_to_mesa_emit_op1(ir, OPCODE_RCP, result_dst, result_src); + break; + case ir_unop_rsq: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); + break; + case ir_unop_i2f: + /* Mesa IR lacks types, ints are stored as truncated floats. */ + result_src = op[0]; + break; + case ir_unop_f2i: + ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); + break; + case ir_unop_f2b: + ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, + result_src, src_reg_for_float(0.0)); + break; + case ir_unop_trunc: + ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); + break; + case ir_unop_ceil: + op[0].negate = ~op[0].negate; + ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); + result_src.negate = ~result_src.negate; + break; + case ir_unop_floor: + ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); + break; + case ir_binop_min: + ir_to_mesa_emit_op2(ir, OPCODE_MIN, result_dst, op[0], op[1]); + break; + case ir_binop_max: + ir_to_mesa_emit_op2(ir, OPCODE_MAX, result_dst, op[0], op[1]); + break; + default: + ir_print_visitor v; + printf("Failed to get tree for expression:\n"); + ir->accept(&v); + exit(1); + break; + } + + this->result = result_src; +} + + +void +ir_to_mesa_visitor::visit(ir_swizzle *ir) +{ + ir_to_mesa_src_reg src_reg; + int i; + int swizzle[4]; + + /* Note that this is only swizzles in expressions, not those on the left + * hand side of an assignment, which do write masking. See ir_assignment + * for that. + */ + + ir->val->accept(this); + src_reg = this->result; + assert(src_reg.file != PROGRAM_UNDEFINED); + + for (i = 0; i < 4; i++) { + if (i < ir->type->vector_elements) { + switch (i) { + case 0: + swizzle[i] = ir->mask.x; + break; + case 1: + swizzle[i] = ir->mask.y; + break; + case 2: + swizzle[i] = ir->mask.z; + break; + case 3: + swizzle[i] = ir->mask.w; + break; + } + } else { + /* If the type is smaller than a vec4, replicate the last + * channel out. + */ + swizzle[i] = ir->type->vector_elements - 1; + } + } + + src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], + swizzle[1], + swizzle[2], + swizzle[3]); + + this->result = src_reg; +} + +void +ir_to_mesa_visitor::visit(ir_dereference_variable *ir) +{ + ir_to_mesa_src_reg src_reg; + temp_entry *entry = find_variable_storage(ir->var); + unsigned int i; + bool var_in; + + if (!entry) { + switch (ir->var->mode) { + case ir_var_uniform: + entry = new(ctx) temp_entry(ir->var, PROGRAM_UNIFORM, + this->next_uniform); + this->variable_storage.push_tail(entry); + + this->next_uniform += type_size(ir->var->type); + break; + case ir_var_in: + case ir_var_out: + case ir_var_inout: + var_in = (ir->var->mode == ir_var_in || + ir->var->mode == ir_var_inout); + + for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { + bool in = builtin_var_to_mesa_reg[i].file == PROGRAM_INPUT; + + if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0 && + !(var_in ^ in)) + break; + } + if (i == ARRAY_SIZE(builtin_var_to_mesa_reg)) { + printf("Failed to find builtin for %s variable %s\n", + var_in ? "in" : "out", + ir->var->name); + abort(); + } + entry = new(ctx) temp_entry(ir->var, + builtin_var_to_mesa_reg[i].file, + builtin_var_to_mesa_reg[i].index); + break; + case ir_var_auto: + entry = new(ctx) temp_entry(ir->var, PROGRAM_TEMPORARY, + this->next_temp); + this->variable_storage.push_tail(entry); + + next_temp += type_size(ir->var->type); + break; + } + + if (!entry) { + printf("Failed to make storage for %s\n", ir->var->name); + exit(1); + } + } + + src_reg.file = entry->file; + src_reg.index = entry->index; + /* If the type is smaller than a vec4, replicate the last channel out. */ + src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); + src_reg.reladdr = false; + src_reg.negate = 0; + + this->result = src_reg; +} + +void +ir_to_mesa_visitor::visit(ir_dereference_array *ir) +{ + ir_constant *index; + ir_to_mesa_src_reg src_reg; + + index = ir->array_index->constant_expression_value(); + + /* By the time we make it to this stage, matrices should be broken down + * to vectors. + */ + assert(!ir->type->is_matrix()); + + ir->array->accept(this); + src_reg = this->result; + + if (src_reg.file == PROGRAM_INPUT || + src_reg.file == PROGRAM_OUTPUT) { + assert(index); /* FINISHME: Handle variable indexing of builtins. */ + + src_reg.index += index->value.i[0]; + } else { + if (index) { + src_reg.index += index->value.i[0]; + } else { + ir_to_mesa_src_reg array_base = this->result; + /* Variable index array dereference. It eats the "vec4" of the + * base of the array and an index that offsets the Mesa register + * index. + */ + ir->array_index->accept(this); + + /* FINISHME: This doesn't work when we're trying to do the LHS + * of an assignment. + */ + src_reg.reladdr = true; + ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, + this->result); + + this->result = get_temp(ir->type); + ir_to_mesa_emit_op1(ir, OPCODE_MOV, + ir_to_mesa_dst_reg_from_src(this->result), + src_reg); + } + } + + /* If the type is smaller than a vec4, replicate the last channel out. */ + src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); + + this->result = src_reg; +} + +void +ir_to_mesa_visitor::visit(ir_dereference_record *ir) +{ + unsigned int i; + const glsl_type *struct_type = ir->record->type; + int offset = 0; + + ir->record->accept(this); + + for (i = 0; i < struct_type->length; i++) { + if (strcmp(struct_type->fields.structure[i].name, ir->field) == 0) + break; + offset += type_size(struct_type->fields.structure[i].type); + } + this->result.index += offset; +} + +/** + * We want to be careful in assignment setup to hit the actual storage + * instead of potentially using a temporary like we might with the + * ir_dereference handler. + * + * Thanks to ir_swizzle_swizzle, and ir_vec_index_to_swizzle, we + * should only see potentially one variable array index of a vector, + * and one swizzle, before getting to actual vec4 storage. So handle + * those, then go use ir_dereference to handle the rest. + */ +static struct ir_to_mesa_dst_reg +get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) +{ + struct ir_to_mesa_dst_reg dst_reg; + ir_dereference *deref; + ir_swizzle *swiz; + + /* Use the rvalue deref handler for the most part. We'll ignore + * swizzles in it and write swizzles using writemask, though. + */ + ir->accept(v); + dst_reg = ir_to_mesa_dst_reg_from_src(v->result); + + if ((deref = ir->as_dereference())) { + ir_dereference_array *deref_array = ir->as_dereference_array(); + assert(!deref_array || deref_array->array->type->is_array()); + + ir->accept(v); + } else if ((swiz = ir->as_swizzle())) { + dst_reg.writemask = 0; + if (swiz->mask.num_components >= 1) + dst_reg.writemask |= (1 << swiz->mask.x); + if (swiz->mask.num_components >= 2) + dst_reg.writemask |= (1 << swiz->mask.y); + if (swiz->mask.num_components >= 3) + dst_reg.writemask |= (1 << swiz->mask.z); + if (swiz->mask.num_components >= 4) + dst_reg.writemask |= (1 << swiz->mask.w); + } + + return dst_reg; +} + +void +ir_to_mesa_visitor::visit(ir_assignment *ir) +{ + struct ir_to_mesa_dst_reg l; + struct ir_to_mesa_src_reg r; + + assert(!ir->lhs->type->is_matrix()); + assert(!ir->lhs->type->is_array()); + assert(ir->lhs->type->base_type != GLSL_TYPE_STRUCT); + + l = get_assignment_lhs(ir->lhs, this); + + ir->rhs->accept(this); + r = this->result; + assert(l.file != PROGRAM_UNDEFINED); + assert(r.file != PROGRAM_UNDEFINED); + + if (ir->condition) { + ir_constant *condition_constant; + + condition_constant = ir->condition->constant_expression_value(); + + assert(condition_constant && condition_constant->value.b[0]); + } + + ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); +} + + +void +ir_to_mesa_visitor::visit(ir_constant *ir) +{ + ir_to_mesa_src_reg src_reg; + + assert(ir->type->base_type == GLSL_TYPE_FLOAT || + ir->type->base_type == GLSL_TYPE_UINT || + ir->type->base_type == GLSL_TYPE_INT || + ir->type->base_type == GLSL_TYPE_BOOL); + + /* FINISHME: This will end up being _mesa_add_unnamed_constant, + * which handles sharing values and sharing channels of vec4 + * constants for small values. + */ + /* FINISHME: Do something with the constant values for now. + */ + src_reg.file = PROGRAM_CONSTANT; + src_reg.index = this->next_constant; + src_reg.swizzle = SWIZZLE_NOOP; + src_reg.reladdr = false; + src_reg.negate = 0; + + this->next_constant += type_size(ir->type); + + this->result = src_reg; +} + + +void +ir_to_mesa_visitor::visit(ir_call *ir) +{ + printf("Can't support call to %s\n", ir->callee_name()); + exit(1); +} + + +void +ir_to_mesa_visitor::visit(ir_texture *ir) +{ + assert(0); + + ir->coordinate->accept(this); +} + +void +ir_to_mesa_visitor::visit(ir_return *ir) +{ + assert(0); + + ir->get_value()->accept(this); +} + + +void +ir_to_mesa_visitor::visit(ir_if *ir) +{ + ir_to_mesa_instruction *if_inst, *else_inst = NULL; + + ir->condition->accept(this); + assert(this->result.file != PROGRAM_UNDEFINED); + + if_inst = ir_to_mesa_emit_op1(ir->condition, + OPCODE_IF, ir_to_mesa_undef_dst, + this->result); + + this->instructions.push_tail(if_inst); + + visit_exec_list(&ir->then_instructions, this); + + if (!ir->else_instructions.is_empty()) { + else_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ELSE, + ir_to_mesa_undef_dst, + ir_to_mesa_undef); + visit_exec_list(&ir->then_instructions, this); + } + + if_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ENDIF, + ir_to_mesa_undef_dst, ir_to_mesa_undef); +} + +ir_to_mesa_visitor::ir_to_mesa_visitor() +{ + result.file = PROGRAM_UNDEFINED; + next_temp = 1; + next_constant = 0; + next_uniform = 0; +} + +static struct prog_src_register +mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) +{ + struct prog_src_register mesa_reg; + + mesa_reg.File = reg.file; + assert(reg.index < (1 << INST_INDEX_BITS) - 1); + mesa_reg.Index = reg.index; + mesa_reg.Swizzle = reg.swizzle; + mesa_reg.RelAddr = reg.reladdr; + + return mesa_reg; +} + +static void +set_branchtargets(struct prog_instruction *mesa_instructions, + int num_instructions) +{ + int if_count = 0, loop_count; + int *if_stack, *loop_stack; + int if_stack_pos = 0, loop_stack_pos = 0; + int i, j; + + for (i = 0; i < num_instructions; i++) { + switch (mesa_instructions[i].Opcode) { + case OPCODE_IF: + if_count++; + break; + case OPCODE_BGNLOOP: + loop_count++; + break; + case OPCODE_BRK: + case OPCODE_CONT: + mesa_instructions[i].BranchTarget = -1; + break; + default: + break; + } + } + + if_stack = (int *)calloc(if_count, sizeof(*if_stack)); + loop_stack = (int *)calloc(loop_count, sizeof(*loop_stack)); + + for (i = 0; i < num_instructions; i++) { + switch (mesa_instructions[i].Opcode) { + case OPCODE_IF: + if_stack[if_stack_pos] = i; + if_stack_pos++; + break; + case OPCODE_ELSE: + mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; + if_stack[if_stack_pos - 1] = i; + break; + case OPCODE_ENDIF: + mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; + if_stack_pos--; + break; + case OPCODE_BGNLOOP: + loop_stack[loop_stack_pos] = i; + loop_stack_pos++; + break; + case OPCODE_ENDLOOP: + loop_stack_pos--; + /* Rewrite any breaks/conts at this nesting level (haven't + * already had a BranchTarget assigned) to point to the end + * of the loop. + */ + for (j = loop_stack[loop_stack_pos]; j < i; j++) { + if (mesa_instructions[j].Opcode == OPCODE_BRK || + mesa_instructions[j].Opcode == OPCODE_CONT) { + if (mesa_instructions[j].BranchTarget == -1) { + mesa_instructions[j].BranchTarget = i; + } + } + } + /* The loop ends point at each other. */ + mesa_instructions[i].BranchTarget = loop_stack[loop_stack_pos]; + mesa_instructions[loop_stack[loop_stack_pos]].BranchTarget = i; + default: + break; + } + } + + free(if_stack); +} + +static void +print_program(struct prog_instruction *mesa_instructions, + ir_instruction **mesa_instruction_annotation, + int num_instructions) +{ + ir_instruction *last_ir = NULL; + int i; + + for (i = 0; i < num_instructions; i++) { + struct prog_instruction *mesa_inst = mesa_instructions + i; + ir_instruction *ir = mesa_instruction_annotation[i]; + + if (last_ir != ir && ir) { + ir_print_visitor print; + ir->accept(&print); + printf("\n"); + last_ir = ir; + } + + _mesa_print_instruction(mesa_inst); + } +} + +void +do_ir_to_mesa(exec_list *instructions) +{ + ir_to_mesa_visitor v; + struct prog_instruction *mesa_instructions, *mesa_inst; + ir_instruction **mesa_instruction_annotation; + int i; + + v.ctx = talloc_new(NULL); + visit_exec_list(instructions, &v); + + int num_instructions = 0; + foreach_iter(exec_list_iterator, iter, v.instructions) { + num_instructions++; + } + + mesa_instructions = + (struct prog_instruction *)calloc(num_instructions, + sizeof(*mesa_instructions)); + mesa_instruction_annotation = + (ir_instruction **)calloc(num_instructions, + sizeof(*mesa_instruction_annotation)); + + mesa_inst = mesa_instructions; + i = 0; + foreach_iter(exec_list_iterator, iter, v.instructions) { + ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); + + mesa_inst->Opcode = inst->op; + mesa_inst->DstReg.File = inst->dst_reg.file; + mesa_inst->DstReg.Index = inst->dst_reg.index; + mesa_inst->DstReg.CondMask = COND_TR; + mesa_inst->DstReg.WriteMask = inst->dst_reg.writemask; + mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); + mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); + mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); + mesa_instruction_annotation[i] = inst->ir; + + mesa_inst++; + i++; + } + + set_branchtargets(mesa_instructions, num_instructions); + print_program(mesa_instructions, mesa_instruction_annotation, num_instructions); + + free(mesa_instruction_annotation); + talloc_free(v.ctx); +} -- cgit v1.2.3 From e82ddb781ad100702322eb465e82b1cec433f099 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 15:52:07 -0700 Subject: glsl2: Stop .gitignoring the old standalone build system. --- src/glsl/.gitignore | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/glsl/.gitignore b/src/glsl/.gitignore index 376aaeda13a..e90b98accb5 100644 --- a/src/glsl/.gitignore +++ b/src/glsl/.gitignore @@ -1,25 +1 @@ -.deps -COPYING -INSTALL -Makefile.in -aclocal.m4 -autom4te.cache -config.* -configure -depcomp -ylwrap -install-sh -missing -stamp-h1 -libtool -ltmain.sh -Makefile -*.o -*~ -glsl_lexer.cpp -glsl_parser.output -glsl_parser.cpp -glsl_parser.h glsl -mesa_codegen.cpp -mesa_codegen.h -- cgit v1.2.3 From f4869f33269c54779f8199b68e769024100421a3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 16:34:43 -0700 Subject: glsl2: Remove files that had been imported for standalone. --- src/glsl/hash_table.c | 159 ----- src/glsl/hash_table.h | 125 ---- src/glsl/main/imports.h | 6 - src/glsl/main/mtypes.h | 270 -------- src/glsl/main/simple_list.h | 235 ------- src/glsl/mesa/shader/prog_instruction.c | 363 ----------- src/glsl/mesa/shader/prog_instruction.h | 437 ------------- src/glsl/mesa/shader/prog_print.c | 1089 ------------------------------- src/glsl/mesa/shader/prog_print.h | 98 --- src/glsl/symbol_table.c | 413 ------------ src/glsl/symbol_table.h | 66 -- 11 files changed, 3261 deletions(-) delete mode 100644 src/glsl/hash_table.c delete mode 100644 src/glsl/hash_table.h delete mode 100644 src/glsl/main/imports.h delete mode 100644 src/glsl/main/mtypes.h delete mode 100644 src/glsl/main/simple_list.h delete mode 100644 src/glsl/mesa/shader/prog_instruction.c delete mode 100644 src/glsl/mesa/shader/prog_instruction.h delete mode 100644 src/glsl/mesa/shader/prog_print.c delete mode 100644 src/glsl/mesa/shader/prog_print.h delete mode 100644 src/glsl/symbol_table.c delete mode 100644 src/glsl/symbol_table.h diff --git a/src/glsl/hash_table.c b/src/glsl/hash_table.c deleted file mode 100644 index e89a2564d76..00000000000 --- a/src/glsl/hash_table.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file hash_table.c - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick - */ - -#include "main/imports.h" -#include "main/simple_list.h" -#include "hash_table.h" - -struct node { - struct node *next; - struct node *prev; -}; - -struct hash_table { - hash_func_t hash; - hash_compare_func_t compare; - - unsigned num_buckets; - struct node buckets[1]; -}; - - -struct hash_node { - struct node link; - const void *key; - void *data; -}; - - -struct hash_table * -hash_table_ctor(unsigned num_buckets, hash_func_t hash, - hash_compare_func_t compare) -{ - struct hash_table *ht; - unsigned i; - - - if (num_buckets < 16) { - num_buckets = 16; - } - - ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1) - * sizeof(ht->buckets[0]))); - if (ht != NULL) { - ht->hash = hash; - ht->compare = compare; - ht->num_buckets = num_buckets; - - for (i = 0; i < num_buckets; i++) { - make_empty_list(& ht->buckets[i]); - } - } - - return ht; -} - - -void -hash_table_dtor(struct hash_table *ht) -{ - hash_table_clear(ht); - _mesa_free(ht); -} - - -void -hash_table_clear(struct hash_table *ht) -{ - struct node *node; - struct node *temp; - unsigned i; - - - for (i = 0; i < ht->num_buckets; i++) { - foreach_s(node, temp, & ht->buckets[i]) { - remove_from_list(node); - _mesa_free(node); - } - - assert(is_empty_list(& ht->buckets[i])); - } -} - - -void * -hash_table_find(struct hash_table *ht, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct node *node; - - foreach(node, & ht->buckets[bucket]) { - struct hash_node *hn = (struct hash_node *) node; - - if ((*ht->compare)(hn->key, key) == 0) { - return hn->data; - } - } - - return NULL; -} - - -void -hash_table_insert(struct hash_table *ht, void *data, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct hash_node *node; - - node = _mesa_calloc(sizeof(*node)); - - node->data = data; - node->key = key; - - insert_at_head(& ht->buckets[bucket], & node->link); -} - - -unsigned -hash_table_string_hash(const void *key) -{ - const char *str = (const char *) key; - unsigned hash = 5381; - - - while (*str != '\0') { - hash = (hash * 33) + *str; - str++; - } - - return hash; -} diff --git a/src/glsl/hash_table.h b/src/glsl/hash_table.h deleted file mode 100644 index b9dd343dee9..00000000000 --- a/src/glsl/hash_table.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file hash_table.h - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick - */ - -#ifndef HASH_TABLE_H -#define HASH_TABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -struct hash_table; - -typedef unsigned (*hash_func_t)(const void *key); -typedef int (*hash_compare_func_t)(const void *key1, const void *key2); - -/** - * Hash table constructor - * - * Creates a hash table with the specified number of buckets. The supplied - * \c hash and \c compare routines are used when adding elements to the table - * and when searching for elements in the table. - * - * \param num_buckets Number of buckets (bins) in the hash table. - * \param hash Function used to compute hash value of input keys. - * \param compare Function used to compare keys. - */ -extern struct hash_table *hash_table_ctor(unsigned num_buckets, - hash_func_t hash, hash_compare_func_t compare); - - -/** - * Release all memory associated with a hash table - * - * \warning - * This function cannot release memory occupied either by keys or data. - */ -extern void hash_table_dtor(struct hash_table *ht); - - -/** - * Flush all entries from a hash table - * - * \param ht Table to be cleared of its entries. - */ -extern void hash_table_clear(struct hash_table *ht); - - -/** - * Search a hash table for a specific element - * - * \param ht Table to be searched - * \param key Key of the desired element - * - * \return - * The \c data value supplied to \c hash_table_insert when the element with - * the matching key was added. If no matching key exists in the table, - * \c NULL is returned. - */ -extern void *hash_table_find(struct hash_table *ht, const void *key); - - -/** - * Add an element to a hash table - */ -extern void hash_table_insert(struct hash_table *ht, void *data, - const void *key); - - -/** - * Compute hash value of a string - * - * Computes the hash value of a string using the DJB2 algorithm developed by - * Professor Daniel J. Bernstein. It was published on comp.lang.c once upon - * a time. I was unable to find the original posting in the archives. - * - * \param key Pointer to a NUL terminated string to be hashed. - * - * \sa hash_table_string_compare - */ -extern unsigned hash_table_string_hash(const void *key); - - -/** - * Compare two strings used as keys - * - * This is just a macro wrapper around \c strcmp. - * - * \sa hash_table_string_hash - */ -#define hash_table_string_compare ((hash_compare_func_t) strcmp) - -#ifdef __cplusplus -}; -#endif - -#endif /* HASH_TABLE_H */ diff --git a/src/glsl/main/imports.h b/src/glsl/main/imports.h deleted file mode 100644 index d2197342c04..00000000000 --- a/src/glsl/main/imports.h +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -#define _mesa_malloc(x) malloc(x) -#define _mesa_free(x) free(x) -#define _mesa_calloc(x) calloc(1,x) diff --git a/src/glsl/main/mtypes.h b/src/glsl/main/mtypes.h deleted file mode 100644 index 06e2dd4b540..00000000000 --- a/src/glsl/main/mtypes.h +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file mtypes.h - * Main Mesa data structures. - * - * Please try to mark derived values with a leading underscore ('_'). - */ - -#ifndef MTYPES_H -#define MTYPES_H - -#define MAX_DRAW_BUFFERS 8 -#define MAX_VARYING 16 - -#include - -/** - * Indexes for vertex program attributes. - * GL_NV_vertex_program aliases generic attributes over the conventional - * attributes. In GL_ARB_vertex_program shader the aliasing is optional. - * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the - * generic attributes are distinct/separate). - */ -typedef enum -{ - VERT_ATTRIB_POS = 0, - VERT_ATTRIB_WEIGHT = 1, - VERT_ATTRIB_NORMAL = 2, - VERT_ATTRIB_COLOR0 = 3, - VERT_ATTRIB_COLOR1 = 4, - VERT_ATTRIB_FOG = 5, - VERT_ATTRIB_COLOR_INDEX = 6, - VERT_ATTRIB_POINT_SIZE = 6, /*alias*/ - VERT_ATTRIB_EDGEFLAG = 7, - VERT_ATTRIB_TEX0 = 8, - VERT_ATTRIB_TEX1 = 9, - VERT_ATTRIB_TEX2 = 10, - VERT_ATTRIB_TEX3 = 11, - VERT_ATTRIB_TEX4 = 12, - VERT_ATTRIB_TEX5 = 13, - VERT_ATTRIB_TEX6 = 14, - VERT_ATTRIB_TEX7 = 15, - VERT_ATTRIB_GENERIC0 = 16, - VERT_ATTRIB_GENERIC1 = 17, - VERT_ATTRIB_GENERIC2 = 18, - VERT_ATTRIB_GENERIC3 = 19, - VERT_ATTRIB_GENERIC4 = 20, - VERT_ATTRIB_GENERIC5 = 21, - VERT_ATTRIB_GENERIC6 = 22, - VERT_ATTRIB_GENERIC7 = 23, - VERT_ATTRIB_GENERIC8 = 24, - VERT_ATTRIB_GENERIC9 = 25, - VERT_ATTRIB_GENERIC10 = 26, - VERT_ATTRIB_GENERIC11 = 27, - VERT_ATTRIB_GENERIC12 = 28, - VERT_ATTRIB_GENERIC13 = 29, - VERT_ATTRIB_GENERIC14 = 30, - VERT_ATTRIB_GENERIC15 = 31, - VERT_ATTRIB_MAX = 32 -} gl_vert_attrib; - -/** - * Bitflags for vertex attributes. - * These are used in bitfields in many places. - */ -/*@{*/ -#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) -#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) -#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) -#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) -#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) -#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) -#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) -#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG) -#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) -#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) -#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) -#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) -#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) -#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) -#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) -#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) -#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) -#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) -#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) -#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) -#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) -#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) -#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) -#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) -#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) -#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) -#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) -#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) -#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) -#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) -#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) -#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) - -#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) -#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) -/*@}*/ - - -/** - * Indexes for vertex program result attributes - */ -typedef enum -{ - VERT_RESULT_HPOS = 0, - VERT_RESULT_COL0 = 1, - VERT_RESULT_COL1 = 2, - VERT_RESULT_FOGC = 3, - VERT_RESULT_TEX0 = 4, - VERT_RESULT_TEX1 = 5, - VERT_RESULT_TEX2 = 6, - VERT_RESULT_TEX3 = 7, - VERT_RESULT_TEX4 = 8, - VERT_RESULT_TEX5 = 9, - VERT_RESULT_TEX6 = 10, - VERT_RESULT_TEX7 = 11, - VERT_RESULT_PSIZ = 12, - VERT_RESULT_BFC0 = 13, - VERT_RESULT_BFC1 = 14, - VERT_RESULT_EDGE = 15, - VERT_RESULT_VAR0 = 16, /**< shader varying */ - VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) -} gl_vert_result; - - -/** - * Indexes for fragment program input attributes. - */ -typedef enum -{ - FRAG_ATTRIB_WPOS = 0, - FRAG_ATTRIB_COL0 = 1, - FRAG_ATTRIB_COL1 = 2, - FRAG_ATTRIB_FOGC = 3, - FRAG_ATTRIB_TEX0 = 4, - FRAG_ATTRIB_TEX1 = 5, - FRAG_ATTRIB_TEX2 = 6, - FRAG_ATTRIB_TEX3 = 7, - FRAG_ATTRIB_TEX4 = 8, - FRAG_ATTRIB_TEX5 = 9, - FRAG_ATTRIB_TEX6 = 10, - FRAG_ATTRIB_TEX7 = 11, - FRAG_ATTRIB_FACE = 12, /**< front/back face */ - FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ - FRAG_ATTRIB_VAR0 = 14, /**< shader varying */ - FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) -} gl_frag_attrib; - -/** - * Bitflags for fragment program input attributes. - */ -/*@{*/ -#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) -#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) -#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) -#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) -#define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE) -#define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC) -#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) -#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1) -#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2) -#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3) -#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4) -#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5) -#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6) -#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7) -#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0) - -#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U)) -#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V)) - -#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \ - FRAG_BIT_TEX1| \ - FRAG_BIT_TEX2| \ - FRAG_BIT_TEX3| \ - FRAG_BIT_TEX4| \ - FRAG_BIT_TEX5| \ - FRAG_BIT_TEX6| \ - FRAG_BIT_TEX7) -/*@}*/ - - -/** - * Fragment program results - */ -typedef enum -{ - FRAG_RESULT_DEPTH = 0, - FRAG_RESULT_COLOR = 1, - FRAG_RESULT_DATA0 = 2, - FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) -} gl_frag_result; - -/** - * Names of the various vertex/fragment program register files, etc. - * - * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) - * All values should fit in a 4-bit field. - * - * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, - * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to - * be "uniform" variables since they can only be set outside glBegin/End. - * They're also all stored in the same Parameters array. - */ -typedef enum -{ - PROGRAM_TEMPORARY, /**< machine->Temporary[] */ - PROGRAM_INPUT, /**< machine->Inputs[] */ - PROGRAM_OUTPUT, /**< machine->Outputs[] */ - PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */ - PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ - PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */ - PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ - PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ - PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ - PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ - PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ - PROGRAM_ADDRESS, /**< machine->AddressReg */ - PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ - PROGRAM_UNDEFINED, /**< Invalid/TBD value */ - PROGRAM_FILE_MAX -} gl_register_file; - -/** - * An index for each type of texture object. These correspond to the GL - * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. - * Note: the order is from highest priority to lowest priority. - */ -typedef enum -{ - TEXTURE_2D_ARRAY_INDEX, - TEXTURE_1D_ARRAY_INDEX, - TEXTURE_CUBE_INDEX, - TEXTURE_3D_INDEX, - TEXTURE_RECT_INDEX, - TEXTURE_2D_INDEX, - TEXTURE_1D_INDEX, - NUM_TEXTURE_TARGETS -} gl_texture_index; - -#endif /* MTYPES_H */ diff --git a/src/glsl/main/simple_list.h b/src/glsl/main/simple_list.h deleted file mode 100644 index 5ef39e14cc6..00000000000 --- a/src/glsl/main/simple_list.h +++ /dev/null @@ -1,235 +0,0 @@ -/** - * \file simple_list.h - * Simple macros for type-safe, intrusive lists. - * - * Intended to work with a list sentinal which is created as an empty - * list. Insert & delete are O(1). - * - * \author - * (C) 1997, Keith Whitwell - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _SIMPLE_LIST_H -#define _SIMPLE_LIST_H - -struct simple_node { - struct simple_node *next; - struct simple_node *prev; -}; - -/** - * Remove an element from list. - * - * \param elem element to remove. - */ -#define remove_from_list(elem) \ -do { \ - (elem)->next->prev = (elem)->prev; \ - (elem)->prev->next = (elem)->next; \ -} while (0) - -/** - * Insert an element to the list head. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_head(list, elem) \ -do { \ - (elem)->prev = list; \ - (elem)->next = (list)->next; \ - (list)->next->prev = elem; \ - (list)->next = elem; \ -} while(0) - -/** - * Insert an element to the list tail. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_tail(list, elem) \ -do { \ - (elem)->next = list; \ - (elem)->prev = (list)->prev; \ - (list)->prev->next = elem; \ - (list)->prev = elem; \ -} while(0) - -/** - * Move an element to the list head. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_head(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_head(list, elem); \ -} while (0) - -/** - * Move an element to the list tail. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_tail(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_tail(list, elem); \ -} while (0) - -/** - * Consatinate a cyclic list to a list - * - * Appends the sequence of nodes starting with \c tail to the list \c head. - * A "cyclic list" is a list that does not have a sentinal node. This means - * that the data pointed to by \c tail is an actual node, not a dataless - * sentinal. Note that if \c tail constist of a single node, this macro - * behaves identically to \c insert_at_tail - * - * \param head Head of the list to be appended to. This may or may not - * be a cyclic list. - * \param tail Head of the cyclic list to be appended to \c head. - * \param temp Temporary \c simple_list used by the macro - * - * \sa insert_at_tail - */ -#define concat_list_and_cycle(head, tail, temp) \ -do { \ - (head)->prev->next = (tail); \ - (tail)->prev->next = (head); \ - (temp) = (head)->prev; \ - (head)->prev = (tail)->prev; \ - (tail)->prev = (temp); \ -} while (0) - -#define concat_list(head, next_list) \ -do { \ - (next_list)->next->prev = (head)->prev; \ - (next_list)->prev->next = (head); \ - (head)->prev->next = (next_list)->next; \ - (head)->prev = (next_list)->prev; \ -} while (0) - -/** - * Make a empty list empty. - * - * \param sentinal list (sentinal element). - */ -#define make_empty_list(sentinal) \ -do { \ - (sentinal)->next = sentinal; \ - (sentinal)->prev = sentinal; \ -} while (0) - -/** - * Get list first element. - * - * \param list list. - * - * \return pointer to first element. - */ -#define first_elem(list) ((list)->next) - -/** - * Get list last element. - * - * \param list list. - * - * \return pointer to last element. - */ -#define last_elem(list) ((list)->prev) - -/** - * Get next element. - * - * \param elem element. - * - * \return pointer to next element. - */ -#define next_elem(elem) ((elem)->next) - -/** - * Get previous element. - * - * \param elem element. - * - * \return pointer to previous element. - */ -#define prev_elem(elem) ((elem)->prev) - -/** - * Test whether element is at end of the list. - * - * \param list list. - * \param elem element. - * - * \return non-zero if element is at end of list, or zero otherwise. - */ -#define at_end(list, elem) ((elem) == (list)) - -/** - * Test if a list is empty. - * - * \param list list. - * - * \return non-zero if list empty, or zero otherwise. - */ -#define is_empty_list(list) ((list)->next == (list)) - -/** - * Walk through the elements of a list. - * - * \param ptr pointer to the current element. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach(ptr, list) \ - for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) - -/** - * Walk through the elements of a list. - * - * Same as #foreach but lets you unlink the current value during a list - * traversal. Useful for freeing a list, element by element. - * - * \param ptr pointer to the current element. - * \param t temporary pointer. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach_s(ptr, t, list) \ - for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) - -#endif diff --git a/src/glsl/mesa/shader/prog_instruction.c b/src/glsl/mesa/shader/prog_instruction.c deleted file mode 100644 index fbcf868f509..00000000000 --- a/src/glsl/mesa/shader/prog_instruction.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#define _GNU_SOURCE -#include -#include -#include - -#if 0 -#include "main/glheader.h" -#else -#define _mesa_strdup strdup -#define _mesa_snprintf snprintf -#define ASSERT assert -#endif -#include "main/imports.h" -#include "main/mtypes.h" -#include "prog_instruction.h" - - -/** - * Initialize program instruction fields to defaults. - * \param inst first instruction to initialize - * \param count number of instructions to initialize - */ -void -_mesa_init_instructions(struct prog_instruction *inst, GLuint count) -{ - GLuint i; - - memset(inst, 0, count * sizeof(struct prog_instruction)); - - for (i = 0; i < count; i++) { - inst[i].SrcReg[0].File = PROGRAM_UNDEFINED; - inst[i].SrcReg[0].Swizzle = SWIZZLE_NOOP; - inst[i].SrcReg[1].File = PROGRAM_UNDEFINED; - inst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP; - inst[i].SrcReg[2].File = PROGRAM_UNDEFINED; - inst[i].SrcReg[2].Swizzle = SWIZZLE_NOOP; - - inst[i].DstReg.File = PROGRAM_UNDEFINED; - inst[i].DstReg.WriteMask = WRITEMASK_XYZW; - inst[i].DstReg.CondMask = COND_TR; - inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP; - - inst[i].SaturateMode = SATURATE_OFF; - inst[i].Precision = FLOAT32; - } -} - - -/** - * Allocate an array of program instructions. - * \param numInst number of instructions - * \return pointer to instruction memory - */ -struct prog_instruction * -_mesa_alloc_instructions(GLuint numInst) -{ - return (struct prog_instruction *) - calloc(1, numInst * sizeof(struct prog_instruction)); -} - - -/** - * Reallocate memory storing an array of program instructions. - * This is used when we need to append additional instructions onto an - * program. - * \param oldInst pointer to first of old/src instructions - * \param numOldInst number of instructions at - * \param numNewInst desired size of new instruction array. - * \return pointer to start of new instruction array. - */ -struct prog_instruction * -_mesa_realloc_instructions(struct prog_instruction *oldInst, - GLuint numOldInst, GLuint numNewInst) -{ - struct prog_instruction *newInst; - - (void)numOldInst; - newInst = (struct prog_instruction *) - realloc(oldInst, - numNewInst * sizeof(struct prog_instruction)); - - return newInst; -} - - -/** - * Copy an array of program instructions. - * \param dest pointer to destination. - * \param src pointer to source. - * \param n number of instructions to copy. - * \return pointer to destination. - */ -struct prog_instruction * -_mesa_copy_instructions(struct prog_instruction *dest, - const struct prog_instruction *src, GLuint n) -{ - GLuint i; - memcpy(dest, src, n * sizeof(struct prog_instruction)); - for (i = 0; i < n; i++) { - if (src[i].Comment) - dest[i].Comment = _mesa_strdup(src[i].Comment); - } - return dest; -} - - -/** - * Free an array of instructions - */ -void -_mesa_free_instructions(struct prog_instruction *inst, GLuint count) -{ - GLuint i; - for (i = 0; i < count; i++) { - if (inst[i].Data) - free(inst[i].Data); - if (inst[i].Comment) - free((char *) inst[i].Comment); - } - free(inst); -} - - -/** - * Basic info about each instruction - */ -struct instruction_info -{ - gl_inst_opcode Opcode; - const char *Name; - GLuint NumSrcRegs; - GLuint NumDstRegs; -}; - -/** - * Instruction info - * \note Opcode should equal array index! - */ -static const struct instruction_info InstInfo[MAX_OPCODE] = { - { OPCODE_NOP, "NOP", 0, 0 }, - { OPCODE_ABS, "ABS", 1, 1 }, - { OPCODE_ADD, "ADD", 2, 1 }, - { OPCODE_AND, "AND", 2, 1 }, - { OPCODE_ARA, "ARA", 1, 1 }, - { OPCODE_ARL, "ARL", 1, 1 }, - { OPCODE_ARL_NV, "ARL_NV", 1, 1 }, - { OPCODE_ARR, "ARL", 1, 1 }, - { OPCODE_BGNLOOP,"BGNLOOP", 0, 0 }, - { OPCODE_BGNSUB, "BGNSUB", 0, 0 }, - { OPCODE_BRA, "BRA", 0, 0 }, - { OPCODE_BRK, "BRK", 0, 0 }, - { OPCODE_CAL, "CAL", 0, 0 }, - { OPCODE_CMP, "CMP", 3, 1 }, - { OPCODE_CONT, "CONT", 0, 0 }, - { OPCODE_COS, "COS", 1, 1 }, - { OPCODE_DDX, "DDX", 1, 1 }, - { OPCODE_DDY, "DDY", 1, 1 }, - { OPCODE_DP2, "DP2", 2, 1 }, - { OPCODE_DP2A, "DP2A", 3, 1 }, - { OPCODE_DP3, "DP3", 2, 1 }, - { OPCODE_DP4, "DP4", 2, 1 }, - { OPCODE_DPH, "DPH", 2, 1 }, - { OPCODE_DST, "DST", 2, 1 }, - { OPCODE_ELSE, "ELSE", 0, 0 }, - { OPCODE_END, "END", 0, 0 }, - { OPCODE_ENDIF, "ENDIF", 0, 0 }, - { OPCODE_ENDLOOP,"ENDLOOP", 0, 0 }, - { OPCODE_ENDSUB, "ENDSUB", 0, 0 }, - { OPCODE_EX2, "EX2", 1, 1 }, - { OPCODE_EXP, "EXP", 1, 1 }, - { OPCODE_FLR, "FLR", 1, 1 }, - { OPCODE_FRC, "FRC", 1, 1 }, - { OPCODE_IF, "IF", 1, 0 }, - { OPCODE_KIL, "KIL", 1, 0 }, - { OPCODE_KIL_NV, "KIL_NV", 0, 0 }, - { OPCODE_LG2, "LG2", 1, 1 }, - { OPCODE_LIT, "LIT", 1, 1 }, - { OPCODE_LOG, "LOG", 1, 1 }, - { OPCODE_LRP, "LRP", 3, 1 }, - { OPCODE_MAD, "MAD", 3, 1 }, - { OPCODE_MAX, "MAX", 2, 1 }, - { OPCODE_MIN, "MIN", 2, 1 }, - { OPCODE_MOV, "MOV", 1, 1 }, - { OPCODE_MUL, "MUL", 2, 1 }, - { OPCODE_NOISE1, "NOISE1", 1, 1 }, - { OPCODE_NOISE2, "NOISE2", 1, 1 }, - { OPCODE_NOISE3, "NOISE3", 1, 1 }, - { OPCODE_NOISE4, "NOISE4", 1, 1 }, - { OPCODE_NOT, "NOT", 1, 1 }, - { OPCODE_NRM3, "NRM3", 1, 1 }, - { OPCODE_NRM4, "NRM4", 1, 1 }, - { OPCODE_OR, "OR", 2, 1 }, - { OPCODE_PK2H, "PK2H", 1, 1 }, - { OPCODE_PK2US, "PK2US", 1, 1 }, - { OPCODE_PK4B, "PK4B", 1, 1 }, - { OPCODE_PK4UB, "PK4UB", 1, 1 }, - { OPCODE_POW, "POW", 2, 1 }, - { OPCODE_POPA, "POPA", 0, 0 }, - { OPCODE_PRINT, "PRINT", 1, 0 }, - { OPCODE_PUSHA, "PUSHA", 0, 0 }, - { OPCODE_RCC, "RCC", 1, 1 }, - { OPCODE_RCP, "RCP", 1, 1 }, - { OPCODE_RET, "RET", 0, 0 }, - { OPCODE_RFL, "RFL", 1, 1 }, - { OPCODE_RSQ, "RSQ", 1, 1 }, - { OPCODE_SCS, "SCS", 1, 1 }, - { OPCODE_SEQ, "SEQ", 2, 1 }, - { OPCODE_SFL, "SFL", 0, 1 }, - { OPCODE_SGE, "SGE", 2, 1 }, - { OPCODE_SGT, "SGT", 2, 1 }, - { OPCODE_SIN, "SIN", 1, 1 }, - { OPCODE_SLE, "SLE", 2, 1 }, - { OPCODE_SLT, "SLT", 2, 1 }, - { OPCODE_SNE, "SNE", 2, 1 }, - { OPCODE_SSG, "SSG", 1, 1 }, - { OPCODE_STR, "STR", 0, 1 }, - { OPCODE_SUB, "SUB", 2, 1 }, - { OPCODE_SWZ, "SWZ", 1, 1 }, - { OPCODE_TEX, "TEX", 1, 1 }, - { OPCODE_TXB, "TXB", 1, 1 }, - { OPCODE_TXD, "TXD", 3, 1 }, - { OPCODE_TXL, "TXL", 1, 1 }, - { OPCODE_TXP, "TXP", 1, 1 }, - { OPCODE_TXP_NV, "TXP_NV", 1, 1 }, - { OPCODE_TRUNC, "TRUNC", 1, 1 }, - { OPCODE_UP2H, "UP2H", 1, 1 }, - { OPCODE_UP2US, "UP2US", 1, 1 }, - { OPCODE_UP4B, "UP4B", 1, 1 }, - { OPCODE_UP4UB, "UP4UB", 1, 1 }, - { OPCODE_X2D, "X2D", 3, 1 }, - { OPCODE_XOR, "XOR", 2, 1 }, - { OPCODE_XPD, "XPD", 2, 1 } -}; - - -/** - * Return the number of src registers for the given instruction/opcode. - */ -GLuint -_mesa_num_inst_src_regs(gl_inst_opcode opcode) -{ - ASSERT(opcode < MAX_OPCODE); - ASSERT(opcode == InstInfo[opcode].Opcode); - ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); - return InstInfo[opcode].NumSrcRegs; -} - - -/** - * Return the number of dst registers for the given instruction/opcode. - */ -GLuint -_mesa_num_inst_dst_regs(gl_inst_opcode opcode) -{ - ASSERT(opcode < MAX_OPCODE); - ASSERT(opcode == InstInfo[opcode].Opcode); - ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); - return InstInfo[opcode].NumDstRegs; -} - - -GLboolean -_mesa_is_tex_instruction(gl_inst_opcode opcode) -{ - return (opcode == OPCODE_TEX || - opcode == OPCODE_TXB || - opcode == OPCODE_TXD || - opcode == OPCODE_TXL || - opcode == OPCODE_TXP); -} - - -/** - * Check if there's a potential src/dst register data dependency when - * using SOA execution. - * Example: - * MOV T, T.yxwz; - * This would expand into: - * MOV t0, t1; - * MOV t1, t0; - * MOV t2, t3; - * MOV t3, t2; - * The second instruction will have the wrong value for t0 if executed as-is. - */ -GLboolean -_mesa_check_soa_dependencies(const struct prog_instruction *inst) -{ - GLuint i, chan; - - if (inst->DstReg.WriteMask == WRITEMASK_X || - inst->DstReg.WriteMask == WRITEMASK_Y || - inst->DstReg.WriteMask == WRITEMASK_Z || - inst->DstReg.WriteMask == WRITEMASK_W || - inst->DstReg.WriteMask == 0x0) { - /* no chance of data dependency */ - return GL_FALSE; - } - - /* loop over src regs */ - for (i = 0; i < 3; i++) { - if (inst->SrcReg[i].File == inst->DstReg.File && - inst->SrcReg[i].Index == inst->DstReg.Index) { - /* loop over dest channels */ - GLuint channelsWritten = 0x0; - for (chan = 0; chan < 4; chan++) { - if (inst->DstReg.WriteMask & (1 << chan)) { - /* check if we're reading a channel that's been written */ - GLuint swizzle = GET_SWZ(inst->SrcReg[i].Swizzle, chan); - if (swizzle <= SWIZZLE_W && - (channelsWritten & (1 << swizzle))) { - return GL_TRUE; - } - - channelsWritten |= (1 << chan); - } - } - } - } - return GL_FALSE; -} - - -/** - * Return string name for given program opcode. - */ -const char * -_mesa_opcode_string(gl_inst_opcode opcode) -{ - if (opcode < MAX_OPCODE) - return InstInfo[opcode].Name; - else { - static char s[20]; - _mesa_snprintf(s, sizeof(s), "OP%u", opcode); - return s; - } -} - diff --git a/src/glsl/mesa/shader/prog_instruction.h b/src/glsl/mesa/shader/prog_instruction.h deleted file mode 100644 index 2c95d274cab..00000000000 --- a/src/glsl/mesa/shader/prog_instruction.h +++ /dev/null @@ -1,437 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file prog_instruction.h - * - * Vertex/fragment program instruction datatypes and constants. - * - * \author Brian Paul - * \author Keith Whitwell - * \author Ian Romanick - */ - - -#ifndef PROG_INSTRUCTION_H -#define PROG_INSTRUCTION_H - - -#include "main/mtypes.h" - - -/** - * Swizzle indexes. - * Do not change! - */ -/*@{*/ -#define SWIZZLE_X 0 -#define SWIZZLE_Y 1 -#define SWIZZLE_Z 2 -#define SWIZZLE_W 3 -#define SWIZZLE_ZERO 4 /**< For SWZ instruction only */ -#define SWIZZLE_ONE 5 /**< For SWZ instruction only */ -#define SWIZZLE_NIL 7 /**< used during shader code gen (undefined value) */ -/*@}*/ - -#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9)) -#define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3) -#define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7) -#define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1) - -#define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) -#define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X) -#define SWIZZLE_YYYY MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y) -#define SWIZZLE_ZZZZ MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z) -#define SWIZZLE_WWWW MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W) - - -/** - * Writemask values, 1 bit per component. - */ -/*@{*/ -#define WRITEMASK_X 0x1 -#define WRITEMASK_Y 0x2 -#define WRITEMASK_XY 0x3 -#define WRITEMASK_Z 0x4 -#define WRITEMASK_XZ 0x5 -#define WRITEMASK_YZ 0x6 -#define WRITEMASK_XYZ 0x7 -#define WRITEMASK_W 0x8 -#define WRITEMASK_XW 0x9 -#define WRITEMASK_YW 0xa -#define WRITEMASK_XYW 0xb -#define WRITEMASK_ZW 0xc -#define WRITEMASK_XZW 0xd -#define WRITEMASK_YZW 0xe -#define WRITEMASK_XYZW 0xf -/*@}*/ - - -/** - * Condition codes - */ -/*@{*/ -#define COND_GT 1 /**< greater than zero */ -#define COND_EQ 2 /**< equal to zero */ -#define COND_LT 3 /**< less than zero */ -#define COND_UN 4 /**< unordered (NaN) */ -#define COND_GE 5 /**< greater than or equal to zero */ -#define COND_LE 6 /**< less than or equal to zero */ -#define COND_NE 7 /**< not equal to zero */ -#define COND_TR 8 /**< always true */ -#define COND_FL 9 /**< always false */ -/*@}*/ - - -/** - * Instruction precision for GL_NV_fragment_program - */ -/*@{*/ -#define FLOAT32 0x1 -#define FLOAT16 0x2 -#define FIXED12 0x4 -/*@}*/ - - -/** - * Saturation modes when storing values. - */ -/*@{*/ -#define SATURATE_OFF 0 -#define SATURATE_ZERO_ONE 1 -/*@}*/ - - -/** - * Per-component negation masks - */ -/*@{*/ -#define NEGATE_X 0x1 -#define NEGATE_Y 0x2 -#define NEGATE_Z 0x4 -#define NEGATE_W 0x8 -#define NEGATE_XYZ 0x7 -#define NEGATE_XYZW 0xf -#define NEGATE_NONE 0x0 -/*@}*/ - - -/** - * Program instruction opcodes, for both vertex and fragment programs. - * \note changes to this opcode list must be reflected in t_vb_arbprogram.c - */ -typedef enum prog_opcode { - /* ARB_vp ARB_fp NV_vp NV_fp GLSL */ - /*------------------------------------------*/ - OPCODE_NOP = 0, /* X */ - OPCODE_ABS, /* X X 1.1 X */ - OPCODE_ADD, /* X X X X X */ - OPCODE_AND, /* */ - OPCODE_ARA, /* 2 */ - OPCODE_ARL, /* X X */ - OPCODE_ARL_NV, /* 2 */ - OPCODE_ARR, /* 2 */ - OPCODE_BGNLOOP, /* opt */ - OPCODE_BGNSUB, /* opt */ - OPCODE_BRA, /* 2 X */ - OPCODE_BRK, /* 2 opt */ - OPCODE_CAL, /* 2 2 */ - OPCODE_CMP, /* X */ - OPCODE_CONT, /* opt */ - OPCODE_COS, /* X 2 X X */ - OPCODE_DDX, /* X X */ - OPCODE_DDY, /* X X */ - OPCODE_DP2, /* 2 */ - OPCODE_DP2A, /* 2 */ - OPCODE_DP3, /* X X X X X */ - OPCODE_DP4, /* X X X X X */ - OPCODE_DPH, /* X X 1.1 */ - OPCODE_DST, /* X X X X */ - OPCODE_ELSE, /* X */ - OPCODE_END, /* X X X X opt */ - OPCODE_ENDIF, /* opt */ - OPCODE_ENDLOOP, /* opt */ - OPCODE_ENDSUB, /* opt */ - OPCODE_EX2, /* X X 2 X X */ - OPCODE_EXP, /* X X X */ - OPCODE_FLR, /* X X 2 X X */ - OPCODE_FRC, /* X X 2 X X */ - OPCODE_IF, /* opt */ - OPCODE_KIL, /* X */ - OPCODE_KIL_NV, /* X X */ - OPCODE_LG2, /* X X 2 X X */ - OPCODE_LIT, /* X X X X */ - OPCODE_LOG, /* X X X */ - OPCODE_LRP, /* X X */ - OPCODE_MAD, /* X X X X X */ - OPCODE_MAX, /* X X X X X */ - OPCODE_MIN, /* X X X X X */ - OPCODE_MOV, /* X X X X X */ - OPCODE_MUL, /* X X X X X */ - OPCODE_NOISE1, /* X */ - OPCODE_NOISE2, /* X */ - OPCODE_NOISE3, /* X */ - OPCODE_NOISE4, /* X */ - OPCODE_NOT, /* */ - OPCODE_NRM3, /* */ - OPCODE_NRM4, /* */ - OPCODE_OR, /* */ - OPCODE_PK2H, /* X */ - OPCODE_PK2US, /* X */ - OPCODE_PK4B, /* X */ - OPCODE_PK4UB, /* X */ - OPCODE_POW, /* X X X X */ - OPCODE_POPA, /* 3 */ - OPCODE_PRINT, /* X X */ - OPCODE_PUSHA, /* 3 */ - OPCODE_RCC, /* 1.1 */ - OPCODE_RCP, /* X X X X X */ - OPCODE_RET, /* 2 2 */ - OPCODE_RFL, /* X X */ - OPCODE_RSQ, /* X X X X X */ - OPCODE_SCS, /* X */ - OPCODE_SEQ, /* 2 X X */ - OPCODE_SFL, /* 2 X */ - OPCODE_SGE, /* X X X X X */ - OPCODE_SGT, /* 2 X X */ - OPCODE_SIN, /* X 2 X X */ - OPCODE_SLE, /* 2 X X */ - OPCODE_SLT, /* X X X X X */ - OPCODE_SNE, /* 2 X X */ - OPCODE_SSG, /* 2 */ - OPCODE_STR, /* 2 X */ - OPCODE_SUB, /* X X 1.1 X X */ - OPCODE_SWZ, /* X X */ - OPCODE_TEX, /* X 3 X X */ - OPCODE_TXB, /* X 3 X */ - OPCODE_TXD, /* X X */ - OPCODE_TXL, /* 3 2 X */ - OPCODE_TXP, /* X X */ - OPCODE_TXP_NV, /* 3 X */ - OPCODE_TRUNC, /* X */ - OPCODE_UP2H, /* X */ - OPCODE_UP2US, /* X */ - OPCODE_UP4B, /* X */ - OPCODE_UP4UB, /* X */ - OPCODE_X2D, /* X */ - OPCODE_XOR, /* */ - OPCODE_XPD, /* X X X */ - MAX_OPCODE -} gl_inst_opcode; - - -/** - * Number of bits for the src/dst register Index field. - * This limits the size of temp/uniform register files. - */ -#define INST_INDEX_BITS 10 - - -/** - * Instruction source register. - */ -struct prog_src_register -{ - GLuint File:4; /**< One of the PROGRAM_* register file values. */ - GLint Index:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit. - * May be negative for relative addressing. - */ - GLuint Swizzle:12; - GLuint RelAddr:1; - - /** Take the component-wise absolute value */ - GLuint Abs:1; - - /** - * Post-Abs negation. - * This will either be NEGATE_NONE or NEGATE_XYZW, except for the SWZ - * instruction which allows per-component negation. - */ - GLuint Negate:4; -}; - - -/** - * Instruction destination register. - */ -struct prog_dst_register -{ - GLuint File:4; /**< One of the PROGRAM_* register file values */ - GLuint Index:INST_INDEX_BITS; /**< Unsigned, never negative */ - GLuint WriteMask:4; - GLuint RelAddr:1; - - /** - * \name Conditional destination update control. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, - * NV_vertex_program2_option. - */ - /*@{*/ - /** - * Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT, - * NE, TR, or UN). Dest reg is only written to if the matching - * (swizzled) condition code value passes. When a conditional update mask - * is not specified, this will be \c COND_TR. - */ - GLuint CondMask:4; - - /** - * Condition code swizzle value. - */ - GLuint CondSwizzle:12; - - /** - * Selects the condition code register to use for conditional destination - * update masking. In NV_fragmnet_program or NV_vertex_program2 mode, only - * condition code register 0 is available. In NV_vertex_program3 mode, - * condition code registers 0 and 1 are available. - */ - GLuint CondSrc:1; - /*@}*/ -}; - - -/** - * Vertex/fragment program instruction. - */ -struct prog_instruction -{ - gl_inst_opcode Opcode; - struct prog_src_register SrcReg[3]; - struct prog_dst_register DstReg; - - /** - * Indicates that the instruction should update the condition code - * register. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, - * NV_vertex_program2_option. - */ - GLuint CondUpdate:1; - - /** - * If prog_instruction::CondUpdate is \c GL_TRUE, this value selects the - * condition code register that is to be updated. - * - * In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition - * code register 0 is available. In GL_NV_vertex_program3 mode, condition - * code registers 0 and 1 are available. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, - * NV_vertex_program2_option. - */ - GLuint CondDst:1; - - /** - * Saturate each value of the vectored result to the range [0,1] or the - * range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is - * only available in NV_fragment_program2 mode. - * Value is one of the SATURATE_* tokens. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program3. - */ - GLuint SaturateMode:2; - - /** - * Per-instruction selectable precision: FLOAT32, FLOAT16, FIXED12. - * - * \since - * NV_fragment_program, NV_fragment_program_option. - */ - GLuint Precision:3; - - /** - * \name Extra fields for TEX, TXB, TXD, TXL, TXP instructions. - */ - /*@{*/ - /** Source texture unit. */ - GLuint TexSrcUnit:5; - - /** Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX */ - GLuint TexSrcTarget:3; - - /** True if tex instruction should do shadow comparison */ - GLuint TexShadow:1; - /*@}*/ - - /** - * For BRA and CAL instructions, the location to jump to. - * For BGNLOOP, points to ENDLOOP (and vice-versa). - * For BRK, points to BGNLOOP (which points to ENDLOOP). - * For IF, points to ELSE or ENDIF. - * For ELSE, points to ENDIF. - */ - GLint BranchTarget; - - /** for debugging purposes */ - const char *Comment; - - /** Arbitrary data. Used for OPCODE_PRINT and some drivers */ - void *Data; - - /** for driver use (try to remove someday) */ - GLint Aux; -}; - - -extern void -_mesa_init_instructions(struct prog_instruction *inst, GLuint count); - -extern struct prog_instruction * -_mesa_alloc_instructions(GLuint numInst); - -extern struct prog_instruction * -_mesa_realloc_instructions(struct prog_instruction *oldInst, - GLuint numOldInst, GLuint numNewInst); - -extern struct prog_instruction * -_mesa_copy_instructions(struct prog_instruction *dest, - const struct prog_instruction *src, GLuint n); - -extern void -_mesa_free_instructions(struct prog_instruction *inst, GLuint count); - -extern GLuint -_mesa_num_inst_src_regs(gl_inst_opcode opcode); - -extern GLuint -_mesa_num_inst_dst_regs(gl_inst_opcode opcode); - -extern GLboolean -_mesa_is_tex_instruction(gl_inst_opcode opcode); - -extern GLboolean -_mesa_check_soa_dependencies(const struct prog_instruction *inst); - -extern const char * -_mesa_opcode_string(gl_inst_opcode opcode); - - -#endif /* PROG_INSTRUCTION_H */ diff --git a/src/glsl/mesa/shader/prog_print.c b/src/glsl/mesa/shader/prog_print.c deleted file mode 100644 index 3f1cb48e4bf..00000000000 --- a/src/glsl/mesa/shader/prog_print.c +++ /dev/null @@ -1,1089 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file prog_print.c - * Print vertex/fragment programs - for debugging. - * \author Brian Paul - */ - -#if 0 -#include "main/glheader.h" -#include "main/context.h" -#include "main/imports.h" -#else - -#define _GNU_SOURCE - -#include -#include -#include -#include -struct gl_program { - int Target; -}; - -void _mesa_problem(void *ctx, char *msg) -{ - (void)ctx; - fprintf(stderr, "%s", msg); - exit(1); -} - -#endif - -#include "prog_instruction.h" -#include "prog_print.h" - - - -/** - * Return string name for given program/register file. - */ -static const char * -file_string(gl_register_file f, gl_prog_print_mode mode) -{ - (void)mode; - switch (f) { - case PROGRAM_TEMPORARY: - return "TEMP"; - case PROGRAM_LOCAL_PARAM: - return "LOCAL"; - case PROGRAM_ENV_PARAM: - return "ENV"; - case PROGRAM_STATE_VAR: - return "STATE"; - case PROGRAM_INPUT: - return "INPUT"; - case PROGRAM_OUTPUT: - return "OUTPUT"; - case PROGRAM_NAMED_PARAM: - return "NAMED"; - case PROGRAM_CONSTANT: - return "CONST"; - case PROGRAM_UNIFORM: - return "UNIFORM"; - case PROGRAM_VARYING: - return "VARYING"; - case PROGRAM_WRITE_ONLY: - return "WRITE_ONLY"; - case PROGRAM_ADDRESS: - return "ADDR"; - case PROGRAM_SAMPLER: - return "SAMPLER"; - case PROGRAM_UNDEFINED: - return "UNDEFINED"; - default: - { - static char s[20]; - snprintf(s, sizeof(s), "FILE%u", f); - return s; - } - } -} - - -/** - * Return ARB_v/f_prog-style input attrib string. - */ -static const char * -arb_input_attrib_string(GLint index, GLenum progType) -{ - /* - * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens. - */ - const char *vertAttribs[] = { - "vertex.position", - "vertex.weight", - "vertex.normal", - "vertex.color.primary", - "vertex.color.secondary", - "vertex.fogcoord", - "vertex.(six)", - "vertex.(seven)", - "vertex.texcoord[0]", - "vertex.texcoord[1]", - "vertex.texcoord[2]", - "vertex.texcoord[3]", - "vertex.texcoord[4]", - "vertex.texcoord[5]", - "vertex.texcoord[6]", - "vertex.texcoord[7]", - "vertex.attrib[0]", - "vertex.attrib[1]", - "vertex.attrib[2]", - "vertex.attrib[3]", - "vertex.attrib[4]", - "vertex.attrib[5]", - "vertex.attrib[6]", - "vertex.attrib[7]", - "vertex.attrib[8]", - "vertex.attrib[9]", - "vertex.attrib[10]", - "vertex.attrib[11]", - "vertex.attrib[12]", - "vertex.attrib[13]", - "vertex.attrib[14]", - "vertex.attrib[15]" - }; - const char *fragAttribs[] = { - "fragment.position", - "fragment.color.primary", - "fragment.color.secondary", - "fragment.fogcoord", - "fragment.texcoord[0]", - "fragment.texcoord[1]", - "fragment.texcoord[2]", - "fragment.texcoord[3]", - "fragment.texcoord[4]", - "fragment.texcoord[5]", - "fragment.texcoord[6]", - "fragment.texcoord[7]", - "fragment.varying[0]", - "fragment.varying[1]", - "fragment.varying[2]", - "fragment.varying[3]", - "fragment.varying[4]", - "fragment.varying[5]", - "fragment.varying[6]", - "fragment.varying[7]" - }; - - /* sanity checks */ - assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0); - assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0); - - if (progType == GL_VERTEX_PROGRAM_ARB) { - assert((unsigned int)index < sizeof(vertAttribs) / sizeof(vertAttribs[0])); - return vertAttribs[index]; - } - else { - assert((unsigned int)index < sizeof(fragAttribs) / sizeof(fragAttribs[0])); - return fragAttribs[index]; - } -} - - -/** - * Print a vertex program's InputsRead field in human-readable format. - * For debugging. - */ -void -_mesa_print_vp_inputs(GLbitfield inputs) -{ - printf("VP Inputs 0x%x: \n", inputs); - while (inputs) { - GLint attr = ffs(inputs) - 1; - const char *name = arb_input_attrib_string(attr, - GL_VERTEX_PROGRAM_ARB); - printf(" %d: %s\n", attr, name); - inputs &= ~(1 << attr); - } -} - - -/** - * Print a fragment program's InputsRead field in human-readable format. - * For debugging. - */ -void -_mesa_print_fp_inputs(GLbitfield inputs) -{ - printf("FP Inputs 0x%x: \n", inputs); - while (inputs) { - GLint attr = ffs(inputs) - 1; - const char *name = arb_input_attrib_string(attr, - GL_FRAGMENT_PROGRAM_ARB); - printf(" %d: %s\n", attr, name); - inputs &= ~(1 << attr); - } -} - - -#if 0 -/** - * Return ARB_v/f_prog-style output attrib string. - */ -static const char * -arb_output_attrib_string(GLint index, GLenum progType) -{ - /* - * These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens. - */ - const char *vertResults[] = { - "result.position", - "result.color.primary", - "result.color.secondary", - "result.fogcoord", - "result.texcoord[0]", - "result.texcoord[1]", - "result.texcoord[2]", - "result.texcoord[3]", - "result.texcoord[4]", - "result.texcoord[5]", - "result.texcoord[6]", - "result.texcoord[7]", - "result.varying[0]", - "result.varying[1]", - "result.varying[2]", - "result.varying[3]", - "result.varying[4]", - "result.varying[5]", - "result.varying[6]", - "result.varying[7]" - }; - const char *fragResults[] = { - "result.color", - "result.color(half)", - "result.depth", - "result.color[0]", - "result.color[1]", - "result.color[2]", - "result.color[3]" - }; - - if (progType == GL_VERTEX_PROGRAM_ARB) { - assert(index < sizeof(vertResults) / sizeof(vertResults[0])); - return vertResults[index]; - } - else { - assert(index < sizeof(fragResults) / sizeof(fragResults[0])); - return fragResults[index]; - } -} -#endif - -/** - * Return string representation of the given register. - * Note that some types of registers (like PROGRAM_UNIFORM) aren't defined - * by the ARB/NV program languages so we've taken some liberties here. - * \param f the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc) - * \param index number of the register in the register file - * \param mode the output format/mode/style - * \param prog pointer to containing program - */ -static const char * -reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, - GLboolean relAddr, const struct gl_program *prog) -{ - static char str[100]; - const char *addr = relAddr ? "ADDR+" : ""; - - str[0] = 0; - - switch (mode) { - case PROG_PRINT_DEBUG: - sprintf(str, "%s[%s%d]", file_string(f, mode), addr, index); - break; - case PROG_PRINT_ARB: -#if 0 - switch (f) { - case PROGRAM_INPUT: - sprintf(str, "%s", arb_input_attrib_string(index, prog->Target)); - break; - case PROGRAM_OUTPUT: - sprintf(str, "%s", arb_output_attrib_string(index, prog->Target)); - break; - case PROGRAM_TEMPORARY: - sprintf(str, "temp%d", index); - break; - case PROGRAM_ENV_PARAM: - sprintf(str, "program.env[%s%d]", addr, index); - break; - case PROGRAM_LOCAL_PARAM: - sprintf(str, "program.local[%s%d]", addr, index); - break; - case PROGRAM_VARYING: /* extension */ - sprintf(str, "varying[%s%d]", addr, index); - break; - case PROGRAM_CONSTANT: /* extension */ - sprintf(str, "constant[%s%d]", addr, index); - break; - case PROGRAM_UNIFORM: /* extension */ - sprintf(str, "uniform[%s%d]", addr, index); - break; - case PROGRAM_STATE_VAR: - { - struct gl_program_parameter *param - = prog->Parameters->Parameters + index; - char *state = _mesa_program_state_string(param->StateIndexes); - sprintf(str, "%s", state); - free(state); - } - break; - case PROGRAM_ADDRESS: - sprintf(str, "A%d", index); - break; - default: - _mesa_problem(NULL, "bad file in reg_string()"); - } - break; -#else - assert(0); - break; -#endif - - case PROG_PRINT_NV: - switch (f) { - case PROGRAM_INPUT: - if (prog->Target == GL_VERTEX_PROGRAM_ARB) - sprintf(str, "v[%d]", index); - else - sprintf(str, "f[%d]", index); - break; - case PROGRAM_OUTPUT: - sprintf(str, "o[%d]", index); - break; - case PROGRAM_TEMPORARY: - sprintf(str, "R%d", index); - break; - case PROGRAM_ENV_PARAM: - sprintf(str, "c[%d]", index); - break; - case PROGRAM_VARYING: /* extension */ - sprintf(str, "varying[%s%d]", addr, index); - break; - case PROGRAM_UNIFORM: /* extension */ - sprintf(str, "uniform[%s%d]", addr, index); - break; - case PROGRAM_CONSTANT: /* extension */ - sprintf(str, "constant[%s%d]", addr, index); - break; - case PROGRAM_STATE_VAR: /* extension */ - sprintf(str, "state[%s%d]", addr, index); - break; - default: - _mesa_problem(NULL, "bad file in reg_string()"); - } - break; - - default: - _mesa_problem(NULL, "bad mode in reg_string()"); - } - - return str; -} - - -/** - * Return a string representation of the given swizzle word. - * If extended is true, use extended (comma-separated) format. - * \param swizzle the swizzle field - * \param negateBase 4-bit negation vector - * \param extended if true, also allow 0, 1 values - */ -const char * -_mesa_swizzle_string(GLuint swizzle, GLuint negateMask, GLboolean extended) -{ - static const char swz[] = "xyzw01!?"; /* See SWIZZLE_x definitions */ - static char s[20]; - GLuint i = 0; - - if (!extended && swizzle == SWIZZLE_NOOP && negateMask == 0) - return ""; /* no swizzle/negation */ - - if (!extended) - s[i++] = '.'; - - if (negateMask & NEGATE_X) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 0)]; - - if (extended) { - s[i++] = ','; - } - - if (negateMask & NEGATE_Y) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 1)]; - - if (extended) { - s[i++] = ','; - } - - if (negateMask & NEGATE_Z) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 2)]; - - if (extended) { - s[i++] = ','; - } - - if (negateMask & NEGATE_W) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 3)]; - - s[i] = 0; - return s; -} - - -void -_mesa_print_swizzle(GLuint swizzle) -{ - if (swizzle == SWIZZLE_XYZW) { - printf(".xyzw\n"); - } - else { - const char *s = _mesa_swizzle_string(swizzle, 0, 0); - printf("%s\n", s); - } -} - - -const char * -_mesa_writemask_string(GLuint writeMask) -{ - static char s[10]; - GLuint i = 0; - - if (writeMask == WRITEMASK_XYZW) - return ""; - - s[i++] = '.'; - if (writeMask & WRITEMASK_X) - s[i++] = 'x'; - if (writeMask & WRITEMASK_Y) - s[i++] = 'y'; - if (writeMask & WRITEMASK_Z) - s[i++] = 'z'; - if (writeMask & WRITEMASK_W) - s[i++] = 'w'; - - s[i] = 0; - return s; -} - - -const char * -_mesa_condcode_string(GLuint condcode) -{ - switch (condcode) { - case COND_GT: return "GT"; - case COND_EQ: return "EQ"; - case COND_LT: return "LT"; - case COND_UN: return "UN"; - case COND_GE: return "GE"; - case COND_LE: return "LE"; - case COND_NE: return "NE"; - case COND_TR: return "TR"; - case COND_FL: return "FL"; - default: return "cond???"; - } -} - - -static void -fprint_dst_reg(FILE * f, - const struct prog_dst_register *dstReg, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - fprintf(f, "%s%s", - reg_string((gl_register_file) dstReg->File, - dstReg->Index, mode, dstReg->RelAddr, prog), - _mesa_writemask_string(dstReg->WriteMask)); - - if (dstReg->CondMask != COND_TR) { - fprintf(f, " (%s.%s)", - _mesa_condcode_string(dstReg->CondMask), - _mesa_swizzle_string(dstReg->CondSwizzle, - GL_FALSE, GL_FALSE)); - } - -#if 0 - fprintf(f, "%s[%d]%s", - file_string((gl_register_file) dstReg->File, mode), - dstReg->Index, - _mesa_writemask_string(dstReg->WriteMask)); -#endif -} - - -static void -fprint_src_reg(FILE *f, - const struct prog_src_register *srcReg, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - const char *abs = srcReg->Abs ? "|" : ""; - - fprintf(f, "%s%s%s%s", - abs, - reg_string((gl_register_file) srcReg->File, - srcReg->Index, mode, srcReg->RelAddr, prog), - _mesa_swizzle_string(srcReg->Swizzle, - srcReg->Negate, GL_FALSE), - abs); -#if 0 - fprintf(f, "%s[%d]%s", - file_string((gl_register_file) srcReg->File, mode), - srcReg->Index, - _mesa_swizzle_string(srcReg->Swizzle, - srcReg->Negate, GL_FALSE)); -#endif -} - - -static void -fprint_comment(FILE *f, const struct prog_instruction *inst) -{ - if (inst->Comment) - fprintf(f, "; # %s\n", inst->Comment); - else - fprintf(f, ";\n"); -} - - -static void -fprint_alu_instruction(FILE *f, - const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - GLuint j; - - fprintf(f, "%s", opcode_string); - if (inst->CondUpdate) - fprintf(f, ".C"); - - /* frag prog only */ - if (inst->SaturateMode == SATURATE_ZERO_ONE) - fprintf(f, "_SAT"); - - fprintf(f, " "); - if (inst->DstReg.File != PROGRAM_UNDEFINED) { - fprint_dst_reg(f, &inst->DstReg, mode, prog); - } - else { - fprintf(f, " ???"); - } - - if (numRegs > 0) - fprintf(f, ", "); - - for (j = 0; j < numRegs; j++) { - fprint_src_reg(f, inst->SrcReg + j, mode, prog); - if (j + 1 < numRegs) - fprintf(f, ", "); - } - - fprint_comment(f, inst); -} - - -void -_mesa_print_alu_instruction(const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs) -{ - fprint_alu_instruction(stderr, inst, opcode_string, - numRegs, PROG_PRINT_DEBUG, NULL); -} - - -/** - * Print a single vertex/fragment program instruction. - */ -GLint -_mesa_fprint_instruction_opt(FILE *f, - const struct prog_instruction *inst, - GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - GLint i; - - if (inst->Opcode == OPCODE_ELSE || - inst->Opcode == OPCODE_ENDIF || - inst->Opcode == OPCODE_ENDLOOP || - inst->Opcode == OPCODE_ENDSUB) { - indent -= 3; - } - for (i = 0; i < indent; i++) { - fprintf(f, " "); - } - - switch (inst->Opcode) { - case OPCODE_PRINT: - fprintf(f, "PRINT '%s'", (char *) inst->Data); - if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { - fprintf(f, ", "); - fprintf(f, "%s[%d]%s", - file_string((gl_register_file) inst->SrcReg[0].File, - mode), - inst->SrcReg[0].Index, - _mesa_swizzle_string(inst->SrcReg[0].Swizzle, - inst->SrcReg[0].Negate, GL_FALSE)); - } - if (inst->Comment) - fprintf(f, " # %s", inst->Comment); - fprint_comment(f, inst); - break; - case OPCODE_SWZ: - fprintf(f, "SWZ"); - if (inst->SaturateMode == SATURATE_ZERO_ONE) - fprintf(f, "_SAT"); - fprintf(f, " "); - fprint_dst_reg(f, &inst->DstReg, mode, prog); - fprintf(f, ", %s[%d], %s", - file_string((gl_register_file) inst->SrcReg[0].File, - mode), - inst->SrcReg[0].Index, - _mesa_swizzle_string(inst->SrcReg[0].Swizzle, - inst->SrcReg[0].Negate, GL_TRUE)); - fprint_comment(f, inst); - break; - case OPCODE_TEX: - case OPCODE_TXP: - case OPCODE_TXL: - case OPCODE_TXB: - fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - if (inst->SaturateMode == SATURATE_ZERO_ONE) - fprintf(f, "_SAT"); - fprintf(f, " "); - fprint_dst_reg(f, &inst->DstReg, mode, prog); - fprintf(f, ", "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprintf(f, ", texture[%d], ", inst->TexSrcUnit); - switch (inst->TexSrcTarget) { - case TEXTURE_1D_INDEX: fprintf(f, "1D"); break; - case TEXTURE_2D_INDEX: fprintf(f, "2D"); break; - case TEXTURE_3D_INDEX: fprintf(f, "3D"); break; - case TEXTURE_CUBE_INDEX: fprintf(f, "CUBE"); break; - case TEXTURE_RECT_INDEX: fprintf(f, "RECT"); break; - case TEXTURE_1D_ARRAY_INDEX: fprintf(f, "1D_ARRAY"); break; - case TEXTURE_2D_ARRAY_INDEX: fprintf(f, "2D_ARRAY"); break; - default: - ; - } - if (inst->TexShadow) - fprintf(f, " SHADOW"); - fprint_comment(f, inst); - break; - - case OPCODE_KIL: - fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - fprintf(f, " "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprint_comment(f, inst); - break; - case OPCODE_KIL_NV: - fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - fprintf(f, " "); - fprintf(f, "%s.%s", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, - GL_FALSE, GL_FALSE)); - fprint_comment(f, inst); - break; - - case OPCODE_ARL: - fprintf(f, "ARL "); - fprint_dst_reg(f, &inst->DstReg, mode, prog); - fprintf(f, ", "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprint_comment(f, inst); - break; - case OPCODE_BRA: - fprintf(f, "BRA %d (%s%s)", - inst->BranchTarget, - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); - fprint_comment(f, inst); - break; - case OPCODE_IF: - if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { - /* Use ordinary register */ - fprintf(f, "IF "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprintf(f, "; "); - } - else { - /* Use cond codes */ - fprintf(f, "IF (%s%s);", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, - 0, GL_FALSE)); - } - fprintf(f, " # (if false, goto %d)", inst->BranchTarget); - fprint_comment(f, inst); - return indent + 3; - case OPCODE_ELSE: - fprintf(f, "ELSE; # (goto %d)\n", inst->BranchTarget); - return indent + 3; - case OPCODE_ENDIF: - fprintf(f, "ENDIF;\n"); - break; - case OPCODE_BGNLOOP: - fprintf(f, "BGNLOOP; # (end at %d)\n", inst->BranchTarget); - return indent + 3; - case OPCODE_ENDLOOP: - fprintf(f, "ENDLOOP; # (goto %d)\n", inst->BranchTarget); - break; - case OPCODE_BRK: - case OPCODE_CONT: - fprintf(f, "%s (%s%s); # (goto %d)", - _mesa_opcode_string(inst->Opcode), - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), - inst->BranchTarget); - fprint_comment(f, inst); - break; - - case OPCODE_BGNSUB: - if (mode == PROG_PRINT_NV) { - fprintf(f, "%s:\n", inst->Comment); /* comment is label */ - return indent; - } - else { - fprintf(f, "BGNSUB"); - fprint_comment(f, inst); - return indent + 3; - } - case OPCODE_ENDSUB: - if (mode == PROG_PRINT_DEBUG) { - fprintf(f, "ENDSUB"); - fprint_comment(f, inst); - } - break; - case OPCODE_CAL: - if (mode == PROG_PRINT_NV) { - fprintf(f, "CAL %s; # (goto %d)\n", inst->Comment, inst->BranchTarget); - } - else { - fprintf(f, "CAL %u", inst->BranchTarget); - fprint_comment(f, inst); - } - break; - case OPCODE_RET: - fprintf(f, "RET (%s%s)", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); - fprint_comment(f, inst); - break; - - case OPCODE_END: - fprintf(f, "END\n"); - break; - case OPCODE_NOP: - if (mode == PROG_PRINT_DEBUG) { - fprintf(f, "NOP"); - fprint_comment(f, inst); - } - else if (inst->Comment) { - /* ARB/NV extensions don't have NOP instruction */ - fprintf(f, "# %s\n", inst->Comment); - } - break; - /* XXX may need other special-case instructions */ - default: - if (inst->Opcode < MAX_OPCODE) { - /* typical alu instruction */ - fprint_alu_instruction(f, inst, - _mesa_opcode_string(inst->Opcode), - _mesa_num_inst_src_regs(inst->Opcode), - mode, prog); - } - else { - fprint_alu_instruction(f, inst, - _mesa_opcode_string(inst->Opcode), - 3/*_mesa_num_inst_src_regs(inst->Opcode)*/, - mode, prog); - } - break; - } - return indent; -} - - -GLint -_mesa_print_instruction_opt(const struct prog_instruction *inst, - GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - return _mesa_fprint_instruction_opt(stderr, inst, indent, mode, prog); -} - - -void -_mesa_print_instruction(const struct prog_instruction *inst) -{ - /* note: 4th param should be ignored for PROG_PRINT_DEBUG */ - _mesa_fprint_instruction_opt(stdout, inst, 0, PROG_PRINT_DEBUG, NULL); -} - -#if 0 -/** - * Print program, with options. - */ -void -_mesa_fprint_program_opt(FILE *f, - const struct gl_program *prog, - gl_prog_print_mode mode, - GLboolean lineNumbers) -{ - GLuint i, indent = 0; - - switch (prog->Target) { - case GL_VERTEX_PROGRAM_ARB: - if (mode == PROG_PRINT_ARB) - fprintf(f, "!!ARBvp1.0\n"); - else if (mode == PROG_PRINT_NV) - fprintf(f, "!!VP1.0\n"); - else - fprintf(f, "# Vertex Program/Shader %u\n", prog->Id); - break; - case GL_FRAGMENT_PROGRAM_ARB: - case GL_FRAGMENT_PROGRAM_NV: - if (mode == PROG_PRINT_ARB) - fprintf(f, "!!ARBfp1.0\n"); - else if (mode == PROG_PRINT_NV) - fprintf(f, "!!FP1.0\n"); - else - fprintf(f, "# Fragment Program/Shader %u\n", prog->Id); - break; - } - - for (i = 0; i < prog->NumInstructions; i++) { - if (lineNumbers) - fprintf(f, "%3d: ", i); - indent = _mesa_fprint_instruction_opt(f, prog->Instructions + i, - indent, mode, prog); - } -} - - -/** - * Print program to stderr, default options. - */ -void -_mesa_print_program(const struct gl_program *prog) -{ - _mesa_fprint_program_opt(stderr, prog, PROG_PRINT_DEBUG, GL_TRUE); -} - -/** - * Return binary representation of 64-bit value (as a string). - * Insert a comma to separate each group of 8 bits. - * Note we return a pointer to local static storage so this is not - * re-entrant, etc. - * XXX move to imports.[ch] if useful elsewhere. - */ -static const char * -binary(GLbitfield64 val) -{ - static char buf[80]; - GLint i, len = 0; - for (i = 63; i >= 0; --i) { - if (val & (1ULL << i)) - buf[len++] = '1'; - else if (len > 0 || i == 0) - buf[len++] = '0'; - if (len > 0 && ((i-1) % 8) == 7) - buf[len++] = ','; - } - buf[len] = '\0'; - return buf; -} - - -/** - * Print all of a program's parameters/fields to given file. - */ -static void -_mesa_fprint_program_parameters(FILE *f, - GLcontext *ctx, - const struct gl_program *prog) -{ - GLuint i; - - fprintf(f, "InputsRead: 0x%x (0b%s)\n", - prog->InputsRead, binary(prog->InputsRead)); - fprintf(f, "OutputsWritten: 0x%llx (0b%s)\n", - prog->OutputsWritten, binary(prog->OutputsWritten)); - fprintf(f, "NumInstructions=%d\n", prog->NumInstructions); - fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries); - fprintf(f, "NumParameters=%d\n", prog->NumParameters); - fprintf(f, "NumAttributes=%d\n", prog->NumAttributes); - fprintf(f, "NumAddressRegs=%d\n", prog->NumAddressRegs); - fprintf(f, "SamplersUsed: 0x%x (0b%s)\n", - prog->SamplersUsed, binary(prog->SamplersUsed)); - fprintf(f, "Samplers=[ "); - for (i = 0; i < MAX_SAMPLERS; i++) { - fprintf(f, "%d ", prog->SamplerUnits[i]); - } - fprintf(f, "]\n"); - - _mesa_load_state_parameters(ctx, prog->Parameters); - -#if 0 - fprintf(f, "Local Params:\n"); - for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){ - const GLfloat *p = prog->LocalParams[i]; - fprintf(f, "%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]); - } -#endif - _mesa_print_parameter_list(prog->Parameters); -} - - -/** - * Print all of a program's parameters/fields to stderr. - */ -void -_mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog) -{ - _mesa_fprint_program_parameters(stderr, ctx, prog); -} - - -/** - * Print a program parameter list to given file. - */ -static void -_mesa_fprint_parameter_list(FILE *f, - const struct gl_program_parameter_list *list) -{ - const gl_prog_print_mode mode = PROG_PRINT_DEBUG; - GLuint i; - - if (!list) - return; - - if (0) - fprintf(f, "param list %p\n", (void *) list); - fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags); - for (i = 0; i < list->NumParameters; i++){ - struct gl_program_parameter *param = list->Parameters + i; - const GLfloat *v = list->ParameterValues[i]; - fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", - i, param->Size, - file_string(list->Parameters[i].Type, mode), - param->Name, v[0], v[1], v[2], v[3]); - if (param->Flags & PROG_PARAM_BIT_CENTROID) - fprintf(f, " Centroid"); - if (param->Flags & PROG_PARAM_BIT_INVARIANT) - fprintf(f, " Invariant"); - if (param->Flags & PROG_PARAM_BIT_FLAT) - fprintf(f, " Flat"); - if (param->Flags & PROG_PARAM_BIT_LINEAR) - fprintf(f, " Linear"); - fprintf(f, "\n"); - } -} - - -/** - * Print a program parameter list to stderr. - */ -void -_mesa_print_parameter_list(const struct gl_program_parameter_list *list) -{ - _mesa_fprint_parameter_list(stderr, list); -} - - -/** - * Write shader and associated info to a file. - */ -void -_mesa_write_shader_to_file(const struct gl_shader *shader) -{ - const char *type; - char filename[100]; - FILE *f; - - if (shader->Type == GL_FRAGMENT_SHADER) - type = "frag"; - else - type = "vert"; - - snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); - f = fopen(filename, "w"); - if (!f) { - fprintf(stderr, "Unable to open %s for writing\n", filename); - return; - } - - fprintf(f, "/* Shader %u source, checksum %u */\n", shader->Name, shader->SourceChecksum); - fputs(shader->Source, f); - fprintf(f, "\n"); - - fprintf(f, "/* Compile status: %s */\n", - shader->CompileStatus ? "ok" : "fail"); - if (!shader->CompileStatus) { - fprintf(f, "/* Log Info: */\n"); - fputs(shader->InfoLog, f); - } - else { - fprintf(f, "/* GPU code */\n"); - fprintf(f, "/*\n"); - _mesa_fprint_program_opt(f, shader->Program, PROG_PRINT_DEBUG, GL_TRUE); - fprintf(f, "*/\n"); - fprintf(f, "/* Parameters / constants */\n"); - fprintf(f, "/*\n"); - _mesa_fprint_parameter_list(f, shader->Program->Parameters); - fprintf(f, "*/\n"); - } - - fclose(f); -} - - -/** - * Append the shader's uniform info/values to the shader log file. - * The log file will typically have been created by the - * _mesa_write_shader_to_file function. - */ -void -_mesa_append_uniforms_to_file(const struct gl_shader *shader, - const struct gl_program *prog) -{ - const char *type; - char filename[100]; - FILE *f; - - if (shader->Type == GL_FRAGMENT_SHADER) - type = "frag"; - else - type = "vert"; - - snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); - f = fopen(filename, "a"); /* append */ - if (!f) { - fprintf(stderr, "Unable to open %s for appending\n", filename); - return; - } - - fprintf(f, "/* First-draw parameters / constants */\n"); - fprintf(f, "/*\n"); - _mesa_fprint_parameter_list(f, prog->Parameters); - fprintf(f, "*/\n"); - - fclose(f); -} -#endif diff --git a/src/glsl/mesa/shader/prog_print.h b/src/glsl/mesa/shader/prog_print.h deleted file mode 100644 index f0df77b5129..00000000000 --- a/src/glsl/mesa/shader/prog_print.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef PROG_PRINT_H -#define PROG_PRINT_H - - -/** - * The output style to use when printing programs. - */ -typedef enum { - PROG_PRINT_ARB, - PROG_PRINT_NV, - PROG_PRINT_DEBUG -} gl_prog_print_mode; - - -extern void -_mesa_print_vp_inputs(GLbitfield inputs); - -extern void -_mesa_print_fp_inputs(GLbitfield inputs); - -extern const char * -_mesa_condcode_string(GLuint condcode); - -extern const char * -_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended); - -const char * -_mesa_writemask_string(GLuint writeMask); - -extern void -_mesa_print_swizzle(GLuint swizzle); - -extern void -_mesa_print_alu_instruction(const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs); - -extern void -_mesa_print_instruction(const struct prog_instruction *inst); - -extern GLint -_mesa_fprint_instruction_opt(FILE *f, - const struct prog_instruction *inst, - GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog); - -extern GLint -_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog); - -extern void -_mesa_print_program(const struct gl_program *prog); - -extern void -_mesa_fprint_program_opt(FILE *f, - const struct gl_program *prog, gl_prog_print_mode mode, - GLboolean lineNumbers); - -#if 0 -extern void -_mesa_print_parameter_list(const struct gl_program_parameter_list *list); - -extern void -_mesa_write_shader_to_file(const struct gl_shader *shader); - -extern void -_mesa_append_uniforms_to_file(const struct gl_shader *shader, - const struct gl_program *prog); -#endif - - -#endif /* PROG_PRINT_H */ diff --git a/src/glsl/symbol_table.c b/src/glsl/symbol_table.c deleted file mode 100644 index 0f0df7a261b..00000000000 --- a/src/glsl/symbol_table.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "main/imports.h" -#include "symbol_table.h" -#include "hash_table.h" - -struct symbol { - /** - * Link to the next symbol in the table with the same name - * - * The linked list of symbols with the same name is ordered by scope - * from inner-most to outer-most. - */ - struct symbol *next_with_same_name; - - - /** - * Link to the next symbol in the table with the same scope - * - * The linked list of symbols with the same scope is unordered. Symbols - * in this list my have unique names. - */ - struct symbol *next_with_same_scope; - - - /** - * Header information for the list of symbols with the same name. - */ - struct symbol_header *hdr; - - - /** - * Name space of the symbol - * - * Name space are arbitrary user assigned integers. No two symbols can - * exist in the same name space at the same scope level. - */ - int name_space; - - - /** - * Arbitrary user supplied data. - */ - void *data; - - /** Scope depth where this symbol was defined. */ - unsigned depth; -}; - - -/** - */ -struct symbol_header { - /** Linkage in list of all headers in a given symbol table. */ - struct symbol_header *next; - - /** Symbol name. */ - const char *name; - - /** Linked list of symbols with the same name. */ - struct symbol *symbols; -}; - - -/** - * Element of the scope stack. - */ -struct scope_level { - /** Link to next (inner) scope level. */ - struct scope_level *next; - - /** Linked list of symbols with the same scope. */ - struct symbol *symbols; -}; - - -/** - * - */ -struct _mesa_symbol_table { - /** Hash table containing all symbols in the symbol table. */ - struct hash_table *ht; - - /** Top of scope stack. */ - struct scope_level *current_scope; - - /** List of all symbol headers in the table. */ - struct symbol_header *hdr; - - /** Current scope depth. */ - unsigned depth; -}; - - -struct _mesa_symbol_table_iterator { - /** - * Name space of symbols returned by this iterator. - */ - int name_space; - - - /** - * Currently iterated symbol - * - * The next call to \c _mesa_symbol_table_iterator_get will return this - * value. It will also update this value to the value that should be - * returned by the next call. - */ - struct symbol *curr; -}; - - -static void -check_symbol_table(struct _mesa_symbol_table *table) -{ -#if 1 - struct scope_level *scope; - - for (scope = table->current_scope; scope != NULL; scope = scope->next) { - struct symbol *sym; - - for (sym = scope->symbols - ; sym != NULL - ; sym = sym->next_with_same_name) { - const struct symbol_header *const hdr = sym->hdr; - struct symbol *sym2; - - for (sym2 = hdr->symbols - ; sym2 != NULL - ; sym2 = sym2->next_with_same_name) { - assert(sym2->hdr == hdr); - } - } - } -#endif -} - -void -_mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table) -{ - struct scope_level *const scope = table->current_scope; - struct symbol *sym = scope->symbols; - - table->current_scope = scope->next; - table->depth--; - - free(scope); - - while (sym != NULL) { - struct symbol *const next = sym->next_with_same_scope; - struct symbol_header *const hdr = sym->hdr; - - assert(hdr->symbols == sym); - - hdr->symbols = sym->next_with_same_name; - - free(sym); - - sym = next; - } - - check_symbol_table(table); -} - - -void -_mesa_symbol_table_push_scope(struct _mesa_symbol_table *table) -{ - struct scope_level *const scope = calloc(1, sizeof(*scope)); - - scope->next = table->current_scope; - table->current_scope = scope; - table->depth++; -} - - -static struct symbol_header * -find_symbol(struct _mesa_symbol_table *table, const char *name) -{ - return (struct symbol_header *) hash_table_find(table->ht, name); -} - - -struct _mesa_symbol_table_iterator * -_mesa_symbol_table_iterator_ctor(struct _mesa_symbol_table *table, - int name_space, const char *name) -{ - struct _mesa_symbol_table_iterator *iter = calloc(1, sizeof(*iter)); - struct symbol_header *const hdr = find_symbol(table, name); - - iter->name_space = name_space; - - if (hdr != NULL) { - struct symbol *sym; - - for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { - assert(sym->hdr == hdr); - - if ((name_space == -1) || (sym->name_space == name_space)) { - iter->curr = sym; - break; - } - } - } - - return iter; -} - - -void -_mesa_symbol_table_iterator_dtor(struct _mesa_symbol_table_iterator *iter) -{ - free(iter); -} - - -void * -_mesa_symbol_table_iterator_get(struct _mesa_symbol_table_iterator *iter) -{ - return (iter->curr == NULL) ? NULL : iter->curr->data; -} - - -int -_mesa_symbol_table_iterator_next(struct _mesa_symbol_table_iterator *iter) -{ - struct symbol_header *hdr; - - if (iter->curr == NULL) { - return 0; - } - - hdr = iter->curr->hdr; - iter->curr = iter->curr->next_with_same_name; - - while (iter->curr != NULL) { - assert(iter->curr->hdr == hdr); - - if ((iter->name_space == -1) - || (iter->curr->name_space == iter->name_space)) { - return 1; - } - - iter->curr = iter->curr->next_with_same_name; - } - - return 0; -} - - -/** - * Determine the scope "distance" of a symbol from the current scope - * - * \return - * A non-negative number for the number of scopes between the current scope - * and the scope where a symbol was defined. A value of zero means the current - * scope. A negative number if the symbol does not exist. - */ -int -_mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, - int name_space, const char *name) -{ - struct symbol_header *const hdr = find_symbol(table, name); - struct symbol *sym; - - if (hdr != NULL) { - for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { - assert(sym->hdr == hdr); - - if ((name_space == -1) || (sym->name_space == name_space)) { - assert(sym->depth <= table->depth); - return sym->depth - table->depth; - } - } - } - - return -1; -} - - -void * -_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table, - int name_space, const char *name) -{ - struct symbol_header *const hdr = find_symbol(table, name); - - if (hdr != NULL) { - struct symbol *sym; - - - for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { - assert(sym->hdr == hdr); - - if ((name_space == -1) || (sym->name_space == name_space)) { - return sym->data; - } - } - } - - return NULL; -} - - -int -_mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, - int name_space, const char *name, - void *declaration) -{ - struct symbol_header *hdr; - struct symbol *sym; - - check_symbol_table(table); - - hdr = find_symbol(table, name); - - check_symbol_table(table); - - if (hdr == NULL) { - hdr = calloc(1, sizeof(*hdr)); - hdr->name = name; - - hash_table_insert(table->ht, hdr, name); - hdr->next = table->hdr; - table->hdr = hdr; - } - - check_symbol_table(table); - - /* If the symbol already exists in this namespace at this scope, it cannot - * be added to the table. - */ - for (sym = hdr->symbols - ; (sym != NULL) && (sym->name_space != name_space) - ; sym = sym->next_with_same_name) { - /* empty */ - } - - if (sym && (sym->depth == table->depth)) - return -1; - - sym = calloc(1, sizeof(*sym)); - sym->next_with_same_name = hdr->symbols; - sym->next_with_same_scope = table->current_scope->symbols; - sym->hdr = hdr; - sym->name_space = name_space; - sym->data = declaration; - sym->depth = table->depth; - - assert(sym->hdr == hdr); - - hdr->symbols = sym; - table->current_scope->symbols = sym; - - check_symbol_table(table); - return 0; -} - - -struct _mesa_symbol_table * -_mesa_symbol_table_ctor(void) -{ - struct _mesa_symbol_table *table = calloc(1, sizeof(*table)); - - if (table != NULL) { - table->ht = hash_table_ctor(32, hash_table_string_hash, - hash_table_string_compare); - - _mesa_symbol_table_push_scope(table); - } - - return table; -} - - -void -_mesa_symbol_table_dtor(struct _mesa_symbol_table *table) -{ - struct symbol_header *hdr; - struct symbol_header *next; - - while (table->current_scope != NULL) { - _mesa_symbol_table_pop_scope(table); - } - - for (hdr = table->hdr; hdr != NULL; hdr = next) { - next = hdr->next; - _mesa_free(hdr); - } - - hash_table_dtor(table->ht); - free(table); -} diff --git a/src/glsl/symbol_table.h b/src/glsl/symbol_table.h deleted file mode 100644 index 3a9994c1ac9..00000000000 --- a/src/glsl/symbol_table.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#ifndef MESA_SYMBOL_TABLE_H -#define MESA_SYMBOL_TABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct _mesa_symbol_table; -struct _mesa_symbol_table_iterator; - -extern void _mesa_symbol_table_push_scope(struct _mesa_symbol_table *table); - -extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table); - -extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, - int name_space, const char *name, void *declaration); - -extern int _mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, - int name_space, const char *name); - -extern void *_mesa_symbol_table_find_symbol( - struct _mesa_symbol_table *symtab, int name_space, const char *name); - -extern struct _mesa_symbol_table *_mesa_symbol_table_ctor(void); - -extern void _mesa_symbol_table_dtor(struct _mesa_symbol_table *); - -extern struct _mesa_symbol_table_iterator *_mesa_symbol_table_iterator_ctor( - struct _mesa_symbol_table *table, int name_space, const char *name); - -extern void _mesa_symbol_table_iterator_dtor( - struct _mesa_symbol_table_iterator *); - -extern void *_mesa_symbol_table_iterator_get( - struct _mesa_symbol_table_iterator *iter); - -extern int _mesa_symbol_table_iterator_next( - struct _mesa_symbol_table_iterator *iter); - -#ifdef __cplusplus -} -#endif - -#endif /* MESA_SYMBOL_TABLE_H */ -- cgit v1.2.3 From 3d6012303c3ce24c75d209267e6914f706d025c5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 17:08:53 -0700 Subject: glsl2: Wrap includes of C interfaces with extern "C". --- src/glsl/ast_type.cpp | 2 ++ src/glsl/glsl_symbol_table.h | 2 ++ src/glsl/glsl_types.cpp | 3 ++- src/glsl/ir_clone.cpp | 2 ++ src/glsl/ir_function_inlining.cpp | 2 ++ src/glsl/ir_validate.cpp | 2 ++ src/glsl/linker.cpp | 2 ++ 7 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp index cb0852bb773..49dfde20e97 100644 --- a/src/glsl/ast_type.cpp +++ b/src/glsl/ast_type.cpp @@ -23,7 +23,9 @@ #include #include "ast.h" +extern "C" { #include "symbol_table.h" +} void ast_type_specifier::print(void) const diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h index ae2fd3f4f1f..8fbc66c974d 100644 --- a/src/glsl/glsl_symbol_table.h +++ b/src/glsl/glsl_symbol_table.h @@ -28,7 +28,9 @@ #include +extern "C" { #include "symbol_table.h" +} #include "ir.h" #include "glsl_types.h" diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index bef267fa6be..9a53fbdbcb4 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -27,8 +27,9 @@ #include "glsl_parser_extras.h" #include "glsl_types.h" #include "builtin_types.h" +extern "C" { #include "hash_table.h" - +} hash_table *glsl_type::array_types = NULL; diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 84176383fca..01a1ce3a6d4 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -24,7 +24,9 @@ #include #include "ir.h" #include "glsl_types.h" +extern "C" { #include "hash_table.h" +} /** * Duplicate an IR variable diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index e55780c940e..1adf67868ee 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -33,7 +33,9 @@ #include "ir_function_inlining.h" #include "ir_expression_flattening.h" #include "glsl_types.h" +extern "C" { #include "hash_table.h" +} class ir_function_inlining_visitor : public ir_hierarchical_visitor { public: diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 507e88993f2..19538524879 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -36,7 +36,9 @@ #include #include "ir.h" #include "ir_hierarchical_visitor.h" +extern "C" { #include "hash_table.h" +} static unsigned int hash_func(const void *key) { diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index ba382fe8816..8547f74ce65 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -77,7 +77,9 @@ extern "C" { #include "ir.h" #include "ir_optimization.h" #include "program.h" +extern "C" { #include "hash_table.h" +} /** * Visitor that determines whether or not a variable is ever written. -- cgit v1.2.3 From 0a1b54df7ac118722bb627c61cb322cb4e248ace Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 21 Jun 2010 11:29:15 -0700 Subject: glsl2: Replace the GLSL compiler with the glsl2 project. --- configure.ac | 4 +- src/glsl/Makefile | 130 +++++++++++++++++++++++++++++++-- src/glsl/Makefile.am | 8 +- src/mesa/Makefile | 19 ++--- src/mesa/drivers/dri/Makefile.template | 4 +- src/mesa/shader/ir_to_mesa.cpp | 1 + src/mesa/shader/shader_api.c | 6 +- src/mesa/sources.mak | 21 ++++-- 8 files changed, 157 insertions(+), 36 deletions(-) diff --git a/configure.ac b/configure.ac index 21123eccccb..bf42992b2fd 100644 --- a/configure.ac +++ b/configure.ac @@ -462,6 +462,8 @@ xxlib|xdri|xosmesa) ;; esac +PKG_CHECK_MODULES([TALLOC], [talloc]) + dnl dnl Driver specific build directories dnl @@ -852,7 +854,7 @@ if test "$mesa_driver" = dri; then [AC_MSG_ERROR([Expat required for DRI.])]) # put all the necessary libs together - DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS" + DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS $TALLOC_LIBS" fi AC_SUBST([DRI_DIRS]) AC_SUBST([EXPAT_INCLUDES]) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index ca7f2d2ac7d..91e4d2e05dd 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -1,15 +1,129 @@ -# src/glsl/Makefile +#src/glsl/pp/Makefile TOP = ../.. include $(TOP)/configs/current -SUBDIRS = pp cl apps +LIBNAME = glsl -default install clean: - @for dir in $(SUBDIRS) ; do \ - if [ -d $$dir ] ; then \ - (cd $$dir && $(MAKE) $@) || exit 1; \ - fi \ - done +C_SOURCES = \ + glcpp/glcpp.c \ + glcpp/glcpp-lex.c \ + glcpp/glcpp-parse.c \ + glcpp/pp.c \ + glcpp/xtalloc.c +CXX_SOURCES = \ + ast_expr.cpp \ + ast_function.cpp \ + ast_to_hir.cpp \ + ast_type.cpp \ + builtin_function.cpp \ + glsl_lexer.cpp \ + glsl_parser.cpp \ + glsl_parser_extras.cpp \ + glsl_types.cpp \ + hir_field_selection.cpp \ + ir_basic_block.cpp \ + ir_clone.cpp \ + ir_constant_expression.cpp \ + ir_constant_folding.cpp \ + ir_constant_variable.cpp \ + ir_copy_propagation.cpp \ + ir.cpp \ + ir_dead_code.cpp \ + ir_dead_code_local.cpp \ + ir_expression_flattening.cpp \ + ir_function_can_inline.cpp \ + ir_function.cpp \ + ir_function_inlining.cpp \ + ir_hierarchical_visitor.cpp \ + ir_hv_accept.cpp \ + ir_if_simplification.cpp \ + ir_print_visitor.cpp \ + ir_reader.cpp \ + ir_swizzle_swizzle.cpp \ + ir_validate.cpp \ + ir_variable.cpp \ + ir_vec_index_to_swizzle.cpp \ + linker.cpp \ + s_expression.cpp + +LIBS = \ + $(TOP)/src/glsl/libglsl.a \ + $(shell pkg-config --libs talloc) + +APPS = glsl_compiler +GLSL2_C_SOURCES = \ + ../mesa/shader/hash_table.c \ + ../mesa/shader/symbol_table.c +GLSL2_CXX_SOURCES = \ + main.cpp + +GLSL2_OBJECTS = \ + $(GLSL2_C_SOURCES:.c=.o) \ + $(GLSL2_CXX_SOURCES:.cpp=.o) + +### Basic defines ### + +OBJECTS = \ + $(C_SOURCES:.c=.o) \ + $(CXX_SOURCES:.cpp=.o) + +INCLUDES = \ + -I. \ + -I../mesa \ + -I../mapi \ + -I../mesa/shader \ + $(LIBRARY_INCLUDES) + + +##### TARGETS ##### + +default: depend lib$(LIBNAME).a $(APPS) + +lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/glsl/Makefile.template + $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS) + +depend: $(CXX_SOURCES) $(GLSL2_CXX_SOURCES) $(GLSL2_C_SOURCES) + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $@ 2> /dev/null + +# Remove .o and backup files +clean: + rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak + -rm -f $(APPS) + +# Dummy target +install: + @echo -n "" + + +##### RULES ##### + +glsl_compiler: $(GLSL2_OBJECTS) libglsl.a + $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) $(LIBS) -o $@ + +.cpp.o: + $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@ + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ + +glsl_lexer.cpp: glsl_lexer.lpp + flex --never-interactive --outfile="$@" $< + +glsl_parser.cpp: glsl_parser.ypp + bison -v -o "$@" --defines=glsl_parser.h $< + +glcpp/glcpp-lex.c: glcpp/glcpp-lex.l + flex --never-interactive --outfile="$@" $< + +glcpp/glcpp-parse.c: glcpp/glcpp-parse.y + bison -v -o "$@" --defines=glcpp/glcpp-parse.h $< + +builtin_function.cpp: builtins/*/* + ./builtins/tools/generate_builtins.pl > builtin_function.cpp + +-include depend diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am index c34f7d8abfb..5728a8b63da 100644 --- a/src/glsl/Makefile.am +++ b/src/glsl/Makefile.am @@ -32,7 +32,7 @@ glsl_LDFLAGS = @LDFLAGS@ $(talloc_LIBS) glsl_SOURCES = \ main.cpp \ builtin_types.h \ - symbol_table.c hash_table.c glsl_types.cpp \ + glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \ ir.cpp hir_field_selection.cpp builtin_function.cpp \ @@ -62,11 +62,7 @@ glsl_SOURCES = \ ir_to_mesa.h \ ir_validate.cpp \ ir_vec_index_to_swizzle.cpp \ - linker.cpp \ - mesa/shader/prog_instruction.c \ - mesa/shader/prog_instruction.h \ - mesa/shader/prog_print.c \ - mesa/shader/prog_print.h + linker.cpp BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp CLEANFILES = $(BUILT_SOURCES) diff --git a/src/mesa/Makefile b/src/mesa/Makefile index 4f81768924a..84ced279536 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -35,16 +35,24 @@ MESA_GALLIUM_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS)) MESA_INCLUDES := $(INCLUDE_DIRS) ES1_INCLUDES := -I$(TOP)/src/mapi/es1api $(INCLUDE_DIRS) ES2_INCLUDES := -I$(TOP)/src/mapi/es2api $(INCLUDE_DIRS) - +MESA_INCLUDES := -I$(TOP)/src/glsl $(MESA_INCLUDES) define mesa-cc-c @mkdir -p $(dir $@) $(CC) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_INCLUDES) $(CFLAGS) endef +define mesa-cxx-c + @mkdir -p $(dir $@) + $(CXX) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_INCLUDES) $(CXXFLAGS) +endef + $(MESA_OBJ_DIR)/%.o: %.c $(call mesa-cc-c,MESA) +$(MESA_OBJ_DIR)/%.o: %.cpp + $(call mesa-cxx-c,MESA) + $(MESA_OBJ_DIR)/%.o: %.S $(call mesa-cc-c,MESA) @@ -63,7 +71,7 @@ $(ES2_OBJ_DIR)/%.o: %.S # Default: build dependencies, then asm_subdirs, GLSL built-in lib, # then convenience libs (.a) and finally the device drivers: -default: $(DEPENDS) asm_subdirs glsl_builtin \ +default: $(DEPENDS) asm_subdirs \ $(MESA_LIBS) $(ES1_LIBS) $(ES2_LIBS) driver_subdirs main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py @@ -113,12 +121,6 @@ asm_subdirs: fi -###################################################################### -# GLSL built-in library -glsl_builtin: - (cd shader/slang/library && $(MAKE)) || exit 1 ; - - ###################################################################### # Dependency generation @@ -234,7 +236,6 @@ clean: clean-es1 clean-es2 -rm -f depend depend.bak libmesa.a libmesagallium.a -rm -f drivers/*/*.o -rm -f *.pc - -rm -f shader/slang/library/*_gc.h -@cd drivers/dri && $(MAKE) clean -@cd drivers/x11 && $(MAKE) clean -@cd drivers/osmesa && $(MAKE) clean diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 8cb25439e48..35daacfacdc 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -54,9 +54,9 @@ lib: symlinks subdirs depend $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \ $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o - $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + $(MKLIB) -o $@.tmp -noprefix -linker '$(CXX)' -ldflags '$(LDFLAGS)' \ $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS) - $(CC) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) + $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) @rm -f $@.test mv -f $@.tmp $@ diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 26449c5a5c4..9fc1268e5ab 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -36,6 +36,7 @@ #include "glsl_types.h" extern "C" { +#include "main/mtypes.h" #include "shader/prog_instruction.h" #include "shader/prog_print.h" } diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index c414e89825f..a584f6072c4 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -44,8 +44,6 @@ #include "shader/prog_uniform.h" #include "shader/shader_api.h" #include "shader/uniforms.h" -#include "shader/slang/slang_compile.h" -#include "shader/slang/slang_link.h" /** @@ -1100,7 +1098,7 @@ _mesa_compile_shader(GLcontext *ctx, GLuint shaderObj) /* this call will set the sh->CompileStatus field to indicate if * compilation was successful. */ - (void) _slang_compile(ctx, sh); + _mesa_glsl_compile_shader(ctx, sh); } @@ -1126,7 +1124,7 @@ _mesa_link_program(GLcontext *ctx, GLuint program) FLUSH_VERTICES(ctx, _NEW_PROGRAM); - _slang_link(ctx, program, shProg); + _mesa_glsl_link_shader(ctx, shProg); /* debug code */ if (0) { diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index ddd63cea0b4..117b3f3d2b9 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -250,6 +250,9 @@ SHADER_SOURCES = \ shader/shader_api.c \ shader/uniforms.c +SHADER_CXX_SOURCES = \ + shader/ir_to_mesa.cpp + SLANG_SOURCES = \ shader/slang/slang_builtin.c \ shader/slang/slang_codegen.c \ @@ -324,8 +327,10 @@ MESA_SOURCES = \ $(SWRAST_SOURCES) \ $(SWRAST_SETUP_SOURCES) \ $(COMMON_DRIVER_SOURCES)\ - $(ASM_C_SOURCES) \ - $(SLANG_SOURCES) + $(ASM_C_SOURCES) + +MESA_CXX_SOURCES = \ + $(SHADER_CXX_SOURCES) # Sources for building Gallium drivers MESA_GALLIUM_SOURCES = \ @@ -335,12 +340,15 @@ MESA_GALLIUM_SOURCES = \ $(STATETRACKER_SOURCES) \ $(SHADER_SOURCES) \ ppc/common_ppc.c \ - x86/common_x86.c \ - $(SLANG_SOURCES) + x86/common_x86.c + +MESA_GALLIUM_CXX_SOURCES = \ + $(SHADER_CXX_SOURCES) # All the core C sources, for dependency checking ALL_SOURCES = \ $(MESA_SOURCES) \ + $(MESA_CXX_SOURCES) \ $(MESA_ASM_SOURCES) \ $(STATETRACKER_SOURCES) @@ -349,10 +357,12 @@ ALL_SOURCES = \ MESA_OBJECTS = \ $(MESA_SOURCES:.c=.o) \ + $(MESA_CXX_SOURCES:.cpp=.o) \ $(MESA_ASM_SOURCES:.S=.o) MESA_GALLIUM_OBJECTS = \ $(MESA_GALLIUM_SOURCES:.c=.o) \ + $(MESA_GALLIUM_CXX_SOURCES:.cpp=.o) \ $(MESA_ASM_SOURCES:.S=.o) @@ -362,8 +372,7 @@ COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o) ### Other archives/libraries GLSL_LIBS = \ - $(TOP)/src/glsl/pp/libglslpp.a \ - $(TOP)/src/glsl/cl/libglslcl.a + $(TOP)/src/glsl/libglsl.a ### Include directories -- cgit v1.2.3 From 2a3d46dd46779136e14c3e939a5b761c58576862 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 12:23:20 -0700 Subject: glsl2: Fix dependencies. (at least partially) --- src/glsl/Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 91e4d2e05dd..f4e32b91857 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -77,6 +77,11 @@ INCLUDES = \ -I../mesa/shader \ $(LIBRARY_INCLUDES) +ALL_SOURCES = \ + $(C_SOURCES) \ + $(CXX_SOURCES) \ + $(GLSL2_CXX_SOURCES) \ + $(GLSL2_C_SOURCES) ##### TARGETS ##### @@ -85,10 +90,10 @@ default: depend lib$(LIBNAME).a $(APPS) lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/glsl/Makefile.template $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS) -depend: $(CXX_SOURCES) $(GLSL2_CXX_SOURCES) $(GLSL2_C_SOURCES) +depend: $(ALL_SOURCES) Makefile rm -f depend touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $@ 2> /dev/null + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null # Remove .o and backup files clean: -- cgit v1.2.3 From 7f2bf62d25b2fdc059163ee046cf2fe007e5041e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 12:23:38 -0700 Subject: glsl2: Use Mesa types instead of duping them into our program.h. --- src/glsl/program.h | 80 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 78 deletions(-) diff --git a/src/glsl/program.h b/src/glsl/program.h index d21b04344cd..3c656e9e7c3 100644 --- a/src/glsl/program.h +++ b/src/glsl/program.h @@ -23,6 +23,8 @@ #include #include "main/mtypes.h" +#include "shader/prog_parameter.h" +#include "shader/prog_uniform.h" /** * Based on gl_shader in Mesa's mtypes.h. @@ -41,84 +43,6 @@ struct glsl_shader { struct glsl_symbol_table *symbols; }; - -typedef int gl_state_index; -#define STATE_LENGTH 5 - -/** - * Program parameter. - * Used by shaders/programs for uniforms, constants, varying vars, etc. - */ -struct gl_program_parameter -{ - const char *Name; /**< Null-terminated string */ - gl_register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */ - GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ - /** - * Number of components (1..4), or more. - * If the number of components is greater than 4, - * this parameter is part of a larger uniform like a GLSL matrix or array. - * The next program parameter's Size will be Size-4 of this parameter. - */ - GLuint Size; - GLboolean Used; /**< Helper flag for GLSL uniform tracking */ - GLboolean Initialized; /**< Has the ParameterValue[] been set? */ - GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ - /** - * A sequence of STATE_* tokens and integers to identify GL state. - */ - gl_state_index StateIndexes[STATE_LENGTH]; -}; - - -/** - * List of gl_program_parameter instances. - */ -struct gl_program_parameter_list -{ - GLuint Size; /**< allocated size of Parameters, ParameterValues */ - GLuint NumParameters; /**< number of parameters in arrays */ - struct gl_program_parameter *Parameters; /**< Array [Size] */ - GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */ - GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes - might invalidate ParameterValues[] */ -}; - - -/** - * Shader program uniform variable. - * The glGetUniformLocation() and glUniform() commands will use this - * information. - * Note that a uniform such as "binormal" might be used in both the - * vertex shader and the fragment shader. When glUniform() is called to - * set the uniform's value, it must be updated in both the vertex and - * fragment shaders. The uniform may be in different locations in the - * two shaders so we keep track of that here. - */ -struct gl_uniform -{ - const char *Name; /**< Null-terminated string */ - GLint VertPos; - GLint FragPos; - GLboolean Initialized; /**< For debug. Has this uniform been set? */ -#if 0 - GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ - GLuint Size; /**< Number of components (1..4) */ -#endif -}; - - -/** - * List of gl_uniforms - */ -struct gl_uniform_list -{ - GLuint Size; /**< allocated size of Uniforms array */ - GLuint NumUniforms; /**< number of uniforms in the array */ - struct gl_uniform *Uniforms; /**< Array [Size] */ -}; - - /** * Based on gl_shader_program in Mesa's mtypes.h. */ -- cgit v1.2.3 From 364fcd8ee1af39e215338fba59306a14dd81c2b2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 12:37:21 -0700 Subject: glsl2: Start integrating ir_to_mesa.cpp into shader_api.h The compiler is now called by the driver, and generates program instructions. Parameter lists are still not set up, so the driver chokes on it shortly thereafter. --- src/glsl/program.h | 4 + src/mesa/Makefile | 2 + src/mesa/shader/ir_to_mesa.cpp | 218 +++++++++++++++++++++++++++++++++++++---- src/mesa/shader/shader_api.h | 2 +- 4 files changed, 206 insertions(+), 20 deletions(-) diff --git a/src/glsl/program.h b/src/glsl/program.h index 3c656e9e7c3..fd8197a45a6 100644 --- a/src/glsl/program.h +++ b/src/glsl/program.h @@ -23,8 +23,11 @@ #include #include "main/mtypes.h" + +extern "C" { #include "shader/prog_parameter.h" #include "shader/prog_uniform.h" +} /** * Based on gl_shader in Mesa's mtypes.h. @@ -41,6 +44,7 @@ struct glsl_shader { struct exec_list ir; struct glsl_symbol_table *symbols; + struct gl_shader *mesa_shader; }; /** diff --git a/src/mesa/Makefile b/src/mesa/Makefile index 84ced279536..e2eeb16c9a4 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -36,6 +36,8 @@ MESA_INCLUDES := $(INCLUDE_DIRS) ES1_INCLUDES := -I$(TOP)/src/mapi/es1api $(INCLUDE_DIRS) ES2_INCLUDES := -I$(TOP)/src/mapi/es2api $(INCLUDE_DIRS) MESA_INCLUDES := -I$(TOP)/src/glsl $(MESA_INCLUDES) +# For symbol_table.h in glsl compiler headers. +MESA_INCLUDES := -I$(TOP)/src/mesa/shader $(MESA_INCLUDES) define mesa-cc-c @mkdir -p $(dir $@) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 9fc1268e5ab..02d3f7e2eeb 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -34,11 +34,19 @@ #include "ir_print_visitor.h" #include "ir_expression_flattening.h" #include "glsl_types.h" +#include "glsl_parser_extras.h" +#include "../glsl/program.h" +#include "ir_optimization.h" +#include "ast.h" extern "C" { #include "main/mtypes.h" #include "shader/prog_instruction.h" #include "shader/prog_print.h" +#include "shader/program.h" +#include "shader/prog_uniform.h" +#include "shader/prog_parameter.h" +#include "shader/shader_api.h" } /** @@ -87,6 +95,9 @@ class ir_to_mesa_visitor : public ir_visitor { public: ir_to_mesa_visitor(); + GLcontext *ctx; + struct gl_program *prog; + int next_temp; int next_constant; int next_uniform; @@ -154,8 +165,7 @@ public: ir_to_mesa_dst_reg dst, ir_to_mesa_src_reg src0); - /* talloc context (the ) */ - void *ctx; + void *mem_ctx; }; ir_to_mesa_src_reg ir_to_mesa_undef = { @@ -240,7 +250,7 @@ ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir, ir_to_mesa_src_reg src1, ir_to_mesa_src_reg src2) { - ir_to_mesa_instruction *inst = new(ctx) ir_to_mesa_instruction(); + ir_to_mesa_instruction *inst = new(mem_ctx) ir_to_mesa_instruction(); inst->op = op; inst->dst_reg = dst; @@ -770,8 +780,8 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) if (!entry) { switch (ir->var->mode) { case ir_var_uniform: - entry = new(ctx) temp_entry(ir->var, PROGRAM_UNIFORM, - this->next_uniform); + entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_UNIFORM, + this->next_uniform); this->variable_storage.push_tail(entry); this->next_uniform += type_size(ir->var->type); @@ -795,13 +805,13 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) ir->var->name); abort(); } - entry = new(ctx) temp_entry(ir->var, - builtin_var_to_mesa_reg[i].file, - builtin_var_to_mesa_reg[i].index); + entry = new(mem_ctx) temp_entry(ir->var, + builtin_var_to_mesa_reg[i].file, + builtin_var_to_mesa_reg[i].index); break; case ir_var_auto: - entry = new(ctx) temp_entry(ir->var, PROGRAM_TEMPORARY, - this->next_temp); + entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_TEMPORARY, + this->next_temp); this->variable_storage.push_tail(entry); next_temp += type_size(ir->var->type); @@ -1162,17 +1172,37 @@ print_program(struct prog_instruction *mesa_instructions, } } -void -do_ir_to_mesa(exec_list *instructions) +struct gl_program * +get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader) { ir_to_mesa_visitor v; struct prog_instruction *mesa_instructions, *mesa_inst; ir_instruction **mesa_instruction_annotation; int i; + exec_list *instructions = &shader->ir; + struct gl_program *prog; + GLenum target; + + switch (shader->Type) { + case GL_VERTEX_SHADER: target = GL_VERTEX_PROGRAM_ARB; break; + case GL_FRAGMENT_SHADER: target = GL_FRAGMENT_PROGRAM_ARB; break; + default: assert(!"should not be reached"); break; + } - v.ctx = talloc_new(NULL); + prog = ctx->Driver.NewProgram(ctx, target, 1); + if (!prog) + return NULL; + prog->Parameters = _mesa_new_parameter_list(); + prog->Varying = _mesa_new_parameter_list(); + prog->Attributes = _mesa_new_parameter_list(); + v.ctx = ctx; + v.prog = prog; + + v.mem_ctx = talloc_new(NULL); visit_exec_list(instructions, &v); + prog->NumTemporaries = v.next_temp; + int num_instructions = 0; foreach_iter(exec_list_iterator, iter, v.instructions) { num_instructions++; @@ -1181,9 +1211,8 @@ do_ir_to_mesa(exec_list *instructions) mesa_instructions = (struct prog_instruction *)calloc(num_instructions, sizeof(*mesa_instructions)); - mesa_instruction_annotation = - (ir_instruction **)calloc(num_instructions, - sizeof(*mesa_instruction_annotation)); + mesa_instruction_annotation = talloc_array(mem_ctx, ir_instruction *, + num_instructions); mesa_inst = mesa_instructions; i = 0; @@ -1205,8 +1234,159 @@ do_ir_to_mesa(exec_list *instructions) } set_branchtargets(mesa_instructions, num_instructions); - print_program(mesa_instructions, mesa_instruction_annotation, num_instructions); + if (0) { + print_program(mesa_instructions, mesa_instruction_annotation, + num_instructions); + } + + prog->Instructions = mesa_instructions; + prog->NumInstructions = num_instructions; + + _mesa_reference_program(ctx, &shader->mesa_shader->Program, prog); + + return prog; +} + +/* Takes a Mesa gl shader structure and compiles it, returning our Mesa-like + * structure with the IR and such attached. + */ +static struct glsl_shader * +_mesa_get_glsl_shader(GLcontext *ctx, void *mem_ctx, struct gl_shader *sh) +{ + struct glsl_shader *shader = talloc_zero(mem_ctx, struct glsl_shader); + struct _mesa_glsl_parse_state *state; + + shader->Type = sh->Type; + shader->Name = sh->Name; + shader->RefCount = 1; + shader->Source = sh->Source; + shader->SourceLen = strlen(sh->Source); + shader->mesa_shader = sh; + + state = talloc_zero(shader, struct _mesa_glsl_parse_state); + switch (shader->Type) { + case GL_VERTEX_SHADER: state->target = vertex_shader; break; + case GL_FRAGMENT_SHADER: state->target = fragment_shader; break; + case GL_GEOMETRY_SHADER: state->target = geometry_shader; break; + } + + state->scanner = NULL; + state->translation_unit.make_empty(); + state->symbols = new(mem_ctx) glsl_symbol_table; + state->info_log = talloc_strdup(shader, ""); + state->error = false; + state->temp_index = 0; + state->loop_or_switch_nesting = NULL; + state->ARB_texture_rectangle_enable = true; + + _mesa_glsl_lexer_ctor(state, shader->Source); + _mesa_glsl_parse(state); + _mesa_glsl_lexer_dtor(state); + + shader->ir.make_empty(); + if (!state->error && !state->translation_unit.is_empty()) + _mesa_ast_to_hir(&shader->ir, state); + + /* Optimization passes */ + if (!state->error && !shader->ir.is_empty()) { + bool progress; + do { + progress = false; + + progress = do_function_inlining(&shader->ir) || progress; + progress = do_if_simplification(&shader->ir) || progress; + progress = do_copy_propagation(&shader->ir) || progress; + progress = do_dead_code_local(&shader->ir) || progress; + progress = do_dead_code_unlinked(&shader->ir) || progress; + progress = do_constant_variable_unlinked(&shader->ir) || progress; + progress = do_constant_folding(&shader->ir) || progress; + progress = do_vec_index_to_swizzle(&shader->ir) || progress; + progress = do_swizzle_swizzle(&shader->ir) || progress; + } while (progress); + } + + shader->symbols = state->symbols; + + shader->CompileStatus = !state->error; + shader->InfoLog = state->info_log; - free(mesa_instruction_annotation); - talloc_free(v.ctx); + talloc_free(state); + + return shader; } + +extern "C" { + +void +_mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *sh) +{ + struct glsl_shader *shader; + TALLOC_CTX *mem_ctx = talloc_new(NULL); + + shader = _mesa_get_glsl_shader(ctx, mem_ctx, sh); + + sh->CompileStatus = shader->CompileStatus; + sh->InfoLog = strdup(shader->InfoLog); + talloc_free(mem_ctx); + } + +void +_mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) +{ + struct glsl_program *whole_program; + unsigned int i; + + _mesa_clear_shader_program_data(ctx, prog); + + whole_program = talloc_zero(NULL, struct glsl_program); + whole_program->LinkStatus = GL_TRUE; + whole_program->NumShaders = prog->NumShaders; + whole_program->Shaders = talloc_array(whole_program, struct glsl_shader *, + prog->NumShaders); + + for (i = 0; i < prog->NumShaders; i++) { + whole_program->Shaders[i] = _mesa_get_glsl_shader(ctx, whole_program, + prog->Shaders[i]); + if (!whole_program->Shaders[i]->CompileStatus) { + whole_program->InfoLog = + talloc_asprintf_append(whole_program->InfoLog, + "linking with uncompiled shader"); + whole_program->LinkStatus = GL_FALSE; + } + } + + prog->Uniforms = _mesa_new_uniform_list(); + prog->Varying = _mesa_new_parameter_list(); + _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL); + _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL); + + if (whole_program->LinkStatus) + link_shaders(whole_program); + + prog->LinkStatus = whole_program->LinkStatus; + + /* FINISHME: This should use the linker-generated code */ + if (prog->LinkStatus) { + for (i = 0; i < prog->NumShaders; i++) { + struct gl_program *linked_prog; + + linked_prog = get_mesa_program(ctx, whole_program, + whole_program->Shaders[i]); + + switch (whole_program->Shaders[i]->Type) { + case GL_VERTEX_SHADER: + _mesa_reference_vertprog(ctx, &prog->VertexProgram, + (struct gl_vertex_program *)linked_prog); + break; + case GL_FRAGMENT_SHADER: + _mesa_reference_fragprog(ctx, &prog->FragmentProgram, + (struct gl_fragment_program *)linked_prog); + break; + } + } + } + + talloc_free(whole_program); +} + +} /* extern "C" */ diff --git a/src/mesa/shader/shader_api.h b/src/mesa/shader/shader_api.h index 9743a23ce63..557e910595a 100644 --- a/src/mesa/shader/shader_api.h +++ b/src/mesa/shader/shader_api.h @@ -30,7 +30,7 @@ #include "main/glheader.h" #include "main/mtypes.h" - +#include "ir_to_mesa.h" /** * Internal functions -- cgit v1.2.3 From ffc845a50a69b48446f5e25e7b4485089231bbe7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 12:52:01 -0700 Subject: glsl2: Set InputsRead and OutputsWritten on the generated programs. --- src/mesa/shader/ir_to_mesa.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 02d3f7e2eeb..465d5529f82 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1172,6 +1172,43 @@ print_program(struct prog_instruction *mesa_instructions, } } +static void +count_resources(struct gl_program *prog) +{ + prog->InputsRead = 0; + prog->OutputsWritten = 0; + unsigned int i; + + for (i = 0; i < prog->NumInstructions; i++) { + struct prog_instruction *inst = &prog->Instructions[i]; + unsigned int reg; + + switch (inst->DstReg.File) { + case PROGRAM_OUTPUT: + prog->OutputsWritten |= BITFIELD64_BIT(inst->DstReg.Index); + break; + case PROGRAM_INPUT: + prog->InputsRead |= BITFIELD64_BIT(inst->DstReg.Index); + break; + default: + break; + } + + for (reg = 0; reg < _mesa_num_inst_src_regs(inst->Opcode); reg++) { + switch (inst->SrcReg[reg].File) { + case PROGRAM_OUTPUT: + prog->OutputsWritten |= BITFIELD64_BIT(inst->DstReg.Index); + break; + case PROGRAM_INPUT: + prog->InputsRead |= BITFIELD64_BIT(inst->DstReg.Index); + break; + default: + break; + } + } + } +} + struct gl_program * get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader) { @@ -1372,6 +1409,7 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) linked_prog = get_mesa_program(ctx, whole_program, whole_program->Shaders[i]); + count_resources(linked_prog); switch (whole_program->Shaders[i]->Type) { case GL_VERTEX_SHADER: -- cgit v1.2.3 From 582b73fe691ef7ea12a002cb2ae57505c3b1c21e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 12:59:10 -0700 Subject: glsl2: Hook up constant parameters in ir_to_mesa. --- src/mesa/shader/ir_to_mesa.cpp | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 465d5529f82..accd151576d 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -56,7 +56,7 @@ extern "C" { typedef struct ir_to_mesa_src_reg { int file; /**< PROGRAM_* from Mesa */ int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ - int swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ + GLuint swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ int negate; /**< NEGATE_XYZW mask from mesa */ bool reladdr; /**< Register index should be offset by address reg. */ } ir_to_mesa_src_reg; @@ -319,14 +319,14 @@ ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, * dst channels. */ for (i = 0; i < 4; i++) { - int this_mask = (1 << i); + GLuint this_mask = (1 << i); ir_to_mesa_instruction *inst; ir_to_mesa_src_reg src = src0; if (done_mask & this_mask) continue; - int src_swiz = GET_SWZ(src.swizzle, i); + GLuint src_swiz = GET_SWZ(src.swizzle, i); for (j = i + 1; j < 4; j++) { if (!(done_mask & (1 << j)) && GET_SWZ(src.swizzle, j) == src_swiz) { this_mask |= (1 << j); @@ -348,15 +348,9 @@ ir_to_mesa_visitor::src_reg_for_float(float val) { ir_to_mesa_src_reg src_reg; - /* FINISHME: This will end up being _mesa_add_unnamed_constant, - * which handles sharing values and sharing channels of vec4 - * constants for small values. - */ - /* FINISHME: Do something with the constant values for now. - */ - (void)val; src_reg.file = PROGRAM_CONSTANT; - src_reg.index = this->next_constant++; + src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, + &val, 1, &src_reg.swizzle); src_reg.swizzle = SWIZZLE_NOOP; return src_reg; @@ -985,15 +979,17 @@ ir_to_mesa_visitor::visit(ir_constant *ir) ir->type->base_type == GLSL_TYPE_INT || ir->type->base_type == GLSL_TYPE_BOOL); - /* FINISHME: This will end up being _mesa_add_unnamed_constant, - * which handles sharing values and sharing channels of vec4 - * constants for small values. - */ - /* FINISHME: Do something with the constant values for now. - */ - src_reg.file = PROGRAM_CONSTANT; - src_reg.index = this->next_constant; - src_reg.swizzle = SWIZZLE_NOOP; + if (ir->type->base_type == GLSL_TYPE_FLOAT && + !ir->type->is_matrix() && !ir->type->is_array()) { + src_reg.file = PROGRAM_CONSTANT; + src_reg.index = + _mesa_add_unnamed_constant(this->prog->Parameters, + &ir->value.f[0], ir->type->vector_elements, + &src_reg.swizzle); + src_reg.swizzle = SWIZZLE_NOOP; + } else { + assert(!"FINISHME: non-float constants"); + } src_reg.reladdr = false; src_reg.negate = 0; -- cgit v1.2.3 From abc4e52992c53ee6b6895480b47e6a6e27ef9bd0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 13:00:38 -0700 Subject: glsl2: Emit OPCODE_END at the end of the Mesa program. The 965 driver can now run a glsl2-generated shader! --- src/mesa/shader/ir_to_mesa.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index accd151576d..f58af0f65f5 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1233,6 +1233,8 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader) v.mem_ctx = talloc_new(NULL); visit_exec_list(instructions, &v); + v.ir_to_mesa_emit_op1(NULL, OPCODE_END, + ir_to_mesa_undef_dst, ir_to_mesa_undef); prog->NumTemporaries = v.next_temp; -- cgit v1.2.3 From bda27424cf04c0d2ec2b49c56f562d5b2d2f0bff Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 13:38:38 -0700 Subject: glsl2: Use the parser state as the talloc context for dead code elimination. This cuts runtime by around 20% from talloc_parent() lookups. --- src/glsl/ir_dead_code.cpp | 15 +++++++++------ src/glsl/ir_optimization.h | 6 ++++-- src/glsl/main.cpp | 2 +- src/mesa/shader/ir_to_mesa.cpp | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp index 88213046825..51fa96df0cc 100644 --- a/src/glsl/ir_dead_code.cpp +++ b/src/glsl/ir_dead_code.cpp @@ -71,6 +71,8 @@ public: /* List of variable_entry */ exec_list variable_list; + + void *mem_ctx; }; @@ -84,9 +86,7 @@ ir_dead_code_visitor::get_variable_entry(ir_variable *var) return entry; } - void *ctx = talloc_parent(var); - - variable_entry *entry = new(ctx) variable_entry(var); + variable_entry *entry = new(mem_ctx) variable_entry(var); this->variable_list.push_tail(entry); return entry; } @@ -147,11 +147,13 @@ ir_dead_code_visitor::visit_leave(ir_assignment *ir) * for usage on an unlinked instruction stream. */ bool -do_dead_code(exec_list *instructions) +do_dead_code(struct _mesa_glsl_parse_state *state, + exec_list *instructions) { ir_dead_code_visitor v; bool progress = false; + v.mem_ctx = state; v.run(instructions); foreach_iter(exec_list_iterator, iter, v.variable_list) { @@ -198,7 +200,8 @@ do_dead_code(exec_list *instructions) * with global scope. */ bool -do_dead_code_unlinked(exec_list *instructions) +do_dead_code_unlinked(struct _mesa_glsl_parse_state *state, + exec_list *instructions) { bool progress = false; @@ -209,7 +212,7 @@ do_dead_code_unlinked(exec_list *instructions) foreach_iter(exec_list_iterator, sigiter, *f) { ir_function_signature *sig = (ir_function_signature *) sigiter.get(); - if (do_dead_code(&sig->body)) + if (do_dead_code(state, &sig->body)) progress = true; } } diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 432a33458c2..147f92176bf 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -32,9 +32,11 @@ bool do_constant_folding(exec_list *instructions); bool do_constant_variable(exec_list *instructions); bool do_constant_variable_unlinked(exec_list *instructions); bool do_copy_propagation(exec_list *instructions); -bool do_dead_code(exec_list *instructions); +bool do_dead_code(struct _mesa_glsl_parse_state *state, + exec_list *instructions); bool do_dead_code_local(exec_list *instructions); -bool do_dead_code_unlinked(exec_list *instructions); +bool do_dead_code_unlinked(struct _mesa_glsl_parse_state *state, + exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_if_simplification(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index dcd9bd69c0c..b32e2ad3dbc 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -157,7 +157,7 @@ compile_shader(struct glsl_shader *shader) progress = do_if_simplification(&shader->ir) || progress; progress = do_copy_propagation(&shader->ir) || progress; progress = do_dead_code_local(&shader->ir) || progress; - progress = do_dead_code_unlinked(&shader->ir) || progress; + progress = do_dead_code_unlinked(state, &shader->ir) || progress; progress = do_constant_variable_unlinked(&shader->ir) || progress; progress = do_constant_folding(&shader->ir) || progress; progress = do_vec_index_to_swizzle(&shader->ir) || progress; diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index f58af0f65f5..0425e7d91ea 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1332,7 +1332,7 @@ _mesa_get_glsl_shader(GLcontext *ctx, void *mem_ctx, struct gl_shader *sh) progress = do_if_simplification(&shader->ir) || progress; progress = do_copy_propagation(&shader->ir) || progress; progress = do_dead_code_local(&shader->ir) || progress; - progress = do_dead_code_unlinked(&shader->ir) || progress; + progress = do_dead_code_unlinked(state, &shader->ir) || progress; progress = do_constant_variable_unlinked(&shader->ir) || progress; progress = do_constant_folding(&shader->ir) || progress; progress = do_vec_index_to_swizzle(&shader->ir) || progress; -- cgit v1.2.3 From 0fd97db8b077ad1bd5d26e86e67ebb2d58b6a38a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 14:27:07 -0700 Subject: glsl2: Associate the GLenum for the type with builtin GLSL types. --- src/glsl/builtin_types.h | 150 ++++++++++++++++++++++++++++------------------- src/glsl/glsl_types.h | 10 +++- 2 files changed, 99 insertions(+), 61 deletions(-) diff --git a/src/glsl/builtin_types.h b/src/glsl/builtin_types.h index 48202f56454..526421a0174 100644 --- a/src/glsl/builtin_types.h +++ b/src/glsl/builtin_types.h @@ -26,10 +26,10 @@ #endif static const struct glsl_type _error_type = - glsl_type(GLSL_TYPE_ERROR, 0, 0, ""); + glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, ""); static const struct glsl_type void_type = - glsl_type(GLSL_TYPE_VOID, 0, 0, "void"); + glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void"); const glsl_type *const glsl_type::error_type = & _error_type; @@ -40,27 +40,33 @@ const glsl_type *const glsl_type::error_type = & _error_type; /*@{*/ static const struct glsl_type builtin_core_types[] = { - glsl_type( GLSL_TYPE_BOOL, 1, 1, "bool"), - glsl_type( GLSL_TYPE_BOOL, 2, 1, "bvec2"), - glsl_type( GLSL_TYPE_BOOL, 3, 1, "bvec3"), - glsl_type( GLSL_TYPE_BOOL, 4, 1, "bvec4"), - glsl_type( GLSL_TYPE_INT, 1, 1, "int"), - glsl_type( GLSL_TYPE_INT, 2, 1, "ivec2"), - glsl_type( GLSL_TYPE_INT, 3, 1, "ivec3"), - glsl_type( GLSL_TYPE_INT, 4, 1, "ivec4"), - glsl_type( GLSL_TYPE_FLOAT, 1, 1, "float"), - glsl_type( GLSL_TYPE_FLOAT, 2, 1, "vec2"), - glsl_type( GLSL_TYPE_FLOAT, 3, 1, "vec3"), - glsl_type( GLSL_TYPE_FLOAT, 4, 1, "vec4"), - glsl_type( GLSL_TYPE_FLOAT, 2, 2, "mat2"), - glsl_type( GLSL_TYPE_FLOAT, 3, 3, "mat3"), - glsl_type( GLSL_TYPE_FLOAT, 4, 4, "mat4"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT, "sampler1D"), - glsl_type( GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT, "sampler1DShadow"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT, "sampler2D"), - glsl_type( GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT, "sampler2DShadow"), - glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT, "sampler3D"), - glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT, "samplerCube"), + glsl_type(GL_BOOL, GLSL_TYPE_BOOL, 1, 1, "bool"), + glsl_type(GL_BOOL_VEC2, GLSL_TYPE_BOOL, 2, 1, "bvec2"), + glsl_type(GL_BOOL_VEC3, GLSL_TYPE_BOOL, 3, 1, "bvec3"), + glsl_type(GL_BOOL_VEC4, GLSL_TYPE_BOOL, 4, 1, "bvec4"), + glsl_type(GL_INT, GLSL_TYPE_INT, 1, 1, "int"), + glsl_type(GL_INT_VEC2, GLSL_TYPE_INT, 2, 1, "ivec2"), + glsl_type(GL_INT_VEC3, GLSL_TYPE_INT, 3, 1, "ivec3"), + glsl_type(GL_INT_VEC4, GLSL_TYPE_INT, 4, 1, "ivec4"), + glsl_type(GL_FLOAT, GLSL_TYPE_FLOAT, 1, 1, "float"), + glsl_type(GL_FLOAT_VEC2, GLSL_TYPE_FLOAT, 2, 1, "vec2"), + glsl_type(GL_FLOAT_VEC3, GLSL_TYPE_FLOAT, 3, 1, "vec3"), + glsl_type(GL_FLOAT_VEC4, GLSL_TYPE_FLOAT, 4, 1, "vec4"), + glsl_type(GL_FLOAT_MAT2, GLSL_TYPE_FLOAT, 2, 2, "mat2"), + glsl_type(GL_FLOAT_MAT3, GLSL_TYPE_FLOAT, 3, 3, "mat3"), + glsl_type(GL_FLOAT_MAT4, GLSL_TYPE_FLOAT, 4, 4, "mat4"), + glsl_type(GL_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT, + "sampler1D"), + glsl_type(GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT, + "sampler1DShadow"), + glsl_type(GL_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT, + "sampler2D"), + glsl_type(GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT, + "sampler2DShadow"), + glsl_type(GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT, + "sampler3D"), + glsl_type(GL_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT, + "samplerCube"), }; const glsl_type *const glsl_type::bool_type = & builtin_core_types[0]; @@ -181,12 +187,12 @@ static const struct glsl_type builtin_110_deprecated_structure_types[] = { /*@{*/ static const struct glsl_type builtin_120_types[] = { - glsl_type( GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), - glsl_type( GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), - glsl_type( GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), - glsl_type( GLSL_TYPE_FLOAT, 4, 3, "mat3x4"), - glsl_type( GLSL_TYPE_FLOAT, 2, 4, "mat4x2"), - glsl_type( GLSL_TYPE_FLOAT, 3, 4, "mat4x3"), + glsl_type(GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), + glsl_type(GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), + glsl_type(GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), + glsl_type(GL_FLOAT_MAT3x4, GLSL_TYPE_FLOAT, 4, 3, "mat3x4"), + glsl_type(GL_FLOAT_MAT4x2, GLSL_TYPE_FLOAT, 2, 4, "mat4x2"), + glsl_type(GL_FLOAT_MAT4x3, GLSL_TYPE_FLOAT, 3, 4, "mat4x3"), }; const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0]; const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1]; @@ -201,33 +207,50 @@ const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5]; /*@{*/ static const struct glsl_type builtin_130_types[] = { - glsl_type( GLSL_TYPE_UINT, 1, 1, "uint"), - glsl_type( GLSL_TYPE_UINT, 2, 1, "uvec2"), - glsl_type( GLSL_TYPE_UINT, 3, 1, "uvec3"), - glsl_type( GLSL_TYPE_UINT, 4, 1, "uvec4"), + glsl_type(GL_UNSIGNED_INT, GLSL_TYPE_UINT, 1, 1, "uint"), + glsl_type(GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1, "uvec2"), + glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"), + glsl_type(GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1, "uvec4"), /* 1D and 2D texture arrays */ - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), + glsl_type(GL_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), + glsl_type(GL_INT_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"), + glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW, + GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), + glsl_type(GL_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), + glsl_type(GL_INT_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"), + glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW, + GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), /* cube shadow samplers */ - glsl_type(GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"), + glsl_type(GL_SAMPLER_CUBE_SHADOW, + GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"), /* signed and unsigned integer samplers */ - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"), - glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"), - glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"), - glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"), - glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"), + glsl_type(GL_INT_SAMPLER_1D, + GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_1D, + GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"), + glsl_type(GL_INT_SAMPLER_2D, + GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_2D, + GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"), + glsl_type(GL_INT_SAMPLER_3D, + GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_3D, + GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"), + glsl_type(GL_INT_SAMPLER_CUBE, + GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"), + glsl_type(GL_INT_SAMPLER_CUBE, + GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"), }; const glsl_type *const glsl_type::uint_type = & builtin_130_types[0]; @@ -239,8 +262,10 @@ const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3]; /*@{*/ static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { - glsl_type(GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"), - glsl_type(GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"), + glsl_type(GL_SAMPLER_2D_RECT, + GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"), + glsl_type(GL_SAMPLER_2D_RECT_SHADOW, + GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"), }; /*@}*/ @@ -249,10 +274,14 @@ static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { /*@{*/ static const struct glsl_type builtin_EXT_texture_array_types[] = { - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), - glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), + glsl_type(GL_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), + glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), + glsl_type(GL_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), + glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW, + GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), }; /*@}*/ @@ -261,8 +290,11 @@ static const struct glsl_type builtin_EXT_texture_array_types[] = { /*@{*/ static const struct glsl_type builtin_EXT_texture_buffer_object_types[] = { - glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"), - glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"), - glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"), + glsl_type(GL_SAMPLER_BUFFER, + GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"), + glsl_type(GL_INT_SAMPLER_BUFFER, + GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_BUFFER, + GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"), }; /*@}*/ diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 39e6ac970aa..93cf60be8dc 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -30,6 +30,7 @@ #include extern "C" { +#include "GL/gl.h" #include } @@ -55,6 +56,7 @@ enum glsl_sampler_dim { struct glsl_type { + GLenum gl_type; unsigned base_type:4; unsigned sampler_dimensionality:3; @@ -151,8 +153,10 @@ struct glsl_type { /*@}*/ - glsl_type(unsigned base_type, unsigned vector_elements, + glsl_type(GLenum gl_type, + unsigned base_type, unsigned vector_elements, unsigned matrix_columns, const char *name) : + gl_type(gl_type), base_type(base_type), sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), sampler_type(0), @@ -166,8 +170,10 @@ struct glsl_type { memset(& fields, 0, sizeof(fields)); } - glsl_type(enum glsl_sampler_dim dim, bool shadow, bool array, + glsl_type(GLenum gl_type, + enum glsl_sampler_dim dim, bool shadow, bool array, unsigned type, const char *name) : + gl_type(gl_type), base_type(GLSL_TYPE_SAMPLER), sampler_dimensionality(dim), sampler_shadow(shadow), sampler_array(array), sampler_type(type), -- cgit v1.2.3 From 85c978f38c819003b6447e8e4feb8b90bb352eea Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 14:35:48 -0700 Subject: glsl2: Start trying to hook up uniforms. This should be resolved with linker.cpp's location assignment, as currently we drop that location assignment on the ground. However, this gets basic programs using uniforms working for now. --- src/mesa/shader/ir_to_mesa.cpp | 52 +++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 0425e7d91ea..a46286e82b4 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -99,8 +99,6 @@ public: struct gl_program *prog; int next_temp; - int next_constant; - int next_uniform; temp_entry *find_variable_storage(ir_variable *var); @@ -768,17 +766,27 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) { ir_to_mesa_src_reg src_reg; temp_entry *entry = find_variable_storage(ir->var); - unsigned int i; + unsigned int i, loc; bool var_in; if (!entry) { switch (ir->var->mode) { case ir_var_uniform: - entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_UNIFORM, - this->next_uniform); - this->variable_storage.push_tail(entry); + /* FINISHME: Fix up uniform name for arrays and things */ + assert(ir->var->type->gl_type != 0 && + ir->var->type->gl_type != GL_INVALID_ENUM); + loc = _mesa_add_uniform(this->prog->Parameters, + ir->var->name, + type_size(ir->var->type) * 4, + ir->var->type->gl_type, + NULL); + /* Always mark the uniform used at this point. If it isn't + * used, dead code elimination should have nuked the decl already. + */ + this->prog->Parameters->Parameters[loc].Used = GL_TRUE; - this->next_uniform += type_size(ir->var->type); + entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_UNIFORM, loc); + this->variable_storage.push_tail(entry); break; case ir_var_in: case ir_var_out: @@ -993,8 +1001,6 @@ ir_to_mesa_visitor::visit(ir_constant *ir) src_reg.reladdr = false; src_reg.negate = 0; - this->next_constant += type_size(ir->type); - this->result = src_reg; } @@ -1055,8 +1061,6 @@ ir_to_mesa_visitor::ir_to_mesa_visitor() { result.file = PROGRAM_UNDEFINED; next_temp = 1; - next_constant = 0; - next_uniform = 0; } static struct prog_src_register @@ -1205,6 +1209,29 @@ count_resources(struct gl_program *prog) } } +/* Each stage has some uniforms in its Parameters list. The Uniforms + * list for the linked shader program has a pointer to these uniforms + * in each of the stage's Parameters list, so that their values can be + * updated when a uniform is set. + */ +static void +link_uniforms_to_shared_uniform_list(struct gl_uniform_list *uniforms, + struct gl_program *prog) +{ + unsigned int i; + + for (i = 0; i < prog->Parameters->NumParameters; i++) { + const struct gl_program_parameter *p = prog->Parameters->Parameters + i; + + if (p->Type == PROGRAM_UNIFORM || p->Type == PROGRAM_SAMPLER) { + struct gl_uniform *uniform = + _mesa_append_uniform(uniforms, p->Name, prog->Target, i); + if (uniform) + uniform->Initialized = p->Initialized; + } + } +} + struct gl_program * get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader) { @@ -1409,6 +1436,8 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) whole_program->Shaders[i]); count_resources(linked_prog); + link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog); + switch (whole_program->Shaders[i]->Type) { case GL_VERTEX_SHADER: _mesa_reference_vertprog(ctx, &prog->VertexProgram, @@ -1421,6 +1450,7 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) } } } + ctx->Shader.Flags |= GLSL_UNIFORMS; talloc_free(whole_program); } -- cgit v1.2.3 From 78062273de65bf8133f2550aa2a26040a82a65aa Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 25 Jun 2010 13:10:37 -0700 Subject: ir_reader: Free memory for S-Expressions earlier. There's no point in keeping it around once we've read the IR. Also, remove an unnecessary talloc_parent call. --- src/glsl/ir_reader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 7383c42cbc7..03dce0d6849 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -70,8 +70,7 @@ void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, const char *src) { - void *ctx = talloc_parent(state); - s_expression *expr = s_expression::read_expression(ctx, src); + s_expression *expr = s_expression::read_expression(state, src); if (expr == NULL) { ir_read_error(state, NULL, "couldn't parse S-Expression."); return; @@ -82,6 +81,7 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, return; read_instructions(state, instructions, expr, NULL); + talloc_free(expr); } static void -- cgit v1.2.3 From b2d7ed2aba916a995af9037c955930524977d310 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 17:20:46 -0700 Subject: glsl2: Don't clear swizzles for Mesa IR constants after fetching them. Missed this while hacking in constants support. Fixes: glsl-algebraic-mul-* glsl-algebraic-rcp-* glsl-vs-swizzle-swizzle-lhs glsl-vs-vec4-indexing-6 --- src/mesa/shader/ir_to_mesa.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index a46286e82b4..456f69cd36f 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -349,7 +349,6 @@ ir_to_mesa_visitor::src_reg_for_float(float val) src_reg.file = PROGRAM_CONSTANT; src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, &val, 1, &src_reg.swizzle); - src_reg.swizzle = SWIZZLE_NOOP; return src_reg; } @@ -994,7 +993,6 @@ ir_to_mesa_visitor::visit(ir_constant *ir) _mesa_add_unnamed_constant(this->prog->Parameters, &ir->value.f[0], ir->type->vector_elements, &src_reg.swizzle); - src_reg.swizzle = SWIZZLE_NOOP; } else { assert(!"FINISHME: non-float constants"); } -- cgit v1.2.3 From 6152fa16a16c876497ab1791212dc79b15e91c1a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 17:23:31 -0700 Subject: glsl2: Take out the spamming of debug flags I'd added. --- src/mesa/shader/ir_to_mesa.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 456f69cd36f..f28f5fcbfcb 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1448,7 +1448,6 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) } } } - ctx->Shader.Flags |= GLSL_UNIFORMS; talloc_free(whole_program); } -- cgit v1.2.3 From 0bef5b97a9eccebc4b59dff42b2863770da770fe Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 17:50:25 -0700 Subject: glsl2: Add support for non-float constants in Mesa IR. Fixes glsl-vs-vec4-indexing-4. --- src/mesa/shader/ir_to_mesa.cpp | 47 +++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index f28f5fcbfcb..99ec55a0d85 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -980,22 +980,41 @@ void ir_to_mesa_visitor::visit(ir_constant *ir) { ir_to_mesa_src_reg src_reg; + GLfloat stack_vals[4]; + GLfloat *values = stack_vals; + unsigned int i; - assert(ir->type->base_type == GLSL_TYPE_FLOAT || - ir->type->base_type == GLSL_TYPE_UINT || - ir->type->base_type == GLSL_TYPE_INT || - ir->type->base_type == GLSL_TYPE_BOOL); - - if (ir->type->base_type == GLSL_TYPE_FLOAT && - !ir->type->is_matrix() && !ir->type->is_array()) { - src_reg.file = PROGRAM_CONSTANT; - src_reg.index = - _mesa_add_unnamed_constant(this->prog->Parameters, - &ir->value.f[0], ir->type->vector_elements, - &src_reg.swizzle); - } else { - assert(!"FINISHME: non-float constants"); + if (ir->type->is_matrix() || ir->type->is_array()) { + assert(!"FINISHME: array/matrix constants"); } + + src_reg.file = PROGRAM_CONSTANT; + switch (ir->type->base_type) { + case GLSL_TYPE_FLOAT: + values = &ir->value.f[0]; + break; + case GLSL_TYPE_UINT: + for (i = 0; i < ir->type->vector_elements; i++) { + values[i] = ir->value.u[i]; + } + break; + case GLSL_TYPE_INT: + for (i = 0; i < ir->type->vector_elements; i++) { + values[i] = ir->value.i[i]; + } + break; + case GLSL_TYPE_BOOL: + for (i = 0; i < ir->type->vector_elements; i++) { + values[i] = ir->value.b[i]; + } + break; + default: + assert(!"Non-float/uint/int/bool constant"); + } + + src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, + values, ir->type->vector_elements, + &src_reg.swizzle); src_reg.reladdr = false; src_reg.negate = 0; -- cgit v1.2.3 From 26b5d33dce37755a6a4a799a9edfcdff8c5ce3e5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 25 Jun 2010 16:19:45 -0700 Subject: glsl2: Use i2b and f2b IR opcodes for casting int or float to bool --- src/glsl/ast_function.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 761af00b95e..f431d1d0156 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -172,17 +172,17 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) break; } break; - case GLSL_TYPE_BOOL: { - ir_constant *zero = NULL; - + case GLSL_TYPE_BOOL: switch (b) { - case GLSL_TYPE_UINT: zero = new(ctx) ir_constant(unsigned(0)); break; - case GLSL_TYPE_INT: zero = new(ctx) ir_constant(int(0)); break; - case GLSL_TYPE_FLOAT: zero = new(ctx) ir_constant(0.0f); break; + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + result = new(ctx) ir_expression(ir_unop_i2b, desired_type, src, NULL); + break; + case GLSL_TYPE_FLOAT: + result = new(ctx) ir_expression(ir_unop_f2b, desired_type, src, NULL); + break; } - - result = new(ctx) ir_expression(ir_binop_nequal, desired_type, src, zero); - } + break; } assert(result != NULL); -- cgit v1.2.3 From 22c23dedad4e7f362ffbd990f1c2d5caf4cae75a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 25 Jun 2010 15:27:47 -0700 Subject: glsl2: Add option to stand-alone GLSL compiler to dump IR before optimizations --- src/glsl/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index b32e2ad3dbc..16b2cf84c53 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -89,11 +89,13 @@ usage_fail(const char *name) int dump_ast = 0; +int dump_hir = 0; int dump_lir = 0; int do_link = 0; const struct option compiler_opts[] = { { "dump-ast", 0, &dump_ast, 1 }, + { "dump-hir", 0, &dump_hir, 1 }, { "dump-lir", 0, &dump_lir, 1 }, { "link", 0, &do_link, 1 }, { NULL, 0, NULL, 0 } @@ -147,6 +149,11 @@ compile_shader(struct glsl_shader *shader) validate_ir_tree(&shader->ir); + /* Print out the unoptimized IR. */ + if (!state->error && dump_hir) { + _mesa_print_ir(&shader->ir, state); + } + /* Optimization passes */ if (!state->error && !shader->ir.is_empty()) { bool progress; -- cgit v1.2.3 From a815f7fb83b1117e957c097044f36eae3a6851fb Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 25 Jun 2010 13:36:14 -0700 Subject: Use more sensible contexts in ir_dead_code_local. --- src/glsl/ir_dead_code_local.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_dead_code_local.cpp b/src/glsl/ir_dead_code_local.cpp index e01877077c9..5e197e19484 100644 --- a/src/glsl/ir_dead_code_local.cpp +++ b/src/glsl/ir_dead_code_local.cpp @@ -111,9 +111,8 @@ public: * of a variable to a variable. */ static bool -process_assignment(ir_assignment *ir, exec_list *assignments) +process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments) { - void *ctx = talloc_parent(ir); ir_variable *var = NULL; bool progress = false; kill_for_derefs_visitor v(assignments); @@ -186,6 +185,7 @@ dead_code_local_basic_block(ir_instruction *first, bool *out_progress = (bool *)data; bool progress = false; + void *ctx = talloc(NULL, void*); /* Safe looping, since process_assignment */ for (ir = first, ir_next = (ir_instruction *)first->next;; ir = ir_next, ir_next = (ir_instruction *)ir->next) { @@ -197,7 +197,7 @@ dead_code_local_basic_block(ir_instruction *first, } if (ir_assign) { - progress = process_assignment(ir_assign, &assignments) || progress; + progress = process_assignment(ctx, ir_assign, &assignments) || progress; } else { kill_for_derefs_visitor kill(&assignments); ir->accept(&kill); @@ -207,6 +207,7 @@ dead_code_local_basic_block(ir_instruction *first, break; } *out_progress = progress; + talloc_free(ctx); } /** -- cgit v1.2.3 From 5f3fe44595e53874908d1f047405d27861f1df0f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 25 Jun 2010 13:44:09 -0700 Subject: Use a more sensible context in copy propagation. --- src/glsl/ir_copy_propagation.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_copy_propagation.cpp b/src/glsl/ir_copy_propagation.cpp index 46ef6679d9f..a02852ed0cc 100644 --- a/src/glsl/ir_copy_propagation.cpp +++ b/src/glsl/ir_copy_propagation.cpp @@ -195,9 +195,8 @@ kill_invalidated_copies(ir_assignment *ir, exec_list *acp) * of a variable to a variable. */ static void -add_copy(ir_assignment *ir, exec_list *acp) +add_copy(void *ctx, ir_assignment *ir, exec_list *acp) { - void *ctx = talloc_parent(ir); acp_entry *entry; if (ir->condition) { @@ -226,6 +225,7 @@ copy_propagation_basic_block(ir_instruction *first, bool *out_progress = (bool *)data; bool progress = false; + void *ctx = talloc(NULL, void*); for (ir = first;; ir = (ir_instruction *)ir->next) { ir_assignment *ir_assign = ir->as_assignment(); @@ -234,12 +234,13 @@ copy_propagation_basic_block(ir_instruction *first, if (ir_assign) { kill_invalidated_copies(ir_assign, &acp); - add_copy(ir_assign, &acp); + add_copy(ctx, ir_assign, &acp); } if (ir == last) break; } *out_progress = progress; + talloc_free(ctx); } /** -- cgit v1.2.3 From 81b7b79c472cbc15cb044656bd37b101a941f358 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 27 Jun 2010 20:43:09 -0700 Subject: ir_to_mesa: Fix copy and wasted InputsRead/OutputsWritten setup. --- src/mesa/shader/ir_to_mesa.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 99ec55a0d85..af5237f697c 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1214,10 +1214,10 @@ count_resources(struct gl_program *prog) for (reg = 0; reg < _mesa_num_inst_src_regs(inst->Opcode); reg++) { switch (inst->SrcReg[reg].File) { case PROGRAM_OUTPUT: - prog->OutputsWritten |= BITFIELD64_BIT(inst->DstReg.Index); + prog->OutputsWritten |= BITFIELD64_BIT(inst->SrcReg[reg].Index); break; case PROGRAM_INPUT: - prog->InputsRead |= BITFIELD64_BIT(inst->DstReg.Index); + prog->InputsRead |= BITFIELD64_BIT(inst->SrcReg[reg].Index); break; default: break; -- cgit v1.2.3 From bd3b835e7c32e093f91f636330fd93b3dedd8362 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 27 Jun 2010 20:36:41 -0700 Subject: glsl2: Add support for some builtin matrices. --- src/mesa/shader/ir_to_mesa.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index af5237f697c..a0217bf8d92 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1,4 +1,6 @@ /* + * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 VMware, Inc. All Rights Reserved. * Copyright © 2010 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a @@ -760,6 +762,86 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) this->result = src_reg; } +static temp_entry * +get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var) +{ + /* + * NOTE: The ARB_vertex_program extension specified that matrices get + * loaded in registers in row-major order. With GLSL, we want column- + * major order. So, we need to transpose all matrices here... + */ + static const struct { + const char *name; + int matrix; + int modifier; + } matrices[] = { + { "gl_ModelViewMatrix", STATE_MODELVIEW_MATRIX, STATE_MATRIX_TRANSPOSE }, + { "gl_ModelViewMatrixInverse", STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVTRANS }, + { "gl_ModelViewMatrixTranspose", STATE_MODELVIEW_MATRIX, 0 }, + { "gl_ModelViewMatrixInverseTranspose", STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVERSE }, + + { "gl_ProjectionMatrix", STATE_PROJECTION_MATRIX, STATE_MATRIX_TRANSPOSE }, + { "gl_ProjectionMatrixInverse", STATE_PROJECTION_MATRIX, STATE_MATRIX_INVTRANS }, + { "gl_ProjectionMatrixTranspose", STATE_PROJECTION_MATRIX, 0 }, + { "gl_ProjectionMatrixInverseTranspose", STATE_PROJECTION_MATRIX, STATE_MATRIX_INVERSE }, + + { "gl_ModelViewProjectionMatrix", STATE_MVP_MATRIX, STATE_MATRIX_TRANSPOSE }, + { "gl_ModelViewProjectionMatrixInverse", STATE_MVP_MATRIX, STATE_MATRIX_INVTRANS }, + { "gl_ModelViewProjectionMatrixTranspose", STATE_MVP_MATRIX, 0 }, + { "gl_ModelViewProjectionMatrixInverseTranspose", STATE_MVP_MATRIX, STATE_MATRIX_INVERSE }, + + { "gl_TextureMatrix", STATE_TEXTURE_MATRIX, STATE_MATRIX_TRANSPOSE }, + { "gl_TextureMatrixInverse", STATE_TEXTURE_MATRIX, STATE_MATRIX_INVTRANS }, + { "gl_TextureMatrixTranspose", STATE_TEXTURE_MATRIX, 0 }, + { "gl_TextureMatrixInverseTranspose", STATE_TEXTURE_MATRIX, STATE_MATRIX_INVERSE }, + + { "gl_NormalMatrix", STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVERSE }, + + }; + unsigned int i; + temp_entry *entry; + + /* C++ gets angry when we try to use an int as a gl_state_index, so we use + * ints for gl_state_index. Make sure they're compatible. + */ + assert(sizeof(gl_state_index) == sizeof(int)); + + for (i = 0; i < Elements(matrices); i++) { + if (strcmp(var->name, matrices[i].name) == 0) { + int j; + int last_pos = -1, base_pos = -1; + int tokens[STATE_LENGTH]; + + tokens[0] = matrices[i].matrix; + tokens[1] = 0; /* array index! */ + tokens[4] = matrices[i].modifier; + + /* Add a ref for each column. It looks like the reason we do + * it this way is that _mesa_add_state_reference doesn't work + * for things that aren't vec4s, so the tokens[2]/tokens[3] + * range has to be equal. + */ + for (j = 0; j < 4; j++) { + tokens[2] = j; + tokens[3] = j; + int pos = _mesa_add_state_reference(prog->Parameters, + (gl_state_index *)tokens); + assert(last_pos == -1 || last_pos == base_pos + j); + if (base_pos == -1) + base_pos = pos; + } + + entry = new(mem_ctx) temp_entry(var, + PROGRAM_STATE_VAR, + base_pos); + + return entry; + } + } + + return NULL; +} + void ir_to_mesa_visitor::visit(ir_dereference_variable *ir) { @@ -771,6 +853,10 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) if (!entry) { switch (ir->var->mode) { case ir_var_uniform: + entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, ir->var); + if (entry) + break; + /* FINISHME: Fix up uniform name for arrays and things */ assert(ir->var->type->gl_type != 0 && ir->var->type->gl_type != GL_INVALID_ENUM); -- cgit v1.2.3 From ad2dc740b95f91f66d57dffe2840dffdefce1c1a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 27 Jun 2010 21:07:21 -0700 Subject: ir_to_mesa: Check the right element for matrix * scalar multiplication. --- src/mesa/shader/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index a0217bf8d92..8541906ca64 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -579,7 +579,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_binop_mul: if (ir->operands[0]->type->is_matrix() && !ir->operands[1]->type->is_matrix()) { - if (ir->operands[0]->type->is_scalar()) { + if (ir->operands[1]->type->is_scalar()) { ir_to_mesa_dst_reg dst_column = result_dst; ir_to_mesa_src_reg src_column = op[0]; for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { -- cgit v1.2.3 From 3f3f41357d33893d01213b37c6d92bcb435b0eeb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 19:56:53 -0700 Subject: ir_to_mesa: Fix matrix * scalar multiplication. We're accessing in terms of columns, so we need to do MUL/MAD/MAD/MAD instead of DP4s. Fixes: glsl-fs-exp2 glsl-fs-log2 glsl-fs-mix-constant glsl-fs-sqrt-zero glsl-vs-sqrt-zero --- src/mesa/shader/ir_to_mesa.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 8541906ca64..b8113dab2be 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -589,15 +589,21 @@ ir_to_mesa_visitor::visit(ir_expression *ir) src_column.index++; } } else { - ir_to_mesa_dst_reg dst_chan = result_dst; ir_to_mesa_src_reg src_column = op[0]; ir_to_mesa_src_reg src_chan = op[1]; - for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { - dst_chan.writemask = (1 << i); - src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - dst_chan, src_column, src_chan); - src_column.index++; + assert(!ir->operands[1]->type->is_matrix() || + !"FINISHME: matrix * matrix"); + for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { + src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); + if (i == 0) { + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + result_dst, src_column, src_chan); + } else { + ir_to_mesa_emit_op3(ir, OPCODE_MAD, + result_dst, src_column, src_chan, + result_src); + } + src_column.index++; } } } else { -- cgit v1.2.3 From 0a52e8b691cecfeec27717c3289763226d5f1bda Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 11:44:30 -0700 Subject: ir_to_mesa: Traverse the "else" instrs after "else", instead of "then" again. --- src/mesa/shader/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index b8113dab2be..a825bf9e67b 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1159,7 +1159,7 @@ ir_to_mesa_visitor::visit(ir_if *ir) else_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ELSE, ir_to_mesa_undef_dst, ir_to_mesa_undef); - visit_exec_list(&ir->then_instructions, this); + visit_exec_list(&ir->else_instructions, this); } if_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ENDIF, -- cgit v1.2.3 From 854fd66cbb569cb3d4768196f4c680eff489733e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 11:59:13 -0700 Subject: ir_to_mesa: Respect EmitCondCodes for IF statements. Fixes glsl-vs-if-* for the 965 driver. --- src/mesa/shader/ir_to_mesa.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index a825bf9e67b..3141a53f5d2 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -67,6 +67,7 @@ typedef struct ir_to_mesa_dst_reg { int file; /**< PROGRAM_* from Mesa */ int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ int writemask; /**< Bitfield of WRITEMASK_[XYZW] */ + GLuint cond_mask:4; } ir_to_mesa_dst_reg; extern ir_to_mesa_src_reg ir_to_mesa_undef; @@ -78,6 +79,7 @@ public: ir_to_mesa_src_reg src_reg[3]; /** Pointer to the ir source this tree came from for debugging */ ir_instruction *ir; + GLboolean cond_update; }; class temp_entry : public exec_node { @@ -293,6 +295,7 @@ ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) dst_reg.file = reg.file; dst_reg.index = reg.index; dst_reg.writemask = WRITEMASK_XYZW; + dst_reg.cond_mask = COND_TR; return dst_reg; } @@ -1142,14 +1145,24 @@ ir_to_mesa_visitor::visit(ir_return *ir) void ir_to_mesa_visitor::visit(ir_if *ir) { - ir_to_mesa_instruction *if_inst, *else_inst = NULL; + ir_to_mesa_instruction *cond_inst, *if_inst, *else_inst = NULL; ir->condition->accept(this); assert(this->result.file != PROGRAM_UNDEFINED); - if_inst = ir_to_mesa_emit_op1(ir->condition, - OPCODE_IF, ir_to_mesa_undef_dst, - this->result); + if (ctx->Shader.EmitCondCodes) { + cond_inst = (ir_to_mesa_instruction *)this->instructions.get_tail(); + cond_inst->cond_update = GL_TRUE; + + if_inst = ir_to_mesa_emit_op1(ir->condition, + OPCODE_IF, ir_to_mesa_undef_dst, + ir_to_mesa_undef); + if_inst->dst_reg.cond_mask = COND_NE; + } else { + if_inst = ir_to_mesa_emit_op1(ir->condition, + OPCODE_IF, ir_to_mesa_undef_dst, + this->result); + } this->instructions.push_tail(if_inst); @@ -1391,9 +1404,10 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader) ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); mesa_inst->Opcode = inst->op; + mesa_inst->CondUpdate = inst->cond_update; mesa_inst->DstReg.File = inst->dst_reg.file; mesa_inst->DstReg.Index = inst->dst_reg.index; - mesa_inst->DstReg.CondMask = COND_TR; + mesa_inst->DstReg.CondMask = inst->dst_reg.cond_mask; mesa_inst->DstReg.WriteMask = inst->dst_reg.writemask; mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); -- cgit v1.2.3 From cbe52c8012659abe5d81cf1180659820e704d290 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 12:16:03 -0700 Subject: ir_to_mesa: Fix EmitCondCodes for boolean vars as condition. Fixes glsl-vs-if-bool. --- src/mesa/shader/ir_to_mesa.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 3141a53f5d2..85aedd69676 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1146,12 +1146,26 @@ void ir_to_mesa_visitor::visit(ir_if *ir) { ir_to_mesa_instruction *cond_inst, *if_inst, *else_inst = NULL; + ir_to_mesa_instruction *prev_inst; + + prev_inst = (ir_to_mesa_instruction *)this->instructions.get_tail(); ir->condition->accept(this); assert(this->result.file != PROGRAM_UNDEFINED); if (ctx->Shader.EmitCondCodes) { cond_inst = (ir_to_mesa_instruction *)this->instructions.get_tail(); + + /* See if we actually generated any instruction for generating + * the condition. If not, then cook up a move to a temp so we + * have something to set cond_update on. + */ + if (cond_inst == prev_inst) { + ir_to_mesa_src_reg temp = get_temp(glsl_type::bool_type); + cond_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_MOV, + ir_to_mesa_dst_reg_from_src(temp), + result); + } cond_inst->cond_update = GL_TRUE; if_inst = ir_to_mesa_emit_op1(ir->condition, -- cgit v1.2.3 From 904b5bfe9986a297dc71fe081ce0f2661d43b00b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 12:26:19 -0700 Subject: ir_to_mesa: Add support for the pow expression. Fixes glsl-algebraic-pow-two. --- src/mesa/shader/ir_to_mesa.cpp | 48 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 85aedd69676..30d05c39ef4 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -167,6 +167,12 @@ public: ir_to_mesa_dst_reg dst, ir_to_mesa_src_reg src0); + void ir_to_mesa_emit_scalar_op2(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0, + ir_to_mesa_src_reg src1); + void *mem_ctx; }; @@ -309,10 +315,11 @@ ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) * to produce dest channels. */ void -ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, +ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op2(ir_instruction *ir, enum prog_opcode op, ir_to_mesa_dst_reg dst, - ir_to_mesa_src_reg src0) + ir_to_mesa_src_reg orig_src0, + ir_to_mesa_src_reg orig_src1) { int i, j; int done_mask = ~dst.writemask; @@ -324,28 +331,48 @@ ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, for (i = 0; i < 4; i++) { GLuint this_mask = (1 << i); ir_to_mesa_instruction *inst; - ir_to_mesa_src_reg src = src0; + ir_to_mesa_src_reg src0 = orig_src0; + ir_to_mesa_src_reg src1 = orig_src1; if (done_mask & this_mask) continue; - GLuint src_swiz = GET_SWZ(src.swizzle, i); + GLuint src0_swiz = GET_SWZ(src0.swizzle, i); + GLuint src1_swiz = GET_SWZ(src1.swizzle, i); for (j = i + 1; j < 4; j++) { - if (!(done_mask & (1 << j)) && GET_SWZ(src.swizzle, j) == src_swiz) { + if (!(done_mask & (1 << j)) && + GET_SWZ(src0.swizzle, j) == src0_swiz && + GET_SWZ(src1.swizzle, j) == src1_swiz) { this_mask |= (1 << j); } } - src.swizzle = MAKE_SWIZZLE4(src_swiz, src_swiz, - src_swiz, src_swiz); + src0.swizzle = MAKE_SWIZZLE4(src0_swiz, src0_swiz, + src0_swiz, src0_swiz); + src1.swizzle = MAKE_SWIZZLE4(src1_swiz, src1_swiz, + src1_swiz, src1_swiz); - inst = ir_to_mesa_emit_op1(ir, op, + inst = ir_to_mesa_emit_op2(ir, op, dst, - src); + src0, + src1); inst->dst_reg.writemask = this_mask; done_mask |= this_mask; } } +void +ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, + enum prog_opcode op, + ir_to_mesa_dst_reg dst, + ir_to_mesa_src_reg src0) +{ + ir_to_mesa_src_reg undef; + + undef.swizzle = SWIZZLE_XXXX; + + ir_to_mesa_emit_scalar_op2(ir, op, dst, src0, undef); +} + struct ir_to_mesa_src_reg ir_to_mesa_visitor::src_reg_for_float(float val) { @@ -711,6 +738,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_binop_max: ir_to_mesa_emit_op2(ir, OPCODE_MAX, result_dst, op[0], op[1]); break; + case ir_binop_pow: + ir_to_mesa_emit_scalar_op2(ir, OPCODE_POW, result_dst, op[0], op[1]); + break; default: ir_print_visitor v; printf("Failed to get tree for expression:\n"); -- cgit v1.2.3 From 7dc1e0b3267f0bf4dc0ef015b972f7fa6c4c317a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 12:35:54 -0700 Subject: ir_to_mesa: Notify the driver when we generate new Mesa programs for GLSL. Fixes glsl-fs-if-*. --- src/mesa/shader/ir_to_mesa.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 30d05c39ef4..90684ad5559 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1609,10 +1609,14 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) case GL_VERTEX_SHADER: _mesa_reference_vertprog(ctx, &prog->VertexProgram, (struct gl_vertex_program *)linked_prog); + ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, + linked_prog); break; case GL_FRAGMENT_SHADER: _mesa_reference_fragprog(ctx, &prog->FragmentProgram, (struct gl_fragment_program *)linked_prog); + ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB, + linked_prog); break; } } -- cgit v1.2.3 From d5a5df45a4af93bb845483bdeeae7c8e042b03d8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 12:48:47 -0700 Subject: ir_to_mesa: Fix indexes of temps used in expressions. It looks like I managed to horribly mangle this in some rebase of the branch. Fixes: glsl-fs-fragcoord glsl-fs-mix --- src/mesa/shader/ir_to_mesa.cpp | 59 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 90684ad5559..9cf78391484 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -385,35 +385,6 @@ ir_to_mesa_visitor::src_reg_for_float(float val) return src_reg; } -/** - * In the initial pass of codegen, we assign temporary numbers to - * intermediate results. (not SSA -- variable assignments will reuse - * storage). Actual register allocation for the Mesa VM occurs in a - * pass over the Mesa IR later. - */ -ir_to_mesa_src_reg -ir_to_mesa_visitor::get_temp(const glsl_type *type) -{ - ir_to_mesa_src_reg src_reg; - int swizzle[4]; - int i; - - assert(!type->is_array()); - - src_reg.file = PROGRAM_TEMPORARY; - src_reg.index = type->matrix_columns; - src_reg.reladdr = false; - - for (i = 0; i < type->vector_elements; i++) - swizzle[i] = i; - for (; i < 4; i++) - swizzle[i] = type->vector_elements - 1; - src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], - swizzle[2], swizzle[3]); - - return src_reg; -} - static int type_size(const struct glsl_type *type) { @@ -448,6 +419,36 @@ type_size(const struct glsl_type *type) } } +/** + * In the initial pass of codegen, we assign temporary numbers to + * intermediate results. (not SSA -- variable assignments will reuse + * storage). Actual register allocation for the Mesa VM occurs in a + * pass over the Mesa IR later. + */ +ir_to_mesa_src_reg +ir_to_mesa_visitor::get_temp(const glsl_type *type) +{ + ir_to_mesa_src_reg src_reg; + int swizzle[4]; + int i; + + assert(!type->is_array()); + + src_reg.file = PROGRAM_TEMPORARY; + src_reg.index = next_temp; + src_reg.reladdr = false; + next_temp += type_size(type); + + for (i = 0; i < type->vector_elements; i++) + swizzle[i] = i; + for (; i < 4; i++) + swizzle[i] = type->vector_elements - 1; + src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], + swizzle[2], swizzle[3]); + + return src_reg; +} + temp_entry * ir_to_mesa_visitor::find_variable_storage(ir_variable *var) { -- cgit v1.2.3 From 8f62ad6d0ff3c11808739c74441f82f6f12485d6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 13:01:49 -0700 Subject: ir_to_mesa: Fix binop_sqrt for multi-channel and negative source channels. Fixes glsl-fs-sqrt-branch. --- src/mesa/shader/ir_to_mesa.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 9cf78391484..d371e35f9cf 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -706,7 +706,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir) break; case ir_unop_sqrt: ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); - ir_to_mesa_emit_op1(ir, OPCODE_RCP, result_dst, result_src); + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, result_src); + /* For incoming channels < 0, set the result to 0. */ + ir_to_mesa_emit_op3(ir, OPCODE_CMP, result_dst, + op[0], src_reg_for_float(0.0), result_src); break; case ir_unop_rsq: ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); -- cgit v1.2.3 From ad8ad338f45c43fe9039d0069d3f3405ede756aa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 13:45:43 -0700 Subject: ir_to_mesa: Actually add the header file for the interface. --- src/mesa/shader/ir_to_mesa.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/mesa/shader/ir_to_mesa.h diff --git a/src/mesa/shader/ir_to_mesa.h b/src/mesa/shader/ir_to_mesa.h new file mode 100644 index 00000000000..e832f84e754 --- /dev/null +++ b/src/mesa/shader/ir_to_mesa.h @@ -0,0 +1,36 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "main/config.h" +#include "main/mtypes.h" + +void _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *sh); +void _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog); + +#ifdef __cplusplus +} +#endif -- cgit v1.2.3 From f9ffccb06bcc90c862f20f8849b824022fbeebbf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 14:47:43 -0700 Subject: ir_to_mesa: Support user-defined varyings using the linker's locations. Fixes glsl-reload-source. --- src/mesa/shader/ir_to_mesa.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index d371e35f9cf..0f035b9e0e9 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -929,15 +929,29 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) !(var_in ^ in)) break; } - if (i == ARRAY_SIZE(builtin_var_to_mesa_reg)) { - printf("Failed to find builtin for %s variable %s\n", - var_in ? "in" : "out", - ir->var->name); - abort(); + if (i != ARRAY_SIZE(builtin_var_to_mesa_reg)) { + entry = new(mem_ctx) temp_entry(ir->var, + builtin_var_to_mesa_reg[i].file, + builtin_var_to_mesa_reg[i].index); + break; } - entry = new(mem_ctx) temp_entry(ir->var, - builtin_var_to_mesa_reg[i].file, - builtin_var_to_mesa_reg[i].index); + + /* If no builtin, then it's a user-generated varying + * (FINISHME: or a function argument!) + */ + /* The linker-assigned location is VERT_RESULT_* or FRAG_ATTRIB* + */ + assert(ir->var->location != -1); + if (var_in) { + entry = new(mem_ctx) temp_entry(ir->var, + PROGRAM_INPUT, + ir->var->location); + } else { + entry = new(mem_ctx) temp_entry(ir->var, + PROGRAM_OUTPUT, + ir->var->location); + } + break; case ir_var_auto: entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_TEMPORARY, -- cgit v1.2.3 From 59a23d7fb93603b2449db4c5d786934a07aebfcb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 28 Jun 2010 15:02:51 -0700 Subject: ir_to_mesa: Actually initialize the undef register for scalar_op1. Fixes glsl-sin, glsl-cos on 965, where we rely on unused src arguments in the VS having a file of PROGRAM_UNDEFINED. --- src/mesa/shader/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 0f035b9e0e9..24b03e1be11 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -366,7 +366,7 @@ ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, ir_to_mesa_dst_reg dst, ir_to_mesa_src_reg src0) { - ir_to_mesa_src_reg undef; + ir_to_mesa_src_reg undef = ir_to_mesa_undef; undef.swizzle = SWIZZLE_XXXX; -- cgit v1.2.3 From 153eca98064252be4daad9cc27746f37c245b627 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 29 Jun 2010 10:02:36 -0700 Subject: glsl2: Invoke preprocessor before calling the compiler proper --- src/mesa/shader/ir_to_mesa.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 24b03e1be11..1232bada27a 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1526,9 +1526,17 @@ _mesa_get_glsl_shader(GLcontext *ctx, void *mem_ctx, struct gl_shader *sh) state->loop_or_switch_nesting = NULL; state->ARB_texture_rectangle_enable = true; - _mesa_glsl_lexer_ctor(state, shader->Source); - _mesa_glsl_parse(state); - _mesa_glsl_lexer_dtor(state); + /* Create a new context for the preprocessor output. Ultimately, this + * should probably be the parser context, but there isn't one yet. + */ + const char *source = shader->Source; + state->error = preprocess(shader, &source, &state->info_log); + + if (!state->error) { + _mesa_glsl_lexer_ctor(state, source); + _mesa_glsl_parse(state); + _mesa_glsl_lexer_dtor(state); + } shader->ir.make_empty(); if (!state->error && !state->translation_unit.is_empty()) -- cgit v1.2.3 From 18707eba1cd6c07fa8b63d0ba5b26f6433f1ae91 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 28 Jun 2010 23:38:04 -0700 Subject: glsl2: Check that returned expressions match the function return type. From my reading of the specification, implicit conversions are not allowed. ATI seems to agree, though nVidia allows it without warning. --- src/glsl/ast_to_hir.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 33eb27533fd..45228649adc 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2151,9 +2151,17 @@ ast_jump_statement::hir(exec_list *instructions, opt_return_value->hir(instructions, state); assert(ret != NULL); - /* FINISHME: Make sure the type of the return value matches the return - * FINISHME: type of the enclosing function. - */ + /* Implicit conversions are not allowed for return values. */ + if (state->current_function->return_type != ret->type) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`return' with wrong type %s, in function `%s' " + "returning %s", + ret->type->name, + state->current_function->function_name(), + state->current_function->return_type->name); + } inst = new(ctx) ir_return(ret); } else { -- cgit v1.2.3 From 28527ed557923aecff5d3b88e5d7776f04389547 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 29 Jun 2010 00:47:44 -0700 Subject: glsl2: Add a method for querying if an AST type has any qualifiers. --- src/glsl/ast.h | 1 + src/glsl/ast_type.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index de300e719c4..adb5fb11d47 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -418,6 +418,7 @@ public: class ast_fully_specified_type : public ast_node { public: virtual void print(void) const; + bool has_qualifiers() const; ast_type_qualifier qualifier; ast_type_specifier *specifier; diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp index 49dfde20e97..e2510a10c62 100644 --- a/src/glsl/ast_type.cpp +++ b/src/glsl/ast_type.cpp @@ -110,3 +110,13 @@ ast_type_specifier::ast_type_specifier(int specifier) type_name = names[specifier]; } + +bool +ast_fully_specified_type::has_qualifiers() const +{ + return qualifier.invariant || qualifier.constant || qualifier.attribute + || qualifier.varying || qualifier.in + || qualifier.out || qualifier.centroid + || qualifier.uniform || qualifier.smooth + || qualifier.flat || qualifier.noperspective; +} -- cgit v1.2.3 From ac04c257e31fe012dac750bcf5bf3134ba07ebdc Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 29 Jun 2010 00:48:10 -0700 Subject: glsl2: Reject return types with qualifiers. Fixes piglit test return-qualifier.frag. --- src/glsl/ast_to_hir.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 45228649adc..5a13b74c037 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1984,6 +1984,7 @@ ast_function::hir(exec_list *instructions, ir_function_signature *sig = NULL; exec_list hir_parameters; + const char *const name = identifier; /* Convert the list of function parameters to HIR now so that they can be * used below to compare this function's signature with previously seen @@ -1999,11 +2000,19 @@ ast_function::hir(exec_list *instructions, assert(return_type != NULL); + /* From page 56 (page 62 of the PDF) of the GLSL 1.30 spec: + * "No qualifier is allowed on the return type of a function." + */ + if (this->return_type->has_qualifiers()) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(& loc, state, + "function `%s' return type has qualifiers", name); + } + /* Verify that this function's signature either doesn't match a previously * seen signature for a function with the same name, or, if a match is found, * that the previously seen signature does not have an associated definition. */ - const char *const name = identifier; f = state->symbols->get_function(name); if (f != NULL) { ir_function_signature *sig = f->exact_matching_signature(&hir_parameters); -- cgit v1.2.3 From 6de825650560198eb97f19e72b2d56e68e3d7a63 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 29 Jun 2010 09:59:40 -0700 Subject: glsl2: Check for non-void functions that don't have a return statement. This doesn't do any control flow analysis to ensure that the return statements are actually reached. Fixes piglit tests function5.frag and function-07.vert. --- src/glsl/ast_to_hir.cpp | 10 ++++++++++ src/glsl/glsl_parser_extras.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 5a13b74c037..c5df0b0fd0c 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2097,6 +2097,7 @@ ast_function_definition::hir(exec_list *instructions, assert(state->current_function == NULL); state->current_function = signature; + state->found_return = false; /* Duplicate parameters declared in the prototype as concrete variables. * Add these to the symbol table. @@ -2128,6 +2129,14 @@ ast_function_definition::hir(exec_list *instructions, assert(state->current_function == signature); state->current_function = NULL; + if (!signature->return_type->is_void() && !state->found_return) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(& loc, state, "function `%s' has non-void return type " + "%s, but no return statement", + signature->function_name(), + signature->return_type->name); + } + /* Function definitions do not have r-values. */ return NULL; @@ -2186,6 +2195,7 @@ ast_jump_statement::hir(exec_list *instructions, inst = new(ctx) ir_return; } + state->found_return = true; instructions->push_tail(inst); break; } diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index cfe02e3b0c1..726bafa7e4b 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -51,6 +51,9 @@ struct _mesa_glsl_parse_state { */ class ir_function_signature *current_function; + /** Have we found a return statement in this function? */ + bool found_return; + /** Was there an error during compilation? */ bool error; -- cgit v1.2.3 From 50577b96ac07bc24af1ef8e2490cb633aa84dd7d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 29 Jun 2010 10:02:01 -0700 Subject: glsl2: Update TODO. --- src/glsl/TODO | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/glsl/TODO b/src/glsl/TODO index 193cfc767d8..c702eb4927e 100644 --- a/src/glsl/TODO +++ b/src/glsl/TODO @@ -43,10 +43,7 @@ - Care must be taken to handle both the 1.10 rules and the 1.20+ rules. In 1.10, built-in functions cannot be constant expressions. -- Detect non-void functions that lack a return statement - -- Detect return statements with a type not matching the funciton's - return type. +- Detect code paths in non-void functions that don't reach a return statement - Handle over-riding built-in functions - Is the overload per-compilation unit or per-linked shader? -- cgit v1.2.3 From 6315b68f5fbe529bce3497b67c42af1eaa62b8c1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 25 Jun 2010 15:25:27 -0700 Subject: ir_swizzle: Add new constructor, refactor constructors Adds a new constructor that takes an array of component values. Refactors the meat of the two constructors to an init_mask method. --- src/glsl/ir.cpp | 63 ++++++++++++++++++++++++++++++++++++++++----------------- src/glsl/ir.h | 11 ++++++++++ 2 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 2756752ba49..4eb0e9e33eb 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -573,28 +573,40 @@ ir_texture::set_sampler(ir_dereference *sampler) } -ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, - unsigned w, unsigned count) - : val(val) +void +ir_swizzle::init_mask(const unsigned *comp, unsigned count) { assert((count >= 1) && (count <= 4)); - const unsigned dup_mask = 0 - | ((count > 1) ? ((1U << y) & ((1U << x) )) : 0) - | ((count > 2) ? ((1U << z) & ((1U << x) | (1U << y) )) : 0) - | ((count > 3) ? ((1U << w) & ((1U << x) | (1U << y) | (1U << z))) : 0); - - assert(x <= 3); - assert(y <= 3); - assert(z <= 3); - assert(w <= 3); + memset(&this->mask, 0, sizeof(this->mask)); + this->mask.num_components = count; + + unsigned dup_mask = 0; + switch (count) { + case 4: + assert(comp[3] <= 3); + dup_mask |= (1U << comp[3]) + & ((1U << comp[0]) | (1U << comp[1]) | (1U << comp[2])); + this->mask.w = comp[3]; + + case 3: + assert(comp[2] <= 3); + dup_mask |= (1U << comp[2]) + & ((1U << comp[0]) | (1U << comp[1])); + this->mask.z = comp[2]; + + case 2: + assert(comp[1] <= 3); + dup_mask |= (1U << comp[1]) + & ((1U << comp[0])); + this->mask.y = comp[1]; + + case 1: + assert(comp[0] <= 3); + this->mask.x = comp[0]; + } - mask.x = x; - mask.y = y; - mask.z = z; - mask.w = w; - mask.num_components = count; - mask.has_duplicates = dup_mask != 0; + this->mask.has_duplicates = dup_mask != 0; /* Based on the number of elements in the swizzle and the base type * (i.e., float, int, unsigned, or bool) of the vector being swizzled, @@ -603,6 +615,21 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, type = glsl_type::get_instance(val->type->base_type, mask.num_components, 1); } +ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, + unsigned w, unsigned count) + : val(val) +{ + const unsigned components[4] = { x, y, z, w }; + this->init_mask(components, count); +} + +ir_swizzle::ir_swizzle(ir_rvalue *val, const unsigned *comp, + unsigned count) + : val(val) +{ + this->init_mask(comp, count); +} + ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) { this->val = val; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 3d2c7ff5cf5..de1124975d2 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -918,6 +918,9 @@ class ir_swizzle : public ir_rvalue { public: ir_swizzle(ir_rvalue *, unsigned x, unsigned y, unsigned z, unsigned w, unsigned count); + + ir_swizzle(ir_rvalue *val, const unsigned *components, unsigned count); + ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask); virtual ir_instruction *clone(struct hash_table *) const; @@ -951,6 +954,14 @@ public: ir_rvalue *val; ir_swizzle_mask mask; + +private: + /** + * Initialize the mask component of a swizzle + * + * This is used by the \c ir_swizzle constructors. + */ + void init_mask(const unsigned *components, unsigned count); }; -- cgit v1.2.3 From c31dcdf57ed9646580040ebfe44c2609885fe96b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 23 Jun 2010 15:19:40 -0700 Subject: glsl2: Always emit vector constructors inline --- src/glsl/ast_function.cpp | 101 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index f431d1d0156..f1ab6f0c5a1 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -444,6 +444,98 @@ generate_constructor_vector(const glsl_type *type, ir_constant *initializer, } +/** + * Determine if a list consists of a single scalar r-value + */ +bool +single_scalar_parameter(exec_list *parameters) +{ + const ir_rvalue *const p = (ir_rvalue *) parameters->head; + assert(((ir_rvalue *)p)->as_rvalue() != NULL); + + return (p->type->is_scalar() && p->next->is_tail_sentinal()); +} + + +/** + * Generate inline code for a vector constructor + * + * The generated constructor code will consist of a temporary variable + * declaration of the same type as the constructor. A sequence of assignments + * from constructor parameters to the temporary will follow. + * + * \return + * An \c ir_dereference_variable of the temprorary generated in the constructor + * body. + */ +ir_rvalue * +emit_inline_vector_constructor(const glsl_type *type, + exec_list *instructions, + exec_list *parameters, + void *ctx) +{ + assert(!parameters->is_empty()); + + ir_variable *var = new(ctx) ir_variable(type, strdup("vec_ctor")); + instructions->push_tail(var); + + /* There are two kinds of vector constructors. + * + * - Construct a vector from a single scalar by replicating that scalar to + * all components of the vector. + * + * - Construct a vector from an arbirary combination of vectors and + * scalars. The components of the constructor parameters are assigned + * to the vector in order until the vector is full. + */ + const unsigned lhs_components = type->components(); + if (single_scalar_parameter(parameters)) { + ir_rvalue *first_param = (ir_rvalue *)parameters->head; + ir_rvalue *rhs = new(ctx) ir_swizzle(first_param, 0, 0, 0, 0, + lhs_components); + ir_dereference_variable *lhs = new(ctx) ir_dereference_variable(var); + + assert(rhs->type == lhs->type); + + ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + } else { + unsigned base_component = 0; + foreach_list(node, parameters) { + ir_rvalue *rhs = (ir_rvalue *) node; + unsigned rhs_components = rhs->type->components(); + + /* Do not try to assign more components to the vector than it has! + */ + if ((rhs_components + base_component) > lhs_components) { + rhs_components = lhs_components - base_component; + } + + /* Emit an assignment of the constructor parameter to the next set of + * components in the temporary variable. + */ + unsigned mask[4] = { 0, 0, 0, 0 }; + for (unsigned i = 0; i < rhs_components; i++) { + mask[i] = i + base_component; + } + + + ir_rvalue *lhs_ref = new(ctx) ir_dereference_variable(var); + ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, mask, rhs_components); + + ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + + /* Advance the component index by the number of components that were + * just assigned. + */ + base_component += rhs_components; + } + } + return new(ctx) ir_dereference_variable(var); +} + + ir_rvalue * ast_function_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -708,8 +800,15 @@ ast_function_expression::hir(exec_list *instructions, &data); return new(ctx) ir_constant(sig->return_type, &data); - } else + } else if (constructor_type->is_vector()) { + return emit_inline_vector_constructor(constructor_type, + instructions, + &actual_parameters, + ctx); + } else { + assert(constructor_type->is_matrix()); return new(ctx) ir_call(sig, & actual_parameters); + } } else { /* FINISHME: Log a better error message here. G++ will show the * FINSIHME: types of the actual parameters and the set of -- cgit v1.2.3 From 81c7e94466da19f9295b8eb5e4b5e587fea96284 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 25 Jun 2010 16:10:43 -0700 Subject: glsl2: Always emit matrix constructors inline --- src/glsl/ast_function.cpp | 322 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 321 insertions(+), 1 deletion(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index f1ab6f0c5a1..3828d3273fd 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -26,6 +26,11 @@ #include "glsl_types.h" #include "ir.h" +inline unsigned min(unsigned a, unsigned b) +{ + return (a < b) ? a : b; +} + static unsigned process_parameters(exec_list *instructions, exec_list *actual_parameters, exec_list *parameters, @@ -536,6 +541,318 @@ emit_inline_vector_constructor(const glsl_type *type, } +/** + * Generate assignment of a portion of a vector to a portion of a matrix column + * + * \param src_base First component of the source to be used in assignment + * \param column Column of destination to be assiged + * \param row_base First component of the destination column to be assigned + * \param count Number of components to be assigned + * + * \note + * \c src_base + \c count must be less than or equal to the number of components + * in the source vector. + */ +ir_instruction * +assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base, + ir_rvalue *src, unsigned src_base, unsigned count, + TALLOC_CTX *ctx) +{ + const unsigned mask[8] = { 0, 1, 2, 3, 0, 0, 0, 0 }; + + ir_constant *col_idx = new(ctx) ir_constant(column); + ir_rvalue *column_ref = new(ctx) ir_dereference_array(var, col_idx); + + assert(column_ref->type->components() >= (row_base + count)); + ir_rvalue *lhs = new(ctx) ir_swizzle(column_ref, &mask[row_base], count); + + assert(src->type->components() >= (src_base + count)); + ir_rvalue *rhs = new(ctx) ir_swizzle(src, &mask[src_base], count); + + return new(ctx) ir_assignment(lhs, rhs, NULL); +} + + +/** + * Generate inline code for a matrix constructor + * + * The generated constructor code will consist of a temporary variable + * declaration of the same type as the constructor. A sequence of assignments + * from constructor parameters to the temporary will follow. + * + * \return + * An \c ir_dereference_variable of the temprorary generated in the constructor + * body. + */ +ir_rvalue * +emit_inline_matrix_constructor(const glsl_type *type, + exec_list *instructions, + exec_list *parameters, + void *ctx) +{ + assert(!parameters->is_empty()); + + ir_variable *var = new(ctx) ir_variable(type, strdup("mat_ctor")); + instructions->push_tail(var); + + /* There are three kinds of matrix constructors. + * + * - Construct a matrix from a single scalar by replicating that scalar to + * along the diagonal of the matrix and setting all other components to + * zero. + * + * - Construct a matrix from an arbirary combination of vectors and + * scalars. The components of the constructor parameters are assigned + * to the matrix in colum-major order until the matrix is full. + * + * - Construct a matrix from a single matrix. The source matrix is copied + * to the upper left portion of the constructed matrix, and the remaining + * elements take values from the identity matrix. + */ + ir_rvalue *const first_param = (ir_rvalue *) parameters->head; + if (single_scalar_parameter(parameters)) { + /* Assign the scalar to the X component of a vec4, and fill the remaining + * components with zero. + */ + ir_variable *rhs_var = new(ctx) ir_variable(glsl_type::vec4_type, + strdup("mat_ctor_vec")); + instructions->push_tail(rhs_var); + + ir_constant_data zero; + zero.f[0] = 0.0; + zero.f[1] = 0.0; + zero.f[2] = 0.0; + zero.f[3] = 0.0; + + ir_instruction *inst = + new(ctx) ir_assignment(new(ctx) ir_dereference_variable(rhs_var), + new(ctx) ir_constant(rhs_var->type, &zero), + NULL); + instructions->push_tail(inst); + + ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); + ir_rvalue *const x_of_rhs = new(ctx) ir_swizzle(rhs_ref, 0, 0, 0, 0, 1); + + inst = new(ctx) ir_assignment(x_of_rhs, first_param, NULL); + instructions->push_tail(inst); + + /* Assign the temporary vector to each column of the destination matrix + * with a swizzle that puts the X component on the diagonal of the + * matrix. In some cases this may mean that the X component does not + * get assigned into the column at all (i.e., when the matrix has more + * columns than rows). + */ + static const unsigned rhs_swiz[4][4] = { + { 0, 1, 1, 1 }, + { 1, 0, 1, 1 }, + { 1, 1, 0, 1 }, + { 1, 1, 1, 0 } + }; + + const unsigned cols_to_init = min(type->matrix_columns, + type->vector_elements); + for (unsigned i = 0; i < cols_to_init; i++) { + ir_constant *const col_idx = new(ctx) ir_constant(i); + ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx); + + ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); + ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, rhs_swiz[i], + type->vector_elements); + + inst = new(ctx) ir_assignment(col_ref, rhs, NULL); + instructions->push_tail(inst); + } + + for (unsigned i = cols_to_init; i < type->matrix_columns; i++) { + ir_constant *const col_idx = new(ctx) ir_constant(i); + ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx); + + ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); + ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, 1, 1, 1, 1, + type->vector_elements); + + inst = new(ctx) ir_assignment(col_ref, rhs, NULL); + instructions->push_tail(inst); + } + } else if (first_param->type->is_matrix()) { + /* From page 50 (56 of the PDF) of the GLSL 1.50 spec: + * + * "If a matrix is constructed from a matrix, then each component + * (column i, row j) in the result that has a corresponding + * component (column i, row j) in the argument will be initialized + * from there. All other components will be initialized to the + * identity matrix. If a matrix argument is given to a matrix + * constructor, it is an error to have any other arguments." + */ + assert(first_param->next->is_tail_sentinal()); + ir_rvalue *const src_matrix = first_param; + + /* If the source matrix is smaller, pre-initialize the relavent parts of + * the destination matrix to the identity matrix. + */ + if ((src_matrix->type->matrix_columns < var->type->matrix_columns) + || (src_matrix->type->vector_elements < var->type->vector_elements)) { + + /* If the source matrix has fewer rows, every column of the destination + * must be initialized. Otherwise only the columns in the destination + * that do not exist in the source must be initialized. + */ + unsigned col = + (src_matrix->type->vector_elements < var->type->vector_elements) + ? 0 : src_matrix->type->matrix_columns; + + const glsl_type *const col_type = var->type->column_type(); + for (/* empty */; col < var->type->matrix_columns; col++) { + ir_constant_data ident; + + ident.f[0] = 0.0; + ident.f[1] = 0.0; + ident.f[2] = 0.0; + ident.f[3] = 0.0; + + ident.f[col] = 1.0; + + ir_rvalue *const rhs = new(ctx) ir_constant(col_type, &ident); + + ir_rvalue *const lhs = + new(ctx) ir_dereference_array(var, new(ctx) ir_constant(col)); + + ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + } + } + + /* Assign columns from the source matrix to the destination matrix. + * + * Since the parameter will be used in the RHS of multiple assignments, + * generate a temporary and copy the paramter there. + */ + ir_variable *const rhs_var = new(ctx) ir_variable(first_param->type, + strdup("mat_ctor_mat")); + instructions->push_tail(rhs_var); + + ir_dereference *const rhs_var_ref = + new(ctx) ir_dereference_variable(rhs_var); + ir_instruction *const inst = + new(ctx) ir_assignment(rhs_var_ref, first_param, NULL); + instructions->push_tail(inst); + + + const unsigned swiz[4] = { 0, 1, 2, 3 }; + const unsigned last_col = min(src_matrix->type->matrix_columns, + var->type->matrix_columns); + for (unsigned i = 0; i < last_col; i++) { + ir_rvalue *const lhs_col = + new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i)); + ir_rvalue *const rhs_col = + new(ctx) ir_dereference_array(rhs_var, new(ctx) ir_constant(i)); + + /* If one matrix has columns that are smaller than the columns of the + * other matrix, wrap the column access of the larger with a swizzle + * so that the LHS and RHS of the assignment have the same size (and + * therefore have the same type). + * + * It would be perfectly valid to unconditionally generate the + * swizzles, this this will typically result in a more compact IR tree. + */ + ir_rvalue *lhs; + ir_rvalue *rhs; + if (lhs_col->type->vector_elements < rhs_col->type->vector_elements) { + lhs = lhs_col; + + rhs = new(ctx) ir_swizzle(rhs_col, swiz, + lhs_col->type->vector_elements); + } else if (lhs_col->type->vector_elements + > rhs_col->type->vector_elements) { + lhs = new(ctx) ir_swizzle(lhs_col, swiz, + rhs_col->type->vector_elements); + rhs = rhs_col; + } else { + lhs = lhs_col; + rhs = rhs_col; + } + + assert(lhs->type == rhs->type); + + ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + } + } else { + const unsigned rows = type->matrix_columns; + const unsigned cols = type->vector_elements; + unsigned col_idx = 0; + unsigned row_idx = 0; + + foreach_list (node, parameters) { + ir_rvalue *const rhs = (ir_rvalue *) node; + const unsigned components_remaining_this_column = rows - row_idx; + unsigned rhs_components = rhs->type->components(); + unsigned rhs_base = 0; + + /* Since the parameter might be used in the RHS of two assignments, + * generate a temporary and copy the paramter there. + */ + ir_variable *rhs_var = new(ctx) ir_variable(rhs->type, + strdup("mat_ctor_vec")); + instructions->push_tail(rhs_var); + + ir_dereference *rhs_var_ref = + new(ctx) ir_dereference_variable(rhs_var); + ir_instruction *inst = new(ctx) ir_assignment(rhs_var_ref, rhs, NULL); + instructions->push_tail(inst); + + /* Assign the current parameter to as many components of the matrix + * as it will fill. + * + * NOTE: A single vector parameter can span two matrix columns. A + * single vec4, for example, can completely fill a mat2. + */ + if (rhs_components >= components_remaining_this_column) { + const unsigned count = min(rhs_components, + components_remaining_this_column); + + rhs_var_ref = new(ctx) ir_dereference_variable(rhs_var); + + ir_instruction *inst = assign_to_matrix_column(var, col_idx, + row_idx, + rhs_var_ref, 0, + count, ctx); + instructions->push_tail(inst); + + rhs_base = count; + + col_idx++; + row_idx = 0; + } + + /* If there is data left in the parameter and components left to be + * set in the destination, emit another assignment. It is possible + * that the assignment could be of a vec4 to the last element of the + * matrix. In this case col_idx==cols, but there is still data + * left in the source parameter. Obviously, don't emit an assignment + * to data outside the destination matrix. + */ + if ((col_idx < cols) && (rhs_base < rhs_components)) { + const unsigned count = rhs_components - rhs_base; + + rhs_var_ref = new(ctx) ir_dereference_variable(rhs_var); + + ir_instruction *inst = assign_to_matrix_column(var, col_idx, + row_idx, + rhs_var_ref, + rhs_base, + count, ctx); + instructions->push_tail(inst); + + row_idx += count; + } + } + } + + return new(ctx) ir_dereference_variable(var); +} + + ir_rvalue * ast_function_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -807,7 +1124,10 @@ ast_function_expression::hir(exec_list *instructions, ctx); } else { assert(constructor_type->is_matrix()); - return new(ctx) ir_call(sig, & actual_parameters); + return emit_inline_matrix_constructor(constructor_type, + instructions, + &actual_parameters, + ctx); } } else { /* FINISHME: Log a better error message here. G++ will show the -- cgit v1.2.3 From 699b247661b1c70e890e478dba88253cad035969 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 25 Jun 2010 17:36:17 -0700 Subject: glsl2: Don't flatten constructor parameters to scalars Now that all scalar, vector, and matrix constructors are emitted in-line, the parameters to these constructors should not be flattened to a pile of scalars. Instead, the functions that emit the in-line constructor bodies can directly write the parameters to the correct locations in the objects being constructed. --- src/glsl/ast_function.cpp | 188 +++++++++++++++------------------------------- 1 file changed, 59 insertions(+), 129 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 3828d3273fd..e23d789fa98 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -903,19 +903,6 @@ ast_function_expression::hir(exec_list *instructions, * matching rules as functions. */ if (constructor_type->is_numeric() || constructor_type->is_boolean()) { - /* Constructing a numeric type has a couple steps. First all values - * passed to the constructor are broken into individual parameters - * and type converted to the base type of the thing being constructed. - * - * At that point we have some number of values that match the base - * type of the thing being constructed. Now the constructor can be - * treated like a function call. Each numeric type has a small set - * of constructor functions. The set of new parameters will either - * match one of those functions or the original constructor is - * invalid. - */ - const glsl_type *const base_type = constructor_type->get_base_type(); - /* Total number of components of the type being constructed. */ const unsigned type_components = constructor_type->components(); @@ -944,19 +931,6 @@ ast_function_expression::hir(exec_list *instructions, ast_node *ast = exec_node_data(ast_node, n, link); ir_rvalue *result = ast->hir(instructions, state)->as_rvalue(); - ir_variable *result_var = NULL; - - /* Attempt to convert the parameter to a constant valued expression. - * After doing so, track whether or not all the parameters to the - * constructor are trivially constant valued expressions. - */ - ir_rvalue *const constant = - result->constant_expression_value(); - - if (constant != NULL) - result = constant; - else - all_parameters_are_constant = false; /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: * @@ -985,58 +959,28 @@ ast_function_expression::hir(exec_list *instructions, else nonmatrix_parameters++; - /* We can't use the same instruction node in the multiple - * swizzle dereferences that happen, so assign it to a - * variable and deref that. Plus it saves computation for - * complicated expressions and handles - * glsl-vs-constructor-call.shader_test. + /* Type cast the parameter and add it to the parameter list for + * the constructor. */ - if (result->type->components() >= 1 && !result->as_constant()) { - result_var = new(ctx) ir_variable(result->type, - "constructor_tmp"); - ir_dereference_variable *lhs; - - lhs = new(ctx) ir_dereference_variable(result_var); - instructions->push_tail(new(ctx) ir_assignment(lhs, - result, NULL)); - } + const glsl_type *desired_type = + glsl_type::get_instance(constructor_type->base_type, + result->type->vector_elements, + result->type->matrix_columns); + result = convert_component(result, desired_type); - /* Process each of the components of the parameter. Dereference - * each component individually, perform any type conversions, and - * add it to the parameter list for the constructor. + /* Attempt to convert the parameter to a constant valued expression. + * After doing so, track whether or not all the parameters to the + * constructor are trivially constant valued expressions. */ - for (unsigned i = 0; i < result->type->components(); i++) { - if (components_used >= type_components) - break; - - ir_rvalue *component; - - if (result_var) { - ir_dereference *d = new(ctx) ir_dereference_variable(result_var); - component = dereference_component(d, i); - } else { - component = dereference_component(result, i); - } - component = convert_component(component, base_type); - - /* All cases that could result in component->type being the - * error type should have already been caught above. - */ - assert(component->type == base_type); - - if (component->as_constant() == NULL) - all_parameters_are_constant = false; + ir_rvalue *const constant = result->constant_expression_value(); - /* Don't actually generate constructor calls for scalars. - * Instead, do the usual component selection and conversion, - * and return the single component. - */ - if (constructor_type->is_scalar()) - return component; + if (constant != NULL) + result = constant; + else + all_parameters_are_constant = false; - actual_parameters.push_tail(component); - components_used++; - } + actual_parameters.push_tail(result); + components_used += result->type->components(); } /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: @@ -1079,65 +1023,51 @@ ast_function_expression::hir(exec_list *instructions, return ir_call::get_error_instruction(ctx); } - ir_function *f = state->symbols->get_function(constructor_type->name); - if (f == NULL) { - _mesa_glsl_error(& loc, state, "no constructor for type `%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - const ir_function_signature *sig = - f->matching_signature(& actual_parameters); - if (sig != NULL) { - /* If all of the parameters are trivially constant, create a - * constant representing the complete collection of parameters. + /* If all of the parameters are trivially constant, create a + * constant representing the complete collection of parameters. + */ + if (all_parameters_are_constant) { + if (components_used >= type_components) + return new(ctx) ir_constant(constructor_type, + & actual_parameters); + + /* The above case must handle all scalar constructors. */ - if (all_parameters_are_constant) { - if (components_used >= type_components) - return new(ctx) ir_constant(sig->return_type, - & actual_parameters); - - assert(sig->return_type->is_vector() - || sig->return_type->is_matrix()); - - /* Constructors with exactly one component are special for - * vectors and matrices. For vectors it causes all elements of - * the vector to be filled with the value. For matrices it - * causes the matrix to be filled with 0 and the diagonal to be - * filled with the value. - */ - ir_constant_data data; - ir_constant *const initializer = - (ir_constant *) actual_parameters.head; - if (sig->return_type->is_matrix()) - generate_constructor_matrix(sig->return_type, initializer, - &data); - else - generate_constructor_vector(sig->return_type, initializer, - &data); - - return new(ctx) ir_constant(sig->return_type, &data); - } else if (constructor_type->is_vector()) { - return emit_inline_vector_constructor(constructor_type, - instructions, - &actual_parameters, - ctx); - } else { - assert(constructor_type->is_matrix()); - return emit_inline_matrix_constructor(constructor_type, - instructions, - &actual_parameters, - ctx); - } - } else { - /* FINISHME: Log a better error message here. G++ will show the - * FINSIHME: types of the actual parameters and the set of - * FINSIHME: candidate functions. A different error should also be - * FINSIHME: logged when multiple functions match. + assert(constructor_type->is_vector() + || constructor_type->is_matrix()); + + /* Constructors with exactly one component are special for + * vectors and matrices. For vectors it causes all elements of + * the vector to be filled with the value. For matrices it + * causes the matrix to be filled with 0 and the diagonal to be + * filled with the value. */ - _mesa_glsl_error(& loc, state, "no matching constructor for `%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); + ir_constant_data data; + ir_constant *const initializer = + (ir_constant *) actual_parameters.head; + if (constructor_type->is_matrix()) + generate_constructor_matrix(constructor_type, initializer, + &data); + else + generate_constructor_vector(constructor_type, initializer, + &data); + + return new(ctx) ir_constant(constructor_type, &data); + } else if (constructor_type->is_scalar()) { + return dereference_component((ir_rvalue *) actual_parameters.head, + 0); + } else if (constructor_type->is_vector()) { + return emit_inline_vector_constructor(constructor_type, + instructions, + &actual_parameters, + ctx); + } else { + assert(constructor_type->is_matrix()); + return emit_inline_matrix_constructor(constructor_type, + instructions, + &actual_parameters, + ctx); } } -- cgit v1.2.3 From 12681610f54b40324e9e342dc25976c223614b81 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 25 Jun 2010 17:58:16 -0700 Subject: glsl_type: Remove vector and matrix constructor generators All scalar, vector, and matrix constructors are generated in-line during AST-to-HIR translation. There is no longer any need to generate function versions of the constructors. --- src/glsl/ast_to_hir.cpp | 1 - src/glsl/glsl_types.cpp | 365 ------------------------------------------------ src/glsl/glsl_types.h | 4 - 3 files changed, 370 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index c5df0b0fd0c..54a8e9e00a7 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -60,7 +60,6 @@ void _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { _mesa_glsl_initialize_variables(instructions, state); - _mesa_glsl_initialize_constructors(instructions, state); _mesa_glsl_initialize_functions(instructions, state); state->current_function = NULL; diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 9a53fbdbcb4..ff157080ff6 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -210,371 +210,6 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const } -/** - * Generate the function intro for a constructor - * - * \param type Data type to be constructed - * \param count Number of parameters to this concrete constructor. Most - * types have at least two constructors. One will take a - * single scalar parameter and the other will take "N" - * scalar parameters. - * \param parameters Storage for the list of parameters. These are - * typically stored in an \c ir_function_signature. - * \param declarations Pointers to the variable declarations for the function - * parameters. These are used later to avoid having to use - * the symbol table. - */ -static ir_function_signature * -generate_constructor_intro(void *ctx, - const glsl_type *type, unsigned parameter_count, - ir_variable **declarations) -{ - /* Names of parameters used in vector and matrix constructors - */ - static const char *const names[] = { - "a", "b", "c", "d", "e", "f", "g", "h", - "i", "j", "k", "l", "m", "n", "o", "p", - }; - - assert(parameter_count <= Elements(names)); - - const glsl_type *const parameter_type = type->get_base_type(); - - ir_function_signature *const signature = new(ctx) ir_function_signature(type); - - for (unsigned i = 0; i < parameter_count; i++) { - ir_variable *var = new(ctx) ir_variable(parameter_type, names[i]); - - var->mode = ir_var_in; - signature->parameters.push_tail(var); - - declarations[i] = var; - } - - ir_variable *retval = new(ctx) ir_variable(type, "__retval"); - signature->body.push_tail(retval); - - declarations[16] = retval; - return signature; -} - - -/** - * Generate the body of a vector constructor that takes a single scalar - */ -static void -generate_vec_body_from_scalar(void *ctx, - exec_list *instructions, - ir_variable **declarations) -{ - ir_instruction *inst; - - /* Generate a single assignment of the parameter to __retval.x and return - * __retval.xxxx for however many vector components there are. - */ - ir_dereference *const lhs_ref = - new(ctx) ir_dereference_variable(declarations[16]); - ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[0]); - - ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); - - inst = new(ctx) ir_assignment(lhs, rhs, NULL); - instructions->push_tail(inst); - - ir_dereference *const retref = new(ctx) ir_dereference_variable(declarations[16]); - - ir_swizzle *retval = new(ctx) ir_swizzle(retref, 0, 0, 0, 0, - declarations[16]->type->vector_elements); - - inst = new(ctx) ir_return(retval); - instructions->push_tail(inst); -} - - -/** - * Generate the body of a vector constructor that takes multiple scalars - */ -static void -generate_vec_body_from_N_scalars(void *ctx, - exec_list *instructions, - ir_variable **declarations) -{ - ir_instruction *inst; - const glsl_type *const vec_type = declarations[16]->type; - - /* Generate an assignment of each parameter to a single component of - * __retval.x and return __retval. - */ - for (unsigned i = 0; i < vec_type->vector_elements; i++) { - ir_dereference *const lhs_ref = - new(ctx) ir_dereference_variable(declarations[16]); - ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[i]); - - ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, i, 0, 0, 0, 1); - - inst = new(ctx) ir_assignment(lhs, rhs, NULL); - instructions->push_tail(inst); - } - - ir_dereference *retval = new(ctx) ir_dereference_variable(declarations[16]); - - inst = new(ctx) ir_return(retval); - instructions->push_tail(inst); -} - - -/** - * Generate the body of a matrix constructor that takes a single scalar - */ -static void -generate_mat_body_from_scalar(void *ctx, - exec_list *instructions, - ir_variable **declarations) -{ - ir_instruction *inst; - - /* Generate an assignment of the parameter to the X component of a - * temporary vector. Set the remaining fields of the vector to 0. The - * size of the vector is equal to the number of rows of the matrix. - * - * Set each column of the matrix to a successive "rotation" of the - * temporary vector. This fills the matrix with 0s, but writes the single - * scalar along the matrix's diagonal. - * - * For a mat4x3, this is equivalent to: - * - * vec3 tmp; - * mat4x3 __retval; - * tmp.x = a; - * tmp.y = 0.0; - * tmp.z = 0.0; - * __retval[0] = tmp.xyy; - * __retval[1] = tmp.yxy; - * __retval[2] = tmp.yyx; - * __retval[3] = tmp.yyy; - */ - const glsl_type *const column_type = declarations[16]->type->column_type(); - const glsl_type *const row_type = declarations[16]->type->row_type(); - - ir_variable *const column = new(ctx) ir_variable(column_type, "v"); - - instructions->push_tail(column); - - ir_dereference *const lhs_ref = new(ctx) ir_dereference_variable(column); - ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[0]); - - ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, 0, 0, 0, 0, 1); - - inst = new(ctx) ir_assignment(lhs, rhs, NULL); - instructions->push_tail(inst); - - for (unsigned i = 1; i < column_type->vector_elements; i++) { - ir_dereference *const lhs_ref = new(ctx) ir_dereference_variable(column); - ir_constant *const zero = new(ctx) ir_constant(0.0f); - - ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, i, 0, 0, 0, 1); - - inst = new(ctx) ir_assignment(lhs, zero, NULL); - instructions->push_tail(inst); - } - - - for (unsigned i = 0; i < row_type->vector_elements; i++) { - static const unsigned swiz[] = { 1, 1, 1, 0, 1, 1, 1 }; - ir_dereference *const rhs_ref = new(ctx) ir_dereference_variable(column); - - /* This will be .xyyy when i=0, .yxyy when i=1, etc. - */ - ir_swizzle *rhs = new(ctx) ir_swizzle(rhs_ref, swiz[3 - i], swiz[4 - i], - swiz[5 - i], swiz[6 - i], - column_type->vector_elements); - - ir_constant *const idx = new(ctx) ir_constant(int(i)); - ir_dereference *const lhs = - new(ctx) ir_dereference_array(declarations[16], idx); - - inst = new(ctx) ir_assignment(lhs, rhs, NULL); - instructions->push_tail(inst); - } - - ir_dereference *const retval = new(ctx) ir_dereference_variable(declarations[16]); - inst = new(ctx) ir_return(retval); - instructions->push_tail(inst); -} - - -/** - * Generate the body of a vector constructor that takes multiple scalars - */ -static void -generate_mat_body_from_N_scalars(void *ctx, - exec_list *instructions, - ir_variable **declarations) -{ - ir_instruction *inst; - const glsl_type *const row_type = declarations[16]->type->row_type(); - const glsl_type *const column_type = declarations[16]->type->column_type(); - - /* Generate an assignment of each parameter to a single component of - * of a particular column of __retval and return __retval. - */ - for (unsigned i = 0; i < column_type->vector_elements; i++) { - for (unsigned j = 0; j < row_type->vector_elements; j++) { - ir_constant *row_index = new(ctx) ir_constant(int(i)); - ir_dereference *const row_access = - new(ctx) ir_dereference_array(declarations[16], row_index); - - ir_swizzle *component_access = new(ctx) ir_swizzle(row_access, - j, 0, 0, 0, 1); - - const unsigned param = (i * row_type->vector_elements) + j; - ir_dereference *const rhs = - new(ctx) ir_dereference_variable(declarations[param]); - - inst = new(ctx) ir_assignment(component_access, rhs, NULL); - instructions->push_tail(inst); - } - } - - ir_dereference *retval = new(ctx) ir_dereference_variable(declarations[16]); - - inst = new(ctx) ir_return(retval); - instructions->push_tail(inst); -} - - -/** - * Generate the constructors for a set of GLSL types - * - * Constructor implementations are added to \c instructions, and the symbols - * are added to \c symtab. - */ -static void -generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, - unsigned num_types, exec_list *instructions) -{ - void *ctx = symtab; - ir_variable *declarations[17]; - - for (unsigned i = 0; i < num_types; i++) { - /* Only numeric and boolean vectors and matrices get constructors here. - * Structures need to be handled elsewhere. It is expected that scalar - * constructors are never actually called, so they are not generated. - */ - if (!types[i].is_numeric() && !types[i].is_boolean()) - continue; - - if (types[i].is_scalar()) - continue; - - /* Generate the function block, add it to the symbol table, and emit it. - */ - ir_function *const f = new(ctx) ir_function(types[i].name); - - bool added = symtab->add_function(types[i].name, f); - assert(added); - - instructions->push_tail(f); - - /* Each type has several basic constructors. The total number of forms - * depends on the derived type. - * - * Vectors: 1 scalar, N scalars - * Matrices: 1 scalar, NxM scalars - * - * Several possible types of constructors are not included in this list. - * - * Scalar constructors are not included. The expectation is that the - * IR generator won't actually generate these as constructor calls. The - * expectation is that it will just generate the necessary type - * conversion. - * - * Matrix contructors from matrices are also not included. The - * expectation is that the IR generator will generate a call to the - * appropriate from-scalars constructor. - */ - ir_function_signature *const sig = - generate_constructor_intro(ctx, &types[i], 1, declarations); - f->add_signature(sig); - - if (types[i].is_vector()) { - generate_vec_body_from_scalar(ctx, &sig->body, declarations); - - ir_function_signature *const vec_sig = - generate_constructor_intro(ctx, - &types[i], types[i].vector_elements, - declarations); - f->add_signature(vec_sig); - - generate_vec_body_from_N_scalars(ctx, &vec_sig->body, declarations); - } else { - assert(types[i].is_matrix()); - - generate_mat_body_from_scalar(ctx, &sig->body, declarations); - - ir_function_signature *const mat_sig = - generate_constructor_intro(ctx, - &types[i], - (types[i].vector_elements - * types[i].matrix_columns), - declarations); - f->add_signature(mat_sig); - - generate_mat_body_from_N_scalars(ctx, &mat_sig->body, declarations); - } - } -} - - -void -generate_110_constructors(glsl_symbol_table *symtab, exec_list *instructions) -{ - generate_constructor(symtab, builtin_core_types, - Elements(builtin_core_types), instructions); -} - - -void -generate_120_constructors(glsl_symbol_table *symtab, exec_list *instructions) -{ - generate_110_constructors(symtab, instructions); - - generate_constructor(symtab, builtin_120_types, - Elements(builtin_120_types), instructions); -} - - -void -generate_130_constructors(glsl_symbol_table *symtab, exec_list *instructions) -{ - generate_120_constructors(symtab, instructions); - - generate_constructor(symtab, builtin_130_types, - Elements(builtin_130_types), instructions); -} - - -void -_mesa_glsl_initialize_constructors(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - switch (state->language_version) { - case 110: - generate_110_constructors(state->symbols, instructions); - break; - case 120: - generate_120_constructors(state->symbols, instructions); - break; - case 130: - generate_130_constructors(state->symbols, instructions); - break; - default: - /* error */ - break; - } -} - - glsl_type::glsl_type(void *ctx, const glsl_type *array, unsigned length) : base_type(GLSL_TYPE_ARRAY), sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 93cf60be8dc..b753742b91c 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -440,10 +440,6 @@ extern "C" { extern void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); -extern void -_mesa_glsl_initialize_constructors(struct exec_list *instructions, - struct _mesa_glsl_parse_state *state); - #ifdef __cplusplus } #endif -- cgit v1.2.3 From 4b6feb0398458a69259e3b77d7a8573b926f2039 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 28 Jun 2010 13:22:55 -0700 Subject: glsl2: Use talloc_strdup when generating constructor temporary names --- src/glsl/ast_function.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index e23d789fa98..f3074a362d7 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -481,7 +481,8 @@ emit_inline_vector_constructor(const glsl_type *type, { assert(!parameters->is_empty()); - ir_variable *var = new(ctx) ir_variable(type, strdup("vec_ctor")); + ir_variable *var = new(ctx) ir_variable(type, + talloc_strdup(ctx, "vec_ctor")); instructions->push_tail(var); /* There are two kinds of vector constructors. @@ -592,7 +593,8 @@ emit_inline_matrix_constructor(const glsl_type *type, { assert(!parameters->is_empty()); - ir_variable *var = new(ctx) ir_variable(type, strdup("mat_ctor")); + ir_variable *var = new(ctx) ir_variable(type, + talloc_strdup(ctx, "mat_ctor")); instructions->push_tail(var); /* There are three kinds of matrix constructors. @@ -614,8 +616,9 @@ emit_inline_matrix_constructor(const glsl_type *type, /* Assign the scalar to the X component of a vec4, and fill the remaining * components with zero. */ - ir_variable *rhs_var = new(ctx) ir_variable(glsl_type::vec4_type, - strdup("mat_ctor_vec")); + ir_variable *rhs_var = + new(ctx) ir_variable(glsl_type::vec4_type, + talloc_strdup(ctx, "mat_ctor_vec")); instructions->push_tail(rhs_var); ir_constant_data zero; @@ -727,8 +730,9 @@ emit_inline_matrix_constructor(const glsl_type *type, * Since the parameter will be used in the RHS of multiple assignments, * generate a temporary and copy the paramter there. */ - ir_variable *const rhs_var = new(ctx) ir_variable(first_param->type, - strdup("mat_ctor_mat")); + ir_variable *const rhs_var = + new(ctx) ir_variable(first_param->type, + talloc_strdup(ctx, "mat_ctor_mat")); instructions->push_tail(rhs_var); ir_dereference *const rhs_var_ref = @@ -792,8 +796,9 @@ emit_inline_matrix_constructor(const glsl_type *type, /* Since the parameter might be used in the RHS of two assignments, * generate a temporary and copy the paramter there. */ - ir_variable *rhs_var = new(ctx) ir_variable(rhs->type, - strdup("mat_ctor_vec")); + ir_variable *rhs_var = + new(ctx) ir_variable(rhs->type, + talloc_strdup(ctx, "mat_ctor_vec")); instructions->push_tail(rhs_var); ir_dereference *rhs_var_ref = -- cgit v1.2.3 From e94642eb0d99ff7f6cdaee31ed4f5f29bdabd6f7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 28 Jun 2010 11:01:57 -0700 Subject: glsl_type: Make all static objects be class private --- src/glsl/builtin_types.h | 22 +++++++++---------- src/glsl/glsl_types.cpp | 32 ++++++++++++++------------- src/glsl/glsl_types.h | 57 +++++++++++++++++++++++++++++++++++++----------- 3 files changed, 72 insertions(+), 39 deletions(-) diff --git a/src/glsl/builtin_types.h b/src/glsl/builtin_types.h index 526421a0174..bd8f8b583a5 100644 --- a/src/glsl/builtin_types.h +++ b/src/glsl/builtin_types.h @@ -25,13 +25,13 @@ #define Elements(x) (sizeof(x)/sizeof(*(x))) #endif -static const struct glsl_type _error_type = +const glsl_type glsl_type::_error_type = glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, ""); -static const struct glsl_type void_type = +const glsl_type glsl_type::void_type = glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void"); -const glsl_type *const glsl_type::error_type = & _error_type; +const glsl_type *const glsl_type::error_type = & glsl_type::_error_type; /** \name Core built-in types * @@ -39,7 +39,7 @@ const glsl_type *const glsl_type::error_type = & _error_type; */ /*@{*/ -static const struct glsl_type builtin_core_types[] = { +const glsl_type glsl_type::builtin_core_types[] = { glsl_type(GL_BOOL, GLSL_TYPE_BOOL, 1, 1, "bool"), glsl_type(GL_BOOL_VEC2, GLSL_TYPE_BOOL, 2, 1, "bvec2"), glsl_type(GL_BOOL_VEC3, GLSL_TYPE_BOOL, 3, 1, "bvec3"), @@ -91,7 +91,7 @@ static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = { { glsl_type::float_type, "diff" }, }; -static const struct glsl_type builtin_structure_types[] = { +const glsl_type glsl_type::builtin_structure_types[] = { glsl_type(gl_DepthRangeParameters_fields, Elements(gl_DepthRangeParameters_fields), "gl_DepthRangeParameters"), @@ -157,7 +157,7 @@ static const struct glsl_struct_field gl_FogParameters_fields[] = { { glsl_type::float_type, "scale" }, }; -static const struct glsl_type builtin_110_deprecated_structure_types[] = { +const glsl_type glsl_type::builtin_110_deprecated_structure_types[] = { glsl_type(gl_PointParameters_fields, Elements(gl_PointParameters_fields), "gl_PointParameters"), @@ -186,7 +186,7 @@ static const struct glsl_type builtin_110_deprecated_structure_types[] = { */ /*@{*/ -static const struct glsl_type builtin_120_types[] = { +const glsl_type glsl_type::builtin_120_types[] = { glsl_type(GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), glsl_type(GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), glsl_type(GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), @@ -206,7 +206,7 @@ const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5]; */ /*@{*/ -static const struct glsl_type builtin_130_types[] = { +const glsl_type glsl_type::builtin_130_types[] = { glsl_type(GL_UNSIGNED_INT, GLSL_TYPE_UINT, 1, 1, "uint"), glsl_type(GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1, "uvec2"), glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"), @@ -261,7 +261,7 @@ const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3]; */ /*@{*/ -static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { +const glsl_type glsl_type::builtin_ARB_texture_rectangle_types[] = { glsl_type(GL_SAMPLER_2D_RECT, GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"), glsl_type(GL_SAMPLER_2D_RECT_SHADOW, @@ -273,7 +273,7 @@ static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { */ /*@{*/ -static const struct glsl_type builtin_EXT_texture_array_types[] = { +const glsl_type glsl_type::builtin_EXT_texture_array_types[] = { glsl_type(GL_SAMPLER_1D_ARRAY, GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW, @@ -289,7 +289,7 @@ static const struct glsl_type builtin_EXT_texture_array_types[] = { */ /*@{*/ -static const struct glsl_type builtin_EXT_texture_buffer_object_types[] = { +const glsl_type glsl_type::builtin_EXT_texture_buffer_object_types[] = { glsl_type(GL_SAMPLER_BUFFER, GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"), glsl_type(GL_INT_SAMPLER_BUFFER, diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index ff157080ff6..69bed33d815 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -46,8 +46,8 @@ add_types_to_symbol_table(glsl_symbol_table *symtab, } -static void -generate_110_types(glsl_symbol_table *symtab) +void +glsl_type::generate_110_types(glsl_symbol_table *symtab) { add_types_to_symbol_table(symtab, builtin_core_types, Elements(builtin_core_types), @@ -62,8 +62,8 @@ generate_110_types(glsl_symbol_table *symtab) } -static void -generate_120_types(glsl_symbol_table *symtab) +void +glsl_type::generate_120_types(glsl_symbol_table *symtab) { generate_110_types(symtab); @@ -72,8 +72,8 @@ generate_120_types(glsl_symbol_table *symtab) } -static void -generate_130_types(glsl_symbol_table *symtab) +void +glsl_type::generate_130_types(glsl_symbol_table *symtab) { generate_120_types(symtab); @@ -82,8 +82,9 @@ generate_130_types(glsl_symbol_table *symtab) } -static void -generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, bool warn) +void +glsl_type::generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, + bool warn) { add_types_to_symbol_table(symtab, builtin_ARB_texture_rectangle_types, Elements(builtin_ARB_texture_rectangle_types), @@ -91,8 +92,9 @@ generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, bool warn) } -static void -generate_EXT_texture_array_types(glsl_symbol_table *symtab, bool warn) +void +glsl_type::generate_EXT_texture_array_types(glsl_symbol_table *symtab, + bool warn) { add_types_to_symbol_table(symtab, builtin_EXT_texture_array_types, Elements(builtin_EXT_texture_array_types), @@ -105,13 +107,13 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) { switch (state->language_version) { case 110: - generate_110_types(state->symbols); + glsl_type::generate_110_types(state->symbols); break; case 120: - generate_120_types(state->symbols); + glsl_type::generate_120_types(state->symbols); break; case 130: - generate_130_types(state->symbols); + glsl_type::generate_130_types(state->symbols); break; default: /* error */ @@ -119,13 +121,13 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) } if (state->ARB_texture_rectangle_enable) { - generate_ARB_texture_rectangle_types(state->symbols, + glsl_type::generate_ARB_texture_rectangle_types(state->symbols, state->ARB_texture_rectangle_warn); } if (state->EXT_texture_array_enable && state->language_version < 130) { // These are already included in 130; don't create twice. - generate_EXT_texture_array_types(state->symbols, + glsl_type::generate_EXT_texture_array_types(state->symbols, state->EXT_texture_array_warn); } } diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index b753742b91c..c62d290def8 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -34,6 +34,11 @@ extern "C" { #include } +struct _mesa_glsl_parse_state; + +extern "C" void +_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); + #define GLSL_TYPE_UINT 0 #define GLSL_TYPE_INT 1 #define GLSL_TYPE_FLOAT 2 @@ -424,6 +429,45 @@ private: static int array_key_compare(const void *a, const void *b); static unsigned array_key_hash(const void *key); + + /** + * \name Pointers to various type singletons + */ + /*@{*/ + static const glsl_type _error_type; + static const glsl_type void_type; + static const glsl_type builtin_core_types[]; + static const glsl_type builtin_structure_types[]; + static const glsl_type builtin_110_deprecated_structure_types[]; + static const glsl_type builtin_120_types[]; + static const glsl_type builtin_130_types[]; + static const glsl_type builtin_ARB_texture_rectangle_types[]; + static const glsl_type builtin_EXT_texture_array_types[]; + static const glsl_type builtin_EXT_texture_buffer_object_types[]; + /*@}*/ + + /** + * \name Methods to populate a symbol table with built-in types. + * + * \internal + * This is one of the truely annoying things about C++. Methods that are + * completely internal and private to a type still have to be advertised to + * the world in a public header file. + */ + /*@{*/ + static void generate_110_types(class glsl_symbol_table *); + static void generate_120_types(class glsl_symbol_table *); + static void generate_130_types(class glsl_symbol_table *); + static void generate_ARB_texture_rectangle_types(class glsl_symbol_table *, + bool); + static void generate_EXT_texture_array_types(class glsl_symbol_table *, + bool); + /** + * This function is a friend because it needs to call the various + * generate_*_types functions and it has C linkage. + */ + friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *); + /*@}*/ }; struct glsl_struct_field { @@ -431,17 +475,4 @@ struct glsl_struct_field { const char *name; }; -struct _mesa_glsl_parse_state; - -#ifdef __cplusplus -extern "C" { -#endif - -extern void -_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); - -#ifdef __cplusplus -} -#endif - #endif /* GLSL_TYPES_H */ -- cgit v1.2.3 From 31bcce04b1f9c8c5e33370e26a3a9d6e60049aa8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 28 Jun 2010 11:09:40 -0700 Subject: glsl_type: Vector, matrix, and sampler type constructors are private --- src/glsl/glsl_types.cpp | 31 +++++++++++++++++++++++++++++++ src/glsl/glsl_types.h | 45 +++++++++++---------------------------------- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 69bed33d815..158659c71e5 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -33,6 +33,37 @@ extern "C" { hash_table *glsl_type::array_types = NULL; +glsl_type::glsl_type(GLenum gl_type, + unsigned base_type, unsigned vector_elements, + unsigned matrix_columns, const char *name) : + gl_type(gl_type), + base_type(base_type), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(vector_elements), matrix_columns(matrix_columns), + name(name), + length(0) +{ + /* Neither dimension is zero or both dimensions are zero. + */ + assert((vector_elements == 0) == (matrix_columns == 0)); + memset(& fields, 0, sizeof(fields)); +} + +glsl_type::glsl_type(GLenum gl_type, + enum glsl_sampler_dim dim, bool shadow, bool array, + unsigned type, const char *name) : + gl_type(gl_type), + base_type(GLSL_TYPE_SAMPLER), + sampler_dimensionality(dim), sampler_shadow(shadow), + sampler_array(array), sampler_type(type), + vector_elements(0), matrix_columns(0), + name(name), + length(0) +{ + memset(& fields, 0, sizeof(fields)); +} + static void add_types_to_symbol_table(glsl_symbol_table *symtab, const struct glsl_type *types, diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index c62d290def8..e1bfd34f4ef 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -158,37 +158,6 @@ struct glsl_type { /*@}*/ - glsl_type(GLenum gl_type, - unsigned base_type, unsigned vector_elements, - unsigned matrix_columns, const char *name) : - gl_type(gl_type), - base_type(base_type), - sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), - sampler_type(0), - vector_elements(vector_elements), matrix_columns(matrix_columns), - name(name), - length(0) - { - /* Neither dimension is zero or both dimensions are zero. - */ - assert((vector_elements == 0) == (matrix_columns == 0)); - memset(& fields, 0, sizeof(fields)); - } - - glsl_type(GLenum gl_type, - enum glsl_sampler_dim dim, bool shadow, bool array, - unsigned type, const char *name) : - gl_type(gl_type), - base_type(GLSL_TYPE_SAMPLER), - sampler_dimensionality(dim), sampler_shadow(shadow), - sampler_array(array), sampler_type(type), - vector_elements(0), matrix_columns(0), - name(name), - length(0) - { - memset(& fields, 0, sizeof(fields)); - } - glsl_type(const glsl_struct_field *fields, unsigned num_fields, const char *name) : base_type(GLSL_TYPE_STRUCT), @@ -419,9 +388,17 @@ struct glsl_type { } private: - /** - * Constructor for array types - */ + /** Constructor for vector and matrix types */ + glsl_type(GLenum gl_type, + unsigned base_type, unsigned vector_elements, + unsigned matrix_columns, const char *name); + + /** Constructor for sampler types */ + glsl_type(GLenum gl_type, + enum glsl_sampler_dim dim, bool shadow, bool array, + unsigned type, const char *name); + + /** Constructor for array types */ glsl_type(void *ctx, const glsl_type *array, unsigned length); /** Hash table containing the known array types. */ -- cgit v1.2.3 From 49e3577b91f44013746f7a3db411e7041b7d899e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 28 Jun 2010 11:54:57 -0700 Subject: glsl_type: Add get_record_instance method --- src/glsl/ast_to_hir.cpp | 4 +-- src/glsl/glsl_types.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ src/glsl/glsl_types.h | 12 +++++++++ 3 files changed, 86 insertions(+), 2 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 54a8e9e00a7..664e4687c4e 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2383,7 +2383,6 @@ ir_rvalue * ast_struct_specifier::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); unsigned decl_count = 0; /* Make an initial pass over the list of structure fields to determine how @@ -2446,7 +2445,8 @@ ast_struct_specifier::hir(exec_list *instructions, name = this->name; } - glsl_type *t = new(ctx) glsl_type(fields, decl_count, name); + const glsl_type *t = + glsl_type::get_record_instance(fields, decl_count, name); YYLTYPE loc = this->get_location(); if (!state->symbols->add_type(name, t)) { diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 158659c71e5..672a7f7cd17 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -32,6 +32,7 @@ extern "C" { } hash_table *glsl_type::array_types = NULL; +hash_table *glsl_type::record_types = NULL; glsl_type::glsl_type(GLenum gl_type, unsigned base_type, unsigned vector_elements, @@ -384,6 +385,77 @@ glsl_type::get_array_instance(void *ctx, const glsl_type *base, } +int +glsl_type::record_key_compare(const void *a, const void *b) +{ + const glsl_type *const key1 = (glsl_type *) a; + const glsl_type *const key2 = (glsl_type *) b; + + /* Return zero is the types match (there is zero difference) or non-zero + * otherwise. + */ + if (strcmp(key1->name, key2->name) != 0) + return 1; + + if (key1->length != key2->length) + return 1; + + for (unsigned i = 0; i < key1->length; i++) + /* FINISHME: Is the name of the structure field also significant? */ + if (key1->fields.structure[i].type != key2->fields.structure[i].type) + return 1; + + return 0; +} + + +unsigned +glsl_type::record_key_hash(const void *a) +{ + const glsl_type *const key = (glsl_type *) a; + char hash_key[128]; + unsigned size = 0; + + size = snprintf(hash_key, sizeof(hash_key), "%08x", key->length); + + for (unsigned i = 0; i < key->length; i++) { + if (size >= sizeof(hash_key)) + break; + + size += snprintf(& hash_key[size], sizeof(hash_key) - size, + "%p", key->fields.structure[i].type); + } + + return hash_table_string_hash(& hash_key); +} + + +const glsl_type * +glsl_type::get_record_instance(const glsl_struct_field *fields, + unsigned num_fields, + const char *name) +{ + const glsl_type key(fields, num_fields, name); + + if (record_types == NULL) { + record_types = hash_table_ctor(64, record_key_hash, record_key_compare); + } + + const glsl_type *t = (glsl_type *) hash_table_find(record_types, & key); + if (t == NULL) { + t = new(NULL) glsl_type(fields, num_fields, name); + + hash_table_insert(record_types, (void *) t, t); + } + + assert(t->base_type == GLSL_TYPE_STRUCT); + assert(t->length == num_fields); + assert(strcmp(t->name, name) == 0); + + return t; +} + + const glsl_type * glsl_type::field_type(const char *name) const { diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index e1bfd34f4ef..a1c9fae4f9f 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -205,6 +205,12 @@ struct glsl_type { const glsl_type *base, unsigned elements); + /** + * Get the instance of a record type + */ + static const glsl_type *get_record_instance(const glsl_struct_field *fields, + unsigned num_fields, + const char *name); /** * Generate the constructor for this type and add it to the symbol table */ @@ -407,6 +413,12 @@ private: static int array_key_compare(const void *a, const void *b); static unsigned array_key_hash(const void *key); + /** Hash table containing the known record types. */ + static struct hash_table *record_types; + + static int record_key_compare(const void *a, const void *b); + static unsigned record_key_hash(const void *key); + /** * \name Pointers to various type singletons */ -- cgit v1.2.3 From 72e627d02a78cbf40c861384293e355588fd0977 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 28 Jun 2010 11:57:38 -0700 Subject: glsl_type: Record type constructors are private --- src/glsl/glsl_types.cpp | 12 ++++++++++++ src/glsl/glsl_types.h | 16 ++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 672a7f7cd17..f910efdddef 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -65,6 +65,18 @@ glsl_type::glsl_type(GLenum gl_type, memset(& fields, 0, sizeof(fields)); } +glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, + const char *name) : + base_type(GLSL_TYPE_STRUCT), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(0), matrix_columns(0), + name(name), + length(num_fields) +{ + this->fields.structure = fields; +} + static void add_types_to_symbol_table(glsl_symbol_table *symtab, const struct glsl_type *types, diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index a1c9fae4f9f..fc94bea1ccc 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -158,18 +158,6 @@ struct glsl_type { /*@}*/ - glsl_type(const glsl_struct_field *fields, unsigned num_fields, - const char *name) : - base_type(GLSL_TYPE_STRUCT), - sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), - sampler_type(0), - vector_elements(0), matrix_columns(0), - name(name), - length(num_fields) - { - this->fields.structure = fields; - } - /** * For numeric and boolean derrived types returns the basic scalar type * @@ -404,6 +392,10 @@ private: enum glsl_sampler_dim dim, bool shadow, bool array, unsigned type, const char *name); + /** Constructor for record types */ + glsl_type(const glsl_struct_field *fields, unsigned num_fields, + const char *name); + /** Constructor for array types */ glsl_type(void *ctx, const glsl_type *array, unsigned length); -- cgit v1.2.3 From e1374d48ded09dba576f5a2b86c3d11984d1f7c4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 28 Jun 2010 12:19:52 -0700 Subject: glsl_type: All glsl_type objects live in their own talloc context --- src/glsl/glsl_types.cpp | 5 +++-- src/glsl/glsl_types.h | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index f910efdddef..0d807fbc3dc 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -33,6 +33,7 @@ extern "C" { hash_table *glsl_type::array_types = NULL; hash_table *glsl_type::record_types = NULL; +void *glsl_type::ctx = NULL; glsl_type::glsl_type(GLenum gl_type, unsigned base_type, unsigned vector_elements, @@ -384,7 +385,7 @@ glsl_type::get_array_instance(void *ctx, const glsl_type *base, const glsl_type *t = (glsl_type *) hash_table_find(array_types, & key); if (t == NULL) { - t = new(ctx) glsl_type(ctx, base, array_size); + t = new glsl_type(ctx, base, array_size); hash_table_insert(array_types, (void *) t, t); } @@ -455,7 +456,7 @@ glsl_type::get_record_instance(const glsl_struct_field *fields, const glsl_type *t = (glsl_type *) hash_table_find(record_types, & key); if (t == NULL) { - t = new(NULL) glsl_type(fields, num_fields, name); + t = new glsl_type(fields, num_fields, name); hash_table_insert(record_types, (void *) t, t); } diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index fc94bea1ccc..1147d38ca64 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -74,11 +74,16 @@ struct glsl_type { /* Callers of this talloc-based new need not call delete. It's * easier to just talloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) + static void* operator new(size_t size) { + if (glsl_type::ctx == NULL) { + glsl_type::ctx = talloc_init("glsl_type"); + assert(glsl_type::ctx != NULL); + } + void *type; - type = talloc_size(ctx, size); + type = talloc_size(glsl_type::ctx, size); assert(type != NULL); return type; @@ -382,6 +387,13 @@ struct glsl_type { } private: + /** + * talloc context for all glsl_type allocations + * + * Set on the first call to \c glsl_type::new. + */ + static TALLOC_CTX *ctx; + /** Constructor for vector and matrix types */ glsl_type(GLenum gl_type, unsigned base_type, unsigned vector_elements, -- cgit v1.2.3 From efc15f862b08a9f035c06a79bc43848cca740372 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 28 Jun 2010 13:17:18 -0700 Subject: glsl_type: Add _mesa_glsl_release_types to release all type related storage --- src/glsl/glsl_types.cpp | 20 ++++++++++++++++++++ src/glsl/glsl_types.h | 14 ++++++++++++-- src/glsl/main.cpp | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 0d807fbc3dc..806b71495de 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -195,6 +195,26 @@ const glsl_type *glsl_type::get_base_type() const } +void +_mesa_glsl_release_types(void) +{ + if (glsl_type::array_types != NULL) { + hash_table_dtor(glsl_type::array_types); + glsl_type::array_types = NULL; + } + + if (glsl_type::record_types != NULL) { + hash_table_dtor(glsl_type::record_types); + glsl_type::record_types = NULL; + } + + if (glsl_type::ctx != NULL) { + talloc_free(glsl_type::ctx); + glsl_type::ctx = NULL; + } +} + + ir_function * glsl_type::generate_constructor(glsl_symbol_table *symtab) const { diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 1147d38ca64..e869071cab0 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -39,6 +39,9 @@ struct _mesa_glsl_parse_state; extern "C" void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); +extern "C" void +_mesa_glsl_release_types(void); + #define GLSL_TYPE_UINT 0 #define GLSL_TYPE_INT 1 #define GLSL_TYPE_FLOAT 2 @@ -455,11 +458,18 @@ private: bool); static void generate_EXT_texture_array_types(class glsl_symbol_table *, bool); + /*@}*/ + /** - * This function is a friend because it needs to call the various - * generate_*_types functions and it has C linkage. + * \name Friend functions. + * + * These functions are friends because they must have C linkage and the + * need to call various private methods or access various private static + * data. */ + /*@{*/ friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *); + friend void _mesa_glsl_release_types(void); /*@}*/ }; diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 16b2cf84c53..342cf988404 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -258,6 +258,7 @@ main(int argc, char **argv) } talloc_free(whole_program); + _mesa_glsl_release_types(); return status; } -- cgit v1.2.3 From 5e18b051c039564d1998818d08caf1bff3983630 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 29 Jun 2010 14:21:05 -0700 Subject: glsl2: Pass MaxDrawBuffers from core Mesa into the GLSL compiler --- src/glsl/glsl_parser_extras.h | 9 +++++++++ src/glsl/ir_variable.cpp | 46 ++++++++++++++++++++---------------------- src/glsl/main.cpp | 2 ++ src/mesa/shader/ir_to_mesa.cpp | 2 ++ 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 726bafa7e4b..f957a926be3 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -43,6 +43,15 @@ struct _mesa_glsl_parse_state { unsigned language_version; enum _mesa_glsl_parser_targets target; + /** + * Implementation defined limits that affect built-in variables, etc. + * + * \sa struct gl_constants (in mtypes.h) + */ + struct { + unsigned MaxDrawBuffers; + } Const; + /** * During AST to IR conversion, pointer to current IR function * diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 15a4a92f628..44c3065107f 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -221,20 +221,20 @@ initialize_vs_variables(exec_list *instructions, static void generate_110_fs_variables(exec_list *instructions, - glsl_symbol_table *symtab) + struct _mesa_glsl_parse_state *state) { for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { add_builtin_variable(& builtin_core_fs_variables[i], - instructions, symtab); + instructions, state->symbols); } for (unsigned i = 0 ; i < Elements(builtin_110_deprecated_fs_variables) ; i++) { add_builtin_variable(& builtin_110_deprecated_fs_variables[i], - instructions, symtab); + instructions, state->symbols); } - generate_110_uniforms(instructions, symtab); + generate_110_uniforms(instructions, state->symbols); /* FINISHME: The size of this array is implementation dependent based on the * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports @@ -242,27 +242,25 @@ generate_110_fs_variables(exec_list *instructions, * FINISHME: for now. */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 4); + glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 4); add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type, - instructions, symtab); + instructions, state->symbols); } static void generate_ARB_draw_buffers_fs_variables(exec_list *instructions, - glsl_symbol_table *symtab, bool warn) + struct _mesa_glsl_parse_state *state, + bool warn) { - /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_DRAW_BUFFERS. GL_MAX_DRAW_BUFFERS must be - * FINISHME: at least 1, so hard-code 1 for now. - */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 1); + glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, + state->Const.MaxDrawBuffers); ir_variable *const fd = add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0, - vec4_array_type, instructions, symtab); + vec4_array_type, instructions, state->symbols); if (warn) fd->warn_extension = "GL_ARB_draw_buffers"; @@ -271,18 +269,18 @@ generate_ARB_draw_buffers_fs_variables(exec_list *instructions, static void generate_120_fs_variables(exec_list *instructions, - glsl_symbol_table *symtab) + struct _mesa_glsl_parse_state *state) { - generate_110_fs_variables(instructions, symtab); - generate_ARB_draw_buffers_fs_variables(instructions, symtab, false); + generate_110_fs_variables(instructions, state); + generate_ARB_draw_buffers_fs_variables(instructions, state, false); } static void generate_130_fs_variables(exec_list *instructions, - glsl_symbol_table *symtab) + struct _mesa_glsl_parse_state *state) { - void *ctx = symtab; - generate_120_fs_variables(instructions, symtab); + void *ctx = state->symbols; + generate_120_fs_variables(instructions, state); /* FINISHME: The size of this array is implementation dependent based on * FINISHME: the value of GL_MAX_CLIP_DISTANCES. @@ -292,7 +290,7 @@ generate_130_fs_variables(exec_list *instructions, /* FINISHME: gl_ClipDistance needs a real location assigned. */ add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type, - instructions, symtab); + instructions, state->symbols); } static void @@ -302,13 +300,13 @@ initialize_fs_variables(exec_list *instructions, switch (state->language_version) { case 110: - generate_110_fs_variables(instructions, state->symbols); + generate_110_fs_variables(instructions, state); break; case 120: - generate_120_fs_variables(instructions, state->symbols); + generate_120_fs_variables(instructions, state); break; case 130: - generate_130_fs_variables(instructions, state->symbols); + generate_130_fs_variables(instructions, state); break; } @@ -318,7 +316,7 @@ initialize_fs_variables(exec_list *instructions, */ if (state->language_version < 120) { if (state->ARB_draw_buffers_enable) { - generate_ARB_draw_buffers_fs_variables(instructions, state->symbols, + generate_ARB_draw_buffers_fs_variables(instructions, state, state->ARB_draw_buffers_warn); } } diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 342cf988404..f1dab7b576a 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -123,6 +123,8 @@ compile_shader(struct glsl_shader *shader) state->loop_or_switch_nesting = NULL; state->ARB_texture_rectangle_enable = true; + state->Const.MaxDrawBuffers = 2; + /* Create a new context for the preprocessor output. Ultimately, this * should probably be the parser context, but there isn't one yet. */ diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 1232bada27a..ab8aca0a813 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1526,6 +1526,8 @@ _mesa_get_glsl_shader(GLcontext *ctx, void *mem_ctx, struct gl_shader *sh) state->loop_or_switch_nesting = NULL; state->ARB_texture_rectangle_enable = true; + state->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; + /* Create a new context for the preprocessor output. Ultimately, this * should probably be the parser context, but there isn't one yet. */ -- cgit v1.2.3 From 9c4b1f2bad97b1b83c6bf01db567be5494dfaee5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 29 Jun 2010 15:10:09 -0700 Subject: glsl2: Make gl_FragData be available in GLSL 1.10 too --- src/glsl/ir_variable.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 44c3065107f..6e466fa6d1e 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -30,6 +30,9 @@ #define Elements(x) (sizeof(x)/sizeof(*(x))) #endif +static void generate_ARB_draw_buffers_fs_variables(exec_list *, + struct _mesa_glsl_parse_state *, bool); + static ir_variable * add_variable(const char *name, enum ir_variable_mode mode, int slot, const glsl_type *type, exec_list *instructions, @@ -246,6 +249,8 @@ generate_110_fs_variables(exec_list *instructions, add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type, instructions, state->symbols); + + generate_ARB_draw_buffers_fs_variables(instructions, state, false); } @@ -272,7 +277,6 @@ generate_120_fs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { generate_110_fs_variables(instructions, state); - generate_ARB_draw_buffers_fs_variables(instructions, state, false); } static void @@ -309,17 +313,6 @@ initialize_fs_variables(exec_list *instructions, generate_130_fs_variables(instructions, state); break; } - - - /* Since GL_ARB_draw_buffers is included in GLSL 1.20 and later, we - * can basically ignore any extension settings for it. - */ - if (state->language_version < 120) { - if (state->ARB_draw_buffers_enable) { - generate_ARB_draw_buffers_fs_variables(instructions, state, - state->ARB_draw_buffers_warn); - } - } } void -- cgit v1.2.3 From e2f84f04e5df1d4364694e5f150058f7c847550e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 29 Jun 2010 15:19:11 -0700 Subject: glsl2: Make gl_MaxDrawBuffers available in the fragment shader --- src/glsl/ir_variable.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 6e466fa6d1e..e298a0e06b5 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -42,6 +42,9 @@ add_variable(const char *name, enum ir_variable_mode mode, int slot, var->mode = mode; switch (var->mode) { + case ir_var_auto: + var->read_only = true; + break; case ir_var_in: var->shader_in = true; var->read_only = true; @@ -259,6 +262,18 @@ generate_ARB_draw_buffers_fs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state, bool warn) { + assert(state->Const.MaxDrawBuffers >= 1); + + ir_variable *const mdb = + add_variable("gl_MaxDrawBuffers", ir_var_auto, -1, + glsl_type::int_type, instructions, state->symbols); + + if (warn) + mdb->warn_extension = "GL_ARB_draw_buffers"; + + mdb->constant_value = new(mdb) + ir_constant(int(state->Const.MaxDrawBuffers)); + const glsl_type *const vec4_array_type = glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, state->Const.MaxDrawBuffers); -- cgit v1.2.3 From 22971e922a72c8a433638429b635935fe80907ee Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 29 Jun 2010 15:29:56 -0700 Subject: glsl2: Make gl_MaxDrawBuffers available in the vertex shader --- src/glsl/ir_variable.cpp | 74 +++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index e298a0e06b5..ac168142dc6 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -30,8 +30,9 @@ #define Elements(x) (sizeof(x)/sizeof(*(x))) #endif -static void generate_ARB_draw_buffers_fs_variables(exec_list *, - struct _mesa_glsl_parse_state *, bool); +static void generate_ARB_draw_buffers_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, @@ -143,20 +144,20 @@ generate_110_uniforms(exec_list *instructions, static void generate_110_vs_variables(exec_list *instructions, - glsl_symbol_table *symtab) + struct _mesa_glsl_parse_state *state) { for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { add_builtin_variable(& builtin_core_vs_variables[i], - instructions, symtab); + instructions, state->symbols); } for (unsigned i = 0 ; i < Elements(builtin_110_deprecated_vs_variables) ; i++) { add_builtin_variable(& builtin_110_deprecated_vs_variables[i], - instructions, symtab); + instructions, state->symbols); } - generate_110_uniforms(instructions, symtab); + generate_110_uniforms(instructions, state->symbols); /* FINISHME: The size of this array is implementation dependent based on the * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports @@ -164,34 +165,37 @@ generate_110_vs_variables(exec_list *instructions, * FINISHME: for now. */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(symtab, glsl_type::vec4_type, 4); + glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 4); add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type, - instructions, symtab); + instructions, state->symbols); + + generate_ARB_draw_buffers_variables(instructions, state, false, + vertex_shader); } static void generate_120_vs_variables(exec_list *instructions, - glsl_symbol_table *symtab) + struct _mesa_glsl_parse_state *state) { /* GLSL version 1.20 did not add any built-in variables in the vertex * shader. */ - generate_110_vs_variables(instructions, symtab); + generate_110_vs_variables(instructions, state); } static void generate_130_vs_variables(exec_list *instructions, - glsl_symbol_table *symtab) + struct _mesa_glsl_parse_state *state) { - void *ctx = symtab; - generate_120_vs_variables(instructions, symtab); + void *ctx = state->symbols; + generate_120_vs_variables(instructions, state); for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { add_builtin_variable(& builtin_130_vs_variables[i], - instructions, symtab); + instructions, state->symbols); } /* FINISHME: The size of this array is implementation dependent based on @@ -202,7 +206,7 @@ generate_130_vs_variables(exec_list *instructions, /* FINISHME: gl_ClipDistance needs a real location assigned. */ add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type, - instructions, symtab); + instructions, state->symbols); } @@ -214,13 +218,13 @@ initialize_vs_variables(exec_list *instructions, switch (state->language_version) { case 110: - generate_110_vs_variables(instructions, state->symbols); + generate_110_vs_variables(instructions, state); break; case 120: - generate_120_vs_variables(instructions, state->symbols); + generate_120_vs_variables(instructions, state); break; case 130: - generate_130_vs_variables(instructions, state->symbols); + generate_130_vs_variables(instructions, state); break; } } @@ -253,17 +257,18 @@ generate_110_fs_variables(exec_list *instructions, add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type, instructions, state->symbols); - generate_ARB_draw_buffers_fs_variables(instructions, state, false); + generate_ARB_draw_buffers_variables(instructions, state, false, + fragment_shader); } static void -generate_ARB_draw_buffers_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool warn) +generate_ARB_draw_buffers_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + bool warn, _mesa_glsl_parser_targets target) { - assert(state->Const.MaxDrawBuffers >= 1); - + /* gl_MaxDrawBuffers is available in all shader stages. + */ ir_variable *const mdb = add_variable("gl_MaxDrawBuffers", ir_var_auto, -1, glsl_type::int_type, instructions, state->symbols); @@ -274,16 +279,21 @@ generate_ARB_draw_buffers_fs_variables(exec_list *instructions, mdb->constant_value = new(mdb) ir_constant(int(state->Const.MaxDrawBuffers)); - const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, - state->Const.MaxDrawBuffers); - ir_variable *const fd = - add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0, - vec4_array_type, instructions, state->symbols); + /* gl_FragData is only available in the fragment shader. + */ + if (target == fragment_shader) { + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, + state->Const.MaxDrawBuffers); + + ir_variable *const fd = + add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0, + vec4_array_type, instructions, state->symbols); - if (warn) - fd->warn_extension = "GL_ARB_draw_buffers"; + if (warn) + fd->warn_extension = "GL_ARB_draw_buffers"; + } } -- cgit v1.2.3 From 506199b852390e14a1d78392285bee8f06b6ede7 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 29 Jun 2010 15:59:27 -0700 Subject: glsl2: Keep the same number of components in implicit conversions. Fixes piglit test glsl-implicit-conversion-01. --- src/glsl/ast_to_hir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 664e4687c4e..ba292400925 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -109,6 +109,12 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, if (!to->is_float() || !from->type->is_numeric()) return false; + /* Convert to a floating point type with the same number of components + * as the original type - i.e. int to float, not int to vec4. + */ + to = glsl_type::get_instance(GLSL_TYPE_FLOAT, from->type->vector_elements, + from->type->matrix_columns); + switch (from->type->base_type) { case GLSL_TYPE_INT: from = new(ctx) ir_expression(ir_unop_i2f, to, from, NULL); -- cgit v1.2.3 From d4f7e660dd81e05b0829c1b70663b3959fd78f47 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 29 Jun 2010 14:16:11 -0700 Subject: ir_to_mesa: Start adding support for texture instructions. Fixes: glsl-fs-bug25902 glsl-fs-sampler-numbering glsl-lod-bias --- src/glsl/ir.h | 6 ++ src/mesa/shader/ir_to_mesa.cpp | 138 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 142 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index de1124975d2..65026ef1f5b 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -73,6 +73,7 @@ public: virtual class ir_function * as_function() { return NULL; } virtual class ir_dereference * as_dereference() { return NULL; } virtual class ir_dereference_array * as_dereference_array() { return NULL; } + virtual class ir_dereference_variable *as_dereference_variable() { return NULL; } virtual class ir_rvalue * as_rvalue() { return NULL; } virtual class ir_loop * as_loop() { return NULL; } virtual class ir_assignment * as_assignment() { return NULL; } @@ -987,6 +988,11 @@ public: virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_dereference_variable *as_dereference_variable() + { + return this; + } + /** * Get the variable that is ultimately referenced by an r-value */ diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index ab8aca0a813..f04518175d1 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -80,6 +80,8 @@ public: /** Pointer to the ir source this tree came from for debugging */ ir_instruction *ir; GLboolean cond_update; + int sampler; /**< sampler index */ + int tex_target; /**< One of TEXTURE_*_INDEX */ }; class temp_entry : public exec_node { @@ -173,6 +175,12 @@ public: ir_to_mesa_src_reg src0, ir_to_mesa_src_reg src1); + int *sampler_map; + int sampler_map_size; + + void map_sampler(int location, int sampler); + int get_sampler_number(int location); + void *mem_ctx; }; @@ -293,6 +301,25 @@ ir_to_mesa_visitor::ir_to_mesa_emit_op1(ir_instruction *ir, src0, ir_to_mesa_undef, ir_to_mesa_undef); } +void +ir_to_mesa_visitor::map_sampler(int location, int sampler) +{ + if (this->sampler_map_size <= location) { + this->sampler_map = talloc_realloc(this->mem_ctx, this->sampler_map, + int, location + 1); + this->sampler_map_size = location + 1; + } + + this->sampler_map[location] = sampler; +} + +int +ir_to_mesa_visitor::get_sampler_number(int location) +{ + assert(location < this->sampler_map_size); + return this->sampler_map[location]; +} + inline ir_to_mesa_dst_reg ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) { @@ -901,6 +928,21 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) break; /* FINISHME: Fix up uniform name for arrays and things */ + if (ir->var->type->base_type == GLSL_TYPE_SAMPLER) { + /* FINISHME: we whack the location of the var here, which + * is probably not expected. But we need to communicate + * mesa's sampler number to the tex instruction. + */ + int sampler = _mesa_add_sampler(this->prog->Parameters, + ir->var->name, + ir->var->type->gl_type); + map_sampler(ir->var->location, sampler); + + entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_SAMPLER, sampler); + this->variable_storage.push_tail(entry); + break; + } + assert(ir->var->type->gl_type != 0 && ir->var->type->gl_type != GL_INVALID_ENUM); loc = _mesa_add_uniform(this->prog->Parameters, @@ -908,6 +950,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) type_size(ir->var->type) * 4, ir->var->type->gl_type, NULL); + /* Always mark the uniform used at this point. If it isn't * used, dead code elimination should have nuked the decl already. */ @@ -1176,9 +1219,77 @@ ir_to_mesa_visitor::visit(ir_call *ir) void ir_to_mesa_visitor::visit(ir_texture *ir) { - assert(0); + ir_to_mesa_src_reg result_src, coord; + ir_to_mesa_dst_reg result_dst, lod_info; + ir_to_mesa_instruction *inst = NULL; ir->coordinate->accept(this); + coord = this->result; + + /* Storage for our result. Ideally for an assignment we'd be using + * the actual storage for the result here, instead. + */ + result_src = get_temp(glsl_type::vec4_type); + result_dst = ir_to_mesa_dst_reg_from_src(result_src); + + switch (ir->op) { + case ir_tex: + inst = ir_to_mesa_emit_op1(ir, OPCODE_TEX, result_dst, coord); + break; + case ir_txb: + /* Mesa IR stores bias in the last channel of the coords. */ + lod_info = ir_to_mesa_dst_reg_from_src(coord); + lod_info.writemask = WRITEMASK_W; + ir->lod_info.bias->accept(this); + ir_to_mesa_emit_op1(ir, OPCODE_MOV, lod_info, this->result); + + inst = ir_to_mesa_emit_op1(ir, OPCODE_TXB, result_dst, coord); + break; + case ir_txl: + /* Mesa IR stores lod in the last channel of the coords. */ + lod_info = ir_to_mesa_dst_reg_from_src(coord); + lod_info.writemask = WRITEMASK_W; + ir->lod_info.lod->accept(this); + ir_to_mesa_emit_op1(ir, OPCODE_MOV, lod_info, this->result); + + inst = ir_to_mesa_emit_op1(ir, OPCODE_TXL, result_dst, coord); + break; + case ir_txd: + case ir_txf: + assert(!"GLSL 1.30 features unsupported"); + break; + } + + ir_dereference_variable *sampler = ir->sampler->as_dereference_variable(); + assert(sampler); /* FINISHME: sampler arrays */ + /* generate the mapping, remove when we generate storage at + * declaration time + */ + sampler->accept(this); + + inst->sampler = get_sampler_number(sampler->var->location); + + switch (sampler->type->sampler_dimensionality) { + case GLSL_SAMPLER_DIM_1D: + inst->tex_target = TEXTURE_1D_INDEX; + break; + case GLSL_SAMPLER_DIM_2D: + inst->tex_target = TEXTURE_2D_INDEX; + break; + case GLSL_SAMPLER_DIM_3D: + inst->tex_target = TEXTURE_3D_INDEX; + break; + case GLSL_SAMPLER_DIM_CUBE: + inst->tex_target = TEXTURE_CUBE_INDEX; + break; + default: + assert(!"FINISHME: other texture targets"); + } + + assert(!ir->projector); /* FINISHME */ + assert(!ir->shadow_comparitor); /* FINISHME */ + + this->result = result_src; } void @@ -1245,6 +1356,8 @@ ir_to_mesa_visitor::ir_to_mesa_visitor() { result.file = PROGRAM_UNDEFINED; next_temp = 1; + sampler_map = NULL; + sampler_map_size = 0; } static struct prog_src_register @@ -1359,9 +1472,11 @@ print_program(struct prog_instruction *mesa_instructions, static void count_resources(struct gl_program *prog) { + unsigned int i; + prog->InputsRead = 0; prog->OutputsWritten = 0; - unsigned int i; + prog->SamplersUsed = 0; for (i = 0; i < prog->NumInstructions; i++) { struct prog_instruction *inst = &prog->Instructions[i]; @@ -1390,7 +1505,24 @@ count_resources(struct gl_program *prog) break; } } + + /* Instead of just using the uniform's value to map to a + * sampler, Mesa first allocates a separate number for the + * sampler (_mesa_add_sampler), then we reindex it down to a + * small integer (sampler_map[], SamplersUsed), then that gets + * mapped to the uniform's value, and we get an actual sampler. + */ + if (_mesa_is_tex_instruction(inst->Opcode)) { + prog->SamplerTargets[inst->TexSrcUnit] = + (gl_texture_index)inst->TexSrcTarget; + prog->SamplersUsed |= 1 << inst->TexSrcUnit; + if (inst->TexShadow) { + prog->ShadowSamplers |= 1 << inst->TexSrcUnit; + } + } } + + _mesa_update_shader_textures_used(prog); } /* Each stage has some uniforms in its Parameters list. The Uniforms @@ -1474,6 +1606,8 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader) mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); + mesa_inst->TexSrcUnit = inst->sampler; + mesa_inst->TexSrcTarget = inst->tex_target; mesa_instruction_annotation[i] = inst->ir; mesa_inst++; -- cgit v1.2.3 From ba9bd708cb3480817e18cc47e57d83a4e4c305bb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 29 Jun 2010 16:36:42 -0700 Subject: ir_to_mesa: Add support for dFdx, dFdy. --- src/mesa/shader/ir_to_mesa.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index f04518175d1..152cb1d9e55 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -628,6 +628,14 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_unop_cos: ir_to_mesa_emit_scalar_op1(ir, OPCODE_COS, result_dst, op[0]); break; + + case ir_unop_dFdx: + ir_to_mesa_emit_op1(ir, OPCODE_DDX, result_dst, op[0]); + break; + case ir_unop_dFdy: + ir_to_mesa_emit_op1(ir, OPCODE_DDY, result_dst, op[0]); + break; + case ir_binop_add: ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]); break; -- cgit v1.2.3 From 524745bc55dd23c612aebdb545125727bfb16e4d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 29 Jun 2010 16:39:38 -0700 Subject: ir_to_mesa: Add support for ir_unop_abs. --- src/mesa/shader/ir_to_mesa.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 152cb1d9e55..85ede3e3280 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -610,6 +610,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir) op[0].negate = ~op[0].negate; result_src = op[0]; break; + case ir_unop_abs: + ir_to_mesa_emit_op1(ir, OPCODE_ABS, result_dst, op[0]); + break; + case ir_unop_exp: ir_to_mesa_emit_scalar_op1(ir, OPCODE_EXP, result_dst, op[0]); break; -- cgit v1.2.3 From 16b68b1952d0da14b9ce8306efa64988ce46b4b7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 11:05:43 -0700 Subject: glsl2: Move our data from a glsl_shader* on the side to the main gl_shader *. This saves recompiling at link time. gl_shader->ir is made a pointer so that we don't have to bring exec_list into mtypes.h. --- src/glsl/linker.cpp | 48 +++++++++++++-------------- src/glsl/list.h | 19 +++++++++++ src/glsl/main.cpp | 47 +++++++++++++-------------- src/glsl/program.h | 22 ++----------- src/mesa/main/mtypes.h | 3 ++ src/mesa/shader/ir_to_mesa.cpp | 73 +++++++++++++----------------------------- src/mesa/shader/shader_api.c | 8 ++--- 7 files changed, 95 insertions(+), 125 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 8547f74ce65..df71f21b546 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -128,10 +128,10 @@ linker_error_printf(glsl_program *prog, const char *fmt, ...) void -invalidate_variable_locations(glsl_shader *sh, enum ir_variable_mode mode, +invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode, int generic_base) { - foreach_list(node, &sh->ir) { + foreach_list(node, sh->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); if ((var == NULL) || (var->mode != (unsigned) mode)) @@ -187,7 +187,7 @@ count_attribute_slots(const glsl_type *t) */ bool validate_vertex_shader_executable(struct glsl_program *prog, - struct glsl_shader *shader) + struct gl_shader *shader) { if (shader == NULL) return true; @@ -198,7 +198,7 @@ validate_vertex_shader_executable(struct glsl_program *prog, } find_assignment_visitor find("gl_Position"); - find.run(&shader->ir); + find.run(shader->ir); if (!find.variable_found()) { linker_error_printf(prog, "vertex shader does not write to `gl_Position'\n"); @@ -216,7 +216,7 @@ validate_vertex_shader_executable(struct glsl_program *prog, */ bool validate_fragment_shader_executable(struct glsl_program *prog, - struct glsl_shader *shader) + struct gl_shader *shader) { if (shader == NULL) return true; @@ -229,8 +229,8 @@ validate_fragment_shader_executable(struct glsl_program *prog, find_assignment_visitor frag_color("gl_FragColor"); find_assignment_visitor frag_data("gl_FragData"); - frag_color.run(&shader->ir); - frag_data.run(&shader->ir); + frag_color.run(shader->ir); + frag_data.run(shader->ir); if (!frag_color.variable_found() && !frag_data.variable_found()) { linker_error_printf(prog, "fragment shader does not write to " @@ -259,7 +259,7 @@ cross_validate_uniforms(struct glsl_program *prog) */ glsl_symbol_table uniforms; for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { - foreach_list(node, &prog->_LinkedShaders[i]->ir) { + foreach_list(node, prog->_LinkedShaders[i]->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); if ((var == NULL) || (var->mode != ir_var_uniform)) @@ -309,7 +309,7 @@ cross_validate_uniforms(struct glsl_program *prog) */ bool cross_validate_outputs_to_inputs(struct glsl_program *prog, - glsl_shader *producer, glsl_shader *consumer) + gl_shader *producer, gl_shader *consumer) { glsl_symbol_table parameters; /* FINISHME: Figure these out dynamically. */ @@ -318,7 +318,7 @@ cross_validate_outputs_to_inputs(struct glsl_program *prog, /* Find all shader outputs in the "producer" stage. */ - foreach_list(node, &producer->ir) { + foreach_list(node, producer->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); /* FINISHME: For geometry shaders, this should also look for inout @@ -335,7 +335,7 @@ cross_validate_outputs_to_inputs(struct glsl_program *prog, * matching outputs already in the symbol table must have the same type and * qualifiers. */ - foreach_list(node, &consumer->ir) { + foreach_list(node, consumer->ir) { ir_variable *const input = ((ir_instruction *) node)->as_variable(); /* FINISHME: For geometry shaders, this should also look for inout @@ -423,7 +423,7 @@ assign_uniform_locations(struct glsl_program *prog) for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { unsigned next_position = 0; - foreach_list(node, &prog->_LinkedShaders[i]->ir) { + foreach_list(node, prog->_LinkedShaders[i]->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); if ((var == NULL) || (var->mode != ir_var_uniform)) @@ -540,7 +540,7 @@ assign_attribute_locations(glsl_program *prog, unsigned max_attribute_index) unsigned used_locations = (max_attribute_index >= 32) ? ~0 : ~((1 << max_attribute_index) - 1); - glsl_shader *const sh = prog->_LinkedShaders[0]; + gl_shader *const sh = prog->_LinkedShaders[0]; assert(sh->Type == GL_VERTEX_SHADER); /* Operate in a total of four passes. @@ -644,7 +644,7 @@ assign_attribute_locations(glsl_program *prog, unsigned max_attribute_index) unsigned num_attr = 0; - foreach_list(node, &sh->ir) { + foreach_list(node, sh->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); if ((var == NULL) || (var->mode != ir_var_in)) @@ -694,7 +694,7 @@ assign_attribute_locations(glsl_program *prog, unsigned max_attribute_index) void -assign_varying_locations(glsl_shader *producer, glsl_shader *consumer) +assign_varying_locations(gl_shader *producer, gl_shader *consumer) { /* FINISHME: Set dynamically when geometry shader support is added. */ unsigned output_index = VERT_RESULT_VAR0; @@ -714,7 +714,7 @@ assign_varying_locations(glsl_shader *producer, glsl_shader *consumer) invalidate_variable_locations(producer, ir_var_out, VERT_RESULT_VAR0); invalidate_variable_locations(consumer, ir_var_in, FRAG_ATTRIB_VAR0); - foreach_list(node, &producer->ir) { + foreach_list(node, producer->ir) { ir_variable *const output_var = ((ir_instruction *) node)->as_variable(); if ((output_var == NULL) || (output_var->mode != ir_var_out) @@ -740,7 +740,7 @@ assign_varying_locations(glsl_shader *producer, glsl_shader *consumer) input_index++; } - foreach_list(node, &producer->ir) { + foreach_list(node, producer->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); if ((var == NULL) || (var->mode != ir_var_out)) @@ -752,7 +752,7 @@ assign_varying_locations(glsl_shader *producer, glsl_shader *consumer) var->shader_out = (var->location != -1); } - foreach_list(node, &consumer->ir) { + foreach_list(node, consumer->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); if ((var == NULL) || (var->mode != ir_var_in)) @@ -780,13 +780,13 @@ link_shaders(struct glsl_program *prog) /* Separate the shaders into groups based on their type. */ - struct glsl_shader **vert_shader_list; + struct gl_shader **vert_shader_list; unsigned num_vert_shaders = 0; - struct glsl_shader **frag_shader_list; + struct gl_shader **frag_shader_list; unsigned num_frag_shaders = 0; - vert_shader_list = (struct glsl_shader **) - calloc(2 * prog->NumShaders, sizeof(struct glsl_shader *)); + vert_shader_list = (struct gl_shader **) + calloc(2 * prog->NumShaders, sizeof(struct gl_shader *)); frag_shader_list = &vert_shader_list[prog->NumShaders]; for (unsigned i = 0; i < prog->NumShaders; i++) { @@ -817,8 +817,8 @@ link_shaders(struct glsl_program *prog) goto done; - prog->_LinkedShaders = (struct glsl_shader **) - calloc(2, sizeof(struct glsl_shader *)); + prog->_LinkedShaders = (struct gl_shader **) + calloc(2, sizeof(struct gl_shader *)); prog->_NumLinkedShaders = 0; if (num_vert_shaders > 0) { diff --git a/src/glsl/list.h b/src/glsl/list.h index 7732d66d7a6..d449bdd8b12 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -272,6 +272,25 @@ struct exec_list { struct exec_node *tail_pred; #ifdef __cplusplus + /* Callers of this talloc-based new need not call delete. It's + * easier to just talloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *node; + + node = talloc_size(ctx, size); + assert(node != NULL); + + return node; + } + + /* If the user *does* call delete, that's OK, we will just + * talloc_free in that case. */ + static void operator delete(void *node) + { + talloc_free(node); + } + exec_list() { make_empty(); diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index f1dab7b576a..e78af42ac65 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -38,14 +38,13 @@ /* Returned string will have 'ctx' as its talloc owner. */ static char * -load_text_file(void *ctx, const char *file_name, size_t *size) +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 = 0; if (fd < 0) { return NULL; } @@ -70,7 +69,6 @@ load_text_file(void *ctx, const char *file_name, size_t *size) } while (total_read < st.st_size); text[total_read] = '\0'; - *size = total_read; } } @@ -102,7 +100,7 @@ const struct option compiler_opts[] = { }; void -compile_shader(struct glsl_shader *shader) +compile_shader(struct gl_shader *shader) { struct _mesa_glsl_parse_state *state; @@ -145,40 +143,40 @@ compile_shader(struct glsl_shader *shader) printf("\n\n"); } - shader->ir.make_empty(); + shader->ir = new(shader) exec_list; if (!state->error && !state->translation_unit.is_empty()) - _mesa_ast_to_hir(&shader->ir, state); + _mesa_ast_to_hir(shader->ir, state); - validate_ir_tree(&shader->ir); + validate_ir_tree(shader->ir); /* Print out the unoptimized IR. */ if (!state->error && dump_hir) { - _mesa_print_ir(&shader->ir, state); + _mesa_print_ir(shader->ir, state); } /* Optimization passes */ - if (!state->error && !shader->ir.is_empty()) { + if (!state->error && !shader->ir->is_empty()) { bool progress; do { progress = false; - progress = do_function_inlining(&shader->ir) || progress; - progress = do_if_simplification(&shader->ir) || progress; - progress = do_copy_propagation(&shader->ir) || progress; - progress = do_dead_code_local(&shader->ir) || progress; - progress = do_dead_code_unlinked(state, &shader->ir) || progress; - progress = do_constant_variable_unlinked(&shader->ir) || progress; - progress = do_constant_folding(&shader->ir) || progress; - progress = do_vec_index_to_swizzle(&shader->ir) || progress; - progress = do_swizzle_swizzle(&shader->ir) || progress; + progress = do_function_inlining(shader->ir) || progress; + progress = do_if_simplification(shader->ir) || progress; + progress = do_copy_propagation(shader->ir) || progress; + progress = do_dead_code_local(shader->ir) || progress; + progress = do_dead_code_unlinked(state, shader->ir) || progress; + progress = do_constant_variable_unlinked(shader->ir) || progress; + progress = do_constant_folding(shader->ir) || progress; + progress = do_vec_index_to_swizzle(shader->ir) || progress; + progress = do_swizzle_swizzle(shader->ir) || progress; } while (progress); } - validate_ir_tree(&shader->ir); + validate_ir_tree(shader->ir); /* Print out the resulting IR */ if (!state->error && dump_lir) { - _mesa_print_ir(&shader->ir, state); + _mesa_print_ir(shader->ir, state); } shader->symbols = state->symbols; @@ -214,12 +212,12 @@ main(int argc, char **argv) assert(whole_program != NULL); for (/* empty */; argc > optind; optind++) { - whole_program->Shaders = (struct glsl_shader **) + whole_program->Shaders = (struct gl_shader **) talloc_realloc(whole_program, whole_program->Shaders, - struct glsl_shader *, whole_program->NumShaders + 1); + struct gl_shader *, whole_program->NumShaders + 1); assert(whole_program->Shaders != NULL); - struct glsl_shader *shader = talloc_zero(whole_program, glsl_shader); + struct gl_shader *shader = talloc_zero(whole_program, gl_shader); whole_program->Shaders[whole_program->NumShaders] = shader; whole_program->NumShaders++; @@ -238,8 +236,7 @@ main(int argc, char **argv) else usage_fail(argv[0]); - shader->Source = load_text_file(whole_program, - argv[optind], &shader->SourceLen); + shader->Source = load_text_file(whole_program, argv[optind]); if (shader->Source == NULL) { printf("File \"%s\" does not exist.\n", argv[optind]); exit(EXIT_FAILURE); diff --git a/src/glsl/program.h b/src/glsl/program.h index fd8197a45a6..19c3a3e611b 100644 --- a/src/glsl/program.h +++ b/src/glsl/program.h @@ -29,24 +29,6 @@ extern "C" { #include "shader/prog_uniform.h" } -/** - * Based on gl_shader in Mesa's mtypes.h. - */ -struct glsl_shader { - GLenum Type; - GLuint Name; - GLint RefCount; - GLboolean DeletePending; - GLboolean CompileStatus; - const GLchar *Source; /**< Source code string */ - size_t SourceLen; - GLchar *InfoLog; - - struct exec_list ir; - struct glsl_symbol_table *symbols; - struct gl_shader *mesa_shader; -}; - /** * Based on gl_shader_program in Mesa's mtypes.h. */ @@ -57,14 +39,14 @@ struct glsl_program { GLboolean DeletePending; GLuint NumShaders; /**< number of attached shaders */ - struct glsl_shader **Shaders; /**< List of attached the shaders */ + struct gl_shader **Shaders; /**< List of attached the shaders */ /** * Per-stage shaders resulting from the first stage of linking. */ /*@{*/ unsigned _NumLinkedShaders; - struct glsl_shader **_LinkedShaders; + struct gl_shader **_LinkedShaders; /*@}*/ /** User-defined attribute bindings (glBindAttribLocation) */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index c34d9bac4a0..6fc7e29baf9 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1966,6 +1966,9 @@ struct gl_shader struct gl_program *Program; /**< Post-compile assembly code */ GLchar *InfoLog; struct gl_sl_pragmas Pragmas; + + struct exec_list *ir; + struct glsl_symbol_table *symbols; }; diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 85ede3e3280..c2dde312efb 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1561,13 +1561,12 @@ link_uniforms_to_shared_uniform_list(struct gl_uniform_list *uniforms, } struct gl_program * -get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader) +get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) { ir_to_mesa_visitor v; struct prog_instruction *mesa_instructions, *mesa_inst; ir_instruction **mesa_instruction_annotation; int i; - exec_list *instructions = &shader->ir; struct gl_program *prog; GLenum target; @@ -1587,7 +1586,7 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader) v.prog = prog; v.mem_ctx = talloc_new(NULL); - visit_exec_list(instructions, &v); + visit_exec_list(shader->ir, &v); v.ir_to_mesa_emit_op1(NULL, OPCODE_END, ir_to_mesa_undef_dst, ir_to_mesa_undef); @@ -1635,27 +1634,18 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader) prog->Instructions = mesa_instructions; prog->NumInstructions = num_instructions; - _mesa_reference_program(ctx, &shader->mesa_shader->Program, prog); + _mesa_reference_program(ctx, &shader->Program, prog); return prog; } -/* Takes a Mesa gl shader structure and compiles it, returning our Mesa-like - * structure with the IR and such attached. - */ -static struct glsl_shader * -_mesa_get_glsl_shader(GLcontext *ctx, void *mem_ctx, struct gl_shader *sh) +extern "C" { + +void +_mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) { - struct glsl_shader *shader = talloc_zero(mem_ctx, struct glsl_shader); struct _mesa_glsl_parse_state *state; - shader->Type = sh->Type; - shader->Name = sh->Name; - shader->RefCount = 1; - shader->Source = sh->Source; - shader->SourceLen = strlen(sh->Source); - shader->mesa_shader = sh; - state = talloc_zero(shader, struct _mesa_glsl_parse_state); switch (shader->Type) { case GL_VERTEX_SHADER: state->target = vertex_shader; break; @@ -1665,7 +1655,7 @@ _mesa_get_glsl_shader(GLcontext *ctx, void *mem_ctx, struct gl_shader *sh) state->scanner = NULL; state->translation_unit.make_empty(); - state->symbols = new(mem_ctx) glsl_symbol_table; + state->symbols = new(shader) glsl_symbol_table; state->info_log = talloc_strdup(shader, ""); state->error = false; state->temp_index = 0; @@ -1686,25 +1676,25 @@ _mesa_get_glsl_shader(GLcontext *ctx, void *mem_ctx, struct gl_shader *sh) _mesa_glsl_lexer_dtor(state); } - shader->ir.make_empty(); + shader->ir = new(shader) exec_list; if (!state->error && !state->translation_unit.is_empty()) - _mesa_ast_to_hir(&shader->ir, state); + _mesa_ast_to_hir(shader->ir, state); /* Optimization passes */ - if (!state->error && !shader->ir.is_empty()) { + if (!state->error && !shader->ir->is_empty()) { bool progress; do { progress = false; - progress = do_function_inlining(&shader->ir) || progress; - progress = do_if_simplification(&shader->ir) || progress; - progress = do_copy_propagation(&shader->ir) || progress; - progress = do_dead_code_local(&shader->ir) || progress; - progress = do_dead_code_unlinked(state, &shader->ir) || progress; - progress = do_constant_variable_unlinked(&shader->ir) || progress; - progress = do_constant_folding(&shader->ir) || progress; - progress = do_vec_index_to_swizzle(&shader->ir) || progress; - progress = do_swizzle_swizzle(&shader->ir) || progress; + progress = do_function_inlining(shader->ir) || progress; + progress = do_if_simplification(shader->ir) || progress; + progress = do_copy_propagation(shader->ir) || progress; + progress = do_dead_code_local(shader->ir) || progress; + progress = do_dead_code_unlinked(state, shader->ir) || progress; + progress = do_constant_variable_unlinked(shader->ir) || progress; + progress = do_constant_folding(shader->ir) || progress; + progress = do_vec_index_to_swizzle(shader->ir) || progress; + progress = do_swizzle_swizzle(shader->ir) || progress; } while (progress); } @@ -1714,23 +1704,6 @@ _mesa_get_glsl_shader(GLcontext *ctx, void *mem_ctx, struct gl_shader *sh) shader->InfoLog = state->info_log; talloc_free(state); - - return shader; -} - -extern "C" { - -void -_mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *sh) -{ - struct glsl_shader *shader; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - - shader = _mesa_get_glsl_shader(ctx, mem_ctx, sh); - - sh->CompileStatus = shader->CompileStatus; - sh->InfoLog = strdup(shader->InfoLog); - talloc_free(mem_ctx); } void @@ -1738,18 +1711,16 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) { struct glsl_program *whole_program; unsigned int i; - _mesa_clear_shader_program_data(ctx, prog); whole_program = talloc_zero(NULL, struct glsl_program); whole_program->LinkStatus = GL_TRUE; whole_program->NumShaders = prog->NumShaders; - whole_program->Shaders = talloc_array(whole_program, struct glsl_shader *, + whole_program->Shaders = talloc_array(whole_program, struct gl_shader *, prog->NumShaders); for (i = 0; i < prog->NumShaders; i++) { - whole_program->Shaders[i] = _mesa_get_glsl_shader(ctx, whole_program, - prog->Shaders[i]); + whole_program->Shaders[i] = prog->Shaders[i]; if (!whole_program->Shaders[i]->CompileStatus) { whole_program->InfoLog = talloc_asprintf_append(whole_program->InfoLog, diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index a584f6072c4..40b8286a13f 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -44,7 +44,7 @@ #include "shader/prog_uniform.h" #include "shader/shader_api.h" #include "shader/uniforms.h" - +#include "talloc.h" /** * Allocate a new gl_shader_program object, initialize it. @@ -253,7 +253,7 @@ _mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type) { struct gl_shader *shader; assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER); - shader = CALLOC_STRUCT(gl_shader); + shader = talloc_zero(NULL, struct gl_shader); if (shader) { shader->Type = type; shader->Name = name; @@ -268,10 +268,8 @@ _mesa_free_shader(GLcontext *ctx, struct gl_shader *sh) { if (sh->Source) free((void *) sh->Source); - if (sh->InfoLog) - free(sh->InfoLog); _mesa_reference_program(ctx, &sh->Program, NULL); - free(sh); + talloc_free(sh); } -- cgit v1.2.3 From 0eda9ae0a6bcd6a7e014df046c87fac5caee0e9e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 11:51:54 -0700 Subject: glsl2: Make function names and variable names be children of the node. This avoids losing their memory when the parser state is freed. --- src/glsl/ir.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 4eb0e9e33eb..60ee36d17cb 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -733,7 +733,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) mode(ir_var_auto), interpolation(ir_var_smooth), array_lvalue(false) { this->type = type; - this->name = name; + this->name = talloc_strdup(this, name); this->location = -1; this->warn_extension = NULL; this->constant_value = NULL; @@ -820,9 +820,8 @@ ir_function_signature::replace_parameters(exec_list *new_params) ir_function::ir_function(const char *name) - : name(name) { - /* empty */ + this->name = talloc_strdup(this, name); } -- cgit v1.2.3 From 849e18153cd91d812f694b806a84008498860bc3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 11:49:17 -0700 Subject: glsl2: Use Mesa's gl_shader_program instead of our own struct glsl_program. This avoids more allocation and shuffling of data around. --- src/glsl/linker.cpp | 16 ++++++++-------- src/glsl/main.cpp | 4 ++-- src/glsl/program.h | 34 +--------------------------------- src/mesa/main/mtypes.h | 3 +++ src/mesa/shader/ir_to_mesa.cpp | 39 +++++++++++++++++++-------------------- src/mesa/shader/shader_api.c | 6 +++--- 6 files changed, 36 insertions(+), 66 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index df71f21b546..719cae2f274 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -116,7 +116,7 @@ private: void -linker_error_printf(glsl_program *prog, const char *fmt, ...) +linker_error_printf(gl_shader_program *prog, const char *fmt, ...) { va_list ap; @@ -186,7 +186,7 @@ count_attribute_slots(const glsl_type *t) * \param shader Vertex shader executable to be verified */ bool -validate_vertex_shader_executable(struct glsl_program *prog, +validate_vertex_shader_executable(struct gl_shader_program *prog, struct gl_shader *shader) { if (shader == NULL) @@ -215,7 +215,7 @@ validate_vertex_shader_executable(struct glsl_program *prog, * \param shader Fragment shader executable to be verified */ bool -validate_fragment_shader_executable(struct glsl_program *prog, +validate_fragment_shader_executable(struct gl_shader_program *prog, struct gl_shader *shader) { if (shader == NULL) @@ -252,7 +252,7 @@ validate_fragment_shader_executable(struct glsl_program *prog, * Perform validation of uniforms used across multiple shader stages */ bool -cross_validate_uniforms(struct glsl_program *prog) +cross_validate_uniforms(struct gl_shader_program *prog) { /* Examine all of the uniforms in all of the shaders and cross validate * them. @@ -308,7 +308,7 @@ cross_validate_uniforms(struct glsl_program *prog) * Validate that outputs from one stage match inputs of another */ bool -cross_validate_outputs_to_inputs(struct glsl_program *prog, +cross_validate_outputs_to_inputs(struct gl_shader_program *prog, gl_shader *producer, gl_shader *consumer) { glsl_symbol_table parameters; @@ -412,7 +412,7 @@ struct uniform_node { }; void -assign_uniform_locations(struct glsl_program *prog) +assign_uniform_locations(struct gl_shader_program *prog) { /* */ exec_list uniforms; @@ -533,7 +533,7 @@ find_available_slots(unsigned used_mask, unsigned needed_count) bool -assign_attribute_locations(glsl_program *prog, unsigned max_attribute_index) +assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index) { /* Mark invalid attribute locations as being used. */ @@ -767,7 +767,7 @@ assign_varying_locations(gl_shader *producer, gl_shader *consumer) void -link_shaders(struct glsl_program *prog) +link_shaders(struct gl_shader_program *prog) { prog->LinkStatus = false; prog->Validated = false; diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index e78af42ac65..1ed22e1f33b 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -206,9 +206,9 @@ main(int argc, char **argv) if (argc <= optind) usage_fail(argv[0]); - struct glsl_program *whole_program; + struct gl_shader_program *whole_program; - whole_program = talloc_zero (NULL, struct glsl_program); + whole_program = talloc_zero (NULL, struct gl_shader_program); assert(whole_program != NULL); for (/* empty */; argc > optind; optind++) { diff --git a/src/glsl/program.h b/src/glsl/program.h index 19c3a3e611b..bb1cd919cd6 100644 --- a/src/glsl/program.h +++ b/src/glsl/program.h @@ -29,37 +29,5 @@ extern "C" { #include "shader/prog_uniform.h" } -/** - * Based on gl_shader_program in Mesa's mtypes.h. - */ -struct glsl_program { - GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ - GLuint Name; /**< aka handle or ID */ - GLint RefCount; /**< Reference count */ - GLboolean DeletePending; - - GLuint NumShaders; /**< number of attached shaders */ - struct gl_shader **Shaders; /**< List of attached the shaders */ - - /** - * Per-stage shaders resulting from the first stage of linking. - */ - /*@{*/ - unsigned _NumLinkedShaders; - struct gl_shader **_LinkedShaders; - /*@}*/ - - /** User-defined attribute bindings (glBindAttribLocation) */ - struct gl_program_parameter_list *Attributes; - - /* post-link info: */ - struct gl_uniform_list *Uniforms; - struct gl_program_parameter_list *Varying; - GLboolean LinkStatus; /**< GL_LINK_STATUS */ - GLboolean Validated; - GLboolean _Used; /**< Ever used for drawing? */ - GLchar *InfoLog; -}; - extern void -link_shaders(struct glsl_program *prog); +link_shaders(struct gl_shader_program *prog); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 6fc7e29baf9..bc90b1e0441 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2005,6 +2005,9 @@ struct gl_shader_program GLboolean Validated; GLboolean _Used; /**< Ever used for drawing? */ GLchar *InfoLog; + + GLuint _NumLinkedShaders; + struct gl_shader **_LinkedShaders; }; diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index c2dde312efb..f0eb46a3ee1 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1709,48 +1709,49 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) void _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) { - struct glsl_program *whole_program; unsigned int i; + _mesa_clear_shader_program_data(ctx, prog); - whole_program = talloc_zero(NULL, struct glsl_program); - whole_program->LinkStatus = GL_TRUE; - whole_program->NumShaders = prog->NumShaders; - whole_program->Shaders = talloc_array(whole_program, struct gl_shader *, - prog->NumShaders); + prog->LinkStatus = GL_TRUE; for (i = 0; i < prog->NumShaders; i++) { - whole_program->Shaders[i] = prog->Shaders[i]; - if (!whole_program->Shaders[i]->CompileStatus) { - whole_program->InfoLog = - talloc_asprintf_append(whole_program->InfoLog, + if (!prog->Shaders[i]->CompileStatus) { + prog->InfoLog = + talloc_asprintf_append(prog->InfoLog, "linking with uncompiled shader"); - whole_program->LinkStatus = GL_FALSE; + prog->LinkStatus = GL_FALSE; } } - prog->Uniforms = _mesa_new_uniform_list(); prog->Varying = _mesa_new_parameter_list(); _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL); _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL); - if (whole_program->LinkStatus) - link_shaders(whole_program); + if (prog->LinkStatus) { + link_shaders(prog); + + /* We don't use the linker's uniforms list, and cook up our own at + * generate time. + */ + free(prog->Uniforms); + prog->Uniforms = _mesa_new_uniform_list(); + } - prog->LinkStatus = whole_program->LinkStatus; + prog->LinkStatus = prog->LinkStatus; /* FINISHME: This should use the linker-generated code */ if (prog->LinkStatus) { for (i = 0; i < prog->NumShaders; i++) { struct gl_program *linked_prog; - linked_prog = get_mesa_program(ctx, whole_program, - whole_program->Shaders[i]); + linked_prog = get_mesa_program(ctx, prog, + prog->Shaders[i]); count_resources(linked_prog); link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog); - switch (whole_program->Shaders[i]->Type) { + switch (prog->Shaders[i]->Type) { case GL_VERTEX_SHADER: _mesa_reference_vertprog(ctx, &prog->VertexProgram, (struct gl_vertex_program *)linked_prog); @@ -1766,8 +1767,6 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) } } } - - talloc_free(whole_program); } } /* extern "C" */ diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 40b8286a13f..f05ebc9fcb6 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -53,7 +53,7 @@ static struct gl_shader_program * _mesa_new_shader_program(GLcontext *ctx, GLuint name) { struct gl_shader_program *shProg; - shProg = CALLOC_STRUCT(gl_shader_program); + shProg = talloc_zero(NULL, struct gl_shader_program); if (shProg) { shProg->Type = GL_SHADER_PROGRAM_MESA; shProg->Name = name; @@ -117,7 +117,7 @@ _mesa_free_shader_program_data(GLcontext *ctx, } if (shProg->InfoLog) { - free(shProg->InfoLog); + talloc_free(shProg->InfoLog); shProg->InfoLog = NULL; } @@ -139,7 +139,7 @@ _mesa_free_shader_program(GLcontext *ctx, struct gl_shader_program *shProg) { _mesa_free_shader_program_data(ctx, shProg); - free(shProg); + talloc_free(shProg); } -- cgit v1.2.3 From 982e3798d8b9bfec7ff3f37c52687036b36bc153 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 29 Jun 2010 18:58:20 -0700 Subject: linker: Don't automatically allocate VERT_ATTRIB_GENERIC0 --- src/glsl/linker.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 719cae2f274..a53e91d2eff 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -669,6 +669,12 @@ assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index qsort(to_assign, num_attr, sizeof(to_assign[0]), temp_attr::compare); + /* VERT_ATTRIB_GENERIC0 is a psdueo-alias for VERT_ATTRIB_POS. It can only + * be explicitly assigned by via glBindAttribLocation. Mark it as reserved + * to prevent it from being automatically allocated below. + */ + used_locations |= VERT_BIT_GENERIC0; + for (unsigned i = 0; i < num_attr; i++) { /* Mask representing the contiguous slots that will be used by this * attribute. -- cgit v1.2.3 From edcb9c2b062693a5974aa74725f6259023fff794 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 29 Jun 2010 18:23:05 -0700 Subject: ir_to_mesa: Tell Mesa about our choices for vertex attribute locations. --- src/mesa/shader/ir_to_mesa.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index f0eb46a3ee1..75021a70fdb 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1001,6 +1001,15 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_INPUT, ir->var->location); + + if (this->prog->Target == GL_VERTEX_PROGRAM_ARB && + ir->var->location >= VERT_ATTRIB_GENERIC0) { + _mesa_add_attribute(prog->Attributes, + ir->var->name, + type_size(ir->var->type) * 4, + ir->var->type->gl_type, + ir->var->location); + } } else { entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_OUTPUT, -- cgit v1.2.3 From ef5f1948316664055c1444d12076c7d86589a8b9 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 29 Jun 2010 17:58:43 -0700 Subject: linker: Don't dynamically allocate slots for linked shaders The can be at most one shader per stage. There are currently only two stages. There is zero reason to dynamically size this array. --- src/glsl/linker.cpp | 2 -- src/mesa/main/mtypes.h | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index a53e91d2eff..11fccba3786 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -823,8 +823,6 @@ link_shaders(struct gl_shader_program *prog) goto done; - prog->_LinkedShaders = (struct gl_shader **) - calloc(2, sizeof(struct gl_shader *)); prog->_NumLinkedShaders = 0; if (num_vert_shaders > 0) { diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index bc90b1e0441..9a36740c415 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2006,8 +2006,13 @@ struct gl_shader_program GLboolean _Used; /**< Ever used for drawing? */ GLchar *InfoLog; + /** + * Per-stage shaders resulting from the first stage of linking. + */ + /*@{*/ GLuint _NumLinkedShaders; - struct gl_shader **_LinkedShaders; + struct gl_shader *_LinkedShaders[2]; + /*@}*/ }; -- cgit v1.2.3 From 116f1d4f95d8eb0a82b272016590549632c865b3 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 25 Jun 2010 14:10:01 -0700 Subject: glsl2: Steal the live IR and free the rest of the junk. --- src/glsl/main.cpp | 11 +++++++++++ src/mesa/shader/ir_to_mesa.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 1ed22e1f33b..8b2eeaa13ab 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -99,6 +99,12 @@ const struct option compiler_opts[] = { { NULL, 0, NULL, 0 } }; +static void +steal_memory(ir_instruction *ir, void *new_ctx) +{ + talloc_steal(new_ctx, ir); +} + void compile_shader(struct gl_shader *shader) { @@ -187,6 +193,11 @@ compile_shader(struct gl_shader *shader) shader->InfoLog = state->info_log; + /* Retain any live IR, but trash the rest. */ + foreach_list(node, shader->ir) { + visit_tree((ir_instruction *) node, steal_memory, shader); + } + talloc_free(state); return; diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 75021a70fdb..c3de3aae05b 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1650,6 +1650,12 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) extern "C" { +static void +steal_memory(ir_instruction *ir, void *new_ctx) +{ + talloc_steal(new_ctx, ir); +} + void _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) { @@ -1712,6 +1718,11 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) shader->CompileStatus = !state->error; shader->InfoLog = state->info_log; + /* Retain any live IR, but trash the rest. */ + foreach_list(node, shader->ir) { + visit_tree((ir_instruction *) node, steal_memory, shader); + } + talloc_free(state); } -- cgit v1.2.3 From 953ff1283d3d52e6a6b4850c2b0b574111625010 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 25 Jun 2010 13:14:37 -0700 Subject: glsl2: Use _mesa_glsl_parse_state as the talloc parent, not glsl_shader. _mesa_glsl_parse_state should be the parent for all temporary allocation done while compiling a shader. glsl_shader should only be used as the parent for the shader's final IR---the _result_ of compilation. Since many IR instructions may be added or discarded during optimization passes, IR should not ever be allocated to glsl_shader directly. Done via sed -i s/talloc_parent(state)/state/g and s/talloc_parent(st)/st/g. This also removes a ton of talloc_parent calls, which may help performance. --- src/glsl/ast_function.cpp | 10 +-- src/glsl/ast_to_hir.cpp | 22 ++--- src/glsl/glsl_lexer.lpp | 2 +- src/glsl/glsl_parser.ypp | 174 +++++++++++++++++++-------------------- src/glsl/hir_field_selection.cpp | 2 +- src/glsl/ir_reader.cpp | 30 +++---- 6 files changed, 120 insertions(+), 120 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index f3074a362d7..b6811153879 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -59,7 +59,7 @@ process_call(exec_list *instructions, ir_function *f, YYLTYPE *loc, exec_list *actual_parameters, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; const ir_function_signature *sig = f->matching_signature(actual_parameters); @@ -119,7 +119,7 @@ match_function_by_name(exec_list *instructions, const char *name, YYLTYPE *loc, exec_list *actual_parameters, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; ir_function *f = state->symbols->get_function(name); if (f == NULL) { @@ -244,7 +244,7 @@ process_array_constructor(exec_list *instructions, YYLTYPE *loc, exec_list *parameters, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; /* Array constructors come in two forms: sized and unsized. Sized array * constructors look like 'vec4[2](a, b)', where 'a' and 'b' are vec4 * variables. In this case the number of parameters must exactly match the @@ -318,7 +318,7 @@ constant_record_constructor(const glsl_type *constructor_type, YYLTYPE *loc, exec_list *parameters, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; bool all_parameters_are_constant = true; exec_node *node = parameters->head; @@ -862,7 +862,7 @@ ir_rvalue * ast_function_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; /* There are three sorts of function calls. * * 1. contstructors - The first subexpression is an ast_type_specifier. diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index ba292400925..53f17de7b95 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -86,7 +86,7 @@ static bool apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; if (to->base_type == from->type->base_type) return true; @@ -473,7 +473,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, ir_rvalue *lhs, ir_rvalue *rhs, YYLTYPE lhs_loc) { - void *ctx = talloc_parent(state); + void *ctx = state; bool error_emitted = (lhs->type->is_error() || rhs->type->is_error()); if (!error_emitted) { @@ -550,7 +550,7 @@ static ir_variable * generate_temporary(const glsl_type *type, exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; char *name = (char *) malloc(sizeof(char) * 13); snprintf(name, 13, "tmp_%08X", state->temp_index); @@ -600,7 +600,7 @@ ir_rvalue * ast_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; static const int operations[AST_NUM_OPERATORS] = { -1, /* ast_assign doesn't convert to ir_expression. */ -1, /* ast_plus doesn't convert to ir_expression. */ @@ -1544,7 +1544,7 @@ ir_rvalue * ast_declarator_list::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; const struct glsl_type *decl_type; const char *type_name = NULL; ir_rvalue *result = NULL; @@ -1883,7 +1883,7 @@ ir_rvalue * ast_parameter_declarator::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; const struct glsl_type *type; const char *name = NULL; YYLTYPE loc = this->get_location(); @@ -1984,7 +1984,7 @@ ir_rvalue * ast_function::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; ir_function *f = NULL; ir_function_signature *sig = NULL; exec_list hir_parameters; @@ -2152,7 +2152,7 @@ ir_rvalue * ast_jump_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; switch (mode) { case ast_return: { @@ -2255,7 +2255,7 @@ ir_rvalue * ast_selection_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; ir_rvalue *const condition = this->condition->hir(instructions, state); @@ -2295,7 +2295,7 @@ void ast_iteration_statement::condition_to_hir(ir_loop *stmt, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; if (condition != NULL) { ir_rvalue *const cond = @@ -2331,7 +2331,7 @@ ir_rvalue * ast_iteration_statement::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; /* For-loops and while-loops start a new scope, but do-while loops do not. */ diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index fa439f12787..f236a156820 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -313,7 +313,7 @@ precision return PRECISION; [_a-zA-Z][_a-zA-Z0-9]* { struct _mesa_glsl_parse_state *state = yyextra; - void *ctx = talloc_parent(state); + void *ctx = state; yylval->identifier = talloc_strdup(ctx, yytext); return IDENTIFIER; } diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 4132495f403..d894a968ec2 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -255,35 +255,35 @@ variable_identifier: primary_expression: variable_identifier { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.identifier = $1; } | INTCONSTANT { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.int_constant = $1; } | UINTCONSTANT { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.uint_constant = $1; } | FLOATCONSTANT { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.float_constant = $1; } | BOOLCONSTANT { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.bool_constant = $1; @@ -298,7 +298,7 @@ postfix_expression: primary_expression | postfix_expression '[' integer_expression ']' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL); $$->set_location(yylloc); } @@ -314,20 +314,20 @@ postfix_expression: } | postfix_expression '.' IDENTIFIER { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL); $$->set_location(yylloc); $$->primary_expression.identifier = $3; } | postfix_expression INC_OP { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL); $$->set_location(yylloc); } | postfix_expression DEC_OP { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL); $$->set_location(yylloc); } @@ -345,7 +345,7 @@ function_call_or_method: function_call_generic | postfix_expression '.' function_call_generic { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL); $$->set_location(yylloc); } @@ -386,20 +386,20 @@ function_call_header: function_identifier: type_specifier { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_function_expression($1); $$->set_location(yylloc); } | IDENTIFIER { - void *ctx = talloc_parent(state); + void *ctx = state; ast_expression *callee = new(ctx) ast_expression($1); $$ = new(ctx) ast_function_expression(callee); $$->set_location(yylloc); } | FIELD_SELECTION { - void *ctx = talloc_parent(state); + void *ctx = state; ast_expression *callee = new(ctx) ast_expression($1); $$ = new(ctx) ast_function_expression(callee); $$->set_location(yylloc); @@ -411,19 +411,19 @@ unary_expression: postfix_expression | INC_OP unary_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL); $$->set_location(yylloc); } | DEC_OP unary_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL); $$->set_location(yylloc); } | unary_operator unary_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression($1, $2, NULL, NULL); $$->set_location(yylloc); } @@ -441,19 +441,19 @@ multiplicative_expression: unary_expression | multiplicative_expression '*' unary_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3); $$->set_location(yylloc); } | multiplicative_expression '/' unary_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_div, $1, $3); $$->set_location(yylloc); } | multiplicative_expression '%' unary_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3); $$->set_location(yylloc); } @@ -463,13 +463,13 @@ additive_expression: multiplicative_expression | additive_expression '+' multiplicative_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_add, $1, $3); $$->set_location(yylloc); } | additive_expression '-' multiplicative_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3); $$->set_location(yylloc); } @@ -479,13 +479,13 @@ shift_expression: additive_expression | shift_expression LEFT_OP additive_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3); $$->set_location(yylloc); } | shift_expression RIGHT_OP additive_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3); $$->set_location(yylloc); } @@ -495,25 +495,25 @@ relational_expression: shift_expression | relational_expression '<' shift_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_less, $1, $3); $$->set_location(yylloc); } | relational_expression '>' shift_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3); $$->set_location(yylloc); } | relational_expression LE_OP shift_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3); $$->set_location(yylloc); } | relational_expression GE_OP shift_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3); $$->set_location(yylloc); } @@ -523,13 +523,13 @@ equality_expression: relational_expression | equality_expression EQ_OP relational_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3); $$->set_location(yylloc); } | equality_expression NE_OP relational_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3); $$->set_location(yylloc); } @@ -539,7 +539,7 @@ and_expression: equality_expression | and_expression '&' equality_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); $$->set_location(yylloc); } @@ -549,7 +549,7 @@ exclusive_or_expression: and_expression | exclusive_or_expression '^' and_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3); $$->set_location(yylloc); } @@ -559,7 +559,7 @@ inclusive_or_expression: exclusive_or_expression | inclusive_or_expression '|' exclusive_or_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); $$->set_location(yylloc); } @@ -569,7 +569,7 @@ logical_and_expression: inclusive_or_expression | logical_and_expression AND_OP inclusive_or_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3); $$->set_location(yylloc); } @@ -579,7 +579,7 @@ logical_xor_expression: logical_and_expression | logical_xor_expression XOR_OP logical_and_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3); $$->set_location(yylloc); } @@ -589,7 +589,7 @@ logical_or_expression: logical_xor_expression | logical_or_expression OR_OP logical_xor_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3); $$->set_location(yylloc); } @@ -599,7 +599,7 @@ conditional_expression: logical_or_expression | logical_or_expression '?' expression ':' assignment_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5); $$->set_location(yylloc); } @@ -609,7 +609,7 @@ assignment_expression: conditional_expression | unary_expression assignment_operator assignment_expression { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression($2, $1, $3, NULL); $$->set_location(yylloc); } @@ -636,7 +636,7 @@ expression: } | expression ',' assignment_expression { - void *ctx = talloc_parent(state); + void *ctx = state; if ($1->oper != ast_sequence) { $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL); $$->set_location(yylloc); @@ -700,7 +700,7 @@ function_header_with_parameters: function_header: fully_specified_type IDENTIFIER '(' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_function(); $$->set_location(yylloc); $$->return_type = $1; @@ -711,7 +711,7 @@ function_header: parameter_declarator: type_specifier IDENTIFIER { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_parameter_declarator(); $$->set_location(yylloc); $$->type = new(ctx) ast_fully_specified_type(); @@ -721,7 +721,7 @@ parameter_declarator: } | type_specifier IDENTIFIER '[' constant_expression ']' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_parameter_declarator(); $$->set_location(yylloc); $$->type = new(ctx) ast_fully_specified_type(); @@ -748,7 +748,7 @@ parameter_declaration: } | parameter_type_qualifier parameter_qualifier parameter_type_specifier { - void *ctx = talloc_parent(state); + void *ctx = state; $1.i |= $2.i; $$ = new(ctx) ast_parameter_declarator(); @@ -759,7 +759,7 @@ parameter_declaration: } | parameter_qualifier parameter_type_specifier { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_parameter_declarator(); $$->set_location(yylloc); $$->type = new(ctx) ast_fully_specified_type(); @@ -783,7 +783,7 @@ init_declarator_list: single_declaration | init_declarator_list ',' IDENTIFIER { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL); decl->set_location(yylloc); @@ -792,7 +792,7 @@ init_declarator_list: } | init_declarator_list ',' IDENTIFIER '[' ']' { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL); decl->set_location(yylloc); @@ -801,7 +801,7 @@ init_declarator_list: } | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL); decl->set_location(yylloc); @@ -810,7 +810,7 @@ init_declarator_list: } | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7); decl->set_location(yylloc); @@ -819,7 +819,7 @@ init_declarator_list: } | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8); decl->set_location(yylloc); @@ -828,7 +828,7 @@ init_declarator_list: } | init_declarator_list ',' IDENTIFIER '=' initializer { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5); decl->set_location(yylloc); @@ -841,7 +841,7 @@ init_declarator_list: single_declaration: fully_specified_type { - void *ctx = talloc_parent(state); + void *ctx = state; if ($1->specifier->type_specifier != ast_struct) { _mesa_glsl_error(& @1, state, "empty declaration list\n"); YYERROR; @@ -852,7 +852,7 @@ single_declaration: } | fully_specified_type IDENTIFIER { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); $$ = new(ctx) ast_declarator_list($1); @@ -861,7 +861,7 @@ single_declaration: } | fully_specified_type IDENTIFIER '[' ']' { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL); $$ = new(ctx) ast_declarator_list($1); @@ -870,7 +870,7 @@ single_declaration: } | fully_specified_type IDENTIFIER '[' constant_expression ']' { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL); $$ = new(ctx) ast_declarator_list($1); @@ -879,7 +879,7 @@ single_declaration: } | fully_specified_type IDENTIFIER '[' ']' '=' initializer { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6); $$ = new(ctx) ast_declarator_list($1); @@ -888,7 +888,7 @@ single_declaration: } | fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7); $$ = new(ctx) ast_declarator_list($1); @@ -897,7 +897,7 @@ single_declaration: } | fully_specified_type IDENTIFIER '=' initializer { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); $$ = new(ctx) ast_declarator_list($1); @@ -906,7 +906,7 @@ single_declaration: } | INVARIANT IDENTIFIER // Vertex only. { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); $$ = new(ctx) ast_declarator_list(NULL); @@ -920,14 +920,14 @@ single_declaration: fully_specified_type: type_specifier { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_fully_specified_type(); $$->set_location(yylloc); $$->specifier = $1; } | type_qualifier type_specifier { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_fully_specified_type(); $$->set_location(yylloc); $$->qualifier = $1.q; @@ -998,19 +998,19 @@ type_specifier_no_prec: type_specifier_nonarray: basic_type_specifier_nonarray { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_type_specifier($1); $$->set_location(yylloc); } | struct_specifier { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_type_specifier($1); $$->set_location(yylloc); } | IDENTIFIER { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_type_specifier($1); $$->set_location(yylloc); } @@ -1112,13 +1112,13 @@ precision_qualifier: struct_specifier: STRUCT IDENTIFIER '{' struct_declaration_list '}' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_struct_specifier($2, $4); $$->set_location(yylloc); } | STRUCT '{' struct_declaration_list '}' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_struct_specifier(NULL, $3); $$->set_location(yylloc); } @@ -1140,7 +1140,7 @@ struct_declaration_list: struct_declaration: type_specifier struct_declarator_list ';' { - void *ctx = talloc_parent(state); + void *ctx = state; ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); type->set_location(yylloc); @@ -1168,13 +1168,13 @@ struct_declarator_list: struct_declarator: IDENTIFIER { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_declaration($1, false, NULL, NULL); $$->set_location(yylloc); } | IDENTIFIER '[' constant_expression ']' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_declaration($1, true, $3, NULL); $$->set_location(yylloc); } @@ -1217,13 +1217,13 @@ simple_statement: compound_statement: '{' '}' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_compound_statement(true, NULL); $$->set_location(yylloc); } | '{' statement_list '}' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_compound_statement(true, $2); $$->set_location(yylloc); } @@ -1237,13 +1237,13 @@ statement_no_new_scope: compound_statement_no_new_scope: '{' '}' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_compound_statement(false, NULL); $$->set_location(yylloc); } | '{' statement_list '}' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_compound_statement(false, $2); $$->set_location(yylloc); } @@ -1274,13 +1274,13 @@ statement_list: expression_statement: ';' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_statement(NULL); $$->set_location(yylloc); } | expression ';' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_expression_statement($1); $$->set_location(yylloc); } @@ -1289,7 +1289,7 @@ expression_statement: selection_statement_matched: IF '(' expression ')' statement_matched ELSE statement_matched { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_selection_statement($3, $5, $7); $$->set_location(yylloc); } @@ -1298,19 +1298,19 @@ selection_statement_matched: selection_statement_unmatched: IF '(' expression ')' statement_matched { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_selection_statement($3, $5, NULL); $$->set_location(yylloc); } | IF '(' expression ')' statement_unmatched { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_selection_statement($3, $5, NULL); $$->set_location(yylloc); } | IF '(' expression ')' statement_matched ELSE statement_unmatched { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_selection_statement($3, $5, $7); $$->set_location(yylloc); } @@ -1323,7 +1323,7 @@ condition: } | fully_specified_type IDENTIFIER '=' initializer { - void *ctx = talloc_parent(state); + void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); ast_declarator_list *declarator = new(ctx) ast_declarator_list($1); decl->set_location(yylloc); @@ -1346,21 +1346,21 @@ case_label: iteration_statement: WHILE '(' condition ')' statement_no_new_scope { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, NULL, $3, NULL, $5); $$->set_location(yylloc); } | DO statement WHILE '(' expression ')' ';' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, NULL, $5, NULL, $2); $$->set_location(yylloc); } | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, $3, $4.cond, $4.rest, $6); $$->set_location(yylloc); @@ -1397,31 +1397,31 @@ for_rest_statement: jump_statement: CONTINUE ';' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); $$->set_location(yylloc); } | BREAK ';' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); $$->set_location(yylloc); } | RETURN ';' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); $$->set_location(yylloc); } | RETURN expression ';' { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2); $$->set_location(yylloc); } | DISCARD ';' // Fragment shader only. { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); $$->set_location(yylloc); } @@ -1435,7 +1435,7 @@ external_declaration: function_definition: function_prototype compound_statement_no_new_scope { - void *ctx = talloc_parent(state); + void *ctx = state; $$ = new(ctx) ast_function_definition(); $$->set_location(yylloc); $$->prototype = $1; diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp index e2efff60d34..5500e09d7e6 100644 --- a/src/glsl/hir_field_selection.cpp +++ b/src/glsl/hir_field_selection.cpp @@ -33,7 +33,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = talloc_parent(state); + void *ctx = state; ir_rvalue *result = NULL; ir_rvalue *op; diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 03dce0d6849..5ba76e29ea0 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -191,7 +191,7 @@ scan_for_prototypes(_mesa_glsl_parse_state *st, exec_list *instructions, static ir_function * read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() < 3) { ir_read_error(st, list, "Expected (function (signature ...) ...)"); return NULL; @@ -235,7 +235,7 @@ static void read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list, bool skip_body) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 4) { ir_read_error(st, list, "Expected (signature (parameters ...) " "( ...))"); @@ -334,7 +334,7 @@ static ir_instruction * read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, ir_loop *loop_ctx) { - void *ctx = talloc_parent(st); + void *ctx = st; s_symbol *symbol = SX_AS_SYMBOL(expr); if (symbol != NULL) { if (strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL) @@ -376,7 +376,7 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, static ir_variable * read_declaration(_mesa_glsl_parse_state *st, s_list *list) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 4) { ir_read_error(st, list, "expected (declare () " ")"); @@ -448,7 +448,7 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) static ir_if * read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 4) { ir_read_error(st, list, "expected (if ( ...) " "( ...))"); @@ -480,7 +480,7 @@ 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) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 6) { ir_read_error(st, list, "expected (loop " " )"); @@ -508,7 +508,7 @@ read_loop(_mesa_glsl_parse_state *st, s_list *list) static ir_return * read_return(_mesa_glsl_parse_state *st, s_list *list) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 2) { ir_read_error(st, list, "expected (return )"); return NULL; @@ -564,7 +564,7 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) static ir_assignment * read_assignment(_mesa_glsl_parse_state *st, s_list *list) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 4) { ir_read_error(st, list, "expected (assign )"); return NULL; @@ -599,7 +599,7 @@ read_assignment(_mesa_glsl_parse_state *st, s_list *list) static ir_call * read_call(_mesa_glsl_parse_state *st, s_list *list) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 3) { ir_read_error(st, list, "expected (call ( ...))"); return NULL; @@ -644,7 +644,7 @@ read_call(_mesa_glsl_parse_state *st, s_list *list) static ir_expression * read_expression(_mesa_glsl_parse_state *st, s_list *list) { - void *ctx = talloc_parent(st); + void *ctx = st; const unsigned list_length = list->length(); if (list_length < 4) { ir_read_error(st, list, "expected (expression " @@ -749,7 +749,7 @@ read_swizzle(_mesa_glsl_parse_state *st, s_list *list) static ir_constant * read_constant(_mesa_glsl_parse_state *st, s_list *list) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 3) { ir_read_error(st, list, "expected (constant ( ... ))"); return NULL; @@ -840,7 +840,7 @@ read_dereference(_mesa_glsl_parse_state *st, s_expression *expr) static ir_dereference * read_var_ref(_mesa_glsl_parse_state *st, s_list *list) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 2) { ir_read_error(st, list, "expected (var_ref )"); return NULL; @@ -863,7 +863,7 @@ read_var_ref(_mesa_glsl_parse_state *st, s_list *list) static ir_dereference * read_array_ref(_mesa_glsl_parse_state *st, s_list *list) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 3) { ir_read_error(st, list, "expected (array_ref )"); return NULL; @@ -884,7 +884,7 @@ read_array_ref(_mesa_glsl_parse_state *st, s_list *list) static ir_dereference * read_record_ref(_mesa_glsl_parse_state *st, s_list *list) { - void *ctx = talloc_parent(st); + void *ctx = st; if (list->length() != 3) { ir_read_error(st, list, "expected (record_ref )"); return NULL; @@ -920,7 +920,7 @@ valid_texture_list_length(ir_texture_opcode op, s_list *list) static ir_texture * read_texture(_mesa_glsl_parse_state *st, s_list *list) { - void *ctx = talloc_parent(st); + void *ctx = st; s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head); assert(tag != NULL); -- cgit v1.2.3 From c6099a65f8f8310a540f7c19cfc380ad980c9dd7 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 25 Jun 2010 13:36:14 -0700 Subject: glsl2: Create new talloc contexts the "right" way. --- src/glsl/ir_copy_propagation.cpp | 2 +- src/glsl/ir_dead_code_local.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_copy_propagation.cpp b/src/glsl/ir_copy_propagation.cpp index a02852ed0cc..f502f5e0b06 100644 --- a/src/glsl/ir_copy_propagation.cpp +++ b/src/glsl/ir_copy_propagation.cpp @@ -225,7 +225,7 @@ copy_propagation_basic_block(ir_instruction *first, bool *out_progress = (bool *)data; bool progress = false; - void *ctx = talloc(NULL, void*); + void *ctx = talloc_new(NULL); for (ir = first;; ir = (ir_instruction *)ir->next) { ir_assignment *ir_assign = ir->as_assignment(); diff --git a/src/glsl/ir_dead_code_local.cpp b/src/glsl/ir_dead_code_local.cpp index 5e197e19484..7a44ec8a4a4 100644 --- a/src/glsl/ir_dead_code_local.cpp +++ b/src/glsl/ir_dead_code_local.cpp @@ -185,7 +185,7 @@ dead_code_local_basic_block(ir_instruction *first, bool *out_progress = (bool *)data; bool progress = false; - void *ctx = talloc(NULL, void*); + void *ctx = talloc_new(NULL); /* Safe looping, since process_assignment */ for (ir = first, ir_next = (ir_instruction *)first->next;; ir = ir_next, ir_next = (ir_instruction *)ir->next) { -- cgit v1.2.3 From 629198b96a8f471c48932d6af56184b6c33b5fe5 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 29 Jun 2010 11:31:04 -0700 Subject: glsl2: Preprocessed source doesn't need to live past compile time. --- src/glsl/main.cpp | 5 +---- src/mesa/shader/ir_to_mesa.cpp | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 8b2eeaa13ab..fa63853b476 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -129,11 +129,8 @@ compile_shader(struct gl_shader *shader) state->Const.MaxDrawBuffers = 2; - /* Create a new context for the preprocessor output. Ultimately, this - * should probably be the parser context, but there isn't one yet. - */ const char *source = shader->Source; - state->error = preprocess(shader, &source, &state->info_log); + state->error = preprocess(state, &source, &state->info_log); if (!state->error) { _mesa_glsl_lexer_ctor(state, source); diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index c3de3aae05b..4eac810679f 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1679,11 +1679,8 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) state->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; - /* Create a new context for the preprocessor output. Ultimately, this - * should probably be the parser context, but there isn't one yet. - */ const char *source = shader->Source; - state->error = preprocess(shader, &source, &state->info_log); + state->error = preprocess(state, &source, &state->info_log); if (!state->error) { _mesa_glsl_lexer_ctor(state, source); -- cgit v1.2.3 From c7f4ff193a6f7cfae2e4cdc6c4b9162a16226dc0 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 30 Jun 2010 11:57:43 -0700 Subject: glsl2: Fix storing of dead memory in the symbol table. decl->identifier is part of the AST, so it doesn't live very long. Instead, add var->name which is owned by var. --- src/glsl/ast_to_hir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 53f17de7b95..a0ca7e5f6df 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1851,7 +1851,7 @@ ast_declarator_list::hir(exec_list *instructions, "const declaration of `%s' must be initialized"); } - /* Add the vairable to the symbol table after processing the initializer. + /* Add the variable to the symbol table after processing the initializer. * This differs from most C-like languages, but it follows the GLSL * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 * spec: @@ -1861,7 +1861,7 @@ ast_declarator_list::hir(exec_list *instructions, * being declared if not." */ const bool added_variable = - state->symbols->add_variable(decl->identifier, var); + state->symbols->add_variable(var->name, var); assert(added_variable); } -- cgit v1.2.3 From c64da87611823b4b53e93188f861f748a69936a3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 14:01:43 -0700 Subject: ir_to_mesa: Fix the indexing of attributes in the program's Attributes. This fixes GetAttribLocation returning VERT_ATTRIB_GENERIC1 instead of 1, caught by glsl-dlist-getattriblocation. --- src/mesa/shader/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 4eac810679f..c39621bf796 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1008,7 +1008,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) ir->var->name, type_size(ir->var->type) * 4, ir->var->type->gl_type, - ir->var->location); + ir->var->location - VERT_ATTRIB_GENERIC0); } } else { entry = new(mem_ctx) temp_entry(ir->var, -- cgit v1.2.3 From 3e2127b9dea6fd0628c4d7cb9e338d83583d2729 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 14:28:38 -0700 Subject: mesa: Don't look in unallocatd param slots for parameter values. glsl-derivs would add 40.0, 0.0, and 1.0 in order. When we went looking for 0.0, we'd find it in the second slot of the param, and use it, but param->Size would still be 1. When we went to add 1.0 and didn't find it, we'd put allocate it to that second slot and the 0.0 would actualy end up being 1.0. Fixes glsl-derivs, glsl-deriv-varyings. --- src/mesa/shader/prog_parameter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c index aac488c79ab..ddbfe95c152 100644 --- a/src/mesa/shader/prog_parameter.c +++ b/src/mesa/shader/prog_parameter.c @@ -591,7 +591,7 @@ _mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list, if (vSize == 1) { /* look for v[0] anywhere within float[4] value */ GLuint j; - for (j = 0; j < 4; j++) { + for (j = 0; j < list->Parameters[i].Size; j++) { if (list->ParameterValues[i][j] == v[0]) { /* found it */ *posOut = i; -- cgit v1.2.3 From 97eba76b8c5fe60738716c4dce9404de417a7d34 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 14:51:50 -0700 Subject: glsl2: Allow a fragment shader to not write a color. I can't find any text justifying this check, and it caused a reasonable-looking shader in glsl-bug-22603 (which writes only gl_FragDepth) to fail. --- src/glsl/linker.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 11fccba3786..5227d42e353 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -232,12 +232,6 @@ validate_fragment_shader_executable(struct gl_shader_program *prog, frag_color.run(shader->ir); frag_data.run(shader->ir); - if (!frag_color.variable_found() && !frag_data.variable_found()) { - linker_error_printf(prog, "fragment shader does not write to " - "`gl_FragColor' or `gl_FragData'\n"); - return false; - } - if (frag_color.variable_found() && frag_data.variable_found()) { linker_error_printf(prog, "fragment shader writes to both " "`gl_FragColor' and `gl_FragData'\n"); -- cgit v1.2.3 From 88c20c46b8f708e89adef28f341c51ea7883b6a0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 14:55:45 -0700 Subject: ir_to_mesa: Support gl_FragDepth. Fixes glsl-bug-22603. --- src/mesa/shader/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index c39621bf796..ef9a96e2f52 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -222,7 +222,7 @@ static const struct { {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS}, {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE}, {"gl_FragColor", PROGRAM_OUTPUT, FRAG_ATTRIB_COL0}, - {"gl_FragDepth", PROGRAM_UNDEFINED, FRAG_ATTRIB_WPOS}, /* FINISHME: WPOS.z */ + {"gl_FragDepth", PROGRAM_OUTPUT, FRAG_RESULT_DEPTH}, /* 110_deprecated_fs */ {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, -- cgit v1.2.3 From 16efab1c4dee6e6a827ba5f1c482378159545ae5 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 30 Jun 2010 10:47:34 -0700 Subject: glsl2: Define new ir_discard instruction. --- src/glsl/ir.h | 27 +++++++++++++++++++++++++++ src/glsl/ir_clone.cpp | 12 ++++++++++++ src/glsl/ir_constant_expression.cpp | 9 +++++++++ src/glsl/ir_constant_folding.cpp | 8 ++++++++ src/glsl/ir_hierarchical_visitor.cpp | 16 ++++++++++++++++ src/glsl/ir_hierarchical_visitor.h | 2 ++ src/glsl/ir_hv_accept.cpp | 17 +++++++++++++++++ src/glsl/ir_print_visitor.cpp | 14 ++++++++++++++ src/glsl/ir_print_visitor.h | 1 + src/glsl/ir_visitor.h | 1 + src/mesa/shader/ir_to_mesa.cpp | 8 ++++++++ 11 files changed, 115 insertions(+) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 65026ef1f5b..00b0076c172 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -793,6 +793,33 @@ private: /** Loop containing this break instruction. */ ir_loop *loop; }; + +/** + * IR instruction representing discard statements. + */ +class ir_discard : public ir_jump { +public: + ir_discard() + { + this->condition = NULL; + } + + ir_discard(ir_rvalue *cond) + { + this->condition = cond; + } + + virtual ir_instruction *clone(struct hash_table *ht) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_rvalue *condition; +}; /*@}*/ diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 01a1ce3a6d4..74cc858bda4 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -74,6 +74,18 @@ ir_return::clone(struct hash_table *ht) const return new(ctx) ir_return(new_value); } +ir_instruction * +ir_discard::clone(struct hash_table *ht) const +{ + void *ctx = talloc_parent(this); + ir_rvalue *new_condition = NULL; + + if (this->condition != NULL) + new_condition = (ir_rvalue *) this->condition->clone(ht); + + return new(ctx) ir_discard(new_condition); +} + ir_instruction * ir_loop_jump::clone(struct hash_table *ht) const { diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 3408f5256a7..c6348ac4347 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -75,6 +75,7 @@ public: virtual void visit(ir_constant *); virtual void visit(ir_call *); virtual void visit(ir_return *); + virtual void visit(ir_discard *); virtual void visit(ir_if *); virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); @@ -647,6 +648,14 @@ ir_constant_visitor::visit(ir_return *ir) } +void +ir_constant_visitor::visit(ir_discard *ir) +{ + (void) ir; + value = NULL; +} + + void ir_constant_visitor::visit(ir_if *ir) { diff --git a/src/glsl/ir_constant_folding.cpp b/src/glsl/ir_constant_folding.cpp index 342d027bbe8..2daa6fde38d 100644 --- a/src/glsl/ir_constant_folding.cpp +++ b/src/glsl/ir_constant_folding.cpp @@ -68,6 +68,7 @@ public: virtual void visit(ir_constant *); virtual void visit(ir_call *); virtual void visit(ir_return *); + virtual void visit(ir_discard *); virtual void visit(ir_if *); virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); @@ -190,6 +191,13 @@ ir_constant_folding_visitor::visit(ir_return *ir) } +void +ir_constant_folding_visitor::visit(ir_discard *ir) +{ + (void) ir; +} + + void ir_constant_folding_visitor::visit(ir_if *ir) { diff --git a/src/glsl/ir_hierarchical_visitor.cpp b/src/glsl/ir_hierarchical_visitor.cpp index 0d520b127f2..9afb12a4a2b 100644 --- a/src/glsl/ir_hierarchical_visitor.cpp +++ b/src/glsl/ir_hierarchical_visitor.cpp @@ -242,6 +242,22 @@ ir_hierarchical_visitor::visit_leave(ir_return *ir) return visit_continue; } +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_discard *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_discard *ir) +{ + (void) ir; + return visit_continue; +} + ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_if *ir) { diff --git a/src/glsl/ir_hierarchical_visitor.h b/src/glsl/ir_hierarchical_visitor.h index 8b9e49dab13..2c4590d4b10 100644 --- a/src/glsl/ir_hierarchical_visitor.h +++ b/src/glsl/ir_hierarchical_visitor.h @@ -129,6 +129,8 @@ public: virtual ir_visitor_status visit_leave(class ir_call *); virtual ir_visitor_status visit_enter(class ir_return *); virtual ir_visitor_status visit_leave(class ir_return *); + virtual ir_visitor_status visit_enter(class ir_discard *); + virtual ir_visitor_status visit_leave(class ir_discard *); virtual ir_visitor_status visit_enter(class ir_if *); virtual ir_visitor_status visit_leave(class ir_if *); /*@}*/ diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp index f936b3500eb..7b5cc5234c5 100644 --- a/src/glsl/ir_hv_accept.cpp +++ b/src/glsl/ir_hv_accept.cpp @@ -321,6 +321,23 @@ ir_return::accept(ir_hierarchical_visitor *v) } +ir_visitor_status +ir_discard::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (this->condition != NULL) { + s = this->condition->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + return v->visit_leave(this); +} + + ir_visitor_status ir_if::accept(ir_hierarchical_visitor *v) { diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index be5a843f67d..6f867e32532 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -314,6 +314,20 @@ ir_print_visitor::visit(ir_return *ir) } +void +ir_print_visitor::visit(ir_discard *ir) +{ + printf("(discard "); + + if (ir->condition != NULL) { + printf(" "); + ir->condition->accept(this); + } + + printf(")"); +} + + void ir_print_visitor::visit(ir_if *ir) { diff --git a/src/glsl/ir_print_visitor.h b/src/glsl/ir_print_visitor.h index e97b823522a..3db42e24ca3 100644 --- a/src/glsl/ir_print_visitor.h +++ b/src/glsl/ir_print_visitor.h @@ -69,6 +69,7 @@ public: virtual void visit(ir_constant *); virtual void visit(ir_call *); virtual void visit(ir_return *); + virtual void visit(ir_discard *); virtual void visit(ir_if *); virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); diff --git a/src/glsl/ir_visitor.h b/src/glsl/ir_visitor.h index a6f9d2b7ee3..b87d7373180 100644 --- a/src/glsl/ir_visitor.h +++ b/src/glsl/ir_visitor.h @@ -57,6 +57,7 @@ public: virtual void visit(class ir_constant *) = 0; virtual void visit(class ir_call *) = 0; virtual void visit(class ir_return *) = 0; + virtual void visit(class ir_discard *) = 0; virtual void visit(class ir_if *) = 0; virtual void visit(class ir_loop *) = 0; virtual void visit(class ir_loop_jump *) = 0; diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index ef9a96e2f52..8c074a8bd9a 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -134,6 +134,7 @@ public: virtual void visit(ir_constant *); virtual void visit(ir_call *); virtual void visit(ir_return *); + virtual void visit(ir_discard *); virtual void visit(ir_texture *); virtual void visit(ir_if *); /*@}*/ @@ -1321,6 +1322,13 @@ ir_to_mesa_visitor::visit(ir_return *ir) ir->get_value()->accept(this); } +void +ir_to_mesa_visitor::visit(ir_discard *ir) +{ + assert(0); + + ir->condition->accept(this); +} void ir_to_mesa_visitor::visit(ir_if *ir) -- cgit v1.2.3 From 77049a702ad54e09c4102fe8c964e069944f83e5 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 30 Jun 2010 14:11:00 -0700 Subject: glsl2: Implement AST->HIR support for the "discard" instruction. --- src/glsl/ast_to_hir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index a0ca7e5f6df..7d966f848b3 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2206,13 +2206,13 @@ ast_jump_statement::hir(exec_list *instructions, } case ast_discard: - /* FINISHME: discard support */ if (state->target != fragment_shader) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "`discard' may only appear in a fragment shader"); } + instructions->push_tail(new(ctx) ir_discard); break; case ast_break: -- cgit v1.2.3 From 698b84444343189357ad252856d3c5493e47e4fa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 15:26:41 -0700 Subject: ir_to_mesa: When generating a swizzle, respect the reg's current swizzle. Fixes depth-tex-modes-glsl. --- src/mesa/shader/ir_to_mesa.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 8c074a8bd9a..61a1f306c88 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -817,23 +817,23 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) if (i < ir->type->vector_elements) { switch (i) { case 0: - swizzle[i] = ir->mask.x; + swizzle[i] = GET_SWZ(src_reg.swizzle, ir->mask.x); break; case 1: - swizzle[i] = ir->mask.y; + swizzle[i] = GET_SWZ(src_reg.swizzle, ir->mask.y); break; case 2: - swizzle[i] = ir->mask.z; + swizzle[i] = GET_SWZ(src_reg.swizzle, ir->mask.z); break; case 3: - swizzle[i] = ir->mask.w; + swizzle[i] = GET_SWZ(src_reg.swizzle, ir->mask.w); break; } } else { /* If the type is smaller than a vec4, replicate the last * channel out. */ - swizzle[i] = ir->type->vector_elements - 1; + swizzle[i] = swizzle[ir->type->vector_elements - 1]; } } -- cgit v1.2.3 From ea6b34cce4471d6239201101a3b24db17eaae870 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 15:44:01 -0700 Subject: ir_to_mesa: Send the negate field on to Mesa IR. Fixes glsl-fs-neg. --- src/mesa/shader/ir_to_mesa.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 61a1f306c88..8bfa4687a37 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -473,6 +473,7 @@ ir_to_mesa_visitor::get_temp(const glsl_type *type) swizzle[i] = type->vector_elements - 1; src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], swizzle[2], swizzle[3]); + src_reg.negate = 0; return src_reg; } @@ -1399,6 +1400,7 @@ mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) mesa_reg.Index = reg.index; mesa_reg.Swizzle = reg.swizzle; mesa_reg.RelAddr = reg.reladdr; + mesa_reg.Negate = reg.negate; return mesa_reg; } -- cgit v1.2.3 From 285ff93819724b9a858984dc8c30858784a5ee5b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 15:49:04 -0700 Subject: ir_to_mesa: Initialize the (we never use it) abs field of Mesa src regs. --- src/mesa/shader/ir_to_mesa.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 8bfa4687a37..ed1373b6d96 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1401,6 +1401,7 @@ mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) mesa_reg.Swizzle = reg.swizzle; mesa_reg.RelAddr = reg.reladdr; mesa_reg.Negate = reg.negate; + mesa_reg.Abs = 0; return mesa_reg; } -- cgit v1.2.3 From 4e16a7b526bb4736cd11e512009cf6532b2d1dc5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 15:59:07 -0700 Subject: glsl2: Fix up the implementation of fract() for vector types. There's no need to split each vector component out, just do vector ops. --- src/glsl/builtin_function.cpp | 18 +++--------------- src/glsl/builtins/110/fract | 18 +++--------------- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index d248388a1ab..626ba4e2bf3 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -786,29 +786,17 @@ static const char *builtins_110_fract = { " (signature vec2\n" " (parameters\n" " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" - " (return (var_ref t))))\n" + " ((return (expression vec2 - (var_ref x) (expression vec2 floor (var_ref x))))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x)))))\n" - " (return (var_ref t))))\n" + " ((return (expression vec3 - (var_ref x) (expression vec3 floor (var_ref x))))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x)))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float - (swiz w (var_ref x)) (expression float floor (swiz w (var_ref x)))))\n" - " (return (var_ref t))))\n" + " ((return (expression vec4 - (var_ref x) (expression vec4 floor (var_ref x))))))\n" "))\n" "\n" }; diff --git a/src/glsl/builtins/110/fract b/src/glsl/builtins/110/fract index 3995bfaf3f9..46741bb3cb4 100644 --- a/src/glsl/builtins/110/fract +++ b/src/glsl/builtins/110/fract @@ -7,28 +7,16 @@ (signature vec2 (parameters (declare (in) vec2 x)) - ((declare () vec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) - (return (var_ref t)))) + ((return (expression vec2 - (var_ref x) (expression vec2 floor (var_ref x)))))) (signature vec3 (parameters (declare (in) vec3 x)) - ((declare () vec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x))))) - (return (var_ref t)))) + ((return (expression vec3 - (var_ref x) (expression vec3 floor (var_ref x)))))) (signature vec4 (parameters (declare (in) vec4 x)) - ((declare () vec4 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float - (swiz x (var_ref x)) (expression float floor (swiz x (var_ref x))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float - (swiz y (var_ref x)) (expression float floor (swiz y (var_ref x))))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float - (swiz z (var_ref x)) (expression float floor (swiz z (var_ref x))))) - (assign (constant bool (1)) (swiz w (var_ref t)) (expression float - (swiz w (var_ref x)) (expression float floor (swiz w (var_ref x))))) - (return (var_ref t)))) + ((return (expression vec4 - (var_ref x) (expression vec4 floor (var_ref x)))))) )) -- cgit v1.2.3 From e64a4aaacbc682f24180dff3627b84861844476d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 16:18:06 -0700 Subject: ir_to_mesa: Note which of our expr ops are unsupported 1.30 features. --- src/mesa/shader/ir_to_mesa.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index ed1373b6d96..6542441a8c3 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -786,6 +786,17 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_binop_pow: ir_to_mesa_emit_scalar_op2(ir, OPCODE_POW, result_dst, op[0], op[1]); break; + + case ir_unop_bit_not: + case ir_unop_u2f: + case ir_binop_lshift: + case ir_binop_rshift: + case ir_binop_bit_and: + case ir_binop_bit_xor: + case ir_binop_bit_or: + assert(!"GLSL 1.30 features unsupported"); + break; + default: ir_print_visitor v; printf("Failed to get tree for expression:\n"); -- cgit v1.2.3 From 02d615306eb930bd6de9f1503ddd54ee33d3b930 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 16:22:52 -0700 Subject: glsl2: Fix reversed value of step(). It's 0.0 if x < edge, not 1.0. Partial fix for glsl-fs-step. --- src/glsl/builtin_function.cpp | 38 +++++++++++++++++++------------------- src/glsl/builtins/110/step | 38 +++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 626ba4e2bf3..811c5b20ac3 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -2164,15 +2164,15 @@ static const char *builtins_110_step = { " (parameters\n" " (declare (in) float edge)\n" " (declare (in) float x))\n" - " ((return (expression float b2f (expression bool < (var_ref x) (var_ref edge))))))\n" + " ((return (expression float b2f (expression bool >= (var_ref x) (var_ref edge))))))\n" "\n" " (signature vec2\n" " (parameters\n" " (declare (in) float edge)\n" " (declare (in) vec2 x))\n" " ((declare () vec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" " (return (var_ref t))))\n" "\n" " (signature vec3\n" @@ -2180,9 +2180,9 @@ static const char *builtins_110_step = { " (declare (in) float edge)\n" " (declare (in) vec3 x))\n" " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))\n" " (return (var_ref t))))\n" "\n" " (signature vec4\n" @@ -2190,10 +2190,10 @@ static const char *builtins_110_step = { " (declare (in) float edge)\n" " (declare (in) vec4 x))\n" " ((declare () vec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge))))\n" " (return (var_ref t))))\n" "\n" " (signature vec2\n" @@ -2201,8 +2201,8 @@ static const char *builtins_110_step = { " (declare (in) vec2 edge)\n" " (declare (in) vec2 x))\n" " ((declare () vec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" " (return (var_ref t))))\n" "\n" " (signature vec3\n" @@ -2210,9 +2210,9 @@ static const char *builtins_110_step = { " (declare (in) vec3 edge)\n" " (declare (in) vec3 x))\n" " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(swiz z (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))\n" " (return (var_ref t))))\n" "\n" " (signature vec4\n" @@ -2220,10 +2220,10 @@ static const char *builtins_110_step = { " (declare (in) vec4 edge)\n" " (declare (in) vec4 x))\n" " ((declare () vec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz z (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(swiz w (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz z (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(swiz w (var_ref edge)))))\n" " (return (var_ref t))))\n" "))\n" "\n" diff --git a/src/glsl/builtins/110/step b/src/glsl/builtins/110/step index 1cc2b51f8fb..ce6f4354228 100644 --- a/src/glsl/builtins/110/step +++ b/src/glsl/builtins/110/step @@ -3,15 +3,15 @@ (parameters (declare (in) float edge) (declare (in) float x)) - ((return (expression float b2f (expression bool < (var_ref x) (var_ref edge)))))) + ((return (expression float b2f (expression bool >= (var_ref x) (var_ref edge)))))) (signature vec2 (parameters (declare (in) float edge) (declare (in) vec2 x)) ((declare () vec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz 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)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz 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)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz 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)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge))))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz z (var_ref x))(swiz z (var_ref edge))))) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (var_ref t)) (expression float b2f (expression bool < (swiz x (var_ref x))(swiz x (var_ref edge))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz y (var_ref edge))))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool < (swiz y (var_ref x))(swiz z (var_ref edge))))) - (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool < (swiz w (var_ref x))(swiz w (var_ref edge))))) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz z (var_ref edge))))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(swiz w (var_ref edge))))) (return (var_ref t)))) )) -- cgit v1.2.3 From d6ebe9b16b25f25ba763baf3738addc50676d5d0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 16:23:32 -0700 Subject: ir_to_mesa: Add missing no-op type conversions. Fixes glsl-fs-step. --- src/mesa/shader/ir_to_mesa.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 6542441a8c3..af9bdb54828 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -756,6 +756,8 @@ ir_to_mesa_visitor::visit(ir_expression *ir) ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); break; case ir_unop_i2f: + case ir_unop_b2f: + case ir_unop_b2i: /* Mesa IR lacks types, ints are stored as truncated floats. */ result_src = op[0]; break; -- cgit v1.2.3 From e558786a3ed52222c07f916e213b63dcba1890a2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 17:05:11 -0700 Subject: i965: Add support for OPCODE_SSG. The old compiler didn't use SSG, and instead emitted SGT/SGT/SUB. We can do a little better for SSG than we do for the SGT series. --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 20 ++++++++++++++++++++ src/mesa/drivers/dri/i965/brw_wm.h | 4 ++++ src/mesa/drivers/dri/i965/brw_wm_emit.c | 26 ++++++++++++++++++++++++++ src/mesa/drivers/dri/i965/brw_wm_glsl.c | 3 +++ src/mesa/drivers/dri/i965/brw_wm_pass1.c | 1 + 5 files changed, 54 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index 0b44deeb634..128987d78a6 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -485,6 +485,23 @@ static void emit_cmp( struct brw_compile *p, brw_set_predicate_control(p, BRW_PREDICATE_NONE); } +static void emit_sign(struct brw_vs_compile *c, + struct brw_reg dst, + struct brw_reg arg0) +{ + struct brw_compile *p = &c->func; + + brw_MOV(p, dst, brw_imm_f(0)); + + brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0, brw_imm_f(0)); + brw_MOV(p, dst, brw_imm_f(-1.0)); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + + brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_G, arg0, brw_imm_f(0)); + brw_MOV(p, dst, brw_imm_f(1.0)); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); +} + static void emit_max( struct brw_compile *p, struct brw_reg dst, struct brw_reg arg0, @@ -1719,6 +1736,9 @@ void brw_vs_emit(struct brw_vs_compile *c ) case OPCODE_SLE: unalias2(c, dst, args[0], args[1], emit_sle); break; + case OPCODE_SSG: + unalias1(c, dst, args[0], emit_sign); + break; case OPCODE_SUB: brw_ADD(p, dst, args[0], negate(args[1])); break; diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index 277b6de4425..938557ff369 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -425,6 +425,10 @@ void emit_sop(struct brw_compile *p, GLuint cond, const struct brw_reg *arg0, const struct brw_reg *arg1); +void emit_sign(struct brw_compile *p, + const struct brw_reg *dst, + GLuint mask, + const struct brw_reg *arg0); void emit_tex(struct brw_wm_compile *c, struct brw_reg *dst, GLuint dst_flags, diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index 323cfac8fa7..11f482bddf2 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -668,6 +668,28 @@ void emit_cmp(struct brw_compile *p, } } +void emit_sign(struct brw_compile *p, + const struct brw_reg *dst, + GLuint mask, + const struct brw_reg *arg0) +{ + GLuint i; + + for (i = 0; i < 4; i++) { + if (mask & (1< Date: Wed, 30 Jun 2010 17:06:06 -0700 Subject: ir_to_mesa: Add support for ir_unop_sign. Fixes glsl-fs-sign, glsl-vs-sign. --- src/mesa/shader/ir_to_mesa.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index af9bdb54828..b140d96851f 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -615,6 +615,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_unop_abs: ir_to_mesa_emit_op1(ir, OPCODE_ABS, result_dst, op[0]); break; + case ir_unop_sign: + ir_to_mesa_emit_op1(ir, OPCODE_SSG, result_dst, op[0]); + break; case ir_unop_exp: ir_to_mesa_emit_scalar_op1(ir, OPCODE_EXP, result_dst, op[0]); -- cgit v1.2.3 From f5b3b2a01a320d136df3cf1f8c6fa78685d164d1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 17:25:09 -0700 Subject: glsl2: Don't break sign() down by vector components. --- src/glsl/builtin_function.cpp | 19 +++---------------- src/glsl/builtins/110/sign | 19 +++---------------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 811c5b20ac3..b7dbc6b34f5 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -1856,31 +1856,18 @@ static const char *builtins_110_sign = { " (signature vec2\n" " (parameters\n" " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" - " (return (var_ref t))))\n" + " ((return (expression vec2 sign (var_ref x)))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x))))\n" - " (return (var_ref t))))\n" + " ((return (expression vec3 sign (var_ref x)))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float sign (swiz w (var_ref x))))\n" - " (return (var_ref t))))\n" + " ((return (expression vec4 sign (var_ref x)))))\n" "))\n" - "\n" }; static const char *builtins_110_sin = { diff --git a/src/glsl/builtins/110/sign b/src/glsl/builtins/110/sign index 7d540de405b..fa475197cf5 100644 --- a/src/glsl/builtins/110/sign +++ b/src/glsl/builtins/110/sign @@ -7,28 +7,15 @@ (signature vec2 (parameters (declare (in) vec2 x)) - ((declare () vec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) - (return (var_ref t)))) + ((return (expression vec2 sign (var_ref x))))) (signature vec3 (parameters (declare (in) vec3 x)) - ((declare () vec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x)))) - (return (var_ref t)))) + ((return (expression vec3 sign (var_ref x))))) (signature vec4 (parameters (declare (in) vec4 x)) - ((declare () vec4 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x)))) - (assign (constant bool (1)) (swiz w (var_ref t)) (expression float sign (swiz w (var_ref x)))) - (return (var_ref t)))) + ((return (expression vec4 sign (var_ref x))))) )) - -- cgit v1.2.3 From 5e4dd061d17563828bcce5525400a0ce363aa15d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Jun 2010 17:31:06 -0700 Subject: ir_to_mesa: Add support for discard instructions. Fixes glsl-fs-discard-01. --- src/mesa/shader/ir_to_mesa.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index b140d96851f..b270e2da413 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1342,9 +1342,10 @@ ir_to_mesa_visitor::visit(ir_return *ir) void ir_to_mesa_visitor::visit(ir_discard *ir) { - assert(0); + assert(ir->condition == NULL); /* FINISHME */ - ir->condition->accept(this); + ir_to_mesa_emit_op1(ir, OPCODE_KIL_NV, + ir_to_mesa_undef_dst, ir_to_mesa_undef); } void -- cgit v1.2.3 From d925c9173009e9e5d48df30b30aaef22753183aa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Jul 2010 10:37:11 -0700 Subject: glsl2: Add ir_unop_fract as an expression type. Most backends will prefer seeing this to seeing (a - floor(a)), so represent it explicitly. --- src/glsl/builtin_function.cpp | 8 ++++---- src/glsl/builtins/110/fract | 8 ++++---- src/glsl/ir.cpp | 2 ++ src/glsl/ir.h | 1 + src/glsl/ir_constant_expression.cpp | 18 ++++++++++++++++++ src/mesa/shader/ir_to_mesa.cpp | 4 ++++ 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index b7dbc6b34f5..30ba6a52677 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -781,22 +781,22 @@ static const char *builtins_110_fract = { " (signature float\n" " (parameters\n" " (declare (in) float x))\n" - " ((return (expression float - (var_ref x) (expression float floor (var_ref x))))))\n" + " ((return (expression float fract (var_ref x)))))\n" "\n" " (signature vec2\n" " (parameters\n" " (declare (in) vec2 x))\n" - " ((return (expression vec2 - (var_ref x) (expression vec2 floor (var_ref x))))))\n" + " ((return (expression vec2 fract (var_ref x)))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 x))\n" - " ((return (expression vec3 - (var_ref x) (expression vec3 floor (var_ref x))))))\n" + " ((return (expression vec3 fract (var_ref x)))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 x))\n" - " ((return (expression vec4 - (var_ref x) (expression vec4 floor (var_ref x))))))\n" + " ((return (expression vec4 fract (var_ref x)))))\n" "))\n" "\n" }; diff --git a/src/glsl/builtins/110/fract b/src/glsl/builtins/110/fract index 46741bb3cb4..3f0763d1b3e 100644 --- a/src/glsl/builtins/110/fract +++ b/src/glsl/builtins/110/fract @@ -2,21 +2,21 @@ (signature float (parameters (declare (in) float x)) - ((return (expression float - (var_ref x) (expression float floor (var_ref x)))))) + ((return (expression float fract (var_ref x))))) (signature vec2 (parameters (declare (in) vec2 x)) - ((return (expression vec2 - (var_ref x) (expression vec2 floor (var_ref x)))))) + ((return (expression vec2 fract (var_ref x))))) (signature vec3 (parameters (declare (in) vec3 x)) - ((return (expression vec3 - (var_ref x) (expression vec3 floor (var_ref x)))))) + ((return (expression vec3 fract (var_ref x))))) (signature vec4 (parameters (declare (in) vec4 x)) - ((return (expression vec4 - (var_ref x) (expression vec4 floor (var_ref x)))))) + ((return (expression vec4 fract (var_ref x))))) )) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 60ee36d17cb..42578425839 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -72,6 +72,7 @@ ir_expression::get_num_operands(ir_expression_operation op) 1, /* ir_unop_trunc */ 1, /* ir_unop_ceil */ 1, /* ir_unop_floor */ + 1, /* ir_unop_fract */ 1, /* ir_unop_sin */ 1, /* ir_unop_cos */ @@ -137,6 +138,7 @@ static const char *const operator_strs[] = { "trunc", "ceil", "floor", + "fract", "sin", "cos", "dFdx", diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 00b0076c172..f47813786b5 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -528,6 +528,7 @@ enum ir_expression_operation { ir_unop_trunc, ir_unop_ceil, ir_unop_floor, + ir_unop_fract, /*@}*/ /** diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index c6348ac4347..548217cddd9 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -187,6 +187,24 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_fract: + for (c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = 0; + break; + case GLSL_TYPE_INT: + data.i[c] = 0; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c] - floor(op[0]->value.f[c]); + break; + default: + assert(0); + } + } + break; + case ir_unop_neg: for (c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index b270e2da413..2f2096ef97b 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -782,6 +782,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_unop_floor: ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]); break; + case ir_unop_fract: + ir_to_mesa_emit_op1(ir, OPCODE_FRC, result_dst, op[0]); + break; + case ir_binop_min: ir_to_mesa_emit_op2(ir, OPCODE_MIN, result_dst, op[0], op[1]); break; -- cgit v1.2.3 From 9acf618f24428eba72650c0e328e7ed52986728e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Jul 2010 10:52:30 -0700 Subject: glsl2: Remove dead member from dead code visitor. --- src/glsl/ir_dead_code.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp index 51fa96df0cc..ea78107f493 100644 --- a/src/glsl/ir_dead_code.cpp +++ b/src/glsl/ir_dead_code.cpp @@ -67,7 +67,6 @@ public: variable_entry *get_variable_entry(ir_variable *var); bool (*predicate)(ir_instruction *ir); - ir_instruction *base_ir; /* List of variable_entry */ exec_list variable_list; -- cgit v1.2.3 From 8a1f186cc55979bb9df0a88b48da8d81460c3e7c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Jul 2010 10:09:58 -0700 Subject: glsl2: Add a pass to convert mod(a, b) to b * fract(a/b). This is used by the Mesa IR backend to implement mod, fixing glsl-fs-mod. --- src/glsl/Makefile | 1 + src/glsl/ir.h | 9 ++++ src/glsl/ir_hierarchical_visitor.cpp | 7 +-- src/glsl/ir_hierarchical_visitor.h | 12 +++++ src/glsl/ir_hv_accept.cpp | 5 +- src/glsl/ir_mod_to_fract.cpp | 89 ++++++++++++++++++++++++++++++++++++ src/glsl/ir_optimization.h | 1 + src/mesa/shader/ir_to_mesa.cpp | 3 ++ 8 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 src/glsl/ir_mod_to_fract.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index f4e32b91857..a709bf7121e 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -40,6 +40,7 @@ CXX_SOURCES = \ ir_hierarchical_visitor.cpp \ ir_hv_accept.cpp \ ir_if_simplification.cpp \ + ir_mod_to_fract.cpp \ ir_print_visitor.cpp \ ir_reader.cpp \ ir_swizzle_swizzle.cpp \ diff --git a/src/glsl/ir.h b/src/glsl/ir.h index f47813786b5..c19bd417c33 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -551,6 +551,15 @@ enum ir_expression_operation { ir_binop_sub, ir_binop_mul, ir_binop_div, + + /** + * Takes one of two combinations of arguments: + * + * - mod(vecN, vecN) + * - mod(vecN, float) + * + * Does not take integer types. + */ ir_binop_mod, /** diff --git a/src/glsl/ir_hierarchical_visitor.cpp b/src/glsl/ir_hierarchical_visitor.cpp index 9afb12a4a2b..d475df62fce 100644 --- a/src/glsl/ir_hierarchical_visitor.cpp +++ b/src/glsl/ir_hierarchical_visitor.cpp @@ -277,12 +277,7 @@ ir_hierarchical_visitor::visit_leave(ir_if *ir) void ir_hierarchical_visitor::run(exec_list *instructions) { - foreach_list(n, instructions) { - ir_instruction *ir = (ir_instruction *) n; - - if (ir->accept(this) != visit_continue) - break; - } + visit_list_elements(this, instructions); } diff --git a/src/glsl/ir_hierarchical_visitor.h b/src/glsl/ir_hierarchical_visitor.h index 2c4590d4b10..afa780dc912 100644 --- a/src/glsl/ir_hierarchical_visitor.h +++ b/src/glsl/ir_hierarchical_visitor.h @@ -141,6 +141,16 @@ public: */ void run(struct exec_list *instructions); + /* Some visitors may need to insert new variable declarations and + * assignments for portions of a subtree, which means they need a + * pointer to the current instruction in the stream, not just their + * node in the tree rooted at that instruction. + * + * This is implemented by visit_list_elements -- if the visitor is + * not called by it, nothing good will happen. + */ + class ir_instruction *base_ir; + /** * Callback function that is invoked on entry to each node visited. * @@ -161,4 +171,6 @@ void visit_tree(ir_instruction *ir, void (*callback)(class ir_instruction *ir, void *data), void *data); +ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l); + #endif /* IR_HIERARCHICAL_VISITOR_H */ diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp index 7b5cc5234c5..e772018a458 100644 --- a/src/glsl/ir_hv_accept.cpp +++ b/src/glsl/ir_hv_accept.cpp @@ -37,20 +37,23 @@ * from list. However, if nodes are added to the list after the node being * processed, some of the added noded may not be processed. */ -static ir_visitor_status +ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l) { exec_node *next; + ir_instruction *prev_base_ir = v->base_ir; for (exec_node *n = l->head; n->next != NULL; n = next) { next = n->next; ir_instruction *const ir = (ir_instruction *) n; + v->base_ir = ir; ir_visitor_status s = ir->accept(v); if (s != visit_continue) return s; } + v->base_ir = prev_base_ir; return visit_continue; } diff --git a/src/glsl/ir_mod_to_fract.cpp b/src/glsl/ir_mod_to_fract.cpp new file mode 100644 index 00000000000..ec1e65092d9 --- /dev/null +++ b/src/glsl/ir_mod_to_fract.cpp @@ -0,0 +1,89 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_mod_to_floor.cpp + * + * Breaks an ir_unop_mod expression down to (op1 * fract(op0 / op1)) + * + * Many GPUs don't have a MOD instruction (945 and 965 included), and + * if we have to break it down like this anyway, it gives an + * opportunity to do things like constant fold the (1.0 / op1) easily. + */ + +#include "ir.h" + +class ir_mod_to_fract_visitor : public ir_hierarchical_visitor { +public: + ir_mod_to_fract_visitor() + { + this->made_progress = false; + } + + ir_visitor_status visit_leave(ir_expression *); + + bool made_progress; +}; + +bool +do_mod_to_fract(exec_list *instructions) +{ + ir_mod_to_fract_visitor v; + + visit_list_elements(&v, instructions); + return v.made_progress; +} + +ir_visitor_status +ir_mod_to_fract_visitor::visit_leave(ir_expression *ir) +{ + if (ir->operation != ir_binop_mod) + return visit_continue; + + ir_variable *temp = new(ir) ir_variable(ir->operands[1]->type, "mod_b"); + this->base_ir->insert_before(temp); + + ir_assignment *assign; + ir_rvalue *expr; + + assign = new(ir) ir_assignment(new(ir) ir_dereference_variable(temp), + ir->operands[1], NULL); + this->base_ir->insert_before(assign); + + expr = new(ir) ir_expression(ir_binop_div, + ir->operands[0]->type, + ir->operands[0], + new(ir) ir_dereference_variable(temp)); + + expr = new(ir) ir_expression(ir_unop_fract, + ir->operands[0]->type, + expr, + NULL); + + ir->operation = ir_binop_mul; + ir->operands[0] = new(ir) ir_dereference_variable(temp); + ir->operands[1] = expr; + this->made_progress = true; + + return visit_continue; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 147f92176bf..1a8b740566b 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -39,5 +39,6 @@ bool do_dead_code_unlinked(struct _mesa_glsl_parse_state *state, exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_if_simplification(exec_list *instructions); +bool do_mod_to_fract(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); bool do_vec_index_to_swizzle(exec_list *instructions); diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 2f2096ef97b..25267d79b53 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1724,6 +1724,9 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) if (!state->error && !state->translation_unit.is_empty()) _mesa_ast_to_hir(shader->ir, state); + /* Lowering */ + do_mod_to_fract(shader->ir); + /* Optimization passes */ if (!state->error && !shader->ir->is_empty()) { bool progress; -- cgit v1.2.3 From d1b07167b947715577a45b9d9b256c846f3964c6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Jul 2010 10:32:30 -0700 Subject: glsl2: Update README for what I've been thinking about with expr types work. --- src/glsl/README | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/glsl/README b/src/glsl/README index 8b6162ab672..74520321b21 100644 --- a/src/glsl/README +++ b/src/glsl/README @@ -68,7 +68,8 @@ Q: How is the IR structured? A: The best way to get started seeing it would be to run the standalone compiler against a shader: -./glsl --dump-lir ~/src/piglit/tests/shaders/glsl-orangebook-ch06-bump.frag +./glsl_compiler --dump-lir \ + ~/src/piglit/tests/shaders/glsl-orangebook-ch06-bump.frag So for example one of the ir_instructions in main() contains: @@ -151,3 +152,39 @@ significantly by the target architecture. For now, targeting the Mesa IR backend, SSA does not appear to be that important to producing excellent code, but we do expect to do some SSA-based optimizations for the 965 fragment shader backend when that is developed. + +Q: How should I expand instructions that take multiple backend instructions? + +Sometimes you'll have to do the expansion in your code generation -- +see, for example, ir_to_mesa.cpp's handling of ir_binop_mul for +matrices. However, in many cases you'll want to do a pass over the IR +to convert non-native instructions to a series of native instructions. +For example, for the Mesa backend we have ir_div_to_mul_rcp.cpp because +Mesa IR (and many hardware backends) only have a reciprocal +instruction, not a divide. Implementing non-native instructions this +way gives the chance for constant folding to occur, so (a / 2.0) +becomes (a * 0.5) after codegen instead of (a * (1.0 / 2.0)) + +Q: How shoud I handle my special hardware instructions with respect to IR? + +Our current theory is that if multiple targets have an instruction for +some operation, then we should probably be able to represent that in +the IR. Generally this is in the form of an ir_{bin,un}op expression +type. For example, we initially implemented fract() using (a - +floor(a)), but both 945 and 965 have instructions to give that result, +and it would also simplify the implementation of mod(), so +ir_unop_fract was added. The following areas need updating to add a +new expression type: + +ir.h (new enum) +ir.cpp:get_num_operands() (used for ir_reader) +ir.cpp:operator_strs (used for ir_reader) +ir_constant_expression.cpp (you probably want to be able to constant fold) + +You may also need to update the backends if they will see the new expr type: + +../mesa/shaders/ir_to_mesa.cpp + +You can then use the new expression from builtins (if all backends +would rather see it), or scan the IR and convert to use your new +expression type (see ir_mod_to_fract, for example). -- cgit v1.2.3 From 8761fcc2bf964d26c70229c712ce446dbe504ab7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Jul 2010 11:23:02 -0700 Subject: ir_to_mesa: Add support for ir_unop_rcp. This isn't used at the moment, but will be soon. --- src/mesa/shader/ir_to_mesa.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 25267d79b53..dca2b10f23e 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -618,6 +618,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_unop_sign: ir_to_mesa_emit_op1(ir, OPCODE_SSG, result_dst, op[0]); break; + case ir_unop_rcp: + ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[0]); + break; case ir_unop_exp: ir_to_mesa_emit_scalar_op1(ir, OPCODE_EXP, result_dst, op[0]); -- cgit v1.2.3 From 411fb36b7cee223e090b4b9ef9bc14e058201a68 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Jul 2010 11:24:38 -0700 Subject: ir_to_mesa: Fill in remaining ops, remove default case for expression types. We should now have support for all the expression types we need for GLSL 1.20. --- src/mesa/shader/ir_to_mesa.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index dca2b10f23e..1e186354c58 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -694,6 +694,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir) ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[1]); ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], result_src); break; + case ir_binop_mod: + assert(!"ir_binop_mod should have been converted to b * fract(a/b)"); + break; case ir_binop_less: ir_to_mesa_emit_op2(ir, OPCODE_SLT, result_dst, op[0], op[1]); @@ -771,6 +774,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]); break; case ir_unop_f2b: + case ir_unop_i2b: ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, result_src, src_reg_for_float(0.0)); break; @@ -808,13 +812,6 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_binop_bit_or: assert(!"GLSL 1.30 features unsupported"); break; - - default: - ir_print_visitor v; - printf("Failed to get tree for expression:\n"); - ir->accept(&v); - exit(1); - break; } this->result = result_src; -- cgit v1.2.3 From 5466b63968b98c9627b8dd207ea2bebf838b5268 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Jul 2010 12:46:55 -0700 Subject: glsl2: Change order of semaintic checks on variable declarations This will make it easier to support more (valid) kinds of redeclarations. --- src/glsl/ast_to_hir.cpp | 122 ++++++++++++++++++++++++------------------------ 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 7d966f848b3..9d642c1a642 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1636,67 +1636,6 @@ ast_declarator_list::hir(exec_list *instructions, apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc); - /* Attempt to add the variable to the symbol table. If this fails, it - * means the variable has already been declared at this scope. Arrays - * fudge this rule a little bit. - * - * From page 24 (page 30 of the PDF) of the GLSL 1.50 spec, - * - * "It is legal to declare an array without a size and then - * later re-declare the same name as an array of the same - * type and specify a size." - */ - if (state->symbols->name_declared_this_scope(decl->identifier)) { - ir_variable *const earlier = - state->symbols->get_variable(decl->identifier); - - if ((earlier != NULL) - && (earlier->type->array_size() == 0) - && var->type->is_array() - && (var->type->element_type() == earlier->type->element_type())) { - /* FINISHME: This doesn't match the qualifiers on the two - * FINISHME: declarations. It's not 100% clear whether this is - * FINISHME: required or not. - */ - - if (var->type->array_size() <= (int)earlier->max_array_access) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "array size must be > %u due to " - "previous access", - earlier->max_array_access); - } - - earlier->type = var->type; - delete var; - var = NULL; - } else { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "`%s' redeclared", - decl->identifier); - } - - continue; - } - - /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec, - * - * "Identifiers starting with "gl_" are reserved for use by - * OpenGL, and may not be declared in a shader as either a - * variable or a function." - */ - if (strncmp(decl->identifier, "gl_", 3) == 0) { - /* FINISHME: This should only trigger if we're not redefining - * FINISHME: a builtin (to add a qualifier, for example). - */ - _mesa_glsl_error(& loc, state, - "identifier `%s' uses reserved `gl_' prefix", - decl->identifier); - } - - instructions->push_tail(var); - if (state->current_function != NULL) { const char *mode = NULL; const char *extra = ""; @@ -1851,6 +1790,67 @@ ast_declarator_list::hir(exec_list *instructions, "const declaration of `%s' must be initialized"); } + /* Attempt to add the variable to the symbol table. If this fails, it + * means the variable has already been declared at this scope. Arrays + * fudge this rule a little bit. + * + * From page 24 (page 30 of the PDF) of the GLSL 1.50 spec, + * + * "It is legal to declare an array without a size and then + * later re-declare the same name as an array of the same + * type and specify a size." + */ + if (state->symbols->name_declared_this_scope(decl->identifier)) { + ir_variable *const earlier = + state->symbols->get_variable(decl->identifier); + + if ((earlier != NULL) + && (earlier->type->array_size() == 0) + && var->type->is_array() + && (var->type->element_type() == earlier->type->element_type())) { + /* FINISHME: This doesn't match the qualifiers on the two + * FINISHME: declarations. It's not 100% clear whether this is + * FINISHME: required or not. + */ + + if (var->type->array_size() <= (int)earlier->max_array_access) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "array size must be > %u due to " + "previous access", + earlier->max_array_access); + } + + earlier->type = var->type; + delete var; + var = NULL; + } else { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "`%s' redeclared", + decl->identifier); + } + + continue; + } + + /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec, + * + * "Identifiers starting with "gl_" are reserved for use by + * OpenGL, and may not be declared in a shader as either a + * variable or a function." + */ + if (strncmp(decl->identifier, "gl_", 3) == 0) { + /* FINISHME: This should only trigger if we're not redefining + * FINISHME: a builtin (to add a qualifier, for example). + */ + _mesa_glsl_error(& loc, state, + "identifier `%s' uses reserved `gl_' prefix", + decl->identifier); + } + + instructions->push_tail(var); + /* Add the variable to the symbol table after processing the initializer. * This differs from most C-like languages, but it follows the GLSL * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 -- cgit v1.2.3 From cd00d5b88caa41ebf4b407126f314832f9fdae54 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Jul 2010 13:17:54 -0700 Subject: glsl2: Default delcaration of gl_TexCoord is unsized --- src/glsl/ast_to_hir.cpp | 19 ++++++++++++++++++- src/glsl/ir_variable.cpp | 26 ++++++++++++++++---------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 9d642c1a642..22d9f7ad532 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1813,7 +1813,24 @@ ast_declarator_list::hir(exec_list *instructions, * FINISHME: required or not. */ - if (var->type->array_size() <= (int)earlier->max_array_access) { + /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: + * + * "The size [of gl_TexCoord] can be at most + * gl_MaxTextureCoords." + * + * FINISHME: Every platform that supports GLSL sets + * FINISHME: gl_MaxTextureCoords to at least 4, so hard-code 4 + * FINISHME: for now. + */ + if ((strcmp("gl_TexCoord", var->name) == 0) + && (var->type->array_size() > 4)) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "`gl_TexCoord' array size cannot " + "be larger than gl_MaxTextureCoords (%u)\n", + 4); + } else if (var->type->array_size() <= + (int)earlier->max_array_access) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "array size must be > %u due to " diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index ac168142dc6..d43809ef9c2 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -159,13 +159,16 @@ generate_110_vs_variables(exec_list *instructions, } generate_110_uniforms(instructions, state->symbols); - /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports - * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 - * FINISHME: for now. + /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: + * + * "As with all arrays, indices used to subscript gl_TexCoord must + * either be an integral constant expressions, or this array must be + * re-declared by the shader with a size. The size can be at most + * gl_MaxTextureCoords. Using indexes close to 0 may aid the + * implementation in preserving varying resources." */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 4); + glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 0); add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type, instructions, state->symbols); @@ -246,13 +249,16 @@ generate_110_fs_variables(exec_list *instructions, } generate_110_uniforms(instructions, state->symbols); - /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports - * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 - * FINISHME: for now. + /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: + * + * "As with all arrays, indices used to subscript gl_TexCoord must + * either be an integral constant expressions, or this array must be + * re-declared by the shader with a size. The size can be at most + * gl_MaxTextureCoords. Using indexes close to 0 may aid the + * implementation in preserving varying resources." */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 4); + glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 0); add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type, instructions, state->symbols); -- cgit v1.2.3 From 127308b4be077e5bdf60f76320307550921e86bb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Jul 2010 13:30:50 -0700 Subject: glsl2: Add gl_MaxTextureCoords --- src/glsl/ast_to_hir.cpp | 12 ++++-------- src/glsl/glsl_parser_extras.h | 1 + src/glsl/ir_variable.cpp | 31 +++++++++++++++++-------------- src/glsl/main.cpp | 1 + src/mesa/shader/ir_to_mesa.cpp | 1 + 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 22d9f7ad532..fc5a652f25d 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1817,20 +1817,16 @@ ast_declarator_list::hir(exec_list *instructions, * * "The size [of gl_TexCoord] can be at most * gl_MaxTextureCoords." - * - * FINISHME: Every platform that supports GLSL sets - * FINISHME: gl_MaxTextureCoords to at least 4, so hard-code 4 - * FINISHME: for now. */ + const unsigned size = unsigned(var->type->array_size()); if ((strcmp("gl_TexCoord", var->name) == 0) - && (var->type->array_size() > 4)) { + && (size > state->Const.MaxTextureCoords)) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "`gl_TexCoord' array size cannot " "be larger than gl_MaxTextureCoords (%u)\n", - 4); - } else if (var->type->array_size() <= - (int)earlier->max_array_access) { + state->Const.MaxTextureCoords); + } else if (size <= earlier->max_array_access) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "array size must be > %u due to " diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index f957a926be3..3aeba83cc52 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -50,6 +50,7 @@ struct _mesa_glsl_parse_state { */ struct { unsigned MaxDrawBuffers; + unsigned MaxTextureCoords; } Const; /** diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index d43809ef9c2..9daad803e96 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -96,25 +96,28 @@ add_builtin_variable(const builtin_variable *proto, exec_list *instructions, static void generate_110_uniforms(exec_list *instructions, - glsl_symbol_table *symtab) + struct _mesa_glsl_parse_state *state) { for (unsigned i = 0 ; i < Elements(builtin_110_deprecated_uniforms) ; i++) { add_builtin_variable(& builtin_110_deprecated_uniforms[i], - instructions, symtab); + instructions, state->symbols); } - /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_COORDS. Every platform that supports - * FINISHME: GLSL sets GL_MAX_TEXTURE_COORDS to at least 4, so hard-code 4 - * FINISHME: for now. - */ + ir_variable *const mtc = add_variable("gl_MaxTextureCoords", ir_var_auto, + -1, glsl_type::int_type, + instructions, state->symbols); + mtc->constant_value = new(mtc) + ir_constant(int(state->Const.MaxTextureCoords)); + + const glsl_type *const mat4_array_type = - glsl_type::get_array_instance(symtab, glsl_type::mat4_type, 4); + glsl_type::get_array_instance(state->symbols, glsl_type::mat4_type, + state->Const.MaxTextureCoords); add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type, - instructions, symtab); + instructions, state->symbols); /* FINISHME: Add support for gl_DepthRangeParameters */ /* FINISHME: Add support for gl_ClipPlane[] */ @@ -129,11 +132,11 @@ generate_110_uniforms(exec_list *instructions, * FINISHME: at least 8, so hard-code 8 for now. */ const glsl_type *const light_source_array_type = - glsl_type::get_array_instance(symtab, - symtab->get_type("gl_LightSourceParameters"), 8); + glsl_type::get_array_instance(state->symbols, + state->symbols->get_type("gl_LightSourceParameters"), 8); add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type, - instructions, symtab); + instructions, state->symbols); /* FINISHME: Add support for gl_LightModel */ /* FINISHME: Add support for gl_FrontLightProduct[], gl_BackLightProduct[] */ @@ -157,7 +160,7 @@ generate_110_vs_variables(exec_list *instructions, add_builtin_variable(& builtin_110_deprecated_vs_variables[i], instructions, state->symbols); } - generate_110_uniforms(instructions, state->symbols); + generate_110_uniforms(instructions, state); /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: * @@ -247,7 +250,7 @@ generate_110_fs_variables(exec_list *instructions, add_builtin_variable(& builtin_110_deprecated_fs_variables[i], instructions, state->symbols); } - generate_110_uniforms(instructions, state->symbols); + generate_110_uniforms(instructions, state); /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: * diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index fa63853b476..c833c9cde6d 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -128,6 +128,7 @@ compile_shader(struct gl_shader *shader) state->ARB_texture_rectangle_enable = true; state->Const.MaxDrawBuffers = 2; + state->Const.MaxTextureCoords = 4; const char *source = shader->Source; state->error = preprocess(state, &source, &state->info_log); diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 1e186354c58..14abf602af2 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1710,6 +1710,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) state->ARB_texture_rectangle_enable = true; state->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; + state->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits; const char *source = shader->Source; state->error = preprocess(state, &source, &state->info_log); -- cgit v1.2.3 From 12873fa4e332959295154edfe957c0af79af5e74 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Jul 2010 14:10:19 -0700 Subject: glsl2: Don't bounds check unsize array redeclarations This along with several previous commits fix test CorrectUnsizedArray.frag. --- src/glsl/ast_to_hir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index fc5a652f25d..3a7fcf16c52 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1826,7 +1826,7 @@ ast_declarator_list::hir(exec_list *instructions, _mesa_glsl_error(& loc, state, "`gl_TexCoord' array size cannot " "be larger than gl_MaxTextureCoords (%u)\n", state->Const.MaxTextureCoords); - } else if (size <= earlier->max_array_access) { + } else if ((size > 0) && (size <= earlier->max_array_access)) { YYLTYPE loc = this->get_location(); _mesa_glsl_error(& loc, state, "array size must be > %u due to " -- cgit v1.2.3 From 3832706f81d7f5310882eda6d7ef0c3e39593b18 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Jul 2010 17:10:11 -0700 Subject: glsl2: Initialize ast_declarator_list::invariant in constructor --- src/glsl/glsl_parser_extras.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 1d16ef55f57..2e17c4c3372 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -484,6 +484,7 @@ ast_declarator_list::print(void) const ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type) { this->type = type; + this->invariant = false; } void -- cgit v1.2.3 From 6f0823da09384cc1b557385b9e19a9cc7e901ad7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Jul 2010 20:39:08 -0700 Subject: glsl2: Support AST-to-IR translation of invariant keyword --- src/glsl/ast_to_hir.cpp | 84 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 14 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 3a7fcf16c52..3bd0bd65913 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1550,29 +1550,73 @@ ast_declarator_list::hir(exec_list *instructions, ir_rvalue *result = NULL; YYLTYPE loc = this->get_location(); + /* From page 46 (page 52 of the PDF) of the GLSL 1.50 spec: + * + * "To ensure that a particular output variable is invariant, it is + * necessary to use the invariant qualifier. It can either be used to + * qualify a previously declared variable as being invariant + * + * invariant gl_Position; // make existing gl_Position be invariant" + * + * In these cases the parser will set the 'invariant' flag in the declarator + * list, and the type will be NULL. + */ + if (this->invariant) { + assert(this->type == NULL); + + if (state->current_function != NULL) { + _mesa_glsl_error(& loc, state, + "All uses of `invariant' keyword must be at global " + "scope\n"); + } + + foreach_list_typed (ast_declaration, decl, link, &this->declarations) { + assert(!decl->is_array); + assert(decl->array_size == NULL); + assert(decl->initializer == NULL); + + ir_variable *const earlier = + state->symbols->get_variable(decl->identifier); + if (earlier == NULL) { + _mesa_glsl_error(& loc, state, + "Undeclared variable `%s' cannot be marked " + "invariant\n", decl->identifier); + } else if ((state->target == vertex_shader) + && (earlier->mode != ir_var_out)) { + _mesa_glsl_error(& loc, state, + "`%s' cannot be marked invariant, vertex shader " + "outputs only\n", decl->identifier); + } else if ((state->target == fragment_shader) + && (earlier->mode != ir_var_in)) { + _mesa_glsl_error(& loc, state, + "`%s' cannot be marked invariant, fragment shader " + "inputs only\n", decl->identifier); + } else { + earlier->invariant = true; + } + } + + /* Invariant redeclarations do not have r-values. + */ + return NULL; + } + + assert(this->type != NULL); + assert(!this->invariant); + /* The type specifier may contain a structure definition. Process that * before any of the variable declarations. */ (void) this->type->specifier->hir(instructions, state); - /* FINISHME: Handle vertex shader "invariant" declarations that do not - * FINISHME: include a type. These re-declare built-in variables to be - * FINISHME: invariant. - */ - decl_type = this->type->specifier->glsl_type(& type_name, state); if (this->declarations.is_empty()) { - /* There are only two valid cases where the declaration list can be - * empty. - * - * 1. The declaration is setting the default precision of a built-in - * type (e.g., 'precision highp vec4;'). - * - * 2. Adding 'invariant' to an existing vertex shader output. + /* The only valid case where the declaration list can be empty is when + * the declaration is setting the default precision of a built-in type + * (e.g., 'precision highp vec4;'). */ - if (this->type->qualifier.invariant) { - } else if (decl_type != NULL) { + if (decl_type != NULL) { } else { _mesa_glsl_error(& loc, state, "incomplete declaration"); } @@ -1636,6 +1680,18 @@ ast_declarator_list::hir(exec_list *instructions, apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc); + if (this->type->qualifier.invariant) { + if ((state->target == vertex_shader) && !var->shader_out) { + _mesa_glsl_error(& loc, state, + "`%s' cannot be marked invariant, vertex shader " + "outputs only\n", var->name); + } else if ((state->target == fragment_shader) && !var->shader_in) { + _mesa_glsl_error(& loc, state, + "`%s' cannot be marked invariant, fragment shader " + "inputs only\n", var->name); + } + } + if (state->current_function != NULL) { const char *mode = NULL; const char *extra = ""; -- cgit v1.2.3 From 2d1223611700b33aab084f1927bfc1ff1b284115 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 30 Jun 2010 16:03:19 -0700 Subject: glsl2: Define preprocessor tokens for extensions Currently only GL_ARB_draw_buffers and GL_ARB_texture_rectangle are defined because those extensions are always enabled. This make tex_rect-03.frag pass. --- src/glsl/glcpp/glcpp-parse.y | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 6beac18c65d..d4cb006bbcd 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -897,6 +897,8 @@ glcpp_parser_t * glcpp_parser_create (void) { glcpp_parser_t *parser; + token_t *tok; + token_list_t *list; parser = xtalloc (NULL, glcpp_parser_t); @@ -919,6 +921,19 @@ glcpp_parser_create (void) parser->info_log = talloc_strdup(parser, ""); parser->error = 0; + /* Add pre-defined macros. */ + tok = _token_create_ival (parser, INTEGER, 1); + + list = _token_list_create(parser); + _token_list_append(list, tok); + _define_object_macro(parser, NULL, "GL_ARB_draw_buffers", list); + + list = _token_list_create(parser); + _token_list_append(list, tok); + _define_object_macro(parser, NULL, "GL_ARB_texture_rectangle", list); + + talloc_unlink(parser, tok); + return parser; } @@ -1413,7 +1428,8 @@ _define_object_macro (glcpp_parser_t *parser, { macro_t *macro; - _check_for_reserved_macro_name(parser, loc, identifier); + if (loc != NULL) + _check_for_reserved_macro_name(parser, loc, identifier); macro = xtalloc (parser, macro_t); -- cgit v1.2.3 From 06143ea09411aa283ac3633bfbfa4326584cd952 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 30 Jun 2010 16:27:22 -0700 Subject: glsl2: Conditionally define preprocessor tokens for optional extensions The only optional extension currently supported by the compiler is GL_EXT_texture_array. --- src/glsl/glcpp/glcpp-parse.y | 10 +++++++++- src/glsl/glcpp/glcpp.c | 5 +---- src/glsl/glcpp/glcpp.h | 7 +++++-- src/glsl/glcpp/pp.c | 5 +++-- src/glsl/glsl_parser_extras.h | 3 ++- src/glsl/main.cpp | 4 +++- src/mesa/shader/ir_to_mesa.cpp | 3 ++- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index d4cb006bbcd..e5544fe29b8 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -28,6 +28,7 @@ #include #include "glcpp.h" +#include "main/mtypes.h" #define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) #define glcpp_printf(stream, fmt, args...) \ @@ -894,7 +895,7 @@ yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error) } glcpp_parser_t * -glcpp_parser_create (void) +glcpp_parser_create (const struct gl_extensions *extensions) { glcpp_parser_t *parser; token_t *tok; @@ -932,6 +933,13 @@ glcpp_parser_create (void) _token_list_append(list, tok); _define_object_macro(parser, NULL, "GL_ARB_texture_rectangle", list); + if ((extensions != NULL) && extensions->EXT_texture_array) { + list = _token_list_create(parser); + _token_list_append(list, tok); + _define_object_macro(parser, NULL, + "GL_EXT_texture_array", list); + } + talloc_unlink(parser, tok); return parser; diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c index cc87e14950b..a245cb54060 100644 --- a/src/glsl/glcpp/glcpp.c +++ b/src/glsl/glcpp/glcpp.c @@ -68,16 +68,13 @@ load_text_file(void *ctx, const char *file_name) return text; } -int -preprocess(void *talloc_ctx, const char **shader, char **info_log); - int main (void) { void *ctx = talloc(NULL, void*); const char *shader = load_text_file(ctx, NULL); char *info_log = talloc_strdup(ctx, ""); - int ret = preprocess(ctx, &shader, &info_log); + int ret = preprocess(ctx, &shader, &info_log, NULL); printf("%s", shader); fprintf(stderr, "%s", info_log); diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index 2cfa98d2b1d..fc9511a67a8 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -158,8 +158,10 @@ struct glcpp_parser { int error; }; +struct gl_extensions; + glcpp_parser_t * -glcpp_parser_create (void); +glcpp_parser_create (const struct gl_extensions *extensions); int glcpp_parser_parse (glcpp_parser_t *parser); @@ -168,7 +170,8 @@ void glcpp_parser_destroy (glcpp_parser_t *parser); int -preprocess(void *talloc_ctx, const char **shader, char **info_log); +preprocess(void *talloc_ctx, const char **shader, char **info_log, + const struct gl_extensions *extensions); /* Functions for writing to the info log */ diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index a25b7b72a6b..1ce829a2c97 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -134,10 +134,11 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader) } extern int -preprocess(void *talloc_ctx, const char **shader, char **info_log) +preprocess(void *talloc_ctx, const char **shader, char **info_log, + const struct gl_extensions *extensions) { int errors; - glcpp_parser_t *parser = glcpp_parser_create (); + glcpp_parser_t *parser = glcpp_parser_create (extensions); *shader = remove_line_continuations(parser, *shader); glcpp_lex_set_source_string (parser, *shader); diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 3aeba83cc52..dc3d23ac545 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -115,7 +115,8 @@ extern void _mesa_glsl_warning(const YYLTYPE *locp, const char *fmt, ...); extern "C" { -extern int preprocess(void *ctx, const char **shader, char **info_log); +extern int preprocess(void *ctx, const char **shader, char **info_log, + const struct gl_extensions *extensions); } extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index c833c9cde6d..deaab7e0335 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -109,6 +109,7 @@ void compile_shader(struct gl_shader *shader) { struct _mesa_glsl_parse_state *state; + struct gl_extensions ext; state = talloc_zero(talloc_parent(shader), struct _mesa_glsl_parse_state); @@ -127,11 +128,12 @@ compile_shader(struct gl_shader *shader) state->loop_or_switch_nesting = NULL; state->ARB_texture_rectangle_enable = true; + memset(&ext, 0, sizeof(ext)); state->Const.MaxDrawBuffers = 2; state->Const.MaxTextureCoords = 4; const char *source = shader->Source; - state->error = preprocess(state, &source, &state->info_log); + state->error = preprocess(state, &source, &state->info_log, &ext); if (!state->error) { _mesa_glsl_lexer_ctor(state, source); diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 14abf602af2..918004c79f1 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1713,7 +1713,8 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) state->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits; const char *source = shader->Source; - state->error = preprocess(state, &source, &state->info_log); + state->error = preprocess(state, &source, &state->info_log, + &ctx->Extensions); if (!state->error) { _mesa_glsl_lexer_ctor(state, source); -- cgit v1.2.3 From efb6b24223e0bfd29959e131cd308b1e07ff20df Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 30 Jun 2010 16:40:47 -0700 Subject: glsl2: Append _TOK to some parser tokens This prevents conflicts with defines elsewhere in Mesa and allows including mtypes.h in the compiler. --- src/glsl/glsl_lexer.lpp | 6 +++--- src/glsl/glsl_parser.ypp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index f236a156820..ddaa19db722 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -105,7 +105,7 @@ HASH ^{SPC}#{SPC} \n { yylineno++; yycolumn = 0; } attribute return ATTRIBUTE; -const return CONST; +const return CONST_TOK; bool return BOOL; float return FLOAT; int return INT; @@ -272,10 +272,10 @@ packed return PACKED; goto return GOTO; switch return SWITCH; default return DEFAULT; -inline return INLINE; +inline return INLINE_TOK; noinline return NOINLINE; volatile return VOLATILE; -public return PUBLIC; +public return PUBLIC_TOK; static return STATIC; extern return EXTERN; external return EXTERNAL; diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index d894a968ec2..f85b419271d 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -70,7 +70,7 @@ } for_rest_statement; } -%token ATTRIBUTE CONST BOOL FLOAT INT UINT +%token ATTRIBUTE CONST_TOK BOOL FLOAT INT UINT %token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT %token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 %token MAT2 MAT3 MAT4 CENTROID IN OUT INOUT UNIFORM VARYING @@ -101,7 +101,7 @@ /* Reserved words that are not actually used in the grammar. */ %token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED GOTO -%token INLINE NOINLINE VOLATILE PUBLIC STATIC EXTERN EXTERNAL +%token INLINE_TOK NOINLINE VOLATILE PUBLIC_TOK STATIC EXTERN EXTERNAL %token LONG SHORT DOUBLE HALF FIXED UNSIGNED INPUT OUPTUT %token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 %token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW @@ -942,7 +942,7 @@ interpolation_qualifier: ; parameter_type_qualifier: - CONST { $$.i = 0; $$.q.constant = 1; } + CONST_TOK { $$.i = 0; $$.q.constant = 1; } ; type_qualifier: @@ -959,7 +959,7 @@ type_qualifier: ; storage_qualifier: - CONST { $$.i = 0; $$.q.constant = 1; } + CONST_TOK { $$.i = 0; $$.q.constant = 1; } | ATTRIBUTE { $$.i = 0; $$.q.attribute = 1; } | VARYING { $$.i = 0; $$.q.varying = 1; } | CENTROID VARYING { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; } -- cgit v1.2.3 From 667f4e1940c4c4660e35dc9906672a476369660f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 30 Jun 2010 16:42:07 -0700 Subject: glsl2: Conditionally allow optional extensions to be enabled The only optional extension currently supported by the compiler is GL_EXT_texture_array. --- src/glsl/glsl_parser_extras.cpp | 6 ++++++ src/glsl/glsl_parser_extras.h | 3 +++ src/glsl/main.cpp | 1 + src/mesa/shader/ir_to_mesa.cpp | 1 + 4 files changed, 11 insertions(+) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 2e17c4c3372..fc3f9e90b6b 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -27,6 +27,7 @@ extern "C" { #include +#include "main/mtypes.h" } #include "ast.h" @@ -135,6 +136,11 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, } else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) { state->ARB_texture_rectangle_enable = (ext_mode != extension_disable); state->ARB_texture_rectangle_warn = (ext_mode == extension_warn); + } else if (strcmp(name, "GL_EXT_texture_array") == 0) { + state->EXT_texture_array_enable = (ext_mode != extension_disable); + state->EXT_texture_array_warn = (ext_mode == extension_warn); + + unsupported = !state->extensions->EXT_texture_array; } else { unsupported = true; } diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index dc3d23ac545..16f72681816 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -90,6 +90,9 @@ struct _mesa_glsl_parse_state { unsigned EXT_texture_array_enable:1; unsigned EXT_texture_array_warn:1; /*@}*/ + + /** Extensions supported by the OpenGL implementation. */ + const struct gl_extensions *extensions; }; typedef struct YYLTYPE { diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index deaab7e0335..16bbc8cd3f1 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -129,6 +129,7 @@ compile_shader(struct gl_shader *shader) state->ARB_texture_rectangle_enable = true; memset(&ext, 0, sizeof(ext)); + state->extensions = &ext; state->Const.MaxDrawBuffers = 2; state->Const.MaxTextureCoords = 4; diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 918004c79f1..7c7e368d0d5 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1709,6 +1709,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) state->loop_or_switch_nesting = NULL; state->ARB_texture_rectangle_enable = true; + state->extensions = &ctx->Extensions; state->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; state->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits; -- cgit v1.2.3 From 9a0e421983edc31371440c08687fa2bb2207924d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Jul 2010 11:27:06 -0700 Subject: glsl2: Add a pass to break ir_binop_div to _mul and _rcp. This results in constant folding of a constant divisor. --- src/glsl/Makefile | 1 + src/glsl/ir_div_to_mul_rcp.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++ src/glsl/ir_optimization.h | 1 + src/mesa/shader/ir_to_mesa.cpp | 5 ++- 4 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 src/glsl/ir_div_to_mul_rcp.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index a709bf7121e..30ba475d923 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -33,6 +33,7 @@ CXX_SOURCES = \ ir.cpp \ ir_dead_code.cpp \ ir_dead_code_local.cpp \ + ir_div_to_mul_rcp.cpp \ ir_expression_flattening.cpp \ ir_function_can_inline.cpp \ ir_function.cpp \ diff --git a/src/glsl/ir_div_to_mul_rcp.cpp b/src/glsl/ir_div_to_mul_rcp.cpp new file mode 100644 index 00000000000..ce84add2213 --- /dev/null +++ b/src/glsl/ir_div_to_mul_rcp.cpp @@ -0,0 +1,77 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_div_to_mul_rcp.cpp + * + * Breaks an ir_unop_div expression down to op0 * (rcp(op1)). + * + * Many GPUs don't have a divide instruction (945 and 965 included), + * but they do have an RCP instruction to compute an approximate + * reciprocal. By breaking the operation down, constant reciprocals + * can get constant folded. + */ + +#include "ir.h" + +class ir_div_to_mul_rcp_visitor : public ir_hierarchical_visitor { +public: + ir_div_to_mul_rcp_visitor() + { + this->made_progress = false; + } + + ir_visitor_status visit_leave(ir_expression *); + + bool made_progress; +}; + +bool +do_div_to_mul_rcp(exec_list *instructions) +{ + ir_div_to_mul_rcp_visitor v; + + visit_list_elements(&v, instructions); + return v.made_progress; +} + +ir_visitor_status +ir_div_to_mul_rcp_visitor::visit_leave(ir_expression *ir) +{ + if (ir->operation != ir_binop_div) + return visit_continue; + + /* New expression for the 1.0 / op1 */ + ir_rvalue *expr; + expr = new(ir) ir_expression(ir_unop_rcp, + ir->operands[1]->type, + ir->operands[1], + NULL); + + /* op0 / op1 -> op0 * (1.0 / op1) */ + ir->operation = ir_binop_mul; + ir->operands[1] = expr; + this->made_progress = true; + + return visit_continue; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 1a8b740566b..6d02e591c3d 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -37,6 +37,7 @@ bool do_dead_code(struct _mesa_glsl_parse_state *state, bool do_dead_code_local(exec_list *instructions); bool do_dead_code_unlinked(struct _mesa_glsl_parse_state *state, exec_list *instructions); +bool do_div_to_mul_rcp(exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_if_simplification(exec_list *instructions); bool do_mod_to_fract(exec_list *instructions); diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 7c7e368d0d5..d5664e7b91e 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -691,9 +691,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) } break; case ir_binop_div: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[1]); - ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], result_src); - break; + assert(!"not reached: should be handled by ir_div_to_mul_rcp"); case ir_binop_mod: assert(!"ir_binop_mod should have been converted to b * fract(a/b)"); break; @@ -1729,6 +1727,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) /* Lowering */ do_mod_to_fract(shader->ir); + do_div_to_mul_rcp(shader->ir); /* Optimization passes */ if (!state->error && !shader->ir->is_empty()) { -- cgit v1.2.3 From 28faa12dc2413d93c7f4778327a5e7c4c8f57c85 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Jul 2010 11:37:39 -0700 Subject: ir_to_mesa: Don't forget to run the Mesa IR optimization passes. With how we generate assignments, the trivial copy propagation in it is really important, and some drivers will really want the register allocation, too. --- src/mesa/shader/ir_to_mesa.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index d5664e7b91e..11fb7b9f16a 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -44,6 +44,7 @@ extern "C" { #include "main/mtypes.h" #include "shader/prog_instruction.h" +#include "shader/prog_optimize.h" #include "shader/prog_print.h" #include "shader/program.h" #include "shader/prog_uniform.h" @@ -1675,6 +1676,10 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) _mesa_reference_program(ctx, &shader->Program, prog); + if ((ctx->Shader.Flags & GLSL_NO_OPT) == 0) { + _mesa_optimize_program(ctx, prog); + } + return prog; } -- cgit v1.2.3 From cab95c228b12f0fc568164d57475c561c8d6053e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Jul 2010 14:06:34 -0700 Subject: ir_to_mesa: Fix sparse swizzling of src regs when a writemask is present. Fixes glsl-fs-texture2d-masked. --- src/mesa/shader/ir_to_mesa.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 11fb7b9f16a..59268e6d176 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1175,6 +1175,29 @@ get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) return dst_reg; } +static GLuint +reswizzle_for_writemask(GLuint writemask, GLuint swizzle) +{ + int new_swizzle[4], pos = 0; + int i; + + /* reswizzle the rhs so the components are in place for the + * components we'll assign to the lhs. + */ + for (i = 0; i < 4; i++) { + if (writemask & (1 << i)) { + new_swizzle[i] = GET_SWZ(swizzle, pos++); + } else { + new_swizzle[i] = GET_SWZ(swizzle, 0); + } + } + + return MAKE_SWIZZLE4(new_swizzle[0], + new_swizzle[1], + new_swizzle[2], + new_swizzle[3]); +} + void ir_to_mesa_visitor::visit(ir_assignment *ir) { @@ -1189,6 +1212,9 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) ir->rhs->accept(this); r = this->result; + + r.swizzle = reswizzle_for_writemask(l.writemask, r.swizzle); + assert(l.file != PROGRAM_UNDEFINED); assert(r.file != PROGRAM_UNDEFINED); -- cgit v1.2.3 From de75dfac4ea2cad64dc91f6ac16fe205b5015af6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Jul 2010 14:49:29 -0700 Subject: ir_to_mesa: Add support for projected non-shadow/bias/lod texturing. Fixes: glsl-fs-texture2dproj glsl-fs-texture2dproj-2 --- src/mesa/shader/ir_to_mesa.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 59268e6d176..96f3cd7e4d9 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1287,13 +1287,18 @@ ir_to_mesa_visitor::visit(ir_call *ir) void ir_to_mesa_visitor::visit(ir_texture *ir) { - ir_to_mesa_src_reg result_src, coord; + ir_to_mesa_src_reg result_src, coord, projector; ir_to_mesa_dst_reg result_dst, lod_info; ir_to_mesa_instruction *inst = NULL; ir->coordinate->accept(this); coord = this->result; + if (ir->projector) { + ir->projector->accept(this); + projector = this->result; + } + /* Storage for our result. Ideally for an assignment we'd be using * the actual storage for the result here, instead. */ @@ -1302,7 +1307,16 @@ ir_to_mesa_visitor::visit(ir_texture *ir) switch (ir->op) { case ir_tex: - inst = ir_to_mesa_emit_op1(ir, OPCODE_TEX, result_dst, coord); + if (ir->projector) { + /* Compute new coord as vec4(texcoord.xyz, projector) */ + ir_to_mesa_emit_op1(ir, OPCODE_MOV, result_dst, coord); + result_dst.writemask = WRITEMASK_W; + ir_to_mesa_emit_op1(ir, OPCODE_MOV, result_dst, projector); + result_dst.writemask = WRITEMASK_XYZW; + inst = ir_to_mesa_emit_op1(ir, OPCODE_TXP, result_dst, result_src); + } else { + inst = ir_to_mesa_emit_op1(ir, OPCODE_TEX, result_dst, coord); + } break; case ir_txb: /* Mesa IR stores bias in the last channel of the coords. */ @@ -1312,6 +1326,7 @@ ir_to_mesa_visitor::visit(ir_texture *ir) ir_to_mesa_emit_op1(ir, OPCODE_MOV, lod_info, this->result); inst = ir_to_mesa_emit_op1(ir, OPCODE_TXB, result_dst, coord); + assert(!ir->projector); /* FINISHME */ break; case ir_txl: /* Mesa IR stores lod in the last channel of the coords. */ @@ -1321,6 +1336,7 @@ ir_to_mesa_visitor::visit(ir_texture *ir) ir_to_mesa_emit_op1(ir, OPCODE_MOV, lod_info, this->result); inst = ir_to_mesa_emit_op1(ir, OPCODE_TXL, result_dst, coord); + assert(!ir->projector); /* FINISHME */ break; case ir_txd: case ir_txf: @@ -1354,7 +1370,6 @@ ir_to_mesa_visitor::visit(ir_texture *ir) assert(!"FINISHME: other texture targets"); } - assert(!ir->projector); /* FINISHME */ assert(!ir->shadow_comparitor); /* FINISHME */ this->result = result_src; -- cgit v1.2.3 From 4d962e66e319191d5b94291b6f55d720df71130a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Jul 2010 14:43:01 -0700 Subject: glsl2: Print the linking info log in the stand-alone compiler --- src/glsl/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 16bbc8cd3f1..9bed2c6bccc 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -266,6 +266,9 @@ main(int argc, char **argv) if ((status == EXIT_SUCCESS) && do_link) { link_shaders(whole_program); status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE; + + if (strlen(whole_program->InfoLog) > 0) + printf("Info log for linking:\n%s\n", whole_program->InfoLog); } talloc_free(whole_program); -- cgit v1.2.3 From d3983ca03248092d92b5240fbc6a30c24f80d313 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Jul 2010 15:37:24 -0700 Subject: ir_to_mesa: Move projection handling out of ir_tex so txb and txl get it. Fixes: glsl-fs-texture2dproj-bias glsl-fs-texture2dproj-bias-2 --- src/mesa/shader/ir_to_mesa.cpp | 80 ++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 27 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 96f3cd7e4d9..53e5242b10b 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1287,12 +1287,22 @@ ir_to_mesa_visitor::visit(ir_call *ir) void ir_to_mesa_visitor::visit(ir_texture *ir) { - ir_to_mesa_src_reg result_src, coord, projector; - ir_to_mesa_dst_reg result_dst, lod_info; + ir_to_mesa_src_reg result_src, coord, lod_info, projector; + ir_to_mesa_dst_reg result_dst, coord_dst; ir_to_mesa_instruction *inst = NULL; + prog_opcode opcode = OPCODE_NOP; ir->coordinate->accept(this); - coord = this->result; + + /* Put our coords in a temp. We'll need to modify them for shadow, + * projection, or LOD, so the only case we'd use it as is is if + * we're doing plain old texturing. Mesa IR optimization should + * handle cleaning up our mess in that case. + */ + coord = get_temp(glsl_type::vec4_type); + coord_dst = ir_to_mesa_dst_reg_from_src(coord); + ir_to_mesa_emit_op1(ir, OPCODE_MOV, coord_dst, + this->result); if (ir->projector) { ir->projector->accept(this); @@ -1307,36 +1317,17 @@ ir_to_mesa_visitor::visit(ir_texture *ir) switch (ir->op) { case ir_tex: - if (ir->projector) { - /* Compute new coord as vec4(texcoord.xyz, projector) */ - ir_to_mesa_emit_op1(ir, OPCODE_MOV, result_dst, coord); - result_dst.writemask = WRITEMASK_W; - ir_to_mesa_emit_op1(ir, OPCODE_MOV, result_dst, projector); - result_dst.writemask = WRITEMASK_XYZW; - inst = ir_to_mesa_emit_op1(ir, OPCODE_TXP, result_dst, result_src); - } else { - inst = ir_to_mesa_emit_op1(ir, OPCODE_TEX, result_dst, coord); - } + opcode = OPCODE_TEX; break; case ir_txb: - /* Mesa IR stores bias in the last channel of the coords. */ - lod_info = ir_to_mesa_dst_reg_from_src(coord); - lod_info.writemask = WRITEMASK_W; + opcode = OPCODE_TXB; ir->lod_info.bias->accept(this); - ir_to_mesa_emit_op1(ir, OPCODE_MOV, lod_info, this->result); - - inst = ir_to_mesa_emit_op1(ir, OPCODE_TXB, result_dst, coord); - assert(!ir->projector); /* FINISHME */ + lod_info = this->result; break; case ir_txl: - /* Mesa IR stores lod in the last channel of the coords. */ - lod_info = ir_to_mesa_dst_reg_from_src(coord); - lod_info.writemask = WRITEMASK_W; + opcode = OPCODE_TXL; ir->lod_info.lod->accept(this); - ir_to_mesa_emit_op1(ir, OPCODE_MOV, lod_info, this->result); - - inst = ir_to_mesa_emit_op1(ir, OPCODE_TXL, result_dst, coord); - assert(!ir->projector); /* FINISHME */ + lod_info = this->result; break; case ir_txd: case ir_txf: @@ -1344,6 +1335,41 @@ ir_to_mesa_visitor::visit(ir_texture *ir) break; } + if (ir->projector) { + if (opcode == OPCODE_TEX) { + /* Slot the projector in as the last component of the coord. */ + coord_dst.writemask = WRITEMASK_W; + ir_to_mesa_emit_op1(ir, OPCODE_MOV, coord_dst, projector); + coord_dst.writemask = WRITEMASK_XYZW; + opcode = OPCODE_TXP; + } else { + ir_to_mesa_src_reg coord_w = coord; + coord_w.swizzle = SWIZZLE_WWWW; + + /* For the other TEX opcodes there's no projective version + * since the last slot is taken up by lod info. Do the + * projective divide now. + */ + coord_dst.writemask = WRITEMASK_W; + ir_to_mesa_emit_op1(ir, OPCODE_RCP, coord_dst, projector); + + coord_dst.writemask = WRITEMASK_XYZ; + ir_to_mesa_emit_op2(ir, OPCODE_MUL, coord_dst, coord, coord_w); + + coord_dst.writemask = WRITEMASK_XYZW; + coord.swizzle = SWIZZLE_XYZW; + } + } + + if (opcode == OPCODE_TXL || opcode == OPCODE_TXB) { + /* Mesa IR stores lod or lod bias in the last channel of the coords. */ + coord_dst.writemask = WRITEMASK_W; + ir_to_mesa_emit_op1(ir, OPCODE_MOV, coord_dst, lod_info); + coord_dst.writemask = WRITEMASK_XYZW; + } + + inst = ir_to_mesa_emit_op1(ir, opcode, result_dst, coord); + ir_dereference_variable *sampler = ir->sampler->as_dereference_variable(); assert(sampler); /* FINISHME: sampler arrays */ /* generate the mapping, remove when we generate storage at -- cgit v1.2.3 From b61f4241f314144d3290085cda5db1959d8960a2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Jul 2010 16:09:44 -0700 Subject: ir_to_mesa: Add support for shadow comparison to texture instructions. piglit lacks tests for this currently. --- src/mesa/shader/ir_to_mesa.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 53e5242b10b..c4678254925 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -83,6 +83,7 @@ public: GLboolean cond_update; int sampler; /**< sampler index */ int tex_target; /**< One of TEXTURE_*_INDEX */ + GLboolean tex_shadow; }; class temp_entry : public exec_node { @@ -1361,6 +1362,16 @@ ir_to_mesa_visitor::visit(ir_texture *ir) } } + if (ir->shadow_comparitor) { + /* Slot the shadow value in as the second to last component of the + * coord. + */ + ir->shadow_comparitor->accept(this); + coord_dst.writemask = WRITEMASK_Z; + ir_to_mesa_emit_op1(ir, OPCODE_MOV, coord_dst, this->result); + coord_dst.writemask = WRITEMASK_XYZW; + } + if (opcode == OPCODE_TXL || opcode == OPCODE_TXB) { /* Mesa IR stores lod or lod bias in the last channel of the coords. */ coord_dst.writemask = WRITEMASK_W; @@ -1370,6 +1381,9 @@ ir_to_mesa_visitor::visit(ir_texture *ir) inst = ir_to_mesa_emit_op1(ir, opcode, result_dst, coord); + if (ir->shadow_comparitor) + inst->tex_shadow = GL_TRUE; + ir_dereference_variable *sampler = ir->sampler->as_dereference_variable(); assert(sampler); /* FINISHME: sampler arrays */ /* generate the mapping, remove when we generate storage at @@ -1396,8 +1410,6 @@ ir_to_mesa_visitor::visit(ir_texture *ir) assert(!"FINISHME: other texture targets"); } - assert(!ir->shadow_comparitor); /* FINISHME */ - this->result = result_src; } @@ -1726,6 +1738,7 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); mesa_inst->TexSrcUnit = inst->sampler; mesa_inst->TexSrcTarget = inst->tex_target; + mesa_inst->TexShadow = inst->tex_shadow; mesa_instruction_annotation[i] = inst->ir; mesa_inst++; -- cgit v1.2.3 From 8f25d198e54a117b36e68582977a644d085a4a94 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Jul 2010 16:10:31 -0700 Subject: ir_to_mesa: Add support for scalar * mat, vec * mat. This is not tested by piglit currently. --- src/mesa/shader/ir_to_mesa.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index c4678254925..f8858af26d6 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -686,6 +686,42 @@ ir_to_mesa_visitor::visit(ir_expression *ir) src_column.index++; } } + } else if (ir->operands[1]->type->is_matrix()) { + if (ir->operands[0]->type->is_scalar()) { + ir_to_mesa_dst_reg dst_column = result_dst; + ir_to_mesa_src_reg src_column = op[1]; + for (int i = 0; i < ir->operands[1]->type->matrix_columns; i++) { + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + dst_column, src_column, op[0]); + dst_column.index++; + src_column.index++; + } + } else { + ir_to_mesa_src_reg src_column = op[1]; + ir_to_mesa_dst_reg dst_chan = result_dst; + + /* FINISHME here and above: non-square matrices */ + assert(ir->operands[1]->type->vector_elements == + ir->operands[1]->type->matrix_columns); + + for (int i = 0; i < ir->operands[0]->type->vector_elements; i++) { + dst_chan.writemask = (1 << i); + switch (ir->operands[0]->type->vector_elements) { + case 2: + ir_to_mesa_emit_op2(ir, OPCODE_DP2, dst_chan, op[0], src_column); + break; + case 3: + ir_to_mesa_emit_op2(ir, OPCODE_DP3, dst_chan, op[0], src_column); + break; + case 4: + ir_to_mesa_emit_op2(ir, OPCODE_DP4, dst_chan, op[0], src_column); + break; + default: + assert(0); + } + src_column.index++; + } + } } else { assert(!ir->operands[0]->type->is_matrix()); assert(!ir->operands[1]->type->is_matrix()); -- cgit v1.2.3 From 4e7d5d0e74c26cac182cea1be0f6b79bb664ad8c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Jul 2010 16:17:50 -0700 Subject: i965: Add support for the DP2 opcode, which we use for dot(vec2, vec2). The original glsl compiler would generate a.x * b.x + a.y * b.y, which we would do mul+mul+add for instead of this mul+mac. Fixes glsl-fs-dot-vec2. --- src/mesa/drivers/dri/i965/brw_wm.h | 5 +++++ src/mesa/drivers/dri/i965/brw_wm_emit.c | 25 +++++++++++++++++++++++++ src/mesa/drivers/dri/i965/brw_wm_glsl.c | 3 +++ src/mesa/drivers/dri/i965/brw_wm_pass1.c | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index 938557ff369..197b8754345 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -343,6 +343,11 @@ void emit_delta_xy(struct brw_compile *p, const struct brw_reg *dst, GLuint mask, const struct brw_reg *arg0); +void emit_dp2(struct brw_compile *p, + const struct brw_reg *dst, + GLuint mask, + const struct brw_reg *arg0, + const struct brw_reg *arg1); void emit_dp3(struct brw_compile *p, const struct brw_reg *dst, GLuint mask, diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index 11f482bddf2..a90a2d3cf25 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -731,6 +731,27 @@ void emit_min(struct brw_compile *p, } +void emit_dp2(struct brw_compile *p, + const struct brw_reg *dst, + GLuint mask, + const struct brw_reg *arg0, + const struct brw_reg *arg1) +{ + int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1; + + if (!(mask & WRITEMASK_XYZW)) + return; /* Do not emit dead code */ + + assert(is_power_of_two(mask & WRITEMASK_XYZW)); + + brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]); + + brw_set_saturate(p, (mask & SATURATE) ? 1 : 0); + brw_MAC(p, dst[dst_chan], arg0[1], arg1[1]); + brw_set_saturate(p, 0); +} + + void emit_dp3(struct brw_compile *p, const struct brw_reg *dst, GLuint mask, @@ -1584,6 +1605,10 @@ void brw_wm_emit( struct brw_wm_compile *c ) emit_ddxy(p, dst, dst_flags, GL_FALSE, args[0]); break; + case OPCODE_DP2: + emit_dp2(p, dst, dst_flags, args[0], args[1]); + break; + case OPCODE_DP3: emit_dp3(p, dst, dst_flags, args[0], args[1]); break; diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index e23ce7ad7a5..57be08a8d1d 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -1903,6 +1903,9 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) case OPCODE_SWZ: emit_alu1(p, brw_MOV, dst, dst_flags, args[0]); break; + case OPCODE_DP2: + emit_dp2(p, dst, dst_flags, args[0], args[1]); + break; case OPCODE_DP3: emit_dp3(p, dst, dst_flags, args[0], args[1]); break; diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass1.c b/src/mesa/drivers/dri/i965/brw_wm_pass1.c index 8ee1f153b1f..962515a99e9 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_pass1.c +++ b/src/mesa/drivers/dri/i965/brw_wm_pass1.c @@ -255,6 +255,11 @@ void brw_wm_pass1( struct brw_wm_compile *c ) read2 = WRITEMASK_W; /* pixel w */ break; + case OPCODE_DP2: + read0 = WRITEMASK_XY; + read1 = WRITEMASK_XY; + break; + case OPCODE_DP3: read0 = WRITEMASK_XYZ; read1 = WRITEMASK_XYZ; -- cgit v1.2.3 From b0ac07e3de8d9609fb0b1b7ec85b4149c4ee2c70 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Jul 2010 17:02:42 -0700 Subject: ir_to_mesa: Fix up implementation of ir_unop_exp. OPCODE_EXP is not to ir_unop_exp what OPCODE_EX2 is to ir_unop_exp2. It's the weird VP approximation helper opcode. Just implement it with OPCODE_POW instead. Fixes glsl-fs-exp. --- src/mesa/shader/ir_to_mesa.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index f8858af26d6..87d6f8452a2 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -625,7 +625,8 @@ ir_to_mesa_visitor::visit(ir_expression *ir) break; case ir_unop_exp: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_EXP, result_dst, op[0]); + ir_to_mesa_emit_scalar_op2(ir, OPCODE_POW, result_dst, + src_reg_for_float(M_E), op[0]); break; case ir_unop_exp2: ir_to_mesa_emit_scalar_op1(ir, OPCODE_EX2, result_dst, op[0]); -- cgit v1.2.3 From 9a7ac272fb7d87e56277ed88585f389446a4a1b9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 2 Jul 2010 02:10:01 -0700 Subject: glsl2/builtins: Use vector ops in "smoothstep." --- src/glsl/builtins/110/smoothstep | 101 ++++++--------------------------------- 1 file changed, 15 insertions(+), 86 deletions(-) diff --git a/src/glsl/builtins/110/smoothstep b/src/glsl/builtins/110/smoothstep index b4255ba78f1..663eec63419 100644 --- a/src/glsl/builtins/110/smoothstep +++ b/src/glsl/builtins/110/smoothstep @@ -122,103 +122,32 @@ (declare (in) vec2 edge0) (declare (in) vec2 edge1) (declare (in) vec2 x)) - ((declare () vec2 t) - (declare () vec2 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - (return (var_ref retval)) - )) + ((return (expression vec2 max + (expression vec2 min + (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0))) + (constant vec2 (1.0 1.0))) + (constant vec2 (0.0 0.0)))))) (signature vec3 (parameters (declare (in) vec3 edge0) (declare (in) vec3 edge1) (declare (in) vec3 x)) - ((declare () vec3 t) - (declare () vec3 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - - (assign (constant bool (1)) (swiz z (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) - (return (var_ref retval)) - )) - + ((return (expression vec3 max + (expression vec3 min + (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0))) + (constant vec3 (1.0 1.0 1.0))) + (constant vec3 (0.0 0.0 0.0)))))) (signature vec4 (parameters (declare (in) vec4 edge0) (declare (in) vec4 edge1) (declare (in) vec4 x)) - ((declare () vec4 t) - (declare () vec4 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - - (assign (constant bool (1)) (swiz z (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) - - (assign (constant bool (1)) (swiz w (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz w (var_ref x)) (swiz w (var_ref edge0))) (expression float - (swiz w (var_ref edge1)) (swiz w (var_ref edge0)))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t))))))) - (return (var_ref retval)) - )) - + ((return (expression vec4 max + (expression vec4 min + (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0))) + (constant vec4 (1.0 1.0 1.0 1.0))) + (constant vec4 (0.0 0.0 0.0 0.0)))))) )) -- cgit v1.2.3 From ddc3aa07832c3fa35382b57ce2539dbac5a6158d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 2 Jul 2010 02:12:34 -0700 Subject: glsl2/builtins: Use vector ops in the 130 version of "sign." --- src/glsl/builtins/130/sign | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/glsl/builtins/130/sign b/src/glsl/builtins/130/sign index 0bdc0e09d25..170795948b2 100644 --- a/src/glsl/builtins/130/sign +++ b/src/glsl/builtins/130/sign @@ -7,28 +7,16 @@ (signature ivec2 (parameters (declare (in) ivec2 x)) - ((declare () ivec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) - (return (var_ref t)))) + ((return (expression ivec2 sign (var_ref x))))) (signature ivec3 (parameters (declare (in) ivec3 x)) - ((declare () ivec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x)))) - (return (var_ref t)))) + ((return (expression ivec3 sign (var_ref x))))) (signature ivec4 (parameters (declare (in) ivec4 x)) - ((declare () ivec4 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x)))) - (assign (constant bool (1)) (swiz w (var_ref t)) (expression int sign (swiz w (var_ref x)))) - (return (var_ref t)))) + ((return (expression ivec4 sign (var_ref x))))) )) -- cgit v1.2.3 From e2a358348b143a163c065d82c7375e6a94e98f2a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 2 Jul 2010 02:50:40 -0700 Subject: ir_to_mesa: Fix uninitalized value. --- src/mesa/shader/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 87d6f8452a2..547b18402f9 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1546,7 +1546,7 @@ static void set_branchtargets(struct prog_instruction *mesa_instructions, int num_instructions) { - int if_count = 0, loop_count; + int if_count = 0, loop_count = 0; int *if_stack, *loop_stack; int if_stack_pos = 0, loop_stack_pos = 0; int i, j; -- cgit v1.2.3 From 2070f9f5bec99e7b91309060984431aa7ea32c00 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 2 Jul 2010 15:02:57 -0700 Subject: glsl2: Fix for dead strings being stored in the symbol table. --- src/glsl/ir_reader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 5ba76e29ea0..80dbc086457 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -206,7 +206,7 @@ read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) ir_function *f = st->symbols->get_function(name->value()); if (f == NULL) { f = new(ctx) ir_function(name->value()); - bool added = st->symbols->add_function(name->value(), f); + bool added = st->symbols->add_function(f->name, f); assert(added); } @@ -439,7 +439,7 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) } // Add the variable to the symbol table - st->symbols->add_variable(var_name->value(), var); + st->symbols->add_variable(var->name, var); return var; } -- cgit v1.2.3 From 7e908a6a27f196027a4dfd0f4d8c37aa71e163fa Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 2 Jul 2010 15:31:26 -0700 Subject: glcpp: Add #error support. --- src/glsl/glcpp/glcpp-lex.l | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index afddd7ddb32..6a91b09954a 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -24,6 +24,7 @@ #include #include +#include #include "glcpp.h" #include "glcpp-parse.h" @@ -139,6 +140,13 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } } +{HASH}error.* { + char *p; + for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */ + p += 5; /* skip "error" */ + glcpp_error(yylloc, yyextra, "#error%s", p); +} + {HASH}define{HSPACE}+/{IDENTIFIER}"(" { yyextra->space_tokens = 0; return HASH_DEFINE_FUNC; -- cgit v1.2.3 From 83035574dbe0e225fbdeb9ceb4f0af9b0e0c5ddb Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 2 Jul 2010 18:20:19 -0700 Subject: Refresh autogenerated file builtin_function.cpp. --- src/glsl/builtin_function.cpp | 119 +++++++----------------------------------- 1 file changed, 18 insertions(+), 101 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 30ba6a52677..40c85e7c989 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -2019,104 +2019,33 @@ static const char *builtins_110_smoothstep = { " (declare (in) vec2 edge0)\n" " (declare (in) vec2 edge1)\n" " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (declare () vec2 retval)\n" - "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" + " ((return (expression vec2 max\n" + " (expression vec2 min\n" + " (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0)))\n" + " (constant vec2 (1.0 1.0)))\n" + " (constant vec2 (0.0 0.0))))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 edge0)\n" " (declare (in) vec3 edge1)\n" " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (declare () vec3 retval)\n" - "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz z (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" - "\n" + " ((return (expression vec3 max\n" + " (expression vec3 min\n" + " (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0)))\n" + " (constant vec3 (1.0 1.0 1.0)))\n" + " (constant vec3 (0.0 0.0 0.0))))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 edge0)\n" " (declare (in) vec4 edge1)\n" " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (declare () vec4 retval)\n" - "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (swiz x (var_ref edge0))) (expression float - (swiz x (var_ref edge1)) (swiz x (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (swiz y (var_ref edge0))) (expression float - (swiz y (var_ref edge1)) (swiz y (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz z (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz z (var_ref x)) (swiz z (var_ref edge0))) (expression float - (swiz z (var_ref edge1)) (swiz z (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" - "\n" - " (assign (constant bool (1)) (swiz w (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz w (var_ref x)) (swiz w (var_ref edge0))) (expression float - (swiz w (var_ref edge1)) (swiz w (var_ref edge0))))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" - "\n" + " ((return (expression vec4 max\n" + " (expression vec4 min\n" + " (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0)))\n" + " (constant vec4 (1.0 1.0 1.0 1.0)))\n" + " (constant vec4 (0.0 0.0 0.0 0.0))))))\n" "))\n" "\n" }; @@ -3664,29 +3593,17 @@ static const char *builtins_130_sign = { " (signature ivec2\n" " (parameters\n" " (declare (in) ivec2 x))\n" - " ((declare () ivec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" - " (return (var_ref t))))\n" + " ((return (expression ivec2 sign (var_ref x)))))\n" "\n" " (signature ivec3\n" " (parameters\n" " (declare (in) ivec3 x))\n" - " ((declare () ivec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x))))\n" - " (return (var_ref t))))\n" + " ((return (expression ivec3 sign (var_ref x)))))\n" "\n" " (signature ivec4\n" " (parameters\n" " (declare (in) ivec4 x))\n" - " ((declare () ivec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression int sign (swiz w (var_ref x))))\n" - " (return (var_ref t))))\n" + " ((return (expression ivec4 sign (var_ref x)))))\n" "))\n" "\n" }; -- cgit v1.2.3 From a0b3b9302978ab6d4db62f0c9b2b313ebc7ed0b4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Jul 2010 12:28:12 -0700 Subject: ir_to_mesa: Use the compiler-assigned locations for builtin attrs/varyings. The previous table didn't distinguish gl_Color for the VS and FS, so we would use the FS's attribute index for the VS and read undefined. This partially fixes glsl-routing to match its behavior on master. --- src/mesa/shader/ir_to_mesa.cpp | 83 +++++------------------------------------- 1 file changed, 9 insertions(+), 74 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 547b18402f9..e1b0397dde5 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -211,56 +211,6 @@ static int swizzle_for_size(int size) return size_swizzles[size - 1]; } -/* This list should match up with builtin_variables.h */ -static const struct { - const char *name; - int file; - int index; -} builtin_var_to_mesa_reg[] = { - /* core_vs */ - {"gl_Position", PROGRAM_OUTPUT, VERT_RESULT_HPOS}, - {"gl_PointSize", PROGRAM_OUTPUT, VERT_RESULT_PSIZ}, - - /* core_fs */ - {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS}, - {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE}, - {"gl_FragColor", PROGRAM_OUTPUT, FRAG_ATTRIB_COL0}, - {"gl_FragDepth", PROGRAM_OUTPUT, FRAG_RESULT_DEPTH}, - - /* 110_deprecated_fs */ - {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0}, - {"gl_SecondaryColor", PROGRAM_INPUT, FRAG_ATTRIB_COL1}, - {"gl_FogFragCoord", PROGRAM_INPUT, FRAG_ATTRIB_FOGC}, - {"gl_TexCoord", PROGRAM_INPUT, FRAG_ATTRIB_TEX0}, /* array */ - - /* 110_deprecated_vs */ - {"gl_Vertex", PROGRAM_INPUT, VERT_ATTRIB_POS}, - {"gl_Normal", PROGRAM_INPUT, VERT_ATTRIB_NORMAL}, - {"gl_Color", PROGRAM_INPUT, VERT_ATTRIB_COLOR0}, - {"gl_SecondaryColor", PROGRAM_INPUT, VERT_ATTRIB_COLOR1}, - {"gl_MultiTexCoord0", PROGRAM_INPUT, VERT_ATTRIB_TEX0}, - {"gl_MultiTexCoord1", PROGRAM_INPUT, VERT_ATTRIB_TEX1}, - {"gl_MultiTexCoord2", PROGRAM_INPUT, VERT_ATTRIB_TEX2}, - {"gl_MultiTexCoord3", PROGRAM_INPUT, VERT_ATTRIB_TEX3}, - {"gl_MultiTexCoord4", PROGRAM_INPUT, VERT_ATTRIB_TEX4}, - {"gl_MultiTexCoord5", PROGRAM_INPUT, VERT_ATTRIB_TEX5}, - {"gl_MultiTexCoord6", PROGRAM_INPUT, VERT_ATTRIB_TEX6}, - {"gl_MultiTexCoord7", PROGRAM_INPUT, VERT_ATTRIB_TEX7}, - {"gl_TexCoord", PROGRAM_OUTPUT, VERT_RESULT_TEX0}, /* array */ - {"gl_FogCoord", PROGRAM_INPUT, VERT_RESULT_FOGC}, - /*{"gl_ClipVertex", PROGRAM_OUTPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ - {"gl_FrontColor", PROGRAM_OUTPUT, VERT_RESULT_COL0}, - {"gl_BackColor", PROGRAM_OUTPUT, VERT_RESULT_BFC0}, - {"gl_FrontSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_COL1}, - {"gl_BackSecondaryColor", PROGRAM_OUTPUT, VERT_RESULT_BFC1}, - {"gl_FogFragCoord", PROGRAM_OUTPUT, VERT_RESULT_FOGC}, - - /* 130_vs */ - /*{"gl_VertexID", PROGRAM_INPUT, VERT_ATTRIB_FOGC},*/ /* FINISHME */ - - {"gl_FragData", PROGRAM_OUTPUT, FRAG_RESULT_DATA0}, /* array */ -}; - ir_to_mesa_instruction * ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir, enum prog_opcode op, @@ -988,8 +938,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) { ir_to_mesa_src_reg src_reg; temp_entry *entry = find_variable_storage(ir->var); - unsigned int i, loc; - bool var_in; + unsigned int loc; if (!entry) { switch (ir->var->mode) { @@ -1033,30 +982,16 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) case ir_var_in: case ir_var_out: case ir_var_inout: - var_in = (ir->var->mode == ir_var_in || - ir->var->mode == ir_var_inout); - - for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) { - bool in = builtin_var_to_mesa_reg[i].file == PROGRAM_INPUT; - - if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0 && - !(var_in ^ in)) - break; - } - if (i != ARRAY_SIZE(builtin_var_to_mesa_reg)) { - entry = new(mem_ctx) temp_entry(ir->var, - builtin_var_to_mesa_reg[i].file, - builtin_var_to_mesa_reg[i].index); - break; - } - - /* If no builtin, then it's a user-generated varying - * (FINISHME: or a function argument!) - */ - /* The linker-assigned location is VERT_RESULT_* or FRAG_ATTRIB* + /* The linker assigns locations for varyings and attributes, + * including deprecated builtins (like gl_Color), user-assign + * generic attributes (glBindVertexLocation), and + * user-defined varyings. + * + * FINISHME: We would hit this path for function arguments. Fix! */ assert(ir->var->location != -1); - if (var_in) { + if (ir->var->mode == ir_var_in || + ir->var->mode == ir_var_inout) { entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_INPUT, ir->var->location); -- cgit v1.2.3 From e45a982313e02dbc186b51cf0935e0bec18dc61a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 6 Jul 2010 14:36:54 -0700 Subject: Make hashtable.h be C++ friendly --- src/mesa/shader/hash_table.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mesa/shader/hash_table.h b/src/mesa/shader/hash_table.h index 7b302f5dbee..881e756f087 100644 --- a/src/mesa/shader/hash_table.h +++ b/src/mesa/shader/hash_table.h @@ -38,6 +38,10 @@ struct hash_table; typedef unsigned (*hash_func_t)(const void *key); typedef int (*hash_compare_func_t)(const void *key1, const void *key2); +#ifdef __cplusplus +extern "C" { +#endif + /** * Hash table constructor * @@ -114,4 +118,7 @@ extern unsigned hash_table_string_hash(const void *key); */ #define hash_table_string_compare ((hash_compare_func_t) strcmp) +#ifdef __cplusplus +}; +#endif #endif /* HASH_TABLE_H */ -- cgit v1.2.3 From d1a1ee583e7e8338243b3e9768d2fc5312a1145d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 6 Jul 2010 14:49:14 -0700 Subject: Add hash table helper functions for using pointers as hash keys --- src/glsl/ir_function_inlining.cpp | 14 +------------- src/glsl/ir_validate.cpp | 15 ++------------- src/mesa/shader/hash_table.c | 14 ++++++++++++++ src/mesa/shader/hash_table.h | 24 ++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 1adf67868ee..b3d1f1d1674 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -33,9 +33,7 @@ #include "ir_function_inlining.h" #include "ir_expression_flattening.h" #include "glsl_types.h" -extern "C" { #include "hash_table.h" -} class ir_function_inlining_visitor : public ir_hierarchical_visitor { public: @@ -60,16 +58,6 @@ public: }; -unsigned int hash_func(const void *key) -{ - return (unsigned int)(uintptr_t)key; -} - -int hash_compare_func(const void *key1, const void *key2) -{ - return key1 == key2 ? 0 : 1; -} - bool automatic_inlining_predicate(ir_instruction *ir) { @@ -124,7 +112,7 @@ ir_call::generate_inline(ir_instruction *next_ir) ir_variable *retval = NULL; struct hash_table *ht; - ht = hash_table_ctor(0, hash_func, hash_compare_func); + ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); num_parameters = 0; foreach_iter(exec_list_iterator, iter_sig, this->callee->parameters) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 19538524879..7582d57e7c3 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -36,26 +36,15 @@ #include #include "ir.h" #include "ir_hierarchical_visitor.h" -extern "C" { #include "hash_table.h" -} - -static unsigned int hash_func(const void *key) -{ - return (unsigned int)(uintptr_t)key; -} - -static int hash_compare_func(const void *key1, const void *key2) -{ - return key1 == key2 ? 0 : 1; -} class ir_validate : public ir_hierarchical_visitor { public: ir_validate() { - this->ht = hash_table_ctor(0, hash_func, hash_compare_func); + this->ht = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); this->callback = ir_validate::validate_ir; this->data = ht; diff --git a/src/mesa/shader/hash_table.c b/src/mesa/shader/hash_table.c index fa6ba2bfdfc..933e300abdd 100644 --- a/src/mesa/shader/hash_table.c +++ b/src/mesa/shader/hash_table.c @@ -157,3 +157,17 @@ hash_table_string_hash(const void *key) return hash; } + + +unsigned +hash_table_pointer_hash(const void *key) +{ + return (unsigned)((uintptr_t) key / sizeof(void *)); +} + + +int +hash_table_pointer_compare(const void *key1, const void *key2) +{ + return key1 == key2 ? 0 : 1; +} diff --git a/src/mesa/shader/hash_table.h b/src/mesa/shader/hash_table.h index 881e756f087..05526914643 100644 --- a/src/mesa/shader/hash_table.h +++ b/src/mesa/shader/hash_table.h @@ -118,6 +118,30 @@ extern unsigned hash_table_string_hash(const void *key); */ #define hash_table_string_compare ((hash_compare_func_t) strcmp) + +/** + * Compute hash value of a pointer + * + * \param key Pointer to be used as a hash key + * + * \note + * The memory pointed to by \c key is \b never accessed. The value of \c key + * itself is used as the hash key + * + * \sa hash_table_pointer_compare + */ +unsigned +hash_table_pointer_hash(const void *key); + + +/** + * Compare two pointers used as keys + * + * \sa hash_table_pointer_hash + */ +int +hash_table_pointer_compare(const void *key1, const void *key2); + #ifdef __cplusplus }; #endif -- cgit v1.2.3 From c63a1db81f56cc2021fe1fb2411c327f720b0e09 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 5 Jul 2010 22:33:35 -0700 Subject: ir_constant_expression: Initialize all components of constant data to 0. This is probably just a good idea, and will come in useful when implementing things like matrix multiplication. --- src/glsl/ir_constant_expression.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 548217cddd9..1b81017698e 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -133,6 +133,8 @@ ir_constant_visitor::visit(ir_expression *ir) unsigned int operand, c; ir_constant_data data; + memset(&data, 0, sizeof(data)); + for (operand = 0; operand < ir->get_num_operands(); operand++) { op[operand] = ir->operands[operand]->constant_expression_value(); if (!op[operand]) -- cgit v1.2.3 From 6bc432e14e12c280bc53e57338bf86fbf8d26885 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 2 Jul 2010 17:12:23 -0700 Subject: ir_constant_expression: Initialize op[0] and op[1] to NULL. This makes it easy to check if there is a second argument. --- src/glsl/ir_constant_expression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 1b81017698e..6d6ee093d79 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -129,7 +129,7 @@ void ir_constant_visitor::visit(ir_expression *ir) { value = NULL; - ir_constant *op[2]; + ir_constant *op[2] = { NULL, NULL }; unsigned int operand, c; ir_constant_data data; -- cgit v1.2.3 From 6fc983b9bb5555e2906d2680bc3cbd11c43b63f6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 6 Jul 2010 02:39:57 -0700 Subject: ir_constant_expression: Assert that both operands share a base type. --- src/glsl/ir_constant_expression.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 6d6ee093d79..610d9479a94 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -141,6 +141,9 @@ ir_constant_visitor::visit(ir_expression *ir) return; } + if (op[1] != NULL) + assert(op[0]->type->base_type == op[1]->type->base_type); + switch (ir->operation) { case ir_unop_logic_not: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); -- cgit v1.2.3 From e74dcd7924901e5cb3d0952f46e955e15d0b3207 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 6 Jul 2010 02:48:16 -0700 Subject: ir_constant_expression: Support scalar + vector and scalar + matrix. Fixes piglit tests const-vec-scalar-01.frag, const-vec-scalar-05.frag, and const-mat-scalar-01.frag. --- src/glsl/ir_constant_expression.cpp | 46 ++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 610d9479a94..033eee1d722 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -144,6 +144,16 @@ ir_constant_visitor::visit(ir_expression *ir) if (op[1] != NULL) assert(op[0]->type->base_type == op[1]->type->base_type); + bool op0_scalar = op[0]->type->is_scalar(); + bool op1_scalar = op[1] != NULL && op[1]->type->is_scalar(); + + /* When iterating over a vector or matrix's components, we want to increase + * the loop counter. However, for scalars, we want to stay at 0. + */ + unsigned c0_inc = op0_scalar ? 1 : 0; + unsigned c1_inc = op1_scalar ? 1 : 0; + unsigned components = op[op1_scalar ? 0 : 1]->type->components(); + switch (ir->operation) { case ir_unop_logic_not: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); @@ -308,25 +318,25 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_binop_add: - if (ir->operands[0]->type == ir->operands[1]->type) { - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c] + op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c] + op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c] + op[1]->value.f[c]; - break; - default: - assert(0); - } + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] + op[1]->value.u[c1]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] + op[1]->value.i[c1]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c0] + op[1]->value.f[c1]; + break; + default: + assert(0); } - } else - /* FINISHME: Support operations with non-equal types. */ - return; + } break; case ir_binop_sub: -- cgit v1.2.3 From 97b44f040abc9cbf257aba1b7fdaa11134dcc70b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 6 Jul 2010 02:53:29 -0700 Subject: ir_constant_expression: Support scalar - vector and scalar - matrix. Fixes piglit tests const-vec-scalar-02.frag and const-mat-scalar-02.frag. --- src/glsl/ir_constant_expression.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 033eee1d722..fbf06f13255 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -340,25 +340,25 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_binop_sub: - if (ir->operands[0]->type == ir->operands[1]->type) { - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c] - op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c] - op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c] - op[1]->value.f[c]; - break; - default: - assert(0); - } + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] - op[1]->value.u[c1]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] - op[1]->value.i[c1]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1]; + break; + default: + assert(0); } - } else - /* FINISHME: Support operations with non-equal types. */ - return; + } break; case ir_binop_mul: -- cgit v1.2.3 From dad35eb8b0c7378588d9dca1c1091aaede83a83f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 6 Jul 2010 02:56:36 -0700 Subject: ir_constant_expression: Support scalar / vector and scalar / matrix. Fixes piglit tests const-vec-scalar-04.frag and const-mat-scalar-04.frag. --- src/glsl/ir_constant_expression.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index fbf06f13255..2fab03bb60e 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -385,25 +385,25 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_binop_div: - if (ir->operands[0]->type == ir->operands[1]->type) { - for (c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c] / op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c] / op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c] / op[1]->value.f[c]; - break; - default: - assert(0); - } + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] / op[1]->value.u[c1]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] / op[1]->value.i[c1]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c0] / op[1]->value.f[c1]; + break; + default: + assert(0); } - } else - /* FINISHME: Support operations with non-equal types. */ - return; + } break; case ir_binop_logic_and: -- cgit v1.2.3 From 37b3f9d0edb55807f822c02292348e20a8369c43 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 6 Jul 2010 03:01:15 -0700 Subject: ir_constant_expression: Support scalar * vector and scalar * matrix. The test here is slightly different since we need to keep matrix multiplication separate. Fixes piglit tests const-vec-scalar-03.frag and const-mat-scalar-03.frag. --- src/glsl/ir_constant_expression.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 2fab03bb60e..e039504d4e4 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -362,25 +362,28 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_binop_mul: - if (ir->operands[0]->type == ir->operands[1]->type && - !ir->operands[0]->type->is_matrix()) { - for (c = 0; c < ir->operands[0]->type->components(); c++) { + if ((op[0]->type == op[1]->type && !op[0]->type->is_matrix()) + || op0_scalar || op1_scalar) { + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c] * op[1]->value.u[c]; + data.u[c] = op[0]->value.u[c0] * op[1]->value.u[c1]; break; case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c] * op[1]->value.i[c]; + data.i[c] = op[0]->value.i[c0] * op[1]->value.i[c1]; break; case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c] * op[1]->value.f[c]; + data.f[c] = op[0]->value.f[c0] * op[1]->value.f[c1]; break; default: assert(0); } } } else - /* FINISHME: Support operations with non-equal types. */ + /* FINISHME: Support vector/matrix and matrix multiplication. */ return; break; -- cgit v1.2.3 From cf80a4d177225345c2238d8e545f8ae02b41da71 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 5 Jul 2010 23:19:56 -0700 Subject: ir_constant_expression: Add support for matrix multiplication. Also handles matrix/vector and vector/matrix multiplication. Fixes piglit tests const-matrix-multiply-01.frag, const-matrix-multiply-02.frag, and const-vec-mat.frag. --- src/glsl/ir_constant_expression.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index e039504d4e4..d05aa104f8d 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -362,6 +362,7 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_binop_mul: + /* Check for equal types, or unequal types involving scalars */ if ((op[0]->type == op[1]->type && !op[0]->type->is_matrix()) || op0_scalar || op1_scalar) { for (unsigned c = 0, c0 = 0, c1 = 0; @@ -382,9 +383,30 @@ ir_constant_visitor::visit(ir_expression *ir) assert(0); } } - } else - /* FINISHME: Support vector/matrix and matrix multiplication. */ - return; + } else { + assert(op[0]->type->is_matrix() || op[1]->type->is_matrix()); + + /* Multiply an N-by-M matrix with an M-by-P matrix. Since either + * matrix can be a GLSL vector, either N or P can be 1. + * + * For vec*mat, the vector is treated as a row vector. This + * means the vector is a 1-row x M-column matrix. + * + * For mat*vec, the vector is treated as a column vector. Since + * matrix_columns is 1 for vectors, this just works. + */ + const unsigned n = op[0]->type->is_vector() + ? 1 : op[0]->type->vector_elements; + const unsigned m = op[1]->type->vector_elements; + const unsigned p = op[1]->type->matrix_columns; + for (unsigned j = 0; j < p; j++) { + for (unsigned i = 0; i < n; i++) { + for (unsigned k = 0; k < m; k++) { + data.f[i+n*j] += op[0]->value.f[i+n*k]*op[1]->value.f[k+m*j]; + } + } + } + } break; case ir_binop_div: -- cgit v1.2.3 From 3f4a0b8bb0cfa36cc6f9968c8aab03f1cb0678ff Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 5 Jul 2010 21:15:32 -0700 Subject: ir_constant_expression: Add support for dot products. --- src/glsl/ir_constant_expression.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index d05aa104f8d..5c2e3629e1c 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -317,6 +317,26 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_binop_dot: + assert(op[0]->type->is_vector() && op[1]->type->is_vector()); + data.f[0] = 0; + for (c = 0; c < op[0]->type->components(); c++) { + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[0] += op[0]->value.u[c] * op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.i[0] += op[0]->value.i[c] * op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.f[0] += op[0]->value.f[c] * op[1]->value.f[c]; + break; + default: + assert(0); + } + } + + break; case ir_binop_add: assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); for (unsigned c = 0, c0 = 0, c1 = 0; -- cgit v1.2.3 From f2dfac6d7455b6bf95cb94bd9ba296dea5c93faf Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 6 Jul 2010 04:59:08 -0700 Subject: glsl2: Update TODO. --- src/glsl/TODO | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/glsl/TODO b/src/glsl/TODO index c702eb4927e..b2baa130786 100644 --- a/src/glsl/TODO +++ b/src/glsl/TODO @@ -1,13 +1,3 @@ -- Implement AST-to-HIR conversion of discard instructions. - -- Handle constant expressions of (matrix {+,-,*,/} scalar) - -- Handle constant expressions of (vector {+,-,*,/} scalar) - -- Handle constant expressions of (matrix * vector) - -- Handle constant expressions of (matrix * matrix) - - Handle currently unsupported constant expression types - ir_unop_sign - ir_unop_exp2 @@ -18,7 +8,6 @@ - ir_unop_floor - ir_unop_sin - ir_unop_cos - - ir_binop_dot - ir_binop_min - ir_binop_max - ir_binop_pow @@ -79,3 +68,6 @@ - ir_binop_bit_and - ir_binop_bit_xor - ir_binop_bit_or + +- Implement support for 1.30 style shadow compares which only return a float + instead of a vec4. -- cgit v1.2.3 From f14e596f11b4e44c75a880536efb1e8c5a72da7d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 6 Jul 2010 16:26:11 -0700 Subject: ir_constant_expression: Declare loop counting variables in the loops. Fixes "name lookup of 'c' changed" warning. --- src/glsl/ir_constant_expression.cpp | 47 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 5c2e3629e1c..11c810bc484 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -130,12 +130,11 @@ ir_constant_visitor::visit(ir_expression *ir) { value = NULL; ir_constant *op[2] = { NULL, NULL }; - unsigned int operand, c; ir_constant_data data; memset(&data, 0, sizeof(data)); - for (operand = 0; operand < ir->get_num_operands(); operand++) { + for (unsigned operand = 0; operand < ir->get_num_operands(); operand++) { op[operand] = ir->operands[operand]->constant_expression_value(); if (!op[operand]) return; @@ -157,20 +156,20 @@ ir_constant_visitor::visit(ir_expression *ir) switch (ir->operation) { case ir_unop_logic_not: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) data.b[c] = !op[0]->value.b[c]; break; case ir_unop_f2i: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { data.i[c] = op[0]->value.f[c]; } break; case ir_unop_i2f: assert(op[0]->type->base_type == GLSL_TYPE_UINT || op[0]->type->base_type == GLSL_TYPE_INT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { if (op[0]->type->base_type == GLSL_TYPE_INT) data.f[c] = op[0]->value.i[c]; else @@ -179,31 +178,31 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_unop_b2f: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = op[0]->value.b[c] ? 1.0 : 0.0; } break; case ir_unop_f2b: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { data.b[c] = bool(op[0]->value.f[c]); } break; case ir_unop_b2i: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { data.u[c] = op[0]->value.b[c] ? 1 : 0; } break; case ir_unop_i2b: assert(op[0]->type->is_integer()); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { data.b[c] = bool(op[0]->value.u[c]); } break; case ir_unop_fract: - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = 0; @@ -221,7 +220,7 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_unop_neg: - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = -op[0]->value.u[c]; @@ -240,7 +239,7 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_abs: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = op[0]->value.u[c]; @@ -261,7 +260,7 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_rcp: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { case GLSL_TYPE_UINT: if (op[0]->value.u[c] != 0.0) @@ -283,28 +282,28 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_rsq: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = 1.0 / sqrtf(op[0]->value.f[c]); } break; case ir_unop_sqrt: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = sqrtf(op[0]->value.f[c]); } break; case ir_unop_exp: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = expf(op[0]->value.f[c]); } break; case ir_unop_log: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = logf(op[0]->value.f[c]); } break; @@ -312,7 +311,7 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_unop_dFdx: case ir_unop_dFdy: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { data.f[c] = 0.0; } break; @@ -320,7 +319,7 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_binop_dot: assert(op[0]->type->is_vector() && op[1]->type->is_vector()); data.f[0] = 0; - for (c = 0; c < op[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: data.u[0] += op[0]->value.u[c] * op[1]->value.u[c]; @@ -453,17 +452,17 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_binop_logic_and: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) data.b[c] = op[0]->value.b[c] && op[1]->value.b[c]; break; case ir_binop_logic_xor: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c]; break; case ir_binop_logic_or: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (c = 0; c < ir->operands[0]->type->components(); c++) + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) data.b[c] = op[0]->value.b[c] || op[1]->value.b[c]; break; @@ -530,7 +529,7 @@ ir_constant_visitor::visit(ir_expression *ir) case ir_binop_equal: data.b[0] = true; - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = data.b[0] && op[0]->value.u[c] == op[1]->value.u[c]; @@ -551,7 +550,7 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_binop_nequal: data.b[0] = false; - for (c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->operands[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = data.b[0] || op[0]->value.u[c] != op[1]->value.u[c]; -- cgit v1.2.3 From ca088cc277ce9f986693c857f3961dc0e1a4d91c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 6 Jul 2010 17:41:02 -0700 Subject: glsl2: Clone methods return the type of the thing being cloned This is as opposed to returning the type of the base class of the hierarchy. --- src/glsl/ast_to_hir.cpp | 10 +++++----- src/glsl/ir.h | 38 ++++++++++++++++++++----------------- src/glsl/ir_clone.cpp | 34 ++++++++++++++++----------------- src/glsl/ir_constant_expression.cpp | 2 +- src/glsl/ir_function_inlining.cpp | 2 +- 5 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 3bd0bd65913..f5e93b02547 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -961,7 +961,7 @@ ast_expression::hir(exec_list *instructions, op[0], op[1]); result = do_assignment(instructions, state, - (ir_rvalue *)op[0]->clone(NULL), temp_rhs, + op[0]->clone(NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; error_emitted = (op[0]->type->is_error()); @@ -987,7 +987,7 @@ ast_expression::hir(exec_list *instructions, op[0], op[1]); result = do_assignment(instructions, state, - (ir_rvalue *)op[0]->clone(NULL), temp_rhs, + op[0]->clone(NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; error_emitted = type->is_error(); @@ -1107,7 +1107,7 @@ ast_expression::hir(exec_list *instructions, op[0], op[1]); result = do_assignment(instructions, state, - (ir_rvalue *)op[0]->clone(NULL), temp_rhs, + op[0]->clone(NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; error_emitted = op[0]->type->is_error(); @@ -1133,10 +1133,10 @@ ast_expression::hir(exec_list *instructions, /* Get a temporary of a copy of the lvalue before it's modified. * This may get thrown away later. */ - result = get_lvalue_copy(instructions, (ir_rvalue *)op[0]->clone(NULL)); + result = get_lvalue_copy(instructions, op[0]->clone(NULL)); (void)do_assignment(instructions, state, - (ir_rvalue *)op[0]->clone(NULL), temp_rhs, + op[0]->clone(NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index c19bd417c33..500a8c7a006 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -94,6 +94,8 @@ protected: class ir_rvalue : public ir_instruction { public: + virtual ir_rvalue *clone(struct hash_table *) const = 0; + virtual ir_rvalue * as_rvalue() { return this; @@ -154,7 +156,7 @@ class ir_variable : public ir_instruction { public: ir_variable(const struct glsl_type *, const char *); - virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_variable *clone(struct hash_table *ht) const; virtual ir_variable *as_variable() { @@ -258,7 +260,7 @@ class ir_function_signature : public ir_instruction { public: ir_function_signature(const glsl_type *return_type); - virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_function_signature *clone(struct hash_table *ht) const; virtual void accept(ir_visitor *v) { @@ -324,7 +326,7 @@ class ir_function : public ir_instruction { public: ir_function(const char *name); - virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_function *clone(struct hash_table *ht) const; virtual ir_function *as_function() { @@ -394,7 +396,7 @@ public: /* empty */ } - virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_if *clone(struct hash_table *ht) const; virtual ir_if *as_if() { @@ -426,7 +428,7 @@ public: /* empty */ } - virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_loop *clone(struct hash_table *ht) const; virtual void accept(ir_visitor *v) { @@ -467,7 +469,7 @@ class ir_assignment : public ir_rvalue { public: ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); - virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_assignment *clone(struct hash_table *ht) const; virtual void accept(ir_visitor *v) { @@ -601,7 +603,7 @@ public: ir_expression(int op, const struct glsl_type *type, ir_rvalue *, ir_rvalue *); - virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_expression *clone(struct hash_table *ht) const; static unsigned int get_num_operands(ir_expression_operation); unsigned int get_num_operands() const @@ -644,7 +646,7 @@ public: actual_parameters->move_nodes_to(& this->actual_parameters); } - virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_call *clone(struct hash_table *ht) const; virtual ir_call *as_call() { @@ -734,7 +736,7 @@ public: /* empty */ } - virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_return *clone(struct hash_table *) const; virtual ir_return *as_return() { @@ -778,7 +780,7 @@ public: this->loop = loop; } - virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_loop_jump *clone(struct hash_table *) const; virtual void accept(ir_visitor *v) { @@ -819,7 +821,7 @@ public: this->condition = cond; } - virtual ir_instruction *clone(struct hash_table *ht) const; + virtual ir_discard *clone(struct hash_table *ht) const; virtual void accept(ir_visitor *v) { @@ -871,7 +873,7 @@ public: /* empty */ } - virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_texture *clone(struct hash_table *) const; virtual void accept(ir_visitor *v) { @@ -961,7 +963,7 @@ public: ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask); - virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_swizzle *clone(struct hash_table *) const; virtual ir_swizzle *as_swizzle() { @@ -1005,6 +1007,8 @@ private: class ir_dereference : public ir_rvalue { public: + virtual ir_dereference *clone(struct hash_table *) const = 0; + virtual ir_dereference *as_dereference() { return this; @@ -1023,7 +1027,7 @@ class ir_dereference_variable : public ir_dereference { public: ir_dereference_variable(ir_variable *var); - virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_dereference_variable *clone(struct hash_table *) const; virtual ir_dereference_variable *as_dereference_variable() { @@ -1069,7 +1073,7 @@ public: ir_dereference_array(ir_variable *var, ir_rvalue *array_index); - virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_dereference_array *clone(struct hash_table *) const; virtual ir_dereference_array *as_dereference_array() { @@ -1105,7 +1109,7 @@ public: ir_dereference_record(ir_variable *var, const char *field); - virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_dereference_record *clone(struct hash_table *) const; /** * Get the variable that is ultimately referenced by an r-value @@ -1163,7 +1167,7 @@ public: */ ir_constant(const ir_constant *c, unsigned i); - virtual ir_instruction *clone(struct hash_table *) const; + virtual ir_constant *clone(struct hash_table *) const; virtual ir_constant *as_constant() { diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 74cc858bda4..cf21c24d732 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -35,7 +35,7 @@ extern "C" { * This will probably be made \c virtual and moved to the base class * eventually. */ -ir_instruction * +ir_variable * ir_variable::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -55,14 +55,14 @@ ir_variable::clone(struct hash_table *ht) const return var; } -ir_instruction * +ir_swizzle * ir_swizzle::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); return new(ctx) ir_swizzle((ir_rvalue *)this->val->clone(ht), this->mask); } -ir_instruction * +ir_return * ir_return::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -74,7 +74,7 @@ ir_return::clone(struct hash_table *ht) const return new(ctx) ir_return(new_value); } -ir_instruction * +ir_discard * ir_discard::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -86,7 +86,7 @@ ir_discard::clone(struct hash_table *ht) const return new(ctx) ir_discard(new_condition); } -ir_instruction * +ir_loop_jump * ir_loop_jump::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -95,7 +95,7 @@ ir_loop_jump::clone(struct hash_table *ht) const return new(ctx) ir_loop_jump(this->mode); } -ir_instruction * +ir_if * ir_if::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -114,7 +114,7 @@ ir_if::clone(struct hash_table *ht) const return new_if; } -ir_instruction * +ir_loop * ir_loop::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -136,7 +136,7 @@ ir_loop::clone(struct hash_table *ht) const return new_loop; } -ir_instruction * +ir_call * ir_call::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -150,7 +150,7 @@ ir_call::clone(struct hash_table *ht) const return new(ctx) ir_call(this->callee, &new_parameters); } -ir_instruction * +ir_expression * ir_expression::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -164,7 +164,7 @@ ir_expression::clone(struct hash_table *ht) const return new(ctx) ir_expression(this->operation, this->type, op[0], op[1]); } -ir_instruction * +ir_dereference_variable * ir_dereference_variable::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -181,7 +181,7 @@ ir_dereference_variable::clone(struct hash_table *ht) const return new(ctx) ir_dereference_variable(new_var); } -ir_instruction * +ir_dereference_array * ir_dereference_array::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -189,7 +189,7 @@ ir_dereference_array::clone(struct hash_table *ht) const (ir_rvalue *)this->array_index->clone(ht)); } -ir_instruction * +ir_dereference_record * ir_dereference_record::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -197,7 +197,7 @@ ir_dereference_record::clone(struct hash_table *ht) const this->field); } -ir_instruction * +ir_texture * ir_texture::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); @@ -236,7 +236,7 @@ ir_texture::clone(struct hash_table *ht) const return new_tex; } -ir_instruction * +ir_assignment * ir_assignment::clone(struct hash_table *ht) const { ir_rvalue *new_condition = NULL; @@ -250,7 +250,7 @@ ir_assignment::clone(struct hash_table *ht) const new_condition); } -ir_instruction * +ir_function * ir_function::clone(struct hash_table *ht) const { (void)ht; @@ -258,7 +258,7 @@ ir_function::clone(struct hash_table *ht) const abort(); } -ir_instruction * +ir_function_signature * ir_function_signature::clone(struct hash_table *ht) const { (void)ht; @@ -266,7 +266,7 @@ ir_function_signature::clone(struct hash_table *ht) const abort(); } -ir_instruction * +ir_constant * ir_constant::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 11c810bc484..541398a91c7 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -626,7 +626,7 @@ ir_constant_visitor::visit(ir_dereference_variable *ir) ir_variable *var = ir->variable_referenced(); if (var && var->constant_value) - value = (ir_constant *)var->constant_value->clone(NULL); + value = var->constant_value->clone(NULL); } diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index b3d1f1d1674..6fe1264b0a4 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -137,7 +137,7 @@ ir_call::generate_inline(ir_instruction *next_ir) ir_rvalue *param = (ir_rvalue *) param_iter.get(); /* Generate a new variable for the parameter. */ - parameters[i] = (ir_variable *)sig_param->clone(ht); + parameters[i] = sig_param->clone(ht); parameters[i]->mode = ir_var_auto; next_ir->insert_before(parameters[i]); -- cgit v1.2.3 From 2d1789e667c4180777829f96856daf91326721b9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Jul 2010 17:11:03 -0700 Subject: ir_to_mesa: Add support for conditional moves. Nothing generates conditional moves yet. --- src/mesa/shader/ir_to_mesa.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index e1b0397dde5..021e270f18a 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -286,6 +286,20 @@ ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) return dst_reg; } +inline ir_to_mesa_src_reg +ir_to_mesa_src_reg_from_dst(ir_to_mesa_dst_reg reg) +{ + ir_to_mesa_src_reg src_reg; + + src_reg.file = reg.file; + src_reg.index = reg.index; + src_reg.swizzle = SWIZZLE_XYZW; + src_reg.negate = 0; + src_reg.reladdr = 0; + + return src_reg; +} + /** * Emits Mesa scalar opcodes to produce unique answers across channels. * @@ -1192,14 +1206,22 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) assert(r.file != PROGRAM_UNDEFINED); if (ir->condition) { - ir_constant *condition_constant; + ir_to_mesa_src_reg condition; - condition_constant = ir->condition->constant_expression_value(); + ir->condition->accept(this); + condition = this->result; - assert(condition_constant && condition_constant->value.b[0]); + /* We use the OPCODE_CMP (a < 0 ? b : c) for conditional moves, + * and the condition we produced is 0.0 or 1.0. By flipping the + * sign, we can choose which value OPCODE_CMP produces without + * an extra computing the condition. + */ + condition.negate = ~condition.negate; + ir_to_mesa_emit_op3(ir, OPCODE_CMP, l, + condition, r, ir_to_mesa_src_reg_from_dst(l)); + } else { + ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); } - - ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); } -- cgit v1.2.3 From a36334be02cb0a2b834667116bfeb680bf365857 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Jul 2010 17:53:32 -0700 Subject: glsl2: Add pass for supporting variable vector indexing in rvalues. The Mesa IR needs this to support vector indexing correctly, and hardware backends such as 915 would want this behavior as well. Fixes glsl-vs-vec4-indexing-2. --- src/glsl/Makefile | 1 + src/glsl/ir_optimization.h | 1 + src/glsl/ir_vec_index_to_cond_assign.cpp | 197 +++++++++++++++++++++++++++++++ src/glsl/main.cpp | 1 + src/mesa/shader/ir_to_mesa.cpp | 6 + 5 files changed, 206 insertions(+) create mode 100644 src/glsl/ir_vec_index_to_cond_assign.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 30ba475d923..d2a687aa335 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -47,6 +47,7 @@ CXX_SOURCES = \ ir_swizzle_swizzle.cpp \ ir_validate.cpp \ ir_variable.cpp \ + ir_vec_index_to_cond_assign.cpp \ ir_vec_index_to_swizzle.cpp \ linker.cpp \ s_expression.cpp diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 6d02e591c3d..93010dadbee 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -42,4 +42,5 @@ bool do_function_inlining(exec_list *instructions); bool do_if_simplification(exec_list *instructions); bool do_mod_to_fract(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); +bool do_vec_index_to_cond_assign(exec_list *instructions); bool do_vec_index_to_swizzle(exec_list *instructions); diff --git a/src/glsl/ir_vec_index_to_cond_assign.cpp b/src/glsl/ir_vec_index_to_cond_assign.cpp new file mode 100644 index 00000000000..6264a430e3b --- /dev/null +++ b/src/glsl/ir_vec_index_to_cond_assign.cpp @@ -0,0 +1,197 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_vec_index_to_cond_assign.cpp + * + * Turns indexing into vector types to a series of conditional moves + * of each channel's swizzle into a temporary. + * + * Most GPUs don't have a native way to do this operation, and this + * works around that. For drivers using both this pass and + * ir_vec_index_to_swizzle, there's a risk that this pass will happen + * before sufficient constant folding to find that the array index is + * constant. However, we hope that other optimization passes, + * particularly constant folding of assignment conditions and copy + * propagation, will result in the same code in the end. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +class ir_vec_index_to_cond_assign_visitor : public ir_hierarchical_visitor { +public: + ir_vec_index_to_cond_assign_visitor() + { + progress = false; + } + + ir_rvalue *convert_vec_index_to_cond_assign(ir_rvalue *val); + + virtual ir_visitor_status visit_enter(ir_expression *); + virtual ir_visitor_status visit_enter(ir_swizzle *); + virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_call *); + virtual ir_visitor_status visit_enter(ir_if *); + + bool progress; +}; + +ir_rvalue * +ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue *ir) +{ + ir_dereference_array *orig_deref = ir->as_dereference_array(); + ir_assignment *assign; + ir_variable *index, *var; + ir_dereference *deref; + ir_expression *condition; + ir_swizzle *swizzle; + int i; + + if (!orig_deref) + return ir; + + if (orig_deref->array->type->is_matrix() || + orig_deref->array->type->is_array()) + return ir; + + assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); + + /* Store the index to a temporary to avoid reusing its tree. */ + index = new(base_ir) ir_variable(glsl_type::int_type, + "vec_index_tmp_i"); + base_ir->insert_before(index); + deref = new(base_ir) ir_dereference_variable(index); + assign = new(base_ir) ir_assignment(deref, orig_deref->array_index, NULL); + base_ir->insert_before(assign); + + /* Temporary where we store whichever value we swizzle out. */ + var = new(base_ir) ir_variable(ir->type, "vec_index_tmp_v"); + base_ir->insert_before(var); + + /* Generate a conditional move of each vector element to the temp. */ + for (i = 0; i < orig_deref->array->type->vector_elements; i++) { + deref = new(base_ir) ir_dereference_variable(index); + condition = new(base_ir) ir_expression(ir_binop_equal, + glsl_type::bool_type, + deref, + new(base_ir) ir_constant(i)); + + /* Just clone the rest of the deref chain when trying to get at the + * underlying variable. + */ + deref = (ir_dereference *)orig_deref->array->clone(NULL); + swizzle = new(base_ir) ir_swizzle(deref, i, 0, 0, 0, 1); + + deref = new(base_ir) ir_dereference_variable(var); + assign = new(base_ir) ir_assignment(deref, swizzle, condition); + base_ir->insert_before(assign); + } + + this->progress = true; + return new(base_ir) ir_dereference_variable(var); +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_expression *ir) +{ + unsigned int i; + + for (i = 0; i < ir->get_num_operands(); i++) { + ir->operands[i] = convert_vec_index_to_cond_assign(ir->operands[i]); + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_swizzle *ir) +{ + /* Can't be hit from normal GLSL, since you can't swizzle a scalar (which + * the result of indexing a vector is. But maybe at some point we'll end up + * using swizzling of scalars for vector construction. + */ + ir->val = convert_vec_index_to_cond_assign(ir->val); + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_assignment *ir) +{ + /* FINISHME: Handle it on the LHS. */ + ir->rhs = convert_vec_index_to_cond_assign(ir->rhs); + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = convert_vec_index_to_cond_assign(param); + + if (new_param != param) { + param->insert_before(new_param); + param->remove(); + } + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_return *ir) +{ + if (ir->value) { + ir->value = convert_vec_index_to_cond_assign(ir->value); + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_if *ir) +{ + ir->condition = convert_vec_index_to_cond_assign(ir->condition); + + return visit_continue; +} + +bool +do_vec_index_to_cond_assign(exec_list *instructions) +{ + ir_vec_index_to_cond_assign_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 9bed2c6bccc..782934a8d7e 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -175,6 +175,7 @@ compile_shader(struct gl_shader *shader) progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; progress = do_vec_index_to_swizzle(shader->ir) || progress; + progress = do_vec_index_to_cond_assign(shader->ir) || progress; progress = do_swizzle_swizzle(shader->ir) || progress; } while (progress); } diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 021e270f18a..daf09e9e652 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1821,7 +1821,13 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) progress = do_dead_code_unlinked(state, shader->ir) || progress; progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; + progress = do_vec_index_to_swizzle(shader->ir) || progress; + /* Do this one after the previous to let the easier pass handle + * constant vector indexing. + */ + progress = do_vec_index_to_cond_assign(shader->ir) || progress; + progress = do_swizzle_swizzle(shader->ir) || progress; } while (progress); } -- cgit v1.2.3 From d4d630b72c7b7f38074addda0f1b819608247d93 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Jul 2010 18:31:32 -0700 Subject: glsl2: Put the declaration in the instruction stream before its initializer. This fixes a regression in the generated code from when I did the ir_validate.cpp-driven rework of assignments. --- src/glsl/ast_to_hir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index f5e93b02547..3de754fa818 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1772,6 +1772,8 @@ ast_declarator_list::hir(exec_list *instructions, } } + instructions->push_tail(var); + if (decl->initializer != NULL) { YYLTYPE initializer_loc = decl->initializer->get_location(); @@ -1918,8 +1920,6 @@ ast_declarator_list::hir(exec_list *instructions, decl->identifier); } - instructions->push_tail(var); - /* Add the variable to the symbol table after processing the initializer. * This differs from most C-like languages, but it follows the GLSL * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 -- cgit v1.2.3 From 570dc0d4004bf09d257b3e4c8664d3c26a8af510 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 09:07:09 -0700 Subject: glsl2: Avoid null deref in scalar constant unop expressions. --- src/glsl/ir_constant_expression.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 541398a91c7..98cbb6cec6c 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -151,7 +151,12 @@ ir_constant_visitor::visit(ir_expression *ir) */ unsigned c0_inc = op0_scalar ? 1 : 0; unsigned c1_inc = op1_scalar ? 1 : 0; - unsigned components = op[op1_scalar ? 0 : 1]->type->components(); + unsigned components; + if (op1_scalar || !op[1]) { + components = op[0]->type->components(); + } else { + components = op[1]->type->components(); + } switch (ir->operation) { case ir_unop_logic_not: -- cgit v1.2.3 From 773025b92c934014b9ceb4ebfdabcfc9d8587aa2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 08:38:16 -0700 Subject: glsl2: Don't forget to walk the parameters to a function in the hv. Fixes segfaults from use after free after the steal of ir nodes and free of the compile context. --- src/glsl/ir_hv_accept.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp index e772018a458..1a88c594394 100644 --- a/src/glsl/ir_hv_accept.cpp +++ b/src/glsl/ir_hv_accept.cpp @@ -116,6 +116,10 @@ ir_function_signature::accept(ir_hierarchical_visitor *v) if (s != visit_continue) return (s == visit_continue_with_parent) ? visit_continue : s; + s = visit_list_elements(v, &this->parameters); + if (s == visit_stop) + return s; + s = visit_list_elements(v, &this->body); return (s == visit_stop) ? s : v->visit_leave(this); } -- cgit v1.2.3 From 6de882334ac7f3d32d04261adfed1397e075ffd5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 08:39:09 -0700 Subject: glsl2: Clean up vec_index_to_cond_assign after the clone return type change. --- src/glsl/ir_vec_index_to_cond_assign.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_vec_index_to_cond_assign.cpp b/src/glsl/ir_vec_index_to_cond_assign.cpp index 6264a430e3b..3f527fcbe71 100644 --- a/src/glsl/ir_vec_index_to_cond_assign.cpp +++ b/src/glsl/ir_vec_index_to_cond_assign.cpp @@ -107,8 +107,8 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue /* Just clone the rest of the deref chain when trying to get at the * underlying variable. */ - deref = (ir_dereference *)orig_deref->array->clone(NULL); - swizzle = new(base_ir) ir_swizzle(deref, i, 0, 0, 0, 1); + swizzle = new(base_ir) ir_swizzle(orig_deref->array->clone(NULL), + i, 0, 0, 0, 1); deref = new(base_ir) ir_dereference_variable(var); assign = new(base_ir) ir_assignment(deref, swizzle, condition); -- cgit v1.2.3 From d674ebcee0d2731e50d6530502cefcebc39dcdb6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 Jul 2010 18:09:39 -0700 Subject: glsl2: Add a pass to simplify if statements returning from both sides. This allows function inlining making the following tests work even without function calls implemented: glsl-fs-functions-2 glsl-fs-functions-3 glsl-vs-functions glsl-vs-functions-2 glsl-vs-functions-3 glsl-vs-vec4-indexing-5 (Note that those tests were designed to trigger actual function calls, and this defeats them. However, those testcases ended up catching the bug in the previous commit.) --- src/glsl/Makefile | 1 + src/glsl/ir_if_return.cpp | 123 +++++++++++++++++++++++++++++++++++++++++ src/glsl/ir_optimization.h | 1 + src/mesa/shader/ir_to_mesa.cpp | 1 + 4 files changed, 126 insertions(+) create mode 100644 src/glsl/ir_if_return.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index d2a687aa335..ddc9d82d61f 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -40,6 +40,7 @@ CXX_SOURCES = \ ir_function_inlining.cpp \ ir_hierarchical_visitor.cpp \ ir_hv_accept.cpp \ + ir_if_return.cpp \ ir_if_simplification.cpp \ ir_mod_to_fract.cpp \ ir_print_visitor.cpp \ diff --git a/src/glsl/ir_if_return.cpp b/src/glsl/ir_if_return.cpp new file mode 100644 index 00000000000..f68dcfb5010 --- /dev/null +++ b/src/glsl/ir_if_return.cpp @@ -0,0 +1,123 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_if_return.cpp + * + * If a function includes an if statement that returns from both + * branches, then make the branches write the return val to a temp and + * return the temp after the if statement. + * + * This allows inlinining in the common case of short functions that + * return one of two values based on a condition. This helps on + * hardware with no branching support, and may even be a useful + * transform on hardware supporting control flow by masked returns + * with normal returns. + */ + +#include "ir.h" + +class ir_if_return_visitor : public ir_hierarchical_visitor { +public: + ir_if_return_visitor() + { + this->progress = false; + } + + ir_visitor_status visit_enter(ir_if *); + + bool progress; +}; + +bool +do_if_return(exec_list *instructions) +{ + ir_if_return_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} + + +ir_visitor_status +ir_if_return_visitor::visit_enter(ir_if *ir) +{ + ir_return *then_return = NULL; + ir_return *else_return = NULL; + + /* Try to find a return statement on both sides. */ + foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { + ir_instruction *then_ir = (ir_instruction *)then_iter.get(); + then_return = then_ir->as_return(); + if (then_return) + break; + } + if (!then_return) + return visit_continue; + + foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { + ir_instruction *else_ir = (ir_instruction *)else_iter.get(); + else_return = else_ir->as_return(); + if (else_return) + break; + } + if (!else_return) + return visit_continue; + + /* Trim off any trailing instructions after the return statements + * on both sides. + */ + while (then_return->get_next()->get_next()) + ((ir_instruction *)then_return->get_next())->remove(); + while (else_return->get_next()->get_next()) + ((ir_instruction *)else_return->get_next())->remove(); + + this->progress = true; + + if (!then_return->value) { + then_return->remove(); + else_return->remove(); + ir->insert_after(new(ir) ir_return(NULL)); + } else { + ir_assignment *assign; + ir_variable *new_var = new(ir) ir_variable(then_return->value->type, + "if_return_tmp"); + ir->insert_before(new_var); + + assign = new(ir) ir_assignment(new(ir) ir_dereference_variable(new_var), + then_return->value, NULL); + then_return->insert_before(assign); + then_return->remove(); + + assign = new(ir) ir_assignment(new(ir) ir_dereference_variable(new_var), + else_return->value, NULL); + else_return->insert_before(assign); + else_return->remove(); + + ir_dereference_variable *deref = new(ir) ir_dereference_variable(new_var); + ir->insert_after(new(ir) ir_return(deref)); + } + + return visit_continue; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 93010dadbee..b03c0644cf0 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -39,6 +39,7 @@ bool do_dead_code_unlinked(struct _mesa_glsl_parse_state *state, exec_list *instructions); bool do_div_to_mul_rcp(exec_list *instructions); bool do_function_inlining(exec_list *instructions); +bool do_if_return(exec_list *instructions); bool do_if_simplification(exec_list *instructions); bool do_mod_to_fract(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index daf09e9e652..2ffff60065d 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1821,6 +1821,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) progress = do_dead_code_unlinked(state, shader->ir) || progress; progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; + progress = do_if_return(shader->ir) || progress; progress = do_vec_index_to_swizzle(shader->ir) || progress; /* Do this one after the previous to let the easier pass handle -- cgit v1.2.3 From 8bb15c1ed55eb71533d2af94a6afbf01e3d23610 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 11:38:55 -0700 Subject: ir_to_mesa: Fill in some uninitialized fields that sometimes contained junk. --- src/mesa/shader/ir_to_mesa.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 2ffff60065d..d1796920725 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -192,11 +192,11 @@ ir_to_mesa_src_reg ir_to_mesa_undef = { }; ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, COND_TR }; ir_to_mesa_dst_reg ir_to_mesa_address_reg = { - PROGRAM_ADDRESS, 0, WRITEMASK_X + PROGRAM_ADDRESS, 0, WRITEMASK_X, COND_TR }; static int swizzle_for_size(int size) @@ -375,6 +375,8 @@ ir_to_mesa_visitor::src_reg_for_float(float val) src_reg.file = PROGRAM_CONSTANT; src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, &val, 1, &src_reg.swizzle); + src_reg.reladdr = GL_FALSE; + src_reg.negate = 0; return src_reg; } -- cgit v1.2.3 From 76101f7c0468c7f346b1a8d6b824fc8914a17bd1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 11:39:48 -0700 Subject: ir_to_mesa: Add support for gl_TextureMatrix access. Fixes glsl-vs-texturematrix-1, and glsl-vs-texturematrix-2 on swrast. --- src/mesa/shader/ir_to_mesa.cpp | 103 +++++++++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 19 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index d1796920725..21b01edefd4 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -869,8 +869,34 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) this->result = src_reg; } +static int +add_matrix_ref(struct gl_program *prog, int *tokens) +{ + int base_pos = -1; + int i; + + /* Add a ref for each column. It looks like the reason we do + * it this way is that _mesa_add_state_reference doesn't work + * for things that aren't vec4s, so the tokens[2]/tokens[3] + * range has to be equal. + */ + for (i = 0; i < 4; i++) { + tokens[2] = i; + tokens[3] = i; + int pos = _mesa_add_state_reference(prog->Parameters, + (gl_state_index *)tokens); + if (base_pos == -1) + base_pos = pos; + else + assert(base_pos + i == pos); + } + + return base_pos; +} + static temp_entry * -get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var) +get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var, + ir_rvalue *array_index) { /* * NOTE: The ARB_vertex_program extension specified that matrices get @@ -915,28 +941,31 @@ get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var) for (i = 0; i < Elements(matrices); i++) { if (strcmp(var->name, matrices[i].name) == 0) { - int j; - int last_pos = -1, base_pos = -1; int tokens[STATE_LENGTH]; + int base_pos = -1; tokens[0] = matrices[i].matrix; - tokens[1] = 0; /* array index! */ tokens[4] = matrices[i].modifier; - - /* Add a ref for each column. It looks like the reason we do - * it this way is that _mesa_add_state_reference doesn't work - * for things that aren't vec4s, so the tokens[2]/tokens[3] - * range has to be equal. - */ - for (j = 0; j < 4; j++) { - tokens[2] = j; - tokens[3] = j; - int pos = _mesa_add_state_reference(prog->Parameters, - (gl_state_index *)tokens); - assert(last_pos == -1 || last_pos == base_pos + j); - if (base_pos == -1) - base_pos = pos; + if (matrices[i].matrix == STATE_TEXTURE_MATRIX) { + ir_constant *index = array_index->constant_expression_value(); + if (index) { + tokens[1] = index->value.i[0]; + base_pos = add_matrix_ref(prog, tokens); + } else { + for (i = 0; i < var->type->length; i++) { + tokens[1] = i; + int pos = add_matrix_ref(prog, tokens); + if (base_pos == -1) + base_pos = pos; + else + assert(base_pos + (int)i * 4 == pos); + } + } + } else { + tokens[1] = 0; /* unused array index */ + base_pos = add_matrix_ref(prog, tokens); } + tokens[4] = matrices[i].modifier; entry = new(mem_ctx) temp_entry(var, PROGRAM_STATE_VAR, @@ -959,7 +988,8 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) if (!entry) { switch (ir->var->mode) { case ir_var_uniform: - entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, ir->var); + entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, ir->var, + NULL); if (entry) break; @@ -1057,9 +1087,44 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) { ir_constant *index; ir_to_mesa_src_reg src_reg; + ir_dereference_variable *deref_var = ir->array->as_dereference_variable(); index = ir->array_index->constant_expression_value(); + if (deref_var && strncmp(deref_var->var->name, + "gl_TextureMatrix", + strlen("gl_TextureMatrix")) == 0) { + ir_to_mesa_src_reg src_reg; + struct temp_entry *entry; + + entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, deref_var->var, + ir->array_index); + assert(entry); + + src_reg.file = entry->file; + src_reg.index = entry->index; + src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); + src_reg.negate = 0; + + if (index) { + src_reg.reladdr = GL_FALSE; + } else { + ir_to_mesa_src_reg index_reg = get_temp(glsl_type::float_type); + + ir->array_index->accept(this); + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + ir_to_mesa_dst_reg_from_src(index_reg), + this->result, src_reg_for_float(4.0)); + + src_reg.reladdr = true; + ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, + index_reg); + } + + this->result = src_reg; + return; + } + /* By the time we make it to this stage, matrices should be broken down * to vectors. */ -- cgit v1.2.3 From 2e85f993d8a014b53ad2f6d295cf66d3fb38b091 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Jul 2010 11:57:16 -0700 Subject: Revert "glsl2: Put the declaration in the instruction stream before its initializer." This change causes segfaults in other tests. A fix for both sets of segfaults is coming. This reverts commit d4d630b72c7b7f38074addda0f1b819608247d93. --- src/glsl/ast_to_hir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 3de754fa818..f5e93b02547 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1772,8 +1772,6 @@ ast_declarator_list::hir(exec_list *instructions, } } - instructions->push_tail(var); - if (decl->initializer != NULL) { YYLTYPE initializer_loc = decl->initializer->get_location(); @@ -1920,6 +1918,8 @@ ast_declarator_list::hir(exec_list *instructions, decl->identifier); } + instructions->push_tail(var); + /* Add the variable to the symbol table after processing the initializer. * This differs from most C-like languages, but it follows the GLSL * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 -- cgit v1.2.3 From c44556317abf77ca6e344c79d119c91bebe25c8c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Jul 2010 12:12:48 -0700 Subject: exec_list: Add method to append one complete list to another --- src/glsl/list.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/glsl/list.h b/src/glsl/list.h index d449bdd8b12..b5a413dc511 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -385,6 +385,30 @@ struct exec_list { } } + /** + * Append all nodes from the source list to the target list + */ + void + append_list(exec_list *source) + { + if (source->is_empty()) + return; + + /* Link the first node of the source with the last node of the target list. + */ + this->tail_pred->next = source->head; + source->head->prev = this->tail_pred; + + /* Make the tail of the source list be the tail of the target list. + */ + this->tail_pred = source->tail_pred; + this->tail_pred->next = (exec_node *) &this->tail; + + /* Make the source list empty for good measure. + */ + source->make_empty(); + } + exec_list_iterator iterator() { return exec_list_iterator(head); -- cgit v1.2.3 From e78e0fa42b49b50ed1150f7fdb74bf942ebd6bcf Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Jul 2010 12:13:34 -0700 Subject: glsl2: Put the initializer in the instruction stream after the declaration --- src/glsl/ast_to_hir.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index f5e93b02547..b21131f60f8 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1772,6 +1772,13 @@ ast_declarator_list::hir(exec_list *instructions, } } + /* Process the initializer and add its instructions to a temporary + * list. This list will be added to the instruction stream (below) after + * the declaration is added. This is done because in some cases (such as + * redeclarations) the declaration may not actually be added to the + * instruction stream. + */ + exec_list intializer_instructions; if (decl->initializer != NULL) { YYLTYPE initializer_loc = decl->initializer->get_location(); @@ -1801,7 +1808,8 @@ ast_declarator_list::hir(exec_list *instructions, } ir_dereference *const lhs = new(ctx) ir_dereference_variable(var); - ir_rvalue *rhs = decl->initializer->hir(instructions, state); + ir_rvalue *rhs = decl->initializer->hir(&intializer_instructions, + state); /* Calculate the constant value if this is a const or uniform * declaration. @@ -1829,7 +1837,7 @@ ast_declarator_list::hir(exec_list *instructions, /* Never emit code to initialize a uniform. */ if (!this->type->qualifier.uniform) - result = do_assignment(instructions, state, lhs, rhs, + result = do_assignment(&intializer_instructions, state, lhs, rhs, this->get_location()); var->read_only = temp; } @@ -1919,6 +1927,7 @@ ast_declarator_list::hir(exec_list *instructions, } instructions->push_tail(var); + instructions->append_list(&intializer_instructions); /* Add the variable to the symbol table after processing the initializer. * This differs from most C-like languages, but it follows the GLSL -- cgit v1.2.3 From 388ab9fa6b468d8c162dd4fc645d2f758c49051c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Jul 2010 11:40:51 -0700 Subject: glsl2: Initialize yylineno and yycolumn so line numbers are sane. --- src/glsl/glcpp/glcpp-lex.l | 1 + src/glsl/glsl_lexer.lpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 6a91b09954a..53e85556c16 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -36,6 +36,7 @@ yylloc->first_line = yylineno; \ yycolumn += yyleng; \ } while(0); +#define YY_USER_INIT yylineno = 0; yycolumn = 0; %} %option bison-bridge bison-locations reentrant noyywrap diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index ddaa19db722..6c1000876e1 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -34,6 +34,8 @@ yycolumn += yyleng; \ } while(0); +#define YY_USER_INIT yylineno = 0; yycolumn = 0; + %} %option bison-bridge bison-locations reentrant noyywrap -- cgit v1.2.3 From acf88f2769c15c9185abe5bd76a885218f431e58 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Jul 2010 12:08:23 -0700 Subject: ir_constant_expression: Fix loop increments. --- src/glsl/ir_constant_expression.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 98cbb6cec6c..0fe93adcead 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -149,8 +149,8 @@ ir_constant_visitor::visit(ir_expression *ir) /* When iterating over a vector or matrix's components, we want to increase * the loop counter. However, for scalars, we want to stay at 0. */ - unsigned c0_inc = op0_scalar ? 1 : 0; - unsigned c1_inc = op1_scalar ? 1 : 0; + unsigned c0_inc = op0_scalar ? 0 : 1; + unsigned c1_inc = op1_scalar ? 0 : 1; unsigned components; if (op1_scalar || !op[1]) { components = op[0]->type->components(); -- cgit v1.2.3 From 43b5b03d67ce890e867c81d4a5cfc4871d711d43 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 14:04:30 -0700 Subject: glsl2: Actually add the declaration of _post_incdec_temp. --- src/glsl/ast_to_hir.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index b21131f60f8..e716b8a11e7 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -571,6 +571,7 @@ get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) /* FINISHME: Give unique names to the temporaries. */ var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp"); + instructions->push_tail(var); var->mode = ir_var_auto; instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), -- cgit v1.2.3 From 9cbd8a1d5a85f39f12e9edbd2defbb9e9d0468ef Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 12:25:22 -0700 Subject: glsl2: Fix ir_div_to_mul_rcp for integer division. rcp of an integer value did not produce the result you're looking for. Instead, do the a * rcp(b) as float and truncate after. This mostly fixes glsl-fs-loop-nested. --- src/glsl/ir_div_to_mul_rcp.cpp | 56 +++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/src/glsl/ir_div_to_mul_rcp.cpp b/src/glsl/ir_div_to_mul_rcp.cpp index ce84add2213..640d5d64f98 100644 --- a/src/glsl/ir_div_to_mul_rcp.cpp +++ b/src/glsl/ir_div_to_mul_rcp.cpp @@ -33,6 +33,7 @@ */ #include "ir.h" +#include "glsl_types.h" class ir_div_to_mul_rcp_visitor : public ir_hierarchical_visitor { public: @@ -61,16 +62,53 @@ ir_div_to_mul_rcp_visitor::visit_leave(ir_expression *ir) if (ir->operation != ir_binop_div) return visit_continue; - /* New expression for the 1.0 / op1 */ - ir_rvalue *expr; - expr = new(ir) ir_expression(ir_unop_rcp, - ir->operands[1]->type, - ir->operands[1], - NULL); + if (ir->operands[1]->type->base_type != GLSL_TYPE_INT && + ir->operands[1]->type->base_type != GLSL_TYPE_UINT) { + /* New expression for the 1.0 / op1 */ + ir_rvalue *expr; + expr = new(ir) ir_expression(ir_unop_rcp, + ir->operands[1]->type, + ir->operands[1], + NULL); + + /* op0 / op1 -> op0 * (1.0 / op1) */ + ir->operation = ir_binop_mul; + ir->operands[1] = expr; + } else { + /* Be careful with integer division -- we need to do it as a + * float and re-truncate, since rcp(n > 1) of an integer would + * just be 0. + */ + ir_rvalue *op0, *op1; + const struct glsl_type *vec_type; + + vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, + ir->operands[1]->type->vector_elements, + ir->operands[1]->type->matrix_columns); + + if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) + op1 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[1], NULL); + else + op1 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[1], NULL); + + op1 = new(ir) ir_expression(ir_unop_rcp, op1->type, op1, NULL); + + vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, + ir->operands[0]->type->vector_elements, + ir->operands[0]->type->matrix_columns); + + if (ir->operands[0]->type->base_type == GLSL_TYPE_INT) + op0 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[0], NULL); + else + op0 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[0], NULL); + + op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1); + + ir->operation = ir_unop_f2i; + ir->operands[0] = op0; + ir->operands[1] = NULL; + } - /* op0 / op1 -> op0 * (1.0 / op1) */ - ir->operation = ir_binop_mul; - ir->operands[1] = expr; this->made_progress = true; return visit_continue; -- cgit v1.2.3 From 0b74bbb3dcf07489e1dbd1976f07093ad7821e51 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 14:53:43 -0700 Subject: glsl: Fix the setup of refract()'s output for vec3/vec4 and k < 0.0. caught by valgrind. --- src/glsl/builtin_function.cpp | 4 ++-- src/glsl/builtins/110/refract | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 40c85e7c989..5b3b49d3107 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -1808,7 +1808,7 @@ static const char *builtins_110_refract = { " (expression float dot (var_ref n) (var_ref i))\n" " (expression float dot (var_ref n) (var_ref i))))))))\n" " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant vec3 (0.0 0.0))))\n" + " ((return (constant vec3 (0.0 0.0 0.0))))\n" " ((return (expression vec3 -\n" " (expression vec3 * (var_ref eta) (var_ref i))\n" " (expression vec3 *\n" @@ -1833,7 +1833,7 @@ static const char *builtins_110_refract = { " (expression float dot (var_ref n) (var_ref i))\n" " (expression float dot (var_ref n) (var_ref i))))))))\n" " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant vec4 (0.0 0.0))))\n" + " ((return (constant vec4 (0.0 0.0 0.0 0.0))))\n" " ((return (expression vec4 -\n" " (expression vec4 * (var_ref eta) (var_ref i))\n" " (expression vec4 *\n" diff --git a/src/glsl/builtins/110/refract b/src/glsl/builtins/110/refract index e9b1475294a..522ab411734 100644 --- a/src/glsl/builtins/110/refract +++ b/src/glsl/builtins/110/refract @@ -64,7 +64,7 @@ (expression float dot (var_ref n) (var_ref i)) (expression float dot (var_ref n) (var_ref i)))))))) (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant vec3 (0.0 0.0)))) + ((return (constant vec3 (0.0 0.0 0.0)))) ((return (expression vec3 - (expression vec3 * (var_ref eta) (var_ref i)) (expression vec3 * @@ -89,7 +89,7 @@ (expression float dot (var_ref n) (var_ref i)) (expression float dot (var_ref n) (var_ref i)))))))) (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant vec4 (0.0 0.0)))) + ((return (constant vec4 (0.0 0.0 0.0 0.0)))) ((return (expression vec4 - (expression vec4 * (var_ref eta) (var_ref i)) (expression vec4 * -- cgit v1.2.3 From 35c89204e597e6d4d3e8b8c665ce1c51d6dde4d7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Jul 2010 16:28:39 -0700 Subject: linker: Use bit-0 instead of VERT_BIT_GENERIC0 Uses of the bits for allocation are offset by 16, and VERT_BIT_GENERIC0 already has the 16 offset. As a result, it was preventing the wrong thing from being allocated. --- src/glsl/linker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 5227d42e353..eb10f90a911 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -667,7 +667,7 @@ assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index * be explicitly assigned by via glBindAttribLocation. Mark it as reserved * to prevent it from being automatically allocated below. */ - used_locations |= VERT_BIT_GENERIC0; + used_locations |= (1 << 0); for (unsigned i = 0; i < num_attr; i++) { /* Mask representing the contiguous slots that will be used by this -- cgit v1.2.3 From e024c5c6900c068634c2726d9ccfb9beac966c57 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 7 Jul 2010 15:23:27 -0700 Subject: ir_reader: Don't emit ir_function multiple times. --- src/glsl/ir_reader.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 80dbc086457..03212830cdb 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -192,6 +192,7 @@ static ir_function * read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) { void *ctx = st; + bool added = false; if (list->length() < 3) { ir_read_error(st, list, "Expected (function (signature ...) ...)"); return NULL; @@ -206,7 +207,7 @@ read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) ir_function *f = st->symbols->get_function(name->value()); if (f == NULL) { f = new(ctx) ir_function(name->value()); - bool added = st->symbols->add_function(f->name, f); + added = st->symbols->add_function(f->name, f); assert(added); } @@ -228,7 +229,7 @@ read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) read_function_sig(st, f, siglist, skip_body); } - return f; + return added ? f : NULL; } static void @@ -321,11 +322,8 @@ read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions, foreach_iter(exec_list_iterator, it, list->subexpressions) { s_expression *sub = (s_expression*) it.get(); ir_instruction *ir = read_instruction(st, sub, loop_ctx); - if (ir == NULL) { - ir_read_error(st, sub, "Invalid instruction.\n"); - return; - } - instructions->push_tail(ir); + if (ir != NULL) + instructions->push_tail(ir); } } @@ -344,8 +342,10 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, } s_list *list = SX_AS_LIST(expr); - if (list == NULL || list->subexpressions.is_empty()) + if (list == NULL || list->subexpressions.is_empty()) { + ir_read_error(st, expr, "Invalid instruction.\n"); return NULL; + } s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head()); if (tag == NULL) { -- cgit v1.2.3 From 9b68b88e43c424439d425534ef280ee7a9406a1b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 15:55:47 -0700 Subject: ir_to_mesa: Add support for matrix * matrix. --- src/mesa/shader/ir_to_mesa.cpp | 43 ++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 21b01edefd4..00fa2cccfef 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -623,9 +623,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_binop_sub: ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); break; + case ir_binop_mul: - if (ir->operands[0]->type->is_matrix() && - !ir->operands[1]->type->is_matrix()) { + if (ir->operands[0]->type->is_matrix()) { if (ir->operands[1]->type->is_scalar()) { ir_to_mesa_dst_reg dst_column = result_dst; ir_to_mesa_src_reg src_column = op[0]; @@ -636,21 +636,32 @@ ir_to_mesa_visitor::visit(ir_expression *ir) src_column.index++; } } else { - ir_to_mesa_src_reg src_column = op[0]; + /* matrix * vec or matrix * matrix */ + int op1_col; + ir_to_mesa_dst_reg dst_column = result_dst; + ir_to_mesa_src_reg dst_column_src; ir_to_mesa_src_reg src_chan = op[1]; - assert(!ir->operands[1]->type->is_matrix() || - !"FINISHME: matrix * matrix"); - for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { - src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); - if (i == 0) { - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - result_dst, src_column, src_chan); - } else { - ir_to_mesa_emit_op3(ir, OPCODE_MAD, - result_dst, src_column, src_chan, - result_src); - } - src_column.index++; + + dst_column_src = ir_to_mesa_src_reg_from_dst(result_dst); + for (op1_col = 0; op1_col < ir->operands[1]->type->matrix_columns; + op1_col++) { + ir_to_mesa_src_reg src_column = op[0]; + + for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { + src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); + if (i == 0) { + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + dst_column, src_column, src_chan); + } else { + ir_to_mesa_emit_op3(ir, OPCODE_MAD, + dst_column, src_column, src_chan, + dst_column_src); + } + src_column.index++; + } + src_chan.index++; + dst_column.index++; + dst_column_src.index++; } } } else if (ir->operands[1]->type->is_matrix()) { -- cgit v1.2.3 From 7d8091f7cca0314dd66599bdce5bfcf09fe8b578 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 16:10:04 -0700 Subject: ir_to_mesa: Add support for assignment of aggregates. --- src/mesa/shader/ir_to_mesa.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 00fa2cccfef..9497b17a2a9 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1268,6 +1268,7 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) { struct ir_to_mesa_dst_reg l; struct ir_to_mesa_src_reg r; + int i; assert(!ir->lhs->type->is_matrix()); assert(!ir->lhs->type->is_array()); @@ -1295,10 +1296,18 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) * an extra computing the condition. */ condition.negate = ~condition.negate; - ir_to_mesa_emit_op3(ir, OPCODE_CMP, l, - condition, r, ir_to_mesa_src_reg_from_dst(l)); + for (i = 0; i < type_size(ir->lhs->type); i++) { + ir_to_mesa_emit_op3(ir, OPCODE_CMP, l, + condition, r, ir_to_mesa_src_reg_from_dst(l)); + l.index++; + r.index++; + } } else { - ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); + for (i = 0; i < type_size(ir->lhs->type); i++) { + ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); + l.index++; + r.index++; + } } } -- cgit v1.2.3 From 9968f1b23c475c99139f0209c7a049ed00df01af Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 16:16:09 -0700 Subject: ir_to_mesa: Only allocate a vector per column of a matrix. --- src/mesa/shader/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 9497b17a2a9..5cb5564d503 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -393,7 +393,7 @@ type_size(const struct glsl_type *type) case GLSL_TYPE_FLOAT: case GLSL_TYPE_BOOL: if (type->is_matrix()) { - return 4; /* FINISHME: Not all matrices are 4x4. */ + return type->matrix_columns; } else { /* Regardless of size of vector, it gets a vec4. This is bad * packing for things like floats, but otherwise arrays become a -- cgit v1.2.3 From 69676fc6a3ffbc2c99af541b954427c2e4966d68 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 17:24:00 -0700 Subject: ir_to_mesa: Don't assert that we can't assign matrices. It should work now. --- src/mesa/shader/ir_to_mesa.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 5cb5564d503..e1c0fca7bdd 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1270,7 +1270,6 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) struct ir_to_mesa_src_reg r; int i; - assert(!ir->lhs->type->is_matrix()); assert(!ir->lhs->type->is_array()); assert(ir->lhs->type->base_type != GLSL_TYPE_STRUCT); -- cgit v1.2.3 From b4d0c0e0ee983ee614b047799c3e01221a353c98 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 17:08:58 -0700 Subject: ir_to_mesa: Add support for adding/subtracting matrices. This isn't really tested, but didn't break normal vector add/sub. --- src/mesa/shader/ir_to_mesa.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index e1c0fca7bdd..b42ac84842e 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -178,6 +178,13 @@ public: ir_to_mesa_src_reg src0, ir_to_mesa_src_reg src1); + void ir_to_mesa_emit_addsub(ir_expression *ir, + enum prog_opcode opcode, + struct ir_to_mesa_src_reg result_src, + struct ir_to_mesa_dst_reg result_dst, + struct ir_to_mesa_src_reg op0, + struct ir_to_mesa_src_reg op1); + int *sampler_map; int sampler_map_size; @@ -530,6 +537,32 @@ ir_to_mesa_visitor::visit(ir_function *ir) } } +void +ir_to_mesa_visitor::ir_to_mesa_emit_addsub(ir_expression *ir, + enum prog_opcode opcode, + struct ir_to_mesa_src_reg result_src, + struct ir_to_mesa_dst_reg result_dst, + struct ir_to_mesa_src_reg op0, + struct ir_to_mesa_src_reg op1) +{ + ir_to_mesa_dst_reg dst_column = result_dst; + int matrix_columns; + + if (ir->operands[0]->type->is_matrix()) + matrix_columns = ir->operands[0]->type->matrix_columns; + else + matrix_columns = ir->operands[1]->type->matrix_columns; + + for (int i = 0; i < matrix_columns; i++) { + ir_to_mesa_emit_op2(ir, opcode, dst_column, op0, op1); + dst_column.index++; + if (ir->operands[0]->type->is_matrix()) + op0.index++; + if (ir->operands[1]->type->is_matrix()) + op1.index++; + } +} + void ir_to_mesa_visitor::visit(ir_expression *ir) { @@ -554,7 +587,8 @@ ir_to_mesa_visitor::visit(ir_expression *ir) /* Only expression implemented for matrices yet */ assert(!ir->operands[operand]->type->is_matrix() || - ir->operation == ir_binop_mul); + ir->operation == ir_binop_mul || + ir->operation == ir_binop_add); } this->result.file = PROGRAM_UNDEFINED; @@ -618,10 +652,12 @@ ir_to_mesa_visitor::visit(ir_expression *ir) break; case ir_binop_add: - ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]); + ir_to_mesa_emit_addsub(ir, OPCODE_ADD, + result_src, result_dst, op[0], op[1]); break; case ir_binop_sub: - ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); + ir_to_mesa_emit_addsub(ir, OPCODE_SUB, + result_src, result_dst, op[0], op[1]); break; case ir_binop_mul: -- cgit v1.2.3 From ffd24b0a6844871eed0c78608431e2f82d5615e1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 17:49:05 -0700 Subject: ir_to_mesa: Add support for constant matrices (untested). --- src/mesa/shader/ir_to_mesa.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index b42ac84842e..727a815753c 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1355,8 +1355,39 @@ ir_to_mesa_visitor::visit(ir_constant *ir) GLfloat *values = stack_vals; unsigned int i; - if (ir->type->is_matrix() || ir->type->is_array()) { - assert(!"FINISHME: array/matrix constants"); + if (ir->type->is_array()) { + ir->print(); + printf("\n"); + assert(!"FINISHME: array constants"); + } + + if (ir->type->is_matrix()) { + /* Unfortunately, 4 floats is all we can get into + * _mesa_add_unnamed_constant. So, make a temp to store the + * matrix and move each constant value into it. If we get + * lucky, copy propagation will eliminate the extra moves. + */ + ir_to_mesa_src_reg mat = get_temp(glsl_type::vec4_type); + ir_to_mesa_dst_reg mat_column = ir_to_mesa_dst_reg_from_src(mat); + + for (i = 0; i < ir->type->matrix_columns; i++) { + src_reg.file = PROGRAM_CONSTANT; + + assert(ir->type->base_type == GLSL_TYPE_FLOAT); + values = &ir->value.f[i * ir->type->vector_elements]; + + src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, + values, + ir->type->vector_elements, + &src_reg.swizzle); + src_reg.reladdr = false; + src_reg.negate = 0; + ir_to_mesa_emit_op1(ir, OPCODE_MOV, mat_column, src_reg); + + mat_column.index++; + } + + this->result = mat; } src_reg.file = PROGRAM_CONSTANT; -- cgit v1.2.3 From ea2a03f0a5b8b58ea88ecb607664ea50c9d6e96e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 17:59:50 -0700 Subject: ir_to_mesa: Fix the assertion on LHS array derefs to DWIM. This allows array derefs of matrices now, which makes idr's GLSL demo happy. --- src/mesa/shader/ir_to_mesa.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 727a815753c..4496daf2a55 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1247,21 +1247,24 @@ static struct ir_to_mesa_dst_reg get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) { struct ir_to_mesa_dst_reg dst_reg; - ir_dereference *deref; ir_swizzle *swiz; + ir_dereference_array *deref_array = ir->as_dereference_array(); + /* This should have been handled by ir_vec_index_to_cond_assign */ + if (deref_array) { + assert(!deref_array->array->type->is_vector()); + + /* We don't handle relative addressing on the LHS yet. */ + assert(deref_array->array_index->constant_expression_value() != NULL); + } + /* Use the rvalue deref handler for the most part. We'll ignore * swizzles in it and write swizzles using writemask, though. */ ir->accept(v); dst_reg = ir_to_mesa_dst_reg_from_src(v->result); - if ((deref = ir->as_dereference())) { - ir_dereference_array *deref_array = ir->as_dereference_array(); - assert(!deref_array || deref_array->array->type->is_array()); - - ir->accept(v); - } else if ((swiz = ir->as_swizzle())) { + if ((swiz = ir->as_swizzle())) { dst_reg.writemask = 0; if (swiz->mask.num_components >= 1) dst_reg.writemask |= (1 << swiz->mask.x); -- cgit v1.2.3 From 152b55e74da7bf548d8846538b85960f703d6059 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 19:45:22 -0700 Subject: glsl2: Add support for gl_PointCoord in 1.20. Fixes glsl-fs-pointcoord on swrast (remains broken on 965, like master) --- src/glsl/builtin_variables.h | 4 ++++ src/glsl/ir_variable.cpp | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/glsl/builtin_variables.h b/src/glsl/builtin_variables.h index 77f2fe55023..9551e1accf9 100644 --- a/src/glsl/builtin_variables.h +++ b/src/glsl/builtin_variables.h @@ -70,6 +70,10 @@ static const builtin_variable builtin_110_deprecated_vs_variables[] = { { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" }, }; +static const builtin_variable builtin_120_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, +}; + static const builtin_variable builtin_130_vs_variables[] = { { ir_var_in, -1, "int", "gl_VertexID" }, }; diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 9daad803e96..a0b66b77702 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -311,6 +311,13 @@ generate_120_fs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { generate_110_fs_variables(instructions, state); + + for (unsigned i = 0 + ; i < Elements(builtin_120_fs_variables) + ; i++) { + add_builtin_variable(& builtin_120_fs_variables[i], + instructions, state->symbols); + } } static void -- cgit v1.2.3 From f632a330eccb26c28a3b94216c55994e94988751 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 21:00:32 -0700 Subject: mesa: Fix documentation of BranchTarget for BRK. It was changed in 2009 and the comment wasn't updated. --- src/mesa/shader/prog_instruction.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/prog_instruction.h b/src/mesa/shader/prog_instruction.h index 28c797a4ba8..c1e3a1e80d7 100644 --- a/src/mesa/shader/prog_instruction.h +++ b/src/mesa/shader/prog_instruction.h @@ -384,7 +384,7 @@ struct prog_instruction /** * For BRA and CAL instructions, the location to jump to. * For BGNLOOP, points to ENDLOOP (and vice-versa). - * For BRK, points to BGNLOOP (which points to ENDLOOP). + * For BRK, points to ENDLOOP * For IF, points to ELSE or ENDIF. * For ELSE, points to ENDIF. */ -- cgit v1.2.3 From 25cda5039df0da6c2c65f1cac1bfc750c0c16e82 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Jul 2010 21:28:28 -0700 Subject: mesa: Extend register lifetimes to the end of the largest loop required. Previously, a register defined at main scope and used in a loop in a loop could end up getting marked as needed only from the definition outside of the loops to the end of the inner loop, and we would cleverly slot in something else in its register in the end of the outer loop. Fixes glsl-vs-loop-nested and glsl-fs-loop-nested on glsl2. This doesn't happen much on master because the original compiler does its own register allocation, so we find little we can do with linear scan register (re)allocation. --- src/mesa/shader/prog_optimize.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/mesa/shader/prog_optimize.c b/src/mesa/shader/prog_optimize.c index 2941a17da3f..bd120b8643c 100644 --- a/src/mesa/shader/prog_optimize.c +++ b/src/mesa/shader/prog_optimize.c @@ -728,14 +728,32 @@ sort_interval_list_by_start(struct interval_list *list) #endif } +struct loop_info +{ + GLuint Start, End; /**< Start, end instructions of loop */ +}; /** * Update the intermediate interval info for register 'index' and * instruction 'ic'. */ static void -update_interval(GLint intBegin[], GLint intEnd[], GLuint index, GLuint ic) +update_interval(GLint intBegin[], GLint intEnd[], + struct loop_info *loopStack, GLuint loopStackDepth, + GLuint index, GLuint ic) { + int i; + + /* If the register is used in a loop, extend its lifetime through the end + * of the outermost loop that doesn't contain its definition. + */ + for (i = 0; i < loopStackDepth; i++) { + if (intBegin[index] < loopStack[i].Start) { + ic = loopStack[i].End; + break; + } + } + ASSERT(index < MAX_PROGRAM_TEMPS); if (intBegin[index] == -1) { ASSERT(intEnd[index] == -1); @@ -756,10 +774,6 @@ _mesa_find_temp_intervals(const struct prog_instruction *instructions, GLint intBegin[MAX_PROGRAM_TEMPS], GLint intEnd[MAX_PROGRAM_TEMPS]) { - struct loop_info - { - GLuint Start, End; /**< Start, end instructions of loop */ - }; struct loop_info loopStack[MAX_LOOP_NESTING]; GLuint loopStackDepth = 0; GLuint i; @@ -790,24 +804,16 @@ _mesa_find_temp_intervals(const struct prog_instruction *instructions, const GLuint index = inst->SrcReg[j].Index; if (inst->SrcReg[j].RelAddr) return GL_FALSE; - update_interval(intBegin, intEnd, index, i); - if (loopStackDepth > 0) { - /* extend temp register's interval to end of loop */ - GLuint loopEnd = loopStack[loopStackDepth - 1].End; - update_interval(intBegin, intEnd, index, loopEnd); - } + update_interval(intBegin, intEnd, loopStack, loopStackDepth, + index, i); } } if (inst->DstReg.File == PROGRAM_TEMPORARY) { const GLuint index = inst->DstReg.Index; if (inst->DstReg.RelAddr) return GL_FALSE; - update_interval(intBegin, intEnd, index, i); - if (loopStackDepth > 0) { - /* extend temp register's interval to end of loop */ - GLuint loopEnd = loopStack[loopStackDepth - 1].End; - update_interval(intBegin, intEnd, index, loopEnd); - } + update_interval(intBegin, intEnd, loopStack, loopStackDepth, + index, i); } } } -- cgit v1.2.3 From dfd30ca6a95a7d95835dad78ffe1fba4d1f4ef69 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 12:40:52 -0700 Subject: glsl2: Remove generate_temporary and global temporary counter. Most places in the code simply use a static name, which works because names are never used to look up an ir_variable. generate_temporary is simply unnecessary (and looks like it would leak memory, and isn't thread safe...) --- src/glsl/ast_to_hir.cpp | 32 +++++--------------------------- src/glsl/glsl_parser_extras.h | 3 --- src/glsl/main.cpp | 1 - src/mesa/shader/ir_to_mesa.cpp | 1 - 4 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index e716b8a11e7..e03bb6394fb 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -542,27 +542,6 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, return new(ctx) ir_dereference_variable(var); } - -/** - * Generate a new temporary and add its declaration to the instruction stream - */ -static ir_variable * -generate_temporary(const glsl_type *type, exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - char *name = (char *) malloc(sizeof(char) * 13); - - snprintf(name, 13, "tmp_%08X", state->temp_index); - state->temp_index++; - - ir_variable *const var = new(ctx) ir_variable(type, name); - instructions->push_tail(var); - - return var; -} - - static ir_rvalue * get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) { @@ -840,8 +819,8 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; } - ir_variable *const tmp = generate_temporary(glsl_type::bool_type, - instructions, state); + ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, + "and_tmp"); ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); ir_assignment *const then_assign = @@ -892,8 +871,8 @@ ast_expression::hir(exec_list *instructions, ir_if *const stmt = new(ctx) ir_if(op[0]); instructions->push_tail(stmt); - ir_variable *const tmp = generate_temporary(glsl_type::bool_type, - instructions, state); + ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, + "or_tmp"); op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); @@ -1068,8 +1047,7 @@ ast_expression::hir(exec_list *instructions, && (cond_val != NULL) && (then_val != NULL) && (else_val != NULL)) { result = (cond_val->value.b[0]) ? then_val : else_val; } else { - ir_variable *const tmp = generate_temporary(type, - instructions, state); + ir_variable *const tmp = new(ctx) ir_variable(type, "conditional_tmp"); ir_if *const stmt = new(ctx) ir_if(op[0]); instructions->push_tail(stmt); diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 16f72681816..4b28ae118df 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -67,9 +67,6 @@ struct _mesa_glsl_parse_state { /** Was there an error during compilation? */ bool error; - /** Index of last generated anonymous temporary. */ - unsigned temp_index; - /** Loop or switch statement containing the current instructions. */ class ir_instruction *loop_or_switch_nesting; diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 782934a8d7e..dd43d12474b 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -124,7 +124,6 @@ compile_shader(struct gl_shader *shader) state->symbols = new(shader) glsl_symbol_table; state->info_log = talloc_strdup(shader, ""); state->error = false; - state->temp_index = 0; state->loop_or_switch_nesting = NULL; state->ARB_texture_rectangle_enable = true; diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 4496daf2a55..708c6fece1c 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1938,7 +1938,6 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) state->symbols = new(shader) glsl_symbol_table; state->info_log = talloc_strdup(shader, ""); state->error = false; - state->temp_index = 0; state->loop_or_switch_nesting = NULL; state->ARB_texture_rectangle_enable = true; -- cgit v1.2.3 From f3290e950cd78a423d380b7e0a7aa18eb7718e27 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 13:06:22 -0700 Subject: glsl2: Add foreach_list_safe which works even when mutating the list. In particular, with foreach_list_safe, one can remove and free the current node without crashes; if new nodes are added after the current node, they will be properly visited as well. Signed-off-by: Ian Romanick --- src/glsl/list.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/glsl/list.h b/src/glsl/list.h index b5a413dc511..48502fb4c8c 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -421,6 +421,20 @@ struct exec_list { #endif }; +/** + * This version is safe even if the current node is removed. If you insert + * new nodes before the current node, they will be processed next. + * + * \note + * The extra test for \c __node being \c NULL is required because after the + * iteration \c __prev coupld be the last node in the list. The loop increment + * then causes \c __prev to point to the sentinal and \c __node to be \c NULL. + */ +#define foreach_list_safe(__node, __list) \ + for (exec_node * __prev = (exec_node *) (__list), * __node = (__list)->head \ + ; __node != NULL && (__node)->next != NULL \ + ; __prev = (__prev)->next, __node = (__prev)->next) + #define foreach_list(__node, __list) \ for (exec_node * __node = (__list)->head \ ; (__node)->next != NULL \ -- cgit v1.2.3 From a4dde28ee6893ab99c6ca93699392bb8bc2d981c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 13:08:14 -0700 Subject: glsl2: Use new foreach_list_safe abstraction. --- src/glsl/ir_hv_accept.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp index 1a88c594394..46bc5b17fe3 100644 --- a/src/glsl/ir_hv_accept.cpp +++ b/src/glsl/ir_hv_accept.cpp @@ -32,20 +32,16 @@ /** * Process a list of nodes using a hierarchical vistor * - * \warning * This function will operate correctly if a node being processed is removed - * from list. However, if nodes are added to the list after the node being - * processed, some of the added noded may not be processed. + * from the list. If nodes are inserted before the current node, they will be + * processed next. */ ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l) { - exec_node *next; ir_instruction *prev_base_ir = v->base_ir; - for (exec_node *n = l->head; n->next != NULL; n = next) { - next = n->next; - + foreach_list_safe(n, l) { ir_instruction *const ir = (ir_instruction *) n; v->base_ir = ir; ir_visitor_status s = ir->accept(v); -- cgit v1.2.3 From 59df3385e1c413332c75be5d0e7751972d45430e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 17:59:56 -0700 Subject: ast_function: Remove unnecessary check for empty constructors. This case is already caught by a later check that ensures sufficient components were provided, based on the type. --- src/glsl/ast_function.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index b6811153879..c6cc3eb43c2 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -923,15 +923,6 @@ ast_function_expression::hir(exec_list *instructions, bool all_parameters_are_constant = true; - /* This handles invalid constructor calls such as 'vec4 v = vec4();' - */ - if (this->expressions.is_empty()) { - _mesa_glsl_error(& loc, state, "too few components to construct " - "`%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - foreach_list (n, &this->expressions) { ast_node *ast = exec_node_data(ast_node, n, link); ir_rvalue *result = -- cgit v1.2.3 From f58bbd134e921b14f50ecd1e76b2943753ba194c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 18:03:28 -0700 Subject: ast_function: Move error return earlier and don't indent the world. This has no functional changes. --- src/glsl/ast_function.cpp | 281 +++++++++++++++++++++++----------------------- 1 file changed, 139 insertions(+), 142 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index c6cc3eb43c2..566eac4d332 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -865,7 +865,7 @@ ast_function_expression::hir(exec_list *instructions, void *ctx = state; /* There are three sorts of function calls. * - * 1. contstructors - The first subexpression is an ast_type_specifier. + * 1. constructors - The first subexpression is an ast_type_specifier. * 2. methods - Only the .length() method of array types. * 3. functions - Calls to regular old functions. * @@ -907,167 +907,164 @@ ast_function_expression::hir(exec_list *instructions, * correct order. These constructors follow essentially the same type * matching rules as functions. */ - if (constructor_type->is_numeric() || constructor_type->is_boolean()) { - /* Total number of components of the type being constructed. - */ - const unsigned type_components = constructor_type->components(); + if (!constructor_type->is_numeric() && !constructor_type->is_boolean()) + return ir_call::get_error_instruction(ctx); - /* Number of components from parameters that have actually been - * consumed. This is used to perform several kinds of error checking. - */ - unsigned components_used = 0; - - unsigned matrix_parameters = 0; - unsigned nonmatrix_parameters = 0; - exec_list actual_parameters; - - bool all_parameters_are_constant = true; - - foreach_list (n, &this->expressions) { - ast_node *ast = exec_node_data(ast_node, n, link); - ir_rvalue *result = - ast->hir(instructions, state)->as_rvalue(); - - /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: - * - * "It is an error to provide extra arguments beyond this - * last used argument." - */ - if (components_used >= type_components) { - _mesa_glsl_error(& loc, state, "too many parameters to `%s' " - "constructor", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } + /* Total number of components of the type being constructed. */ + const unsigned type_components = constructor_type->components(); - if (!result->type->is_numeric() && !result->type->is_boolean()) { - _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " - "non-numeric data type", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } + /* Number of components from parameters that have actually been + * consumed. This is used to perform several kinds of error checking. + */ + unsigned components_used = 0; - /* Count the number of matrix and nonmatrix parameters. This - * is used below to enforce some of the constructor rules. - */ - if (result->type->is_matrix()) - matrix_parameters++; - else - nonmatrix_parameters++; - - /* Type cast the parameter and add it to the parameter list for - * the constructor. - */ - const glsl_type *desired_type = - glsl_type::get_instance(constructor_type->base_type, - result->type->vector_elements, - result->type->matrix_columns); - result = convert_component(result, desired_type); - - /* Attempt to convert the parameter to a constant valued expression. - * After doing so, track whether or not all the parameters to the - * constructor are trivially constant valued expressions. - */ - ir_rvalue *const constant = result->constant_expression_value(); - - if (constant != NULL) - result = constant; - else - all_parameters_are_constant = false; - - actual_parameters.push_tail(result); - components_used += result->type->components(); - } + unsigned matrix_parameters = 0; + unsigned nonmatrix_parameters = 0; + exec_list actual_parameters; - /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: - * - * "It is an error to construct matrices from other matrices. This - * is reserved for future use." - */ - if ((state->language_version <= 110) && (matrix_parameters > 0) - && constructor_type->is_matrix()) { - _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " - "matrix in GLSL 1.10", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } + bool all_parameters_are_constant = true; + + foreach_list (n, &this->expressions) { + ast_node *ast = exec_node_data(ast_node, n, link); + ir_rvalue *result = ast->hir(instructions, state)->as_rvalue(); /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: * - * "If a matrix argument is given to a matrix constructor, it is - * an error to have any other arguments." + * "It is an error to provide extra arguments beyond this + * last used argument." */ - if ((matrix_parameters > 0) - && ((matrix_parameters + nonmatrix_parameters) > 1) - && constructor_type->is_matrix()) { - _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, " - "matrix must be only parameter", + if (components_used >= type_components) { + _mesa_glsl_error(& loc, state, "too many parameters to `%s' " + "constructor", constructor_type->name); return ir_call::get_error_instruction(ctx); } - /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: - * - * "In these cases, there must be enough components provided in the - * arguments to provide an initializer for every component in the - * constructed value." - */ - if ((components_used < type_components) && (components_used != 1)) { - _mesa_glsl_error(& loc, state, "too few components to construct " - "`%s'", + if (!result->type->is_numeric() && !result->type->is_boolean()) { + _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " + "non-numeric data type", constructor_type->name); return ir_call::get_error_instruction(ctx); } + /* Count the number of matrix and nonmatrix parameters. This + * is used below to enforce some of the constructor rules. + */ + if (result->type->is_matrix()) + matrix_parameters++; + else + nonmatrix_parameters++; - /* If all of the parameters are trivially constant, create a - * constant representing the complete collection of parameters. + /* Type cast the parameter and add it to the parameter list for + * the constructor. */ - if (all_parameters_are_constant) { - if (components_used >= type_components) - return new(ctx) ir_constant(constructor_type, - & actual_parameters); - - /* The above case must handle all scalar constructors. - */ - assert(constructor_type->is_vector() - || constructor_type->is_matrix()); - - /* Constructors with exactly one component are special for - * vectors and matrices. For vectors it causes all elements of - * the vector to be filled with the value. For matrices it - * causes the matrix to be filled with 0 and the diagonal to be - * filled with the value. - */ - ir_constant_data data; - ir_constant *const initializer = - (ir_constant *) actual_parameters.head; - if (constructor_type->is_matrix()) - generate_constructor_matrix(constructor_type, initializer, - &data); - else - generate_constructor_vector(constructor_type, initializer, - &data); - - return new(ctx) ir_constant(constructor_type, &data); - } else if (constructor_type->is_scalar()) { - return dereference_component((ir_rvalue *) actual_parameters.head, - 0); - } else if (constructor_type->is_vector()) { - return emit_inline_vector_constructor(constructor_type, - instructions, - &actual_parameters, - ctx); - } else { - assert(constructor_type->is_matrix()); - return emit_inline_matrix_constructor(constructor_type, - instructions, - &actual_parameters, - ctx); - } + const glsl_type *desired_type = + glsl_type::get_instance(constructor_type->base_type, + result->type->vector_elements, + result->type->matrix_columns); + result = convert_component(result, desired_type); + + /* Attempt to convert the parameter to a constant valued expression. + * After doing so, track whether or not all the parameters to the + * constructor are trivially constant valued expressions. + */ + ir_rvalue *const constant = result->constant_expression_value(); + + if (constant != NULL) + result = constant; + else + all_parameters_are_constant = false; + + actual_parameters.push_tail(result); + components_used += result->type->components(); } - return ir_call::get_error_instruction(ctx); + /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: + * + * "It is an error to construct matrices from other matrices. This + * is reserved for future use." + */ + if ((state->language_version <= 110) && (matrix_parameters > 0) + && constructor_type->is_matrix()) { + _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " + "matrix in GLSL 1.10", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: + * + * "If a matrix argument is given to a matrix constructor, it is + * an error to have any other arguments." + */ + if ((matrix_parameters > 0) + && ((matrix_parameters + nonmatrix_parameters) > 1) + && constructor_type->is_matrix()) { + _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, " + "matrix must be only parameter", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: + * + * "In these cases, there must be enough components provided in the + * arguments to provide an initializer for every component in the + * constructed value." + */ + if ((components_used < type_components) && (components_used != 1)) { + _mesa_glsl_error(& loc, state, "too few components to construct " + "`%s'", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + + /* If all of the parameters are trivially constant, create a + * constant representing the complete collection of parameters. + */ + if (all_parameters_are_constant) { + if (components_used >= type_components) + return new(ctx) ir_constant(constructor_type, + & actual_parameters); + + /* The above case must handle all scalar constructors. + */ + assert(constructor_type->is_vector() + || constructor_type->is_matrix()); + + /* Constructors with exactly one component are special for + * vectors and matrices. For vectors it causes all elements of + * the vector to be filled with the value. For matrices it + * causes the matrix to be filled with 0 and the diagonal to be + * filled with the value. + */ + ir_constant_data data; + ir_constant *const initializer = + (ir_constant *) actual_parameters.head; + if (constructor_type->is_matrix()) + generate_constructor_matrix(constructor_type, initializer, + &data); + else + generate_constructor_vector(constructor_type, initializer, + &data); + + return new(ctx) ir_constant(constructor_type, &data); + } else if (constructor_type->is_scalar()) { + return dereference_component((ir_rvalue *) actual_parameters.head, + 0); + } else if (constructor_type->is_vector()) { + return emit_inline_vector_constructor(constructor_type, + instructions, + &actual_parameters, + ctx); + } else { + assert(constructor_type->is_matrix()); + return emit_inline_matrix_constructor(constructor_type, + instructions, + &actual_parameters, + ctx); + } } else { const ast_expression *id = subexpressions[0]; YYLTYPE loc = id->get_location(); -- cgit v1.2.3 From 284d821206d74fddb346cd0d892d2dcec463e2a5 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 18:15:32 -0700 Subject: ast_function: Fix non-float constructors with matrix arguments. Previously, code like ivec4(mat2(...)) would fail because the compiler would naively try to convert a mat2 to an imat2...which doesn't exist. Now, a separate pass breaks such matrices down to their columns, which can be converted from vec2 to ivec2. Fixes piglit tests constructor-11.vert, constructor-14.vert, constructor-15.vert, and CorrectConstFolding2.frag. --- src/glsl/ast_function.cpp | 77 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 22 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 566eac4d332..9315a92ecbc 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -922,8 +922,6 @@ ast_function_expression::hir(exec_list *instructions, unsigned nonmatrix_parameters = 0; exec_list actual_parameters; - bool all_parameters_are_constant = true; - foreach_list (n, &this->expressions) { ast_node *ast = exec_node_data(ast_node, n, link); ir_rvalue *result = ast->hir(instructions, state)->as_rvalue(); @@ -955,26 +953,6 @@ ast_function_expression::hir(exec_list *instructions, else nonmatrix_parameters++; - /* Type cast the parameter and add it to the parameter list for - * the constructor. - */ - const glsl_type *desired_type = - glsl_type::get_instance(constructor_type->base_type, - result->type->vector_elements, - result->type->matrix_columns); - result = convert_component(result, desired_type); - - /* Attempt to convert the parameter to a constant valued expression. - * After doing so, track whether or not all the parameters to the - * constructor are trivially constant valued expressions. - */ - ir_rvalue *const constant = result->constant_expression_value(); - - if (constant != NULL) - result = constant; - else - all_parameters_are_constant = false; - actual_parameters.push_tail(result); components_used += result->type->components(); } @@ -1019,6 +997,61 @@ ast_function_expression::hir(exec_list *instructions, return ir_call::get_error_instruction(ctx); } + /* Later, we cast each parameter to the same base type as the + * constructor. Since there are no non-floating point matrices, we + * need to break them up into a series of column vectors. + */ + if (constructor_type->base_type != GLSL_TYPE_FLOAT) { + foreach_list_safe(n, &actual_parameters) { + ir_rvalue *matrix = (ir_rvalue *) n; + + if (!matrix->type->is_matrix()) + continue; + + /* Create a temporary containing the matrix. */ + ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp"); + instructions->push_tail(var); + instructions->push_tail(new(ctx) ir_assignment(new(ctx) + ir_dereference_variable(var), matrix, NULL)); + var->constant_value = matrix->constant_expression_value(); + + /* Replace the matrix with dereferences of its columns. */ + for (int i = 0; i < matrix->type->matrix_columns; i++) { + matrix->insert_before(new (ctx) ir_dereference_array(var, + new(ctx) ir_constant(i))); + } + matrix->remove(); + } + } + + bool all_parameters_are_constant = true; + + /* Type cast each parameter and, if possible, fold constants.*/ + foreach_list_safe(n, &actual_parameters) { + ir_rvalue *ir = (ir_rvalue *) n; + + const glsl_type *desired_type = + glsl_type::get_instance(constructor_type->base_type, + ir->type->vector_elements, + ir->type->matrix_columns); + ir_rvalue *result = convert_component(ir, desired_type); + + /* Attempt to convert the parameter to a constant valued expression. + * After doing so, track whether or not all the parameters to the + * constructor are trivially constant valued expressions. + */ + ir_rvalue *const constant = result->constant_expression_value(); + + if (constant != NULL) + result = constant; + else + all_parameters_are_constant = false; + + if (result != ir) { + ir->insert_before(result); + ir->remove(); + } + } /* If all of the parameters are trivially constant, create a * constant representing the complete collection of parameters. -- cgit v1.2.3 From d2afc874452a84965ee71c96f80e1d124c211ff4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 10:13:20 -0700 Subject: glsl2: Check when inlining a bare function call that it actually is. It would be easy to miss an entry either of the two visitors involved that would result in trying to ir->remove() the call to remove it from the instruction stream when really it's part of an expression tree that wasn't flattened. --- src/glsl/ir_function_inlining.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 6fe1264b0a4..8c545aaa6b7 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -233,6 +233,12 @@ ir_visitor_status ir_function_inlining_visitor::visit_enter(ir_call *ir) { if (can_inline(ir)) { + /* If the call was part of some tree, then it should have been + * flattened out or we shouldn't have seen it because of a + * visit_continue_with_parent in this visitor. + */ + assert(ir == base_ir); + (void) ir->generate_inline(ir); ir->remove(); this->progress = true; -- cgit v1.2.3 From 5723e5bb8b73cd2a3b77d750972e3d0b4d0d0ff8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 10:48:22 -0700 Subject: glsl2: Flatten out expressions that are the child of an assignment rhs. This feels a little odd, but it will be useful for ir_mat_to_vec, where I want to see a plain assignment of the expression to a variable, not to a writemasked array dereference with a call as the array index. --- src/glsl/ir_expression_flattening.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp index 5ba24e390b4..0f10b671936 100644 --- a/src/glsl/ir_expression_flattening.cpp +++ b/src/glsl/ir_expression_flattening.cpp @@ -57,9 +57,11 @@ public: virtual ir_visitor_status visit_enter(ir_function_signature *); virtual ir_visitor_status visit_enter(ir_if *); virtual ir_visitor_status visit_enter(ir_loop *); + virtual ir_visitor_status visit_leave(ir_assignment *); virtual ir_visitor_status visit_leave(ir_expression *); virtual ir_visitor_status visit_leave(ir_swizzle *); + ir_rvalue *operand_to_temp(ir_rvalue *val); bool (*predicate)(ir_instruction *ir); ir_instruction *base_ir; }; @@ -77,13 +79,16 @@ do_expression_flattening(exec_list *instructions, } -static ir_rvalue * -operand_to_temp(ir_instruction *base_ir, ir_rvalue *ir) +ir_rvalue * +ir_expression_flattening_visitor::operand_to_temp(ir_rvalue *ir) { void *ctx = talloc_parent(base_ir); ir_variable *var; ir_assignment *assign; + if (!this->predicate(ir)) + return ir; + var = new(ctx) ir_variable(ir->type, "flattening_tmp"); base_ir->insert_before(var); @@ -131,20 +136,27 @@ ir_expression_flattening_visitor::visit_leave(ir_expression *ir) /* If the operand matches the predicate, then we'll assign its * value to a temporary and deref the temporary as the operand. */ - if (this->predicate(ir->operands[operand])) { - ir->operands[operand] = operand_to_temp(base_ir, - ir->operands[operand]); - } + ir->operands[operand] = operand_to_temp(ir->operands[operand]); } return visit_continue; } +ir_visitor_status +ir_expression_flattening_visitor::visit_leave(ir_assignment *ir) +{ + ir->rhs = operand_to_temp(ir->rhs); + if (ir->condition) + ir->condition = operand_to_temp(ir->condition); + + return visit_continue; +} + ir_visitor_status ir_expression_flattening_visitor::visit_leave(ir_swizzle *ir) { if (this->predicate(ir->val)) { - ir->val = operand_to_temp(this->base_ir, ir->val); + ir->val = operand_to_temp(ir->val); } return visit_continue; -- cgit v1.2.3 From 6d8a0a0aadaafbab02dffcf7f89eb0210dd37b2e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 11:04:07 -0700 Subject: glsl2: Add a new pass at the IR level to break down matrix ops to vector ops. This will be used by the Mesa IR and likely most HW backends, as it allows other optimizations to occur that might not otherwise. Fixes glsl-vs-mat-sub-1, glsl-vs-mat-div-1. --- src/glsl/Makefile | 1 + src/glsl/ir.h | 6 ++ src/glsl/ir_mat_op_to_vec.cpp | 188 +++++++++++++++++++++++++++++++++++++++++ src/glsl/ir_optimization.h | 1 + src/mesa/shader/ir_to_mesa.cpp | 1 + 5 files changed, 197 insertions(+) create mode 100644 src/glsl/ir_mat_op_to_vec.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index ddc9d82d61f..a36ff28a4be 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -42,6 +42,7 @@ CXX_SOURCES = \ ir_hv_accept.cpp \ ir_if_return.cpp \ ir_if_simplification.cpp \ + ir_mat_op_to_vec.cpp \ ir_mod_to_fract.cpp \ ir_print_visitor.cpp \ ir_reader.cpp \ diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 500a8c7a006..0d5bbc20aa8 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -74,6 +74,7 @@ public: virtual class ir_dereference * as_dereference() { return NULL; } virtual class ir_dereference_array * as_dereference_array() { return NULL; } virtual class ir_dereference_variable *as_dereference_variable() { return NULL; } + virtual class ir_expression * as_expression() { return NULL; } virtual class ir_rvalue * as_rvalue() { return NULL; } virtual class ir_loop * as_loop() { return NULL; } virtual class ir_assignment * as_assignment() { return NULL; } @@ -603,6 +604,11 @@ public: ir_expression(int op, const struct glsl_type *type, ir_rvalue *, ir_rvalue *); + virtual ir_expression *as_expression() + { + return this; + } + virtual ir_expression *clone(struct hash_table *ht) const; static unsigned int get_num_operands(ir_expression_operation); diff --git a/src/glsl/ir_mat_op_to_vec.cpp b/src/glsl/ir_mat_op_to_vec.cpp new file mode 100644 index 00000000000..828c63c17a7 --- /dev/null +++ b/src/glsl/ir_mat_op_to_vec.cpp @@ -0,0 +1,188 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_mat_op_to_vec.cpp + * + * Breaks matrix operation expressions down to a series of vector operations. + * + * Generally this is how we have to codegen matrix operations for a + * GPU, so this gives us the chance to constant fold operations on a + * column or row. + */ + +#include "ir.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +class ir_mat_op_to_vec_visitor : public ir_hierarchical_visitor { +public: + ir_mat_op_to_vec_visitor() + { + this->made_progress = false; + } + + ir_visitor_status visit_leave(ir_assignment *); + + ir_rvalue *get_column(ir_variable *var, int i); + + bool made_progress; +}; + +static bool +mat_op_to_vec_predicate(ir_instruction *ir) +{ + ir_expression *expr = ir->as_expression(); + unsigned int i; + + if (!expr) + return false; + + for (i = 0; i < expr->get_num_operands(); i++) { + if (expr->operands[i]->type->is_matrix()) + return true; + } + + return false; +} + +bool +do_mat_op_to_vec(exec_list *instructions) +{ + ir_mat_op_to_vec_visitor v; + + /* Pull out any matrix expression to a separate assignment to a + * temp. This will make our handling of the breakdown to + * operations on the matrix's vector components much easier. + */ + do_expression_flattening(instructions, mat_op_to_vec_predicate); + + visit_list_elements(&v, instructions); + + return v.made_progress; +} + +ir_rvalue * +ir_mat_op_to_vec_visitor::get_column(ir_variable *var, int i) +{ + ir_dereference *deref; + + if (!var->type->is_matrix()) { + deref = new(base_ir) ir_dereference_variable(var); + } else { + deref = new(base_ir) ir_dereference_variable(var); + deref = new(base_ir) ir_dereference_array(deref, + new(base_ir) ir_constant(i)); + } + + return deref; +} + +ir_visitor_status +ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign) +{ + ir_expression *expr = assign->rhs->as_expression(); + bool found_matrix = false; + unsigned int i, matrix_columns = 1; + ir_variable *op_var[2]; + + if (!expr) + return visit_continue; + + for (i = 0; i < expr->get_num_operands(); i++) { + if (expr->operands[i]->type->is_matrix()) { + found_matrix = true; + matrix_columns = expr->operands[i]->type->matrix_columns; + break; + } + } + if (!found_matrix) + return visit_continue; + + /* FINISHME: see below */ + if (expr->operation == ir_binop_mul) + return visit_continue; + + ir_dereference_variable *lhs_deref = assign->lhs->as_dereference_variable(); + assert(lhs_deref); + + ir_variable *result_var = lhs_deref->var; + + /* Store the expression operands in temps so we can use them + * multiple times. + */ + for (i = 0; i < expr->get_num_operands(); i++) { + ir_assignment *assign; + + op_var[i] = new(base_ir) ir_variable(expr->operands[i]->type, + "mat_op_to_vec"); + base_ir->insert_before(op_var[i]); + + lhs_deref = new(base_ir) ir_dereference_variable(op_var[i]); + assign = new(base_ir) ir_assignment(lhs_deref, + expr->operands[i], + NULL); + base_ir->insert_before(assign); + } + + /* OK, time to break down this matrix operation. */ + switch (expr->operation) { + case ir_binop_add: + case ir_binop_sub: + case ir_binop_div: + case ir_binop_mod: + /* For most operations, the matrix version is just going + * column-wise through and applying the operation to each column + * if available. + */ + for (i = 0; i < matrix_columns; i++) { + ir_rvalue *op0 = get_column(op_var[0], i); + ir_rvalue *op1 = get_column(op_var[1], i); + ir_rvalue *result = get_column(result_var, i); + ir_expression *column_expr; + ir_assignment *column_assign; + + column_expr = new(base_ir) ir_expression(expr->operation, + result->type, + op0, + op1); + + column_assign = new(base_ir) ir_assignment(result, + column_expr, + NULL); + base_ir->insert_before(column_assign); + } + break; + case ir_binop_mul: + /* FINISHME */ + return visit_continue; + break; + default: + printf("FINISHME: Handle matrix operation for %s\n", expr->operator_string()); + abort(); + } + assign->remove(); + this->made_progress = true; + + return visit_continue; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index b03c0644cf0..fae583df756 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -41,6 +41,7 @@ bool do_div_to_mul_rcp(exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_if_return(exec_list *instructions); bool do_if_simplification(exec_list *instructions); +bool do_mat_op_to_vec(exec_list *instructions); bool do_mod_to_fract(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); bool do_vec_index_to_cond_assign(exec_list *instructions); diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 708c6fece1c..81b91918cb0 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1960,6 +1960,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) _mesa_ast_to_hir(shader->ir, state); /* Lowering */ + do_mat_op_to_vec(shader->ir); do_mod_to_fract(shader->ir); do_div_to_mul_rcp(shader->ir); -- cgit v1.2.3 From 7b48843ecd6690902e4f3bd709a041133b7fb540 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 12:03:33 -0700 Subject: Revert "ir_to_mesa: Add support for adding/subtracting matrices." This reverts commit b4d0c0e0ee983ee614b047799c3e01221a353c98. Now that ir_mat_op_to_vec is landed, this change is no longer needed. --- src/mesa/shader/ir_to_mesa.cpp | 42 +++--------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 81b91918cb0..c636d69abaa 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -178,13 +178,6 @@ public: ir_to_mesa_src_reg src0, ir_to_mesa_src_reg src1); - void ir_to_mesa_emit_addsub(ir_expression *ir, - enum prog_opcode opcode, - struct ir_to_mesa_src_reg result_src, - struct ir_to_mesa_dst_reg result_dst, - struct ir_to_mesa_src_reg op0, - struct ir_to_mesa_src_reg op1); - int *sampler_map; int sampler_map_size; @@ -537,32 +530,6 @@ ir_to_mesa_visitor::visit(ir_function *ir) } } -void -ir_to_mesa_visitor::ir_to_mesa_emit_addsub(ir_expression *ir, - enum prog_opcode opcode, - struct ir_to_mesa_src_reg result_src, - struct ir_to_mesa_dst_reg result_dst, - struct ir_to_mesa_src_reg op0, - struct ir_to_mesa_src_reg op1) -{ - ir_to_mesa_dst_reg dst_column = result_dst; - int matrix_columns; - - if (ir->operands[0]->type->is_matrix()) - matrix_columns = ir->operands[0]->type->matrix_columns; - else - matrix_columns = ir->operands[1]->type->matrix_columns; - - for (int i = 0; i < matrix_columns; i++) { - ir_to_mesa_emit_op2(ir, opcode, dst_column, op0, op1); - dst_column.index++; - if (ir->operands[0]->type->is_matrix()) - op0.index++; - if (ir->operands[1]->type->is_matrix()) - op1.index++; - } -} - void ir_to_mesa_visitor::visit(ir_expression *ir) { @@ -587,8 +554,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) /* Only expression implemented for matrices yet */ assert(!ir->operands[operand]->type->is_matrix() || - ir->operation == ir_binop_mul || - ir->operation == ir_binop_add); + ir->operation == ir_binop_mul); } this->result.file = PROGRAM_UNDEFINED; @@ -652,12 +618,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir) break; case ir_binop_add: - ir_to_mesa_emit_addsub(ir, OPCODE_ADD, - result_src, result_dst, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]); break; case ir_binop_sub: - ir_to_mesa_emit_addsub(ir, OPCODE_SUB, - result_src, result_dst, op[0], op[1]); + ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); break; case ir_binop_mul: -- cgit v1.2.3 From 288733f6001a2148d6689587d9a05e6909e88a61 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 14:02:59 -0700 Subject: glsl2: Store the gl_type of the array's element type in the array. Fixes glsl-fs-uniform-array-1, glsl-vs-uniform-array-1, and the -2 tests on software. --- src/glsl/glsl_types.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 806b71495de..d6799cf4283 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -285,6 +285,11 @@ glsl_type::glsl_type(void *ctx, const glsl_type *array, unsigned length) : name(NULL), length(length) { this->fields.array = array; + /* Inherit the gl type of the base. The GL type is used for + * uniform/statevar handling in Mesa and the arrayness of the type + * is represented by the size rather than the type. + */ + this->gl_type = array->gl_type; /* Allow a maximum of 10 characters for the array size. This is enough * for 32-bits of ~0. The extra 3 are for the '[', ']', and terminating -- cgit v1.2.3 From 0b9ae3befb0bf80e000b159fd44c961a144f9c36 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 12 Jul 2010 14:22:05 -0700 Subject: glsl2: Add declarations for temporaries to instruction stream Temporary variables added for &&, ||, and ?: were not being added to the instruction stream. This resulted in either test failures or Valgrind being angry after the original IR tree was destroyed by talloc_free. The talloc_free caused the ir_variables to be destroyed even though they were still referenced. --- src/glsl/ast_to_hir.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index e03bb6394fb..a9ab17f4216 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -821,6 +821,7 @@ ast_expression::hir(exec_list *instructions, ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, "and_tmp"); + instructions->push_tail(tmp); ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); ir_assignment *const then_assign = @@ -873,6 +874,7 @@ ast_expression::hir(exec_list *instructions, ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, "or_tmp"); + instructions->push_tail(tmp); op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); @@ -1048,6 +1050,7 @@ ast_expression::hir(exec_list *instructions, result = (cond_val->value.b[0]) ? then_val : else_val; } else { ir_variable *const tmp = new(ctx) ir_variable(type, "conditional_tmp"); + instructions->push_tail(tmp); ir_if *const stmt = new(ctx) ir_if(op[0]); instructions->push_tail(stmt); -- cgit v1.2.3 From 10d222b70266a1b6e8dde90652156c6e18bcd3c8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Jul 2010 16:11:10 -0700 Subject: glsl2: Add missing fields in ir_variable::clone --- src/glsl/ir_clone.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index cf21c24d732..f1d2851793f 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -45,8 +45,16 @@ ir_variable::clone(struct hash_table *ht) const var->read_only = this->read_only; var->centroid = this->centroid; var->invariant = this->invariant; + var->shader_in = this->shader_in; + var->shader_out = this->shader_out; var->mode = this->mode; var->interpolation = this->interpolation; + var->array_lvalue = this->array_lvalue; + var->location = this->location; + var->warn_extension = this->warn_extension; + + if (this->constant_value) + var->constant_value = this->constant_value->clone(ht); if (ht) { hash_table_insert(ht, var, (void *)const_cast(this)); -- cgit v1.2.3 From 81d664f099a5fd5fac777480532fb4307d591451 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 12 Jul 2010 15:18:55 -0700 Subject: glsl2: Move temp declaration to correct side of if-statement in IR --- src/glsl/ast_to_hir.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index a9ab17f4216..98090d2b01b 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -805,6 +805,10 @@ ast_expression::hir(exec_list *instructions, } type = glsl_type::bool_type; } else { + ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, + "and_tmp"); + instructions->push_tail(tmp); + ir_if *const stmt = new(ctx) ir_if(op[0]); instructions->push_tail(stmt); @@ -819,10 +823,6 @@ ast_expression::hir(exec_list *instructions, error_emitted = true; } - ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, - "and_tmp"); - instructions->push_tail(tmp); - ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); ir_assignment *const then_assign = new(ctx) ir_assignment(then_deref, op[1], NULL); @@ -869,13 +869,13 @@ ast_expression::hir(exec_list *instructions, } type = glsl_type::bool_type; } else { - ir_if *const stmt = new(ctx) ir_if(op[0]); - instructions->push_tail(stmt); - ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, "or_tmp"); instructions->push_tail(tmp); + ir_if *const stmt = new(ctx) ir_if(op[0]); + instructions->push_tail(stmt); + op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { -- cgit v1.2.3 From b50098122696c00e7f9e57089197e25e5fe0e0cf Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Jul 2010 11:02:19 -0700 Subject: glsl2: Implement ir_function::clone and ir_function_signature::clone --- src/glsl/ir_clone.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index f1d2851793f..2bde585914a 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -261,17 +261,54 @@ ir_assignment::clone(struct hash_table *ht) const ir_function * ir_function::clone(struct hash_table *ht) const { - (void)ht; - /* FINISHME */ - abort(); + void *mem_ctx = talloc_parent(this); + ir_function *copy = new(mem_ctx) ir_function(this->name); + + foreach_list_const(node, &this->signatures) { + const ir_function_signature *const sig = + (const ir_function_signature *const) node; + + ir_function_signature *sig_copy = sig->clone(ht); + copy->add_signature(sig_copy); + + if (ht != NULL) + hash_table_insert(ht, sig_copy, + (void *)const_cast(sig)); + } + + return copy; } ir_function_signature * ir_function_signature::clone(struct hash_table *ht) const { - (void)ht; - /* FINISHME */ - abort(); + void *mem_ctx = talloc_parent(this); + ir_function_signature *copy = + new(mem_ctx) ir_function_signature(this->return_type); + + copy->is_defined = this->is_defined; + + /* Clone the parameter list. + */ + foreach_list_const(node, &this->parameters) { + const ir_variable *const param = (const ir_variable *) node; + + assert(const_cast(param)->as_variable() != NULL); + + ir_variable *const param_copy = param->clone(ht); + copy->parameters.push_tail(param_copy); + } + + /* Clone the instruction list. + */ + foreach_list_const(node, &this->body) { + const ir_instruction *const inst = (const ir_instruction *) node; + + ir_instruction *const inst_copy = inst->clone(ht); + copy->body.push_tail(inst_copy); + } + + return copy; } ir_constant * -- cgit v1.2.3 From 792e01c1e259077eb339af3ce61905fd227ae4bd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Jul 2010 11:33:13 -0700 Subject: ir_call: Add method to set the function signature being called --- src/glsl/ir.cpp | 8 ++++++++ src/glsl/ir.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 42578425839..f3ee12ce81f 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -836,6 +836,14 @@ ir_call::get_error_instruction(void *ctx) return call; } +void +ir_call::set_callee(const ir_function_signature *sig) +{ + assert((this->type == NULL) || (this->type == sig->return_type)); + + this->callee = sig; +} + void visit_exec_list(exec_list *list, ir_visitor *visitor) { diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 0d5bbc20aa8..89922c6bbcd 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -694,6 +694,11 @@ public: return callee; } + /** + * Set the function call target + */ + void set_callee(const ir_function_signature *sig); + /** * Generates an inline version of the function before @ir, * returning the return value of the function. -- cgit v1.2.3 From f3235eb37f264244f4ea432700be7dd6b2930d6c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 6 Jul 2010 16:01:06 -0700 Subject: glsl2: Add utility function clone_ir_list --- src/glsl/ir.h | 9 ++++++++ src/glsl/ir_clone.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 89922c6bbcd..18294ebc314 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1236,6 +1236,15 @@ visit_exec_list(exec_list *list, ir_visitor *visitor); void validate_ir_tree(exec_list *instructions); +/** + * Make a clone of each IR instruction in a list + * + * \param in List of IR instructions that are to be cloned + * \param out List to hold the cloned instructions + */ +void +clone_ir_list(exec_list *out, const exec_list *in); + extern void _mesa_glsl_initialize_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state); diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 2bde585914a..f1547d9106f 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -344,3 +344,63 @@ ir_constant::clone(struct hash_table *ht) const return NULL; } } + + +class fixup_ir_call_visitor : public ir_hierarchical_visitor { +public: + fixup_ir_call_visitor(struct hash_table *ht) + { + this->ht = ht; + } + + virtual ir_visitor_status visit_enter(ir_call *ir) + { + /* Try to find the function signature referenced by the ir_call in the + * table. If it is found, replace it with the value from the table. + */ + const ir_function_signature *const sig = + (ir_function_signature *) hash_table_find(this->ht, ir->get_callee()); + if (sig != NULL) + ir->set_callee(sig); + + /* Since this may be used before function call parameters are flattened, + * the children also need to be processed. + */ + return visit_continue; + } + +private: + struct hash_table *ht; +}; + + +static void +fixup_function_calls(struct hash_table *ht, exec_list *instructions) +{ + fixup_ir_call_visitor v(ht); + v.run(instructions); +} + + +void +clone_ir_list(exec_list *out, const exec_list *in) +{ + struct hash_table *ht = + hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); + + foreach_list_const(node, in) { + const ir_instruction *const original = (ir_instruction *) node; + ir_instruction *copy = original->clone(ht); + + out->push_tail(copy); + } + + /* Make a pass over the cloned tree to fix up ir_call nodes to point to the + * cloned ir_function_signature nodes. This cannot be done automatically + * during cloning because the ir_call might be a forward reference (i.e., + * the function signature that it references may not have been cloned yet). + */ + fixup_function_calls(ht, out); + + hash_table_dtor(ht); +} -- cgit v1.2.3 From df05ad4e1aa5512ce1dfd2e6661641e012c8b279 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Jul 2010 13:28:32 -0700 Subject: ir_function_signature: Add method to get the function owning a signature There is no setter function, the getter returns a constant pointer, and ir_function_signature::_function is private for a reason. The only way to make a connection between a function and function signature is via ir_function::add_signature. This helps ensure that certain invariants (i.e., a function signature is in the list of signatures for its _function) are met. --- src/glsl/ir.cpp | 2 +- src/glsl/ir.h | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index f3ee12ce81f..6d899132861 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -771,7 +771,7 @@ ir_variable::component_slots() const ir_function_signature::ir_function_signature(const glsl_type *return_type) - : return_type(return_type), is_defined(false) + : return_type(return_type), is_defined(false), _function(NULL) { /* empty */ } diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 18294ebc314..fb94b5a560d 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -275,6 +275,23 @@ public: */ const char *function_name() const; + /** + * Get a handle to the function for which this is a signature + * + * There is no setter function, this function returns a \c const pointer, + * and \c ir_function_signature::_function is private for a reason. The + * only way to make a connection between a function and function signature + * is via \c ir_function::add_signature. This helps ensure that certain + * invariants (i.e., a function signature is in the list of signatures for + * its \c _function) are met. + * + * \sa ir_function::add_signature + */ + inline const class ir_function *function() const + { + return this->_function; + } + /** * Check whether the qualifiers match between this signature's parameters * and the supplied parameter list. If not, returns the name of the first @@ -312,7 +329,7 @@ public: private: /** Function of which this signature is one overload. */ - class ir_function *function; + class ir_function *_function; friend class ir_function; }; @@ -343,8 +360,8 @@ public: void add_signature(ir_function_signature *sig) { - sig->function = this; - signatures.push_tail(sig); + sig->_function = this; + this->signatures.push_tail(sig); } /** @@ -381,7 +398,7 @@ private: inline const char *ir_function_signature::function_name() const { - return function->name; + return this->_function->name; } /*@}*/ -- cgit v1.2.3 From c67016de960c988c748ffdb11247072543a8f328 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 2 Jul 2010 13:30:23 -0700 Subject: ir_validate: Additional function related invariant checks Add two invariant checks related to functions and function signatures: 1. Ensure that function definitions (ir_function) are not nested. 2. Ensure that the ir_function pointed to by an ir_function_signature is the one that contains it in its signatures list. --- src/glsl/ir_validate.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 7582d57e7c3..8c86748d26a 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -46,6 +46,8 @@ public: this->ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); + this->current_function = NULL; + this->callback = ir_validate::validate_ir; this->data = ht; } @@ -57,11 +59,69 @@ public: virtual ir_visitor_status visit(ir_variable *v); + virtual ir_visitor_status visit_enter(ir_function *ir); + virtual ir_visitor_status visit_leave(ir_function *ir); + virtual ir_visitor_status visit_enter(ir_function_signature *ir); + static void validate_ir(ir_instruction *ir, void *data); + ir_function *current_function; + struct hash_table *ht; }; +ir_visitor_status +ir_validate::visit_enter(ir_function *ir) +{ + /* Function definitions cannot be nested. + */ + if (this->current_function != NULL) { + printf("Function definition nested inside another function " + "definition:\n"); + printf("%s %p inside %s %p\n", + ir->name, ir, + this->current_function->name, this->current_function); + abort(); + } + + /* Store the current function hierarchy being traversed. This is used + * by the function signature visitor to ensure that the signatures are + * linked with the correct functions. + */ + this->current_function = ir; + + this->validate_ir(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_leave(ir_function *ir) +{ + (void) ir; + + this->current_function = NULL; + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_function_signature *ir) +{ + if (this->current_function != ir->function()) { + printf("Function signature nested inside wrong function " + "definition:\n"); + printf("%p inside %s %p instead of %s %p\n", + ir, + this->current_function->name, this->current_function, + ir->function_name(), ir->function()); + abort(); + } + + this->validate_ir(ir, this->data); + + return visit_continue; +} + ir_visitor_status ir_validate::visit(ir_variable *ir) { -- cgit v1.2.3 From ffd7bb031e67f0d4e1eb36aa27261e8744e7b133 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Jul 2010 11:03:21 -0700 Subject: Make shader_api.h be C++ friendly --- src/mesa/shader/shader_api.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mesa/shader/shader_api.h b/src/mesa/shader/shader_api.h index 557e910595a..22f582a6a1d 100644 --- a/src/mesa/shader/shader_api.h +++ b/src/mesa/shader/shader_api.h @@ -32,6 +32,9 @@ #include "main/mtypes.h" #include "ir_to_mesa.h" +#ifdef __cplusplus +extern "C" { +#endif /** * Internal functions */ @@ -109,5 +112,8 @@ _mesa_validate_shader_program(GLcontext *ctx, extern void _mesa_init_glsl_driver_functions(struct dd_function_table *driver); +#ifdef __cplusplus +}; +#endif #endif /* SHADER_API_H */ -- cgit v1.2.3 From 3fb878722ed53d79eedb9fe68972ef32b79575d4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 9 Jul 2010 14:09:34 -0700 Subject: linker: Stub-out intrastage linker --- src/glsl/linker.cpp | 81 ++++++++++++++++++++++++++++++++++-------- src/glsl/main.cpp | 22 ++++++++++++ src/mesa/shader/ir_to_mesa.cpp | 9 ++--- 3 files changed, 92 insertions(+), 20 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index eb10f90a911..e70fa31a2b0 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -77,9 +77,8 @@ extern "C" { #include "ir.h" #include "ir_optimization.h" #include "program.h" -extern "C" { #include "hash_table.h" -} +#include "shader_api.h" /** * Visitor that determines whether or not a variable is ever written. @@ -399,6 +398,53 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog, } +/** + * Populates a shaders symbol table with all global declarations + */ +static void +populate_symbol_table(gl_shader *sh) +{ + sh->symbols = new(sh) glsl_symbol_table; + + foreach_list(node, sh->ir) { + ir_instruction *const inst = (ir_instruction *) node; + ir_variable *var; + ir_function *func; + + if ((func = inst->as_function()) != NULL) { + sh->symbols->add_function(func->name, func); + } else if ((var = inst->as_variable()) != NULL) { + sh->symbols->add_variable(var->name, var); + } + } +} + + +/** + * Combine a group of shaders for a single stage to generate a linked shader + * + * \note + * If this function is supplied a single shader, it is cloned, and the new + * shader is returned. + */ +static struct gl_shader * +link_intrastage_shaders(struct gl_shader_program *prog, + struct gl_shader **shader_list, + unsigned num_shaders) +{ + (void) prog; + assert(num_shaders == 1); + + gl_shader *const linked = _mesa_new_shader(NULL, 0, shader_list[0]->Type); + linked->ir = new(linked) exec_list; + clone_ir_list(linked->ir, shader_list[0]->ir); + + populate_symbol_table(linked); + + return linked; +} + + struct uniform_node { exec_node link; struct gl_uniform *u; @@ -807,25 +853,32 @@ link_shaders(struct gl_shader_program *prog) } /* FINISHME: Implement intra-stage linking. */ - assert(num_vert_shaders <= 1); - assert(num_frag_shaders <= 1); - - /* Verify that each of the per-target executables is valid. - */ - if (!validate_vertex_shader_executable(prog, vert_shader_list[0]) - || !validate_fragment_shader_executable(prog, frag_shader_list[0])) - goto done; + prog->_NumLinkedShaders = 0; + if (num_vert_shaders > 0) { + gl_shader *const sh = + link_intrastage_shaders(prog, vert_shader_list, num_vert_shaders); + if (sh == NULL) + goto done; - prog->_NumLinkedShaders = 0; + if (!validate_vertex_shader_executable(prog, sh)) + goto done; - if (num_vert_shaders > 0) { - prog->_LinkedShaders[prog->_NumLinkedShaders] = vert_shader_list[0]; + prog->_LinkedShaders[prog->_NumLinkedShaders] = sh; prog->_NumLinkedShaders++; } if (num_frag_shaders > 0) { - prog->_LinkedShaders[prog->_NumLinkedShaders] = frag_shader_list[0]; + gl_shader *const sh = + link_intrastage_shaders(prog, frag_shader_list, num_frag_shaders); + + if (sh == NULL) + goto done; + + if (!validate_fragment_shader_executable(prog, sh)) + goto done; + + prog->_LinkedShaders[prog->_NumLinkedShaders] = sh; prog->_NumLinkedShaders++; } diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index dd43d12474b..8b0bccdcb71 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -36,6 +36,25 @@ #include "ir_print_visitor.h" #include "program.h" +extern "C" struct gl_shader * +_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type); + +/* Copied from shader_api.c for the stand-alone compiler. + */ +struct gl_shader * +_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type) +{ + struct gl_shader *shader; + assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER); + shader = talloc_zero(NULL, struct gl_shader); + if (shader) { + shader->Type = type; + shader->Name = name; + shader->RefCount = 1; + } + return shader; +} + /* Returned string will have 'ctx' as its talloc owner. */ static char * load_text_file(void *ctx, const char *file_name) @@ -271,6 +290,9 @@ main(int argc, char **argv) printf("Info log for linking:\n%s\n", whole_program->InfoLog); } + for (unsigned i = 0; i < whole_program->_NumLinkedShaders; i++) + talloc_free(whole_program->_LinkedShaders[i]); + talloc_free(whole_program); _mesa_glsl_release_types(); diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index c636d69abaa..8945e9b3b4d 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1998,20 +1998,17 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) prog->Uniforms = _mesa_new_uniform_list(); } - prog->LinkStatus = prog->LinkStatus; - - /* FINISHME: This should use the linker-generated code */ if (prog->LinkStatus) { - for (i = 0; i < prog->NumShaders; i++) { + for (i = 0; i < prog->_NumLinkedShaders; i++) { struct gl_program *linked_prog; linked_prog = get_mesa_program(ctx, prog, - prog->Shaders[i]); + prog->_LinkedShaders[i]); count_resources(linked_prog); link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog); - switch (prog->Shaders[i]->Type) { + switch (prog->_LinkedShaders[i]->Type) { case GL_VERTEX_SHADER: _mesa_reference_vertprog(ctx, &prog->VertexProgram, (struct gl_vertex_program *)linked_prog); -- cgit v1.2.3 From 8baf21b1a4d50efca086679cc43bb0cfc3fee03a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 12 Jul 2010 13:55:32 -0700 Subject: ir_validate: Validate that varibles are declared before used in IR --- src/glsl/ir_validate.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 8c86748d26a..74b4826e355 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -58,6 +58,7 @@ public: } virtual ir_visitor_status visit(ir_variable *v); + virtual ir_visitor_status visit(ir_dereference_variable *ir); virtual ir_visitor_status visit_enter(ir_function *ir); virtual ir_visitor_status visit_leave(ir_function *ir); @@ -70,6 +71,27 @@ public: struct hash_table *ht; }; + +ir_visitor_status +ir_validate::visit(ir_dereference_variable *ir) +{ + if ((ir->var == NULL) || (ir->var->as_variable() == NULL)) { + printf("ir_dereference_variable @ %p does not specify a variable %p\n", + ir, ir->var); + abort(); + } + + if (hash_table_find(ht, ir->var) == NULL) { + printf("ir_dereference_variable @ %p specifies undeclared variable " + "`%s' @ %p\n", + ir, ir->var->name, ir->var); + abort(); + } + + return visit_continue; +} + + ir_visitor_status ir_validate::visit_enter(ir_function *ir) { @@ -126,9 +148,11 @@ ir_visitor_status ir_validate::visit(ir_variable *ir) { /* An ir_variable is the one thing that can (and will) appear multiple times - * in an IR tree. + * in an IR tree. It is added to the hashtable so that it can be used + * in the ir_dereference_variable handler to ensure that a variable is + * declared before it is dereferenced. */ - (void) ir; + hash_table_insert(ht, ir, ir); return visit_continue; } -- cgit v1.2.3 From 506880bc32e7bb98fd1896a9b2fe3614abab904f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 12 Jul 2010 15:46:16 -0700 Subject: ir_validate: Also perform usual checks on ir_dereference_variable nodes --- src/glsl/ir_validate.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 74b4826e355..4284f6b1201 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -88,6 +88,8 @@ ir_validate::visit(ir_dereference_variable *ir) abort(); } + this->validate_ir(ir, this->data); + return visit_continue; } -- cgit v1.2.3 From 8258a6a2c36c9769428f4525415d6c0d565e588c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 14:14:53 -0700 Subject: ir_to_mesa: Add support for dereferencing matrices from arrays. --- src/mesa/shader/ir_to_mesa.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 8945e9b3b4d..467e335fc4b 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1099,6 +1099,7 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) ir_constant *index; ir_to_mesa_src_reg src_reg; ir_dereference_variable *deref_var = ir->array->as_dereference_variable(); + int element_size = type_size(ir->type); index = ir->array_index->constant_expression_value(); @@ -1125,7 +1126,7 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) ir->array_index->accept(this); ir_to_mesa_emit_op2(ir, OPCODE_MUL, ir_to_mesa_dst_reg_from_src(index_reg), - this->result, src_reg_for_float(4.0)); + this->result, src_reg_for_float(element_size)); src_reg.reladdr = true; ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, @@ -1136,11 +1137,6 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) return; } - /* By the time we make it to this stage, matrices should be broken down - * to vectors. - */ - assert(!ir->type->is_matrix()); - ir->array->accept(this); src_reg = this->result; @@ -1151,7 +1147,7 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) src_reg.index += index->value.i[0]; } else { if (index) { - src_reg.index += index->value.i[0]; + src_reg.index += index->value.i[0] * element_size; } else { ir_to_mesa_src_reg array_base = this->result; /* Variable index array dereference. It eats the "vec4" of the @@ -1160,12 +1156,24 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) */ ir->array_index->accept(this); + ir_to_mesa_src_reg index_reg; + + if (element_size == 1) { + index_reg = this->result; + } else { + index_reg = get_temp(glsl_type::float_type); + + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + ir_to_mesa_dst_reg_from_src(index_reg), + this->result, src_reg_for_float(element_size)); + } + /* FINISHME: This doesn't work when we're trying to do the LHS * of an assignment. */ src_reg.reladdr = true; ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, - this->result); + index_reg); this->result = get_temp(ir->type); ir_to_mesa_emit_op1(ir, OPCODE_MOV, -- cgit v1.2.3 From b87259d3efeadf05556e2daf688935a038097bba Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 15:32:37 -0700 Subject: glsl2: Fix copy propagation in the presence of derefs in array indexes. We would clear the in_lhs flag early, avoiding copy propagation on the array index variable (oops) and then copy propagating on the array variable (ouch). Just avoid all copy propagation on the LHS instead. --- src/glsl/ir_copy_propagation.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_copy_propagation.cpp b/src/glsl/ir_copy_propagation.cpp index f502f5e0b06..57123987322 100644 --- a/src/glsl/ir_copy_propagation.cpp +++ b/src/glsl/ir_copy_propagation.cpp @@ -96,9 +96,29 @@ ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir) ir_visitor_status ir_copy_propagation_visitor::visit_enter(ir_assignment *ir) { - (void) ir; + ir_visitor_status s; + + /* Inline the rest of ir_assignment::accept(ir_hv *v), wrapping the + * LHS part with setting in_lhs so that we can avoid copy + * propagating into the LHS. + * + * Note that this means we won't copy propagate into the derefs of + * an array index. Oh well. + */ this->in_lhs = true; - return visit_continue; + s = ir->lhs->accept(this); + this->in_lhs = false; + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = ir->rhs->accept(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (ir->condition) + s = ir->condition->accept(this); + + return (s == visit_stop) ? s : visit_continue_with_parent; } ir_visitor_status @@ -122,7 +142,6 @@ ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) * other storage! */ if (this->in_lhs) { - this->in_lhs = false; return visit_continue; } -- cgit v1.2.3 From 7b96b474e06f83bf4abec42b3a9cb2dee0ea1b68 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 15:18:52 -0700 Subject: glsl2: Add support for variable vector indexing on the LHS of assignments. Fixes glsl-vs-vec4-indexing-3. --- src/glsl/ir_vec_index_to_cond_assign.cpp | 60 ++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_vec_index_to_cond_assign.cpp b/src/glsl/ir_vec_index_to_cond_assign.cpp index 3f527fcbe71..ac420454e88 100644 --- a/src/glsl/ir_vec_index_to_cond_assign.cpp +++ b/src/glsl/ir_vec_index_to_cond_assign.cpp @@ -56,7 +56,7 @@ public: virtual ir_visitor_status visit_enter(ir_expression *); virtual ir_visitor_status visit_enter(ir_swizzle *); - virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_leave(ir_assignment *); virtual ir_visitor_status visit_enter(ir_return *); virtual ir_visitor_status visit_enter(ir_call *); virtual ir_visitor_status visit_enter(ir_if *); @@ -144,10 +144,64 @@ ir_vec_index_to_cond_assign_visitor::visit_enter(ir_swizzle *ir) } ir_visitor_status -ir_vec_index_to_cond_assign_visitor::visit_enter(ir_assignment *ir) +ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) { - /* FINISHME: Handle it on the LHS. */ + ir_variable *index, *var; + ir_dereference_variable *deref; + ir_assignment *assign; + int i; + ir->rhs = convert_vec_index_to_cond_assign(ir->rhs); + if (ir->condition) + ir->condition = convert_vec_index_to_cond_assign(ir->condition); + + /* Last, handle the LHS */ + ir_dereference_array *orig_deref = ir->lhs->as_dereference_array(); + + if (!orig_deref || + orig_deref->array->type->is_matrix() || + orig_deref->array->type->is_array()) + return visit_continue; + + assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); + + /* Store the index to a temporary to avoid reusing its tree. */ + index = new(ir) ir_variable(glsl_type::int_type, "vec_index_tmp_i"); + ir->insert_before(index); + deref = new(ir) ir_dereference_variable(index); + assign = new(ir) ir_assignment(deref, orig_deref->array_index, NULL); + ir->insert_before(assign); + + /* Store the RHS to a temporary to avoid reusing its tree. */ + var = new(ir) ir_variable(ir->rhs->type, "vec_index_tmp_v"); + ir->insert_before(var); + deref = new(ir) ir_dereference_variable(var); + assign = new(ir) ir_assignment(deref, ir->rhs, NULL); + ir->insert_before(assign); + + /* Generate a conditional move of each vector element to the temp. */ + for (i = 0; i < orig_deref->array->type->vector_elements; i++) { + ir_rvalue *condition, *swizzle; + + deref = new(ir) ir_dereference_variable(index); + condition = new(ir) ir_expression(ir_binop_equal, + glsl_type::bool_type, + deref, + new(ir) ir_constant(i)); + + /* Just clone the rest of the deref chain when trying to get at the + * underlying variable. + */ + swizzle = new(ir) ir_swizzle(orig_deref->array->clone(NULL), + i, 0, 0, 0, 1); + + deref = new(ir) ir_dereference_variable(var); + assign = new(ir) ir_assignment(swizzle, deref, condition); + ir->insert_before(assign); + } + ir->remove(); + + this->progress = true; return visit_continue; } -- cgit v1.2.3 From d74c9ff046c9cf8ee33c202eb5eba3dfc7f8e06e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 15:41:31 -0700 Subject: glsl2: Use a better talloc context for ir_expression_flattening. The instruction can be hung off of any other in the tree, even if the other one will be deleted, since it'll get stolen to the shader's context later if it's still live. --- src/glsl/ir_expression_flattening.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp index 0f10b671936..629194c1a04 100644 --- a/src/glsl/ir_expression_flattening.cpp +++ b/src/glsl/ir_expression_flattening.cpp @@ -82,7 +82,7 @@ do_expression_flattening(exec_list *instructions, ir_rvalue * ir_expression_flattening_visitor::operand_to_temp(ir_rvalue *ir) { - void *ctx = talloc_parent(base_ir); + void *ctx = base_ir; ir_variable *var; ir_assignment *assign; -- cgit v1.2.3 From e2e5d0def490ed03970efa0a7468fef0623ae617 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 29 Jun 2010 18:47:11 -0700 Subject: linker: Refactor cross_validate_uniforms into cross_validate_globals The later, more generic function will be used in the intra-stage linker. --- src/glsl/linker.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e70fa31a2b0..04b4efd84ba 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -242,42 +242,72 @@ validate_fragment_shader_executable(struct gl_shader_program *prog, /** - * Perform validation of uniforms used across multiple shader stages + * Generate a string describing the mode of a variable + */ +static const char * +mode_string(const ir_variable *var) +{ + switch (var->mode) { + case ir_var_auto: + return (var->read_only) ? "global constant" : "global variable"; + + case ir_var_uniform: return "uniform"; + case ir_var_in: return "shader input"; + case ir_var_out: return "shader output"; + case ir_var_inout: return "shader inout"; + default: + assert(!"Should not get here."); + return "invalid variable"; + } +} + + +/** + * Perform validation of global variables used across multiple shaders */ bool -cross_validate_uniforms(struct gl_shader_program *prog) +cross_validate_globals(struct gl_shader_program *prog, + struct gl_shader **shader_list, + unsigned num_shaders, + bool uniforms_only) { /* Examine all of the uniforms in all of the shaders and cross validate * them. */ - glsl_symbol_table uniforms; - for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { - foreach_list(node, prog->_LinkedShaders[i]->ir) { + glsl_symbol_table variables; + for (unsigned i = 0; i < num_shaders; i++) { + foreach_list(node, shader_list[i]->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if ((var == NULL) || (var->mode != ir_var_uniform)) + if (var == NULL) continue; - /* If a uniform with this name has already been seen, verify that the - * new instance has the same type. In addition, if the uniforms have + if (uniforms_only && (var->mode != ir_var_uniform)) + continue; + + /* If a global with this name has already been seen, verify that the + * new instance has the same type. In addition, if the globals have * initializers, the values of the initializers must be the same. */ - ir_variable *const existing = uniforms.get_variable(var->name); + ir_variable *const existing = variables.get_variable(var->name); if (existing != NULL) { if (var->type != existing->type) { - linker_error_printf(prog, "uniform `%s' declared as type " + linker_error_printf(prog, "%s `%s' declared as type " "`%s' and type `%s'\n", + mode_string(var), var->name, var->type->name, existing->type->name); return false; } + /* FINISHME: Handle non-constant initializers. + */ if (var->constant_value != NULL) { if (existing->constant_value != NULL) { if (!var->constant_value->has_value(existing->constant_value)) { - linker_error_printf(prog, "initializers for uniform " + linker_error_printf(prog, "initializers for %s " "`%s' have differing values\n", - var->name); + mode_string(var), var->name); return false; } } else @@ -289,7 +319,7 @@ cross_validate_uniforms(struct gl_shader_program *prog) (ir_constant *)var->constant_value->clone(NULL); } } else - uniforms.add_variable(var->name, var); + variables.add_variable(var->name, var); } } @@ -297,6 +327,17 @@ cross_validate_uniforms(struct gl_shader_program *prog) } +/** + * Perform validation of uniforms used across multiple shader stages + */ +bool +cross_validate_uniforms(struct gl_shader_program *prog) +{ + return cross_validate_globals(prog, prog->_LinkedShaders, + prog->_NumLinkedShaders, true); +} + + /** * Validate that outputs from one stage match inputs of another */ -- cgit v1.2.3 From 13f782c4ae4e38e64ec4fe87a1c24597a5e894c3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 29 Jun 2010 18:53:38 -0700 Subject: linker: Implement first bits of intrastage linking This currently involves an ugly hack so that every link doesn't result in all the built-in functions showing up as multiply defined. As soon as the built-in functions are stored in a separate compilation unit, ir_function_signature::is_built_in can be removed. --- src/glsl/ir.h | 3 +++ src/glsl/ir_clone.cpp | 1 + src/glsl/ir_reader.cpp | 1 + src/glsl/linker.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index fb94b5a560d..25bf6c6d151 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -324,6 +324,9 @@ public: /** Whether or not this function has a body (which may be empty). */ unsigned is_defined:1; + /** Whether or not this function signature is a built-in. */ + unsigned is_built_in:1; + /** Body of instructions in the function. */ struct exec_list body; diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index f1547d9106f..2562ad91187 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -287,6 +287,7 @@ ir_function_signature::clone(struct hash_table *ht) const new(mem_ctx) ir_function_signature(this->return_type); copy->is_defined = this->is_defined; + copy->is_built_in = this->is_built_in; /* Clone the parameter list. */ diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 03212830cdb..c83f92ef575 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -291,6 +291,7 @@ read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list, } } else { sig = new(ctx) ir_function_signature(return_type); + sig->is_built_in = true; f->add_signature(sig); } diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 04b4efd84ba..3d8f24bb444 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -473,8 +473,64 @@ link_intrastage_shaders(struct gl_shader_program *prog, struct gl_shader **shader_list, unsigned num_shaders) { - (void) prog; - assert(num_shaders == 1); + /* Check that global variables defined in multiple shaders are consistent. + */ + if (!cross_validate_globals(prog, shader_list, num_shaders, false)) + return NULL; + + /* Check that there is only a single definition of each function signature + * across all shaders. + */ + for (unsigned i = 0; i < (num_shaders - 1); i++) { + foreach_list(node, shader_list[i]->ir) { + ir_function *const f = ((ir_instruction *) node)->as_function(); + + if (f == NULL) + continue; + + for (unsigned j = i + 1; j < num_shaders; j++) { + ir_function *const other = + shader_list[j]->symbols->get_function(f->name); + + /* If the other shader has no function (and therefore no function + * signatures) with the same name, skip to the next shader. + */ + if (other == NULL) + continue; + + foreach_iter (exec_list_iterator, iter, *f) { + ir_function_signature *sig = + (ir_function_signature *) iter.get(); + + if (!sig->is_defined || sig->is_built_in) + continue; + + ir_function_signature *other_sig = + other->exact_matching_signature(& sig->parameters); + + if ((other_sig != NULL) && other_sig->is_defined + && !other_sig->is_built_in) { + linker_error_printf(prog, + "function `%s' is multiply defined", + f->name); + return NULL; + } + } + } + } + } + + /* Find the shader that defines main, and make a clone of it. + * + * Starting with the clone, search for undefined references. If one is + * found, find the shader that defines it. Clone the reference and add + * it to the shader. Repeat until there are no undefined references or + * until a reference cannot be resolved. + */ + + + /* Resolve initializers for global variables in the linked shader. + */ gl_shader *const linked = _mesa_new_shader(NULL, 0, shader_list[0]->Type); linked->ir = new(linked) exec_list; -- cgit v1.2.3 From 11fc7beb2fa82179cfd9202449e1365b28f868a9 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 12 Jul 2010 18:35:20 -0700 Subject: ir_function: Make matching_signature not return const The linker needs to use this function to get specific function signatures, but it also needs to modify the returned signature. Since this method isn't itself const (i.e., const this pointer), there is no value in making a const and non-const version. --- src/glsl/ir.h | 2 +- src/glsl/ir_function.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 25bf6c6d151..053b6fecd1d 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -379,7 +379,7 @@ public: * Find a signature that matches a set of actual parameters, taking implicit * conversions into account. */ - const ir_function_signature *matching_signature(exec_list *actual_param); + ir_function_signature *matching_signature(exec_list *actual_param); /** * Find a signature that exactly matches a set of actual parameters without diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp index 5db93f67fb8..fcdb83be561 100644 --- a/src/glsl/ir_function.cpp +++ b/src/glsl/ir_function.cpp @@ -155,7 +155,7 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) } -const ir_function_signature * +ir_function_signature * ir_function::matching_signature(exec_list *actual_parameters) { ir_function_signature *match = NULL; -- cgit v1.2.3 From 15ce87e9f2d4f66ef87af693a284b3cc9fd870c1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 9 Jul 2010 15:28:22 -0700 Subject: linker: Detect the shader that contains "main" during intrastage linking --- src/glsl/linker.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 3d8f24bb444..11deeed5930 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -461,6 +461,33 @@ populate_symbol_table(gl_shader *sh) } +/** + * Get the function signature for main from a shader + */ +static ir_function_signature * +get_main_function_signature(gl_shader *sh) +{ + ir_function *const f = sh->symbols->get_function("main"); + if (f != NULL) { + exec_list void_parameters; + + /* Look for the 'void main()' signature and ensure that it's defined. + * This keeps the linker from accidentally pick a shader that just + * contains a prototype for main. + * + * We don't have to check for multiple definitions of main (in multiple + * shaders) because that would have already been caught above. + */ + ir_function_signature *sig = f->matching_signature(&void_parameters); + if ((sig != NULL) && sig->is_defined) { + return sig; + } + } + + return NULL; +} + + /** * Combine a group of shaders for a single stage to generate a linked shader * @@ -527,17 +554,30 @@ link_intrastage_shaders(struct gl_shader_program *prog, * it to the shader. Repeat until there are no undefined references or * until a reference cannot be resolved. */ + gl_shader *main = NULL; + for (unsigned i = 0; i < num_shaders; i++) { + if (get_main_function_signature(shader_list[i]) != NULL) { + main = shader_list[i]; + break; + } + } + if (main == NULL) { + linker_error_printf(prog, "%s shader lacks `main'\n", + (shader_list[0]->Type == GL_VERTEX_SHADER) + ? "vertex" : "fragment"); + return NULL; + } - /* Resolve initializers for global variables in the linked shader. - */ - - gl_shader *const linked = _mesa_new_shader(NULL, 0, shader_list[0]->Type); + gl_shader *const linked = _mesa_new_shader(NULL, 0, main->Type); linked->ir = new(linked) exec_list; - clone_ir_list(linked->ir, shader_list[0]->ir); + clone_ir_list(linked->ir, main->ir); populate_symbol_table(linked); + /* Resolve initializers for global variables in the linked shader. + */ + return linked; } -- cgit v1.2.3 From 31a97868fc14d4c57681c35021571b4b61f29e20 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 12 Jul 2010 18:48:50 -0700 Subject: linker: Merge global-scope instructions into main Find instructions in all shaders that are not contained in a function (i.e., initializers for global variables). "Move" these instructions to the top of the main function in the linked shader. As a side-effect, many global variables will also be copied into the linked shader. --- src/glsl/linker.cpp | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 11deeed5930..481fcab16fe 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -461,6 +461,111 @@ populate_symbol_table(gl_shader *sh) } +/** + * Remap variables referenced in an instruction tree + * + * This is used when instruction trees are cloned from one shader and placed in + * another. These trees will contain references to \c ir_variable nodes that + * do not exist in the target shader. This function finds these \c ir_variable + * references and replaces the references with matching variables in the target + * shader. + * + * If there is no matching variable in the target shader, a clone of the + * \c ir_variable is made and added to the target shader. The new variable is + * added to \b both the instruction stream and the symbol table. + * + * \param inst IR tree that is to be processed. + * \param symbols Symbol table containing global scope symbols in the + * linked shader. + * \param instructions Instruction stream where new variable declarations + * should be added. + */ +void +remap_variables(ir_instruction *inst, glsl_symbol_table *symbols, + exec_list *instructions) +{ + class remap_visitor : public ir_hierarchical_visitor { + public: + remap_visitor(glsl_symbol_table *symbols, exec_list *instructions) + { + this->symbols = symbols; + this->instructions = instructions; + } + + virtual ir_visitor_status visit(ir_dereference_variable *ir) + { + ir_variable *const existing = + this->symbols->get_variable(ir->var->name); + if (existing != NULL) + ir->var = existing; + else { + ir_variable *copy = ir->var->clone(NULL); + + this->symbols->add_variable(copy->name, copy); + this->instructions->push_head(copy); + } + + return visit_continue; + } + + private: + glsl_symbol_table *symbols; + exec_list *instructions; + }; + + remap_visitor v(symbols, instructions); + + inst->accept(&v); +} + + +/** + * Move non-declarations from one instruction stream to another + * + * The intended usage pattern of this function is to pass the pointer to the + * head sentinal of a list (i.e., a pointer to the list cast to an \c exec_node + * pointer) for \c last and \c false for \c make_copies on the first + * call. Successive calls pass the return value of the previous call for + * \c last and \c true for \c make_copies. + * + * \param instructions Source instruction stream + * \param last Instruction after which new instructions should be + * inserted in the target instruction stream + * \param make_copies Flag selecting whether instructions in \c instructions + * should be copied (via \c ir_instruction::clone) into the + * target list or moved. + * + * \return + * The new "last" instruction in the target instruction stream. This pointer + * is suitable for use as the \c last parameter of a later call to this + * function. + */ +exec_node * +move_non_declarations(exec_list *instructions, exec_node *last, + bool make_copies, gl_shader *target) +{ + foreach_list(node, instructions) { + ir_instruction *inst = (ir_instruction *) node; + + if (inst->as_variable() || inst->as_function()) + continue; + + assert(inst->as_assignment()); + + if (make_copies) { + inst = inst->clone(NULL); + remap_variables(inst, target->symbols, target->ir); + } else { + inst->remove(); + } + + last->insert_after(inst); + last = inst; + } + + return last; +} + /** * Get the function signature for main from a shader */ @@ -575,6 +680,22 @@ link_intrastage_shaders(struct gl_shader_program *prog, populate_symbol_table(linked); + /* The a pointer to the main function in the final linked shader (i.e., the + * copy of the original shader that contained the main function). + */ + ir_function_signature *const main_sig = get_main_function_signature(linked); + + /* Move any instructions other than variable declarations or function + * declarations into main. + */ + exec_node *insertion_point = (exec_node *) &main_sig->body; + for (unsigned i = 0; i < num_shaders; i++) { + insertion_point = move_non_declarations(shader_list[i]->ir, + insertion_point, + (shader_list[i] != main), + linked); + } + /* Resolve initializers for global variables in the linked shader. */ -- cgit v1.2.3 From 94da2abfd49c6b4060544986ef68d5662b1cc292 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 19:31:54 -0700 Subject: glsl2: Flatten expressions that appear as the children of ir_return as well. --- src/glsl/ir_expression_flattening.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp index 629194c1a04..66268a679d9 100644 --- a/src/glsl/ir_expression_flattening.cpp +++ b/src/glsl/ir_expression_flattening.cpp @@ -176,9 +176,7 @@ ir_expression_flattening_visitor::visit_enter(ir_call *ir) ir_visitor_status ir_expression_flattening_visitor::visit_enter(ir_return *ir) { - /* FINISHME: Why not process the return value? (Same behavior as original - * FINISHME: code.) - */ - (void) ir; - return visit_continue_with_parent; + if (ir->value) + ir->value = operand_to_temp(ir->value); + return visit_continue; } -- cgit v1.2.3 From 562c3d0cb1aedbf3c9f13f206678fa3f0fa26a9f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 19:50:01 -0700 Subject: glsl2: Flatten expression that appear as the parameters of ir_call as well. --- src/glsl/ir_expression_flattening.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp index 66268a679d9..f18659342f5 100644 --- a/src/glsl/ir_expression_flattening.cpp +++ b/src/glsl/ir_expression_flattening.cpp @@ -165,11 +165,18 @@ ir_expression_flattening_visitor::visit_leave(ir_swizzle *ir) ir_visitor_status ir_expression_flattening_visitor::visit_enter(ir_call *ir) { - /* FINISHME: Why not process the call parameters? (Same behavior as original - * FINISHME: code.) - */ - (void) ir; - return visit_continue_with_parent; + /* Reminder: iterating ir_call iterates its parameters. */ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *ir = (ir_rvalue *)iter.get(); + ir_rvalue *new_ir = operand_to_temp(ir); + + if (new_ir != ir) { + ir->insert_before(new_ir); + ir->remove(); + } + } + + return visit_continue; } -- cgit v1.2.3 From 3f08989267d9cdd944787fcf7a300c6f1f84462c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 19:28:07 -0700 Subject: ir_to_mesa: Emit OPCODE_MAD when we find an ADD of a MUL. Bug #27914. --- src/mesa/shader/ir_to_mesa.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 467e335fc4b..fc50d26a618 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -178,6 +178,9 @@ public: ir_to_mesa_src_reg src0, ir_to_mesa_src_reg src1); + GLboolean try_emit_mad(ir_expression *ir, + int mul_operand); + int *sampler_map; int sampler_map_size; @@ -530,6 +533,30 @@ ir_to_mesa_visitor::visit(ir_function *ir) } } +GLboolean +ir_to_mesa_visitor::try_emit_mad(ir_expression *ir, int mul_operand) +{ + int nonmul_operand = 1 - mul_operand; + ir_to_mesa_src_reg a, b, c; + + ir_expression *expr = ir->operands[mul_operand]->as_expression(); + if (!expr || expr->operation != ir_binop_mul) + return false; + + expr->operands[0]->accept(this); + a = this->result; + expr->operands[1]->accept(this); + b = this->result; + ir->operands[nonmul_operand]->accept(this); + c = this->result; + + this->result = get_temp(ir->type); + ir_to_mesa_emit_op3(ir, OPCODE_MAD, + ir_to_mesa_dst_reg_from_src(this->result), a, b, c); + + return true; +} + void ir_to_mesa_visitor::visit(ir_expression *ir) { @@ -541,6 +568,15 @@ ir_to_mesa_visitor::visit(ir_expression *ir) const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); + /* Quick peephole: Emit OPCODE_MAD(a, b, c) instead of ADD(MUL(a, b), c) + */ + if (ir->operation == ir_binop_add) { + if (try_emit_mad(ir, 1)) + return; + if (try_emit_mad(ir, 0)) + return; + } + for (operand = 0; operand < ir->get_num_operands(); operand++) { this->result.file = PROGRAM_UNDEFINED; ir->operands[operand]->accept(this); -- cgit v1.2.3 From 15ded6327966fa5824e34f7291e624994457f9b5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 17:34:17 -0700 Subject: glsl2: Add matrix multiplication to ir_mat_op_to_vec. --- src/glsl/ir_mat_op_to_vec.cpp | 197 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 188 insertions(+), 9 deletions(-) diff --git a/src/glsl/ir_mat_op_to_vec.cpp b/src/glsl/ir_mat_op_to_vec.cpp index 828c63c17a7..7bdb9057d82 100644 --- a/src/glsl/ir_mat_op_to_vec.cpp +++ b/src/glsl/ir_mat_op_to_vec.cpp @@ -44,7 +44,17 @@ public: ir_visitor_status visit_leave(ir_assignment *); - ir_rvalue *get_column(ir_variable *var, int i); + ir_rvalue *get_column(ir_variable *var, int col); + ir_rvalue *get_element(ir_variable *var, int col, int row); + + void do_mul_mat_mat(ir_variable *result_var, + ir_variable *a_var, ir_variable *b_var); + void do_mul_mat_vec(ir_variable *result_var, + ir_variable *a_var, ir_variable *b_var); + void do_mul_vec_mat(ir_variable *result_var, + ir_variable *a_var, ir_variable *b_var); + void do_mul_mat_scalar(ir_variable *result_var, + ir_variable *a_var, ir_variable *b_var); bool made_progress; }; @@ -83,7 +93,24 @@ do_mat_op_to_vec(exec_list *instructions) } ir_rvalue * -ir_mat_op_to_vec_visitor::get_column(ir_variable *var, int i) +ir_mat_op_to_vec_visitor::get_element(ir_variable *var, int col, int row) +{ + ir_dereference *deref; + + deref = new(base_ir) ir_dereference_variable(var); + + if (var->type->is_matrix()) { + deref = new(base_ir) ir_dereference_array(var, + new(base_ir) ir_constant(col)); + } else { + assert(col == 0); + } + + return new(base_ir) ir_swizzle(deref, row, 0, 0, 0, 1); +} + +ir_rvalue * +ir_mat_op_to_vec_visitor::get_column(ir_variable *var, int row) { ir_dereference *deref; @@ -92,12 +119,152 @@ ir_mat_op_to_vec_visitor::get_column(ir_variable *var, int i) } else { deref = new(base_ir) ir_dereference_variable(var); deref = new(base_ir) ir_dereference_array(deref, - new(base_ir) ir_constant(i)); + new(base_ir) ir_constant(row)); } return deref; } +void +ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_variable *result_var, + ir_variable *a_var, + ir_variable *b_var) +{ + int b_col, i; + ir_assignment *assign; + ir_expression *expr; + + for (b_col = 0; b_col < b_var->type->matrix_columns; b_col++) { + ir_rvalue *a = get_column(a_var, 0); + ir_rvalue *b = get_element(b_var, b_col, 0); + + /* first column */ + expr = new(base_ir) ir_expression(ir_binop_mul, + a->type, + a, + b); + + /* following columns */ + for (i = 1; i < a_var->type->matrix_columns; i++) { + ir_expression *mul_expr; + + a = get_column(a_var, i); + b = get_element(b_var, b_col, i); + + mul_expr = new(base_ir) ir_expression(ir_binop_mul, + a->type, + a, + b); + expr = new(base_ir) ir_expression(ir_binop_add, + a->type, + expr, + mul_expr); + } + + ir_rvalue *result = get_column(result_var, b_col); + assign = new(base_ir) ir_assignment(result, + expr, + NULL); + base_ir->insert_before(assign); + } +} + +void +ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_variable *result_var, + ir_variable *a_var, + ir_variable *b_var) +{ + int i; + ir_rvalue *a = get_column(a_var, 0); + ir_rvalue *b = get_element(b_var, 0, 0); + ir_assignment *assign; + ir_expression *expr; + + /* first column */ + expr = new(base_ir) ir_expression(ir_binop_mul, + result_var->type, + a, + b); + + /* following columns */ + for (i = 1; i < a_var->type->matrix_columns; i++) { + ir_expression *mul_expr; + + a = get_column(a_var, i); + b = get_element(b_var, 0, i); + + mul_expr = new(base_ir) ir_expression(ir_binop_mul, + result_var->type, + a, + b); + expr = new(base_ir) ir_expression(ir_binop_add, + result_var->type, + expr, + mul_expr); + } + + ir_rvalue *result = new(base_ir) ir_dereference_variable(result_var); + assign = new(base_ir) ir_assignment(result, + expr, + NULL); + base_ir->insert_before(assign); +} + +void +ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_variable *result_var, + ir_variable *a_var, + ir_variable *b_var) +{ + int i; + + for (i = 0; i < b_var->type->matrix_columns; i++) { + ir_rvalue *a = new(base_ir) ir_dereference_variable(a_var); + ir_rvalue *b = get_column(b_var, i); + ir_rvalue *result; + ir_expression *column_expr; + ir_assignment *column_assign; + + result = new(base_ir) ir_dereference_variable(result_var); + result = new(base_ir) ir_swizzle(result, i, 0, 0, 0, 1); + + column_expr = new(base_ir) ir_expression(ir_binop_dot, + result->type, + a, + b); + + column_assign = new(base_ir) ir_assignment(result, + column_expr, + NULL); + base_ir->insert_before(column_assign); + } +} + +void +ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_variable *result_var, + ir_variable *a_var, + ir_variable *b_var) +{ + int i; + + for (i = 0; i < a_var->type->matrix_columns; i++) { + ir_rvalue *a = get_column(a_var, i); + ir_rvalue *b = new(base_ir) ir_dereference_variable(b_var); + ir_rvalue *result = get_column(result_var, i); + ir_expression *column_expr; + ir_assignment *column_assign; + + column_expr = new(base_ir) ir_expression(ir_binop_mul, + result->type, + a, + b); + + column_assign = new(base_ir) ir_assignment(result, + column_expr, + NULL); + base_ir->insert_before(column_assign); + } +} + ir_visitor_status ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign) { @@ -119,10 +286,6 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign) if (!found_matrix) return visit_continue; - /* FINISHME: see below */ - if (expr->operation == ir_binop_mul) - return visit_continue; - ir_dereference_variable *lhs_deref = assign->lhs->as_dereference_variable(); assert(lhs_deref); @@ -174,8 +337,24 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign) } break; case ir_binop_mul: - /* FINISHME */ - return visit_continue; + if (op_var[0]->type->is_matrix()) { + if (op_var[1]->type->is_matrix()) { + do_mul_mat_mat(result_var, op_var[0], op_var[1]); + } else if (op_var[1]->type->is_vector()) { + do_mul_mat_vec(result_var, op_var[0], op_var[1]); + } else { + assert(op_var[1]->type->is_scalar()); + do_mul_mat_scalar(result_var, op_var[0], op_var[1]); + } + } else { + assert(op_var[1]->type->is_matrix()); + if (op_var[0]->type->is_vector()) { + do_mul_vec_mat(result_var, op_var[0], op_var[1]); + } else { + assert(op_var[0]->type->is_scalar()); + do_mul_mat_scalar(result_var, op_var[1], op_var[0]); + } + } break; default: printf("FINISHME: Handle matrix operation for %s\n", expr->operator_string()); -- cgit v1.2.3 From 4ca07882afad656bf0a0f56b68038ce556bceec4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 12 Jul 2010 17:57:46 -0700 Subject: ir_to_mesa: Rely on ir_mat_op_to_vec for matrix multiplication support. --- src/mesa/shader/ir_to_mesa.cpp | 88 +++--------------------------------------- 1 file changed, 5 insertions(+), 83 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index fc50d26a618..110fc100db5 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -588,9 +588,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir) } op[operand] = this->result; - /* Only expression implemented for matrices yet */ - assert(!ir->operands[operand]->type->is_matrix() || - ir->operation == ir_binop_mul); + /* Matrix expression operands should have been broken down to vector + * operations already. + */ + assert(!ir->operands[operand]->type->is_matrix()); } this->result.file = PROGRAM_UNDEFINED; @@ -661,86 +662,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) break; case ir_binop_mul: - if (ir->operands[0]->type->is_matrix()) { - if (ir->operands[1]->type->is_scalar()) { - ir_to_mesa_dst_reg dst_column = result_dst; - ir_to_mesa_src_reg src_column = op[0]; - for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - dst_column, src_column, op[1]); - dst_column.index++; - src_column.index++; - } - } else { - /* matrix * vec or matrix * matrix */ - int op1_col; - ir_to_mesa_dst_reg dst_column = result_dst; - ir_to_mesa_src_reg dst_column_src; - ir_to_mesa_src_reg src_chan = op[1]; - - dst_column_src = ir_to_mesa_src_reg_from_dst(result_dst); - for (op1_col = 0; op1_col < ir->operands[1]->type->matrix_columns; - op1_col++) { - ir_to_mesa_src_reg src_column = op[0]; - - for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { - src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); - if (i == 0) { - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - dst_column, src_column, src_chan); - } else { - ir_to_mesa_emit_op3(ir, OPCODE_MAD, - dst_column, src_column, src_chan, - dst_column_src); - } - src_column.index++; - } - src_chan.index++; - dst_column.index++; - dst_column_src.index++; - } - } - } else if (ir->operands[1]->type->is_matrix()) { - if (ir->operands[0]->type->is_scalar()) { - ir_to_mesa_dst_reg dst_column = result_dst; - ir_to_mesa_src_reg src_column = op[1]; - for (int i = 0; i < ir->operands[1]->type->matrix_columns; i++) { - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - dst_column, src_column, op[0]); - dst_column.index++; - src_column.index++; - } - } else { - ir_to_mesa_src_reg src_column = op[1]; - ir_to_mesa_dst_reg dst_chan = result_dst; - - /* FINISHME here and above: non-square matrices */ - assert(ir->operands[1]->type->vector_elements == - ir->operands[1]->type->matrix_columns); - - for (int i = 0; i < ir->operands[0]->type->vector_elements; i++) { - dst_chan.writemask = (1 << i); - switch (ir->operands[0]->type->vector_elements) { - case 2: - ir_to_mesa_emit_op2(ir, OPCODE_DP2, dst_chan, op[0], src_column); - break; - case 3: - ir_to_mesa_emit_op2(ir, OPCODE_DP3, dst_chan, op[0], src_column); - break; - case 4: - ir_to_mesa_emit_op2(ir, OPCODE_DP4, dst_chan, op[0], src_column); - break; - default: - assert(0); - } - src_column.index++; - } - } - } else { - assert(!ir->operands[0]->type->is_matrix()); - assert(!ir->operands[1]->type->is_matrix()); - ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], op[1]); - } + ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], op[1]); break; case ir_binop_div: assert(!"not reached: should be handled by ir_div_to_mul_rcp"); -- cgit v1.2.3 From 4e6a3e0d2d148747002ab9e9c1dffe63e912c688 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 13 Jul 2010 09:22:35 -0700 Subject: glsl2: Remove unnecessary casts of clone return values --- src/glsl/ir_clone.cpp | 47 ++++++++++++++++++++++------------------------- src/glsl/linker.cpp | 3 +-- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 2562ad91187..c7b786f0c48 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -67,7 +67,7 @@ ir_swizzle * ir_swizzle::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); - return new(ctx) ir_swizzle((ir_rvalue *)this->val->clone(ht), this->mask); + return new(ctx) ir_swizzle(this->val->clone(ht), this->mask); } ir_return * @@ -77,7 +77,7 @@ ir_return::clone(struct hash_table *ht) const ir_rvalue *new_value = NULL; if (this->value) - new_value = (ir_rvalue *)this->value->clone(ht); + new_value = this->value->clone(ht); return new(ctx) ir_return(new_value); } @@ -89,7 +89,7 @@ ir_discard::clone(struct hash_table *ht) const ir_rvalue *new_condition = NULL; if (this->condition != NULL) - new_condition = (ir_rvalue *) this->condition->clone(ht); + new_condition = this->condition->clone(ht); return new(ctx) ir_discard(new_condition); } @@ -107,7 +107,7 @@ ir_if * ir_if::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); - ir_if *new_if = new(ctx) ir_if((ir_rvalue *)this->condition->clone(ht)); + ir_if *new_if = new(ctx) ir_if(this->condition->clone(ht)); foreach_iter(exec_list_iterator, iter, this->then_instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); @@ -129,11 +129,11 @@ ir_loop::clone(struct hash_table *ht) const ir_loop *new_loop = new(ctx) ir_loop(); if (this->from) - new_loop->from = (ir_rvalue *)this->from->clone(ht); + new_loop->from = this->from->clone(ht); if (this->to) - new_loop->to = (ir_rvalue *)this->to->clone(ht); + new_loop->to = this->to->clone(ht); if (this->increment) - new_loop->increment = (ir_rvalue *)this->increment->clone(ht); + new_loop->increment = this->increment->clone(ht); new_loop->counter = counter; foreach_iter(exec_list_iterator, iter, this->body_instructions) { @@ -166,7 +166,7 @@ ir_expression::clone(struct hash_table *ht) const unsigned int i; for (i = 0; i < get_num_operands(); i++) { - op[i] = (ir_rvalue *)this->operands[i]->clone(ht); + op[i] = this->operands[i]->clone(ht); } return new(ctx) ir_expression(this->operation, this->type, op[0], op[1]); @@ -193,15 +193,15 @@ ir_dereference_array * ir_dereference_array::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); - return new(ctx) ir_dereference_array((ir_rvalue *)this->array->clone(ht), - (ir_rvalue *)this->array_index->clone(ht)); + return new(ctx) ir_dereference_array(this->array->clone(ht), + this->array_index->clone(ht)); } ir_dereference_record * ir_dereference_record::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); - return new(ctx) ir_dereference_record((ir_rvalue *)this->record->clone(ht), + return new(ctx) ir_dereference_record(this->record->clone(ht), this->field); } @@ -211,13 +211,12 @@ ir_texture::clone(struct hash_table *ht) const void *ctx = talloc_parent(this); ir_texture *new_tex = new(ctx) ir_texture(this->op); - new_tex->sampler = (ir_dereference *)this->sampler->clone(ht); - new_tex->coordinate = (ir_rvalue *)this->coordinate->clone(ht); + new_tex->sampler = this->sampler->clone(ht); + new_tex->coordinate = this->coordinate->clone(ht); if (this->projector) - new_tex->projector = (ir_rvalue *)this->projector->clone(ht); + new_tex->projector = this->projector->clone(ht); if (this->shadow_comparitor) { - new_tex->shadow_comparitor = - (ir_rvalue *)this->shadow_comparitor->clone(ht); + new_tex->shadow_comparitor = this->shadow_comparitor->clone(ht); } for (int i = 0; i < 3; i++) @@ -227,17 +226,15 @@ ir_texture::clone(struct hash_table *ht) const case ir_tex: break; case ir_txb: - new_tex->lod_info.bias = (ir_rvalue *)this->lod_info.bias->clone(ht); + new_tex->lod_info.bias = this->lod_info.bias->clone(ht); break; case ir_txl: case ir_txf: - new_tex->lod_info.lod = (ir_rvalue *)this->lod_info.lod->clone(ht); + new_tex->lod_info.lod = this->lod_info.lod->clone(ht); break; case ir_txd: - new_tex->lod_info.grad.dPdx = - (ir_rvalue *)this->lod_info.grad.dPdx->clone(ht); - new_tex->lod_info.grad.dPdy = - (ir_rvalue *)this->lod_info.grad.dPdy->clone(ht); + new_tex->lod_info.grad.dPdx = this->lod_info.grad.dPdx->clone(ht); + new_tex->lod_info.grad.dPdy = this->lod_info.grad.dPdy->clone(ht); break; } @@ -250,11 +247,11 @@ ir_assignment::clone(struct hash_table *ht) const ir_rvalue *new_condition = NULL; if (this->condition) - new_condition = (ir_rvalue *)this->condition->clone(ht); + new_condition = this->condition->clone(ht); void *ctx = talloc_parent(this); - return new(ctx) ir_assignment((ir_rvalue *)this->lhs->clone(ht), - (ir_rvalue *)this->rhs->clone(ht), + return new(ctx) ir_assignment(this->lhs->clone(ht), + this->rhs->clone(ht), new_condition); } diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 481fcab16fe..90dc97bc535 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -315,8 +315,7 @@ cross_validate_globals(struct gl_shader_program *prog, * have an initializer but a later instance does, copy the * initializer to the version stored in the symbol table. */ - existing->constant_value = - (ir_constant *)var->constant_value->clone(NULL); + existing->constant_value = var->constant_value->clone(NULL); } } else variables.add_variable(var->name, var); -- cgit v1.2.3 From f8a2b65bc9bf3dfb4a4aa6fe1c0ea65f78a01922 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Jul 2010 09:05:28 -0700 Subject: ir_to_mesa: Add support for array dereferences on the LHS of assignments. The big change is to delay address reg setup until the instruction that needs the deref. It was hard to use the deref chain support for the LHS because it does the copy of the dereffed value to a temporary (to avoid problems when two src regs are array derefs), so we wouldn't haev a pointer to actual storage in the end. Fixes glsl-vs-arrays on swrast. --- src/mesa/shader/ir_to_mesa.cpp | 96 +++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 29 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 110fc100db5..f4a8ceb09eb 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -61,7 +61,8 @@ typedef struct ir_to_mesa_src_reg { int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ GLuint swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ int negate; /**< NEGATE_XYZW mask from mesa */ - bool reladdr; /**< Register index should be offset by address reg. */ + /** Register index should be offset by the integer in this reg. */ + ir_to_mesa_src_reg *reladdr; } ir_to_mesa_src_reg; typedef struct ir_to_mesa_dst_reg { @@ -69,6 +70,8 @@ typedef struct ir_to_mesa_dst_reg { int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ int writemask; /**< Bitfield of WRITEMASK_[XYZW] */ GLuint cond_mask:4; + /** Register index should be offset by the integer in this reg. */ + ir_to_mesa_src_reg *reladdr; } ir_to_mesa_dst_reg; extern ir_to_mesa_src_reg ir_to_mesa_undef; @@ -111,6 +114,8 @@ public: temp_entry *find_variable_storage(ir_variable *var); ir_to_mesa_src_reg get_temp(const glsl_type *type); + void reladdr_to_temp(ir_instruction *ir, + ir_to_mesa_src_reg *reg, int *num_reladdr); struct ir_to_mesa_src_reg src_reg_for_float(float val); @@ -191,15 +196,15 @@ public: }; ir_to_mesa_src_reg ir_to_mesa_undef = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, NEGATE_NONE, false, + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, NEGATE_NONE, NULL, }; ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, COND_TR + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, COND_TR, NULL, }; ir_to_mesa_dst_reg ir_to_mesa_address_reg = { - PROGRAM_ADDRESS, 0, WRITEMASK_X, COND_TR + PROGRAM_ADDRESS, 0, WRITEMASK_X, COND_TR, NULL }; static int swizzle_for_size(int size) @@ -223,6 +228,28 @@ ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir, ir_to_mesa_src_reg src2) { ir_to_mesa_instruction *inst = new(mem_ctx) ir_to_mesa_instruction(); + int num_reladdr = 0; + + /* If we have to do relative addressing, we want to load the ARL + * reg directly for one of the regs, and preload the other reladdr + * sources into temps. + */ + num_reladdr += dst.reladdr != NULL; + num_reladdr += src0.reladdr != NULL; + num_reladdr += src1.reladdr != NULL; + num_reladdr += src2.reladdr != NULL; + + reladdr_to_temp(ir, &src2, &num_reladdr); + reladdr_to_temp(ir, &src1, &num_reladdr); + reladdr_to_temp(ir, &src0, &num_reladdr); + + if (dst.reladdr) { + ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, + *dst.reladdr); + + num_reladdr--; + } + assert(num_reladdr == 0); inst->op = op; inst->dst_reg = dst; @@ -285,6 +312,7 @@ ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) dst_reg.index = reg.index; dst_reg.writemask = WRITEMASK_XYZW; dst_reg.cond_mask = COND_TR; + dst_reg.reladdr = reg.reladdr; return dst_reg; } @@ -298,7 +326,7 @@ ir_to_mesa_src_reg_from_dst(ir_to_mesa_dst_reg reg) src_reg.index = reg.index; src_reg.swizzle = SWIZZLE_XYZW; src_reg.negate = 0; - src_reg.reladdr = 0; + src_reg.reladdr = reg.reladdr; return src_reg; } @@ -378,7 +406,7 @@ ir_to_mesa_visitor::src_reg_for_float(float val) src_reg.file = PROGRAM_CONSTANT; src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, &val, 1, &src_reg.swizzle); - src_reg.reladdr = GL_FALSE; + src_reg.reladdr = NULL; src_reg.negate = 0; return src_reg; @@ -435,7 +463,7 @@ ir_to_mesa_visitor::get_temp(const glsl_type *type) src_reg.file = PROGRAM_TEMPORARY; src_reg.index = next_temp; - src_reg.reladdr = false; + src_reg.reladdr = NULL; next_temp += type_size(type); for (i = 0; i < type->vector_elements; i++) @@ -557,6 +585,26 @@ ir_to_mesa_visitor::try_emit_mad(ir_expression *ir, int mul_operand) return true; } +void +ir_to_mesa_visitor::reladdr_to_temp(ir_instruction *ir, + ir_to_mesa_src_reg *reg, int *num_reladdr) +{ + if (!reg->reladdr) + return; + + ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, *reg->reladdr); + + if (*num_reladdr != 1) { + ir_to_mesa_src_reg temp = get_temp(glsl_type::vec4_type); + + ir_to_mesa_emit_op1(ir, OPCODE_MOV, + ir_to_mesa_dst_reg_from_src(temp), *reg); + *reg = temp; + } + + (*num_reladdr)--; +} + void ir_to_mesa_visitor::visit(ir_expression *ir) { @@ -1045,7 +1093,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) src_reg.index = entry->index; /* If the type is smaller than a vec4, replicate the last channel out. */ src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); - src_reg.reladdr = false; + src_reg.reladdr = NULL; src_reg.negate = 0; this->result = src_reg; @@ -1077,7 +1125,7 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) src_reg.negate = 0; if (index) { - src_reg.reladdr = GL_FALSE; + src_reg.reladdr = NULL; } else { ir_to_mesa_src_reg index_reg = get_temp(glsl_type::float_type); @@ -1086,9 +1134,8 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) ir_to_mesa_dst_reg_from_src(index_reg), this->result, src_reg_for_float(element_size)); - src_reg.reladdr = true; - ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, - index_reg); + src_reg.reladdr = talloc(mem_ctx, ir_to_mesa_src_reg); + memcpy(src_reg.reladdr, &index_reg, sizeof(index_reg)); } this->result = src_reg; @@ -1126,17 +1173,10 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) this->result, src_reg_for_float(element_size)); } - /* FINISHME: This doesn't work when we're trying to do the LHS - * of an assignment. - */ - src_reg.reladdr = true; - ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, - index_reg); - - this->result = get_temp(ir->type); - ir_to_mesa_emit_op1(ir, OPCODE_MOV, - ir_to_mesa_dst_reg_from_src(this->result), - src_reg); + src_reg.reladdr = talloc(mem_ctx, ir_to_mesa_src_reg); + memcpy(src_reg.reladdr, &index_reg, sizeof(index_reg)); + + this->result = src_reg; } } @@ -1183,9 +1223,6 @@ get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) /* This should have been handled by ir_vec_index_to_cond_assign */ if (deref_array) { assert(!deref_array->array->type->is_vector()); - - /* We don't handle relative addressing on the LHS yet. */ - assert(deref_array->array_index->constant_expression_value() != NULL); } /* Use the rvalue deref handler for the most part. We'll ignore @@ -1313,7 +1350,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir) values, ir->type->vector_elements, &src_reg.swizzle); - src_reg.reladdr = false; + src_reg.reladdr = NULL; src_reg.negate = 0; ir_to_mesa_emit_op1(ir, OPCODE_MOV, mat_column, src_reg); @@ -1350,7 +1387,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir) src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, values, ir->type->vector_elements, &src_reg.swizzle); - src_reg.reladdr = false; + src_reg.reladdr = NULL; src_reg.negate = 0; this->result = src_reg; @@ -1578,7 +1615,7 @@ mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) assert(reg.index < (1 << INST_INDEX_BITS) - 1); mesa_reg.Index = reg.index; mesa_reg.Swizzle = reg.swizzle; - mesa_reg.RelAddr = reg.reladdr; + mesa_reg.RelAddr = reg.reladdr != NULL; mesa_reg.Negate = reg.negate; mesa_reg.Abs = 0; @@ -1813,6 +1850,7 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) mesa_inst->DstReg.Index = inst->dst_reg.index; mesa_inst->DstReg.CondMask = inst->dst_reg.cond_mask; mesa_inst->DstReg.WriteMask = inst->dst_reg.writemask; + mesa_inst->DstReg.RelAddr = inst->dst_reg.reladdr != NULL; mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); -- cgit v1.2.3 From 4d5da50b94115d055ba8d0ff8717054582665384 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Jul 2010 09:46:26 -0700 Subject: ir_to_mesa: Add support for variable array indexing of builtin varyings. That is to say, gl_TexCoord[i] now works, fixing glsl-texcoord-array on swrast. --- src/mesa/shader/ir_to_mesa.cpp | 94 ++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 32 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index f4a8ceb09eb..fee94547236 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1145,39 +1145,30 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) ir->array->accept(this); src_reg = this->result; - if (src_reg.file == PROGRAM_INPUT || - src_reg.file == PROGRAM_OUTPUT) { - assert(index); /* FINISHME: Handle variable indexing of builtins. */ - - src_reg.index += index->value.i[0]; + if (index) { + src_reg.index += index->value.i[0] * element_size; } else { - if (index) { - src_reg.index += index->value.i[0] * element_size; - } else { - ir_to_mesa_src_reg array_base = this->result; - /* Variable index array dereference. It eats the "vec4" of the - * base of the array and an index that offsets the Mesa register - * index. - */ - ir->array_index->accept(this); - - ir_to_mesa_src_reg index_reg; - - if (element_size == 1) { - index_reg = this->result; - } else { - index_reg = get_temp(glsl_type::float_type); + ir_to_mesa_src_reg array_base = this->result; + /* Variable index array dereference. It eats the "vec4" of the + * base of the array and an index that offsets the Mesa register + * index. + */ + ir->array_index->accept(this); - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - ir_to_mesa_dst_reg_from_src(index_reg), - this->result, src_reg_for_float(element_size)); - } + ir_to_mesa_src_reg index_reg; - src_reg.reladdr = talloc(mem_ctx, ir_to_mesa_src_reg); - memcpy(src_reg.reladdr, &index_reg, sizeof(index_reg)); + if (element_size == 1) { + index_reg = this->result; + } else { + index_reg = get_temp(glsl_type::float_type); - this->result = src_reg; + ir_to_mesa_emit_op2(ir, OPCODE_MUL, + ir_to_mesa_dst_reg_from_src(index_reg), + this->result, src_reg_for_float(element_size)); } + + src_reg.reladdr = talloc(mem_ctx, ir_to_mesa_src_reg); + memcpy(src_reg.reladdr, &index_reg, sizeof(index_reg)); } /* If the type is smaller than a vec4, replicate the last channel out. */ @@ -1717,6 +1708,44 @@ print_program(struct prog_instruction *mesa_instructions, } } +static void +mark_input(struct gl_program *prog, + int index, + GLboolean reladdr) +{ + prog->InputsRead |= BITFIELD64_BIT(index); + int i; + + if (reladdr) { + if (index >= FRAG_ATTRIB_TEX0 && index <= FRAG_ATTRIB_TEX7) { + for (i = 0; i < 8; i++) { + prog->InputsRead |= BITFIELD64_BIT(FRAG_ATTRIB_TEX0 + i); + } + } else { + assert(!"FINISHME: Mark InputsRead for varying arrays"); + } + } +} + +static void +mark_output(struct gl_program *prog, + int index, + GLboolean reladdr) +{ + prog->OutputsWritten |= BITFIELD64_BIT(index); + int i; + + if (reladdr) { + if (index >= VERT_RESULT_TEX0 && index <= VERT_RESULT_TEX7) { + for (i = 0; i < 8; i++) { + prog->OutputsWritten |= BITFIELD64_BIT(FRAG_ATTRIB_TEX0 + i); + } + } else { + assert(!"FINISHME: Mark OutputsWritten for varying arrays"); + } + } +} + static void count_resources(struct gl_program *prog) { @@ -1732,10 +1761,10 @@ count_resources(struct gl_program *prog) switch (inst->DstReg.File) { case PROGRAM_OUTPUT: - prog->OutputsWritten |= BITFIELD64_BIT(inst->DstReg.Index); + mark_output(prog, inst->DstReg.Index, inst->DstReg.RelAddr); break; case PROGRAM_INPUT: - prog->InputsRead |= BITFIELD64_BIT(inst->DstReg.Index); + mark_input(prog, inst->DstReg.Index, inst->DstReg.RelAddr); break; default: break; @@ -1744,10 +1773,11 @@ count_resources(struct gl_program *prog) for (reg = 0; reg < _mesa_num_inst_src_regs(inst->Opcode); reg++) { switch (inst->SrcReg[reg].File) { case PROGRAM_OUTPUT: - prog->OutputsWritten |= BITFIELD64_BIT(inst->SrcReg[reg].Index); + mark_output(prog, inst->SrcReg[reg].Index, + inst->SrcReg[reg].RelAddr); break; case PROGRAM_INPUT: - prog->InputsRead |= BITFIELD64_BIT(inst->SrcReg[reg].Index); + mark_input(prog, inst->SrcReg[reg].Index, inst->SrcReg[reg].RelAddr); break; default: break; -- cgit v1.2.3 From c10a68522c400d48553dbd473b9778140842d9dd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Jul 2010 11:07:16 -0700 Subject: glsl2: When linking makes a variable not a varying output, make it ir_var_auto. This almost fixes glsl-unused-varying, except that the used varying gets assigned to the first varying slot (position). --- src/glsl/linker.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 90dc97bc535..c71c07d6e97 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1052,7 +1052,10 @@ assign_varying_locations(gl_shader *producer, gl_shader *consumer) /* An 'out' variable is only really a shader output if its value is read * by the following stage. */ - var->shader_out = (var->location != -1); + if (var->location == -1) { + var->shader_out = false; + var->mode = ir_var_auto; + } } foreach_list(node, consumer->ir) { -- cgit v1.2.3 From 021222c6a872ca2eef770ebadb8754f659775204 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Jul 2010 12:24:39 -0700 Subject: ir_to_mesa: Add convenience function for opcodes with no src/dst reg. Most of flow control is like this. --- src/mesa/shader/ir_to_mesa.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index fee94547236..6ecc6d317c7 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -154,6 +154,9 @@ public: /** List of ir_to_mesa_instruction */ exec_list instructions; + ir_to_mesa_instruction *ir_to_mesa_emit_op0(ir_instruction *ir, + enum prog_opcode op); + ir_to_mesa_instruction *ir_to_mesa_emit_op1(ir_instruction *ir, enum prog_opcode op, ir_to_mesa_dst_reg dst, @@ -284,6 +287,16 @@ ir_to_mesa_visitor::ir_to_mesa_emit_op1(ir_instruction *ir, src0, ir_to_mesa_undef, ir_to_mesa_undef); } +ir_to_mesa_instruction * +ir_to_mesa_visitor::ir_to_mesa_emit_op0(ir_instruction *ir, + enum prog_opcode op) +{ + return ir_to_mesa_emit_op3(ir, op, ir_to_mesa_undef_dst, + ir_to_mesa_undef, + ir_to_mesa_undef, + ir_to_mesa_undef); +} + void ir_to_mesa_visitor::map_sampler(int location, int sampler) { @@ -507,13 +520,9 @@ ir_to_mesa_visitor::visit(ir_loop *ir) assert(!ir->increment); assert(!ir->counter); - ir_to_mesa_emit_op1(NULL, OPCODE_BGNLOOP, - ir_to_mesa_undef_dst, ir_to_mesa_undef); - + ir_to_mesa_emit_op0(NULL, OPCODE_BGNLOOP); visit_exec_list(&ir->body_instructions, this); - - ir_to_mesa_emit_op1(NULL, OPCODE_ENDLOOP, - ir_to_mesa_undef_dst, ir_to_mesa_undef); + ir_to_mesa_emit_op0(NULL, OPCODE_ENDLOOP); } void @@ -521,12 +530,10 @@ ir_to_mesa_visitor::visit(ir_loop_jump *ir) { switch (ir->mode) { case ir_loop_jump::jump_break: - ir_to_mesa_emit_op1(NULL, OPCODE_BRK, - ir_to_mesa_undef_dst, ir_to_mesa_undef); + ir_to_mesa_emit_op0(NULL, OPCODE_BRK); break; case ir_loop_jump::jump_continue: - ir_to_mesa_emit_op1(NULL, OPCODE_CONT, - ir_to_mesa_undef_dst, ir_to_mesa_undef); + ir_to_mesa_emit_op0(NULL, OPCODE_CONT); break; } } @@ -1534,8 +1541,7 @@ ir_to_mesa_visitor::visit(ir_discard *ir) { assert(ir->condition == NULL); /* FINISHME */ - ir_to_mesa_emit_op1(ir, OPCODE_KIL_NV, - ir_to_mesa_undef_dst, ir_to_mesa_undef); + ir_to_mesa_emit_op0(ir, OPCODE_KIL_NV); } void @@ -1564,9 +1570,7 @@ ir_to_mesa_visitor::visit(ir_if *ir) } cond_inst->cond_update = GL_TRUE; - if_inst = ir_to_mesa_emit_op1(ir->condition, - OPCODE_IF, ir_to_mesa_undef_dst, - ir_to_mesa_undef); + if_inst = ir_to_mesa_emit_op0(ir->condition, OPCODE_IF); if_inst->dst_reg.cond_mask = COND_NE; } else { if_inst = ir_to_mesa_emit_op1(ir->condition, @@ -1579,9 +1583,7 @@ ir_to_mesa_visitor::visit(ir_if *ir) visit_exec_list(&ir->then_instructions, this); if (!ir->else_instructions.is_empty()) { - else_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ELSE, - ir_to_mesa_undef_dst, - ir_to_mesa_undef); + else_inst = ir_to_mesa_emit_op0(ir->condition, OPCODE_ELSE); visit_exec_list(&ir->else_instructions, this); } @@ -1853,8 +1855,7 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) v.mem_ctx = talloc_new(NULL); visit_exec_list(shader->ir, &v); - v.ir_to_mesa_emit_op1(NULL, OPCODE_END, - ir_to_mesa_undef_dst, ir_to_mesa_undef); + v.ir_to_mesa_emit_op0(NULL, OPCODE_END); prog->NumTemporaries = v.next_temp; -- cgit v1.2.3 From 7d19bf2ec34dceb621ec82861be3d12ba73e67d3 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 14 Jul 2010 11:54:15 -0700 Subject: glsl2: Remove ir_program bong hits. --- src/glsl/ir.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 053b6fecd1d..790173ed6be 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -41,10 +41,6 @@ extern "C" { #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #endif -struct ir_program { - void *bong_hits; -}; - /** * Base class of all IR instructions */ -- cgit v1.2.3 From 5e840dba4412b33ae49289efd357a60098ac2611 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 23:09:48 -0700 Subject: ir_constant_expression: Remove bogus assert in ir_unop_abs case. abs is defined for integral types; it's even implemented. --- src/glsl/ir_constant_expression.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 0fe93adcead..06d7dd8fbe0 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -243,7 +243,6 @@ ir_constant_visitor::visit(ir_expression *ir) break; case ir_unop_abs: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { case GLSL_TYPE_UINT: -- cgit v1.2.3 From 14b7b2660c771aa090477c11f85da998ec3d2570 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 23:11:14 -0700 Subject: ir_constant_expression: Add support for ir_unop_sign. --- src/glsl/ir_constant_expression.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 06d7dd8fbe0..5ba6264dd65 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -262,6 +262,24 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_sign: + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + switch (ir->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.i[c] > 0; + break; + case GLSL_TYPE_INT: + data.i[c] = (op[0]->value.i[c] > 0) - (op[0]->value.i[c] < 0); + break; + case GLSL_TYPE_FLOAT: + data.f[c] = float((op[0]->value.f[c] > 0)-(op[0]->value.f[c] < 0)); + break; + default: + assert(0); + } + } + break; + case ir_unop_rcp: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { -- cgit v1.2.3 From aca01edc8336fd14005a7ac853e7158f31a74940 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 23:14:32 -0700 Subject: ir_constant_expression: Add support for ir_unop_exp2. This uses a C99 function. --- src/glsl/ir_constant_expression.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 5ba6264dd65..871bce43b7a 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -323,6 +323,13 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_exp2: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = exp2f(op[0]->value.f[c]); + } + break; + case ir_unop_log: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { -- cgit v1.2.3 From cb63929df4ce17e94e8ead0316a00d48b51944c9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 23:18:09 -0700 Subject: ir_constant_expression: Add support for ir_unop_log2. This uses a C99 function. --- src/glsl/ir_constant_expression.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 871bce43b7a..292461e5eb7 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -337,6 +337,13 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_log2: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = log2f(op[0]->value.f[c]); + } + break; + case ir_unop_dFdx: case ir_unop_dFdy: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); -- cgit v1.2.3 From 323d909ab21c9f378903e2027fcfef5ba9e890f9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 23:21:36 -0700 Subject: ir_constant_expression: Add support for ir_unop_trunc. This uses a C99 function. --- src/glsl/ir_constant_expression.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 292461e5eb7..09bc5b6bbff 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -206,6 +206,13 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_trunc: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = truncf(op[0]->value.f[c]); + } + break; + case ir_unop_fract: for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { -- cgit v1.2.3 From c1ee30a14590d73217f7dbd35e6a1839435cc5b4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 23:22:36 -0700 Subject: ir_constant_expression: Add support for ir_unop_ceil. --- src/glsl/ir_constant_expression.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 09bc5b6bbff..19498a3bf95 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -213,6 +213,13 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_ceil: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = ceilf(op[0]->value.f[c]); + } + break; + case ir_unop_fract: for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { -- cgit v1.2.3 From 074720477ce9de3b4dafceffd7406bcebae1a3b9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 23:23:23 -0700 Subject: ir_constant_expression: Add support for ir_unop_floor. --- src/glsl/ir_constant_expression.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 19498a3bf95..44a69854ad0 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -220,6 +220,13 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_floor: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = floorf(op[0]->value.f[c]); + } + break; + case ir_unop_fract: for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { -- cgit v1.2.3 From 908afd16d1f6b5283a2535e388b6dcb77e6504d2 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 23:28:50 -0700 Subject: ir_constant_expression: Add support for ir_unop_sin. --- src/glsl/ir_constant_expression.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 44a69854ad0..3d0a5e5fe08 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -245,6 +245,13 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_sin: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = sinf(op[0]->value.f[c]); + } + break; + case ir_unop_neg: for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { -- cgit v1.2.3 From 3fab376bef8c5f407d4011b89a17ea4fd414f213 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 23:29:37 -0700 Subject: ir_constant_expression: Add support for ir_unop_cos. --- src/glsl/ir_constant_expression.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 3d0a5e5fe08..ef8661baf57 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -252,6 +252,13 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_unop_cos: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = cosf(op[0]->value.f[c]); + } + break; + case ir_unop_neg: for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { switch (ir->type->base_type) { -- cgit v1.2.3 From 891a0647e419c0cd2b67e43540936bf0ac94f840 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 8 Jul 2010 23:35:09 -0700 Subject: ir_constant_expression: Add support for ir_binop_pow. --- src/glsl/ir_constant_expression.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index ef8661baf57..437a3805de4 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -387,6 +387,13 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_binop_pow: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + data.f[c] = powf(op[0]->value.f[c], op[1]->value.f[c]); + } + break; + case ir_binop_dot: assert(op[0]->type->is_vector() && op[1]->type->is_vector()); data.f[0] = 0; -- cgit v1.2.3 From 79fed377f4625da9ce6a0a32c1e7277a2e90e914 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Jul 2010 11:53:56 -0700 Subject: ir_constant_expression: Add support for ir_binop_min and ir_binop_max. These now work on scalar/vector combos. Semantically, if a is a scalar, min(a, vec2(x,y)) == vec2(min(a,x), min(a,y)) --- src/glsl/ir_constant_expression.cpp | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 437a3805de4..7e276e1c257 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -38,6 +38,9 @@ #include "ir_visitor.h" #include "glsl_types.h" +#define min(x,y) (x) < (y) ? (x) : (y) +#define max(x,y) (x) > (y) ? (x) : (y) + /** * Visitor class for evaluating constant expressions */ @@ -413,6 +416,50 @@ ir_constant_visitor::visit(ir_expression *ir) } } + break; + case ir_binop_min: + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = min(op[0]->value.u[c0], op[1]->value.u[c1]); + break; + case GLSL_TYPE_INT: + data.i[c] = min(op[0]->value.i[c0], op[1]->value.i[c1]); + break; + case GLSL_TYPE_FLOAT: + data.f[c] = min(op[0]->value.f[c0], op[1]->value.f[c1]); + break; + default: + assert(0); + } + } + + break; + case ir_binop_max: + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = max(op[0]->value.u[c0], op[1]->value.u[c1]); + break; + case GLSL_TYPE_INT: + data.i[c] = max(op[0]->value.i[c0], op[1]->value.i[c1]); + break; + case GLSL_TYPE_FLOAT: + data.f[c] = max(op[0]->value.f[c0], op[1]->value.f[c1]); + break; + default: + assert(0); + } + } + break; case ir_binop_add: assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); -- cgit v1.2.3 From ce5ae5f49d82b545ab204b9fdb9a8f939e0a6d78 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 14 Jul 2010 11:28:40 -0700 Subject: ir_constant_expression: Add support for ir_binop_mod. --- src/glsl/ir_constant_expression.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 7e276e1c257..c0fe47067bd 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -575,6 +575,33 @@ ir_constant_visitor::visit(ir_expression *ir) } break; + case ir_binop_mod: + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (ir->operands[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] % op[1]->value.u[c1]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] % op[1]->value.i[c1]; + break; + case GLSL_TYPE_FLOAT: + /* We don't use fmod because it rounds toward zero; GLSL specifies + * the use of floor. + */ + data.f[c] = (op[0]->value.f[c0] - op[1]->value.f[c1]) + * floorf(op[0]->value.f[c0] / op[1]->value.f[c1]); + break; + default: + assert(0); + } + } + + break; + case ir_binop_logic_and: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) -- cgit v1.2.3 From 8984203abb711d5b9e763afc6afc8f52cc4f7cc2 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Jul 2010 12:12:41 -0700 Subject: glsl2/builtins: Rework min/max to use scalar/vector combinations. --- src/glsl/builtins/110/max | 27 +++--------------------- src/glsl/builtins/110/min | 27 +++--------------------- src/glsl/builtins/130/max | 54 ++++++----------------------------------------- src/glsl/builtins/130/min | 54 ++++++----------------------------------------- 4 files changed, 18 insertions(+), 144 deletions(-) diff --git a/src/glsl/builtins/110/max b/src/glsl/builtins/110/max index c05545f3d93..f91ae417e4b 100644 --- a/src/glsl/builtins/110/max +++ b/src/glsl/builtins/110/max @@ -27,38 +27,17 @@ (parameters (declare (in) vec2 arg0) (declare (in) float arg1)) - ((declare () vec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec2 max (var_ref arg0) (var_ref arg1))))) (signature vec3 (parameters (declare (in) vec3 arg0) (declare (in) float arg1)) - ((declare () vec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float max (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec3 max (var_ref arg0) (var_ref arg1))))) (signature vec4 (parameters (declare (in) vec4 arg0) (declare (in) float arg1)) - ((declare () vec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float max (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression float max (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) )) diff --git a/src/glsl/builtins/110/min b/src/glsl/builtins/110/min index 31e79489405..78fc44120af 100644 --- a/src/glsl/builtins/110/min +++ b/src/glsl/builtins/110/min @@ -27,38 +27,17 @@ (parameters (declare (in) vec2 arg0) (declare (in) float arg1)) - ((declare () vec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec2 min (var_ref arg0) (var_ref arg1))))) (signature vec3 (parameters (declare (in) vec3 arg0) (declare (in) float arg1)) - ((declare () vec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float min (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec3 min (var_ref arg0) (var_ref arg1))))) (signature vec4 (parameters (declare (in) vec4 arg0) (declare (in) float arg1)) - ((declare () vec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float min (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression float min (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) )) diff --git a/src/glsl/builtins/130/max b/src/glsl/builtins/130/max index 45a6089c9f2..0863e411a32 100644 --- a/src/glsl/builtins/130/max +++ b/src/glsl/builtins/130/max @@ -27,40 +27,19 @@ (parameters (declare (in) ivec2 arg0) (declare (in) int arg1)) - ((declare () ivec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression ivec2 max (var_ref arg0) (var_ref arg1))))) (signature ivec3 (parameters (declare (in) ivec3 arg0) (declare (in) int arg1)) - ((declare () ivec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression int max (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression ivec3 max (var_ref arg0) (var_ref arg1))))) (signature ivec4 (parameters (declare (in) ivec4 arg0) (declare (in) int arg1)) - ((declare () ivec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression int max (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression int max (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression ivec4 max (var_ref arg0) (var_ref arg1))))) (signature uint (parameters @@ -90,38 +69,17 @@ (parameters (declare (in) uvec2 arg0) (declare (in) uint arg1)) - ((declare () uvec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression uvec2 max (var_ref arg0) (var_ref arg1))))) (signature uvec3 (parameters (declare (in) uvec3 arg0) (declare (in) uint arg1)) - ((declare () uvec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression uint max (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression uvec3 max (var_ref arg0) (var_ref arg1))))) (signature uvec4 (parameters (declare (in) uvec4 arg0) (declare (in) uint arg1)) - ((declare () uvec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint max (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint max (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression uint max (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression uint max (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression uvec4 max (var_ref arg0) (var_ref arg1))))) )) diff --git a/src/glsl/builtins/130/min b/src/glsl/builtins/130/min index d98ec1e79da..576546f6f20 100644 --- a/src/glsl/builtins/130/min +++ b/src/glsl/builtins/130/min @@ -27,40 +27,19 @@ (parameters (declare (in) ivec2 arg0) (declare (in) int arg1)) - ((declare () ivec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression ivec2 min (var_ref arg0) (var_ref arg1))))) (signature ivec3 (parameters (declare (in) ivec3 arg0) (declare (in) int arg1)) - ((declare () ivec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression int min (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression ivec3 min (var_ref arg0) (var_ref arg1))))) (signature ivec4 (parameters (declare (in) ivec4 arg0) (declare (in) int arg1)) - ((declare () ivec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression int min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression int min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression int min (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression int min (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression ivec4 min (var_ref arg0) (var_ref arg1))))) (signature uint (parameters @@ -90,38 +69,17 @@ (parameters (declare (in) uvec2 arg0) (declare (in) uint arg1)) - ((declare () uvec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression uvec2 min (var_ref arg0) (var_ref arg1))))) (signature uvec3 (parameters (declare (in) uvec3 arg0) (declare (in) uint arg1)) - ((declare () uvec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression uint min (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression uvec3 min (var_ref arg0) (var_ref arg1))))) (signature uvec4 (parameters (declare (in) uvec4 arg0) (declare (in) uint arg1)) - ((declare () uvec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression uint min (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression uint min (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression uint min (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression uint min (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression uvec4 min (var_ref arg0) (var_ref arg1))))) )) -- cgit v1.2.3 From d5316aeb38865b3315a8a2b46f2c5bfd0d985d65 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 10 Jul 2010 12:54:41 -0700 Subject: glsl2/builtins: Rework clamp to use scalar/vector combinations. --- src/glsl/builtins/110/clamp | 18 +++--------------- src/glsl/builtins/130/clamp | 36 ++++++------------------------------ 2 files changed, 9 insertions(+), 45 deletions(-) diff --git a/src/glsl/builtins/110/clamp b/src/glsl/builtins/110/clamp index 94c8e5ed168..d05cc76dc23 100644 --- a/src/glsl/builtins/110/clamp +++ b/src/glsl/builtins/110/clamp @@ -32,31 +32,19 @@ (declare (in) vec2 arg0) (declare (in) float arg1) (declare (in) float arg2)) - ((declare () vec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) (signature vec3 (parameters (declare (in) vec3 arg0) (declare (in) float arg1) (declare (in) float arg2)) - ((declare () vec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) (signature vec4 (parameters (declare (in) vec4 arg0) (declare (in) float arg1) (declare (in) float arg2)) - ((declare () vec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) (expression vec4 max (expression vec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) )) diff --git a/src/glsl/builtins/130/clamp b/src/glsl/builtins/130/clamp index 3aed22c20df..e1aad5c8d98 100644 --- a/src/glsl/builtins/130/clamp +++ b/src/glsl/builtins/130/clamp @@ -32,33 +32,21 @@ (declare (in) ivec2 arg0) (declare (in) int arg1) (declare (in) int arg2)) - ((declare () ivec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) (signature ivec3 (parameters (declare (in) ivec3 arg0) (declare (in) int arg1) (declare (in) int arg2)) - ((declare () ivec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) (signature ivec4 (parameters (declare (in) ivec4 arg0) (declare (in) int arg1) (declare (in) int arg2)) - ((declare () ivec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) (signature uint (parameters @@ -93,31 +81,19 @@ (declare (in) uvec2 arg0) (declare (in) uint arg1) (declare (in) uint arg2)) - ((declare () uvec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) (signature uvec3 (parameters (declare (in) uvec3 arg0) (declare (in) uint arg1) (declare (in) uint arg2)) - ((declare () uvec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) (signature uvec4 (parameters (declare (in) uvec4 arg0) (declare (in) uint arg1) (declare (in) uint arg2)) - ((declare () uvec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) )) -- cgit v1.2.3 From 53120805a83a834349a96515d8e2dcbd622d06db Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 12 Jul 2010 13:54:36 -0700 Subject: Refresh autogenerated file builtin_function.cpp. --- src/glsl/builtin_function.cpp | 216 ++++++------------------------------------ 1 file changed, 27 insertions(+), 189 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 5b3b49d3107..1cf88ada165 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -438,33 +438,21 @@ static const char *builtins_110_clamp = { " (declare (in) vec2 arg0)\n" " (declare (in) float arg1)\n" " (declare (in) float arg2))\n" - " ((declare () vec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 arg0)\n" " (declare (in) float arg1)\n" " (declare (in) float arg2))\n" - " ((declare () vec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 arg0)\n" " (declare (in) float arg1)\n" " (declare (in) float arg2))\n" - " ((declare () vec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression vec4 max (expression vec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression vec4 max (expression vec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression vec4 max (expression vec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result)) (expression vec4 max (expression vec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "))\n" }; @@ -1218,40 +1206,19 @@ static const char *builtins_110_max = { " (parameters\n" " (declare (in) vec2 arg0)\n" " (declare (in) float arg1))\n" - " ((declare () vec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 arg0)\n" " (declare (in) float arg1))\n" - " ((declare () vec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 arg0)\n" " (declare (in) float arg1))\n" - " ((declare () vec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression float max (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" "))\n" }; @@ -1285,40 +1252,19 @@ static const char *builtins_110_min = { " (parameters\n" " (declare (in) vec2 arg0)\n" " (declare (in) float arg1))\n" - " ((declare () vec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 arg0)\n" " (declare (in) float arg1))\n" - " ((declare () vec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 arg0)\n" " (declare (in) float arg1))\n" - " ((declare () vec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression float min (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" "))\n" }; @@ -2995,33 +2941,21 @@ static const char *builtins_130_clamp = { " (declare (in) ivec2 arg0)\n" " (declare (in) int arg1)\n" " (declare (in) int arg2))\n" - " ((declare () ivec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" " (signature ivec3\n" " (parameters\n" " (declare (in) ivec3 arg0)\n" " (declare (in) int arg1)\n" " (declare (in) int arg2))\n" - " ((declare () ivec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" " (signature ivec4\n" " (parameters\n" " (declare (in) ivec4 arg0)\n" " (declare (in) int arg1)\n" " (declare (in) int arg2))\n" - " ((declare () ivec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result)) (expression ivec4 max (expression ivec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" " (signature uint\n" " (parameters\n" @@ -3056,33 +2990,21 @@ static const char *builtins_130_clamp = { " (declare (in) uvec2 arg0)\n" " (declare (in) uint arg1)\n" " (declare (in) uint arg2))\n" - " ((declare () uvec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" " (signature uvec3\n" " (parameters\n" " (declare (in) uvec3 arg0)\n" " (declare (in) uint arg1)\n" " (declare (in) uint arg2))\n" - " ((declare () uvec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" " (signature uvec4\n" " (parameters\n" " (declare (in) uvec4 arg0)\n" " (declare (in) uint arg1)\n" " (declare (in) uint arg2))\n" - " ((declare () uvec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz x (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz y (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz z (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result)) (expression uvec4 max (expression uvec4 min (swiz w (var_ref arg0)) (var_ref arg2)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "))\n" }; @@ -3319,40 +3241,19 @@ static const char *builtins_130_max = { " (parameters\n" " (declare (in) ivec2 arg0)\n" " (declare (in) int arg1))\n" - " ((declare () ivec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature ivec3\n" " (parameters\n" " (declare (in) ivec3 arg0)\n" " (declare (in) int arg1))\n" - " ((declare () ivec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression int max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature ivec4\n" " (parameters\n" " (declare (in) ivec4 arg0)\n" " (declare (in) int arg1))\n" - " ((declare () ivec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression int max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression int max (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature uint\n" " (parameters\n" @@ -3382,40 +3283,19 @@ static const char *builtins_130_max = { " (parameters\n" " (declare (in) uvec2 arg0)\n" " (declare (in) uint arg1))\n" - " ((declare () uvec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature uvec3\n" " (parameters\n" " (declare (in) uvec3 arg0)\n" " (declare (in) uint arg1))\n" - " ((declare () uvec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression uint max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature uvec4\n" " (parameters\n" " (declare (in) uvec4 arg0)\n" " (declare (in) uint arg1))\n" - " ((declare () uvec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint max (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint max (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression uint max (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression uint max (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n" "))\n" }; @@ -3449,40 +3329,19 @@ static const char *builtins_130_min = { " (parameters\n" " (declare (in) ivec2 arg0)\n" " (declare (in) int arg1))\n" - " ((declare () ivec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature ivec3\n" " (parameters\n" " (declare (in) ivec3 arg0)\n" " (declare (in) int arg1))\n" - " ((declare () ivec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression int min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature ivec4\n" " (parameters\n" " (declare (in) ivec4 arg0)\n" " (declare (in) int arg1))\n" - " ((declare () ivec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression int min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression int min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression int min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression int min (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature uint\n" " (parameters\n" @@ -3512,40 +3371,19 @@ static const char *builtins_130_min = { " (parameters\n" " (declare (in) uvec2 arg0)\n" " (declare (in) uint arg1))\n" - " ((declare () uvec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature uvec3\n" " (parameters\n" " (declare (in) uvec3 arg0)\n" " (declare (in) uint arg1))\n" - " ((declare () uvec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression uint min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature uvec4\n" " (parameters\n" " (declare (in) uvec4 arg0)\n" " (declare (in) uint arg1))\n" - " ((declare () uvec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression uint min (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression uint min (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression uint min (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression uint min (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n" "))\n" }; -- cgit v1.2.3 From 1fdcdb2dca97cdf4b8f4790aa66587ff3e89e526 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 14 Jul 2010 12:14:26 -0700 Subject: exec_list: Add a new replace_with method. --- src/glsl/list.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/glsl/list.h b/src/glsl/list.h index 48502fb4c8c..29997c78ee8 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -165,6 +165,17 @@ struct exec_node { this->prev->next = before; this->prev = before; } + /** + * Replace the current node with the given node. + */ + void replace_with(exec_node *replacement) + { + replacement->prev = this->prev; + replacement->next = this->next; + + this->prev->next = replacement; + this->next->prev = replacement; + } /** * Is this the sentinal at the tail of the list? -- cgit v1.2.3 From 17a307d154489d718ab51a6272d2054868d782f6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 14 Jul 2010 13:22:07 -0700 Subject: ast_function: Actually do type conversion on function arguments. --- src/glsl/ast_function.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 9315a92ecbc..467722c8680 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -31,6 +31,9 @@ inline unsigned min(unsigned a, unsigned b) return (a < b) ? a : b; } +static ir_rvalue * +convert_component(ir_rvalue *src, const glsl_type *desired_type); + static unsigned process_parameters(exec_list *instructions, exec_list *actual_parameters, exec_list *parameters, @@ -93,13 +96,15 @@ process_call(exec_list *instructions, ir_function *f, } } + if (formal->type->is_numeric() || formal->type->is_boolean()) { + ir_rvalue *converted = convert_component(actual, formal->type); + actual->replace_with(converted); + } + actual_iter.next(); formal_iter.next(); } - /* FINISHME: The list of actual parameters needs to be modified to - * FINISHME: include any necessary conversions. - */ return new(ctx) ir_call(sig, actual_parameters); } else { /* FINISHME: Log a better error message here. G++ will show the types -- cgit v1.2.3 From 87a2ee8db6222006480bd0e0ac58b77795c5d951 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 18 Jul 2010 17:47:15 -0700 Subject: glsl2: Fix warning from always-false assert not being known to not return. --- src/glsl/glsl_parser_extras.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index fc3f9e90b6b..cb7b6d36a2d 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -45,6 +45,7 @@ _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) } assert(!"Should not get here."); + return "unknown"; } -- cgit v1.2.3 From 9be7f638130f46a9df2bfbcd4a03b36de9e4f3aa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Jul 2010 15:37:57 -0700 Subject: glsl2: Make cross() be an expression operation. ARB_fp, ARB_vp, Mesa IR, and the 965 vertex shader all have instructions for cross. Shaves 12 Mesa instructions off of a 66-instruction shader I have. --- src/glsl/builtin_function.cpp | 12 +----------- src/glsl/builtins/110/cross | 12 +----------- src/glsl/ir.cpp | 2 ++ src/glsl/ir.h | 1 + src/glsl/ir_constant_expression.cpp | 11 +++++++++++ src/mesa/shader/ir_to_mesa.cpp | 5 +++++ 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 1cf88ada165..b3a283306df 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -486,17 +486,7 @@ static const char *builtins_110_cross = { " (parameters\n" " (declare (in) vec3 arg0)\n" " (declare (in) vec3 arg1))\n" - " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float - (expression float * (swiz y (var_ref arg0)) (swiz z (var_ref arg1)))\n" - " (expression float * (swiz y (var_ref arg1)) (swiz z (var_ref arg0)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float - (expression float * (swiz z (var_ref arg0)) (swiz x (var_ref arg1)))\n" - " (expression float * (swiz z (var_ref arg1)) (swiz x (var_ref arg0)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t))\n" - " (expression float - (expression float * (swiz x (var_ref arg0)) (swiz y (var_ref arg1)))\n" - " (expression float * (swiz x (var_ref arg1)) (swiz y (var_ref arg0)))))\n" - " (return (var_ref t))))\n" + " ((return (expression vec3 cross (var_ref arg0) (var_ref arg1)))))\n" "))\n" }; diff --git a/src/glsl/builtins/110/cross b/src/glsl/builtins/110/cross index deb2f952bfc..24717a2183d 100644 --- a/src/glsl/builtins/110/cross +++ b/src/glsl/builtins/110/cross @@ -3,15 +3,5 @@ (parameters (declare (in) vec3 arg0) (declare (in) vec3 arg1)) - ((declare () vec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float - (expression float * (swiz y (var_ref arg0)) (swiz z (var_ref arg1))) - (expression float * (swiz y (var_ref arg1)) (swiz z (var_ref arg0))))) - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float - (expression float * (swiz z (var_ref arg0)) (swiz x (var_ref arg1))) - (expression float * (swiz z (var_ref arg1)) (swiz x (var_ref arg0))))) - (assign (constant bool (1)) (swiz z (var_ref t)) - (expression float - (expression float * (swiz x (var_ref arg0)) (swiz y (var_ref arg1))) - (expression float * (swiz x (var_ref arg1)) (swiz y (var_ref arg0))))) - (return (var_ref t)))) + ((return (expression vec3 cross (var_ref arg0) (var_ref arg1))))) )) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 6d899132861..fcf5deced8d 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -104,6 +104,7 @@ ir_expression::get_num_operands(ir_expression_operation op) 2, /* ir_binop_logic_or */ 2, /* ir_binop_dot */ + 2, /* ir_binop_cross */ 2, /* ir_binop_min */ 2, /* ir_binop_max */ @@ -163,6 +164,7 @@ static const char *const operator_strs[] = { "^^", "||", "dot", + "cross", "min", "max", "pow", diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 790173ed6be..9d7af2dcabc 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -609,6 +609,7 @@ enum ir_expression_operation { ir_binop_logic_or, ir_binop_dot, + ir_binop_cross, ir_binop_min, ir_binop_max, diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index c0fe47067bd..ca834978f47 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -459,8 +459,19 @@ ir_constant_visitor::visit(ir_expression *ir) assert(0); } } + break; + case ir_binop_cross: + assert(op[0]->type == glsl_type::vec3_type); + assert(op[1]->type == glsl_type::vec3_type); + data.f[0] = (op[0]->value.f[1] * op[1]->value.f[2] - + op[1]->value.f[1] * op[0]->value.f[2]); + data.f[1] = (op[0]->value.f[2] * op[1]->value.f[0] - + op[1]->value.f[2] * op[0]->value.f[0]); + data.f[2] = (op[0]->value.f[0] * op[1]->value.f[1] - + op[1]->value.f[0] * op[0]->value.f[1]); break; + case ir_binop_add: assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); for (unsigned c = 0, c0 = 0, c1 = 0; diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 6ecc6d317c7..f99a1fc4508 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -781,6 +781,11 @@ ir_to_mesa_visitor::visit(ir_expression *ir) op[0], op[1]); } break; + + case ir_binop_cross: + ir_to_mesa_emit_op2(ir, OPCODE_XPD, result_dst, op[0], op[1]); + break; + case ir_unop_sqrt: ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]); ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, result_src); -- cgit v1.2.3 From 1f47245bdda2c85bf0f0174e6c24a50486b413aa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 18 Jul 2010 17:45:16 -0700 Subject: glsl2: Remove the const disease from function signature's callee. --- src/glsl/ast_function.cpp | 3 +-- src/glsl/ir.cpp | 2 +- src/glsl/ir.h | 8 ++++---- src/glsl/ir_clone.cpp | 2 +- src/glsl/ir_reader.cpp | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 467722c8680..aaf1e57ae28 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -64,8 +64,7 @@ process_call(exec_list *instructions, ir_function *f, { void *ctx = state; - const ir_function_signature *sig = - f->matching_signature(actual_parameters); + ir_function_signature *sig = f->matching_signature(actual_parameters); /* The instructions param will be used when the FINISHMEs below are done */ (void) instructions; diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index fcf5deced8d..70905ddb80f 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -839,7 +839,7 @@ ir_call::get_error_instruction(void *ctx) } void -ir_call::set_callee(const ir_function_signature *sig) +ir_call::set_callee(ir_function_signature *sig) { assert((this->type == NULL) || (this->type == sig->return_type)); diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 9d7af2dcabc..042da94d853 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -661,7 +661,7 @@ public: */ class ir_call : public ir_rvalue { public: - ir_call(const ir_function_signature *callee, exec_list *actual_parameters) + ir_call(ir_function_signature *callee, exec_list *actual_parameters) : callee(callee) { assert(callee->return_type != NULL); @@ -706,7 +706,7 @@ public: return callee->function_name(); } - const ir_function_signature *get_callee() + ir_function_signature *get_callee() { return callee; } @@ -714,7 +714,7 @@ public: /** * Set the function call target */ - void set_callee(const ir_function_signature *sig); + void set_callee(ir_function_signature *sig); /** * Generates an inline version of the function before @ir, @@ -729,7 +729,7 @@ private: /* empty */ } - const ir_function_signature *callee; + ir_function_signature *callee; /* List of ir_rvalue of paramaters passed in this call. */ exec_list actual_parameters; diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index c7b786f0c48..91d6977354d 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -356,7 +356,7 @@ public: /* Try to find the function signature referenced by the ir_call in the * table. If it is found, replace it with the value from the table. */ - const ir_function_signature *const sig = + ir_function_signature *sig = (ir_function_signature *) hash_table_find(this->ht, ir->get_callee()); if (sig != NULL) ir->set_callee(sig); diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index c83f92ef575..a1e5a7ad74b 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -632,7 +632,7 @@ read_call(_mesa_glsl_parse_state *st, s_list *list) return NULL; } - const ir_function_signature *callee = f->matching_signature(¶meters); + ir_function_signature *callee = f->matching_signature(¶meters); if (callee == NULL) { ir_read_error(st, list, "couldn't find matching signature for function " "%s", name->value()); -- cgit v1.2.3 From 7b130149427019ac9ae6d39b6871c14fb6ba2dad Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Jul 2010 12:22:05 -0700 Subject: ir_to_mesa: Add support for function calls. Unlike the previous compiler, in this case we emit only one copy of the function regardless of how many times it's called. --- src/mesa/shader/ir_to_mesa.cpp | 233 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 227 insertions(+), 6 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index f99a1fc4508..6d1837f59ea 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -87,6 +87,8 @@ public: int sampler; /**< sampler index */ int tex_target; /**< One of TEXTURE_*_INDEX */ GLboolean tex_shadow; + + class function_entry *function; /* Set on OPCODE_CAL or OPCODE_BGNSUB */ }; class temp_entry : public exec_node { @@ -102,10 +104,45 @@ public: ir_variable *var; /* variable that maps to this, if any */ }; +class function_entry : public exec_node { +public: + ir_function_signature *sig; + + /** + * identifier of this function signature used by the program. + * + * At the point that Mesa instructions for function calls are + * generated, we don't know the address of the first instruction of + * the function body. So we make the BranchTarget that is called a + * small integer and rewrite them during set_branchtargets(). + */ + int sig_id; + + /** + * Pointer to first instruction of the function body. + * + * Set during function body emits after main() is processed. + */ + ir_to_mesa_instruction *bgn_inst; + + /** + * Index of the first instruction of the function body in actual + * Mesa IR. + * + * Set after convertion from ir_to_mesa_instruction to prog_instruction. + */ + int inst; + + /** Storage for the return value. */ + ir_to_mesa_src_reg return_reg; +}; + class ir_to_mesa_visitor : public ir_visitor { public: ir_to_mesa_visitor(); + function_entry *current_function; + GLcontext *ctx; struct gl_program *prog; @@ -113,6 +150,8 @@ public: temp_entry *find_variable_storage(ir_variable *var); + function_entry *get_function_signature(ir_function_signature *sig); + ir_to_mesa_src_reg get_temp(const glsl_type *type); void reladdr_to_temp(ir_instruction *ir, ir_to_mesa_src_reg *reg, int *num_reladdr); @@ -151,6 +190,10 @@ public: /** List of temp_entry */ exec_list variable_storage; + /** List of function_entry */ + exec_list function_signatures; + int next_signature_id; + /** List of ir_to_mesa_instruction */ exec_list instructions; @@ -261,6 +304,8 @@ ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir, inst->src_reg[2] = src2; inst->ir = ir; + inst->function = NULL; + this->instructions.push_tail(inst); return inst; @@ -1396,12 +1441,128 @@ ir_to_mesa_visitor::visit(ir_constant *ir) this->result = src_reg; } +function_entry * +ir_to_mesa_visitor::get_function_signature(ir_function_signature *sig) +{ + function_entry *entry; + + foreach_iter(exec_list_iterator, iter, this->function_signatures) { + entry = (function_entry *)iter.get(); + + if (entry->sig == sig) + return entry; + } + + entry = talloc(mem_ctx, function_entry); + entry->sig = sig; + entry->sig_id = this->next_signature_id++; + entry->bgn_inst = NULL; + + /* Allocate storage for all the parameters. */ + foreach_iter(exec_list_iterator, iter, sig->parameters) { + ir_variable *param = (ir_variable *)iter.get(); + temp_entry *storage; + + storage = find_variable_storage(param); + assert(!storage); + + storage = new(mem_ctx) temp_entry(param, PROGRAM_TEMPORARY, + this->next_temp); + this->variable_storage.push_tail(storage); + + this->next_temp += type_size(param->type); + break; + } + + if (sig->return_type) { + entry->return_reg = get_temp(sig->return_type); + } else { + entry->return_reg = ir_to_mesa_undef; + } + + this->function_signatures.push_tail(entry); + return entry; +} void ir_to_mesa_visitor::visit(ir_call *ir) { - printf("Can't support call to %s\n", ir->callee_name()); - exit(1); + ir_to_mesa_instruction *call_inst; + ir_function_signature *sig = ir->get_callee(); + function_entry *entry = get_function_signature(sig); + int i; + + /* Process in parameters. */ + exec_list_iterator sig_iter = sig->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param_rval = (ir_rvalue *)iter.get(); + ir_variable *param = (ir_variable *)sig_iter.get(); + + if (param->mode == ir_var_in || + param->mode == ir_var_inout) { + temp_entry *storage = find_variable_storage(param); + assert(storage); + + param_rval->accept(this); + ir_to_mesa_src_reg r = this->result; + + ir_to_mesa_dst_reg l; + l.file = storage->file; + l.index = storage->index; + l.reladdr = NULL; + l.writemask = WRITEMASK_XYZW; + l.cond_mask = COND_TR; + + for (i = 0; i < type_size(param->type); i++) { + ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); + l.index++; + r.index++; + } + } + + sig_iter.next(); + } + assert(!sig_iter.has_next()); + + /* Emit call instruction */ + call_inst = ir_to_mesa_emit_op1(ir, OPCODE_CAL, + ir_to_mesa_undef_dst, ir_to_mesa_undef); + call_inst->function = entry; + + /* Process out parameters. */ + sig_iter = sig->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param_rval = (ir_rvalue *)iter.get(); + ir_variable *param = (ir_variable *)sig_iter.get(); + + if (param->mode == ir_var_out || + param->mode == ir_var_inout) { + temp_entry *storage = find_variable_storage(param); + assert(storage); + + ir_to_mesa_src_reg r; + r.file = storage->file; + r.index = storage->index; + r.reladdr = NULL; + r.swizzle = SWIZZLE_NOOP; + r.negate = 0; + + param_rval->accept(this); + ir_to_mesa_dst_reg l = ir_to_mesa_dst_reg_from_src(this->result); + + for (i = 0; i < type_size(param->type); i++) { + ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); + l.index++; + r.index++; + } + } + + sig_iter.next(); + } + assert(!sig_iter.has_next()); + + /* Process return value. */ + this->result = entry->return_reg; } @@ -1536,9 +1697,25 @@ ir_to_mesa_visitor::visit(ir_texture *ir) void ir_to_mesa_visitor::visit(ir_return *ir) { - assert(0); + assert(current_function); + + if (ir->get_value()) { + ir_to_mesa_dst_reg l; + int i; + + ir->get_value()->accept(this); + ir_to_mesa_src_reg r = this->result; - ir->get_value()->accept(this); + l = ir_to_mesa_dst_reg_from_src(current_function->return_reg); + + for (i = 0; i < type_size(current_function->sig->return_type); i++) { + ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); + l.index++; + r.index++; + } + } + + ir_to_mesa_emit_op0(ir, OPCODE_RET); } void @@ -1600,8 +1777,10 @@ ir_to_mesa_visitor::ir_to_mesa_visitor() { result.file = PROGRAM_UNDEFINED; next_temp = 1; + next_signature_id = 1; sampler_map = NULL; sampler_map_size = 0; + current_function = NULL; } static struct prog_src_register @@ -1621,7 +1800,8 @@ mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) } static void -set_branchtargets(struct prog_instruction *mesa_instructions, +set_branchtargets(ir_to_mesa_visitor *v, + struct prog_instruction *mesa_instructions, int num_instructions) { int if_count = 0, loop_count = 0; @@ -1684,6 +1864,17 @@ set_branchtargets(struct prog_instruction *mesa_instructions, /* The loop ends point at each other. */ mesa_instructions[i].BranchTarget = loop_stack[loop_stack_pos]; mesa_instructions[loop_stack[loop_stack_pos]].BranchTarget = i; + break; + case OPCODE_CAL: + foreach_iter(exec_list_iterator, iter, v->function_signatures) { + function_entry *entry = (function_entry *)iter.get(); + + if (entry->sig_id == mesa_instructions[i].BranchTarget) { + mesa_instructions[i].BranchTarget = entry->inst; + break; + } + } + break; default: break; } @@ -1842,6 +2033,7 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) int i; struct gl_program *prog; GLenum target; + GLboolean progress; switch (shader->Type) { case GL_VERTEX_SHADER: target = GL_VERTEX_PROGRAM_ARB; break; @@ -1859,9 +2051,33 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) v.prog = prog; v.mem_ctx = talloc_new(NULL); + + /* Emit Mesa IR for main(). */ visit_exec_list(shader->ir, &v); v.ir_to_mesa_emit_op0(NULL, OPCODE_END); + /* Now emit bodies for any functions that were used. */ + do { + progress = GL_FALSE; + + foreach_iter(exec_list_iterator, iter, v.function_signatures) { + function_entry *entry = (function_entry *)iter.get(); + + if (!entry->bgn_inst) { + v.current_function = entry; + + entry->bgn_inst = v.ir_to_mesa_emit_op0(NULL, OPCODE_BGNSUB); + entry->bgn_inst->function = entry; + + visit_exec_list(&entry->sig->body, &v); + + entry->bgn_inst = v.ir_to_mesa_emit_op0(NULL, OPCODE_RET); + entry->bgn_inst = v.ir_to_mesa_emit_op0(NULL, OPCODE_ENDSUB); + progress = GL_TRUE; + } + } + } while (progress); + prog->NumTemporaries = v.next_temp; int num_instructions = 0; @@ -1895,11 +2111,16 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) mesa_inst->TexShadow = inst->tex_shadow; mesa_instruction_annotation[i] = inst->ir; + if (mesa_inst->Opcode == OPCODE_BGNSUB) + inst->function->inst = i; + else if (mesa_inst->Opcode == OPCODE_CAL) + mesa_inst->BranchTarget = inst->function->sig_id; /* rewritten later */ + mesa_inst++; i++; } - set_branchtargets(mesa_instructions, num_instructions); + set_branchtargets(&v, mesa_instructions, num_instructions); if (0) { print_program(mesa_instructions, mesa_instruction_annotation, num_instructions); -- cgit v1.2.3 From b29d31cd67a423995b5673fdeedea82dfa12ec3c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 18 Jul 2010 17:57:19 -0700 Subject: ir_to_mesa: Rename struct temp_entry, which is used for all variables now. --- src/mesa/shader/ir_to_mesa.cpp | 71 +++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 6d1837f59ea..c75a13d06ef 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -91,9 +91,9 @@ public: class function_entry *function; /* Set on OPCODE_CAL or OPCODE_BGNSUB */ }; -class temp_entry : public exec_node { +class variable_storage : public exec_node { public: - temp_entry(ir_variable *var, int file, int index) + variable_storage(ir_variable *var, int file, int index) : file(file), index(index), var(var) { /* empty */ @@ -148,7 +148,7 @@ public: int next_temp; - temp_entry *find_variable_storage(ir_variable *var); + variable_storage *find_variable_storage(ir_variable *var); function_entry *get_function_signature(ir_function_signature *sig); @@ -187,8 +187,8 @@ public: struct ir_to_mesa_src_reg result; - /** List of temp_entry */ - exec_list variable_storage; + /** List of variable_storage */ + exec_list variables; /** List of function_entry */ exec_list function_signatures; @@ -535,14 +535,14 @@ ir_to_mesa_visitor::get_temp(const glsl_type *type) return src_reg; } -temp_entry * +variable_storage * ir_to_mesa_visitor::find_variable_storage(ir_variable *var) { - temp_entry *entry; + variable_storage *entry; - foreach_iter(exec_list_iterator, iter, this->variable_storage) { - entry = (temp_entry *)iter.get(); + foreach_iter(exec_list_iterator, iter, this->variables) { + entry = (variable_storage *)iter.get(); if (entry->var == var) return entry; @@ -968,7 +968,7 @@ add_matrix_ref(struct gl_program *prog, int *tokens) return base_pos; } -static temp_entry * +static variable_storage * get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var, ir_rvalue *array_index) { @@ -1006,7 +1006,7 @@ get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var, }; unsigned int i; - temp_entry *entry; + variable_storage *entry; /* C++ gets angry when we try to use an int as a gl_state_index, so we use * ints for gl_state_index. Make sure they're compatible. @@ -1041,9 +1041,9 @@ get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var, } tokens[4] = matrices[i].modifier; - entry = new(mem_ctx) temp_entry(var, - PROGRAM_STATE_VAR, - base_pos); + entry = new(mem_ctx) variable_storage(var, + PROGRAM_STATE_VAR, + base_pos); return entry; } @@ -1056,7 +1056,7 @@ void ir_to_mesa_visitor::visit(ir_dereference_variable *ir) { ir_to_mesa_src_reg src_reg; - temp_entry *entry = find_variable_storage(ir->var); + variable_storage *entry = find_variable_storage(ir->var); unsigned int loc; if (!entry) { @@ -1078,8 +1078,9 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) ir->var->type->gl_type); map_sampler(ir->var->location, sampler); - entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_SAMPLER, sampler); - this->variable_storage.push_tail(entry); + entry = new(mem_ctx) variable_storage(ir->var, PROGRAM_SAMPLER, + sampler); + this->variables.push_tail(entry); break; } @@ -1096,8 +1097,8 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) */ this->prog->Parameters->Parameters[loc].Used = GL_TRUE; - entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_UNIFORM, loc); - this->variable_storage.push_tail(entry); + entry = new(mem_ctx) variable_storage(ir->var, PROGRAM_UNIFORM, loc); + this->variables.push_tail(entry); break; case ir_var_in: case ir_var_out: @@ -1112,9 +1113,9 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) assert(ir->var->location != -1); if (ir->var->mode == ir_var_in || ir->var->mode == ir_var_inout) { - entry = new(mem_ctx) temp_entry(ir->var, - PROGRAM_INPUT, - ir->var->location); + entry = new(mem_ctx) variable_storage(ir->var, + PROGRAM_INPUT, + ir->var->location); if (this->prog->Target == GL_VERTEX_PROGRAM_ARB && ir->var->location >= VERT_ATTRIB_GENERIC0) { @@ -1125,16 +1126,16 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) ir->var->location - VERT_ATTRIB_GENERIC0); } } else { - entry = new(mem_ctx) temp_entry(ir->var, - PROGRAM_OUTPUT, - ir->var->location); + entry = new(mem_ctx) variable_storage(ir->var, + PROGRAM_OUTPUT, + ir->var->location); } break; case ir_var_auto: - entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_TEMPORARY, - this->next_temp); - this->variable_storage.push_tail(entry); + entry = new(mem_ctx) variable_storage(ir->var, PROGRAM_TEMPORARY, + this->next_temp); + this->variables.push_tail(entry); next_temp += type_size(ir->var->type); break; @@ -1170,7 +1171,7 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) "gl_TextureMatrix", strlen("gl_TextureMatrix")) == 0) { ir_to_mesa_src_reg src_reg; - struct temp_entry *entry; + struct variable_storage *entry; entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, deref_var->var, ir->array_index); @@ -1461,14 +1462,14 @@ ir_to_mesa_visitor::get_function_signature(ir_function_signature *sig) /* Allocate storage for all the parameters. */ foreach_iter(exec_list_iterator, iter, sig->parameters) { ir_variable *param = (ir_variable *)iter.get(); - temp_entry *storage; + variable_storage *storage; storage = find_variable_storage(param); assert(!storage); - storage = new(mem_ctx) temp_entry(param, PROGRAM_TEMPORARY, - this->next_temp); - this->variable_storage.push_tail(storage); + storage = new(mem_ctx) variable_storage(param, PROGRAM_TEMPORARY, + this->next_temp); + this->variables.push_tail(storage); this->next_temp += type_size(param->type); break; @@ -1500,7 +1501,7 @@ ir_to_mesa_visitor::visit(ir_call *ir) if (param->mode == ir_var_in || param->mode == ir_var_inout) { - temp_entry *storage = find_variable_storage(param); + variable_storage *storage = find_variable_storage(param); assert(storage); param_rval->accept(this); @@ -1537,7 +1538,7 @@ ir_to_mesa_visitor::visit(ir_call *ir) if (param->mode == ir_var_out || param->mode == ir_var_inout) { - temp_entry *storage = find_variable_storage(param); + variable_storage *storage = find_variable_storage(param); assert(storage); ir_to_mesa_src_reg r; -- cgit v1.2.3 From 4802fd905ae7c1a1122ec71c0556c2b19214a7fd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Jul 2010 09:44:30 -0700 Subject: ir_to_mesa: Don't do lowering passes on an errored-out shader. --- src/mesa/shader/ir_to_mesa.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index c75a13d06ef..a7799cc01db 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2185,13 +2185,13 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) if (!state->error && !state->translation_unit.is_empty()) _mesa_ast_to_hir(shader->ir, state); - /* Lowering */ - do_mat_op_to_vec(shader->ir); - do_mod_to_fract(shader->ir); - do_div_to_mul_rcp(shader->ir); - - /* Optimization passes */ if (!state->error && !shader->ir->is_empty()) { + /* Lowering */ + do_mat_op_to_vec(shader->ir); + do_mod_to_fract(shader->ir); + do_div_to_mul_rcp(shader->ir); + + /* Optimization passes */ bool progress; do { progress = false; -- cgit v1.2.3 From ee7b2b3f44d09c2311887d3524e197b9738580a9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Jul 2010 08:55:54 -0700 Subject: ir_to_mesa: Do validation on the IR tree. --- src/mesa/shader/ir_to_mesa.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index a7799cc01db..84cfff40106 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2186,6 +2186,8 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) _mesa_ast_to_hir(shader->ir, state); if (!state->error && !shader->ir->is_empty()) { + validate_ir_tree(shader->ir); + /* Lowering */ do_mat_op_to_vec(shader->ir); do_mod_to_fract(shader->ir); @@ -2213,6 +2215,8 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) progress = do_swizzle_swizzle(shader->ir) || progress; } while (progress); + + validate_ir_tree(shader->ir); } shader->symbols = state->symbols; -- cgit v1.2.3 From d16044ad4d6176fec6164f96450a25f76b7677f1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Jul 2010 09:05:42 -0700 Subject: glsl2: Give IR nodes a type field. This is a big deal for debugging if nothing else ("what class is this ir_instruction, really?"), but is also nice for avoiding building a whole visitor or an if (node->as_whatever() || node->as_other_thing()) chain. --- src/glsl/ir.cpp | 23 +++++++++++++++++++++-- src/glsl/ir.h | 42 ++++++++++++++++++++++++++++++++++-------- src/glsl/ir_validate.cpp | 15 +++++++++++++++ 3 files changed, 70 insertions(+), 10 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 70905ddb80f..1648848ecb6 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -29,6 +29,7 @@ ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition) { + this->ir_type = ir_type_assignment; this->lhs = lhs; this->rhs = rhs; this->condition = condition; @@ -38,6 +39,7 @@ ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_expression::ir_expression(int op, const struct glsl_type *type, ir_rvalue *op0, ir_rvalue *op1) { + this->ir_type = ir_type_expression; this->type = type; this->operation = ir_expression_operation(op); this->operands[0] = op0; @@ -190,7 +192,7 @@ ir_expression::get_operator(const char *str) ir_constant::ir_constant() { - /* empty */ + this->ir_type = ir_type_constant; } ir_constant::ir_constant(const struct glsl_type *type, @@ -199,36 +201,42 @@ ir_constant::ir_constant(const struct glsl_type *type, assert((type->base_type >= GLSL_TYPE_UINT) && (type->base_type <= GLSL_TYPE_BOOL)); + this->ir_type = ir_type_constant; this->type = type; memcpy(& this->value, data, sizeof(this->value)); } ir_constant::ir_constant(float f) { + this->ir_type = ir_type_constant; this->type = glsl_type::float_type; this->value.f[0] = f; } ir_constant::ir_constant(unsigned int u) { + this->ir_type = ir_type_constant; this->type = glsl_type::uint_type; this->value.u[0] = u; } ir_constant::ir_constant(int i) { + this->ir_type = ir_type_constant; this->type = glsl_type::int_type; this->value.i[0] = i; } ir_constant::ir_constant(bool b) { + this->ir_type = ir_type_constant; this->type = glsl_type::bool_type; this->value.b[0] = b; } ir_constant::ir_constant(const ir_constant *c, unsigned i) { + this->ir_type = ir_type_constant; this->type = c->type->get_base_type(); switch (this->type->base_type) { @@ -242,6 +250,7 @@ ir_constant::ir_constant(const ir_constant *c, unsigned i) ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) { + this->ir_type = ir_type_constant; this->type = type; /* FINISHME: Support array types. */ @@ -454,6 +463,7 @@ ir_constant::has_value(const ir_constant *c) const ir_dereference_variable::ir_dereference_variable(ir_variable *var) { + this->ir_type = ir_type_dereference_variable; this->var = var; this->type = (var != NULL) ? var->type : glsl_type::error_type; } @@ -462,6 +472,7 @@ ir_dereference_variable::ir_dereference_variable(ir_variable *var) ir_dereference_array::ir_dereference_array(ir_rvalue *value, ir_rvalue *array_index) { + this->ir_type = ir_type_dereference_array; this->array_index = array_index; this->set_array(value); } @@ -472,6 +483,7 @@ ir_dereference_array::ir_dereference_array(ir_variable *var, { void *ctx = talloc_parent(var); + this->ir_type = ir_type_dereference_array; this->array_index = array_index; this->set_array(new(ctx) ir_dereference_variable(var)); } @@ -500,6 +512,7 @@ ir_dereference_array::set_array(ir_rvalue *value) ir_dereference_record::ir_dereference_record(ir_rvalue *value, const char *field) { + this->ir_type = ir_type_dereference_record; this->record = value; this->field = field; this->type = (this->record != NULL) @@ -512,6 +525,7 @@ ir_dereference_record::ir_dereference_record(ir_variable *var, { void *ctx = talloc_parent(var); + this->ir_type = ir_type_dereference_record; this->record = new(ctx) ir_dereference_variable(var); this->field = field; this->type = (this->record != NULL) @@ -624,6 +638,7 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, : val(val) { const unsigned components[4] = { x, y, z, w }; + this->ir_type = ir_type_swizzle; this->init_mask(components, count); } @@ -631,11 +646,13 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, const unsigned *comp, unsigned count) : val(val) { + this->ir_type = ir_type_swizzle; this->init_mask(comp, count); } ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) { + this->ir_type = ir_type_swizzle; this->val = val; this->mask = mask; this->type = glsl_type::get_instance(val->type->base_type, @@ -736,6 +753,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name) shader_in(false), shader_out(false), mode(ir_var_auto), interpolation(ir_var_smooth), array_lvalue(false) { + this->ir_type = ir_type_variable; this->type = type; this->name = talloc_strdup(this, name); this->location = -1; @@ -775,7 +793,7 @@ ir_variable::component_slots() const ir_function_signature::ir_function_signature(const glsl_type *return_type) : return_type(return_type), is_defined(false), _function(NULL) { - /* empty */ + this->ir_type = ir_type_function_signature; } @@ -825,6 +843,7 @@ ir_function_signature::replace_parameters(exec_list *new_params) ir_function::ir_function(const char *name) { + this->ir_type = ir_type_function; this->name = talloc_strdup(this, name); } diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 042da94d853..389fe243262 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -41,11 +41,34 @@ extern "C" { #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #endif +enum ir_node_type { + ir_type_unset, + ir_type_variable, + ir_type_assignment, + ir_type_call, + ir_type_constant, + ir_type_dereference_array, + ir_type_dereference_record, + ir_type_dereference_variable, + ir_type_discard, + ir_type_expression, + ir_type_function, + ir_type_function_signature, + ir_type_if, + ir_type_loop, + ir_type_loop_jump, + ir_type_return, + ir_type_swizzle, + ir_type_texture, + ir_type_max, /**< maximum ir_type enum number, for validation */ +}; + /** * Base class of all IR instructions */ class ir_instruction : public exec_node { public: + enum ir_node_type ir_type; const struct glsl_type *type; class ir_constant *constant_expression_value(); @@ -84,7 +107,7 @@ public: protected: ir_instruction() { - /* empty */ + ir_type = ir_type_unset; } }; @@ -410,7 +433,7 @@ public: ir_if(ir_rvalue *condition) : condition(condition) { - /* empty */ + ir_type = ir_type_if; } virtual ir_if *clone(struct hash_table *ht) const; @@ -442,7 +465,7 @@ class ir_loop : public ir_instruction { public: ir_loop() : from(NULL), to(NULL), increment(NULL), counter(NULL) { - /* empty */ + ir_type = ir_type_loop; } virtual ir_loop *clone(struct hash_table *ht) const; @@ -664,6 +687,7 @@ public: ir_call(ir_function_signature *callee, exec_list *actual_parameters) : callee(callee) { + ir_type = ir_type_call; assert(callee->return_type != NULL); type = callee->return_type; actual_parameters->move_nodes_to(& this->actual_parameters); @@ -726,7 +750,7 @@ private: ir_call() : callee(NULL) { - /* empty */ + this->ir_type = ir_type_call; } ir_function_signature *callee; @@ -746,7 +770,7 @@ class ir_jump : public ir_instruction { protected: ir_jump() { - /* empty */ + ir_type = ir_type_unset; } }; @@ -755,13 +779,13 @@ public: ir_return() : value(NULL) { - /* empty */ + this->ir_type = ir_type_return; } ir_return(ir_rvalue *value) : value(value) { - /* empty */ + this->ir_type = ir_type_return; } virtual ir_return *clone(struct hash_table *) const; @@ -804,6 +828,7 @@ public: ir_loop_jump(jump_mode mode) { + this->ir_type = ir_type_loop_jump; this->mode = mode; this->loop = loop; } @@ -841,6 +866,7 @@ class ir_discard : public ir_jump { public: ir_discard() { + this->ir_type = ir_type_discard; this->condition = NULL; } @@ -898,7 +924,7 @@ public: ir_texture(enum ir_texture_opcode op) : op(op), projector(NULL), shadow_comparitor(NULL) { - /* empty */ + this->ir_type = ir_type_texture; } virtual ir_texture *clone(struct hash_table *) const; diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 4284f6b1201..8a567954a1f 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -172,10 +172,25 @@ ir_validate::validate_ir(ir_instruction *ir, void *data) hash_table_insert(ht, ir, ir); } +void +check_node_type(ir_instruction *ir, void *data) +{ + if (ir->ir_type <= ir_type_unset || ir->ir_type >= ir_type_max) { + printf("Instruction node with unset type\n"); + ir->print(); printf("\n"); + } +} + void validate_ir_tree(exec_list *instructions) { ir_validate v; v.run(instructions); + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + visit_tree(ir, check_node_type, NULL); + } } -- cgit v1.2.3 From 29ce44ad2b8d37ea54923f1d1856b44ef26903e5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Jul 2010 09:36:43 -0700 Subject: glsl2: Add a pass for converting if statements to conditional assignment. This will be used on 915 and similar hardware of that generation. --- src/glsl/Makefile | 1 + src/glsl/ir_if_to_cond_assign.cpp | 167 ++++++++++++++++++++++++++++++++++++++ src/glsl/ir_optimization.h | 1 + 3 files changed, 169 insertions(+) create mode 100644 src/glsl/ir_if_to_cond_assign.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index a36ff28a4be..c09735dff61 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -42,6 +42,7 @@ CXX_SOURCES = \ ir_hv_accept.cpp \ ir_if_return.cpp \ ir_if_simplification.cpp \ + ir_if_to_cond_assign.cpp \ ir_mat_op_to_vec.cpp \ ir_mod_to_fract.cpp \ ir_print_visitor.cpp \ diff --git a/src/glsl/ir_if_to_cond_assign.cpp b/src/glsl/ir_if_to_cond_assign.cpp new file mode 100644 index 00000000000..274874bbb76 --- /dev/null +++ b/src/glsl/ir_if_to_cond_assign.cpp @@ -0,0 +1,167 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_if_to_cond_assign.cpp + * + * This attempts to flatten all if statements to conditional + * assignments for GPUs that don't do control flow. + * + * It can't handle other control flow being inside of its block, such + * as calls or loops. Hopefully loop unrolling and inlining will take + * care of those. + */ + +#include "glsl_types.h" +#include "ir.h" + +class ir_if_to_cond_assign_visitor : public ir_hierarchical_visitor { +public: + ir_if_to_cond_assign_visitor() + { + this->progress = false; + } + + ir_visitor_status visit_leave(ir_if *); + + bool progress; +}; + +bool +do_if_to_cond_assign(exec_list *instructions) +{ + ir_if_to_cond_assign_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} + +void +check_control_flow(ir_instruction *ir, void *data) +{ + bool *found_control_flow = (bool *)data; + switch (ir->ir_type) { + case ir_type_call: + case ir_type_discard: + case ir_type_loop: + case ir_type_loop_jump: + case ir_type_return: + *found_control_flow = true; + break; + default: + break; + } +} + +void +move_block_to_cond_assign(void *mem_ctx, + ir_if *if_ir, ir_variable *cond_var, bool then) +{ + exec_list *instructions; + + if (then) { + instructions = &if_ir->then_instructions; + } else { + instructions = &if_ir->else_instructions; + } + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + if (ir->ir_type == ir_type_assignment) { + ir_assignment *assign = (ir_assignment *)ir; + ir_rvalue *cond_expr; + ir_dereference *deref = new(mem_ctx) ir_dereference_variable(cond_var); + + if (then) { + cond_expr = deref; + } else { + cond_expr = new(mem_ctx) ir_expression(ir_unop_logic_not, + glsl_type::bool_type, + deref, + NULL); + } + + if (!assign->condition) { + assign->condition = cond_expr; + } else { + assign->condition = new(mem_ctx) ir_expression(ir_binop_logic_and, + glsl_type::bool_type, + cond_expr, + assign->condition); + } + } + + /* Now, move from the if block to the block surrounding it. */ + ir->remove(); + if_ir->insert_before(ir); + } +} + +ir_visitor_status +ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir) +{ + bool found_control_flow = false; + ir_variable *cond_var; + ir_assignment *assign; + ir_dereference_variable *deref; + + /* Check that both blocks don't contain anything we can't support. */ + foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { + ir_instruction *then_ir = (ir_instruction *)then_iter.get(); + visit_tree(then_ir, check_control_flow, &found_control_flow); + } + foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { + ir_instruction *else_ir = (ir_instruction *)else_iter.get(); + visit_tree(else_ir, check_control_flow, &found_control_flow); + } + if (found_control_flow) + return visit_continue; + + void *mem_ctx = talloc_parent(ir); + + /* Store the condition to a variable so the assignment conditions are + * simpler. + */ + cond_var = new(mem_ctx) ir_variable(glsl_type::bool_type, + "if_to_cond_assign_condition"); + ir->insert_before(cond_var); + + deref = new(mem_ctx) ir_dereference_variable(cond_var); + assign = new(mem_ctx) ir_assignment(deref, + ir->condition, NULL); + ir->insert_before(assign); + + /* Now, move all of the instructions out of the if blocks, putting + * conditions on assignments. + */ + move_block_to_cond_assign(mem_ctx, ir, cond_var, true); + move_block_to_cond_assign(mem_ctx, ir, cond_var, false); + + ir->remove(); + + this->progress = true; + + return visit_continue; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index fae583df756..06cb4d22ca8 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -41,6 +41,7 @@ bool do_div_to_mul_rcp(exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_if_return(exec_list *instructions); bool do_if_simplification(exec_list *instructions); +bool do_if_to_cond_assign(exec_list *instructions); bool do_mat_op_to_vec(exec_list *instructions); bool do_mod_to_fract(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); -- cgit v1.2.3 From 95c08920ea3d040360e5cc51d8a852d21a0329ee Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Jul 2010 10:21:58 -0700 Subject: i915: Ask the compiler to flatten out all the if statements that it can. --- src/mesa/drivers/dri/i915/i915_context.c | 2 ++ src/mesa/main/mtypes.h | 5 +++++ src/mesa/shader/ir_to_mesa.cpp | 13 ++++++++++++- src/mesa/shader/shader_api.c | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index b3fe1c05d66..d8715cf026d 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -174,6 +174,8 @@ i915CreateContext(int api, ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; + ctx->Shader.EmitNoIfs = GL_TRUE; + ctx->Const.MaxDrawBuffers = 1; _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 9a36740c415..be9eaaa875c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2038,6 +2038,11 @@ struct gl_shader_state GLboolean EmitCondCodes; /**< Use condition codes? */ GLboolean EmitComments; /**< Annotated instructions */ GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */ + /** + * Attempts to flatten all ir_if (OPCODE_IF) for GPUs that can't + * support control flow. + */ + GLboolean EmitNoIfs; void *MemPool; GLbitfield Flags; /**< Mask of GLSL_x flags */ struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 84cfff40106..58320c92174 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2026,8 +2026,10 @@ link_uniforms_to_shared_uniform_list(struct gl_uniform_list *uniforms, } struct gl_program * -get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) +get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, + struct gl_shader *shader) { + void *mem_ctx = shader_program; ir_to_mesa_visitor v; struct prog_instruction *mesa_instructions, *mesa_inst; ir_instruction **mesa_instruction_annotation; @@ -2112,6 +2114,13 @@ get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader) mesa_inst->TexShadow = inst->tex_shadow; mesa_instruction_annotation[i] = inst->ir; + if (ctx->Shader.EmitNoIfs && mesa_inst->Opcode == OPCODE_IF) { + shader_program->InfoLog = + talloc_asprintf_append(shader_program->InfoLog, + "Couldn't flatten if statement\n"); + shader_program->LinkStatus = false; + } + if (mesa_inst->Opcode == OPCODE_BGNSUB) inst->function->inst = i; else if (mesa_inst->Opcode == OPCODE_CAL) @@ -2206,6 +2215,8 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; progress = do_if_return(shader->ir) || progress; + if (ctx->Shader.EmitNoIfs) + progress = do_if_to_cond_assign(shader->ir) || progress; progress = do_vec_index_to_swizzle(shader->ir) || progress; /* Do this one after the previous to let the easier pass handle diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index f05ebc9fcb6..cd02d7d8307 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -431,6 +431,7 @@ _mesa_init_shader_state(GLcontext * ctx) ctx->Shader.EmitContReturn = GL_TRUE; ctx->Shader.EmitCondCodes = GL_FALSE; ctx->Shader.EmitComments = GL_FALSE; + ctx->Shader.EmitNoIfs = GL_FALSE; ctx->Shader.Flags = get_shader_flags(); /* Default pragma settings */ -- cgit v1.2.3 From 82d4b9593bd541b20771cddc1365add21dea6ba9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Jul 2010 10:31:03 -0700 Subject: glsl2: Fix the expression type for atan's pi * sign(y). Fixes CorrectFunction.vert. --- src/glsl/builtin_function.cpp | 8 ++++---- src/glsl/builtins/110/atan | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index b3a283306df..75e058c41c8 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -292,7 +292,7 @@ static const char *builtins_110_atan = { " (expression float +\n" " (var_ref r)\n" " (expression float *\n" - " (expression int sign (var_ref y))\n" + " (expression float sign (var_ref y))\n" " (constant float (3.1415926))))))\n" " ()))\n" " ())\n" @@ -318,7 +318,7 @@ static const char *builtins_110_atan = { " (expression vec2 +\n" " (var_ref r)\n" " (expression vec2 *\n" - " (expression int sign (var_ref y))\n" + " (expression float sign (var_ref y))\n" " (constant float (3.1415926))))))\n" " ()))\n" " ())\n" @@ -344,7 +344,7 @@ static const char *builtins_110_atan = { " (expression vec3 +\n" " (var_ref r)\n" " (expression vec3 *\n" - " (expression int sign (var_ref y))\n" + " (expression float sign (var_ref y))\n" " (constant float (3.1415926))))))\n" " ()))\n" " ())\n" @@ -370,7 +370,7 @@ static const char *builtins_110_atan = { " (expression vec4 +\n" " (var_ref r)\n" " (expression vec4 *\n" - " (expression int sign (var_ref y))\n" + " (expression float sign (var_ref y))\n" " (constant float (3.1415926))))))\n" " ()))\n" " ())\n" diff --git a/src/glsl/builtins/110/atan b/src/glsl/builtins/110/atan index e5542350b51..bcf75718e45 100644 --- a/src/glsl/builtins/110/atan +++ b/src/glsl/builtins/110/atan @@ -67,7 +67,7 @@ (expression float + (var_ref r) (expression float * - (expression int sign (var_ref y)) + (expression float sign (var_ref y)) (constant float (3.1415926)))))) ())) ()) @@ -93,7 +93,7 @@ (expression vec2 + (var_ref r) (expression vec2 * - (expression int sign (var_ref y)) + (expression float sign (var_ref y)) (constant float (3.1415926)))))) ())) ()) @@ -119,7 +119,7 @@ (expression vec3 + (var_ref r) (expression vec3 * - (expression int sign (var_ref y)) + (expression float sign (var_ref y)) (constant float (3.1415926)))))) ())) ()) @@ -145,7 +145,7 @@ (expression vec4 + (var_ref r) (expression vec4 * - (expression int sign (var_ref y)) + (expression float sign (var_ref y)) (constant float (3.1415926)))))) ())) ()) -- cgit v1.2.3 From 5304493c40c5f450568fb518cb09940a72c1bc1d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Jul 2010 11:52:54 -0700 Subject: glsl2: Fix lexing of octal values, including "0". When faced with a constructor like 'ivec4(0, 2, 0, 0)', we would manage to get a value of 2 instead of 0 for the first "0". Usually 2 characters past "0" would point at some junk and lex as 0 anyway. Fixes glsl-octal and glsl-unused-varyings. --- src/glsl/glsl_lexer.lpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index 6c1000876e1..b0afc44d5e9 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -231,7 +231,7 @@ void return VOID; return INTCONSTANT; } 0[0-7]* { - yylval->n = strtol(yytext + 2, NULL, 8); + yylval->n = strtol(yytext, NULL, 8); return INTCONSTANT; } -- cgit v1.2.3 From 9303e358cb3062f62c39961ebd4708bf63db03c1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 19 Jul 2010 12:33:54 -0700 Subject: linker: Move global instructions from the linked shader first For the shader containing 'main', use the linked shader (i.e., the clone of the original shader that contained main) as the source for global instructions to move into main. --- src/glsl/linker.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index c71c07d6e97..d46744eeda5 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -687,12 +687,16 @@ link_intrastage_shaders(struct gl_shader_program *prog, /* Move any instructions other than variable declarations or function * declarations into main. */ - exec_node *insertion_point = (exec_node *) &main_sig->body; + exec_node *insertion_point = + move_non_declarations(linked->ir, (exec_node *) &main_sig->body, false, + linked); + for (unsigned i = 0; i < num_shaders; i++) { + if (shader_list[i] == main) + continue; + insertion_point = move_non_declarations(shader_list[i]->ir, - insertion_point, - (shader_list[i] != main), - linked); + insertion_point, true, linked); } /* Resolve initializers for global variables in the linked shader. -- cgit v1.2.3 From 303c99f12fd1234a763147f9e081f2544433fc77 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 19 Jul 2010 12:34:56 -0700 Subject: linker: Use foreach_list_safe in move_non_declarations The node being processed may be removed from the list and put in a different list. Not using the safe version caused list processing to change streams after moving a node. --- src/glsl/linker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index d46744eeda5..72b83ff992d 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -543,7 +543,7 @@ exec_node * move_non_declarations(exec_list *instructions, exec_node *last, bool make_copies, gl_shader *target) { - foreach_list(node, instructions) { + foreach_list_safe(node, instructions) { ir_instruction *inst = (ir_instruction *) node; if (inst->as_variable() || inst->as_function()) -- cgit v1.2.3 From 61a44ccaef63a8ad36ebd934e6944ede5587e4d5 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 19 Jul 2010 14:49:34 -0700 Subject: exec_list: Fix foreach_list_safe. It now works correctly when nodes are removed, as it was originally intended to do; it no longer processes nodes added to the list before the current node, nor those added immediately after the current node. This matches the behavior of Linux's list_for_each_safe. --- src/glsl/ir_hv_accept.cpp | 5 +++-- src/glsl/list.h | 16 +++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp index 46bc5b17fe3..8989605e26f 100644 --- a/src/glsl/ir_hv_accept.cpp +++ b/src/glsl/ir_hv_accept.cpp @@ -32,9 +32,10 @@ /** * Process a list of nodes using a hierarchical vistor * + * \warning * This function will operate correctly if a node being processed is removed - * from the list. If nodes are inserted before the current node, they will be - * processed next. + * from the list. However, if nodes are added to the list after the node being + * processed, some of the added nodes may not be processed. */ ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l) diff --git a/src/glsl/list.h b/src/glsl/list.h index 29997c78ee8..7348e323c1b 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -433,18 +433,12 @@ struct exec_list { }; /** - * This version is safe even if the current node is removed. If you insert - * new nodes before the current node, they will be processed next. - * - * \note - * The extra test for \c __node being \c NULL is required because after the - * iteration \c __prev coupld be the last node in the list. The loop increment - * then causes \c __prev to point to the sentinal and \c __node to be \c NULL. + * This version is safe even if the current node is removed. */ -#define foreach_list_safe(__node, __list) \ - for (exec_node * __prev = (exec_node *) (__list), * __node = (__list)->head \ - ; __node != NULL && (__node)->next != NULL \ - ; __prev = (__prev)->next, __node = (__prev)->next) +#define foreach_list_safe(__node, __list) \ + for (exec_node * __node = (__list)->head, * __next = __node->next \ + ; __next != NULL \ + ; __node = __next, __next = __next->next) #define foreach_list(__node, __list) \ for (exec_node * __node = (__list)->head \ -- cgit v1.2.3 From 3880d07f4bde3f3743bad6e0f5966276c476fb21 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 13 Jul 2010 17:31:12 -0700 Subject: linker: Remove some unnecessary includes --- src/glsl/linker.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 72b83ff992d..155c9d40b32 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -73,9 +73,7 @@ extern "C" { #include "main/mtypes.h" #include "glsl_symbol_table.h" -#include "glsl_parser_extras.h" #include "ir.h" -#include "ir_optimization.h" #include "program.h" #include "hash_table.h" #include "shader_api.h" -- cgit v1.2.3 From a48a2b66e86d6d1c2fbb24bc60df2fdef42b3086 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 13 Jul 2010 17:34:02 -0700 Subject: ir_function_signature: Make actual_parameters public --- src/glsl/ir.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 389fe243262..ff91a8dbce3 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -746,6 +746,9 @@ public: */ ir_rvalue *generate_inline(ir_instruction *ir); + /* List of ir_rvalue of paramaters passed in this call. */ + exec_list actual_parameters; + private: ir_call() : callee(NULL) @@ -754,9 +757,6 @@ private: } ir_function_signature *callee; - - /* List of ir_rvalue of paramaters passed in this call. */ - exec_list actual_parameters; }; -- cgit v1.2.3 From 8fe8a814b0c746f0f655a67f8755f9dee858d230 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 13 Jul 2010 17:36:13 -0700 Subject: linker: First bits of intrastage, intershader function linking This handles the easy case of linking a function in a different compilation unit that doesn't call any functions or reference any global variables. --- src/glsl/Makefile | 1 + src/glsl/link_functions.cpp | 176 ++++++++++++++++++++++++++++++++++++++++++++ src/glsl/linker.cpp | 2 + src/glsl/linker.h | 35 +++++++++ 4 files changed, 214 insertions(+) create mode 100644 src/glsl/link_functions.cpp create mode 100644 src/glsl/linker.h diff --git a/src/glsl/Makefile b/src/glsl/Makefile index c09735dff61..497f6ca1a0c 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -53,6 +53,7 @@ CXX_SOURCES = \ ir_vec_index_to_cond_assign.cpp \ ir_vec_index_to_swizzle.cpp \ linker.cpp \ + link_functions.cpp \ s_expression.cpp LIBS = \ diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp new file mode 100644 index 00000000000..35bd22350d5 --- /dev/null +++ b/src/glsl/link_functions.cpp @@ -0,0 +1,176 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include + +extern "C" { +#include +} + +#include "main/mtypes.h" +#include "glsl_symbol_table.h" +#include "glsl_parser_extras.h" +#include "ir.h" +#include "program.h" +#include "hash_table.h" +#include "linker.h" + +class call_link_visitor : public ir_hierarchical_visitor { +public: + call_link_visitor(gl_shader_program *prog, gl_shader **shader_list, + unsigned num_shaders) + { + this->prog = prog; + this->shader_list = shader_list; + this->num_shaders = num_shaders; + this->success = true; + } + + virtual ir_visitor_status visit_enter(ir_call *ir) + { + /* If the function call references a function signature that does not + * have a definition, try to find the definition in one of the other + * shaders. + */ + ir_function_signature *callee = + const_cast(ir->get_callee()); + assert(callee != NULL); + + if (callee->is_defined) + /* FINISHME: Do children need to be processed, or are all parameters + * FINISHME: with function calls already flattend? + */ + return visit_continue; + + const char *const name = callee->function_name(); + + ir_function_signature *sig = const_cast + (this->find_matching_signature(name, &ir->actual_parameters)); + if (sig == NULL) { + /* FINISHME: Log the full signature of unresolved function. + */ + linker_error_printf(this->prog, "unresolved reference to function " + "`%s'\n", name); + this->success = false; + return visit_stop; + } + + /* Create an in-place clone of the function definition. This multistep + * process introduces some complexity here, but it has some advantages. + * The parameter list and the and function body are cloned separately. + * The clone of the parameter list is used to prime the hashtable used + * to replace variable references in the cloned body. + * + * The big advantage is that the ir_function_signature does not change. + * This means that we don't have to process the rest of the IR tree to + * patch ir_call nodes. In addition, there is no way to remove or replace + * signature stored in a function. One could easily be added, but this + * avoids the need. + */ + struct hash_table *ht = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + exec_list formal_parameters; + foreach_list_const(node, &sig->parameters) { + const ir_instruction *const original = (ir_instruction *) node; + assert(const_cast(original)->as_variable()); + + ir_instruction *copy = original->clone(ht); + formal_parameters.push_tail(copy); + } + + callee->replace_parameters(&formal_parameters); + + assert(callee->body.is_empty()); + foreach_list_const(node, &sig->body) { + const ir_instruction *const original = (ir_instruction *) node; + + ir_instruction *copy = original->clone(ht); + callee->body.push_tail(copy); + } + + callee->is_defined = true; + + /* FINISHME: Patch references inside the function to things outside the + * FINISHME: function (i.e., function calls and global variables). + */ + + hash_table_dtor(ht); + + return visit_continue; + } + + /** Was function linking successful? */ + bool success; + +private: + /** + * Shader program being linked + * + * This is only used for logging error messages. + */ + gl_shader_program *prog; + + /** List of shaders available for linking. */ + gl_shader **shader_list; + + /** Number of shaders available for linking. */ + unsigned num_shaders; + + /** + * Searches all shaders for a particular function definition + */ + const ir_function_signature * + find_matching_signature(const char *name, exec_list *actual_parameters) + { + for (unsigned i = 0; i < this->num_shaders; i++) { + ir_function *const f = + this->shader_list[i]->symbols->get_function(name); + + if (f == NULL) + continue; + + const ir_function_signature *sig = + f->matching_signature(actual_parameters); + + if ((sig == NULL) || !sig->is_defined) + continue; + + return sig; + } + + return NULL; + } +}; + + +bool +link_function_calls(gl_shader_program *prog, gl_shader *main, + gl_shader **shader_list, unsigned num_shaders) +{ + call_link_visitor v(prog, shader_list, num_shaders); + + v.run(main->ir); + return v.success; +} diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 155c9d40b32..f7c178e9677 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -77,6 +77,7 @@ extern "C" { #include "program.h" #include "hash_table.h" #include "shader_api.h" +#include "linker.h" /** * Visitor that determines whether or not a variable is ever written. @@ -699,6 +700,7 @@ link_intrastage_shaders(struct gl_shader_program *prog, /* Resolve initializers for global variables in the linked shader. */ + link_function_calls(prog, linked, shader_list, num_shaders); return linked; } diff --git a/src/glsl/linker.h b/src/glsl/linker.h new file mode 100644 index 00000000000..a8ce16a7ec1 --- /dev/null +++ b/src/glsl/linker.h @@ -0,0 +1,35 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_LINKER_H +#define GLSL_LINKER_H + +extern void +linker_error_printf(gl_shader_program *prog, const char *fmt, ...); + +extern bool +link_function_calls(gl_shader_program *prog, gl_shader *main, + gl_shader **shader_list, unsigned num_shaders); + +#endif /* GLSL_LINKER_H */ -- cgit v1.2.3 From de415b7f4b1278f10097f4af80886bc82912dd92 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 14 Jul 2010 13:22:12 -0700 Subject: linker: Add comment about bug in initializer handling --- src/glsl/linker.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index f7c178e9677..06aa24e66f5 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -314,6 +314,14 @@ cross_validate_globals(struct gl_shader_program *prog, * have an initializer but a later instance does, copy the * initializer to the version stored in the symbol table. */ + /* FINISHME: This is wrong. The constant_value field should + * FINISHME: not be modified! Imagine a case where a shader + * FINISHME: without an initializer is linked in two different + * FINISHME: programs with shaders that have differing + * FINISHME: initializers. Linking with the first will + * FINISHME: modify the shader, and linking with the second + * FINISHME: will fail. + */ existing->constant_value = var->constant_value->clone(NULL); } } else -- cgit v1.2.3 From b95897b89d36a25c237a021c299a4eb295856476 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 15 Jul 2010 13:09:25 -0700 Subject: glsl2: Explicitly walk lists in ir_function::parameter_lists_match Give ir_function::parameter_lists_match_exist similar treatment. Make the parameters const, and propogate the constness as far as it will trivially go. --- src/glsl/ir.h | 4 ++-- src/glsl/ir_function.cpp | 44 +++++++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index ff91a8dbce3..1d667be89c0 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -398,13 +398,13 @@ public: * Find a signature that matches a set of actual parameters, taking implicit * conversions into account. */ - ir_function_signature *matching_signature(exec_list *actual_param); + ir_function_signature *matching_signature(const exec_list *actual_param); /** * Find a signature that exactly matches a set of actual parameters without * any implicit type conversions. */ - ir_function_signature *exact_matching_signature(exec_list *actual_ps); + ir_function_signature *exact_matching_signature(const exec_list *actual_ps); /** * Name of the function. diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp index fcdb83be561..e85b18ce021 100644 --- a/src/glsl/ir_function.cpp +++ b/src/glsl/ir_function.cpp @@ -87,23 +87,25 @@ type_compare(const glsl_type *a, const glsl_type *b) static int -parameter_lists_match(exec_list *list_a, exec_list *list_b) +parameter_lists_match(const exec_list *list_a, const exec_list *list_b) { - exec_list_iterator iter_a = list_a->iterator(); - exec_list_iterator iter_b = list_b->iterator(); + const exec_node *node_a = list_a->head; + const exec_node *node_b = list_b->head; int total_score = 0; - for (/* empty */ ; iter_a.has_next(); iter_a.next(), iter_b.next()) { + for (/* empty */ + ; !node_a->is_tail_sentinal() + ; node_a = node_a->next, node_b = node_b->next) { /* If all of the parameters from the other parameter list have been * exhausted, the lists have different length and, by definition, * do not match. */ - if (!iter_b.has_next()) + if (node_b->is_tail_sentinal()) return -1; - const ir_variable *const param = (ir_variable *) iter_a.get(); - const ir_instruction *const actual = (ir_instruction *) iter_b.get(); + const ir_variable *const param = (ir_variable *) node_a; + const ir_instruction *const actual = (ir_instruction *) node_b; /* Determine whether or not the types match. If the types are an * exact match, the match score is zero. If the types don't match @@ -148,7 +150,7 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) * exhausted, the lists have different length and, by definition, do not * match. */ - if (iter_b.has_next()) + if (!node_b->is_tail_sentinal()) return -1; return total_score; @@ -156,7 +158,7 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b) ir_function_signature * -ir_function::matching_signature(exec_list *actual_parameters) +ir_function::matching_signature(const exec_list *actual_parameters) { ir_function_signature *match = NULL; @@ -183,36 +185,32 @@ ir_function::matching_signature(exec_list *actual_parameters) static bool -parameter_lists_match_exact(exec_list *list_a, exec_list *list_b) +parameter_lists_match_exact(const exec_list *list_a, const exec_list *list_b) { - exec_list_iterator iter_a = list_a->iterator(); - exec_list_iterator iter_b = list_b->iterator(); + const exec_node *node_a = list_a->head; + const exec_node *node_b = list_b->head; - while (iter_a.has_next() && iter_b.has_next()) { - ir_variable *a = (ir_variable *)iter_a.get(); - ir_variable *b = (ir_variable *)iter_b.get(); + for (/* empty */ + ; !node_a->is_tail_sentinal() && !node_b->is_tail_sentinal() + ; node_a = node_a->next, node_b = node_b->next) { + ir_variable *a = (ir_variable *) node_a; + ir_variable *b = (ir_variable *) node_b; /* If the types of the parameters do not match, the parameters lists * are different. */ if (a->type != b->type) return false; - - iter_a.next(); - iter_b.next(); } /* Unless both lists are exhausted, they differ in length and, by * definition, do not match. */ - if (iter_a.has_next() != iter_b.has_next()) - return false; - - return true; + return (node_a->is_tail_sentinal() == node_b->is_tail_sentinal()); } ir_function_signature * -ir_function::exact_matching_signature(exec_list *actual_parameters) +ir_function::exact_matching_signature(const exec_list *actual_parameters) { foreach_iter(exec_list_iterator, iter, signatures) { ir_function_signature *const sig = -- cgit v1.2.3 From 5adbf0bff168c088d9fd5140226b76e3ba6471b8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 15 Jul 2010 13:32:27 -0700 Subject: linker: Pull find_matching_signature out of call_link_visitor The list of shaders to search needs to be provided as an explicit parameter to support coming changes. At that point there is no reason for it to be in the class. Also, fix some of the 'const' decorators. --- src/glsl/link_functions.cpp | 48 +++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp index 35bd22350d5..28e56cb0fa2 100644 --- a/src/glsl/link_functions.cpp +++ b/src/glsl/link_functions.cpp @@ -37,6 +37,10 @@ extern "C" { #include "hash_table.h" #include "linker.h" +static ir_function_signature * +find_matching_signature(const char *name, const exec_list *actual_parameters, + gl_shader **shader_list, unsigned num_shaders); + class call_link_visitor : public ir_hierarchical_visitor { public: call_link_visitor(gl_shader_program *prog, gl_shader **shader_list, @@ -66,8 +70,9 @@ public: const char *const name = callee->function_name(); - ir_function_signature *sig = const_cast - (this->find_matching_signature(name, &ir->actual_parameters)); + ir_function_signature *sig = + find_matching_signature(name, &ir->actual_parameters, shader_list, + num_shaders); if (sig == NULL) { /* FINISHME: Log the full signature of unresolved function. */ @@ -138,31 +143,32 @@ private: /** Number of shaders available for linking. */ unsigned num_shaders; - /** - * Searches all shaders for a particular function definition - */ - const ir_function_signature * - find_matching_signature(const char *name, exec_list *actual_parameters) - { - for (unsigned i = 0; i < this->num_shaders; i++) { - ir_function *const f = - this->shader_list[i]->symbols->get_function(name); +}; + - if (f == NULL) - continue; +/** + * Searches a list of shaders for a particular function definition + */ +ir_function_signature * +find_matching_signature(const char *name, const exec_list *actual_parameters, + gl_shader **shader_list, unsigned num_shaders) +{ + for (unsigned i = 0; i < num_shaders; i++) { + ir_function *const f = shader_list[i]->symbols->get_function(name); - const ir_function_signature *sig = - f->matching_signature(actual_parameters); + if (f == NULL) + continue; - if ((sig == NULL) || !sig->is_defined) - continue; + ir_function_signature *sig = f->matching_signature(actual_parameters); - return sig; - } + if ((sig == NULL) || !sig->is_defined) + continue; - return NULL; + return sig; } -}; + + return NULL; +} bool -- cgit v1.2.3 From 532c2d30850908b75f4b0ad0aa5fa7ce88f8202d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 15 Jul 2010 19:28:32 -0700 Subject: linker: look up function signatures during linking instead of using callee Instead of using ir_call::callee, search for the signature in the linked shader. This will allow resolving calls from functions imported from other shaders. The ir_call::callee pointer in the imported function will still reference a signature in the original shader. --- src/glsl/link_functions.cpp | 83 ++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp index 28e56cb0fa2..721bec65f3e 100644 --- a/src/glsl/link_functions.cpp +++ b/src/glsl/link_functions.cpp @@ -43,36 +43,43 @@ find_matching_signature(const char *name, const exec_list *actual_parameters, class call_link_visitor : public ir_hierarchical_visitor { public: - call_link_visitor(gl_shader_program *prog, gl_shader **shader_list, - unsigned num_shaders) + call_link_visitor(gl_shader_program *prog, gl_shader *linked, + gl_shader **shader_list, unsigned num_shaders) { this->prog = prog; this->shader_list = shader_list; this->num_shaders = num_shaders; this->success = true; + this->linked = linked; } virtual ir_visitor_status visit_enter(ir_call *ir) { - /* If the function call references a function signature that does not - * have a definition, try to find the definition in one of the other - * shaders. + /* If ir is an ir_call from a function that was imported from another + * shader callee will point to an ir_function_signature in the original + * shader. In this case the function signature MUST NOT BE MODIFIED. + * Doing so will modify the original shader. This may prevent that + * shader from being linkable in other programs. */ - ir_function_signature *callee = - const_cast(ir->get_callee()); + const ir_function_signature *const callee = ir->get_callee(); assert(callee != NULL); - - if (callee->is_defined) - /* FINISHME: Do children need to be processed, or are all parameters - * FINISHME: with function calls already flattend? - */ - return visit_continue; - const char *const name = callee->function_name(); + /* Determine if the requested function signature already exists in the + * final linked shader. If it does, use it as the target of the call. + */ ir_function_signature *sig = - find_matching_signature(name, &ir->actual_parameters, shader_list, - num_shaders); + find_matching_signature(name, &callee->parameters, &linked, 1); + if (sig != NULL) { + ir->set_callee(sig); + return visit_continue; + } + + /* Try to find the signature in one of the other shaders that is being + * linked. If it's not found there, return an error. + */ + sig = find_matching_signature(name, &ir->actual_parameters, shader_list, + num_shaders); if (sig == NULL) { /* FINISHME: Log the full signature of unresolved function. */ @@ -82,6 +89,27 @@ public: return visit_stop; } + /* Find the prototype information in the linked shader. Generate any + * details that may be missing. + */ + ir_function *f = linked->symbols->get_function(name); + if (f == NULL) + f = new(linked) ir_function(name); + + ir_function_signature *linked_sig = + f->matching_signature(&callee->parameters); + if (linked_sig == NULL) { + linked_sig = new(linked) ir_function_signature(callee->return_type); + f->add_signature(linked_sig); + } + + /* At this point linked_sig and called may be the same. If ir is an + * ir_call from linked then linked_sig and callee will be + * ir_function_signatures that have no definitions (is_defined is false). + */ + assert(!linked_sig->is_defined); + assert(linked_sig->body.is_empty()); + /* Create an in-place clone of the function definition. This multistep * process introduces some complexity here, but it has some advantages. * The parameter list and the and function body are cloned separately. @@ -90,9 +118,9 @@ public: * * The big advantage is that the ir_function_signature does not change. * This means that we don't have to process the rest of the IR tree to - * patch ir_call nodes. In addition, there is no way to remove or replace - * signature stored in a function. One could easily be added, but this - * avoids the need. + * patch ir_call nodes. In addition, there is no way to remove or + * replace signature stored in a function. One could easily be added, + * but this avoids the need. */ struct hash_table *ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); @@ -105,17 +133,16 @@ public: formal_parameters.push_tail(copy); } - callee->replace_parameters(&formal_parameters); + linked_sig->replace_parameters(&formal_parameters); - assert(callee->body.is_empty()); foreach_list_const(node, &sig->body) { const ir_instruction *const original = (ir_instruction *) node; ir_instruction *copy = original->clone(ht); - callee->body.push_tail(copy); + linked_sig->body.push_tail(copy); } - callee->is_defined = true; + linked_sig->is_defined = true; /* FINISHME: Patch references inside the function to things outside the * FINISHME: function (i.e., function calls and global variables). @@ -143,6 +170,14 @@ private: /** Number of shaders available for linking. */ unsigned num_shaders; + /** + * Final linked shader + * + * This is used two ways. It is used to find global variables in the + * linked shader that are accessed by the function. It is also used to add + * global variables from the shader where the function originated. + */ + gl_shader *linked; }; @@ -175,7 +210,7 @@ bool link_function_calls(gl_shader_program *prog, gl_shader *main, gl_shader **shader_list, unsigned num_shaders) { - call_link_visitor v(prog, shader_list, num_shaders); + call_link_visitor v(prog, main, shader_list, num_shaders); v.run(main->ir); return v.success; -- cgit v1.2.3 From fc9ae101b4b7a71ca7a5d4f185e887064007e0d1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 15 Jul 2010 20:20:36 -0700 Subject: linker: Recursively resolve function calls in imported functions --- src/glsl/link_functions.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp index 721bec65f3e..a9ed49a3492 100644 --- a/src/glsl/link_functions.cpp +++ b/src/glsl/link_functions.cpp @@ -51,6 +51,20 @@ public: this->num_shaders = num_shaders; this->success = true; this->linked = linked; + + this->locals = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + } + + ~call_link_visitor() + { + hash_table_dtor(this->locals); + } + + virtual ir_visitor_status visit(ir_variable *ir) + { + hash_table_insert(locals, ir, ir); + return visit_continue; } virtual ir_visitor_status visit_enter(ir_call *ir) @@ -143,12 +157,36 @@ public: } linked_sig->is_defined = true; + hash_table_dtor(ht); - /* FINISHME: Patch references inside the function to things outside the - * FINISHME: function (i.e., function calls and global variables). + /* Patch references inside the function to things outside the function + * (i.e., function calls and global variables). */ + linked_sig->accept(this); - hash_table_dtor(ht); + return visit_continue; + } + + virtual ir_visitor_status visit(ir_dereference_variable *ir) + { + if (hash_table_find(locals, ir->var) == NULL) { + /* The non-function variable must be a global, so try to find the + * variable in the shader's symbol table. If the variable is not + * found, then it's a global that *MUST* be defined in the original + * shader. + */ + ir_variable *var = linked->symbols->get_variable(ir->var->name); + if (var == NULL) { + /* Clone the ir_variable that the dereference already has and add + * it to the linked shader. + */ + var = ir->var->clone(NULL); + linked->symbols->add_variable(var->name, var); + linked->ir->push_head(var); + } + + ir->var = var; + } return visit_continue; } @@ -178,6 +216,11 @@ private: * global variables from the shader where the function originated. */ gl_shader *linked; + + /** + * Table of variables local to the function. + */ + hash_table *locals; }; -- cgit v1.2.3 From b64e979971e764ec1df8800d31c755298e618ba0 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 16 Jul 2010 15:31:23 -0700 Subject: glsl2: Use Elements macro --- src/glsl/builtin_function.cpp | 22 +++++++++++++--------- src/glsl/builtins/tools/generate_builtins.pl | 7 +++++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 75e058c41c8..fbb2638fc93 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -4748,6 +4748,10 @@ static const char *functions_for_EXT_texture_array_fs [] = { builtins_EXT_texture_array_fs_textures, }; +#ifndef Elements +#define Elements(x) (sizeof(x)/sizeof(*(x))) +#endif + void _mesa_glsl_initialize_functions(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -4755,46 +4759,46 @@ _mesa_glsl_initialize_functions(exec_list *instructions, if (state->language_version >= 110) read_builtins(state, instructions, functions_for_110, - sizeof(functions_for_110) / sizeof(const char *)); + Elements(functions_for_110)); if (state->target == fragment_shader && state->language_version >= 110) read_builtins(state, instructions, functions_for_110_fs, - sizeof(functions_for_110_fs) / sizeof(const char *)); + Elements(functions_for_110_fs)); if (state->target == vertex_shader && state->language_version >= 110) read_builtins(state, instructions, functions_for_110_vs, - sizeof(functions_for_110_vs) / sizeof(const char *)); + Elements(functions_for_110_vs)); if (state->language_version >= 120) read_builtins(state, instructions, functions_for_120, - sizeof(functions_for_120) / sizeof(const char *)); + Elements(functions_for_120)); if (state->language_version >= 130) read_builtins(state, instructions, functions_for_130, - sizeof(functions_for_130) / sizeof(const char *)); + Elements(functions_for_130)); if (state->target == fragment_shader && state->language_version >= 130) read_builtins(state, instructions, functions_for_130_fs, - sizeof(functions_for_130_fs) / sizeof(const char *)); + Elements(functions_for_130_fs)); if (state->ARB_texture_rectangle_enable) read_builtins(state, instructions, functions_for_ARB_texture_rectangle, - sizeof(functions_for_ARB_texture_rectangle) / sizeof(const char *)); + Elements(functions_for_ARB_texture_rectangle)); if (state->EXT_texture_array_enable) read_builtins(state, instructions, functions_for_EXT_texture_array, - sizeof(functions_for_EXT_texture_array) / sizeof(const char *)); + Elements(functions_for_EXT_texture_array)); if (state->target == fragment_shader && state->EXT_texture_array_enable) read_builtins(state, instructions, functions_for_EXT_texture_array_fs, - sizeof(functions_for_EXT_texture_array_fs) / sizeof(const char *)); + Elements(functions_for_EXT_texture_array_fs)); } diff --git a/src/glsl/builtins/tools/generate_builtins.pl b/src/glsl/builtins/tools/generate_builtins.pl index 8b640ab8ff9..a0b5c1f421c 100755 --- a/src/glsl/builtins/tools/generate_builtins.pl +++ b/src/glsl/builtins/tools/generate_builtins.pl @@ -91,6 +91,10 @@ foreach $version (@versions) { } print << 'EOF'; +#ifndef Elements +#define Elements(x) (sizeof(x)/sizeof(*(x))) +#endif + void _mesa_glsl_initialize_functions(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -116,8 +120,7 @@ foreach $version_xs (@versions) { print " if ($check)\n"; print " read_builtins(state, instructions,\n"; print " functions_for_$version_xs,\n"; - print " sizeof(functions_for_$version_xs) / "; - print "sizeof(const char *));\n\n" + print " Elements(functions_for_$version_xs));\n\n" } print "}\n"; -- cgit v1.2.3 From 25f51d3b9b8c36c41cd23d2797b6a06f6e27ff86 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 16 Jul 2010 15:51:50 -0700 Subject: linker: Track and validate GLSL versions used in shaders --- src/glsl/linker.cpp | 21 +++++++++++++++++++++ src/glsl/main.cpp | 1 + src/mesa/main/mtypes.h | 4 ++++ src/mesa/shader/ir_to_mesa.cpp | 1 + 4 files changed, 27 insertions(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 06aa24e66f5..4933686b5e9 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -66,12 +66,14 @@ #include #include #include +#include extern "C" { #include } #include "main/mtypes.h" +#include "main/macros.h" #include "glsl_symbol_table.h" #include "ir.h" #include "program.h" @@ -1107,7 +1109,12 @@ link_shaders(struct gl_shader_program *prog) calloc(2 * prog->NumShaders, sizeof(struct gl_shader *)); frag_shader_list = &vert_shader_list[prog->NumShaders]; + unsigned min_version = UINT_MAX; + unsigned max_version = 0; for (unsigned i = 0; i < prog->NumShaders; i++) { + min_version = MIN2(min_version, prog->Shaders[i]->Version); + max_version = MAX2(max_version, prog->Shaders[i]->Version); + switch (prog->Shaders[i]->Type) { case GL_VERTEX_SHADER: vert_shader_list[num_vert_shaders] = prog->Shaders[i]; @@ -1124,6 +1131,20 @@ link_shaders(struct gl_shader_program *prog) } } + /* Previous to GLSL version 1.30, different compilation units could mix and + * match shading language versions. With GLSL 1.30 and later, the versions + * of all shaders must match. + */ + assert(min_version >= 110); + assert(max_version <= 130); + if ((max_version >= 130) && (min_version != max_version)) { + linker_error_printf(prog, "all shaders must use same shading " + "language version\n"); + goto done; + } + + prog->Version = max_version; + /* FINISHME: Implement intra-stage linking. */ prog->_NumLinkedShaders = 0; if (num_vert_shaders > 0) { diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 8b0bccdcb71..e27d9c1d855 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -207,6 +207,7 @@ compile_shader(struct gl_shader *shader) shader->symbols = state->symbols; shader->CompileStatus = !state->error; + shader->Version = state->language_version; if (shader->InfoLog) talloc_free(shader->InfoLog); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index be9eaaa875c..729c2eaf0fd 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1967,6 +1967,8 @@ struct gl_shader GLchar *InfoLog; struct gl_sl_pragmas Pragmas; + unsigned Version; /**< GLSL version used for linking */ + struct exec_list *ir; struct glsl_symbol_table *symbols; }; @@ -2006,6 +2008,8 @@ struct gl_shader_program GLboolean _Used; /**< Ever used for drawing? */ GLchar *InfoLog; + unsigned Version; /**< GLSL version used for linking */ + /** * Per-stage shaders resulting from the first stage of linking. */ diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 58320c92174..557f5d319d2 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2234,6 +2234,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) shader->CompileStatus = !state->error; shader->InfoLog = state->info_log; + shader->Version = state->language_version; /* Retain any live IR, but trash the rest. */ foreach_list(node, shader->ir) { -- cgit v1.2.3 From 1a03a644d2f933fbbbe535e584a92fdf1ad619f1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 16 Jul 2010 15:52:40 -0700 Subject: linker: Remove redundant check for 'main' in shaders This is now handled in link_intrastage_shaders. --- src/glsl/linker.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 4933686b5e9..a4776b1941c 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -192,11 +192,6 @@ validate_vertex_shader_executable(struct gl_shader_program *prog, if (shader == NULL) return true; - if (!shader->symbols->get_function("main")) { - linker_error_printf(prog, "vertex shader lacks `main'\n"); - return false; - } - find_assignment_visitor find("gl_Position"); find.run(shader->ir); if (!find.variable_found()) { @@ -221,11 +216,6 @@ validate_fragment_shader_executable(struct gl_shader_program *prog, if (shader == NULL) return true; - if (!shader->symbols->get_function("main")) { - linker_error_printf(prog, "fragment shader lacks `main'\n"); - return false; - } - find_assignment_visitor frag_color("gl_FragColor"); find_assignment_visitor frag_data("gl_FragData"); -- cgit v1.2.3 From cd6764ed6ec5ae1a4bce636feaf9d4b18ff3ccf3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 16 Jul 2010 16:00:07 -0700 Subject: linker: Remove the FINISHME comment for intrastage linking --- src/glsl/linker.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index a4776b1941c..4869dbe1ca5 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1135,7 +1135,8 @@ link_shaders(struct gl_shader_program *prog) prog->Version = max_version; - /* FINISHME: Implement intra-stage linking. */ + /* Link all shaders for a particular stage and validate the result. + */ prog->_NumLinkedShaders = 0; if (num_vert_shaders > 0) { gl_shader *const sh = -- cgit v1.2.3 From 18ab797d3aff776833fac1bd0ea01a2750f377b1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 11:14:33 -0700 Subject: ir_to_mesa: Fix swizzled writemasks with swapped component ordering. I hadn't noticed you could do this, but glsl1 tests caught it. Fixes: glsl1-Swizzled writemask glsl1-Swizzled writemask (2) glsl1-Swizzled writemask (rgba) glsl1-Swizzled writemask (stpq) --- src/mesa/shader/ir_to_mesa.cpp | 61 +++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 557f5d319d2..848fb0fb6c2 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1263,7 +1263,8 @@ ir_to_mesa_visitor::visit(ir_dereference_record *ir) * those, then go use ir_dereference to handle the rest. */ static struct ir_to_mesa_dst_reg -get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) +get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v, + ir_to_mesa_src_reg *r) { struct ir_to_mesa_dst_reg dst_reg; ir_swizzle *swiz; @@ -1281,41 +1282,35 @@ get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) dst_reg = ir_to_mesa_dst_reg_from_src(v->result); if ((swiz = ir->as_swizzle())) { - dst_reg.writemask = 0; - if (swiz->mask.num_components >= 1) - dst_reg.writemask |= (1 << swiz->mask.x); - if (swiz->mask.num_components >= 2) - dst_reg.writemask |= (1 << swiz->mask.y); - if (swiz->mask.num_components >= 3) - dst_reg.writemask |= (1 << swiz->mask.z); - if (swiz->mask.num_components >= 4) - dst_reg.writemask |= (1 << swiz->mask.w); - } - - return dst_reg; -} + int swizzles[4] = { + swiz->mask.x, + swiz->mask.y, + swiz->mask.z, + swiz->mask.w + }; + int new_r_swizzle[4]; + int orig_r_swizzle = r->swizzle; + int i; -static GLuint -reswizzle_for_writemask(GLuint writemask, GLuint swizzle) -{ - int new_swizzle[4], pos = 0; - int i; + for (i = 0; i < 4; i++) { + new_r_swizzle[i] = GET_SWZ(orig_r_swizzle, 0); + } - /* reswizzle the rhs so the components are in place for the - * components we'll assign to the lhs. - */ - for (i = 0; i < 4; i++) { - if (writemask & (1 << i)) { - new_swizzle[i] = GET_SWZ(swizzle, pos++); - } else { - new_swizzle[i] = GET_SWZ(swizzle, 0); + dst_reg.writemask = 0; + for (i = 0; i < 4; i++) { + if (i < swiz->mask.num_components) { + dst_reg.writemask |= 1 << swizzles[i]; + new_r_swizzle[swizzles[i]] = GET_SWZ(orig_r_swizzle, i); + } } + + r->swizzle = MAKE_SWIZZLE4(new_r_swizzle[0], + new_r_swizzle[1], + new_r_swizzle[2], + new_r_swizzle[3]); } - return MAKE_SWIZZLE4(new_swizzle[0], - new_swizzle[1], - new_swizzle[2], - new_swizzle[3]); + return dst_reg; } void @@ -1328,12 +1323,10 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) assert(!ir->lhs->type->is_array()); assert(ir->lhs->type->base_type != GLSL_TYPE_STRUCT); - l = get_assignment_lhs(ir->lhs, this); - ir->rhs->accept(this); r = this->result; - r.swizzle = reswizzle_for_writemask(l.writemask, r.swizzle); + l = get_assignment_lhs(ir->lhs, this, &r); assert(l.file != PROGRAM_UNDEFINED); assert(r.file != PROGRAM_UNDEFINED); -- cgit v1.2.3 From 5a2e0b8ce59a3d9f8fa7510546137aff40016c74 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 20 Jul 2010 11:37:45 -0700 Subject: glsl2: Don't validate IR if there were compilation errors --- src/glsl/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index e27d9c1d855..3ae0eebab3c 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -172,10 +172,9 @@ compile_shader(struct gl_shader *shader) if (!state->error && !state->translation_unit.is_empty()) _mesa_ast_to_hir(shader->ir, state); - validate_ir_tree(shader->ir); - /* Print out the unoptimized IR. */ if (!state->error && dump_hir) { + validate_ir_tree(shader->ir); _mesa_print_ir(shader->ir, state); } @@ -196,9 +195,10 @@ compile_shader(struct gl_shader *shader) progress = do_vec_index_to_cond_assign(shader->ir) || progress; progress = do_swizzle_swizzle(shader->ir) || progress; } while (progress); + + validate_ir_tree(shader->ir); } - validate_ir_tree(shader->ir); /* Print out the resulting IR */ if (!state->error && dump_lir) { -- cgit v1.2.3 From 14f8e16132409f38656e4874aa53bc471977f9ad Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 11:43:28 -0700 Subject: glsl2: Constant-fold assignment conditions. --- src/glsl/ir_constant_folding.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/glsl/ir_constant_folding.cpp b/src/glsl/ir_constant_folding.cpp index 2daa6fde38d..66a92e9f3b6 100644 --- a/src/glsl/ir_constant_folding.cpp +++ b/src/glsl/ir_constant_folding.cpp @@ -167,6 +167,19 @@ ir_constant_folding_visitor::visit(ir_assignment *ir) ir->rhs = const_val; else ir->rhs->accept(this); + + if (ir->condition) { + /* If the condition is constant, either remove the condition or + * remove the never-executed assignment. + */ + const_val = ir->condition->constant_expression_value(); + if (const_val) { + if (const_val->value.b[0]) + ir->condition = NULL; + else + ir->remove(); + } + } } -- cgit v1.2.3 From 117d154b4d877e8c4d7880432af0a80b8f717dc6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 11:56:48 -0700 Subject: glsl2: notEqual() produces a boolean value, not the base type of the args. Fixes: glsl1-vector relational (bvec2 ==,!=) glsl1-vector relational (vec4 !=) --- src/glsl/builtin_function.cpp | 36 ++++++++++++++++++------------------ src/glsl/builtins/110/notEqual | 36 ++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index fbb2638fc93..be7a4f2c633 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -1507,8 +1507,8 @@ static const char *builtins_110_notEqual = { " (declare (in) vec2 arg0)\n" " (declare (in) vec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -1516,9 +1516,9 @@ static const char *builtins_110_notEqual = { " (declare (in) vec3 arg0)\n" " (declare (in) vec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -1526,10 +1526,10 @@ static const char *builtins_110_notEqual = { " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))\n" " (return (var_ref temp))))\n" "\n" " (signature bvec2\n" @@ -1537,8 +1537,8 @@ static const char *builtins_110_notEqual = { " (declare (in) ivec2 arg0)\n" " (declare (in) ivec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -1546,9 +1546,9 @@ static const char *builtins_110_notEqual = { " (declare (in) ivec3 arg0)\n" " (declare (in) ivec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -1556,10 +1556,10 @@ static const char *builtins_110_notEqual = { " (declare (in) ivec4 arg0)\n" " (declare (in) ivec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))\n" " (return (var_ref temp))))\n" "))\n" }; diff --git a/src/glsl/builtins/110/notEqual b/src/glsl/builtins/110/notEqual index c87efa317f7..ccdcaa3aafa 100644 --- a/src/glsl/builtins/110/notEqual +++ b/src/glsl/builtins/110/notEqual @@ -4,8 +4,8 @@ (declare (in) vec2 arg0) (declare (in) vec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -13,9 +13,9 @@ (declare (in) vec3 arg0) (declare (in) vec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -23,10 +23,10 @@ (declare (in) vec4 arg0) (declare (in) vec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression float != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression float != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression float != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression float != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) (signature bvec2 @@ -34,8 +34,8 @@ (declare (in) ivec2 arg0) (declare (in) ivec2 arg1)) ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) (return (var_ref temp)))) (signature bvec3 @@ -43,9 +43,9 @@ (declare (in) ivec3 arg0) (declare (in) ivec3 arg1)) ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) (return (var_ref temp)))) (signature bvec4 @@ -53,9 +53,9 @@ (declare (in) ivec4 arg0) (declare (in) ivec4 arg1)) ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression int != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression int != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression int != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression int != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) (return (var_ref temp)))) )) -- cgit v1.2.3 From 1245babe0c69846d227a78a11429584433e77a9e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 12:22:37 -0700 Subject: glsl2: Fix asin() implementation. I'd flipped around the order of two operations in paren-balancing adventures, and left out the multiply by sign(x) required for negative x. Fixes: glsl1-acos(vec4) function glsl1-asin(vec4) function glsl1-atan(vec4) function --- src/glsl/builtin_function.cpp | 130 ++++++++++++++++++++++-------------------- src/glsl/builtins/110/asin | 130 ++++++++++++++++++++++-------------------- 2 files changed, 138 insertions(+), 122 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index be7a4f2c633..967bcd0c40d 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -113,90 +113,98 @@ static const char *builtins_110_asin = { " (parameters\n" " (declare (in) float x))\n" " ((return (expression float *\n" - " (expression float -\n" - " (expression float *\n" + " (expression float sign (var_ref x))\n" + " (expression float -\n" + " (expression float *\n" " (constant float (3.1415926))\n" " (constant float (0.5)))\n" - " (expression float sqrt\n" - " (expression float -\n" - " (constant float (1.0))\n" - " (expression float abs (var_ref x)))))\n" - " (expression float +\n" - " (constant float (1.5707288))\n" - " (expression float *\n" - " (expression float abs (var_ref x))\n" - " (expression float +\n" - " (constant float (-0.2121144))\n" - " (expression float *\n" - " (constant float (0.0742610))\n" - " (expression float abs (var_ref x))))))))))\n" + " (expression float *\n" + " (expression float sqrt\n" + " (expression float -\n" + " (constant float (1.0))\n" + " (expression float abs (var_ref x))))\n" + " (expression float +\n" + " (constant float (1.5707288))\n" + " (expression float *\n" + " (expression float abs (var_ref x))\n" + " (expression float +\n" + " (constant float (-0.2121144))\n" + " (expression float *\n" + " (constant float (0.0742610))\n" + " (expression float abs (var_ref x))))))))))))\n" "\n" " (signature vec2\n" " (parameters\n" " (declare (in) vec2 x))\n" " ((return (expression vec2 *\n" - " (expression float -\n" - " (expression float *\n" + " (expression vec2 sign (var_ref x))\n" + " (expression vec2 -\n" + " (expression float *\n" " (constant float (3.1415926))\n" " (constant float (0.5)))\n" - " (expression vec2 sqrt\n" - " (expression vec2 -\n" - " (constant float (1.0))\n" - " (expression vec2 abs (var_ref x)))))\n" - " (expression vec2 +\n" - " (constant float (1.5707288))\n" - " (expression vec2 *\n" - " (expression vec2 abs (var_ref x))\n" - " (expression vec2 +\n" - " (constant float (-0.2121144))\n" - " (expression vec2 *\n" - " (constant float (0.0742610))\n" - " (expression vec2 abs (var_ref x))))))))))\n" + " (expression vec2 *\n" + " (expression vec2 sqrt\n" + " (expression vec2 -\n" + " (constant float (1.0))\n" + " (expression vec2 abs (var_ref x))))\n" + " (expression vec2 +\n" + " (constant float (1.5707288))\n" + " (expression vec2 *\n" + " (expression vec2 abs (var_ref x))\n" + " (expression vec2 +\n" + " (constant float (-0.2121144))\n" + " (expression vec2 *\n" + " (constant float (0.0742610))\n" + " (expression vec2 abs (var_ref x))))))))))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 x))\n" " ((return (expression vec3 *\n" - " (expression vec3 -\n" - " (expression float *\n" + " (expression vec3 sign (var_ref x))\n" + " (expression vec3 -\n" + " (expression float *\n" " (constant float (3.1415926))\n" " (constant float (0.5)))\n" - " (expression vec3 sqrt\n" - " (expression vec3 -\n" - " (constant float (1.0))\n" - " (expression vec3 abs (var_ref x)))))\n" - " (expression vec3 +\n" - " (constant float (1.5707288))\n" - " (expression vec3 *\n" - " (expression vec3 abs (var_ref x))\n" - " (expression vec3 +\n" - " (constant float (-0.2121144))\n" - " (expression vec3 *\n" - " (constant float (0.0742610))\n" - " (expression vec3 abs (var_ref x))))))))))\n" + " (expression vec3 *\n" + " (expression vec3 sqrt\n" + " (expression vec3 -\n" + " (constant float (1.0))\n" + " (expression vec3 abs (var_ref x))))\n" + " (expression vec3 +\n" + " (constant float (1.5707288))\n" + " (expression vec3 *\n" + " (expression vec3 abs (var_ref x))\n" + " (expression vec3 +\n" + " (constant float (-0.2121144))\n" + " (expression vec3 *\n" + " (constant float (0.0742610))\n" + " (expression vec3 abs (var_ref x))))))))))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 x))\n" " ((return (expression vec4 *\n" - " (expression vec4 -\n" - " (expression float *\n" + " (expression vec4 sign (var_ref x))\n" + " (expression vec4 -\n" + " (expression float *\n" " (constant float (3.1415926))\n" " (constant float (0.5)))\n" - " (expression vec4 sqrt\n" - " (expression vec4 -\n" - " (constant float (1.0))\n" - " (expression vec4 abs (var_ref x)))))\n" - " (expression vec4 +\n" - " (constant float (1.5707288))\n" - " (expression vec4 *\n" - " (expression vec4 abs (var_ref x))\n" - " (expression vec4 +\n" - " (constant float (-0.2121144))\n" - " (expression vec4 *\n" - " (constant float (0.0742610))\n" - " (expression vec4 abs (var_ref x))))))))))\n" - ")\n" + " (expression vec4 *\n" + " (expression vec4 sqrt\n" + " (expression vec4 -\n" + " (constant float (1.0))\n" + " (expression vec4 abs (var_ref x))))\n" + " (expression vec4 +\n" + " (constant float (1.5707288))\n" + " (expression vec4 *\n" + " (expression vec4 abs (var_ref x))\n" + " (expression vec4 +\n" + " (constant float (-0.2121144))\n" + " (expression vec4 *\n" + " (constant float (0.0742610))\n" + " (expression vec4 abs (var_ref x)))))))))))\n" + "))\n" "\n" " (function acos\n" " (signature float\n" diff --git a/src/glsl/builtins/110/asin b/src/glsl/builtins/110/asin index fe93337bffc..d26bde364b1 100644 --- a/src/glsl/builtins/110/asin +++ b/src/glsl/builtins/110/asin @@ -3,90 +3,98 @@ (parameters (declare (in) float x)) ((return (expression float * - (expression float - - (expression float * + (expression float sign (var_ref x)) + (expression float - + (expression float * (constant float (3.1415926)) (constant float (0.5))) - (expression float sqrt - (expression float - - (constant float (1.0)) - (expression float abs (var_ref x))))) - (expression float + - (constant float (1.5707288)) - (expression float * - (expression float abs (var_ref x)) - (expression float + - (constant float (-0.2121144)) - (expression float * - (constant float (0.0742610)) - (expression float abs (var_ref x)))))))))) + (expression float * + (expression float sqrt + (expression float - + (constant float (1.0)) + (expression float abs (var_ref x)))) + (expression float + + (constant float (1.5707288)) + (expression float * + (expression float abs (var_ref x)) + (expression float + + (constant float (-0.2121144)) + (expression float * + (constant float (0.0742610)) + (expression float abs (var_ref x)))))))))))) (signature vec2 (parameters (declare (in) vec2 x)) ((return (expression vec2 * - (expression float - - (expression float * + (expression vec2 sign (var_ref x)) + (expression vec2 - + (expression float * (constant float (3.1415926)) (constant float (0.5))) - (expression vec2 sqrt - (expression vec2 - - (constant float (1.0)) - (expression vec2 abs (var_ref x))))) - (expression vec2 + - (constant float (1.5707288)) - (expression vec2 * - (expression vec2 abs (var_ref x)) - (expression vec2 + - (constant float (-0.2121144)) - (expression vec2 * - (constant float (0.0742610)) - (expression vec2 abs (var_ref x)))))))))) + (expression vec2 * + (expression vec2 sqrt + (expression vec2 - + (constant float (1.0)) + (expression vec2 abs (var_ref x)))) + (expression vec2 + + (constant float (1.5707288)) + (expression vec2 * + (expression vec2 abs (var_ref x)) + (expression vec2 + + (constant float (-0.2121144)) + (expression vec2 * + (constant float (0.0742610)) + (expression vec2 abs (var_ref x)))))))))))) (signature vec3 (parameters (declare (in) vec3 x)) ((return (expression vec3 * - (expression vec3 - - (expression float * + (expression vec3 sign (var_ref x)) + (expression vec3 - + (expression float * (constant float (3.1415926)) (constant float (0.5))) - (expression vec3 sqrt - (expression vec3 - - (constant float (1.0)) - (expression vec3 abs (var_ref x))))) - (expression vec3 + - (constant float (1.5707288)) - (expression vec3 * - (expression vec3 abs (var_ref x)) - (expression vec3 + - (constant float (-0.2121144)) - (expression vec3 * - (constant float (0.0742610)) - (expression vec3 abs (var_ref x)))))))))) + (expression vec3 * + (expression vec3 sqrt + (expression vec3 - + (constant float (1.0)) + (expression vec3 abs (var_ref x)))) + (expression vec3 + + (constant float (1.5707288)) + (expression vec3 * + (expression vec3 abs (var_ref x)) + (expression vec3 + + (constant float (-0.2121144)) + (expression vec3 * + (constant float (0.0742610)) + (expression vec3 abs (var_ref x)))))))))))) (signature vec4 (parameters (declare (in) vec4 x)) ((return (expression vec4 * - (expression vec4 - - (expression float * + (expression vec4 sign (var_ref x)) + (expression vec4 - + (expression float * (constant float (3.1415926)) (constant float (0.5))) - (expression vec4 sqrt - (expression vec4 - - (constant float (1.0)) - (expression vec4 abs (var_ref x))))) - (expression vec4 + - (constant float (1.5707288)) - (expression vec4 * - (expression vec4 abs (var_ref x)) - (expression vec4 + - (constant float (-0.2121144)) - (expression vec4 * - (constant float (0.0742610)) - (expression vec4 abs (var_ref x)))))))))) -) + (expression vec4 * + (expression vec4 sqrt + (expression vec4 - + (constant float (1.0)) + (expression vec4 abs (var_ref x)))) + (expression vec4 + + (constant float (1.5707288)) + (expression vec4 * + (expression vec4 abs (var_ref x)) + (expression vec4 + + (constant float (-0.2121144)) + (expression vec4 * + (constant float (0.0742610)) + (expression vec4 abs (var_ref x))))))))))) +)) (function acos (signature float -- cgit v1.2.3 From f8946699ecfa5bc6566821fb855072bbdbd716b2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 14:03:35 -0700 Subject: glsl2: Add definitions of the builtin constants present in GLSL 1.10. Fixes: glsl1-built-in constants --- src/glsl/glsl_parser_extras.h | 15 ++++++++++++++- src/glsl/ir_variable.cpp | 38 ++++++++++++++++++++++++++++++++------ src/glsl/main.cpp | 19 ++++++++++++++++++- src/mesa/shader/ir_to_mesa.cpp | 14 +++++++++++++- 4 files changed, 77 insertions(+), 9 deletions(-) diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 4b28ae118df..fed6e8c823f 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -49,8 +49,21 @@ struct _mesa_glsl_parse_state { * \sa struct gl_constants (in mtypes.h) */ struct { - unsigned MaxDrawBuffers; + /* 1.10 */ + unsigned MaxLights; + unsigned MaxClipPlanes; + unsigned MaxTextureUnits; unsigned MaxTextureCoords; + unsigned MaxVertexAttribs; + unsigned MaxVertexUniformComponents; + unsigned MaxVaryingFloats; + unsigned MaxVertexTextureImageUnits; + unsigned MaxCombinedTextureImageUnits; + unsigned MaxTextureImageUnits; + unsigned MaxFragmentUniformComponents; + + /* ARB_draw_buffers */ + unsigned MaxDrawBuffers; } Const; /** diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index a0b66b77702..4593c181127 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -93,6 +93,16 @@ add_builtin_variable(const builtin_variable *proto, exec_list *instructions, symtab); } +static void +add_builtin_constant(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + const char *name, int value) +{ + ir_variable *const var = add_variable(name, ir_var_auto, + -1, glsl_type::int_type, + instructions, state->symbols); + var->constant_value = new(var) ir_constant(value); +} static void generate_110_uniforms(exec_list *instructions, @@ -105,12 +115,28 @@ generate_110_uniforms(exec_list *instructions, instructions, state->symbols); } - ir_variable *const mtc = add_variable("gl_MaxTextureCoords", ir_var_auto, - -1, glsl_type::int_type, - instructions, state->symbols); - mtc->constant_value = new(mtc) - ir_constant(int(state->Const.MaxTextureCoords)); - + add_builtin_constant(instructions, state, "gl_MaxLights", + state->Const.MaxLights); + add_builtin_constant(instructions, state, "gl_MaxClipPlanes", + state->Const.MaxClipPlanes); + add_builtin_constant(instructions, state, "gl_MaxTextureUnits", + state->Const.MaxTextureUnits); + add_builtin_constant(instructions, state, "gl_MaxTextureCoords", + state->Const.MaxTextureCoords); + add_builtin_constant(instructions, state, "gl_MaxVertexAttribs", + state->Const.MaxVertexAttribs); + add_builtin_constant(instructions, state, "gl_MaxVertexUniformComponents", + state->Const.MaxVertexUniformComponents); + add_builtin_constant(instructions, state, "gl_MaxVaryingFloats", + state->Const.MaxVaryingFloats); + add_builtin_constant(instructions, state, "gl_MaxVertexTextureImageUnits", + state->Const.MaxVertexTextureImageUnits); + add_builtin_constant(instructions, state, "gl_MaxCombinedTextureImageUnits", + state->Const.MaxCombinedTextureImageUnits); + add_builtin_constant(instructions, state, "gl_MaxTextureImageUnits", + state->Const.MaxTextureImageUnits); + add_builtin_constant(instructions, state, "gl_MaxFragmentUniformComponents", + state->Const.MaxFragmentUniformComponents); const glsl_type *const mat4_array_type = glsl_type::get_array_instance(state->symbols, glsl_type::mat4_type, diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 3ae0eebab3c..6b1a01c7046 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -148,9 +148,26 @@ compile_shader(struct gl_shader *shader) memset(&ext, 0, sizeof(ext)); state->extensions = &ext; - state->Const.MaxDrawBuffers = 2; + /* 1.10 minimums. */ + state->Const.MaxLights = 8; + state->Const.MaxClipPlanes = 8; + state->Const.MaxTextureUnits = 2; + + /* More than the 1.10 minimum to appease parser tests taken from + * apps that (hopefully) already checked the number of coords. + */ state->Const.MaxTextureCoords = 4; + state->Const.MaxVertexAttribs = 16; + state->Const.MaxVertexUniformComponents = 512; + state->Const.MaxVaryingFloats = 32; + state->Const.MaxVertexTextureImageUnits = 0; + state->Const.MaxCombinedTextureImageUnits = 2; + state->Const.MaxTextureImageUnits = 2; + state->Const.MaxFragmentUniformComponents = 64; + + state->Const.MaxDrawBuffers = 2; + const char *source = shader->Source; state->error = preprocess(state, &source, &state->info_log, &ext); diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 848fb0fb6c2..5803960d444 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2170,8 +2170,20 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) state->ARB_texture_rectangle_enable = true; state->extensions = &ctx->Extensions; - state->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; + + state->Const.MaxLights = ctx->Const.MaxLights; + state->Const.MaxClipPlanes = ctx->Const.MaxClipPlanes; + state->Const.MaxTextureUnits = ctx->Const.MaxTextureUnits; state->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits; + state->Const.MaxVertexAttribs = ctx->Const.VertexProgram.MaxAttribs; + state->Const.MaxVertexUniformComponents = ctx->Const.VertexProgram.MaxUniformComponents; + state->Const.MaxVaryingFloats = ctx->Const.MaxVarying * 4; + state->Const.MaxVertexTextureImageUnits = ctx->Const.MaxVertexTextureImageUnits; + state->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxCombinedTextureImageUnits; + state->Const.MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits; + state->Const.MaxFragmentUniformComponents = ctx->Const.FragmentProgram.MaxUniformComponents; + + state->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; const char *source = shader->Source; state->error = preprocess(state, &source, &state->info_log, -- cgit v1.2.3 From 02d3711a21f5766d286b09fbe1eda5d8520d151a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 15:50:48 -0700 Subject: glsl2: Always insert function calls into the instruction stream. If they have a return value, this means putting it into a temporary and making a deref of the temp be the rvalue, since we don't know if the rvalue will be used or not. --- src/glsl/ast_function.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index aaf1e57ae28..643eb229a77 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -104,7 +104,30 @@ process_call(exec_list *instructions, ir_function *f, formal_iter.next(); } - return new(ctx) ir_call(sig, actual_parameters); + /* Always insert the call in the instruction stream, and return a deref + * of its return val if it returns a value, since we don't know if + * the rvalue is going to be assigned to anything or not. + */ + ir_call *call = new(ctx) ir_call(sig, actual_parameters); + if (!sig->return_type->is_void()) { + ir_variable *var; + ir_dereference_variable *deref; + + var = new(ctx) ir_variable(sig->return_type, + talloc_asprintf(ctx, "%s_retval", + sig->function_name())); + instructions->push_tail(var); + + deref = new(ctx) ir_dereference_variable(var); + ir_assignment *assign = new(ctx) ir_assignment(deref, call, NULL); + instructions->push_tail(assign); + + deref = new(ctx) ir_dereference_variable(var); + return deref; + } else { + instructions->push_tail(call); + return NULL; + } } else { /* FINISHME: Log a better error message here. G++ will show the types * FINISHME: of the actual parameters and the set of candidate -- cgit v1.2.3 From 2927c81ed10c0dc617f734c00376d0582ac3c061 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 14:21:43 -0700 Subject: glsl2: Don't mark a variable as constant if it was used as an out param. --- src/glsl/ir_constant_variable.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/glsl/ir_constant_variable.cpp b/src/glsl/ir_constant_variable.cpp index ef5e1e418e5..c5ccd52e5db 100644 --- a/src/glsl/ir_constant_variable.cpp +++ b/src/glsl/ir_constant_variable.cpp @@ -47,6 +47,7 @@ struct assignment_entry { class ir_constant_variable_visitor : public ir_hierarchical_visitor { public: virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_call *); exec_list list; }; @@ -107,6 +108,28 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir) return visit_continue; } +ir_visitor_status +ir_constant_variable_visitor::visit_enter(ir_call *ir) +{ + exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param_rval = (ir_rvalue *)iter.get(); + ir_variable *param = (ir_variable *)sig_iter.get(); + + if (param->mode == ir_var_out || + param->mode == ir_var_inout) { + ir_variable *var = param_rval->variable_referenced(); + struct assignment_entry *entry; + + assert(var); + entry = get_assignment_entry(var, &this->list); + entry->assignment_count++; + } + sig_iter.next(); + } + return visit_continue; +} + /** * Does a copy propagation pass on the code present in the instruction stream. */ -- cgit v1.2.3 From 325a49701fbee14a99a02c69872a1d7577a633cf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 16:03:46 -0700 Subject: glsl2: Fix handling of out values in function inlining. The parameters[i] is our inlined variables representing the parameters, so they are always ir_var_auto. Walk the signature params in handling "out" values like we do for "in" values to find the mode. Fixes (with the previous 2 commits): glsl1-function call with in, out params glsl1-function call with inout params --- src/glsl/ir_function_inlining.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 8c545aaa6b7..a3f7089cdc8 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -169,21 +169,24 @@ ir_call::generate_inline(ir_instruction *next_ir) */ i = 0; param_iter = this->actual_parameters.iterator(); + sig_param_iter = this->callee->parameters.iterator(); for (i = 0; i < num_parameters; i++) { ir_instruction *const param = (ir_instruction *) param_iter.get(); + const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get(); /* Move our param variable into the actual param if it's an 'out' type. */ - if (parameters[i]->mode == ir_var_out || - parameters[i]->mode == ir_var_inout) { + if (sig_param->mode == ir_var_out || + sig_param->mode == ir_var_inout) { ir_assignment *assign; - assign = new(ctx) ir_assignment(param->as_rvalue(), + assign = new(ctx) ir_assignment(param->clone(NULL)->as_rvalue(), new(ctx) ir_dereference_variable(parameters[i]), NULL); next_ir->insert_before(assign); } param_iter.next(); + sig_param_iter.next(); } delete [] parameters; -- cgit v1.2.3 From f15e27ec1d3238df5cd5ab40642e21aea5a162e3 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 14 Jul 2010 12:45:58 -0700 Subject: glcpp: Delete copies of hash_table.c, hash_table.h, and other headers. These were only ever intended to exist in the original, standalone implementation of glcpp, (with the idea of dropping them as soon as the code moved into mesa). The current build system wasn't compiling this C file, but the presence of the header files could cause problems if the two copies diverge in the future. We head those problems off by deleting al of these redundant files. --- src/glsl/glcpp/Makefile.am | 1 - src/glsl/glcpp/hash_table.c | 159 -------------------------- src/glsl/glcpp/hash_table.h | 125 -------------------- src/glsl/glcpp/main/imports.h | 6 - src/glsl/glcpp/main/simple_list.h | 235 -------------------------------------- 5 files changed, 526 deletions(-) delete mode 100644 src/glsl/glcpp/hash_table.c delete mode 100644 src/glsl/glcpp/hash_table.h delete mode 100644 src/glsl/glcpp/main/imports.h delete mode 100644 src/glsl/glcpp/main/simple_list.h diff --git a/src/glsl/glcpp/Makefile.am b/src/glsl/glcpp/Makefile.am index a49fd615cda..00c6c5610eb 100644 --- a/src/glsl/glcpp/Makefile.am +++ b/src/glsl/glcpp/Makefile.am @@ -25,7 +25,6 @@ libglcpp_la_SOURCES = \ glcpp-lex.l \ glcpp-parse.y \ glcpp.h \ - hash_table.c \ pp.c \ xtalloc.c diff --git a/src/glsl/glcpp/hash_table.c b/src/glsl/glcpp/hash_table.c deleted file mode 100644 index e89a2564d76..00000000000 --- a/src/glsl/glcpp/hash_table.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file hash_table.c - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick - */ - -#include "main/imports.h" -#include "main/simple_list.h" -#include "hash_table.h" - -struct node { - struct node *next; - struct node *prev; -}; - -struct hash_table { - hash_func_t hash; - hash_compare_func_t compare; - - unsigned num_buckets; - struct node buckets[1]; -}; - - -struct hash_node { - struct node link; - const void *key; - void *data; -}; - - -struct hash_table * -hash_table_ctor(unsigned num_buckets, hash_func_t hash, - hash_compare_func_t compare) -{ - struct hash_table *ht; - unsigned i; - - - if (num_buckets < 16) { - num_buckets = 16; - } - - ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1) - * sizeof(ht->buckets[0]))); - if (ht != NULL) { - ht->hash = hash; - ht->compare = compare; - ht->num_buckets = num_buckets; - - for (i = 0; i < num_buckets; i++) { - make_empty_list(& ht->buckets[i]); - } - } - - return ht; -} - - -void -hash_table_dtor(struct hash_table *ht) -{ - hash_table_clear(ht); - _mesa_free(ht); -} - - -void -hash_table_clear(struct hash_table *ht) -{ - struct node *node; - struct node *temp; - unsigned i; - - - for (i = 0; i < ht->num_buckets; i++) { - foreach_s(node, temp, & ht->buckets[i]) { - remove_from_list(node); - _mesa_free(node); - } - - assert(is_empty_list(& ht->buckets[i])); - } -} - - -void * -hash_table_find(struct hash_table *ht, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct node *node; - - foreach(node, & ht->buckets[bucket]) { - struct hash_node *hn = (struct hash_node *) node; - - if ((*ht->compare)(hn->key, key) == 0) { - return hn->data; - } - } - - return NULL; -} - - -void -hash_table_insert(struct hash_table *ht, void *data, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct hash_node *node; - - node = _mesa_calloc(sizeof(*node)); - - node->data = data; - node->key = key; - - insert_at_head(& ht->buckets[bucket], & node->link); -} - - -unsigned -hash_table_string_hash(const void *key) -{ - const char *str = (const char *) key; - unsigned hash = 5381; - - - while (*str != '\0') { - hash = (hash * 33) + *str; - str++; - } - - return hash; -} diff --git a/src/glsl/glcpp/hash_table.h b/src/glsl/glcpp/hash_table.h deleted file mode 100644 index b9dd343dee9..00000000000 --- a/src/glsl/glcpp/hash_table.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file hash_table.h - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick - */ - -#ifndef HASH_TABLE_H -#define HASH_TABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -struct hash_table; - -typedef unsigned (*hash_func_t)(const void *key); -typedef int (*hash_compare_func_t)(const void *key1, const void *key2); - -/** - * Hash table constructor - * - * Creates a hash table with the specified number of buckets. The supplied - * \c hash and \c compare routines are used when adding elements to the table - * and when searching for elements in the table. - * - * \param num_buckets Number of buckets (bins) in the hash table. - * \param hash Function used to compute hash value of input keys. - * \param compare Function used to compare keys. - */ -extern struct hash_table *hash_table_ctor(unsigned num_buckets, - hash_func_t hash, hash_compare_func_t compare); - - -/** - * Release all memory associated with a hash table - * - * \warning - * This function cannot release memory occupied either by keys or data. - */ -extern void hash_table_dtor(struct hash_table *ht); - - -/** - * Flush all entries from a hash table - * - * \param ht Table to be cleared of its entries. - */ -extern void hash_table_clear(struct hash_table *ht); - - -/** - * Search a hash table for a specific element - * - * \param ht Table to be searched - * \param key Key of the desired element - * - * \return - * The \c data value supplied to \c hash_table_insert when the element with - * the matching key was added. If no matching key exists in the table, - * \c NULL is returned. - */ -extern void *hash_table_find(struct hash_table *ht, const void *key); - - -/** - * Add an element to a hash table - */ -extern void hash_table_insert(struct hash_table *ht, void *data, - const void *key); - - -/** - * Compute hash value of a string - * - * Computes the hash value of a string using the DJB2 algorithm developed by - * Professor Daniel J. Bernstein. It was published on comp.lang.c once upon - * a time. I was unable to find the original posting in the archives. - * - * \param key Pointer to a NUL terminated string to be hashed. - * - * \sa hash_table_string_compare - */ -extern unsigned hash_table_string_hash(const void *key); - - -/** - * Compare two strings used as keys - * - * This is just a macro wrapper around \c strcmp. - * - * \sa hash_table_string_hash - */ -#define hash_table_string_compare ((hash_compare_func_t) strcmp) - -#ifdef __cplusplus -}; -#endif - -#endif /* HASH_TABLE_H */ diff --git a/src/glsl/glcpp/main/imports.h b/src/glsl/glcpp/main/imports.h deleted file mode 100644 index d2197342c04..00000000000 --- a/src/glsl/glcpp/main/imports.h +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -#define _mesa_malloc(x) malloc(x) -#define _mesa_free(x) free(x) -#define _mesa_calloc(x) calloc(1,x) diff --git a/src/glsl/glcpp/main/simple_list.h b/src/glsl/glcpp/main/simple_list.h deleted file mode 100644 index 5ef39e14cc6..00000000000 --- a/src/glsl/glcpp/main/simple_list.h +++ /dev/null @@ -1,235 +0,0 @@ -/** - * \file simple_list.h - * Simple macros for type-safe, intrusive lists. - * - * Intended to work with a list sentinal which is created as an empty - * list. Insert & delete are O(1). - * - * \author - * (C) 1997, Keith Whitwell - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _SIMPLE_LIST_H -#define _SIMPLE_LIST_H - -struct simple_node { - struct simple_node *next; - struct simple_node *prev; -}; - -/** - * Remove an element from list. - * - * \param elem element to remove. - */ -#define remove_from_list(elem) \ -do { \ - (elem)->next->prev = (elem)->prev; \ - (elem)->prev->next = (elem)->next; \ -} while (0) - -/** - * Insert an element to the list head. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_head(list, elem) \ -do { \ - (elem)->prev = list; \ - (elem)->next = (list)->next; \ - (list)->next->prev = elem; \ - (list)->next = elem; \ -} while(0) - -/** - * Insert an element to the list tail. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_tail(list, elem) \ -do { \ - (elem)->next = list; \ - (elem)->prev = (list)->prev; \ - (list)->prev->next = elem; \ - (list)->prev = elem; \ -} while(0) - -/** - * Move an element to the list head. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_head(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_head(list, elem); \ -} while (0) - -/** - * Move an element to the list tail. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_tail(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_tail(list, elem); \ -} while (0) - -/** - * Consatinate a cyclic list to a list - * - * Appends the sequence of nodes starting with \c tail to the list \c head. - * A "cyclic list" is a list that does not have a sentinal node. This means - * that the data pointed to by \c tail is an actual node, not a dataless - * sentinal. Note that if \c tail constist of a single node, this macro - * behaves identically to \c insert_at_tail - * - * \param head Head of the list to be appended to. This may or may not - * be a cyclic list. - * \param tail Head of the cyclic list to be appended to \c head. - * \param temp Temporary \c simple_list used by the macro - * - * \sa insert_at_tail - */ -#define concat_list_and_cycle(head, tail, temp) \ -do { \ - (head)->prev->next = (tail); \ - (tail)->prev->next = (head); \ - (temp) = (head)->prev; \ - (head)->prev = (tail)->prev; \ - (tail)->prev = (temp); \ -} while (0) - -#define concat_list(head, next_list) \ -do { \ - (next_list)->next->prev = (head)->prev; \ - (next_list)->prev->next = (head); \ - (head)->prev->next = (next_list)->next; \ - (head)->prev = (next_list)->prev; \ -} while (0) - -/** - * Make a empty list empty. - * - * \param sentinal list (sentinal element). - */ -#define make_empty_list(sentinal) \ -do { \ - (sentinal)->next = sentinal; \ - (sentinal)->prev = sentinal; \ -} while (0) - -/** - * Get list first element. - * - * \param list list. - * - * \return pointer to first element. - */ -#define first_elem(list) ((list)->next) - -/** - * Get list last element. - * - * \param list list. - * - * \return pointer to last element. - */ -#define last_elem(list) ((list)->prev) - -/** - * Get next element. - * - * \param elem element. - * - * \return pointer to next element. - */ -#define next_elem(elem) ((elem)->next) - -/** - * Get previous element. - * - * \param elem element. - * - * \return pointer to previous element. - */ -#define prev_elem(elem) ((elem)->prev) - -/** - * Test whether element is at end of the list. - * - * \param list list. - * \param elem element. - * - * \return non-zero if element is at end of list, or zero otherwise. - */ -#define at_end(list, elem) ((elem) == (list)) - -/** - * Test if a list is empty. - * - * \param list list. - * - * \return non-zero if list empty, or zero otherwise. - */ -#define is_empty_list(list) ((list)->next == (list)) - -/** - * Walk through the elements of a list. - * - * \param ptr pointer to the current element. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach(ptr, list) \ - for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) - -/** - * Walk through the elements of a list. - * - * Same as #foreach but lets you unlink the current value during a list - * traversal. Useful for freeing a list, element by element. - * - * \param ptr pointer to the current element. - * \param t temporary pointer. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach_s(ptr, t, list) \ - for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) - -#endif -- cgit v1.2.3 From 41d525f2dfde130b4a1cfa908a729e5a3f79b200 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 14 Jul 2010 14:48:15 -0700 Subject: Build a standalone glcpp binary. This is convenient for testing the preprocessor independent of the rest of mesa, (just run glcpp-test in the src/glsl/glcpp/tests). --- src/glsl/Makefile | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 497f6ca1a0c..7bf95fbfc2d 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -6,13 +6,19 @@ include $(TOP)/configs/current LIBNAME = glsl -C_SOURCES = \ - glcpp/glcpp.c \ +LIBGLCPP_SOURCES = \ glcpp/glcpp-lex.c \ glcpp/glcpp-parse.c \ glcpp/pp.c \ glcpp/xtalloc.c +GLCPP_SOURCES = \ + $(LIBGLCPP_SOURCES) \ + glcpp/glcpp.c + +C_SOURCES = \ + $(LIBGLCPP_SOURCES) + CXX_SOURCES = \ ast_expr.cpp \ ast_function.cpp \ @@ -60,7 +66,8 @@ LIBS = \ $(TOP)/src/glsl/libglsl.a \ $(shell pkg-config --libs talloc) -APPS = glsl_compiler +APPS = glsl_compiler glcpp/glcpp + GLSL2_C_SOURCES = \ ../mesa/shader/hash_table.c \ ../mesa/shader/symbol_table.c @@ -73,6 +80,10 @@ GLSL2_OBJECTS = \ ### Basic defines ### +GLCPP_OBJECTS = \ + $(GLCPP_SOURCES:.c=.o) \ + ../mesa/shader/hash_table.o + OBJECTS = \ $(C_SOURCES:.c=.o) \ $(CXX_SOURCES:.cpp=.o) @@ -117,6 +128,9 @@ install: glsl_compiler: $(GLSL2_OBJECTS) libglsl.a $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) $(LIBS) -o $@ +glcpp/glcpp: $(GLCPP_OBJECTS) libglsl.a + $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) $(LIBS) -o $@ + .cpp.o: $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@ -- cgit v1.2.3 From 3a530b8ef68a40526b33de2af8de85f71ebdb30d Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 19 Jul 2010 17:48:17 -0700 Subject: glcpp: Make test suite report final count of passed/total tests. And report PASS or FAIL for each test along the way as well. --- src/glsl/glcpp/tests/glcpp-test | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/glsl/glcpp/tests/glcpp-test b/src/glsl/glcpp/tests/glcpp-test index 396f6e175e8..82777197150 100755 --- a/src/glsl/glcpp/tests/glcpp-test +++ b/src/glsl/glcpp/tests/glcpp-test @@ -1,7 +1,27 @@ #!/bin/sh +total=0 +pass=0 + for test in *.c; do - echo "Testing $test" + echo -n "Testing $test..." ../glcpp < $test > $test.out - diff -u $test.expected $test.out + total=$((total+1)) + if cmp $test.expected $test.out; then + echo "PASS" + pass=$((pass+1)) + else + echo "FAIL" + diff -u $test.expected $test.out + fi done + +echo "$pass/$total tests returned correct results" +echo "" + +if [ "$pass" = "$total" ] ; then + exit 0 +else + exit 1 +fi + -- cgit v1.2.3 From d1500f8a195b7afe871cd768a5d33ecfecad5f31 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 19 Jul 2010 17:49:23 -0700 Subject: glcpp: Make test suite test for valgrind cleanliness. As it turns out, 4 of our current tests are not valgrind clean, (use after free errors or so), so this will be helpful for investigating and fixing those. --- src/glsl/glcpp/tests/glcpp-test | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/glsl/glcpp/tests/glcpp-test b/src/glsl/glcpp/tests/glcpp-test index 82777197150..cfe7e978786 100755 --- a/src/glsl/glcpp/tests/glcpp-test +++ b/src/glsl/glcpp/tests/glcpp-test @@ -2,7 +2,9 @@ total=0 pass=0 +clean=0 +echo "====== Testing for correctness ======" for test in *.c; do echo -n "Testing $test..." ../glcpp < $test > $test.out @@ -16,10 +18,28 @@ for test in *.c; do fi done +echo "" echo "$pass/$total tests returned correct results" echo "" -if [ "$pass" = "$total" ] ; then +echo "====== Testing for valgrind cleanliness ======" +for test in *.c; do + echo -n "Testing $test with valgrind..." + if valgrind --error-exitcode=1 --log-file=$test.valgrind-errors ../glcpp < $test >/dev/null; then + echo "CLEAN" + clean=$((clean+1)) + rm $test.valgrind-errors + else + echo "ERRORS" + cat $test.valgrind-errors + fi +done + +echo "" +echo "$pass/$total tests returned correct results" +echo "$clean/$total tests are valgrind-clean" + +if [ "$pass" = "$total" ] && [ "$clean" = "$total" ]; then exit 0 else exit 1 -- cgit v1.2.3 From d4f239de6e988a59d4ba3783ea325aa1552c3f5a Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 19 Jul 2010 18:01:43 -0700 Subject: hash_table: Add new hash_table_remove function. To allow for the removal of a single element from a hash table. --- src/mesa/shader/hash_table.c | 17 +++++++++++++++++ src/mesa/shader/hash_table.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/src/mesa/shader/hash_table.c b/src/mesa/shader/hash_table.c index 933e300abdd..f7ef366c1a0 100644 --- a/src/mesa/shader/hash_table.c +++ b/src/mesa/shader/hash_table.c @@ -142,6 +142,23 @@ hash_table_insert(struct hash_table *ht, void *data, const void *key) insert_at_head(& ht->buckets[bucket], & node->link); } +void +hash_table_remove(struct hash_table *ht, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct node *node; + + foreach(node, & ht->buckets[bucket]) { + struct hash_node *hn = (struct hash_node *) node; + + if ((*ht->compare)(hn->key, key) == 0) { + remove_from_list(node); + free(node); + return; + } + } +} unsigned hash_table_string_hash(const void *key) diff --git a/src/mesa/shader/hash_table.h b/src/mesa/shader/hash_table.h index 05526914643..228ab948ff4 100644 --- a/src/mesa/shader/hash_table.h +++ b/src/mesa/shader/hash_table.h @@ -94,6 +94,10 @@ extern void *hash_table_find(struct hash_table *ht, const void *key); extern void hash_table_insert(struct hash_table *ht, void *data, const void *key); +/** + * Remove a specific element from a hash table. + */ +extern void hash_table_remove(struct hash_table *ht, const void *key); /** * Compute hash value of a string -- cgit v1.2.3 From 61ebc01dfecda0963a184e881ea966e2d92f0519 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 19 Jul 2010 18:02:12 -0700 Subject: glcpp: Fix use-after-free error from #undef directive. By taking advantage of the recently-added hash_table_remove function. With this change, all existing tests are now valgrind-clean. --- src/glsl/glcpp/glcpp-parse.y | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index e5544fe29b8..a2b54eff507 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -202,10 +202,7 @@ control_line: | HASH_UNDEF IDENTIFIER NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); if (macro) { - /* XXX: Need hash table to support a real way - * to remove an element rather than prefixing - * a new node with data of NULL like this. */ - hash_table_insert (parser->defines, NULL, $2); + hash_table_remove (parser->defines, $2); talloc_free (macro); } talloc_free ($2); -- cgit v1.2.3 From 17f9beb6c313b41ca08984add7b76ecb84a7339e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 20 Jul 2010 13:16:17 -0700 Subject: glcpp: Support #if(expression) with no intervening space. And add a test case to ensure that this works. --- src/glsl/glcpp/glcpp-lex.l | 2 +- src/glsl/glcpp/tests/066-if-nospace-expression.c | 3 +++ src/glsl/glcpp/tests/066-if-nospace-expression.c.expected | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/glsl/glcpp/tests/066-if-nospace-expression.c create mode 100644 src/glsl/glcpp/tests/066-if-nospace-expression.c.expected diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 53e85556c16..a81c8f92c14 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -99,7 +99,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return HASH_IFNDEF; } -{HASH}if{HSPACE}/.*\n { +{HASH}if{HSPACE}*/[^_a-zA-Z0-9].*\n { yyextra->lexing_if = 1; yyextra->space_tokens = 0; return HASH_IF; diff --git a/src/glsl/glcpp/tests/066-if-nospace-expression.c b/src/glsl/glcpp/tests/066-if-nospace-expression.c new file mode 100644 index 00000000000..3b0b47349d0 --- /dev/null +++ b/src/glsl/glcpp/tests/066-if-nospace-expression.c @@ -0,0 +1,3 @@ +#if(1) +success +#endif diff --git a/src/glsl/glcpp/tests/066-if-nospace-expression.c.expected b/src/glsl/glcpp/tests/066-if-nospace-expression.c.expected new file mode 100644 index 00000000000..0e84a7cda39 --- /dev/null +++ b/src/glsl/glcpp/tests/066-if-nospace-expression.c.expected @@ -0,0 +1,4 @@ + +success + + -- cgit v1.2.3 From 1d7e03e48e87328ce0081021dde133921b78b406 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 20 Jul 2010 14:13:32 -0700 Subject: glcpp: Fix support for nested #ifdef and nested #ifndef Previously, if the outer #ifdef/#ifndef evaluated to false, the inner directive would not be parsed correctly, (the identifier as the subject of the #ifdef/#ifndef would inadvertently be skipped along with the other content correctly being skipped). We fix this by setting the lexing_if state in each case here. We also add a new test to the test suite to ensure that this case is tested. --- src/glsl/glcpp/glcpp-lex.l | 6 ++-- src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c | 40 +++++++++++++++++++++ .../glcpp/tests/067-nested-ifdef-ifndef.c.expected | 41 ++++++++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c create mode 100644 src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index a81c8f92c14..6773832f29d 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -90,16 +90,18 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } {HASH}ifdef/.*\n { + yyextra->lexing_if = 1; yyextra->space_tokens = 0; return HASH_IFDEF; } {HASH}ifndef/.*\n { + yyextra->lexing_if = 1; yyextra->space_tokens = 0; return HASH_IFNDEF; } -{HASH}if{HSPACE}*/[^_a-zA-Z0-9].*\n { +{HASH}if/[^_a-zA-Z0-9].*\n { yyextra->lexing_if = 1; yyextra->space_tokens = 0; return HASH_IF; @@ -122,7 +124,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } /* When skipping (due to an #if 0 or similar) consume anything - * up to a newline. We do this less priroty than any + * up to a newline. We do this with less priority than any * #if-related directive (#if, #elif, #else, #endif), but with * more priority than any other directive or token to avoid * any side-effects from skipped content. diff --git a/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c new file mode 100644 index 00000000000..f46cce4e60a --- /dev/null +++ b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c @@ -0,0 +1,40 @@ +#define D1 +#define D2 + +#define result success + +#ifdef U1 +#ifdef U2 +#undef result +#define result failure +#endif +#endif +result + +#ifndef D1 +#ifndef D2 +#undef result +#define result failure +#endif +#endif +result + +#undef result +#define result failure +#ifdef D1 +#ifdef D2 +#undef result +#define result success +#endif +#endif +result + +#undef result +#define result failure +#ifndef U1 +#ifndef U2 +#undef result +#define result success +#endif +#endif +result diff --git a/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected new file mode 100644 index 00000000000..3340daaa1f9 --- /dev/null +++ b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected @@ -0,0 +1,41 @@ + + + + + + + + + + + +success + + + + + + + +success + + + + + + + + + +success + + + + + + + + + +success + -- cgit v1.2.3 From a9bb4bcde360ef8d0a444bf1c4a7d02a8fdb5fa1 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 20 Jul 2010 15:03:20 -0700 Subject: glcpp-lex: Declare some generated functions to eliminate compiler warnings. It's really a bug in flex that these functions are generated with neither a declaration nor the 'static' keyword, but we can at least avoid the warnings this way. --- src/glsl/glcpp/glcpp-lex.l | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 6773832f29d..29b27693974 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -29,6 +29,11 @@ #include "glcpp.h" #include "glcpp-parse.h" +/* Flex annoyingly generates some functions without making them + * static. Let's declare them here. */ +int glcpp_get_column (yyscan_t yyscanner); +void glcpp_set_column (int column_no , yyscan_t yyscanner); + #define YY_USER_ACTION \ do { \ yylloc->source = 0; \ -- cgit v1.2.3 From fb90560744864e44730330e4c801ac47c4ece0e1 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 20 Jul 2010 15:53:14 -0700 Subject: glcpp: Avoid warnings in generated flex code. We define the YY_NO_INPUT macro to avoid one needless function being generated. for the other needless functions, (yyunput and yy_top_state), we add a new UNREACHABLE start condition and call these functions from an action there. This doesn't change functionality at all, (since we never enter the UNREACHABLE start condition), but makes the compiler stop complaining about these two functions being defined but not used. --- src/glsl/glcpp/glcpp-lex.l | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 29b27693974..a4c891bdc69 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -34,6 +34,8 @@ int glcpp_get_column (yyscan_t yyscanner); void glcpp_set_column (int column_no , yyscan_t yyscanner); +#define YY_NO_INPUT + #define YY_USER_ACTION \ do { \ yylloc->source = 0; \ @@ -49,7 +51,7 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner); %option prefix="glcpp_" %option stack -%x DONE COMMENT +%x DONE COMMENT UNREACHABLE SPACE [[:space:]] NONSPACE [^[:space:]] @@ -264,6 +266,15 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return NEWLINE; } + /* We don't actually use the UNREACHABLE start condition. We + only have this action here so that we can pretend to call some + generated functions, (to avoid "defined but not used" + warnings. */ +. { + unput('.'); + yy_top_state(yyextra); +} + %% void -- cgit v1.2.3 From d80dcaf427e12a5cba9cfc5bcd1b485572a2714b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 20 Jul 2010 15:55:21 -0700 Subject: glcpp: Add static keyword to several functions in the parser. This quiets warnings about missing declarations otherwise. --- src/glsl/glcpp/glcpp-parse.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index a2b54eff507..c37c9bcff0b 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -692,7 +692,7 @@ _token_list_append_list (token_list_t *list, token_list_t *tail) list->non_space_tail = tail->non_space_tail; } -token_list_t * +static token_list_t * _token_list_copy (void *ctx, token_list_t *other) { token_list_t *copy; @@ -708,7 +708,7 @@ _token_list_copy (void *ctx, token_list_t *other) return copy; } -void +static void _token_list_trim_trailing_space (token_list_t *list) { token_node_t *tail, *next; @@ -1410,7 +1410,7 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, _token_list_print (parser, list); } -void +static void _check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc, const char *identifier) { -- cgit v1.2.3 From 942ccc517012e360a7e30d3322331c8450dda022 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 20 Jul 2010 15:56:02 -0700 Subject: glcpp: Add missing include in xtalloc.c Without this, the compiler was legitimately complaining about missing declarations for all of the functions being defined here. --- src/glsl/glcpp/xtalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/glcpp/xtalloc.c b/src/glsl/glcpp/xtalloc.c index 656ac2d6cb5..a20ea8b93fa 100644 --- a/src/glsl/glcpp/xtalloc.c +++ b/src/glsl/glcpp/xtalloc.c @@ -21,7 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ -#include +#include "glcpp.h" void * xtalloc_named_const (const void *context, size_t size, const char *name) -- cgit v1.2.3 From e1acbfca322c4ac720707ec8d3fda08fab65a30b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 20 Jul 2010 16:44:03 -0700 Subject: glcpp: Avoid accidental token pasting in preprocessed result. Consider this test case: #define EMPTY int foo = 1+EMPTY+4; The expression should compile as the sequence of tokens 1, PLUS, UNARY_POSITIVE, 4. But glcpp has been failing for this case since it results in the string "1++4" which a compiler correctly sees as a syntax error, (1, POST_INCREMENT, 4). We fix this by changing any macro with an empty definition to result in a single SPACE token rather than nothing. This then gives "1+ +4" which compiles correctly. This commit does touch up the two existing test cases which already have empty macros, (to add the space to the expected result). It also adds a new test case to exercise the above scenario. --- src/glsl/glcpp/glcpp-parse.y | 21 ++++++++++++++++++--- src/glsl/glcpp/tests/008-define-empty.c.expected | 2 +- .../glcpp/tests/011-define-func-empty.c.expected | 2 +- src/glsl/glcpp/tests/068-accidental-pasting.c | 11 +++++++++++ .../glcpp/tests/068-accidental-pasting.c.expected | 12 ++++++++++++ 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 src/glsl/glcpp/tests/068-accidental-pasting.c create mode 100644 src/glsl/glcpp/tests/068-accidental-pasting.c.expected diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index c37c9bcff0b..e4dcc76e0a7 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -1048,6 +1048,19 @@ _arguments_parse (argument_list_t *arguments, return FUNCTION_STATUS_SUCCESS; } +static token_list_t * +_token_list_create_with_one_space (void *ctx) +{ + token_list_t *list; + token_t *space; + + list = _token_list_create (ctx); + space = _token_create_ival (list, SPACE, SPACE); + _token_list_append (list, space); + + return list; +} + /* This is a helper function that's essentially part of the * implementation of _glcpp_parser_expand_node. It shouldn't be called * except for by that function. @@ -1097,9 +1110,10 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, return NULL; } + /* Replace a macro defined as empty with a SPACE token. */ if (macro->replacements == NULL) { talloc_free (arguments); - return _token_list_create (parser); + return _token_list_create_with_one_space (parser); } if (! ((_argument_list_length (arguments) == @@ -1203,7 +1217,7 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, * * Otherwise, returns the token list that results from the expansion * and sets *last to the last node in the list that was consumed by - * the expansion. Specificallty, *last will be set as follows: + * the expansion. Specifically, *last will be set as follows: * * As 'node' in the case of object-like macro expansion. * @@ -1262,8 +1276,9 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser, { *last = node; + /* Replace a macro defined as empty with a SPACE token. */ if (macro->replacements == NULL) - return _token_list_create (parser); + return _token_list_create_with_one_space (parser); return _token_list_copy (parser, macro->replacements); } diff --git a/src/glsl/glcpp/tests/008-define-empty.c.expected b/src/glsl/glcpp/tests/008-define-empty.c.expected index b28b04f6431..c0f53d75c71 100644 --- a/src/glsl/glcpp/tests/008-define-empty.c.expected +++ b/src/glsl/glcpp/tests/008-define-empty.c.expected @@ -1,3 +1,3 @@ - + diff --git a/src/glsl/glcpp/tests/011-define-func-empty.c.expected b/src/glsl/glcpp/tests/011-define-func-empty.c.expected index b28b04f6431..c0f53d75c71 100644 --- a/src/glsl/glcpp/tests/011-define-func-empty.c.expected +++ b/src/glsl/glcpp/tests/011-define-func-empty.c.expected @@ -1,3 +1,3 @@ - + diff --git a/src/glsl/glcpp/tests/068-accidental-pasting.c b/src/glsl/glcpp/tests/068-accidental-pasting.c new file mode 100644 index 00000000000..699ac5144e5 --- /dev/null +++ b/src/glsl/glcpp/tests/068-accidental-pasting.c @@ -0,0 +1,11 @@ +#define empty +empty> +>empty= +=empty= +!empty= +&empty& +|empty| ++empty+ +-empty- diff --git a/src/glsl/glcpp/tests/068-accidental-pasting.c.expected b/src/glsl/glcpp/tests/068-accidental-pasting.c.expected new file mode 100644 index 00000000000..ce41cd6e524 --- /dev/null +++ b/src/glsl/glcpp/tests/068-accidental-pasting.c.expected @@ -0,0 +1,12 @@ + +< < +< = +> > +> = += = +! = +& & +| | ++ + +- - + -- cgit v1.2.3 From e340854115f2562109c91fa908ffe6628432f989 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 12 Jul 2010 13:55:10 -0700 Subject: glsl2: Move constant_expression_value method to ir_rvalue. This prevents top-level callers from asking for the value of something that is guaranteed not to have one. --- src/glsl/ir.h | 4 ++-- src/glsl/ir_constant_expression.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 1d667be89c0..b6cd1bae31c 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -71,8 +71,6 @@ public: enum ir_node_type ir_type; const struct glsl_type *type; - class ir_constant *constant_expression_value(); - /** ir_print_visitor helper for debugging. */ void print(void) const; @@ -114,6 +112,8 @@ protected: class ir_rvalue : public ir_instruction { public: + class ir_constant *constant_expression_value(); + virtual ir_rvalue *clone(struct hash_table *) const = 0; virtual ir_rvalue * as_rvalue() diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index ca834978f47..44f4a642099 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -96,7 +96,7 @@ public: ir_constant * -ir_instruction::constant_expression_value() +ir_rvalue::constant_expression_value() { ir_constant_visitor visitor; -- cgit v1.2.3 From fb2ffd2846b48cb50128fb74df56f2ee63179832 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 15 Jul 2010 10:09:09 -0700 Subject: ir_constant_expression: Convert from a visitor to a virtual function. The constant_expression_wrapper was already the only external API, and much of the internal code used it anyway. Also, it wouldn't ever visit non-rvalue ir_instructions, so using a visitor seemed a bit unnecessary. This uses "ir_foo *ir = this;" lines to avoid code churn. These should be removed. --- src/glsl/ir.h | 22 +++- src/glsl/ir_constant_expression.cpp | 207 +++++++----------------------------- 2 files changed, 60 insertions(+), 169 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index b6cd1bae31c..3be096270d8 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -112,10 +112,10 @@ protected: class ir_rvalue : public ir_instruction { public: - class ir_constant *constant_expression_value(); - virtual ir_rvalue *clone(struct hash_table *) const = 0; + virtual ir_constant *constant_expression_value() = 0; + virtual ir_rvalue * as_rvalue() { return this; @@ -511,6 +511,8 @@ public: virtual ir_assignment *clone(struct hash_table *ht) const; + virtual ir_constant *constant_expression_value(); + virtual void accept(ir_visitor *v) { v->visit(this); @@ -651,6 +653,8 @@ public: virtual ir_expression *clone(struct hash_table *ht) const; + virtual ir_constant *constant_expression_value(); + static unsigned int get_num_operands(ir_expression_operation); unsigned int get_num_operands() const { @@ -695,6 +699,8 @@ public: virtual ir_call *clone(struct hash_table *ht) const; + virtual ir_constant *constant_expression_value(); + virtual ir_call *as_call() { return this; @@ -929,6 +935,8 @@ public: virtual ir_texture *clone(struct hash_table *) const; + virtual ir_constant *constant_expression_value(); + virtual void accept(ir_visitor *v) { v->visit(this); @@ -1019,6 +1027,8 @@ public: virtual ir_swizzle *clone(struct hash_table *) const; + virtual ir_constant *constant_expression_value(); + virtual ir_swizzle *as_swizzle() { return this; @@ -1083,6 +1093,8 @@ public: virtual ir_dereference_variable *clone(struct hash_table *) const; + virtual ir_constant *constant_expression_value(); + virtual ir_dereference_variable *as_dereference_variable() { return this; @@ -1129,6 +1141,8 @@ public: virtual ir_dereference_array *clone(struct hash_table *) const; + virtual ir_constant *constant_expression_value(); + virtual ir_dereference_array *as_dereference_array() { return this; @@ -1165,6 +1179,8 @@ public: virtual ir_dereference_record *clone(struct hash_table *) const; + virtual ir_constant *constant_expression_value(); + /** * Get the variable that is ultimately referenced by an r-value */ @@ -1223,6 +1239,8 @@ public: virtual ir_constant *clone(struct hash_table *) const; + virtual ir_constant *constant_expression_value(); + virtual ir_constant *as_constant() { return this; diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 44f4a642099..e3e717a14e6 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -41,97 +41,10 @@ #define min(x,y) (x) < (y) ? (x) : (y) #define max(x,y) (x) > (y) ? (x) : (y) -/** - * Visitor class for evaluating constant expressions - */ -class ir_constant_visitor : public ir_visitor { -public: - ir_constant_visitor() - : value(NULL) - { - /* empty */ - } - - virtual ~ir_constant_visitor() - { - /* empty */ - } - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_texture *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_discard *); - virtual void visit(ir_if *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - /*@}*/ - - /** - * Value of the constant expression. - * - * \note - * This field will be \c NULL if the expression is not constant valued. - */ - /* FINIHSME: This cannot hold values for constant arrays or structures. */ - ir_constant *value; -}; - - ir_constant * -ir_rvalue::constant_expression_value() -{ - ir_constant_visitor visitor; - - this->accept(& visitor); - return visitor.value; -} - - -void -ir_constant_visitor::visit(ir_variable *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_function_signature *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_function *ir) +ir_expression::constant_expression_value() { - (void) ir; - value = NULL; -} - -void -ir_constant_visitor::visit(ir_expression *ir) -{ - value = NULL; + ir_expression *ir = this; ir_constant *op[2] = { NULL, NULL }; ir_constant_data data; @@ -140,7 +53,7 @@ ir_constant_visitor::visit(ir_expression *ir) for (unsigned operand = 0; operand < ir->get_num_operands(); operand++) { op[operand] = ir->operands[operand]->constant_expression_value(); if (!op[operand]) - return; + return NULL; } if (op[1] != NULL) @@ -735,30 +648,28 @@ ir_constant_visitor::visit(ir_expression *ir) default: /* FINISHME: Should handle all expression types. */ - return; + return NULL; } void *ctx = talloc_parent(ir); - this->value = new(ctx) ir_constant(ir->type, &data); + return new(ctx) ir_constant(ir->type, &data); } -void -ir_constant_visitor::visit(ir_texture *ir) +ir_constant * +ir_texture::constant_expression_value() { - // FINISHME: Do stuff with texture lookups - (void) ir; - value = NULL; + /* texture lookups aren't constant expressions */ + return NULL; } -void -ir_constant_visitor::visit(ir_swizzle *ir) +ir_constant * +ir_swizzle::constant_expression_value() { + ir_swizzle *ir = this; ir_constant *v = ir->val->constant_expression_value(); - this->value = NULL; - if (v != NULL) { ir_constant_data data; @@ -777,31 +688,30 @@ ir_constant_visitor::visit(ir_swizzle *ir) } void *ctx = talloc_parent(ir); - this->value = new(ctx) ir_constant(ir->type, &data); + return new(ctx) ir_constant(ir->type, &data); } + return NULL; } -void -ir_constant_visitor::visit(ir_dereference_variable *ir) +ir_constant * +ir_dereference_variable::constant_expression_value() { - value = NULL; - - ir_variable *var = ir->variable_referenced(); + ir_variable *var = this->variable_referenced(); if (var && var->constant_value) - value = var->constant_value->clone(NULL); + return var->constant_value->clone(NULL); + return NULL; } -void -ir_constant_visitor::visit(ir_dereference_array *ir) +ir_constant * +ir_dereference_array::constant_expression_value() { + ir_dereference_array *ir = this; void *ctx = talloc_parent(ir); ir_constant *array = ir->array->constant_expression_value(); ir_constant *idx = ir->array_index->constant_expression_value(); - this->value = NULL; - if ((array != NULL) && (idx != NULL)) { if (array->type->is_matrix()) { /* Array access of a matrix results in a vector. @@ -836,85 +746,48 @@ ir_constant_visitor::visit(ir_dereference_array *ir) break; } - this->value = new(ctx) ir_constant(column_type, &data); + return new(ctx) ir_constant(column_type, &data); } else if (array->type->is_vector()) { const unsigned component = idx->value.u[0]; - this->value = new(ctx) ir_constant(array, component); + return new(ctx) ir_constant(array, component); } else { /* FINISHME: Handle access of constant arrays. */ } } + return NULL; } -void -ir_constant_visitor::visit(ir_dereference_record *ir) +ir_constant * +ir_dereference_record::constant_expression_value() { + ir_dereference_record *ir = this; ir_constant *v = ir->record->constant_expression_value(); - this->value = (v != NULL) ? v->get_record_field(ir->field) : NULL; -} - - -void -ir_constant_visitor::visit(ir_assignment *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_constant *ir) -{ - value = ir; -} - - -void -ir_constant_visitor::visit(ir_call *ir) -{ - (void) ir; - value = NULL; -} - - -void -ir_constant_visitor::visit(ir_return *ir) -{ - (void) ir; - value = NULL; + return (v != NULL) ? v->get_record_field(ir->field) : NULL; } -void -ir_constant_visitor::visit(ir_discard *ir) +ir_constant * +ir_assignment::constant_expression_value() { - (void) ir; - value = NULL; + /* FINISHME: Handle CEs involving assignment (return RHS) */ + return NULL; } -void -ir_constant_visitor::visit(ir_if *ir) +ir_constant * +ir_constant::constant_expression_value() { - (void) ir; - value = NULL; + return this; } -void -ir_constant_visitor::visit(ir_loop *ir) +ir_constant * +ir_call::constant_expression_value() { - (void) ir; - value = NULL; + /* FINISHME: Handle CEs involving builtin function calls. */ + return NULL; } - -void -ir_constant_visitor::visit(ir_loop_jump *ir) -{ - (void) ir; - value = NULL; -} -- cgit v1.2.3 From 98f32a13bef1eef732304eb8e2781e08835ff69a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 15 Jul 2010 10:20:51 -0700 Subject: ir_constant_expression: Use "this" pointer directly. In ir_expression's signature, I replaced ir->operands[i] with op[i] as it is more concise; an assertion already ensures these are equal. --- src/glsl/ir_constant_expression.cpp | 132 +++++++++++++++++------------------- 1 file changed, 64 insertions(+), 68 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index e3e717a14e6..186d0c48c12 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -44,14 +44,13 @@ ir_constant * ir_expression::constant_expression_value() { - ir_expression *ir = this; ir_constant *op[2] = { NULL, NULL }; ir_constant_data data; memset(&data, 0, sizeof(data)); - for (unsigned operand = 0; operand < ir->get_num_operands(); operand++) { - op[operand] = ir->operands[operand]->constant_expression_value(); + for (unsigned operand = 0; operand < this->get_num_operands(); operand++) { + op[operand] = this->operands[operand]->constant_expression_value(); if (!op[operand]) return NULL; } @@ -74,23 +73,23 @@ ir_expression::constant_expression_value() components = op[1]->type->components(); } - switch (ir->operation) { + switch (this->operation) { case ir_unop_logic_not: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) + for (unsigned c = 0; c < op[0]->type->components(); c++) data.b[c] = !op[0]->value.b[c]; break; case ir_unop_f2i: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.i[c] = op[0]->value.f[c]; } break; case ir_unop_i2f: assert(op[0]->type->base_type == GLSL_TYPE_UINT || op[0]->type->base_type == GLSL_TYPE_INT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { if (op[0]->type->base_type == GLSL_TYPE_INT) data.f[c] = op[0]->value.i[c]; else @@ -99,53 +98,53 @@ ir_expression::constant_expression_value() break; case ir_unop_b2f: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = op[0]->value.b[c] ? 1.0 : 0.0; } break; case ir_unop_f2b: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.b[c] = bool(op[0]->value.f[c]); } break; case ir_unop_b2i: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.u[c] = op[0]->value.b[c] ? 1 : 0; } break; case ir_unop_i2b: assert(op[0]->type->is_integer()); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.b[c] = bool(op[0]->value.u[c]); } break; case ir_unop_trunc: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = truncf(op[0]->value.f[c]); } break; case ir_unop_ceil: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = ceilf(op[0]->value.f[c]); } break; case ir_unop_floor: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = floorf(op[0]->value.f[c]); } break; case ir_unop_fract: - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->type->base_type) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (this->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = 0; break; @@ -163,21 +162,21 @@ ir_expression::constant_expression_value() case ir_unop_sin: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = sinf(op[0]->value.f[c]); } break; case ir_unop_cos: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = cosf(op[0]->value.f[c]); } break; case ir_unop_neg: - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->type->base_type) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (this->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = -op[0]->value.u[c]; break; @@ -194,8 +193,8 @@ ir_expression::constant_expression_value() break; case ir_unop_abs: - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->type->base_type) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (this->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = op[0]->value.u[c]; break; @@ -214,8 +213,8 @@ ir_expression::constant_expression_value() break; case ir_unop_sign: - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->type->base_type) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (this->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = op[0]->value.i[c] > 0; break; @@ -233,8 +232,8 @@ ir_expression::constant_expression_value() case ir_unop_rcp: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->type->base_type) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (this->type->base_type) { case GLSL_TYPE_UINT: if (op[0]->value.u[c] != 0.0) data.u[c] = 1 / op[0]->value.u[c]; @@ -255,42 +254,42 @@ ir_expression::constant_expression_value() case ir_unop_rsq: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = 1.0 / sqrtf(op[0]->value.f[c]); } break; case ir_unop_sqrt: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = sqrtf(op[0]->value.f[c]); } break; case ir_unop_exp: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = expf(op[0]->value.f[c]); } break; case ir_unop_exp2: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = exp2f(op[0]->value.f[c]); } break; case ir_unop_log: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = logf(op[0]->value.f[c]); } break; case ir_unop_log2: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = log2f(op[0]->value.f[c]); } break; @@ -298,14 +297,14 @@ ir_expression::constant_expression_value() case ir_unop_dFdx: case ir_unop_dFdy: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = 0.0; } break; case ir_binop_pow: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { data.f[c] = powf(op[0]->value.f[c], op[1]->value.f[c]); } break; @@ -314,7 +313,7 @@ ir_expression::constant_expression_value() assert(op[0]->type->is_vector() && op[1]->type->is_vector()); data.f[0] = 0; for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.u[0] += op[0]->value.u[c] * op[1]->value.u[c]; break; @@ -336,7 +335,7 @@ ir_expression::constant_expression_value() c < components; c0 += c0_inc, c1 += c1_inc, c++) { - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = min(op[0]->value.u[c0], op[1]->value.u[c1]); break; @@ -358,7 +357,7 @@ ir_expression::constant_expression_value() c < components; c0 += c0_inc, c1 += c1_inc, c++) { - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = max(op[0]->value.u[c0], op[1]->value.u[c1]); break; @@ -391,7 +390,7 @@ ir_expression::constant_expression_value() c < components; c0 += c0_inc, c1 += c1_inc, c++) { - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = op[0]->value.u[c0] + op[1]->value.u[c1]; break; @@ -413,7 +412,7 @@ ir_expression::constant_expression_value() c < components; c0 += c0_inc, c1 += c1_inc, c++) { - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = op[0]->value.u[c0] - op[1]->value.u[c1]; break; @@ -437,7 +436,7 @@ ir_expression::constant_expression_value() c < components; c0 += c0_inc, c1 += c1_inc, c++) { - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = op[0]->value.u[c0] * op[1]->value.u[c1]; break; @@ -483,7 +482,7 @@ ir_expression::constant_expression_value() c < components; c0 += c0_inc, c1 += c1_inc, c++) { - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = op[0]->value.u[c0] / op[1]->value.u[c1]; break; @@ -505,7 +504,7 @@ ir_expression::constant_expression_value() c < components; c0 += c0_inc, c1 += c1_inc, c++) { - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.u[c] = op[0]->value.u[c0] % op[1]->value.u[c1]; break; @@ -528,22 +527,22 @@ ir_expression::constant_expression_value() case ir_binop_logic_and: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) + for (unsigned c = 0; c < op[0]->type->components(); c++) data.b[c] = op[0]->value.b[c] && op[1]->value.b[c]; break; case ir_binop_logic_xor: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) + for (unsigned c = 0; c < op[0]->type->components(); c++) data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c]; break; case ir_binop_logic_or: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) + for (unsigned c = 0; c < op[0]->type->components(); c++) data.b[c] = op[0]->value.b[c] || op[1]->value.b[c]; break; case ir_binop_less: - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = op[0]->value.u[0] < op[1]->value.u[0]; break; @@ -558,7 +557,7 @@ ir_expression::constant_expression_value() } break; case ir_binop_greater: - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = op[0]->value.u[0] > op[1]->value.u[0]; break; @@ -573,7 +572,7 @@ ir_expression::constant_expression_value() } break; case ir_binop_lequal: - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0]; break; @@ -588,7 +587,7 @@ ir_expression::constant_expression_value() } break; case ir_binop_gequal: - switch (ir->operands[0]->type->base_type) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0]; break; @@ -605,8 +604,8 @@ ir_expression::constant_expression_value() case ir_binop_equal: data.b[0] = true; - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = data.b[0] && op[0]->value.u[c] == op[1]->value.u[c]; break; @@ -626,8 +625,8 @@ ir_expression::constant_expression_value() break; case ir_binop_nequal: data.b[0] = false; - for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) { - switch (ir->operands[0]->type->base_type) { + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: data.b[0] = data.b[0] || op[0]->value.u[c] != op[1]->value.u[c]; break; @@ -651,8 +650,8 @@ ir_expression::constant_expression_value() return NULL; } - void *ctx = talloc_parent(ir); - return new(ctx) ir_constant(ir->type, &data); + void *ctx = talloc_parent(this); + return new(ctx) ir_constant(this->type, &data); } @@ -667,17 +666,16 @@ ir_texture::constant_expression_value() ir_constant * ir_swizzle::constant_expression_value() { - ir_swizzle *ir = this; - ir_constant *v = ir->val->constant_expression_value(); + ir_constant *v = this->val->constant_expression_value(); if (v != NULL) { ir_constant_data data; const unsigned swiz_idx[4] = { - ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w + this->mask.x, this->mask.y, this->mask.z, this->mask.w }; - for (unsigned i = 0; i < ir->mask.num_components; i++) { + for (unsigned i = 0; i < this->mask.num_components; i++) { switch (v->type->base_type) { case GLSL_TYPE_UINT: case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break; @@ -687,8 +685,8 @@ ir_swizzle::constant_expression_value() } } - void *ctx = talloc_parent(ir); - return new(ctx) ir_constant(ir->type, &data); + void *ctx = talloc_parent(this); + return new(ctx) ir_constant(this->type, &data); } return NULL; } @@ -707,10 +705,9 @@ ir_dereference_variable::constant_expression_value() ir_constant * ir_dereference_array::constant_expression_value() { - ir_dereference_array *ir = this; - void *ctx = talloc_parent(ir); - ir_constant *array = ir->array->constant_expression_value(); - ir_constant *idx = ir->array_index->constant_expression_value(); + void *ctx = talloc_parent(this); + ir_constant *array = this->array->constant_expression_value(); + ir_constant *idx = this->array_index->constant_expression_value(); if ((array != NULL) && (idx != NULL)) { if (array->type->is_matrix()) { @@ -762,10 +759,9 @@ ir_dereference_array::constant_expression_value() ir_constant * ir_dereference_record::constant_expression_value() { - ir_dereference_record *ir = this; - ir_constant *v = ir->record->constant_expression_value(); + ir_constant *v = this->record->constant_expression_value(); - return (v != NULL) ? v->get_record_field(ir->field) : NULL; + return (v != NULL) ? v->get_record_field(this->field) : NULL; } -- cgit v1.2.3 From e4768eecd5da6f9e955aa7c3892810813623f0dc Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 15 Jul 2010 10:27:53 -0700 Subject: ir_constant_expression: Remove pointless use of variable_referenced. ir_dereference_variable always references an ir_variable, so there's no point in calling a function and NULL-checking the result. --- src/glsl/ir_constant_expression.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 186d0c48c12..cb07f381281 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -695,10 +695,7 @@ ir_swizzle::constant_expression_value() ir_constant * ir_dereference_variable::constant_expression_value() { - ir_variable *var = this->variable_referenced(); - if (var && var->constant_value) - return var->constant_value->clone(NULL); - return NULL; + return var->constant_value ? var->constant_value->clone(NULL) : NULL; } -- cgit v1.2.3 From 2b7c42b40ae459f7b290eb134d6dabd075aab9f0 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 16 Jul 2010 18:28:44 -0700 Subject: glsl2: Disallow non-constant array indexing for unsized arrays. Fixes piglit test unsized-array-non-const-index.vert. --- src/glsl/ast_to_hir.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 98090d2b01b..41371e75367 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1233,6 +1233,8 @@ ast_expression::hir(exec_list *instructions, if ((v != NULL) && (unsigned(idx) > v->max_array_access)) v->max_array_access = idx; } + } else if (array->type->array_size() == 0) { + _mesa_glsl_error(&loc, state, "unsized array index must be constant"); } if (error_emitted) -- cgit v1.2.3 From 1036a7ebae2da03efd1b990037b6fd102d4cc5ca Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 17 Jul 2010 22:42:35 -0700 Subject: glsl2: Remove incorrect assertion in the parser. This assertion is triggered by method calls (i.e. array.length()), where subexpressions[1] is an ast_function_call expression. Since the assertion itself had a comment saying it could be removed eventually, simply do so. Causes negative glslparser tests array-length-110.frag, array-length-args.frag, and array-length-unsized.frag to pass, but only because the length() method is not supported yet. --- src/glsl/glsl_parser.ypp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index f85b419271d..6782255d45c 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -304,12 +304,6 @@ postfix_expression: } | function_call { - /* Function call parameters used to be stored as a circular list in - * subexpressions[1]. They are now stored as a regular list in - * expressions. This assertion validates that the old code was - * correctly converted. It can eventually be removed. - */ - assert($1->subexpressions[1] == NULL); $$ = $1; } | postfix_expression '.' IDENTIFIER -- cgit v1.2.3 From 094cf8c199930d958d9e1139467eb8579d082df6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 17 Jul 2010 22:50:26 -0700 Subject: glsl2: Add support for the .length() method on arrays. Fixes piglit test glsl-array-length, and provides proper error messages for negative piglit tests array-length-110.frag, array-length-unsized.frag, and array-length-args.frag. --- src/glsl/hir_field_selection.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp index 5500e09d7e6..db1e06932f4 100644 --- a/src/glsl/hir_field_selection.cpp +++ b/src/glsl/hir_field_selection.cpp @@ -71,6 +71,28 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, "structure", expr->primary_expression.identifier); } + } else if (expr->subexpressions[1] != NULL) { + /* Handle "method calls" in GLSL 1.20 - namely, array.length() */ + if (state->language_version < 120) + _mesa_glsl_error(&loc, state, "Methods not supported in GLSL 1.10."); + + ast_expression *call = expr->subexpressions[1]; + assert(call->oper == ast_function_call); + + const char *method; + method = call->subexpressions[0]->primary_expression.identifier; + + if (op->type->is_array() && strcmp(method, "length") == 0) { + if (!call->expressions.is_empty()) + _mesa_glsl_error(&loc, state, "length method takes no arguments."); + + if (op->type->array_size() == 0) + _mesa_glsl_error(&loc, state, "length called on unsized array."); + + result = new(ctx) ir_constant(op->type->array_size()); + } else { + _mesa_glsl_error(&loc, state, "Unknown method: `%s'.", method); + } } else { _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " "non-structure / non-vector.", -- cgit v1.2.3 From b6e92ad7da9d4f00607caca90bd0b8853623a493 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 16:38:23 -0700 Subject: glsl2: Don't claim a match on structure types with different field names. We regularly do lookups on the field names of the structure to find the types within the struct, so returning a structure type with bad names will lead to lots of error types being found. --- src/glsl/glsl_types.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index d6799cf4283..6ca141ef481 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -438,10 +438,13 @@ glsl_type::record_key_compare(const void *a, const void *b) if (key1->length != key2->length) return 1; - for (unsigned i = 0; i < key1->length; i++) - /* FINISHME: Is the name of the structure field also significant? */ + for (unsigned i = 0; i < key1->length; i++) { if (key1->fields.structure[i].type != key2->fields.structure[i].type) return 1; + if (strcmp(key1->fields.structure[i].name, + key2->fields.structure[i].name) != 0) + return 1; + } return 0; } -- cgit v1.2.3 From 21b0dbd79937e9d6787f045af7d60d4b6c649ec8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 16:47:25 -0700 Subject: glsl2: talloc the glsl_struct_field[] we use to look up structure types. Since the types are singletons across the lifetime of the compiler, repeatedly compiling a program with the same structure type defined would drop a copy of the array on the floor per compile. This is a bit tricky because the static GLSL types are not called with the talloc-based new, so we have to use the global type context, which may not be initialized yet. --- src/glsl/ast_to_hir.cpp | 4 ++-- src/glsl/glsl_types.cpp | 15 ++++++++++++++- src/glsl/glsl_types.h | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 41371e75367..f20c7ead336 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2471,8 +2471,8 @@ ast_struct_specifier::hir(exec_list *instructions, * the types to HIR. This ensures that structure definitions embedded in * other structure definitions are processed. */ - glsl_struct_field *const fields = (glsl_struct_field *) - malloc(sizeof(*fields) * decl_count); + glsl_struct_field *const fields = talloc_array(state, glsl_struct_field, + decl_count); unsigned i = 0; foreach_list_typed (ast_declarator_list, decl_list, link, diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 6ca141ef481..77c591ed691 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -75,7 +75,20 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, name(name), length(num_fields) { - this->fields.structure = fields; + unsigned int i; + + if (glsl_type::ctx == NULL) { + glsl_type::ctx = talloc_init("glsl_type"); + assert(glsl_type::ctx != NULL); + } + + this->fields.structure = talloc_array(glsl_type::ctx, + glsl_struct_field, length); + for (i = 0; i < length; i++) { + this->fields.structure[i].type = fields[i].type; + this->fields.structure[i].name = talloc_strdup(this->fields.structure, + fields[i].name); + } } static void diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index e869071cab0..8ba9b5ff635 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -136,7 +136,7 @@ struct glsl_type { union { const struct glsl_type *array; /**< Type of array elements. */ const struct glsl_type *parameters; /**< Parameters to function. */ - const struct glsl_struct_field *structure;/**< List of struct fields. */ + struct glsl_struct_field *structure; /**< List of struct fields. */ } fields; -- cgit v1.2.3 From fade78edcbff1e0ae24a1e2c455be2cc7932ee9c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 17:17:47 -0700 Subject: glsl2: strdup the field names used in dereference_record. Otherwise, after linking and freeing the old data, the pointer would dangle. Partial fix for glsl1-struct*. --- src/glsl/ir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 1648848ecb6..ba8ee7b9ac9 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -514,7 +514,7 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value, { this->ir_type = ir_type_dereference_record; this->record = value; - this->field = field; + this->field = talloc_strdup(this, field); this->type = (this->record != NULL) ? this->record->type->field_type(field) : glsl_type::error_type; } @@ -527,7 +527,7 @@ ir_dereference_record::ir_dereference_record(ir_variable *var, this->ir_type = ir_type_dereference_record; this->record = new(ctx) ir_dereference_variable(var); - this->field = field; + this->field = talloc_strdup(this, field); this->type = (this->record != NULL) ? this->record->type->field_type(field) : glsl_type::error_type; } -- cgit v1.2.3 From f141fa63a4391621cc92cd2c39724a952b297a58 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 17:18:57 -0700 Subject: glsl2: Check that nodes in a valid tree aren't error-type. We're good at propagating error types around, but finding when the first one was triggered can be painful if we aren't paying attention. --- src/glsl/ir_validate.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 8a567954a1f..c05edf2ee3d 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -37,7 +37,7 @@ #include "ir.h" #include "ir_hierarchical_visitor.h" #include "hash_table.h" - +#include "glsl_types.h" class ir_validate : public ir_hierarchical_visitor { public: @@ -179,6 +179,7 @@ check_node_type(ir_instruction *ir, void *data) printf("Instruction node with unset type\n"); ir->print(); printf("\n"); } + assert(ir->type != glsl_type::error_type); } void -- cgit v1.2.3 From 1124e5a3cbba839ffd968742bfa3295c8de5498c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Jul 2010 17:19:57 -0700 Subject: ir_to_mesa: Validate the linked shaders as well. This caught the failure in cloning of ir_dereference_record. --- src/mesa/shader/ir_to_mesa.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 5803960d444..352b496625d 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2037,6 +2037,8 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, default: assert(!"should not be reached"); break; } + validate_ir_tree(shader->ir); + prog = ctx->Driver.NewProgram(ctx, target, 1); if (!prog) return NULL; -- cgit v1.2.3 From 7e2aa91507a5883e33473e0a94215ee3985baad1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 19 Jul 2010 17:12:42 -0700 Subject: glsl2: Add and use new variable mode ir_var_temporary This is quite a large patch because breaking it into smaller pieces would result in the tree being intermitently broken. The big changes are: * Add the ir_var_temporary variable mode * Change the ir_variable constructor to take the mode as a parameter and correctly specify the mode for all ir_varables. * Change the linker to not cross validate ir_var_temporary variables. * Change the linker to pull all ir_var_temporary variables from global scope into 'main'. --- src/glsl/ast_function.cpp | 21 +++++++++----- src/glsl/ast_to_hir.cpp | 26 ++++++++++------- src/glsl/glsl_types.cpp | 7 ++--- src/glsl/ir.cpp | 6 ++-- src/glsl/ir.h | 5 ++-- src/glsl/ir_clone.cpp | 4 +-- src/glsl/ir_expression_flattening.cpp | 2 +- src/glsl/ir_function.cpp | 1 + src/glsl/ir_function_inlining.cpp | 3 +- src/glsl/ir_if_return.cpp | 3 +- src/glsl/ir_if_to_cond_assign.cpp | 3 +- src/glsl/ir_mat_op_to_vec.cpp | 3 +- src/glsl/ir_mod_to_fract.cpp | 3 +- src/glsl/ir_reader.cpp | 3 +- src/glsl/ir_variable.cpp | 3 +- src/glsl/ir_vec_index_to_cond_assign.cpp | 12 +++++--- src/glsl/linker.cpp | 50 ++++++++++++++++++++++++++++---- src/mesa/shader/ir_to_mesa.cpp | 1 + 18 files changed, 109 insertions(+), 47 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 643eb229a77..14c36af9116 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -115,7 +115,8 @@ process_call(exec_list *instructions, ir_function *f, var = new(ctx) ir_variable(sig->return_type, talloc_asprintf(ctx, "%s_retval", - sig->function_name())); + sig->function_name()), + ir_var_temporary); instructions->push_tail(var); deref = new(ctx) ir_dereference_variable(var); @@ -509,7 +510,8 @@ emit_inline_vector_constructor(const glsl_type *type, assert(!parameters->is_empty()); ir_variable *var = new(ctx) ir_variable(type, - talloc_strdup(ctx, "vec_ctor")); + talloc_strdup(ctx, "vec_ctor"), + ir_var_temporary); instructions->push_tail(var); /* There are two kinds of vector constructors. @@ -621,7 +623,8 @@ emit_inline_matrix_constructor(const glsl_type *type, assert(!parameters->is_empty()); ir_variable *var = new(ctx) ir_variable(type, - talloc_strdup(ctx, "mat_ctor")); + talloc_strdup(ctx, "mat_ctor"), + ir_var_temporary); instructions->push_tail(var); /* There are three kinds of matrix constructors. @@ -645,7 +648,8 @@ emit_inline_matrix_constructor(const glsl_type *type, */ ir_variable *rhs_var = new(ctx) ir_variable(glsl_type::vec4_type, - talloc_strdup(ctx, "mat_ctor_vec")); + talloc_strdup(ctx, "mat_ctor_vec"), + ir_var_temporary); instructions->push_tail(rhs_var); ir_constant_data zero; @@ -759,7 +763,8 @@ emit_inline_matrix_constructor(const glsl_type *type, */ ir_variable *const rhs_var = new(ctx) ir_variable(first_param->type, - talloc_strdup(ctx, "mat_ctor_mat")); + talloc_strdup(ctx, "mat_ctor_mat"), + ir_var_temporary); instructions->push_tail(rhs_var); ir_dereference *const rhs_var_ref = @@ -825,7 +830,8 @@ emit_inline_matrix_constructor(const glsl_type *type, */ ir_variable *rhs_var = new(ctx) ir_variable(rhs->type, - talloc_strdup(ctx, "mat_ctor_vec")); + talloc_strdup(ctx, "mat_ctor_vec"), + ir_var_temporary); instructions->push_tail(rhs_var); ir_dereference *rhs_var_ref = @@ -1036,7 +1042,8 @@ ast_function_expression::hir(exec_list *instructions, continue; /* Create a temporary containing the matrix. */ - ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp"); + ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp", + ir_var_temporary); instructions->push_tail(var); instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), matrix, NULL)); diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index f20c7ead336..c68e136256c 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -527,7 +527,8 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, * temporary and return a deref of that temporary. If the rvalue * ends up not being used, the temp will get copy-propagated out. */ - ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp"); + ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp", + ir_var_temporary); ir_dereference_variable *deref_var = new(ctx) ir_dereference_variable(var); instructions->push_tail(var); instructions->push_tail(new(ctx) ir_assignment(deref_var, @@ -549,7 +550,8 @@ get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) ir_variable *var; /* FINISHME: Give unique names to the temporaries. */ - var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp"); + var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp", + ir_var_temporary); instructions->push_tail(var); var->mode = ir_var_auto; @@ -806,7 +808,8 @@ ast_expression::hir(exec_list *instructions, type = glsl_type::bool_type; } else { ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, - "and_tmp"); + "and_tmp", + ir_var_temporary); instructions->push_tail(tmp); ir_if *const stmt = new(ctx) ir_if(op[0]); @@ -870,7 +873,8 @@ ast_expression::hir(exec_list *instructions, type = glsl_type::bool_type; } else { ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, - "or_tmp"); + "or_tmp", + ir_var_temporary); instructions->push_tail(tmp); ir_if *const stmt = new(ctx) ir_if(op[0]); @@ -1049,7 +1053,8 @@ ast_expression::hir(exec_list *instructions, && (cond_val != NULL) && (then_val != NULL) && (else_val != NULL)) { result = (cond_val->value.b[0]) ? then_val : else_val; } else { - ir_variable *const tmp = new(ctx) ir_variable(type, "conditional_tmp"); + ir_variable *const tmp = + new(ctx) ir_variable(type, "conditional_tmp", ir_var_temporary); instructions->push_tail(tmp); ir_if *const stmt = new(ctx) ir_if(op[0]); @@ -1474,6 +1479,9 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, } } + /* If there is no qualifier that changes the mode of the variable, leave + * the setting alone. + */ if (qual->in && qual->out) var->mode = ir_var_inout; else if (qual->attribute || qual->in @@ -1483,8 +1491,6 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, var->mode = ir_var_out; else if (qual->uniform) var->mode = ir_var_uniform; - else - var->mode = ir_var_auto; if (qual->uniform) var->shader_in = true; @@ -1633,7 +1639,7 @@ ast_declarator_list::hir(exec_list *instructions, var_type = decl_type; } - var = new(ctx) ir_variable(var_type, decl->identifier); + var = new(ctx) ir_variable(var_type, decl->identifier, ir_var_auto); /* From page 22 (page 28 of the PDF) of the GLSL 1.10 specification; * @@ -1993,7 +1999,7 @@ ast_parameter_declarator::hir(exec_list *instructions, } is_void = false; - ir_variable *var = new(ctx) ir_variable(type, this->identifier); + ir_variable *var = new(ctx) ir_variable(type, this->identifier, ir_var_in); /* FINISHME: Handle array declarations. Note that this requires * FINISHME: complete handling of constant expressions. @@ -2003,8 +2009,6 @@ ast_parameter_declarator::hir(exec_list *instructions, * for function parameters the default mode is 'in'. */ apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc); - if (var->mode == ir_var_auto) - var->mode = ir_var_in; instructions->push_tail(var); diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 77c591ed691..5cb327c89d5 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -251,10 +251,9 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const snprintf(param_name, 10, "p%08X", i); ir_variable *var = (this->base_type == GLSL_TYPE_ARRAY) - ? new(ctx) ir_variable(fields.array, param_name) - : new(ctx) ir_variable(fields.structure[i].type, param_name); + ? new(ctx) ir_variable(fields.array, param_name, ir_var_in) + : new(ctx) ir_variable(fields.structure[i].type, param_name, ir_var_in); - var->mode = ir_var_in; declarations[i] = var; sig->parameters.push_tail(var); } @@ -264,7 +263,7 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const * the same type as the constructor. After initializing __retval, * __retval is returned. */ - ir_variable *retval = new(ctx) ir_variable(this, "__retval"); + ir_variable *retval = new(ctx) ir_variable(this, "__retval", ir_var_auto); sig->body.push_tail(retval); for (unsigned i = 0; i < length; i++) { diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index ba8ee7b9ac9..146ff17af31 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -748,10 +748,12 @@ ir_swizzle::variable_referenced() return this->val->variable_referenced(); } -ir_variable::ir_variable(const struct glsl_type *type, const char *name) + +ir_variable::ir_variable(const struct glsl_type *type, const char *name, + ir_variable_mode mode) : max_array_access(0), read_only(false), centroid(false), invariant(false), shader_in(false), shader_out(false), - mode(ir_var_auto), interpolation(ir_var_smooth), array_lvalue(false) + mode(mode), interpolation(ir_var_smooth), array_lvalue(false) { this->ir_type = ir_type_variable; this->type = type; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 3be096270d8..9fd9850391f 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -162,7 +162,8 @@ enum ir_variable_mode { ir_var_uniform, ir_var_in, ir_var_out, - ir_var_inout + ir_var_inout, + ir_var_temporary /**< Temporary variable generated during compilation. */ }; enum ir_variable_interpolation { @@ -174,7 +175,7 @@ enum ir_variable_interpolation { class ir_variable : public ir_instruction { public: - ir_variable(const struct glsl_type *, const char *); + ir_variable(const struct glsl_type *, const char *, ir_variable_mode); virtual ir_variable *clone(struct hash_table *ht) const; diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 91d6977354d..f7e8794728c 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -39,7 +39,8 @@ ir_variable * ir_variable::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); - ir_variable *var = new(ctx) ir_variable(type, name); + ir_variable *var = new(ctx) ir_variable(this->type, this->name, + (ir_variable_mode) this->mode); var->max_array_access = this->max_array_access; var->read_only = this->read_only; @@ -47,7 +48,6 @@ ir_variable::clone(struct hash_table *ht) const var->invariant = this->invariant; var->shader_in = this->shader_in; var->shader_out = this->shader_out; - var->mode = this->mode; var->interpolation = this->interpolation; var->array_lvalue = this->array_lvalue; var->location = this->location; diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp index f18659342f5..6dbebc63780 100644 --- a/src/glsl/ir_expression_flattening.cpp +++ b/src/glsl/ir_expression_flattening.cpp @@ -89,7 +89,7 @@ ir_expression_flattening_visitor::operand_to_temp(ir_rvalue *ir) if (!this->predicate(ir)) return ir; - var = new(ctx) ir_variable(ir->type, "flattening_tmp"); + var = new(ctx) ir_variable(ir->type, "flattening_tmp", ir_var_temporary); base_ir->insert_before(var); assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp index e85b18ce021..28a5c399f15 100644 --- a/src/glsl/ir_function.cpp +++ b/src/glsl/ir_function.cpp @@ -116,6 +116,7 @@ parameter_lists_match(const exec_list *list_a, const exec_list *list_b) switch ((enum ir_variable_mode)(param->mode)) { case ir_var_auto: case ir_var_uniform: + case ir_var_temporary: /* These are all error conditions. It is invalid for a parameter to * a function to be declared as auto (not in, out, or inout) or * as uniform. diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index a3f7089cdc8..05dd83f7ffd 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -122,7 +122,8 @@ ir_call::generate_inline(ir_instruction *next_ir) /* Generate storage for the return value. */ if (this->callee->return_type) { - retval = new(ctx) ir_variable(this->callee->return_type, "__retval"); + retval = new(ctx) ir_variable(this->callee->return_type, "__retval", + ir_var_auto); next_ir->insert_before(retval); } diff --git a/src/glsl/ir_if_return.cpp b/src/glsl/ir_if_return.cpp index f68dcfb5010..a9af7166b96 100644 --- a/src/glsl/ir_if_return.cpp +++ b/src/glsl/ir_if_return.cpp @@ -102,7 +102,8 @@ ir_if_return_visitor::visit_enter(ir_if *ir) } else { ir_assignment *assign; ir_variable *new_var = new(ir) ir_variable(then_return->value->type, - "if_return_tmp"); + "if_return_tmp", + ir_var_temporary); ir->insert_before(new_var); assign = new(ir) ir_assignment(new(ir) ir_dereference_variable(new_var), diff --git a/src/glsl/ir_if_to_cond_assign.cpp b/src/glsl/ir_if_to_cond_assign.cpp index 274874bbb76..0b87413941a 100644 --- a/src/glsl/ir_if_to_cond_assign.cpp +++ b/src/glsl/ir_if_to_cond_assign.cpp @@ -145,7 +145,8 @@ ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir) * simpler. */ cond_var = new(mem_ctx) ir_variable(glsl_type::bool_type, - "if_to_cond_assign_condition"); + "if_to_cond_assign_condition", + ir_var_temporary); ir->insert_before(cond_var); deref = new(mem_ctx) ir_dereference_variable(cond_var); diff --git a/src/glsl/ir_mat_op_to_vec.cpp b/src/glsl/ir_mat_op_to_vec.cpp index 7bdb9057d82..742fc2a2952 100644 --- a/src/glsl/ir_mat_op_to_vec.cpp +++ b/src/glsl/ir_mat_op_to_vec.cpp @@ -298,7 +298,8 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign) ir_assignment *assign; op_var[i] = new(base_ir) ir_variable(expr->operands[i]->type, - "mat_op_to_vec"); + "mat_op_to_vec", + ir_var_temporary); base_ir->insert_before(op_var[i]); lhs_deref = new(base_ir) ir_dereference_variable(op_var[i]); diff --git a/src/glsl/ir_mod_to_fract.cpp b/src/glsl/ir_mod_to_fract.cpp index ec1e65092d9..71c9472b12b 100644 --- a/src/glsl/ir_mod_to_fract.cpp +++ b/src/glsl/ir_mod_to_fract.cpp @@ -60,7 +60,8 @@ ir_mod_to_fract_visitor::visit_leave(ir_expression *ir) if (ir->operation != ir_binop_mod) return visit_continue; - ir_variable *temp = new(ir) ir_variable(ir->operands[1]->type, "mod_b"); + ir_variable *temp = new(ir) ir_variable(ir->operands[1]->type, "mod_b", + ir_var_temporary); this->base_ir->insert_before(temp); ir_assignment *assign; diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index a1e5a7ad74b..ed68496587a 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -401,7 +401,8 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) return NULL; } - ir_variable *var = new(ctx) ir_variable(type, var_name->value()); + ir_variable *var = new(ctx) ir_variable(type, var_name->value(), + ir_var_auto); foreach_iter(exec_list_iterator, it, quals->subexpressions) { s_symbol *qualifier = SX_AS_SYMBOL(it.get()); diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 4593c181127..700c5de648d 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -39,9 +39,8 @@ add_variable(const char *name, enum ir_variable_mode mode, int slot, const glsl_type *type, exec_list *instructions, glsl_symbol_table *symtab) { - ir_variable *var = new(symtab) ir_variable(type, name); + ir_variable *var = new(symtab) ir_variable(type, name, mode); - var->mode = mode; switch (var->mode) { case ir_var_auto: var->read_only = true; diff --git a/src/glsl/ir_vec_index_to_cond_assign.cpp b/src/glsl/ir_vec_index_to_cond_assign.cpp index ac420454e88..7e04389b5f9 100644 --- a/src/glsl/ir_vec_index_to_cond_assign.cpp +++ b/src/glsl/ir_vec_index_to_cond_assign.cpp @@ -86,14 +86,16 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue /* Store the index to a temporary to avoid reusing its tree. */ index = new(base_ir) ir_variable(glsl_type::int_type, - "vec_index_tmp_i"); + "vec_index_tmp_i", + ir_var_temporary); base_ir->insert_before(index); deref = new(base_ir) ir_dereference_variable(index); assign = new(base_ir) ir_assignment(deref, orig_deref->array_index, NULL); base_ir->insert_before(assign); /* Temporary where we store whichever value we swizzle out. */ - var = new(base_ir) ir_variable(ir->type, "vec_index_tmp_v"); + var = new(base_ir) ir_variable(ir->type, "vec_index_tmp_v", + ir_var_temporary); base_ir->insert_before(var); /* Generate a conditional move of each vector element to the temp. */ @@ -166,14 +168,16 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); /* Store the index to a temporary to avoid reusing its tree. */ - index = new(ir) ir_variable(glsl_type::int_type, "vec_index_tmp_i"); + index = new(ir) ir_variable(glsl_type::int_type, "vec_index_tmp_i", + ir_var_temporary); ir->insert_before(index); deref = new(ir) ir_dereference_variable(index); assign = new(ir) ir_assignment(deref, orig_deref->array_index, NULL); ir->insert_before(assign); /* Store the RHS to a temporary to avoid reusing its tree. */ - var = new(ir) ir_variable(ir->rhs->type, "vec_index_tmp_v"); + var = new(ir) ir_variable(ir->rhs->type, "vec_index_tmp_v", + ir_var_temporary); ir->insert_before(var); deref = new(ir) ir_dereference_variable(var); assign = new(ir) ir_assignment(deref, ir->rhs, NULL); diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 4869dbe1ca5..eb4eb9d20e1 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -246,6 +246,8 @@ mode_string(const ir_variable *var) case ir_var_in: return "shader input"; case ir_var_out: return "shader output"; case ir_var_inout: return "shader inout"; + + case ir_var_temporary: default: assert(!"Should not get here."); return "invalid variable"; @@ -276,6 +278,12 @@ cross_validate_globals(struct gl_shader_program *prog, if (uniforms_only && (var->mode != ir_var_uniform)) continue; + /* Don't cross validate temporaries that are at global scope. These + * will eventually get pulled into the shaders 'main'. + */ + if (var->mode == ir_var_temporary) + continue; + /* If a global with this name has already been seen, verify that the * new instance has the same type. In addition, if the globals have * initializers, the values of the initializers must be the same. @@ -480,18 +488,28 @@ populate_symbol_table(gl_shader *sh) */ void remap_variables(ir_instruction *inst, glsl_symbol_table *symbols, - exec_list *instructions) + exec_list *instructions, hash_table *temps) { class remap_visitor : public ir_hierarchical_visitor { public: - remap_visitor(glsl_symbol_table *symbols, exec_list *instructions) + remap_visitor(glsl_symbol_table *symbols, exec_list *instructions, + hash_table *temps) { this->symbols = symbols; this->instructions = instructions; + this->temps = temps; } virtual ir_visitor_status visit(ir_dereference_variable *ir) { + if (ir->var->mode == ir_var_temporary) { + ir_variable *var = (ir_variable *) hash_table_find(temps, ir->var); + + assert(var != NULL); + ir->var = var; + return visit_continue; + } + ir_variable *const existing = this->symbols->get_variable(ir->var->name); if (existing != NULL) @@ -501,6 +519,7 @@ remap_variables(ir_instruction *inst, glsl_symbol_table *symbols, this->symbols->add_variable(copy->name, copy); this->instructions->push_head(copy); + ir->var = copy; } return visit_continue; @@ -509,9 +528,10 @@ remap_variables(ir_instruction *inst, glsl_symbol_table *symbols, private: glsl_symbol_table *symbols; exec_list *instructions; + hash_table *temps; }; - remap_visitor v(symbols, instructions); + remap_visitor v(symbols, instructions, temps); inst->accept(&v); } @@ -542,17 +562,32 @@ exec_node * move_non_declarations(exec_list *instructions, exec_node *last, bool make_copies, gl_shader *target) { + hash_table *temps = NULL; + + if (make_copies) + temps = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + foreach_list_safe(node, instructions) { ir_instruction *inst = (ir_instruction *) node; - if (inst->as_variable() || inst->as_function()) + if (inst->as_function()) + continue; + + ir_variable *var = inst->as_variable(); + if ((var != NULL) && (var->mode != ir_var_temporary)) continue; - assert(inst->as_assignment()); + assert(inst->as_assignment() + || ((var != NULL) && (var->mode == ir_var_temporary))); if (make_copies) { inst = inst->clone(NULL); - remap_variables(inst, target->symbols, target->ir); + + if (var != NULL) + hash_table_insert(temps, inst, var); + else + remap_variables(inst, target->symbols, target->ir, temps); } else { inst->remove(); } @@ -561,6 +596,9 @@ move_non_declarations(exec_list *instructions, exec_node *last, last = inst; } + if (make_copies) + hash_table_dtor(temps); + return last; } diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 352b496625d..7cc469f3a72 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1133,6 +1133,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) break; case ir_var_auto: + case ir_var_temporary: entry = new(mem_ctx) variable_storage(ir->var, PROGRAM_TEMPORARY, this->next_temp); this->variables.push_tail(entry); -- cgit v1.2.3 From 2462a536ea5c98867296905e3da127eba7c7bdff Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sun, 18 Jul 2010 15:59:43 -0700 Subject: glsl2: Add a constructor for _mesa_glsl_parse_state Coming changes to the handling of built-in functions necessitate this. --- src/glsl/Makefile | 1 + src/glsl/glsl_parser_extras.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/glsl/glsl_parser_extras.h | 22 ++++++++++++++++++++++ src/mesa/shader/ir_to_mesa.cpp | 34 ++-------------------------------- 4 files changed, 66 insertions(+), 32 deletions(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 7bf95fbfc2d..2b040377b0c 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -93,6 +93,7 @@ INCLUDES = \ -I../mesa \ -I../mapi \ -I../mesa/shader \ + -I../../include \ $(LIBRARY_INCLUDES) ALL_SOURCES = \ diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index cb7b6d36a2d..bcf2579733d 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -34,6 +34,47 @@ extern "C" { #include "glsl_parser_extras.h" #include "glsl_parser.h" +_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct __GLcontextRec *ctx, + GLenum target, void *mem_ctx) +{ + switch (target) { + case GL_VERTEX_SHADER: this->target = vertex_shader; break; + case GL_FRAGMENT_SHADER: this->target = fragment_shader; break; + case GL_GEOMETRY_SHADER: this->target = geometry_shader; break; + } + + this->scanner = NULL; + this->translation_unit.make_empty(); + this->symbols = new(mem_ctx) glsl_symbol_table; + this->info_log = talloc_strdup(mem_ctx, ""); + this->error = false; + this->loop_or_switch_nesting = NULL; + this->ARB_texture_rectangle_enable = true; + + if (ctx != NULL) { + this->extensions = &ctx->Extensions; + + this->Const.MaxLights = ctx->Const.MaxLights; + this->Const.MaxClipPlanes = ctx->Const.MaxClipPlanes; + this->Const.MaxTextureUnits = ctx->Const.MaxTextureUnits; + this->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits; + this->Const.MaxVertexAttribs = ctx->Const.VertexProgram.MaxAttribs; + this->Const.MaxVertexUniformComponents = ctx->Const.VertexProgram.MaxUniformComponents; + this->Const.MaxVaryingFloats = ctx->Const.MaxVarying * 4; + this->Const.MaxVertexTextureImageUnits = ctx->Const.MaxVertexTextureImageUnits; + this->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxCombinedTextureImageUnits; + this->Const.MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits; + this->Const.MaxFragmentUniformComponents = ctx->Const.FragmentProgram.MaxUniformComponents; + + this->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; + } else { + static struct gl_extensions null_extensions; + + memset(&null_extensions, 0, sizeof(null_extensions)); + this->extensions = &null_extensions; + } +} + const char * _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) { diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index fed6e8c823f..e2efbd9ac9f 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -35,7 +35,29 @@ enum _mesa_glsl_parser_targets { ir_shader }; +struct __GLcontextRec; + struct _mesa_glsl_parse_state { + _mesa_glsl_parse_state(struct __GLcontextRec *ctx, GLenum target, + void *mem_ctx); + + /* Callers of this talloc-based new need not call delete. It's + * easier to just talloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *mem = talloc_zero_size(ctx, size); + assert(mem != NULL); + + return mem; + } + + /* If the user *does* call delete, that's OK, we will just + * talloc_free in that case. */ + static void operator delete(void *mem) + { + talloc_free(mem); + } + void *scanner; exec_list translation_unit; glsl_symbol_table *symbols; diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 7cc469f3a72..1a9b0e39481 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2155,38 +2155,8 @@ steal_memory(ir_instruction *ir, void *new_ctx) void _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) { - struct _mesa_glsl_parse_state *state; - - state = talloc_zero(shader, struct _mesa_glsl_parse_state); - switch (shader->Type) { - case GL_VERTEX_SHADER: state->target = vertex_shader; break; - case GL_FRAGMENT_SHADER: state->target = fragment_shader; break; - case GL_GEOMETRY_SHADER: state->target = geometry_shader; break; - } - - state->scanner = NULL; - state->translation_unit.make_empty(); - state->symbols = new(shader) glsl_symbol_table; - state->info_log = talloc_strdup(shader, ""); - state->error = false; - state->loop_or_switch_nesting = NULL; - state->ARB_texture_rectangle_enable = true; - - state->extensions = &ctx->Extensions; - - state->Const.MaxLights = ctx->Const.MaxLights; - state->Const.MaxClipPlanes = ctx->Const.MaxClipPlanes; - state->Const.MaxTextureUnits = ctx->Const.MaxTextureUnits; - state->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits; - state->Const.MaxVertexAttribs = ctx->Const.VertexProgram.MaxAttribs; - state->Const.MaxVertexUniformComponents = ctx->Const.VertexProgram.MaxUniformComponents; - state->Const.MaxVaryingFloats = ctx->Const.MaxVarying * 4; - state->Const.MaxVertexTextureImageUnits = ctx->Const.MaxVertexTextureImageUnits; - state->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxCombinedTextureImageUnits; - state->Const.MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits; - state->Const.MaxFragmentUniformComponents = ctx->Const.FragmentProgram.MaxUniformComponents; - - state->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; + struct _mesa_glsl_parse_state *state = + new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader); const char *source = shader->Source; state->error = preprocess(state, &source, &state->info_log, -- cgit v1.2.3 From 60e2d06d1ccc66ad00cd7ab81c418853f21be291 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 20 Jul 2010 11:27:38 -0700 Subject: glsl2: Implement utility routine to talloc reparent an IR tree --- src/glsl/ir.cpp | 15 +++++++++++++++ src/glsl/ir.h | 3 +++ src/glsl/main.cpp | 10 +--------- src/mesa/shader/ir_to_mesa.cpp | 10 +--------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 146ff17af31..a2732962f03 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -875,3 +875,18 @@ visit_exec_list(exec_list *list, ir_visitor *visitor) } } + +static void +steal_memory(ir_instruction *ir, void *new_ctx) +{ + talloc_steal(new_ctx, ir); +} + + +void +reparent_ir(exec_list *list, void *mem_ctx) +{ + foreach_list(node, list) { + visit_tree((ir_instruction *) node, steal_memory, mem_ctx); + } +} diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 9fd9850391f..e4b0e9f0822 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1315,4 +1315,7 @@ extern void _mesa_glsl_initialize_functions(exec_list *instructions, struct _mesa_glsl_parse_state *state); +extern void +reparent_ir(exec_list *list, void *mem_ctx); + #endif /* IR_H */ diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 6b1a01c7046..cf9a5157857 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -118,12 +118,6 @@ const struct option compiler_opts[] = { { NULL, 0, NULL, 0 } }; -static void -steal_memory(ir_instruction *ir, void *new_ctx) -{ - talloc_steal(new_ctx, ir); -} - void compile_shader(struct gl_shader *shader) { @@ -232,9 +226,7 @@ compile_shader(struct gl_shader *shader) shader->InfoLog = state->info_log; /* Retain any live IR, but trash the rest. */ - foreach_list(node, shader->ir) { - visit_tree((ir_instruction *) node, steal_memory, shader); - } + reparent_ir(shader->ir, shader); talloc_free(state); diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 1a9b0e39481..d1c09febd6b 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2146,12 +2146,6 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, extern "C" { -static void -steal_memory(ir_instruction *ir, void *new_ctx) -{ - talloc_steal(new_ctx, ir); -} - void _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) { @@ -2215,9 +2209,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) shader->Version = state->language_version; /* Retain any live IR, but trash the rest. */ - foreach_list(node, shader->ir) { - visit_tree((ir_instruction *) node, steal_memory, shader); - } + reparent_ir(shader->ir, shader); talloc_free(state); } -- cgit v1.2.3 From a7ba9a7919110fd619b0e792368aa1f3534080fe Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 20 Jul 2010 13:36:32 -0700 Subject: linker: Do post-link lowering and optimization The lowering code should probably be moved elsewhere. --- src/glsl/linker.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index eb4eb9d20e1..640e6eee8e0 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -80,6 +80,7 @@ extern "C" { #include "hash_table.h" #include "shader_api.h" #include "linker.h" +#include "ir_optimization.h" /** * Visitor that determines whether or not a variable is ever written. @@ -1223,6 +1224,43 @@ link_shaders(struct gl_shader_program *prog) } /* FINISHME: Perform whole-program optimization here. */ + for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { + /* Optimization passes */ + bool progress; + exec_list *ir = prog->_LinkedShaders[i]->ir; + + /* Lowering */ + do_mat_op_to_vec(ir); + do_mod_to_fract(ir); + do_div_to_mul_rcp(ir); + + do { + progress = false; + + progress = do_function_inlining(ir) || progress; + progress = do_if_simplification(ir) || progress; + progress = do_copy_propagation(ir) || progress; + progress = do_dead_code_local(ir) || progress; +#if 0 + progress = do_dead_code_unlinked(state, ir) || progress; +#endif + progress = do_constant_variable_unlinked(ir) || progress; + progress = do_constant_folding(ir) || progress; + progress = do_if_return(ir) || progress; +#if 0 + if (ctx->Shader.EmitNoIfs) + progress = do_if_to_cond_assign(ir) || progress; +#endif + + progress = do_vec_index_to_swizzle(ir) || progress; + /* Do this one after the previous to let the easier pass handle + * constant vector indexing. + */ + progress = do_vec_index_to_cond_assign(ir) || progress; + + progress = do_swizzle_swizzle(ir) || progress; + } while (progress); + } assign_uniform_locations(prog); -- cgit v1.2.3 From f38d15b80d4e4c8ecb7a76087cdc49835f0aa271 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 20 Jul 2010 15:33:40 -0700 Subject: glsl2: glsl_type has its own talloc context, don't pass one in --- src/glsl/ast_function.cpp | 3 +-- src/glsl/ast_to_hir.cpp | 5 ++--- src/glsl/glsl_types.cpp | 11 +++++------ src/glsl/glsl_types.h | 5 ++--- src/glsl/ir_reader.cpp | 2 +- src/glsl/ir_variable.cpp | 17 +++++++---------- 6 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 14c36af9116..73af882c530 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -312,8 +312,7 @@ process_array_constructor(exec_list *instructions, if (constructor_type->length == 0) { constructor_type = - glsl_type::get_array_instance(state, - constructor_type->element_type(), + glsl_type::get_array_instance(constructor_type->element_type(), parameter_count); assert(constructor_type != NULL); assert(constructor_type->length == parameter_count); diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index c68e136256c..5cadcd19461 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -511,8 +511,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, var->max_array_access); } - var->type = glsl_type::get_array_instance(state, - lhs->type->element_type(), + var->type = glsl_type::get_array_instance(lhs->type->element_type(), rhs->type->array_size()); } } @@ -1407,7 +1406,7 @@ process_array_type(const glsl_type *base, ast_node *array_size, } } - return glsl_type::get_array_instance(state, base, length); + return glsl_type::get_array_instance(base, length); } diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 5cb327c89d5..de0adc0c6ec 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -289,7 +289,7 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const } -glsl_type::glsl_type(void *ctx, const glsl_type *array, unsigned length) : +glsl_type::glsl_type(const glsl_type *array, unsigned length) : base_type(GLSL_TYPE_ARRAY), sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), sampler_type(0), @@ -308,7 +308,7 @@ glsl_type::glsl_type(void *ctx, const glsl_type *array, unsigned length) : * NUL. */ const unsigned name_length = strlen(array->name) + 10 + 3; - char *const n = (char *) talloc_size(ctx, name_length); + char *const n = (char *) talloc_size(this->ctx, name_length); if (length == 0) snprintf(n, name_length, "%s[]", array->name); @@ -411,10 +411,9 @@ glsl_type::array_key_hash(const void *a) const glsl_type * -glsl_type::get_array_instance(void *ctx, const glsl_type *base, - unsigned array_size) +glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) { - const glsl_type key(ctx, base, array_size); + const glsl_type key(base, array_size); if (array_types == NULL) { array_types = hash_table_ctor(64, array_key_hash, array_key_compare); @@ -422,7 +421,7 @@ glsl_type::get_array_instance(void *ctx, const glsl_type *base, const glsl_type *t = (glsl_type *) hash_table_find(array_types, & key); if (t == NULL) { - t = new glsl_type(ctx, base, array_size); + t = new glsl_type(base, array_size); hash_table_insert(array_types, (void *) t, t); } diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 8ba9b5ff635..69fb9e3fb58 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -197,8 +197,7 @@ struct glsl_type { /** * Get the instance of an array type */ - static const glsl_type *get_array_instance(void *ctx, - const glsl_type *base, + static const glsl_type *get_array_instance(const glsl_type *base, unsigned elements); /** @@ -412,7 +411,7 @@ private: const char *name); /** Constructor for array types */ - glsl_type(void *ctx, const glsl_type *array, unsigned length); + glsl_type(const glsl_type *array, unsigned length); /** Hash table containing the known array types. */ static struct hash_table *array_types; diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index ed68496587a..8b4be4100b0 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -138,7 +138,7 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr) return NULL; } - return glsl_type::get_array_instance(st, base_type, size->value()); + return glsl_type::get_array_instance(base_type, size->value()); } else if (strcmp(type_sym->value(), "struct") == 0) { assert(false); // FINISHME } else { diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 700c5de648d..0dd6d834b7f 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -138,7 +138,7 @@ generate_110_uniforms(exec_list *instructions, state->Const.MaxFragmentUniformComponents); const glsl_type *const mat4_array_type = - glsl_type::get_array_instance(state->symbols, glsl_type::mat4_type, + glsl_type::get_array_instance(glsl_type::mat4_type, state->Const.MaxTextureCoords); add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type, @@ -157,8 +157,7 @@ generate_110_uniforms(exec_list *instructions, * FINISHME: at least 8, so hard-code 8 for now. */ const glsl_type *const light_source_array_type = - glsl_type::get_array_instance(state->symbols, - state->symbols->get_type("gl_LightSourceParameters"), 8); + glsl_type::get_array_instance(state->symbols->get_type("gl_LightSourceParameters"), 8); add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type, instructions, state->symbols); @@ -196,7 +195,7 @@ generate_110_vs_variables(exec_list *instructions, * implementation in preserving varying resources." */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 0); + glsl_type::get_array_instance(glsl_type::vec4_type, 0); add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type, instructions, state->symbols); @@ -221,7 +220,6 @@ static void generate_130_vs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = state->symbols; generate_120_vs_variables(instructions, state); for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { @@ -233,7 +231,7 @@ generate_130_vs_variables(exec_list *instructions, * FINISHME: the value of GL_MAX_CLIP_DISTANCES. */ const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(ctx, glsl_type::float_type, 8); + glsl_type::get_array_instance(glsl_type::float_type, 8); /* FINISHME: gl_ClipDistance needs a real location assigned. */ add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type, @@ -286,7 +284,7 @@ generate_110_fs_variables(exec_list *instructions, * implementation in preserving varying resources." */ const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 0); + glsl_type::get_array_instance(glsl_type::vec4_type, 0); add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type, instructions, state->symbols); @@ -318,7 +316,7 @@ generate_ARB_draw_buffers_variables(exec_list *instructions, */ if (target == fragment_shader) { const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, + glsl_type::get_array_instance(glsl_type::vec4_type, state->Const.MaxDrawBuffers); ir_variable *const fd = @@ -349,14 +347,13 @@ static void generate_130_fs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - void *ctx = state->symbols; generate_120_fs_variables(instructions, state); /* FINISHME: The size of this array is implementation dependent based on * FINISHME: the value of GL_MAX_CLIP_DISTANCES. */ const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(ctx, glsl_type::float_type, 8); + glsl_type::get_array_instance(glsl_type::float_type, 8); /* FINISHME: gl_ClipDistance needs a real location assigned. */ add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type, -- cgit v1.2.3 From c24bcad9f88379ffba9e2f0ff92f22cdf60c2927 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 21 Jul 2010 11:23:51 -0700 Subject: glsl: Correctly handle unary plus operator. Previously, any occurence of the unary plus operator would trigger a bogus type mismatch error. Fix this by making the ast_plus case look more like the ast_neg case as far as type-checking is concerned. With this change the shaders/CorrectPreprocess8.frag test in piglit now passes. --- src/glsl/ast_to_hir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 5cadcd19461..e9257eee289 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -660,9 +660,9 @@ ast_expression::hir(exec_list *instructions, case ast_plus: op[0] = this->subexpressions[0]->hir(instructions, state); - error_emitted = op[0]->type->is_error(); - if (type->is_error()) - op[0]->type = type; + type = unary_arithmetic_result_type(op[0]->type, state, & loc); + + error_emitted = type->is_error(); result = op[0]; break; -- cgit v1.2.3 From a0cfe8c44085032fd982bbbff1f02252ffaa7114 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 21 Jul 2010 13:43:47 -0700 Subject: glsl: Fix missing initialization of yylloc.source In both the preprocessor and in the compiler proper, we use a custom yyltype struct to allow tracking the source-string number in addition to line and column. However, we were previously relying on bison's default initialization of the yyltype struct which of course is not aware of the source field and leaves it uninitialized. We fix this by defining our own YYLLOC_DEFAULT macro expanding on the default version (as appears in the bison manual) and adding initialization of yylloc.source. --- src/glsl/glcpp/glcpp.h | 19 +++++++++++++++++++ src/glsl/glsl_parser_extras.h | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index fc9511a67a8..869de2efbcc 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -69,6 +69,25 @@ typedef struct YYLTYPE { # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 +# define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC(Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC(Rhs, 0).last_column; \ + } \ + (Current).source = 0; \ +} while (0) + struct token { int type; YYSTYPE value; diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index e2efbd9ac9f..b50d9eea676 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -137,6 +137,25 @@ typedef struct YYLTYPE { # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 +# define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC(Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC(Rhs, 0).last_column; \ + } \ + (Current).source = 0; \ +} while (0) + extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, const char *fmt, ...); -- cgit v1.2.3 From 56d33f8e2be1695c951a811fac1800117c2ca406 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 21 Jul 2010 13:50:38 -0700 Subject: ir_to_mesa: Add missing initializion of lod_info variable. To quiet a compiler warning. --- src/mesa/shader/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index d1c09febd6b..a2b2eb95c82 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1564,7 +1564,7 @@ ir_to_mesa_visitor::visit(ir_call *ir) void ir_to_mesa_visitor::visit(ir_texture *ir) { - ir_to_mesa_src_reg result_src, coord, lod_info, projector; + ir_to_mesa_src_reg result_src, coord, lod_info = { 0 }, projector; ir_to_mesa_dst_reg result_dst, coord_dst; ir_to_mesa_instruction *inst = NULL; prog_opcode opcode = OPCODE_NOP; -- cgit v1.2.3 From 4ccd3c548b9b9a2fee79342445f68d73525bfcdb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 20 Jul 2010 11:28:31 -0700 Subject: glsl2: Add function to import function prototypes from one IR tree to another --- src/glsl/Makefile | 1 + src/glsl/ir.h | 6 ++ src/glsl/ir_import_prototypes.cpp | 137 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 src/glsl/ir_import_prototypes.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 2b040377b0c..47292bdb156 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -49,6 +49,7 @@ CXX_SOURCES = \ ir_if_return.cpp \ ir_if_simplification.cpp \ ir_if_to_cond_assign.cpp \ + ir_import_prototypes.cpp \ ir_mat_op_to_vec.cpp \ ir_mod_to_fract.cpp \ ir_print_visitor.cpp \ diff --git a/src/glsl/ir.h b/src/glsl/ir.h index e4b0e9f0822..38b10f5b06d 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1318,4 +1318,10 @@ _mesa_glsl_initialize_functions(exec_list *instructions, extern void reparent_ir(exec_list *list, void *mem_ctx); +class glsl_symbol_table; + +extern void +import_prototypes(const exec_list *source, exec_list *dest, + class glsl_symbol_table *symbols, void *mem_ctx); + #endif /* IR_H */ diff --git a/src/glsl/ir_import_prototypes.cpp b/src/glsl/ir_import_prototypes.cpp new file mode 100644 index 00000000000..20aa8a6ae23 --- /dev/null +++ b/src/glsl/ir_import_prototypes.cpp @@ -0,0 +1,137 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_import_prototypes.cpp + * Import function prototypes from one IR tree into another. + * + * \author Ian Romanick + */ +#include +#include "ir.h" +#include "glsl_symbol_table.h" + +/** + * Visitor used to import function prototypes + * + * Normally the \c clone method of either \c ir_function or + * \c ir_function_signature could be used. However, we don't want a complete + * clone of the \c ir_function_signature. We want everything \b except the + * body of the function. + */ +class import_prototype_visitor : public ir_hierarchical_visitor { +public: + /** + */ + import_prototype_visitor(exec_list *list, glsl_symbol_table *symbols, + void *mem_ctx) + { + this->mem_ctx = mem_ctx; + this->list = list; + this->symbols = symbols; + this->function = NULL; + } + + virtual ir_visitor_status visit_enter(ir_function *ir) + { + assert(this->function == NULL); + this->function = new(this->mem_ctx) ir_function(ir->name); + return visit_continue; + } + + virtual ir_visitor_status visit_leave(ir_function *ir) + { + (void) ir; + assert(this->function != NULL); + + /* Add the new function (and all its signatures) to the end of the + * instruction stream. + */ + list->push_tail(this->function); + + /* Add the new function to the symbol table. + */ + this->symbols->add_function(this->function->name, this->function); + + this->function = NULL; + return visit_continue; + } + + ir_visitor_status visit_enter(ir_function_signature *ir) + { + assert(this->function != NULL); + + ir_function_signature *copy = + new(mem_ctx) ir_function_signature(ir->return_type); + + copy->is_defined = false; + copy->is_built_in = ir->is_built_in; + + /* Clone the parameter list, but NOT the body. + */ + foreach_list_const(node, &ir->parameters) { + const ir_variable *const param = (const ir_variable *) node; + + assert(const_cast(param)->as_variable() != NULL); + + ir_variable *const param_copy = param->clone(NULL); + copy->parameters.push_tail(param_copy); + } + + this->function->add_signature(copy); + + /* Do not process child nodes of the ir_function_signature. There can + * never be any nodes inside the ir_function_signature that we care + * about. Instead continue with the next sibling. + */ + return visit_continue_with_parent; + } + +private: + exec_list *list; + ir_function *function; + glsl_symbol_table *symbols; + void *mem_ctx; +}; + + +/** + * Import function prototypes from one IR tree into another + * + * \param source Source instruction stream containing functions whose + * prototypes are to be imported + * \param dest Destination instruction stream where new \c ir_function and + * \c ir_function_signature nodes will be stored + * \param symbols Symbol table where new functions will be stored + * \param mem_ctx talloc memory context used for new allocations + */ +void +import_prototypes(const exec_list *source, exec_list *dest, + glsl_symbol_table *symbols, void *mem_ctx) +{ + import_prototype_visitor v(dest, symbols, mem_ctx); + + /* Making source be const is just extra documentation. + */ + v.run(const_cast(source)); +} -- cgit v1.2.3 From d5be2acae379783c4aa31243e0a88a9e67e6ca7e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 20 Jul 2010 11:29:46 -0700 Subject: linker: Link built-in functions instead of including them in every shader This is an invasive set of changes. Each user shader tracks a set of other shaders that contain built-in functions. During compilation, function prototypes are imported from these shaders. During linking, the shaders are linked with these built-in-function shaders just like with any other shader. --- src/glsl/builtin_function.cpp | 218 ++++++++++++++++++++------- src/glsl/builtins/110_vs/ftransform | 4 +- src/glsl/builtins/tools/generate_builtins.pl | 63 ++++++-- src/glsl/glsl_parser_extras.h | 4 + src/glsl/ir.h | 3 + src/glsl/linker.cpp | 23 ++- src/glsl/main.cpp | 4 + src/mesa/main/mtypes.h | 4 + src/mesa/shader/ir_to_mesa.cpp | 3 + 9 files changed, 261 insertions(+), 65 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 967bcd0c40d..10e59e491e4 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -25,22 +25,41 @@ #include #include "glsl_parser_extras.h" #include "ir_reader.h" +#include "program.h" -void -read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, - const char **functions, unsigned count) +extern "C" struct gl_shader * +_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type); + +gl_shader * +read_builtins(GLenum target, const char **functions, unsigned count) { - if (st->error) - return; + gl_shader *sh = _mesa_new_shader(NULL, 0, target); + struct _mesa_glsl_parse_state *st = + new(sh) _mesa_glsl_parse_state(NULL, target, sh); + + st->language_version = 130; + st->ARB_texture_rectangle_enable = true; + st->EXT_texture_array_enable = true; + _mesa_glsl_initialize_types(st); + + sh->ir = new(sh) exec_list; + sh->symbols = st->symbols; for (unsigned i = 0; i < count; i++) { - _mesa_glsl_read_ir(st, instructions, functions[i]); + _mesa_glsl_read_ir(st, sh->ir, functions[i]); if (st->error) { printf("error reading builtin: %.35s ...\n", functions[i]); - return; + delete st; + talloc_free(sh); + return NULL; } } + + reparent_ir(sh->ir, sh); + delete st; + + return sh; } /* 110 builtins */ @@ -2580,7 +2599,9 @@ static const char *functions_for_110_fs [] = { /* 110_vs builtins */ static const char *builtins_110_vs_ftransform = { - "((function ftransform\n" + "((declare (uniform) mat4 gl_ModelViewProjectionMatrix)\n" + " (declare (in) vec4 gl_Vertex)\n" + " (function ftransform\n" " (signature vec4\n" " (parameters)\n" " ((return (expression vec4 *\n" @@ -4760,53 +4781,146 @@ static const char *functions_for_EXT_texture_array_fs [] = { #define Elements(x) (sizeof(x)/sizeof(*(x))) #endif +void *builtin_mem_ctx = NULL; + +void +_mesa_glsl_release_functions(void) +{ + talloc_free(builtin_mem_ctx); +} + void _mesa_glsl_initialize_functions(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - if (state->language_version >= 110) - read_builtins(state, instructions, - functions_for_110, - Elements(functions_for_110)); - - if (state->target == fragment_shader && state->language_version >= 110) - read_builtins(state, instructions, - functions_for_110_fs, - Elements(functions_for_110_fs)); - - if (state->target == vertex_shader && state->language_version >= 110) - read_builtins(state, instructions, - functions_for_110_vs, - Elements(functions_for_110_vs)); - - if (state->language_version >= 120) - read_builtins(state, instructions, - functions_for_120, - Elements(functions_for_120)); - - if (state->language_version >= 130) - read_builtins(state, instructions, - functions_for_130, - Elements(functions_for_130)); - - if (state->target == fragment_shader && state->language_version >= 130) - read_builtins(state, instructions, - functions_for_130_fs, - Elements(functions_for_130_fs)); - - if (state->ARB_texture_rectangle_enable) - read_builtins(state, instructions, - functions_for_ARB_texture_rectangle, - Elements(functions_for_ARB_texture_rectangle)); - - if (state->EXT_texture_array_enable) - read_builtins(state, instructions, - functions_for_EXT_texture_array, - Elements(functions_for_EXT_texture_array)); - - if (state->target == fragment_shader && state->EXT_texture_array_enable) - read_builtins(state, instructions, - functions_for_EXT_texture_array_fs, - Elements(functions_for_EXT_texture_array_fs)); + if (builtin_mem_ctx == NULL) + builtin_mem_ctx = talloc_init("GLSL built-in functions"); + + state->num_builtins_to_link = 0; + if (state->language_version >= 110) { + static gl_shader *sh = NULL; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, functions_for_110, + Elements(functions_for_110)); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } + + if (state->target == fragment_shader && state->language_version >= 110) { + static gl_shader *sh = NULL; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, functions_for_110_fs, + Elements(functions_for_110_fs)); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } + + if (state->target == vertex_shader && state->language_version >= 110) { + static gl_shader *sh = NULL; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, functions_for_110_vs, + Elements(functions_for_110_vs)); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } + + if (state->language_version >= 120) { + static gl_shader *sh = NULL; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, functions_for_120, + Elements(functions_for_120)); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } + + if (state->language_version >= 130) { + static gl_shader *sh = NULL; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, functions_for_130, + Elements(functions_for_130)); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } + + if (state->target == fragment_shader && state->language_version >= 130) { + static gl_shader *sh = NULL; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, functions_for_130_fs, + Elements(functions_for_130_fs)); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } + + if (state->ARB_texture_rectangle_enable) { + static gl_shader *sh = NULL; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, functions_for_ARB_texture_rectangle, + Elements(functions_for_ARB_texture_rectangle)); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } + + if (state->EXT_texture_array_enable) { + static gl_shader *sh = NULL; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, functions_for_EXT_texture_array, + Elements(functions_for_EXT_texture_array)); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } + + if (state->target == fragment_shader && state->EXT_texture_array_enable) { + static gl_shader *sh = NULL; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, functions_for_EXT_texture_array_fs, + Elements(functions_for_EXT_texture_array_fs)); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } } diff --git a/src/glsl/builtins/110_vs/ftransform b/src/glsl/builtins/110_vs/ftransform index 3a5e8ccecfc..9ca63dc1e34 100644 --- a/src/glsl/builtins/110_vs/ftransform +++ b/src/glsl/builtins/110_vs/ftransform @@ -1,4 +1,6 @@ -((function ftransform +((declare (uniform) mat4 gl_ModelViewProjectionMatrix) + (declare (in) vec4 gl_Vertex) + (function ftransform (signature vec4 (parameters) ((return (expression vec4 * diff --git a/src/glsl/builtins/tools/generate_builtins.pl b/src/glsl/builtins/tools/generate_builtins.pl index a0b5c1f421c..61d511da1d4 100755 --- a/src/glsl/builtins/tools/generate_builtins.pl +++ b/src/glsl/builtins/tools/generate_builtins.pl @@ -64,22 +64,41 @@ print << 'EOF'; #include #include "glsl_parser_extras.h" #include "ir_reader.h" +#include "program.h" -void -read_builtins(_mesa_glsl_parse_state *st, exec_list *instructions, - const char **functions, unsigned count) +extern "C" struct gl_shader * +_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type); + +gl_shader * +read_builtins(GLenum target, const char **functions, unsigned count) { - if (st->error) - return; + gl_shader *sh = _mesa_new_shader(NULL, 0, target); + struct _mesa_glsl_parse_state *st = + new(sh) _mesa_glsl_parse_state(NULL, target, sh); + + st->language_version = 130; + st->ARB_texture_rectangle_enable = true; + st->EXT_texture_array_enable = true; + _mesa_glsl_initialize_types(st); + + sh->ir = new(sh) exec_list; + sh->symbols = st->symbols; for (unsigned i = 0; i < count; i++) { - _mesa_glsl_read_ir(st, instructions, functions[i]); + _mesa_glsl_read_ir(st, sh->ir, functions[i]); if (st->error) { printf("error reading builtin: %.35s ...\n", functions[i]); - return; + delete st; + talloc_free(sh); + return NULL; } } + + reparent_ir(sh->ir, sh); + delete st; + + return sh; } EOF @@ -95,10 +114,22 @@ print << 'EOF'; #define Elements(x) (sizeof(x)/sizeof(*(x))) #endif +void *builtin_mem_ctx = NULL; + +void +_mesa_glsl_release_functions(void) +{ + talloc_free(builtin_mem_ctx); +} + void _mesa_glsl_initialize_functions(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + if (builtin_mem_ctx == NULL) + builtin_mem_ctx = talloc_init("GLSL built-in functions"); + + state->num_builtins_to_link = 0; EOF foreach $version_xs (@versions) { @@ -117,10 +148,20 @@ foreach $version_xs (@versions) { # Not a version...an extension name $check = "${check}state->${version}_enable"; } - print " if ($check)\n"; - print " read_builtins(state, instructions,\n"; - print " functions_for_$version_xs,\n"; - print " Elements(functions_for_$version_xs));\n\n" + print " if ($check) {\n"; + print " static gl_shader *sh = NULL;\n"; + print "\n"; + print " if (sh == NULL) {\n"; + print " sh = read_builtins(GL_VERTEX_SHADER, functions_for_$version_xs,\n"; + print " Elements(functions_for_$version_xs));\n"; + print " talloc_steal(builtin_mem_ctx, sh);\n"; + print " }\n"; + print "\n"; + print " import_prototypes(sh->ir, instructions, state->symbols, state);\n"; + print " state->builtins_to_link[state->num_builtins_to_link] = sh;\n"; + print " state->num_builtins_to_link++;\n"; + print " }\n"; + print "\n"; } print "}\n"; diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index b50d9eea676..56f6e18e0bd 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -125,6 +125,10 @@ struct _mesa_glsl_parse_state { /** Extensions supported by the OpenGL implementation. */ const struct gl_extensions *extensions; + + /** Shaders containing built-in functions that are used for linking. */ + struct gl_shader *builtins_to_link[16]; + unsigned num_builtins_to_link; }; typedef struct YYLTYPE { diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 38b10f5b06d..3a643fc5807 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1315,6 +1315,9 @@ extern void _mesa_glsl_initialize_functions(exec_list *instructions, struct _mesa_glsl_parse_state *state); +extern void +_mesa_glsl_release_functions(void); + extern void reparent_ir(exec_list *list, void *mem_ctx); diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 640e6eee8e0..7c30a40a6ce 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -739,7 +739,28 @@ link_intrastage_shaders(struct gl_shader_program *prog, /* Resolve initializers for global variables in the linked shader. */ - link_function_calls(prog, linked, shader_list, num_shaders); + unsigned num_linking_shaders = num_shaders; + for (unsigned i = 0; i < num_shaders; i++) + num_linking_shaders += shader_list[i]->num_builtins_to_link; + + gl_shader **linking_shaders = + (gl_shader **) calloc(num_linking_shaders, sizeof(gl_shader *)); + + memcpy(linking_shaders, shader_list, + sizeof(linking_shaders[0]) * num_shaders); + + unsigned idx = num_shaders; + for (unsigned i = 0; i < num_shaders; i++) { + memcpy(&linking_shaders[idx], shader_list[i]->builtins_to_link, + sizeof(linking_shaders[0]) * shader_list[i]->num_builtins_to_link); + idx += shader_list[i]->num_builtins_to_link; + } + + assert(idx == num_linking_shaders); + + link_function_calls(prog, linked, linking_shaders, num_linking_shaders); + + free(linking_shaders); return linked; } diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index cf9a5157857..2ecf57f8ce2 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -219,6 +219,9 @@ compile_shader(struct gl_shader *shader) shader->symbols = state->symbols; shader->CompileStatus = !state->error; shader->Version = state->language_version; + memcpy(shader->builtins_to_link, state->builtins_to_link, + sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link); + shader->num_builtins_to_link = state->num_builtins_to_link; if (shader->InfoLog) talloc_free(shader->InfoLog); @@ -305,6 +308,7 @@ main(int argc, char **argv) talloc_free(whole_program); _mesa_glsl_release_types(); + _mesa_glsl_release_functions(); return status; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 729c2eaf0fd..f8257d565bf 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1971,6 +1971,10 @@ struct gl_shader struct exec_list *ir; struct glsl_symbol_table *symbols; + + /** Shaders containing built-in functions that are used for linking. */ + struct gl_shader *builtins_to_link[16]; + unsigned num_builtins_to_link; }; diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index a2b2eb95c82..bfb8e3201ac 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2207,6 +2207,9 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) shader->CompileStatus = !state->error; shader->InfoLog = state->info_log; shader->Version = state->language_version; + memcpy(shader->builtins_to_link, state->builtins_to_link, + sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link); + shader->num_builtins_to_link = state->num_builtins_to_link; /* Retain any live IR, but trash the rest. */ reparent_ir(shader->ir, shader); -- cgit v1.2.3 From c7a18da69022d3f9b05c21ff2473e8ea390f77f1 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 19 Jul 2010 21:44:03 -0700 Subject: glsl2: Replace insert_before/remove pairs with exec_node::replace_with. --- src/glsl/ast_function.cpp | 3 +-- src/glsl/ir_expression_flattening.cpp | 3 +-- src/glsl/ir_function_inlining.cpp | 3 +-- src/glsl/ir_if_return.cpp | 6 ++---- src/glsl/ir_vec_index_to_cond_assign.cpp | 3 +-- src/glsl/ir_vec_index_to_swizzle.cpp | 3 +-- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 73af882c530..2348bdf24fa 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -1081,8 +1081,7 @@ ast_function_expression::hir(exec_list *instructions, all_parameters_are_constant = false; if (result != ir) { - ir->insert_before(result); - ir->remove(); + ir->replace_with(result); } } diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp index 6dbebc63780..ccb2e2bce9e 100644 --- a/src/glsl/ir_expression_flattening.cpp +++ b/src/glsl/ir_expression_flattening.cpp @@ -171,8 +171,7 @@ ir_expression_flattening_visitor::visit_enter(ir_call *ir) ir_rvalue *new_ir = operand_to_temp(ir); if (new_ir != ir) { - ir->insert_before(new_ir); - ir->remove(); + ir->replace_with(new_ir); } } diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 05dd83f7ffd..c391f12d883 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -91,8 +91,7 @@ replace_return_with_assignment(ir_instruction *ir, void *data) if (ret) { if (ret->value) { ir_rvalue *lhs = new(ctx) ir_dereference_variable(retval); - ret->insert_before(new(ctx) ir_assignment(lhs, ret->value, NULL)); - ret->remove(); + ret->replace_with(new(ctx) ir_assignment(lhs, ret->value, NULL)); } else { /* un-valued return has to be the last return, or we shouldn't * have reached here. (see can_inline()). diff --git a/src/glsl/ir_if_return.cpp b/src/glsl/ir_if_return.cpp index a9af7166b96..bfb52e7e684 100644 --- a/src/glsl/ir_if_return.cpp +++ b/src/glsl/ir_if_return.cpp @@ -108,13 +108,11 @@ ir_if_return_visitor::visit_enter(ir_if *ir) assign = new(ir) ir_assignment(new(ir) ir_dereference_variable(new_var), then_return->value, NULL); - then_return->insert_before(assign); - then_return->remove(); + then_return->replace_with(assign); assign = new(ir) ir_assignment(new(ir) ir_dereference_variable(new_var), else_return->value, NULL); - else_return->insert_before(assign); - else_return->remove(); + else_return->replace_with(assign); ir_dereference_variable *deref = new(ir) ir_dereference_variable(new_var); ir->insert_after(new(ir) ir_return(deref)); diff --git a/src/glsl/ir_vec_index_to_cond_assign.cpp b/src/glsl/ir_vec_index_to_cond_assign.cpp index 7e04389b5f9..dbc6f9ada89 100644 --- a/src/glsl/ir_vec_index_to_cond_assign.cpp +++ b/src/glsl/ir_vec_index_to_cond_assign.cpp @@ -218,8 +218,7 @@ ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir) ir_rvalue *new_param = convert_vec_index_to_cond_assign(param); if (new_param != param) { - param->insert_before(new_param); - param->remove(); + param->replace_with(new_param); } } diff --git a/src/glsl/ir_vec_index_to_swizzle.cpp b/src/glsl/ir_vec_index_to_swizzle.cpp index abeb43cd68e..1e170cbae61 100644 --- a/src/glsl/ir_vec_index_to_swizzle.cpp +++ b/src/glsl/ir_vec_index_to_swizzle.cpp @@ -121,8 +121,7 @@ ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir) ir_rvalue *new_param = convert_vec_index_to_swizzle(param); if (new_param != param) { - param->insert_before(new_param); - param->remove(); + param->replace_with(new_param); } } -- cgit v1.2.3 From 0048c7aef82b17c6bd160f49125a91a70cbf2b55 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 19 Jul 2010 23:45:23 -0700 Subject: glsl2: Add some comments. --- src/glsl/ast_function.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 2348bdf24fa..1122521e0dc 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -164,6 +164,9 @@ match_function_by_name(exec_list *instructions, const char *name, /** * Perform automatic type conversion of constructor parameters + * + * This implements the rules in the "Conversion and Scalar Constructors" + * section (GLSL 1.10 section 5.4.1), not the "Implicit Conversions" rules. */ static ir_rvalue * convert_component(ir_rvalue *src, const glsl_type *desired_type) @@ -220,11 +223,11 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) assert(result != NULL); + /* Try constant folding; it may fold in the conversion we just added. */ ir_constant *const constant = result->constant_expression_value(); return (constant != NULL) ? (ir_rvalue *) constant : (ir_rvalue *) result; } - /** * Dereference a specific component from a scalar, vector, or matrix */ -- cgit v1.2.3 From 3163f87463e6d0123c4f95bd76a658cb1e5d0843 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 03:01:54 -0700 Subject: ir_constant_expression: Remove open coded equality comparisons. The ir_constant::has_value method already does this. --- src/glsl/ir_constant_expression.cpp | 40 ++----------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index cb07f381281..b0333dbebb7 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -603,46 +603,10 @@ ir_expression::constant_expression_value() break; case ir_binop_equal: - data.b[0] = true; - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[0] = data.b[0] && op[0]->value.u[c] == op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[0] = data.b[0] && op[0]->value.i[c] == op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[0] = data.b[0] && op[0]->value.f[c] == op[1]->value.f[c]; - break; - case GLSL_TYPE_BOOL: - data.b[0] = data.b[0] && op[0]->value.b[c] == op[1]->value.b[c]; - break; - default: - assert(0); - } - } + data.b[0] = op[0]->has_value(op[1]); break; case ir_binop_nequal: - data.b[0] = false; - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[0] = data.b[0] || op[0]->value.u[c] != op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[0] = data.b[0] || op[0]->value.i[c] != op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[0] = data.b[0] || op[0]->value.f[c] != op[1]->value.f[c]; - break; - case GLSL_TYPE_BOOL: - data.b[0] = data.b[0] || op[0]->value.b[c] != op[1]->value.b[c]; - break; - default: - assert(0); - } - } + data.b[0] = !op[0]->has_value(op[1]); break; default: -- cgit v1.2.3 From 46d6b8d1ba09d9d6844ce99a30416283004f77c6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 13:01:56 -0700 Subject: ir_constant_expression: Add support for ir_unop_u2f. Also make ir_unop_i2f only operate on signed integers. --- src/glsl/ir_constant_expression.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index b0333dbebb7..acfbb864597 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -87,13 +87,15 @@ ir_expression::constant_expression_value() } break; case ir_unop_i2f: - assert(op[0]->type->base_type == GLSL_TYPE_UINT || - op[0]->type->base_type == GLSL_TYPE_INT); + assert(op[0]->type->base_type == GLSL_TYPE_INT); for (unsigned c = 0; c < op[0]->type->components(); c++) { - if (op[0]->type->base_type == GLSL_TYPE_INT) - data.f[c] = op[0]->value.i[c]; - else - data.f[c] = op[0]->value.u[c]; + data.f[c] = op[0]->value.i[c]; + } + break; + case ir_unop_u2f: + assert(op[0]->type->base_type == GLSL_TYPE_UINT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = op[0]->value.u[c]; } break; case ir_unop_b2f: -- cgit v1.2.3 From e1d71850faba23d1bea3858a8c2e05a45fd21143 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 03:53:47 -0700 Subject: ast_to_hir: Fix bug in constant initializers. Implicit conversions were not being performed, nor was there any type checking - it was possible to have, say, var->type == float and var->constant_value->type == int. Later use of the constant expression would trigger an assertion. Fixes piglit test const-implicit-conversion.frag. --- src/glsl/ast_to_hir.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index e9257eee289..99a2183cf86 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1804,6 +1804,16 @@ ast_declarator_list::hir(exec_list *instructions, * declaration. */ if (this->type->qualifier.constant || this->type->qualifier.uniform) { + ir_rvalue *new_rhs = validate_assignment(state, var->type, rhs); + if (new_rhs != NULL) { + rhs = new_rhs; + } else { + _mesa_glsl_error(&initializer_loc, state, + "initializer of type %s cannot be assigned to " + "variable of type %s", + rhs->type->name, var->type->name); + } + ir_constant *constant_value = rhs->constant_expression_value(); if (!constant_value) { _mesa_glsl_error(& initializer_loc, state, -- cgit v1.2.3 From 13a19745d46d383fa7fc148ce129150ebde151b7 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 19 Jul 2010 23:49:58 -0700 Subject: glsl2: Emit array constructors inline. --- src/glsl/ast_function.cpp | 64 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 1122521e0dc..1982c83a430 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -321,22 +321,64 @@ process_array_constructor(exec_list *instructions, assert(constructor_type->length == parameter_count); } - ir_function *f = state->symbols->get_function(constructor_type->name); + bool all_parameters_are_constant = true; - /* If the constructor for this type of array does not exist, generate the - * prototype and add it to the symbol table. - */ - if (f == NULL) { - f = constructor_type->generate_constructor(state->symbols); + /* Type cast each parameter and, if possible, fold constants. */ + foreach_list_safe(n, &actual_parameters) { + ir_rvalue *ir = (ir_rvalue *) n; + ir_rvalue *result = ir; + + /* Apply implicit conversions (not the scalar constructor rules!) */ + if (constructor_type->element_type()->is_float()) { + const glsl_type *desired_type = + glsl_type::get_instance(GLSL_TYPE_FLOAT, + ir->type->vector_elements, + ir->type->matrix_columns); + result = convert_component(ir, desired_type); + } + + if (result->type != constructor_type->element_type()) { + _mesa_glsl_error(loc, state, "type error in array constructor: " + "expected: %s, found %s", + constructor_type->element_type()->name, + result->type->name); + } + + /* Attempt to convert the parameter to a constant valued expression. + * After doing so, track whether or not all the parameters to the + * constructor are trivially constant valued expressions. + */ + ir_rvalue *const constant = result->constant_expression_value(); + + if (constant != NULL) + result = constant; + else + all_parameters_are_constant = false; + + ir->replace_with(result); } - ir_rvalue *const r = - process_call(instructions, f, loc, &actual_parameters, state); + if (all_parameters_are_constant) { + /* FINISHME: Add support for generating constant arrays. */ + } - assert(r != NULL); - assert(r->type->is_error() || (r->type == constructor_type)); + ir_variable *var = new(ctx) ir_variable(constructor_type, "array_ctor", + ir_var_temporary); + instructions->push_tail(var); - return r; + int i = 0; + foreach_list(node, &actual_parameters) { + ir_rvalue *rhs = (ir_rvalue *) node; + ir_rvalue *lhs = new(ctx) ir_dereference_array(var, + new(ctx) ir_constant(i)); + + ir_instruction *assignment = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(assignment); + + i++; + } + + return new(ctx) ir_dereference_variable(var); } -- cgit v1.2.3 From 74e1802f5dd8921750851abc6128e4073602d405 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 01:06:33 -0700 Subject: glsl2: Extend ir_constant to store constant arrays, and generate them. Since GLSL permits arrays of structures, we need to store each element as an ir_constant*, not just ir_constant_data. Fixes parser tests const-array-01.frag, const-array-03.frag, const-array-04.frag, const-array-05.frag, though 03 and 04 generate the wrong code. --- src/glsl/ast_function.cpp | 5 ++--- src/glsl/ir.cpp | 23 +++++++++++++++++++++-- src/glsl/ir.h | 6 ++++++ src/glsl/ir_clone.cpp | 11 +++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 1982c83a430..855f27f1756 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -358,9 +358,8 @@ process_array_constructor(exec_list *instructions, ir->replace_with(result); } - if (all_parameters_are_constant) { - /* FINISHME: Add support for generating constant arrays. */ - } + if (all_parameters_are_constant) + return new(ctx) ir_constant(constructor_type, &actual_parameters); ir_variable *var = new(ctx) ir_variable(constructor_type, "array_ctor", ir_var_temporary); diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index a2732962f03..d3f7302b54f 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -253,9 +253,20 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) this->ir_type = ir_type_constant; this->type = type; - /* FINISHME: Support array types. */ assert(type->is_scalar() || type->is_vector() || type->is_matrix() - || type->is_record()); + || type->is_record() || type->is_array()); + + if (type->is_array()) { + this->array_elements = talloc_array(this, ir_constant *, type->length); + unsigned i = 0; + foreach_list(node, value_list) { + ir_constant *value = (ir_constant *) node; + assert(value->as_constant() != NULL); + + this->array_elements[i++] = value; + } + return; + } /* If the constant is a record, the types of each of the entries in * value_list must be a 1-for-1 match with the structure components. Each @@ -378,6 +389,14 @@ ir_constant::get_uint_component(unsigned i) const return 0; } +ir_constant * +ir_constant::get_array_element(unsigned i) const +{ + assert(this->type->is_array()); + assert(i < this->type->length); + + return array_elements[i]; +} ir_constant * ir_constant::get_record_field(const char *name) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 3a643fc5807..c73bf4ce8b2 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1268,6 +1268,8 @@ public: unsigned get_uint_component(unsigned i) const; /*@}*/ + ir_constant *get_array_element(unsigned i) const; + ir_constant *get_record_field(const char *name); /** @@ -1284,6 +1286,10 @@ public: */ union ir_constant_data value; + /* Array elements */ + ir_constant **array_elements; + + /* Structure fields */ exec_list components; private: diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index f7e8794728c..a3e4a3ae311 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -337,6 +337,17 @@ ir_constant::clone(struct hash_table *ht) const return c; } + case GLSL_TYPE_ARRAY: { + ir_constant *c = new(ctx) ir_constant; + + c->type = this->type; + c->array_elements = talloc_array(c, ir_constant *, this->type->length); + for (unsigned i = 0; i < this->type->length; i++) { + c->array_elements[i] = this->array_elements[i]->clone(NULL); + } + return c; + } + default: assert(!"Should not get here."); break; return NULL; -- cgit v1.2.3 From 7ea977a15c05f4a638478b7a5b8ca78454cecf41 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 01:23:12 -0700 Subject: ir_print_visitor: Remove commas between ir_constant's components. The IR reader does not expect commas. --- src/glsl/ir_print_visitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 6f867e32532..05ac3029922 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -272,7 +272,7 @@ void ir_print_visitor::visit(ir_constant *ir) for (unsigned i = 0; i < ir->type->components(); i++) { if (i != 0) - printf(", "); + printf(" "); switch (base_type->base_type) { case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break; -- cgit v1.2.3 From 9930d18c2aefad12152d12bc251d02ae1c1593bc Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 01:28:09 -0700 Subject: ir_print_visitor: Print out constant arrays. --- src/glsl/ir_print_visitor.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 05ac3029922..1eb073ff6a0 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -270,16 +270,20 @@ void ir_print_visitor::visit(ir_constant *ir) print_type(ir->type); printf(" ("); - for (unsigned i = 0; i < ir->type->components(); i++) { - if (i != 0) - printf(" "); - - switch (base_type->base_type) { - case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break; - case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break; - case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break; - case GLSL_TYPE_BOOL: printf("%d", ir->value.b[i]); break; - default: assert(0); + if (ir->type->is_array()) { + for (unsigned i = 0; i < ir->type->length; i++) + ir->get_array_element(i)->accept(this); + } else { + for (unsigned i = 0; i < ir->type->components(); i++) { + if (i != 0) + printf(" "); + switch (base_type->base_type) { + case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break; + case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break; + case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break; + case GLSL_TYPE_BOOL: printf("%d", ir->value.b[i]); break; + default: assert(0); + } } } printf(")) "); -- cgit v1.2.3 From ef2c38b2450eb366a2e6f6a46d1725aa6c14d74b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 01:53:07 -0700 Subject: ir_reader: Add support for reading constant arrays. --- src/glsl/ir_reader.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 8b4be4100b0..2248e926d5d 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -753,7 +753,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) { void *ctx = st; if (list->length() != 3) { - ir_read_error(st, list, "expected (constant ( ... ))"); + ir_read_error(st, list, "expected (constant (...))"); return NULL; } @@ -764,10 +764,35 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) s_list *values = SX_AS_LIST(type_expr->next); if (values == NULL) { - ir_read_error(st, list, "expected (constant ( ... ))"); + ir_read_error(st, list, "expected (constant (...))"); 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; + } + + 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); + if (ir_elt == NULL) + return NULL; + elements.push_tail(ir_elt); + } + return new(ctx) ir_constant(type, &elements); + } + const glsl_type *const base_type = type->get_base_type(); ir_constant_data data; -- cgit v1.2.3 From a096fa747611472965cf0f953bfe2757fc80383c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 01:31:29 -0700 Subject: ir_constant_expression: Add support for constant arrays. Fixes piglit test const-array-02.frag. --- src/glsl/ir_constant_expression.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index acfbb864597..d72a57c66ab 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -712,7 +712,8 @@ ir_dereference_array::constant_expression_value() return new(ctx) ir_constant(array, component); } else { - /* FINISHME: Handle access of constant arrays. */ + const unsigned index = idx->value.u[0]; + return array->get_array_element(index)->clone(NULL); } } return NULL; -- cgit v1.2.3 From 9a6d40fbfb679f01412c1fcc9d767c20a22246d8 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 03:08:32 -0700 Subject: ir_constant_expression: Add support for array == and !=. Piglit parser tests const-array-03.frag and const-array-04.frag now generate the correct code. --- src/glsl/ir.cpp | 11 ++++++++--- src/glsl/ir_constant_expression.cpp | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index d3f7302b54f..5054ec725cc 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -430,9 +430,14 @@ ir_constant::has_value(const ir_constant *c) const if (this->type != c->type) return false; - /* FINISHME: This will probably also handle constant arrays as soon as those - * FINISHME: are supported. - */ + if (this->type->is_array()) { + for (unsigned i = 0; i < this->type->length; i++) { + if (this->array_elements[i]->has_value(c->array_elements[i])) + return false; + } + return true; + } + if (this->type->base_type == GLSL_TYPE_STRUCT) { const exec_node *a_node = this->components.head; const exec_node *b_node = c->components.head; diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index d72a57c66ab..5bef17c7554 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -73,6 +73,22 @@ ir_expression::constant_expression_value() components = op[1]->type->components(); } + void *ctx = talloc_parent(this); + + /* Handle array operations here, rather than below. */ + if (op[0]->type->is_array()) { + assert(op[1] != NULL && op[1]->type->is_array()); + switch (this->operation) { + case ir_binop_equal: + return new(ctx) ir_constant(op[0]->has_value(op[1])); + case ir_binop_nequal: + return new(ctx) ir_constant(!op[0]->has_value(op[1])); + default: + break; + } + return NULL; + } + switch (this->operation) { case ir_unop_logic_not: assert(op[0]->type->base_type == GLSL_TYPE_BOOL); @@ -616,7 +632,6 @@ ir_expression::constant_expression_value() return NULL; } - void *ctx = talloc_parent(this); return new(ctx) ir_constant(this->type, &data); } -- cgit v1.2.3 From e9384d1d7fdf06b6345b3be0a70a294b90eac96e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 13:04:23 -0700 Subject: glsl2: Update TODO. --- src/glsl/TODO | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/glsl/TODO b/src/glsl/TODO index b2baa130786..07ac5f5c6e8 100644 --- a/src/glsl/TODO +++ b/src/glsl/TODO @@ -1,30 +1,7 @@ -- Handle currently unsupported constant expression types - - ir_unop_sign - - ir_unop_exp2 - - ir_unop_log2 - - ir_unop_u2f - - ir_unop_trunc - - ir_unop_ceil - - ir_unop_floor - - ir_unop_sin - - ir_unop_cos - - ir_binop_min - - ir_binop_max - - ir_binop_pow - - Handle constant expressions of (struct == struct) - Handle constant expressions of (struct != struct) -- Add support to ir_constant for array constants Arrays can only be - - declared 'const' in GLSL 1.20+. This is because there are no - array constructors in GLSL 1.10, and any variable declared as - 'const' must have an initializer. - -- Handle constant expressions of (array == array) - -- Handle constant expressions of (array != array) - - Treat built-in functions with constant parameters as constant expressions. - Rewrite all built-in functions return a single expression. - Modify the HIR generator for functions to automatically inline built-in -- cgit v1.2.3 From 7095e2f860b91288c89c57add438e912e10df38e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 21 Jul 2010 23:21:23 -0700 Subject: glsl2: Use talloc on InfoLog handling in ValidateProgram Fixes a segfault in Regnum Online. --- src/mesa/shader/shader_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index cd02d7d8307..1c1665308e4 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1380,9 +1380,9 @@ _mesa_validate_program(GLcontext *ctx, GLuint program) if (!shProg->Validated) { /* update info log */ if (shProg->InfoLog) { - free(shProg->InfoLog); + talloc_free(shProg->InfoLog); } - shProg->InfoLog = _mesa_strdup(errMsg); + shProg->InfoLog = talloc_strdup(shProg, errMsg); } } -- cgit v1.2.3 From c8d0a9f0065c321308be635529c95735f3beb68f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 12:11:36 -0700 Subject: ir_to_mesa: Add support for MESA_GLSL=dump environment var. --- src/mesa/shader/ir_to_mesa.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index bfb8e3201ac..c92fe49a207 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2030,12 +2030,21 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, int i; struct gl_program *prog; GLenum target; + const char *target_string; GLboolean progress; switch (shader->Type) { - case GL_VERTEX_SHADER: target = GL_VERTEX_PROGRAM_ARB; break; - case GL_FRAGMENT_SHADER: target = GL_FRAGMENT_PROGRAM_ARB; break; - default: assert(!"should not be reached"); break; + case GL_VERTEX_SHADER: + target = GL_VERTEX_PROGRAM_ARB; + target_string = "vertex"; + break; + case GL_FRAGMENT_SHADER: + target = GL_FRAGMENT_PROGRAM_ARB; + target_string = "fragment"; + break; + default: + assert(!"should not be reached"); + break; } validate_ir_tree(shader->ir); @@ -2127,7 +2136,8 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, } set_branchtargets(&v, mesa_instructions, num_instructions); - if (0) { + if (ctx->Shader.Flags & GLSL_DUMP) { + printf("Mesa %s program:\n", target_string); print_program(mesa_instructions, mesa_instruction_annotation, num_instructions); } -- cgit v1.2.3 From cc15ef07e03e465d93df7062a516f9b4bfbaeda0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 12:16:11 -0700 Subject: mesa: Only complain about an infinite loop in a swrast program once. Chances are, if one fragment looped badly, others will too, and debugging output gets overwhelmed by the looping complaints. --- src/mesa/shader/prog_execute.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index f85c6513f31..b6da3449b26 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -1788,7 +1788,11 @@ _mesa_execute_program(GLcontext * ctx, numExec++; if (numExec > maxExec) { - _mesa_problem(ctx, "Infinite loop detected in fragment program"); + static GLboolean reported = GL_FALSE; + if (!reported) { + _mesa_problem(ctx, "Infinite loop detected in fragment program"); + reported = GL_TRUE; + } return GL_TRUE; } -- cgit v1.2.3 From 748c343f8bdbbc8c5f00403b790ad7130424c35f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 12:25:39 -0700 Subject: ir_to_mesa: Pretty up the printing of MESA_GLSL=dump --- src/mesa/shader/ir_to_mesa.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index c92fe49a207..ba45c87e59c 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1885,19 +1885,29 @@ print_program(struct prog_instruction *mesa_instructions, { ir_instruction *last_ir = NULL; int i; + int indent = 0; for (i = 0; i < num_instructions; i++) { struct prog_instruction *mesa_inst = mesa_instructions + i; ir_instruction *ir = mesa_instruction_annotation[i]; + fprintf(stdout, "%3d: ", i); + if (last_ir != ir && ir) { - ir_print_visitor print; - ir->accept(&print); + int j; + + for (j = 0; j < indent; j++) { + fprintf(stdout, " "); + } + ir->print(); printf("\n"); last_ir = ir; + + fprintf(stdout, " "); /* line number spacing. */ } - _mesa_print_instruction(mesa_inst); + indent = _mesa_fprint_instruction_opt(stdout, mesa_inst, indent, + PROG_PRINT_DEBUG, NULL); } } -- cgit v1.2.3 From 2d1ed7b1b112cf13dd7eda7f500691f4c98a1ccc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 12:55:16 -0700 Subject: glsl2: When a "continue" happens in a "for" loop, run the loop expression. Fixes: glsl1-for-loop with continue Bug #29097 --- src/glsl/ast_to_hir.cpp | 14 ++++++++++++++ src/glsl/glsl_parser_extras.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 99a2183cf86..0cb3863b3ef 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2308,6 +2308,16 @@ ast_jump_statement::hir(exec_list *instructions, } else { ir_loop *const loop = state->loop_or_switch_nesting->as_loop(); + /* Inline the for loop expression again, since we don't know + * where near the end of the loop body the normal copy of it + * is going to be placed. + */ + if (mode == ast_continue && + state->loop_or_switch_nesting_ast->rest_expression) { + state->loop_or_switch_nesting_ast->rest_expression->hir(instructions, + state); + } + if (loop != NULL) { ir_loop_jump *const jump = new(ctx) ir_loop_jump((mode == ast_break) @@ -2422,7 +2432,10 @@ ast_iteration_statement::hir(exec_list *instructions, /* Track the current loop and / or switch-statement nesting. */ ir_instruction *const nesting = state->loop_or_switch_nesting; + ast_iteration_statement *nesting_ast = state->loop_or_switch_nesting_ast; + state->loop_or_switch_nesting = stmt; + state->loop_or_switch_nesting_ast = this; if (mode != ast_do_while) condition_to_hir(stmt, state); @@ -2442,6 +2455,7 @@ ast_iteration_statement::hir(exec_list *instructions, /* Restore previous nesting before returning. */ state->loop_or_switch_nesting = nesting; + state->loop_or_switch_nesting_ast = nesting_ast; /* Loops do not have r-values. */ diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 56f6e18e0bd..3865843fd10 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -104,6 +104,7 @@ struct _mesa_glsl_parse_state { /** Loop or switch statement containing the current instructions. */ class ir_instruction *loop_or_switch_nesting; + class ast_iteration_statement *loop_or_switch_nesting_ast; /** List of structures defined in user code. */ const glsl_type **user_structures; -- cgit v1.2.3 From 8ec0b8187ea695353c75eed7314e86344df60e5a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 13:52:41 -0700 Subject: glsl2: When inlining, don't clone and assign sampler arguments. Instead, just use the incoming sampler param. Fixes many texture-using piglit tests since the linker rework. --- src/glsl/ir_function_inlining.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index c391f12d883..b143190ff6e 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -133,17 +133,27 @@ ir_call::generate_inline(ir_instruction *next_ir) exec_list_iterator sig_param_iter = this->callee->parameters.iterator(); exec_list_iterator param_iter = this->actual_parameters.iterator(); for (i = 0; i < num_parameters; i++) { - const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get(); + ir_variable *sig_param = (ir_variable *) sig_param_iter.get(); ir_rvalue *param = (ir_rvalue *) param_iter.get(); /* Generate a new variable for the parameter. */ - parameters[i] = sig_param->clone(ht); - parameters[i]->mode = ir_var_auto; - next_ir->insert_before(parameters[i]); + if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) { + /* For samplers, we want the inlined sampler references + * referencing the passed in sampler variable, since that + * will have the location information, which an assignment of + * a sampler wouldn't. + */ + parameters[i] = NULL; + hash_table_insert(ht, param->variable_referenced(), sig_param); + } else { + parameters[i] = sig_param->clone(ht); + parameters[i]->mode = ir_var_auto; + next_ir->insert_before(parameters[i]); + } /* Move the actual param into our param variable if it's an 'in' type. */ - if (sig_param->mode == ir_var_in || - sig_param->mode == ir_var_inout) { + if (parameters[i] && (sig_param->mode == ir_var_in || + sig_param->mode == ir_var_inout)) { ir_assignment *assign; assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]), @@ -175,8 +185,8 @@ ir_call::generate_inline(ir_instruction *next_ir) const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get(); /* Move our param variable into the actual param if it's an 'out' type. */ - if (sig_param->mode == ir_var_out || - sig_param->mode == ir_var_inout) { + if (parameters[i] && (sig_param->mode == ir_var_out || + sig_param->mode == ir_var_inout)) { ir_assignment *assign; assign = new(ctx) ir_assignment(param->clone(NULL)->as_rvalue(), -- cgit v1.2.3 From e65dfa89eef86be127d788ecd5bd23c35c8fbbe4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 14:25:26 -0700 Subject: glsl2: Fix the type of (1.0 - arg2) for mix(gen, gen, float). Previously, we'd constant-fold up a value of vec4(1.0 - arg2, 0, 0, 0). Fixes: glsl1-mix(vec4) function --- src/glsl/builtin_function.cpp | 6 +++--- src/glsl/builtins/110/mix | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 10e59e491e4..ae0eabcf778 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -1320,21 +1320,21 @@ static const char *builtins_110_mix = { " (declare (in) vec2 arg0)\n" " (declare (in) vec2 arg1)\n" " (declare (in) float arg2))\n" - " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" + " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 arg0)\n" " (declare (in) vec3 arg1)\n" " (declare (in) float arg2))\n" - " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" + " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1)\n" " (declare (in) float arg2))\n" - " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" + " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" "))\n" }; diff --git a/src/glsl/builtins/110/mix b/src/glsl/builtins/110/mix index 032f29e5fa8..8638d06887c 100644 --- a/src/glsl/builtins/110/mix +++ b/src/glsl/builtins/110/mix @@ -32,19 +32,19 @@ (declare (in) vec2 arg0) (declare (in) vec2 arg1) (declare (in) float arg2)) - ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) + ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) (signature vec3 (parameters (declare (in) vec3 arg0) (declare (in) vec3 arg1) (declare (in) float arg2)) - ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) + ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) (signature vec4 (parameters (declare (in) vec4 arg0) (declare (in) vec4 arg1) (declare (in) float arg2)) - ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) + ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) )) -- cgit v1.2.3 From 47c90b144729e3edf3b5cbf5b260c1c46e429879 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 22 Jul 2010 14:56:14 -0700 Subject: glsl2: Fix expected type for multiplying vector with non-square matrix. Previously, the compiler expected the result of the multiplication to be of the same type as the vector. This is correct for square matrices, but wrong for all others. We fix this by instead expecting a vector with the same number of rows as the matrix (for the case of M*v with a column vector) or the same number of columns as the matrix (for v*M with a row vector). This fix causes the following four glean tests to now pass: glsl1-mat4x2 * vec4 glsl1-vec2 * mat4x2 multiply glsl1-vec3 * mat4x3 multiply glsl1-vec4 * mat3x4 multiply --- src/glsl/ast_to_hir.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 0cb3863b3ef..5e26f21e9af 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -282,8 +282,17 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, * means the vector type of a row from A must be the same as the * vector the type of B. */ - if (type_a->row_type() == type_b) - return type_b; + if (type_a->row_type() == type_b) { + /* The resulting vector has a number of elements equal to + * the number of rows of matrix A. */ + const glsl_type *const type = + glsl_type::get_instance(type_a->base_type, + type_a->column_type()->vector_elements, + 1); + assert(type != glsl_type::error_type); + + return type; + } } else { assert(type_b->is_matrix()); @@ -292,8 +301,17 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, * the type of A must be the same as the vector type of a column from * B. */ - if (type_a == type_b->column_type()) - return type_a; + if (type_a == type_b->column_type()) { + /* The resulting vector has a number of elements equal to + * the number of columns of matrix B. */ + const glsl_type *const type = + glsl_type::get_instance(type_a->base_type, + type_b->row_type()->vector_elements, + 1); + assert(type != glsl_type::error_type); + + return type; + } } _mesa_glsl_error(loc, state, "size mismatch for matrix multiplication"); -- cgit v1.2.3 From 1bef4c8c4bc11e7f4150500def6e6a4291ceb587 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 14:57:55 -0700 Subject: glsl2: Fix builtin prototypes defined in multiple glsl/builtins/* files If we put the protos in separate ir_functions, they wouldn't be found at lookup time for linking. Fixes: glsl-fs-texture2d-bias glsl-fs-texture2dproj-bias glsl-fs-texture2dproj-bias-2 glsl-lod-bias glsl1-texture2D(), computed coordinate --- src/glsl/ir_import_prototypes.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/glsl/ir_import_prototypes.cpp b/src/glsl/ir_import_prototypes.cpp index 20aa8a6ae23..5c5dc00ad71 100644 --- a/src/glsl/ir_import_prototypes.cpp +++ b/src/glsl/ir_import_prototypes.cpp @@ -55,7 +55,17 @@ public: virtual ir_visitor_status visit_enter(ir_function *ir) { assert(this->function == NULL); - this->function = new(this->mem_ctx) ir_function(ir->name); + + this->function = this->symbols->get_function(ir->name); + if (!this->function) { + this->function = new(this->mem_ctx) ir_function(ir->name); + + list->push_tail(this->function); + + /* Add the new function to the symbol table. + */ + this->symbols->add_function(this->function->name, this->function); + } return visit_continue; } @@ -64,15 +74,6 @@ public: (void) ir; assert(this->function != NULL); - /* Add the new function (and all its signatures) to the end of the - * instruction stream. - */ - list->push_tail(this->function); - - /* Add the new function to the symbol table. - */ - this->symbols->add_function(this->function->name, this->function); - this->function = NULL; return visit_continue; } -- cgit v1.2.3 From a711ad6bf2407f63110de8e8f216eacd09dd8e82 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 15:17:23 -0700 Subject: glsl2: Add the API defines to the glsl2 build so we get the right GLcontext Fixes: draw_buffers-08.frag draw_buffers-09.frag glsl-vs-texturematrix-2 --- src/glsl/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 47292bdb156..f4b0fb55a78 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -81,6 +81,10 @@ GLSL2_OBJECTS = \ ### Basic defines ### +DEFINES = \ + $(LIBRARY_DEFINES) \ + $(API_DEFINES) + GLCPP_OBJECTS = \ $(GLCPP_SOURCES:.c=.o) \ ../mesa/shader/hash_table.o @@ -134,10 +138,10 @@ glcpp/glcpp: $(GLCPP_OBJECTS) libglsl.a $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) $(LIBS) -o $@ .cpp.o: - $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@ + $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@ .c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ glsl_lexer.cpp: glsl_lexer.lpp flex --never-interactive --outfile="$@" $< -- cgit v1.2.3 From c3081e627302429cdf2ee23a40fb20fa5cbf5770 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 15:34:01 -0700 Subject: glsl2: Set the type on cloned tex instructions. --- src/glsl/ir_clone.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index a3e4a3ae311..c49a7324818 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -210,6 +210,7 @@ ir_texture::clone(struct hash_table *ht) const { void *ctx = talloc_parent(this); ir_texture *new_tex = new(ctx) ir_texture(this->op); + new_tex->type = this->type; new_tex->sampler = this->sampler->clone(ht); new_tex->coordinate = this->coordinate->clone(ht); -- cgit v1.2.3 From 9703ed05e684f4269cd8af27c94e9b6bf8781d85 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 15:50:37 -0700 Subject: glsl2: When setting the size of an unsized array, set its deref's size too. --- src/glsl/ast_to_hir.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 5e26f21e9af..c03206fd2e5 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -531,6 +531,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, var->type = glsl_type::get_array_instance(lhs->type->element_type(), rhs->type->array_size()); + d->type = var->type; } } -- cgit v1.2.3 From 85e93da18ca2c967ca12870b62ab1aac2f0b880c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 16:11:08 -0700 Subject: ir_to_mesa: Fix the swizzles on record and array dereferences. Fixes: glsl1-struct (1) glsl1-struct (2) glsl1-struct (3) glsl1-struct (4) --- src/mesa/shader/ir_to_mesa.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index ba45c87e59c..c397838e259 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1151,7 +1151,10 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) src_reg.file = entry->file; src_reg.index = entry->index; /* If the type is smaller than a vec4, replicate the last channel out. */ - src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); + if (ir->type->is_scalar() || ir->type->is_vector()) + src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); + else + src_reg.swizzle = SWIZZLE_NOOP; src_reg.reladdr = NULL; src_reg.negate = 0; @@ -1231,7 +1234,10 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) } /* If the type is smaller than a vec4, replicate the last channel out. */ - src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); + if (ir->type->is_scalar() || ir->type->is_vector()) + src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); + else + src_reg.swizzle = SWIZZLE_NOOP; this->result = src_reg; } @@ -1250,6 +1256,7 @@ ir_to_mesa_visitor::visit(ir_dereference_record *ir) break; offset += type_size(struct_type->fields.structure[i].type); } + this->result.swizzle = swizzle_for_size(ir->type->vector_elements); this->result.index += offset; } @@ -1322,7 +1329,6 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) int i; assert(!ir->lhs->type->is_array()); - assert(ir->lhs->type->base_type != GLSL_TYPE_STRUCT); ir->rhs->accept(this); r = this->result; -- cgit v1.2.3 From 432b787b29202301dbfc139c3289521b0bfc3dec Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 16:24:49 -0700 Subject: glsl2: Validate that ir_if conditions are actually bool. --- src/glsl/ir_validate.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index c05edf2ee3d..bb381a00df3 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -59,6 +59,7 @@ public: virtual ir_visitor_status visit(ir_variable *v); virtual ir_visitor_status visit(ir_dereference_variable *ir); + virtual ir_visitor_status visit(ir_if *ir); virtual ir_visitor_status visit_enter(ir_function *ir); virtual ir_visitor_status visit_leave(ir_function *ir); @@ -93,6 +94,18 @@ ir_validate::visit(ir_dereference_variable *ir) return visit_continue; } +ir_visitor_status +ir_validate::visit(ir_if *ir) +{ + if (ir->condition->type != glsl_type::bool_type) { + printf("ir_if condition %s type instead of bool.\n", + ir->condition->type->name); + ir->print(); + printf("\n"); + abort(); + } +} + ir_visitor_status ir_validate::visit_enter(ir_function *ir) -- cgit v1.2.3 From a0879b9dd438d78635f047cdd5ed4c72bc831b60 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 16:30:41 -0700 Subject: glsl2: Put side effects of the RHS of logic_or in the right branch. Kind of missing the point to only do the side effects if the LHS evaluates as true. Fixes: glsl1-|| operator, short-circuit --- src/glsl/ast_to_hir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index c03206fd2e5..98ea789249d 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -898,7 +898,7 @@ ast_expression::hir(exec_list *instructions, ir_if *const stmt = new(ctx) ir_if(op[0]); instructions->push_tail(stmt); - op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state); + op[1] = this->subexpressions[1]->hir(&stmt->else_instructions, state); if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) { YYLTYPE loc = this->subexpressions[1]->get_location(); -- cgit v1.2.3 From fbe4240626bfe102a9c4c889ee18cb9ea27bddec Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 22 Jul 2010 16:36:04 -0700 Subject: glcpp: Fix function-like macros with an argument used multiple times. It's really hard to believe that this case has been broken, but apparently no test previously exercised it. So this commit adds such a test and fixes it by making a copy of the argument token-list before expanding it. This fix causes the following glean tests to now pass: glsl1-Preprocessor test 6 (#if 0, #define macro) glsl1-Preprocessor test 7 (multi-line #define) --- src/glsl/glcpp/glcpp-parse.y | 10 +++++++--- src/glsl/glcpp/tests/069-repeated-argument.c | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/glsl/glcpp/tests/069-repeated-argument.c diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index e4dcc76e0a7..5b7467836d7 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -1075,7 +1075,7 @@ _token_list_create_with_one_space (void *ctx) * * Returns the token list that results from the expansion and sets * *last to the last node in the list that was consumed by the - * expansion. Specificallty, *last will be set as follows: as the + * expansion. Specifically, *last will be set as follows: as the * token of the closing right parenthesis. */ static token_list_t * @@ -1147,9 +1147,13 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser, * tokens, or append a placeholder token for * an empty argument. */ if (argument->head) { + token_list_t *expanded_argument; + expanded_argument = _token_list_copy (parser, + argument); _glcpp_parser_expand_token_list (parser, - argument); - _token_list_append_list (substituted, argument); + expanded_argument); + _token_list_append_list (substituted, + expanded_argument); } else { token_t *new_token; diff --git a/src/glsl/glcpp/tests/069-repeated-argument.c b/src/glsl/glcpp/tests/069-repeated-argument.c new file mode 100644 index 00000000000..2b46ead294c --- /dev/null +++ b/src/glsl/glcpp/tests/069-repeated-argument.c @@ -0,0 +1,2 @@ +#define double(x) x x +double(1) -- cgit v1.2.3 From 40c4298a6ea9e83b49858916d5423fd2135ef39c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Jul 2010 16:18:57 -0700 Subject: ir_print_visitor: Add "temporary" to mode string printing. Variables with mode ir_var_temporary were causing an out of bounds array access and filling my screen with rubbish. I'm not sure if "temporary" is the right thing to print. --- src/glsl/ir_print_visitor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 1eb073ff6a0..ee489cda7f3 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -85,7 +85,8 @@ void ir_print_visitor::visit(ir_variable *ir) const char *const cent = (ir->centroid) ? "centroid " : ""; const char *const inv = (ir->invariant) ? "invariant " : ""; - const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " }; + const char *const mode[] = { "", "uniform ", "in ", "out ", "inout ", + "temporary " }; const char *const interp[] = { "", "flat", "noperspective" }; printf("(%s%s%s%s) ", -- cgit v1.2.3 From aa9f86ae8b3bb2172092ff9b50751677c509e6b4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Jul 2010 16:20:36 -0700 Subject: glsl2: Fix standalone compiler to not crash horribly. ir_to_mesa was updated for the _mesa_glsl_parse_state constructor changes, but main.cpp was not. --- src/glsl/glsl_parser_extras.cpp | 23 +++++++++++++++++++++ src/glsl/main.cpp | 45 ++++------------------------------------- 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index bcf2579733d..009aabcd354 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -68,10 +68,33 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct __GLcontextRec *ctx, this->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; } else { + /* If there is no GL context (standalone compiler), fill in constants + * with the minimum required values. + */ static struct gl_extensions null_extensions; memset(&null_extensions, 0, sizeof(null_extensions)); this->extensions = &null_extensions; + + /* 1.10 minimums. */ + this->Const.MaxLights = 8; + this->Const.MaxClipPlanes = 8; + this->Const.MaxTextureUnits = 2; + + /* More than the 1.10 minimum to appease parser tests taken from + * apps that (hopefully) already checked the number of coords. + */ + this->Const.MaxTextureCoords = 4; + + this->Const.MaxVertexAttribs = 16; + this->Const.MaxVertexUniformComponents = 512; + this->Const.MaxVaryingFloats = 32; + this->Const.MaxVertexTextureImageUnits = 0; + this->Const.MaxCombinedTextureImageUnits = 2; + this->Const.MaxTextureImageUnits = 2; + this->Const.MaxFragmentUniformComponents = 64; + + this->Const.MaxDrawBuffers = 2; } } diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 2ecf57f8ce2..5c0f6475e0b 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -121,49 +121,12 @@ const struct option compiler_opts[] = { void compile_shader(struct gl_shader *shader) { - struct _mesa_glsl_parse_state *state; - struct gl_extensions ext; - - state = talloc_zero(talloc_parent(shader), struct _mesa_glsl_parse_state); - - switch (shader->Type) { - case GL_VERTEX_SHADER: state->target = vertex_shader; break; - case GL_FRAGMENT_SHADER: state->target = fragment_shader; break; - case GL_GEOMETRY_SHADER: state->target = geometry_shader; break; - } - - state->scanner = NULL; - state->translation_unit.make_empty(); - state->symbols = new(shader) glsl_symbol_table; - state->info_log = talloc_strdup(shader, ""); - state->error = false; - state->loop_or_switch_nesting = NULL; - state->ARB_texture_rectangle_enable = true; - - memset(&ext, 0, sizeof(ext)); - state->extensions = &ext; - /* 1.10 minimums. */ - state->Const.MaxLights = 8; - state->Const.MaxClipPlanes = 8; - state->Const.MaxTextureUnits = 2; - - /* More than the 1.10 minimum to appease parser tests taken from - * apps that (hopefully) already checked the number of coords. - */ - state->Const.MaxTextureCoords = 4; - - state->Const.MaxVertexAttribs = 16; - state->Const.MaxVertexUniformComponents = 512; - state->Const.MaxVaryingFloats = 32; - state->Const.MaxVertexTextureImageUnits = 0; - state->Const.MaxCombinedTextureImageUnits = 2; - state->Const.MaxTextureImageUnits = 2; - state->Const.MaxFragmentUniformComponents = 64; - - state->Const.MaxDrawBuffers = 2; + struct _mesa_glsl_parse_state *state = + new(shader) _mesa_glsl_parse_state(NULL, shader->Type, shader); const char *source = shader->Source; - state->error = preprocess(state, &source, &state->info_log, &ext); + state->error = preprocess(state, &source, &state->info_log, + state->extensions); if (!state->error) { _mesa_glsl_lexer_ctor(state, source); -- cgit v1.2.3 From 3c033637de7def553559c11d037f2e8bbb750f77 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Jul 2010 16:40:35 -0700 Subject: glsl2: Make ir_assignment derive from ir_instruction, not ir_rvalue. Assignments can only exist at the top level instruction stream; the residual value is handled by assigning the value to a temporary and returning an ir_dereference_variable of that temporary. --- src/glsl/ir.h | 2 +- src/glsl/ir_reader.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index c73bf4ce8b2..3fd3a7660bc 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -506,7 +506,7 @@ public: }; -class ir_assignment : public ir_rvalue { +class ir_assignment : public ir_instruction { public: ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 2248e926d5d..14bd2d62fd7 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -357,6 +357,8 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, ir_instruction *inst = NULL; if (strcmp(tag->value(), "declare") == 0) { inst = read_declaration(st, list); + } else if (strcmp(tag->value(), "assign") == 0) { + inst = read_assignment(st, list); } else if (strcmp(tag->value(), "if") == 0) { inst = read_if(st, list, loop_ctx); } else if (strcmp(tag->value(), "loop") == 0) { @@ -546,8 +548,6 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) return rvalue; else if (strcmp(tag->value(), "swiz") == 0) { rvalue = read_swizzle(st, list); - } else if (strcmp(tag->value(), "assign") == 0) { - rvalue = read_assignment(st, list); } else if (strcmp(tag->value(), "expression") == 0) { rvalue = read_expression(st, list); } else if (strcmp(tag->value(), "call") == 0) { -- cgit v1.2.3 From 0a89175a35ba3ac2a94d0ba9bcc9926edc8927e3 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Jul 2010 16:45:37 -0700 Subject: glsl2: Initialize ir_instruction::type and ir_rvalue::type. Top-level instructions now get NULL as their default type (since type is irrelevant for things like ir_function), while ir_rvalues get error_type by default. This should make it easier to tell if we've forgotten to set a type. It also fixes some "Conditional jump or move depends on uninitialized value" errors in valgrind caused by ir_validate examining the type of top level ir_instructions, which weren't set. --- src/glsl/ir.cpp | 5 +++++ src/glsl/ir.h | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 5054ec725cc..8ebef7d95a3 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -26,6 +26,11 @@ #include "ir_visitor.h" #include "glsl_types.h" +ir_rvalue::ir_rvalue() +{ + this->type = glsl_type::error_type; +} + ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition) { diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 3fd3a7660bc..e0f3683a7ab 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -106,6 +106,7 @@ protected: ir_instruction() { ir_type = ir_type_unset; + type = NULL; } }; @@ -150,10 +151,7 @@ public: } protected: - ir_rvalue() - { - /* empty */ - } + ir_rvalue(); }; -- cgit v1.2.3 From 63a92c975dd97445979c6aa1c5fef63d37bfc897 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:17:44 -0700 Subject: glsl2/builtins: Fix "mod" builtin to use scalar/vector operations. --- src/glsl/builtins/110/mod | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/glsl/builtins/110/mod b/src/glsl/builtins/110/mod index 9e08bbc7ef4..aeaea240e2d 100644 --- a/src/glsl/builtins/110/mod +++ b/src/glsl/builtins/110/mod @@ -27,38 +27,17 @@ (parameters (declare (in) vec2 arg0) (declare (in) float arg1)) - ((declare () vec2 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec2 % (var_ref arg0) (var_ref arg1))))) (signature vec3 (parameters (declare (in) vec3 arg0) (declare (in) float arg1)) - ((declare () vec3 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float % (swiz z (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec3 % (var_ref arg0) (var_ref arg1))))) (signature vec4 (parameters (declare (in) vec4 arg0) (declare (in) float arg1)) - ((declare () vec4 result) - (assign (constant bool (1)) (swiz x (var_ref result)) - (expression float % (swiz x (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz y (var_ref result)) - (expression float % (swiz y (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz z (var_ref result)) - (expression float % (swiz z (var_ref arg0)) (var_ref arg1))) - (assign (constant bool (1)) (swiz w (var_ref result)) - (expression float % (swiz w (var_ref arg0)) (var_ref arg1))) - (return (var_ref result)))) + ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) )) -- cgit v1.2.3 From 5304c251fcceca40096d69002efcf1a122df259d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:25:49 -0700 Subject: glsl2/builtins: Fix 1.30 sign implementation for ints. --- src/glsl/builtins/130/sign | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/builtins/130/sign b/src/glsl/builtins/130/sign index 170795948b2..f86062a2443 100644 --- a/src/glsl/builtins/130/sign +++ b/src/glsl/builtins/130/sign @@ -2,7 +2,7 @@ (signature int (parameters (declare (in) int x)) - ((return (expression int / (var_ref x) (expression int abs (var_ref x)))))) + ((return (expression int sign (var_ref x))))) (signature ivec2 (parameters -- cgit v1.2.3 From 0b8e5f384c75b56bf2ee34c317bb9d06095c798b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Jul 2010 16:52:32 -0700 Subject: glsl2/builtins: Add 1.30 bvec variant of the "mix" builtin. --- src/glsl/builtins/130/mix | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/glsl/builtins/130/mix diff --git a/src/glsl/builtins/130/mix b/src/glsl/builtins/130/mix new file mode 100644 index 00000000000..9a1fcd70ffa --- /dev/null +++ b/src/glsl/builtins/130/mix @@ -0,0 +1,39 @@ +((function mix + (signature float + (parameters + (declare (in) float v1) + (declare (in) float v2) + (declare (in) bool a)) + ((assign (var_ref a) (var_ref v1) (var_ref v2)) + (return (var_ref v1)))) + + (signature vec2 + (parameters + (declare (in) vec2 v1) + (declare (in) vec2 v2) + (declare (in) bvec2 a)) + ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2))) + (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2))) + (return (var_ref v1)))) + + (signature vec3 + (parameters + (declare (in) vec3 v1) + (declare (in) vec3 v2) + (declare (in) bvec3 a)) + ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2))) + (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2))) + (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2))) + (return (var_ref v1)))) + + (signature vec4 + (parameters + (declare (in) vec4 v1) + (declare (in) vec4 v2) + (declare (in) bvec4 a)) + ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2))) + (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2))) + (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2))) + (assign (swiz w (var_ref a)) (swiz w (var_ref v1)) (swiz w (var_ref v2))) + (return (var_ref v1)))) +)) -- cgit v1.2.3 From 0a71527dabb7086e81d488451cf4a5cd90380938 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:33:57 -0700 Subject: glsl2: Refresh autogenerated file builtin_function.cpp. --- src/glsl/builtin_function.cpp | 72 ++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index ae0eabcf778..cc957e4b661 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -1368,40 +1368,19 @@ static const char *builtins_110_mod = { " (parameters\n" " (declare (in) vec2 arg0)\n" " (declare (in) float arg1))\n" - " ((declare () vec2 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 arg0)\n" " (declare (in) float arg1))\n" - " ((declare () vec3 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float % (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 arg0)\n" " (declare (in) float arg1))\n" - " ((declare () vec4 result)\n" - " (assign (constant bool (1)) (swiz x (var_ref result))\n" - " (expression float % (swiz x (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz y (var_ref result))\n" - " (expression float % (swiz y (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz z (var_ref result))\n" - " (expression float % (swiz z (var_ref arg0)) (var_ref arg1)))\n" - " (assign (constant bool (1)) (swiz w (var_ref result))\n" - " (expression float % (swiz w (var_ref arg0)) (var_ref arg1)))\n" - " (return (var_ref result))))\n" + " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" "))\n" }; @@ -3406,6 +3385,48 @@ static const char *builtins_130_min = { "))\n" }; +static const char *builtins_130_mix = { + "((function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float v1)\n" + " (declare (in) float v2)\n" + " (declare (in) bool a))\n" + " ((assign (var_ref a) (var_ref v1) (var_ref v2))\n" + " (return (var_ref v1))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 v1)\n" + " (declare (in) vec2 v2)\n" + " (declare (in) bvec2 a))\n" + " ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2)))\n" + " (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2)))\n" + " (return (var_ref v1))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 v1)\n" + " (declare (in) vec3 v2)\n" + " (declare (in) bvec3 a))\n" + " ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2)))\n" + " (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2)))\n" + " (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2)))\n" + " (return (var_ref v1))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 v1)\n" + " (declare (in) vec4 v2)\n" + " (declare (in) bvec4 a))\n" + " ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2)))\n" + " (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2)))\n" + " (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2)))\n" + " (assign (swiz w (var_ref a)) (swiz w (var_ref v1)) (swiz w (var_ref v2)))\n" + " (return (var_ref v1))))\n" + "))\n" +}; + static const char *builtins_130_notEqual = { "((function notEqual\n" " (signature bvec2\n" @@ -3445,7 +3466,7 @@ static const char *builtins_130_sign = { " (signature int\n" " (parameters\n" " (declare (in) int x))\n" - " ((return (expression int / (var_ref x) (expression int abs (var_ref x))))))\n" + " ((return (expression int sign (var_ref x)))))\n" "\n" " (signature ivec2\n" " (parameters\n" @@ -4387,6 +4408,7 @@ static const char *functions_for_130 [] = { builtins_130_lessThanEqual, builtins_130_max, builtins_130_min, + builtins_130_mix, builtins_130_notEqual, builtins_130_sign, builtins_130_sinh, -- cgit v1.2.3 From 3e882ec84a2493da74c55d105010a37de521e593 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Jul 2010 17:44:34 -0700 Subject: ir_constant_expression: Fix broken code for floating point modulus. It's supposed to be x - y * floor(x/y), not (x - y) * floor(x/y). --- src/glsl/ir_constant_expression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 5bef17c7554..f15530ae89e 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -533,7 +533,7 @@ ir_expression::constant_expression_value() /* We don't use fmod because it rounds toward zero; GLSL specifies * the use of floor. */ - data.f[c] = (op[0]->value.f[c0] - op[1]->value.f[c1]) + data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1] * floorf(op[0]->value.f[c0] / op[1]->value.f[c1]); break; default: -- cgit v1.2.3 From d64343f1ae84979bd154475badf11af8a9bfc2eb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Jul 2010 17:30:35 -0700 Subject: ir_to_mesa: Flag when we use the address reg. Hardware backends will get angry otherwise. --- src/mesa/shader/ir_to_mesa.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index c397838e259..89cad8a8b0f 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -2146,6 +2146,8 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, inst->function->inst = i; else if (mesa_inst->Opcode == OPCODE_CAL) mesa_inst->BranchTarget = inst->function->sig_id; /* rewritten later */ + else if (mesa_inst->Opcode == OPCODE_ARL) + prog->NumAddressRegs = 1; mesa_inst++; i++; -- cgit v1.2.3 From e2130d4e39b6ebd9f5d39598a006906680efd830 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Jul 2010 17:54:35 -0700 Subject: glsl2: Remove old .gitignore file from when we were out of tree. --- src/glsl/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/glsl/.gitignore diff --git a/src/glsl/.gitignore b/src/glsl/.gitignore deleted file mode 100644 index e90b98accb5..00000000000 --- a/src/glsl/.gitignore +++ /dev/null @@ -1 +0,0 @@ -glsl -- cgit v1.2.3 From eb2cc4f1b1f5ac657c632aa41da5f23eb1cdbe10 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 23 Jul 2010 12:49:17 -0700 Subject: glsl2: Steal ir_variable's constant_value field. Fixes a link-time crash in glsl-vs-cross-3. --- src/glsl/ir.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 8ebef7d95a3..2fd654e9bfe 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -908,6 +908,9 @@ visit_exec_list(exec_list *list, ir_visitor *visitor) static void steal_memory(ir_instruction *ir, void *new_ctx) { + ir_variable *var = ir->as_variable(); + if (var != NULL && var->constant_value != NULL) + talloc_steal(ir, var->constant_value); talloc_steal(new_ctx, ir); } -- cgit v1.2.3 From fbaca31352678ab7d7bf132f0c9a6aa29ca9fabf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Jul 2010 19:26:53 -0700 Subject: glsl2: Also steal the constant components of aggregate-typed ir_constants. --- src/glsl/ir.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 2fd654e9bfe..6dccbd806e8 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -909,8 +909,26 @@ static void steal_memory(ir_instruction *ir, void *new_ctx) { ir_variable *var = ir->as_variable(); + ir_constant *constant = ir->as_constant(); if (var != NULL && var->constant_value != NULL) talloc_steal(ir, var->constant_value); + + /* The components of aggregate constants are not visited by the normal + * visitor, so steal their values by hand. + */ + if (constant != NULL) { + if (constant->type->is_record()) { + foreach_iter(exec_list_iterator, iter, constant->components) { + ir_constant *field = (ir_constant *)iter.get(); + steal_memory(field, ir); + } + } else if (constant->type->is_array()) { + for (unsigned int i = 0; i < constant->type->length; i++) { + steal_memory(constant->array_elements[i], ir); + } + } + } + talloc_steal(new_ctx, ir); } -- cgit v1.2.3 From 5b6890a388d554f06880e88d61c73dcd62c5f141 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Jul 2010 19:08:44 -0700 Subject: ir_to_mesa: Add support for structure constants. Fixes: TPPStreamCompiler::assignOperands --- src/mesa/program/ir_to_mesa.cpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 1903b8fcf8f..20228e04280 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1381,12 +1381,37 @@ ir_to_mesa_visitor::visit(ir_constant *ir) assert(!"FINISHME: array constants"); } + /* Unfortunately, 4 floats is all we can get into + * _mesa_add_unnamed_constant. So, make a temp to store an + * aggregate constant and move each constant value into it. If we + * get lucky, copy propagation will eliminate the extra moves. + */ + + if (ir->type->base_type == GLSL_TYPE_STRUCT) { + ir_to_mesa_src_reg temp_base = get_temp(ir->type); + ir_to_mesa_dst_reg temp = ir_to_mesa_dst_reg_from_src(temp_base); + + foreach_iter(exec_list_iterator, iter, ir->components) { + ir_constant *field_value = (ir_constant *)iter.get(); + int size = type_size(field_value->type); + + assert(size > 0); + + field_value->accept(this); + src_reg = this->result; + + for (i = 0; i < (unsigned int)size; i++) { + ir_to_mesa_emit_op1(ir, OPCODE_MOV, temp, src_reg); + + src_reg.index++; + temp.index++; + } + } + this->result = temp_base; + return; + } + if (ir->type->is_matrix()) { - /* Unfortunately, 4 floats is all we can get into - * _mesa_add_unnamed_constant. So, make a temp to store the - * matrix and move each constant value into it. If we get - * lucky, copy propagation will eliminate the extra moves. - */ ir_to_mesa_src_reg mat = get_temp(glsl_type::vec4_type); ir_to_mesa_dst_reg mat_column = ir_to_mesa_dst_reg_from_src(mat); -- cgit v1.2.3 From c91809e1e4a4fa8884e6588159368ea32431ee0e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Jul 2010 19:41:23 -0700 Subject: ir_to_mesa: Actually allocate the right size for constant matrix temps. --- src/mesa/program/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 20228e04280..6eceddfb818 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1412,7 +1412,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir) } if (ir->type->is_matrix()) { - ir_to_mesa_src_reg mat = get_temp(glsl_type::vec4_type); + ir_to_mesa_src_reg mat = get_temp(ir->type); ir_to_mesa_dst_reg mat_column = ir_to_mesa_dst_reg_from_src(mat); for (i = 0; i < ir->type->matrix_columns; i++) { -- cgit v1.2.3 From 576d01ad8c8b8aa57b4711c98d8e004d4f20fc0b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Jul 2010 19:36:53 -0700 Subject: ir_to_mesa: Fix up handling of void function returns. void functions have a type of glsl_type::void_type, not a null type. --- src/mesa/program/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 6eceddfb818..d06b83261c6 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1501,7 +1501,7 @@ ir_to_mesa_visitor::get_function_signature(ir_function_signature *sig) break; } - if (sig->return_type) { + if (!sig->return_type->is_void()) { entry->return_reg = get_temp(sig->return_type); } else { entry->return_reg = ir_to_mesa_undef; -- cgit v1.2.3 From 6a1401eb889b5e535c212c414743cc7ea07f6622 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 00:18:33 -0700 Subject: glsl2: Fix missing visit_continue return in ir_validate. --- src/glsl/ir_validate.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index bb381a00df3..93f9c0f7af3 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -104,6 +104,8 @@ ir_validate::visit(ir_if *ir) printf("\n"); abort(); } + + return visit_continue; } -- cgit v1.2.3 From 5533c6e38030ff6e26375a1a4e4bfa9ab2204d4c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 09:01:30 -0700 Subject: ir_validate: Check the types of expression operations. --- src/glsl/ir_validate.cpp | 144 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 93f9c0f7af3..1fa6e19ce96 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -65,6 +65,8 @@ public: virtual ir_visitor_status visit_leave(ir_function *ir); virtual ir_visitor_status visit_enter(ir_function_signature *ir); + virtual ir_visitor_status visit_leave(ir_expression *ir); + static void validate_ir(ir_instruction *ir, void *data); ir_function *current_function; @@ -161,6 +163,148 @@ ir_validate::visit_enter(ir_function_signature *ir) return visit_continue; } +ir_visitor_status +ir_validate::visit_leave(ir_expression *ir) +{ + switch (ir->operation) { + case ir_unop_bit_not: + assert(ir->operands[0]->type == ir->type); + break; + case ir_unop_logic_not: + assert(ir->type == glsl_type::bool_type); + assert(ir->operands[0]->type == glsl_type::bool_type); + break; + + case ir_unop_neg: + case ir_unop_abs: + case ir_unop_sign: + case ir_unop_rcp: + case ir_unop_rsq: + case ir_unop_sqrt: + case ir_unop_exp: + case ir_unop_log: + case ir_unop_exp2: + case ir_unop_log2: + assert(ir->type == ir->operands[0]->type); + break; + + case ir_unop_f2i: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->base_type == GLSL_TYPE_INT); + break; + case ir_unop_i2f: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); + assert(ir->type->base_type == GLSL_TYPE_FLOAT); + break; + case ir_unop_f2b: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->base_type == GLSL_TYPE_BOOL); + break; + case ir_unop_b2f: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); + assert(ir->type->base_type == GLSL_TYPE_FLOAT); + break; + case ir_unop_i2b: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); + assert(ir->type->base_type == GLSL_TYPE_BOOL); + break; + case ir_unop_b2i: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); + assert(ir->type->base_type == GLSL_TYPE_INT); + break; + case ir_unop_u2f: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT); + assert(ir->type->base_type == GLSL_TYPE_FLOAT); + break; + + case ir_unop_trunc: + case ir_unop_ceil: + case ir_unop_floor: + case ir_unop_fract: + case ir_unop_sin: + case ir_unop_cos: + case ir_unop_dFdx: + case ir_unop_dFdy: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type == ir->type); + break; + + case ir_binop_add: + case ir_binop_sub: + case ir_binop_mul: + case ir_binop_div: + case ir_binop_mod: + case ir_binop_min: + case ir_binop_max: + case ir_binop_pow: + if (ir->operands[0]->type->is_scalar()) + assert(ir->operands[1]->type == ir->type); + else if (ir->operands[1]->type->is_scalar()) + assert(ir->operands[0]->type == ir->type); + else if (ir->operands[0]->type->is_vector() && + ir->operands[1]->type->is_vector()) { + assert(ir->operands[0]->type == ir->operands[1]->type); + assert(ir->operands[0]->type == ir->type); + } + break; + case ir_binop_less: + case ir_binop_greater: + case ir_binop_lequal: + case ir_binop_gequal: + /* GLSL < > <= >= operators take scalar floats/ints, but in the + * IR we may want to do them for vectors instead to support the + * lessEqual() and friends builtins. + */ + assert(ir->type == glsl_type::bool_type); + assert(ir->operands[0]->type == ir->operands[1]->type); + break; + + case ir_binop_equal: + case ir_binop_nequal: + /* GLSL == and != operate on vectors and return a bool, and the + * IR matches that. We may want to switch up the IR to work on + * vectors and return a bvec and make the operators break down + * to ANDing/ORing the results of the vector comparison. + */ + assert(ir->type == glsl_type::bool_type); + assert(ir->operands[0]->type == ir->operands[1]->type); + break; + + case ir_binop_lshift: + case ir_binop_rshift: + case ir_binop_bit_and: + case ir_binop_bit_xor: + case ir_binop_bit_or: + assert(ir->operands[0]->type == ir->operands[1]->type); + assert(ir->type == ir->operands[0]->type); + assert(ir->type->base_type == GLSL_TYPE_INT || + ir->type->base_type == GLSL_TYPE_UINT); + break; + + case ir_binop_logic_and: + case ir_binop_logic_xor: + case ir_binop_logic_or: + assert(ir->type == glsl_type::bool_type); + assert(ir->operands[0]->type == glsl_type::bool_type); + assert(ir->operands[1]->type == glsl_type::bool_type); + break; + + case ir_binop_dot: + assert(ir->type == glsl_type::float_type); + assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type == ir->operands[1]->type); + break; + + case ir_binop_cross: + assert(ir->operands[0]->type == glsl_type::vec3_type); + assert(ir->operands[1]->type == glsl_type::vec3_type); + assert(ir->type == glsl_type::vec3_type); + break; + } + + return visit_continue; +} + ir_visitor_status ir_validate::visit(ir_variable *ir) { -- cgit v1.2.3 From 832aad989e3d319a8aaac046aa49df25da134d82 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Jul 2010 22:50:29 -0700 Subject: glsl2: Add optimization pass for algebraic simplifications. This cleans up the assembly output of almost all the non-logic tests glsl-algebraic-*. glsl-algebraic-pow-two needs love (basically, flattening to a temporary and squaring it). --- src/glsl/Makefile | 1 + src/glsl/ir.h | 8 + src/glsl/ir_algebraic.cpp | 366 ++++++++++++++++++++++++++++++++++++++++ src/glsl/ir_optimization.h | 3 +- src/glsl/main.cpp | 1 + src/mesa/program/ir_to_mesa.cpp | 1 + 6 files changed, 379 insertions(+), 1 deletion(-) create mode 100644 src/glsl/ir_algebraic.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 462d49e8840..4c85af8906d 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -30,6 +30,7 @@ CXX_SOURCES = \ glsl_parser_extras.cpp \ glsl_types.cpp \ hir_field_selection.cpp \ + ir_algebraic.cpp \ ir_basic_block.cpp \ ir_clone.cpp \ ir_constant_expression.cpp \ diff --git a/src/glsl/ir.h b/src/glsl/ir.h index e0f3683a7ab..7e8363106da 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -613,7 +613,15 @@ enum ir_expression_operation { ir_binop_greater, ir_binop_lequal, ir_binop_gequal, + /** + * Returns single boolean for whether all components of operands[0] + * equal the components of operands[1]. + */ ir_binop_equal, + /** + * Returns single boolean for whether any component of operands[0] + * is not equal to the corresponding component of operands[1]. + */ ir_binop_nequal, /*@}*/ diff --git a/src/glsl/ir_algebraic.cpp b/src/glsl/ir_algebraic.cpp new file mode 100644 index 00000000000..5b065b086e5 --- /dev/null +++ b/src/glsl/ir_algebraic.cpp @@ -0,0 +1,366 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_algebraic.cpp + * + * Takes advantage of association, commutivity, and other algebraic + * properties to simplify expressions. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +class ir_algebraic_visitor : public ir_hierarchical_visitor { +public: + ir_algebraic_visitor() + { + this->progress = false; + } + + virtual ~ir_algebraic_visitor() + { + } + + virtual ir_visitor_status visit_leave(ir_assignment *); + virtual ir_visitor_status visit_leave(ir_call *); + virtual ir_visitor_status visit_leave(ir_dereference_array *); + virtual ir_visitor_status visit_leave(ir_expression *); + virtual ir_visitor_status visit_leave(ir_if *); + virtual ir_visitor_status visit_leave(ir_return *); + virtual ir_visitor_status visit_leave(ir_swizzle *); + virtual ir_visitor_status visit_leave(ir_texture *); + + ir_rvalue *handle_expression(ir_rvalue *in_ir); + + bool progress; +}; + +static bool +is_vec_zero(ir_constant *ir) +{ + int c; + + if (!ir) + return false; + if (!ir->type->is_scalar() && + !ir->type->is_vector()) + return false; + + for (c = 0; c < ir->type->vector_elements; c++) { + switch (ir->type->base_type) { + case GLSL_TYPE_FLOAT: + if (ir->value.f[c] != 0.0) + return false; + break; + case GLSL_TYPE_INT: + if (ir->value.i[c] != 0) + return false; + break; + case GLSL_TYPE_UINT: + if (ir->value.u[c] != 0) + return false; + break; + case GLSL_TYPE_BOOL: + if (ir->value.b[c] != false) + return false; + break; + default: + assert(!"bad base type"); + return false; + } + } + + return true; +} + +static bool +is_vec_one(ir_constant *ir) +{ + int c; + + if (!ir) + return false; + if (!ir->type->is_scalar() && + !ir->type->is_vector()) + return false; + + for (c = 0; c < ir->type->vector_elements; c++) { + switch (ir->type->base_type) { + case GLSL_TYPE_FLOAT: + if (ir->value.f[c] != 1.0) + return false; + break; + case GLSL_TYPE_INT: + if (ir->value.i[c] != 1) + return false; + break; + case GLSL_TYPE_UINT: + if (ir->value.u[c] != 1) + return false; + break; + case GLSL_TYPE_BOOL: + if (ir->value.b[c] != true) + return false; + break; + default: + assert(!"bad base type"); + return false; + } + } + + return true; +} + +ir_rvalue * +ir_algebraic_visitor::handle_expression(ir_rvalue *in_ir) +{ + ir_expression *ir = (ir_expression *)in_ir; + ir_constant *op_const[2] = {NULL, NULL}; + ir_expression *op_expr[2] = {NULL, NULL}; + unsigned int i; + + if (!in_ir) + return NULL; + + if (in_ir->ir_type != ir_type_expression) + return in_ir; + + for (i = 0; i < ir->get_num_operands(); i++) { + if (ir->operands[i]->type->is_matrix()) + return in_ir; + + op_const[i] = ir->operands[i]->constant_expression_value(); + op_expr[i] = ir->operands[i]->as_expression(); + } + + switch (ir->operation) { + case ir_unop_logic_not: + if (op_expr[0] && op_expr[0]->operation == ir_binop_equal) { + this->progress = true; + return new(ir) ir_expression(ir_binop_nequal, + ir->type, + op_expr[0]->operands[0], + op_expr[0]->operands[1]); + } + if (op_expr[0] && op_expr[0]->operation == ir_binop_nequal) { + this->progress = true; + return new(ir) ir_expression(ir_binop_equal, + ir->type, + op_expr[0]->operands[0], + op_expr[0]->operands[1]); + } + break; + + case ir_binop_add: + if (is_vec_zero(op_const[0])) { + this->progress = true; + return ir->operands[1]; + } + if (is_vec_zero(op_const[1])) { + this->progress = true; + return ir->operands[0]; + } + break; + + case ir_binop_sub: + if (is_vec_zero(op_const[0])) { + this->progress = true; + return new(ir) ir_expression(ir_unop_neg, + ir->type, + ir->operands[1], + NULL); + } + if (is_vec_zero(op_const[1])) { + this->progress = true; + return ir->operands[0]; + } + break; + + case ir_binop_mul: + if (is_vec_one(op_const[0])) { + this->progress = true; + return ir->operands[1]; + } + if (is_vec_one(op_const[1])) { + this->progress = true; + return ir->operands[0]; + } + + if (is_vec_zero(op_const[0]) || + is_vec_zero(op_const[1])) { + ir_constant_data zero_data; + memset(&zero_data, 0, sizeof(zero_data)); + + this->progress = true; + return new(ir) ir_constant(ir->type, &zero_data); + } + break; + + case ir_binop_div: + if (is_vec_one(op_const[0]) && ir->type->base_type == GLSL_TYPE_FLOAT) { + this->progress = true; + return new(ir) ir_expression(ir_unop_rcp, + ir->type, + ir->operands[1], + NULL); + } + if (is_vec_one(op_const[1])) { + this->progress = true; + return ir->operands[0]; + } + break; + + case ir_unop_rcp: + if (op_expr[0] && op_expr[0]->operation == ir_unop_rcp) { + this->progress = true; + return op_expr[0]->operands[0]; + } + + /* FINISHME: We should do rcp(rsq(x)) -> sqrt(x) for some + * backends, except that some backends will have done sqrt -> + * rcp(rsq(x)) and we don't want to undo it for them. + */ + + /* As far as we know, all backends are OK with rsq. */ + if (op_expr[0] && op_expr[0]->operation == ir_unop_sqrt) { + this->progress = true; + return new(ir) ir_expression(ir_unop_rsq, + ir->type, + op_expr[0]->operands[0], + NULL); + } + + break; + + default: + break; + } + + return in_ir; +} + +ir_visitor_status +ir_algebraic_visitor::visit_leave(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + ir->operands[operand] = handle_expression(ir->operands[operand]); + } + + return visit_continue; +} + +ir_visitor_status +ir_algebraic_visitor::visit_leave(ir_texture *ir) +{ + ir->coordinate = handle_expression(ir->coordinate); + ir->projector = handle_expression(ir->projector); + ir->shadow_comparitor = handle_expression(ir->shadow_comparitor); + + switch (ir->op) { + case ir_tex: + break; + case ir_txb: + ir->lod_info.bias = handle_expression(ir->lod_info.bias); + break; + case ir_txf: + case ir_txl: + ir->lod_info.lod = handle_expression(ir->lod_info.lod); + break; + case ir_txd: + ir->lod_info.grad.dPdx = handle_expression(ir->lod_info.grad.dPdx); + ir->lod_info.grad.dPdy = handle_expression(ir->lod_info.grad.dPdy); + break; + } + + return visit_continue; +} + +ir_visitor_status +ir_algebraic_visitor::visit_leave(ir_swizzle *ir) +{ + ir->val = handle_expression(ir->val); + return visit_continue; +} + +ir_visitor_status +ir_algebraic_visitor::visit_leave(ir_dereference_array *ir) +{ + ir->array_index = handle_expression(ir->array_index); + return visit_continue; +} + +ir_visitor_status +ir_algebraic_visitor::visit_leave(ir_assignment *ir) +{ + ir->rhs = handle_expression(ir->rhs); + ir->condition = handle_expression(ir->condition); + return visit_continue; +} + +ir_visitor_status +ir_algebraic_visitor::visit_leave(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = handle_expression(param); + + if (new_param != param) { + param->replace_with(new_param); + } + } + return visit_continue; +} + +ir_visitor_status +ir_algebraic_visitor::visit_leave(ir_return *ir) +{ + ir->value = handle_expression(ir->value);; + return visit_continue; +} + +ir_visitor_status +ir_algebraic_visitor::visit_leave(ir_if *ir) +{ + ir->condition = handle_expression(ir->condition); + return visit_continue; +} + + +bool +do_algebraic(exec_list *instructions) +{ + ir_algebraic_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 06cb4d22ca8..4f39565e5f1 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -23,11 +23,12 @@ /** - * \file ir_dead_code.h + * \file ir_optimization.h * * Prototypes for optimization passes to be called by the compiler and drivers. */ +bool do_algebraic(exec_list *instructions); bool do_constant_folding(exec_list *instructions); bool do_constant_variable(exec_list *instructions); bool do_constant_variable_unlinked(exec_list *instructions); diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 5c0f6475e0b..b62902278c4 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -165,6 +165,7 @@ compile_shader(struct gl_shader *shader) progress = do_dead_code_unlinked(state, shader->ir) || progress; progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; + progress = do_algebraic(shader->ir) || progress; progress = do_vec_index_to_swizzle(shader->ir) || progress; progress = do_vec_index_to_cond_assign(shader->ir) || progress; progress = do_swizzle_swizzle(shader->ir) || progress; diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index d06b83261c6..2fd0507c2fb 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2240,6 +2240,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) progress = do_dead_code_unlinked(state, shader->ir) || progress; progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; + progress = do_algebraic(shader->ir) || progress; progress = do_if_return(shader->ir) || progress; if (ctx->Shader.EmitNoIfs) progress = do_if_to_cond_assign(shader->ir) || progress; -- cgit v1.2.3 From fdbaca931a504a70d6fec54e2f85caac6281377d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 10:08:38 -0700 Subject: ir_to_mesa: Fix stray "break" that broke functions of >1 argument. --- src/mesa/program/ir_to_mesa.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 2fd0507c2fb..defacc7fdc4 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1498,7 +1498,6 @@ ir_to_mesa_visitor::get_function_signature(ir_function_signature *sig) this->variables.push_tail(storage); this->next_temp += type_size(param->type); - break; } if (!sig->return_type->is_void()) { -- cgit v1.2.3 From 9a770ee49f8cb82653bb5c1976f7751d9a6b801e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 10:39:40 -0700 Subject: ir_to_mesa: Set the swizzle on constant struct src regs. MESA_GLSL=nopt now produces believable output for glsl-fs-raytrace. --- src/mesa/program/ir_to_mesa.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index defacc7fdc4..5cc999c2e35 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1389,6 +1389,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir) if (ir->type->base_type == GLSL_TYPE_STRUCT) { ir_to_mesa_src_reg temp_base = get_temp(ir->type); + temp_base.swizzle = SWIZZLE_NOOP; ir_to_mesa_dst_reg temp = ir_to_mesa_dst_reg_from_src(temp_base); foreach_iter(exec_list_iterator, iter, ir->components) { -- cgit v1.2.3 From 85cd64ee170e578317a6aa41d824314550a318ac Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 11:14:59 -0700 Subject: glsl2: Talloc type names. Otherwise, we end up losing structure names after compile time, and dumping IR often ends up reporting some other mysterious string. --- src/glsl/glsl_types.cpp | 25 ++++++++++++++++--------- src/glsl/glsl_types.h | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index de0adc0c6ec..8192b86dfc9 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -35,6 +35,15 @@ hash_table *glsl_type::array_types = NULL; hash_table *glsl_type::record_types = NULL; void *glsl_type::ctx = NULL; +static void +init_talloc_type_ctx(void) +{ + if (glsl_type::ctx == NULL) { + glsl_type::ctx = talloc_init("glsl_type"); + assert(glsl_type::ctx != NULL); + } +} + glsl_type::glsl_type(GLenum gl_type, unsigned base_type, unsigned vector_elements, unsigned matrix_columns, const char *name) : @@ -43,9 +52,10 @@ glsl_type::glsl_type(GLenum gl_type, sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), sampler_type(0), vector_elements(vector_elements), matrix_columns(matrix_columns), - name(name), length(0) { + init_talloc_type_ctx(); + this->name = talloc_strdup(this->ctx, name); /* Neither dimension is zero or both dimensions are zero. */ assert((vector_elements == 0) == (matrix_columns == 0)); @@ -60,9 +70,10 @@ glsl_type::glsl_type(GLenum gl_type, sampler_dimensionality(dim), sampler_shadow(shadow), sampler_array(array), sampler_type(type), vector_elements(0), matrix_columns(0), - name(name), length(0) { + init_talloc_type_ctx(); + this->name = talloc_strdup(this->ctx, name); memset(& fields, 0, sizeof(fields)); } @@ -72,17 +83,13 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), sampler_type(0), vector_elements(0), matrix_columns(0), - name(name), length(num_fields) { unsigned int i; - if (glsl_type::ctx == NULL) { - glsl_type::ctx = talloc_init("glsl_type"); - assert(glsl_type::ctx != NULL); - } - - this->fields.structure = talloc_array(glsl_type::ctx, + init_talloc_type_ctx(); + this->name = talloc_strdup(this->ctx, name); + this->fields.structure = talloc_array(this->ctx, glsl_struct_field, length); for (i = 0; i < length; i++) { this->fields.structure[i].type = fields[i].type; diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 69fb9e3fb58..4bec3181679 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -388,7 +388,6 @@ struct glsl_type { return is_array() ? length : -1; } -private: /** * talloc context for all glsl_type allocations * @@ -396,6 +395,7 @@ private: */ static TALLOC_CTX *ctx; +private: /** Constructor for vector and matrix types */ glsl_type(GLenum gl_type, unsigned base_type, unsigned vector_elements, -- cgit v1.2.3 From 8bbdf6e7cdfc3265439761a06eea79627f4ee2fa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 11:45:27 -0700 Subject: mesa: Allow large temporary indices coming into the temporary reg allocator. This gets glsl-vs-raytrace, glsl-fs-raytrace running on the new compiler. --- src/mesa/program/prog_optimize.c | 48 ++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/mesa/program/prog_optimize.c b/src/mesa/program/prog_optimize.c index bd120b8643c..457ace14c6b 100644 --- a/src/mesa/program/prog_optimize.c +++ b/src/mesa/program/prog_optimize.c @@ -34,7 +34,12 @@ #define MAX_LOOP_NESTING 50 - +/* MAX_PROGRAM_TEMPS is a low number (256), and we want to be able to + * register allocate many temporary values into that small number of + * temps. So allow large temporary indices coming into the register + * allocator. + */ +#define REG_ALLOCATE_MAX_PROGRAM_TEMPS ((1 << INST_INDEX_BITS) - 1) static GLboolean dbg = GL_FALSE; @@ -154,8 +159,8 @@ replace_regs(struct gl_program *prog, gl_register_file file, const GLint map[]) static void _mesa_consolidate_registers(struct gl_program *prog) { - GLboolean tempUsed[MAX_PROGRAM_TEMPS]; - GLint tempMap[MAX_PROGRAM_TEMPS]; + GLboolean tempUsed[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; + GLint tempMap[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; GLuint tempMax = 0, i; if (dbg) { @@ -164,7 +169,7 @@ _mesa_consolidate_registers(struct gl_program *prog) memset(tempUsed, 0, sizeof(tempUsed)); - for (i = 0; i < MAX_PROGRAM_TEMPS; i++) { + for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++) { tempMap[i] = -1; } @@ -176,7 +181,7 @@ _mesa_consolidate_registers(struct gl_program *prog) for (j = 0; j < numSrc; j++) { if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) { const GLuint index = inst->SrcReg[j].Index; - ASSERT(index < MAX_PROGRAM_TEMPS); + ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); tempUsed[index] = GL_TRUE; tempMax = MAX2(tempMax, index); break; @@ -184,7 +189,7 @@ _mesa_consolidate_registers(struct gl_program *prog) } if (inst->DstReg.File == PROGRAM_TEMPORARY) { const GLuint index = inst->DstReg.Index; - ASSERT(index < MAX_PROGRAM_TEMPS); + ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); tempUsed[index] = GL_TRUE; tempMax = MAX2(tempMax, index); } @@ -225,7 +230,7 @@ _mesa_consolidate_registers(struct gl_program *prog) static void _mesa_remove_dead_code(struct gl_program *prog) { - GLboolean tempRead[MAX_PROGRAM_TEMPS][4]; + GLboolean tempRead[REG_ALLOCATE_MAX_PROGRAM_TEMPS][4]; GLboolean *removeInst; /* per-instruction removal flag */ GLuint i, rem = 0, comp; @@ -250,7 +255,7 @@ _mesa_remove_dead_code(struct gl_program *prog) if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) { const GLuint index = inst->SrcReg[j].Index; GLuint read_mask; - ASSERT(index < MAX_PROGRAM_TEMPS); + ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); read_mask = get_src_arg_mask(inst, j); if (inst->SrcReg[j].RelAddr) { @@ -286,7 +291,7 @@ _mesa_remove_dead_code(struct gl_program *prog) /* check dst reg */ if (inst->DstReg.File == PROGRAM_TEMPORARY) { const GLuint index = inst->DstReg.Index; - ASSERT(index < MAX_PROGRAM_TEMPS); + ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); if (inst->DstReg.RelAddr) { if (dbg) @@ -642,7 +647,7 @@ struct interval struct interval_list { GLuint Num; - struct interval Intervals[MAX_PROGRAM_TEMPS]; + struct interval Intervals[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; }; @@ -754,7 +759,7 @@ update_interval(GLint intBegin[], GLint intEnd[], } } - ASSERT(index < MAX_PROGRAM_TEMPS); + ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); if (intBegin[index] == -1) { ASSERT(intEnd[index] == -1); intBegin[index] = intEnd[index] = ic; @@ -771,14 +776,14 @@ update_interval(GLint intBegin[], GLint intEnd[], GLboolean _mesa_find_temp_intervals(const struct prog_instruction *instructions, GLuint numInstructions, - GLint intBegin[MAX_PROGRAM_TEMPS], - GLint intEnd[MAX_PROGRAM_TEMPS]) + GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS], + GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS]) { struct loop_info loopStack[MAX_LOOP_NESTING]; GLuint loopStackDepth = 0; GLuint i; - for (i = 0; i < MAX_PROGRAM_TEMPS; i++){ + for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){ intBegin[i] = intEnd[i] = -1; } @@ -833,7 +838,8 @@ static GLboolean find_live_intervals(struct gl_program *prog, struct interval_list *liveIntervals) { - GLint intBegin[MAX_PROGRAM_TEMPS], intEnd[MAX_PROGRAM_TEMPS]; + GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; + GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; GLuint i; /* @@ -853,7 +859,7 @@ find_live_intervals(struct gl_program *prog, /* Build live intervals list from intermediate arrays */ liveIntervals->Num = 0; - for (i = 0; i < MAX_PROGRAM_TEMPS; i++) { + for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++) { if (intBegin[i] >= 0) { struct interval inv; inv.Reg = i; @@ -889,10 +895,10 @@ find_live_intervals(struct gl_program *prog, /** Scan the array of used register flags to find free entry */ static GLint -alloc_register(GLboolean usedRegs[MAX_PROGRAM_TEMPS]) +alloc_register(GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS]) { GLuint k; - for (k = 0; k < MAX_PROGRAM_TEMPS; k++) { + for (k = 0; k < REG_ALLOCATE_MAX_PROGRAM_TEMPS; k++) { if (!usedRegs[k]) { usedRegs[k] = GL_TRUE; return k; @@ -914,8 +920,8 @@ static void _mesa_reallocate_registers(struct gl_program *prog) { struct interval_list liveIntervals; - GLint registerMap[MAX_PROGRAM_TEMPS]; - GLboolean usedRegs[MAX_PROGRAM_TEMPS]; + GLint registerMap[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; + GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; GLuint i; GLint maxTemp = -1; @@ -924,7 +930,7 @@ _mesa_reallocate_registers(struct gl_program *prog) _mesa_print_program(prog); } - for (i = 0; i < MAX_PROGRAM_TEMPS; i++){ + for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){ registerMap[i] = -1; usedRegs[i] = GL_FALSE; } -- cgit v1.2.3 From 66d4c65ee2c311ea0c71c39a28456d0c11798d6b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 11:28:26 -0700 Subject: glsl2: Make the dead code handler make its own talloc context. This way, we don't need to pass in a parse state, and the context doesn't grow with the number of passes through optimization. --- src/glsl/ir_dead_code.cpp | 12 ++++++------ src/glsl/ir_optimization.h | 6 ++---- src/glsl/main.cpp | 2 +- src/mesa/program/ir_to_mesa.cpp | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp index ea78107f493..4804407bdc3 100644 --- a/src/glsl/ir_dead_code.cpp +++ b/src/glsl/ir_dead_code.cpp @@ -146,13 +146,12 @@ ir_dead_code_visitor::visit_leave(ir_assignment *ir) * for usage on an unlinked instruction stream. */ bool -do_dead_code(struct _mesa_glsl_parse_state *state, - exec_list *instructions) +do_dead_code(exec_list *instructions) { ir_dead_code_visitor v; bool progress = false; - v.mem_ctx = state; + v.mem_ctx = talloc_new(NULL); v.run(instructions); foreach_iter(exec_list_iterator, iter, v.variable_list) { @@ -188,6 +187,8 @@ do_dead_code(struct _mesa_glsl_parse_state *state, progress = true; } } + talloc_free(v.mem_ctx); + return progress; } @@ -199,8 +200,7 @@ do_dead_code(struct _mesa_glsl_parse_state *state, * with global scope. */ bool -do_dead_code_unlinked(struct _mesa_glsl_parse_state *state, - exec_list *instructions) +do_dead_code_unlinked(exec_list *instructions) { bool progress = false; @@ -211,7 +211,7 @@ do_dead_code_unlinked(struct _mesa_glsl_parse_state *state, foreach_iter(exec_list_iterator, sigiter, *f) { ir_function_signature *sig = (ir_function_signature *) sigiter.get(); - if (do_dead_code(state, &sig->body)) + if (do_dead_code(&sig->body)) progress = true; } } diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 4f39565e5f1..5dbb025d357 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -33,11 +33,9 @@ bool do_constant_folding(exec_list *instructions); bool do_constant_variable(exec_list *instructions); bool do_constant_variable_unlinked(exec_list *instructions); bool do_copy_propagation(exec_list *instructions); -bool do_dead_code(struct _mesa_glsl_parse_state *state, - exec_list *instructions); +bool do_dead_code(exec_list *instructions); bool do_dead_code_local(exec_list *instructions); -bool do_dead_code_unlinked(struct _mesa_glsl_parse_state *state, - exec_list *instructions); +bool do_dead_code_unlinked(exec_list *instructions); bool do_div_to_mul_rcp(exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_if_return(exec_list *instructions); diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index b62902278c4..08b133f124e 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -162,7 +162,7 @@ compile_shader(struct gl_shader *shader) progress = do_if_simplification(shader->ir) || progress; progress = do_copy_propagation(shader->ir) || progress; progress = do_dead_code_local(shader->ir) || progress; - progress = do_dead_code_unlinked(state, shader->ir) || progress; + progress = do_dead_code_unlinked(shader->ir) || progress; progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; progress = do_algebraic(shader->ir) || progress; diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 5cc999c2e35..409b6d72881 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2237,7 +2237,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) progress = do_if_simplification(shader->ir) || progress; progress = do_copy_propagation(shader->ir) || progress; progress = do_dead_code_local(shader->ir) || progress; - progress = do_dead_code_unlinked(state, shader->ir) || progress; + progress = do_dead_code_unlinked(shader->ir) || progress; progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; progress = do_algebraic(shader->ir) || progress; -- cgit v1.2.3 From 5532c4ca696fea32fb9b2f8de15beabe4a20ae15 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 11:29:17 -0700 Subject: glsl2: Fix the linked version of ir_dead_code. If we don't walk into functions, we won't see any usage of variables in the functions. --- src/glsl/ir_dead_code.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp index 4804407bdc3..eab459b920f 100644 --- a/src/glsl/ir_dead_code.cpp +++ b/src/glsl/ir_dead_code.cpp @@ -61,7 +61,7 @@ public: virtual ir_visitor_status visit(ir_variable *); virtual ir_visitor_status visit(ir_dereference_variable *); - virtual ir_visitor_status visit_enter(ir_function *); + virtual ir_visitor_status visit_enter(ir_function_signature *); virtual ir_visitor_status visit_leave(ir_assignment *); variable_entry *get_variable_entry(ir_variable *var); @@ -116,9 +116,12 @@ ir_dead_code_visitor::visit(ir_dereference_variable *ir) ir_visitor_status -ir_dead_code_visitor::visit_enter(ir_function *ir) +ir_dead_code_visitor::visit_enter(ir_function_signature *ir) { - (void) ir; + /* We don't want to descend into the function parameters and + * dead-code eliminate them, so just accept the body here. + */ + visit_list_elements(this, &ir->body); return visit_continue_with_parent; } -- cgit v1.2.3 From bf6ad0ab3d3940ca642c388444f7ddae91eefffc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 11:31:12 -0700 Subject: glsl2: Use ir_dead_code's linked version after linking. glsl-fs-raytrace-bug27060 goes from 485 Mesa IR instructions to 389 before Mesa IR optimization. --- src/glsl/linker.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index ea0274eac33..06f2a8231a9 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1262,9 +1262,7 @@ link_shaders(struct gl_shader_program *prog) progress = do_if_simplification(ir) || progress; progress = do_copy_propagation(ir) || progress; progress = do_dead_code_local(ir) || progress; -#if 0 - progress = do_dead_code_unlinked(state, ir) || progress; -#endif + progress = do_dead_code_unlinked(ir) || progress; progress = do_constant_variable_unlinked(ir) || progress; progress = do_constant_folding(ir) || progress; progress = do_if_return(ir) || progress; -- cgit v1.2.3 From 20c074ae28b310348a6a1920ad0ddf1e5cbb7a46 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 11:58:32 -0700 Subject: ir_to_mesa: Add support for array constants. Fixes: glsl1-GLSL 1.20 array constructor 1 glsl1-GLSL 1.20 array constructor 2 glsl1-GLSL 1.20 array.length() glsl1-GLSL 1.20 const array constructor 1 glsl1-GLSL 1.20 const array constructor 2 --- src/mesa/program/ir_to_mesa.cpp | 48 ++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 409b6d72881..bd79913dcf4 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -518,19 +518,21 @@ ir_to_mesa_visitor::get_temp(const glsl_type *type) int swizzle[4]; int i; - assert(!type->is_array()); - src_reg.file = PROGRAM_TEMPORARY; src_reg.index = next_temp; src_reg.reladdr = NULL; next_temp += type_size(type); - for (i = 0; i < type->vector_elements; i++) - swizzle[i] = i; - for (; i < 4; i++) - swizzle[i] = type->vector_elements - 1; - src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], - swizzle[2], swizzle[3]); + if (type->is_array() || type->is_record()) { + src_reg.swizzle = SWIZZLE_NOOP; + } else { + for (i = 0; i < type->vector_elements; i++) + swizzle[i] = i; + for (; i < 4; i++) + swizzle[i] = type->vector_elements - 1; + src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], + swizzle[2], swizzle[3]); + } src_reg.negate = 0; return src_reg; @@ -1329,8 +1331,6 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) struct ir_to_mesa_src_reg r; int i; - assert(!ir->lhs->type->is_array()); - ir->rhs->accept(this); r = this->result; @@ -1375,12 +1375,6 @@ ir_to_mesa_visitor::visit(ir_constant *ir) GLfloat *values = stack_vals; unsigned int i; - if (ir->type->is_array()) { - ir->print(); - printf("\n"); - assert(!"FINISHME: array constants"); - } - /* Unfortunately, 4 floats is all we can get into * _mesa_add_unnamed_constant. So, make a temp to store an * aggregate constant and move each constant value into it. If we @@ -1389,7 +1383,6 @@ ir_to_mesa_visitor::visit(ir_constant *ir) if (ir->type->base_type == GLSL_TYPE_STRUCT) { ir_to_mesa_src_reg temp_base = get_temp(ir->type); - temp_base.swizzle = SWIZZLE_NOOP; ir_to_mesa_dst_reg temp = ir_to_mesa_dst_reg_from_src(temp_base); foreach_iter(exec_list_iterator, iter, ir->components) { @@ -1412,6 +1405,27 @@ ir_to_mesa_visitor::visit(ir_constant *ir) return; } + if (ir->type->is_array()) { + ir_to_mesa_src_reg temp_base = get_temp(ir->type); + ir_to_mesa_dst_reg temp = ir_to_mesa_dst_reg_from_src(temp_base); + int size = type_size(ir->type->fields.array); + + assert(size > 0); + + for (i = 0; i < ir->type->length; i++) { + ir->array_elements[i]->accept(this); + src_reg = this->result; + for (int j = 0; j < size; j++) { + ir_to_mesa_emit_op1(ir, OPCODE_MOV, temp, src_reg); + + src_reg.index++; + temp.index++; + } + } + this->result = temp_base; + return; + } + if (ir->type->is_matrix()) { ir_to_mesa_src_reg mat = get_temp(ir->type); ir_to_mesa_dst_reg mat_column = ir_to_mesa_dst_reg_from_src(mat); -- cgit v1.2.3 From 54f583a206a15b1a92c547333adfae29ced796ef Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 12:10:50 -0700 Subject: glsl2: Don't dereference a NULL var in CE handling during a compile error. If an undeclared variable was dereferenced in an expression that needed constant expression handling, we would walk off a null ir->var pointer. Fixes: glsl1-TIntermediate::addUnaryMath --- src/glsl/ir_constant_expression.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index f15530ae89e..6a07f4e1895 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -676,6 +676,10 @@ ir_swizzle::constant_expression_value() ir_constant * ir_dereference_variable::constant_expression_value() { + /* This may occur during compile and var->type is glsl_type::error_type */ + if (!var) + return NULL; + return var->constant_value ? var->constant_value->clone(NULL) : NULL; } -- cgit v1.2.3 From 59c45e9e6cf80be149c6e5d94763e98312f49be2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 14:32:21 -0700 Subject: glsl2: Actually use the linked dead code eliminator. I managed to revert the change from unlinked at some point while cleaning up the changes. glsl-fs-raytrace-bug27060 drops from 389 instructions to 370. --- src/glsl/linker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 06f2a8231a9..e7bc7000290 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1262,7 +1262,7 @@ link_shaders(struct gl_shader_program *prog) progress = do_if_simplification(ir) || progress; progress = do_copy_propagation(ir) || progress; progress = do_dead_code_local(ir) || progress; - progress = do_dead_code_unlinked(ir) || progress; + progress = do_dead_code(ir) || progress; progress = do_constant_variable_unlinked(ir) || progress; progress = do_constant_folding(ir) || progress; progress = do_if_return(ir) || progress; -- cgit v1.2.3 From 9a670c2e9b7e07ba43d175f3bfb23951296794c4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 15:10:38 -0700 Subject: ir_to_mesa: Provide a restricted type size to _mesa_add_uniform. Fixes: glsl-uniform-out-of-bounds. --- src/mesa/program/ir_to_mesa.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index bd79913dcf4..fe0c19acea0 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1061,6 +1061,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) ir_to_mesa_src_reg src_reg; variable_storage *entry = find_variable_storage(ir->var); unsigned int loc; + int len; if (!entry) { switch (ir->var->mode) { @@ -1089,9 +1090,17 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) assert(ir->var->type->gl_type != 0 && ir->var->type->gl_type != GL_INVALID_ENUM); + + if (ir->var->type->is_vector() || + ir->var->type->is_scalar()) { + len = ir->var->type->vector_elements; + } else { + len = type_size(ir->var->type) * 4; + } + loc = _mesa_add_uniform(this->prog->Parameters, ir->var->name, - type_size(ir->var->type) * 4, + len, ir->var->type->gl_type, NULL); -- cgit v1.2.3 From f9b0e5e322a676cf778dc3785281040fcc0bd248 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Jul 2010 15:25:07 -0700 Subject: glsl2: When stealing var->constant_value, steal its children as well. Fixes: glsl1-GLSL 1.20 uniform array constructor --- src/glsl/ir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 6dccbd806e8..c75d560c48c 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -911,7 +911,7 @@ steal_memory(ir_instruction *ir, void *new_ctx) ir_variable *var = ir->as_variable(); ir_constant *constant = ir->as_constant(); if (var != NULL && var->constant_value != NULL) - talloc_steal(ir, var->constant_value); + steal_memory(var->constant_value, ir); /* The components of aggregate constants are not visited by the normal * visitor, so steal their values by hand. -- cgit v1.2.3 From 2233d10442f1e19d18693fc030aefe292b14cf29 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 28 Jul 2010 11:07:46 -0700 Subject: glcpp: Remove 2 shift/reduce conflicts from the grammar. Since we have productions to turn "defined FOO" and "defined ( FOO )" into a conditional_token we don't need to list DEFINED as an operator as well. Doing so just introduces the shift/reduce ambiguity with no benefit. --- src/glsl/glcpp/glcpp-parse.y | 1 - 1 file changed, 1 deletion(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 5b7467836d7..3322db06ed3 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -478,7 +478,6 @@ operator: | ',' { $$ = ','; } | '=' { $$ = '='; } | PASTE { $$ = PASTE; } -| DEFINED { $$ = DEFINED; } ; %% -- cgit v1.2.3 From efef950f393dfe6cb7ef60bee646f2197143df41 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 28 Jul 2010 11:10:52 -0700 Subject: glcpp: Explicitly expect 0 shift/reduce conflicts. The "%expect 0" construct will make bison emit an error if any future changes to the grammar introduce shift/reduce conflicts, (without also increasing the number after "%expect"). --- src/glsl/glcpp/glcpp-parse.y | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 3322db06ed3..41cfff5551c 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -141,6 +141,7 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} +%expect 0 %token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING NEWLINE OTHER PLACEHOLDER SPACE %token PASTE %type expression INTEGER operator SPACE -- cgit v1.2.3 From 73df636e043fc72a07b0b8b759906d92d7edf793 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 08:18:59 -0700 Subject: glsl2: Size builtin arrays according to the context constants. Cleans up some of the FINISHMEs in this file. --- src/glsl/ir_variable.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 0dd6d834b7f..ea2872f237c 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -152,12 +152,8 @@ generate_110_uniforms(exec_list *instructions, * FINISHME: (glFrontMaterial, glBackMaterial) */ - /* FINISHME: The size of this array is implementation dependent based on the - * FINISHME: value of GL_MAX_TEXTURE_LIGHTS. GL_MAX_TEXTURE_LIGHTS must be - * FINISHME: at least 8, so hard-code 8 for now. - */ const glsl_type *const light_source_array_type = - glsl_type::get_array_instance(state->symbols->get_type("gl_LightSourceParameters"), 8); + glsl_type::get_array_instance(state->symbols->get_type("gl_LightSourceParameters"), state->Const.MaxLights); add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type, instructions, state->symbols); @@ -227,11 +223,9 @@ generate_130_vs_variables(exec_list *instructions, instructions, state->symbols); } - /* FINISHME: The size of this array is implementation dependent based on - * FINISHME: the value of GL_MAX_CLIP_DISTANCES. - */ const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(glsl_type::float_type, 8); + glsl_type::get_array_instance(glsl_type::float_type, + state->Const.MaxClipPlanes); /* FINISHME: gl_ClipDistance needs a real location assigned. */ add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type, @@ -349,11 +343,9 @@ generate_130_fs_variables(exec_list *instructions, { generate_120_fs_variables(instructions, state); - /* FINISHME: The size of this array is implementation dependent based on - * FINISHME: the value of GL_MAX_CLIP_DISTANCES. - */ const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(glsl_type::float_type, 8); + glsl_type::get_array_instance(glsl_type::float_type, + state->Const.MaxClipPlanes); /* FINISHME: gl_ClipDistance needs a real location assigned. */ add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type, -- cgit v1.2.3 From 85b5dba5933437763dfb6ddc5384f59c0943d658 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 12:23:51 -0700 Subject: glsl2: Add the remaining builtin uniforms. --- src/glsl/ir_variable.cpp | 68 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index ea2872f237c..478cefc5a6c 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -76,6 +76,14 @@ add_variable(const char *name, enum ir_variable_mode mode, int slot, return var; } +static ir_variable * +add_uniform(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + const char *name, const glsl_type *type) +{ + return add_variable(name, ir_var_uniform, -1, type, instructions, + state->symbols); +} static void add_builtin_variable(const builtin_variable *proto, exec_list *instructions, @@ -141,28 +149,58 @@ generate_110_uniforms(exec_list *instructions, glsl_type::get_array_instance(glsl_type::mat4_type, state->Const.MaxTextureCoords); - add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type, - instructions, state->symbols); + add_uniform(instructions, state, "gl_TextureMatrix", mat4_array_type); - /* FINISHME: Add support for gl_DepthRangeParameters */ - /* FINISHME: Add support for gl_ClipPlane[] */ - /* FINISHME: Add support for gl_PointParameters */ + add_uniform(instructions, state, "gl_DepthRangeParameters", + state->symbols->get_type("gl_DepthRangeParameters")); - /* FINISHME: Add support for gl_MaterialParameters - * FINISHME: (glFrontMaterial, glBackMaterial) - */ + add_uniform(instructions, state, "gl_ClipPlane", + glsl_type::get_array_instance(glsl_type::vec4_type, + state->Const.MaxClipPlanes)); + add_uniform(instructions, state, "gl_Point", + state->symbols->get_type("gl_PointParameters")); + + const glsl_type *const material_parameters_type = + state->symbols->get_type("gl_MaterialParameters"); + add_uniform(instructions, state, "gl_FrontMaterial", material_parameters_type); + add_uniform(instructions, state, "gl_BackMaterial", material_parameters_type); const glsl_type *const light_source_array_type = glsl_type::get_array_instance(state->symbols->get_type("gl_LightSourceParameters"), state->Const.MaxLights); - add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type, - instructions, state->symbols); + add_uniform(instructions, state, "gl_LightSource", light_source_array_type); + + const glsl_type *const light_model_products_type = + state->symbols->get_type("gl_LightModelProducts"); + add_uniform(instructions, state, "gl_FrontLightModelProduct", + light_model_products_type); + add_uniform(instructions, state, "gl_BackLightModelProduct", + light_model_products_type); + + const glsl_type *const light_products_type = + glsl_type::get_array_instance(state->symbols->get_type("gl_LightProducts"), + state->Const.MaxLights); + add_uniform(instructions, state, "gl_FrontLightProduct", light_products_type); + add_uniform(instructions, state, "gl_BackLightProduct", light_products_type); - /* FINISHME: Add support for gl_LightModel */ - /* FINISHME: Add support for gl_FrontLightProduct[], gl_BackLightProduct[] */ - /* FINISHME: Add support for gl_TextureEnvColor[] */ - /* FINISHME: Add support for gl_ObjectPlane*[], gl_EyePlane*[] */ - /* FINISHME: Add support for gl_Fog */ + add_uniform(instructions, state, "gl_TextureEnvColor", + glsl_type::get_array_instance(glsl_type::vec4_type, + state->Const.MaxTextureUnits)); + + const glsl_type *const texcoords_vec4 = + glsl_type::get_array_instance(glsl_type::vec4_type, + state->Const.MaxTextureCoords); + add_uniform(instructions, state, "gl_EyePlaneS", texcoords_vec4); + add_uniform(instructions, state, "gl_EyePlaneT", texcoords_vec4); + add_uniform(instructions, state, "gl_EyePlaneR", texcoords_vec4); + add_uniform(instructions, state, "gl_EyePlaneQ", texcoords_vec4); + add_uniform(instructions, state, "gl_ObjectPlaneS", texcoords_vec4); + add_uniform(instructions, state, "gl_ObjectPlaneT", texcoords_vec4); + add_uniform(instructions, state, "gl_ObjectPlaneR", texcoords_vec4); + add_uniform(instructions, state, "gl_ObjectPlaneQ", texcoords_vec4); + + add_uniform(instructions, state, "gl_Fog", + state->symbols->get_type("gl_FogParameters")); } static void -- cgit v1.2.3 From dc27e7356952984d023e05fef90d0f8c4bb07a09 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 08:13:53 -0700 Subject: ir_to_mesa: Add remaining state variable (builtin uniforms) support. Fixes: glsl1-GL state variable reference (diffuse product) glsl1-GL state variable reference (gl_FrontMaterial.ambient) glsl1-GL state variable reference (gl_LightSource[0].diffuse) glsl1-GL state variable reference (point attenuation) glsl1-GL state variable reference (point size) glsl1-linear fog --- src/mesa/program/ir_to_mesa.cpp | 201 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index fe0c19acea0..c53381e29d9 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -946,6 +946,181 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) this->result = src_reg; } +static const struct { + const char *name; + const char *field; + int tokens[STATE_LENGTH]; + int swizzle; + bool array_indexed; +} statevars[] = { + {"gl_DepthRange", "near", + {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX}, + {"gl_DepthRange", "far", + {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_YYYY}, + {"gl_DepthRange", "diff", + {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_ZZZZ}, + + {"gl_ClipPlane", NULL, + {STATE_CLIPPLANE, 0, 0}, SWIZZLE_XYZW, true} +, + {"gl_Point", "size", + {STATE_POINT_SIZE}, SWIZZLE_XXXX}, + {"gl_Point", "sizeMin", + {STATE_POINT_SIZE}, SWIZZLE_YYYY}, + {"gl_Point", "sizeMax", + {STATE_POINT_SIZE}, SWIZZLE_ZZZZ}, + {"gl_Point", "fadeThresholdSize", + {STATE_POINT_SIZE}, SWIZZLE_WWWW}, + {"gl_Point", "distanceConstantAttenuation", + {STATE_POINT_ATTENUATION}, SWIZZLE_XXXX}, + {"gl_Point", "distanceLinearAttenuation", + {STATE_POINT_ATTENUATION}, SWIZZLE_YYYY}, + {"gl_Point", "distanceQuadraticAttenuation", + {STATE_POINT_ATTENUATION}, SWIZZLE_ZZZZ}, + + {"gl_FrontMaterial", "emission", + {STATE_MATERIAL, 0, STATE_EMISSION}, SWIZZLE_XYZW}, + {"gl_FrontMaterial", "ambient", + {STATE_MATERIAL, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"gl_FrontMaterial", "diffuse", + {STATE_MATERIAL, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"gl_FrontMaterial", "specular", + {STATE_MATERIAL, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, + {"gl_FrontMaterial", "shininess", + {STATE_MATERIAL, 0, STATE_SHININESS}, SWIZZLE_XXXX}, + + {"gl_BackMaterial", "emission", + {STATE_MATERIAL, 1, STATE_EMISSION}, SWIZZLE_XYZW}, + {"gl_BackMaterial", "ambient", + {STATE_MATERIAL, 1, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"gl_BackMaterial", "diffuse", + {STATE_MATERIAL, 1, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"gl_BackMaterial", "specular", + {STATE_MATERIAL, 1, STATE_SPECULAR}, SWIZZLE_XYZW}, + {"gl_BackMaterial", "shininess", + {STATE_MATERIAL, 1, STATE_SHININESS}, SWIZZLE_XXXX}, + + {"gl_LightSource", "ambient", + {STATE_LIGHT, 0, STATE_AMBIENT}, SWIZZLE_XYZW, true}, + {"gl_LightSource", "diffuse", + {STATE_LIGHT, 0, STATE_DIFFUSE}, SWIZZLE_XYZW, true}, + {"gl_LightSource", "specular", + {STATE_LIGHT, 0, STATE_SPECULAR}, SWIZZLE_XYZW, true}, + {"gl_LightSource", "position", + {STATE_LIGHT, 0, STATE_POSITION}, SWIZZLE_XYZW, true}, + {"gl_LightSource", "halfVector", + {STATE_LIGHT, 0, STATE_HALF_VECTOR}, SWIZZLE_XYZW, true}, + {"gl_LightSource", "spotDirection", + {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, SWIZZLE_XYZW, true}, + {"gl_LightSource", "spotCosCutoff", + {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, SWIZZLE_WWWW, true}, + {"gl_LightSource", "spotCutoff", + {STATE_LIGHT, 0, STATE_SPOT_CUTOFF}, SWIZZLE_XXXX, true}, + {"gl_LightSource", "spotExponent", + {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_WWWW, true}, + {"gl_LightSource", "constantAttenuation", + {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_XXXX, true}, + {"gl_LightSource", "linearAttenuation", + {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_YYYY, true}, + {"gl_LightSource", "quadraticAttenuation", + {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_ZZZZ, true}, + + {"gl_LightModel", NULL, + {STATE_LIGHTMODEL_AMBIENT, 0}, SWIZZLE_XYZW}, + + {"gl_FrontLightModelProduct", NULL, + {STATE_LIGHTMODEL_SCENECOLOR, 0}, SWIZZLE_XYZW}, + {"gl_BackLightModelProduct", NULL, + {STATE_LIGHTMODEL_SCENECOLOR, 1}, SWIZZLE_XYZW}, + + {"gl_FrontLightProduct", "ambient", + {STATE_LIGHTPROD, 0, 0, STATE_AMBIENT}, SWIZZLE_XYZW, true}, + {"gl_FrontLightProduct", "diffuse", + {STATE_LIGHTPROD, 0, 0, STATE_DIFFUSE}, SWIZZLE_XYZW, true}, + {"gl_FrontLightProduct", "specular", + {STATE_LIGHTPROD, 0, 0, STATE_SPECULAR}, SWIZZLE_XYZW, true}, + + {"gl_BackLightProduct", "ambient", + {STATE_LIGHTPROD, 0, 1, STATE_AMBIENT}, SWIZZLE_XYZW, true}, + {"gl_BackLightProduct", "diffuse", + {STATE_LIGHTPROD, 0, 1, STATE_DIFFUSE}, SWIZZLE_XYZW, true}, + {"gl_BackLightProduct", "specular", + {STATE_LIGHTPROD, 0, 1, STATE_SPECULAR}, SWIZZLE_XYZW, true}, + + {"gl_TextureEnvColor", "ambient", + {STATE_TEXENV_COLOR, 0}, SWIZZLE_XYZW, true}, + + {"gl_EyePlaneS", NULL, + {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_S}, SWIZZLE_XYZW, true}, + {"gl_EyePlaneT", NULL, + {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_T}, SWIZZLE_XYZW, true}, + {"gl_EyePlaneR", NULL, + {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_R}, SWIZZLE_XYZW, true}, + {"gl_EyePlaneQ", NULL, + {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_Q}, SWIZZLE_XYZW, true}, + + {"gl_ObjectPlaneS", NULL, + {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_S}, SWIZZLE_XYZW, true}, + {"gl_ObjectPlaneT", NULL, + {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_T}, SWIZZLE_XYZW, true}, + {"gl_ObjectPlaneR", NULL, + {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_R}, SWIZZLE_XYZW, true}, + {"gl_ObjectPlaneQ", NULL, + {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_Q}, SWIZZLE_XYZW, true}, + + {"gl_Fog", "color", + {STATE_FOG_COLOR}, SWIZZLE_XYZW}, + {"gl_Fog", "density", + {STATE_FOG_PARAMS}, SWIZZLE_XXXX}, + {"gl_Fog", "start", + {STATE_FOG_PARAMS}, SWIZZLE_YYYY}, + {"gl_Fog", "end", + {STATE_FOG_PARAMS}, SWIZZLE_ZZZZ}, + {"gl_Fog", "scale", + {STATE_FOG_PARAMS}, SWIZZLE_WWWW}, +}; + +static ir_to_mesa_src_reg +get_builtin_uniform_reg(struct gl_program *prog, + const char *name, int array_index, const char *field) +{ + unsigned int i; + ir_to_mesa_src_reg src_reg; + int tokens[STATE_LENGTH]; + + for (i = 0; i < Elements(statevars); i++) { + if (strcmp(statevars[i].name, name) != 0) + continue; + if (!field && statevars[i].field) { + assert(!"FINISHME: whole-structure state var dereference"); + } + if (field && strcmp(statevars[i].field, field) != 0) + continue; + break; + } + + if (i == Elements(statevars)) { + printf("builtin uniform %s%s%s not found\n", + name, + field ? "." : "", + field ? field : ""); + abort(); + } + + memcpy(&tokens, statevars[i].tokens, sizeof(tokens)); + if (statevars[i].array_indexed) + tokens[1] = array_index; + + src_reg.file = PROGRAM_STATE_VAR; + src_reg.index = _mesa_add_state_reference(prog->Parameters, + (gl_state_index *)tokens); + src_reg.swizzle = statevars[i].swizzle; + src_reg.negate = 0; + src_reg.reladdr = false; + + return src_reg; +} + static int add_matrix_ref(struct gl_program *prog, int *tokens) { @@ -1176,6 +1351,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) void ir_to_mesa_visitor::visit(ir_dereference_array *ir) { + ir_variable *var = ir->variable_referenced(); ir_constant *index; ir_to_mesa_src_reg src_reg; ir_dereference_variable *deref_var = ir->array->as_dereference_variable(); @@ -1216,6 +1392,20 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) return; } + if (strncmp(var->name, "gl_", 3) == 0 && var->mode == ir_var_uniform && + !var->type->is_matrix()) { + ir_dereference_record *record = NULL; + if (ir->array->ir_type == ir_type_dereference_record) + record = (ir_dereference_record *)ir->array; + + assert(index || !"FINISHME: variable-indexed builtin uniform access"); + + this->result = get_builtin_uniform_reg(prog, + var->name, + index->value.i[0], + record ? record->field : NULL); + } + ir->array->accept(this); src_reg = this->result; @@ -1260,6 +1450,17 @@ ir_to_mesa_visitor::visit(ir_dereference_record *ir) unsigned int i; const glsl_type *struct_type = ir->record->type; int offset = 0; + ir_variable *var = ir->record->variable_referenced(); + + if (strncmp(var->name, "gl_", 3) == 0 && var->mode == ir_var_uniform) { + assert(var); + + this->result = get_builtin_uniform_reg(prog, + var->name, + 0, + ir->field); + return; + } ir->record->accept(this); -- cgit v1.2.3 From 279cc22dbc297b32ddc7301ed1790336cd1038ae Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 28 Jul 2010 12:19:44 -0700 Subject: glcpp: Add expected output for a recently-added test. I simply forgot to add this file when adding the test case originally. --- src/glsl/glcpp/tests/069-repeated-argument.c.expected | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/glsl/glcpp/tests/069-repeated-argument.c.expected diff --git a/src/glsl/glcpp/tests/069-repeated-argument.c.expected b/src/glsl/glcpp/tests/069-repeated-argument.c.expected new file mode 100644 index 00000000000..755c4d4b56c --- /dev/null +++ b/src/glsl/glcpp/tests/069-repeated-argument.c.expected @@ -0,0 +1,3 @@ + +1 1 + -- cgit v1.2.3 From e8a8f0f278d3c2b46b9e9883cbd837a59fcc3aaa Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 28 Jul 2010 12:27:33 -0700 Subject: glsl: Add generated files from flex/bison. The mesa build environment does not (currently) accept external dependencies such as flex and bison. The compromise is to commit the generated output files, (in spite of the pain that comes from having generated files under version control). --- src/glsl/glsl_lexer.cpp | 3174 +++++++++++++++++++++++++++++ src/glsl/glsl_parser.cpp | 5054 ++++++++++++++++++++++++++++++++++++++++++++++ src/glsl/glsl_parser.h | 262 +++ 3 files changed, 8490 insertions(+) create mode 100644 src/glsl/glsl_lexer.cpp create mode 100644 src/glsl/glsl_parser.cpp create mode 100644 src/glsl/glsl_parser.h diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp new file mode 100644 index 00000000000..e3e89195b2c --- /dev/null +++ b/src/glsl/glsl_lexer.cpp @@ -0,0 +1,3174 @@ +#line 2 "glsl_lexer.cpp" + +#line 4 "glsl_lexer.cpp" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE _mesa_glsl_restart(yyin ,yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via _mesa_glsl_restart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void _mesa_glsl_restart (FILE *input_file ,yyscan_t yyscanner ); +void _mesa_glsl__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE _mesa_glsl__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void _mesa_glsl__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void _mesa_glsl__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void _mesa_glsl_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void _mesa_glsl_pop_buffer_state (yyscan_t yyscanner ); + +static void _mesa_glsl_ensure_buffer_stack (yyscan_t yyscanner ); +static void _mesa_glsl__load_buffer_state (yyscan_t yyscanner ); +static void _mesa_glsl__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); + +#define YY_FLUSH_BUFFER _mesa_glsl__flush_buffer(YY_CURRENT_BUFFER ,yyscanner) + +YY_BUFFER_STATE _mesa_glsl__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE _mesa_glsl__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); + +void *_mesa_glsl_alloc (yy_size_t ,yyscan_t yyscanner ); +void *_mesa_glsl_realloc (void *,yy_size_t ,yyscan_t yyscanner ); +void _mesa_glsl_free (void * ,yyscan_t yyscanner ); + +#define yy_new_buffer _mesa_glsl__create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + _mesa_glsl_ensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + _mesa_glsl_ensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define _mesa_glsl_wrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 145 +#define YY_END_OF_BUFFER 146 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[519] = + { 0, + 0, 0, 9, 9, 146, 144, 1, 14, 144, 144, + 144, 144, 144, 144, 144, 144, 89, 87, 144, 144, + 144, 143, 144, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 144, 1, 144, 84, 145, 9, 13, + 145, 12, 10, 11, 1, 73, 80, 74, 83, 77, + 68, 79, 69, 86, 91, 78, 92, 89, 0, 0, + 0, 87, 0, 70, 72, 71, 0, 143, 76, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 22, 143, 143, 143, 143, 143, 143, 143, 143, 143, + + 143, 143, 143, 143, 26, 50, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 85, 75, 1, 0, 0, 2, 0, + 0, 0, 0, 9, 8, 12, 11, 0, 91, 90, + 0, 92, 0, 93, 88, 81, 82, 96, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 25, 143, 143, + 143, 143, 143, 143, 143, 143, 19, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 51, 143, 143, 143, + + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 0, 0, 0, 0, 8, 0, 91, 0, 90, 0, + 92, 93, 143, 17, 143, 143, 136, 143, 143, 143, + 143, 143, 143, 143, 143, 24, 99, 143, 143, 143, + 57, 143, 143, 104, 118, 143, 143, 143, 143, 143, + 143, 143, 143, 115, 139, 38, 39, 40, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 102, 94, 143, 143, 143, + 143, 143, 143, 35, 36, 37, 67, 143, 143, 0, + + 0, 0, 0, 0, 90, 143, 20, 29, 30, 31, + 143, 97, 16, 143, 143, 143, 143, 126, 127, 128, + 143, 95, 119, 18, 129, 130, 131, 141, 123, 124, + 125, 143, 52, 121, 143, 143, 32, 33, 34, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 116, 143, 143, 143, 143, 143, 143, 143, + 143, 98, 143, 138, 143, 143, 23, 0, 0, 0, + 0, 143, 143, 143, 143, 143, 117, 112, 107, 143, + 143, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 143, 143, 143, 143, 122, 103, 143, 110, 28, 143, + + 135, 58, 111, 66, 105, 143, 143, 143, 143, 143, + 143, 0, 0, 0, 0, 143, 143, 143, 106, 27, + 143, 143, 143, 140, 143, 143, 143, 143, 143, 143, + 100, 53, 143, 54, 143, 0, 0, 0, 7, 0, + 143, 55, 21, 113, 143, 143, 143, 108, 143, 143, + 143, 143, 143, 143, 101, 120, 109, 0, 0, 6, + 0, 0, 0, 3, 15, 114, 56, 137, 143, 142, + 60, 61, 62, 143, 0, 0, 0, 0, 143, 143, + 143, 143, 143, 143, 4, 0, 5, 0, 0, 0, + 143, 143, 143, 143, 143, 63, 0, 143, 143, 143, + + 143, 143, 59, 143, 132, 143, 133, 143, 143, 143, + 64, 143, 65, 143, 143, 143, 134, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 1, + 1, 9, 10, 1, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 19, 19, 20, 20, 21, 1, 22, + 23, 24, 1, 1, 25, 25, 26, 27, 28, 29, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 31, 32, 30, 30, 30, 30, 33, 30, 30, + 1, 1, 1, 34, 30, 1, 35, 36, 37, 38, + + 39, 40, 41, 42, 43, 30, 44, 45, 46, 47, + 48, 49, 30, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 1, 59, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[60] = + { 0, + 1, 2, 3, 1, 1, 1, 1, 1, 1, 4, + 4, 5, 1, 6, 6, 6, 6, 6, 6, 7, + 1, 1, 1, 1, 8, 8, 8, 9, 10, 11, + 11, 11, 12, 1, 8, 8, 8, 8, 9, 10, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 12, 11, 11, 1 + } ; + +static yyconst flex_int16_t yy_base[538] = + { 0, + 0, 58, 81, 0, 809, 810, 59, 810, 785, 784, + 54, 783, 55, 56, 54, 782, 129, 130, 53, 781, + 127, 0, 769, 101, 106, 126, 116, 128, 143, 754, + 144, 136, 753, 128, 145, 747, 142, 760, 159, 165, + 149, 164, 756, 149, 214, 207, 774, 810, 215, 810, + 783, 209, 810, 0, 228, 810, 810, 810, 810, 810, + 810, 810, 810, 810, 205, 810, 208, 133, 223, 171, + 0, 226, 772, 810, 810, 810, 771, 0, 810, 747, + 740, 743, 751, 750, 737, 740, 751, 738, 744, 732, + 729, 742, 729, 726, 726, 732, 720, 205, 725, 735, + + 721, 727, 730, 731, 0, 215, 730, 166, 716, 729, + 720, 200, 713, 727, 724, 726, 709, 714, 711, 700, + 709, 207, 713, 709, 711, 700, 703, 188, 708, 700, + 712, 223, 705, 810, 810, 268, 256, 273, 810, 691, + 703, 695, 705, 269, 0, 263, 0, 274, 810, 258, + 278, 810, 314, 280, 0, 810, 810, 0, 693, 697, + 706, 703, 687, 686, 686, 241, 701, 698, 698, 696, + 693, 685, 691, 678, 689, 675, 691, 0, 688, 676, + 683, 680, 684, 677, 666, 665, 678, 681, 678, 673, + 664, 286, 669, 672, 663, 670, 659, 663, 669, 660, + + 651, 654, 652, 662, 652, 647, 645, 645, 647, 644, + 655, 654, 259, 649, 644, 633, 297, 651, 653, 642, + 634, 638, 649, 633, 0, 321, 313, 306, 810, 329, + 340, 810, 639, 0, 637, 338, 0, 630, 628, 626, + 634, 623, 640, 629, 341, 0, 0, 623, 633, 633, + 0, 618, 344, 0, 0, 620, 347, 621, 615, 614, + 615, 614, 350, 0, 0, 607, 606, 605, 607, 608, + 613, 607, 603, 616, 611, 610, 602, 606, 598, 601, + 596, 604, 609, 608, 599, 0, 0, 605, 594, 594, + 599, 598, 595, 0, 0, 0, 0, 585, 597, 596, + + 595, 592, 581, 356, 367, 595, 0, 0, 0, 0, + 582, 0, 0, 582, 583, 577, 587, 0, 0, 0, + 578, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 585, 0, 0, 583, 579, 0, 0, 0, 365, + 368, 371, 575, 571, 576, 567, 565, 578, 564, 577, + 566, 573, 0, 571, 568, 572, 556, 565, 571, 566, + 554, 0, 556, 0, 555, 558, 0, 553, 597, 552, + 554, 543, 552, 541, 541, 554, 0, 556, 0, 548, + 547, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 529, 542, 529, 526, 0, 0, 531, 0, 0, 522, + + 0, 0, 0, 0, 0, 519, 521, 514, 516, 513, + 505, 498, 395, 513, 499, 494, 506, 504, 0, 0, + 493, 497, 483, 0, 482, 470, 467, 452, 375, 456, + 0, 0, 439, 0, 433, 428, 391, 323, 810, 423, + 430, 0, 0, 0, 429, 415, 427, 0, 428, 417, + 436, 435, 434, 407, 0, 0, 0, 411, 402, 810, + 415, 0, 396, 810, 0, 0, 0, 0, 406, 0, + 425, 371, 418, 412, 399, 417, 419, 423, 402, 402, + 404, 400, 402, 384, 810, 425, 810, 437, 0, 433, + 354, 371, 363, 360, 342, 0, 435, 313, 283, 267, + + 273, 256, 0, 258, 268, 248, 0, 239, 213, 195, + 0, 206, 0, 168, 32, 11, 0, 810, 469, 473, + 480, 487, 492, 498, 504, 506, 516, 525, 529, 533, + 539, 550, 556, 558, 567, 578, 580 + } ; + +static yyconst flex_int16_t yy_def[538] = + { 0, + 518, 1, 518, 3, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 519, 518, 518, + 518, 520, 518, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 521, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 522, 518, 523, 17, 524, 525, + 526, 519, 518, 518, 518, 518, 518, 520, 518, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 527, 518, 521, 528, 518, 523, + 529, 518, 518, 525, 526, 518, 518, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 518, 518, 518, 518, 527, 518, 528, 530, 518, 518, + 529, 518, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 518, + + 518, 518, 518, 518, 530, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 518, 518, 518, + 518, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 518, 518, 518, 518, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 518, 531, 532, 518, 518, + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 518, 533, 518, + 518, 534, 532, 518, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 518, 535, 536, 534, 520, 520, + 520, 520, 520, 520, 518, 518, 518, 518, 537, 536, + 520, 520, 520, 520, 520, 520, 537, 520, 520, 520, + + 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + 520, 520, 520, 520, 520, 520, 520, 0, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518 + } ; + +static yyconst flex_int16_t yy_nxt[870] = + { 0, + 6, 7, 8, 7, 9, 6, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 18, 18, 18, 18, 18, + 6, 19, 20, 21, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 22, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 22, 22, 22, 44, 45, + 55, 58, 55, 46, 61, 517, 63, 65, 65, 65, + 65, 65, 65, 65, 73, 74, 59, 62, 64, 516, + 47, 48, 49, 50, 49, 48, 48, 48, 48, 48, + 48, 48, 48, 51, 48, 52, 52, 52, 52, 52, + + 52, 53, 48, 48, 48, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 48, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 48, + 67, 67, 68, 68, 68, 68, 68, 68, 69, 76, + 77, 80, 81, 82, 89, 83, 70, 70, 90, 84, + 85, 71, 109, 91, 86, 518, 110, 70, 70, 92, + 87, 134, 93, 88, 94, 105, 114, 96, 102, 111, + 153, 153, 106, 95, 71, 97, 103, 98, 518, 107, + 99, 115, 112, 118, 116, 128, 100, 104, 130, 129, + + 119, 120, 131, 124, 121, 515, 125, 135, 138, 139, + 122, 132, 190, 123, 126, 136, 144, 55, 144, 137, + 191, 127, 146, 146, 146, 146, 146, 146, 146, 55, + 213, 55, 148, 149, 67, 151, 152, 67, 214, 176, + 514, 206, 195, 148, 149, 140, 151, 152, 196, 513, + 70, 141, 177, 70, 512, 142, 207, 138, 139, 184, + 143, 70, 185, 186, 70, 218, 187, 219, 188, 136, + 144, 55, 144, 137, 138, 139, 146, 146, 146, 146, + 146, 146, 146, 226, 226, 228, 229, 230, 230, 518, + 518, 240, 241, 511, 140, 510, 228, 229, 289, 509, + + 141, 266, 267, 268, 142, 508, 290, 507, 232, 143, + 506, 140, 294, 295, 296, 304, 304, 141, 505, 232, + 504, 142, 518, 518, 459, 460, 143, 154, 154, 154, + 154, 154, 154, 154, 227, 227, 227, 227, 227, 227, + 227, 149, 231, 231, 231, 231, 231, 231, 231, 518, + 518, 503, 149, 308, 309, 310, 318, 319, 320, 325, + 326, 327, 329, 330, 331, 337, 338, 339, 152, 305, + 305, 305, 305, 305, 305, 305, 518, 518, 502, 152, + 382, 383, 384, 385, 386, 387, 388, 389, 390, 451, + 452, 453, 459, 460, 501, 229, 413, 459, 460, 500, + + 454, 481, 482, 459, 460, 499, 229, 498, 437, 438, + 438, 438, 438, 438, 438, 476, 459, 460, 486, 487, + 486, 487, 496, 462, 459, 460, 486, 487, 461, 461, + 461, 461, 461, 461, 486, 487, 486, 487, 486, 487, + 495, 494, 493, 492, 491, 485, 462, 484, 483, 489, + 488, 488, 488, 488, 488, 488, 480, 479, 475, 474, + 473, 472, 471, 470, 469, 468, 467, 466, 465, 464, + 458, 457, 489, 72, 72, 72, 456, 72, 78, 78, + 78, 78, 78, 78, 78, 147, 147, 147, 147, 147, + 147, 147, 65, 65, 455, 65, 65, 150, 150, 450, + + 150, 150, 69, 69, 69, 449, 69, 154, 448, 154, + 154, 155, 155, 155, 155, 155, 225, 225, 447, 225, + 225, 225, 225, 225, 225, 225, 225, 225, 227, 446, + 227, 227, 231, 445, 231, 231, 305, 444, 305, 305, + 461, 461, 443, 442, 461, 441, 440, 439, 436, 435, + 461, 463, 463, 434, 433, 463, 463, 477, 477, 432, + 431, 477, 477, 478, 478, 478, 478, 478, 488, 488, + 430, 429, 488, 428, 427, 426, 425, 424, 488, 490, + 490, 423, 422, 490, 490, 497, 497, 497, 497, 497, + 421, 420, 419, 418, 417, 416, 415, 414, 413, 412, + + 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, + 401, 400, 399, 398, 397, 396, 395, 394, 393, 392, + 391, 381, 380, 379, 378, 377, 376, 375, 374, 373, + 372, 371, 370, 369, 368, 367, 366, 365, 364, 363, + 362, 361, 360, 359, 358, 357, 356, 355, 354, 353, + 352, 351, 350, 349, 348, 347, 346, 345, 344, 343, + 342, 341, 340, 336, 335, 334, 333, 332, 328, 324, + 323, 322, 321, 317, 316, 315, 314, 313, 312, 311, + 307, 306, 303, 302, 301, 300, 299, 298, 297, 293, + 292, 291, 288, 287, 286, 285, 284, 283, 282, 281, + + 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, + 270, 269, 265, 264, 263, 262, 261, 260, 259, 258, + 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, + 247, 246, 245, 244, 243, 242, 239, 238, 237, 236, + 235, 234, 233, 224, 223, 222, 221, 220, 217, 216, + 215, 212, 211, 210, 209, 208, 205, 204, 203, 202, + 201, 200, 199, 198, 197, 194, 193, 192, 189, 183, + 182, 181, 180, 179, 178, 175, 174, 173, 172, 171, + 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, + 160, 159, 158, 157, 156, 145, 75, 133, 117, 113, + + 108, 101, 79, 75, 66, 60, 57, 56, 518, 5, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518 + } ; + +static yyconst flex_int16_t yy_chk[870] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 7, 11, 7, 2, 13, 516, 14, 15, 15, 15, + 15, 15, 15, 15, 19, 19, 11, 13, 14, 515, + 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 17, 18, 17, 17, 17, 17, 17, 17, 17, 21, + 21, 24, 24, 25, 27, 25, 17, 18, 27, 25, + 26, 17, 34, 27, 26, 68, 34, 17, 18, 27, + 26, 44, 28, 26, 28, 32, 37, 29, 31, 35, + 70, 70, 32, 28, 17, 29, 31, 29, 68, 32, + 29, 37, 35, 39, 37, 41, 29, 31, 42, 41, + + 39, 39, 42, 40, 39, 514, 40, 44, 46, 46, + 39, 42, 108, 39, 40, 45, 49, 45, 49, 45, + 108, 40, 52, 52, 52, 52, 52, 52, 52, 55, + 128, 55, 65, 65, 69, 67, 67, 72, 128, 98, + 512, 122, 112, 65, 65, 46, 67, 67, 112, 510, + 69, 46, 98, 72, 509, 46, 122, 137, 137, 106, + 46, 69, 106, 106, 72, 132, 106, 132, 106, 136, + 144, 136, 144, 136, 138, 138, 146, 146, 146, 146, + 146, 146, 146, 148, 148, 150, 150, 151, 151, 154, + 154, 166, 166, 508, 137, 506, 150, 150, 213, 505, + + 137, 192, 192, 192, 137, 504, 213, 502, 154, 137, + 501, 138, 217, 217, 217, 228, 228, 138, 500, 154, + 499, 138, 227, 227, 438, 438, 138, 153, 153, 153, + 153, 153, 153, 153, 226, 226, 226, 226, 226, 226, + 226, 227, 230, 230, 230, 230, 230, 230, 230, 231, + 231, 498, 227, 236, 236, 236, 245, 245, 245, 253, + 253, 253, 257, 257, 257, 263, 263, 263, 231, 304, + 304, 304, 304, 304, 304, 304, 305, 305, 495, 231, + 340, 340, 340, 341, 341, 341, 342, 342, 342, 429, + 429, 429, 437, 437, 494, 305, 413, 463, 463, 493, + + 429, 472, 472, 459, 459, 492, 305, 491, 413, 413, + 413, 413, 413, 413, 413, 459, 461, 461, 476, 476, + 477, 477, 484, 437, 478, 478, 486, 486, 461, 461, + 461, 461, 461, 461, 490, 490, 497, 497, 488, 488, + 483, 482, 481, 480, 479, 475, 437, 474, 473, 476, + 488, 488, 488, 488, 488, 488, 471, 469, 458, 454, + 453, 452, 451, 450, 449, 447, 446, 445, 441, 440, + 436, 435, 476, 519, 519, 519, 433, 519, 520, 520, + 520, 520, 520, 520, 520, 521, 521, 521, 521, 521, + 521, 521, 522, 522, 430, 522, 522, 523, 523, 428, + + 523, 523, 524, 524, 524, 427, 524, 525, 426, 525, + 525, 526, 526, 526, 526, 526, 527, 527, 425, 527, + 527, 527, 527, 527, 527, 527, 527, 527, 528, 423, + 528, 528, 529, 422, 529, 529, 530, 421, 530, 530, + 531, 531, 418, 417, 531, 416, 415, 414, 412, 411, + 531, 532, 532, 410, 409, 532, 532, 533, 533, 408, + 407, 533, 533, 534, 534, 534, 534, 534, 535, 535, + 406, 400, 535, 397, 394, 393, 392, 391, 535, 536, + 536, 381, 380, 536, 536, 537, 537, 537, 537, 537, + 378, 376, 375, 374, 373, 372, 371, 370, 369, 368, + + 366, 365, 363, 361, 360, 359, 358, 357, 356, 355, + 354, 352, 351, 350, 349, 348, 347, 346, 345, 344, + 343, 336, 335, 332, 321, 317, 316, 315, 314, 311, + 306, 303, 302, 301, 300, 299, 298, 293, 292, 291, + 290, 289, 288, 285, 284, 283, 282, 281, 280, 279, + 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, + 268, 267, 266, 262, 261, 260, 259, 258, 256, 252, + 250, 249, 248, 244, 243, 242, 241, 240, 239, 238, + 235, 233, 224, 223, 222, 221, 220, 219, 218, 216, + 215, 214, 212, 211, 210, 209, 208, 207, 206, 205, + + 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, + 194, 193, 191, 190, 189, 188, 187, 186, 185, 184, + 183, 182, 181, 180, 179, 177, 176, 175, 174, 173, + 172, 171, 170, 169, 168, 167, 165, 164, 163, 162, + 161, 160, 159, 143, 142, 141, 140, 133, 131, 130, + 129, 127, 126, 125, 124, 123, 121, 120, 119, 118, + 117, 116, 115, 114, 113, 111, 110, 109, 107, 104, + 103, 102, 101, 100, 99, 97, 96, 95, 94, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 82, 81, 80, 77, 73, 51, 47, 43, 38, 36, + + 33, 30, 23, 20, 16, 12, 10, 9, 5, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, + 518, 518, 518, 518, 518, 518, 518, 518, 518 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "glsl_lexer.lpp" +#line 2 "glsl_lexer.lpp" +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" + +#define YY_USER_ACTION \ + do { \ + yylloc->source = 0; \ + yylloc->first_column = yycolumn + 1; \ + yylloc->first_line = yylineno + 1; \ + yycolumn += yyleng; \ + } while(0); + +#define YY_USER_INIT yylineno = 0; yycolumn = 0; + + +#line 845 "glsl_lexer.cpp" + +#define INITIAL 0 +#define PP 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#define YY_EXTRA_TYPE struct _mesa_glsl_parse_state * + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + YYLTYPE * yylloc_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals (yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + + # define yylloc yyg->yylloc_r + +int _mesa_glsl_lex_init (yyscan_t* scanner); + +int _mesa_glsl_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int _mesa_glsl_lex_destroy (yyscan_t yyscanner ); + +int _mesa_glsl_get_debug (yyscan_t yyscanner ); + +void _mesa_glsl_set_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE _mesa_glsl_get_extra (yyscan_t yyscanner ); + +void _mesa_glsl_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *_mesa_glsl_get_in (yyscan_t yyscanner ); + +void _mesa_glsl_set_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *_mesa_glsl_get_out (yyscan_t yyscanner ); + +void _mesa_glsl_set_out (FILE * out_str ,yyscan_t yyscanner ); + +int _mesa_glsl_get_leng (yyscan_t yyscanner ); + +char *_mesa_glsl_get_text (yyscan_t yyscanner ); + +int _mesa_glsl_get_lineno (yyscan_t yyscanner ); + +void _mesa_glsl_set_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * _mesa_glsl_get_lval (yyscan_t yyscanner ); + +void _mesa_glsl_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + + YYLTYPE *_mesa_glsl_get_lloc (yyscan_t yyscanner ); + + void _mesa_glsl_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int _mesa_glsl_wrap (yyscan_t yyscanner ); +#else +extern int _mesa_glsl_wrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (yyscan_t yyscanner ); +#else +static int input (yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int _mesa_glsl_lex \ + (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); + +#define YY_DECL int _mesa_glsl_lex \ + (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + +#line 56 "glsl_lexer.lpp" + + +#line 1094 "glsl_lexer.cpp" + + yylval = yylval_param; + + yylloc = yylloc_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + _mesa_glsl_ensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + _mesa_glsl__load_buffer_state(yyscanner ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 519 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 518 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 58 "glsl_lexer.lpp" +; + YY_BREAK +/* Preprocessor tokens. */ +case 2: +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 61 "glsl_lexer.lpp" +; + YY_BREAK +case 3: +YY_RULE_SETUP +#line 62 "glsl_lexer.lpp" +{ BEGIN PP; return VERSION; } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 63 "glsl_lexer.lpp" +{ BEGIN PP; return EXTENSION; } + YY_BREAK +case 5: +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 64 "glsl_lexer.lpp" +{ + /* Eat characters until the first digit is + * encountered + */ + char *ptr = yytext; + while (!isdigit(*ptr)) + ptr++; + + /* Subtract one from the line number because + * yylineno is zero-based instead of + * one-based. + */ + yylineno = strtol(ptr, &ptr, 0) - 1; + yylloc->source = strtol(ptr, NULL, 0); + } + YY_BREAK +case 6: +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 79 "glsl_lexer.lpp" +{ + /* Eat characters until the first digit is + * encountered + */ + char *ptr = yytext; + while (!isdigit(*ptr)) + ptr++; + + /* Subtract one from the line number because + * yylineno is zero-based instead of + * one-based. + */ + yylineno = strtol(ptr, &ptr, 0) - 1; + } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 93 "glsl_lexer.lpp" +{ BEGIN PP; return PRAGMA; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 94 "glsl_lexer.lpp" +{ } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 95 "glsl_lexer.lpp" +{ } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 96 "glsl_lexer.lpp" +return COLON; + YY_BREAK +case 11: +YY_RULE_SETUP +#line 97 "glsl_lexer.lpp" +{ + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 101 "glsl_lexer.lpp" +{ + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } + YY_BREAK +case 13: +/* rule 13 can match eol */ +YY_RULE_SETUP +#line 105 "glsl_lexer.lpp" +{ BEGIN 0; yylineno++; yycolumn = 0; return EOL; } + YY_BREAK +case 14: +/* rule 14 can match eol */ +YY_RULE_SETUP +#line 107 "glsl_lexer.lpp" +{ yylineno++; yycolumn = 0; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 109 "glsl_lexer.lpp" +return ATTRIBUTE; + YY_BREAK +case 16: +YY_RULE_SETUP +#line 110 "glsl_lexer.lpp" +return CONST_TOK; + YY_BREAK +case 17: +YY_RULE_SETUP +#line 111 "glsl_lexer.lpp" +return BOOL; + YY_BREAK +case 18: +YY_RULE_SETUP +#line 112 "glsl_lexer.lpp" +return FLOAT; + YY_BREAK +case 19: +YY_RULE_SETUP +#line 113 "glsl_lexer.lpp" +return INT; + YY_BREAK +case 20: +YY_RULE_SETUP +#line 115 "glsl_lexer.lpp" +return BREAK; + YY_BREAK +case 21: +YY_RULE_SETUP +#line 116 "glsl_lexer.lpp" +return CONTINUE; + YY_BREAK +case 22: +YY_RULE_SETUP +#line 117 "glsl_lexer.lpp" +return DO; + YY_BREAK +case 23: +YY_RULE_SETUP +#line 118 "glsl_lexer.lpp" +return WHILE; + YY_BREAK +case 24: +YY_RULE_SETUP +#line 119 "glsl_lexer.lpp" +return ELSE; + YY_BREAK +case 25: +YY_RULE_SETUP +#line 120 "glsl_lexer.lpp" +return FOR; + YY_BREAK +case 26: +YY_RULE_SETUP +#line 121 "glsl_lexer.lpp" +return IF; + YY_BREAK +case 27: +YY_RULE_SETUP +#line 122 "glsl_lexer.lpp" +return DISCARD; + YY_BREAK +case 28: +YY_RULE_SETUP +#line 123 "glsl_lexer.lpp" +return RETURN; + YY_BREAK +case 29: +YY_RULE_SETUP +#line 125 "glsl_lexer.lpp" +return BVEC2; + YY_BREAK +case 30: +YY_RULE_SETUP +#line 126 "glsl_lexer.lpp" +return BVEC3; + YY_BREAK +case 31: +YY_RULE_SETUP +#line 127 "glsl_lexer.lpp" +return BVEC4; + YY_BREAK +case 32: +YY_RULE_SETUP +#line 128 "glsl_lexer.lpp" +return IVEC2; + YY_BREAK +case 33: +YY_RULE_SETUP +#line 129 "glsl_lexer.lpp" +return IVEC3; + YY_BREAK +case 34: +YY_RULE_SETUP +#line 130 "glsl_lexer.lpp" +return IVEC4; + YY_BREAK +case 35: +YY_RULE_SETUP +#line 131 "glsl_lexer.lpp" +return VEC2; + YY_BREAK +case 36: +YY_RULE_SETUP +#line 132 "glsl_lexer.lpp" +return VEC3; + YY_BREAK +case 37: +YY_RULE_SETUP +#line 133 "glsl_lexer.lpp" +return VEC4; + YY_BREAK +case 38: +YY_RULE_SETUP +#line 134 "glsl_lexer.lpp" +return MAT2; + YY_BREAK +case 39: +YY_RULE_SETUP +#line 135 "glsl_lexer.lpp" +return MAT3; + YY_BREAK +case 40: +YY_RULE_SETUP +#line 136 "glsl_lexer.lpp" +return MAT4; + YY_BREAK +case 41: +YY_RULE_SETUP +#line 137 "glsl_lexer.lpp" +return MAT2X2; + YY_BREAK +case 42: +YY_RULE_SETUP +#line 138 "glsl_lexer.lpp" +return MAT2X3; + YY_BREAK +case 43: +YY_RULE_SETUP +#line 139 "glsl_lexer.lpp" +return MAT2X4; + YY_BREAK +case 44: +YY_RULE_SETUP +#line 140 "glsl_lexer.lpp" +return MAT3X2; + YY_BREAK +case 45: +YY_RULE_SETUP +#line 141 "glsl_lexer.lpp" +return MAT3X3; + YY_BREAK +case 46: +YY_RULE_SETUP +#line 142 "glsl_lexer.lpp" +return MAT3X4; + YY_BREAK +case 47: +YY_RULE_SETUP +#line 143 "glsl_lexer.lpp" +return MAT4X2; + YY_BREAK +case 48: +YY_RULE_SETUP +#line 144 "glsl_lexer.lpp" +return MAT4X3; + YY_BREAK +case 49: +YY_RULE_SETUP +#line 145 "glsl_lexer.lpp" +return MAT4X4; + YY_BREAK +case 50: +YY_RULE_SETUP +#line 147 "glsl_lexer.lpp" +return IN; + YY_BREAK +case 51: +YY_RULE_SETUP +#line 148 "glsl_lexer.lpp" +return OUT; + YY_BREAK +case 52: +YY_RULE_SETUP +#line 149 "glsl_lexer.lpp" +return INOUT; + YY_BREAK +case 53: +YY_RULE_SETUP +#line 150 "glsl_lexer.lpp" +return UNIFORM; + YY_BREAK +case 54: +YY_RULE_SETUP +#line 151 "glsl_lexer.lpp" +return VARYING; + YY_BREAK +case 55: +YY_RULE_SETUP +#line 152 "glsl_lexer.lpp" +{ + if (yyextra->language_version >= 120) { + return CENTROID; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 160 "glsl_lexer.lpp" +{ + if (yyextra->language_version >= 120) { + return INVARIANT; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 169 "glsl_lexer.lpp" +{ + if (yyextra->language_version >= 130) { + return FLAT; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + YY_BREAK +case 58: +YY_RULE_SETUP +#line 177 "glsl_lexer.lpp" +{ + if (yyextra->language_version >= 130) { + return SMOOTH; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + YY_BREAK +case 59: +YY_RULE_SETUP +#line 185 "glsl_lexer.lpp" +{ + if (yyextra->language_version >= 130) { + return NOPERSPECTIVE; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + YY_BREAK +case 60: +YY_RULE_SETUP +#line 194 "glsl_lexer.lpp" +return SAMPLER1D; + YY_BREAK +case 61: +YY_RULE_SETUP +#line 195 "glsl_lexer.lpp" +return SAMPLER2D; + YY_BREAK +case 62: +YY_RULE_SETUP +#line 196 "glsl_lexer.lpp" +return SAMPLER3D; + YY_BREAK +case 63: +YY_RULE_SETUP +#line 197 "glsl_lexer.lpp" +return SAMPLERCUBE; + YY_BREAK +case 64: +YY_RULE_SETUP +#line 198 "glsl_lexer.lpp" +return SAMPLER1DSHADOW; + YY_BREAK +case 65: +YY_RULE_SETUP +#line 199 "glsl_lexer.lpp" +return SAMPLER2DSHADOW; + YY_BREAK +case 66: +YY_RULE_SETUP +#line 201 "glsl_lexer.lpp" +return STRUCT; + YY_BREAK +case 67: +YY_RULE_SETUP +#line 202 "glsl_lexer.lpp" +return VOID; + YY_BREAK +case 68: +YY_RULE_SETUP +#line 204 "glsl_lexer.lpp" +return INC_OP; + YY_BREAK +case 69: +YY_RULE_SETUP +#line 205 "glsl_lexer.lpp" +return DEC_OP; + YY_BREAK +case 70: +YY_RULE_SETUP +#line 206 "glsl_lexer.lpp" +return LE_OP; + YY_BREAK +case 71: +YY_RULE_SETUP +#line 207 "glsl_lexer.lpp" +return GE_OP; + YY_BREAK +case 72: +YY_RULE_SETUP +#line 208 "glsl_lexer.lpp" +return EQ_OP; + YY_BREAK +case 73: +YY_RULE_SETUP +#line 209 "glsl_lexer.lpp" +return NE_OP; + YY_BREAK +case 74: +YY_RULE_SETUP +#line 210 "glsl_lexer.lpp" +return AND_OP; + YY_BREAK +case 75: +YY_RULE_SETUP +#line 211 "glsl_lexer.lpp" +return OR_OP; + YY_BREAK +case 76: +YY_RULE_SETUP +#line 212 "glsl_lexer.lpp" +return XOR_OP; + YY_BREAK +case 77: +YY_RULE_SETUP +#line 214 "glsl_lexer.lpp" +return MUL_ASSIGN; + YY_BREAK +case 78: +YY_RULE_SETUP +#line 215 "glsl_lexer.lpp" +return DIV_ASSIGN; + YY_BREAK +case 79: +YY_RULE_SETUP +#line 216 "glsl_lexer.lpp" +return ADD_ASSIGN; + YY_BREAK +case 80: +YY_RULE_SETUP +#line 217 "glsl_lexer.lpp" +return MOD_ASSIGN; + YY_BREAK +case 81: +YY_RULE_SETUP +#line 218 "glsl_lexer.lpp" +return LEFT_ASSIGN; + YY_BREAK +case 82: +YY_RULE_SETUP +#line 219 "glsl_lexer.lpp" +return RIGHT_ASSIGN; + YY_BREAK +case 83: +YY_RULE_SETUP +#line 220 "glsl_lexer.lpp" +return AND_ASSIGN; + YY_BREAK +case 84: +YY_RULE_SETUP +#line 221 "glsl_lexer.lpp" +return XOR_ASSIGN; + YY_BREAK +case 85: +YY_RULE_SETUP +#line 222 "glsl_lexer.lpp" +return OR_ASSIGN; + YY_BREAK +case 86: +YY_RULE_SETUP +#line 223 "glsl_lexer.lpp" +return SUB_ASSIGN; + YY_BREAK +case 87: +YY_RULE_SETUP +#line 225 "glsl_lexer.lpp" +{ + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } + YY_BREAK +case 88: +YY_RULE_SETUP +#line 229 "glsl_lexer.lpp" +{ + yylval->n = strtol(yytext + 2, NULL, 16); + return INTCONSTANT; + } + YY_BREAK +case 89: +YY_RULE_SETUP +#line 233 "glsl_lexer.lpp" +{ + yylval->n = strtol(yytext, NULL, 8); + return INTCONSTANT; + } + YY_BREAK +case 90: +YY_RULE_SETUP +#line 238 "glsl_lexer.lpp" +{ + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } + YY_BREAK +case 91: +YY_RULE_SETUP +#line 242 "glsl_lexer.lpp" +{ + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } + YY_BREAK +case 92: +YY_RULE_SETUP +#line 246 "glsl_lexer.lpp" +{ + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } + YY_BREAK +case 93: +YY_RULE_SETUP +#line 250 "glsl_lexer.lpp" +{ + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } + YY_BREAK +case 94: +YY_RULE_SETUP +#line 255 "glsl_lexer.lpp" +{ + yylval->n = 1; + return BOOLCONSTANT; + } + YY_BREAK +case 95: +YY_RULE_SETUP +#line 259 "glsl_lexer.lpp" +{ + yylval->n = 0; + return BOOLCONSTANT; + } + YY_BREAK +/* Reserved words in GLSL 1.10. */ +case 96: +YY_RULE_SETUP +#line 266 "glsl_lexer.lpp" +return ASM; + YY_BREAK +case 97: +YY_RULE_SETUP +#line 267 "glsl_lexer.lpp" +return CLASS; + YY_BREAK +case 98: +YY_RULE_SETUP +#line 268 "glsl_lexer.lpp" +return UNION; + YY_BREAK +case 99: +YY_RULE_SETUP +#line 269 "glsl_lexer.lpp" +return ENUM; + YY_BREAK +case 100: +YY_RULE_SETUP +#line 270 "glsl_lexer.lpp" +return TYPEDEF; + YY_BREAK +case 101: +YY_RULE_SETUP +#line 271 "glsl_lexer.lpp" +return TEMPLATE; + YY_BREAK +case 102: +YY_RULE_SETUP +#line 272 "glsl_lexer.lpp" +return THIS; + YY_BREAK +case 103: +YY_RULE_SETUP +#line 273 "glsl_lexer.lpp" +return PACKED; + YY_BREAK +case 104: +YY_RULE_SETUP +#line 274 "glsl_lexer.lpp" +return GOTO; + YY_BREAK +case 105: +YY_RULE_SETUP +#line 275 "glsl_lexer.lpp" +return SWITCH; + YY_BREAK +case 106: +YY_RULE_SETUP +#line 276 "glsl_lexer.lpp" +return DEFAULT; + YY_BREAK +case 107: +YY_RULE_SETUP +#line 277 "glsl_lexer.lpp" +return INLINE_TOK; + YY_BREAK +case 108: +YY_RULE_SETUP +#line 278 "glsl_lexer.lpp" +return NOINLINE; + YY_BREAK +case 109: +YY_RULE_SETUP +#line 279 "glsl_lexer.lpp" +return VOLATILE; + YY_BREAK +case 110: +YY_RULE_SETUP +#line 280 "glsl_lexer.lpp" +return PUBLIC_TOK; + YY_BREAK +case 111: +YY_RULE_SETUP +#line 281 "glsl_lexer.lpp" +return STATIC; + YY_BREAK +case 112: +YY_RULE_SETUP +#line 282 "glsl_lexer.lpp" +return EXTERN; + YY_BREAK +case 113: +YY_RULE_SETUP +#line 283 "glsl_lexer.lpp" +return EXTERNAL; + YY_BREAK +case 114: +YY_RULE_SETUP +#line 284 "glsl_lexer.lpp" +return INTERFACE; + YY_BREAK +case 115: +YY_RULE_SETUP +#line 285 "glsl_lexer.lpp" +return LONG; + YY_BREAK +case 116: +YY_RULE_SETUP +#line 286 "glsl_lexer.lpp" +return SHORT; + YY_BREAK +case 117: +YY_RULE_SETUP +#line 287 "glsl_lexer.lpp" +return DOUBLE; + YY_BREAK +case 118: +YY_RULE_SETUP +#line 288 "glsl_lexer.lpp" +return HALF; + YY_BREAK +case 119: +YY_RULE_SETUP +#line 289 "glsl_lexer.lpp" +return FIXED; + YY_BREAK +case 120: +YY_RULE_SETUP +#line 290 "glsl_lexer.lpp" +return UNSIGNED; + YY_BREAK +case 121: +YY_RULE_SETUP +#line 291 "glsl_lexer.lpp" +return INPUT; + YY_BREAK +case 122: +YY_RULE_SETUP +#line 292 "glsl_lexer.lpp" +return OUTPUT; + YY_BREAK +case 123: +YY_RULE_SETUP +#line 293 "glsl_lexer.lpp" +return HVEC2; + YY_BREAK +case 124: +YY_RULE_SETUP +#line 294 "glsl_lexer.lpp" +return HVEC3; + YY_BREAK +case 125: +YY_RULE_SETUP +#line 295 "glsl_lexer.lpp" +return HVEC4; + YY_BREAK +case 126: +YY_RULE_SETUP +#line 296 "glsl_lexer.lpp" +return DVEC2; + YY_BREAK +case 127: +YY_RULE_SETUP +#line 297 "glsl_lexer.lpp" +return DVEC3; + YY_BREAK +case 128: +YY_RULE_SETUP +#line 298 "glsl_lexer.lpp" +return DVEC4; + YY_BREAK +case 129: +YY_RULE_SETUP +#line 299 "glsl_lexer.lpp" +return FVEC2; + YY_BREAK +case 130: +YY_RULE_SETUP +#line 300 "glsl_lexer.lpp" +return FVEC3; + YY_BREAK +case 131: +YY_RULE_SETUP +#line 301 "glsl_lexer.lpp" +return FVEC4; + YY_BREAK +case 132: +YY_RULE_SETUP +#line 302 "glsl_lexer.lpp" +return SAMPLER2DRECT; + YY_BREAK +case 133: +YY_RULE_SETUP +#line 303 "glsl_lexer.lpp" +return SAMPLER3DRECT; + YY_BREAK +case 134: +YY_RULE_SETUP +#line 304 "glsl_lexer.lpp" +return SAMPLER2DRECTSHADOW; + YY_BREAK +case 135: +YY_RULE_SETUP +#line 305 "glsl_lexer.lpp" +return SIZEOF; + YY_BREAK +case 136: +YY_RULE_SETUP +#line 306 "glsl_lexer.lpp" +return CAST; + YY_BREAK +case 137: +YY_RULE_SETUP +#line 307 "glsl_lexer.lpp" +return NAMESPACE; + YY_BREAK +case 138: +YY_RULE_SETUP +#line 308 "glsl_lexer.lpp" +return USING; + YY_BREAK +/* Additional reserved words in GLSL 1.20. */ +case 139: +YY_RULE_SETUP +#line 311 "glsl_lexer.lpp" +return LOWP; + YY_BREAK +case 140: +YY_RULE_SETUP +#line 312 "glsl_lexer.lpp" +return MEDIUMP; + YY_BREAK +case 141: +YY_RULE_SETUP +#line 313 "glsl_lexer.lpp" +return HIGHP; + YY_BREAK +case 142: +YY_RULE_SETUP +#line 314 "glsl_lexer.lpp" +return PRECISION; + YY_BREAK +case 143: +YY_RULE_SETUP +#line 316 "glsl_lexer.lpp" +{ + struct _mesa_glsl_parse_state *state = yyextra; + void *ctx = state; + yylval->identifier = talloc_strdup(ctx, yytext); + return IDENTIFIER; + } + YY_BREAK +case 144: +YY_RULE_SETUP +#line 323 "glsl_lexer.lpp" +{ return yytext[0]; } + YY_BREAK +case 145: +YY_RULE_SETUP +#line 325 "glsl_lexer.lpp" +ECHO; + YY_BREAK +#line 2017 "glsl_lexer.cpp" +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(PP): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * _mesa_glsl_lex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( _mesa_glsl_wrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of _mesa_glsl_lex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + _mesa_glsl_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + _mesa_glsl_restart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) _mesa_glsl_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 519 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + register int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + register char *yy_cp = yyg->yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 519 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 518); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + _mesa_glsl_restart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( _mesa_glsl_wrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void _mesa_glsl_restart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + _mesa_glsl_ensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + _mesa_glsl__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + _mesa_glsl__load_buffer_state(yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void _mesa_glsl__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * _mesa_glsl_pop_buffer_state(); + * _mesa_glsl_push_buffer_state(new_buffer); + */ + _mesa_glsl_ensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + _mesa_glsl__load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (_mesa_glsl_wrap()) processing, but the only time this flag + * is looked at is after _mesa_glsl_wrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void _mesa_glsl__load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE _mesa_glsl__create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) _mesa_glsl_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) _mesa_glsl_alloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__create_buffer()" ); + + b->yy_is_our_buffer = 1; + + _mesa_glsl__init_buffer(b,file ,yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with _mesa_glsl__create_buffer() + * @param yyscanner The scanner object. + */ + void _mesa_glsl__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + _mesa_glsl_free((void *) b->yy_ch_buf ,yyscanner ); + + _mesa_glsl_free((void *) b ,yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a _mesa_glsl_restart() or at EOF. + */ + static void _mesa_glsl__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + _mesa_glsl__flush_buffer(b ,yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then _mesa_glsl__init_buffer was _probably_ + * called from _mesa_glsl_restart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void _mesa_glsl__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + _mesa_glsl__load_buffer_state(yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void _mesa_glsl_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + _mesa_glsl_ensure_buffer_stack(yyscanner); + + /* This block is copied from _mesa_glsl__switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from _mesa_glsl__switch_to_buffer. */ + _mesa_glsl__load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void _mesa_glsl_pop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + _mesa_glsl__delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + _mesa_glsl__load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void _mesa_glsl_ensure_buffer_stack (yyscan_t yyscanner) +{ + int num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)_mesa_glsl_alloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl_ensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)_mesa_glsl_realloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl_ensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE _mesa_glsl__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) _mesa_glsl_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + _mesa_glsl__switch_to_buffer(b ,yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to _mesa_glsl_lex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * _mesa_glsl__scan_bytes() instead. + */ +YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char * yystr , yyscan_t yyscanner) +{ + + return _mesa_glsl__scan_bytes(yystr,strlen(yystr) ,yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to _mesa_glsl_lex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE _mesa_glsl__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) _mesa_glsl_alloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = _mesa_glsl__scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in _mesa_glsl__scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE _mesa_glsl_get_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int _mesa_glsl_get_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int _mesa_glsl_get_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *_mesa_glsl_get_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *_mesa_glsl_get_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +int _mesa_glsl_get_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *_mesa_glsl_get_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void _mesa_glsl_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. + */ +void _mesa_glsl_set_lineno (int line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "_mesa_glsl_set_lineno called with no buffer" , yyscanner); + + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void _mesa_glsl_set_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "_mesa_glsl_set_column called with no buffer" , yyscanner); + + yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see _mesa_glsl__switch_to_buffer + */ +void _mesa_glsl_set_in (FILE * in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; +} + +void _mesa_glsl_set_out (FILE * out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; +} + +int _mesa_glsl_get_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void _mesa_glsl_set_debug (int bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * _mesa_glsl_get_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void _mesa_glsl_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +YYLTYPE *_mesa_glsl_get_lloc (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylloc; +} + +void _mesa_glsl_set_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylloc = yylloc_param; +} + +/* User-visible API */ + +/* _mesa_glsl_lex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int _mesa_glsl_lex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) _mesa_glsl_alloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* _mesa_glsl_lex_init_extra has the same functionality as _mesa_glsl_lex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to _mesa_glsl_alloc in + * the yyextra field. + */ + +int _mesa_glsl_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + _mesa_glsl_set_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) _mesa_glsl_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + _mesa_glsl_set_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from _mesa_glsl_lex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * _mesa_glsl_lex_init() + */ + return 0; +} + +/* _mesa_glsl_lex_destroy is for both reentrant and non-reentrant scanners. */ +int _mesa_glsl_lex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + _mesa_glsl__delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + _mesa_glsl_pop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + _mesa_glsl_free(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + _mesa_glsl_free(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * _mesa_glsl_lex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + _mesa_glsl_free ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *_mesa_glsl_alloc (yy_size_t size , yyscan_t yyscanner) +{ + return (void *) malloc( size ); +} + +void *_mesa_glsl_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void _mesa_glsl_free (void * ptr , yyscan_t yyscanner) +{ + free( (char *) ptr ); /* see _mesa_glsl_realloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 325 "glsl_lexer.lpp" + + + +void +_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) +{ + _mesa_glsl_lex_init_extra(state,& state->scanner); + _mesa_glsl__scan_string(string,state->scanner); +} + +void +_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) +{ + _mesa_glsl_lex_destroy(state->scanner); +} + diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp new file mode 100644 index 00000000000..b2113c083c6 --- /dev/null +++ b/src/glsl/glsl_parser.cpp @@ -0,0 +1,5054 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.4.1" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + +/* Using locations. */ +#define YYLSP_NEEDED 1 + +/* Substitute the variable and function names. */ +#define yyparse _mesa_glsl_parse +#define yylex _mesa_glsl_lex +#define yyerror _mesa_glsl_error +#define yylval _mesa_glsl_lval +#define yychar _mesa_glsl_char +#define yydebug _mesa_glsl_debug +#define yynerrs _mesa_glsl_nerrs +#define yylloc _mesa_glsl_lloc + +/* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ +#line 1 "glsl_parser.ypp" + +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" + +#define YYLEX_PARAM state->scanner + + + +/* Line 189 of yacc.c */ +#line 118 "glsl_parser.cpp" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 1 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ATTRIBUTE = 258, + CONST_TOK = 259, + BOOL = 260, + FLOAT = 261, + INT = 262, + UINT = 263, + BREAK = 264, + CONTINUE = 265, + DO = 266, + ELSE = 267, + FOR = 268, + IF = 269, + DISCARD = 270, + RETURN = 271, + SWITCH = 272, + CASE = 273, + DEFAULT = 274, + BVEC2 = 275, + BVEC3 = 276, + BVEC4 = 277, + IVEC2 = 278, + IVEC3 = 279, + IVEC4 = 280, + UVEC2 = 281, + UVEC3 = 282, + UVEC4 = 283, + VEC2 = 284, + VEC3 = 285, + VEC4 = 286, + MAT2 = 287, + MAT3 = 288, + MAT4 = 289, + CENTROID = 290, + IN = 291, + OUT = 292, + INOUT = 293, + UNIFORM = 294, + VARYING = 295, + NOPERSPECTIVE = 296, + FLAT = 297, + SMOOTH = 298, + MAT2X2 = 299, + MAT2X3 = 300, + MAT2X4 = 301, + MAT3X2 = 302, + MAT3X3 = 303, + MAT3X4 = 304, + MAT4X2 = 305, + MAT4X3 = 306, + MAT4X4 = 307, + SAMPLER1D = 308, + SAMPLER2D = 309, + SAMPLER3D = 310, + SAMPLERCUBE = 311, + SAMPLER1DSHADOW = 312, + SAMPLER2DSHADOW = 313, + SAMPLERCUBESHADOW = 314, + SAMPLER1DARRAY = 315, + SAMPLER2DARRAY = 316, + SAMPLER1DARRAYSHADOW = 317, + SAMPLER2DARRAYSHADOW = 318, + ISAMPLER1D = 319, + ISAMPLER2D = 320, + ISAMPLER3D = 321, + ISAMPLERCUBE = 322, + ISAMPLER1DARRAY = 323, + ISAMPLER2DARRAY = 324, + USAMPLER1D = 325, + USAMPLER2D = 326, + USAMPLER3D = 327, + USAMPLERCUBE = 328, + USAMPLER1DARRAY = 329, + USAMPLER2DARRAY = 330, + STRUCT = 331, + VOID = 332, + WHILE = 333, + IDENTIFIER = 334, + FLOATCONSTANT = 335, + INTCONSTANT = 336, + UINTCONSTANT = 337, + BOOLCONSTANT = 338, + FIELD_SELECTION = 339, + LEFT_OP = 340, + RIGHT_OP = 341, + INC_OP = 342, + DEC_OP = 343, + LE_OP = 344, + GE_OP = 345, + EQ_OP = 346, + NE_OP = 347, + AND_OP = 348, + OR_OP = 349, + XOR_OP = 350, + MUL_ASSIGN = 351, + DIV_ASSIGN = 352, + ADD_ASSIGN = 353, + MOD_ASSIGN = 354, + LEFT_ASSIGN = 355, + RIGHT_ASSIGN = 356, + AND_ASSIGN = 357, + XOR_ASSIGN = 358, + OR_ASSIGN = 359, + SUB_ASSIGN = 360, + INVARIANT = 361, + LOWP = 362, + MEDIUMP = 363, + HIGHP = 364, + PRECISION = 365, + VERSION = 366, + EXTENSION = 367, + LINE = 368, + PRAGMA = 369, + COLON = 370, + EOL = 371, + INTERFACE = 372, + OUTPUT = 373, + ASM = 374, + CLASS = 375, + UNION = 376, + ENUM = 377, + TYPEDEF = 378, + TEMPLATE = 379, + THIS = 380, + PACKED = 381, + GOTO = 382, + INLINE_TOK = 383, + NOINLINE = 384, + VOLATILE = 385, + PUBLIC_TOK = 386, + STATIC = 387, + EXTERN = 388, + EXTERNAL = 389, + LONG = 390, + SHORT = 391, + DOUBLE = 392, + HALF = 393, + FIXED = 394, + UNSIGNED = 395, + INPUT = 396, + OUPTUT = 397, + HVEC2 = 398, + HVEC3 = 399, + HVEC4 = 400, + DVEC2 = 401, + DVEC3 = 402, + DVEC4 = 403, + FVEC2 = 404, + FVEC3 = 405, + FVEC4 = 406, + SAMPLER2DRECT = 407, + SAMPLER3DRECT = 408, + SAMPLER2DRECTSHADOW = 409, + SIZEOF = 410, + CAST = 411, + NAMESPACE = 412, + USING = 413 + }; +#endif + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 214 of yacc.c */ +#line 45 "glsl_parser.ypp" + + int n; + float real; + char *identifier; + + union { + struct ast_type_qualifier q; + unsigned i; + } type_qualifier; + + struct ast_node *node; + struct ast_type_specifier *type_specifier; + struct ast_fully_specified_type *fully_specified_type; + struct ast_function *function; + struct ast_parameter_declarator *parameter_declarator; + struct ast_function_definition *function_definition; + struct ast_compound_statement *compound_statement; + struct ast_expression *expression; + struct ast_declarator_list *declarator_list; + struct ast_struct_specifier *struct_specifier; + struct ast_declaration *declaration; + + struct { + struct ast_node *cond; + struct ast_expression *rest; + } for_rest_statement; + + + +/* Line 214 of yacc.c */ +#line 342 "glsl_parser.cpp" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 264 of yacc.c */ +#line 367 "glsl_parser.cpp" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; + YYLTYPE yyls_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 5 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 3646 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 183 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 85 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 270 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 403 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 413 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 167, 2, 2, 2, 171, 174, 2, + 159, 160, 169, 165, 164, 166, 163, 170, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 178, 180, + 172, 179, 173, 177, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 161, 2, 162, 175, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 181, 176, 182, 168, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, + 155, 156, 157, 158 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 4, 9, 10, 14, 15, 18, 24, + 26, 29, 31, 33, 35, 37, 39, 41, 45, 47, + 52, 54, 58, 61, 64, 66, 68, 70, 74, 77, + 80, 83, 85, 88, 92, 95, 97, 99, 101, 103, + 106, 109, 112, 114, 116, 118, 120, 122, 126, 130, + 134, 136, 140, 144, 146, 150, 154, 156, 160, 164, + 168, 172, 174, 178, 182, 184, 188, 190, 194, 196, + 200, 202, 206, 208, 212, 214, 218, 220, 226, 228, + 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, + 252, 254, 256, 260, 262, 265, 268, 273, 276, 278, + 280, 283, 287, 291, 294, 300, 304, 307, 311, 314, + 315, 317, 319, 321, 323, 325, 329, 335, 342, 350, + 359, 365, 367, 370, 375, 381, 388, 396, 401, 404, + 406, 409, 411, 413, 415, 417, 419, 422, 425, 427, + 429, 431, 434, 436, 438, 441, 444, 446, 448, 451, + 453, 457, 462, 464, 466, 468, 470, 472, 474, 476, + 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, + 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, + 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, + 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, + 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, + 578, 580, 582, 588, 593, 595, 598, 602, 604, 608, + 610, 615, 617, 619, 621, 623, 625, 627, 629, 631, + 633, 635, 637, 639, 641, 643, 646, 650, 652, 654, + 657, 661, 663, 666, 668, 671, 679, 685, 691, 699, + 701, 706, 712, 716, 719, 725, 733, 740, 742, 744, + 746, 747, 750, 754, 757, 760, 763, 767, 770, 772, + 774 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = +{ + 184, 0, -1, -1, 186, 187, 185, 189, -1, -1, + 111, 81, 116, -1, -1, 187, 188, -1, 112, 79, + 115, 79, 116, -1, 266, -1, 189, 266, -1, 79, + -1, 190, -1, 81, -1, 82, -1, 80, -1, 83, + -1, 159, 217, 160, -1, 191, -1, 192, 161, 193, + 162, -1, 194, -1, 192, 163, 79, -1, 192, 87, + -1, 192, 88, -1, 217, -1, 195, -1, 196, -1, + 192, 163, 196, -1, 198, 160, -1, 197, 160, -1, + 199, 77, -1, 199, -1, 199, 215, -1, 198, 164, + 215, -1, 200, 159, -1, 235, -1, 79, -1, 84, + -1, 192, -1, 87, 201, -1, 88, 201, -1, 202, + 201, -1, 165, -1, 166, -1, 167, -1, 168, -1, + 201, -1, 203, 169, 201, -1, 203, 170, 201, -1, + 203, 171, 201, -1, 203, -1, 204, 165, 203, -1, + 204, 166, 203, -1, 204, -1, 205, 85, 204, -1, + 205, 86, 204, -1, 205, -1, 206, 172, 205, -1, + 206, 173, 205, -1, 206, 89, 205, -1, 206, 90, + 205, -1, 206, -1, 207, 91, 206, -1, 207, 92, + 206, -1, 207, -1, 208, 174, 207, -1, 208, -1, + 209, 175, 208, -1, 209, -1, 210, 176, 209, -1, + 210, -1, 211, 93, 210, -1, 211, -1, 212, 95, + 211, -1, 212, -1, 213, 94, 212, -1, 213, -1, + 213, 177, 217, 178, 215, -1, 214, -1, 201, 216, + 215, -1, 179, -1, 96, -1, 97, -1, 99, -1, + 98, -1, 105, -1, 100, -1, 101, -1, 102, -1, + 103, -1, 104, -1, 215, -1, 217, 164, 215, -1, + 214, -1, 220, 180, -1, 228, 180, -1, 110, 239, + 236, 180, -1, 221, 160, -1, 223, -1, 222, -1, + 223, 225, -1, 222, 164, 225, -1, 230, 79, 159, + -1, 235, 79, -1, 235, 79, 161, 218, 162, -1, + 232, 226, 224, -1, 226, 224, -1, 232, 226, 227, + -1, 226, 227, -1, -1, 36, -1, 37, -1, 38, + -1, 235, -1, 229, -1, 228, 164, 79, -1, 228, + 164, 79, 161, 162, -1, 228, 164, 79, 161, 218, + 162, -1, 228, 164, 79, 161, 162, 179, 245, -1, + 228, 164, 79, 161, 218, 162, 179, 245, -1, 228, + 164, 79, 179, 245, -1, 230, -1, 230, 79, -1, + 230, 79, 161, 162, -1, 230, 79, 161, 218, 162, + -1, 230, 79, 161, 162, 179, 245, -1, 230, 79, + 161, 218, 162, 179, 245, -1, 230, 79, 179, 245, + -1, 106, 79, -1, 235, -1, 233, 235, -1, 43, + -1, 42, -1, 41, -1, 4, -1, 234, -1, 231, + 233, -1, 106, 233, -1, 4, -1, 3, -1, 40, + -1, 35, 40, -1, 36, -1, 37, -1, 35, 36, + -1, 35, 37, -1, 39, -1, 236, -1, 239, 236, + -1, 237, -1, 237, 161, 162, -1, 237, 161, 218, + 162, -1, 238, -1, 240, -1, 79, -1, 77, -1, + 6, -1, 7, -1, 8, -1, 5, -1, 29, -1, + 30, -1, 31, -1, 20, -1, 21, -1, 22, -1, + 23, -1, 24, -1, 25, -1, 26, -1, 27, -1, + 28, -1, 32, -1, 33, -1, 34, -1, 44, -1, + 45, -1, 46, -1, 47, -1, 48, -1, 49, -1, + 50, -1, 51, -1, 52, -1, 53, -1, 54, -1, + 152, -1, 55, -1, 56, -1, 57, -1, 58, -1, + 154, -1, 59, -1, 60, -1, 61, -1, 62, -1, + 63, -1, 64, -1, 65, -1, 66, -1, 67, -1, + 68, -1, 69, -1, 70, -1, 71, -1, 72, -1, + 73, -1, 74, -1, 75, -1, 109, -1, 108, -1, + 107, -1, 76, 79, 181, 241, 182, -1, 76, 181, + 241, 182, -1, 242, -1, 241, 242, -1, 235, 243, + 180, -1, 244, -1, 243, 164, 244, -1, 79, -1, + 79, 161, 218, 162, -1, 215, -1, 219, -1, 248, + -1, 249, -1, 251, -1, 250, -1, 257, -1, 246, + -1, 255, -1, 256, -1, 259, -1, 260, -1, 261, + -1, 265, -1, 181, 182, -1, 181, 254, 182, -1, + 253, -1, 250, -1, 181, 182, -1, 181, 254, 182, + -1, 247, -1, 254, 247, -1, 180, -1, 217, 180, + -1, 14, 159, 217, 160, 248, 12, 248, -1, 14, + 159, 217, 160, 248, -1, 14, 159, 217, 160, 249, + -1, 14, 159, 217, 160, 248, 12, 249, -1, 217, + -1, 230, 79, 179, 245, -1, 17, 159, 217, 160, + 251, -1, 18, 217, 178, -1, 19, 178, -1, 78, + 159, 258, 160, 252, -1, 11, 247, 78, 159, 217, + 160, 180, -1, 13, 159, 262, 264, 160, 252, -1, + 255, -1, 246, -1, 258, -1, -1, 263, 180, -1, + 263, 180, 217, -1, 10, 180, -1, 9, 180, -1, + 16, 180, -1, 16, 217, 180, -1, 15, 180, -1, + 267, -1, 219, -1, 220, 253, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 190, 190, 189, 198, 201, 218, 220, 224, 233, + 241, 252, 256, 263, 270, 277, 284, 291, 298, 299, + 305, 309, 316, 322, 331, 335, 339, 340, 349, 350, + 354, 355, 359, 365, 377, 381, 387, 394, 405, 406, + 412, 418, 428, 429, 430, 431, 435, 436, 442, 448, + 457, 458, 464, 473, 474, 480, 489, 490, 496, 502, + 508, 517, 518, 524, 533, 534, 543, 544, 553, 554, + 563, 564, 573, 574, 583, 584, 593, 594, 603, 604, + 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, + 623, 627, 631, 647, 651, 655, 659, 673, 677, 678, + 682, 687, 695, 706, 716, 731, 738, 743, 754, 766, + 767, 768, 769, 773, 777, 778, 787, 796, 805, 814, + 823, 836, 847, 856, 865, 874, 883, 892, 901, 915, + 922, 933, 934, 935, 939, 943, 944, 948, 956, 957, + 958, 959, 960, 961, 962, 963, 964, 968, 969, 977, + 978, 984, 993, 999, 1005, 1014, 1015, 1016, 1017, 1018, + 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, + 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, + 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, + 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, + 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1071, + 1082, 1093, 1107, 1113, 1122, 1127, 1135, 1150, 1155, 1163, + 1169, 1178, 1182, 1188, 1189, 1193, 1194, 1198, 1202, 1203, + 1204, 1205, 1206, 1207, 1208, 1212, 1218, 1227, 1228, 1232, + 1238, 1247, 1257, 1269, 1275, 1284, 1293, 1299, 1305, 1314, + 1318, 1332, 1336, 1337, 1341, 1348, 1355, 1365, 1366, 1370, + 1372, 1378, 1383, 1392, 1398, 1404, 1410, 1416, 1425, 1426, + 1430 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "ATTRIBUTE", "CONST_TOK", "BOOL", + "FLOAT", "INT", "UINT", "BREAK", "CONTINUE", "DO", "ELSE", "FOR", "IF", + "DISCARD", "RETURN", "SWITCH", "CASE", "DEFAULT", "BVEC2", "BVEC3", + "BVEC4", "IVEC2", "IVEC3", "IVEC4", "UVEC2", "UVEC3", "UVEC4", "VEC2", + "VEC3", "VEC4", "MAT2", "MAT3", "MAT4", "CENTROID", "IN", "OUT", "INOUT", + "UNIFORM", "VARYING", "NOPERSPECTIVE", "FLAT", "SMOOTH", "MAT2X2", + "MAT2X3", "MAT2X4", "MAT3X2", "MAT3X3", "MAT3X4", "MAT4X2", "MAT4X3", + "MAT4X4", "SAMPLER1D", "SAMPLER2D", "SAMPLER3D", "SAMPLERCUBE", + "SAMPLER1DSHADOW", "SAMPLER2DSHADOW", "SAMPLERCUBESHADOW", + "SAMPLER1DARRAY", "SAMPLER2DARRAY", "SAMPLER1DARRAYSHADOW", + "SAMPLER2DARRAYSHADOW", "ISAMPLER1D", "ISAMPLER2D", "ISAMPLER3D", + "ISAMPLERCUBE", "ISAMPLER1DARRAY", "ISAMPLER2DARRAY", "USAMPLER1D", + "USAMPLER2D", "USAMPLER3D", "USAMPLERCUBE", "USAMPLER1DARRAY", + "USAMPLER2DARRAY", "STRUCT", "VOID", "WHILE", "IDENTIFIER", + "FLOATCONSTANT", "INTCONSTANT", "UINTCONSTANT", "BOOLCONSTANT", + "FIELD_SELECTION", "LEFT_OP", "RIGHT_OP", "INC_OP", "DEC_OP", "LE_OP", + "GE_OP", "EQ_OP", "NE_OP", "AND_OP", "OR_OP", "XOR_OP", "MUL_ASSIGN", + "DIV_ASSIGN", "ADD_ASSIGN", "MOD_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN", + "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", "SUB_ASSIGN", "INVARIANT", + "LOWP", "MEDIUMP", "HIGHP", "PRECISION", "VERSION", "EXTENSION", "LINE", + "PRAGMA", "COLON", "EOL", "INTERFACE", "OUTPUT", "ASM", "CLASS", "UNION", + "ENUM", "TYPEDEF", "TEMPLATE", "THIS", "PACKED", "GOTO", "INLINE_TOK", + "NOINLINE", "VOLATILE", "PUBLIC_TOK", "STATIC", "EXTERN", "EXTERNAL", + "LONG", "SHORT", "DOUBLE", "HALF", "FIXED", "UNSIGNED", "INPUT", + "OUPTUT", "HVEC2", "HVEC3", "HVEC4", "DVEC2", "DVEC3", "DVEC4", "FVEC2", + "FVEC3", "FVEC4", "SAMPLER2DRECT", "SAMPLER3DRECT", + "SAMPLER2DRECTSHADOW", "SIZEOF", "CAST", "NAMESPACE", "USING", "'('", + "')'", "'['", "']'", "'.'", "','", "'+'", "'-'", "'!'", "'~'", "'*'", + "'/'", "'%'", "'<'", "'>'", "'&'", "'^'", "'|'", "'?'", "':'", "'='", + "';'", "'{'", "'}'", "$accept", "translation_unit", "$@1", + "version_statement", "extension_statement_list", "extension_statement", + "external_declaration_list", "variable_identifier", "primary_expression", + "postfix_expression", "integer_expression", "function_call", + "function_call_or_method", "function_call_generic", + "function_call_header_no_parameters", + "function_call_header_with_parameters", "function_call_header", + "function_identifier", "unary_expression", "unary_operator", + "multiplicative_expression", "additive_expression", "shift_expression", + "relational_expression", "equality_expression", "and_expression", + "exclusive_or_expression", "inclusive_or_expression", + "logical_and_expression", "logical_xor_expression", + "logical_or_expression", "conditional_expression", + "assignment_expression", "assignment_operator", "expression", + "constant_expression", "declaration", "function_prototype", + "function_declarator", "function_header_with_parameters", + "function_header", "parameter_declarator", "parameter_declaration", + "parameter_qualifier", "parameter_type_specifier", + "init_declarator_list", "single_declaration", "fully_specified_type", + "interpolation_qualifier", "parameter_type_qualifier", "type_qualifier", + "storage_qualifier", "type_specifier", "type_specifier_no_prec", + "type_specifier_nonarray", "basic_type_specifier_nonarray", + "precision_qualifier", "struct_specifier", "struct_declaration_list", + "struct_declaration", "struct_declarator_list", "struct_declarator", + "initializer", "declaration_statement", "statement", "statement_matched", + "statement_unmatched", "simple_statement", "compound_statement", + "statement_no_new_scope", "compound_statement_no_new_scope", + "statement_list", "expression_statement", "selection_statement_matched", + "selection_statement_unmatched", "condition", "switch_statement", + "case_label", "iteration_statement", "for_init_statement", + "conditionopt", "for_rest_statement", "jump_statement", + "external_declaration", "function_definition", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, + 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, + 405, 406, 407, 408, 409, 410, 411, 412, 413, 40, + 41, 91, 93, 46, 44, 43, 45, 33, 126, 42, + 47, 37, 60, 62, 38, 94, 124, 63, 58, 61, + 59, 123, 125 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint16 yyr1[] = +{ + 0, 183, 185, 184, 186, 186, 187, 187, 188, 189, + 189, 190, 191, 191, 191, 191, 191, 191, 192, 192, + 192, 192, 192, 192, 193, 194, 195, 195, 196, 196, + 197, 197, 198, 198, 199, 200, 200, 200, 201, 201, + 201, 201, 202, 202, 202, 202, 203, 203, 203, 203, + 204, 204, 204, 205, 205, 205, 206, 206, 206, 206, + 206, 207, 207, 207, 208, 208, 209, 209, 210, 210, + 211, 211, 212, 212, 213, 213, 214, 214, 215, 215, + 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + 216, 217, 217, 218, 219, 219, 219, 220, 221, 221, + 222, 222, 223, 224, 224, 225, 225, 225, 225, 226, + 226, 226, 226, 227, 228, 228, 228, 228, 228, 228, + 228, 229, 229, 229, 229, 229, 229, 229, 229, 230, + 230, 231, 231, 231, 232, 233, 233, 233, 234, 234, + 234, 234, 234, 234, 234, 234, 234, 235, 235, 236, + 236, 236, 237, 237, 237, 238, 238, 238, 238, 238, + 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, + 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, + 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, + 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, + 238, 238, 238, 238, 238, 238, 238, 238, 238, 239, + 239, 239, 240, 240, 241, 241, 242, 243, 243, 244, + 244, 245, 246, 247, 247, 248, 248, 249, 250, 250, + 250, 250, 250, 250, 250, 251, 251, 252, 252, 253, + 253, 254, 254, 255, 255, 256, 257, 257, 257, 258, + 258, 259, 260, 260, 261, 261, 261, 262, 262, 263, + 263, 264, 264, 265, 265, 265, 265, 265, 266, 266, + 267 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 4, 0, 3, 0, 2, 5, 1, + 2, 1, 1, 1, 1, 1, 1, 3, 1, 4, + 1, 3, 2, 2, 1, 1, 1, 3, 2, 2, + 2, 1, 2, 3, 2, 1, 1, 1, 1, 2, + 2, 2, 1, 1, 1, 1, 1, 3, 3, 3, + 1, 3, 3, 1, 3, 3, 1, 3, 3, 3, + 3, 1, 3, 3, 1, 3, 1, 3, 1, 3, + 1, 3, 1, 3, 1, 3, 1, 5, 1, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 3, 1, 2, 2, 4, 2, 1, 1, + 2, 3, 3, 2, 5, 3, 2, 3, 2, 0, + 1, 1, 1, 1, 1, 3, 5, 6, 7, 8, + 5, 1, 2, 4, 5, 6, 7, 4, 2, 1, + 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, + 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, + 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 5, 4, 1, 2, 3, 1, 3, 1, + 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 3, 1, 1, 2, + 3, 1, 2, 1, 2, 7, 5, 5, 7, 1, + 4, 5, 3, 2, 5, 7, 6, 1, 1, 1, + 0, 2, 3, 2, 2, 2, 3, 2, 1, 1, + 2 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint16 yydefact[] = +{ + 4, 0, 0, 6, 0, 1, 2, 5, 0, 0, + 7, 0, 139, 138, 159, 156, 157, 158, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 160, 161, 162, + 172, 173, 174, 0, 142, 143, 146, 140, 133, 132, + 131, 175, 176, 177, 178, 179, 180, 181, 182, 183, + 184, 185, 187, 188, 189, 190, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + 206, 207, 208, 0, 155, 154, 0, 211, 210, 209, + 0, 186, 191, 3, 269, 0, 0, 99, 109, 0, + 114, 121, 0, 0, 135, 129, 147, 149, 152, 0, + 153, 9, 268, 0, 144, 145, 141, 0, 0, 128, + 0, 137, 0, 10, 94, 0, 270, 97, 109, 134, + 110, 111, 112, 100, 0, 109, 0, 95, 122, 136, + 130, 0, 148, 0, 0, 0, 0, 214, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 11, 15, 13, 14, 16, 37, 0, 0, 0, 42, + 43, 44, 45, 243, 0, 239, 12, 18, 38, 20, + 25, 26, 0, 0, 31, 0, 46, 0, 50, 53, + 56, 61, 64, 66, 68, 70, 72, 74, 76, 78, + 91, 0, 222, 0, 129, 228, 241, 223, 224, 226, + 225, 0, 229, 230, 227, 231, 232, 233, 234, 101, + 106, 108, 113, 0, 115, 102, 0, 0, 150, 46, + 93, 0, 35, 8, 0, 219, 0, 217, 213, 215, + 96, 264, 263, 0, 0, 0, 267, 265, 0, 0, + 0, 253, 0, 39, 40, 0, 235, 0, 22, 23, + 0, 0, 29, 28, 0, 155, 32, 34, 81, 82, + 84, 83, 86, 87, 88, 89, 90, 85, 80, 0, + 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 244, 240, 242, 103, 105, 107, 0, 0, + 123, 0, 221, 127, 151, 212, 0, 0, 216, 0, + 258, 257, 260, 0, 266, 0, 252, 249, 0, 0, + 17, 236, 0, 24, 21, 27, 33, 79, 47, 48, + 49, 51, 52, 54, 55, 59, 60, 57, 58, 62, + 63, 65, 67, 69, 71, 73, 75, 0, 92, 0, + 116, 0, 120, 0, 124, 0, 218, 0, 259, 0, + 0, 0, 0, 0, 0, 19, 0, 0, 0, 117, + 125, 0, 220, 0, 261, 0, 246, 247, 251, 0, + 0, 238, 254, 237, 77, 104, 118, 0, 126, 0, + 262, 256, 0, 250, 0, 119, 255, 245, 248, 0, + 0, 0, 0 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 2, 9, 3, 6, 10, 83, 166, 167, 168, + 322, 169, 170, 171, 172, 173, 174, 175, 176, 177, + 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, + 188, 189, 190, 269, 191, 221, 192, 193, 86, 87, + 88, 210, 123, 124, 211, 89, 90, 91, 92, 125, + 93, 94, 222, 96, 97, 98, 99, 100, 136, 137, + 226, 227, 303, 195, 196, 197, 198, 199, 200, 382, + 383, 201, 202, 203, 204, 319, 205, 206, 207, 312, + 359, 360, 208, 101, 102 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -325 +static const yytype_int16 yypact[] = +{ + -52, -1, 67, -325, -31, -325, 37, -325, 23, 3159, + -325, 52, -325, -325, -325, -325, -325, -325, -325, -325, + -325, -325, -325, -325, -325, -325, -325, -325, -325, -325, + -325, -325, -325, 94, -325, -325, -325, -325, -325, -325, + -325, -325, -325, -325, -325, -325, -325, -325, -325, -325, + -325, -325, -325, -325, -325, -325, -325, -325, -325, -325, + -325, -325, -325, -325, -325, -325, -325, -325, -325, -325, + -325, -325, -325, -72, -325, -325, 12, -325, -325, -325, + 36, -325, -325, 3159, -325, -163, 30, 27, -2, -98, + -325, 114, 144, 3381, -325, -325, -325, 33, -325, 3492, + -325, -325, -325, 117, -325, -325, -325, 17, 3381, -325, + 144, -325, 3492, -325, -325, 391, -325, -325, 35, -325, + -325, -325, -325, -325, 3381, 116, 120, -325, -119, -325, + -325, 2393, -325, 86, 3381, 124, 1799, -325, 25, 26, + 29, 1111, 48, 51, 31, 2077, 53, 2843, 39, 54, + -67, -325, -325, -325, -325, -325, 2843, 2843, 2843, -325, + -325, -325, -325, -325, 571, -325, -325, -325, -44, -325, + -325, -325, 60, -99, 2993, 55, -75, 2843, -10, 4, + 71, -79, 80, 47, 49, 46, 130, 131, -63, -325, + -325, -59, -325, 50, 68, -325, -325, -325, -325, -325, + -325, 751, -325, -325, -325, -325, -325, -325, -325, -325, + -325, -325, 149, 3381, -129, -325, 2543, 2843, -325, -325, + -325, 69, -325, -325, 1938, 73, -56, -325, -325, -325, + -325, -325, -325, 151, 1635, 2843, -325, -325, -51, 2843, + -108, -325, 2243, -325, -325, -38, -325, 931, -325, -325, + 2843, 3270, -325, -325, 2843, 72, -325, -325, -325, -325, + -325, -325, -325, -325, -325, -325, -325, -325, -325, 2843, + -325, 2843, 2843, 2843, 2843, 2843, 2843, 2843, 2843, 2843, + 2843, 2843, 2843, 2843, 2843, 2843, 2843, 2843, 2843, 2843, + 2843, 2843, -325, -325, -325, 75, -325, -325, 2693, 2843, + 58, 77, -325, -325, -325, -325, 2843, 124, -325, 81, + -325, -325, 2243, -27, -325, -25, -325, 78, 162, 83, + -325, -325, 82, 78, 87, -325, -325, -325, -325, -325, + -325, -10, -10, 4, 4, 71, 71, 71, 71, -79, + -79, 80, 47, 49, 46, 130, 131, -102, -325, 2843, + 66, 85, -325, 2843, 70, 89, -325, 2843, -325, 74, + 88, 1111, 95, 96, 1290, -325, 2843, 90, 2843, 98, + -325, 2843, -325, -24, 2843, 1290, 241, -325, -325, 2843, + 119, -325, -325, -325, -325, -325, -325, 2843, -325, 99, + 78, -325, 1111, -325, 2843, -325, -325, -325, -325, -14, + 1469, 268, 1469 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -325, -325, -325, -325, -325, -325, -325, -325, -325, -325, + -325, -325, -325, 34, -325, -325, -325, -325, -15, -325, + -100, -88, -115, -105, -3, 1, -4, 0, 2, -5, + -325, -130, -171, -325, -139, -211, 5, 24, -325, -325, + -325, 76, 170, 167, 84, -325, -325, -222, -325, -325, + -35, -325, -9, -54, -325, -325, 213, -325, 160, -123, + -325, -12, -290, 62, -137, -323, -324, -252, -64, -76, + 215, 137, 79, -325, -325, -8, -325, -325, -325, -325, + -325, -325, -325, 219, -325 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -155 +static const yytype_int16 yytable[] = +{ + 95, 220, 119, 256, 233, 301, 238, 107, 240, 352, + 278, 279, -154, 229, 84, 12, 13, 114, 115, 245, + 318, 258, 259, 260, 261, 262, 263, 264, 265, 266, + 267, 289, 298, 85, 120, 121, 122, 377, 376, 119, + 215, 111, 216, 248, 249, 132, 302, 33, 34, 35, + 299, 36, 37, 38, 39, 40, 291, 129, 138, 1, + 217, 253, 291, 370, 294, 254, 126, 5, 398, 397, + 316, 120, 121, 122, 95, 111, 366, 401, 386, 397, + 4, 388, 127, 326, 130, 7, 220, 351, 84, 393, + 318, 109, -36, 280, 281, 355, 313, 395, 327, 135, + 315, 229, 11, 317, 268, 291, 194, 85, 307, 108, + 294, 323, 381, 291, 290, 212, 219, 250, 110, 251, + 348, 292, 320, 381, 308, 135, 291, 135, 302, 314, + 104, 105, 194, 361, 106, 362, 389, 291, 367, 291, + 291, 243, 244, 77, 78, 79, 400, 12, 13, 8, + 291, 347, 120, 121, 122, 194, 276, 277, -98, 271, + 272, 273, 270, 335, 336, 337, 338, 103, 220, 274, + 275, 282, 283, 317, 331, 332, 220, 339, 340, 33, + 34, 35, 302, 36, 37, 38, 39, 40, 333, 334, + 117, 118, 194, 128, 131, 384, 133, 302, 134, 214, + 302, 219, 223, 225, 212, 230, 231, 234, 302, 232, + 235, 236, 239, 242, 257, 135, 302, 241, 373, 220, + 252, 284, 286, 287, 285, 194, 288, -35, 295, 309, + 114, 304, -30, 194, 306, 390, 349, 353, 194, 354, + 357, 363, 291, 364, 365, 368, -36, 369, 375, 371, + 110, 372, 385, 392, 374, 399, 328, 329, 330, 219, + 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, + 219, 219, 219, 219, 219, 379, 164, 387, 394, 396, + 402, 341, 343, 219, 346, 325, 342, 344, 209, 296, + 345, 219, 213, 112, 224, 356, 310, 297, 378, 391, + 116, 247, 113, 194, 358, 0, 0, 0, 0, 0, + 0, 0, 0, 311, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 219, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 194, 0, 0, 194, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 194, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 194, 0, 0, 0, 0, 0, 0, + 0, 194, 0, 194, 12, 13, 14, 15, 16, 17, + 139, 140, 141, 0, 142, 143, 144, 145, 146, 147, + 148, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 149, + 150, 151, 152, 153, 154, 155, 0, 0, 156, 157, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, + 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 81, 0, 82, 0, 0, 0, 0, + 158, 0, 0, 0, 0, 0, 159, 160, 161, 162, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 163, 164, 165, 12, 13, 14, 15, 16, 17, + 139, 140, 141, 0, 142, 143, 144, 145, 146, 147, + 148, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 149, + 150, 151, 152, 153, 154, 155, 0, 0, 156, 157, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, + 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 81, 0, 82, 0, 0, 0, 0, + 158, 0, 0, 0, 0, 0, 159, 160, 161, 162, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 163, 164, 246, 12, 13, 14, 15, 16, 17, + 139, 140, 141, 0, 142, 143, 144, 145, 146, 147, + 148, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 149, + 150, 151, 152, 153, 154, 155, 0, 0, 156, 157, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, + 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 81, 0, 82, 0, 0, 0, 0, + 158, 0, 0, 0, 0, 0, 159, 160, 161, 162, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 163, 164, 293, 12, 13, 14, 15, 16, 17, + 139, 140, 141, 0, 142, 143, 144, 145, 146, 147, + 148, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 149, + 150, 151, 152, 153, 154, 155, 0, 0, 156, 157, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, + 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 81, 0, 82, 0, 0, 0, 0, + 158, 0, 0, 0, 0, 0, 159, 160, 161, 162, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 163, 164, 321, 12, 13, 14, 15, 16, 17, + 139, 140, 141, 0, 142, 143, 144, 145, 146, 147, + 148, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 149, + 150, 151, 152, 153, 154, 155, 0, 0, 156, 157, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, + 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 81, 0, 82, 0, 0, 0, 0, + 158, 0, 0, 0, 0, 0, 159, 160, 161, 162, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 163, 164, 12, 13, 14, 15, 16, 17, 139, + 140, 141, 0, 142, 380, 144, 145, 146, 147, 148, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 0, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 149, 150, + 151, 152, 153, 154, 155, 0, 0, 156, 157, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 76, 77, 78, 79, + 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 81, 0, 82, 0, 0, 0, 0, 158, + 0, 0, 0, 0, 0, 159, 160, 161, 162, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 163, 115, 12, 13, 14, 15, 16, 17, 139, 140, + 141, 0, 142, 380, 144, 145, 146, 147, 148, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 0, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 149, 150, 151, + 152, 153, 154, 155, 0, 0, 156, 157, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 76, 77, 78, 79, 80, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 81, 0, 82, 0, 0, 0, 0, 158, 0, + 0, 0, 0, 0, 159, 160, 161, 162, 12, 13, + 14, 15, 16, 17, 0, 0, 0, 0, 0, 163, + 164, 0, 0, 0, 0, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 0, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 0, 150, 151, 152, 153, 154, 155, + 0, 0, 156, 157, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 76, 77, 78, 79, 80, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 81, 0, 82, + 0, 0, 0, 0, 158, 0, 0, 0, 0, 0, + 159, 160, 161, 162, 14, 15, 16, 17, 0, 0, + 0, 0, 0, 0, 0, 163, 0, 0, 0, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 0, 75, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 77, 78, 79, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, + 0, 81, 0, 82, 0, 0, 0, 0, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, + 0, 228, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 0, 75, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 77, 78, 79, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, + 81, 0, 82, 0, 0, 0, 0, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, + 305, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 0, 150, 151, 152, 153, + 154, 155, 0, 0, 156, 157, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 77, 78, 79, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, + 0, 82, 0, 0, 0, 0, 158, 0, 0, 0, + 0, 0, 159, 160, 161, 162, 12, 13, 14, 15, + 16, 17, 0, 0, 0, 0, 0, 237, 0, 0, + 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 0, 150, 151, 152, 153, 154, 155, 0, 0, + 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, + 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 81, 0, 82, 14, 15, + 16, 17, 158, 0, 0, 0, 0, 0, 159, 160, + 161, 162, 0, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 0, 150, 151, 152, 153, 154, 155, 0, 0, + 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 81, 0, 82, 14, 15, + 16, 17, 158, 0, 0, 218, 0, 0, 159, 160, + 161, 162, 0, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 0, 150, 151, 152, 153, 154, 155, 0, 0, + 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 81, 0, 82, 14, 15, + 16, 17, 158, 0, 0, 300, 0, 0, 159, 160, + 161, 162, 0, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 0, 150, 151, 152, 153, 154, 155, 0, 0, + 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 81, 0, 82, 14, 15, + 16, 17, 158, 0, 0, 350, 0, 0, 159, 160, + 161, 162, 0, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 0, 150, 151, 152, 153, 154, 155, 0, 0, + 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 81, 0, 82, 14, 15, + 16, 17, 158, 0, 0, 0, 0, 0, 159, 160, + 161, 162, 0, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 255, 0, 150, 151, 152, 153, 154, 155, 0, 0, + 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 81, 0, 82, 0, 0, + 0, 0, 158, 0, 0, 0, 0, 0, 159, 160, + 161, 162, 12, 13, 14, 15, 16, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 0, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 0, 75, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 76, 77, 78, 79, 80, + 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, + 0, 81, 0, 82, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 0, 324, + 0, 0, 0, 0, 155, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 77, 78, 79, + 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, + 0, 0, 81, 0, 82, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 0, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 77, 78, + 79, 0, 0, 0, 0, 0, 0, 14, 15, 16, + 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, + 0, 0, 0, 81, 0, 82, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 81, 0, 82 +}; + +static const yytype_int16 yycheck[] = +{ + 9, 131, 4, 174, 141, 216, 145, 79, 147, 299, + 89, 90, 79, 136, 9, 3, 4, 180, 181, 158, + 242, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 94, 161, 9, 36, 37, 38, 361, 361, 4, + 159, 76, 161, 87, 88, 99, 217, 35, 36, 37, + 179, 39, 40, 41, 42, 43, 164, 92, 112, 111, + 179, 160, 164, 353, 201, 164, 164, 0, 392, 392, + 178, 36, 37, 38, 83, 110, 178, 400, 368, 402, + 81, 371, 180, 254, 93, 116, 216, 298, 83, 379, + 312, 79, 159, 172, 173, 306, 235, 387, 269, 108, + 239, 224, 79, 242, 179, 164, 115, 83, 164, 181, + 247, 250, 364, 164, 177, 124, 131, 161, 106, 163, + 291, 180, 160, 375, 180, 134, 164, 136, 299, 180, + 36, 37, 141, 160, 40, 160, 160, 164, 349, 164, + 164, 156, 157, 107, 108, 109, 160, 3, 4, 112, + 164, 290, 36, 37, 38, 164, 85, 86, 160, 169, + 170, 171, 177, 278, 279, 280, 281, 115, 298, 165, + 166, 91, 92, 312, 274, 275, 306, 282, 283, 35, + 36, 37, 353, 39, 40, 41, 42, 43, 276, 277, + 160, 164, 201, 79, 161, 366, 79, 368, 181, 79, + 371, 216, 116, 79, 213, 180, 180, 159, 379, 180, + 159, 180, 159, 159, 159, 224, 387, 178, 357, 349, + 160, 174, 176, 93, 175, 234, 95, 159, 79, 78, + 180, 162, 160, 242, 161, 374, 161, 179, 247, 162, + 159, 79, 164, 160, 162, 179, 159, 162, 160, 179, + 106, 162, 162, 12, 180, 394, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 179, 181, 179, 159, 180, + 12, 284, 286, 298, 289, 251, 285, 287, 118, 213, + 288, 306, 125, 80, 134, 307, 234, 213, 362, 375, + 85, 164, 83, 312, 312, -1, -1, -1, -1, -1, + -1, -1, -1, 234, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 349, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 361, -1, -1, 364, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 375, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 392, -1, -1, -1, -1, -1, -1, + -1, 400, -1, 402, 3, 4, 5, 6, 7, 8, + 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, + 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 152, -1, 154, -1, -1, -1, -1, + 159, -1, -1, -1, -1, -1, 165, 166, 167, 168, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 180, 181, 182, 3, 4, 5, 6, 7, 8, + 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, + 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 152, -1, 154, -1, -1, -1, -1, + 159, -1, -1, -1, -1, -1, 165, 166, 167, 168, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 180, 181, 182, 3, 4, 5, 6, 7, 8, + 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, + 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 152, -1, 154, -1, -1, -1, -1, + 159, -1, -1, -1, -1, -1, 165, 166, 167, 168, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 180, 181, 182, 3, 4, 5, 6, 7, 8, + 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, + 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 152, -1, 154, -1, -1, -1, -1, + 159, -1, -1, -1, -1, -1, 165, 166, 167, 168, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 180, 181, 182, 3, 4, 5, 6, 7, 8, + 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, + 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 152, -1, 154, -1, -1, -1, -1, + 159, -1, -1, -1, -1, -1, 165, 166, 167, 168, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 180, 181, 3, 4, 5, 6, 7, 8, 9, + 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, -1, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 106, 107, 108, 109, + 110, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 152, -1, 154, -1, -1, -1, -1, 159, + -1, -1, -1, -1, -1, 165, 166, 167, 168, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 180, 181, 3, 4, 5, 6, 7, 8, 9, 10, + 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, -1, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 106, 107, 108, 109, 110, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 152, -1, 154, -1, -1, -1, -1, 159, -1, + -1, -1, -1, -1, 165, 166, 167, 168, 3, 4, + 5, 6, 7, 8, -1, -1, -1, -1, -1, 180, + 181, -1, -1, -1, -1, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, -1, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, + -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 106, 107, 108, 109, 110, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 152, -1, 154, + -1, -1, -1, -1, 159, -1, -1, -1, -1, -1, + 165, 166, 167, 168, 5, 6, 7, 8, -1, -1, + -1, -1, -1, -1, -1, 180, -1, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, -1, 79, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 107, 108, 109, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 5, 6, 7, 8, -1, -1, -1, + -1, 152, -1, 154, -1, -1, -1, -1, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, -1, -1, -1, -1, -1, -1, + -1, 182, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, -1, 79, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, + 152, -1, 154, -1, -1, -1, -1, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, + 182, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 152, + -1, 154, -1, -1, -1, -1, 159, -1, -1, -1, + -1, -1, 165, 166, 167, 168, 3, 4, 5, 6, + 7, 8, -1, -1, -1, -1, -1, 180, -1, -1, + -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, -1, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, + 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, + 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 152, -1, 154, 5, 6, + 7, 8, 159, -1, -1, -1, -1, -1, 165, 166, + 167, 168, -1, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, + 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 152, -1, 154, 5, 6, + 7, 8, 159, -1, -1, 162, -1, -1, 165, 166, + 167, 168, -1, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, + 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 152, -1, 154, 5, 6, + 7, 8, 159, -1, -1, 162, -1, -1, 165, 166, + 167, 168, -1, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, + 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 152, -1, 154, 5, 6, + 7, 8, 159, -1, -1, 162, -1, -1, 165, 166, + 167, 168, -1, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, + 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 152, -1, 154, 5, 6, + 7, 8, 159, -1, -1, -1, -1, -1, 165, 166, + 167, 168, -1, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, + 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 152, -1, 154, -1, -1, + -1, -1, 159, -1, -1, -1, -1, -1, 165, 166, + 167, 168, 3, 4, 5, 6, 7, 8, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, -1, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, -1, 79, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 106, 107, 108, 109, 110, + -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, -1, -1, -1, -1, -1, + -1, 152, -1, 154, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, + -1, -1, -1, -1, 84, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 107, 108, 109, + -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, -1, -1, -1, -1, + -1, -1, 152, -1, 154, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, + 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 107, 108, + 109, -1, -1, -1, -1, -1, -1, 5, 6, 7, + 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, -1, -1, -1, + -1, -1, -1, 152, -1, 154, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 152, -1, 154 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint16 yystos[] = +{ + 0, 111, 184, 186, 81, 0, 187, 116, 112, 185, + 188, 79, 3, 4, 5, 6, 7, 8, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 79, 106, 107, 108, 109, + 110, 152, 154, 189, 219, 220, 221, 222, 223, 228, + 229, 230, 231, 233, 234, 235, 236, 237, 238, 239, + 240, 266, 267, 115, 36, 37, 40, 79, 181, 79, + 106, 233, 239, 266, 180, 181, 253, 160, 164, 4, + 36, 37, 38, 225, 226, 232, 164, 180, 79, 233, + 235, 161, 236, 79, 181, 235, 241, 242, 236, 9, + 10, 11, 13, 14, 15, 16, 17, 18, 19, 78, + 79, 80, 81, 82, 83, 84, 87, 88, 159, 165, + 166, 167, 168, 180, 181, 182, 190, 191, 192, 194, + 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, + 215, 217, 219, 220, 235, 246, 247, 248, 249, 250, + 251, 254, 255, 256, 257, 259, 260, 261, 265, 225, + 224, 227, 235, 226, 79, 159, 161, 179, 162, 201, + 214, 218, 235, 116, 241, 79, 243, 244, 182, 242, + 180, 180, 180, 247, 159, 159, 180, 180, 217, 159, + 217, 178, 159, 201, 201, 217, 182, 254, 87, 88, + 161, 163, 160, 160, 164, 77, 215, 159, 96, 97, + 98, 99, 100, 101, 102, 103, 104, 105, 179, 216, + 201, 169, 170, 171, 165, 166, 85, 86, 89, 90, + 172, 173, 91, 92, 174, 175, 176, 93, 95, 94, + 177, 164, 180, 182, 247, 79, 224, 227, 161, 179, + 162, 218, 215, 245, 162, 182, 161, 164, 180, 78, + 246, 255, 262, 217, 180, 217, 178, 217, 230, 258, + 160, 182, 193, 217, 79, 196, 215, 215, 201, 201, + 201, 203, 203, 204, 204, 205, 205, 205, 205, 206, + 206, 207, 208, 209, 210, 211, 212, 217, 215, 161, + 162, 218, 245, 179, 162, 218, 244, 159, 258, 263, + 264, 160, 160, 79, 160, 162, 178, 218, 179, 162, + 245, 179, 162, 217, 180, 160, 248, 249, 251, 179, + 14, 250, 252, 253, 215, 162, 245, 179, 245, 160, + 217, 252, 12, 245, 159, 245, 180, 248, 249, 217, + 160, 248, 12 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (&yylloc, state, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, &yylloc, scanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, Location, state); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct _mesa_glsl_parse_state *state) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, state) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; + struct _mesa_glsl_parse_state *state; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yylocationp); + YYUSE (state); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct _mesa_glsl_parse_state *state) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, state) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; + struct _mesa_glsl_parse_state *state; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, state); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, struct _mesa_glsl_parse_state *state) +#else +static void +yy_reduce_print (yyvsp, yylsp, yyrule, state) + YYSTYPE *yyvsp; + YYLTYPE *yylsp; + int yyrule; + struct _mesa_glsl_parse_state *state; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , &(yylsp[(yyi + 1) - (yynrhs)]) , state); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, yylsp, Rule, state); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, struct _mesa_glsl_parse_state *state) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yylocationp, state) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + YYLTYPE *yylocationp; + struct _mesa_glsl_parse_state *state; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yylocationp); + YYUSE (state); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (struct _mesa_glsl_parse_state *state); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (struct _mesa_glsl_parse_state *state) +#else +int +yyparse (state) + struct _mesa_glsl_parse_state *state; +#endif +#endif +{ +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Location data for the lookahead symbol. */ +YYLTYPE yylloc; + + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls; + YYLTYPE *yylsp; + + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yyls = yylsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; + yylsp = yyls; + +#if YYLTYPE_IS_TRIVIAL + /* Initialize the default location before parsing starts. */ + yylloc.first_line = yylloc.last_line = 1; + yylloc.first_column = yylloc.last_column = 1; +#endif + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + YYLTYPE *yyls1 = yyls; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), + &yystacksize); + + yyls = yyls1; + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyls_alloc, yyls); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + yylsp = yyls + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + *++yylsp = yylloc; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: + +/* Line 1455 of yacc.c */ +#line 190 "glsl_parser.ypp" + { + _mesa_glsl_initialize_types(state); + ;} + break; + + case 4: + +/* Line 1455 of yacc.c */ +#line 198 "glsl_parser.ypp" + { + state->language_version = 110; + ;} + break; + + case 5: + +/* Line 1455 of yacc.c */ +#line 202 "glsl_parser.ypp" + { + switch ((yyvsp[(2) - (3)].n)) { + case 110: + case 120: + case 130: + /* FINISHME: Check against implementation support versions. */ + state->language_version = (yyvsp[(2) - (3)].n); + break; + default: + _mesa_glsl_error(& (yylsp[(2) - (3)]), state, "Shading language version" + "%u is not supported\n", (yyvsp[(2) - (3)].n)); + break; + } + ;} + break; + + case 8: + +/* Line 1455 of yacc.c */ +#line 225 "glsl_parser.ypp" + { + if (!_mesa_glsl_process_extension((yyvsp[(2) - (5)].identifier), & (yylsp[(2) - (5)]), (yyvsp[(4) - (5)].identifier), & (yylsp[(4) - (5)]), state)) { + YYERROR; + } + ;} + break; + + case 9: + +/* Line 1455 of yacc.c */ +#line 234 "glsl_parser.ypp" + { + /* FINISHME: The NULL test is only required because 'precision' + * FINISHME: statements are not yet supported. + */ + if ((yyvsp[(1) - (1)].node) != NULL) + state->translation_unit.push_tail(& (yyvsp[(1) - (1)].node)->link); + ;} + break; + + case 10: + +/* Line 1455 of yacc.c */ +#line 242 "glsl_parser.ypp" + { + /* FINISHME: The NULL test is only required because 'precision' + * FINISHME: statements are not yet supported. + */ + if ((yyvsp[(2) - (2)].node) != NULL) + state->translation_unit.push_tail(& (yyvsp[(2) - (2)].node)->link); + ;} + break; + + case 12: + +/* Line 1455 of yacc.c */ +#line 257 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.identifier = (yyvsp[(1) - (1)].identifier); + ;} + break; + + case 13: + +/* Line 1455 of yacc.c */ +#line 264 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.int_constant = (yyvsp[(1) - (1)].n); + ;} + break; + + case 14: + +/* Line 1455 of yacc.c */ +#line 271 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.uint_constant = (yyvsp[(1) - (1)].n); + ;} + break; + + case 15: + +/* Line 1455 of yacc.c */ +#line 278 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.float_constant = (yyvsp[(1) - (1)].real); + ;} + break; + + case 16: + +/* Line 1455 of yacc.c */ +#line 285 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.bool_constant = (yyvsp[(1) - (1)].n); + ;} + break; + + case 17: + +/* Line 1455 of yacc.c */ +#line 292 "glsl_parser.ypp" + { + (yyval.expression) = (yyvsp[(2) - (3)].expression); + ;} + break; + + case 19: + +/* Line 1455 of yacc.c */ +#line 300 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_array_index, (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression), NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 20: + +/* Line 1455 of yacc.c */ +#line 306 "glsl_parser.ypp" + { + (yyval.expression) = (yyvsp[(1) - (1)].expression); + ;} + break; + + case 21: + +/* Line 1455 of yacc.c */ +#line 310 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.identifier = (yyvsp[(3) - (3)].identifier); + ;} + break; + + case 22: + +/* Line 1455 of yacc.c */ +#line 317 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_post_inc, (yyvsp[(1) - (2)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 23: + +/* Line 1455 of yacc.c */ +#line 323 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_post_dec, (yyvsp[(1) - (2)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 27: + +/* Line 1455 of yacc.c */ +#line 341 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 32: + +/* Line 1455 of yacc.c */ +#line 360 "glsl_parser.ypp" + { + (yyval.expression) = (yyvsp[(1) - (2)].expression); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->expressions.push_tail(& (yyvsp[(2) - (2)].expression)->link); + ;} + break; + + case 33: + +/* Line 1455 of yacc.c */ +#line 366 "glsl_parser.ypp" + { + (yyval.expression) = (yyvsp[(1) - (3)].expression); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->expressions.push_tail(& (yyvsp[(3) - (3)].expression)->link); + ;} + break; + + case 35: + +/* Line 1455 of yacc.c */ +#line 382 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_function_expression((yyvsp[(1) - (1)].type_specifier)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 36: + +/* Line 1455 of yacc.c */ +#line 388 "glsl_parser.ypp" + { + void *ctx = state; + ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); + (yyval.expression) = new(ctx) ast_function_expression(callee); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 37: + +/* Line 1455 of yacc.c */ +#line 395 "glsl_parser.ypp" + { + void *ctx = state; + ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); + (yyval.expression) = new(ctx) ast_function_expression(callee); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 39: + +/* Line 1455 of yacc.c */ +#line 407 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_pre_inc, (yyvsp[(2) - (2)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 40: + +/* Line 1455 of yacc.c */ +#line 413 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_pre_dec, (yyvsp[(2) - (2)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 41: + +/* Line 1455 of yacc.c */ +#line 419 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression((yyvsp[(1) - (2)].n), (yyvsp[(2) - (2)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 42: + +/* Line 1455 of yacc.c */ +#line 428 "glsl_parser.ypp" + { (yyval.n) = ast_plus; ;} + break; + + case 43: + +/* Line 1455 of yacc.c */ +#line 429 "glsl_parser.ypp" + { (yyval.n) = ast_neg; ;} + break; + + case 44: + +/* Line 1455 of yacc.c */ +#line 430 "glsl_parser.ypp" + { (yyval.n) = ast_logic_not; ;} + break; + + case 45: + +/* Line 1455 of yacc.c */ +#line 431 "glsl_parser.ypp" + { (yyval.n) = ast_bit_not; ;} + break; + + case 47: + +/* Line 1455 of yacc.c */ +#line 437 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_mul, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 48: + +/* Line 1455 of yacc.c */ +#line 443 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_div, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 49: + +/* Line 1455 of yacc.c */ +#line 449 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_mod, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 51: + +/* Line 1455 of yacc.c */ +#line 459 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_add, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 52: + +/* Line 1455 of yacc.c */ +#line 465 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_sub, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 54: + +/* Line 1455 of yacc.c */ +#line 475 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_lshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 55: + +/* Line 1455 of yacc.c */ +#line 481 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_rshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 57: + +/* Line 1455 of yacc.c */ +#line 491 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_less, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 58: + +/* Line 1455 of yacc.c */ +#line 497 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_greater, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 59: + +/* Line 1455 of yacc.c */ +#line 503 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_lequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 60: + +/* Line 1455 of yacc.c */ +#line 509 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_gequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 62: + +/* Line 1455 of yacc.c */ +#line 519 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_equal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 63: + +/* Line 1455 of yacc.c */ +#line 525 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_nequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 65: + +/* Line 1455 of yacc.c */ +#line 535 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 67: + +/* Line 1455 of yacc.c */ +#line 545 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 69: + +/* Line 1455 of yacc.c */ +#line 555 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 71: + +/* Line 1455 of yacc.c */ +#line 565 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 73: + +/* Line 1455 of yacc.c */ +#line 575 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 75: + +/* Line 1455 of yacc.c */ +#line 585 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 77: + +/* Line 1455 of yacc.c */ +#line 595 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_conditional, (yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 79: + +/* Line 1455 of yacc.c */ +#line 605 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression((yyvsp[(2) - (3)].n), (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 80: + +/* Line 1455 of yacc.c */ +#line 613 "glsl_parser.ypp" + { (yyval.n) = ast_assign; ;} + break; + + case 81: + +/* Line 1455 of yacc.c */ +#line 614 "glsl_parser.ypp" + { (yyval.n) = ast_mul_assign; ;} + break; + + case 82: + +/* Line 1455 of yacc.c */ +#line 615 "glsl_parser.ypp" + { (yyval.n) = ast_div_assign; ;} + break; + + case 83: + +/* Line 1455 of yacc.c */ +#line 616 "glsl_parser.ypp" + { (yyval.n) = ast_mod_assign; ;} + break; + + case 84: + +/* Line 1455 of yacc.c */ +#line 617 "glsl_parser.ypp" + { (yyval.n) = ast_add_assign; ;} + break; + + case 85: + +/* Line 1455 of yacc.c */ +#line 618 "glsl_parser.ypp" + { (yyval.n) = ast_sub_assign; ;} + break; + + case 86: + +/* Line 1455 of yacc.c */ +#line 619 "glsl_parser.ypp" + { (yyval.n) = ast_ls_assign; ;} + break; + + case 87: + +/* Line 1455 of yacc.c */ +#line 620 "glsl_parser.ypp" + { (yyval.n) = ast_rs_assign; ;} + break; + + case 88: + +/* Line 1455 of yacc.c */ +#line 621 "glsl_parser.ypp" + { (yyval.n) = ast_and_assign; ;} + break; + + case 89: + +/* Line 1455 of yacc.c */ +#line 622 "glsl_parser.ypp" + { (yyval.n) = ast_xor_assign; ;} + break; + + case 90: + +/* Line 1455 of yacc.c */ +#line 623 "glsl_parser.ypp" + { (yyval.n) = ast_or_assign; ;} + break; + + case 91: + +/* Line 1455 of yacc.c */ +#line 628 "glsl_parser.ypp" + { + (yyval.expression) = (yyvsp[(1) - (1)].expression); + ;} + break; + + case 92: + +/* Line 1455 of yacc.c */ +#line 632 "glsl_parser.ypp" + { + void *ctx = state; + if ((yyvsp[(1) - (3)].expression)->oper != ast_sequence) { + (yyval.expression) = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->expressions.push_tail(& (yyvsp[(1) - (3)].expression)->link); + } else { + (yyval.expression) = (yyvsp[(1) - (3)].expression); + } + + (yyval.expression)->expressions.push_tail(& (yyvsp[(3) - (3)].expression)->link); + ;} + break; + + case 94: + +/* Line 1455 of yacc.c */ +#line 652 "glsl_parser.ypp" + { + (yyval.node) = (yyvsp[(1) - (2)].function); + ;} + break; + + case 95: + +/* Line 1455 of yacc.c */ +#line 656 "glsl_parser.ypp" + { + (yyval.node) = (yyvsp[(1) - (2)].declarator_list); + ;} + break; + + case 96: + +/* Line 1455 of yacc.c */ +#line 660 "glsl_parser.ypp" + { + if (((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_float) + && ((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_int)) { + _mesa_glsl_error(& (yylsp[(3) - (4)]), state, "global precision qualifier can " + "only be applied to `int' or `float'\n"); + YYERROR; + } + + (yyval.node) = NULL; /* FINISHME */ + ;} + break; + + case 100: + +/* Line 1455 of yacc.c */ +#line 683 "glsl_parser.ypp" + { + (yyval.function) = (yyvsp[(1) - (2)].function); + (yyval.function)->parameters.push_tail(& (yyvsp[(2) - (2)].parameter_declarator)->link); + ;} + break; + + case 101: + +/* Line 1455 of yacc.c */ +#line 688 "glsl_parser.ypp" + { + (yyval.function) = (yyvsp[(1) - (3)].function); + (yyval.function)->parameters.push_tail(& (yyvsp[(3) - (3)].parameter_declarator)->link); + ;} + break; + + case 102: + +/* Line 1455 of yacc.c */ +#line 696 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.function) = new(ctx) ast_function(); + (yyval.function)->set_location(yylloc); + (yyval.function)->return_type = (yyvsp[(1) - (3)].fully_specified_type); + (yyval.function)->identifier = (yyvsp[(2) - (3)].identifier); + ;} + break; + + case 103: + +/* Line 1455 of yacc.c */ +#line 707 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); + (yyval.parameter_declarator)->set_location(yylloc); + (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); + (yyval.parameter_declarator)->type->set_location(yylloc); + (yyval.parameter_declarator)->type->specifier = (yyvsp[(1) - (2)].type_specifier); + (yyval.parameter_declarator)->identifier = (yyvsp[(2) - (2)].identifier); + ;} + break; + + case 104: + +/* Line 1455 of yacc.c */ +#line 717 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); + (yyval.parameter_declarator)->set_location(yylloc); + (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); + (yyval.parameter_declarator)->type->set_location(yylloc); + (yyval.parameter_declarator)->type->specifier = (yyvsp[(1) - (5)].type_specifier); + (yyval.parameter_declarator)->identifier = (yyvsp[(2) - (5)].identifier); + (yyval.parameter_declarator)->is_array = true; + (yyval.parameter_declarator)->array_size = (yyvsp[(4) - (5)].expression); + ;} + break; + + case 105: + +/* Line 1455 of yacc.c */ +#line 732 "glsl_parser.ypp" + { + (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; + + (yyval.parameter_declarator) = (yyvsp[(3) - (3)].parameter_declarator); + (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (3)].type_qualifier).q; + ;} + break; + + case 106: + +/* Line 1455 of yacc.c */ +#line 739 "glsl_parser.ypp" + { + (yyval.parameter_declarator) = (yyvsp[(2) - (2)].parameter_declarator); + (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier).q; + ;} + break; + + case 107: + +/* Line 1455 of yacc.c */ +#line 744 "glsl_parser.ypp" + { + void *ctx = state; + (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; + + (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); + (yyval.parameter_declarator)->set_location(yylloc); + (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); + (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (3)].type_qualifier).q; + (yyval.parameter_declarator)->type->specifier = (yyvsp[(3) - (3)].type_specifier); + ;} + break; + + case 108: + +/* Line 1455 of yacc.c */ +#line 755 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); + (yyval.parameter_declarator)->set_location(yylloc); + (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); + (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier).q; + (yyval.parameter_declarator)->type->specifier = (yyvsp[(2) - (2)].type_specifier); + ;} + break; + + case 109: + +/* Line 1455 of yacc.c */ +#line 766 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; ;} + break; + + case 110: + +/* Line 1455 of yacc.c */ +#line 767 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} + break; + + case 111: + +/* Line 1455 of yacc.c */ +#line 768 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} + break; + + case 112: + +/* Line 1455 of yacc.c */ +#line 769 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; (yyval.type_qualifier).q.out = 1; ;} + break; + + case 115: + +/* Line 1455 of yacc.c */ +#line 779 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (3)].identifier), false, NULL, NULL); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (3)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 116: + +/* Line 1455 of yacc.c */ +#line 788 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), true, NULL, NULL); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (5)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 117: + +/* Line 1455 of yacc.c */ +#line 797 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (6)].identifier), true, (yyvsp[(5) - (6)].expression), NULL); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (6)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 118: + +/* Line 1455 of yacc.c */ +#line 806 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (7)].identifier), true, NULL, (yyvsp[(7) - (7)].expression)); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (7)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 119: + +/* Line 1455 of yacc.c */ +#line 815 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (8)].identifier), true, (yyvsp[(5) - (8)].expression), (yyvsp[(8) - (8)].expression)); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (8)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 120: + +/* Line 1455 of yacc.c */ +#line 824 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), false, NULL, (yyvsp[(5) - (5)].expression)); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (5)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 121: + +/* Line 1455 of yacc.c */ +#line 837 "glsl_parser.ypp" + { + void *ctx = state; + if ((yyvsp[(1) - (1)].fully_specified_type)->specifier->type_specifier != ast_struct) { + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, "empty declaration list\n"); + YYERROR; + } else { + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (1)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + } + ;} + break; + + case 122: + +/* Line 1455 of yacc.c */ +#line 848 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (2)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 123: + +/* Line 1455 of yacc.c */ +#line 857 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), true, NULL, NULL); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 124: + +/* Line 1455 of yacc.c */ +#line 866 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (5)].identifier), true, (yyvsp[(4) - (5)].expression), NULL); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (5)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 125: + +/* Line 1455 of yacc.c */ +#line 875 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (6)].identifier), true, NULL, (yyvsp[(6) - (6)].expression)); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (6)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 126: + +/* Line 1455 of yacc.c */ +#line 884 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (7)].identifier), true, (yyvsp[(4) - (7)].expression), (yyvsp[(7) - (7)].expression)); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (7)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 127: + +/* Line 1455 of yacc.c */ +#line 893 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 128: + +/* Line 1455 of yacc.c */ +#line 902 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); + + (yyval.declarator_list) = new(ctx) ast_declarator_list(NULL); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->invariant = true; + + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 129: + +/* Line 1455 of yacc.c */ +#line 916 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); + (yyval.fully_specified_type)->set_location(yylloc); + (yyval.fully_specified_type)->specifier = (yyvsp[(1) - (1)].type_specifier); + ;} + break; + + case 130: + +/* Line 1455 of yacc.c */ +#line 923 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); + (yyval.fully_specified_type)->set_location(yylloc); + (yyval.fully_specified_type)->qualifier = (yyvsp[(1) - (2)].type_qualifier).q; + (yyval.fully_specified_type)->specifier = (yyvsp[(2) - (2)].type_specifier); + ;} + break; + + case 131: + +/* Line 1455 of yacc.c */ +#line 933 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.smooth = 1; ;} + break; + + case 132: + +/* Line 1455 of yacc.c */ +#line 934 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.flat = 1; ;} + break; + + case 133: + +/* Line 1455 of yacc.c */ +#line 935 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.noperspective = 1; ;} + break; + + case 134: + +/* Line 1455 of yacc.c */ +#line 939 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} + break; + + case 136: + +/* Line 1455 of yacc.c */ +#line 945 "glsl_parser.ypp" + { + (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i | (yyvsp[(2) - (2)].type_qualifier).i; + ;} + break; + + case 137: + +/* Line 1455 of yacc.c */ +#line 949 "glsl_parser.ypp" + { + (yyval.type_qualifier) = (yyvsp[(2) - (2)].type_qualifier); + (yyval.type_qualifier).q.invariant = 1; + ;} + break; + + case 138: + +/* Line 1455 of yacc.c */ +#line 956 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} + break; + + case 139: + +/* Line 1455 of yacc.c */ +#line 957 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.attribute = 1; ;} + break; + + case 140: + +/* Line 1455 of yacc.c */ +#line 958 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.varying = 1; ;} + break; + + case 141: + +/* Line 1455 of yacc.c */ +#line 959 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.varying = 1; ;} + break; + + case 142: + +/* Line 1455 of yacc.c */ +#line 960 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} + break; + + case 143: + +/* Line 1455 of yacc.c */ +#line 961 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} + break; + + case 144: + +/* Line 1455 of yacc.c */ +#line 962 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.in = 1; ;} + break; + + case 145: + +/* Line 1455 of yacc.c */ +#line 963 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.out = 1; ;} + break; + + case 146: + +/* Line 1455 of yacc.c */ +#line 964 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.uniform = 1; ;} + break; + + case 148: + +/* Line 1455 of yacc.c */ +#line 970 "glsl_parser.ypp" + { + (yyval.type_specifier) = (yyvsp[(2) - (2)].type_specifier); + (yyval.type_specifier)->precision = (yyvsp[(1) - (2)].n); + ;} + break; + + case 150: + +/* Line 1455 of yacc.c */ +#line 979 "glsl_parser.ypp" + { + (yyval.type_specifier) = (yyvsp[(1) - (3)].type_specifier); + (yyval.type_specifier)->is_array = true; + (yyval.type_specifier)->array_size = NULL; + ;} + break; + + case 151: + +/* Line 1455 of yacc.c */ +#line 985 "glsl_parser.ypp" + { + (yyval.type_specifier) = (yyvsp[(1) - (4)].type_specifier); + (yyval.type_specifier)->is_array = true; + (yyval.type_specifier)->array_size = (yyvsp[(3) - (4)].expression); + ;} + break; + + case 152: + +/* Line 1455 of yacc.c */ +#line 994 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].n)); + (yyval.type_specifier)->set_location(yylloc); + ;} + break; + + case 153: + +/* Line 1455 of yacc.c */ +#line 1000 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].struct_specifier)); + (yyval.type_specifier)->set_location(yylloc); + ;} + break; + + case 154: + +/* Line 1455 of yacc.c */ +#line 1006 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].identifier)); + (yyval.type_specifier)->set_location(yylloc); + ;} + break; + + case 155: + +/* Line 1455 of yacc.c */ +#line 1014 "glsl_parser.ypp" + { (yyval.n) = ast_void; ;} + break; + + case 156: + +/* Line 1455 of yacc.c */ +#line 1015 "glsl_parser.ypp" + { (yyval.n) = ast_float; ;} + break; + + case 157: + +/* Line 1455 of yacc.c */ +#line 1016 "glsl_parser.ypp" + { (yyval.n) = ast_int; ;} + break; + + case 158: + +/* Line 1455 of yacc.c */ +#line 1017 "glsl_parser.ypp" + { (yyval.n) = ast_uint; ;} + break; + + case 159: + +/* Line 1455 of yacc.c */ +#line 1018 "glsl_parser.ypp" + { (yyval.n) = ast_bool; ;} + break; + + case 160: + +/* Line 1455 of yacc.c */ +#line 1019 "glsl_parser.ypp" + { (yyval.n) = ast_vec2; ;} + break; + + case 161: + +/* Line 1455 of yacc.c */ +#line 1020 "glsl_parser.ypp" + { (yyval.n) = ast_vec3; ;} + break; + + case 162: + +/* Line 1455 of yacc.c */ +#line 1021 "glsl_parser.ypp" + { (yyval.n) = ast_vec4; ;} + break; + + case 163: + +/* Line 1455 of yacc.c */ +#line 1022 "glsl_parser.ypp" + { (yyval.n) = ast_bvec2; ;} + break; + + case 164: + +/* Line 1455 of yacc.c */ +#line 1023 "glsl_parser.ypp" + { (yyval.n) = ast_bvec3; ;} + break; + + case 165: + +/* Line 1455 of yacc.c */ +#line 1024 "glsl_parser.ypp" + { (yyval.n) = ast_bvec4; ;} + break; + + case 166: + +/* Line 1455 of yacc.c */ +#line 1025 "glsl_parser.ypp" + { (yyval.n) = ast_ivec2; ;} + break; + + case 167: + +/* Line 1455 of yacc.c */ +#line 1026 "glsl_parser.ypp" + { (yyval.n) = ast_ivec3; ;} + break; + + case 168: + +/* Line 1455 of yacc.c */ +#line 1027 "glsl_parser.ypp" + { (yyval.n) = ast_ivec4; ;} + break; + + case 169: + +/* Line 1455 of yacc.c */ +#line 1028 "glsl_parser.ypp" + { (yyval.n) = ast_uvec2; ;} + break; + + case 170: + +/* Line 1455 of yacc.c */ +#line 1029 "glsl_parser.ypp" + { (yyval.n) = ast_uvec3; ;} + break; + + case 171: + +/* Line 1455 of yacc.c */ +#line 1030 "glsl_parser.ypp" + { (yyval.n) = ast_uvec4; ;} + break; + + case 172: + +/* Line 1455 of yacc.c */ +#line 1031 "glsl_parser.ypp" + { (yyval.n) = ast_mat2; ;} + break; + + case 173: + +/* Line 1455 of yacc.c */ +#line 1032 "glsl_parser.ypp" + { (yyval.n) = ast_mat3; ;} + break; + + case 174: + +/* Line 1455 of yacc.c */ +#line 1033 "glsl_parser.ypp" + { (yyval.n) = ast_mat4; ;} + break; + + case 175: + +/* Line 1455 of yacc.c */ +#line 1034 "glsl_parser.ypp" + { (yyval.n) = ast_mat2; ;} + break; + + case 176: + +/* Line 1455 of yacc.c */ +#line 1035 "glsl_parser.ypp" + { (yyval.n) = ast_mat2x3; ;} + break; + + case 177: + +/* Line 1455 of yacc.c */ +#line 1036 "glsl_parser.ypp" + { (yyval.n) = ast_mat2x4; ;} + break; + + case 178: + +/* Line 1455 of yacc.c */ +#line 1037 "glsl_parser.ypp" + { (yyval.n) = ast_mat3x2; ;} + break; + + case 179: + +/* Line 1455 of yacc.c */ +#line 1038 "glsl_parser.ypp" + { (yyval.n) = ast_mat3; ;} + break; + + case 180: + +/* Line 1455 of yacc.c */ +#line 1039 "glsl_parser.ypp" + { (yyval.n) = ast_mat3x4; ;} + break; + + case 181: + +/* Line 1455 of yacc.c */ +#line 1040 "glsl_parser.ypp" + { (yyval.n) = ast_mat4x2; ;} + break; + + case 182: + +/* Line 1455 of yacc.c */ +#line 1041 "glsl_parser.ypp" + { (yyval.n) = ast_mat4x3; ;} + break; + + case 183: + +/* Line 1455 of yacc.c */ +#line 1042 "glsl_parser.ypp" + { (yyval.n) = ast_mat4; ;} + break; + + case 184: + +/* Line 1455 of yacc.c */ +#line 1043 "glsl_parser.ypp" + { (yyval.n) = ast_sampler1d; ;} + break; + + case 185: + +/* Line 1455 of yacc.c */ +#line 1044 "glsl_parser.ypp" + { (yyval.n) = ast_sampler2d; ;} + break; + + case 186: + +/* Line 1455 of yacc.c */ +#line 1045 "glsl_parser.ypp" + { (yyval.n) = ast_sampler2drect; ;} + break; + + case 187: + +/* Line 1455 of yacc.c */ +#line 1046 "glsl_parser.ypp" + { (yyval.n) = ast_sampler3d; ;} + break; + + case 188: + +/* Line 1455 of yacc.c */ +#line 1047 "glsl_parser.ypp" + { (yyval.n) = ast_samplercube; ;} + break; + + case 189: + +/* Line 1455 of yacc.c */ +#line 1048 "glsl_parser.ypp" + { (yyval.n) = ast_sampler1dshadow; ;} + break; + + case 190: + +/* Line 1455 of yacc.c */ +#line 1049 "glsl_parser.ypp" + { (yyval.n) = ast_sampler2dshadow; ;} + break; + + case 191: + +/* Line 1455 of yacc.c */ +#line 1050 "glsl_parser.ypp" + { (yyval.n) = ast_sampler2drectshadow; ;} + break; + + case 192: + +/* Line 1455 of yacc.c */ +#line 1051 "glsl_parser.ypp" + { (yyval.n) = ast_samplercubeshadow; ;} + break; + + case 193: + +/* Line 1455 of yacc.c */ +#line 1052 "glsl_parser.ypp" + { (yyval.n) = ast_sampler1darray; ;} + break; + + case 194: + +/* Line 1455 of yacc.c */ +#line 1053 "glsl_parser.ypp" + { (yyval.n) = ast_sampler2darray; ;} + break; + + case 195: + +/* Line 1455 of yacc.c */ +#line 1054 "glsl_parser.ypp" + { (yyval.n) = ast_sampler1darrayshadow; ;} + break; + + case 196: + +/* Line 1455 of yacc.c */ +#line 1055 "glsl_parser.ypp" + { (yyval.n) = ast_sampler2darrayshadow; ;} + break; + + case 197: + +/* Line 1455 of yacc.c */ +#line 1056 "glsl_parser.ypp" + { (yyval.n) = ast_isampler1d; ;} + break; + + case 198: + +/* Line 1455 of yacc.c */ +#line 1057 "glsl_parser.ypp" + { (yyval.n) = ast_isampler2d; ;} + break; + + case 199: + +/* Line 1455 of yacc.c */ +#line 1058 "glsl_parser.ypp" + { (yyval.n) = ast_isampler3d; ;} + break; + + case 200: + +/* Line 1455 of yacc.c */ +#line 1059 "glsl_parser.ypp" + { (yyval.n) = ast_isamplercube; ;} + break; + + case 201: + +/* Line 1455 of yacc.c */ +#line 1060 "glsl_parser.ypp" + { (yyval.n) = ast_isampler1darray; ;} + break; + + case 202: + +/* Line 1455 of yacc.c */ +#line 1061 "glsl_parser.ypp" + { (yyval.n) = ast_isampler2darray; ;} + break; + + case 203: + +/* Line 1455 of yacc.c */ +#line 1062 "glsl_parser.ypp" + { (yyval.n) = ast_usampler1d; ;} + break; + + case 204: + +/* Line 1455 of yacc.c */ +#line 1063 "glsl_parser.ypp" + { (yyval.n) = ast_usampler2d; ;} + break; + + case 205: + +/* Line 1455 of yacc.c */ +#line 1064 "glsl_parser.ypp" + { (yyval.n) = ast_usampler3d; ;} + break; + + case 206: + +/* Line 1455 of yacc.c */ +#line 1065 "glsl_parser.ypp" + { (yyval.n) = ast_usamplercube; ;} + break; + + case 207: + +/* Line 1455 of yacc.c */ +#line 1066 "glsl_parser.ypp" + { (yyval.n) = ast_usampler1darray; ;} + break; + + case 208: + +/* Line 1455 of yacc.c */ +#line 1067 "glsl_parser.ypp" + { (yyval.n) = ast_usampler2darray; ;} + break; + + case 209: + +/* Line 1455 of yacc.c */ +#line 1071 "glsl_parser.ypp" + { + if (state->language_version < 130) + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, + "precission qualifier forbidden " + "in GLSL %d.%d (1.30 or later " + "required)\n", + state->language_version / 100, + state->language_version % 100); + + (yyval.n) = ast_precision_high; + ;} + break; + + case 210: + +/* Line 1455 of yacc.c */ +#line 1082 "glsl_parser.ypp" + { + if (state->language_version < 130) + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, + "precission qualifier forbidden " + "in GLSL %d.%d (1.30 or later " + "required)\n", + state->language_version / 100, + state->language_version % 100); + + (yyval.n) = ast_precision_medium; + ;} + break; + + case 211: + +/* Line 1455 of yacc.c */ +#line 1093 "glsl_parser.ypp" + { + if (state->language_version < 130) + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, + "precission qualifier forbidden " + "in GLSL %d.%d (1.30 or later " + "required)\n", + state->language_version / 100, + state->language_version % 100); + + (yyval.n) = ast_precision_low; + ;} + break; + + case 212: + +/* Line 1455 of yacc.c */ +#line 1108 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node)); + (yyval.struct_specifier)->set_location(yylloc); + ;} + break; + + case 213: + +/* Line 1455 of yacc.c */ +#line 1114 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node)); + (yyval.struct_specifier)->set_location(yylloc); + ;} + break; + + case 214: + +/* Line 1455 of yacc.c */ +#line 1123 "glsl_parser.ypp" + { + (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].declarator_list); + (yyvsp[(1) - (1)].declarator_list)->link.self_link(); + ;} + break; + + case 215: + +/* Line 1455 of yacc.c */ +#line 1128 "glsl_parser.ypp" + { + (yyval.node) = (struct ast_node *) (yyvsp[(1) - (2)].node); + (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); + ;} + break; + + case 216: + +/* Line 1455 of yacc.c */ +#line 1136 "glsl_parser.ypp" + { + void *ctx = state; + ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); + type->set_location(yylloc); + + type->specifier = (yyvsp[(1) - (3)].type_specifier); + (yyval.declarator_list) = new(ctx) ast_declarator_list(type); + (yyval.declarator_list)->set_location(yylloc); + + (yyval.declarator_list)->declarations.push_degenerate_list_at_head(& (yyvsp[(2) - (3)].declaration)->link); + ;} + break; + + case 217: + +/* Line 1455 of yacc.c */ +#line 1151 "glsl_parser.ypp" + { + (yyval.declaration) = (yyvsp[(1) - (1)].declaration); + (yyvsp[(1) - (1)].declaration)->link.self_link(); + ;} + break; + + case 218: + +/* Line 1455 of yacc.c */ +#line 1156 "glsl_parser.ypp" + { + (yyval.declaration) = (yyvsp[(1) - (3)].declaration); + (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link); + ;} + break; + + case 219: + +/* Line 1455 of yacc.c */ +#line 1164 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL); + (yyval.declaration)->set_location(yylloc); + ;} + break; + + case 220: + +/* Line 1455 of yacc.c */ +#line 1170 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL); + (yyval.declaration)->set_location(yylloc); + ;} + break; + + case 225: + +/* Line 1455 of yacc.c */ +#line 1193 "glsl_parser.ypp" + { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} + break; + + case 231: + +/* Line 1455 of yacc.c */ +#line 1205 "glsl_parser.ypp" + { (yyval.node) = NULL; ;} + break; + + case 232: + +/* Line 1455 of yacc.c */ +#line 1206 "glsl_parser.ypp" + { (yyval.node) = NULL; ;} + break; + + case 235: + +/* Line 1455 of yacc.c */ +#line 1213 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL); + (yyval.compound_statement)->set_location(yylloc); + ;} + break; + + case 236: + +/* Line 1455 of yacc.c */ +#line 1219 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(2) - (3)].node)); + (yyval.compound_statement)->set_location(yylloc); + ;} + break; + + case 237: + +/* Line 1455 of yacc.c */ +#line 1227 "glsl_parser.ypp" + { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} + break; + + case 239: + +/* Line 1455 of yacc.c */ +#line 1233 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL); + (yyval.compound_statement)->set_location(yylloc); + ;} + break; + + case 240: + +/* Line 1455 of yacc.c */ +#line 1239 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node)); + (yyval.compound_statement)->set_location(yylloc); + ;} + break; + + case 241: + +/* Line 1455 of yacc.c */ +#line 1248 "glsl_parser.ypp" + { + if ((yyvsp[(1) - (1)].node) == NULL) { + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, " statement\n"); + assert((yyvsp[(1) - (1)].node) != NULL); + } + + (yyval.node) = (yyvsp[(1) - (1)].node); + (yyval.node)->link.self_link(); + ;} + break; + + case 242: + +/* Line 1455 of yacc.c */ +#line 1258 "glsl_parser.ypp" + { + if ((yyvsp[(2) - (2)].node) == NULL) { + _mesa_glsl_error(& (yylsp[(2) - (2)]), state, " statement\n"); + assert((yyvsp[(2) - (2)].node) != NULL); + } + (yyval.node) = (yyvsp[(1) - (2)].node); + (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].node)->link); + ;} + break; + + case 243: + +/* Line 1455 of yacc.c */ +#line 1270 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_expression_statement(NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 244: + +/* Line 1455 of yacc.c */ +#line 1276 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 245: + +/* Line 1455 of yacc.c */ +#line 1285 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 246: + +/* Line 1455 of yacc.c */ +#line 1294 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 247: + +/* Line 1455 of yacc.c */ +#line 1300 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 248: + +/* Line 1455 of yacc.c */ +#line 1306 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 249: + +/* Line 1455 of yacc.c */ +#line 1315 "glsl_parser.ypp" + { + (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].expression); + ;} + break; + + case 250: + +/* Line 1455 of yacc.c */ +#line 1319 "glsl_parser.ypp" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); + ast_declarator_list *declarator = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type)); + decl->set_location(yylloc); + declarator->set_location(yylloc); + + declarator->declarations.push_tail(&decl->link); + (yyval.node) = declarator; + ;} + break; + + case 254: + +/* Line 1455 of yacc.c */ +#line 1342 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, + NULL, (yyvsp[(3) - (5)].node), NULL, (yyvsp[(5) - (5)].node)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 255: + +/* Line 1455 of yacc.c */ +#line 1349 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, + NULL, (yyvsp[(5) - (7)].expression), NULL, (yyvsp[(2) - (7)].node)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 256: + +/* Line 1455 of yacc.c */ +#line 1356 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, + (yyvsp[(3) - (6)].node), (yyvsp[(4) - (6)].for_rest_statement).cond, (yyvsp[(4) - (6)].for_rest_statement).rest, (yyvsp[(6) - (6)].node)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 260: + +/* Line 1455 of yacc.c */ +#line 1372 "glsl_parser.ypp" + { + (yyval.node) = NULL; + ;} + break; + + case 261: + +/* Line 1455 of yacc.c */ +#line 1379 "glsl_parser.ypp" + { + (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node); + (yyval.for_rest_statement).rest = NULL; + ;} + break; + + case 262: + +/* Line 1455 of yacc.c */ +#line 1384 "glsl_parser.ypp" + { + (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node); + (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression); + ;} + break; + + case 263: + +/* Line 1455 of yacc.c */ +#line 1393 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 264: + +/* Line 1455 of yacc.c */ +#line 1399 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 265: + +/* Line 1455 of yacc.c */ +#line 1405 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 266: + +/* Line 1455 of yacc.c */ +#line 1411 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 267: + +/* Line 1455 of yacc.c */ +#line 1417 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 268: + +/* Line 1455 of yacc.c */ +#line 1425 "glsl_parser.ypp" + { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;} + break; + + case 269: + +/* Line 1455 of yacc.c */ +#line 1426 "glsl_parser.ypp" + { (yyval.node) = (yyvsp[(1) - (1)].node); ;} + break; + + case 270: + +/* Line 1455 of yacc.c */ +#line 1431 "glsl_parser.ypp" + { + void *ctx = state; + (yyval.function_definition) = new(ctx) ast_function_definition(); + (yyval.function_definition)->set_location(yylloc); + (yyval.function_definition)->prototype = (yyvsp[(1) - (2)].function); + (yyval.function_definition)->body = (yyvsp[(2) - (2)].compound_statement); + ;} + break; + + + +/* Line 1455 of yacc.c */ +#line 4838 "glsl_parser.cpp" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + *++yylsp = yyloc; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (&yylloc, state, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (&yylloc, state, yymsg); + } + else + { + yyerror (&yylloc, state, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + yyerror_range[0] = yylloc; + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, &yylloc, state); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + yyerror_range[0] = yylsp[1-yylen]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + yyerror_range[0] = *yylsp; + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yylsp, state); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + *++yyvsp = yylval; + + yyerror_range[1] = yylloc; + /* Using YYLLOC is tempting, but would change the location of + the lookahead. YYLOC is available though. */ + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + *++yylsp = yyloc; + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (&yylloc, state, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, &yylloc, state); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yylsp, state); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h new file mode 100644 index 00000000000..6cbab40557b --- /dev/null +++ b/src/glsl/glsl_parser.h @@ -0,0 +1,262 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ATTRIBUTE = 258, + CONST_TOK = 259, + BOOL = 260, + FLOAT = 261, + INT = 262, + UINT = 263, + BREAK = 264, + CONTINUE = 265, + DO = 266, + ELSE = 267, + FOR = 268, + IF = 269, + DISCARD = 270, + RETURN = 271, + SWITCH = 272, + CASE = 273, + DEFAULT = 274, + BVEC2 = 275, + BVEC3 = 276, + BVEC4 = 277, + IVEC2 = 278, + IVEC3 = 279, + IVEC4 = 280, + UVEC2 = 281, + UVEC3 = 282, + UVEC4 = 283, + VEC2 = 284, + VEC3 = 285, + VEC4 = 286, + MAT2 = 287, + MAT3 = 288, + MAT4 = 289, + CENTROID = 290, + IN = 291, + OUT = 292, + INOUT = 293, + UNIFORM = 294, + VARYING = 295, + NOPERSPECTIVE = 296, + FLAT = 297, + SMOOTH = 298, + MAT2X2 = 299, + MAT2X3 = 300, + MAT2X4 = 301, + MAT3X2 = 302, + MAT3X3 = 303, + MAT3X4 = 304, + MAT4X2 = 305, + MAT4X3 = 306, + MAT4X4 = 307, + SAMPLER1D = 308, + SAMPLER2D = 309, + SAMPLER3D = 310, + SAMPLERCUBE = 311, + SAMPLER1DSHADOW = 312, + SAMPLER2DSHADOW = 313, + SAMPLERCUBESHADOW = 314, + SAMPLER1DARRAY = 315, + SAMPLER2DARRAY = 316, + SAMPLER1DARRAYSHADOW = 317, + SAMPLER2DARRAYSHADOW = 318, + ISAMPLER1D = 319, + ISAMPLER2D = 320, + ISAMPLER3D = 321, + ISAMPLERCUBE = 322, + ISAMPLER1DARRAY = 323, + ISAMPLER2DARRAY = 324, + USAMPLER1D = 325, + USAMPLER2D = 326, + USAMPLER3D = 327, + USAMPLERCUBE = 328, + USAMPLER1DARRAY = 329, + USAMPLER2DARRAY = 330, + STRUCT = 331, + VOID = 332, + WHILE = 333, + IDENTIFIER = 334, + FLOATCONSTANT = 335, + INTCONSTANT = 336, + UINTCONSTANT = 337, + BOOLCONSTANT = 338, + FIELD_SELECTION = 339, + LEFT_OP = 340, + RIGHT_OP = 341, + INC_OP = 342, + DEC_OP = 343, + LE_OP = 344, + GE_OP = 345, + EQ_OP = 346, + NE_OP = 347, + AND_OP = 348, + OR_OP = 349, + XOR_OP = 350, + MUL_ASSIGN = 351, + DIV_ASSIGN = 352, + ADD_ASSIGN = 353, + MOD_ASSIGN = 354, + LEFT_ASSIGN = 355, + RIGHT_ASSIGN = 356, + AND_ASSIGN = 357, + XOR_ASSIGN = 358, + OR_ASSIGN = 359, + SUB_ASSIGN = 360, + INVARIANT = 361, + LOWP = 362, + MEDIUMP = 363, + HIGHP = 364, + PRECISION = 365, + VERSION = 366, + EXTENSION = 367, + LINE = 368, + PRAGMA = 369, + COLON = 370, + EOL = 371, + INTERFACE = 372, + OUTPUT = 373, + ASM = 374, + CLASS = 375, + UNION = 376, + ENUM = 377, + TYPEDEF = 378, + TEMPLATE = 379, + THIS = 380, + PACKED = 381, + GOTO = 382, + INLINE_TOK = 383, + NOINLINE = 384, + VOLATILE = 385, + PUBLIC_TOK = 386, + STATIC = 387, + EXTERN = 388, + EXTERNAL = 389, + LONG = 390, + SHORT = 391, + DOUBLE = 392, + HALF = 393, + FIXED = 394, + UNSIGNED = 395, + INPUT = 396, + OUPTUT = 397, + HVEC2 = 398, + HVEC3 = 399, + HVEC4 = 400, + DVEC2 = 401, + DVEC3 = 402, + DVEC4 = 403, + FVEC2 = 404, + FVEC3 = 405, + FVEC4 = 406, + SAMPLER2DRECT = 407, + SAMPLER3DRECT = 408, + SAMPLER2DRECTSHADOW = 409, + SIZEOF = 410, + CAST = 411, + NAMESPACE = 412, + USING = 413 + }; +#endif + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 1676 of yacc.c */ +#line 45 "glsl_parser.ypp" + + int n; + float real; + char *identifier; + + union { + struct ast_type_qualifier q; + unsigned i; + } type_qualifier; + + struct ast_node *node; + struct ast_type_specifier *type_specifier; + struct ast_fully_specified_type *fully_specified_type; + struct ast_function *function; + struct ast_parameter_declarator *parameter_declarator; + struct ast_function_definition *function_definition; + struct ast_compound_statement *compound_statement; + struct ast_expression *expression; + struct ast_declarator_list *declarator_list; + struct ast_struct_specifier *struct_specifier; + struct ast_declaration *declaration; + + struct { + struct ast_node *cond; + struct ast_expression *rest; + } for_rest_statement; + + + +/* Line 1676 of yacc.c */ +#line 240 "glsl_parser.h" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + + -- cgit v1.2.3 From f8a04b38775cc9f40619e3fb3be39d585e0d4920 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 28 Jul 2010 12:30:07 -0700 Subject: glsl: Ignore glsl_compiler and glsl_parser.output files. These are generated files where we can do the sane thing, and keep them out of version control. --- src/glsl/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/glsl/.gitignore diff --git a/src/glsl/.gitignore b/src/glsl/.gitignore new file mode 100644 index 00000000000..4c212313e45 --- /dev/null +++ b/src/glsl/.gitignore @@ -0,0 +1,2 @@ +glsl_compiler +glsl_parser.output -- cgit v1.2.3 From 667173e36293d781e145f40e0d6919cb847af318 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 28 Jul 2010 12:33:56 -0700 Subject: glcpp: Add generated source files. This is now consistent with other usage of flex/bison througout mesa, (which is that these generated files are added to source control so that the build system does not require external tools like flex/bison for non-developers). --- src/glsl/glcpp/.gitignore | 3 - src/glsl/glcpp/glcpp-lex.c | 2636 ++++++++++++++++++++++++++++ src/glsl/glcpp/glcpp-parse.c | 3957 ++++++++++++++++++++++++++++++++++++++++++ src/glsl/glcpp/glcpp-parse.h | 100 ++ 4 files changed, 6693 insertions(+), 3 deletions(-) create mode 100644 src/glsl/glcpp/glcpp-lex.c create mode 100644 src/glsl/glcpp/glcpp-parse.c create mode 100644 src/glsl/glcpp/glcpp-parse.h diff --git a/src/glsl/glcpp/.gitignore b/src/glsl/glcpp/.gitignore index c158dc8b862..dbc37e1926d 100644 --- a/src/glsl/glcpp/.gitignore +++ b/src/glsl/glcpp/.gitignore @@ -1,7 +1,4 @@ glcpp -glcpp-lex.c -glcpp-parse.c -glcpp-parse.h glcpp-parse.output *.o *.lo diff --git a/src/glsl/glcpp/glcpp-lex.c b/src/glsl/glcpp/glcpp-lex.c new file mode 100644 index 00000000000..edf98a4afd2 --- /dev/null +++ b/src/glsl/glcpp/glcpp-lex.c @@ -0,0 +1,2636 @@ +#line 2 "glcpp/glcpp-lex.c" + +#line 4 "glcpp/glcpp-lex.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE glcpp_restart(yyin ,yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via glcpp_restart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void glcpp_restart (FILE *input_file ,yyscan_t yyscanner ); +void glcpp__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE glcpp__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void glcpp__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void glcpp__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void glcpp_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void glcpp_pop_buffer_state (yyscan_t yyscanner ); + +static void glcpp_ensure_buffer_stack (yyscan_t yyscanner ); +static void glcpp__load_buffer_state (yyscan_t yyscanner ); +static void glcpp__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); + +#define YY_FLUSH_BUFFER glcpp__flush_buffer(YY_CURRENT_BUFFER ,yyscanner) + +YY_BUFFER_STATE glcpp__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE glcpp__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE glcpp__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); + +void *glcpp_alloc (yy_size_t ,yyscan_t yyscanner ); +void *glcpp_realloc (void *,yy_size_t ,yyscan_t yyscanner ); +void glcpp_free (void * ,yyscan_t yyscanner ); + +#define yy_new_buffer glcpp__create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + glcpp_ensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + glcpp_ensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define glcpp_wrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 40 +#define YY_END_OF_BUFFER 41 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_acclist[132] = + { 0, + 3, 3, 41, 36, 40, 37, 40, 38, 40, 40, + 35, 40, 40, 35, 40, 35, 40, 35, 40, 22, + 36, 40, 21, 36, 40, 35, 40, 35, 40, 35, + 40, 34, 36, 40, 34, 36, 40, 35, 40, 37, + 40, 20, 40, 40, 3, 40, 4, 40, 5, 40, + 39, 40, 36, 15, 37, 29, 32, 30, 2, 22, + 36, 22, 36, 36, 21, 36, 21, 36, 24, 26, + 28, 27, 25, 34, 36, 34, 36, 31, 37, 20, + 20, 3, 4, 5, 6, 5, 7, 1, 15, 23, + 36, 34, 36,16395, 23, 36, 34, 36, 15, 34, + + 36,16396,16397, 8203, 15, 8203, 34, 36, 8204, 15, + 8205, 15,16398, 16,16393, 19, 33, 34, 36, 18, + 8206, 15, 16, 8201, 15,16394,16401, 8202, 15, 8, + 8209 + } ; + +static yyconst flex_int16_t yy_accept[151] = + { 0, + 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, + 6, 8, 10, 11, 13, 14, 16, 18, 20, 23, + 26, 28, 30, 32, 35, 38, 40, 42, 44, 45, + 47, 49, 51, 53, 54, 54, 55, 56, 57, 58, + 59, 60, 60, 62, 64, 65, 67, 69, 70, 71, + 72, 73, 74, 76, 78, 79, 80, 81, 82, 82, + 82, 82, 82, 82, 82, 83, 84, 85, 86, 87, + 88, 88, 90, 92, 94, 94, 94, 94, 94, 94, + 95, 95, 95, 95, 97, 99, 99, 99, 99, 99, + 99, 99, 99, 100, 100, 100, 100, 100, 100, 102, + + 102, 103, 104, 104, 104, 104, 104, 106, 106, 107, + 107, 107, 107, 107, 107, 109, 109, 109, 111, 111, + 113, 114, 115, 115, 116, 116, 116, 117, 117, 120, + 121, 121, 123, 124, 124, 124, 126, 127, 127, 127, + 128, 128, 128, 130, 131, 131, 131, 132, 132, 132 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 7, 10, 7, 7, 7, 7, 11, 12, 13, 13, + 13, 13, 13, 13, 13, 14, 14, 1, 7, 15, + 16, 17, 1, 1, 18, 18, 18, 18, 18, 18, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 20, 19, 19, 21, 19, 19, + 7, 1, 7, 7, 19, 1, 22, 18, 18, 23, + + 24, 25, 26, 19, 27, 19, 19, 28, 29, 30, + 31, 32, 19, 33, 34, 35, 36, 37, 19, 38, + 19, 19, 7, 39, 7, 7, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[40] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[169] = + { 0, + 0, 38, 0, 0, 38, 39, 426, 425, 427, 48, + 43, 549, 423, 44, 63, 422, 59, 65, 87, 125, + 58, 67, 68, 164, 203, 40, 75, 241, 549, 421, + 549, 140, 549, 140, 420, 549, 144, 419, 418, 417, + 415, 414, 156, 179, 267, 0, 209, 413, 412, 411, + 410, 409, 387, 124, 407, 153, 403, 402, 154, 198, + 159, 155, 160, 192, 404, 549, 186, 549, 214, 549, + 359, 549, 162, 159, 227, 229, 230, 234, 199, 303, + 232, 235, 236, 262, 56, 243, 237, 247, 245, 252, + 291, 358, 357, 292, 238, 296, 293, 254, 335, 256, + + 355, 354, 298, 294, 263, 352, 549, 350, 549, 299, + 297, 322, 325, 257, 306, 328, 346, 549, 345, 549, + 344, 343, 329, 342, 331, 332, 341, 333, 319, 335, + 337, 549, 248, 338, 246, 549, 197, 184, 336, 366, + 403, 182, 549, 141, 434, 416, 79, 473, 549, 512, + 514, 516, 518, 520, 522, 71, 524, 526, 528, 530, + 532, 534, 536, 538, 540, 542, 544, 546 + } ; + +static yyconst flex_int16_t yy_def[169] = + { 0, + 149, 1, 150, 150, 151, 151, 152, 152, 149, 153, + 154, 149, 154, 154, 154, 154, 154, 154, 149, 153, + 154, 154, 154, 155, 155, 154, 154, 154, 149, 156, + 149, 157, 149, 20, 154, 149, 154, 154, 154, 154, + 154, 158, 19, 20, 20, 20, 20, 154, 154, 154, + 154, 154, 25, 25, 154, 154, 28, 28, 154, 154, + 154, 154, 154, 154, 156, 149, 157, 149, 157, 149, + 158, 149, 45, 25, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 20, 25, 154, 154, 154, 154, 154, + 154, 159, 160, 154, 154, 154, 154, 154, 25, 154, + + 161, 162, 154, 154, 154, 159, 149, 160, 149, 154, + 154, 154, 154, 154, 25, 154, 161, 149, 162, 149, + 163, 164, 154, 165, 154, 154, 154, 154, 25, 154, + 163, 149, 164, 154, 165, 149, 166, 167, 154, 149, + 154, 166, 149, 167, 168, 154, 154, 168, 0, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149 + } ; + +static yyconst flex_int16_t yy_nxt[589] = + { 0, + 10, 11, 12, 13, 14, 15, 16, 17, 16, 16, + 18, 19, 20, 20, 21, 22, 23, 24, 24, 24, + 24, 24, 25, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 26, 27, + 31, 31, 36, 28, 37, 36, 36, 32, 32, 35, + 36, 35, 35, 35, 35, 35, 35, 35, 35, 38, + 36, 36, 35, 35, 35, 36, 40, 36, 39, 36, + 36, 65, 48, 49, 41, 42, 56, 36, 55, 53, + 57, 36, 50, 51, 52, 99, 35, 34, 35, 36, + 35, 35, 35, 35, 35, 35, 35, 35, 43, 43, + + 34, 35, 35, 35, 34, 34, 44, 45, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 44, 34, 45, 35, 35, 36, 35, 35, + 35, 35, 35, 35, 35, 35, 46, 46, 46, 35, + 35, 35, 68, 36, 47, 37, 36, 53, 74, 69, + 70, 34, 34, 34, 56, 36, 36, 36, 57, 34, + 47, 36, 36, 35, 34, 35, 36, 35, 35, 35, + 35, 35, 35, 35, 35, 34, 34, 75, 35, 35, + 35, 84, 53, 80, 143, 85, 36, 81, 68, 82, + 34, 34, 34, 34, 36, 149, 149, 84, 34, 143, + + 36, 36, 35, 34, 35, 36, 35, 35, 35, 35, + 35, 35, 35, 35, 34, 83, 68, 35, 35, 35, + 34, 34, 34, 69, 70, 76, 54, 77, 34, 36, + 78, 36, 36, 91, 36, 79, 36, 36, 36, 36, + 36, 35, 58, 36, 34, 36, 39, 36, 136, 36, + 36, 86, 89, 96, 36, 87, 36, 97, 36, 36, + 111, 101, 88, 59, 60, 36, 90, 61, 98, 100, + 102, 103, 62, 34, 34, 34, 63, 64, 73, 73, + 73, 34, 104, 128, 73, 116, 34, 114, 73, 73, + 73, 73, 123, 36, 36, 36, 36, 34, 36, 36, + + 36, 36, 34, 92, 92, 93, 92, 92, 92, 92, + 92, 92, 92, 92, 105, 110, 113, 92, 92, 92, + 125, 112, 121, 124, 36, 94, 122, 36, 129, 53, + 36, 36, 95, 36, 36, 36, 140, 36, 36, 132, + 36, 92, 53, 36, 136, 36, 132, 120, 118, 127, + 126, 130, 109, 138, 107, 137, 120, 118, 115, 109, + 107, 72, 134, 139, 141, 138, 35, 140, 36, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, + + 145, 145, 145, 145, 35, 36, 66, 35, 35, 36, + 53, 36, 36, 36, 36, 36, 72, 36, 36, 36, + 36, 36, 36, 66, 36, 36, 149, 29, 29, 149, + 149, 149, 149, 146, 35, 35, 36, 35, 35, 35, + 35, 35, 147, 35, 35, 138, 149, 149, 35, 35, + 35, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 35, 35, 35, 36, 35, 35, 35, 35, + 35, 147, 35, 35, 149, 149, 149, 35, 35, 35, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 35, 29, 29, 30, 30, 33, 33, 34, 34, + 35, 35, 53, 53, 67, 67, 71, 71, 106, 106, + 108, 108, 117, 117, 119, 119, 131, 131, 133, 133, + 135, 135, 142, 142, 144, 144, 148, 148, 9, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149 + } ; + +static yyconst flex_int16_t yy_chk[589] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 5, 6, 26, 2, 11, 11, 14, 5, 6, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 14, + 21, 17, 10, 10, 10, 15, 17, 18, 15, 22, + 23, 156, 21, 21, 18, 18, 27, 27, 26, 85, + 27, 147, 22, 23, 23, 85, 10, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 32, 144, 20, 37, 37, 54, 54, 32, + 32, 34, 34, 34, 56, 56, 59, 62, 56, 34, + 20, 61, 63, 20, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 34, 43, 59, 24, 24, + 24, 73, 74, 61, 142, 74, 138, 62, 67, 63, + 44, 44, 44, 43, 64, 67, 67, 73, 44, 137, + + 60, 79, 24, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 44, 64, 69, 25, 25, 25, + 47, 47, 47, 69, 69, 60, 25, 60, 47, 75, + 60, 76, 77, 79, 81, 60, 78, 82, 83, 87, + 95, 25, 28, 28, 47, 86, 28, 89, 135, 88, + 133, 75, 77, 81, 90, 76, 98, 82, 100, 114, + 95, 87, 76, 28, 28, 105, 78, 28, 83, 86, + 88, 89, 28, 84, 84, 84, 28, 28, 45, 45, + 45, 84, 90, 114, 45, 100, 45, 98, 45, 45, + 45, 45, 105, 91, 94, 97, 104, 84, 96, 111, + + 103, 110, 45, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 91, 94, 97, 80, 80, 80, + 111, 96, 103, 110, 112, 80, 104, 113, 115, 115, + 116, 123, 80, 125, 126, 128, 130, 130, 139, 131, + 134, 80, 129, 127, 124, 122, 121, 119, 117, 113, + 112, 116, 108, 126, 106, 125, 102, 101, 99, 93, + 92, 71, 123, 128, 134, 139, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, + + 140, 140, 140, 140, 140, 141, 65, 58, 57, 55, + 53, 52, 51, 50, 49, 48, 42, 41, 146, 40, + 39, 38, 35, 30, 16, 13, 9, 8, 7, 0, + 0, 0, 0, 141, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 145, 145, 146, 0, 0, 145, 145, + 145, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 145, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 0, 0, 0, 148, 148, 148, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 148, 150, 150, 151, 151, 152, 152, 153, 153, + 154, 154, 155, 155, 157, 157, 158, 158, 159, 159, + 160, 160, 161, 161, 162, 162, 163, 163, 164, 164, + 165, 165, 166, 166, 167, 167, 168, 168, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149 + } ; + +#define YY_TRAILING_MASK 0x2000 +#define YY_TRAILING_HEAD_MASK 0x4000 +#define REJECT \ +{ \ +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \ +yyg->yy_lp = yyg->yy_full_lp; /* restore orig. accepting pos. */ \ +yyg->yy_state_ptr = yyg->yy_full_state; /* restore orig. state */ \ +yy_current_state = *yyg->yy_state_ptr; /* restore curr. state */ \ +++yyg->yy_lp; \ +goto find_rule; \ +} + +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "glcpp/glcpp-lex.l" +#line 2 "glcpp/glcpp-lex.l" +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include + +#include "glcpp.h" +#include "glcpp-parse.h" + +/* Flex annoyingly generates some functions without making them + * static. Let's declare them here. */ +int glcpp_get_column (yyscan_t yyscanner); +void glcpp_set_column (int column_no , yyscan_t yyscanner); + +#define YY_NO_INPUT + +#define YY_USER_ACTION \ + do { \ + yylloc->source = 0; \ + yylloc->first_column = yycolumn + 1; \ + yylloc->first_line = yylineno; \ + yycolumn += yyleng; \ + } while(0); +#define YY_USER_INIT yylineno = 0; yycolumn = 0; + +#line 694 "glcpp/glcpp-lex.c" + +#define INITIAL 0 +#define DONE 1 +#define COMMENT 2 +#define UNREACHABLE 3 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#define YY_EXTRA_TYPE glcpp_parser_t * + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + yy_state_type *yy_state_buf; + yy_state_type *yy_state_ptr; + char *yy_full_match; + int yy_lp; + + /* These are only needed for trailing context rules, + * but there's no conditional variable for that yet. */ + int yy_looking_for_trail_begin; + int yy_full_lp; + int *yy_full_state; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + YYLTYPE * yylloc_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals (yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + + # define yylloc yyg->yylloc_r + +int glcpp_lex_init (yyscan_t* scanner); + +int glcpp_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int glcpp_lex_destroy (yyscan_t yyscanner ); + +int glcpp_get_debug (yyscan_t yyscanner ); + +void glcpp_set_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE glcpp_get_extra (yyscan_t yyscanner ); + +void glcpp_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *glcpp_get_in (yyscan_t yyscanner ); + +void glcpp_set_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *glcpp_get_out (yyscan_t yyscanner ); + +void glcpp_set_out (FILE * out_str ,yyscan_t yyscanner ); + +int glcpp_get_leng (yyscan_t yyscanner ); + +char *glcpp_get_text (yyscan_t yyscanner ); + +int glcpp_get_lineno (yyscan_t yyscanner ); + +void glcpp_set_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * glcpp_get_lval (yyscan_t yyscanner ); + +void glcpp_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + + YYLTYPE *glcpp_get_lloc (yyscan_t yyscanner ); + + void glcpp_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int glcpp_wrap (yyscan_t yyscanner ); +#else +extern int glcpp_wrap (yyscan_t yyscanner ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (yyscan_t yyscanner ); +#else +static int input (yyscan_t yyscanner ); +#endif + +#endif + + static void yy_push_state (int new_state ,yyscan_t yyscanner); + + static void yy_pop_state (yyscan_t yyscanner ); + + static int yy_top_state (yyscan_t yyscanner ); + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int glcpp_lex \ + (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); + +#define YY_DECL int glcpp_lex \ + (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + +#line 69 "glcpp/glcpp-lex.l" + + + /* Single-line comments */ +#line 965 "glcpp/glcpp-lex.c" + + yylval = yylval_param; + + yylloc = yylloc_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + /* Create the reject buffer large enough to save one state per allowed character. */ + if ( ! yyg->yy_state_buf ) + yyg->yy_state_buf = (yy_state_type *)glcpp_alloc(YY_STATE_BUF_SIZE ,yyscanner); + if ( ! yyg->yy_state_buf ) + YY_FATAL_ERROR( "out of dynamic memory in glcpp_lex()" ); + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + glcpp_ensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + glcpp__load_buffer_state(yyscanner ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); + + yyg->yy_state_ptr = yyg->yy_state_buf; + *yyg->yy_state_ptr++ = yy_current_state; + +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 150 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yyg->yy_state_ptr++ = yy_current_state; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 549 ); + +yy_find_action: + yy_current_state = *--yyg->yy_state_ptr; + yyg->yy_lp = yy_accept[yy_current_state]; +find_rule: /* we branch to this label when backing up */ + for ( ; ; ) /* until we find what rule we matched */ + { + if ( yyg->yy_lp && yyg->yy_lp < yy_accept[yy_current_state + 1] ) + { + yy_act = yy_acclist[yyg->yy_lp]; + if ( yy_act & YY_TRAILING_HEAD_MASK || + yyg->yy_looking_for_trail_begin ) + { + if ( yy_act == yyg->yy_looking_for_trail_begin ) + { + yyg->yy_looking_for_trail_begin = 0; + yy_act &= ~YY_TRAILING_HEAD_MASK; + break; + } + } + else if ( yy_act & YY_TRAILING_MASK ) + { + yyg->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; + yyg->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; + yyg->yy_full_match = yy_cp; + yyg->yy_full_state = yyg->yy_state_ptr; + yyg->yy_full_lp = yyg->yy_lp; + } + else + { + yyg->yy_full_match = yy_cp; + yyg->yy_full_state = yyg->yy_state_ptr; + yyg->yy_full_lp = yyg->yy_lp; + break; + } + ++yyg->yy_lp; + goto find_rule; + } + --yy_cp; + yy_current_state = *--yyg->yy_state_ptr; + yyg->yy_lp = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 72 "glcpp/glcpp-lex.l" +{ + yylineno++; + yycolumn = 0; + return NEWLINE; +} + YY_BREAK +/* Multi-line comments */ +case 2: +YY_RULE_SETUP +#line 79 "glcpp/glcpp-lex.l" +{ yy_push_state(COMMENT, yyscanner); } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 80 "glcpp/glcpp-lex.l" + + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 81 "glcpp/glcpp-lex.l" +{ yylineno++; yycolumn = 0; } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 82 "glcpp/glcpp-lex.l" + + YY_BREAK +case 6: +/* rule 6 can match eol */ +YY_RULE_SETUP +#line 83 "glcpp/glcpp-lex.l" +{ yylineno++; yycolumn = 0; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 84 "glcpp/glcpp-lex.l" +{ + yy_pop_state(yyscanner); + if (yyextra->space_tokens) + return SPACE; +} + YY_BREAK +/* glcpp doesn't handle #extension, #version, or #pragma directives. + * Simply pass them through to the main compiler's lexer/parser. */ +case 8: +YY_RULE_SETUP +#line 92 "glcpp/glcpp-lex.l" +{ + yylval->str = xtalloc_strdup (yyextra, yytext); + yylineno++; + yycolumn = 0; + return OTHER; +} + YY_BREAK +case 9: +/* rule 9 can match eol */ +YY_RULE_SETUP +#line 99 "glcpp/glcpp-lex.l" +{ + yyextra->lexing_if = 1; + yyextra->space_tokens = 0; + return HASH_IFDEF; +} + YY_BREAK +case 10: +/* rule 10 can match eol */ +YY_RULE_SETUP +#line 105 "glcpp/glcpp-lex.l" +{ + yyextra->lexing_if = 1; + yyextra->space_tokens = 0; + return HASH_IFNDEF; +} + YY_BREAK +case 11: +/* rule 11 can match eol */ +YY_RULE_SETUP +#line 111 "glcpp/glcpp-lex.l" +{ + yyextra->lexing_if = 1; + yyextra->space_tokens = 0; + return HASH_IF; +} + YY_BREAK +case 12: +/* rule 12 can match eol */ +YY_RULE_SETUP +#line 117 "glcpp/glcpp-lex.l" +{ + yyextra->lexing_if = 1; + yyextra->space_tokens = 0; + return HASH_ELIF; +} + YY_BREAK +case 13: +/* rule 13 can match eol */ +YY_RULE_SETUP +#line 123 "glcpp/glcpp-lex.l" +{ + yyextra->space_tokens = 0; + return HASH_ELSE; +} + YY_BREAK +case 14: +/* rule 14 can match eol */ +YY_RULE_SETUP +#line 128 "glcpp/glcpp-lex.l" +{ + yyextra->space_tokens = 0; + return HASH_ENDIF; +} + YY_BREAK +/* When skipping (due to an #if 0 or similar) consume anything + * up to a newline. We do this with less priority than any + * #if-related directive (#if, #elif, #else, #endif), but with + * more priority than any other directive or token to avoid + * any side-effects from skipped content. + * + * We use the lexing_if flag to avoid skipping any part of an + * if conditional expression. */ +case 15: +/* rule 15 can match eol */ +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 141 "glcpp/glcpp-lex.l" +{ + /* Since this rule always matches, YY_USER_ACTION gets called for it, + * wrongly incrementing yycolumn. We undo that effect here. */ + yycolumn -= yyleng; + if (yyextra->lexing_if || + yyextra->skip_stack == NULL || + yyextra->skip_stack->type == SKIP_NO_SKIP) + { + REJECT; + } +} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 153 "glcpp/glcpp-lex.l" +{ + char *p; + for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */ + p += 5; /* skip "error" */ + glcpp_error(yylloc, yyextra, "#error%s", p); +} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 160 "glcpp/glcpp-lex.l" +{ + yyextra->space_tokens = 0; + return HASH_DEFINE_FUNC; +} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 165 "glcpp/glcpp-lex.l" +{ + yyextra->space_tokens = 0; + return HASH_DEFINE_OBJ; +} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 170 "glcpp/glcpp-lex.l" +{ + yyextra->space_tokens = 0; + return HASH_UNDEF; +} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 175 "glcpp/glcpp-lex.l" +{ + yyextra->space_tokens = 0; + return HASH; +} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 180 "glcpp/glcpp-lex.l" +{ + yylval->str = xtalloc_strdup (yyextra, yytext); + return INTEGER_STRING; +} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 185 "glcpp/glcpp-lex.l" +{ + yylval->str = xtalloc_strdup (yyextra, yytext); + return INTEGER_STRING; +} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 190 "glcpp/glcpp-lex.l" +{ + yylval->str = xtalloc_strdup (yyextra, yytext); + return INTEGER_STRING; +} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 195 "glcpp/glcpp-lex.l" +{ + return LEFT_SHIFT; +} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 199 "glcpp/glcpp-lex.l" +{ + return RIGHT_SHIFT; +} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 203 "glcpp/glcpp-lex.l" +{ + return LESS_OR_EQUAL; +} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 207 "glcpp/glcpp-lex.l" +{ + return GREATER_OR_EQUAL; +} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 211 "glcpp/glcpp-lex.l" +{ + return EQUAL; +} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 215 "glcpp/glcpp-lex.l" +{ + return NOT_EQUAL; +} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 219 "glcpp/glcpp-lex.l" +{ + return AND; +} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 223 "glcpp/glcpp-lex.l" +{ + return OR; +} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 227 "glcpp/glcpp-lex.l" +{ + return PASTE; +} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 231 "glcpp/glcpp-lex.l" +{ + return DEFINED; +} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 235 "glcpp/glcpp-lex.l" +{ + yylval->str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; +} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 240 "glcpp/glcpp-lex.l" +{ + return yytext[0]; +} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 244 "glcpp/glcpp-lex.l" +{ + yylval->str = xtalloc_strdup (yyextra, yytext); + return OTHER; +} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 249 "glcpp/glcpp-lex.l" +{ + if (yyextra->space_tokens) { + return SPACE; + } +} + YY_BREAK +case 38: +/* rule 38 can match eol */ +YY_RULE_SETUP +#line 255 "glcpp/glcpp-lex.l" +{ + yyextra->lexing_if = 0; + yylineno++; + yycolumn = 0; + return NEWLINE; +} + YY_BREAK +/* Handle missing newline at EOF. */ +case YY_STATE_EOF(INITIAL): +#line 263 "glcpp/glcpp-lex.l" +{ + BEGIN DONE; /* Don't keep matching this rule forever. */ + yyextra->lexing_if = 0; + return NEWLINE; +} + YY_BREAK +/* We don't actually use the UNREACHABLE start condition. We + only have this action here so that we can pretend to call some + generated functions, (to avoid "defined but not used" + warnings. */ +case 39: +YY_RULE_SETUP +#line 273 "glcpp/glcpp-lex.l" +{ + unput('.'); + yy_top_state(yyextra); +} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 278 "glcpp/glcpp-lex.l" +ECHO; + YY_BREAK +#line 1434 "glcpp/glcpp-lex.c" + case YY_STATE_EOF(DONE): + case YY_STATE_EOF(COMMENT): + case YY_STATE_EOF(UNREACHABLE): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * glcpp_lex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( glcpp_wrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of glcpp_lex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + glcpp_restart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) glcpp_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); + + yyg->yy_state_ptr = yyg->yy_state_buf; + *yyg->yy_state_ptr++ = yy_current_state; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 150 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yyg->yy_state_ptr++ = yy_current_state; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + register int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + + register YY_CHAR yy_c = 1; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 150 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 149); + if ( ! yy_is_jam ) + *yyg->yy_state_ptr++ = yy_current_state; + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) +{ + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_cp = yyg->yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yyg->yy_hold_char; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yyg->yy_n_chars + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + yyg->yytext_ptr = yy_bp; + yyg->yy_hold_char = *yy_cp; + yyg->yy_c_buf_p = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + glcpp_restart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( glcpp_wrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void glcpp_restart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + glcpp_ensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + glcpp__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + glcpp__load_buffer_state(yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void glcpp__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * glcpp_pop_buffer_state(); + * glcpp_push_buffer_state(new_buffer); + */ + glcpp_ensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + glcpp__load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (glcpp_wrap()) processing, but the only time this flag + * is looked at is after glcpp_wrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void glcpp__load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE glcpp__create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) glcpp_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in glcpp__create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) glcpp_alloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in glcpp__create_buffer()" ); + + b->yy_is_our_buffer = 1; + + glcpp__init_buffer(b,file ,yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with glcpp__create_buffer() + * @param yyscanner The scanner object. + */ + void glcpp__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + glcpp_free((void *) b->yy_ch_buf ,yyscanner ); + + glcpp_free((void *) b ,yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a glcpp_restart() or at EOF. + */ + static void glcpp__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + glcpp__flush_buffer(b ,yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then glcpp__init_buffer was _probably_ + * called from glcpp_restart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void glcpp__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + glcpp__load_buffer_state(yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void glcpp_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + glcpp_ensure_buffer_stack(yyscanner); + + /* This block is copied from glcpp__switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from glcpp__switch_to_buffer. */ + glcpp__load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void glcpp_pop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + glcpp__delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + glcpp__load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void glcpp_ensure_buffer_stack (yyscan_t yyscanner) +{ + int num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)glcpp_alloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in glcpp_ensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)glcpp_realloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in glcpp_ensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE glcpp__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) glcpp_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in glcpp__scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + glcpp__switch_to_buffer(b ,yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to glcpp_lex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * glcpp__scan_bytes() instead. + */ +YY_BUFFER_STATE glcpp__scan_string (yyconst char * yystr , yyscan_t yyscanner) +{ + + return glcpp__scan_bytes(yystr,strlen(yystr) ,yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to glcpp_lex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE glcpp__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) glcpp_alloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in glcpp__scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = glcpp__scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in glcpp__scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + + static void yy_push_state (int new_state , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth ) + { + yy_size_t new_size; + + yyg->yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yyg->yy_start_stack_depth * sizeof( int ); + + if ( ! yyg->yy_start_stack ) + yyg->yy_start_stack = (int *) glcpp_alloc(new_size ,yyscanner ); + + else + yyg->yy_start_stack = (int *) glcpp_realloc((void *) yyg->yy_start_stack,new_size ,yyscanner ); + + if ( ! yyg->yy_start_stack ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); +} + + static void yy_pop_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( --yyg->yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); +} + + static int yy_top_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE glcpp_get_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int glcpp_get_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int glcpp_get_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *glcpp_get_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *glcpp_get_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +int glcpp_get_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *glcpp_get_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void glcpp_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. + */ +void glcpp_set_lineno (int line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "glcpp_set_lineno called with no buffer" , yyscanner); + + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void glcpp_set_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "glcpp_set_column called with no buffer" , yyscanner); + + yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see glcpp__switch_to_buffer + */ +void glcpp_set_in (FILE * in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; +} + +void glcpp_set_out (FILE * out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; +} + +int glcpp_get_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void glcpp_set_debug (int bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * glcpp_get_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void glcpp_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +YYLTYPE *glcpp_get_lloc (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylloc; +} + +void glcpp_set_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylloc = yylloc_param; +} + +/* User-visible API */ + +/* glcpp_lex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int glcpp_lex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) glcpp_alloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* glcpp_lex_init_extra has the same functionality as glcpp_lex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to glcpp_alloc in + * the yyextra field. + */ + +int glcpp_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + glcpp_set_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) glcpp_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + glcpp_set_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from glcpp_lex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + + yyg->yy_state_buf = 0; + yyg->yy_state_ptr = 0; + yyg->yy_full_match = 0; + yyg->yy_lp = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * glcpp_lex_init() + */ + return 0; +} + +/* glcpp_lex_destroy is for both reentrant and non-reentrant scanners. */ +int glcpp_lex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + glcpp__delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + glcpp_pop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + glcpp_free(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + glcpp_free(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; + + glcpp_free ( yyg->yy_state_buf , yyscanner); + yyg->yy_state_buf = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * glcpp_lex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + glcpp_free ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *glcpp_alloc (yy_size_t size , yyscan_t yyscanner) +{ + return (void *) malloc( size ); +} + +void *glcpp_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void glcpp_free (void * ptr , yyscan_t yyscanner) +{ + free( (char *) ptr ); /* see glcpp_realloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 278 "glcpp/glcpp-lex.l" + + + +void +glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader) +{ + glcpp__scan_string(shader,parser->scanner); +} + diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c new file mode 100644 index 00000000000..2f08ff8112d --- /dev/null +++ b/src/glsl/glcpp/glcpp-parse.c @@ -0,0 +1,3957 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.4.1" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + +/* Using locations. */ +#define YYLSP_NEEDED 1 + + + +/* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ +#line 1 "glcpp/glcpp-parse.y" + +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include + +#include "glcpp.h" +#include "main/mtypes.h" + +#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) +#define glcpp_printf(stream, fmt, args...) \ + stream = talloc_asprintf_append(stream, fmt, args) + +static void +yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error); + +static void +_define_object_macro (glcpp_parser_t *parser, + YYLTYPE *loc, + const char *macro, + token_list_t *replacements); + +static void +_define_function_macro (glcpp_parser_t *parser, + YYLTYPE *loc, + const char *macro, + string_list_t *parameters, + token_list_t *replacements); + +static string_list_t * +_string_list_create (void *ctx); + +static void +_string_list_append_item (string_list_t *list, const char *str); + +static int +_string_list_contains (string_list_t *list, const char *member, int *index); + +static int +_string_list_length (string_list_t *list); + +static argument_list_t * +_argument_list_create (void *ctx); + +static void +_argument_list_append (argument_list_t *list, token_list_t *argument); + +static int +_argument_list_length (argument_list_t *list); + +static token_list_t * +_argument_list_member_at (argument_list_t *list, int index); + +/* Note: This function talloc_steal()s the str pointer. */ +static token_t * +_token_create_str (void *ctx, int type, char *str); + +static token_t * +_token_create_ival (void *ctx, int type, int ival); + +static token_list_t * +_token_list_create (void *ctx); + +/* Note: This function adds a talloc_reference() to token. + * + * You may want to talloc_unlink any current reference if you no + * longer need it. */ +static void +_token_list_append (token_list_t *list, token_t *token); + +static void +_token_list_append_list (token_list_t *list, token_list_t *tail); + +static active_list_t * +_active_list_push (active_list_t *list, + const char *identifier, + token_node_t *marker); + +static active_list_t * +_active_list_pop (active_list_t *list); + +int +_active_list_contains (active_list_t *list, const char *identifier); + +static void +_glcpp_parser_expand_token_list (glcpp_parser_t *parser, + token_list_t *list); + +static void +_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, + token_list_t *list); + +static void +_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, + int condition); + +static void +_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, + const char *type, int condition); + +static void +_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc); + +#define yylex glcpp_parser_lex + +static int +glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser); + +static void +glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); + + + +/* Line 189 of yacc.c */ +#line 210 "glcpp/glcpp-parse.c" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 1 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + COMMA_FINAL = 258, + DEFINED = 259, + ELIF_EXPANDED = 260, + HASH = 261, + HASH_DEFINE_FUNC = 262, + HASH_DEFINE_OBJ = 263, + HASH_ELIF = 264, + HASH_ELSE = 265, + HASH_ENDIF = 266, + HASH_IF = 267, + HASH_IFDEF = 268, + HASH_IFNDEF = 269, + HASH_UNDEF = 270, + IDENTIFIER = 271, + IF_EXPANDED = 272, + INTEGER = 273, + INTEGER_STRING = 274, + NEWLINE = 275, + OTHER = 276, + PLACEHOLDER = 277, + SPACE = 278, + PASTE = 279, + OR = 280, + AND = 281, + NOT_EQUAL = 282, + EQUAL = 283, + GREATER_OR_EQUAL = 284, + LESS_OR_EQUAL = 285, + RIGHT_SHIFT = 286, + LEFT_SHIFT = 287, + UNARY = 288 + }; +#endif + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 264 of yacc.c */ +#line 297 "glcpp/glcpp-parse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; + YYLTYPE yyls_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 2 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 673 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 56 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 16 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 98 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 157 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 288 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 46, 2, 2, 2, 42, 29, 2, + 44, 45, 40, 38, 48, 39, 53, 41, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 54, + 32, 55, 33, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 49, 2, 50, 28, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 51, 27, 52, 47, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 30, 31, 34, 35, 36, 37, 43 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 4, 7, 9, 11, 13, 16, 20, + 24, 29, 36, 44, 48, 52, 57, 62, 66, 69, + 72, 75, 78, 80, 82, 86, 90, 94, 98, 102, + 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, + 146, 150, 154, 157, 160, 163, 166, 170, 172, 176, + 178, 181, 184, 185, 187, 188, 190, 193, 198, 200, + 202, 205, 207, 210, 212, 214, 216, 218, 220, 222, + 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, + 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, + 264, 266, 268, 270, 272, 274, 276, 278, 280 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 57, 0, -1, -1, 57, 58, -1, 60, -1, 63, + -1, 59, -1, 6, 64, -1, 17, 61, 20, -1, + 5, 61, 20, -1, 8, 16, 65, 20, -1, 7, + 16, 44, 45, 65, 20, -1, 7, 16, 44, 62, + 45, 65, 20, -1, 15, 16, 20, -1, 12, 68, + 20, -1, 13, 16, 66, 20, -1, 14, 16, 66, + 20, -1, 9, 68, 20, -1, 9, 20, -1, 10, + 20, -1, 11, 20, -1, 6, 20, -1, 19, -1, + 18, -1, 61, 25, 61, -1, 61, 26, 61, -1, + 61, 27, 61, -1, 61, 28, 61, -1, 61, 29, + 61, -1, 61, 30, 61, -1, 61, 31, 61, -1, + 61, 34, 61, -1, 61, 35, 61, -1, 61, 33, + 61, -1, 61, 32, 61, -1, 61, 36, 61, -1, + 61, 37, 61, -1, 61, 39, 61, -1, 61, 38, + 61, -1, 61, 42, 61, -1, 61, 41, 61, -1, + 61, 40, 61, -1, 46, 61, -1, 47, 61, -1, + 39, 61, -1, 38, 61, -1, 44, 61, 45, -1, + 16, -1, 62, 48, 16, -1, 20, -1, 69, 20, + -1, 69, 20, -1, -1, 69, -1, -1, 69, -1, + 4, 16, -1, 4, 44, 16, 45, -1, 70, -1, + 67, -1, 68, 67, -1, 70, -1, 69, 70, -1, + 16, -1, 19, -1, 71, -1, 21, -1, 23, -1, + 49, -1, 50, -1, 44, -1, 45, -1, 51, -1, + 52, -1, 53, -1, 29, -1, 40, -1, 38, -1, + 39, -1, 47, -1, 46, -1, 41, -1, 42, -1, + 37, -1, 36, -1, 32, -1, 33, -1, 35, -1, + 34, -1, 31, -1, 30, -1, 28, -1, 27, -1, + 26, -1, 25, -1, 54, -1, 48, -1, 55, -1, + 24, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 166, 166, 168, 172, 175, 180, 181, 185, 188, + 194, 197, 200, 203, 211, 223, 228, 233, 245, 256, + 259, 262, 266, 275, 278, 281, 284, 287, 290, 293, + 296, 299, 302, 305, 308, 311, 314, 317, 320, 323, + 326, 329, 332, 335, 338, 341, 344, 350, 355, 363, + 364, 368, 374, 375, 378, 380, 387, 391, 395, 400, + 406, 414, 420, 428, 432, 436, 440, 444, 451, 452, + 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, + 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, + 473, 474, 475, 476, 477, 478, 479, 480, 481 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED", + "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ", + "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF", + "HASH_IFNDEF", "HASH_UNDEF", "IDENTIFIER", "IF_EXPANDED", "INTEGER", + "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE", "PASTE", + "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'", "'>'", + "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT", "'+'", + "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'", "','", + "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept", "input", + "line", "expanded_line", "control_line", "expression", "identifier_list", + "text_line", "non_directive", "replacement_list", "junk", + "conditional_token", "conditional_tokens", "pp_tokens", + "preprocessing_token", "operator", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 124, 94, 38, + 282, 283, 60, 62, 284, 285, 286, 287, 43, 45, + 42, 47, 37, 288, 40, 41, 33, 126, 44, 91, + 93, 123, 125, 46, 59, 61 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 56, 57, 57, 58, 58, 58, 58, 59, 59, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 62, 62, 63, + 63, 64, 65, 65, 66, 66, 67, 67, 67, 68, + 68, 69, 69, 70, 70, 70, 70, 70, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 2, 1, 1, 1, 2, 3, 3, + 4, 6, 7, 3, 3, 4, 4, 3, 2, 2, + 2, 2, 1, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 2, 2, 2, 2, 3, 1, 3, 1, + 2, 2, 0, 1, 0, 1, 2, 4, 1, 1, + 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 63, 0, 64, 49, 66, 67, + 98, 94, 93, 92, 91, 75, 90, 89, 85, 86, + 88, 87, 84, 83, 77, 78, 76, 81, 82, 70, + 71, 80, 79, 96, 68, 69, 72, 73, 74, 95, + 97, 3, 6, 4, 5, 0, 61, 65, 23, 22, + 0, 0, 0, 0, 0, 0, 21, 7, 0, 0, + 52, 0, 18, 59, 0, 58, 19, 20, 0, 54, + 54, 0, 0, 50, 62, 45, 44, 0, 42, 43, + 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, + 0, 0, 53, 56, 0, 17, 60, 14, 0, 55, + 0, 13, 8, 46, 24, 25, 26, 27, 28, 29, + 30, 34, 33, 31, 32, 35, 36, 38, 37, 41, + 40, 39, 47, 52, 0, 10, 0, 15, 16, 0, + 52, 0, 57, 11, 0, 48, 12 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 51, 52, 53, 65, 144, 54, 67, 111, + 118, 73, 74, 112, 56, 57 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -120 +static const yytype_int16 yypact[] = +{ + -120, 108, -120, -17, 356, -9, 9, 160, -15, 6, + 316, 17, 18, 29, -120, -17, -120, -120, -120, -120, + -120, -120, -120, -120, -120, -120, -120, -120, -120, -120, + -120, -120, -120, -120, -120, -120, -120, -120, -120, -120, + -120, -120, -120, -120, -120, -120, -120, -120, -120, -120, + -120, -120, -120, -120, -120, 396, -120, -120, -120, -120, + -17, -17, -17, -17, -17, 512, -120, -120, 436, 2, + 476, -8, -120, -120, 212, -120, -120, -120, 264, 476, + 476, 39, 535, -120, -120, -120, -120, 553, -120, -120, + -120, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17, -17, -17, -120, + -10, 40, 476, -120, 49, -120, -120, -120, 46, 476, + 48, -120, -120, -120, 573, 589, 604, 618, 631, -23, + -23, 1, 1, 1, 1, 16, 16, 22, 22, -120, + -120, -120, -120, 476, -1, -120, 24, -120, -120, 50, + 476, 56, -120, -120, 53, -120, -120 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -120, -120, -120, -120, -120, -11, -120, -120, -120, -119, + -6, -46, 65, 19, -7, -120 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 75, 58, 59, 75, 82, 76, 142, 69, 113, 98, + 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, + 55, 60, 61, 68, 149, 70, 77, 62, 116, 63, + 64, 154, 116, 79, 80, 143, 114, 102, 103, 104, + 105, 106, 107, 108, 150, 81, 110, 151, 84, 85, + 86, 87, 88, 89, 104, 105, 106, 107, 108, 121, + 145, 84, 106, 107, 108, 146, 147, 75, 148, 152, + 153, 75, 155, 156, 120, 78, 0, 0, 0, 0, + 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 119, 119, + 0, 0, 0, 0, 0, 84, 0, 0, 2, 0, + 0, 0, 84, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 0, 16, 17, 18, + 0, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 0, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 71, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 14, 0, 0, 16, + 72, 18, 0, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 0, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 71, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, + 0, 16, 115, 18, 0, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 0, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 71, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 14, 0, 0, 16, 117, 18, 0, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 0, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 0, 0, 16, 0, 18, 0, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 14, 0, 0, 16, 66, 18, 0, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 14, 0, 0, 16, 83, 18, 0, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 14, 0, 0, 16, 109, 18, 0, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 14, 0, 0, 16, 0, 18, 0, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 90, 0, 0, 0, 0, 91, 92, 93, + 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 122, 0, 0, 0, 0, + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, + 101, 102, 103, 104, 105, 106, 107, 108, 91, 92, + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 0, 0, 123, 92, + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 95, 96, 97, + 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108 +}; + +static const yytype_int16 yycheck[] = +{ + 7, 18, 19, 10, 15, 20, 16, 16, 16, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 1, 38, 39, 4, 143, 16, 20, 44, 74, 46, + 47, 150, 78, 16, 16, 45, 44, 36, 37, 38, + 39, 40, 41, 42, 45, 16, 44, 48, 55, 60, + 61, 62, 63, 64, 38, 39, 40, 41, 42, 20, + 20, 68, 40, 41, 42, 16, 20, 74, 20, 45, + 20, 78, 16, 20, 80, 10, -1, -1, -1, -1, + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, + 101, 102, 103, 104, 105, 106, 107, 108, 79, 80, + -1, -1, -1, -1, -1, 112, -1, -1, 0, -1, + -1, -1, 119, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, -1, 19, 20, 21, + -1, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, -1, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 4, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 16, -1, -1, 19, + 20, 21, -1, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, -1, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 4, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 16, -1, + -1, 19, 20, 21, -1, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, -1, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 4, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 16, -1, -1, 19, 20, 21, -1, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, -1, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 16, -1, -1, 19, -1, 21, -1, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 16, -1, -1, 19, 20, 21, -1, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 16, -1, -1, 19, 20, 21, -1, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 16, -1, -1, 19, 20, 21, -1, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 16, -1, -1, 19, -1, 21, -1, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 20, -1, -1, -1, -1, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 20, -1, -1, -1, -1, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, -1, -1, 45, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 57, 0, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 19, 20, 21, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 58, 59, 60, 63, 69, 70, 71, 18, 19, + 38, 39, 44, 46, 47, 61, 20, 64, 69, 16, + 16, 4, 20, 67, 68, 70, 20, 20, 68, 16, + 16, 16, 61, 20, 70, 61, 61, 61, 61, 61, + 20, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 20, + 44, 65, 69, 16, 44, 20, 67, 20, 66, 69, + 66, 20, 20, 45, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 16, 45, 62, 20, 16, 20, 20, 65, + 45, 48, 45, 20, 65, 16, 20 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, &yylloc, parser) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, Location, parser); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; + glcpp_parser_t *parser; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yylocationp); + YYUSE (parser); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parser) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; + glcpp_parser_t *parser; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, glcpp_parser_t *parser) +#else +static void +yy_reduce_print (yyvsp, yylsp, yyrule, parser) + YYSTYPE *yyvsp; + YYLTYPE *yylsp; + int yyrule; + glcpp_parser_t *parser; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , &(yylsp[(yyi + 1) - (yynrhs)]) , parser); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, yylsp, Rule, parser); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, glcpp_parser_t *parser) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yylocationp, parser) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + YYLTYPE *yylocationp; + glcpp_parser_t *parser; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yylocationp); + YYUSE (parser); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (glcpp_parser_t *parser); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (glcpp_parser_t *parser) +#else +int +yyparse (parser) + glcpp_parser_t *parser; +#endif +#endif +{ +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Location data for the lookahead symbol. */ +YYLTYPE yylloc; + + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls; + YYLTYPE *yylsp; + + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yyls = yylsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; + yylsp = yyls; + +#if YYLTYPE_IS_TRIVIAL + /* Initialize the default location before parsing starts. */ + yylloc.first_line = yylloc.last_line = 1; + yylloc.first_column = yylloc.last_column = 1; +#endif + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + YYLTYPE *yyls1 = yyls; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), + &yystacksize); + + yyls = yyls1; + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyls_alloc, yyls); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + yylsp = yyls + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + *++yylsp = yylloc; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 4: + +/* Line 1455 of yacc.c */ +#line 172 "glcpp/glcpp-parse.y" + { + glcpp_print(parser->output, "\n"); + ;} + break; + + case 5: + +/* Line 1455 of yacc.c */ +#line 175 "glcpp/glcpp-parse.y" + { + _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); + glcpp_print(parser->output, "\n"); + talloc_free ((yyvsp[(1) - (1)].token_list)); + ;} + break; + + case 8: + +/* Line 1455 of yacc.c */ +#line 185 "glcpp/glcpp-parse.y" + { + _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); + ;} + break; + + case 9: + +/* Line 1455 of yacc.c */ +#line 188 "glcpp/glcpp-parse.y" + { + _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); + ;} + break; + + case 10: + +/* Line 1455 of yacc.c */ +#line 194 "glcpp/glcpp-parse.y" + { + _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); + ;} + break; + + case 11: + +/* Line 1455 of yacc.c */ +#line 197 "glcpp/glcpp-parse.y" + { + _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); + ;} + break; + + case 12: + +/* Line 1455 of yacc.c */ +#line 200 "glcpp/glcpp-parse.y" + { + _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); + ;} + break; + + case 13: + +/* Line 1455 of yacc.c */ +#line 203 "glcpp/glcpp-parse.y" + { + macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); + if (macro) { + hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str)); + talloc_free (macro); + } + talloc_free ((yyvsp[(2) - (3)].str)); + ;} + break; + + case 14: + +/* Line 1455 of yacc.c */ +#line 211 "glcpp/glcpp-parse.y" + { + token_list_t *expanded; + token_t *token; + + expanded = _token_list_create (parser); + token = _token_create_ival (parser, IF_EXPANDED, IF_EXPANDED); + _token_list_append (expanded, token); + talloc_unlink (parser, token); + _glcpp_parser_expand_token_list (parser, (yyvsp[(2) - (3)].token_list)); + _token_list_append_list (expanded, (yyvsp[(2) - (3)].token_list)); + glcpp_parser_lex_from (parser, expanded); + ;} + break; + + case 15: + +/* Line 1455 of yacc.c */ +#line 223 "glcpp/glcpp-parse.y" + { + macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); + talloc_free ((yyvsp[(2) - (4)].str)); + _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL); + ;} + break; + + case 16: + +/* Line 1455 of yacc.c */ +#line 228 "glcpp/glcpp-parse.y" + { + macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); + talloc_free ((yyvsp[(2) - (4)].str)); + _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL); + ;} + break; + + case 17: + +/* Line 1455 of yacc.c */ +#line 233 "glcpp/glcpp-parse.y" + { + token_list_t *expanded; + token_t *token; + + expanded = _token_list_create (parser); + token = _token_create_ival (parser, ELIF_EXPANDED, ELIF_EXPANDED); + _token_list_append (expanded, token); + talloc_unlink (parser, token); + _glcpp_parser_expand_token_list (parser, (yyvsp[(2) - (3)].token_list)); + _token_list_append_list (expanded, (yyvsp[(2) - (3)].token_list)); + glcpp_parser_lex_from (parser, expanded); + ;} + break; + + case 18: + +/* Line 1455 of yacc.c */ +#line 245 "glcpp/glcpp-parse.y" + { + /* #elif without an expression results in a warning if the + * condition doesn't matter (we just handled #if 1 or such) + * but an error otherwise. */ + if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) { + parser->skip_stack->type = SKIP_TO_ENDIF; + glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression"); + } else { + glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif needs an expression"); + } + ;} + break; + + case 19: + +/* Line 1455 of yacc.c */ +#line 256 "glcpp/glcpp-parse.y" + { + _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); + ;} + break; + + case 20: + +/* Line 1455 of yacc.c */ +#line 259 "glcpp/glcpp-parse.y" + { + _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); + ;} + break; + + case 22: + +/* Line 1455 of yacc.c */ +#line 266 "glcpp/glcpp-parse.y" + { + if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { + (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); + } else if ((yyvsp[(1) - (1)].str)[0] == '0') { + (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 8); + } else { + (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 10); + } + ;} + break; + + case 23: + +/* Line 1455 of yacc.c */ +#line 275 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (1)].ival); + ;} + break; + + case 24: + +/* Line 1455 of yacc.c */ +#line 278 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); + ;} + break; + + case 25: + +/* Line 1455 of yacc.c */ +#line 281 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); + ;} + break; + + case 26: + +/* Line 1455 of yacc.c */ +#line 284 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); + ;} + break; + + case 27: + +/* Line 1455 of yacc.c */ +#line 287 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); + ;} + break; + + case 28: + +/* Line 1455 of yacc.c */ +#line 290 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); + ;} + break; + + case 29: + +/* Line 1455 of yacc.c */ +#line 293 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); + ;} + break; + + case 30: + +/* Line 1455 of yacc.c */ +#line 296 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); + ;} + break; + + case 31: + +/* Line 1455 of yacc.c */ +#line 299 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); + ;} + break; + + case 32: + +/* Line 1455 of yacc.c */ +#line 302 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); + ;} + break; + + case 33: + +/* Line 1455 of yacc.c */ +#line 305 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); + ;} + break; + + case 34: + +/* Line 1455 of yacc.c */ +#line 308 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); + ;} + break; + + case 35: + +/* Line 1455 of yacc.c */ +#line 311 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); + ;} + break; + + case 36: + +/* Line 1455 of yacc.c */ +#line 314 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); + ;} + break; + + case 37: + +/* Line 1455 of yacc.c */ +#line 317 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); + ;} + break; + + case 38: + +/* Line 1455 of yacc.c */ +#line 320 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); + ;} + break; + + case 39: + +/* Line 1455 of yacc.c */ +#line 323 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); + ;} + break; + + case 40: + +/* Line 1455 of yacc.c */ +#line 326 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); + ;} + break; + + case 41: + +/* Line 1455 of yacc.c */ +#line 329 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); + ;} + break; + + case 42: + +/* Line 1455 of yacc.c */ +#line 332 "glcpp/glcpp-parse.y" + { + (yyval.ival) = ! (yyvsp[(2) - (2)].ival); + ;} + break; + + case 43: + +/* Line 1455 of yacc.c */ +#line 335 "glcpp/glcpp-parse.y" + { + (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); + ;} + break; + + case 44: + +/* Line 1455 of yacc.c */ +#line 338 "glcpp/glcpp-parse.y" + { + (yyval.ival) = - (yyvsp[(2) - (2)].ival); + ;} + break; + + case 45: + +/* Line 1455 of yacc.c */ +#line 341 "glcpp/glcpp-parse.y" + { + (yyval.ival) = + (yyvsp[(2) - (2)].ival); + ;} + break; + + case 46: + +/* Line 1455 of yacc.c */ +#line 344 "glcpp/glcpp-parse.y" + { + (yyval.ival) = (yyvsp[(2) - (3)].ival); + ;} + break; + + case 47: + +/* Line 1455 of yacc.c */ +#line 350 "glcpp/glcpp-parse.y" + { + (yyval.string_list) = _string_list_create (parser); + _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); + talloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str)); + ;} + break; + + case 48: + +/* Line 1455 of yacc.c */ +#line 355 "glcpp/glcpp-parse.y" + { + (yyval.string_list) = (yyvsp[(1) - (3)].string_list); + _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); + talloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str)); + ;} + break; + + case 49: + +/* Line 1455 of yacc.c */ +#line 363 "glcpp/glcpp-parse.y" + { (yyval.token_list) = NULL; ;} + break; + + case 51: + +/* Line 1455 of yacc.c */ +#line 368 "glcpp/glcpp-parse.y" + { + yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); + ;} + break; + + case 52: + +/* Line 1455 of yacc.c */ +#line 374 "glcpp/glcpp-parse.y" + { (yyval.token_list) = NULL; ;} + break; + + case 55: + +/* Line 1455 of yacc.c */ +#line 380 "glcpp/glcpp-parse.y" + { + glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); + ;} + break; + + case 56: + +/* Line 1455 of yacc.c */ +#line 387 "glcpp/glcpp-parse.y" + { + int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; + (yyval.token) = _token_create_ival (parser, INTEGER, v); + ;} + break; + + case 57: + +/* Line 1455 of yacc.c */ +#line 391 "glcpp/glcpp-parse.y" + { + int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; + (yyval.token) = _token_create_ival (parser, INTEGER, v); + ;} + break; + + case 59: + +/* Line 1455 of yacc.c */ +#line 400 "glcpp/glcpp-parse.y" + { + parser->space_tokens = 1; + (yyval.token_list) = _token_list_create (parser); + _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token)); + talloc_unlink (parser, (yyvsp[(1) - (1)].token)); + ;} + break; + + case 60: + +/* Line 1455 of yacc.c */ +#line 406 "glcpp/glcpp-parse.y" + { + (yyval.token_list) = (yyvsp[(1) - (2)].token_list); + _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); + talloc_unlink (parser, (yyvsp[(2) - (2)].token)); + ;} + break; + + case 61: + +/* Line 1455 of yacc.c */ +#line 414 "glcpp/glcpp-parse.y" + { + parser->space_tokens = 1; + (yyval.token_list) = _token_list_create (parser); + _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token)); + talloc_unlink (parser, (yyvsp[(1) - (1)].token)); + ;} + break; + + case 62: + +/* Line 1455 of yacc.c */ +#line 420 "glcpp/glcpp-parse.y" + { + (yyval.token_list) = (yyvsp[(1) - (2)].token_list); + _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); + talloc_unlink (parser, (yyvsp[(2) - (2)].token)); + ;} + break; + + case 63: + +/* Line 1455 of yacc.c */ +#line 428 "glcpp/glcpp-parse.y" + { + (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); + (yyval.token)->location = yylloc; + ;} + break; + + case 64: + +/* Line 1455 of yacc.c */ +#line 432 "glcpp/glcpp-parse.y" + { + (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); + (yyval.token)->location = yylloc; + ;} + break; + + case 65: + +/* Line 1455 of yacc.c */ +#line 436 "glcpp/glcpp-parse.y" + { + (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); + (yyval.token)->location = yylloc; + ;} + break; + + case 66: + +/* Line 1455 of yacc.c */ +#line 440 "glcpp/glcpp-parse.y" + { + (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); + (yyval.token)->location = yylloc; + ;} + break; + + case 67: + +/* Line 1455 of yacc.c */ +#line 444 "glcpp/glcpp-parse.y" + { + (yyval.token) = _token_create_ival (parser, SPACE, SPACE); + (yyval.token)->location = yylloc; + ;} + break; + + case 68: + +/* Line 1455 of yacc.c */ +#line 451 "glcpp/glcpp-parse.y" + { (yyval.ival) = '['; ;} + break; + + case 69: + +/* Line 1455 of yacc.c */ +#line 452 "glcpp/glcpp-parse.y" + { (yyval.ival) = ']'; ;} + break; + + case 70: + +/* Line 1455 of yacc.c */ +#line 453 "glcpp/glcpp-parse.y" + { (yyval.ival) = '('; ;} + break; + + case 71: + +/* Line 1455 of yacc.c */ +#line 454 "glcpp/glcpp-parse.y" + { (yyval.ival) = ')'; ;} + break; + + case 72: + +/* Line 1455 of yacc.c */ +#line 455 "glcpp/glcpp-parse.y" + { (yyval.ival) = '{'; ;} + break; + + case 73: + +/* Line 1455 of yacc.c */ +#line 456 "glcpp/glcpp-parse.y" + { (yyval.ival) = '}'; ;} + break; + + case 74: + +/* Line 1455 of yacc.c */ +#line 457 "glcpp/glcpp-parse.y" + { (yyval.ival) = '.'; ;} + break; + + case 75: + +/* Line 1455 of yacc.c */ +#line 458 "glcpp/glcpp-parse.y" + { (yyval.ival) = '&'; ;} + break; + + case 76: + +/* Line 1455 of yacc.c */ +#line 459 "glcpp/glcpp-parse.y" + { (yyval.ival) = '*'; ;} + break; + + case 77: + +/* Line 1455 of yacc.c */ +#line 460 "glcpp/glcpp-parse.y" + { (yyval.ival) = '+'; ;} + break; + + case 78: + +/* Line 1455 of yacc.c */ +#line 461 "glcpp/glcpp-parse.y" + { (yyval.ival) = '-'; ;} + break; + + case 79: + +/* Line 1455 of yacc.c */ +#line 462 "glcpp/glcpp-parse.y" + { (yyval.ival) = '~'; ;} + break; + + case 80: + +/* Line 1455 of yacc.c */ +#line 463 "glcpp/glcpp-parse.y" + { (yyval.ival) = '!'; ;} + break; + + case 81: + +/* Line 1455 of yacc.c */ +#line 464 "glcpp/glcpp-parse.y" + { (yyval.ival) = '/'; ;} + break; + + case 82: + +/* Line 1455 of yacc.c */ +#line 465 "glcpp/glcpp-parse.y" + { (yyval.ival) = '%'; ;} + break; + + case 83: + +/* Line 1455 of yacc.c */ +#line 466 "glcpp/glcpp-parse.y" + { (yyval.ival) = LEFT_SHIFT; ;} + break; + + case 84: + +/* Line 1455 of yacc.c */ +#line 467 "glcpp/glcpp-parse.y" + { (yyval.ival) = RIGHT_SHIFT; ;} + break; + + case 85: + +/* Line 1455 of yacc.c */ +#line 468 "glcpp/glcpp-parse.y" + { (yyval.ival) = '<'; ;} + break; + + case 86: + +/* Line 1455 of yacc.c */ +#line 469 "glcpp/glcpp-parse.y" + { (yyval.ival) = '>'; ;} + break; + + case 87: + +/* Line 1455 of yacc.c */ +#line 470 "glcpp/glcpp-parse.y" + { (yyval.ival) = LESS_OR_EQUAL; ;} + break; + + case 88: + +/* Line 1455 of yacc.c */ +#line 471 "glcpp/glcpp-parse.y" + { (yyval.ival) = GREATER_OR_EQUAL; ;} + break; + + case 89: + +/* Line 1455 of yacc.c */ +#line 472 "glcpp/glcpp-parse.y" + { (yyval.ival) = EQUAL; ;} + break; + + case 90: + +/* Line 1455 of yacc.c */ +#line 473 "glcpp/glcpp-parse.y" + { (yyval.ival) = NOT_EQUAL; ;} + break; + + case 91: + +/* Line 1455 of yacc.c */ +#line 474 "glcpp/glcpp-parse.y" + { (yyval.ival) = '^'; ;} + break; + + case 92: + +/* Line 1455 of yacc.c */ +#line 475 "glcpp/glcpp-parse.y" + { (yyval.ival) = '|'; ;} + break; + + case 93: + +/* Line 1455 of yacc.c */ +#line 476 "glcpp/glcpp-parse.y" + { (yyval.ival) = AND; ;} + break; + + case 94: + +/* Line 1455 of yacc.c */ +#line 477 "glcpp/glcpp-parse.y" + { (yyval.ival) = OR; ;} + break; + + case 95: + +/* Line 1455 of yacc.c */ +#line 478 "glcpp/glcpp-parse.y" + { (yyval.ival) = ';'; ;} + break; + + case 96: + +/* Line 1455 of yacc.c */ +#line 479 "glcpp/glcpp-parse.y" + { (yyval.ival) = ','; ;} + break; + + case 97: + +/* Line 1455 of yacc.c */ +#line 480 "glcpp/glcpp-parse.y" + { (yyval.ival) = '='; ;} + break; + + case 98: + +/* Line 1455 of yacc.c */ +#line 481 "glcpp/glcpp-parse.y" + { (yyval.ival) = PASTE; ;} + break; + + + +/* Line 1455 of yacc.c */ +#line 2570 "glcpp/glcpp-parse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + *++yylsp = yyloc; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (&yylloc, parser, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (&yylloc, parser, yymsg); + } + else + { + yyerror (&yylloc, parser, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + yyerror_range[0] = yylloc; + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, &yylloc, parser); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + yyerror_range[0] = yylsp[1-yylen]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + yyerror_range[0] = *yylsp; + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yylsp, parser); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + *++yyvsp = yylval; + + yyerror_range[1] = yylloc; + /* Using YYLLOC is tempting, but would change the location of + the lookahead. YYLOC is available though. */ + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + *++yylsp = yyloc; + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (&yylloc, parser, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, &yylloc, parser); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yylsp, parser); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + +/* Line 1675 of yacc.c */ +#line 484 "glcpp/glcpp-parse.y" + + +string_list_t * +_string_list_create (void *ctx) +{ + string_list_t *list; + + list = xtalloc (ctx, string_list_t); + list->head = NULL; + list->tail = NULL; + + return list; +} + +void +_string_list_append_item (string_list_t *list, const char *str) +{ + string_node_t *node; + + node = xtalloc (list, string_node_t); + node->str = xtalloc_strdup (node, str); + + node->next = NULL; + + if (list->head == NULL) { + list->head = node; + } else { + list->tail->next = node; + } + + list->tail = node; +} + +int +_string_list_contains (string_list_t *list, const char *member, int *index) +{ + string_node_t *node; + int i; + + if (list == NULL) + return 0; + + for (i = 0, node = list->head; node; i++, node = node->next) { + if (strcmp (node->str, member) == 0) { + if (index) + *index = i; + return 1; + } + } + + return 0; +} + +int +_string_list_length (string_list_t *list) +{ + int length = 0; + string_node_t *node; + + if (list == NULL) + return 0; + + for (node = list->head; node; node = node->next) + length++; + + return length; +} + +argument_list_t * +_argument_list_create (void *ctx) +{ + argument_list_t *list; + + list = xtalloc (ctx, argument_list_t); + list->head = NULL; + list->tail = NULL; + + return list; +} + +void +_argument_list_append (argument_list_t *list, token_list_t *argument) +{ + argument_node_t *node; + + node = xtalloc (list, argument_node_t); + node->argument = argument; + + node->next = NULL; + + if (list->head == NULL) { + list->head = node; + } else { + list->tail->next = node; + } + + list->tail = node; +} + +int +_argument_list_length (argument_list_t *list) +{ + int length = 0; + argument_node_t *node; + + if (list == NULL) + return 0; + + for (node = list->head; node; node = node->next) + length++; + + return length; +} + +token_list_t * +_argument_list_member_at (argument_list_t *list, int index) +{ + argument_node_t *node; + int i; + + if (list == NULL) + return NULL; + + node = list->head; + for (i = 0; i < index; i++) { + node = node->next; + if (node == NULL) + break; + } + + if (node) + return node->argument; + + return NULL; +} + +/* Note: This function talloc_steal()s the str pointer. */ +token_t * +_token_create_str (void *ctx, int type, char *str) +{ + token_t *token; + + token = xtalloc (ctx, token_t); + token->type = type; + token->value.str = talloc_steal (token, str); + + return token; +} + +token_t * +_token_create_ival (void *ctx, int type, int ival) +{ + token_t *token; + + token = xtalloc (ctx, token_t); + token->type = type; + token->value.ival = ival; + + return token; +} + +token_list_t * +_token_list_create (void *ctx) +{ + token_list_t *list; + + list = xtalloc (ctx, token_list_t); + list->head = NULL; + list->tail = NULL; + list->non_space_tail = NULL; + + return list; +} + +void +_token_list_append (token_list_t *list, token_t *token) +{ + token_node_t *node; + + node = xtalloc (list, token_node_t); + node->token = xtalloc_reference (list, token); + + node->next = NULL; + + if (list->head == NULL) { + list->head = node; + } else { + list->tail->next = node; + } + + list->tail = node; + if (token->type != SPACE) + list->non_space_tail = node; +} + +void +_token_list_append_list (token_list_t *list, token_list_t *tail) +{ + if (tail == NULL || tail->head == NULL) + return; + + if (list->head == NULL) { + list->head = tail->head; + } else { + list->tail->next = tail->head; + } + + list->tail = tail->tail; + list->non_space_tail = tail->non_space_tail; +} + +static token_list_t * +_token_list_copy (void *ctx, token_list_t *other) +{ + token_list_t *copy; + token_node_t *node; + + if (other == NULL) + return NULL; + + copy = _token_list_create (ctx); + for (node = other->head; node; node = node->next) + _token_list_append (copy, node->token); + + return copy; +} + +static void +_token_list_trim_trailing_space (token_list_t *list) +{ + token_node_t *tail, *next; + + if (list->non_space_tail) { + tail = list->non_space_tail->next; + list->non_space_tail->next = NULL; + list->tail = list->non_space_tail; + + while (tail) { + next = tail->next; + talloc_free (tail); + tail = next; + } + } +} + +static void +_token_print (char **out, token_t *token) +{ + if (token->type < 256) { + glcpp_printf (*out, "%c", token->type); + return; + } + + switch (token->type) { + case INTEGER: + glcpp_printf (*out, "%" PRIxMAX, token->value.ival); + break; + case IDENTIFIER: + case INTEGER_STRING: + case OTHER: + glcpp_print (*out, token->value.str); + break; + case SPACE: + glcpp_print (*out, " "); + break; + case LEFT_SHIFT: + glcpp_print (*out, "<<"); + break; + case RIGHT_SHIFT: + glcpp_print (*out, ">>"); + break; + case LESS_OR_EQUAL: + glcpp_print (*out, "<="); + break; + case GREATER_OR_EQUAL: + glcpp_print (*out, ">="); + break; + case EQUAL: + glcpp_print (*out, "=="); + break; + case NOT_EQUAL: + glcpp_print (*out, "!="); + break; + case AND: + glcpp_print (*out, "&&"); + break; + case OR: + glcpp_print (*out, "||"); + break; + case PASTE: + glcpp_print (*out, "##"); + break; + case COMMA_FINAL: + glcpp_print (*out, ","); + break; + case PLACEHOLDER: + /* Nothing to print. */ + break; + default: + assert(!"Error: Don't know how to print token."); + break; + } +} + +/* Return a new token (talloc()ed off of 'token') formed by pasting + * 'token' and 'other'. Note that this function may return 'token' or + * 'other' directly rather than allocating anything new. + * + * Caution: Only very cursory error-checking is performed to see if + * the final result is a valid single token. */ +static token_t * +_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) +{ + token_t *combined = NULL; + + /* Pasting a placeholder onto anything makes no change. */ + if (other->type == PLACEHOLDER) + return token; + + /* When 'token' is a placeholder, just return 'other'. */ + if (token->type == PLACEHOLDER) + return other; + + /* A very few single-character punctuators can be combined + * with another to form a multi-character punctuator. */ + switch (token->type) { + case '<': + if (other->type == '<') + combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT); + else if (other->type == '=') + combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL); + break; + case '>': + if (other->type == '>') + combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT); + else if (other->type == '=') + combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL); + break; + case '=': + if (other->type == '=') + combined = _token_create_ival (token, EQUAL, EQUAL); + break; + case '!': + if (other->type == '=') + combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL); + break; + case '&': + if (other->type == '&') + combined = _token_create_ival (token, AND, AND); + break; + case '|': + if (other->type == '|') + combined = _token_create_ival (token, OR, OR); + break; + } + + if (combined != NULL) { + /* Inherit the location from the first token */ + combined->location = token->location; + return combined; + } + + /* Two string-valued tokens can usually just be mashed + * together. + * + * XXX: This isn't actually legitimate. Several things here + * should result in a diagnostic since the result cannot be a + * valid, single pre-processing token. For example, pasting + * "123" and "abc" is not legal, but we don't catch that + * here. */ + if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) && + (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING)) + { + char *str; + + str = xtalloc_asprintf (token, "%s%s", + token->value.str, other->value.str); + combined = _token_create_str (token, token->type, str); + combined->location = token->location; + return combined; + } + + glcpp_error (&token->location, parser, ""); + glcpp_print (parser->info_log, "Pasting \""); + _token_print (&parser->info_log, token); + glcpp_print (parser->info_log, "\" and \""); + _token_print (&parser->info_log, other); + glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n"); + + return token; +} + +static void +_token_list_print (glcpp_parser_t *parser, token_list_t *list) +{ + token_node_t *node; + + if (list == NULL) + return; + + for (node = list->head; node; node = node->next) + _token_print (&parser->output, node->token); +} + +void +yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error) +{ + glcpp_error(locp, parser, "%s", error); +} + +glcpp_parser_t * +glcpp_parser_create (const struct gl_extensions *extensions) +{ + glcpp_parser_t *parser; + token_t *tok; + token_list_t *list; + + parser = xtalloc (NULL, glcpp_parser_t); + + glcpp_lex_init_extra (parser, &parser->scanner); + parser->defines = hash_table_ctor (32, hash_table_string_hash, + hash_table_string_compare); + parser->active = NULL; + parser->lexing_if = 0; + parser->space_tokens = 1; + parser->newline_as_space = 0; + parser->in_control_line = 0; + parser->paren_count = 0; + + parser->skip_stack = NULL; + + parser->lex_from_list = NULL; + parser->lex_from_node = NULL; + + parser->output = talloc_strdup(parser, ""); + parser->info_log = talloc_strdup(parser, ""); + parser->error = 0; + + /* Add pre-defined macros. */ + tok = _token_create_ival (parser, INTEGER, 1); + + list = _token_list_create(parser); + _token_list_append(list, tok); + _define_object_macro(parser, NULL, "GL_ARB_draw_buffers", list); + + list = _token_list_create(parser); + _token_list_append(list, tok); + _define_object_macro(parser, NULL, "GL_ARB_texture_rectangle", list); + + if ((extensions != NULL) && extensions->EXT_texture_array) { + list = _token_list_create(parser); + _token_list_append(list, tok); + _define_object_macro(parser, NULL, + "GL_EXT_texture_array", list); + } + + talloc_unlink(parser, tok); + + return parser; +} + +int +glcpp_parser_parse (glcpp_parser_t *parser) +{ + return yyparse (parser); +} + +void +glcpp_parser_destroy (glcpp_parser_t *parser) +{ + if (parser->skip_stack) + glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); + glcpp_lex_destroy (parser->scanner); + hash_table_dtor (parser->defines); + talloc_free (parser); +} + +typedef enum function_status +{ + FUNCTION_STATUS_SUCCESS, + FUNCTION_NOT_A_FUNCTION, + FUNCTION_UNBALANCED_PARENTHESES +} function_status_t; + +/* Find a set of function-like macro arguments by looking for a + * balanced set of parentheses. + * + * When called, 'node' should be the opening-parenthesis token, (or + * perhaps preceeding SPACE tokens). Upon successful return *last will + * be the last consumed node, (corresponding to the closing right + * parenthesis). + * + * Return values: + * + * FUNCTION_STATUS_SUCCESS: + * + * Successfully parsed a set of function arguments. + * + * FUNCTION_NOT_A_FUNCTION: + * + * Macro name not followed by a '('. This is not an error, but + * simply that the macro name should be treated as a non-macro. + * + * FUNCTION_UNBALANCED_PARENTHESES + * + * Macro name is not followed by a balanced set of parentheses. + */ +static function_status_t +_arguments_parse (argument_list_t *arguments, + token_node_t *node, + token_node_t **last) +{ + token_list_t *argument; + int paren_count; + + node = node->next; + + /* Ignore whitespace before first parenthesis. */ + while (node && node->token->type == SPACE) + node = node->next; + + if (node == NULL || node->token->type != '(') + return FUNCTION_NOT_A_FUNCTION; + + node = node->next; + + argument = _token_list_create (arguments); + _argument_list_append (arguments, argument); + + for (paren_count = 1; node; node = node->next) { + if (node->token->type == '(') + { + paren_count++; + } + else if (node->token->type == ')') + { + paren_count--; + if (paren_count == 0) + break; + } + + if (node->token->type == ',' && + paren_count == 1) + { + _token_list_trim_trailing_space (argument); + argument = _token_list_create (arguments); + _argument_list_append (arguments, argument); + } + else { + if (argument->head == NULL) { + /* Don't treat initial whitespace as + * part of the arguement. */ + if (node->token->type == SPACE) + continue; + } + _token_list_append (argument, node->token); + } + } + + if (paren_count) + return FUNCTION_UNBALANCED_PARENTHESES; + + *last = node; + + return FUNCTION_STATUS_SUCCESS; +} + +static token_list_t * +_token_list_create_with_one_space (void *ctx) +{ + token_list_t *list; + token_t *space; + + list = _token_list_create (ctx); + space = _token_create_ival (list, SPACE, SPACE); + _token_list_append (list, space); + + return list; +} + +/* This is a helper function that's essentially part of the + * implementation of _glcpp_parser_expand_node. It shouldn't be called + * except for by that function. + * + * Returns NULL if node is a simple token with no expansion, (that is, + * although 'node' corresponds to an identifier defined as a + * function-like macro, it is not followed with a parenthesized + * argument list). + * + * Compute the complete expansion of node (which is a function-like + * macro) and subsequent nodes which are arguments. + * + * Returns the token list that results from the expansion and sets + * *last to the last node in the list that was consumed by the + * expansion. Specifically, *last will be set as follows: as the + * token of the closing right parenthesis. + */ +static token_list_t * +_glcpp_parser_expand_function (glcpp_parser_t *parser, + token_node_t *node, + token_node_t **last) + +{ + macro_t *macro; + const char *identifier; + argument_list_t *arguments; + function_status_t status; + token_list_t *substituted; + int parameter_index; + + identifier = node->token->value.str; + + macro = hash_table_find (parser->defines, identifier); + + assert (macro->is_function); + + arguments = _argument_list_create (parser); + status = _arguments_parse (arguments, node, last); + + switch (status) { + case FUNCTION_STATUS_SUCCESS: + break; + case FUNCTION_NOT_A_FUNCTION: + return NULL; + case FUNCTION_UNBALANCED_PARENTHESES: + glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier); + return NULL; + } + + /* Replace a macro defined as empty with a SPACE token. */ + if (macro->replacements == NULL) { + talloc_free (arguments); + return _token_list_create_with_one_space (parser); + } + + if (! ((_argument_list_length (arguments) == + _string_list_length (macro->parameters)) || + (_string_list_length (macro->parameters) == 0 && + _argument_list_length (arguments) == 1 && + arguments->head->argument->head == NULL))) + { + glcpp_error (&node->token->location, parser, + "Error: macro %s invoked with %d arguments (expected %d)\n", + identifier, + _argument_list_length (arguments), + _string_list_length (macro->parameters)); + return NULL; + } + + /* Perform argument substitution on the replacement list. */ + substituted = _token_list_create (arguments); + + for (node = macro->replacements->head; node; node = node->next) + { + if (node->token->type == IDENTIFIER && + _string_list_contains (macro->parameters, + node->token->value.str, + ¶meter_index)) + { + token_list_t *argument; + argument = _argument_list_member_at (arguments, + parameter_index); + /* Before substituting, we expand the argument + * tokens, or append a placeholder token for + * an empty argument. */ + if (argument->head) { + token_list_t *expanded_argument; + expanded_argument = _token_list_copy (parser, + argument); + _glcpp_parser_expand_token_list (parser, + expanded_argument); + _token_list_append_list (substituted, + expanded_argument); + } else { + token_t *new_token; + + new_token = _token_create_ival (substituted, + PLACEHOLDER, + PLACEHOLDER); + _token_list_append (substituted, new_token); + } + } else { + _token_list_append (substituted, node->token); + } + } + + /* After argument substitution, and before further expansion + * below, implement token pasting. */ + + _token_list_trim_trailing_space (substituted); + + node = substituted->head; + while (node) + { + token_node_t *next_non_space; + + /* Look ahead for a PASTE token, skipping space. */ + next_non_space = node->next; + while (next_non_space && next_non_space->token->type == SPACE) + next_non_space = next_non_space->next; + + if (next_non_space == NULL) + break; + + if (next_non_space->token->type != PASTE) { + node = next_non_space; + continue; + } + + /* Now find the next non-space token after the PASTE. */ + next_non_space = next_non_space->next; + while (next_non_space && next_non_space->token->type == SPACE) + next_non_space = next_non_space->next; + + if (next_non_space == NULL) { + yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n"); + return NULL; + } + + node->token = _token_paste (parser, node->token, next_non_space->token); + node->next = next_non_space->next; + if (next_non_space == substituted->tail) + substituted->tail = node; + + node = node->next; + } + + substituted->non_space_tail = substituted->tail; + + return substituted; +} + +/* Compute the complete expansion of node, (and subsequent nodes after + * 'node' in the case that 'node' is a function-like macro and + * subsequent nodes are arguments). + * + * Returns NULL if node is a simple token with no expansion. + * + * Otherwise, returns the token list that results from the expansion + * and sets *last to the last node in the list that was consumed by + * the expansion. Specifically, *last will be set as follows: + * + * As 'node' in the case of object-like macro expansion. + * + * As the token of the closing right parenthesis in the case of + * function-like macro expansion. + */ +static token_list_t * +_glcpp_parser_expand_node (glcpp_parser_t *parser, + token_node_t *node, + token_node_t **last) +{ + token_t *token = node->token; + const char *identifier; + macro_t *macro; + + /* We only expand identifiers */ + if (token->type != IDENTIFIER) { + /* We change any COMMA into a COMMA_FINAL to prevent + * it being mistaken for an argument separator + * later. */ + if (token->type == ',') { + token->type = COMMA_FINAL; + token->value.ival = COMMA_FINAL; + } + + return NULL; + } + + /* Look up this identifier in the hash table. */ + identifier = token->value.str; + macro = hash_table_find (parser->defines, identifier); + + /* Not a macro, so no expansion needed. */ + if (macro == NULL) + return NULL; + + /* Finally, don't expand this macro if we're already actively + * expanding it, (to avoid infinite recursion). */ + if (_active_list_contains (parser->active, identifier)) { + /* We change the token type here from IDENTIFIER to + * OTHER to prevent any future expansion of this + * unexpanded token. */ + char *str; + token_list_t *expansion; + token_t *final; + + str = xtalloc_strdup (parser, token->value.str); + final = _token_create_str (parser, OTHER, str); + expansion = _token_list_create (parser); + _token_list_append (expansion, final); + *last = node; + return expansion; + } + + if (! macro->is_function) + { + *last = node; + + /* Replace a macro defined as empty with a SPACE token. */ + if (macro->replacements == NULL) + return _token_list_create_with_one_space (parser); + + return _token_list_copy (parser, macro->replacements); + } + + return _glcpp_parser_expand_function (parser, node, last); +} + +/* Push a new identifier onto the active list, returning the new list. + * + * Here, 'marker' is the token node that appears in the list after the + * expansion of 'identifier'. That is, when the list iterator begins + * examinging 'marker', then it is time to pop this node from the + * active stack. + */ +active_list_t * +_active_list_push (active_list_t *list, + const char *identifier, + token_node_t *marker) +{ + active_list_t *node; + + node = xtalloc (list, active_list_t); + node->identifier = xtalloc_strdup (node, identifier); + node->marker = marker; + node->next = list; + + return node; +} + +active_list_t * +_active_list_pop (active_list_t *list) +{ + active_list_t *node = list; + + if (node == NULL) + return NULL; + + node = list->next; + talloc_free (list); + + return node; +} + +int +_active_list_contains (active_list_t *list, const char *identifier) +{ + active_list_t *node; + + if (list == NULL) + return 0; + + for (node = list; node; node = node->next) + if (strcmp (node->identifier, identifier) == 0) + return 1; + + return 0; +} + +/* Walk over the token list replacing nodes with their expansion. + * Whenever nodes are expanded the walking will walk over the new + * nodes, continuing to expand as necessary. The results are placed in + * 'list' itself; + */ +static void +_glcpp_parser_expand_token_list (glcpp_parser_t *parser, + token_list_t *list) +{ + token_node_t *node_prev; + token_node_t *node, *last = NULL; + token_list_t *expansion; + + if (list == NULL) + return; + + _token_list_trim_trailing_space (list); + + node_prev = NULL; + node = list->head; + + while (node) { + + while (parser->active && parser->active->marker == node) + parser->active = _active_list_pop (parser->active); + + /* Find the expansion for node, which will replace all + * nodes from node to last, inclusive. */ + expansion = _glcpp_parser_expand_node (parser, node, &last); + if (expansion) { + token_node_t *n; + + for (n = node; n != last->next; n = n->next) + while (parser->active && + parser->active->marker == n) + { + parser->active = _active_list_pop (parser->active); + } + + parser->active = _active_list_push (parser->active, + node->token->value.str, + last->next); + + /* Splice expansion into list, supporting a + * simple deletion if the expansion is + * empty. */ + if (expansion->head) { + if (node_prev) + node_prev->next = expansion->head; + else + list->head = expansion->head; + expansion->tail->next = last->next; + if (last == list->tail) + list->tail = expansion->tail; + } else { + if (node_prev) + node_prev->next = last->next; + else + list->head = last->next; + if (last == list->tail) + list->tail = NULL; + } + } else { + node_prev = node; + } + node = node_prev ? node_prev->next : list->head; + } + + while (parser->active) + parser->active = _active_list_pop (parser->active); + + list->non_space_tail = list->tail; +} + +void +_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, + token_list_t *list) +{ + if (list == NULL) + return; + + _glcpp_parser_expand_token_list (parser, list); + + _token_list_trim_trailing_space (list); + + _token_list_print (parser, list); +} + +static void +_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc, + const char *identifier) +{ + /* According to the GLSL specification, macro names starting with "__" + * or "GL_" are reserved for future use. So, don't allow them. + */ + if (strncmp(identifier, "__", 2) == 0) { + glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n"); + } + if (strncmp(identifier, "GL_", 3) == 0) { + glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n"); + } +} + +void +_define_object_macro (glcpp_parser_t *parser, + YYLTYPE *loc, + const char *identifier, + token_list_t *replacements) +{ + macro_t *macro; + + if (loc != NULL) + _check_for_reserved_macro_name(parser, loc, identifier); + + macro = xtalloc (parser, macro_t); + + macro->is_function = 0; + macro->parameters = NULL; + macro->identifier = talloc_strdup (macro, identifier); + macro->replacements = talloc_steal (macro, replacements); + + hash_table_insert (parser->defines, macro, identifier); +} + +void +_define_function_macro (glcpp_parser_t *parser, + YYLTYPE *loc, + const char *identifier, + string_list_t *parameters, + token_list_t *replacements) +{ + macro_t *macro; + + _check_for_reserved_macro_name(parser, loc, identifier); + + macro = xtalloc (parser, macro_t); + + macro->is_function = 1; + macro->parameters = talloc_steal (macro, parameters); + macro->identifier = talloc_strdup (macro, identifier); + macro->replacements = talloc_steal (macro, replacements); + + hash_table_insert (parser->defines, macro, identifier); +} + +static int +glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser) +{ + token_node_t *node; + int ret; + + if (parser->lex_from_list == NULL) { + ret = glcpp_lex (yylval, yylloc, parser->scanner); + + /* XXX: This ugly block of code exists for the sole + * purpose of converting a NEWLINE token into a SPACE + * token, but only in the case where we have seen a + * function-like macro name, but have not yet seen its + * closing parenthesis. + * + * There's perhaps a more compact way to do this with + * mid-rule actions in the grammar. + * + * I'm definitely not pleased with the complexity of + * this code here. + */ + if (parser->newline_as_space) + { + if (ret == '(') { + parser->paren_count++; + } else if (ret == ')') { + parser->paren_count--; + if (parser->paren_count == 0) + parser->newline_as_space = 0; + } else if (ret == NEWLINE) { + ret = SPACE; + } else if (ret != SPACE) { + if (parser->paren_count == 0) + parser->newline_as_space = 0; + } + } + else if (parser->in_control_line) + { + if (ret == NEWLINE) + parser->in_control_line = 0; + } + else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC || + ret == HASH_UNDEF || ret == HASH_IF || + ret == HASH_IFDEF || ret == HASH_IFNDEF || + ret == HASH_ELIF || ret == HASH_ELSE || + ret == HASH_ENDIF || ret == HASH) + { + parser->in_control_line = 1; + } + else if (ret == IDENTIFIER) + { + macro_t *macro; + macro = hash_table_find (parser->defines, + yylval->str); + if (macro && macro->is_function) { + parser->newline_as_space = 1; + parser->paren_count = 0; + } + } + + return ret; + } + + node = parser->lex_from_node; + + if (node == NULL) { + talloc_free (parser->lex_from_list); + parser->lex_from_list = NULL; + return NEWLINE; + } + + *yylval = node->token->value; + ret = node->token->type; + + parser->lex_from_node = node->next; + + return ret; +} + +static void +glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list) +{ + token_node_t *node; + + assert (parser->lex_from_list == NULL); + + /* Copy list, eliminating any space tokens. */ + parser->lex_from_list = _token_list_create (parser); + + for (node = list->head; node; node = node->next) { + if (node->token->type == SPACE) + continue; + _token_list_append (parser->lex_from_list, node->token); + } + + talloc_free (list); + + parser->lex_from_node = parser->lex_from_list->head; + + /* It's possible the list consisted of nothing but whitespace. */ + if (parser->lex_from_node == NULL) { + talloc_free (parser->lex_from_list); + parser->lex_from_list = NULL; + } +} + +static void +_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, + int condition) +{ + skip_type_t current = SKIP_NO_SKIP; + skip_node_t *node; + + if (parser->skip_stack) + current = parser->skip_stack->type; + + node = xtalloc (parser, skip_node_t); + node->loc = *loc; + + if (current == SKIP_NO_SKIP) { + if (condition) + node->type = SKIP_NO_SKIP; + else + node->type = SKIP_TO_ELSE; + } else { + node->type = SKIP_TO_ENDIF; + } + + node->next = parser->skip_stack; + parser->skip_stack = node; +} + +static void +_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, + const char *type, int condition) +{ + if (parser->skip_stack == NULL) { + glcpp_error (loc, parser, "%s without #if\n", type); + return; + } + + if (parser->skip_stack->type == SKIP_TO_ELSE) { + if (condition) + parser->skip_stack->type = SKIP_NO_SKIP; + } else { + parser->skip_stack->type = SKIP_TO_ENDIF; + } +} + +static void +_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc) +{ + skip_node_t *node; + + if (parser->skip_stack == NULL) { + glcpp_error (loc, parser, "#endif without #if\n"); + return; + } + + node = parser->skip_stack; + parser->skip_stack = node->next; + talloc_free (node); +} + diff --git a/src/glsl/glcpp/glcpp-parse.h b/src/glsl/glcpp/glcpp-parse.h new file mode 100644 index 00000000000..6365068ad0c --- /dev/null +++ b/src/glsl/glcpp/glcpp-parse.h @@ -0,0 +1,100 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + COMMA_FINAL = 258, + DEFINED = 259, + ELIF_EXPANDED = 260, + HASH = 261, + HASH_DEFINE_FUNC = 262, + HASH_DEFINE_OBJ = 263, + HASH_ELIF = 264, + HASH_ELSE = 265, + HASH_ENDIF = 266, + HASH_IF = 267, + HASH_IFDEF = 268, + HASH_IFNDEF = 269, + HASH_UNDEF = 270, + IDENTIFIER = 271, + IF_EXPANDED = 272, + INTEGER = 273, + INTEGER_STRING = 274, + NEWLINE = 275, + OTHER = 276, + PLACEHOLDER = 277, + SPACE = 278, + PASTE = 279, + OR = 280, + AND = 281, + NOT_EQUAL = 282, + EQUAL = 283, + GREATER_OR_EQUAL = 284, + LESS_OR_EQUAL = 285, + RIGHT_SHIFT = 286, + LEFT_SHIFT = 287, + UNARY = 288 + }; +#endif + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + + -- cgit v1.2.3 From a6c7606ab6e2ba8b4fc253e93a83ca2f18a874b4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 13:42:36 -0700 Subject: glsl2: Unmark unwritten varyings as varying. This fixes an assertion failure in ir_to_mesa, and the varying won't take up varying space. --- src/glsl/linker.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e7bc7000290..ec3cc01d404 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1132,6 +1132,7 @@ assign_varying_locations(gl_shader *producer, gl_shader *consumer) * by the previous stage. */ var->shader_in = (var->location != -1); + var->mode = ir_var_auto; } } -- cgit v1.2.3 From b706283c79de41caf775b0bb15b3c849932f2574 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 13:52:23 -0700 Subject: glsl2: Fail linking where the FS reads a varying that the VS doesn't write. Fixes: glsl1-varying read but not written glsl1-varying var mismatch --- src/glsl/linker.cpp | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index ec3cc01d404..fa4fb493f22 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1061,7 +1061,8 @@ assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index void -assign_varying_locations(gl_shader *producer, gl_shader *consumer) +assign_varying_locations(struct gl_shader_program *prog, + gl_shader *producer, gl_shader *consumer) { /* FINISHME: Set dynamically when geometry shader support is added. */ unsigned output_index = VERT_RESULT_VAR0; @@ -1128,11 +1129,32 @@ assign_varying_locations(gl_shader *producer, gl_shader *consumer) if ((var == NULL) || (var->mode != ir_var_in)) continue; - /* An 'in' variable is only really a shader input if its value is written - * by the previous stage. - */ - var->shader_in = (var->location != -1); - var->mode = ir_var_auto; + if (var->location == -1) { + if (prog->Version <= 120) { + /* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec: + * + * Only those varying variables used (i.e. read) in + * the fragment shader executable must be written to + * by the vertex shader executable; declaring + * superfluous varying variables in a vertex shader is + * permissible. + * + * We interpret this text as meaning that the VS must + * write the variable for the FS to read it. See + * "glsl1-varying read but not written" in piglit. + */ + + linker_error_printf(prog, "fragment shader varying %s not written " + "by vertex shader\n.", var->name); + prog->LinkStatus = false; + } + + /* An 'in' variable is only really a shader input if its + * value is written by the previous stage. + */ + var->shader_in = false; + var->mode = ir_var_auto; + } } } @@ -1294,7 +1316,8 @@ link_shaders(struct gl_shader_program *prog) goto done; for (unsigned i = 1; i < prog->_NumLinkedShaders; i++) - assign_varying_locations(prog->_LinkedShaders[i - 1], + assign_varying_locations(prog, + prog->_LinkedShaders[i - 1], prog->_LinkedShaders[i]); /* FINISHME: Assign fragment shader output locations. */ -- cgit v1.2.3 From f50f06552eb1e4af27d6fe99c381eac6a0a4ea0f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 30 Jun 2010 17:30:03 -0700 Subject: glsl2: Parser support for GL_ARB_fragment_coord_conventions --- src/glsl/ast.h | 6 + src/glsl/glsl_lexer.cpp | 1028 +++++++-------- src/glsl/glsl_lexer.lpp | 10 + src/glsl/glsl_parser.cpp | 2613 ++++++++++++++++++++------------------- src/glsl/glsl_parser.h | 83 +- src/glsl/glsl_parser.ypp | 61 +- src/glsl/glsl_parser_extras.cpp | 7 + src/glsl/glsl_parser_extras.h | 2 + 8 files changed, 2009 insertions(+), 1801 deletions(-) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index adb5fb11d47..655054ff6fa 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -302,6 +302,12 @@ struct ast_type_qualifier { unsigned smooth:1; unsigned flat:1; unsigned noperspective:1; + + /** \name Layout qualifiers for GL_ARB_fragment_coord_conventions */ + /*@{*/ + unsigned origin_upper_left:1; + unsigned pixel_center_integer:1; + /*@}*/ }; class ast_struct_specifier : public ast_node { diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp index e3e89195b2c..ecb4b857bbd 100644 --- a/src/glsl/glsl_lexer.cpp +++ b/src/glsl/glsl_lexer.cpp @@ -358,8 +358,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 145 -#define YY_END_OF_BUFFER 146 +#define YY_NUM_RULES 146 +#define YY_END_OF_BUFFER 147 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -367,65 +367,66 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[519] = +static yyconst flex_int16_t yy_accept[524] = { 0, - 0, 0, 9, 9, 146, 144, 1, 14, 144, 144, - 144, 144, 144, 144, 144, 144, 89, 87, 144, 144, - 144, 143, 144, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 144, 1, 144, 84, 145, 9, 13, - 145, 12, 10, 11, 1, 73, 80, 74, 83, 77, - 68, 79, 69, 86, 91, 78, 92, 89, 0, 0, - 0, 87, 0, 70, 72, 71, 0, 143, 76, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 22, 143, 143, 143, 143, 143, 143, 143, 143, 143, - - 143, 143, 143, 143, 26, 50, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 85, 75, 1, 0, 0, 2, 0, - 0, 0, 0, 9, 8, 12, 11, 0, 91, 90, - 0, 92, 0, 93, 88, 81, 82, 96, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 25, 143, 143, - 143, 143, 143, 143, 143, 143, 19, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 51, 143, 143, 143, - - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 0, 0, 0, 0, 8, 0, 91, 0, 90, 0, - 92, 93, 143, 17, 143, 143, 136, 143, 143, 143, - 143, 143, 143, 143, 143, 24, 99, 143, 143, 143, - 57, 143, 143, 104, 118, 143, 143, 143, 143, 143, - 143, 143, 143, 115, 139, 38, 39, 40, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 102, 94, 143, 143, 143, - 143, 143, 143, 35, 36, 37, 67, 143, 143, 0, - - 0, 0, 0, 0, 90, 143, 20, 29, 30, 31, - 143, 97, 16, 143, 143, 143, 143, 126, 127, 128, - 143, 95, 119, 18, 129, 130, 131, 141, 123, 124, - 125, 143, 52, 121, 143, 143, 32, 33, 34, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 116, 143, 143, 143, 143, 143, 143, 143, - 143, 98, 143, 138, 143, 143, 23, 0, 0, 0, - 0, 143, 143, 143, 143, 143, 117, 112, 107, 143, - 143, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 143, 143, 143, 143, 122, 103, 143, 110, 28, 143, - - 135, 58, 111, 66, 105, 143, 143, 143, 143, 143, - 143, 0, 0, 0, 0, 143, 143, 143, 106, 27, - 143, 143, 143, 140, 143, 143, 143, 143, 143, 143, - 100, 53, 143, 54, 143, 0, 0, 0, 7, 0, - 143, 55, 21, 113, 143, 143, 143, 108, 143, 143, - 143, 143, 143, 143, 101, 120, 109, 0, 0, 6, - 0, 0, 0, 3, 15, 114, 56, 137, 143, 142, - 60, 61, 62, 143, 0, 0, 0, 0, 143, 143, - 143, 143, 143, 143, 4, 0, 5, 0, 0, 0, - 143, 143, 143, 143, 143, 63, 0, 143, 143, 143, - - 143, 143, 59, 143, 132, 143, 133, 143, 143, 143, - 64, 143, 65, 143, 143, 143, 134, 0 + 0, 0, 9, 9, 147, 145, 1, 14, 145, 145, + 145, 145, 145, 145, 145, 145, 90, 88, 145, 145, + 145, 144, 145, 144, 144, 144, 144, 144, 144, 144, + 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, + 144, 144, 144, 145, 1, 145, 85, 146, 9, 13, + 146, 12, 10, 11, 1, 74, 81, 75, 84, 78, + 69, 80, 70, 87, 92, 79, 93, 90, 0, 0, + 0, 88, 0, 71, 73, 72, 0, 144, 77, 144, + 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, + 22, 144, 144, 144, 144, 144, 144, 144, 144, 144, + + 144, 144, 144, 144, 26, 50, 144, 144, 144, 144, + 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, + 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, + 144, 144, 144, 144, 86, 76, 1, 0, 0, 2, + 0, 0, 0, 0, 9, 8, 12, 11, 0, 92, + 91, 0, 93, 0, 94, 89, 82, 83, 97, 144, + 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, + 144, 144, 144, 144, 144, 144, 144, 144, 25, 144, + 144, 144, 144, 144, 144, 144, 144, 19, 144, 144, + 144, 144, 144, 144, 144, 144, 144, 144, 51, 144, + + 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, + 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, + 144, 144, 0, 0, 0, 0, 8, 0, 92, 0, + 91, 0, 93, 94, 144, 17, 144, 144, 137, 144, + 144, 144, 144, 144, 144, 144, 144, 24, 100, 144, + 144, 144, 57, 144, 144, 105, 119, 144, 144, 144, + 144, 144, 144, 144, 144, 144, 116, 140, 38, 39, + 40, 144, 144, 144, 144, 144, 144, 144, 144, 144, + 144, 144, 144, 144, 144, 144, 144, 144, 103, 95, + 144, 144, 144, 144, 144, 144, 35, 36, 37, 67, + + 144, 144, 0, 0, 0, 0, 0, 91, 144, 20, + 29, 30, 31, 144, 98, 16, 144, 144, 144, 144, + 127, 128, 129, 144, 96, 120, 18, 130, 131, 132, + 142, 124, 125, 126, 144, 52, 122, 144, 144, 32, + 33, 34, 144, 144, 144, 144, 144, 144, 144, 144, + 144, 144, 144, 144, 144, 144, 117, 144, 144, 144, + 144, 144, 144, 144, 144, 99, 144, 139, 144, 144, + 23, 0, 0, 0, 0, 144, 144, 144, 144, 144, + 118, 113, 108, 144, 144, 68, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 144, 144, 144, 144, 123, + + 104, 144, 111, 28, 144, 136, 58, 112, 66, 106, + 144, 144, 144, 144, 144, 144, 0, 0, 0, 0, + 144, 144, 144, 107, 27, 144, 144, 144, 141, 144, + 144, 144, 144, 144, 144, 101, 53, 144, 54, 144, + 0, 0, 0, 7, 0, 144, 55, 21, 114, 144, + 144, 144, 109, 144, 144, 144, 144, 144, 144, 102, + 121, 110, 0, 0, 6, 0, 0, 0, 3, 15, + 115, 56, 138, 144, 143, 60, 61, 62, 144, 0, + 0, 0, 0, 144, 144, 144, 144, 144, 144, 4, + 0, 5, 0, 0, 0, 144, 144, 144, 144, 144, + + 63, 0, 144, 144, 144, 144, 144, 59, 144, 133, + 144, 134, 144, 144, 144, 64, 144, 65, 144, 144, + 144, 135, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -470,133 +471,135 @@ static yyconst flex_int32_t yy_meta[60] = 11, 11, 11, 11, 11, 12, 11, 11, 1 } ; -static yyconst flex_int16_t yy_base[538] = +static yyconst flex_int16_t yy_base[543] = { 0, - 0, 58, 81, 0, 809, 810, 59, 810, 785, 784, - 54, 783, 55, 56, 54, 782, 129, 130, 53, 781, - 127, 0, 769, 101, 106, 126, 116, 128, 143, 754, - 144, 136, 753, 128, 145, 747, 142, 760, 159, 165, - 149, 164, 756, 149, 214, 207, 774, 810, 215, 810, - 783, 209, 810, 0, 228, 810, 810, 810, 810, 810, - 810, 810, 810, 810, 205, 810, 208, 133, 223, 171, - 0, 226, 772, 810, 810, 810, 771, 0, 810, 747, - 740, 743, 751, 750, 737, 740, 751, 738, 744, 732, - 729, 742, 729, 726, 726, 732, 720, 205, 725, 735, - - 721, 727, 730, 731, 0, 215, 730, 166, 716, 729, - 720, 200, 713, 727, 724, 726, 709, 714, 711, 700, - 709, 207, 713, 709, 711, 700, 703, 188, 708, 700, - 712, 223, 705, 810, 810, 268, 256, 273, 810, 691, - 703, 695, 705, 269, 0, 263, 0, 274, 810, 258, - 278, 810, 314, 280, 0, 810, 810, 0, 693, 697, - 706, 703, 687, 686, 686, 241, 701, 698, 698, 696, - 693, 685, 691, 678, 689, 675, 691, 0, 688, 676, - 683, 680, 684, 677, 666, 665, 678, 681, 678, 673, - 664, 286, 669, 672, 663, 670, 659, 663, 669, 660, - - 651, 654, 652, 662, 652, 647, 645, 645, 647, 644, - 655, 654, 259, 649, 644, 633, 297, 651, 653, 642, - 634, 638, 649, 633, 0, 321, 313, 306, 810, 329, - 340, 810, 639, 0, 637, 338, 0, 630, 628, 626, - 634, 623, 640, 629, 341, 0, 0, 623, 633, 633, - 0, 618, 344, 0, 0, 620, 347, 621, 615, 614, - 615, 614, 350, 0, 0, 607, 606, 605, 607, 608, - 613, 607, 603, 616, 611, 610, 602, 606, 598, 601, - 596, 604, 609, 608, 599, 0, 0, 605, 594, 594, - 599, 598, 595, 0, 0, 0, 0, 585, 597, 596, - - 595, 592, 581, 356, 367, 595, 0, 0, 0, 0, - 582, 0, 0, 582, 583, 577, 587, 0, 0, 0, - 578, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 585, 0, 0, 583, 579, 0, 0, 0, 365, - 368, 371, 575, 571, 576, 567, 565, 578, 564, 577, - 566, 573, 0, 571, 568, 572, 556, 565, 571, 566, - 554, 0, 556, 0, 555, 558, 0, 553, 597, 552, - 554, 543, 552, 541, 541, 554, 0, 556, 0, 548, - 547, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 529, 542, 529, 526, 0, 0, 531, 0, 0, 522, - - 0, 0, 0, 0, 0, 519, 521, 514, 516, 513, - 505, 498, 395, 513, 499, 494, 506, 504, 0, 0, - 493, 497, 483, 0, 482, 470, 467, 452, 375, 456, - 0, 0, 439, 0, 433, 428, 391, 323, 810, 423, - 430, 0, 0, 0, 429, 415, 427, 0, 428, 417, - 436, 435, 434, 407, 0, 0, 0, 411, 402, 810, - 415, 0, 396, 810, 0, 0, 0, 0, 406, 0, - 425, 371, 418, 412, 399, 417, 419, 423, 402, 402, - 404, 400, 402, 384, 810, 425, 810, 437, 0, 433, - 354, 371, 363, 360, 342, 0, 435, 313, 283, 267, - - 273, 256, 0, 258, 268, 248, 0, 239, 213, 195, - 0, 206, 0, 168, 32, 11, 0, 810, 469, 473, - 480, 487, 492, 498, 504, 506, 516, 525, 529, 533, - 539, 550, 556, 558, 567, 578, 580 + 0, 58, 81, 0, 814, 815, 59, 815, 790, 789, + 54, 788, 55, 56, 54, 787, 129, 130, 53, 786, + 127, 0, 774, 101, 106, 126, 116, 128, 143, 759, + 144, 136, 132, 142, 147, 753, 154, 766, 157, 163, + 159, 176, 762, 149, 212, 191, 780, 815, 215, 815, + 789, 232, 815, 0, 219, 815, 815, 815, 815, 815, + 815, 815, 815, 815, 198, 815, 203, 200, 216, 224, + 0, 229, 778, 815, 815, 815, 777, 0, 815, 753, + 746, 749, 757, 756, 743, 746, 757, 744, 750, 738, + 735, 748, 735, 732, 732, 738, 726, 218, 731, 741, + + 727, 733, 736, 737, 0, 213, 736, 717, 216, 721, + 734, 725, 211, 718, 732, 729, 731, 714, 719, 716, + 705, 714, 224, 718, 714, 716, 705, 708, 221, 713, + 705, 717, 230, 710, 815, 815, 274, 267, 279, 815, + 696, 708, 700, 710, 275, 0, 269, 0, 280, 815, + 264, 284, 815, 282, 297, 0, 815, 815, 0, 698, + 702, 711, 708, 692, 691, 691, 258, 706, 703, 703, + 701, 698, 690, 696, 683, 694, 680, 696, 0, 693, + 681, 688, 685, 689, 682, 671, 670, 683, 686, 683, + 671, 677, 668, 297, 673, 676, 667, 674, 663, 667, + + 673, 664, 655, 658, 656, 666, 656, 651, 649, 649, + 651, 648, 659, 658, 271, 653, 648, 637, 313, 655, + 657, 646, 638, 642, 653, 637, 0, 324, 324, 312, + 815, 331, 344, 815, 643, 0, 641, 340, 0, 634, + 632, 630, 638, 627, 644, 633, 343, 0, 0, 627, + 637, 637, 0, 622, 349, 0, 0, 624, 352, 625, + 619, 618, 619, 618, 358, 614, 0, 0, 610, 609, + 608, 610, 611, 616, 610, 606, 619, 614, 613, 605, + 609, 601, 604, 599, 607, 612, 611, 602, 0, 0, + 608, 597, 597, 602, 601, 598, 0, 0, 0, 0, + + 588, 600, 599, 598, 595, 584, 363, 361, 598, 0, + 0, 0, 0, 585, 0, 0, 585, 586, 580, 590, + 0, 0, 0, 581, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 588, 0, 0, 586, 582, 0, + 0, 0, 572, 369, 375, 378, 577, 573, 578, 569, + 567, 580, 566, 579, 568, 575, 0, 573, 570, 574, + 558, 567, 573, 568, 556, 0, 558, 0, 557, 560, + 0, 555, 599, 554, 556, 545, 554, 543, 543, 556, + 0, 551, 0, 550, 546, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 531, 544, 531, 528, 0, + + 0, 532, 0, 0, 524, 0, 0, 0, 0, 0, + 512, 523, 512, 518, 512, 507, 500, 395, 515, 501, + 495, 508, 502, 0, 0, 492, 496, 475, 0, 475, + 470, 464, 450, 390, 441, 0, 0, 437, 0, 435, + 430, 386, 360, 815, 425, 432, 0, 0, 0, 431, + 417, 429, 0, 430, 419, 438, 437, 436, 409, 0, + 0, 0, 413, 415, 815, 418, 0, 396, 815, 0, + 0, 0, 0, 402, 0, 420, 371, 420, 414, 402, + 420, 422, 424, 405, 405, 407, 403, 389, 369, 815, + 428, 815, 441, 0, 436, 350, 365, 315, 301, 295, + + 0, 438, 288, 287, 268, 279, 253, 0, 191, 197, + 177, 0, 167, 159, 141, 0, 131, 0, 125, 32, + 11, 0, 815, 472, 476, 483, 490, 495, 501, 507, + 509, 519, 528, 532, 536, 542, 553, 559, 561, 570, + 581, 583 } ; -static yyconst flex_int16_t yy_def[538] = +static yyconst flex_int16_t yy_def[543] = { 0, - 518, 1, 518, 3, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 519, 518, 518, - 518, 520, 518, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 521, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 522, 518, 523, 17, 524, 525, - 526, 519, 518, 518, 518, 518, 518, 520, 518, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 527, 518, 521, 528, 518, 523, - 529, 518, 518, 525, 526, 518, 518, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 518, 518, 518, 518, 527, 518, 528, 530, 518, 518, - 529, 518, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 518, - - 518, 518, 518, 518, 530, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 518, 518, 518, - 518, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 518, 518, 518, 518, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 518, 531, 532, 518, 518, - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 518, 533, 518, - 518, 534, 532, 518, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 518, 535, 536, 534, 520, 520, - 520, 520, 520, 520, 518, 518, 518, 518, 537, 536, - 520, 520, 520, 520, 520, 520, 537, 520, 520, 520, - - 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, - 520, 520, 520, 520, 520, 520, 520, 0, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518 + 523, 1, 523, 3, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 524, 523, 523, + 523, 525, 523, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 526, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 527, 523, 528, 17, 529, 530, + 531, 524, 523, 523, 523, 523, 523, 525, 523, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 532, 523, 526, 533, 523, + 528, 534, 523, 523, 530, 531, 523, 523, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 523, 523, 523, 523, 532, 523, 533, 535, + 523, 523, 534, 523, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + + 525, 525, 523, 523, 523, 523, 523, 535, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 523, 523, 523, 523, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 523, 523, 523, 523, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 523, 536, 537, 523, 523, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 523, 538, 523, 523, 539, 537, 523, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 523, + 540, 541, 539, 525, 525, 525, 525, 525, 525, 523, + 523, 523, 523, 542, 541, 525, 525, 525, 525, 525, + + 525, 542, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 0, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523 } ; -static yyconst flex_int16_t yy_nxt[870] = +static yyconst flex_int16_t yy_nxt[875] = { 0, 6, 7, 8, 7, 9, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 18, 18, 18, 18, @@ -604,8 +607,8 @@ static yyconst flex_int16_t yy_nxt[870] = 22, 22, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 22, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 22, 22, 22, 44, 45, - 55, 58, 55, 46, 61, 517, 63, 65, 65, 65, - 65, 65, 65, 65, 73, 74, 59, 62, 64, 516, + 55, 58, 55, 46, 61, 522, 63, 65, 65, 65, + 65, 65, 65, 65, 73, 74, 59, 62, 64, 521, 47, 48, 49, 50, 49, 48, 48, 48, 48, 48, 48, 48, 48, 51, 48, 52, 52, 52, 52, 52, @@ -615,87 +618,88 @@ static yyconst flex_int16_t yy_nxt[870] = 54, 54, 54, 54, 54, 54, 54, 54, 54, 48, 67, 67, 68, 68, 68, 68, 68, 68, 69, 76, 77, 80, 81, 82, 89, 83, 70, 70, 90, 84, - 85, 71, 109, 91, 86, 518, 110, 70, 70, 92, - 87, 134, 93, 88, 94, 105, 114, 96, 102, 111, - 153, 153, 106, 95, 71, 97, 103, 98, 518, 107, - 99, 115, 112, 118, 116, 128, 100, 104, 130, 129, - - 119, 120, 131, 124, 121, 515, 125, 135, 138, 139, - 122, 132, 190, 123, 126, 136, 144, 55, 144, 137, - 191, 127, 146, 146, 146, 146, 146, 146, 146, 55, - 213, 55, 148, 149, 67, 151, 152, 67, 214, 176, - 514, 206, 195, 148, 149, 140, 151, 152, 196, 513, - 70, 141, 177, 70, 512, 142, 207, 138, 139, 184, - 143, 70, 185, 186, 70, 218, 187, 219, 188, 136, - 144, 55, 144, 137, 138, 139, 146, 146, 146, 146, - 146, 146, 146, 226, 226, 228, 229, 230, 230, 518, - 518, 240, 241, 511, 140, 510, 228, 229, 289, 509, - - 141, 266, 267, 268, 142, 508, 290, 507, 232, 143, - 506, 140, 294, 295, 296, 304, 304, 141, 505, 232, - 504, 142, 518, 518, 459, 460, 143, 154, 154, 154, - 154, 154, 154, 154, 227, 227, 227, 227, 227, 227, - 227, 149, 231, 231, 231, 231, 231, 231, 231, 518, - 518, 503, 149, 308, 309, 310, 318, 319, 320, 325, - 326, 327, 329, 330, 331, 337, 338, 339, 152, 305, - 305, 305, 305, 305, 305, 305, 518, 518, 502, 152, - 382, 383, 384, 385, 386, 387, 388, 389, 390, 451, - 452, 453, 459, 460, 501, 229, 413, 459, 460, 500, - - 454, 481, 482, 459, 460, 499, 229, 498, 437, 438, - 438, 438, 438, 438, 438, 476, 459, 460, 486, 487, - 486, 487, 496, 462, 459, 460, 486, 487, 461, 461, - 461, 461, 461, 461, 486, 487, 486, 487, 486, 487, - 495, 494, 493, 492, 491, 485, 462, 484, 483, 489, - 488, 488, 488, 488, 488, 488, 480, 479, 475, 474, - 473, 472, 471, 470, 469, 468, 467, 466, 465, 464, - 458, 457, 489, 72, 72, 72, 456, 72, 78, 78, - 78, 78, 78, 78, 78, 147, 147, 147, 147, 147, - 147, 147, 65, 65, 455, 65, 65, 150, 150, 450, - - 150, 150, 69, 69, 69, 449, 69, 154, 448, 154, - 154, 155, 155, 155, 155, 155, 225, 225, 447, 225, - 225, 225, 225, 225, 225, 225, 225, 225, 227, 446, - 227, 227, 231, 445, 231, 231, 305, 444, 305, 305, - 461, 461, 443, 442, 461, 441, 440, 439, 436, 435, - 461, 463, 463, 434, 433, 463, 463, 477, 477, 432, - 431, 477, 477, 478, 478, 478, 478, 478, 488, 488, - 430, 429, 488, 428, 427, 426, 425, 424, 488, 490, - 490, 423, 422, 490, 490, 497, 497, 497, 497, 497, - 421, 420, 419, 418, 417, 416, 415, 414, 413, 412, - - 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, - 401, 400, 399, 398, 397, 396, 395, 394, 393, 392, - 391, 381, 380, 379, 378, 377, 376, 375, 374, 373, - 372, 371, 370, 369, 368, 367, 366, 365, 364, 363, - 362, 361, 360, 359, 358, 357, 356, 355, 354, 353, - 352, 351, 350, 349, 348, 347, 346, 345, 344, 343, - 342, 341, 340, 336, 335, 334, 333, 332, 328, 324, - 323, 322, 321, 317, 316, 315, 314, 313, 312, 311, - 307, 306, 303, 302, 301, 300, 299, 298, 297, 293, - 292, 291, 288, 287, 286, 285, 284, 283, 282, 281, - - 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, - 270, 269, 265, 264, 263, 262, 261, 260, 259, 258, - 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, - 247, 246, 245, 244, 243, 242, 239, 238, 237, 236, - 235, 234, 233, 224, 223, 222, 221, 220, 217, 216, - 215, 212, 211, 210, 209, 208, 205, 204, 203, 202, - 201, 200, 199, 198, 197, 194, 193, 192, 189, 183, - 182, 181, 180, 179, 178, 175, 174, 173, 172, 171, - 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, - 160, 159, 158, 157, 156, 145, 75, 133, 117, 113, - - 108, 101, 79, 75, 66, 60, 57, 56, 518, 5, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518 + 85, 71, 520, 91, 86, 519, 108, 70, 70, 92, + 87, 135, 93, 88, 94, 105, 110, 96, 102, 109, + 111, 112, 106, 95, 71, 97, 103, 98, 115, 107, + 99, 119, 139, 140, 113, 518, 100, 104, 120, 121, + + 517, 125, 122, 116, 126, 129, 117, 136, 123, 130, + 131, 124, 127, 137, 132, 55, 145, 138, 145, 128, + 55, 516, 55, 133, 515, 149, 150, 67, 514, 141, + 152, 153, 523, 154, 154, 142, 149, 150, 513, 143, + 67, 152, 153, 70, 144, 147, 147, 147, 147, 147, + 147, 147, 177, 197, 70, 523, 70, 185, 208, 198, + 186, 187, 192, 215, 188, 178, 189, 70, 139, 140, + 193, 216, 220, 209, 221, 137, 145, 55, 145, 138, + 139, 140, 147, 147, 147, 147, 147, 147, 147, 228, + 228, 230, 231, 232, 232, 155, 155, 155, 155, 155, + + 155, 155, 230, 231, 512, 141, 523, 523, 242, 243, + 292, 142, 269, 270, 271, 143, 511, 141, 293, 510, + 144, 307, 307, 142, 509, 234, 508, 143, 297, 298, + 299, 507, 144, 523, 523, 506, 234, 229, 229, 229, + 229, 229, 229, 229, 233, 233, 233, 233, 233, 233, + 233, 505, 150, 523, 523, 311, 312, 313, 321, 322, + 323, 464, 465, 150, 328, 329, 330, 332, 333, 334, + 523, 523, 153, 340, 341, 342, 308, 308, 308, 308, + 308, 308, 308, 153, 387, 388, 389, 464, 465, 231, + 390, 391, 392, 393, 394, 395, 418, 464, 465, 504, + + 231, 486, 487, 503, 456, 457, 458, 501, 442, 443, + 443, 443, 443, 443, 443, 459, 464, 465, 467, 464, + 465, 491, 492, 491, 492, 464, 465, 500, 481, 491, + 492, 466, 466, 466, 466, 466, 466, 491, 492, 491, + 492, 467, 491, 492, 499, 498, 497, 496, 490, 489, + 488, 485, 494, 484, 493, 493, 493, 493, 493, 493, + 480, 479, 478, 477, 476, 475, 474, 473, 472, 471, + 470, 469, 463, 462, 461, 494, 72, 72, 72, 460, + 72, 78, 78, 78, 78, 78, 78, 78, 148, 148, + 148, 148, 148, 148, 148, 65, 65, 455, 65, 65, + + 151, 151, 454, 151, 151, 69, 69, 69, 453, 69, + 155, 452, 155, 155, 156, 156, 156, 156, 156, 227, + 227, 451, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 229, 450, 229, 229, 233, 449, 233, 233, 308, + 448, 308, 308, 466, 466, 447, 446, 466, 445, 444, + 441, 440, 439, 466, 468, 468, 438, 437, 468, 468, + 482, 482, 436, 435, 482, 482, 483, 483, 483, 483, + 483, 493, 493, 434, 433, 493, 432, 431, 430, 429, + 428, 493, 495, 495, 427, 426, 495, 495, 502, 502, + 502, 502, 502, 425, 424, 423, 422, 421, 420, 419, + + 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, + 408, 407, 406, 405, 404, 403, 402, 401, 400, 399, + 398, 397, 396, 386, 385, 384, 383, 382, 381, 380, + 379, 378, 377, 376, 375, 374, 373, 372, 371, 370, + 369, 368, 367, 366, 365, 364, 363, 362, 361, 360, + 359, 358, 357, 356, 355, 354, 353, 352, 351, 350, + 349, 348, 347, 346, 345, 344, 343, 339, 338, 337, + 336, 335, 331, 327, 326, 325, 324, 320, 319, 318, + 317, 316, 315, 314, 310, 309, 306, 305, 304, 303, + 302, 301, 300, 296, 295, 294, 291, 290, 289, 288, + + 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, + 277, 276, 275, 274, 273, 272, 268, 267, 266, 265, + 264, 263, 262, 261, 260, 259, 258, 257, 256, 255, + 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, + 244, 241, 240, 239, 238, 237, 236, 235, 226, 225, + 224, 223, 222, 219, 218, 217, 214, 213, 212, 211, + 210, 207, 206, 205, 204, 203, 202, 201, 200, 199, + 196, 195, 194, 191, 190, 184, 183, 182, 181, 180, + 179, 176, 175, 174, 173, 172, 171, 170, 169, 168, + 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, + + 157, 146, 75, 134, 118, 114, 101, 79, 75, 66, + 60, 57, 56, 523, 5, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523 } ; -static yyconst flex_int16_t yy_chk[870] = +static yyconst flex_int16_t yy_chk[875] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -703,8 +707,8 @@ static yyconst flex_int16_t yy_chk[870] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 7, 11, 7, 2, 13, 516, 14, 15, 15, 15, - 15, 15, 15, 15, 19, 19, 11, 13, 14, 515, + 7, 11, 7, 2, 13, 521, 14, 15, 15, 15, + 15, 15, 15, 15, 19, 19, 11, 13, 14, 520, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -714,84 +718,85 @@ static yyconst flex_int16_t yy_chk[870] = 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 17, 18, 17, 17, 17, 17, 17, 17, 17, 21, 21, 24, 24, 25, 27, 25, 17, 18, 27, 25, - 26, 17, 34, 27, 26, 68, 34, 17, 18, 27, - 26, 44, 28, 26, 28, 32, 37, 29, 31, 35, - 70, 70, 32, 28, 17, 29, 31, 29, 68, 32, - 29, 37, 35, 39, 37, 41, 29, 31, 42, 41, - - 39, 39, 42, 40, 39, 514, 40, 44, 46, 46, - 39, 42, 108, 39, 40, 45, 49, 45, 49, 45, - 108, 40, 52, 52, 52, 52, 52, 52, 52, 55, - 128, 55, 65, 65, 69, 67, 67, 72, 128, 98, - 512, 122, 112, 65, 65, 46, 67, 67, 112, 510, - 69, 46, 98, 72, 509, 46, 122, 137, 137, 106, - 46, 69, 106, 106, 72, 132, 106, 132, 106, 136, - 144, 136, 144, 136, 138, 138, 146, 146, 146, 146, - 146, 146, 146, 148, 148, 150, 150, 151, 151, 154, - 154, 166, 166, 508, 137, 506, 150, 150, 213, 505, - - 137, 192, 192, 192, 137, 504, 213, 502, 154, 137, - 501, 138, 217, 217, 217, 228, 228, 138, 500, 154, - 499, 138, 227, 227, 438, 438, 138, 153, 153, 153, - 153, 153, 153, 153, 226, 226, 226, 226, 226, 226, - 226, 227, 230, 230, 230, 230, 230, 230, 230, 231, - 231, 498, 227, 236, 236, 236, 245, 245, 245, 253, - 253, 253, 257, 257, 257, 263, 263, 263, 231, 304, - 304, 304, 304, 304, 304, 304, 305, 305, 495, 231, - 340, 340, 340, 341, 341, 341, 342, 342, 342, 429, - 429, 429, 437, 437, 494, 305, 413, 463, 463, 493, - - 429, 472, 472, 459, 459, 492, 305, 491, 413, 413, - 413, 413, 413, 413, 413, 459, 461, 461, 476, 476, - 477, 477, 484, 437, 478, 478, 486, 486, 461, 461, - 461, 461, 461, 461, 490, 490, 497, 497, 488, 488, - 483, 482, 481, 480, 479, 475, 437, 474, 473, 476, - 488, 488, 488, 488, 488, 488, 471, 469, 458, 454, - 453, 452, 451, 450, 449, 447, 446, 445, 441, 440, - 436, 435, 476, 519, 519, 519, 433, 519, 520, 520, - 520, 520, 520, 520, 520, 521, 521, 521, 521, 521, - 521, 521, 522, 522, 430, 522, 522, 523, 523, 428, - - 523, 523, 524, 524, 524, 427, 524, 525, 426, 525, - 525, 526, 526, 526, 526, 526, 527, 527, 425, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 528, 423, - 528, 528, 529, 422, 529, 529, 530, 421, 530, 530, - 531, 531, 418, 417, 531, 416, 415, 414, 412, 411, - 531, 532, 532, 410, 409, 532, 532, 533, 533, 408, - 407, 533, 533, 534, 534, 534, 534, 534, 535, 535, - 406, 400, 535, 397, 394, 393, 392, 391, 535, 536, - 536, 381, 380, 536, 536, 537, 537, 537, 537, 537, - 378, 376, 375, 374, 373, 372, 371, 370, 369, 368, - - 366, 365, 363, 361, 360, 359, 358, 357, 356, 355, - 354, 352, 351, 350, 349, 348, 347, 346, 345, 344, - 343, 336, 335, 332, 321, 317, 316, 315, 314, 311, - 306, 303, 302, 301, 300, 299, 298, 293, 292, 291, - 290, 289, 288, 285, 284, 283, 282, 281, 280, 279, - 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, - 268, 267, 266, 262, 261, 260, 259, 258, 256, 252, - 250, 249, 248, 244, 243, 242, 241, 240, 239, 238, - 235, 233, 224, 223, 222, 221, 220, 219, 218, 216, - 215, 214, 212, 211, 210, 209, 208, 207, 206, 205, - - 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, - 194, 193, 191, 190, 189, 188, 187, 186, 185, 184, - 183, 182, 181, 180, 179, 177, 176, 175, 174, 173, - 172, 171, 170, 169, 168, 167, 165, 164, 163, 162, - 161, 160, 159, 143, 142, 141, 140, 133, 131, 130, - 129, 127, 126, 125, 124, 123, 121, 120, 119, 118, - 117, 116, 115, 114, 113, 111, 110, 109, 107, 104, - 103, 102, 101, 100, 99, 97, 96, 95, 94, 93, - 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, - 82, 81, 80, 77, 73, 51, 47, 43, 38, 36, - - 33, 30, 23, 20, 16, 12, 10, 9, 5, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - 518, 518, 518, 518, 518, 518, 518, 518, 518 + 26, 17, 519, 27, 26, 517, 33, 17, 18, 27, + 26, 44, 28, 26, 28, 32, 34, 29, 31, 33, + 34, 35, 32, 28, 17, 29, 31, 29, 37, 32, + 29, 39, 46, 46, 35, 515, 29, 31, 39, 39, + + 514, 40, 39, 37, 40, 41, 37, 44, 39, 41, + 42, 39, 40, 45, 42, 45, 49, 45, 49, 40, + 55, 513, 55, 42, 511, 65, 65, 69, 510, 46, + 67, 67, 68, 70, 70, 46, 65, 65, 509, 46, + 72, 67, 67, 69, 46, 52, 52, 52, 52, 52, + 52, 52, 98, 113, 69, 68, 72, 106, 123, 113, + 106, 106, 109, 129, 106, 98, 106, 72, 138, 138, + 109, 129, 133, 123, 133, 137, 145, 137, 145, 137, + 139, 139, 147, 147, 147, 147, 147, 147, 147, 149, + 149, 151, 151, 152, 152, 154, 154, 154, 154, 154, + + 154, 154, 151, 151, 507, 138, 155, 155, 167, 167, + 215, 138, 194, 194, 194, 138, 506, 139, 215, 505, + 138, 230, 230, 139, 504, 155, 503, 139, 219, 219, + 219, 500, 139, 229, 229, 499, 155, 228, 228, 228, + 228, 228, 228, 228, 232, 232, 232, 232, 232, 232, + 232, 498, 229, 233, 233, 238, 238, 238, 247, 247, + 247, 443, 443, 229, 255, 255, 255, 259, 259, 259, + 308, 308, 233, 265, 265, 265, 307, 307, 307, 307, + 307, 307, 307, 233, 344, 344, 344, 442, 442, 308, + 345, 345, 345, 346, 346, 346, 418, 468, 468, 497, + + 308, 477, 477, 496, 434, 434, 434, 489, 418, 418, + 418, 418, 418, 418, 418, 434, 464, 464, 442, 466, + 466, 481, 481, 482, 482, 483, 483, 488, 464, 491, + 491, 466, 466, 466, 466, 466, 466, 495, 495, 502, + 502, 442, 493, 493, 487, 486, 485, 484, 480, 479, + 478, 476, 481, 474, 493, 493, 493, 493, 493, 493, + 463, 459, 458, 457, 456, 455, 454, 452, 451, 450, + 446, 445, 441, 440, 438, 481, 524, 524, 524, 435, + 524, 525, 525, 525, 525, 525, 525, 525, 526, 526, + 526, 526, 526, 526, 526, 527, 527, 433, 527, 527, + + 528, 528, 432, 528, 528, 529, 529, 529, 431, 529, + 530, 430, 530, 530, 531, 531, 531, 531, 531, 532, + 532, 428, 532, 532, 532, 532, 532, 532, 532, 532, + 532, 533, 427, 533, 533, 534, 426, 534, 534, 535, + 423, 535, 535, 536, 536, 422, 421, 536, 420, 419, + 417, 416, 415, 536, 537, 537, 414, 413, 537, 537, + 538, 538, 412, 411, 538, 538, 539, 539, 539, 539, + 539, 540, 540, 405, 402, 540, 399, 398, 397, 396, + 385, 540, 541, 541, 384, 382, 541, 541, 542, 542, + 542, 542, 542, 380, 379, 378, 377, 376, 375, 374, + + 373, 372, 370, 369, 367, 365, 364, 363, 362, 361, + 360, 359, 358, 356, 355, 354, 353, 352, 351, 350, + 349, 348, 347, 343, 339, 338, 335, 324, 320, 319, + 318, 317, 314, 309, 306, 305, 304, 303, 302, 301, + 296, 295, 294, 293, 292, 291, 288, 287, 286, 285, + 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, + 274, 273, 272, 271, 270, 269, 266, 264, 263, 262, + 261, 260, 258, 254, 252, 251, 250, 246, 245, 244, + 243, 242, 241, 240, 237, 235, 226, 225, 224, 223, + 222, 221, 220, 218, 217, 216, 214, 213, 212, 211, + + 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, + 200, 199, 198, 197, 196, 195, 193, 192, 191, 190, + 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, + 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, + 168, 166, 165, 164, 163, 162, 161, 160, 144, 143, + 142, 141, 134, 132, 131, 130, 128, 127, 126, 125, + 124, 122, 121, 120, 119, 118, 117, 116, 115, 114, + 112, 111, 110, 108, 107, 104, 103, 102, 101, 100, + 99, 97, 96, 95, 94, 93, 92, 91, 90, 89, + 88, 87, 86, 85, 84, 83, 82, 81, 80, 77, + + 73, 51, 47, 43, 38, 36, 30, 23, 20, 16, + 12, 10, 9, 5, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, + 523, 523, 523, 523 } ; /* The intent behind this definition is that it'll catch @@ -841,7 +846,7 @@ static yyconst flex_int16_t yy_chk[870] = #define YY_USER_INIT yylineno = 0; yycolumn = 0; -#line 845 "glsl_lexer.cpp" +#line 850 "glsl_lexer.cpp" #define INITIAL 0 #define PP 1 @@ -1090,7 +1095,7 @@ YY_DECL #line 56 "glsl_lexer.lpp" -#line 1094 "glsl_lexer.cpp" +#line 1099 "glsl_lexer.cpp" yylval = yylval_param; @@ -1148,13 +1153,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 519 ) + if ( yy_current_state >= 524 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 518 ); + while ( yy_current_state != 523 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1592,410 +1597,423 @@ return VOID; case 68: YY_RULE_SETUP #line 204 "glsl_lexer.lpp" -return INC_OP; +{ + if ((yyextra->language_version >= 140) + || (yyextra->ARB_fragment_coord_conventions_enable)){ + return LAYOUT_TOK; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } YY_BREAK case 69: YY_RULE_SETUP -#line 205 "glsl_lexer.lpp" -return DEC_OP; +#line 214 "glsl_lexer.lpp" +return INC_OP; YY_BREAK case 70: YY_RULE_SETUP -#line 206 "glsl_lexer.lpp" -return LE_OP; +#line 215 "glsl_lexer.lpp" +return DEC_OP; YY_BREAK case 71: YY_RULE_SETUP -#line 207 "glsl_lexer.lpp" -return GE_OP; +#line 216 "glsl_lexer.lpp" +return LE_OP; YY_BREAK case 72: YY_RULE_SETUP -#line 208 "glsl_lexer.lpp" -return EQ_OP; +#line 217 "glsl_lexer.lpp" +return GE_OP; YY_BREAK case 73: YY_RULE_SETUP -#line 209 "glsl_lexer.lpp" -return NE_OP; +#line 218 "glsl_lexer.lpp" +return EQ_OP; YY_BREAK case 74: YY_RULE_SETUP -#line 210 "glsl_lexer.lpp" -return AND_OP; +#line 219 "glsl_lexer.lpp" +return NE_OP; YY_BREAK case 75: YY_RULE_SETUP -#line 211 "glsl_lexer.lpp" -return OR_OP; +#line 220 "glsl_lexer.lpp" +return AND_OP; YY_BREAK case 76: YY_RULE_SETUP -#line 212 "glsl_lexer.lpp" -return XOR_OP; +#line 221 "glsl_lexer.lpp" +return OR_OP; YY_BREAK case 77: YY_RULE_SETUP -#line 214 "glsl_lexer.lpp" -return MUL_ASSIGN; +#line 222 "glsl_lexer.lpp" +return XOR_OP; YY_BREAK case 78: YY_RULE_SETUP -#line 215 "glsl_lexer.lpp" -return DIV_ASSIGN; +#line 224 "glsl_lexer.lpp" +return MUL_ASSIGN; YY_BREAK case 79: YY_RULE_SETUP -#line 216 "glsl_lexer.lpp" -return ADD_ASSIGN; +#line 225 "glsl_lexer.lpp" +return DIV_ASSIGN; YY_BREAK case 80: YY_RULE_SETUP -#line 217 "glsl_lexer.lpp" -return MOD_ASSIGN; +#line 226 "glsl_lexer.lpp" +return ADD_ASSIGN; YY_BREAK case 81: YY_RULE_SETUP -#line 218 "glsl_lexer.lpp" -return LEFT_ASSIGN; +#line 227 "glsl_lexer.lpp" +return MOD_ASSIGN; YY_BREAK case 82: YY_RULE_SETUP -#line 219 "glsl_lexer.lpp" -return RIGHT_ASSIGN; +#line 228 "glsl_lexer.lpp" +return LEFT_ASSIGN; YY_BREAK case 83: YY_RULE_SETUP -#line 220 "glsl_lexer.lpp" -return AND_ASSIGN; +#line 229 "glsl_lexer.lpp" +return RIGHT_ASSIGN; YY_BREAK case 84: YY_RULE_SETUP -#line 221 "glsl_lexer.lpp" -return XOR_ASSIGN; +#line 230 "glsl_lexer.lpp" +return AND_ASSIGN; YY_BREAK case 85: YY_RULE_SETUP -#line 222 "glsl_lexer.lpp" -return OR_ASSIGN; +#line 231 "glsl_lexer.lpp" +return XOR_ASSIGN; YY_BREAK case 86: YY_RULE_SETUP -#line 223 "glsl_lexer.lpp" -return SUB_ASSIGN; +#line 232 "glsl_lexer.lpp" +return OR_ASSIGN; YY_BREAK case 87: YY_RULE_SETUP -#line 225 "glsl_lexer.lpp" +#line 233 "glsl_lexer.lpp" +return SUB_ASSIGN; + YY_BREAK +case 88: +YY_RULE_SETUP +#line 235 "glsl_lexer.lpp" { yylval->n = strtol(yytext, NULL, 10); return INTCONSTANT; } YY_BREAK -case 88: +case 89: YY_RULE_SETUP -#line 229 "glsl_lexer.lpp" +#line 239 "glsl_lexer.lpp" { yylval->n = strtol(yytext + 2, NULL, 16); return INTCONSTANT; } YY_BREAK -case 89: +case 90: YY_RULE_SETUP -#line 233 "glsl_lexer.lpp" +#line 243 "glsl_lexer.lpp" { yylval->n = strtol(yytext, NULL, 8); return INTCONSTANT; } YY_BREAK -case 90: +case 91: YY_RULE_SETUP -#line 238 "glsl_lexer.lpp" +#line 248 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; } YY_BREAK -case 91: +case 92: YY_RULE_SETUP -#line 242 "glsl_lexer.lpp" +#line 252 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; } YY_BREAK -case 92: +case 93: YY_RULE_SETUP -#line 246 "glsl_lexer.lpp" +#line 256 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; } YY_BREAK -case 93: +case 94: YY_RULE_SETUP -#line 250 "glsl_lexer.lpp" +#line 260 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; } YY_BREAK -case 94: +case 95: YY_RULE_SETUP -#line 255 "glsl_lexer.lpp" +#line 265 "glsl_lexer.lpp" { yylval->n = 1; return BOOLCONSTANT; } YY_BREAK -case 95: +case 96: YY_RULE_SETUP -#line 259 "glsl_lexer.lpp" +#line 269 "glsl_lexer.lpp" { yylval->n = 0; return BOOLCONSTANT; } YY_BREAK /* Reserved words in GLSL 1.10. */ -case 96: +case 97: YY_RULE_SETUP -#line 266 "glsl_lexer.lpp" +#line 276 "glsl_lexer.lpp" return ASM; YY_BREAK -case 97: +case 98: YY_RULE_SETUP -#line 267 "glsl_lexer.lpp" +#line 277 "glsl_lexer.lpp" return CLASS; YY_BREAK -case 98: +case 99: YY_RULE_SETUP -#line 268 "glsl_lexer.lpp" +#line 278 "glsl_lexer.lpp" return UNION; YY_BREAK -case 99: +case 100: YY_RULE_SETUP -#line 269 "glsl_lexer.lpp" +#line 279 "glsl_lexer.lpp" return ENUM; YY_BREAK -case 100: +case 101: YY_RULE_SETUP -#line 270 "glsl_lexer.lpp" +#line 280 "glsl_lexer.lpp" return TYPEDEF; YY_BREAK -case 101: +case 102: YY_RULE_SETUP -#line 271 "glsl_lexer.lpp" +#line 281 "glsl_lexer.lpp" return TEMPLATE; YY_BREAK -case 102: +case 103: YY_RULE_SETUP -#line 272 "glsl_lexer.lpp" +#line 282 "glsl_lexer.lpp" return THIS; YY_BREAK -case 103: +case 104: YY_RULE_SETUP -#line 273 "glsl_lexer.lpp" +#line 283 "glsl_lexer.lpp" return PACKED; YY_BREAK -case 104: +case 105: YY_RULE_SETUP -#line 274 "glsl_lexer.lpp" +#line 284 "glsl_lexer.lpp" return GOTO; YY_BREAK -case 105: +case 106: YY_RULE_SETUP -#line 275 "glsl_lexer.lpp" +#line 285 "glsl_lexer.lpp" return SWITCH; YY_BREAK -case 106: +case 107: YY_RULE_SETUP -#line 276 "glsl_lexer.lpp" +#line 286 "glsl_lexer.lpp" return DEFAULT; YY_BREAK -case 107: +case 108: YY_RULE_SETUP -#line 277 "glsl_lexer.lpp" +#line 287 "glsl_lexer.lpp" return INLINE_TOK; YY_BREAK -case 108: +case 109: YY_RULE_SETUP -#line 278 "glsl_lexer.lpp" +#line 288 "glsl_lexer.lpp" return NOINLINE; YY_BREAK -case 109: +case 110: YY_RULE_SETUP -#line 279 "glsl_lexer.lpp" +#line 289 "glsl_lexer.lpp" return VOLATILE; YY_BREAK -case 110: +case 111: YY_RULE_SETUP -#line 280 "glsl_lexer.lpp" +#line 290 "glsl_lexer.lpp" return PUBLIC_TOK; YY_BREAK -case 111: +case 112: YY_RULE_SETUP -#line 281 "glsl_lexer.lpp" +#line 291 "glsl_lexer.lpp" return STATIC; YY_BREAK -case 112: +case 113: YY_RULE_SETUP -#line 282 "glsl_lexer.lpp" +#line 292 "glsl_lexer.lpp" return EXTERN; YY_BREAK -case 113: +case 114: YY_RULE_SETUP -#line 283 "glsl_lexer.lpp" +#line 293 "glsl_lexer.lpp" return EXTERNAL; YY_BREAK -case 114: +case 115: YY_RULE_SETUP -#line 284 "glsl_lexer.lpp" +#line 294 "glsl_lexer.lpp" return INTERFACE; YY_BREAK -case 115: +case 116: YY_RULE_SETUP -#line 285 "glsl_lexer.lpp" +#line 295 "glsl_lexer.lpp" return LONG; YY_BREAK -case 116: +case 117: YY_RULE_SETUP -#line 286 "glsl_lexer.lpp" +#line 296 "glsl_lexer.lpp" return SHORT; YY_BREAK -case 117: +case 118: YY_RULE_SETUP -#line 287 "glsl_lexer.lpp" +#line 297 "glsl_lexer.lpp" return DOUBLE; YY_BREAK -case 118: +case 119: YY_RULE_SETUP -#line 288 "glsl_lexer.lpp" +#line 298 "glsl_lexer.lpp" return HALF; YY_BREAK -case 119: +case 120: YY_RULE_SETUP -#line 289 "glsl_lexer.lpp" +#line 299 "glsl_lexer.lpp" return FIXED; YY_BREAK -case 120: +case 121: YY_RULE_SETUP -#line 290 "glsl_lexer.lpp" +#line 300 "glsl_lexer.lpp" return UNSIGNED; YY_BREAK -case 121: +case 122: YY_RULE_SETUP -#line 291 "glsl_lexer.lpp" +#line 301 "glsl_lexer.lpp" return INPUT; YY_BREAK -case 122: +case 123: YY_RULE_SETUP -#line 292 "glsl_lexer.lpp" +#line 302 "glsl_lexer.lpp" return OUTPUT; YY_BREAK -case 123: +case 124: YY_RULE_SETUP -#line 293 "glsl_lexer.lpp" +#line 303 "glsl_lexer.lpp" return HVEC2; YY_BREAK -case 124: +case 125: YY_RULE_SETUP -#line 294 "glsl_lexer.lpp" +#line 304 "glsl_lexer.lpp" return HVEC3; YY_BREAK -case 125: +case 126: YY_RULE_SETUP -#line 295 "glsl_lexer.lpp" +#line 305 "glsl_lexer.lpp" return HVEC4; YY_BREAK -case 126: +case 127: YY_RULE_SETUP -#line 296 "glsl_lexer.lpp" +#line 306 "glsl_lexer.lpp" return DVEC2; YY_BREAK -case 127: +case 128: YY_RULE_SETUP -#line 297 "glsl_lexer.lpp" +#line 307 "glsl_lexer.lpp" return DVEC3; YY_BREAK -case 128: +case 129: YY_RULE_SETUP -#line 298 "glsl_lexer.lpp" +#line 308 "glsl_lexer.lpp" return DVEC4; YY_BREAK -case 129: +case 130: YY_RULE_SETUP -#line 299 "glsl_lexer.lpp" +#line 309 "glsl_lexer.lpp" return FVEC2; YY_BREAK -case 130: +case 131: YY_RULE_SETUP -#line 300 "glsl_lexer.lpp" +#line 310 "glsl_lexer.lpp" return FVEC3; YY_BREAK -case 131: +case 132: YY_RULE_SETUP -#line 301 "glsl_lexer.lpp" +#line 311 "glsl_lexer.lpp" return FVEC4; YY_BREAK -case 132: +case 133: YY_RULE_SETUP -#line 302 "glsl_lexer.lpp" +#line 312 "glsl_lexer.lpp" return SAMPLER2DRECT; YY_BREAK -case 133: +case 134: YY_RULE_SETUP -#line 303 "glsl_lexer.lpp" +#line 313 "glsl_lexer.lpp" return SAMPLER3DRECT; YY_BREAK -case 134: +case 135: YY_RULE_SETUP -#line 304 "glsl_lexer.lpp" +#line 314 "glsl_lexer.lpp" return SAMPLER2DRECTSHADOW; YY_BREAK -case 135: +case 136: YY_RULE_SETUP -#line 305 "glsl_lexer.lpp" +#line 315 "glsl_lexer.lpp" return SIZEOF; YY_BREAK -case 136: +case 137: YY_RULE_SETUP -#line 306 "glsl_lexer.lpp" +#line 316 "glsl_lexer.lpp" return CAST; YY_BREAK -case 137: +case 138: YY_RULE_SETUP -#line 307 "glsl_lexer.lpp" +#line 317 "glsl_lexer.lpp" return NAMESPACE; YY_BREAK -case 138: +case 139: YY_RULE_SETUP -#line 308 "glsl_lexer.lpp" +#line 318 "glsl_lexer.lpp" return USING; YY_BREAK /* Additional reserved words in GLSL 1.20. */ -case 139: +case 140: YY_RULE_SETUP -#line 311 "glsl_lexer.lpp" +#line 321 "glsl_lexer.lpp" return LOWP; YY_BREAK -case 140: +case 141: YY_RULE_SETUP -#line 312 "glsl_lexer.lpp" +#line 322 "glsl_lexer.lpp" return MEDIUMP; YY_BREAK -case 141: +case 142: YY_RULE_SETUP -#line 313 "glsl_lexer.lpp" +#line 323 "glsl_lexer.lpp" return HIGHP; YY_BREAK -case 142: +case 143: YY_RULE_SETUP -#line 314 "glsl_lexer.lpp" +#line 324 "glsl_lexer.lpp" return PRECISION; YY_BREAK -case 143: +case 144: YY_RULE_SETUP -#line 316 "glsl_lexer.lpp" +#line 326 "glsl_lexer.lpp" { struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; @@ -2003,17 +2021,17 @@ YY_RULE_SETUP return IDENTIFIER; } YY_BREAK -case 144: +case 145: YY_RULE_SETUP -#line 323 "glsl_lexer.lpp" +#line 333 "glsl_lexer.lpp" { return yytext[0]; } YY_BREAK -case 145: +case 146: YY_RULE_SETUP -#line 325 "glsl_lexer.lpp" +#line 335 "glsl_lexer.lpp" ECHO; YY_BREAK -#line 2017 "glsl_lexer.cpp" +#line 2035 "glsl_lexer.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(PP): yyterminate(); @@ -2310,7 +2328,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 519 ) + if ( yy_current_state >= 524 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -2339,11 +2357,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 519 ) + if ( yy_current_state >= 524 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 518); + yy_is_jam = (yy_current_state == 523); return yy_is_jam ? 0 : yy_current_state; } @@ -3155,7 +3173,7 @@ void _mesa_glsl_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 325 "glsl_lexer.lpp" +#line 335 "glsl_lexer.lpp" diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index b0afc44d5e9..ebfea37597d 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -201,6 +201,16 @@ sampler2DShadow return SAMPLER2DSHADOW; struct return STRUCT; void return VOID; +layout { + if ((yyextra->language_version >= 140) + || (yyextra->ARB_fragment_coord_conventions_enable)){ + return LAYOUT_TOK; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + \+\+ return INC_OP; -- return DEC_OP; \<= return LE_OP; diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp index b2113c083c6..b31f558168f 100644 --- a/src/glsl/glsl_parser.cpp +++ b/src/glsl/glsl_parser.cpp @@ -257,46 +257,47 @@ EOL = 371, INTERFACE = 372, OUTPUT = 373, - ASM = 374, - CLASS = 375, - UNION = 376, - ENUM = 377, - TYPEDEF = 378, - TEMPLATE = 379, - THIS = 380, - PACKED = 381, - GOTO = 382, - INLINE_TOK = 383, - NOINLINE = 384, - VOLATILE = 385, - PUBLIC_TOK = 386, - STATIC = 387, - EXTERN = 388, - EXTERNAL = 389, - LONG = 390, - SHORT = 391, - DOUBLE = 392, - HALF = 393, - FIXED = 394, - UNSIGNED = 395, - INPUT = 396, - OUPTUT = 397, - HVEC2 = 398, - HVEC3 = 399, - HVEC4 = 400, - DVEC2 = 401, - DVEC3 = 402, - DVEC4 = 403, - FVEC2 = 404, - FVEC3 = 405, - FVEC4 = 406, - SAMPLER2DRECT = 407, - SAMPLER3DRECT = 408, - SAMPLER2DRECTSHADOW = 409, - SIZEOF = 410, - CAST = 411, - NAMESPACE = 412, - USING = 413 + LAYOUT_TOK = 374, + ASM = 375, + CLASS = 376, + UNION = 377, + ENUM = 378, + TYPEDEF = 379, + TEMPLATE = 380, + THIS = 381, + PACKED = 382, + GOTO = 383, + INLINE_TOK = 384, + NOINLINE = 385, + VOLATILE = 386, + PUBLIC_TOK = 387, + STATIC = 388, + EXTERN = 389, + EXTERNAL = 390, + LONG = 391, + SHORT = 392, + DOUBLE = 393, + HALF = 394, + FIXED = 395, + UNSIGNED = 396, + INPUT = 397, + OUPTUT = 398, + HVEC2 = 399, + HVEC3 = 400, + HVEC4 = 401, + DVEC2 = 402, + DVEC3 = 403, + DVEC4 = 404, + FVEC2 = 405, + FVEC3 = 406, + FVEC4 = 407, + SAMPLER2DRECT = 408, + SAMPLER3DRECT = 409, + SAMPLER2DRECTSHADOW = 410, + SIZEOF = 411, + CAST = 412, + NAMESPACE = 413, + USING = 414 }; #endif @@ -338,7 +339,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 342 "glsl_parser.cpp" +#line 343 "glsl_parser.cpp" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -363,7 +364,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 367 "glsl_parser.cpp" +#line 368 "glsl_parser.cpp" #ifdef short # undef short @@ -580,20 +581,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 5 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 3646 +#define YYLAST 3839 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 183 +#define YYNTOKENS 184 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 85 +#define YYNNTS 89 /* YYNRULES -- Number of rules. */ -#define YYNRULES 270 +#define YYNRULES 276 /* YYNRULES -- Number of states. */ -#define YYNSTATES 403 +#define YYNSTATES 413 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 413 +#define YYMAXUTOK 414 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -604,16 +605,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 167, 2, 2, 2, 171, 174, 2, - 159, 160, 169, 165, 164, 166, 163, 170, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 178, 180, - 172, 179, 173, 177, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 168, 2, 2, 2, 172, 175, 2, + 160, 161, 170, 166, 165, 167, 164, 171, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 179, 181, + 173, 180, 174, 178, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 161, 2, 162, 175, 2, 2, 2, 2, 2, + 2, 162, 2, 163, 176, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 181, 176, 182, 168, 2, 2, 2, + 2, 2, 2, 182, 177, 183, 169, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -642,7 +643,7 @@ static const yytype_uint8 yytranslate[] = 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, - 155, 156, 157, 158 + 155, 156, 157, 158, 159 }; #if YYDEBUG @@ -663,137 +664,139 @@ static const yytype_uint16 yyprhs[] = 280, 283, 287, 291, 294, 300, 304, 307, 311, 314, 315, 317, 319, 321, 323, 325, 329, 335, 342, 350, 359, 365, 367, 370, 375, 381, 388, 396, 401, 404, - 406, 409, 411, 413, 415, 417, 419, 422, 425, 427, - 429, 431, 434, 436, 438, 441, 444, 446, 448, 451, - 453, 457, 462, 464, 466, 468, 470, 472, 474, 476, - 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, - 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, - 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, - 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, - 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, - 578, 580, 582, 588, 593, 595, 598, 602, 604, 608, - 610, 615, 617, 619, 621, 623, 625, 627, 629, 631, - 633, 635, 637, 639, 641, 643, 646, 650, 652, 654, - 657, 661, 663, 666, 668, 671, 679, 685, 691, 699, - 701, 706, 712, 716, 719, 725, 733, 740, 742, 744, - 746, 747, 750, 754, 757, 760, 763, 767, 770, 772, - 774 + 406, 409, 410, 412, 417, 419, 423, 425, 427, 429, + 431, 433, 435, 438, 441, 443, 445, 448, 451, 454, + 456, 459, 462, 464, 466, 469, 471, 475, 480, 482, + 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, + 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, + 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, + 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, + 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, + 584, 586, 588, 590, 592, 594, 596, 598, 600, 606, + 611, 613, 616, 620, 622, 626, 628, 633, 635, 637, + 639, 641, 643, 645, 647, 649, 651, 653, 655, 657, + 659, 661, 664, 668, 670, 672, 675, 679, 681, 684, + 686, 689, 697, 703, 709, 717, 719, 724, 730, 734, + 737, 743, 751, 758, 760, 762, 764, 765, 768, 772, + 775, 778, 781, 785, 788, 790, 792 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 184, 0, -1, -1, 186, 187, 185, 189, -1, -1, - 111, 81, 116, -1, -1, 187, 188, -1, 112, 79, - 115, 79, 116, -1, 266, -1, 189, 266, -1, 79, - -1, 190, -1, 81, -1, 82, -1, 80, -1, 83, - -1, 159, 217, 160, -1, 191, -1, 192, 161, 193, - 162, -1, 194, -1, 192, 163, 79, -1, 192, 87, - -1, 192, 88, -1, 217, -1, 195, -1, 196, -1, - 192, 163, 196, -1, 198, 160, -1, 197, 160, -1, - 199, 77, -1, 199, -1, 199, 215, -1, 198, 164, - 215, -1, 200, 159, -1, 235, -1, 79, -1, 84, - -1, 192, -1, 87, 201, -1, 88, 201, -1, 202, - 201, -1, 165, -1, 166, -1, 167, -1, 168, -1, - 201, -1, 203, 169, 201, -1, 203, 170, 201, -1, - 203, 171, 201, -1, 203, -1, 204, 165, 203, -1, - 204, 166, 203, -1, 204, -1, 205, 85, 204, -1, - 205, 86, 204, -1, 205, -1, 206, 172, 205, -1, - 206, 173, 205, -1, 206, 89, 205, -1, 206, 90, - 205, -1, 206, -1, 207, 91, 206, -1, 207, 92, - 206, -1, 207, -1, 208, 174, 207, -1, 208, -1, - 209, 175, 208, -1, 209, -1, 210, 176, 209, -1, - 210, -1, 211, 93, 210, -1, 211, -1, 212, 95, - 211, -1, 212, -1, 213, 94, 212, -1, 213, -1, - 213, 177, 217, 178, 215, -1, 214, -1, 201, 216, - 215, -1, 179, -1, 96, -1, 97, -1, 99, -1, + 185, 0, -1, -1, 187, 188, 186, 190, -1, -1, + 111, 81, 116, -1, -1, 188, 189, -1, 112, 79, + 115, 79, 116, -1, 271, -1, 190, 271, -1, 79, + -1, 191, -1, 81, -1, 82, -1, 80, -1, 83, + -1, 160, 218, 161, -1, 192, -1, 193, 162, 194, + 163, -1, 195, -1, 193, 164, 79, -1, 193, 87, + -1, 193, 88, -1, 218, -1, 196, -1, 197, -1, + 193, 164, 197, -1, 199, 161, -1, 198, 161, -1, + 200, 77, -1, 200, -1, 200, 216, -1, 199, 165, + 216, -1, 201, 160, -1, 240, -1, 79, -1, 84, + -1, 193, -1, 87, 202, -1, 88, 202, -1, 203, + 202, -1, 166, -1, 167, -1, 168, -1, 169, -1, + 202, -1, 204, 170, 202, -1, 204, 171, 202, -1, + 204, 172, 202, -1, 204, -1, 205, 166, 204, -1, + 205, 167, 204, -1, 205, -1, 206, 85, 205, -1, + 206, 86, 205, -1, 206, -1, 207, 173, 206, -1, + 207, 174, 206, -1, 207, 89, 206, -1, 207, 90, + 206, -1, 207, -1, 208, 91, 207, -1, 208, 92, + 207, -1, 208, -1, 209, 175, 208, -1, 209, -1, + 210, 176, 209, -1, 210, -1, 211, 177, 210, -1, + 211, -1, 212, 93, 211, -1, 212, -1, 213, 95, + 212, -1, 213, -1, 214, 94, 213, -1, 214, -1, + 214, 178, 218, 179, 216, -1, 215, -1, 202, 217, + 216, -1, 180, -1, 96, -1, 97, -1, 99, -1, 98, -1, 105, -1, 100, -1, 101, -1, 102, -1, - 103, -1, 104, -1, 215, -1, 217, 164, 215, -1, - 214, -1, 220, 180, -1, 228, 180, -1, 110, 239, - 236, 180, -1, 221, 160, -1, 223, -1, 222, -1, - 223, 225, -1, 222, 164, 225, -1, 230, 79, 159, - -1, 235, 79, -1, 235, 79, 161, 218, 162, -1, - 232, 226, 224, -1, 226, 224, -1, 232, 226, 227, - -1, 226, 227, -1, -1, 36, -1, 37, -1, 38, - -1, 235, -1, 229, -1, 228, 164, 79, -1, 228, - 164, 79, 161, 162, -1, 228, 164, 79, 161, 218, - 162, -1, 228, 164, 79, 161, 162, 179, 245, -1, - 228, 164, 79, 161, 218, 162, 179, 245, -1, 228, - 164, 79, 179, 245, -1, 230, -1, 230, 79, -1, - 230, 79, 161, 162, -1, 230, 79, 161, 218, 162, - -1, 230, 79, 161, 162, 179, 245, -1, 230, 79, - 161, 218, 162, 179, 245, -1, 230, 79, 179, 245, - -1, 106, 79, -1, 235, -1, 233, 235, -1, 43, - -1, 42, -1, 41, -1, 4, -1, 234, -1, 231, - 233, -1, 106, 233, -1, 4, -1, 3, -1, 40, - -1, 35, 40, -1, 36, -1, 37, -1, 35, 36, - -1, 35, 37, -1, 39, -1, 236, -1, 239, 236, - -1, 237, -1, 237, 161, 162, -1, 237, 161, 218, - 162, -1, 238, -1, 240, -1, 79, -1, 77, -1, - 6, -1, 7, -1, 8, -1, 5, -1, 29, -1, - 30, -1, 31, -1, 20, -1, 21, -1, 22, -1, - 23, -1, 24, -1, 25, -1, 26, -1, 27, -1, - 28, -1, 32, -1, 33, -1, 34, -1, 44, -1, - 45, -1, 46, -1, 47, -1, 48, -1, 49, -1, - 50, -1, 51, -1, 52, -1, 53, -1, 54, -1, - 152, -1, 55, -1, 56, -1, 57, -1, 58, -1, - 154, -1, 59, -1, 60, -1, 61, -1, 62, -1, - 63, -1, 64, -1, 65, -1, 66, -1, 67, -1, - 68, -1, 69, -1, 70, -1, 71, -1, 72, -1, - 73, -1, 74, -1, 75, -1, 109, -1, 108, -1, - 107, -1, 76, 79, 181, 241, 182, -1, 76, 181, - 241, 182, -1, 242, -1, 241, 242, -1, 235, 243, - 180, -1, 244, -1, 243, 164, 244, -1, 79, -1, - 79, 161, 218, 162, -1, 215, -1, 219, -1, 248, - -1, 249, -1, 251, -1, 250, -1, 257, -1, 246, - -1, 255, -1, 256, -1, 259, -1, 260, -1, 261, - -1, 265, -1, 181, 182, -1, 181, 254, 182, -1, - 253, -1, 250, -1, 181, 182, -1, 181, 254, 182, - -1, 247, -1, 254, 247, -1, 180, -1, 217, 180, - -1, 14, 159, 217, 160, 248, 12, 248, -1, 14, - 159, 217, 160, 248, -1, 14, 159, 217, 160, 249, - -1, 14, 159, 217, 160, 248, 12, 249, -1, 217, - -1, 230, 79, 179, 245, -1, 17, 159, 217, 160, - 251, -1, 18, 217, 178, -1, 19, 178, -1, 78, - 159, 258, 160, 252, -1, 11, 247, 78, 159, 217, - 160, 180, -1, 13, 159, 262, 264, 160, 252, -1, - 255, -1, 246, -1, 258, -1, -1, 263, 180, -1, - 263, 180, 217, -1, 10, 180, -1, 9, 180, -1, - 16, 180, -1, 16, 217, 180, -1, 15, 180, -1, - 267, -1, 219, -1, 220, 253, -1 + 103, -1, 104, -1, 216, -1, 218, 165, 216, -1, + 215, -1, 221, 181, -1, 229, 181, -1, 110, 244, + 241, 181, -1, 222, 161, -1, 224, -1, 223, -1, + 224, 226, -1, 223, 165, 226, -1, 231, 79, 160, + -1, 240, 79, -1, 240, 79, 162, 219, 163, -1, + 237, 227, 225, -1, 227, 225, -1, 237, 227, 228, + -1, 227, 228, -1, -1, 36, -1, 37, -1, 38, + -1, 240, -1, 230, -1, 229, 165, 79, -1, 229, + 165, 79, 162, 163, -1, 229, 165, 79, 162, 219, + 163, -1, 229, 165, 79, 162, 163, 180, 250, -1, + 229, 165, 79, 162, 219, 163, 180, 250, -1, 229, + 165, 79, 180, 250, -1, 231, -1, 231, 79, -1, + 231, 79, 162, 163, -1, 231, 79, 162, 219, 163, + -1, 231, 79, 162, 163, 180, 250, -1, 231, 79, + 162, 219, 163, 180, 250, -1, 231, 79, 180, 250, + -1, 106, 79, -1, 240, -1, 238, 240, -1, -1, + 233, -1, 119, 160, 234, 161, -1, 235, -1, 234, + 165, 235, -1, 79, -1, 43, -1, 42, -1, 41, + -1, 4, -1, 239, -1, 236, 238, -1, 106, 238, + -1, 4, -1, 3, -1, 232, 40, -1, 35, 40, + -1, 232, 36, -1, 37, -1, 35, 36, -1, 35, + 37, -1, 39, -1, 241, -1, 244, 241, -1, 242, + -1, 242, 162, 163, -1, 242, 162, 219, 163, -1, + 243, -1, 245, -1, 79, -1, 77, -1, 6, -1, + 7, -1, 8, -1, 5, -1, 29, -1, 30, -1, + 31, -1, 20, -1, 21, -1, 22, -1, 23, -1, + 24, -1, 25, -1, 26, -1, 27, -1, 28, -1, + 32, -1, 33, -1, 34, -1, 44, -1, 45, -1, + 46, -1, 47, -1, 48, -1, 49, -1, 50, -1, + 51, -1, 52, -1, 53, -1, 54, -1, 153, -1, + 55, -1, 56, -1, 57, -1, 58, -1, 155, -1, + 59, -1, 60, -1, 61, -1, 62, -1, 63, -1, + 64, -1, 65, -1, 66, -1, 67, -1, 68, -1, + 69, -1, 70, -1, 71, -1, 72, -1, 73, -1, + 74, -1, 75, -1, 109, -1, 108, -1, 107, -1, + 76, 79, 182, 246, 183, -1, 76, 182, 246, 183, + -1, 247, -1, 246, 247, -1, 240, 248, 181, -1, + 249, -1, 248, 165, 249, -1, 79, -1, 79, 162, + 219, 163, -1, 216, -1, 220, -1, 253, -1, 254, + -1, 256, -1, 255, -1, 262, -1, 251, -1, 260, + -1, 261, -1, 264, -1, 265, -1, 266, -1, 270, + -1, 182, 183, -1, 182, 259, 183, -1, 258, -1, + 255, -1, 182, 183, -1, 182, 259, 183, -1, 252, + -1, 259, 252, -1, 181, -1, 218, 181, -1, 14, + 160, 218, 161, 253, 12, 253, -1, 14, 160, 218, + 161, 253, -1, 14, 160, 218, 161, 254, -1, 14, + 160, 218, 161, 253, 12, 254, -1, 218, -1, 231, + 79, 180, 250, -1, 17, 160, 218, 161, 256, -1, + 18, 218, 179, -1, 19, 179, -1, 78, 160, 263, + 161, 257, -1, 11, 252, 78, 160, 218, 161, 181, + -1, 13, 160, 267, 269, 161, 257, -1, 260, -1, + 251, -1, 263, -1, -1, 268, 181, -1, 268, 181, + 218, -1, 10, 181, -1, 9, 181, -1, 16, 181, + -1, 16, 218, 181, -1, 15, 181, -1, 272, -1, + 220, -1, 221, 258, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 190, 190, 189, 198, 201, 218, 220, 224, 233, - 241, 252, 256, 263, 270, 277, 284, 291, 298, 299, - 305, 309, 316, 322, 331, 335, 339, 340, 349, 350, - 354, 355, 359, 365, 377, 381, 387, 394, 405, 406, - 412, 418, 428, 429, 430, 431, 435, 436, 442, 448, - 457, 458, 464, 473, 474, 480, 489, 490, 496, 502, - 508, 517, 518, 524, 533, 534, 543, 544, 553, 554, - 563, 564, 573, 574, 583, 584, 593, 594, 603, 604, - 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, - 623, 627, 631, 647, 651, 655, 659, 673, 677, 678, - 682, 687, 695, 706, 716, 731, 738, 743, 754, 766, - 767, 768, 769, 773, 777, 778, 787, 796, 805, 814, - 823, 836, 847, 856, 865, 874, 883, 892, 901, 915, - 922, 933, 934, 935, 939, 943, 944, 948, 956, 957, - 958, 959, 960, 961, 962, 963, 964, 968, 969, 977, - 978, 984, 993, 999, 1005, 1014, 1015, 1016, 1017, 1018, - 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, - 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, - 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, - 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, - 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1071, - 1082, 1093, 1107, 1113, 1122, 1127, 1135, 1150, 1155, 1163, - 1169, 1178, 1182, 1188, 1189, 1193, 1194, 1198, 1202, 1203, - 1204, 1205, 1206, 1207, 1208, 1212, 1218, 1227, 1228, 1232, - 1238, 1247, 1257, 1269, 1275, 1284, 1293, 1299, 1305, 1314, - 1318, 1332, 1336, 1337, 1341, 1348, 1355, 1365, 1366, 1370, - 1372, 1378, 1383, 1392, 1398, 1404, 1410, 1416, 1425, 1426, - 1430 + 0, 193, 193, 192, 201, 204, 221, 223, 227, 236, + 244, 255, 259, 266, 273, 280, 287, 294, 301, 302, + 308, 312, 319, 325, 334, 338, 342, 343, 352, 353, + 357, 358, 362, 368, 380, 384, 390, 397, 408, 409, + 415, 421, 431, 432, 433, 434, 438, 439, 445, 451, + 460, 461, 467, 476, 477, 483, 492, 493, 499, 505, + 511, 520, 521, 527, 536, 537, 546, 547, 556, 557, + 566, 567, 576, 577, 586, 587, 596, 597, 606, 607, + 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, + 626, 630, 634, 650, 654, 658, 662, 676, 680, 681, + 685, 690, 698, 709, 719, 734, 741, 746, 757, 769, + 770, 771, 772, 776, 780, 781, 790, 799, 808, 817, + 826, 839, 850, 859, 868, 877, 886, 895, 904, 918, + 925, 936, 937, 941, 948, 949, 956, 990, 991, 992, + 996, 1000, 1001, 1005, 1013, 1014, 1015, 1016, 1017, 1018, + 1019, 1020, 1021, 1025, 1026, 1034, 1035, 1041, 1050, 1056, + 1062, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, + 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, + 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, + 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, + 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, + 1120, 1121, 1122, 1123, 1124, 1128, 1139, 1150, 1164, 1170, + 1179, 1184, 1192, 1207, 1212, 1220, 1226, 1235, 1239, 1245, + 1246, 1250, 1251, 1255, 1259, 1260, 1261, 1262, 1263, 1264, + 1265, 1269, 1275, 1284, 1285, 1289, 1295, 1304, 1314, 1326, + 1332, 1341, 1350, 1356, 1362, 1371, 1375, 1389, 1393, 1394, + 1398, 1405, 1412, 1422, 1423, 1427, 1429, 1435, 1440, 1449, + 1455, 1461, 1467, 1473, 1482, 1483, 1487 }; #endif @@ -822,16 +825,16 @@ static const char *const yytname[] = "DIV_ASSIGN", "ADD_ASSIGN", "MOD_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN", "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", "SUB_ASSIGN", "INVARIANT", "LOWP", "MEDIUMP", "HIGHP", "PRECISION", "VERSION", "EXTENSION", "LINE", - "PRAGMA", "COLON", "EOL", "INTERFACE", "OUTPUT", "ASM", "CLASS", "UNION", - "ENUM", "TYPEDEF", "TEMPLATE", "THIS", "PACKED", "GOTO", "INLINE_TOK", - "NOINLINE", "VOLATILE", "PUBLIC_TOK", "STATIC", "EXTERN", "EXTERNAL", - "LONG", "SHORT", "DOUBLE", "HALF", "FIXED", "UNSIGNED", "INPUT", - "OUPTUT", "HVEC2", "HVEC3", "HVEC4", "DVEC2", "DVEC3", "DVEC4", "FVEC2", - "FVEC3", "FVEC4", "SAMPLER2DRECT", "SAMPLER3DRECT", - "SAMPLER2DRECTSHADOW", "SIZEOF", "CAST", "NAMESPACE", "USING", "'('", - "')'", "'['", "']'", "'.'", "','", "'+'", "'-'", "'!'", "'~'", "'*'", - "'/'", "'%'", "'<'", "'>'", "'&'", "'^'", "'|'", "'?'", "':'", "'='", - "';'", "'{'", "'}'", "$accept", "translation_unit", "$@1", + "PRAGMA", "COLON", "EOL", "INTERFACE", "OUTPUT", "LAYOUT_TOK", "ASM", + "CLASS", "UNION", "ENUM", "TYPEDEF", "TEMPLATE", "THIS", "PACKED", + "GOTO", "INLINE_TOK", "NOINLINE", "VOLATILE", "PUBLIC_TOK", "STATIC", + "EXTERN", "EXTERNAL", "LONG", "SHORT", "DOUBLE", "HALF", "FIXED", + "UNSIGNED", "INPUT", "OUPTUT", "HVEC2", "HVEC3", "HVEC4", "DVEC2", + "DVEC3", "DVEC4", "FVEC2", "FVEC3", "FVEC4", "SAMPLER2DRECT", + "SAMPLER3DRECT", "SAMPLER2DRECTSHADOW", "SIZEOF", "CAST", "NAMESPACE", + "USING", "'('", "')'", "'['", "']'", "'.'", "','", "'+'", "'-'", "'!'", + "'~'", "'*'", "'/'", "'%'", "'<'", "'>'", "'&'", "'^'", "'|'", "'?'", + "':'", "'='", "';'", "'{'", "'}'", "$accept", "translation_unit", "$@1", "version_statement", "extension_statement_list", "extension_statement", "external_declaration_list", "variable_identifier", "primary_expression", "postfix_expression", "integer_expression", "function_call", @@ -850,12 +853,14 @@ static const char *const yytname[] = "function_header", "parameter_declarator", "parameter_declaration", "parameter_qualifier", "parameter_type_specifier", "init_declarator_list", "single_declaration", "fully_specified_type", - "interpolation_qualifier", "parameter_type_qualifier", "type_qualifier", - "storage_qualifier", "type_specifier", "type_specifier_no_prec", - "type_specifier_nonarray", "basic_type_specifier_nonarray", - "precision_qualifier", "struct_specifier", "struct_declaration_list", - "struct_declaration", "struct_declarator_list", "struct_declarator", - "initializer", "declaration_statement", "statement", "statement_matched", + "opt_layout_qualifier", "layout_qualifier", "layout_qualifier_id_list", + "layout_qualifier_id", "interpolation_qualifier", + "parameter_type_qualifier", "type_qualifier", "storage_qualifier", + "type_specifier", "type_specifier_no_prec", "type_specifier_nonarray", + "basic_type_specifier_nonarray", "precision_qualifier", + "struct_specifier", "struct_declaration_list", "struct_declaration", + "struct_declarator_list", "struct_declarator", "initializer", + "declaration_statement", "statement", "statement_matched", "statement_unmatched", "simple_statement", "compound_statement", "statement_no_new_scope", "compound_statement_no_new_scope", "statement_list", "expression_statement", "selection_statement_matched", @@ -886,44 +891,44 @@ static const yytype_uint16 yytoknum[] = 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, - 405, 406, 407, 408, 409, 410, 411, 412, 413, 40, - 41, 91, 93, 46, 44, 43, 45, 33, 126, 42, - 47, 37, 60, 62, 38, 94, 124, 63, 58, 61, - 59, 123, 125 + 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, + 40, 41, 91, 93, 46, 44, 43, 45, 33, 126, + 42, 47, 37, 60, 62, 38, 94, 124, 63, 58, + 61, 59, 123, 125 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { - 0, 183, 185, 184, 186, 186, 187, 187, 188, 189, - 189, 190, 191, 191, 191, 191, 191, 191, 192, 192, - 192, 192, 192, 192, 193, 194, 195, 195, 196, 196, - 197, 197, 198, 198, 199, 200, 200, 200, 201, 201, - 201, 201, 202, 202, 202, 202, 203, 203, 203, 203, - 204, 204, 204, 205, 205, 205, 206, 206, 206, 206, - 206, 207, 207, 207, 208, 208, 209, 209, 210, 210, - 211, 211, 212, 212, 213, 213, 214, 214, 215, 215, - 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - 216, 217, 217, 218, 219, 219, 219, 220, 221, 221, - 222, 222, 223, 224, 224, 225, 225, 225, 225, 226, - 226, 226, 226, 227, 228, 228, 228, 228, 228, 228, - 228, 229, 229, 229, 229, 229, 229, 229, 229, 230, - 230, 231, 231, 231, 232, 233, 233, 233, 234, 234, - 234, 234, 234, 234, 234, 234, 234, 235, 235, 236, - 236, 236, 237, 237, 237, 238, 238, 238, 238, 238, - 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, - 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, - 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, - 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, - 238, 238, 238, 238, 238, 238, 238, 238, 238, 239, - 239, 239, 240, 240, 241, 241, 242, 243, 243, 244, - 244, 245, 246, 247, 247, 248, 248, 249, 250, 250, - 250, 250, 250, 250, 250, 251, 251, 252, 252, 253, - 253, 254, 254, 255, 255, 256, 257, 257, 257, 258, - 258, 259, 260, 260, 261, 261, 261, 262, 262, 263, - 263, 264, 264, 265, 265, 265, 265, 265, 266, 266, - 267 + 0, 184, 186, 185, 187, 187, 188, 188, 189, 190, + 190, 191, 192, 192, 192, 192, 192, 192, 193, 193, + 193, 193, 193, 193, 194, 195, 196, 196, 197, 197, + 198, 198, 199, 199, 200, 201, 201, 201, 202, 202, + 202, 202, 203, 203, 203, 203, 204, 204, 204, 204, + 205, 205, 205, 206, 206, 206, 207, 207, 207, 207, + 207, 208, 208, 208, 209, 209, 210, 210, 211, 211, + 212, 212, 213, 213, 214, 214, 215, 215, 216, 216, + 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, + 217, 218, 218, 219, 220, 220, 220, 221, 222, 222, + 223, 223, 224, 225, 225, 226, 226, 226, 226, 227, + 227, 227, 227, 228, 229, 229, 229, 229, 229, 229, + 229, 230, 230, 230, 230, 230, 230, 230, 230, 231, + 231, 232, 232, 233, 234, 234, 235, 236, 236, 236, + 237, 238, 238, 238, 239, 239, 239, 239, 239, 239, + 239, 239, 239, 240, 240, 241, 241, 241, 242, 242, + 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 243, 243, 243, 243, 244, 244, 244, 245, 245, + 246, 246, 247, 248, 248, 249, 249, 250, 251, 252, + 252, 253, 253, 254, 255, 255, 255, 255, 255, 255, + 255, 256, 256, 257, 257, 258, 258, 259, 259, 260, + 260, 261, 262, 262, 262, 263, 263, 264, 265, 265, + 266, 266, 266, 267, 267, 268, 268, 269, 269, 270, + 270, 270, 270, 270, 271, 271, 272 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -942,21 +947,21 @@ static const yytype_uint8 yyr2[] = 2, 3, 3, 2, 5, 3, 2, 3, 2, 0, 1, 1, 1, 1, 1, 3, 5, 6, 7, 8, 5, 1, 2, 4, 5, 6, 7, 4, 2, 1, - 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, - 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, - 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 0, 1, 4, 1, 3, 1, 1, 1, 1, + 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, + 2, 2, 1, 1, 2, 1, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 5, 4, 1, 2, 3, 1, 3, 1, - 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 3, 1, 1, 2, - 3, 1, 2, 1, 2, 7, 5, 5, 7, 1, - 4, 5, 3, 2, 5, 7, 6, 1, 1, 1, - 0, 2, 3, 2, 2, 2, 3, 2, 1, 1, - 2 + 1, 1, 1, 1, 1, 1, 1, 1, 5, 4, + 1, 2, 3, 1, 3, 1, 4, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 3, 1, 1, 2, 3, 1, 2, 1, + 2, 7, 5, 5, 7, 1, 4, 5, 3, 2, + 5, 7, 6, 1, 1, 1, 0, 2, 3, 2, + 2, 2, 3, 2, 1, 1, 2 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -964,730 +969,757 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint16 yydefact[] = { - 4, 0, 0, 6, 0, 1, 2, 5, 0, 0, - 7, 0, 139, 138, 159, 156, 157, 158, 163, 164, - 165, 166, 167, 168, 169, 170, 171, 160, 161, 162, - 172, 173, 174, 0, 142, 143, 146, 140, 133, 132, - 131, 175, 176, 177, 178, 179, 180, 181, 182, 183, - 184, 185, 187, 188, 189, 190, 192, 193, 194, 195, - 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - 206, 207, 208, 0, 155, 154, 0, 211, 210, 209, - 0, 186, 191, 3, 269, 0, 0, 99, 109, 0, - 114, 121, 0, 0, 135, 129, 147, 149, 152, 0, - 153, 9, 268, 0, 144, 145, 141, 0, 0, 128, - 0, 137, 0, 10, 94, 0, 270, 97, 109, 134, - 110, 111, 112, 100, 0, 109, 0, 95, 122, 136, - 130, 0, 148, 0, 0, 0, 0, 214, 0, 0, + 4, 0, 0, 6, 0, 1, 2, 5, 0, 131, + 7, 0, 145, 144, 165, 162, 163, 164, 169, 170, + 171, 172, 173, 174, 175, 176, 177, 166, 167, 168, + 178, 179, 180, 0, 149, 152, 139, 138, 137, 181, + 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, + 193, 194, 195, 196, 198, 199, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + 214, 0, 161, 160, 131, 217, 216, 215, 0, 0, + 192, 197, 131, 275, 0, 0, 99, 109, 0, 114, + 121, 0, 132, 131, 0, 141, 129, 153, 155, 158, + 0, 159, 9, 274, 0, 150, 151, 147, 0, 0, + 128, 131, 143, 0, 0, 10, 94, 131, 276, 97, + 109, 140, 110, 111, 112, 100, 0, 109, 0, 95, + 122, 148, 146, 142, 130, 0, 154, 0, 0, 0, + 0, 220, 0, 136, 0, 134, 0, 0, 131, 0, + 0, 0, 0, 0, 0, 0, 0, 11, 15, 13, + 14, 16, 37, 0, 0, 0, 42, 43, 44, 45, + 249, 131, 245, 12, 18, 38, 20, 25, 26, 0, + 0, 31, 0, 46, 0, 50, 53, 56, 61, 64, + 66, 68, 70, 72, 74, 76, 78, 91, 0, 228, + 0, 129, 234, 247, 229, 230, 232, 231, 131, 235, + 236, 233, 237, 238, 239, 240, 101, 106, 108, 113, + 0, 115, 102, 0, 0, 156, 46, 93, 0, 35, + 8, 0, 225, 0, 223, 219, 221, 96, 133, 0, + 270, 269, 0, 131, 0, 273, 271, 0, 0, 0, + 259, 131, 39, 40, 0, 241, 131, 22, 23, 0, + 0, 29, 28, 0, 161, 32, 34, 81, 82, 84, + 83, 86, 87, 88, 89, 90, 85, 80, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 11, 15, 13, 14, 16, 37, 0, 0, 0, 42, - 43, 44, 45, 243, 0, 239, 12, 18, 38, 20, - 25, 26, 0, 0, 31, 0, 46, 0, 50, 53, - 56, 61, 64, 66, 68, 70, 72, 74, 76, 78, - 91, 0, 222, 0, 129, 228, 241, 223, 224, 226, - 225, 0, 229, 230, 227, 231, 232, 233, 234, 101, - 106, 108, 113, 0, 115, 102, 0, 0, 150, 46, - 93, 0, 35, 8, 0, 219, 0, 217, 213, 215, - 96, 264, 263, 0, 0, 0, 267, 265, 0, 0, - 0, 253, 0, 39, 40, 0, 235, 0, 22, 23, - 0, 0, 29, 28, 0, 155, 32, 34, 81, 82, - 84, 83, 86, 87, 88, 89, 90, 85, 80, 0, - 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 244, 240, 242, 103, 105, 107, 0, 0, - 123, 0, 221, 127, 151, 212, 0, 0, 216, 0, - 258, 257, 260, 0, 266, 0, 252, 249, 0, 0, - 17, 236, 0, 24, 21, 27, 33, 79, 47, 48, + 0, 250, 246, 248, 103, 105, 107, 0, 0, 123, + 0, 227, 127, 157, 218, 0, 0, 222, 135, 0, + 264, 263, 131, 0, 272, 0, 258, 255, 0, 0, + 17, 242, 0, 24, 21, 27, 33, 79, 47, 48, 49, 51, 52, 54, 55, 59, 60, 57, 58, 62, 63, 65, 67, 69, 71, 73, 75, 0, 92, 0, - 116, 0, 120, 0, 124, 0, 218, 0, 259, 0, - 0, 0, 0, 0, 0, 19, 0, 0, 0, 117, - 125, 0, 220, 0, 261, 0, 246, 247, 251, 0, - 0, 238, 254, 237, 77, 104, 118, 0, 126, 0, - 262, 256, 0, 250, 0, 119, 255, 245, 248, 0, - 0, 0, 0 + 116, 0, 120, 0, 124, 0, 224, 0, 265, 0, + 0, 131, 0, 0, 131, 19, 0, 0, 0, 117, + 125, 0, 226, 0, 267, 131, 252, 253, 257, 0, + 0, 244, 260, 243, 77, 104, 118, 0, 126, 0, + 268, 262, 131, 256, 0, 119, 261, 251, 254, 0, + 131, 0, 131 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 2, 9, 3, 6, 10, 83, 166, 167, 168, - 322, 169, 170, 171, 172, 173, 174, 175, 176, 177, - 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, - 188, 189, 190, 269, 191, 221, 192, 193, 86, 87, - 88, 210, 123, 124, 211, 89, 90, 91, 92, 125, - 93, 94, 222, 96, 97, 98, 99, 100, 136, 137, - 226, 227, 303, 195, 196, 197, 198, 199, 200, 382, - 383, 201, 202, 203, 204, 319, 205, 206, 207, 312, - 359, 360, 208, 101, 102 + -1, 2, 9, 3, 6, 10, 82, 173, 174, 175, + 332, 176, 177, 178, 179, 180, 181, 182, 183, 184, + 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, + 195, 196, 197, 278, 198, 228, 199, 200, 85, 86, + 87, 217, 125, 126, 218, 88, 89, 90, 91, 92, + 144, 145, 93, 127, 94, 95, 229, 97, 98, 99, + 100, 101, 140, 141, 233, 234, 312, 202, 203, 204, + 205, 206, 207, 392, 393, 208, 209, 210, 211, 329, + 212, 213, 214, 322, 369, 370, 215, 102, 103 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -325 +#define YYPACT_NINF -353 static const yytype_int16 yypact[] = { - -52, -1, 67, -325, -31, -325, 37, -325, 23, 3159, - -325, 52, -325, -325, -325, -325, -325, -325, -325, -325, - -325, -325, -325, -325, -325, -325, -325, -325, -325, -325, - -325, -325, -325, 94, -325, -325, -325, -325, -325, -325, - -325, -325, -325, -325, -325, -325, -325, -325, -325, -325, - -325, -325, -325, -325, -325, -325, -325, -325, -325, -325, - -325, -325, -325, -325, -325, -325, -325, -325, -325, -325, - -325, -325, -325, -72, -325, -325, 12, -325, -325, -325, - 36, -325, -325, 3159, -325, -163, 30, 27, -2, -98, - -325, 114, 144, 3381, -325, -325, -325, 33, -325, 3492, - -325, -325, -325, 117, -325, -325, -325, 17, 3381, -325, - 144, -325, 3492, -325, -325, 391, -325, -325, 35, -325, - -325, -325, -325, -325, 3381, 116, 120, -325, -119, -325, - -325, 2393, -325, 86, 3381, 124, 1799, -325, 25, 26, - 29, 1111, 48, 51, 31, 2077, 53, 2843, 39, 54, - -67, -325, -325, -325, -325, -325, 2843, 2843, 2843, -325, - -325, -325, -325, -325, 571, -325, -325, -325, -44, -325, - -325, -325, 60, -99, 2993, 55, -75, 2843, -10, 4, - 71, -79, 80, 47, 49, 46, 130, 131, -63, -325, - -325, -59, -325, 50, 68, -325, -325, -325, -325, -325, - -325, 751, -325, -325, -325, -325, -325, -325, -325, -325, - -325, -325, 149, 3381, -129, -325, 2543, 2843, -325, -325, - -325, 69, -325, -325, 1938, 73, -56, -325, -325, -325, - -325, -325, -325, 151, 1635, 2843, -325, -325, -51, 2843, - -108, -325, 2243, -325, -325, -38, -325, 931, -325, -325, - 2843, 3270, -325, -325, 2843, 72, -325, -325, -325, -325, - -325, -325, -325, -325, -325, -325, -325, -325, -325, 2843, - -325, 2843, 2843, 2843, 2843, 2843, 2843, 2843, 2843, 2843, - 2843, 2843, 2843, 2843, 2843, 2843, 2843, 2843, 2843, 2843, - 2843, 2843, -325, -325, -325, 75, -325, -325, 2693, 2843, - 58, 77, -325, -325, -325, -325, 2843, 124, -325, 81, - -325, -325, 2243, -27, -325, -25, -325, 78, 162, 83, - -325, -325, 82, 78, 87, -325, -325, -325, -325, -325, - -325, -10, -10, 4, 4, 71, 71, 71, 71, -79, - -79, 80, 47, 49, 46, 130, 131, -102, -325, 2843, - 66, 85, -325, 2843, 70, 89, -325, 2843, -325, 74, - 88, 1111, 95, 96, 1290, -325, 2843, 90, 2843, 98, - -325, 2843, -325, -24, 2843, 1290, 241, -325, -325, 2843, - 119, -325, -325, -325, -325, -325, -325, 2843, -325, 99, - 78, -325, 1111, -325, 2843, -325, -325, -325, -325, -14, - 1469, 268, 1469 + -96, -61, 22, -353, -89, -353, -75, -353, -25, 3345, + -353, -48, -353, -353, -353, -353, -353, -353, -353, -353, + -353, -353, -353, -353, -353, -353, -353, -353, -353, -353, + -353, -353, -353, 106, -353, -353, -353, -353, -353, -353, + -353, -353, -353, -353, -353, -353, -353, -353, -353, -353, + -353, -353, -353, -353, -353, -353, -353, -353, -353, -353, + -353, -353, -353, -353, -353, -353, -353, -353, -353, -353, + -353, -78, -353, -353, 3, -353, -353, -353, 63, -80, + -353, -353, 3228, -353, -55, -92, -54, -2, -133, -353, + -5, 50, -353, 14, 3572, -353, -353, -353, -56, -353, + 3684, -353, -353, -353, 34, -353, -353, -353, -44, 3572, + -353, 14, -353, 3684, 62, -353, -353, 273, -353, -353, + 87, -353, -353, -353, -353, -353, 3572, 176, 85, -353, + -137, -353, -353, -353, -353, 2454, -353, 33, 3572, 89, + 1856, -353, -15, -353, -33, -353, 28, 42, 997, 43, + 64, 44, 2136, 66, 2907, 48, 69, -68, -353, -353, + -353, -353, -353, 2907, 2907, 2907, -353, -353, -353, -353, + -353, 454, -353, -353, -353, -59, -353, -353, -353, 13, + -17, 3058, 71, 270, 2907, 49, -31, 70, -76, 103, + 57, 60, 61, 144, 145, -85, -353, -353, -104, -353, + 58, 83, -353, -353, -353, -353, -353, -353, 635, -353, + -353, -353, -353, -353, -353, -353, -353, -353, -353, 165, + 3572, -102, -353, 2605, 2907, -353, -353, -353, 82, -353, + -353, 1996, 84, -100, -353, -353, -353, -353, -353, 62, + -353, -353, 172, 1524, 2907, -353, -353, -94, 2907, -90, + -353, 2303, -353, -353, -14, -353, 816, -353, -353, 2907, + 3460, -353, -353, 2907, 90, -353, -353, -353, -353, -353, + -353, -353, -353, -353, -353, -353, -353, -353, 2907, -353, + 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, + 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, + 2907, -353, -353, -353, 91, -353, -353, 2756, 2907, 72, + 93, -353, -353, -353, -353, 2907, 89, -353, -353, 97, + -353, -353, 1691, -7, -353, -4, -353, 94, 179, 99, + -353, -353, 98, 94, 102, -353, -353, -353, -353, -353, + -353, 49, 49, -31, -31, 70, 70, 70, 70, -76, + -76, 103, 57, 60, 61, 144, 145, -58, -353, 2907, + 86, 100, -353, 2907, 88, 101, -353, 2907, -353, 92, + 104, 997, 127, 95, 1177, -353, 2907, 107, 2907, 105, + -353, 2907, -353, 2, 2907, 1177, 255, -353, -353, 2907, + 109, -353, -353, -353, -353, -353, -353, 2907, -353, 130, + 94, -353, 997, -353, 2907, -353, -353, -353, -353, 4, + 1357, 259, 1357 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -325, -325, -325, -325, -325, -325, -325, -325, -325, -325, - -325, -325, -325, 34, -325, -325, -325, -325, -15, -325, - -100, -88, -115, -105, -3, 1, -4, 0, 2, -5, - -325, -130, -171, -325, -139, -211, 5, 24, -325, -325, - -325, 76, 170, 167, 84, -325, -325, -222, -325, -325, - -35, -325, -9, -54, -325, -325, 213, -325, 160, -123, - -325, -12, -290, 62, -137, -323, -324, -252, -64, -76, - 215, 137, 79, -325, -325, -8, -325, -325, -325, -325, - -325, -325, -325, 219, -325 + -353, -353, -353, -353, -353, -353, -353, -353, -353, -353, + -353, -353, -353, 117, -353, -353, -353, -353, -105, -353, + -86, -69, -82, -91, -21, -20, 68, 108, 67, 80, + -353, -111, -148, -353, -149, -219, 12, 32, -353, -353, + -353, 138, 239, 257, 166, -353, -353, -239, -353, -353, + -353, 146, -353, -353, -27, -353, -9, -74, -353, -353, + 309, -353, 250, -130, -353, 73, -244, 147, -140, -340, + -352, -322, 19, 9, 311, 225, 154, -353, -353, 76, + -353, -353, -353, -353, -353, -353, -353, 317, -353 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -155 +#define YYTABLE_NINF -267 static const yytype_int16 yytable[] = { - 95, 220, 119, 256, 233, 301, 238, 107, 240, 352, - 278, 279, -154, 229, 84, 12, 13, 114, 115, 245, - 318, 258, 259, 260, 261, 262, 263, 264, 265, 266, - 267, 289, 298, 85, 120, 121, 122, 377, 376, 119, - 215, 111, 216, 248, 249, 132, 302, 33, 34, 35, - 299, 36, 37, 38, 39, 40, 291, 129, 138, 1, - 217, 253, 291, 370, 294, 254, 126, 5, 398, 397, - 316, 120, 121, 122, 95, 111, 366, 401, 386, 397, - 4, 388, 127, 326, 130, 7, 220, 351, 84, 393, - 318, 109, -36, 280, 281, 355, 313, 395, 327, 135, - 315, 229, 11, 317, 268, 291, 194, 85, 307, 108, - 294, 323, 381, 291, 290, 212, 219, 250, 110, 251, - 348, 292, 320, 381, 308, 135, 291, 135, 302, 314, - 104, 105, 194, 361, 106, 362, 389, 291, 367, 291, - 291, 243, 244, 77, 78, 79, 400, 12, 13, 8, - 291, 347, 120, 121, 122, 194, 276, 277, -98, 271, - 272, 273, 270, 335, 336, 337, 338, 103, 220, 274, - 275, 282, 283, 317, 331, 332, 220, 339, 340, 33, - 34, 35, 302, 36, 37, 38, 39, 40, 333, 334, - 117, 118, 194, 128, 131, 384, 133, 302, 134, 214, - 302, 219, 223, 225, 212, 230, 231, 234, 302, 232, - 235, 236, 239, 242, 257, 135, 302, 241, 373, 220, - 252, 284, 286, 287, 285, 194, 288, -35, 295, 309, - 114, 304, -30, 194, 306, 390, 349, 353, 194, 354, - 357, 363, 291, 364, 365, 368, -36, 369, 375, 371, - 110, 372, 385, 392, 374, 399, 328, 329, 330, 219, - 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, - 219, 219, 219, 219, 219, 379, 164, 387, 394, 396, - 402, 341, 343, 219, 346, 325, 342, 344, 209, 296, - 345, 219, 213, 112, 224, 356, 310, 297, 378, 391, - 116, 247, 113, 194, 358, 0, 0, 0, 0, 0, - 0, 0, 0, 311, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 219, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 194, 0, 0, 194, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 194, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 194, 0, 0, 0, 0, 0, 0, - 0, 194, 0, 194, 12, 13, 14, 15, 16, 17, - 139, 140, 141, 0, 142, 143, 144, 145, 146, 147, - 148, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 149, - 150, 151, 152, 153, 154, 155, 0, 0, 156, 157, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, - 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 81, 0, 82, 0, 0, 0, 0, - 158, 0, 0, 0, 0, 0, 159, 160, 161, 162, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 163, 164, 165, 12, 13, 14, 15, 16, 17, - 139, 140, 141, 0, 142, 143, 144, 145, 146, 147, - 148, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 149, - 150, 151, 152, 153, 154, 155, 0, 0, 156, 157, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, - 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 81, 0, 82, 0, 0, 0, 0, - 158, 0, 0, 0, 0, 0, 159, 160, 161, 162, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 163, 164, 246, 12, 13, 14, 15, 16, 17, - 139, 140, 141, 0, 142, 143, 144, 145, 146, 147, - 148, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 149, - 150, 151, 152, 153, 154, 155, 0, 0, 156, 157, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, - 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 96, 108, 121, 247, 310, 249, 12, 13, 242, 298, + 236, -160, 328, 287, 288, 1, 254, 12, 13, 387, + 4, 83, 5, 222, 227, 223, 136, 7, 257, 258, + 226, 386, 128, 265, 122, 123, 124, 8, 33, 142, + 34, 84, 35, 224, 36, 37, 38, 112, 129, 33, + 408, 34, 391, 35, 11, 36, 37, 38, 252, 253, + 307, 300, 407, 391, 362, 316, 133, 104, 303, 119, + 411, 300, 407, 96, 130, 300, 311, 301, 308, 279, + 114, 317, 110, 328, 112, 134, 131, 324, 361, 326, + 132, 121, -36, 299, 83, 323, 365, 289, 290, 325, + 139, 236, 327, 259, 109, 260, 135, 300, 201, 111, + 333, 120, 227, 137, 84, 336, 303, 219, 226, 380, + 111, 376, 79, 122, 123, 124, 116, 117, 238, 139, + 337, 139, 239, 79, 396, 283, 284, 398, 138, 201, + 377, 143, 105, 106, 262, 403, 107, 330, 263, 230, + 357, 300, 358, 405, 371, 285, 286, 372, 300, -98, + 311, 300, 201, 399, 221, 410, 237, 300, 232, 300, + 75, 76, 77, 327, 261, 338, 339, 340, 226, 226, + 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, + 226, 226, 226, 226, 291, 292, 227, 341, 342, 201, + 349, 350, 226, 243, 227, 345, 346, 347, 348, 240, + 226, 219, 122, 123, 124, 311, 343, 344, 383, 280, + 281, 282, 139, 241, 244, 245, 248, 250, 394, 251, + 311, 266, 293, 311, 201, 400, 294, 296, 295, 116, + 297, 311, 201, -35, 304, 313, 315, 201, 227, 311, + 319, -30, 363, 359, 226, 409, 364, 367, 373, 300, + 374, 375, -36, 379, 382, 385, 378, 402, 381, 404, + 395, 412, 351, 384, 352, 389, 12, 13, 14, 15, + 16, 17, 146, 147, 148, 397, 149, 150, 151, 152, + 153, 154, 155, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 171, + 34, 406, 35, 201, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 156, 157, 158, 159, 160, 161, 162, 305, 216, + 163, 164, 201, 353, 355, 201, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 201, 335, 356, 74, + 75, 76, 77, 78, 220, 318, 306, 113, 231, 366, + 320, 388, 79, 201, 401, 118, 256, 321, 368, 115, + 0, 201, 0, 201, 354, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, + 0, 0, 0, 165, 0, 0, 0, 0, 0, 166, + 167, 168, 169, 0, 0, 0, 0, 0, 0, 0, + 277, 0, 0, 0, 170, 171, 172, 12, 13, 14, + 15, 16, 17, 146, 147, 148, 0, 149, 150, 151, + 152, 153, 154, 155, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 0, 34, 0, 35, 0, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 156, 157, 158, 159, 160, 161, 162, 0, + 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 81, 0, 82, 0, 0, 0, 0, - 158, 0, 0, 0, 0, 0, 159, 160, 161, 162, + 74, 75, 76, 77, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 163, 164, 293, 12, 13, 14, 15, 16, 17, - 139, 140, 141, 0, 142, 143, 144, 145, 146, 147, - 148, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 149, - 150, 151, 152, 153, 154, 155, 0, 0, 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, - 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, + 0, 0, 0, 0, 165, 0, 0, 0, 0, 0, + 166, 167, 168, 169, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 170, 171, 255, 12, 13, + 14, 15, 16, 17, 146, 147, 148, 0, 149, 150, + 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 0, 34, 0, 35, 0, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 156, 157, 158, 159, 160, 161, 162, + 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 74, 75, 76, 77, 78, 0, 0, 0, 0, + 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 81, 0, 82, 0, 0, 0, 0, - 158, 0, 0, 0, 0, 0, 159, 160, 161, 162, + 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, + 81, 0, 0, 0, 0, 165, 0, 0, 0, 0, + 0, 166, 167, 168, 169, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 170, 171, 302, 12, + 13, 14, 15, 16, 17, 146, 147, 148, 0, 149, + 150, 151, 152, 153, 154, 155, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 0, 34, 0, 35, 0, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 156, 157, 158, 159, 160, 161, + 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 163, 164, 321, 12, 13, 14, 15, 16, 17, - 139, 140, 141, 0, 142, 143, 144, 145, 146, 147, - 148, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 149, - 150, 151, 152, 153, 154, 155, 0, 0, 156, 157, + 0, 0, 74, 75, 76, 77, 78, 0, 0, 0, + 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, - 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, + 0, 81, 0, 0, 0, 0, 165, 0, 0, 0, + 0, 0, 166, 167, 168, 169, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 170, 171, 331, + 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, + 149, 150, 151, 152, 153, 154, 155, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 156, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 74, 75, 76, 77, 78, 0, 0, + 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 81, 0, 82, 0, 0, 0, 0, - 158, 0, 0, 0, 0, 0, 159, 160, 161, 162, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 163, 164, 12, 13, 14, 15, 16, 17, 139, - 140, 141, 0, 142, 380, 144, 145, 146, 147, 148, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 0, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 149, 150, - 151, 152, 153, 154, 155, 0, 0, 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 76, 77, 78, 79, - 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 80, 0, 81, 0, 0, 0, 0, 165, 0, 0, + 0, 0, 0, 166, 167, 168, 169, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 170, 171, + 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, + 149, 390, 151, 152, 153, 154, 155, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 156, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 74, 75, 76, 77, 78, 0, 0, + 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 81, 0, 82, 0, 0, 0, 0, 158, - 0, 0, 0, 0, 0, 159, 160, 161, 162, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 163, 115, 12, 13, 14, 15, 16, 17, 139, 140, - 141, 0, 142, 380, 144, 145, 146, 147, 148, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 0, 36, 37, + 80, 0, 81, 0, 0, 0, 0, 165, 0, 0, + 0, 0, 0, 166, 167, 168, 169, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 170, 117, + 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, + 149, 390, 151, 152, 153, 154, 155, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 149, 150, 151, - 152, 153, 154, 155, 0, 0, 156, 157, 0, 0, + 68, 69, 70, 71, 72, 156, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 76, 77, 78, 79, 80, + 0, 0, 0, 74, 75, 76, 77, 78, 0, 0, + 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 80, 0, 81, 0, 0, 0, 0, 165, 0, 0, + 0, 0, 0, 166, 167, 168, 169, 12, 13, 14, + 15, 16, 17, 0, 0, 0, 0, 0, 170, 171, + 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 0, 34, 0, 35, 0, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 0, 157, 158, 159, 160, 161, 162, 0, + 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 81, 0, 82, 0, 0, 0, 0, 158, 0, - 0, 0, 0, 0, 159, 160, 161, 162, 12, 13, - 14, 15, 16, 17, 0, 0, 0, 0, 0, 163, - 164, 0, 0, 0, 0, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 0, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 0, 150, 151, 152, 153, 154, 155, - 0, 0, 156, 157, 0, 0, 0, 0, 0, 0, + 74, 75, 76, 77, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 76, 77, 78, 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, + 0, 0, 0, 0, 165, 0, 0, 0, 0, 0, + 166, 167, 168, 169, 12, 13, 14, 15, 16, 17, + 0, 0, 0, 0, 0, 170, 0, 0, 0, 0, + 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 0, 34, 0, + 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, + 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 111, 75, 76, + 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 81, 0, 82, - 0, 0, 0, 0, 158, 0, 0, 0, 0, 0, - 159, 160, 161, 162, 14, 15, 16, 17, 0, 0, - 0, 0, 0, 0, 0, 163, 0, 0, 0, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, + 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, + 169, 14, 15, 16, 17, 0, 0, 0, 0, 0, + 0, 0, -266, 0, 0, 0, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, - 0, 81, 0, 82, 0, 0, 0, 0, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, - 0, 228, 41, 42, 43, 44, 45, 46, 47, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 14, 15, 16, 17, 0, 0, 0, 0, 80, + 0, 81, 0, 0, 0, 0, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, 235, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 0, 75, 0, 0, + 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 77, 78, 79, 0, 0, + 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, - 81, 0, 82, 0, 0, 0, 0, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, - 305, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 0, 150, 151, 152, 153, - 154, 155, 0, 0, 156, 157, 0, 0, 0, 0, + 0, 14, 15, 16, 17, 0, 0, 0, 0, 80, + 0, 81, 0, 0, 0, 0, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, 314, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 0, 157, 158, 159, 160, 161, + 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 77, 78, 79, 0, 0, 0, + 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, - 0, 82, 0, 0, 0, 0, 158, 0, 0, 0, - 0, 0, 159, 160, 161, 162, 12, 13, 14, 15, - 16, 17, 0, 0, 0, 0, 0, 237, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, + 0, 81, 0, 0, 0, 0, 165, 0, 0, 0, + 0, 0, 166, 167, 168, 169, 12, 13, 14, 15, + 16, 17, 0, 0, 0, 0, 0, 246, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 0, 150, 151, 152, 153, 154, 155, 0, 0, - 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, - 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, + 34, 0, 35, 0, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 0, 157, 158, 159, 160, 161, 162, 0, 0, + 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, + 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 81, 0, 82, 14, 15, - 16, 17, 158, 0, 0, 0, 0, 0, 159, 160, - 161, 162, 0, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 0, 150, 151, 152, 153, 154, 155, 0, 0, - 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 80, 0, 81, 14, + 15, 16, 17, 165, 0, 0, 0, 0, 0, 166, + 167, 168, 169, 0, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 0, 157, 158, 159, 160, 161, 162, 0, + 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 81, 0, 82, 14, 15, - 16, 17, 158, 0, 0, 218, 0, 0, 159, 160, - 161, 162, 0, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 0, 150, 151, 152, 153, 154, 155, 0, 0, - 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, + 14, 15, 16, 17, 165, 0, 0, 225, 0, 0, + 166, 167, 168, 169, 0, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 0, 157, 158, 159, 160, 161, 162, + 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 81, 0, 82, 14, 15, - 16, 17, 158, 0, 0, 300, 0, 0, 159, 160, - 161, 162, 0, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 0, 150, 151, 152, 153, 154, 155, 0, 0, - 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, + 81, 14, 15, 16, 17, 165, 0, 0, 309, 0, + 0, 166, 167, 168, 169, 0, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 0, 157, 158, 159, 160, 161, + 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 81, 0, 82, 14, 15, - 16, 17, 158, 0, 0, 350, 0, 0, 159, 160, - 161, 162, 0, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 0, 150, 151, 152, 153, 154, 155, 0, 0, - 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, + 0, 81, 14, 15, 16, 17, 165, 0, 0, 360, + 0, 0, 166, 167, 168, 169, 0, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 81, 0, 82, 14, 15, - 16, 17, 158, 0, 0, 0, 0, 0, 159, 160, - 161, 162, 0, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 255, 0, 150, 151, 152, 153, 154, 155, 0, 0, - 156, 157, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 77, 78, 79, 0, 0, 0, 0, 0, 0, 0, + 80, 0, 81, 14, 15, 16, 17, 165, 0, 0, + 0, 0, 0, 166, 167, 168, 169, 0, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 264, 0, 157, 158, 159, + 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 81, 0, 82, 0, 0, - 0, 0, 158, 0, 0, 0, 0, 0, 159, 160, - 161, 162, 12, 13, 14, 15, 16, 17, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 0, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 76, 77, 78, 79, 80, - 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, - 0, 81, 0, 82, 41, 42, 43, 44, 45, 46, + 0, 80, 0, 81, 0, 0, 0, 0, 165, 0, + 0, 0, 0, 0, 166, 167, 168, 169, -3, 0, + 0, 12, 13, 14, 15, 16, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 0, 34, 0, 35, 0, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 0, 324, - 0, 0, 0, 0, 155, 0, 0, 0, 0, 0, + 67, 68, 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 77, 78, 79, - 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, - 0, 0, 81, 0, 82, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 0, - 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 74, 75, 76, 77, 78, 0, + 0, 0, 0, 0, 0, 0, 0, 79, 12, 13, + 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 80, 34, 81, 35, 0, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 77, 78, - 79, 0, 0, 0, 0, 0, 0, 14, 15, 16, + 0, 74, 75, 76, 77, 78, 0, 0, 0, 0, + 0, 0, 0, 0, 79, 14, 15, 16, 17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 0, 0, 0, 80, 0, + 81, 0, 0, 0, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 0, 334, + 0, 0, 0, 0, 162, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 75, 76, 77, + 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, - 0, 0, 0, 81, 0, 82, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 80, 0, 81, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, + 76, 77, 0, 0, 0, 0, 0, 0, 0, 14, + 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, + 0, 0, 0, 0, 0, 80, 0, 81, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 81, 0, 82 + 0, 0, 0, 0, 0, 0, 0, 80, 0, 81 }; static const yytype_int16 yycheck[] = { - 9, 131, 4, 174, 141, 216, 145, 79, 147, 299, - 89, 90, 79, 136, 9, 3, 4, 180, 181, 158, - 242, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 94, 161, 9, 36, 37, 38, 361, 361, 4, - 159, 76, 161, 87, 88, 99, 217, 35, 36, 37, - 179, 39, 40, 41, 42, 43, 164, 92, 112, 111, - 179, 160, 164, 353, 201, 164, 164, 0, 392, 392, - 178, 36, 37, 38, 83, 110, 178, 400, 368, 402, - 81, 371, 180, 254, 93, 116, 216, 298, 83, 379, - 312, 79, 159, 172, 173, 306, 235, 387, 269, 108, - 239, 224, 79, 242, 179, 164, 115, 83, 164, 181, - 247, 250, 364, 164, 177, 124, 131, 161, 106, 163, - 291, 180, 160, 375, 180, 134, 164, 136, 299, 180, - 36, 37, 141, 160, 40, 160, 160, 164, 349, 164, - 164, 156, 157, 107, 108, 109, 160, 3, 4, 112, - 164, 290, 36, 37, 38, 164, 85, 86, 160, 169, - 170, 171, 177, 278, 279, 280, 281, 115, 298, 165, - 166, 91, 92, 312, 274, 275, 306, 282, 283, 35, - 36, 37, 353, 39, 40, 41, 42, 43, 276, 277, - 160, 164, 201, 79, 161, 366, 79, 368, 181, 79, - 371, 216, 116, 79, 213, 180, 180, 159, 379, 180, - 159, 180, 159, 159, 159, 224, 387, 178, 357, 349, - 160, 174, 176, 93, 175, 234, 95, 159, 79, 78, - 180, 162, 160, 242, 161, 374, 161, 179, 247, 162, - 159, 79, 164, 160, 162, 179, 159, 162, 160, 179, - 106, 162, 162, 12, 180, 394, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 179, 181, 179, 159, 180, - 12, 284, 286, 298, 289, 251, 285, 287, 118, 213, - 288, 306, 125, 80, 134, 307, 234, 213, 362, 375, - 85, 164, 83, 312, 312, -1, -1, -1, -1, -1, - -1, -1, -1, 234, -1, -1, -1, -1, -1, -1, + 9, 79, 4, 152, 223, 154, 3, 4, 148, 94, + 140, 79, 251, 89, 90, 111, 165, 3, 4, 371, + 81, 9, 0, 160, 135, 162, 100, 116, 87, 88, + 135, 371, 165, 181, 36, 37, 38, 112, 35, 113, + 37, 9, 39, 180, 41, 42, 43, 74, 181, 35, + 402, 37, 374, 39, 79, 41, 42, 43, 163, 164, + 162, 165, 402, 385, 308, 165, 93, 115, 208, 161, + 410, 165, 412, 82, 79, 165, 224, 181, 180, 184, + 160, 181, 79, 322, 111, 94, 36, 181, 307, 179, + 40, 4, 160, 178, 82, 244, 315, 173, 174, 248, + 109, 231, 251, 162, 182, 164, 162, 165, 117, 106, + 259, 165, 223, 79, 82, 263, 256, 126, 223, 363, + 106, 179, 119, 36, 37, 38, 181, 182, 161, 138, + 278, 140, 165, 119, 378, 166, 167, 381, 182, 148, + 359, 79, 36, 37, 161, 389, 40, 161, 165, 116, + 299, 165, 300, 397, 161, 85, 86, 161, 165, 161, + 308, 165, 171, 161, 79, 161, 181, 165, 79, 165, + 107, 108, 109, 322, 161, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 91, 92, 307, 283, 284, 208, + 291, 292, 307, 160, 315, 287, 288, 289, 290, 181, + 315, 220, 36, 37, 38, 363, 285, 286, 367, 170, + 171, 172, 231, 181, 160, 181, 160, 179, 376, 160, + 378, 160, 175, 381, 243, 384, 176, 93, 177, 181, + 95, 389, 251, 160, 79, 163, 162, 256, 359, 397, + 78, 161, 180, 162, 359, 404, 163, 160, 79, 165, + 161, 163, 160, 163, 163, 161, 180, 12, 180, 160, + 163, 12, 293, 181, 294, 180, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 180, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 182, + 37, 181, 39, 322, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 220, 120, + 87, 88, 371, 295, 297, 374, 96, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 385, 260, 298, 106, + 107, 108, 109, 110, 127, 239, 220, 78, 138, 316, + 243, 372, 119, 402, 385, 84, 171, 243, 322, 82, + -1, 410, -1, 412, 296, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 349, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 153, -1, 155, -1, + -1, -1, -1, 160, -1, -1, -1, -1, -1, 166, + 167, 168, 169, -1, -1, -1, -1, -1, -1, -1, + 180, -1, -1, -1, 181, 182, 183, 3, 4, 5, + 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + -1, 37, -1, 39, -1, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 84, -1, + -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 361, -1, -1, 364, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 375, -1, -1, -1, + 106, 107, 108, 109, 110, -1, -1, -1, -1, -1, + -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 392, -1, -1, -1, -1, -1, -1, - -1, 400, -1, 402, 3, 4, 5, 6, 7, 8, - 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, - 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 153, -1, 155, + -1, -1, -1, -1, 160, -1, -1, -1, -1, -1, + 166, 167, 168, 169, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 181, 182, 183, 3, 4, + 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, -1, 37, -1, 39, -1, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 106, 107, 108, 109, 110, -1, -1, -1, -1, + -1, -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 152, -1, 154, -1, -1, -1, -1, - 159, -1, -1, -1, -1, -1, 165, 166, 167, 168, + -1, -1, -1, -1, -1, -1, -1, -1, 153, -1, + 155, -1, -1, -1, -1, 160, -1, -1, -1, -1, + -1, 166, 167, 168, 169, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 181, 182, 183, 3, + 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, -1, 37, -1, 39, -1, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 180, 181, 182, 3, 4, 5, 6, 7, 8, - 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, + -1, -1, 106, 107, 108, 109, 110, -1, -1, -1, + -1, -1, -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, - 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 153, + -1, 155, -1, -1, -1, -1, 160, -1, -1, -1, + -1, -1, 166, 167, 168, 169, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 181, 182, 183, + 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 106, 107, 108, 109, 110, -1, -1, + -1, -1, -1, -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 152, -1, 154, -1, -1, -1, -1, - 159, -1, -1, -1, -1, -1, 165, 166, 167, 168, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 180, 181, 182, 3, 4, 5, 6, 7, 8, - 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, - 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, + 153, -1, 155, -1, -1, -1, -1, 160, -1, -1, + -1, -1, -1, 166, 167, 168, 169, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 181, 182, + 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 106, 107, 108, 109, 110, -1, -1, + -1, -1, -1, -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 152, -1, 154, -1, -1, -1, -1, - 159, -1, -1, -1, -1, -1, 165, 166, 167, 168, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 180, 181, 182, 3, 4, 5, 6, 7, 8, - 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, + 153, -1, 155, -1, -1, -1, -1, 160, -1, -1, + -1, -1, -1, 166, 167, 168, 169, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 181, 182, + 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 106, 107, 108, 109, 110, -1, -1, + -1, -1, -1, -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, - 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 153, -1, 155, -1, -1, -1, -1, 160, -1, -1, + -1, -1, -1, 166, 167, 168, 169, 3, 4, 5, + 6, 7, 8, -1, -1, -1, -1, -1, 181, 182, + -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + -1, 37, -1, 39, -1, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, -1, 79, 80, 81, 82, 83, 84, -1, + -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 152, -1, 154, -1, -1, -1, -1, - 159, -1, -1, -1, -1, -1, 165, 166, 167, 168, + 106, 107, 108, 109, 110, -1, -1, -1, -1, -1, + -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 180, 181, 182, 3, 4, 5, 6, 7, 8, - 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 153, -1, 155, + -1, -1, -1, -1, 160, -1, -1, -1, -1, -1, + 166, 167, 168, 169, 3, 4, 5, 6, 7, 8, + -1, -1, -1, -1, -1, 181, -1, -1, -1, -1, + -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, -1, 37, -1, + 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, - 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 152, -1, 154, -1, -1, -1, -1, - 159, -1, -1, -1, -1, -1, 165, 166, 167, 168, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 180, 181, 3, 4, 5, 6, 7, 8, 9, - 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, -1, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 106, 107, 108, 109, - 110, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 152, -1, 154, -1, -1, -1, -1, 159, - -1, -1, -1, -1, -1, 165, 166, 167, 168, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 180, 181, 3, 4, 5, 6, 7, 8, 9, 10, - 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, -1, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 106, 107, 108, 109, 110, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 152, -1, 154, -1, -1, -1, -1, 159, -1, - -1, -1, -1, -1, 165, 166, 167, 168, 3, 4, - 5, 6, 7, 8, -1, -1, -1, -1, -1, 180, - 181, -1, -1, -1, -1, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, -1, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, - -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 106, 107, 108, 109, 110, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 152, -1, 154, - -1, -1, -1, -1, 159, -1, -1, -1, -1, -1, - 165, 166, 167, 168, 5, 6, 7, 8, -1, -1, - -1, -1, -1, -1, -1, 180, -1, -1, -1, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, -1, 79, -1, + -1, -1, -1, -1, 153, -1, 155, -1, -1, -1, + -1, 160, -1, -1, -1, -1, -1, 166, 167, 168, + 169, 5, 6, 7, 8, -1, -1, -1, -1, -1, + -1, -1, 181, -1, -1, -1, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 107, 108, 109, -1, + -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 5, 6, 7, 8, -1, -1, -1, - -1, 152, -1, 154, -1, -1, -1, -1, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, -1, -1, -1, -1, -1, -1, -1, - -1, 182, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, -1, 79, -1, -1, + -1, 5, 6, 7, 8, -1, -1, -1, -1, 153, + -1, 155, -1, -1, -1, -1, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, -1, -1, -1, -1, -1, -1, -1, 183, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, + -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, - 152, -1, 154, -1, -1, -1, -1, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, - 182, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, 5, 6, 7, 8, -1, -1, -1, -1, 153, + -1, 155, -1, -1, -1, -1, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, -1, -1, -1, -1, -1, -1, -1, 183, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, -1, 79, 80, 81, 82, 83, + 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, + -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 152, - -1, 154, -1, -1, -1, -1, 159, -1, -1, -1, - -1, -1, 165, 166, 167, 168, 3, 4, 5, 6, - 7, 8, -1, -1, -1, -1, -1, 180, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 153, + -1, 155, -1, -1, -1, -1, 160, -1, -1, -1, + -1, -1, 166, 167, 168, 169, 3, 4, 5, 6, + 7, 8, -1, -1, -1, -1, -1, 181, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, -1, 39, 40, 41, 42, 43, 44, 45, 46, + 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, + 37, -1, 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, @@ -1695,182 +1727,196 @@ static const yytype_int16 yycheck[] = 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 153, -1, 155, 5, + 6, 7, 8, 160, -1, -1, -1, -1, -1, 166, + 167, 168, 169, -1, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, -1, 79, 80, 81, 82, 83, 84, -1, + -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 152, -1, 154, 5, 6, - 7, 8, 159, -1, -1, -1, -1, -1, 165, 166, - 167, 168, -1, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, - 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 153, -1, 155, + 5, 6, 7, 8, 160, -1, -1, 163, -1, -1, + 166, 167, 168, 169, -1, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, + -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 152, -1, 154, 5, 6, - 7, 8, 159, -1, -1, 162, -1, -1, 165, 166, - 167, 168, -1, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, - 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 153, -1, + 155, 5, 6, 7, 8, 160, -1, -1, 163, -1, + -1, 166, 167, 168, 169, -1, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, -1, 79, 80, 81, 82, 83, + 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 152, -1, 154, 5, 6, - 7, 8, 159, -1, -1, 162, -1, -1, 165, 166, - 167, 168, -1, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, - 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 153, + -1, 155, 5, 6, 7, 8, 160, -1, -1, 163, + -1, -1, 166, 167, 168, 169, -1, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 152, -1, 154, 5, 6, - 7, 8, 159, -1, -1, 162, -1, -1, 165, 166, - 167, 168, -1, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, - 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 152, -1, 154, 5, 6, - 7, 8, 159, -1, -1, -1, -1, -1, 165, 166, - 167, 168, -1, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, - 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + 153, -1, 155, 5, 6, 7, 8, 160, -1, -1, + -1, -1, -1, 166, 167, 168, 169, -1, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, -1, 79, 80, 81, + 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 152, -1, 154, -1, -1, - -1, -1, 159, -1, -1, -1, -1, -1, 165, 166, - 167, 168, 3, 4, 5, 6, 7, 8, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, -1, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 153, -1, 155, -1, -1, -1, -1, 160, -1, + -1, -1, -1, -1, 166, 167, 168, 169, 0, -1, + -1, 3, 4, 5, 6, 7, 8, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, -1, 37, -1, 39, -1, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 106, 107, 108, 109, 110, - -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 106, 107, 108, 109, 110, -1, + -1, -1, -1, -1, -1, -1, -1, 119, 3, 4, + 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 153, 37, 155, 39, -1, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 106, 107, 108, 109, 110, -1, -1, -1, -1, + -1, -1, -1, -1, 119, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, -1, -1, -1, -1, -1, - -1, 152, -1, 154, 44, 45, 46, 47, 48, 49, + 30, 31, 32, 33, 34, -1, -1, -1, 153, -1, + 155, -1, -1, -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, 84, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 107, 108, 109, - -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, -1, -1, -1, -1, - -1, -1, 152, -1, 154, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, - 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 107, 108, - 109, -1, -1, -1, -1, -1, -1, 5, 6, 7, + -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, -1, - -1, -1, -1, 152, -1, 154, 44, 45, 46, 47, + -1, -1, -1, 153, -1, 155, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 107, + 108, 109, -1, -1, -1, -1, -1, -1, -1, 5, + 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + -1, -1, -1, -1, -1, 153, -1, 155, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 152, -1, 154 + -1, -1, -1, -1, -1, -1, -1, 153, -1, 155 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { - 0, 111, 184, 186, 81, 0, 187, 116, 112, 185, - 188, 79, 3, 4, 5, 6, 7, 8, 20, 21, + 0, 111, 185, 187, 81, 0, 188, 116, 112, 186, + 189, 79, 3, 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 79, 106, 107, 108, 109, - 110, 152, 154, 189, 219, 220, 221, 222, 223, 228, - 229, 230, 231, 233, 234, 235, 236, 237, 238, 239, - 240, 266, 267, 115, 36, 37, 40, 79, 181, 79, - 106, 233, 239, 266, 180, 181, 253, 160, 164, 4, - 36, 37, 38, 225, 226, 232, 164, 180, 79, 233, - 235, 161, 236, 79, 181, 235, 241, 242, 236, 9, - 10, 11, 13, 14, 15, 16, 17, 18, 19, 78, - 79, 80, 81, 82, 83, 84, 87, 88, 159, 165, - 166, 167, 168, 180, 181, 182, 190, 191, 192, 194, - 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, - 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, - 215, 217, 219, 220, 235, 246, 247, 248, 249, 250, - 251, 254, 255, 256, 257, 259, 260, 261, 265, 225, - 224, 227, 235, 226, 79, 159, 161, 179, 162, 201, - 214, 218, 235, 116, 241, 79, 243, 244, 182, 242, - 180, 180, 180, 247, 159, 159, 180, 180, 217, 159, - 217, 178, 159, 201, 201, 217, 182, 254, 87, 88, - 161, 163, 160, 160, 164, 77, 215, 159, 96, 97, - 98, 99, 100, 101, 102, 103, 104, 105, 179, 216, - 201, 169, 170, 171, 165, 166, 85, 86, 89, 90, - 172, 173, 91, 92, 174, 175, 176, 93, 95, 94, - 177, 164, 180, 182, 247, 79, 224, 227, 161, 179, - 162, 218, 215, 245, 162, 182, 161, 164, 180, 78, - 246, 255, 262, 217, 180, 217, 178, 217, 230, 258, - 160, 182, 193, 217, 79, 196, 215, 215, 201, 201, - 201, 203, 203, 204, 204, 205, 205, 205, 205, 206, - 206, 207, 208, 209, 210, 211, 212, 217, 215, 161, - 162, 218, 245, 179, 162, 218, 244, 159, 258, 263, - 264, 160, 160, 79, 160, 162, 178, 218, 179, 162, - 245, 179, 162, 217, 180, 160, 248, 249, 251, 179, - 14, 250, 252, 253, 215, 162, 245, 179, 245, 160, - 217, 252, 12, 245, 159, 245, 180, 248, 249, 217, - 160, 248, 12 + 32, 33, 34, 35, 37, 39, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 79, 106, 107, 108, 109, 110, 119, + 153, 155, 190, 220, 221, 222, 223, 224, 229, 230, + 231, 232, 233, 236, 238, 239, 240, 241, 242, 243, + 244, 245, 271, 272, 115, 36, 37, 40, 79, 182, + 79, 106, 238, 244, 160, 271, 181, 182, 258, 161, + 165, 4, 36, 37, 38, 226, 227, 237, 165, 181, + 79, 36, 40, 238, 240, 162, 241, 79, 182, 240, + 246, 247, 241, 79, 234, 235, 9, 10, 11, 13, + 14, 15, 16, 17, 18, 19, 78, 79, 80, 81, + 82, 83, 84, 87, 88, 160, 166, 167, 168, 169, + 181, 182, 183, 191, 192, 193, 195, 196, 197, 198, + 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, + 209, 210, 211, 212, 213, 214, 215, 216, 218, 220, + 221, 240, 251, 252, 253, 254, 255, 256, 259, 260, + 261, 262, 264, 265, 266, 270, 226, 225, 228, 240, + 227, 79, 160, 162, 180, 163, 202, 215, 219, 240, + 116, 246, 79, 248, 249, 183, 247, 181, 161, 165, + 181, 181, 252, 160, 160, 181, 181, 218, 160, 218, + 179, 160, 202, 202, 218, 183, 259, 87, 88, 162, + 164, 161, 161, 165, 77, 216, 160, 96, 97, 98, + 99, 100, 101, 102, 103, 104, 105, 180, 217, 202, + 170, 171, 172, 166, 167, 85, 86, 89, 90, 173, + 174, 91, 92, 175, 176, 177, 93, 95, 94, 178, + 165, 181, 183, 252, 79, 225, 228, 162, 180, 163, + 219, 216, 250, 163, 183, 162, 165, 181, 235, 78, + 251, 260, 267, 218, 181, 218, 179, 218, 231, 263, + 161, 183, 194, 218, 79, 197, 216, 216, 202, 202, + 202, 204, 204, 205, 205, 206, 206, 206, 206, 207, + 207, 208, 209, 210, 211, 212, 213, 218, 216, 162, + 163, 219, 250, 180, 163, 219, 249, 160, 263, 268, + 269, 161, 161, 79, 161, 163, 179, 219, 180, 163, + 250, 180, 163, 218, 181, 161, 253, 254, 256, 180, + 14, 255, 257, 258, 216, 163, 250, 180, 250, 161, + 218, 257, 12, 250, 160, 250, 181, 253, 254, 218, + 161, 253, 12 }; #define yyerrok (yyerrstatus = 0) @@ -2724,7 +2770,7 @@ yyreduce: case 2: /* Line 1455 of yacc.c */ -#line 190 "glsl_parser.ypp" +#line 193 "glsl_parser.ypp" { _mesa_glsl_initialize_types(state); ;} @@ -2733,7 +2779,7 @@ yyreduce: case 4: /* Line 1455 of yacc.c */ -#line 198 "glsl_parser.ypp" +#line 201 "glsl_parser.ypp" { state->language_version = 110; ;} @@ -2742,7 +2788,7 @@ yyreduce: case 5: /* Line 1455 of yacc.c */ -#line 202 "glsl_parser.ypp" +#line 205 "glsl_parser.ypp" { switch ((yyvsp[(2) - (3)].n)) { case 110: @@ -2762,7 +2808,7 @@ yyreduce: case 8: /* Line 1455 of yacc.c */ -#line 225 "glsl_parser.ypp" +#line 228 "glsl_parser.ypp" { if (!_mesa_glsl_process_extension((yyvsp[(2) - (5)].identifier), & (yylsp[(2) - (5)]), (yyvsp[(4) - (5)].identifier), & (yylsp[(4) - (5)]), state)) { YYERROR; @@ -2773,7 +2819,7 @@ yyreduce: case 9: /* Line 1455 of yacc.c */ -#line 234 "glsl_parser.ypp" +#line 237 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -2786,7 +2832,7 @@ yyreduce: case 10: /* Line 1455 of yacc.c */ -#line 242 "glsl_parser.ypp" +#line 245 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -2799,7 +2845,7 @@ yyreduce: case 12: /* Line 1455 of yacc.c */ -#line 257 "glsl_parser.ypp" +#line 260 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); @@ -2811,7 +2857,7 @@ yyreduce: case 13: /* Line 1455 of yacc.c */ -#line 264 "glsl_parser.ypp" +#line 267 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); @@ -2823,7 +2869,7 @@ yyreduce: case 14: /* Line 1455 of yacc.c */ -#line 271 "glsl_parser.ypp" +#line 274 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); @@ -2835,7 +2881,7 @@ yyreduce: case 15: /* Line 1455 of yacc.c */ -#line 278 "glsl_parser.ypp" +#line 281 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); @@ -2847,7 +2893,7 @@ yyreduce: case 16: /* Line 1455 of yacc.c */ -#line 285 "glsl_parser.ypp" +#line 288 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); @@ -2859,7 +2905,7 @@ yyreduce: case 17: /* Line 1455 of yacc.c */ -#line 292 "glsl_parser.ypp" +#line 295 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(2) - (3)].expression); ;} @@ -2868,7 +2914,7 @@ yyreduce: case 19: /* Line 1455 of yacc.c */ -#line 300 "glsl_parser.ypp" +#line 303 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_array_index, (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression), NULL); @@ -2879,7 +2925,7 @@ yyreduce: case 20: /* Line 1455 of yacc.c */ -#line 306 "glsl_parser.ypp" +#line 309 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} @@ -2888,7 +2934,7 @@ yyreduce: case 21: /* Line 1455 of yacc.c */ -#line 310 "glsl_parser.ypp" +#line 313 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), NULL, NULL); @@ -2900,7 +2946,7 @@ yyreduce: case 22: /* Line 1455 of yacc.c */ -#line 317 "glsl_parser.ypp" +#line 320 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_inc, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -2911,7 +2957,7 @@ yyreduce: case 23: /* Line 1455 of yacc.c */ -#line 323 "glsl_parser.ypp" +#line 326 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_dec, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -2922,7 +2968,7 @@ yyreduce: case 27: /* Line 1455 of yacc.c */ -#line 341 "glsl_parser.ypp" +#line 344 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -2933,7 +2979,7 @@ yyreduce: case 32: /* Line 1455 of yacc.c */ -#line 360 "glsl_parser.ypp" +#line 363 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (2)].expression); (yyval.expression)->set_location(yylloc); @@ -2944,7 +2990,7 @@ yyreduce: case 33: /* Line 1455 of yacc.c */ -#line 366 "glsl_parser.ypp" +#line 369 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (3)].expression); (yyval.expression)->set_location(yylloc); @@ -2955,7 +3001,7 @@ yyreduce: case 35: /* Line 1455 of yacc.c */ -#line 382 "glsl_parser.ypp" +#line 385 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_function_expression((yyvsp[(1) - (1)].type_specifier)); @@ -2966,7 +3012,7 @@ yyreduce: case 36: /* Line 1455 of yacc.c */ -#line 388 "glsl_parser.ypp" +#line 391 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -2978,7 +3024,7 @@ yyreduce: case 37: /* Line 1455 of yacc.c */ -#line 395 "glsl_parser.ypp" +#line 398 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -2990,7 +3036,7 @@ yyreduce: case 39: /* Line 1455 of yacc.c */ -#line 407 "glsl_parser.ypp" +#line 410 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_inc, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3001,7 +3047,7 @@ yyreduce: case 40: /* Line 1455 of yacc.c */ -#line 413 "glsl_parser.ypp" +#line 416 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_dec, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3012,7 +3058,7 @@ yyreduce: case 41: /* Line 1455 of yacc.c */ -#line 419 "glsl_parser.ypp" +#line 422 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(1) - (2)].n), (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3023,35 +3069,35 @@ yyreduce: case 42: /* Line 1455 of yacc.c */ -#line 428 "glsl_parser.ypp" +#line 431 "glsl_parser.ypp" { (yyval.n) = ast_plus; ;} break; case 43: /* Line 1455 of yacc.c */ -#line 429 "glsl_parser.ypp" +#line 432 "glsl_parser.ypp" { (yyval.n) = ast_neg; ;} break; case 44: /* Line 1455 of yacc.c */ -#line 430 "glsl_parser.ypp" +#line 433 "glsl_parser.ypp" { (yyval.n) = ast_logic_not; ;} break; case 45: /* Line 1455 of yacc.c */ -#line 431 "glsl_parser.ypp" +#line 434 "glsl_parser.ypp" { (yyval.n) = ast_bit_not; ;} break; case 47: /* Line 1455 of yacc.c */ -#line 437 "glsl_parser.ypp" +#line 440 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mul, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3062,7 +3108,7 @@ yyreduce: case 48: /* Line 1455 of yacc.c */ -#line 443 "glsl_parser.ypp" +#line 446 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_div, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3073,7 +3119,7 @@ yyreduce: case 49: /* Line 1455 of yacc.c */ -#line 449 "glsl_parser.ypp" +#line 452 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mod, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3084,7 +3130,7 @@ yyreduce: case 51: /* Line 1455 of yacc.c */ -#line 459 "glsl_parser.ypp" +#line 462 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_add, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3095,7 +3141,7 @@ yyreduce: case 52: /* Line 1455 of yacc.c */ -#line 465 "glsl_parser.ypp" +#line 468 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_sub, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3106,7 +3152,7 @@ yyreduce: case 54: /* Line 1455 of yacc.c */ -#line 475 "glsl_parser.ypp" +#line 478 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3117,7 +3163,7 @@ yyreduce: case 55: /* Line 1455 of yacc.c */ -#line 481 "glsl_parser.ypp" +#line 484 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_rshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3128,7 +3174,7 @@ yyreduce: case 57: /* Line 1455 of yacc.c */ -#line 491 "glsl_parser.ypp" +#line 494 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_less, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3139,7 +3185,7 @@ yyreduce: case 58: /* Line 1455 of yacc.c */ -#line 497 "glsl_parser.ypp" +#line 500 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_greater, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3150,7 +3196,7 @@ yyreduce: case 59: /* Line 1455 of yacc.c */ -#line 503 "glsl_parser.ypp" +#line 506 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3161,7 +3207,7 @@ yyreduce: case 60: /* Line 1455 of yacc.c */ -#line 509 "glsl_parser.ypp" +#line 512 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_gequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3172,7 +3218,7 @@ yyreduce: case 62: /* Line 1455 of yacc.c */ -#line 519 "glsl_parser.ypp" +#line 522 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_equal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3183,7 +3229,7 @@ yyreduce: case 63: /* Line 1455 of yacc.c */ -#line 525 "glsl_parser.ypp" +#line 528 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_nequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3194,7 +3240,7 @@ yyreduce: case 65: /* Line 1455 of yacc.c */ -#line 535 "glsl_parser.ypp" +#line 538 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3205,7 +3251,7 @@ yyreduce: case 67: /* Line 1455 of yacc.c */ -#line 545 "glsl_parser.ypp" +#line 548 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3216,7 +3262,7 @@ yyreduce: case 69: /* Line 1455 of yacc.c */ -#line 555 "glsl_parser.ypp" +#line 558 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3227,7 +3273,7 @@ yyreduce: case 71: /* Line 1455 of yacc.c */ -#line 565 "glsl_parser.ypp" +#line 568 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3238,7 +3284,7 @@ yyreduce: case 73: /* Line 1455 of yacc.c */ -#line 575 "glsl_parser.ypp" +#line 578 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3249,7 +3295,7 @@ yyreduce: case 75: /* Line 1455 of yacc.c */ -#line 585 "glsl_parser.ypp" +#line 588 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3260,7 +3306,7 @@ yyreduce: case 77: /* Line 1455 of yacc.c */ -#line 595 "glsl_parser.ypp" +#line 598 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_conditional, (yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression)); @@ -3271,7 +3317,7 @@ yyreduce: case 79: /* Line 1455 of yacc.c */ -#line 605 "glsl_parser.ypp" +#line 608 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(2) - (3)].n), (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -3282,84 +3328,84 @@ yyreduce: case 80: /* Line 1455 of yacc.c */ -#line 613 "glsl_parser.ypp" +#line 616 "glsl_parser.ypp" { (yyval.n) = ast_assign; ;} break; case 81: /* Line 1455 of yacc.c */ -#line 614 "glsl_parser.ypp" +#line 617 "glsl_parser.ypp" { (yyval.n) = ast_mul_assign; ;} break; case 82: /* Line 1455 of yacc.c */ -#line 615 "glsl_parser.ypp" +#line 618 "glsl_parser.ypp" { (yyval.n) = ast_div_assign; ;} break; case 83: /* Line 1455 of yacc.c */ -#line 616 "glsl_parser.ypp" +#line 619 "glsl_parser.ypp" { (yyval.n) = ast_mod_assign; ;} break; case 84: /* Line 1455 of yacc.c */ -#line 617 "glsl_parser.ypp" +#line 620 "glsl_parser.ypp" { (yyval.n) = ast_add_assign; ;} break; case 85: /* Line 1455 of yacc.c */ -#line 618 "glsl_parser.ypp" +#line 621 "glsl_parser.ypp" { (yyval.n) = ast_sub_assign; ;} break; case 86: /* Line 1455 of yacc.c */ -#line 619 "glsl_parser.ypp" +#line 622 "glsl_parser.ypp" { (yyval.n) = ast_ls_assign; ;} break; case 87: /* Line 1455 of yacc.c */ -#line 620 "glsl_parser.ypp" +#line 623 "glsl_parser.ypp" { (yyval.n) = ast_rs_assign; ;} break; case 88: /* Line 1455 of yacc.c */ -#line 621 "glsl_parser.ypp" +#line 624 "glsl_parser.ypp" { (yyval.n) = ast_and_assign; ;} break; case 89: /* Line 1455 of yacc.c */ -#line 622 "glsl_parser.ypp" +#line 625 "glsl_parser.ypp" { (yyval.n) = ast_xor_assign; ;} break; case 90: /* Line 1455 of yacc.c */ -#line 623 "glsl_parser.ypp" +#line 626 "glsl_parser.ypp" { (yyval.n) = ast_or_assign; ;} break; case 91: /* Line 1455 of yacc.c */ -#line 628 "glsl_parser.ypp" +#line 631 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} @@ -3368,7 +3414,7 @@ yyreduce: case 92: /* Line 1455 of yacc.c */ -#line 632 "glsl_parser.ypp" +#line 635 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (3)].expression)->oper != ast_sequence) { @@ -3386,7 +3432,7 @@ yyreduce: case 94: /* Line 1455 of yacc.c */ -#line 652 "glsl_parser.ypp" +#line 655 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].function); ;} @@ -3395,7 +3441,7 @@ yyreduce: case 95: /* Line 1455 of yacc.c */ -#line 656 "glsl_parser.ypp" +#line 659 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].declarator_list); ;} @@ -3404,7 +3450,7 @@ yyreduce: case 96: /* Line 1455 of yacc.c */ -#line 660 "glsl_parser.ypp" +#line 663 "glsl_parser.ypp" { if (((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_float) && ((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_int)) { @@ -3420,7 +3466,7 @@ yyreduce: case 100: /* Line 1455 of yacc.c */ -#line 683 "glsl_parser.ypp" +#line 686 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (2)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(2) - (2)].parameter_declarator)->link); @@ -3430,7 +3476,7 @@ yyreduce: case 101: /* Line 1455 of yacc.c */ -#line 688 "glsl_parser.ypp" +#line 691 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (3)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(3) - (3)].parameter_declarator)->link); @@ -3440,7 +3486,7 @@ yyreduce: case 102: /* Line 1455 of yacc.c */ -#line 696 "glsl_parser.ypp" +#line 699 "glsl_parser.ypp" { void *ctx = state; (yyval.function) = new(ctx) ast_function(); @@ -3453,7 +3499,7 @@ yyreduce: case 103: /* Line 1455 of yacc.c */ -#line 707 "glsl_parser.ypp" +#line 710 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3468,7 +3514,7 @@ yyreduce: case 104: /* Line 1455 of yacc.c */ -#line 717 "glsl_parser.ypp" +#line 720 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3485,7 +3531,7 @@ yyreduce: case 105: /* Line 1455 of yacc.c */ -#line 732 "glsl_parser.ypp" +#line 735 "glsl_parser.ypp" { (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; @@ -3497,7 +3543,7 @@ yyreduce: case 106: /* Line 1455 of yacc.c */ -#line 739 "glsl_parser.ypp" +#line 742 "glsl_parser.ypp" { (yyval.parameter_declarator) = (yyvsp[(2) - (2)].parameter_declarator); (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier).q; @@ -3507,7 +3553,7 @@ yyreduce: case 107: /* Line 1455 of yacc.c */ -#line 744 "glsl_parser.ypp" +#line 747 "glsl_parser.ypp" { void *ctx = state; (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; @@ -3523,7 +3569,7 @@ yyreduce: case 108: /* Line 1455 of yacc.c */ -#line 755 "glsl_parser.ypp" +#line 758 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3537,35 +3583,35 @@ yyreduce: case 109: /* Line 1455 of yacc.c */ -#line 766 "glsl_parser.ypp" +#line 769 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; ;} break; case 110: /* Line 1455 of yacc.c */ -#line 767 "glsl_parser.ypp" +#line 770 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} break; case 111: /* Line 1455 of yacc.c */ -#line 768 "glsl_parser.ypp" +#line 771 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} break; case 112: /* Line 1455 of yacc.c */ -#line 769 "glsl_parser.ypp" +#line 772 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; (yyval.type_qualifier).q.out = 1; ;} break; case 115: /* Line 1455 of yacc.c */ -#line 779 "glsl_parser.ypp" +#line 782 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (3)].identifier), false, NULL, NULL); @@ -3579,7 +3625,7 @@ yyreduce: case 116: /* Line 1455 of yacc.c */ -#line 788 "glsl_parser.ypp" +#line 791 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), true, NULL, NULL); @@ -3593,7 +3639,7 @@ yyreduce: case 117: /* Line 1455 of yacc.c */ -#line 797 "glsl_parser.ypp" +#line 800 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (6)].identifier), true, (yyvsp[(5) - (6)].expression), NULL); @@ -3607,7 +3653,7 @@ yyreduce: case 118: /* Line 1455 of yacc.c */ -#line 806 "glsl_parser.ypp" +#line 809 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (7)].identifier), true, NULL, (yyvsp[(7) - (7)].expression)); @@ -3621,7 +3667,7 @@ yyreduce: case 119: /* Line 1455 of yacc.c */ -#line 815 "glsl_parser.ypp" +#line 818 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (8)].identifier), true, (yyvsp[(5) - (8)].expression), (yyvsp[(8) - (8)].expression)); @@ -3635,7 +3681,7 @@ yyreduce: case 120: /* Line 1455 of yacc.c */ -#line 824 "glsl_parser.ypp" +#line 827 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), false, NULL, (yyvsp[(5) - (5)].expression)); @@ -3649,7 +3695,7 @@ yyreduce: case 121: /* Line 1455 of yacc.c */ -#line 837 "glsl_parser.ypp" +#line 840 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (1)].fully_specified_type)->specifier->type_specifier != ast_struct) { @@ -3665,7 +3711,7 @@ yyreduce: case 122: /* Line 1455 of yacc.c */ -#line 848 "glsl_parser.ypp" +#line 851 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3679,7 +3725,7 @@ yyreduce: case 123: /* Line 1455 of yacc.c */ -#line 857 "glsl_parser.ypp" +#line 860 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), true, NULL, NULL); @@ -3693,7 +3739,7 @@ yyreduce: case 124: /* Line 1455 of yacc.c */ -#line 866 "glsl_parser.ypp" +#line 869 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (5)].identifier), true, (yyvsp[(4) - (5)].expression), NULL); @@ -3707,7 +3753,7 @@ yyreduce: case 125: /* Line 1455 of yacc.c */ -#line 875 "glsl_parser.ypp" +#line 878 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (6)].identifier), true, NULL, (yyvsp[(6) - (6)].expression)); @@ -3721,7 +3767,7 @@ yyreduce: case 126: /* Line 1455 of yacc.c */ -#line 884 "glsl_parser.ypp" +#line 887 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (7)].identifier), true, (yyvsp[(4) - (7)].expression), (yyvsp[(7) - (7)].expression)); @@ -3735,7 +3781,7 @@ yyreduce: case 127: /* Line 1455 of yacc.c */ -#line 893 "glsl_parser.ypp" +#line 896 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -3749,7 +3795,7 @@ yyreduce: case 128: /* Line 1455 of yacc.c */ -#line 902 "glsl_parser.ypp" +#line 905 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3765,7 +3811,7 @@ yyreduce: case 129: /* Line 1455 of yacc.c */ -#line 916 "glsl_parser.ypp" +#line 919 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -3777,7 +3823,7 @@ yyreduce: case 130: /* Line 1455 of yacc.c */ -#line 923 "glsl_parser.ypp" +#line 926 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -3790,127 +3836,188 @@ yyreduce: case 131: /* Line 1455 of yacc.c */ -#line 933 "glsl_parser.ypp" +#line 936 "glsl_parser.ypp" + { (yyval.type_qualifier).i = 0; ;} + break; + + case 133: + +/* Line 1455 of yacc.c */ +#line 942 "glsl_parser.ypp" + { + (yyval.type_qualifier) = (yyvsp[(3) - (4)].type_qualifier); + ;} + break; + + case 135: + +/* Line 1455 of yacc.c */ +#line 950 "glsl_parser.ypp" + { + (yyval.type_qualifier).i = (yyvsp[(1) - (3)].type_qualifier).i | (yyvsp[(3) - (3)].type_qualifier).i; + ;} + break; + + case 136: + +/* Line 1455 of yacc.c */ +#line 957 "glsl_parser.ypp" + { + (yyval.type_qualifier).i = 0; + + if (state->ARB_fragment_coord_conventions_enable) { + bool got_one = false; + + if (strcmp((yyvsp[(1) - (1)].identifier), "origin_upper_left") == 0) { + got_one = true; + (yyval.type_qualifier).q.origin_upper_left = 1; + } else if (strcmp((yyvsp[(1) - (1)].identifier), "pixel_center_integer") == 0) { + got_one = true; + (yyval.type_qualifier).q.pixel_center_integer = 1; + } + + if (state->ARB_fragment_coord_conventions_warn && got_one) { + _mesa_glsl_warning(& (yylsp[(1) - (1)]), state, + "GL_ARB_fragment_coord_conventions layout " + "identifier `%s' used\n", (yyvsp[(1) - (1)].identifier)); + } + } + + /* If the identifier didn't match any known layout identifiers, + * emit an error. + */ + if ((yyval.type_qualifier).i == 0) { + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, "unrecognized layout identifier " + "`%s'\n", (yyvsp[(1) - (1)].identifier)); + YYERROR; + } + ;} + break; + + case 137: + +/* Line 1455 of yacc.c */ +#line 990 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.smooth = 1; ;} break; - case 132: + case 138: /* Line 1455 of yacc.c */ -#line 934 "glsl_parser.ypp" +#line 991 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.flat = 1; ;} break; - case 133: + case 139: /* Line 1455 of yacc.c */ -#line 935 "glsl_parser.ypp" +#line 992 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.noperspective = 1; ;} break; - case 134: + case 140: /* Line 1455 of yacc.c */ -#line 939 "glsl_parser.ypp" +#line 996 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} break; - case 136: + case 142: /* Line 1455 of yacc.c */ -#line 945 "glsl_parser.ypp" +#line 1002 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i | (yyvsp[(2) - (2)].type_qualifier).i; ;} break; - case 137: + case 143: /* Line 1455 of yacc.c */ -#line 949 "glsl_parser.ypp" +#line 1006 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(2) - (2)].type_qualifier); (yyval.type_qualifier).q.invariant = 1; ;} break; - case 138: + case 144: /* Line 1455 of yacc.c */ -#line 956 "glsl_parser.ypp" +#line 1013 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} break; - case 139: + case 145: /* Line 1455 of yacc.c */ -#line 957 "glsl_parser.ypp" +#line 1014 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.attribute = 1; ;} break; - case 140: + case 146: /* Line 1455 of yacc.c */ -#line 958 "glsl_parser.ypp" - { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.varying = 1; ;} +#line 1015 "glsl_parser.ypp" + { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i; (yyval.type_qualifier).q.varying = 1; ;} break; - case 141: + case 147: /* Line 1455 of yacc.c */ -#line 959 "glsl_parser.ypp" +#line 1016 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.varying = 1; ;} break; - case 142: + case 148: /* Line 1455 of yacc.c */ -#line 960 "glsl_parser.ypp" +#line 1017 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} break; - case 143: + case 149: /* Line 1455 of yacc.c */ -#line 961 "glsl_parser.ypp" +#line 1018 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} break; - case 144: + case 150: /* Line 1455 of yacc.c */ -#line 962 "glsl_parser.ypp" +#line 1019 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.in = 1; ;} break; - case 145: + case 151: /* Line 1455 of yacc.c */ -#line 963 "glsl_parser.ypp" +#line 1020 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.out = 1; ;} break; - case 146: + case 152: /* Line 1455 of yacc.c */ -#line 964 "glsl_parser.ypp" +#line 1021 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.uniform = 1; ;} break; - case 148: + case 154: /* Line 1455 of yacc.c */ -#line 970 "glsl_parser.ypp" +#line 1027 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(2) - (2)].type_specifier); (yyval.type_specifier)->precision = (yyvsp[(1) - (2)].n); ;} break; - case 150: + case 156: /* Line 1455 of yacc.c */ -#line 979 "glsl_parser.ypp" +#line 1036 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (3)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -3918,10 +4025,10 @@ yyreduce: ;} break; - case 151: + case 157: /* Line 1455 of yacc.c */ -#line 985 "glsl_parser.ypp" +#line 1042 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (4)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -3929,10 +4036,10 @@ yyreduce: ;} break; - case 152: + case 158: /* Line 1455 of yacc.c */ -#line 994 "glsl_parser.ypp" +#line 1051 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].n)); @@ -3940,10 +4047,10 @@ yyreduce: ;} break; - case 153: + case 159: /* Line 1455 of yacc.c */ -#line 1000 "glsl_parser.ypp" +#line 1057 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].struct_specifier)); @@ -3951,10 +4058,10 @@ yyreduce: ;} break; - case 154: + case 160: /* Line 1455 of yacc.c */ -#line 1006 "glsl_parser.ypp" +#line 1063 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].identifier)); @@ -3962,388 +4069,388 @@ yyreduce: ;} break; - case 155: + case 161: /* Line 1455 of yacc.c */ -#line 1014 "glsl_parser.ypp" +#line 1071 "glsl_parser.ypp" { (yyval.n) = ast_void; ;} break; - case 156: + case 162: /* Line 1455 of yacc.c */ -#line 1015 "glsl_parser.ypp" +#line 1072 "glsl_parser.ypp" { (yyval.n) = ast_float; ;} break; - case 157: + case 163: /* Line 1455 of yacc.c */ -#line 1016 "glsl_parser.ypp" +#line 1073 "glsl_parser.ypp" { (yyval.n) = ast_int; ;} break; - case 158: + case 164: /* Line 1455 of yacc.c */ -#line 1017 "glsl_parser.ypp" +#line 1074 "glsl_parser.ypp" { (yyval.n) = ast_uint; ;} break; - case 159: + case 165: /* Line 1455 of yacc.c */ -#line 1018 "glsl_parser.ypp" +#line 1075 "glsl_parser.ypp" { (yyval.n) = ast_bool; ;} break; - case 160: + case 166: /* Line 1455 of yacc.c */ -#line 1019 "glsl_parser.ypp" +#line 1076 "glsl_parser.ypp" { (yyval.n) = ast_vec2; ;} break; - case 161: + case 167: /* Line 1455 of yacc.c */ -#line 1020 "glsl_parser.ypp" +#line 1077 "glsl_parser.ypp" { (yyval.n) = ast_vec3; ;} break; - case 162: + case 168: /* Line 1455 of yacc.c */ -#line 1021 "glsl_parser.ypp" +#line 1078 "glsl_parser.ypp" { (yyval.n) = ast_vec4; ;} break; - case 163: + case 169: /* Line 1455 of yacc.c */ -#line 1022 "glsl_parser.ypp" +#line 1079 "glsl_parser.ypp" { (yyval.n) = ast_bvec2; ;} break; - case 164: + case 170: /* Line 1455 of yacc.c */ -#line 1023 "glsl_parser.ypp" +#line 1080 "glsl_parser.ypp" { (yyval.n) = ast_bvec3; ;} break; - case 165: + case 171: /* Line 1455 of yacc.c */ -#line 1024 "glsl_parser.ypp" +#line 1081 "glsl_parser.ypp" { (yyval.n) = ast_bvec4; ;} break; - case 166: + case 172: /* Line 1455 of yacc.c */ -#line 1025 "glsl_parser.ypp" +#line 1082 "glsl_parser.ypp" { (yyval.n) = ast_ivec2; ;} break; - case 167: + case 173: /* Line 1455 of yacc.c */ -#line 1026 "glsl_parser.ypp" +#line 1083 "glsl_parser.ypp" { (yyval.n) = ast_ivec3; ;} break; - case 168: + case 174: /* Line 1455 of yacc.c */ -#line 1027 "glsl_parser.ypp" +#line 1084 "glsl_parser.ypp" { (yyval.n) = ast_ivec4; ;} break; - case 169: + case 175: /* Line 1455 of yacc.c */ -#line 1028 "glsl_parser.ypp" +#line 1085 "glsl_parser.ypp" { (yyval.n) = ast_uvec2; ;} break; - case 170: + case 176: /* Line 1455 of yacc.c */ -#line 1029 "glsl_parser.ypp" +#line 1086 "glsl_parser.ypp" { (yyval.n) = ast_uvec3; ;} break; - case 171: + case 177: /* Line 1455 of yacc.c */ -#line 1030 "glsl_parser.ypp" +#line 1087 "glsl_parser.ypp" { (yyval.n) = ast_uvec4; ;} break; - case 172: + case 178: /* Line 1455 of yacc.c */ -#line 1031 "glsl_parser.ypp" +#line 1088 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; - case 173: + case 179: /* Line 1455 of yacc.c */ -#line 1032 "glsl_parser.ypp" +#line 1089 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; - case 174: + case 180: /* Line 1455 of yacc.c */ -#line 1033 "glsl_parser.ypp" +#line 1090 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; - case 175: + case 181: /* Line 1455 of yacc.c */ -#line 1034 "glsl_parser.ypp" +#line 1091 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; - case 176: + case 182: /* Line 1455 of yacc.c */ -#line 1035 "glsl_parser.ypp" +#line 1092 "glsl_parser.ypp" { (yyval.n) = ast_mat2x3; ;} break; - case 177: + case 183: /* Line 1455 of yacc.c */ -#line 1036 "glsl_parser.ypp" +#line 1093 "glsl_parser.ypp" { (yyval.n) = ast_mat2x4; ;} break; - case 178: + case 184: /* Line 1455 of yacc.c */ -#line 1037 "glsl_parser.ypp" +#line 1094 "glsl_parser.ypp" { (yyval.n) = ast_mat3x2; ;} break; - case 179: + case 185: /* Line 1455 of yacc.c */ -#line 1038 "glsl_parser.ypp" +#line 1095 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; - case 180: + case 186: /* Line 1455 of yacc.c */ -#line 1039 "glsl_parser.ypp" +#line 1096 "glsl_parser.ypp" { (yyval.n) = ast_mat3x4; ;} break; - case 181: + case 187: /* Line 1455 of yacc.c */ -#line 1040 "glsl_parser.ypp" +#line 1097 "glsl_parser.ypp" { (yyval.n) = ast_mat4x2; ;} break; - case 182: + case 188: /* Line 1455 of yacc.c */ -#line 1041 "glsl_parser.ypp" +#line 1098 "glsl_parser.ypp" { (yyval.n) = ast_mat4x3; ;} break; - case 183: + case 189: /* Line 1455 of yacc.c */ -#line 1042 "glsl_parser.ypp" +#line 1099 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; - case 184: + case 190: /* Line 1455 of yacc.c */ -#line 1043 "glsl_parser.ypp" +#line 1100 "glsl_parser.ypp" { (yyval.n) = ast_sampler1d; ;} break; - case 185: + case 191: /* Line 1455 of yacc.c */ -#line 1044 "glsl_parser.ypp" +#line 1101 "glsl_parser.ypp" { (yyval.n) = ast_sampler2d; ;} break; - case 186: + case 192: /* Line 1455 of yacc.c */ -#line 1045 "glsl_parser.ypp" +#line 1102 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drect; ;} break; - case 187: + case 193: /* Line 1455 of yacc.c */ -#line 1046 "glsl_parser.ypp" +#line 1103 "glsl_parser.ypp" { (yyval.n) = ast_sampler3d; ;} break; - case 188: + case 194: /* Line 1455 of yacc.c */ -#line 1047 "glsl_parser.ypp" +#line 1104 "glsl_parser.ypp" { (yyval.n) = ast_samplercube; ;} break; - case 189: + case 195: /* Line 1455 of yacc.c */ -#line 1048 "glsl_parser.ypp" +#line 1105 "glsl_parser.ypp" { (yyval.n) = ast_sampler1dshadow; ;} break; - case 190: + case 196: /* Line 1455 of yacc.c */ -#line 1049 "glsl_parser.ypp" +#line 1106 "glsl_parser.ypp" { (yyval.n) = ast_sampler2dshadow; ;} break; - case 191: + case 197: /* Line 1455 of yacc.c */ -#line 1050 "glsl_parser.ypp" +#line 1107 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drectshadow; ;} break; - case 192: + case 198: /* Line 1455 of yacc.c */ -#line 1051 "glsl_parser.ypp" +#line 1108 "glsl_parser.ypp" { (yyval.n) = ast_samplercubeshadow; ;} break; - case 193: + case 199: /* Line 1455 of yacc.c */ -#line 1052 "glsl_parser.ypp" +#line 1109 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darray; ;} break; - case 194: + case 200: /* Line 1455 of yacc.c */ -#line 1053 "glsl_parser.ypp" +#line 1110 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darray; ;} break; - case 195: + case 201: /* Line 1455 of yacc.c */ -#line 1054 "glsl_parser.ypp" +#line 1111 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darrayshadow; ;} break; - case 196: + case 202: /* Line 1455 of yacc.c */ -#line 1055 "glsl_parser.ypp" +#line 1112 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darrayshadow; ;} break; - case 197: + case 203: /* Line 1455 of yacc.c */ -#line 1056 "glsl_parser.ypp" +#line 1113 "glsl_parser.ypp" { (yyval.n) = ast_isampler1d; ;} break; - case 198: + case 204: /* Line 1455 of yacc.c */ -#line 1057 "glsl_parser.ypp" +#line 1114 "glsl_parser.ypp" { (yyval.n) = ast_isampler2d; ;} break; - case 199: + case 205: /* Line 1455 of yacc.c */ -#line 1058 "glsl_parser.ypp" +#line 1115 "glsl_parser.ypp" { (yyval.n) = ast_isampler3d; ;} break; - case 200: + case 206: /* Line 1455 of yacc.c */ -#line 1059 "glsl_parser.ypp" +#line 1116 "glsl_parser.ypp" { (yyval.n) = ast_isamplercube; ;} break; - case 201: + case 207: /* Line 1455 of yacc.c */ -#line 1060 "glsl_parser.ypp" +#line 1117 "glsl_parser.ypp" { (yyval.n) = ast_isampler1darray; ;} break; - case 202: + case 208: /* Line 1455 of yacc.c */ -#line 1061 "glsl_parser.ypp" +#line 1118 "glsl_parser.ypp" { (yyval.n) = ast_isampler2darray; ;} break; - case 203: + case 209: /* Line 1455 of yacc.c */ -#line 1062 "glsl_parser.ypp" +#line 1119 "glsl_parser.ypp" { (yyval.n) = ast_usampler1d; ;} break; - case 204: + case 210: /* Line 1455 of yacc.c */ -#line 1063 "glsl_parser.ypp" +#line 1120 "glsl_parser.ypp" { (yyval.n) = ast_usampler2d; ;} break; - case 205: + case 211: /* Line 1455 of yacc.c */ -#line 1064 "glsl_parser.ypp" +#line 1121 "glsl_parser.ypp" { (yyval.n) = ast_usampler3d; ;} break; - case 206: + case 212: /* Line 1455 of yacc.c */ -#line 1065 "glsl_parser.ypp" +#line 1122 "glsl_parser.ypp" { (yyval.n) = ast_usamplercube; ;} break; - case 207: + case 213: /* Line 1455 of yacc.c */ -#line 1066 "glsl_parser.ypp" +#line 1123 "glsl_parser.ypp" { (yyval.n) = ast_usampler1darray; ;} break; - case 208: + case 214: /* Line 1455 of yacc.c */ -#line 1067 "glsl_parser.ypp" +#line 1124 "glsl_parser.ypp" { (yyval.n) = ast_usampler2darray; ;} break; - case 209: + case 215: /* Line 1455 of yacc.c */ -#line 1071 "glsl_parser.ypp" +#line 1128 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4357,10 +4464,10 @@ yyreduce: ;} break; - case 210: + case 216: /* Line 1455 of yacc.c */ -#line 1082 "glsl_parser.ypp" +#line 1139 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4374,10 +4481,10 @@ yyreduce: ;} break; - case 211: + case 217: /* Line 1455 of yacc.c */ -#line 1093 "glsl_parser.ypp" +#line 1150 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4391,10 +4498,10 @@ yyreduce: ;} break; - case 212: + case 218: /* Line 1455 of yacc.c */ -#line 1108 "glsl_parser.ypp" +#line 1165 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node)); @@ -4402,10 +4509,10 @@ yyreduce: ;} break; - case 213: + case 219: /* Line 1455 of yacc.c */ -#line 1114 "glsl_parser.ypp" +#line 1171 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node)); @@ -4413,30 +4520,30 @@ yyreduce: ;} break; - case 214: + case 220: /* Line 1455 of yacc.c */ -#line 1123 "glsl_parser.ypp" +#line 1180 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].declarator_list); (yyvsp[(1) - (1)].declarator_list)->link.self_link(); ;} break; - case 215: + case 221: /* Line 1455 of yacc.c */ -#line 1128 "glsl_parser.ypp" +#line 1185 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (2)].node); (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); ;} break; - case 216: + case 222: /* Line 1455 of yacc.c */ -#line 1136 "glsl_parser.ypp" +#line 1193 "glsl_parser.ypp" { void *ctx = state; ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); @@ -4450,30 +4557,30 @@ yyreduce: ;} break; - case 217: + case 223: /* Line 1455 of yacc.c */ -#line 1151 "glsl_parser.ypp" +#line 1208 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (1)].declaration); (yyvsp[(1) - (1)].declaration)->link.self_link(); ;} break; - case 218: + case 224: /* Line 1455 of yacc.c */ -#line 1156 "glsl_parser.ypp" +#line 1213 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (3)].declaration); (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link); ;} break; - case 219: + case 225: /* Line 1455 of yacc.c */ -#line 1164 "glsl_parser.ypp" +#line 1221 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL); @@ -4481,10 +4588,10 @@ yyreduce: ;} break; - case 220: + case 226: /* Line 1455 of yacc.c */ -#line 1170 "glsl_parser.ypp" +#line 1227 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL); @@ -4492,31 +4599,31 @@ yyreduce: ;} break; - case 225: + case 231: /* Line 1455 of yacc.c */ -#line 1193 "glsl_parser.ypp" +#line 1250 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; - case 231: + case 237: /* Line 1455 of yacc.c */ -#line 1205 "glsl_parser.ypp" +#line 1262 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; - case 232: + case 238: /* Line 1455 of yacc.c */ -#line 1206 "glsl_parser.ypp" +#line 1263 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; - case 235: + case 241: /* Line 1455 of yacc.c */ -#line 1213 "glsl_parser.ypp" +#line 1270 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL); @@ -4524,10 +4631,10 @@ yyreduce: ;} break; - case 236: + case 242: /* Line 1455 of yacc.c */ -#line 1219 "glsl_parser.ypp" +#line 1276 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(2) - (3)].node)); @@ -4535,17 +4642,17 @@ yyreduce: ;} break; - case 237: + case 243: /* Line 1455 of yacc.c */ -#line 1227 "glsl_parser.ypp" +#line 1284 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; - case 239: + case 245: /* Line 1455 of yacc.c */ -#line 1233 "glsl_parser.ypp" +#line 1290 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL); @@ -4553,10 +4660,10 @@ yyreduce: ;} break; - case 240: + case 246: /* Line 1455 of yacc.c */ -#line 1239 "glsl_parser.ypp" +#line 1296 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node)); @@ -4564,10 +4671,10 @@ yyreduce: ;} break; - case 241: + case 247: /* Line 1455 of yacc.c */ -#line 1248 "glsl_parser.ypp" +#line 1305 "glsl_parser.ypp" { if ((yyvsp[(1) - (1)].node) == NULL) { _mesa_glsl_error(& (yylsp[(1) - (1)]), state, " statement\n"); @@ -4579,10 +4686,10 @@ yyreduce: ;} break; - case 242: + case 248: /* Line 1455 of yacc.c */ -#line 1258 "glsl_parser.ypp" +#line 1315 "glsl_parser.ypp" { if ((yyvsp[(2) - (2)].node) == NULL) { _mesa_glsl_error(& (yylsp[(2) - (2)]), state, " statement\n"); @@ -4593,10 +4700,10 @@ yyreduce: ;} break; - case 243: + case 249: /* Line 1455 of yacc.c */ -#line 1270 "glsl_parser.ypp" +#line 1327 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement(NULL); @@ -4604,10 +4711,10 @@ yyreduce: ;} break; - case 244: + case 250: /* Line 1455 of yacc.c */ -#line 1276 "glsl_parser.ypp" +#line 1333 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression)); @@ -4615,10 +4722,10 @@ yyreduce: ;} break; - case 245: + case 251: /* Line 1455 of yacc.c */ -#line 1285 "glsl_parser.ypp" +#line 1342 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4626,10 +4733,10 @@ yyreduce: ;} break; - case 246: + case 252: /* Line 1455 of yacc.c */ -#line 1294 "glsl_parser.ypp" +#line 1351 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4637,10 +4744,10 @@ yyreduce: ;} break; - case 247: + case 253: /* Line 1455 of yacc.c */ -#line 1300 "glsl_parser.ypp" +#line 1357 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4648,10 +4755,10 @@ yyreduce: ;} break; - case 248: + case 254: /* Line 1455 of yacc.c */ -#line 1306 "glsl_parser.ypp" +#line 1363 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4659,19 +4766,19 @@ yyreduce: ;} break; - case 249: + case 255: /* Line 1455 of yacc.c */ -#line 1315 "glsl_parser.ypp" +#line 1372 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].expression); ;} break; - case 250: + case 256: /* Line 1455 of yacc.c */ -#line 1319 "glsl_parser.ypp" +#line 1376 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -4684,10 +4791,10 @@ yyreduce: ;} break; - case 254: + case 260: /* Line 1455 of yacc.c */ -#line 1342 "glsl_parser.ypp" +#line 1399 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, @@ -4696,10 +4803,10 @@ yyreduce: ;} break; - case 255: + case 261: /* Line 1455 of yacc.c */ -#line 1349 "glsl_parser.ypp" +#line 1406 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, @@ -4708,10 +4815,10 @@ yyreduce: ;} break; - case 256: + case 262: /* Line 1455 of yacc.c */ -#line 1356 "glsl_parser.ypp" +#line 1413 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, @@ -4720,39 +4827,39 @@ yyreduce: ;} break; - case 260: + case 266: /* Line 1455 of yacc.c */ -#line 1372 "glsl_parser.ypp" +#line 1429 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; - case 261: + case 267: /* Line 1455 of yacc.c */ -#line 1379 "glsl_parser.ypp" +#line 1436 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node); (yyval.for_rest_statement).rest = NULL; ;} break; - case 262: + case 268: /* Line 1455 of yacc.c */ -#line 1384 "glsl_parser.ypp" +#line 1441 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node); (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression); ;} break; - case 263: + case 269: /* Line 1455 of yacc.c */ -#line 1393 "glsl_parser.ypp" +#line 1450 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); @@ -4760,10 +4867,10 @@ yyreduce: ;} break; - case 264: + case 270: /* Line 1455 of yacc.c */ -#line 1399 "glsl_parser.ypp" +#line 1456 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); @@ -4771,10 +4878,10 @@ yyreduce: ;} break; - case 265: + case 271: /* Line 1455 of yacc.c */ -#line 1405 "glsl_parser.ypp" +#line 1462 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); @@ -4782,10 +4889,10 @@ yyreduce: ;} break; - case 266: + case 272: /* Line 1455 of yacc.c */ -#line 1411 "glsl_parser.ypp" +#line 1468 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression)); @@ -4793,10 +4900,10 @@ yyreduce: ;} break; - case 267: + case 273: /* Line 1455 of yacc.c */ -#line 1417 "glsl_parser.ypp" +#line 1474 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); @@ -4804,24 +4911,24 @@ yyreduce: ;} break; - case 268: + case 274: /* Line 1455 of yacc.c */ -#line 1425 "glsl_parser.ypp" +#line 1482 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;} break; - case 269: + case 275: /* Line 1455 of yacc.c */ -#line 1426 "glsl_parser.ypp" +#line 1483 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); ;} break; - case 270: + case 276: /* Line 1455 of yacc.c */ -#line 1431 "glsl_parser.ypp" +#line 1488 "glsl_parser.ypp" { void *ctx = state; (yyval.function_definition) = new(ctx) ast_function_definition(); @@ -4834,7 +4941,7 @@ yyreduce: /* Line 1455 of yacc.c */ -#line 4838 "glsl_parser.cpp" +#line 4945 "glsl_parser.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h index 6cbab40557b..9c4e12fd7ef 100644 --- a/src/glsl/glsl_parser.h +++ b/src/glsl/glsl_parser.h @@ -155,46 +155,47 @@ EOL = 371, INTERFACE = 372, OUTPUT = 373, - ASM = 374, - CLASS = 375, - UNION = 376, - ENUM = 377, - TYPEDEF = 378, - TEMPLATE = 379, - THIS = 380, - PACKED = 381, - GOTO = 382, - INLINE_TOK = 383, - NOINLINE = 384, - VOLATILE = 385, - PUBLIC_TOK = 386, - STATIC = 387, - EXTERN = 388, - EXTERNAL = 389, - LONG = 390, - SHORT = 391, - DOUBLE = 392, - HALF = 393, - FIXED = 394, - UNSIGNED = 395, - INPUT = 396, - OUPTUT = 397, - HVEC2 = 398, - HVEC3 = 399, - HVEC4 = 400, - DVEC2 = 401, - DVEC3 = 402, - DVEC4 = 403, - FVEC2 = 404, - FVEC3 = 405, - FVEC4 = 406, - SAMPLER2DRECT = 407, - SAMPLER3DRECT = 408, - SAMPLER2DRECTSHADOW = 409, - SIZEOF = 410, - CAST = 411, - NAMESPACE = 412, - USING = 413 + LAYOUT_TOK = 374, + ASM = 375, + CLASS = 376, + UNION = 377, + ENUM = 378, + TYPEDEF = 379, + TEMPLATE = 380, + THIS = 381, + PACKED = 382, + GOTO = 383, + INLINE_TOK = 384, + NOINLINE = 385, + VOLATILE = 386, + PUBLIC_TOK = 387, + STATIC = 388, + EXTERN = 389, + EXTERNAL = 390, + LONG = 391, + SHORT = 392, + DOUBLE = 393, + HALF = 394, + FIXED = 395, + UNSIGNED = 396, + INPUT = 397, + OUPTUT = 398, + HVEC2 = 399, + HVEC3 = 400, + HVEC4 = 401, + DVEC2 = 402, + DVEC3 = 403, + DVEC4 = 404, + FVEC2 = 405, + FVEC3 = 406, + FVEC4 = 407, + SAMPLER2DRECT = 408, + SAMPLER3DRECT = 409, + SAMPLER2DRECTSHADOW = 410, + SIZEOF = 411, + CAST = 412, + NAMESPACE = 413, + USING = 414 }; #endif @@ -236,7 +237,7 @@ typedef union YYSTYPE /* Line 1676 of yacc.c */ -#line 240 "glsl_parser.h" +#line 241 "glsl_parser.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 6782255d45c..53132d9067d 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -97,6 +97,7 @@ %token LOWP MEDIUMP HIGHP PRECISION %token VERSION EXTENSION LINE PRAGMA COLON EOL INTERFACE OUTPUT +%token LAYOUT_TOK /* Reserved words that are not actually used in the grammar. */ @@ -117,6 +118,8 @@ %type type_qualifier %type storage_qualifier %type interpolation_qualifier +%type opt_layout_qualifier layout_qualifier +%type layout_qualifier_id_list layout_qualifier_id %type type_specifier %type type_specifier_no_prec %type type_specifier_nonarray @@ -929,6 +932,60 @@ fully_specified_type: } ; +opt_layout_qualifier: + { $$.i = 0; } + | layout_qualifier + ; + +layout_qualifier: + LAYOUT_TOK '(' layout_qualifier_id_list ')' + { + $$ = $3; + } + ; + +layout_qualifier_id_list: + layout_qualifier_id + | layout_qualifier_id_list ',' layout_qualifier_id + { + $$.i = $1.i | $3.i; + } + ; + +layout_qualifier_id: + IDENTIFIER + { + $$.i = 0; + + if (state->ARB_fragment_coord_conventions_enable) { + bool got_one = false; + + if (strcmp($1, "origin_upper_left") == 0) { + got_one = true; + $$.q.origin_upper_left = 1; + } else if (strcmp($1, "pixel_center_integer") == 0) { + got_one = true; + $$.q.pixel_center_integer = 1; + } + + if (state->ARB_fragment_coord_conventions_warn && got_one) { + _mesa_glsl_warning(& @1, state, + "GL_ARB_fragment_coord_conventions layout " + "identifier `%s' used\n", $1); + } + } + + /* If the identifier didn't match any known layout identifiers, + * emit an error. + */ + if ($$.i == 0) { + _mesa_glsl_error(& @1, state, "unrecognized layout identifier " + "`%s'\n", $1); + YYERROR; + } + } + ; + interpolation_qualifier: SMOOTH { $$.i = 0; $$.q.smooth = 1; } | FLAT { $$.i = 0; $$.q.flat = 1; } @@ -955,9 +1012,9 @@ type_qualifier: storage_qualifier: CONST_TOK { $$.i = 0; $$.q.constant = 1; } | ATTRIBUTE { $$.i = 0; $$.q.attribute = 1; } - | VARYING { $$.i = 0; $$.q.varying = 1; } + | opt_layout_qualifier VARYING { $$.i = $1.i; $$.q.varying = 1; } | CENTROID VARYING { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; } - | IN { $$.i = 0; $$.q.in = 1; } + | opt_layout_qualifier IN { $$.i = 0; $$.q.in = 1; } | OUT { $$.i = 0; $$.q.out = 1; } | CENTROID IN { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; } | CENTROID OUT { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; } diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 009aabcd354..20a5021b146 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -198,6 +198,13 @@ _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_fragment_coord_conventions") == 0) { + state->ARB_fragment_coord_conventions_enable = + (ext_mode != extension_disable); + state->ARB_fragment_coord_conventions_warn = + (ext_mode == extension_warn); + + unsupported = !state->extensions->ARB_fragment_coord_conventions; } else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) { state->ARB_texture_rectangle_enable = (ext_mode != extension_disable); state->ARB_texture_rectangle_warn = (ext_mode == extension_warn); diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 3865843fd10..3b53ba07f68 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -118,6 +118,8 @@ struct _mesa_glsl_parse_state { /*@{*/ unsigned ARB_draw_buffers_enable:1; unsigned ARB_draw_buffers_warn:1; + unsigned ARB_fragment_coord_conventions_enable:1; + unsigned ARB_fragment_coord_conventions_warn:1; unsigned ARB_texture_rectangle_enable:1; unsigned ARB_texture_rectangle_warn:1; unsigned EXT_texture_array_enable:1; -- cgit v1.2.3 From 8d8469eb2ade4fd48188403351a38f740987fb80 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 30 Jun 2010 17:48:09 -0700 Subject: glsl2: Perform some semantic checking of ARB_fcc layout qualifiers The rest cannot be handled until built-in variables (i.e., gl_FragCoord) can be redeclared to add qualifiers. --- src/glsl/ast_to_hir.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 98ea789249d..d82cf333895 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1542,6 +1542,19 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, else var->interpolation = ir_var_smooth; + /* FINISHME: Apply the fragment coord convetion layout qualifiers. + */ + if ((qual->origin_upper_left || qual->pixel_center_integer) + && (strcmp(var->name, "gl_FragCoord") != 0)) { + const char *const qual_string = (qual->origin_upper_left) + ? "origin_upper_left" : "pixel_center_integer"; + + _mesa_glsl_error(loc, state, + "layout qualifier `%s' can only be applied to " + "fragment shader input `gl_FragCoord'", + qual_string); + } + if (var->type->is_array() && (state->language_version >= 120)) { var->array_lvalue = true; } -- cgit v1.2.3 From 4a962170d7cf4243d6ae156fca20a6167388925d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 14:41:51 -0700 Subject: glsl2: Add support for redeclaring layout of gl_FragCoord for ARB_fcc. Fixes: glsl-arb-fragment-coord-conventions --- src/glsl/ast_to_hir.cpp | 15 +++++++++++++-- src/glsl/ir.h | 4 ++++ src/glsl/ir_clone.cpp | 2 ++ src/mesa/program/ir_to_mesa.cpp | 7 ++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index d82cf333895..8e8690c628f 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -50,6 +50,7 @@ */ #include "main/imports.h" +#include "main/extensions.h" #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" #include "ast.h" @@ -1542,8 +1543,8 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, else var->interpolation = ir_var_smooth; - /* FINISHME: Apply the fragment coord convetion layout qualifiers. - */ + var->pixel_center_integer = qual->pixel_center_integer; + var->origin_upper_left = qual->origin_upper_left; if ((qual->origin_upper_left || qual->pixel_center_integer) && (strcmp(var->name, "gl_FragCoord") != 0)) { const char *const qual_string = (qual->origin_upper_left) @@ -1932,6 +1933,16 @@ ast_declarator_list::hir(exec_list *instructions, earlier->type = var->type; delete var; var = NULL; + } else if (state->extensions->ARB_fragment_coord_conventions && + (earlier != NULL) && + (strcmp(var->name, "gl_FragCoord") == 0) && + earlier->type == var->type && + earlier->mode == var->mode) { + /* Allow redeclaration of gl_FragCoord for ARB_fcc layout + * qualifiers. + */ + earlier->origin_upper_left = var->origin_upper_left; + earlier->pixel_center_integer = var->pixel_center_integer; } else { YYLTYPE loc = this->get_location(); diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 7e8363106da..202685d145a 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -238,6 +238,10 @@ public: */ unsigned array_lvalue:1; + /* ARB_fragment_coord_conventions */ + unsigned origin_upper_left:1; + unsigned pixel_center_integer:1; + /** * Storage location of the base of this variable * diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index c49a7324818..f97080d2056 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -52,6 +52,8 @@ ir_variable::clone(struct hash_table *ht) const var->array_lvalue = this->array_lvalue; var->location = this->location; var->warn_extension = this->warn_extension; + var->origin_upper_left = this->origin_upper_left; + var->pixel_center_integer = this->pixel_center_integer; if (this->constant_value) var->constant_value = this->constant_value->clone(ht); diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index c53381e29d9..a3019cc650a 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -557,7 +557,12 @@ ir_to_mesa_visitor::find_variable_storage(ir_variable *var) void ir_to_mesa_visitor::visit(ir_variable *ir) { - (void)ir; + if (strcmp(ir->name, "gl_FragCoord") == 0) { + struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog; + + fp->OriginUpperLeft = ir->origin_upper_left; + fp->PixelCenterInteger = ir->pixel_center_integer; + } } void -- cgit v1.2.3 From 0c7b37c8367e72e7b4295cd249561e5c3079d161 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 14:58:31 -0700 Subject: glsl2: Add the define for ARB_fragment_coord_conventions when present. Fixes: glsl-arb-fragment-coord-conventions-define --- src/glsl/glcpp/glcpp-parse.c | 8 ++++++++ src/glsl/glcpp/glcpp-parse.y | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 2f08ff8112d..8fbbdab52fc 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -3242,6 +3242,14 @@ glcpp_parser_create (const struct gl_extensions *extensions) "GL_EXT_texture_array", list); } + if ((extensions != NULL) && + extensions->ARB_fragment_coord_conventions) { + list = _token_list_create(parser); + _token_list_append(list, tok); + _define_object_macro(parser, NULL, + "GL_ARB_fragment_coord_conventions", list); + } + talloc_unlink(parser, tok); return parser; diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 41cfff5551c..c6ff32e544c 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -937,6 +937,14 @@ glcpp_parser_create (const struct gl_extensions *extensions) "GL_EXT_texture_array", list); } + if ((extensions != NULL) && + extensions->ARB_fragment_coord_conventions) { + list = _token_list_create(parser); + _token_list_append(list, tok); + _define_object_macro(parser, NULL, + "GL_ARB_fragment_coord_conventions", list); + } + talloc_unlink(parser, tok); return parser; -- cgit v1.2.3 From ee9a3a51b61f0afe75b4b8b0c3025310140437ec Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 15:54:15 -0700 Subject: glsl2: Add new ir_constant::zero static method. This conveniently creates a zero value of whatever type you want. --- src/glsl/ir.cpp | 12 ++++++++++++ src/glsl/ir.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index c75d560c48c..bb58d956243 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -326,6 +326,18 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) } } +ir_constant * +ir_constant::zero(void *mem_ctx, const glsl_type *type) +{ + assert(type->is_numeric()); + + ir_constant *c = new(mem_ctx) ir_constant; + c->type = type; + memset(&c->value, 0, sizeof(c->value)); + + return c; +} + bool ir_constant::get_bool_component(unsigned i) const { diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 202685d145a..bee9f6a2de4 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1248,6 +1248,11 @@ public: */ ir_constant(const ir_constant *c, unsigned i); + /** + * Return a new ir_constant of the specified type containing all zeros. + */ + static ir_constant *zero(void *mem_ctx, const glsl_type *type); + virtual ir_constant *clone(struct hash_table *) const; virtual ir_constant *constant_expression_value(); -- cgit v1.2.3 From f7b94f32a22a769fc71065ca6515186e5a8e3a96 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Jul 2010 12:20:38 -0700 Subject: ir_algebraic: Use ir_constant::zero. --- src/glsl/ir_algebraic.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/glsl/ir_algebraic.cpp b/src/glsl/ir_algebraic.cpp index 5b065b086e5..a6ecad7b659 100644 --- a/src/glsl/ir_algebraic.cpp +++ b/src/glsl/ir_algebraic.cpp @@ -213,13 +213,9 @@ ir_algebraic_visitor::handle_expression(ir_rvalue *in_ir) return ir->operands[0]; } - if (is_vec_zero(op_const[0]) || - is_vec_zero(op_const[1])) { - ir_constant_data zero_data; - memset(&zero_data, 0, sizeof(zero_data)); - + if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) { this->progress = true; - return new(ir) ir_constant(ir->type, &zero_data); + return ir_constant::zero(ir, ir->type); } break; -- cgit v1.2.3 From f914915d8e86f492cfcbbf834df601251bbba033 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 21:56:13 -0700 Subject: ir_constant_expression: Use Mesa's MIN2/MAX2 instead of our own. --- src/glsl/ir_constant_expression.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 6a07f4e1895..9309b618981 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -34,13 +34,11 @@ */ #include +#include "main/macros.h" #include "ir.h" #include "ir_visitor.h" #include "glsl_types.h" -#define min(x,y) (x) < (y) ? (x) : (y) -#define max(x,y) (x) > (y) ? (x) : (y) - ir_constant * ir_expression::constant_expression_value() { @@ -355,13 +353,13 @@ ir_expression::constant_expression_value() switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: - data.u[c] = min(op[0]->value.u[c0], op[1]->value.u[c1]); + data.u[c] = MIN2(op[0]->value.u[c0], op[1]->value.u[c1]); break; case GLSL_TYPE_INT: - data.i[c] = min(op[0]->value.i[c0], op[1]->value.i[c1]); + data.i[c] = MIN2(op[0]->value.i[c0], op[1]->value.i[c1]); break; case GLSL_TYPE_FLOAT: - data.f[c] = min(op[0]->value.f[c0], op[1]->value.f[c1]); + data.f[c] = MIN2(op[0]->value.f[c0], op[1]->value.f[c1]); break; default: assert(0); @@ -377,13 +375,13 @@ ir_expression::constant_expression_value() switch (op[0]->type->base_type) { case GLSL_TYPE_UINT: - data.u[c] = max(op[0]->value.u[c0], op[1]->value.u[c1]); + data.u[c] = MAX2(op[0]->value.u[c0], op[1]->value.u[c1]); break; case GLSL_TYPE_INT: - data.i[c] = max(op[0]->value.i[c0], op[1]->value.i[c1]); + data.i[c] = MAX2(op[0]->value.i[c0], op[1]->value.i[c1]); break; case GLSL_TYPE_FLOAT: - data.f[c] = max(op[0]->value.f[c0], op[1]->value.f[c1]); + data.f[c] = MAX2(op[0]->value.f[c0], op[1]->value.f[c1]); break; default: assert(0); -- cgit v1.2.3 From bafd89fa0f026cef12024382b154a41d90d00373 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 16:55:46 -0700 Subject: ir_constant_expression: Stub out support for constant builtins. --- src/glsl/ir_constant_expression.cpp | 151 +++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 9309b618981..aa53d8d1867 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -764,7 +764,152 @@ ir_constant::constant_expression_value() ir_constant * ir_call::constant_expression_value() { - /* FINISHME: Handle CEs involving builtin function calls. */ - return NULL; -} + if (this->type == glsl_type::error_type) + return NULL; + + /* From the GLSL 1.20 spec, page 23: + * "Function calls to user-defined functions (non-built-in functions) + * cannot be used to form constant expressions." + */ + if (!this->callee->is_built_in) + return NULL; + + unsigned num_parameters = 0; + + /* Check if all parameters are constant */ + ir_constant *op[3]; + foreach_list(n, &this->actual_parameters) { + ir_constant *constant = ((ir_rvalue *) n)->constant_expression_value(); + if (constant == NULL) + return NULL; + + op[num_parameters] = constant; + + assert(num_parameters < 3); + num_parameters++; + } + /* Individual cases below can either: + * - Assign "expr" a new ir_expression to evaluate (for basic opcodes) + * - Fill "data" with appopriate constant data + * - Return an ir_constant directly. + */ + void *mem_ctx = talloc_parent(this); + ir_expression *expr = NULL; + + ir_constant_data data; + memset(&data, 0, sizeof(data)); + + const char *callee = this->callee_name(); + if (strcmp(callee, "abs") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "all") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "any") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "asin") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "atan") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "ceil") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "clamp") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "cos") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "cosh") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "cross") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "degrees") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "distance") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "dot") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "equal") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "exp") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "exp2") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "faceforward") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "floor") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "fract") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "fwidth") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "greaterThan") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "greaterThanEqual") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "inversesqrt") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "length") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "lessThan") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "lessThanEqual") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "log") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "log2") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "matrixCompMult") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "max") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "min") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "mix") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "mod") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "normalize") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "not") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "notEqual") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "outerProduct") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "pow") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "radians") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "reflect") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "refract") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "sign") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "sin") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "sinh") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "smoothstep") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "sqrt") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "step") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "tan") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "tanh") == 0) { + return NULL; /* FINISHME: implement this */ + } else if (strcmp(callee, "transpose") == 0) { + return NULL; /* FINISHME: implement this */ + } else { + /* Unsupported builtin - some are not allowed in constant expressions. */ + return NULL; + } + + if (expr != NULL) + return expr->constant_expression_value(); + + return new(mem_ctx) ir_constant(this->type, &data); +} -- cgit v1.2.3 From 46d91615a2f6e1beaee98f40af957ba1a1a6b349 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Jul 2010 18:29:29 -0700 Subject: ast_function: Set constant_value on return value temporaries in 1.20+. --- src/glsl/ast_function.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 855f27f1756..bb45e2530db 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -122,6 +122,8 @@ process_call(exec_list *instructions, ir_function *f, deref = new(ctx) ir_dereference_variable(var); ir_assignment *assign = new(ctx) ir_assignment(deref, call, NULL); instructions->push_tail(assign); + if (state->language_version >= 120) + var->constant_value = call->constant_expression_value(); deref = new(ctx) ir_dereference_variable(var); return deref; -- cgit v1.2.3 From 38cb1b273f55f98349d981445cfe06351322b032 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 16:57:10 -0700 Subject: ir_constant_expression: Add support for builtins dFdx, dFdy, and fwidth. These always return zero (the derivative of a constant). --- src/glsl/ir_constant_expression.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index aa53d8d1867..641589ed077 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -812,7 +812,7 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "atan") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) { - return NULL; /* FINISHME: implement this */ + return ir_constant::zero(mem_ctx, this->type); } else if (strcmp(callee, "ceil") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "clamp") == 0) { @@ -842,7 +842,7 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "fract") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "fwidth") == 0) { - return NULL; /* FINISHME: implement this */ + return ir_constant::zero(mem_ctx, this->type); } else if (strcmp(callee, "greaterThan") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "greaterThanEqual") == 0) { -- cgit v1.2.3 From 8b1680acc38cfbb6d2fc80ddab3f3eed24e2522a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 16:57:53 -0700 Subject: ir_constant_expression: Implement builtins that wrap an expression. These builtin functions are represented by ir_expression_operations, so we can just create one of those and ask for its value. --- src/glsl/ir_constant_expression.cpp | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 641589ed077..0ffa1f00972 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -802,7 +802,7 @@ ir_call::constant_expression_value() const char *callee = this->callee_name(); if (strcmp(callee, "abs") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_abs, type, op[0], NULL); } else if (strcmp(callee, "all") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "any") == 0) { @@ -814,33 +814,33 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) { return ir_constant::zero(mem_ctx, this->type); } else if (strcmp(callee, "ceil") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_ceil, type, op[0], NULL); } else if (strcmp(callee, "clamp") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "cos") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_cos, type, op[0], NULL); } else if (strcmp(callee, "cosh") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "cross") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_binop_cross, type, op[0], op[1]); } else if (strcmp(callee, "degrees") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "distance") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "dot") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_binop_dot, type, op[0], op[1]); } else if (strcmp(callee, "equal") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "exp") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_exp, type, op[0], NULL); } else if (strcmp(callee, "exp2") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_exp2, type, op[0], NULL); } else if (strcmp(callee, "faceforward") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "floor") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_floor, type, op[0], NULL); } else if (strcmp(callee, "fract") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_fract, type, op[0], NULL); } else if (strcmp(callee, "fwidth") == 0) { return ir_constant::zero(mem_ctx, this->type); } else if (strcmp(callee, "greaterThan") == 0) { @@ -848,7 +848,7 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "greaterThanEqual") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "inversesqrt") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_rsq, type, op[0], NULL); } else if (strcmp(callee, "length") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "lessThan") == 0) { @@ -856,29 +856,29 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "lessThanEqual") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "log") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_log, type, op[0], NULL); } else if (strcmp(callee, "log2") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_log2, type, op[0], NULL); } else if (strcmp(callee, "matrixCompMult") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "max") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_binop_max, type, op[0], op[1]); } else if (strcmp(callee, "min") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_binop_min, type, op[0], op[1]); } else if (strcmp(callee, "mix") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "mod") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_binop_mod, type, op[0], op[1]); } else if (strcmp(callee, "normalize") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "not") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_logic_not, type, op[0], NULL); } else if (strcmp(callee, "notEqual") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "outerProduct") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "pow") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_binop_pow, type, op[0], op[1]); } else if (strcmp(callee, "radians") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "reflect") == 0) { @@ -886,15 +886,15 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "refract") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "sign") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_sign, type, op[0], NULL); } else if (strcmp(callee, "sin") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_sin, type, op[0], NULL); } else if (strcmp(callee, "sinh") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "smoothstep") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "sqrt") == 0) { - return NULL; /* FINISHME: implement this */ + expr = new(mem_ctx) ir_expression(ir_unop_sqrt, type, op[0], NULL); } else if (strcmp(callee, "step") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "tan") == 0) { -- cgit v1.2.3 From aca7e95222ac33e5eda84ecc566da609f6f6ce8e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:34:32 -0700 Subject: ir_constant_expression: Add support for "all" builtin. --- src/glsl/ir_constant_expression.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 0ffa1f00972..bce6747e872 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -804,7 +804,12 @@ ir_call::constant_expression_value() if (strcmp(callee, "abs") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_abs, type, op[0], NULL); } else if (strcmp(callee, "all") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_boolean()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + if (!op[0]->value.b[c]) + return new(mem_ctx) ir_constant(false); + } + return new(mem_ctx) ir_constant(true); } else if (strcmp(callee, "any") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "asin") == 0) { -- cgit v1.2.3 From d6792a7f7c2b73486987d2bc07fc77d46456b65d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:35:52 -0700 Subject: ir_constant_expression: Add support for "any" builtin. --- src/glsl/ir_constant_expression.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index bce6747e872..e4c4a4d8975 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -811,7 +811,12 @@ ir_call::constant_expression_value() } return new(mem_ctx) ir_constant(true); } else if (strcmp(callee, "any") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_boolean()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + if (op[0]->value.b[c]) + return new(mem_ctx) ir_constant(true); + } + return new(mem_ctx) ir_constant(false); } else if (strcmp(callee, "asin") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "atan") == 0) { -- cgit v1.2.3 From 3b6c29b8f00a2475b24022cace69f372b470a9b1 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:38:38 -0700 Subject: ir_constant_expression: Add support for "asin" builtin. --- src/glsl/ir_constant_expression.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index e4c4a4d8975..2276f4d32e2 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -818,7 +818,9 @@ ir_call::constant_expression_value() } return new(mem_ctx) ir_constant(false); } else if (strcmp(callee, "asin") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = asinf(op[0]->value.f[c]); } else if (strcmp(callee, "atan") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) { -- cgit v1.2.3 From f6ea9dfe473ccb0b5121461653696fe07ee4f328 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:39:47 -0700 Subject: ir_constant_expression: Add support for "acos" builtin. --- src/glsl/ir_constant_expression.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 2276f4d32e2..301bfa80251 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -817,6 +817,10 @@ ir_call::constant_expression_value() return new(mem_ctx) ir_constant(true); } return new(mem_ctx) ir_constant(false); + } else if (strcmp(callee, "acos") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = acosf(op[0]->value.f[c]); } else if (strcmp(callee, "asin") == 0) { assert(op[0]->type->is_float()); for (unsigned c = 0; c < op[0]->type->components(); c++) -- cgit v1.2.3 From 13f8758e9c3babdee3fc0b8b8e1d4a7e13ef9694 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:42:23 -0700 Subject: ir_constant_expression: Add support for "atan" builtins. --- src/glsl/ir_constant_expression.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 301bfa80251..a6ce339e3e0 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -826,7 +826,15 @@ ir_call::constant_expression_value() for (unsigned c = 0; c < op[0]->type->components(); c++) data.f[c] = asinf(op[0]->value.f[c]); } else if (strcmp(callee, "atan") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float()); + if (num_parameters == 2) { + assert(op[1]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = atan2f(op[0]->value.f[c], op[1]->value.f[c]); + } else { + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = atanf(op[0]->value.f[c]); + } } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) { return ir_constant::zero(mem_ctx, this->type); } else if (strcmp(callee, "ceil") == 0) { -- cgit v1.2.3 From ba4178345a1eb8e697a8cb01b5594c0a3b4b1d29 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:47:55 -0700 Subject: ir_constant_expression: Add support for the "cosh" builtin. --- src/glsl/ir_constant_expression.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index a6ce339e3e0..ee99ed2cdd4 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -844,7 +844,9 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "cos") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_cos, type, op[0], NULL); } else if (strcmp(callee, "cosh") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = coshf(op[0]->value.f[c]); } else if (strcmp(callee, "cross") == 0) { expr = new(mem_ctx) ir_expression(ir_binop_cross, type, op[0], op[1]); } else if (strcmp(callee, "degrees") == 0) { -- cgit v1.2.3 From 5d551daf38e30d6cb863038afe1a8e32c806e6ae Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:49:56 -0700 Subject: ir_constant_expression: Add support for the "sinh" builtin. --- src/glsl/ir_constant_expression.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index ee99ed2cdd4..b7ceefc393d 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -916,7 +916,9 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "sin") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_sin, type, op[0], NULL); } else if (strcmp(callee, "sinh") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = sinhf(op[0]->value.f[c]); } else if (strcmp(callee, "smoothstep") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "sqrt") == 0) { -- cgit v1.2.3 From 9c9f8b2d69094fb308de0d6a28bcd60cdf8aedf6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:50:50 -0700 Subject: ir_constant_expression: Add support for the "tan" builtin. --- src/glsl/ir_constant_expression.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index b7ceefc393d..bcf87e000f7 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -926,7 +926,9 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "step") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "tan") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = tanf(op[0]->value.f[c]); } else if (strcmp(callee, "tanh") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "transpose") == 0) { -- cgit v1.2.3 From 20970f7dea220a2f44c180579630f453729ab31b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:51:23 -0700 Subject: ir_constant_expression: Add support for the "tanh" builtin. --- src/glsl/ir_constant_expression.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index bcf87e000f7..aedc661025e 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -930,7 +930,9 @@ ir_call::constant_expression_value() for (unsigned c = 0; c < op[0]->type->components(); c++) data.f[c] = tanf(op[0]->value.f[c]); } else if (strcmp(callee, "tanh") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = tanhf(op[0]->value.f[c]); } else if (strcmp(callee, "transpose") == 0) { return NULL; /* FINISHME: implement this */ } else { -- cgit v1.2.3 From 0afe3493221c6a676bcc045aca508bb08f58a4f4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:58:03 -0700 Subject: ir_constant_expression: Add support for the "radians" builtin. --- src/glsl/ir_constant_expression.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index aedc661025e..bc1261b0b95 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -906,7 +906,9 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "pow") == 0) { expr = new(mem_ctx) ir_expression(ir_binop_pow, type, op[0], op[1]); } else if (strcmp(callee, "radians") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = M_PI/180.0 * op[0]->value.f[c]; } else if (strcmp(callee, "reflect") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "refract") == 0) { -- cgit v1.2.3 From 7bcaa3828f8d3d39cfece5d91e47ed2a135a9471 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 17:59:00 -0700 Subject: ir_constant_expression: Add support for the "degrees" builtin. --- src/glsl/ir_constant_expression.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index bc1261b0b95..e68a7b1a2a2 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -850,7 +850,9 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "cross") == 0) { expr = new(mem_ctx) ir_expression(ir_binop_cross, type, op[0], op[1]); } else if (strcmp(callee, "degrees") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = 180.0/M_PI * op[0]->value.f[c]; } else if (strcmp(callee, "distance") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "dot") == 0) { -- cgit v1.2.3 From 2eaf31642c83086b06dce057997ae4bc4b1bce2c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 18:01:22 -0700 Subject: ir_constant_expression: Add support for the "distance" builtin. --- src/glsl/ir_constant_expression.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index e68a7b1a2a2..52f53d9ff48 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -854,7 +854,13 @@ ir_call::constant_expression_value() for (unsigned c = 0; c < op[0]->type->components(); c++) data.f[c] = 180.0/M_PI * op[0]->value.f[c]; } else if (strcmp(callee, "distance") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float() && op[1]->type->is_float()); + float length_squared = 0.0; + for (unsigned c = 0; c < op[0]->type->components(); c++) { + float t = op[0]->value.f[c] - op[1]->value.f[c]; + length_squared += t * t; + } + return new(mem_ctx) ir_constant(sqrtf(length_squared)); } else if (strcmp(callee, "dot") == 0) { expr = new(mem_ctx) ir_expression(ir_binop_dot, type, op[0], op[1]); } else if (strcmp(callee, "equal") == 0) { -- cgit v1.2.3 From 0b6ef6ef6e1930b6ec03dae7ace53372bb239981 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 18:04:22 -0700 Subject: ir_constant_expression: Add support for the "equal" builtin. --- src/glsl/ir_constant_expression.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 52f53d9ff48..e6f9558b62d 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -864,7 +864,22 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "dot") == 0) { expr = new(mem_ctx) ir_expression(ir_binop_dot, type, op[0], op[1]); } else if (strcmp(callee, "equal") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] == op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] == op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] == op[1]->value.f[c]; + break; + default: + assert(!"Should not get here."); + } + } } else if (strcmp(callee, "exp") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_exp, type, op[0], NULL); } else if (strcmp(callee, "exp2") == 0) { -- cgit v1.2.3 From 48a69ba05794f3d253114b452174710a15eefadf Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 18:05:36 -0700 Subject: ir_constant_expression: Add support for the "notEqual" builtin. --- src/glsl/ir_constant_expression.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index e6f9558b62d..4a5eb7540a4 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -923,7 +923,22 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "not") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_logic_not, type, op[0], NULL); } else if (strcmp(callee, "notEqual") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] != op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] != op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] != op[1]->value.f[c]; + break; + default: + assert(!"Should not get here."); + } + } } else if (strcmp(callee, "outerProduct") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "pow") == 0) { -- cgit v1.2.3 From 6d897f07cf7ed8492ef5f0da90259856fdac5bf6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 18:06:18 -0700 Subject: ir_constant_expression: Add support for the "lessThan" builtin. --- src/glsl/ir_constant_expression.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 4a5eb7540a4..032214eb3c4 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -901,7 +901,22 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "length") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "lessThan") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] < op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] < op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] < op[1]->value.f[c]; + break; + default: + assert(!"Should not get here."); + } + } } else if (strcmp(callee, "lessThanEqual") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "log") == 0) { -- cgit v1.2.3 From 319f4949e0a5f1daa3a760fc84096c041e3ce815 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 18:07:09 -0700 Subject: ir_constant_expression: Add support for the "lessThanEqual" builtin. --- src/glsl/ir_constant_expression.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 032214eb3c4..9c543d48ed1 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -918,7 +918,22 @@ ir_call::constant_expression_value() } } } else if (strcmp(callee, "lessThanEqual") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] <= op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] <= op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] <= op[1]->value.f[c]; + break; + default: + assert(!"Should not get here."); + } + } } else if (strcmp(callee, "log") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_log, type, op[0], NULL); } else if (strcmp(callee, "log2") == 0) { -- cgit v1.2.3 From 7f042b98126b1710c819091512621c642f8fcbbc Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 18:07:43 -0700 Subject: ir_constant_expression: Add support for the "greaterThan" builtin. --- src/glsl/ir_constant_expression.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 9c543d48ed1..d40322252e3 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -893,7 +893,22 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "fwidth") == 0) { return ir_constant::zero(mem_ctx, this->type); } else if (strcmp(callee, "greaterThan") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] > op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] > op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] > op[1]->value.f[c]; + break; + default: + assert(!"Should not get here."); + } + } } else if (strcmp(callee, "greaterThanEqual") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "inversesqrt") == 0) { -- cgit v1.2.3 From 557827340aedbf64d2486226924d00c94107c9e8 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 18:08:05 -0700 Subject: ir_constant_expression: Add support for the "greaterThanEqual" builtin. --- src/glsl/ir_constant_expression.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index d40322252e3..cce13139b77 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -910,7 +910,22 @@ ir_call::constant_expression_value() } } } else if (strcmp(callee, "greaterThanEqual") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] >= op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] >= op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] >= op[1]->value.f[c]; + break; + default: + assert(!"Should not get here."); + } + } } else if (strcmp(callee, "inversesqrt") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_rsq, type, op[0], NULL); } else if (strcmp(callee, "length") == 0) { -- cgit v1.2.3 From 4b1d77ea966771dc5fbdac90dfec1b6066afe3f8 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 18:18:16 -0700 Subject: ir_constant_expression: Remove support for dot products of integers. This shouldn't be required since dot is only defined for floating point types, even in GLSL 4.0. --- src/glsl/ir_constant_expression.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index cce13139b77..799bd4a60b7 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -327,21 +327,10 @@ ir_expression::constant_expression_value() case ir_binop_dot: assert(op[0]->type->is_vector() && op[1]->type->is_vector()); + assert(op[0]->type->is_float() && op[1]->type->is_float()); data.f[0] = 0; for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[0] += op[0]->value.u[c] * op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[0] += op[0]->value.i[c] * op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[0] += op[0]->value.f[c] * op[1]->value.f[c]; - break; - default: - assert(0); - } + data.f[0] += op[0]->value.f[c] * op[1]->value.f[c]; } break; -- cgit v1.2.3 From ffcec135997545b4dc2b3393ccb02558083373a0 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 20:09:21 -0700 Subject: ir_constant_expression: Extract dot product calculation for reuse. --- src/glsl/ir_constant_expression.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 799bd4a60b7..c4a416aa355 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -39,6 +39,18 @@ #include "ir_visitor.h" #include "glsl_types.h" +static float +dot(ir_constant *op0, ir_constant *op1) +{ + assert(op0->type->is_float() && op1->type->is_float()); + + float result = 0; + for (unsigned c = 0; c < op0->type->components(); c++) + result += op0->value.f[c] * op1->value.f[c]; + + return result; +} + ir_constant * ir_expression::constant_expression_value() { @@ -326,14 +338,9 @@ ir_expression::constant_expression_value() break; case ir_binop_dot: - assert(op[0]->type->is_vector() && op[1]->type->is_vector()); - assert(op[0]->type->is_float() && op[1]->type->is_float()); - data.f[0] = 0; - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[0] += op[0]->value.f[c] * op[1]->value.f[c]; - } - + data.f[0] = dot(op[0], op[1]); break; + case ir_binop_min: assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); for (unsigned c = 0, c0 = 0, c1 = 0; -- cgit v1.2.3 From 5489ad086f77e548905c98ccd27cd626d706d5f9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 18:26:00 -0700 Subject: ir_constant_expression: Add support for the "length" builtin. --- src/glsl/ir_constant_expression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index c4a416aa355..83d1b34bed6 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -925,7 +925,7 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "inversesqrt") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_rsq, type, op[0], NULL); } else if (strcmp(callee, "length") == 0) { - return NULL; /* FINISHME: implement this */ + return new(mem_ctx) ir_constant(sqrtf(dot(op[0], op[0]))); } else if (strcmp(callee, "lessThan") == 0) { assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); for (unsigned c = 0; c < op[0]->type->components(); c++) { -- cgit v1.2.3 From a7650af706b359056db8b9da6d1d83669106d463 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 20:12:43 -0700 Subject: ir_constant_expression: Simplify code that implements the "dot" builtin. There's no need to use an ir_expression; we have a handy C function. --- src/glsl/ir_constant_expression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 83d1b34bed6..d20d1953e24 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -858,7 +858,7 @@ ir_call::constant_expression_value() } return new(mem_ctx) ir_constant(sqrtf(length_squared)); } else if (strcmp(callee, "dot") == 0) { - expr = new(mem_ctx) ir_expression(ir_binop_dot, type, op[0], op[1]); + return new(mem_ctx) ir_constant(dot(op[0], op[1])); } else if (strcmp(callee, "equal") == 0) { assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); for (unsigned c = 0; c < op[0]->type->components(); c++) { -- cgit v1.2.3 From 8fe5f30645e1b6a87497c1abc408ade633e9ebc1 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 20:03:55 -0700 Subject: ir_constant_expression: Add support for the "matrixCompMult" builtin. --- src/glsl/ir_constant_expression.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index d20d1953e24..2c80c8b5e09 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -965,7 +965,9 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "log2") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_log2, type, op[0], NULL); } else if (strcmp(callee, "matrixCompMult") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float() && op[1]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = op[0]->value.f[c] * op[1]->value.f[c]; } else if (strcmp(callee, "max") == 0) { expr = new(mem_ctx) ir_expression(ir_binop_max, type, op[0], op[1]); } else if (strcmp(callee, "min") == 0) { -- cgit v1.2.3 From 53f306d573ce6393062cf86d4fe31148eacc5e1e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 20:19:32 -0700 Subject: ir_constant_expression: Add support for the "normalize" builtin. --- src/glsl/ir_constant_expression.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 2c80c8b5e09..809ea609a3d 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -977,7 +977,14 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "mod") == 0) { expr = new(mem_ctx) ir_expression(ir_binop_mod, type, op[0], op[1]); } else if (strcmp(callee, "normalize") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float()); + float length = sqrtf(dot(op[0], op[0])); + + if (length == 0) + return ir_constant::zero(mem_ctx, this->type); + + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = op[0]->value.f[c] / length; } else if (strcmp(callee, "not") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_logic_not, type, op[0], NULL); } else if (strcmp(callee, "notEqual") == 0) { -- cgit v1.2.3 From d60b2b03da30093ae85458f1d0be3cc5c33d992c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 20:24:29 -0700 Subject: ir_constant_expression: Add support for the "reflect" builtin. --- src/glsl/ir_constant_expression.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 809ea609a3d..c8320814a3e 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -1013,7 +1013,10 @@ ir_call::constant_expression_value() for (unsigned c = 0; c < op[0]->type->components(); c++) data.f[c] = M_PI/180.0 * op[0]->value.f[c]; } else if (strcmp(callee, "reflect") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float()); + float dot_NI = dot(op[1], op[0]); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = op[0]->value.f[c] - 2 * dot_NI * op[1]->value.f[c]; } else if (strcmp(callee, "refract") == 0) { return NULL; /* FINISHME: implement this */ } else if (strcmp(callee, "sign") == 0) { -- cgit v1.2.3 From 04b3643dbf2e0d25e67c86845b2506ad1d26939d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 20:33:42 -0700 Subject: ir_constant_expression: Add support for the "refract" builtin. --- src/glsl/ir_constant_expression.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index c8320814a3e..580ef1d4fae 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -1018,7 +1018,17 @@ ir_call::constant_expression_value() for (unsigned c = 0; c < op[0]->type->components(); c++) data.f[c] = op[0]->value.f[c] - 2 * dot_NI * op[1]->value.f[c]; } else if (strcmp(callee, "refract") == 0) { - return NULL; /* FINISHME: implement this */ + const float eta = op[2]->value.f[0]; + const float dot_NI = dot(op[1], op[0]); + const float k = 1.0 - eta * eta * (1.0 - dot_NI * dot_NI); + if (k < 0.0) { + return ir_constant::zero(mem_ctx, this->type); + } else { + for (unsigned c = 0; c < type->components(); c++) { + data.f[c] = eta * op[0]->value.f[c] - (eta * dot_NI + sqrtf(k)) + * op[1]->value.f[c]; + } + } } else if (strcmp(callee, "sign") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_sign, type, op[0], NULL); } else if (strcmp(callee, "sin") == 0) { -- cgit v1.2.3 From 3d5c2f0adbd72a68d4fe3900b0d3e267510950ef Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 21:46:16 -0700 Subject: ir_constant_expression: Add support for the "faceforward" builtin. --- src/glsl/ir_constant_expression.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 580ef1d4fae..c939690129a 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -881,7 +881,10 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "exp2") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_exp2, type, op[0], NULL); } else if (strcmp(callee, "faceforward") == 0) { - return NULL; /* FINISHME: implement this */ + if (dot(op[2], op[1]) < 0) + return op[0]; + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = -op[0]->value.f[c]; } else if (strcmp(callee, "floor") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_floor, type, op[0], NULL); } else if (strcmp(callee, "fract") == 0) { -- cgit v1.2.3 From ff58b7c9b6f513ed8bf57b3e4283b67b06fd9d34 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 21:53:40 -0700 Subject: ir_constant_expression: Add support for the "step" builtin. --- src/glsl/ir_constant_expression.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index c939690129a..5485d79a88f 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -1045,7 +1045,11 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "sqrt") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_sqrt, type, op[0], NULL); } else if (strcmp(callee, "step") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float() && op[1]->type->is_float()); + /* op[0] (edge) may be either a scalar or a vector */ + const unsigned c0_inc = op[0]->type->is_scalar() ? 0 : 1; + for (unsigned c = 0, c0 = 0; c < type->components(); c0 += c0_inc, c++) + data.f[c] = (op[1]->value.f[c] < op[0]->value.f[c0]) ? 0.0 : 1.0; } else if (strcmp(callee, "tan") == 0) { assert(op[0]->type->is_float()); for (unsigned c = 0; c < op[0]->type->components(); c++) -- cgit v1.2.3 From a4ca1cfb66160c4ea2325f503ff025a4adc35084 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 22:23:17 -0700 Subject: ir_constant_expression: Add support for the "clamp" builtin. --- src/glsl/ir_constant_expression.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 5485d79a88f..a2748a726cc 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -836,7 +836,30 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "ceil") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_ceil, type, op[0], NULL); } else if (strcmp(callee, "clamp") == 0) { - return NULL; /* FINISHME: implement this */ + assert(num_parameters == 3); + unsigned c1_inc = op[1]->type->is_scalar() ? 0 : 1; + unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1; + for (unsigned c = 0, c1 = 0, c2 = 0; + c < op[0]->type->components(); + c1 += c1_inc, c2 += c2_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = CLAMP(op[0]->value.u[c], op[1]->value.u[c1], + op[2]->value.u[c2]); + break; + case GLSL_TYPE_INT: + data.i[c] = CLAMP(op[0]->value.i[c], op[1]->value.i[c1], + op[2]->value.u[c2]); + break; + case GLSL_TYPE_FLOAT: + data.f[c] = CLAMP(op[0]->value.f[c], op[1]->value.f[c1], + op[2]->value.f[c2]); + break; + default: + assert(!"Should not get here."); + } + } } else if (strcmp(callee, "cos") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_cos, type, op[0], NULL); } else if (strcmp(callee, "cosh") == 0) { -- cgit v1.2.3 From 546f3a27540c408c9d83368c5f6144e13167dcb3 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2010 22:37:50 -0700 Subject: ir_constant_expression: Add support for the "smoothstep" builtin. --- src/glsl/ir_constant_expression.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index a2748a726cc..b6cb2d86726 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -1064,7 +1064,21 @@ ir_call::constant_expression_value() for (unsigned c = 0; c < op[0]->type->components(); c++) data.f[c] = sinhf(op[0]->value.f[c]); } else if (strcmp(callee, "smoothstep") == 0) { - return NULL; /* FINISHME: implement this */ + assert(num_parameters == 3); + assert(op[1]->type == op[0]->type); + unsigned edge_inc = op[0]->type->is_scalar() ? 0 : 1; + for (unsigned c = 0, e = 0; c < type->components(); e += edge_inc, c++) { + const float edge0 = op[0]->value.f[e]; + const float edge1 = op[1]->value.f[e]; + if (edge0 == edge1) { + data.f[c] = 0.0; /* Avoid a crash - results are undefined anyway */ + } else { + const float numerator = op[2]->value.f[c] - edge0; + const float denominator = edge1 - edge0; + const float t = CLAMP(numerator/denominator, 0, 1); + data.f[c] = t * t * (3 - 2 * t); + } + } } else if (strcmp(callee, "sqrt") == 0) { expr = new(mem_ctx) ir_expression(ir_unop_sqrt, type, op[0], NULL); } else if (strcmp(callee, "step") == 0) { -- cgit v1.2.3 From b09ae5dd3f9b8e380e2608f4ee3a7902f5ecc15e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Jul 2010 15:34:49 -0700 Subject: ir_constant_expression: Add support for the "transpose" builtin. --- src/glsl/ir_constant_expression.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index b6cb2d86726..c4e6d837b02 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -1096,7 +1096,14 @@ ir_call::constant_expression_value() for (unsigned c = 0; c < op[0]->type->components(); c++) data.f[c] = tanhf(op[0]->value.f[c]); } else if (strcmp(callee, "transpose") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_matrix()); + const unsigned n = op[0]->type->vector_elements; + const unsigned m = op[0]->type->matrix_columns; + for (unsigned j = 0; j < m; j++) { + for (unsigned i = 0; i < n; i++) { + data.f[m*i+j] += op[0]->value.f[i+n*j]; + } + } } else { /* Unsupported builtin - some are not allowed in constant expressions. */ return NULL; -- cgit v1.2.3 From 5d255e24b29930e78321c1ba807df71fea12174a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 23 Jul 2010 12:36:50 -0700 Subject: ir_constant_expression: Add support for the "mix" builtin. Both 1.10 and 1.30 variants. --- src/glsl/ir_constant_expression.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index c4e6d837b02..9fc37b37779 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -999,7 +999,19 @@ ir_call::constant_expression_value() } else if (strcmp(callee, "min") == 0) { expr = new(mem_ctx) ir_expression(ir_binop_min, type, op[0], op[1]); } else if (strcmp(callee, "mix") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_float() && op[1]->type->is_float()); + if (op[2]->type->is_float()) { + unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1; + unsigned components = op[0]->type->components(); + for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) { + data.f[c] = op[0]->value.f[c] * (1 - op[2]->value.f[c2]) + + op[1]->value.f[c] * op[2]->value.f[c2]; + } + } else { + assert(op[2]->type->is_boolean()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = op[op[2]->value.b[c] ? 1 : 0]->value.f[c]; + } } else if (strcmp(callee, "mod") == 0) { expr = new(mem_ctx) ir_expression(ir_binop_mod, type, op[0], op[1]); } else if (strcmp(callee, "normalize") == 0) { -- cgit v1.2.3 From 7ddee6a535f7323d7c6131e52e7933130d886ae4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 23 Jul 2010 13:24:09 -0700 Subject: ir_constant_expression: Add support for the "outerProduct" builtin. --- src/glsl/ir_constant_expression.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 9fc37b37779..f02cd3127ee 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -1043,7 +1043,14 @@ ir_call::constant_expression_value() } } } else if (strcmp(callee, "outerProduct") == 0) { - return NULL; /* FINISHME: implement this */ + assert(op[0]->type->is_vector() && op[1]->type->is_vector()); + const unsigned m = op[0]->type->vector_elements; + const unsigned n = op[1]->type->vector_elements; + for (unsigned j = 0; j < n; j++) { + for (unsigned i = 0; i < m; i++) { + data.f[i+m*j] = op[0]->value.f[i] * op[1]->value.f[j]; + } + } } else if (strcmp(callee, "pow") == 0) { expr = new(mem_ctx) ir_expression(ir_binop_pow, type, op[0], op[1]); } else if (strcmp(callee, "radians") == 0) { -- cgit v1.2.3 From 56af4e56e3852363a810174c64650df6f0ae4f53 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Jul 2010 11:58:27 -0700 Subject: glsl2: Fix outerProduct builtin. The type signatures were completely backwards. --- src/glsl/builtin_function.cpp | 98 +++++++++++----------- src/glsl/builtins/120/outerProduct | 98 +++++++++++----------- .../builtins/tools/generate_outerProductGLSL.py | 4 +- 3 files changed, 100 insertions(+), 100 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index cc957e4b661..3343cf5638b 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -2666,92 +2666,92 @@ static const char *builtins_120_outerProduct = { " (declare (in) vec2 u)\n" " (declare (in) vec2 v))\n" " ((declare () mat2 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" - "(return (var_ref m))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" " (signature mat2x3\n" " (parameters\n" - " (declare (in) vec2 u)\n" - " (declare (in) vec3 v))\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec2 v))\n" " ((declare () mat2x3 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" - "(return (var_ref m))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" " (signature mat2x4\n" " (parameters\n" - " (declare (in) vec2 u)\n" - " (declare (in) vec4 v))\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec2 v))\n" " ((declare () mat2x4 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" - "(return (var_ref m))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" " (signature mat3x2\n" " (parameters\n" - " (declare (in) vec3 u)\n" - " (declare (in) vec2 v))\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec3 v))\n" " ((declare () mat3x2 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) \n" - "(return (var_ref m))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))\n" + " (return (var_ref m))\n" + " ))\n" "\n" " (signature mat3\n" " (parameters\n" " (declare (in) vec3 u)\n" " (declare (in) vec3 v))\n" " ((declare () mat3 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) \n" - "(return (var_ref m))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" " (signature mat3x4\n" " (parameters\n" - " (declare (in) vec3 u)\n" - " (declare (in) vec4 v))\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec3 v))\n" " ((declare () mat3x4 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) \n" - "(return (var_ref m))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" " (signature mat4x2\n" " (parameters\n" - " (declare (in) vec4 u)\n" - " (declare (in) vec2 v))\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec4 v))\n" " ((declare () mat4x2 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref v) (swiz w (var_ref u)))) \n" - "(return (var_ref m))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" " (signature mat4x3\n" " (parameters\n" - " (declare (in) vec4 u)\n" - " (declare (in) vec3 v))\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec4 v))\n" " ((declare () mat4x3 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref v) (swiz w (var_ref u)))) \n" - "(return (var_ref m))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" " (signature mat4\n" " (parameters\n" " (declare (in) vec4 u)\n" " (declare (in) vec4 v))\n" " ((declare () mat4 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) \n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref v) (swiz w (var_ref u)))) \n" - "(return (var_ref m))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref u) (swiz w (var_ref v))))\n" + " (return (var_ref m))))\n" "))\n" - "\n" }; static const char *builtins_120_transpose = { diff --git a/src/glsl/builtins/120/outerProduct b/src/glsl/builtins/120/outerProduct index b401ba02337..69ae741e176 100644 --- a/src/glsl/builtins/120/outerProduct +++ b/src/glsl/builtins/120/outerProduct @@ -4,89 +4,89 @@ (declare (in) vec2 u) (declare (in) vec2 v)) ((declare () mat2 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) -(return (var_ref m)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) + (return (var_ref m)))) (signature mat2x3 (parameters - (declare (in) vec2 u) - (declare (in) vec3 v)) + (declare (in) vec3 u) + (declare (in) vec2 v)) ((declare () mat2x3 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) -(return (var_ref m)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) + (return (var_ref m)))) (signature mat2x4 (parameters - (declare (in) vec2 u) - (declare (in) vec4 v)) + (declare (in) vec4 u) + (declare (in) vec2 v)) ((declare () mat2x4 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) -(return (var_ref m)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) + (return (var_ref m)))) (signature mat3x2 (parameters - (declare (in) vec3 u) - (declare (in) vec2 v)) + (declare (in) vec2 u) + (declare (in) vec3 v)) ((declare () mat3x2 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) -(return (var_ref m)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v)))) + (return (var_ref m)) + )) (signature mat3 (parameters (declare (in) vec3 u) (declare (in) vec3 v)) ((declare () mat3 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) -(return (var_ref m)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v)))) + (return (var_ref m)))) (signature mat3x4 (parameters - (declare (in) vec3 u) - (declare (in) vec4 v)) + (declare (in) vec4 u) + (declare (in) vec3 v)) ((declare () mat3x4 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) -(return (var_ref m)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v)))) + (return (var_ref m)))) (signature mat4x2 (parameters - (declare (in) vec4 u) - (declare (in) vec2 v)) + (declare (in) vec2 u) + (declare (in) vec4 v)) ((declare () mat4x2 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref v) (swiz z (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref v) (swiz w (var_ref u)))) -(return (var_ref m)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v)))) + (return (var_ref m)))) (signature mat4x3 (parameters - (declare (in) vec4 u) - (declare (in) vec3 v)) + (declare (in) vec3 u) + (declare (in) vec4 v)) ((declare () mat4x3 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref v) (swiz z (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref v) (swiz w (var_ref u)))) -(return (var_ref m)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v)))) + (return (var_ref m)))) (signature mat4 (parameters (declare (in) vec4 u) (declare (in) vec4 v)) ((declare () mat4 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref v) (swiz x (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref v) (swiz y (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref v) (swiz z (var_ref u)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref v) (swiz w (var_ref u)))) -(return (var_ref m)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v)))) + (assign (constant bool (1)) (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/tools/generate_outerProductGLSL.py b/src/glsl/builtins/tools/generate_outerProductGLSL.py index 48fb72197c3..c561cc3ba14 100755 --- a/src/glsl/builtins/tools/generate_outerProductGLSL.py +++ b/src/glsl/builtins/tools/generate_outerProductGLSL.py @@ -4,11 +4,11 @@ def gen(x, y): type = "mat" + str(x) if x != y: type = type + "x" + str(y) - print type + " outerProduct(vec" + str(x) + " u, vec" + str(y) + " v)\n{" + print type + " outerProduct(vec" + str(y) + " u, vec" + str(x) + " v)\n{" print " " + type + " m;" for i in range(x): - print " m[" + str(i) + "] = v * u[" + str(i) + "];" + print " m[" + str(i) + "] = u * v[" + str(i) + "];" print " return m;\n}" print "#version 120" -- cgit v1.2.3 From 859fd56245c1d725cacab17a34793d41ea14e867 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 15:42:35 -0700 Subject: ir_to_mesa: Respect the driver if it rejects a shader. --- src/mesa/drivers/dri/i965/brw_program.c | 6 ++---- src/mesa/program/ir_to_mesa.cpp | 14 +++++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 4b08d2599bc..c6d11fed064 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -36,6 +36,7 @@ #include "program/program.h" #include "program/programopt.h" #include "tnl/tnl.h" +#include "talloc.h" #include "brw_context.h" #include "brw_wm.h" @@ -114,10 +115,7 @@ shader_error(GLcontext *ctx, struct gl_program *prog, const char *msg) shader = _mesa_lookup_shader_program(ctx, prog->Id); if (shader) { - if (shader->InfoLog) { - free(shader->InfoLog); - } - shader->InfoLog = _mesa_strdup(msg); + shader->InfoLog = talloc_strdup_append(shader->InfoLog, msg); shader->LinkStatus = GL_FALSE; } } diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index a3019cc650a..3a28c566d4d 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2320,7 +2320,7 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, validate_ir_tree(shader->ir); - prog = ctx->Driver.NewProgram(ctx, target, 1); + prog = ctx->Driver.NewProgram(ctx, target, shader_program->Name); if (!prog) return NULL; prog->Parameters = _mesa_new_parameter_list(); @@ -2536,6 +2536,7 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) if (prog->LinkStatus) { for (i = 0; i < prog->_NumLinkedShaders; i++) { struct gl_program *linked_prog; + bool ok = true; linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]); @@ -2547,16 +2548,19 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) case GL_VERTEX_SHADER: _mesa_reference_vertprog(ctx, &prog->VertexProgram, (struct gl_vertex_program *)linked_prog); - ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, - linked_prog); + ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, + linked_prog); break; case GL_FRAGMENT_SHADER: _mesa_reference_fragprog(ctx, &prog->FragmentProgram, (struct gl_fragment_program *)linked_prog); - ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB, - linked_prog); + ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB, + linked_prog); break; } + if (!ok) { + prog->LinkStatus = GL_FALSE; + } } } } -- cgit v1.2.3 From 35cc8b98ec4d898417de5b820dcbcf62c74b3599 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Jul 2010 16:44:56 -0700 Subject: glsl2/Makefile: Append to DEFINES rather than replacing them. Otherwise, we lose DEBUG, which causes mtypes.h to set NDEBUG, which causes assertions to not happen, which is no fun for anyone. --- src/glsl/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 4c85af8906d..cbdd0f9a7a3 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -82,7 +82,7 @@ GLSL2_OBJECTS = \ ### Basic defines ### -DEFINES = \ +DEFINES += \ $(LIBRARY_DEFINES) \ $(API_DEFINES) -- cgit v1.2.3 From 192b57df8c451c7ae39e5471124a9bab36ec17f8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 16:11:26 -0700 Subject: glsl2: Make lowp, mediump, highp, and precision identifiers pre-1.20. Fixes glsl-precision-110. --- src/glsl/glsl_lexer.cpp | 52 +++++++++++++++++++++++++++++++++++++------------ src/glsl/glsl_lexer.lpp | 36 ++++++++++++++++++++++++++++++---- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp index ecb4b857bbd..e5ca1bd0a51 100644 --- a/src/glsl/glsl_lexer.cpp +++ b/src/glsl/glsl_lexer.cpp @@ -1994,26 +1994,54 @@ return USING; case 140: YY_RULE_SETUP #line 321 "glsl_lexer.lpp" -return LOWP; +{ + if (yyextra->language_version >= 120){ + return LOWP; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } YY_BREAK case 141: YY_RULE_SETUP -#line 322 "glsl_lexer.lpp" -return MEDIUMP; +#line 329 "glsl_lexer.lpp" +{ + if (yyextra->language_version >= 120){ + return MEDIUMP; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + }return MEDIUMP; YY_BREAK case 142: YY_RULE_SETUP -#line 323 "glsl_lexer.lpp" -return HIGHP; +#line 337 "glsl_lexer.lpp" +{ + if (yyextra->language_version >= 120){ + return HIGHP; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } YY_BREAK case 143: YY_RULE_SETUP -#line 324 "glsl_lexer.lpp" -return PRECISION; +#line 345 "glsl_lexer.lpp" +{ + if (yyextra->language_version >= 120){ + return PRECISION; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } YY_BREAK case 144: YY_RULE_SETUP -#line 326 "glsl_lexer.lpp" +#line 354 "glsl_lexer.lpp" { struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; @@ -2023,15 +2051,15 @@ YY_RULE_SETUP YY_BREAK case 145: YY_RULE_SETUP -#line 333 "glsl_lexer.lpp" +#line 361 "glsl_lexer.lpp" { return yytext[0]; } YY_BREAK case 146: YY_RULE_SETUP -#line 335 "glsl_lexer.lpp" +#line 363 "glsl_lexer.lpp" ECHO; YY_BREAK -#line 2035 "glsl_lexer.cpp" +#line 2063 "glsl_lexer.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(PP): yyterminate(); @@ -3173,7 +3201,7 @@ void _mesa_glsl_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 335 "glsl_lexer.lpp" +#line 363 "glsl_lexer.lpp" diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index ebfea37597d..702e79a363e 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -318,10 +318,38 @@ namespace return NAMESPACE; using return USING; /* Additional reserved words in GLSL 1.20. */ -lowp return LOWP; -mediump return MEDIUMP; -highp return HIGHP; -precision return PRECISION; +lowp { + if (yyextra->language_version >= 120){ + return LOWP; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } +mediump { + if (yyextra->language_version >= 120){ + return MEDIUMP; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + }return MEDIUMP; +highp { + if (yyextra->language_version >= 120){ + return HIGHP; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } +precision { + if (yyextra->language_version >= 120){ + return PRECISION; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } [_a-zA-Z][_a-zA-Z0-9]* { struct _mesa_glsl_parse_state *state = yyextra; -- cgit v1.2.3 From 8605c297cfb8068737991601f163f866395c41c9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 16:53:51 -0700 Subject: glcpp: Print integer tokens as decimal, not hex. --- src/glsl/glcpp/glcpp-parse.c | 2 +- src/glsl/glcpp/glcpp-parse.y | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 8fbbdab52fc..bfbd97f3d83 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -3041,7 +3041,7 @@ _token_print (char **out, token_t *token) switch (token->type) { case INTEGER: - glcpp_printf (*out, "%" PRIxMAX, token->value.ival); + glcpp_printf (*out, "%" PRIiMAX, token->value.ival); break; case IDENTIFIER: case INTEGER_STRING: diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index c6ff32e544c..2009aeaf8a2 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -736,7 +736,7 @@ _token_print (char **out, token_t *token) switch (token->type) { case INTEGER: - glcpp_printf (*out, "%" PRIxMAX, token->value.ival); + glcpp_printf (*out, "%" PRIiMAX, token->value.ival); break; case IDENTIFIER: case INTEGER_STRING: -- cgit v1.2.3 From d4a04f315560704bf1103df0b93723e468725df7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 16:58:39 -0700 Subject: glcpp: Add __VERSION__ define to the current language version. Fixes: glsl-version-define glsl-version-define-110 glsl-version-define-120 --- src/glsl/glcpp/glcpp-lex.c | 400 +++++++++--------- src/glsl/glcpp/glcpp-lex.l | 10 +- src/glsl/glcpp/glcpp-parse.c | 968 ++++++++++++++++++++++--------------------- src/glsl/glcpp/glcpp-parse.h | 37 +- src/glsl/glcpp/glcpp-parse.y | 73 ++-- 5 files changed, 774 insertions(+), 714 deletions(-) diff --git a/src/glsl/glcpp/glcpp-lex.c b/src/glsl/glcpp/glcpp-lex.c index edf98a4afd2..40db2c27c51 100644 --- a/src/glsl/glcpp/glcpp-lex.c +++ b/src/glsl/glcpp/glcpp-lex.c @@ -358,8 +358,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 40 -#define YY_END_OF_BUFFER 41 +#define YY_NUM_RULES 41 +#define YY_END_OF_BUFFER 42 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -367,26 +367,26 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_acclist[132] = +static yyconst flex_int16_t yy_acclist[133] = { 0, - 3, 3, 41, 36, 40, 37, 40, 38, 40, 40, - 35, 40, 40, 35, 40, 35, 40, 35, 40, 22, - 36, 40, 21, 36, 40, 35, 40, 35, 40, 35, - 40, 34, 36, 40, 34, 36, 40, 35, 40, 37, - 40, 20, 40, 40, 3, 40, 4, 40, 5, 40, - 39, 40, 36, 15, 37, 29, 32, 30, 2, 22, - 36, 22, 36, 36, 21, 36, 21, 36, 24, 26, - 28, 27, 25, 34, 36, 34, 36, 31, 37, 20, - 20, 3, 4, 5, 6, 5, 7, 1, 15, 23, - 36, 34, 36,16395, 23, 36, 34, 36, 15, 34, - - 36,16396,16397, 8203, 15, 8203, 34, 36, 8204, 15, - 8205, 15,16398, 16,16393, 19, 33, 34, 36, 18, - 8206, 15, 16, 8201, 15,16394,16401, 8202, 15, 8, - 8209 + 3, 3, 42, 37, 41, 38, 41, 39, 41, 41, + 36, 41, 41, 36, 41, 36, 41, 36, 41, 23, + 37, 41, 22, 37, 41, 36, 41, 36, 41, 36, + 41, 35, 37, 41, 35, 37, 41, 36, 41, 38, + 41, 21, 41, 41, 3, 41, 4, 41, 5, 41, + 40, 41, 37, 16, 38, 30, 33, 31, 2, 23, + 37, 23, 37, 37, 22, 37, 22, 37, 25, 27, + 29, 28, 26, 35, 37, 35, 37, 32, 38, 21, + 21, 3, 4, 5, 6, 5, 7, 1, 16, 24, + 37, 35, 37,16396, 24, 37, 35, 37, 16, 35, + + 37,16397,16398, 8204, 16, 8204, 35, 37, 8205, 16, + 8206, 16,16399, 17,16394, 20, 34, 35, 37, 19, + 8207, 16, 17, 8202, 16,16395,16402, 8203, 16, 9, + 8, 8210 } ; -static yyconst flex_int16_t yy_accept[151] = +static yyconst flex_int16_t yy_accept[152] = { 0, 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, 6, 8, 10, 11, 13, 14, 16, 18, 20, 23, @@ -403,7 +403,8 @@ static yyconst flex_int16_t yy_accept[151] = 107, 107, 107, 107, 107, 109, 109, 109, 111, 111, 113, 114, 115, 115, 116, 116, 116, 117, 117, 120, 121, 121, 123, 124, 124, 124, 126, 127, 127, 127, - 128, 128, 128, 130, 131, 131, 131, 132, 132, 132 + 128, 128, 128, 130, 131, 132, 132, 132, 133, 133, + 133 } ; static yyconst flex_int32_t yy_ec[256] = @@ -446,48 +447,48 @@ static yyconst flex_int32_t yy_meta[40] = 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; -static yyconst flex_int16_t yy_base[169] = +static yyconst flex_int16_t yy_base[170] = { 0, - 0, 38, 0, 0, 38, 39, 426, 425, 427, 48, - 43, 549, 423, 44, 63, 422, 59, 65, 87, 125, - 58, 67, 68, 164, 203, 40, 75, 241, 549, 421, - 549, 140, 549, 140, 420, 549, 144, 419, 418, 417, - 415, 414, 156, 179, 267, 0, 209, 413, 412, 411, - 410, 409, 387, 124, 407, 153, 403, 402, 154, 198, - 159, 155, 160, 192, 404, 549, 186, 549, 214, 549, - 359, 549, 162, 159, 227, 229, 230, 234, 199, 303, + 0, 38, 0, 0, 38, 39, 427, 426, 428, 48, + 43, 549, 424, 44, 63, 423, 59, 65, 87, 125, + 58, 67, 68, 164, 203, 40, 75, 241, 549, 422, + 549, 140, 549, 140, 421, 549, 144, 420, 419, 418, + 417, 415, 156, 179, 267, 0, 209, 414, 413, 412, + 411, 410, 388, 124, 408, 153, 404, 403, 154, 198, + 159, 155, 160, 192, 405, 549, 186, 549, 214, 549, + 404, 549, 162, 159, 227, 229, 230, 234, 199, 303, 232, 235, 236, 262, 56, 243, 237, 247, 245, 252, - 291, 358, 357, 292, 238, 296, 293, 254, 335, 256, - - 355, 354, 298, 294, 263, 352, 549, 350, 549, 299, - 297, 322, 325, 257, 306, 328, 346, 549, 345, 549, - 344, 343, 329, 342, 331, 332, 341, 333, 319, 335, - 337, 549, 248, 338, 246, 549, 197, 184, 336, 366, - 403, 182, 549, 141, 434, 416, 79, 473, 549, 512, - 514, 516, 518, 520, 522, 71, 524, 526, 528, 530, - 532, 534, 536, 538, 540, 542, 544, 546 + 291, 359, 358, 292, 238, 296, 293, 254, 336, 256, + + 356, 355, 298, 294, 263, 354, 549, 352, 549, 299, + 297, 322, 325, 257, 306, 328, 350, 549, 346, 549, + 345, 344, 329, 343, 331, 332, 342, 333, 320, 335, + 340, 549, 337, 338, 248, 549, 246, 197, 336, 366, + 403, 184, 549, 182, 141, 434, 416, 79, 473, 549, + 512, 514, 516, 518, 520, 522, 71, 524, 526, 528, + 530, 532, 534, 536, 538, 540, 542, 544, 546 } ; -static yyconst flex_int16_t yy_def[169] = +static yyconst flex_int16_t yy_def[170] = { 0, - 149, 1, 150, 150, 151, 151, 152, 152, 149, 153, - 154, 149, 154, 154, 154, 154, 154, 154, 149, 153, - 154, 154, 154, 155, 155, 154, 154, 154, 149, 156, - 149, 157, 149, 20, 154, 149, 154, 154, 154, 154, - 154, 158, 19, 20, 20, 20, 20, 154, 154, 154, - 154, 154, 25, 25, 154, 154, 28, 28, 154, 154, - 154, 154, 154, 154, 156, 149, 157, 149, 157, 149, - 158, 149, 45, 25, 154, 154, 154, 154, 154, 154, - 154, 154, 154, 20, 25, 154, 154, 154, 154, 154, - 154, 159, 160, 154, 154, 154, 154, 154, 25, 154, - - 161, 162, 154, 154, 154, 159, 149, 160, 149, 154, - 154, 154, 154, 154, 25, 154, 161, 149, 162, 149, - 163, 164, 154, 165, 154, 154, 154, 154, 25, 154, - 163, 149, 164, 154, 165, 149, 166, 167, 154, 149, - 154, 166, 149, 167, 168, 154, 154, 168, 0, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149 + 150, 1, 151, 151, 152, 152, 153, 153, 150, 154, + 155, 150, 155, 155, 155, 155, 155, 155, 150, 154, + 155, 155, 155, 156, 156, 155, 155, 155, 150, 157, + 150, 158, 150, 20, 155, 150, 155, 155, 155, 155, + 155, 159, 19, 20, 20, 20, 20, 155, 155, 155, + 155, 155, 25, 25, 155, 155, 28, 28, 155, 155, + 155, 155, 155, 155, 157, 150, 158, 150, 158, 150, + 159, 150, 45, 25, 155, 155, 155, 155, 155, 155, + 155, 155, 155, 20, 25, 155, 155, 155, 155, 155, + 155, 160, 161, 155, 155, 155, 155, 155, 25, 155, + + 162, 163, 155, 155, 155, 160, 150, 161, 150, 155, + 155, 155, 155, 155, 25, 155, 162, 150, 163, 150, + 164, 165, 155, 166, 155, 155, 155, 155, 25, 155, + 164, 150, 165, 155, 166, 150, 167, 168, 155, 150, + 155, 167, 150, 168, 155, 169, 155, 155, 169, 0, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150 } ; static yyconst flex_int16_t yy_nxt[589] = @@ -511,15 +512,15 @@ static yyconst flex_int16_t yy_nxt[589] = 70, 34, 34, 34, 56, 36, 36, 36, 57, 34, 47, 36, 36, 35, 34, 35, 36, 35, 35, 35, 35, 35, 35, 35, 35, 34, 34, 75, 35, 35, - 35, 84, 53, 80, 143, 85, 36, 81, 68, 82, - 34, 34, 34, 34, 36, 149, 149, 84, 34, 143, + 35, 84, 53, 80, 36, 85, 143, 81, 68, 82, + 34, 34, 34, 34, 36, 150, 150, 84, 34, 36, 36, 36, 35, 34, 35, 36, 35, 35, 35, 35, 35, 35, 35, 35, 34, 83, 68, 35, 35, 35, 34, 34, 34, 69, 70, 76, 54, 77, 34, 36, 78, 36, 36, 91, 36, 79, 36, 36, 36, 36, - 36, 35, 58, 36, 34, 36, 39, 36, 136, 36, - 36, 86, 89, 96, 36, 87, 36, 97, 36, 36, + 36, 35, 58, 36, 34, 36, 39, 36, 143, 36, + 136, 86, 89, 96, 36, 87, 36, 97, 36, 36, 111, 101, 88, 59, 60, 36, 90, 61, 98, 100, 102, 103, 62, 34, 34, 34, 63, 64, 73, 73, 73, 34, 104, 128, 73, 116, 34, 114, 73, 73, @@ -528,34 +529,34 @@ static yyconst flex_int16_t yy_nxt[589] = 36, 36, 34, 92, 92, 93, 92, 92, 92, 92, 92, 92, 92, 92, 105, 110, 113, 92, 92, 92, 125, 112, 121, 124, 36, 94, 122, 36, 129, 53, - 36, 36, 95, 36, 36, 36, 140, 36, 36, 132, - 36, 92, 53, 36, 136, 36, 132, 120, 118, 127, - 126, 130, 109, 138, 107, 137, 120, 118, 115, 109, - 107, 72, 134, 139, 141, 138, 35, 140, 36, 35, + 36, 36, 95, 36, 36, 36, 140, 36, 36, 36, + 36, 92, 132, 53, 36, 136, 36, 132, 120, 127, + 126, 130, 118, 138, 109, 137, 107, 120, 118, 115, + 109, 107, 134, 139, 141, 145, 35, 140, 36, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - - 145, 145, 145, 145, 35, 36, 66, 35, 35, 36, - 53, 36, 36, 36, 36, 36, 72, 36, 36, 36, - 36, 36, 36, 66, 36, 36, 149, 29, 29, 149, - 149, 149, 149, 146, 35, 35, 36, 35, 35, 35, - 35, 35, 147, 35, 35, 138, 149, 149, 35, 35, - 35, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 35, 35, 35, 36, 35, 35, 35, 35, - 35, 147, 35, 35, 149, 149, 149, 35, 35, 35, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 35, 29, 29, 30, 30, 33, 33, 34, 34, + 35, 35, 35, 146, 146, 146, 146, 146, 146, 146, + 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, + + 146, 146, 146, 146, 35, 36, 72, 66, 35, 35, + 36, 53, 36, 36, 36, 36, 36, 72, 36, 36, + 36, 36, 36, 36, 66, 36, 36, 150, 29, 29, + 150, 150, 150, 147, 35, 35, 36, 35, 35, 35, + 35, 35, 148, 35, 35, 138, 150, 150, 35, 35, + 35, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 35, 35, 35, 36, 35, 35, 35, 35, + 35, 148, 35, 35, 150, 150, 150, 35, 35, 35, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 35, 29, 29, 30, 30, 33, 33, 34, 34, 35, 35, 53, 53, 67, 67, 71, 71, 106, 106, 108, 108, 117, 117, 119, 119, 131, 131, 133, 133, - 135, 135, 142, 142, 144, 144, 148, 148, 9, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149 + 135, 135, 142, 142, 144, 144, 149, 149, 9, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150 } ; static yyconst flex_int16_t yy_chk[589] = @@ -567,27 +568,27 @@ static yyconst flex_int16_t yy_chk[589] = 5, 6, 26, 2, 11, 11, 14, 5, 6, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 14, 21, 17, 10, 10, 10, 15, 17, 18, 15, 22, - 23, 156, 21, 21, 18, 18, 27, 27, 26, 85, - 27, 147, 22, 23, 23, 85, 10, 19, 19, 19, + 23, 157, 21, 21, 18, 18, 27, 27, 26, 85, + 27, 148, 22, 23, 23, 85, 10, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 32, 144, 20, 37, 37, 54, 54, 32, + 20, 20, 32, 145, 20, 37, 37, 54, 54, 32, 32, 34, 34, 34, 56, 56, 59, 62, 56, 34, 20, 61, 63, 20, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 34, 43, 59, 24, 24, - 24, 73, 74, 61, 142, 74, 138, 62, 67, 63, - 44, 44, 44, 43, 64, 67, 67, 73, 44, 137, + 24, 73, 74, 61, 144, 74, 142, 62, 67, 63, + 44, 44, 44, 43, 64, 67, 67, 73, 44, 138, 60, 79, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 44, 64, 69, 25, 25, 25, 47, 47, 47, 69, 69, 60, 25, 60, 47, 75, 60, 76, 77, 79, 81, 60, 78, 82, 83, 87, - 95, 25, 28, 28, 47, 86, 28, 89, 135, 88, - 133, 75, 77, 81, 90, 76, 98, 82, 100, 114, + 95, 25, 28, 28, 47, 86, 28, 89, 137, 88, + 135, 75, 77, 81, 90, 76, 98, 82, 100, 114, 95, 87, 76, 28, 28, 105, 78, 28, 83, 86, 88, 89, 28, 84, 84, 84, 28, 28, 45, 45, 45, 84, 90, 114, 45, 100, 45, 98, 45, 45, @@ -596,34 +597,34 @@ static yyconst flex_int16_t yy_chk[589] = 103, 110, 45, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 91, 94, 97, 80, 80, 80, 111, 96, 103, 110, 112, 80, 104, 113, 115, 115, - 116, 123, 80, 125, 126, 128, 130, 130, 139, 131, - 134, 80, 129, 127, 124, 122, 121, 119, 117, 113, - 112, 116, 108, 126, 106, 125, 102, 101, 99, 93, - 92, 71, 123, 128, 134, 139, 140, 140, 140, 140, + 116, 123, 80, 125, 126, 128, 130, 130, 139, 133, + 134, 80, 131, 129, 127, 124, 122, 121, 119, 113, + 112, 116, 117, 126, 108, 125, 106, 102, 101, 99, + 93, 92, 123, 128, 134, 139, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 141, 65, 58, 57, 55, - 53, 52, 51, 50, 49, 48, 42, 41, 146, 40, - 39, 38, 35, 30, 16, 13, 9, 8, 7, 0, - 0, 0, 0, 141, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 146, 0, 0, 145, 145, - 145, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 140, 140, 140, 140, 140, 141, 71, 65, 58, 57, + 55, 53, 52, 51, 50, 49, 48, 42, 147, 41, + 40, 39, 38, 35, 30, 16, 13, 9, 8, 7, + 0, 0, 0, 141, 146, 146, 146, 146, 146, 146, + 146, 146, 146, 146, 146, 147, 0, 0, 146, 146, + 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 145, 148, 148, 148, 148, 148, 148, 148, - 148, 148, 148, 148, 0, 0, 0, 148, 148, 148, + 0, 0, 146, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 0, 0, 0, 149, 149, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 148, 150, 150, 151, 151, 152, 152, 153, 153, - 154, 154, 155, 155, 157, 157, 158, 158, 159, 159, - 160, 160, 161, 161, 162, 162, 163, 163, 164, 164, - 165, 165, 166, 166, 167, 167, 168, 168, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149 + 0, 149, 151, 151, 152, 152, 153, 153, 154, 154, + 155, 155, 156, 156, 158, 158, 159, 159, 160, 160, + 161, 161, 162, 162, 163, 163, 164, 164, 165, 165, + 166, 166, 167, 167, 168, 168, 169, 169, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150 } ; #define YY_TRAILING_MASK 0x2000 @@ -690,7 +691,7 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner); } while(0); #define YY_USER_INIT yylineno = 0; yycolumn = 0; -#line 694 "glcpp/glcpp-lex.c" +#line 695 "glcpp/glcpp-lex.c" #define INITIAL 0 #define DONE 1 @@ -961,7 +962,7 @@ YY_DECL /* Single-line comments */ -#line 965 "glcpp/glcpp-lex.c" +#line 966 "glcpp/glcpp-lex.c" yylval = yylval_param; @@ -1024,7 +1025,7 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 150 ) + if ( yy_current_state >= 151 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1128,71 +1129,82 @@ YY_RULE_SETUP return SPACE; } YY_BREAK -/* glcpp doesn't handle #extension, #version, or #pragma directives. - * Simply pass them through to the main compiler's lexer/parser. */ case 8: YY_RULE_SETUP -#line 92 "glcpp/glcpp-lex.l" +#line 90 "glcpp/glcpp-lex.l" { yylval->str = xtalloc_strdup (yyextra, yytext); yylineno++; yycolumn = 0; - return OTHER; + yyextra->space_tokens = 0; + return HASH_VERSION; } YY_BREAK +/* glcpp doesn't handle #extension, #version, or #pragma directives. + * Simply pass them through to the main compiler's lexer/parser. */ case 9: -/* rule 9 can match eol */ YY_RULE_SETUP -#line 99 "glcpp/glcpp-lex.l" +#line 100 "glcpp/glcpp-lex.l" { - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_IFDEF; + yylval->str = xtalloc_strdup (yyextra, yytext); + yylineno++; + yycolumn = 0; + return OTHER; } YY_BREAK case 10: /* rule 10 can match eol */ YY_RULE_SETUP -#line 105 "glcpp/glcpp-lex.l" +#line 107 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; - return HASH_IFNDEF; + return HASH_IFDEF; } YY_BREAK case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 111 "glcpp/glcpp-lex.l" +#line 113 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; - return HASH_IF; + return HASH_IFNDEF; } YY_BREAK case 12: /* rule 12 can match eol */ YY_RULE_SETUP -#line 117 "glcpp/glcpp-lex.l" +#line 119 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; - return HASH_ELIF; + return HASH_IF; } YY_BREAK case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 123 "glcpp/glcpp-lex.l" +#line 125 "glcpp/glcpp-lex.l" { + yyextra->lexing_if = 1; yyextra->space_tokens = 0; - return HASH_ELSE; + return HASH_ELIF; } YY_BREAK case 14: /* rule 14 can match eol */ YY_RULE_SETUP -#line 128 "glcpp/glcpp-lex.l" +#line 131 "glcpp/glcpp-lex.l" +{ + yyextra->space_tokens = 0; + return HASH_ELSE; +} + YY_BREAK +case 15: +/* rule 15 can match eol */ +YY_RULE_SETUP +#line 136 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_ENDIF; @@ -1206,13 +1218,13 @@ YY_RULE_SETUP * * We use the lexing_if flag to avoid skipping any part of an * if conditional expression. */ -case 15: -/* rule 15 can match eol */ +case 16: +/* rule 16 can match eol */ *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 141 "glcpp/glcpp-lex.l" +#line 149 "glcpp/glcpp-lex.l" { /* Since this rule always matches, YY_USER_ACTION gets called for it, * wrongly incrementing yycolumn. We undo that effect here. */ @@ -1225,9 +1237,9 @@ YY_RULE_SETUP } } YY_BREAK -case 16: +case 17: YY_RULE_SETUP -#line 153 "glcpp/glcpp-lex.l" +#line 161 "glcpp/glcpp-lex.l" { char *p; for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */ @@ -1235,168 +1247,168 @@ YY_RULE_SETUP glcpp_error(yylloc, yyextra, "#error%s", p); } YY_BREAK -case 17: +case 18: YY_RULE_SETUP -#line 160 "glcpp/glcpp-lex.l" +#line 168 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_DEFINE_FUNC; } YY_BREAK -case 18: +case 19: YY_RULE_SETUP -#line 165 "glcpp/glcpp-lex.l" +#line 173 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_DEFINE_OBJ; } YY_BREAK -case 19: +case 20: YY_RULE_SETUP -#line 170 "glcpp/glcpp-lex.l" +#line 178 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_UNDEF; } YY_BREAK -case 20: +case 21: YY_RULE_SETUP -#line 175 "glcpp/glcpp-lex.l" +#line 183 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH; } YY_BREAK -case 21: +case 22: YY_RULE_SETUP -#line 180 "glcpp/glcpp-lex.l" +#line 188 "glcpp/glcpp-lex.l" { yylval->str = xtalloc_strdup (yyextra, yytext); return INTEGER_STRING; } YY_BREAK -case 22: +case 23: YY_RULE_SETUP -#line 185 "glcpp/glcpp-lex.l" +#line 193 "glcpp/glcpp-lex.l" { yylval->str = xtalloc_strdup (yyextra, yytext); return INTEGER_STRING; } YY_BREAK -case 23: +case 24: YY_RULE_SETUP -#line 190 "glcpp/glcpp-lex.l" +#line 198 "glcpp/glcpp-lex.l" { yylval->str = xtalloc_strdup (yyextra, yytext); return INTEGER_STRING; } YY_BREAK -case 24: +case 25: YY_RULE_SETUP -#line 195 "glcpp/glcpp-lex.l" +#line 203 "glcpp/glcpp-lex.l" { return LEFT_SHIFT; } YY_BREAK -case 25: +case 26: YY_RULE_SETUP -#line 199 "glcpp/glcpp-lex.l" +#line 207 "glcpp/glcpp-lex.l" { return RIGHT_SHIFT; } YY_BREAK -case 26: +case 27: YY_RULE_SETUP -#line 203 "glcpp/glcpp-lex.l" +#line 211 "glcpp/glcpp-lex.l" { return LESS_OR_EQUAL; } YY_BREAK -case 27: +case 28: YY_RULE_SETUP -#line 207 "glcpp/glcpp-lex.l" +#line 215 "glcpp/glcpp-lex.l" { return GREATER_OR_EQUAL; } YY_BREAK -case 28: +case 29: YY_RULE_SETUP -#line 211 "glcpp/glcpp-lex.l" +#line 219 "glcpp/glcpp-lex.l" { return EQUAL; } YY_BREAK -case 29: +case 30: YY_RULE_SETUP -#line 215 "glcpp/glcpp-lex.l" +#line 223 "glcpp/glcpp-lex.l" { return NOT_EQUAL; } YY_BREAK -case 30: +case 31: YY_RULE_SETUP -#line 219 "glcpp/glcpp-lex.l" +#line 227 "glcpp/glcpp-lex.l" { return AND; } YY_BREAK -case 31: +case 32: YY_RULE_SETUP -#line 223 "glcpp/glcpp-lex.l" +#line 231 "glcpp/glcpp-lex.l" { return OR; } YY_BREAK -case 32: +case 33: YY_RULE_SETUP -#line 227 "glcpp/glcpp-lex.l" +#line 235 "glcpp/glcpp-lex.l" { return PASTE; } YY_BREAK -case 33: +case 34: YY_RULE_SETUP -#line 231 "glcpp/glcpp-lex.l" +#line 239 "glcpp/glcpp-lex.l" { return DEFINED; } YY_BREAK -case 34: +case 35: YY_RULE_SETUP -#line 235 "glcpp/glcpp-lex.l" +#line 243 "glcpp/glcpp-lex.l" { yylval->str = xtalloc_strdup (yyextra, yytext); return IDENTIFIER; } YY_BREAK -case 35: +case 36: YY_RULE_SETUP -#line 240 "glcpp/glcpp-lex.l" +#line 248 "glcpp/glcpp-lex.l" { return yytext[0]; } YY_BREAK -case 36: +case 37: YY_RULE_SETUP -#line 244 "glcpp/glcpp-lex.l" +#line 252 "glcpp/glcpp-lex.l" { yylval->str = xtalloc_strdup (yyextra, yytext); return OTHER; } YY_BREAK -case 37: +case 38: YY_RULE_SETUP -#line 249 "glcpp/glcpp-lex.l" +#line 257 "glcpp/glcpp-lex.l" { if (yyextra->space_tokens) { return SPACE; } } YY_BREAK -case 38: -/* rule 38 can match eol */ +case 39: +/* rule 39 can match eol */ YY_RULE_SETUP -#line 255 "glcpp/glcpp-lex.l" +#line 263 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 0; yylineno++; @@ -1406,7 +1418,7 @@ YY_RULE_SETUP YY_BREAK /* Handle missing newline at EOF. */ case YY_STATE_EOF(INITIAL): -#line 263 "glcpp/glcpp-lex.l" +#line 271 "glcpp/glcpp-lex.l" { BEGIN DONE; /* Don't keep matching this rule forever. */ yyextra->lexing_if = 0; @@ -1417,20 +1429,20 @@ case YY_STATE_EOF(INITIAL): only have this action here so that we can pretend to call some generated functions, (to avoid "defined but not used" warnings. */ -case 39: +case 40: YY_RULE_SETUP -#line 273 "glcpp/glcpp-lex.l" +#line 281 "glcpp/glcpp-lex.l" { unput('.'); yy_top_state(yyextra); } YY_BREAK -case 40: +case 41: YY_RULE_SETUP -#line 278 "glcpp/glcpp-lex.l" +#line 286 "glcpp/glcpp-lex.l" ECHO; YY_BREAK -#line 1434 "glcpp/glcpp-lex.c" +#line 1446 "glcpp/glcpp-lex.c" case YY_STATE_EOF(DONE): case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(UNREACHABLE): @@ -1696,7 +1708,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 150 ) + if ( yy_current_state >= 151 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1720,11 +1732,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 150 ) + if ( yy_current_state >= 151 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 149); + yy_is_jam = (yy_current_state == 150); if ( ! yy_is_jam ) *yyg->yy_state_ptr++ = yy_current_state; @@ -2624,7 +2636,7 @@ void glcpp_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 278 "glcpp/glcpp-lex.l" +#line 286 "glcpp/glcpp-lex.l" diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index a4c891bdc69..17a097e633a 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -87,9 +87,17 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return SPACE; } +{HASH}(version) { + yylval->str = xtalloc_strdup (yyextra, yytext); + yylineno++; + yycolumn = 0; + yyextra->space_tokens = 0; + return HASH_VERSION; +} + /* glcpp doesn't handle #extension, #version, or #pragma directives. * Simply pass them through to the main compiler's lexer/parser. */ -{HASH}(extension|version|pragma)[^\n]+ { +{HASH}(extension|pragma)[^\n]+ { yylval->str = xtalloc_strdup (yyextra, yytext); yylineno++; yycolumn = 0; diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index bfbd97f3d83..f0ad4a08ec7 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -203,10 +203,13 @@ glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser); static void glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); +static void +add_builtin_define(glcpp_parser_t *parser, const char *name, int value); + /* Line 189 of yacc.c */ -#line 210 "glcpp/glcpp-parse.c" +#line 213 "glcpp/glcpp-parse.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -246,24 +249,25 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); HASH_IFDEF = 268, HASH_IFNDEF = 269, HASH_UNDEF = 270, - IDENTIFIER = 271, - IF_EXPANDED = 272, - INTEGER = 273, - INTEGER_STRING = 274, - NEWLINE = 275, - OTHER = 276, - PLACEHOLDER = 277, - SPACE = 278, - PASTE = 279, - OR = 280, - AND = 281, - NOT_EQUAL = 282, - EQUAL = 283, - GREATER_OR_EQUAL = 284, - LESS_OR_EQUAL = 285, - RIGHT_SHIFT = 286, - LEFT_SHIFT = 287, - UNARY = 288 + HASH_VERSION = 271, + IDENTIFIER = 272, + IF_EXPANDED = 273, + INTEGER = 274, + INTEGER_STRING = 275, + NEWLINE = 276, + OTHER = 277, + PLACEHOLDER = 278, + SPACE = 279, + PASTE = 280, + OR = 281, + AND = 282, + NOT_EQUAL = 283, + EQUAL = 284, + GREATER_OR_EQUAL = 285, + LESS_OR_EQUAL = 286, + RIGHT_SHIFT = 287, + LEFT_SHIFT = 288, + UNARY = 289 }; #endif @@ -293,7 +297,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 297 "glcpp/glcpp-parse.c" +#line 301 "glcpp/glcpp-parse.c" #ifdef short # undef short @@ -510,20 +514,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 673 +#define YYLAST 604 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 56 +#define YYNTOKENS 57 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 16 +#define YYNNTS 17 /* YYNRULES -- Number of rules. */ -#define YYNRULES 98 +#define YYNRULES 100 /* YYNRULES -- Number of states. */ -#define YYNSTATES 157 +#define YYNSTATES 161 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 288 +#define YYMAXUTOK 289 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -534,16 +538,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 46, 2, 2, 2, 42, 29, 2, - 44, 45, 40, 38, 48, 39, 53, 41, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 54, - 32, 55, 33, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 47, 2, 2, 2, 43, 30, 2, + 45, 46, 41, 39, 49, 40, 54, 42, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 55, + 33, 56, 34, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 49, 2, 50, 28, 2, 2, 2, 2, 2, + 2, 50, 2, 51, 29, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 51, 27, 52, 47, 2, 2, 2, + 2, 2, 2, 52, 28, 53, 48, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -559,7 +563,7 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 30, 31, 34, 35, 36, 37, 43 + 25, 26, 27, 31, 32, 35, 36, 37, 38, 44 }; #if YYDEBUG @@ -569,63 +573,65 @@ static const yytype_uint16 yyprhs[] = { 0, 0, 3, 4, 7, 9, 11, 13, 16, 20, 24, 29, 36, 44, 48, 52, 57, 62, 66, 69, - 72, 75, 78, 80, 82, 86, 90, 94, 98, 102, - 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, - 146, 150, 154, 157, 160, 163, 166, 170, 172, 176, - 178, 181, 184, 185, 187, 188, 190, 193, 198, 200, - 202, 205, 207, 210, 212, 214, 216, 218, 220, 222, - 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, - 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, - 264, 266, 268, 270, 272, 274, 276, 278, 280 + 72, 75, 79, 82, 84, 86, 88, 92, 96, 100, + 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, + 144, 148, 152, 156, 160, 163, 166, 169, 172, 176, + 178, 182, 184, 187, 190, 191, 193, 194, 196, 199, + 204, 206, 208, 211, 213, 216, 218, 220, 222, 224, + 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, + 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, + 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, + 286 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 57, 0, -1, -1, 57, 58, -1, 60, -1, 63, - -1, 59, -1, 6, 64, -1, 17, 61, 20, -1, - 5, 61, 20, -1, 8, 16, 65, 20, -1, 7, - 16, 44, 45, 65, 20, -1, 7, 16, 44, 62, - 45, 65, 20, -1, 15, 16, 20, -1, 12, 68, - 20, -1, 13, 16, 66, 20, -1, 14, 16, 66, - 20, -1, 9, 68, 20, -1, 9, 20, -1, 10, - 20, -1, 11, 20, -1, 6, 20, -1, 19, -1, - 18, -1, 61, 25, 61, -1, 61, 26, 61, -1, - 61, 27, 61, -1, 61, 28, 61, -1, 61, 29, - 61, -1, 61, 30, 61, -1, 61, 31, 61, -1, - 61, 34, 61, -1, 61, 35, 61, -1, 61, 33, - 61, -1, 61, 32, 61, -1, 61, 36, 61, -1, - 61, 37, 61, -1, 61, 39, 61, -1, 61, 38, - 61, -1, 61, 42, 61, -1, 61, 41, 61, -1, - 61, 40, 61, -1, 46, 61, -1, 47, 61, -1, - 39, 61, -1, 38, 61, -1, 44, 61, 45, -1, - 16, -1, 62, 48, 16, -1, 20, -1, 69, 20, - -1, 69, 20, -1, -1, 69, -1, -1, 69, -1, - 4, 16, -1, 4, 44, 16, 45, -1, 70, -1, - 67, -1, 68, 67, -1, 70, -1, 69, 70, -1, - 16, -1, 19, -1, 71, -1, 21, -1, 23, -1, - 49, -1, 50, -1, 44, -1, 45, -1, 51, -1, - 52, -1, 53, -1, 29, -1, 40, -1, 38, -1, - 39, -1, 47, -1, 46, -1, 41, -1, 42, -1, - 37, -1, 36, -1, 32, -1, 33, -1, 35, -1, - 34, -1, 31, -1, 30, -1, 28, -1, 27, -1, - 26, -1, 25, -1, 54, -1, 48, -1, 55, -1, - 24, -1 + 58, 0, -1, -1, 58, 59, -1, 61, -1, 65, + -1, 60, -1, 6, 66, -1, 18, 63, 21, -1, + 5, 63, 21, -1, 8, 17, 67, 21, -1, 7, + 17, 45, 46, 67, 21, -1, 7, 17, 45, 64, + 46, 67, 21, -1, 15, 17, 21, -1, 12, 70, + 21, -1, 13, 17, 68, 21, -1, 14, 17, 68, + 21, -1, 9, 70, 21, -1, 9, 21, -1, 10, + 21, -1, 11, 21, -1, 16, 62, 21, -1, 6, + 21, -1, 20, -1, 19, -1, 62, -1, 63, 26, + 63, -1, 63, 27, 63, -1, 63, 28, 63, -1, + 63, 29, 63, -1, 63, 30, 63, -1, 63, 31, + 63, -1, 63, 32, 63, -1, 63, 35, 63, -1, + 63, 36, 63, -1, 63, 34, 63, -1, 63, 33, + 63, -1, 63, 37, 63, -1, 63, 38, 63, -1, + 63, 40, 63, -1, 63, 39, 63, -1, 63, 43, + 63, -1, 63, 42, 63, -1, 63, 41, 63, -1, + 47, 63, -1, 48, 63, -1, 40, 63, -1, 39, + 63, -1, 45, 63, 46, -1, 17, -1, 64, 49, + 17, -1, 21, -1, 71, 21, -1, 71, 21, -1, + -1, 71, -1, -1, 71, -1, 4, 17, -1, 4, + 45, 17, 46, -1, 72, -1, 69, -1, 70, 69, + -1, 72, -1, 71, 72, -1, 17, -1, 20, -1, + 73, -1, 22, -1, 24, -1, 50, -1, 51, -1, + 45, -1, 46, -1, 52, -1, 53, -1, 54, -1, + 30, -1, 41, -1, 39, -1, 40, -1, 48, -1, + 47, -1, 42, -1, 43, -1, 38, -1, 37, -1, + 33, -1, 34, -1, 36, -1, 35, -1, 32, -1, + 31, -1, 29, -1, 28, -1, 27, -1, 26, -1, + 55, -1, 49, -1, 56, -1, 25, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 166, 166, 168, 172, 175, 180, 181, 185, 188, - 194, 197, 200, 203, 211, 223, 228, 233, 245, 256, - 259, 262, 266, 275, 278, 281, 284, 287, 290, 293, - 296, 299, 302, 305, 308, 311, 314, 317, 320, 323, - 326, 329, 332, 335, 338, 341, 344, 350, 355, 363, - 364, 368, 374, 375, 378, 380, 387, 391, 395, 400, - 406, 414, 420, 428, 432, 436, 440, 444, 451, 452, - 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, - 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, - 473, 474, 475, 476, 477, 478, 479, 480, 481 + 0, 169, 169, 171, 175, 178, 183, 184, 188, 191, + 197, 200, 203, 206, 214, 226, 231, 236, 248, 259, + 262, 265, 274, 278, 287, 292, 293, 296, 299, 302, + 305, 308, 311, 314, 317, 320, 323, 326, 329, 332, + 335, 338, 341, 344, 347, 350, 353, 356, 359, 365, + 370, 378, 379, 383, 389, 390, 393, 395, 402, 406, + 410, 415, 421, 429, 435, 443, 447, 451, 455, 459, + 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, + 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, + 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, + 496 }; #endif @@ -637,16 +643,16 @@ static const char *const yytname[] = "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED", "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ", "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF", - "HASH_IFNDEF", "HASH_UNDEF", "IDENTIFIER", "IF_EXPANDED", "INTEGER", - "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE", "PASTE", - "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'", "'>'", - "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT", "'+'", - "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'", "','", - "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept", "input", - "line", "expanded_line", "control_line", "expression", "identifier_list", - "text_line", "non_directive", "replacement_list", "junk", - "conditional_token", "conditional_tokens", "pp_tokens", - "preprocessing_token", "operator", 0 + "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED", + "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE", + "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'", + "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT", + "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'", + "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept", + "input", "line", "expanded_line", "control_line", "integer_constant", + "expression", "identifier_list", "text_line", "non_directive", + "replacement_list", "junk", "conditional_token", "conditional_tokens", + "pp_tokens", "preprocessing_token", "operator", 0 }; #endif @@ -657,26 +663,27 @@ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 124, 94, 38, - 282, 283, 60, 62, 284, 285, 286, 287, 43, 45, - 42, 47, 37, 288, 40, 41, 33, 126, 44, 91, - 93, 123, 125, 46, 59, 61 + 275, 276, 277, 278, 279, 280, 281, 282, 124, 94, + 38, 283, 284, 60, 62, 285, 286, 287, 288, 43, + 45, 42, 47, 37, 289, 40, 41, 33, 126, 44, + 91, 93, 123, 125, 46, 59, 61 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 56, 57, 57, 58, 58, 58, 58, 59, 59, - 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 61, 61, 61, 61, 61, 61, 61, 61, + 0, 57, 58, 58, 59, 59, 59, 59, 60, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 62, 62, 63, - 63, 64, 65, 65, 66, 66, 67, 67, 67, 68, - 68, 69, 69, 70, 70, 70, 70, 70, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71 + 61, 61, 61, 62, 62, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, + 64, 65, 65, 66, 67, 67, 68, 68, 69, 69, + 69, 70, 70, 71, 71, 72, 72, 72, 72, 72, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -684,14 +691,15 @@ static const yytype_uint8 yyr2[] = { 0, 2, 0, 2, 1, 1, 1, 2, 3, 3, 4, 6, 7, 3, 3, 4, 4, 3, 2, 2, - 2, 2, 1, 1, 3, 3, 3, 3, 3, 3, + 2, 3, 2, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 2, 2, 2, 2, 3, 1, 3, 1, - 2, 2, 0, 1, 0, 1, 2, 4, 1, 1, - 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 3, 3, 3, 3, 2, 2, 2, 2, 3, 1, + 3, 1, 2, 2, 0, 1, 0, 1, 2, 4, + 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1 + 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -700,58 +708,60 @@ static const yytype_uint8 yyr2[] = static const yytype_uint8 yydefact[] = { 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 63, 0, 64, 49, 66, 67, - 98, 94, 93, 92, 91, 75, 90, 89, 85, 86, - 88, 87, 84, 83, 77, 78, 76, 81, 82, 70, - 71, 80, 79, 96, 68, 69, 72, 73, 74, 95, - 97, 3, 6, 4, 5, 0, 61, 65, 23, 22, - 0, 0, 0, 0, 0, 0, 21, 7, 0, 0, - 52, 0, 18, 59, 0, 58, 19, 20, 0, 54, - 54, 0, 0, 50, 62, 45, 44, 0, 42, 43, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, - 0, 0, 53, 56, 0, 17, 60, 14, 0, 55, - 0, 13, 8, 46, 24, 25, 26, 27, 28, 29, - 30, 34, 33, 31, 32, 35, 36, 38, 37, 41, - 40, 39, 47, 52, 0, 10, 0, 15, 16, 0, - 52, 0, 57, 11, 0, 48, 12 + 0, 0, 0, 0, 0, 65, 0, 66, 51, 68, + 69, 100, 96, 95, 94, 93, 77, 92, 91, 87, + 88, 90, 89, 86, 85, 79, 80, 78, 83, 84, + 72, 73, 82, 81, 98, 70, 71, 74, 75, 76, + 97, 99, 3, 6, 4, 5, 0, 63, 67, 24, + 23, 0, 0, 0, 0, 0, 25, 0, 22, 7, + 0, 0, 54, 0, 18, 61, 0, 60, 19, 20, + 0, 56, 56, 0, 0, 0, 52, 64, 47, 46, + 0, 44, 45, 9, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 53, 0, 0, 55, 58, 0, 17, 62, + 14, 0, 57, 0, 13, 21, 8, 48, 26, 27, + 28, 29, 30, 31, 32, 36, 35, 33, 34, 37, + 38, 40, 39, 43, 42, 41, 49, 54, 0, 10, + 0, 15, 16, 0, 54, 0, 59, 11, 0, 50, + 12 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 51, 52, 53, 65, 144, 54, 67, 111, - 118, 73, 74, 112, 56, 57 + -1, 1, 52, 53, 54, 66, 67, 148, 55, 69, + 114, 121, 75, 76, 115, 57, 58 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -120 +#define YYPACT_NINF -146 static const yytype_int16 yypact[] = { - -120, 108, -120, -17, 356, -9, 9, 160, -15, 6, - 316, 17, 18, 29, -120, -17, -120, -120, -120, -120, - -120, -120, -120, -120, -120, -120, -120, -120, -120, -120, - -120, -120, -120, -120, -120, -120, -120, -120, -120, -120, - -120, -120, -120, -120, -120, -120, -120, -120, -120, -120, - -120, -120, -120, -120, -120, 396, -120, -120, -120, -120, - -17, -17, -17, -17, -17, 512, -120, -120, 436, 2, - 476, -8, -120, -120, 212, -120, -120, -120, 264, 476, - 476, 39, 535, -120, -120, -120, -120, 553, -120, -120, - -120, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17, -17, -120, - -10, 40, 476, -120, 49, -120, -120, -120, 46, 476, - 48, -120, -120, -120, 573, 589, 604, 618, 631, -23, - -23, 1, 1, 1, 1, 16, 16, 22, 22, -120, - -120, -120, -120, 476, -1, -120, 24, -120, -120, 50, - 476, 56, -120, -120, 53, -120, -120 + -146, 111, -146, 429, -10, -9, -4, 151, -15, 27, + 271, 54, 63, 86, 82, -146, 429, -146, -146, -146, + -146, -146, -146, -146, -146, -146, -146, -146, -146, -146, + -146, -146, -146, -146, -146, -146, -146, -146, -146, -146, + -146, -146, -146, -146, -146, -146, -146, -146, -146, -146, + -146, -146, -146, -146, -146, -146, 311, -146, -146, -146, + -146, 429, 429, 429, 429, 429, -146, 452, -146, -146, + 351, 59, 391, 17, -146, -146, 191, -146, -146, -146, + 231, 391, 391, 84, 85, 475, -146, -146, -146, -146, + 424, -146, -146, -146, 429, 429, 429, 429, 429, 429, + 429, 429, 429, 429, 429, 429, 429, 429, 429, 429, + 429, 429, -146, 30, 88, 391, -146, 90, -146, -146, + -146, 89, 391, 91, -146, -146, -146, -146, 492, 508, + 523, 537, 550, 561, 561, 18, 18, 18, 18, 25, + 25, 36, 36, -146, -146, -146, -146, 391, 26, -146, + 67, -146, -146, 93, 391, 113, -146, -146, 148, -146, + -146 }; /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = +static const yytype_int16 yypgoto[] = { - -120, -120, -120, -120, -120, -11, -120, -120, -120, -119, - -6, -46, 65, 19, -7, -120 + -146, -146, -146, -146, -146, 120, -11, -146, -146, -146, + -145, 92, -6, 160, 0, -7, -146 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -761,168 +771,155 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 75, 58, 59, 75, 82, 76, 142, 69, 113, 98, - 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, - 55, 60, 61, 68, 149, 70, 77, 62, 116, 63, - 64, 154, 116, 79, 80, 143, 114, 102, 103, 104, - 105, 106, 107, 108, 150, 81, 110, 151, 84, 85, - 86, 87, 88, 89, 104, 105, 106, 107, 108, 121, - 145, 84, 106, 107, 108, 146, 147, 75, 148, 152, - 153, 75, 155, 156, 120, 78, 0, 0, 0, 0, - 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - 134, 135, 136, 137, 138, 139, 140, 141, 119, 119, - 0, 0, 0, 0, 0, 84, 0, 0, 2, 0, - 0, 0, 84, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 0, 16, 17, 18, - 0, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 0, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 71, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 14, 0, 0, 16, - 72, 18, 0, 19, 20, 21, 22, 23, 24, 25, + 77, 56, 153, 77, 70, 85, 78, 15, 71, 158, + 17, 68, 19, 72, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 0, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 71, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, - 0, 16, 115, 18, 0, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 0, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 71, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 14, 0, 0, 16, 117, 18, 0, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 0, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 14, 0, 0, 16, 0, 18, 0, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 14, 0, 0, 16, 66, 18, 0, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 14, 0, 0, 16, 83, 18, 0, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 14, 0, 0, 16, 109, 18, 0, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 14, 0, 0, 16, 0, 18, 0, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 90, 0, 0, 0, 0, 91, 92, 93, + 36, 37, 38, 39, 116, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 146, 79, 87, + 88, 89, 90, 91, 92, 105, 106, 107, 108, 109, + 110, 111, 117, 87, 107, 108, 109, 110, 111, 77, + 119, 81, 154, 77, 119, 155, 147, 109, 110, 111, + 82, 122, 122, 128, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 59, 60, 83, 113, 124, 125, 150, 87, 149, + 151, 2, 152, 156, 157, 87, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 159, 17, 18, 19, 84, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 73, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 15, 160, + 80, 17, 74, 19, 123, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 73, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, + 0, 17, 118, 19, 0, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 73, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, + 0, 17, 120, 19, 0, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 73, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, + 0, 17, 0, 19, 0, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 0, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, + 0, 17, 86, 19, 0, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 0, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, + 0, 17, 112, 19, 0, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 0, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, + 0, 17, 0, 19, 0, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 0, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 59, 60, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 122, 0, 0, 0, 0, - 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, - 101, 102, 103, 104, 105, 106, 107, 108, 91, 92, - 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, - 103, 104, 105, 106, 107, 108, 0, 0, 123, 92, - 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, - 103, 104, 105, 106, 107, 108, 93, 94, 95, 96, - 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 94, 95, 96, 97, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 95, 96, 97, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108 + 104, 105, 106, 107, 108, 109, 110, 111, 61, 62, + 127, 0, 0, 93, 63, 0, 64, 65, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 126, 0, 0, 0, + 0, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, 111, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 96, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 98, 99, 100, + 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, + 111, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 110, 111 }; static const yytype_int16 yycheck[] = { - 7, 18, 19, 10, 15, 20, 16, 16, 16, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 1, 38, 39, 4, 143, 16, 20, 44, 74, 46, - 47, 150, 78, 16, 16, 45, 44, 36, 37, 38, - 39, 40, 41, 42, 45, 16, 44, 48, 55, 60, - 61, 62, 63, 64, 38, 39, 40, 41, 42, 20, - 20, 68, 40, 41, 42, 16, 20, 74, 20, 45, - 20, 78, 16, 20, 80, 10, -1, -1, -1, -1, - 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, - 101, 102, 103, 104, 105, 106, 107, 108, 79, 80, - -1, -1, -1, -1, -1, 112, -1, -1, 0, -1, - -1, -1, 119, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, -1, 19, 20, 21, - -1, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, -1, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 4, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 16, -1, -1, 19, - 20, 21, -1, 23, 24, 25, 26, 27, 28, 29, + 7, 1, 147, 10, 4, 16, 21, 17, 17, 154, + 20, 21, 22, 17, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, -1, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 4, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 16, -1, - -1, 19, 20, 21, -1, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, -1, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 4, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 16, -1, -1, 19, 20, 21, -1, 23, 24, 25, + 40, 41, 42, 43, 17, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 17, 21, 56, + 61, 62, 63, 64, 65, 37, 38, 39, 40, 41, + 42, 43, 45, 70, 39, 40, 41, 42, 43, 76, + 76, 17, 46, 80, 80, 49, 46, 41, 42, 43, + 17, 81, 82, 94, 95, 96, 97, 98, 99, 100, + 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, + 111, 19, 20, 17, 45, 21, 21, 17, 115, 21, + 21, 0, 21, 46, 21, 122, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 17, 20, 21, 22, 14, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 4, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 17, 21, + 10, 20, 21, 22, 82, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 4, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, + -1, 20, 21, 22, -1, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 4, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, + -1, 20, 21, 22, -1, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 4, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, + -1, 20, -1, 22, -1, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, -1, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, + -1, 20, 21, 22, -1, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, -1, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, + -1, 20, 21, 22, -1, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, -1, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, + -1, 20, -1, 22, -1, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, -1, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 19, 20, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, -1, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 16, -1, -1, 19, -1, 21, -1, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 16, -1, -1, 19, 20, 21, -1, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 16, -1, -1, 19, 20, 21, -1, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 16, -1, -1, 19, 20, 21, -1, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 16, -1, -1, 19, -1, 21, -1, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 20, -1, -1, -1, -1, 25, 26, 27, + 36, 37, 38, 39, 40, 41, 42, 43, 39, 40, + 46, -1, -1, 21, 45, -1, 47, 48, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 20, -1, -1, -1, -1, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, -1, -1, 45, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 29, 30, 31, + 38, 39, 40, 41, 42, 43, 21, -1, -1, -1, + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42 + 42, 43, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 57, 0, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 19, 20, 21, 23, + 0, 58, 0, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 58, 59, 60, 63, 69, 70, 71, 18, 19, - 38, 39, 44, 46, 47, 61, 20, 64, 69, 16, - 16, 4, 20, 67, 68, 70, 20, 20, 68, 16, - 16, 16, 61, 20, 70, 61, 61, 61, 61, 61, - 20, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 20, - 44, 65, 69, 16, 44, 20, 67, 20, 66, 69, - 66, 20, 20, 45, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 16, 45, 62, 20, 16, 20, 20, 65, - 45, 48, 45, 20, 65, 16, 20 + 55, 56, 59, 60, 61, 65, 71, 72, 73, 19, + 20, 39, 40, 45, 47, 48, 62, 63, 21, 66, + 71, 17, 17, 4, 21, 69, 70, 72, 21, 21, + 70, 17, 17, 17, 62, 63, 21, 72, 63, 63, + 63, 63, 63, 21, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 21, 45, 67, 71, 17, 45, 21, 69, + 21, 68, 71, 68, 21, 21, 21, 46, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 17, 46, 64, 21, + 17, 21, 21, 67, 46, 49, 46, 21, 67, 17, + 21 }; #define yyerrok (yyerrstatus = 0) @@ -1776,7 +1773,7 @@ yyreduce: case 4: /* Line 1455 of yacc.c */ -#line 172 "glcpp/glcpp-parse.y" +#line 175 "glcpp/glcpp-parse.y" { glcpp_print(parser->output, "\n"); ;} @@ -1785,7 +1782,7 @@ yyreduce: case 5: /* Line 1455 of yacc.c */ -#line 175 "glcpp/glcpp-parse.y" +#line 178 "glcpp/glcpp-parse.y" { _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); glcpp_print(parser->output, "\n"); @@ -1796,7 +1793,7 @@ yyreduce: case 8: /* Line 1455 of yacc.c */ -#line 185 "glcpp/glcpp-parse.y" +#line 188 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); ;} @@ -1805,7 +1802,7 @@ yyreduce: case 9: /* Line 1455 of yacc.c */ -#line 188 "glcpp/glcpp-parse.y" +#line 191 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); ;} @@ -1814,7 +1811,7 @@ yyreduce: case 10: /* Line 1455 of yacc.c */ -#line 194 "glcpp/glcpp-parse.y" +#line 197 "glcpp/glcpp-parse.y" { _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); ;} @@ -1823,7 +1820,7 @@ yyreduce: case 11: /* Line 1455 of yacc.c */ -#line 197 "glcpp/glcpp-parse.y" +#line 200 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); ;} @@ -1832,7 +1829,7 @@ yyreduce: case 12: /* Line 1455 of yacc.c */ -#line 200 "glcpp/glcpp-parse.y" +#line 203 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); ;} @@ -1841,7 +1838,7 @@ yyreduce: case 13: /* Line 1455 of yacc.c */ -#line 203 "glcpp/glcpp-parse.y" +#line 206 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); if (macro) { @@ -1855,7 +1852,7 @@ yyreduce: case 14: /* Line 1455 of yacc.c */ -#line 211 "glcpp/glcpp-parse.y" +#line 214 "glcpp/glcpp-parse.y" { token_list_t *expanded; token_t *token; @@ -1873,7 +1870,7 @@ yyreduce: case 15: /* Line 1455 of yacc.c */ -#line 223 "glcpp/glcpp-parse.y" +#line 226 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1884,7 +1881,7 @@ yyreduce: case 16: /* Line 1455 of yacc.c */ -#line 228 "glcpp/glcpp-parse.y" +#line 231 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1895,7 +1892,7 @@ yyreduce: case 17: /* Line 1455 of yacc.c */ -#line 233 "glcpp/glcpp-parse.y" +#line 236 "glcpp/glcpp-parse.y" { token_list_t *expanded; token_t *token; @@ -1913,7 +1910,7 @@ yyreduce: case 18: /* Line 1455 of yacc.c */ -#line 245 "glcpp/glcpp-parse.y" +#line 248 "glcpp/glcpp-parse.y" { /* #elif without an expression results in a warning if the * condition doesn't matter (we just handled #if 1 or such) @@ -1930,7 +1927,7 @@ yyreduce: case 19: /* Line 1455 of yacc.c */ -#line 256 "glcpp/glcpp-parse.y" +#line 259 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); ;} @@ -1939,16 +1936,31 @@ yyreduce: case 20: /* Line 1455 of yacc.c */ -#line 259 "glcpp/glcpp-parse.y" +#line 262 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); ;} break; - case 22: + case 21: /* Line 1455 of yacc.c */ -#line 266 "glcpp/glcpp-parse.y" +#line 265 "glcpp/glcpp-parse.y" + { + macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); + if (macro) { + hash_table_remove (parser->defines, "__VERSION__"); + talloc_free (macro); + } + add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival)); + glcpp_printf(parser->output, "#version %" PRIiMAX "\n", (yyvsp[(2) - (3)].ival)); + ;} + break; + + case 23: + +/* Line 1455 of yacc.c */ +#line 278 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); @@ -1960,226 +1972,226 @@ yyreduce: ;} break; - case 23: + case 24: /* Line 1455 of yacc.c */ -#line 275 "glcpp/glcpp-parse.y" +#line 287 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} break; - case 24: + case 26: /* Line 1455 of yacc.c */ -#line 278 "glcpp/glcpp-parse.y" +#line 293 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); ;} break; - case 25: + case 27: /* Line 1455 of yacc.c */ -#line 281 "glcpp/glcpp-parse.y" +#line 296 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); ;} break; - case 26: + case 28: /* Line 1455 of yacc.c */ -#line 284 "glcpp/glcpp-parse.y" +#line 299 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); ;} break; - case 27: + case 29: /* Line 1455 of yacc.c */ -#line 287 "glcpp/glcpp-parse.y" +#line 302 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); ;} break; - case 28: + case 30: /* Line 1455 of yacc.c */ -#line 290 "glcpp/glcpp-parse.y" +#line 305 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); ;} break; - case 29: + case 31: /* Line 1455 of yacc.c */ -#line 293 "glcpp/glcpp-parse.y" +#line 308 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); ;} break; - case 30: + case 32: /* Line 1455 of yacc.c */ -#line 296 "glcpp/glcpp-parse.y" +#line 311 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); ;} break; - case 31: + case 33: /* Line 1455 of yacc.c */ -#line 299 "glcpp/glcpp-parse.y" +#line 314 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); ;} break; - case 32: + case 34: /* Line 1455 of yacc.c */ -#line 302 "glcpp/glcpp-parse.y" +#line 317 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); ;} break; - case 33: + case 35: /* Line 1455 of yacc.c */ -#line 305 "glcpp/glcpp-parse.y" +#line 320 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); ;} break; - case 34: + case 36: /* Line 1455 of yacc.c */ -#line 308 "glcpp/glcpp-parse.y" +#line 323 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); ;} break; - case 35: + case 37: /* Line 1455 of yacc.c */ -#line 311 "glcpp/glcpp-parse.y" +#line 326 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); ;} break; - case 36: + case 38: /* Line 1455 of yacc.c */ -#line 314 "glcpp/glcpp-parse.y" +#line 329 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); ;} break; - case 37: + case 39: /* Line 1455 of yacc.c */ -#line 317 "glcpp/glcpp-parse.y" +#line 332 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); ;} break; - case 38: + case 40: /* Line 1455 of yacc.c */ -#line 320 "glcpp/glcpp-parse.y" +#line 335 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); ;} break; - case 39: + case 41: /* Line 1455 of yacc.c */ -#line 323 "glcpp/glcpp-parse.y" +#line 338 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); ;} break; - case 40: + case 42: /* Line 1455 of yacc.c */ -#line 326 "glcpp/glcpp-parse.y" +#line 341 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); ;} break; - case 41: + case 43: /* Line 1455 of yacc.c */ -#line 329 "glcpp/glcpp-parse.y" +#line 344 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); ;} break; - case 42: + case 44: /* Line 1455 of yacc.c */ -#line 332 "glcpp/glcpp-parse.y" +#line 347 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); ;} break; - case 43: + case 45: /* Line 1455 of yacc.c */ -#line 335 "glcpp/glcpp-parse.y" +#line 350 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); ;} break; - case 44: + case 46: /* Line 1455 of yacc.c */ -#line 338 "glcpp/glcpp-parse.y" +#line 353 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); ;} break; - case 45: + case 47: /* Line 1455 of yacc.c */ -#line 341 "glcpp/glcpp-parse.y" +#line 356 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); ;} break; - case 46: + case 48: /* Line 1455 of yacc.c */ -#line 344 "glcpp/glcpp-parse.y" +#line 359 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); ;} break; - case 47: + case 49: /* Line 1455 of yacc.c */ -#line 350 "glcpp/glcpp-parse.y" +#line 365 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); @@ -2187,10 +2199,10 @@ yyreduce: ;} break; - case 48: + case 50: /* Line 1455 of yacc.c */ -#line 355 "glcpp/glcpp-parse.y" +#line 370 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); @@ -2198,62 +2210,62 @@ yyreduce: ;} break; - case 49: + case 51: /* Line 1455 of yacc.c */ -#line 363 "glcpp/glcpp-parse.y" +#line 378 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; - case 51: + case 53: /* Line 1455 of yacc.c */ -#line 368 "glcpp/glcpp-parse.y" +#line 383 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); ;} break; - case 52: + case 54: /* Line 1455 of yacc.c */ -#line 374 "glcpp/glcpp-parse.y" +#line 389 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; - case 55: + case 57: /* Line 1455 of yacc.c */ -#line 380 "glcpp/glcpp-parse.y" +#line 395 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); ;} break; - case 56: + case 58: /* Line 1455 of yacc.c */ -#line 387 "glcpp/glcpp-parse.y" +#line 402 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); ;} break; - case 57: + case 59: /* Line 1455 of yacc.c */ -#line 391 "glcpp/glcpp-parse.y" +#line 406 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); ;} break; - case 59: + case 61: /* Line 1455 of yacc.c */ -#line 400 "glcpp/glcpp-parse.y" +#line 415 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2262,10 +2274,10 @@ yyreduce: ;} break; - case 60: + case 62: /* Line 1455 of yacc.c */ -#line 406 "glcpp/glcpp-parse.y" +#line 421 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2273,10 +2285,10 @@ yyreduce: ;} break; - case 61: + case 63: /* Line 1455 of yacc.c */ -#line 414 "glcpp/glcpp-parse.y" +#line 429 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2285,10 +2297,10 @@ yyreduce: ;} break; - case 62: + case 64: /* Line 1455 of yacc.c */ -#line 420 "glcpp/glcpp-parse.y" +#line 435 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2296,277 +2308,277 @@ yyreduce: ;} break; - case 63: + case 65: /* Line 1455 of yacc.c */ -#line 428 "glcpp/glcpp-parse.y" +#line 443 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; ;} break; - case 64: + case 66: /* Line 1455 of yacc.c */ -#line 432 "glcpp/glcpp-parse.y" +#line 447 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; ;} break; - case 65: + case 67: /* Line 1455 of yacc.c */ -#line 436 "glcpp/glcpp-parse.y" +#line 451 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); (yyval.token)->location = yylloc; ;} break; - case 66: + case 68: /* Line 1455 of yacc.c */ -#line 440 "glcpp/glcpp-parse.y" +#line 455 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; ;} break; - case 67: + case 69: /* Line 1455 of yacc.c */ -#line 444 "glcpp/glcpp-parse.y" +#line 459 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); (yyval.token)->location = yylloc; ;} break; - case 68: + case 70: /* Line 1455 of yacc.c */ -#line 451 "glcpp/glcpp-parse.y" +#line 466 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; - case 69: + case 71: /* Line 1455 of yacc.c */ -#line 452 "glcpp/glcpp-parse.y" +#line 467 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; - case 70: + case 72: /* Line 1455 of yacc.c */ -#line 453 "glcpp/glcpp-parse.y" +#line 468 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; - case 71: + case 73: /* Line 1455 of yacc.c */ -#line 454 "glcpp/glcpp-parse.y" +#line 469 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; - case 72: + case 74: /* Line 1455 of yacc.c */ -#line 455 "glcpp/glcpp-parse.y" +#line 470 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; - case 73: + case 75: /* Line 1455 of yacc.c */ -#line 456 "glcpp/glcpp-parse.y" +#line 471 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; - case 74: + case 76: /* Line 1455 of yacc.c */ -#line 457 "glcpp/glcpp-parse.y" +#line 472 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; - case 75: + case 77: /* Line 1455 of yacc.c */ -#line 458 "glcpp/glcpp-parse.y" +#line 473 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; - case 76: + case 78: /* Line 1455 of yacc.c */ -#line 459 "glcpp/glcpp-parse.y" +#line 474 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; - case 77: + case 79: /* Line 1455 of yacc.c */ -#line 460 "glcpp/glcpp-parse.y" +#line 475 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; - case 78: + case 80: /* Line 1455 of yacc.c */ -#line 461 "glcpp/glcpp-parse.y" +#line 476 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; - case 79: + case 81: /* Line 1455 of yacc.c */ -#line 462 "glcpp/glcpp-parse.y" +#line 477 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; - case 80: + case 82: /* Line 1455 of yacc.c */ -#line 463 "glcpp/glcpp-parse.y" +#line 478 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; - case 81: + case 83: /* Line 1455 of yacc.c */ -#line 464 "glcpp/glcpp-parse.y" +#line 479 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; - case 82: + case 84: /* Line 1455 of yacc.c */ -#line 465 "glcpp/glcpp-parse.y" +#line 480 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; - case 83: + case 85: /* Line 1455 of yacc.c */ -#line 466 "glcpp/glcpp-parse.y" +#line 481 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; - case 84: + case 86: /* Line 1455 of yacc.c */ -#line 467 "glcpp/glcpp-parse.y" +#line 482 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; - case 85: + case 87: /* Line 1455 of yacc.c */ -#line 468 "glcpp/glcpp-parse.y" +#line 483 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; - case 86: + case 88: /* Line 1455 of yacc.c */ -#line 469 "glcpp/glcpp-parse.y" +#line 484 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; - case 87: + case 89: /* Line 1455 of yacc.c */ -#line 470 "glcpp/glcpp-parse.y" +#line 485 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; - case 88: + case 90: /* Line 1455 of yacc.c */ -#line 471 "glcpp/glcpp-parse.y" +#line 486 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; - case 89: + case 91: /* Line 1455 of yacc.c */ -#line 472 "glcpp/glcpp-parse.y" +#line 487 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; - case 90: + case 92: /* Line 1455 of yacc.c */ -#line 473 "glcpp/glcpp-parse.y" +#line 488 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; - case 91: + case 93: /* Line 1455 of yacc.c */ -#line 474 "glcpp/glcpp-parse.y" +#line 489 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; - case 92: + case 94: /* Line 1455 of yacc.c */ -#line 475 "glcpp/glcpp-parse.y" +#line 490 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; - case 93: + case 95: /* Line 1455 of yacc.c */ -#line 476 "glcpp/glcpp-parse.y" +#line 491 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; - case 94: + case 96: /* Line 1455 of yacc.c */ -#line 477 "glcpp/glcpp-parse.y" +#line 492 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; - case 95: + case 97: /* Line 1455 of yacc.c */ -#line 478 "glcpp/glcpp-parse.y" +#line 493 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; - case 96: + case 98: /* Line 1455 of yacc.c */ -#line 479 "glcpp/glcpp-parse.y" +#line 494 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; - case 97: + case 99: /* Line 1455 of yacc.c */ -#line 480 "glcpp/glcpp-parse.y" +#line 495 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; - case 98: + case 100: /* Line 1455 of yacc.c */ -#line 481 "glcpp/glcpp-parse.y" +#line 496 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; /* Line 1455 of yacc.c */ -#line 2570 "glcpp/glcpp-parse.c" +#line 2582 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2785,7 +2797,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 484 "glcpp/glcpp-parse.y" +#line 499 "glcpp/glcpp-parse.y" string_list_t * @@ -3196,12 +3208,26 @@ yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error) glcpp_error(locp, parser, "%s", error); } +static void add_builtin_define(glcpp_parser_t *parser, + const char *name, int value) +{ + token_t *tok; + token_list_t *list; + + tok = _token_create_ival (parser, INTEGER, value); + + list = _token_list_create(parser); + _token_list_append(list, tok); + _define_object_macro(parser, NULL, name, list); + + talloc_unlink(parser, tok); +} + glcpp_parser_t * glcpp_parser_create (const struct gl_extensions *extensions) { glcpp_parser_t *parser; - token_t *tok; - token_list_t *list; + int language_version; parser = xtalloc (NULL, glcpp_parser_t); @@ -3225,32 +3251,24 @@ glcpp_parser_create (const struct gl_extensions *extensions) parser->error = 0; /* Add pre-defined macros. */ - tok = _token_create_ival (parser, INTEGER, 1); + add_builtin_define(parser, "GL_ARB_draw_buffers", 1); + add_builtin_define(parser, "GL_ARB_texture_rectangle", 1); - list = _token_list_create(parser); - _token_list_append(list, tok); - _define_object_macro(parser, NULL, "GL_ARB_draw_buffers", list); + if (extensions != NULL) { + if (extensions->EXT_texture_array) { + add_builtin_define(parser, "GL_EXT_texture_array", 1); + } - list = _token_list_create(parser); - _token_list_append(list, tok); - _define_object_macro(parser, NULL, "GL_ARB_texture_rectangle", list); - - if ((extensions != NULL) && extensions->EXT_texture_array) { - list = _token_list_create(parser); - _token_list_append(list, tok); - _define_object_macro(parser, NULL, - "GL_EXT_texture_array", list); + if (extensions->ARB_fragment_coord_conventions) + add_builtin_define(parser, "GL_ARB_fragment_coord_conventions", + 1); } - if ((extensions != NULL) && - extensions->ARB_fragment_coord_conventions) { - list = _token_list_create(parser); - _token_list_append(list, tok); - _define_object_macro(parser, NULL, - "GL_ARB_fragment_coord_conventions", list); + language_version = 110; + if (extensions && extensions->ARB_shading_language_120) { + language_version = 120; } - - talloc_unlink(parser, tok); + add_builtin_define(parser, "__VERSION__", language_version); return parser; } diff --git a/src/glsl/glcpp/glcpp-parse.h b/src/glsl/glcpp/glcpp-parse.h index 6365068ad0c..50758930e9c 100644 --- a/src/glsl/glcpp/glcpp-parse.h +++ b/src/glsl/glcpp/glcpp-parse.h @@ -52,24 +52,25 @@ HASH_IFDEF = 268, HASH_IFNDEF = 269, HASH_UNDEF = 270, - IDENTIFIER = 271, - IF_EXPANDED = 272, - INTEGER = 273, - INTEGER_STRING = 274, - NEWLINE = 275, - OTHER = 276, - PLACEHOLDER = 277, - SPACE = 278, - PASTE = 279, - OR = 280, - AND = 281, - NOT_EQUAL = 282, - EQUAL = 283, - GREATER_OR_EQUAL = 284, - LESS_OR_EQUAL = 285, - RIGHT_SHIFT = 286, - LEFT_SHIFT = 287, - UNARY = 288 + HASH_VERSION = 271, + IDENTIFIER = 272, + IF_EXPANDED = 273, + INTEGER = 274, + INTEGER_STRING = 275, + NEWLINE = 276, + OTHER = 277, + PLACEHOLDER = 278, + SPACE = 279, + PASTE = 280, + OR = 281, + AND = 282, + NOT_EQUAL = 283, + EQUAL = 284, + GREATER_OR_EQUAL = 285, + LESS_OR_EQUAL = 286, + RIGHT_SHIFT = 287, + LEFT_SHIFT = 288, + UNARY = 289 }; #endif diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 2009aeaf8a2..e82fc92c8c1 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -132,6 +132,9 @@ glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser); static void glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); +static void +add_builtin_define(glcpp_parser_t *parser, const char *name, int value); + %} %pure-parser @@ -142,9 +145,9 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); %lex-param {glcpp_parser_t *parser} %expect 0 -%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING NEWLINE OTHER PLACEHOLDER SPACE +%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF HASH_VERSION IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING NEWLINE OTHER PLACEHOLDER SPACE %token PASTE -%type expression INTEGER operator SPACE +%type expression INTEGER operator SPACE integer_constant %type IDENTIFIER INTEGER_STRING OTHER %type identifier_list %type preprocessing_token conditional_token @@ -259,10 +262,19 @@ control_line: | HASH_ENDIF NEWLINE { _glcpp_parser_skip_stack_pop (parser, & @1); } +| HASH_VERSION integer_constant NEWLINE { + macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); + if (macro) { + hash_table_remove (parser->defines, "__VERSION__"); + talloc_free (macro); + } + add_builtin_define (parser, "__VERSION__", $2); + glcpp_printf(parser->output, "#version %" PRIiMAX "\n", $2); + } | HASH NEWLINE ; -expression: +integer_constant: INTEGER_STRING { if (strlen ($1) >= 3 && strncmp ($1, "0x", 2) == 0) { $$ = strtoll ($1 + 2, NULL, 16); @@ -275,6 +287,9 @@ expression: | INTEGER { $$ = $1; } + +expression: + integer_constant | expression OR expression { $$ = $1 || $3; } @@ -891,12 +906,26 @@ yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error) glcpp_error(locp, parser, "%s", error); } +static void add_builtin_define(glcpp_parser_t *parser, + const char *name, int value) +{ + token_t *tok; + token_list_t *list; + + tok = _token_create_ival (parser, INTEGER, value); + + list = _token_list_create(parser); + _token_list_append(list, tok); + _define_object_macro(parser, NULL, name, list); + + talloc_unlink(parser, tok); +} + glcpp_parser_t * glcpp_parser_create (const struct gl_extensions *extensions) { glcpp_parser_t *parser; - token_t *tok; - token_list_t *list; + int language_version; parser = xtalloc (NULL, glcpp_parser_t); @@ -920,32 +949,24 @@ glcpp_parser_create (const struct gl_extensions *extensions) parser->error = 0; /* Add pre-defined macros. */ - tok = _token_create_ival (parser, INTEGER, 1); + add_builtin_define(parser, "GL_ARB_draw_buffers", 1); + add_builtin_define(parser, "GL_ARB_texture_rectangle", 1); - list = _token_list_create(parser); - _token_list_append(list, tok); - _define_object_macro(parser, NULL, "GL_ARB_draw_buffers", list); + if (extensions != NULL) { + if (extensions->EXT_texture_array) { + add_builtin_define(parser, "GL_EXT_texture_array", 1); + } - list = _token_list_create(parser); - _token_list_append(list, tok); - _define_object_macro(parser, NULL, "GL_ARB_texture_rectangle", list); - - if ((extensions != NULL) && extensions->EXT_texture_array) { - list = _token_list_create(parser); - _token_list_append(list, tok); - _define_object_macro(parser, NULL, - "GL_EXT_texture_array", list); + if (extensions->ARB_fragment_coord_conventions) + add_builtin_define(parser, "GL_ARB_fragment_coord_conventions", + 1); } - if ((extensions != NULL) && - extensions->ARB_fragment_coord_conventions) { - list = _token_list_create(parser); - _token_list_append(list, tok); - _define_object_macro(parser, NULL, - "GL_ARB_fragment_coord_conventions", list); + language_version = 110; + if (extensions && extensions->ARB_shading_language_120) { + language_version = 120; } - - talloc_unlink(parser, tok); + add_builtin_define(parser, "__VERSION__", language_version); return parser; } -- cgit v1.2.3 From d6942460cec5ffb69dfee7492f7dac59872735de Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 28 Jul 2010 17:36:07 -0700 Subject: glsl2: Actually fix glsl-version-define. --- src/glsl/glcpp/glcpp-parse.c | 3 --- src/glsl/glcpp/glcpp-parse.y | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index f0ad4a08ec7..9dc4bfb3ab1 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -3265,9 +3265,6 @@ glcpp_parser_create (const struct gl_extensions *extensions) } language_version = 110; - if (extensions && extensions->ARB_shading_language_120) { - language_version = 120; - } add_builtin_define(parser, "__VERSION__", language_version); return parser; diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index e82fc92c8c1..855448ff20d 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -963,9 +963,6 @@ glcpp_parser_create (const struct gl_extensions *extensions) } language_version = 110; - if (extensions && extensions->ARB_shading_language_120) { - language_version = 120; - } add_builtin_define(parser, "__VERSION__", language_version); return parser; -- cgit v1.2.3 From 4285247f12d45b0505da06773d7cafcd2c296fb5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 13:42:39 -0700 Subject: glsl2: Remove an inlined unvalued return statement. We already have asserts that it was the last call in the function, so it's safe to remove after it got cloned in. Fixes: glsl-fs-functions-4. --- src/glsl/ir_function_inlining.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index b143190ff6e..9daffeb0171 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -97,6 +97,7 @@ replace_return_with_assignment(ir_instruction *ir, void *data) * have reached here. (see can_inline()). */ assert(!ret->next->is_tail_sentinal()); + ret->remove(); } } } -- cgit v1.2.3 From fa33d0b85403da94e3f4a7e6c868af215c076b4b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 13:50:17 -0700 Subject: glsl2: Fix spelling of "initializer." --- src/glsl/ast_to_hir.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 8e8690c628f..9591d36de8e 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1800,7 +1800,7 @@ ast_declarator_list::hir(exec_list *instructions, * redeclarations) the declaration may not actually be added to the * instruction stream. */ - exec_list intializer_instructions; + exec_list initializer_instructions; if (decl->initializer != NULL) { YYLTYPE initializer_loc = decl->initializer->get_location(); @@ -1830,7 +1830,7 @@ ast_declarator_list::hir(exec_list *instructions, } ir_dereference *const lhs = new(ctx) ir_dereference_variable(var); - ir_rvalue *rhs = decl->initializer->hir(&intializer_instructions, + ir_rvalue *rhs = decl->initializer->hir(&initializer_instructions, state); /* Calculate the constant value if this is a const or uniform @@ -1869,7 +1869,8 @@ ast_declarator_list::hir(exec_list *instructions, /* Never emit code to initialize a uniform. */ if (!this->type->qualifier.uniform) - result = do_assignment(&intializer_instructions, state, lhs, rhs, + result = do_assignment(&initializer_instructions, state, + lhs, rhs, this->get_location()); var->read_only = temp; } @@ -1969,7 +1970,7 @@ ast_declarator_list::hir(exec_list *instructions, } instructions->push_tail(var); - instructions->append_list(&intializer_instructions); + instructions->append_list(&initializer_instructions); /* Add the variable to the symbol table after processing the initializer. * This differs from most C-like languages, but it follows the GLSL -- cgit v1.2.3 From 62c4763b707e2227409f81b09dd5cf6e4410ea6a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 13:52:25 -0700 Subject: glsl2: Fix spelling of "sentinel." --- src/glsl/ast_function.cpp | 6 +++--- src/glsl/ir.cpp | 8 ++++---- src/glsl/ir_clone.cpp | 2 +- src/glsl/ir_function.cpp | 10 +++++----- src/glsl/ir_function_inlining.cpp | 2 +- src/glsl/linker.cpp | 2 +- src/glsl/list.h | 32 ++++++++++++++++---------------- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index bb45e2530db..bbc3bc1a596 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -398,7 +398,7 @@ constant_record_constructor(const glsl_type *constructor_type, for (unsigned i = 0; i < constructor_type->length; i++) { ir_instruction *ir = (ir_instruction *) node; - if (node->is_tail_sentinal()) { + if (node->is_tail_sentinel()) { _mesa_glsl_error(loc, state, "insufficient parameters to constructor for `%s'", constructor_type->name); @@ -531,7 +531,7 @@ single_scalar_parameter(exec_list *parameters) const ir_rvalue *const p = (ir_rvalue *) parameters->head; assert(((ir_rvalue *)p)->as_rvalue() != NULL); - return (p->type->is_scalar() && p->next->is_tail_sentinal()); + return (p->type->is_scalar() && p->next->is_tail_sentinel()); } @@ -763,7 +763,7 @@ emit_inline_matrix_constructor(const glsl_type *type, * identity matrix. If a matrix argument is given to a matrix * constructor, it is an error to have any other arguments." */ - assert(first_param->next->is_tail_sentinal()); + assert(first_param->next->is_tail_sentinel()); ir_rvalue *const src_matrix = first_param; /* If the source matrix is smaller, pre-initialize the relavent parts of diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index bb58d956243..7178c68e6bd 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -295,7 +295,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) */ for (unsigned i = 0; i < type->components(); /* empty */) { assert(value->as_constant() != NULL); - assert(!value->is_tail_sentinal()); + assert(!value->is_tail_sentinel()); for (unsigned j = 0; j < value->type->components(); j++) { switch (type->base_type) { @@ -433,7 +433,7 @@ ir_constant::get_record_field(const char *name) /* If the end of the list is encountered before the element matching the * requested field is found, return NULL. */ - if (node->is_tail_sentinal()) + if (node->is_tail_sentinel()) return NULL; } @@ -459,8 +459,8 @@ ir_constant::has_value(const ir_constant *c) const const exec_node *a_node = this->components.head; const exec_node *b_node = c->components.head; - while (!a_node->is_tail_sentinal()) { - assert(!b_node->is_tail_sentinal()); + while (!a_node->is_tail_sentinel()) { + assert(!b_node->is_tail_sentinel()); const ir_constant *const a_field = (ir_constant *) a_node; const ir_constant *const b_field = (ir_constant *) b_node; diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index f97080d2056..6be3e59a95d 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -330,7 +330,7 @@ ir_constant::clone(struct hash_table *ht) const c->type = this->type; for (exec_node *node = this->components.head - ; !node->is_tail_sentinal() + ; !node->is_tail_sentinel() ; node = node->next) { ir_constant *const orig = (ir_constant *) node; diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp index 28a5c399f15..0a97e014244 100644 --- a/src/glsl/ir_function.cpp +++ b/src/glsl/ir_function.cpp @@ -94,13 +94,13 @@ parameter_lists_match(const exec_list *list_a, const exec_list *list_b) int total_score = 0; for (/* empty */ - ; !node_a->is_tail_sentinal() + ; !node_a->is_tail_sentinel() ; node_a = node_a->next, node_b = node_b->next) { /* If all of the parameters from the other parameter list have been * exhausted, the lists have different length and, by definition, * do not match. */ - if (node_b->is_tail_sentinal()) + if (node_b->is_tail_sentinel()) return -1; @@ -151,7 +151,7 @@ parameter_lists_match(const exec_list *list_a, const exec_list *list_b) * exhausted, the lists have different length and, by definition, do not * match. */ - if (!node_b->is_tail_sentinal()) + if (!node_b->is_tail_sentinel()) return -1; return total_score; @@ -192,7 +192,7 @@ parameter_lists_match_exact(const exec_list *list_a, const exec_list *list_b) const exec_node *node_b = list_b->head; for (/* empty */ - ; !node_a->is_tail_sentinal() && !node_b->is_tail_sentinal() + ; !node_a->is_tail_sentinel() && !node_b->is_tail_sentinel() ; node_a = node_a->next, node_b = node_b->next) { ir_variable *a = (ir_variable *) node_a; ir_variable *b = (ir_variable *) node_b; @@ -207,7 +207,7 @@ parameter_lists_match_exact(const exec_list *list_a, const exec_list *list_b) /* Unless both lists are exhausted, they differ in length and, by * definition, do not match. */ - return (node_a->is_tail_sentinal() == node_b->is_tail_sentinal()); + return (node_a->is_tail_sentinel() == node_b->is_tail_sentinel()); } ir_function_signature * diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 9daffeb0171..77c264f288b 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -96,7 +96,7 @@ replace_return_with_assignment(ir_instruction *ir, void *data) /* un-valued return has to be the last return, or we shouldn't * have reached here. (see can_inline()). */ - assert(!ret->next->is_tail_sentinal()); + assert(!ret->next->is_tail_sentinel()); ret->remove(); } } diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index fa4fb493f22..e9daad28ecf 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -542,7 +542,7 @@ remap_variables(ir_instruction *inst, glsl_symbol_table *symbols, * Move non-declarations from one instruction stream to another * * The intended usage pattern of this function is to pass the pointer to the - * head sentinal of a list (i.e., a pointer to the list cast to an \c exec_node + * head sentinel of a list (i.e., a pointer to the list cast to an \c exec_node * pointer) for \c last and \c false for \c make_copies on the first * call. Successive calls pass the return value of the previous call for * \c last and \c true for \c make_copies. diff --git a/src/glsl/list.h b/src/glsl/list.h index 7348e323c1b..a70b79d571f 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -25,28 +25,28 @@ * \file list.h * \brief Doubly-linked list abstract container type. * - * Each doubly-linked list has a sentinal head and tail node. These nodes - * contain no data. The head sentinal can be identified by its \c prev - * pointer being \c NULL. The tail sentinal can be identified by its + * Each doubly-linked list has a sentinel head and tail node. These nodes + * contain no data. The head sentinel can be identified by its \c prev + * pointer being \c NULL. The tail sentinel can be identified by its * \c next pointer being \c NULL. * - * A list is empty if either the head sentinal's \c next pointer points to the - * tail sentinal or the tail sentinal's \c prev poiner points to the head - * sentinal. + * A list is empty if either the head sentinel's \c next pointer points to the + * tail sentinel or the tail sentinel's \c prev poiner points to the head + * sentinel. * * Instead of tracking two separate \c node structures and a \c list structure - * that points to them, the sentinal nodes are in a single structure. Noting - * that each sentinal node always has one \c NULL pointer, the \c NULL + * that points to them, the sentinel nodes are in a single structure. Noting + * that each sentinel node always has one \c NULL pointer, the \c NULL * pointers occupy the same memory location. In the \c list structure * contains a the following: * * - A \c head pointer that represents the \c next pointer of the - * head sentinal node. + * head sentinel node. * - A \c tail pointer that represents the \c prev pointer of the head - * sentinal node and the \c next pointer of the tail sentinal node. This + * sentinel node and the \c next pointer of the tail sentinel node. This * pointer is \b always \c NULL. * - A \c tail_prev pointer that represents the \c prev pointer of the - * tail sentinal node. + * tail sentinel node. * * Therefore, if \c head->next is \c NULL or \c tail_prev->prev is \c NULL, * the list is empty. @@ -178,17 +178,17 @@ struct exec_node { } /** - * Is this the sentinal at the tail of the list? + * Is this the sentinel at the tail of the list? */ - bool is_tail_sentinal() const + bool is_tail_sentinel() const { return this->next == NULL; } /** - * Is this the sentinal at the head of the list? + * Is this the sentinel at the head of the list? */ - bool is_head_sentinal() const + bool is_head_sentinel() const { return this->prev == NULL; } @@ -320,7 +320,7 @@ struct exec_list { * * - Check to see if the \c head points to the \c tail. * - Check to see if the \c tail_pred points to the \c head. - * - Check to see if the \c head is the sentinal node by test whether its + * - Check to see if the \c head is the sentinel node by test whether its * \c next pointer is \c NULL. * * The first two methods tend to generate better code on modern systems -- cgit v1.2.3 From 9a8eb684d4cd602b6c5e6876cd1eceabc3a8896c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 14:20:39 -0700 Subject: glsl2: When dumping IR for debug, skip all the empty builtin prototypes. --- src/glsl/ir_print_visitor.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index ee489cda7f3..88a0a6f0c88 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -57,8 +57,10 @@ _mesa_print_ir(exec_list *instructions, printf("(\n"); foreach_iter(exec_list_iterator, iter, *instructions) { - ((ir_instruction *)iter.get())->print(); - printf("\n"); + ir_instruction *ir = (ir_instruction *)iter.get(); + ir->print(); + if (ir->ir_type != ir_type_function) + printf("\n"); } printf("\n)"); } @@ -122,6 +124,16 @@ void ir_print_visitor::visit(ir_function_signature *ir) void ir_print_visitor::visit(ir_function *ir) { + bool found_non_builtin_proto = false; + + foreach_iter(exec_list_iterator, iter, *ir) { + ir_function_signature *const sig = (ir_function_signature *) iter.get(); + if (sig->is_defined || !sig->is_built_in) + found_non_builtin_proto = true; + } + if (!found_non_builtin_proto) + return; + printf("(function %s\n", ir->name); foreach_iter(exec_list_iterator, iter, *ir) { ir_function_signature *const sig = (ir_function_signature *) iter.get(); @@ -130,7 +142,7 @@ void ir_print_visitor::visit(ir_function *ir) printf("\n"); } - printf(")\n"); + printf(")\n\n"); } -- cgit v1.2.3 From bf496862be1ba863285aa2c1a2262b2d764c3e53 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 14:36:59 -0700 Subject: glsl2: When dumping IR for debug, indent nested blocks. No more trying to match parens in my head when looking at the body of a short function containing an if statement. --- src/glsl/ir_print_visitor.cpp | 53 ++++++++++++++++++++++++++++++++++++++++--- src/glsl/ir_print_visitor.h | 7 +++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 88a0a6f0c88..7df9d8adcda 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -65,6 +65,13 @@ _mesa_print_ir(exec_list *instructions, printf("\n)"); } + +void ir_print_visitor::indent(void) +{ + for (int i = 0; i < indentation; i++) + printf(" "); +} + static void print_type(const glsl_type *t) { @@ -102,23 +109,43 @@ void ir_print_visitor::visit(ir_variable *ir) void ir_print_visitor::visit(ir_function_signature *ir) { printf("(signature "); + indentation++; + print_type(ir->return_type); - printf("\n (parameters\n"); + printf("\n"); + indent(); + + printf("(parameters\n"); + indentation++; + foreach_iter(exec_list_iterator, iter, ir->parameters) { ir_variable *const inst = (ir_variable *) iter.get(); + indent(); inst->accept(this); printf("\n"); } - printf(" )\n("); + indentation--; + + indent(); + printf(")\n"); + + indent(); + + printf("(\n"); + indentation++; foreach_iter(exec_list_iterator, iter, ir->body) { ir_instruction *const inst = (ir_instruction *) iter.get(); + indent(); inst->accept(this); printf("\n"); } + indentation--; + indent(); printf("))\n"); + indentation--; } @@ -135,13 +162,16 @@ void ir_print_visitor::visit(ir_function *ir) return; printf("(function %s\n", ir->name); + indentation++; foreach_iter(exec_list_iterator, iter, *ir) { ir_function_signature *const sig = (ir_function_signature *) iter.get(); + indent(); sig->accept(this); printf("\n"); } - + indentation--; + indent(); printf(")\n\n"); } @@ -352,21 +382,33 @@ ir_print_visitor::visit(ir_if *ir) ir->condition->accept(this); printf("(\n"); + indentation++; + foreach_iter(exec_list_iterator, iter, ir->then_instructions) { ir_instruction *const inst = (ir_instruction *) iter.get(); + indent(); inst->accept(this); printf("\n"); } + + indentation--; + indent(); printf(")\n"); + indent(); printf("(\n"); + indentation++; + foreach_iter(exec_list_iterator, iter, ir->else_instructions) { ir_instruction *const inst = (ir_instruction *) iter.get(); + indent(); inst->accept(this); printf("\n"); } + indentation--; + indent(); printf("))\n"); } @@ -387,12 +429,17 @@ ir_print_visitor::visit(ir_loop *ir) if (ir->increment != NULL) ir->increment->accept(this); printf(") (\n"); + indentation++; + foreach_iter(exec_list_iterator, iter, ir->body_instructions) { ir_instruction *const inst = (ir_instruction *) iter.get(); + indent(); inst->accept(this); printf("\n"); } + indentation--; + indent(); printf("))\n"); } diff --git a/src/glsl/ir_print_visitor.h b/src/glsl/ir_print_visitor.h index 3db42e24ca3..4feeb8c184d 100644 --- a/src/glsl/ir_print_visitor.h +++ b/src/glsl/ir_print_visitor.h @@ -38,9 +38,8 @@ extern void _mesa_print_ir(exec_list *instructions, class ir_print_visitor : public ir_visitor { public: ir_print_visitor() - : deref_depth(0) { - /* empty */ + indentation = 0; } virtual ~ir_print_visitor() @@ -48,6 +47,8 @@ public: /* empty */ } + void indent(void); + /** * \name Visit methods * @@ -76,7 +77,7 @@ public: /*@}*/ private: - int deref_depth; + int indentation; }; #endif /* IR_PRINT_VISITOR_H */ -- cgit v1.2.3 From ee4b4bab682ca64740b78d99d421e3d676eec447 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 14:54:01 -0700 Subject: ir_constant_variable: Don't mark variable from outside our scope as constant. Fixes (with software, except for alpha): glsl1-function with early return(3) --- src/glsl/ir_constant_variable.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_variable.cpp b/src/glsl/ir_constant_variable.cpp index c5ccd52e5db..749e2cf809f 100644 --- a/src/glsl/ir_constant_variable.cpp +++ b/src/glsl/ir_constant_variable.cpp @@ -42,10 +42,13 @@ struct assignment_entry { int assignment_count; ir_variable *var; ir_constant *constval; + bool our_scope; }; class ir_constant_variable_visitor : public ir_hierarchical_visitor { public: + virtual ir_visitor_status visit_enter(ir_dereference_variable *); + virtual ir_visitor_status visit(ir_variable *); virtual ir_visitor_status visit_enter(ir_assignment *); virtual ir_visitor_status visit_enter(ir_call *); @@ -68,6 +71,22 @@ get_assignment_entry(ir_variable *var, exec_list *list) return entry; } +ir_visitor_status +ir_constant_variable_visitor::visit(ir_variable *ir) +{ + struct assignment_entry *entry = get_assignment_entry(ir, &this->list); + entry->our_scope = true; + return visit_continue; +} + +/* Skip derefs of variables so that we can detect declarations. */ +ir_visitor_status +ir_constant_variable_visitor::visit_enter(ir_dereference_variable *ir) +{ + (void)ir; + return visit_continue_with_parent; +} + ir_visitor_status ir_constant_variable_visitor::visit_enter(ir_assignment *ir) { @@ -146,7 +165,7 @@ do_constant_variable(exec_list *instructions) struct assignment_entry *entry; entry = exec_node_data(struct assignment_entry, v.list.head, link); - if (entry->assignment_count == 1 && entry->constval) { + if (entry->assignment_count == 1 && entry->constval && entry->our_scope) { entry->var->constant_value = entry->constval; progress = true; } -- cgit v1.2.3 From 0e1992255837c88ba3c6631d5282fe944703ba56 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 15:04:45 -0700 Subject: glsl2: Allow use of _mesa_print_ir without a parse state on hand. --- src/glsl/ir_print_visitor.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 7df9d8adcda..73476e7e9b6 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -40,19 +40,21 @@ void _mesa_print_ir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - for (unsigned i = 0; i < state->num_user_structures; i++) { - const glsl_type *const s = state->user_structures[i]; + if (state) { + for (unsigned i = 0; i < state->num_user_structures; i++) { + const glsl_type *const s = state->user_structures[i]; - printf("(structure (%s) (%s@%p) (%u) (\n", - s->name, s->name, s, s->length); + printf("(structure (%s) (%s@%p) (%u) (\n", + s->name, s->name, s, s->length); - for (unsigned j = 0; j < s->length; j++) { - printf("\t(("); - print_type(s->fields.structure[j].type); - printf(")(%s))\n", s->fields.structure[j].name); - } + for (unsigned j = 0; j < s->length; j++) { + printf("\t(("); + print_type(s->fields.structure[j].type); + printf(")(%s))\n", s->fields.structure[j].name); + } - printf(")\n"); + printf(")\n"); + } } printf("(\n"); -- cgit v1.2.3 From 806cb9f9528e3c55c157d7e8bbb751b769b6fcb7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 15:17:23 -0700 Subject: ir_to_mesa: Don't emit a duplicate return at the end of a function. It was harmless, but ugly. --- src/mesa/program/ir_to_mesa.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 3a28c566d4d..b6dfde3783e 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2350,8 +2350,12 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, visit_exec_list(&entry->sig->body, &v); - entry->bgn_inst = v.ir_to_mesa_emit_op0(NULL, OPCODE_RET); - entry->bgn_inst = v.ir_to_mesa_emit_op0(NULL, OPCODE_ENDSUB); + ir_to_mesa_instruction *last; + last = (ir_to_mesa_instruction *)v.instructions.get_tail(); + if (last->op != OPCODE_RET) + v.ir_to_mesa_emit_op0(NULL, OPCODE_RET); + + v.ir_to_mesa_emit_op0(NULL, OPCODE_ENDSUB); progress = GL_TRUE; } } -- cgit v1.2.3 From 92a3768cef122c699b0121ab168def6eaa0faa7a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 12:15:04 -0700 Subject: glsl2: Refactor a bit of ir_if_return for the next changes. --- src/glsl/ir_if_return.cpp | 56 ++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/src/glsl/ir_if_return.cpp b/src/glsl/ir_if_return.cpp index bfb52e7e684..8b8ff85d820 100644 --- a/src/glsl/ir_if_return.cpp +++ b/src/glsl/ir_if_return.cpp @@ -54,11 +54,39 @@ do_if_return(exec_list *instructions) { ir_if_return_visitor v; - visit_list_elements(&v, instructions); + do { + v.progress = false; + visit_list_elements(&v, instructions); + } while (v.progress); return v.progress; } +/** + * Removes any instructions after a (unconditional) return, since they will + * never be executed. + */ +static void +truncate_after_instruction(ir_instruction *ir) +{ + while (!ir->get_next()->is_tail_sentinel()) + ((ir_instruction *)ir->get_next())->remove(); +} + +/** + * Returns an ir_instruction of the first ir_return in the exec_list, or NULL. + */ +static ir_return * +find_return_in_block(exec_list *instructions) +{ + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + if (ir->ir_type == ir_type_return) + return (ir_return *)ir; + } + + return NULL; +} ir_visitor_status ir_if_return_visitor::visit_enter(ir_if *ir) @@ -66,32 +94,16 @@ ir_if_return_visitor::visit_enter(ir_if *ir) ir_return *then_return = NULL; ir_return *else_return = NULL; - /* Try to find a return statement on both sides. */ - foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { - ir_instruction *then_ir = (ir_instruction *)then_iter.get(); - then_return = then_ir->as_return(); - if (then_return) - break; - } - if (!then_return) - return visit_continue; - - foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { - ir_instruction *else_ir = (ir_instruction *)else_iter.get(); - else_return = else_ir->as_return(); - if (else_return) - break; - } - if (!else_return) + then_return = find_return_in_block(&ir->then_instructions); + else_return = find_return_in_block(&ir->else_instructions); + if (!then_return || !else_return) return visit_continue; /* Trim off any trailing instructions after the return statements * on both sides. */ - while (then_return->get_next()->get_next()) - ((ir_instruction *)then_return->get_next())->remove(); - while (else_return->get_next()->get_next()) - ((ir_instruction *)else_return->get_next())->remove(); + truncate_after_instruction(then_return); + truncate_after_instruction(else_return); this->progress = true; -- cgit v1.2.3 From 18964618a14996fff7ab5a5db75c85cd64865ef4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 12:36:06 -0700 Subject: glsl2: Make ir_if_return handle if () { return } else { not return } This makes many remaining functions inlinable. Fixes for i965: glsl1-function with early return (1) glsl1-function with early return (2) --- src/glsl/ir_if_return.cpp | 103 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 77 insertions(+), 26 deletions(-) diff --git a/src/glsl/ir_if_return.cpp b/src/glsl/ir_if_return.cpp index 8b8ff85d820..4d59e707869 100644 --- a/src/glsl/ir_if_return.cpp +++ b/src/glsl/ir_if_return.cpp @@ -24,15 +24,11 @@ /** * \file ir_if_return.cpp * - * If a function includes an if statement that returns from both - * branches, then make the branches write the return val to a temp and - * return the temp after the if statement. + * This pass tries to normalize functions to always return from one place. * - * This allows inlinining in the common case of short functions that - * return one of two values based on a condition. This helps on - * hardware with no branching support, and may even be a useful - * transform on hardware supporting control flow by masked returns - * with normal returns. + * This helps on hardware with no branching support, and may even be a + * useful transform on hardware supporting control flow by turning + * masked returns into normal returns. */ #include "ir.h" @@ -46,6 +42,11 @@ public: ir_visitor_status visit_enter(ir_if *); + void move_outer_block_inside(ir_instruction *ir, + exec_list *inner_block); + void move_returns_after_block(ir_instruction *ir, + ir_return *then_return, + ir_return *else_return); bool progress; }; @@ -69,6 +70,9 @@ do_if_return(exec_list *instructions) static void truncate_after_instruction(ir_instruction *ir) { + if (!ir) + return; + while (!ir->get_next()->is_tail_sentinel()) ((ir_instruction *)ir->get_next())->remove(); } @@ -88,24 +92,11 @@ find_return_in_block(exec_list *instructions) return NULL; } -ir_visitor_status -ir_if_return_visitor::visit_enter(ir_if *ir) +void +ir_if_return_visitor::move_returns_after_block(ir_instruction *ir, + ir_return *then_return, + ir_return *else_return) { - ir_return *then_return = NULL; - ir_return *else_return = NULL; - - then_return = find_return_in_block(&ir->then_instructions); - else_return = find_return_in_block(&ir->else_instructions); - if (!then_return || !else_return) - return visit_continue; - - /* Trim off any trailing instructions after the return statements - * on both sides. - */ - truncate_after_instruction(then_return); - truncate_after_instruction(else_return); - - this->progress = true; if (!then_return->value) { then_return->remove(); @@ -129,6 +120,66 @@ ir_if_return_visitor::visit_enter(ir_if *ir) ir_dereference_variable *deref = new(ir) ir_dereference_variable(new_var); ir->insert_after(new(ir) ir_return(deref)); } + this->progress = true; +} + +void +ir_if_return_visitor::move_outer_block_inside(ir_instruction *ir, + exec_list *inner_block) +{ + if (!ir->get_next()->is_tail_sentinel()) + this->progress = true; + + while (!ir->get_next()->is_tail_sentinel()) { + ir_instruction *move_ir = (ir_instruction *)ir->get_next(); + + move_ir->remove(); + inner_block->push_tail(move_ir); + } +} + +ir_visitor_status +ir_if_return_visitor::visit_enter(ir_if *ir) +{ + ir_return *then_return; + ir_return *else_return; + + then_return = find_return_in_block(&ir->then_instructions); + else_return = find_return_in_block(&ir->else_instructions); + if (!then_return && !else_return) + return visit_continue; + + /* Trim off any trailing instructions after the return statements + * on both sides. + */ + truncate_after_instruction(then_return); + truncate_after_instruction(else_return); + + /* If both sides return, then we can move the returns to a single + * one outside the if statement. + */ + if (then_return && else_return) { + move_returns_after_block(ir, then_return, else_return); + return visit_continue; + } - return visit_continue; + /* If only one side returns, then the block of code after the "if" + * is only executed by the other side, so those instructions don't + * need to be anywhere but that other side. + * + * This will usually pull a return statement up into the other + * side, so we'll trigger the above case on the next pass. + */ + if (then_return) { + move_outer_block_inside(ir, &ir->else_instructions); + } else { + assert(else_return); + move_outer_block_inside(ir, &ir->then_instructions); + } + + /* If we move the instructions following ir inside the block, it + * will confuse the exec_list iteration in the parent that visited + * us. So stop the visit at this point. + */ + return visit_stop; } -- cgit v1.2.3 From a62ef12ef242ecd48887df2aa2052d2ecb0979f7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 13:29:17 -0700 Subject: glsl2: Make sure functions end with a return before doing ir_if_return. This catches a few remaining functions that weren't getting inlined, generally operating on global or out variables and using an early return to skip work when possible. Fixes for i965: glsl1-function with early return (3) --- src/glsl/ir_if_return.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_if_return.cpp b/src/glsl/ir_if_return.cpp index 4d59e707869..293f7aa628d 100644 --- a/src/glsl/ir_if_return.cpp +++ b/src/glsl/ir_if_return.cpp @@ -24,13 +24,16 @@ /** * \file ir_if_return.cpp * - * This pass tries to normalize functions to always return from one place. + * This pass tries to normalize functions to always return from one + * place by moving around blocks of code in if statements. * * This helps on hardware with no branching support, and may even be a * useful transform on hardware supporting control flow by turning * masked returns into normal returns. */ +#include +#include "glsl_types.h" #include "ir.h" class ir_if_return_visitor : public ir_hierarchical_visitor { @@ -40,6 +43,7 @@ public: this->progress = false; } + ir_visitor_status visit_enter(ir_function_signature *); ir_visitor_status visit_enter(ir_if *); void move_outer_block_inside(ir_instruction *ir, @@ -138,6 +142,62 @@ ir_if_return_visitor::move_outer_block_inside(ir_instruction *ir, } } +/* Normalize a function to always have a return statement at the end. + * + * This avoids the ir_if handler needing to know whether it is at the + * top level of the function to know if there's an implicit return at + * the end of the outer block. + */ +ir_visitor_status +ir_if_return_visitor::visit_enter(ir_function_signature *ir) +{ + ir_return *ret; + + if (!ir->is_defined) + return visit_continue_with_parent; + if (strcmp(ir->function_name(), "main") == 0) + return visit_continue_with_parent; + + ret = find_return_in_block(&ir->body); + + if (ret) { + truncate_after_instruction(ret); + } else { + if (ir->return_type->is_void()) { + ir->body.push_tail(new(ir) ir_return(NULL)); + } else { + /* Probably, if we've got a function with a return value + * hitting this point, it's something like: + * + * float reduce_below_half(float val) + * { + * while () { + * if (val >= 0.5) + * val /= 2.0; + * else + * return val; + * } + * } + * + * So we gain a junk return statement of an undefined value + * at the end that never gets executed. However, a backend + * using this pass is probably desperate to get rid of + * function calls, so go ahead and do it for their sake in + * case it fixes apps. + */ + ir_variable *undef = new(ir) ir_variable(ir->return_type, + "if_return_undef", + ir_var_temporary); + ir->body.push_tail(undef); + + ir_dereference_variable *deref = new(ir) ir_dereference_variable(undef); + ir->body.push_tail(new(ir) ir_return(deref)); + } + } + + return visit_continue; +} + ir_visitor_status ir_if_return_visitor::visit_enter(ir_if *ir) { -- cgit v1.2.3 From 0cf545ec696ab450c3f5ee65d7a0c2a5d9dca409 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 29 Jul 2010 15:49:14 -0700 Subject: glsl2: Do ir_if_return on the way out, not the way in. The problem with doing it on the way in is that for a function with multiple early returns, we'll move an outer block in, then restart the pass, then move the two inside returns out, then never move outer blocks in again because the remaining early returns are inside an else block and they don't know that there's a return just after their block. By going inside-out, we get the early returns stacked up so that they all move out with a series of move_returns_after_block(). Fixes (on i965): glsl-fs-raytrace-bug27060 glsl-vs-raytrace-bug26691 --- src/glsl/ir_if_return.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/glsl/ir_if_return.cpp b/src/glsl/ir_if_return.cpp index 293f7aa628d..5ab8759958f 100644 --- a/src/glsl/ir_if_return.cpp +++ b/src/glsl/ir_if_return.cpp @@ -44,10 +44,10 @@ public: } ir_visitor_status visit_enter(ir_function_signature *); - ir_visitor_status visit_enter(ir_if *); + ir_visitor_status visit_leave(ir_if *); - void move_outer_block_inside(ir_instruction *ir, - exec_list *inner_block); + ir_visitor_status move_outer_block_inside(ir_instruction *ir, + exec_list *inner_block); void move_returns_after_block(ir_instruction *ir, ir_return *then_return, ir_return *else_return); @@ -127,18 +127,25 @@ ir_if_return_visitor::move_returns_after_block(ir_instruction *ir, this->progress = true; } -void +ir_visitor_status ir_if_return_visitor::move_outer_block_inside(ir_instruction *ir, exec_list *inner_block) { - if (!ir->get_next()->is_tail_sentinel()) - this->progress = true; + if (!ir->get_next()->is_tail_sentinel()) { + while (!ir->get_next()->is_tail_sentinel()) { + ir_instruction *move_ir = (ir_instruction *)ir->get_next(); - while (!ir->get_next()->is_tail_sentinel()) { - ir_instruction *move_ir = (ir_instruction *)ir->get_next(); + move_ir->remove(); + inner_block->push_tail(move_ir); + } - move_ir->remove(); - inner_block->push_tail(move_ir); + /* If we move the instructions following ir inside the block, it + * will confuse the exec_list iteration in the parent that visited + * us. So stop the visit at this point. + */ + return visit_stop; + } else { + return visit_continue; } } @@ -199,7 +206,7 @@ ir_if_return_visitor::visit_enter(ir_function_signature *ir) } ir_visitor_status -ir_if_return_visitor::visit_enter(ir_if *ir) +ir_if_return_visitor::visit_leave(ir_if *ir) { ir_return *then_return; ir_return *else_return; @@ -231,15 +238,9 @@ ir_if_return_visitor::visit_enter(ir_if *ir) * side, so we'll trigger the above case on the next pass. */ if (then_return) { - move_outer_block_inside(ir, &ir->else_instructions); + return move_outer_block_inside(ir, &ir->else_instructions); } else { assert(else_return); - move_outer_block_inside(ir, &ir->then_instructions); + return move_outer_block_inside(ir, &ir->then_instructions); } - - /* If we move the instructions following ir inside the block, it - * will confuse the exec_list iteration in the parent that visited - * us. So stop the visit at this point. - */ - return visit_stop; } -- cgit v1.2.3 From 805cbf39224580fdb85b09a21be7cbc658f0ecf6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 30 Jul 2010 13:24:50 -0700 Subject: glcpp: Don't look for backslashes before the beginning of the string. Fixes a valgrind error. --- src/glsl/glcpp/pp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index 1ce829a2c97..7aa1a968de7 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -93,12 +93,16 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader) const char *newline; while ((newline = strchr(search_start, '\n')) != NULL) { const char *backslash = NULL; + + /* # of characters preceding the newline. */ + int n = newline - shader; + /* Find the preceding '\', if it exists */ - if (newline[-1] == '\\') { + if (n >= 1 && newline[-1] == '\\') backslash = newline - 1; - } else if (newline[-1] == '\r' && newline[-2] == '\\') { + else if (n >= 2 && newline[-1] == '\r' && newline[-2] == '\\') backslash = newline - 2; - } + /* Double backslashes don't count (the backslash is escaped) */ if (backslash != NULL && backslash[-1] == '\\') { backslash = NULL; -- cgit v1.2.3 From 939a1807fe5a70db25725335ba0acccce8b01db3 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 30 Jul 2010 13:30:11 -0700 Subject: glsl2: Initialize ir_function_signature::is_built_in. Fixes a valgrind error. --- src/glsl/ir.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 7178c68e6bd..2b5f441ddd8 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -837,6 +837,7 @@ ir_function_signature::ir_function_signature(const glsl_type *return_type) : return_type(return_type), is_defined(false), _function(NULL) { this->ir_type = ir_type_function_signature; + this->is_built_in = false; } -- cgit v1.2.3 From 5e5583ee06cff53db48151c13b21916a166ea2ed Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 30 Jul 2010 11:24:23 -0700 Subject: glsl2: Update the callee pointer of calls to newly-linked-in functions. Otherwise, ir_function_inlining will see the body of the function from the unlinked version of the shader, which won't have had the lowering passes done on it or linking's variable remapping. --- src/glsl/link_functions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp index a9ed49a3492..327be73afe6 100644 --- a/src/glsl/link_functions.cpp +++ b/src/glsl/link_functions.cpp @@ -164,6 +164,8 @@ public: */ linked_sig->accept(this); + ir->set_callee(linked_sig); + return visit_continue; } -- cgit v1.2.3 From 40f57c2becbb2cee7cfb6d6ed49dc1db57987e9a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 30 Jul 2010 14:44:09 -0700 Subject: ir_to_mesa: Add the function name as a comment to BGNSUB and ENDSUB. --- src/mesa/program/ir_to_mesa.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index b6dfde3783e..e62395a3b90 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2355,7 +2355,10 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, if (last->op != OPCODE_RET) v.ir_to_mesa_emit_op0(NULL, OPCODE_RET); - v.ir_to_mesa_emit_op0(NULL, OPCODE_ENDSUB); + ir_to_mesa_instruction *end; + end = v.ir_to_mesa_emit_op0(NULL, OPCODE_ENDSUB); + end->function = entry; + progress = GL_TRUE; } } @@ -2401,12 +2404,23 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, shader_program->LinkStatus = false; } - if (mesa_inst->Opcode == OPCODE_BGNSUB) + switch (mesa_inst->Opcode) { + case OPCODE_BGNSUB: inst->function->inst = i; - else if (mesa_inst->Opcode == OPCODE_CAL) + mesa_inst->Comment = strdup(inst->function->sig->function_name()); + break; + case OPCODE_ENDSUB: + mesa_inst->Comment = strdup(inst->function->sig->function_name()); + break; + case OPCODE_CAL: mesa_inst->BranchTarget = inst->function->sig_id; /* rewritten later */ - else if (mesa_inst->Opcode == OPCODE_ARL) + break; + case OPCODE_ARL: prog->NumAddressRegs = 1; + break; + default: + break; + } mesa_inst++; i++; -- cgit v1.2.3 From ec9675ec533cc0c0c7b1c738280e9b9adf2591fb Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 29 Jul 2010 16:39:36 -0700 Subject: ast: Initialize location data in constructor of all ast_node objects. This prevents using uninitialized data in _msea_glsl_error in some cases, (including at least 6 piglit tests). Thanks to valgrind for pointing out the problem! --- src/glsl/glsl_parser_extras.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 20a5021b146..15fa61d9505 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -280,7 +280,9 @@ ast_node::print(void) const ast_node::ast_node(void) { - /* empty */ + this->location.source = 0; + this->location.line = 0; + this->location.column = 0; } -- cgit v1.2.3 From 3fa1b85196b7d57c6c139e62000ac519b1b2320c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 30 Jul 2010 10:20:34 -0700 Subject: glsl2: Fix the implementation of atan(y, x). So many problems here. One is that we can't do the quadrant handling for all the channels at the same time, so we call the float(y, x) version multiple times. I'd also left out the x == 0 handling. Also, the quadrant handling was broken for y == 0, so there was a funny discontinuity on the +x side if you plugged in obvious values to test. I generated the atan(float y, float x) code from a short segment of GLSL and pasted it in by hand. It would be nice to automate that somehow. Fixes: glsl-fs-atan-1 glsl-fs-atan-2 --- src/glsl/builtin_function.cpp | 166 +++++++++++++++++++++--------------------- src/glsl/builtins/110/atan | 166 +++++++++++++++++++++--------------------- 2 files changed, 166 insertions(+), 166 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 3343cf5638b..eade72ad3a5 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -299,56 +299,66 @@ static const char *builtins_110_atan = { " (var_ref y_over_x))\n" " (constant float (1.0))))))))))\n" "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float y)\n" - " (declare (in) float x))\n" - " ((declare () float r)\n" - " (if (expression bool >\n" - " (expression float abs (var_ref x))\n" - " (constant float (.0001)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r) (call atan ((expression float /\n" - " (var_ref y)\n" - " (var_ref x)))))\n" - " (if (expression bool <\n" - " (var_ref x)\n" - " (constant float (0.0)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r)\n" - " (expression float +\n" - " (var_ref r)\n" - " (expression float *\n" - " (expression float sign (var_ref y))\n" - " (constant float (3.1415926))))))\n" - " ()))\n" - " ())\n" - " (return (var_ref r))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y)\n" + " (declare (in ) float x)\n" + " )\n" + " (\n" + " (declare () float r)\n" + " (declare ( ) float abs_retval)\n" + " (assign (constant bool (1)) (var_ref abs_retval) (call abs ((var_ref x) ))\n" + ") \n" + " (if (expression bool > (var_ref abs_retval) (constant float (0.000100)) ) (\n" + " (declare ( ) float atan_retval)\n" + " (assign (constant bool (1)) (var_ref atan_retval) (call atan ((expression float / (var_ref y) (var_ref x) ) ))\n" + ") \n" + " (assign (constant bool (1)) (var_ref r) (var_ref atan_retval) ) \n" + " (if (expression bool < (var_ref x) (constant float (0.000000)) ) (\n" + " (if (expression bool >= (var_ref y) (constant float (0.000000)) ) (\n" + " (declare ( ) float assignment_tmp)\n" + " (assign (constant bool (1)) (var_ref assignment_tmp) (expression float + (var_ref r) (constant float (3.141593)) ) ) \n" + " (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) \n" + " )\n" + " (\n" + " (declare ( ) float assignment_tmp)\n" + " (assign (constant bool (1)) (var_ref assignment_tmp) (expression float - (var_ref r) (constant float (3.141593)) ) ) \n" + " (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) \n" + " ))\n" + "\n" + " )\n" + " (\n" + " ))\n" + "\n" + " )\n" + " (\n" + " (if (expression bool >= (var_ref y) (constant float (0.000000)) ) (\n" + " (assign (constant bool (1)) (var_ref r) (constant float (1.570796)) ) \n" + " )\n" + " (\n" + " (assign (constant bool (1)) (var_ref r) (constant float (-1.570796)) ) \n" + " ))\n" + "\n" + " ))\n" + "\n" + " (return (var_ref r) )\n" + " ))\n" + "\n" + "\n" "\n" " (signature vec2\n" " (parameters\n" " (declare (in) vec2 y)\n" " (declare (in) vec2 x))\n" " ((declare () vec2 r)\n" - " (if (expression bool >\n" - " (expression vec2 abs (var_ref x))\n" - " (constant float (.0001)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r) (call atan ((expression vec2 /\n" - " (var_ref y)\n" - " (var_ref x)))))\n" - " (if (expression bool <\n" - " (var_ref x)\n" - " (constant float (0.0)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r)\n" - " (expression vec2 +\n" - " (var_ref r)\n" - " (expression vec2 *\n" - " (expression float sign (var_ref y))\n" - " (constant float (3.1415926))))))\n" - " ()))\n" - " ())\n" + " (assign (constant bool (1))\n" + " (swiz x (var_ref r))\n" + " (call atan ((swiz x (var_ref y))\n" + " (swiz x (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz y (var_ref r))\n" + " (call atan ((swiz y (var_ref y))\n" + " (swiz y (var_ref x)))))\n" " (return (var_ref r))))\n" "\n" " (signature vec3\n" @@ -356,25 +366,18 @@ static const char *builtins_110_atan = { " (declare (in) vec3 y)\n" " (declare (in) vec3 x))\n" " ((declare () vec3 r)\n" - " (if (expression bool >\n" - " (expression vec3 abs (var_ref x))\n" - " (constant float (.0001)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r) (call atan ((expression vec3 /\n" - " (var_ref y)\n" - " (var_ref x)))))\n" - " (if (expression bool <\n" - " (var_ref x)\n" - " (constant float (0.0)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r)\n" - " (expression vec3 +\n" - " (var_ref r)\n" - " (expression vec3 *\n" - " (expression float sign (var_ref y))\n" - " (constant float (3.1415926))))))\n" - " ()))\n" - " ())\n" + " (assign (constant bool (1))\n" + " (swiz x (var_ref r))\n" + " (call atan ((swiz x (var_ref y))\n" + " (swiz x (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz y (var_ref r))\n" + " (call atan ((swiz y (var_ref y))\n" + " (swiz y (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz z (var_ref r))\n" + " (call atan ((swiz z (var_ref y))\n" + " (swiz z (var_ref x)))))\n" " (return (var_ref r))))\n" "\n" " (signature vec4\n" @@ -382,26 +385,23 @@ static const char *builtins_110_atan = { " (declare (in) vec4 y)\n" " (declare (in) vec4 x))\n" " ((declare () vec4 r)\n" - " (if (expression bool >\n" - " (expression vec4 abs (var_ref x))\n" - " (constant float (.0001)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r) (call atan ((expression vec4 /\n" - " (var_ref y)\n" - " (var_ref x)))))\n" - " (if (expression bool <\n" - " (var_ref x)\n" - " (constant float (0.0)))\n" - " ((assign (constant bool (1))\n" - " (var_ref r)\n" - " (expression vec4 +\n" - " (var_ref r)\n" - " (expression vec4 *\n" - " (expression float sign (var_ref y))\n" - " (constant float (3.1415926))))))\n" - " ()))\n" - " ())\n" - " (return (var_ref r))))\n" + " (assign (constant bool (1))\n" + " (swiz x (var_ref r))\n" + " (call atan ((swiz x (var_ref y))\n" + " (swiz x (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz y (var_ref r))\n" + " (call atan ((swiz y (var_ref y))\n" + " (swiz y (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz z (var_ref r))\n" + " (call atan ((swiz z (var_ref y))\n" + " (swiz z (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz w (var_ref r))\n" + " (call atan ((swiz w (var_ref y))\n" + " (swiz w (var_ref x)))))\n" + " (return (var_ref r)))))\n" "\n" "))\n" }; diff --git a/src/glsl/builtins/110/atan b/src/glsl/builtins/110/atan index bcf75718e45..84048293870 100644 --- a/src/glsl/builtins/110/atan +++ b/src/glsl/builtins/110/atan @@ -47,56 +47,66 @@ (var_ref y_over_x)) (constant float (1.0)))))))))) - (signature float - (parameters - (declare (in) float y) - (declare (in) float x)) - ((declare () float r) - (if (expression bool > - (expression float abs (var_ref x)) - (constant float (.0001))) - ((assign (constant bool (1)) - (var_ref r) (call atan ((expression float / - (var_ref y) - (var_ref x))))) - (if (expression bool < - (var_ref x) - (constant float (0.0))) - ((assign (constant bool (1)) - (var_ref r) - (expression float + - (var_ref r) - (expression float * - (expression float sign (var_ref y)) - (constant float (3.1415926)))))) - ())) - ()) - (return (var_ref r)))) + (signature float + (parameters + (declare (in ) float y) + (declare (in ) float x) + ) + ( + (declare () float r) + (declare ( ) float abs_retval) + (assign (constant bool (1)) (var_ref abs_retval) (call abs ((var_ref x) )) +) + (if (expression bool > (var_ref abs_retval) (constant float (0.000100)) ) ( + (declare ( ) float atan_retval) + (assign (constant bool (1)) (var_ref atan_retval) (call atan ((expression float / (var_ref y) (var_ref x) ) )) +) + (assign (constant bool (1)) (var_ref r) (var_ref atan_retval) ) + (if (expression bool < (var_ref x) (constant float (0.000000)) ) ( + (if (expression bool >= (var_ref y) (constant float (0.000000)) ) ( + (declare ( ) float assignment_tmp) + (assign (constant bool (1)) (var_ref assignment_tmp) (expression float + (var_ref r) (constant float (3.141593)) ) ) + (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) + ) + ( + (declare ( ) float assignment_tmp) + (assign (constant bool (1)) (var_ref assignment_tmp) (expression float - (var_ref r) (constant float (3.141593)) ) ) + (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) + )) + + ) + ( + )) + + ) + ( + (if (expression bool >= (var_ref y) (constant float (0.000000)) ) ( + (assign (constant bool (1)) (var_ref r) (constant float (1.570796)) ) + ) + ( + (assign (constant bool (1)) (var_ref r) (constant float (-1.570796)) ) + )) + + )) + + (return (var_ref r) ) + )) + + (signature vec2 (parameters (declare (in) vec2 y) (declare (in) vec2 x)) ((declare () vec2 r) - (if (expression bool > - (expression vec2 abs (var_ref x)) - (constant float (.0001))) - ((assign (constant bool (1)) - (var_ref r) (call atan ((expression vec2 / - (var_ref y) - (var_ref x))))) - (if (expression bool < - (var_ref x) - (constant float (0.0))) - ((assign (constant bool (1)) - (var_ref r) - (expression vec2 + - (var_ref r) - (expression vec2 * - (expression float sign (var_ref y)) - (constant float (3.1415926)))))) - ())) - ()) + (assign (constant bool (1)) + (swiz x (var_ref r)) + (call atan ((swiz x (var_ref y)) + (swiz x (var_ref x))))) + (assign (constant bool (1)) + (swiz y (var_ref r)) + (call atan ((swiz y (var_ref y)) + (swiz y (var_ref x))))) (return (var_ref r)))) (signature vec3 @@ -104,25 +114,18 @@ (declare (in) vec3 y) (declare (in) vec3 x)) ((declare () vec3 r) - (if (expression bool > - (expression vec3 abs (var_ref x)) - (constant float (.0001))) - ((assign (constant bool (1)) - (var_ref r) (call atan ((expression vec3 / - (var_ref y) - (var_ref x))))) - (if (expression bool < - (var_ref x) - (constant float (0.0))) - ((assign (constant bool (1)) - (var_ref r) - (expression vec3 + - (var_ref r) - (expression vec3 * - (expression float sign (var_ref y)) - (constant float (3.1415926)))))) - ())) - ()) + (assign (constant bool (1)) + (swiz x (var_ref r)) + (call atan ((swiz x (var_ref y)) + (swiz x (var_ref x))))) + (assign (constant bool (1)) + (swiz y (var_ref r)) + (call atan ((swiz y (var_ref y)) + (swiz y (var_ref x))))) + (assign (constant bool (1)) + (swiz z (var_ref r)) + (call atan ((swiz z (var_ref y)) + (swiz z (var_ref x))))) (return (var_ref r)))) (signature vec4 @@ -130,25 +133,22 @@ (declare (in) vec4 y) (declare (in) vec4 x)) ((declare () vec4 r) - (if (expression bool > - (expression vec4 abs (var_ref x)) - (constant float (.0001))) - ((assign (constant bool (1)) - (var_ref r) (call atan ((expression vec4 / - (var_ref y) - (var_ref x))))) - (if (expression bool < - (var_ref x) - (constant float (0.0))) - ((assign (constant bool (1)) - (var_ref r) - (expression vec4 + - (var_ref r) - (expression vec4 * - (expression float sign (var_ref y)) - (constant float (3.1415926)))))) - ())) - ()) - (return (var_ref r)))) + (assign (constant bool (1)) + (swiz x (var_ref r)) + (call atan ((swiz x (var_ref y)) + (swiz x (var_ref x))))) + (assign (constant bool (1)) + (swiz y (var_ref r)) + (call atan ((swiz y (var_ref y)) + (swiz y (var_ref x))))) + (assign (constant bool (1)) + (swiz z (var_ref r)) + (call atan ((swiz z (var_ref y)) + (swiz z (var_ref x))))) + (assign (constant bool (1)) + (swiz w (var_ref r)) + (call atan ((swiz w (var_ref y)) + (swiz w (var_ref x))))) + (return (var_ref r))))) )) -- cgit v1.2.3 From 1c325af4d6b907e0a47ab7f868a2a78f054f153f Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Thu, 29 Jul 2010 15:35:22 +0300 Subject: glsl2: Fix stack smash when ternary selection is used. --- src/glsl/ast_to_hir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 9591d36de8e..3522f55aacd 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -658,7 +658,7 @@ ast_expression::hir(exec_list *instructions, -1, /* ast_sequence doesn't convert to ir_expression. */ }; ir_rvalue *result = NULL; - ir_rvalue *op[2]; + ir_rvalue *op[3]; const struct glsl_type *type = glsl_type::error_type; bool error_emitted = false; YYLTYPE loc; -- cgit v1.2.3 From d72edc4dddb6dd7908ef0d3f2cec353b028bf6c5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 30 Jul 2010 16:05:27 -0700 Subject: glsl2: Factor out the variable refcounting part of ir_dead_code.cpp. --- src/glsl/Makefile | 1 + src/glsl/ir_dead_code.cpp | 114 +------------------------------------- src/glsl/ir_variable_refcount.cpp | 100 +++++++++++++++++++++++++++++++++ src/glsl/ir_variable_refcount.h | 87 +++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+), 112 deletions(-) create mode 100644 src/glsl/ir_variable_refcount.cpp create mode 100644 src/glsl/ir_variable_refcount.h diff --git a/src/glsl/Makefile b/src/glsl/Makefile index cbdd0f9a7a3..aa1922f3bec 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -58,6 +58,7 @@ CXX_SOURCES = \ ir_swizzle_swizzle.cpp \ ir_validate.cpp \ ir_variable.cpp \ + ir_variable_refcount.cpp \ ir_vec_index_to_cond_assign.cpp \ ir_vec_index_to_swizzle.cpp \ linker.cpp \ diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp index eab459b920f..2b971b7aaac 100644 --- a/src/glsl/ir_dead_code.cpp +++ b/src/glsl/ir_dead_code.cpp @@ -29,118 +29,9 @@ #include "ir.h" #include "ir_visitor.h" -#include "ir_expression_flattening.h" +#include "ir_variable_refcount.h" #include "glsl_types.h" -class variable_entry : public exec_node -{ -public: - variable_entry(ir_variable *var) - { - this->var = var; - assign = NULL; - referenced_count = 0; - assigned_count = 0; - declaration = false; - } - - ir_variable *var; /* The key: the variable's pointer. */ - ir_assignment *assign; /* An assignment to the variable, if any */ - - /** Number of times the variable is referenced, including assignments. */ - unsigned referenced_count; - - /** Number of times the variable is assignmened. */ - unsigned assigned_count; - - bool declaration; /* If the variable had a decl in the instruction stream */ -}; - -class ir_dead_code_visitor : public ir_hierarchical_visitor { -public: - virtual ir_visitor_status visit(ir_variable *); - virtual ir_visitor_status visit(ir_dereference_variable *); - - virtual ir_visitor_status visit_enter(ir_function_signature *); - virtual ir_visitor_status visit_leave(ir_assignment *); - - variable_entry *get_variable_entry(ir_variable *var); - - bool (*predicate)(ir_instruction *ir); - - /* List of variable_entry */ - exec_list variable_list; - - void *mem_ctx; -}; - - -variable_entry * -ir_dead_code_visitor::get_variable_entry(ir_variable *var) -{ - assert(var); - foreach_iter(exec_list_iterator, iter, this->variable_list) { - variable_entry *entry = (variable_entry *)iter.get(); - if (entry->var == var) - return entry; - } - - variable_entry *entry = new(mem_ctx) variable_entry(var); - this->variable_list.push_tail(entry); - return entry; -} - - -ir_visitor_status -ir_dead_code_visitor::visit(ir_variable *ir) -{ - variable_entry *entry = this->get_variable_entry(ir); - if (entry) - entry->declaration = true; - - return visit_continue; -} - - -ir_visitor_status -ir_dead_code_visitor::visit(ir_dereference_variable *ir) -{ - ir_variable *const var = ir->variable_referenced(); - variable_entry *entry = this->get_variable_entry(var); - - if (entry) - entry->referenced_count++; - - return visit_continue; -} - - -ir_visitor_status -ir_dead_code_visitor::visit_enter(ir_function_signature *ir) -{ - /* We don't want to descend into the function parameters and - * dead-code eliminate them, so just accept the body here. - */ - visit_list_elements(this, &ir->body); - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_dead_code_visitor::visit_leave(ir_assignment *ir) -{ - variable_entry *entry; - entry = this->get_variable_entry(ir->lhs->variable_referenced()); - if (entry) { - entry->assigned_count++; - if (entry->assign == NULL) - entry->assign = ir; - } - - return visit_continue; -} - - /** * Do a dead code pass over instructions and everything that instructions * references. @@ -151,10 +42,9 @@ ir_dead_code_visitor::visit_leave(ir_assignment *ir) bool do_dead_code(exec_list *instructions) { - ir_dead_code_visitor v; + ir_variable_refcount_visitor v; bool progress = false; - v.mem_ctx = talloc_new(NULL); v.run(instructions); foreach_iter(exec_list_iterator, iter, v.variable_list) { diff --git a/src/glsl/ir_variable_refcount.cpp b/src/glsl/ir_variable_refcount.cpp new file mode 100644 index 00000000000..20c2f6602bf --- /dev/null +++ b/src/glsl/ir_variable_refcount.cpp @@ -0,0 +1,100 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_variable_refcount.cpp + * + * Provides a visitor which produces a list of variables referenced, + * how many times they were referenced and assigned, and whether they + * were defined in the scope. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_variable_refcount.h" +#include "glsl_types.h" + +variable_entry * +ir_variable_refcount_visitor::get_variable_entry(ir_variable *var) +{ + assert(var); + foreach_iter(exec_list_iterator, iter, this->variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + if (entry->var == var) + return entry; + } + + variable_entry *entry = new(mem_ctx) variable_entry(var); + this->variable_list.push_tail(entry); + return entry; +} + + +ir_visitor_status +ir_variable_refcount_visitor::visit(ir_variable *ir) +{ + variable_entry *entry = this->get_variable_entry(ir); + if (entry) + entry->declaration = true; + + return visit_continue; +} + + +ir_visitor_status +ir_variable_refcount_visitor::visit(ir_dereference_variable *ir) +{ + ir_variable *const var = ir->variable_referenced(); + variable_entry *entry = this->get_variable_entry(var); + + if (entry) + entry->referenced_count++; + + return visit_continue; +} + + +ir_visitor_status +ir_variable_refcount_visitor::visit_enter(ir_function_signature *ir) +{ + /* We don't want to descend into the function parameters and + * dead-code eliminate them, so just accept the body here. + */ + visit_list_elements(this, &ir->body); + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_variable_refcount_visitor::visit_leave(ir_assignment *ir) +{ + variable_entry *entry; + entry = this->get_variable_entry(ir->lhs->variable_referenced()); + if (entry) { + entry->assigned_count++; + if (entry->assign == NULL) + entry->assign = ir; + } + + return visit_continue; +} diff --git a/src/glsl/ir_variable_refcount.h b/src/glsl/ir_variable_refcount.h new file mode 100644 index 00000000000..d69cab563e2 --- /dev/null +++ b/src/glsl/ir_variable_refcount.h @@ -0,0 +1,87 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_variable_refcount.h + * + * Provides a visitor which produces a list of variables referenced, + * how many times they were referenced and assigned, and whether they + * were defined in the scope. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "glsl_types.h" + +class variable_entry : public exec_node +{ +public: + variable_entry(ir_variable *var) + { + this->var = var; + assign = NULL; + referenced_count = 0; + assigned_count = 0; + declaration = false; + } + + ir_variable *var; /* The key: the variable's pointer. */ + ir_assignment *assign; /* An assignment to the variable, if any */ + + /** Number of times the variable is referenced, including assignments. */ + unsigned referenced_count; + + /** Number of times the variable is assigned. */ + unsigned assigned_count; + + bool declaration; /* If the variable had a decl in the instruction stream */ +}; + +class ir_variable_refcount_visitor : public ir_hierarchical_visitor { +public: + ir_variable_refcount_visitor(void) + { + this->mem_ctx = talloc_new(NULL); + this->variable_list.make_empty(); + } + + ~ir_variable_refcount_visitor(void) + { + this->mem_ctx = talloc_new(NULL); + } + + virtual ir_visitor_status visit(ir_variable *); + virtual ir_visitor_status visit(ir_dereference_variable *); + + virtual ir_visitor_status visit_enter(ir_function_signature *); + virtual ir_visitor_status visit_leave(ir_assignment *); + + variable_entry *get_variable_entry(ir_variable *var); + + bool (*predicate)(ir_instruction *ir); + + /* List of variable_entry */ + exec_list variable_list; + + void *mem_ctx; +}; -- cgit v1.2.3 From 784695442c415cf0be882434a25671ecfb635d34 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 30 Jul 2010 17:04:49 -0700 Subject: glsl2: Add new tree grafting optimization pass. --- src/glsl/Makefile | 1 + src/glsl/ir_optimization.h | 1 + src/glsl/ir_tree_grafting.cpp | 356 ++++++++++++++++++++++++++++++++++++++++ src/glsl/linker.cpp | 1 + src/glsl/main.cpp | 1 + src/mesa/program/ir_to_mesa.cpp | 1 + 6 files changed, 361 insertions(+) create mode 100644 src/glsl/ir_tree_grafting.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index aa1922f3bec..0254fec756b 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -56,6 +56,7 @@ CXX_SOURCES = \ ir_print_visitor.cpp \ ir_reader.cpp \ ir_swizzle_swizzle.cpp \ + ir_tree_grafting.cpp \ ir_validate.cpp \ ir_variable.cpp \ ir_variable_refcount.cpp \ diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 5dbb025d357..55ec3271936 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -44,5 +44,6 @@ bool do_if_to_cond_assign(exec_list *instructions); bool do_mat_op_to_vec(exec_list *instructions); bool do_mod_to_fract(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); +bool do_tree_grafting(exec_list *instructions); bool do_vec_index_to_cond_assign(exec_list *instructions); bool do_vec_index_to_swizzle(exec_list *instructions); diff --git a/src/glsl/ir_tree_grafting.cpp b/src/glsl/ir_tree_grafting.cpp new file mode 100644 index 00000000000..6f62de758b2 --- /dev/null +++ b/src/glsl/ir_tree_grafting.cpp @@ -0,0 +1,356 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_tree_grafting.cpp + * + * Takes assignments to variables that are dereferenced only once and + * pastes the RHS expression into where the variable is dereferenced. + * + * In the process of various operations like function inlining and + * tertiary op handling, we'll end up with our expression trees having + * been chopped up into a series of assignments of short expressions + * to temps. Other passes like ir_algebraic.cpp would prefer to see + * the deepest expression trees they can to try to optimize them. + * + * This is a lot like copy propagaton. In comparison, copy + * propagation only acts on plain copies, not arbitrary expressions on + * the RHS. Generally, we wouldn't want to go pasting some + * complicated expression everywhere it got used, though, so we don't + * handle expressions in that pass. + * + * The hard part is making sure we don't move an expression across + * some other assignments that would change the value of the + * expression. So we split this into two passes: First, find the + * variables in our scope which are written to once and read once, and + * then go through basic blocks seeing if we find an opportunity to + * move those expressions safely. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_variable_refcount.h" +#include "ir_basic_block.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +static bool debug = false; + +class ir_tree_grafting_visitor : public ir_hierarchical_visitor { +public: + ir_tree_grafting_visitor(ir_assignment *graft_assign, + ir_variable *graft_var) + { + this->progress = false; + this->graft_assign = graft_assign; + this->graft_var = graft_var; + } + + virtual ir_visitor_status visit_leave(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_expression *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_if *); + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_swizzle *); + virtual ir_visitor_status visit_enter(class ir_texture *); + + bool do_graft(ir_rvalue **rvalue); + + bool progress; + ir_variable *graft_var; + ir_assignment *graft_assign; +}; + +struct find_deref_info { + ir_variable *var; + bool found; +}; + +void +dereferences_variable_callback(ir_instruction *ir, void *data) +{ + struct find_deref_info *info = (struct find_deref_info *)data; + + if (ir == info->var) + info->found = true; +} + +static bool +dereferences_variable(ir_instruction *ir, ir_variable *var) +{ + struct find_deref_info info; + + info.var = var; + info.found = false; + + visit_tree(ir, dereferences_variable_callback, &info); + + return info.found; +} + +bool +ir_tree_grafting_visitor::do_graft(ir_rvalue **rvalue) +{ + if (!*rvalue) + return false; + + ir_dereference_variable *deref = (*rvalue)->as_dereference_variable(); + + if (!deref || deref->var != this->graft_var) + return false; + + if (debug) { + printf("GRAFTING:\n"); + this->graft_assign->rhs->print(); + printf("\n"); + printf("TO:\n"); + (*rvalue)->print(); + printf("\n"); + } + + this->graft_assign->remove(); + *rvalue = this->graft_assign->rhs; + + this->progress = true; + return true; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_loop *ir) +{ + (void)ir; + /* Do not traverse into the body of the loop since that is a + * different basic block. + */ + return visit_stop; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_leave(ir_assignment *ir) +{ + if (do_graft(&ir->rhs) || + do_graft(&ir->condition)) + return visit_stop; + + /* If this assignment updates a variable used in the assignment + * we're trying to graft, then we're done. + */ + if (dereferences_variable(this->graft_assign->rhs, + ir->lhs->variable_referenced())) { + if (debug) { + printf("graft killed by: "); + ir->print(); + printf("\n"); + } + return visit_stop; + } + + return visit_continue; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_function *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_function_signature *ir) +{ + (void)ir; + return visit_continue_with_parent; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_call *ir) +{ + /* Reminder: iterating ir_call iterates its parameters. */ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *ir = (ir_rvalue *)iter.get(); + ir_rvalue *new_ir = ir; + + if (do_graft(&new_ir)) { + ir->replace_with(new_ir); + return visit_stop; + } + } + + return visit_continue; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_expression *ir) +{ + for (unsigned int i = 0; i < ir->get_num_operands(); i++) { + if (do_graft(&ir->operands[i])) + return visit_stop; + } + + return visit_continue; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_if *ir) +{ + if (do_graft(&ir->condition)) + return visit_stop; + + /* Do not traverse into the body of the if-statement since that is a + * different basic block. + */ + return visit_continue_with_parent; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_swizzle *ir) +{ + if (do_graft(&ir->val)) + return visit_stop; + + return visit_continue; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_texture *ir) +{ + if (do_graft(&ir->coordinate) || + do_graft(&ir->projector) || + do_graft(&ir->shadow_comparitor)) + return visit_stop; + + switch (ir->op) { + case ir_tex: + break; + case ir_txb: + if (do_graft(&ir->lod_info.bias)) + return visit_stop; + break; + case ir_txf: + case ir_txl: + if (do_graft(&ir->lod_info.lod)) + return visit_stop; + break; + case ir_txd: + if (do_graft(&ir->lod_info.grad.dPdx) || + do_graft(&ir->lod_info.grad.dPdy)) + return visit_stop; + break; + } + + return visit_continue; +} + +struct tree_grafting_info { + ir_variable_refcount_visitor *refs; + bool progress; +}; + +static bool +try_tree_grafting(ir_assignment *start, + ir_variable *lhs_var, + ir_instruction *bb_last) +{ + ir_tree_grafting_visitor v(start, lhs_var); + + if (debug) { + printf("trying to graft: "); + lhs_var->print(); + printf("\n"); + } + + for (ir_instruction *ir = (ir_instruction *)start->next; + ir != bb_last->next; + ir = (ir_instruction *)ir->next) { + + if (debug) { + printf("- "); + ir->print(); + printf("\n"); + } + + ir_visitor_status s = ir->accept(&v); + if (s == visit_stop) + return v.progress; + } + + return false; +} + +static void +tree_grafting_basic_block(ir_instruction *bb_first, + ir_instruction *bb_last, + void *data) +{ + struct tree_grafting_info *info = (struct tree_grafting_info *)data; + ir_instruction *ir, *next; + + for (ir = bb_first, next = (ir_instruction *)ir->next; + ir != bb_last->next; + ir = next, next = (ir_instruction *)ir->next) { + ir_assignment *assign = ir->as_assignment(); + + if (!assign) + continue; + + ir_variable *lhs_var = assign->lhs->whole_variable_referenced(); + if (!lhs_var) + continue; + + struct variable_entry *entry = info->refs->get_variable_entry(lhs_var); + + if (!entry->declaration || + entry->assigned_count != 1 || + entry->referenced_count != 2) + continue; + + assert(assign == entry->assign); + + /* Found a possibly graftable assignment. Now, walk through the + * rest of the BB seeing if the deref is here, and if nothing interfered with + * pasting its expression's values in between. + */ + info->progress |= try_tree_grafting(assign, lhs_var, bb_last); + } +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_tree_grafting(exec_list *instructions) +{ + ir_variable_refcount_visitor refs; + struct tree_grafting_info info; + + info.progress = false; + info.refs = &refs; + + visit_list_elements(info.refs, instructions); + + call_for_basic_blocks(instructions, tree_grafting_basic_block, &info); + + return info.progress; +} diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e9daad28ecf..9b47e4788fc 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1286,6 +1286,7 @@ link_shaders(struct gl_shader_program *prog) progress = do_copy_propagation(ir) || progress; progress = do_dead_code_local(ir) || progress; progress = do_dead_code(ir) || progress; + progress = do_tree_grafting(ir) || progress; progress = do_constant_variable_unlinked(ir) || progress; progress = do_constant_folding(ir) || progress; progress = do_if_return(ir) || progress; diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 08b133f124e..d557dcc4933 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -163,6 +163,7 @@ compile_shader(struct gl_shader *shader) progress = do_copy_propagation(shader->ir) || progress; progress = do_dead_code_local(shader->ir) || progress; progress = do_dead_code_unlinked(shader->ir) || progress; + progress = do_tree_grafting(shader->ir) || progress; progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; progress = do_algebraic(shader->ir) || progress; diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index e62395a3b90..9274723eb73 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2485,6 +2485,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) progress = do_copy_propagation(shader->ir) || progress; progress = do_dead_code_local(shader->ir) || progress; progress = do_dead_code_unlinked(shader->ir) || progress; + progress = do_tree_grafting(shader->ir) || progress; progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; progress = do_algebraic(shader->ir) || progress; -- cgit v1.2.3 From f6b03f323500c71fc20c0d64c618d9aa73ced5b4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 31 Jul 2010 15:47:35 -0700 Subject: glsl2: Do algebraic optimizations after linking as well. Linking brings in inlining of builtins, so we weren't catching the (rcp(/sqrt(x)) -> rsq(x)) without it. --- src/glsl/linker.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 9b47e4788fc..9d53197fdda 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1289,6 +1289,7 @@ link_shaders(struct gl_shader_program *prog) progress = do_tree_grafting(ir) || progress; progress = do_constant_variable_unlinked(ir) || progress; progress = do_constant_folding(ir) || progress; + progress = do_algebraic(ir) || progress; progress = do_if_return(ir) || progress; #if 0 if (ctx->Shader.EmitNoIfs) -- cgit v1.2.3 From 93b10bd353e98670b627873e1da130c789646a4e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 1 Aug 2010 11:40:07 -0700 Subject: glcpp: Add a testcase for the failure in compiling xonotic's shader. gcc and mesa master agree that this is OK. --- src/glsl/glcpp/tests/073-if-in-ifdef.c | 4 ++++ src/glsl/glcpp/tests/073-if-in-ifdef.c.expected | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 src/glsl/glcpp/tests/073-if-in-ifdef.c create mode 100644 src/glsl/glcpp/tests/073-if-in-ifdef.c.expected diff --git a/src/glsl/glcpp/tests/073-if-in-ifdef.c b/src/glsl/glcpp/tests/073-if-in-ifdef.c new file mode 100644 index 00000000000..b9155b521e0 --- /dev/null +++ b/src/glsl/glcpp/tests/073-if-in-ifdef.c @@ -0,0 +1,4 @@ +#if UNDEF +#if UNDEF > 1 +#endif +#endif diff --git a/src/glsl/glcpp/tests/073-if-in-ifdef.c.expected b/src/glsl/glcpp/tests/073-if-in-ifdef.c.expected new file mode 100644 index 00000000000..3f2ff2d6cc8 --- /dev/null +++ b/src/glsl/glcpp/tests/073-if-in-ifdef.c.expected @@ -0,0 +1,5 @@ + + + + + -- cgit v1.2.3 From b42519108dc7ab104cf9ade65a508f54a0294406 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 1 Aug 2010 11:40:41 -0700 Subject: ir_to_mesa: Add support for MESA_GLSL=log. This is the option that dumps shader source to files in the current directory. --- src/mesa/program/ir_to_mesa.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 9274723eb73..8f790af09ac 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2514,6 +2514,10 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link); shader->num_builtins_to_link = state->num_builtins_to_link; + if (ctx->Shader.Flags & GLSL_LOG) { + _mesa_write_shader_to_file(shader); + } + /* Retain any live IR, but trash the rest. */ reparent_ir(shader->ir, shader); -- cgit v1.2.3 From 6a41626e90f75318e17d9907f4f57a8c3c315fea Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 1 Aug 2010 18:44:21 -0700 Subject: glsl2: Make non-square matrix keywords not keywords pre-120. Fixes glsl-mat-110. --- src/glsl/glsl_lexer.cpp | 411 +++++++++++++++++++++--------------------------- src/glsl/glsl_lexer.lpp | 109 ++++--------- 2 files changed, 207 insertions(+), 313 deletions(-) diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp index e5ca1bd0a51..af29dce3376 100644 --- a/src/glsl/glsl_lexer.cpp +++ b/src/glsl/glsl_lexer.cpp @@ -845,8 +845,18 @@ static yyconst flex_int16_t yy_chk[875] = #define YY_USER_INIT yylineno = 0; yycolumn = 0; +#define TOKEN_OR_IDENTIFIER(version, token) \ + do { \ + if (yyextra->language_version >= version) { \ + return token; \ + } else { \ + yylval->identifier = strdup(yytext); \ + return IDENTIFIER; \ + } \ + } while (0) -#line 850 "glsl_lexer.cpp" + +#line 860 "glsl_lexer.cpp" #define INITIAL 0 #define PP 1 @@ -1092,10 +1102,10 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 56 "glsl_lexer.lpp" +#line 66 "glsl_lexer.lpp" -#line 1099 "glsl_lexer.cpp" +#line 1109 "glsl_lexer.cpp" yylval = yylval_param; @@ -1181,7 +1191,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 58 "glsl_lexer.lpp" +#line 68 "glsl_lexer.lpp" ; YY_BREAK /* Preprocessor tokens. */ @@ -1190,17 +1200,17 @@ case 2: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 61 "glsl_lexer.lpp" +#line 71 "glsl_lexer.lpp" ; YY_BREAK case 3: YY_RULE_SETUP -#line 62 "glsl_lexer.lpp" +#line 72 "glsl_lexer.lpp" { BEGIN PP; return VERSION; } YY_BREAK case 4: YY_RULE_SETUP -#line 63 "glsl_lexer.lpp" +#line 73 "glsl_lexer.lpp" { BEGIN PP; return EXTENSION; } YY_BREAK case 5: @@ -1208,7 +1218,7 @@ case 5: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 64 "glsl_lexer.lpp" +#line 74 "glsl_lexer.lpp" { /* Eat characters until the first digit is * encountered @@ -1230,7 +1240,7 @@ case 6: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 79 "glsl_lexer.lpp" +#line 89 "glsl_lexer.lpp" { /* Eat characters until the first digit is * encountered @@ -1248,27 +1258,27 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 93 "glsl_lexer.lpp" +#line 103 "glsl_lexer.lpp" { BEGIN PP; return PRAGMA; } YY_BREAK case 8: YY_RULE_SETUP -#line 94 "glsl_lexer.lpp" +#line 104 "glsl_lexer.lpp" { } YY_BREAK case 9: YY_RULE_SETUP -#line 95 "glsl_lexer.lpp" +#line 105 "glsl_lexer.lpp" { } YY_BREAK case 10: YY_RULE_SETUP -#line 96 "glsl_lexer.lpp" +#line 106 "glsl_lexer.lpp" return COLON; YY_BREAK case 11: YY_RULE_SETUP -#line 97 "glsl_lexer.lpp" +#line 107 "glsl_lexer.lpp" { yylval->identifier = strdup(yytext); return IDENTIFIER; @@ -1276,7 +1286,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 101 "glsl_lexer.lpp" +#line 111 "glsl_lexer.lpp" { yylval->n = strtol(yytext, NULL, 10); return INTCONSTANT; @@ -1285,318 +1295,283 @@ YY_RULE_SETUP case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 105 "glsl_lexer.lpp" +#line 115 "glsl_lexer.lpp" { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } YY_BREAK case 14: /* rule 14 can match eol */ YY_RULE_SETUP -#line 107 "glsl_lexer.lpp" +#line 117 "glsl_lexer.lpp" { yylineno++; yycolumn = 0; } YY_BREAK case 15: YY_RULE_SETUP -#line 109 "glsl_lexer.lpp" +#line 119 "glsl_lexer.lpp" return ATTRIBUTE; YY_BREAK case 16: YY_RULE_SETUP -#line 110 "glsl_lexer.lpp" +#line 120 "glsl_lexer.lpp" return CONST_TOK; YY_BREAK case 17: YY_RULE_SETUP -#line 111 "glsl_lexer.lpp" +#line 121 "glsl_lexer.lpp" return BOOL; YY_BREAK case 18: YY_RULE_SETUP -#line 112 "glsl_lexer.lpp" +#line 122 "glsl_lexer.lpp" return FLOAT; YY_BREAK case 19: YY_RULE_SETUP -#line 113 "glsl_lexer.lpp" +#line 123 "glsl_lexer.lpp" return INT; YY_BREAK case 20: YY_RULE_SETUP -#line 115 "glsl_lexer.lpp" +#line 125 "glsl_lexer.lpp" return BREAK; YY_BREAK case 21: YY_RULE_SETUP -#line 116 "glsl_lexer.lpp" +#line 126 "glsl_lexer.lpp" return CONTINUE; YY_BREAK case 22: YY_RULE_SETUP -#line 117 "glsl_lexer.lpp" +#line 127 "glsl_lexer.lpp" return DO; YY_BREAK case 23: YY_RULE_SETUP -#line 118 "glsl_lexer.lpp" +#line 128 "glsl_lexer.lpp" return WHILE; YY_BREAK case 24: YY_RULE_SETUP -#line 119 "glsl_lexer.lpp" +#line 129 "glsl_lexer.lpp" return ELSE; YY_BREAK case 25: YY_RULE_SETUP -#line 120 "glsl_lexer.lpp" +#line 130 "glsl_lexer.lpp" return FOR; YY_BREAK case 26: YY_RULE_SETUP -#line 121 "glsl_lexer.lpp" +#line 131 "glsl_lexer.lpp" return IF; YY_BREAK case 27: YY_RULE_SETUP -#line 122 "glsl_lexer.lpp" +#line 132 "glsl_lexer.lpp" return DISCARD; YY_BREAK case 28: YY_RULE_SETUP -#line 123 "glsl_lexer.lpp" +#line 133 "glsl_lexer.lpp" return RETURN; YY_BREAK case 29: YY_RULE_SETUP -#line 125 "glsl_lexer.lpp" +#line 135 "glsl_lexer.lpp" return BVEC2; YY_BREAK case 30: YY_RULE_SETUP -#line 126 "glsl_lexer.lpp" +#line 136 "glsl_lexer.lpp" return BVEC3; YY_BREAK case 31: YY_RULE_SETUP -#line 127 "glsl_lexer.lpp" +#line 137 "glsl_lexer.lpp" return BVEC4; YY_BREAK case 32: YY_RULE_SETUP -#line 128 "glsl_lexer.lpp" +#line 138 "glsl_lexer.lpp" return IVEC2; YY_BREAK case 33: YY_RULE_SETUP -#line 129 "glsl_lexer.lpp" +#line 139 "glsl_lexer.lpp" return IVEC3; YY_BREAK case 34: YY_RULE_SETUP -#line 130 "glsl_lexer.lpp" +#line 140 "glsl_lexer.lpp" return IVEC4; YY_BREAK case 35: YY_RULE_SETUP -#line 131 "glsl_lexer.lpp" +#line 141 "glsl_lexer.lpp" return VEC2; YY_BREAK case 36: YY_RULE_SETUP -#line 132 "glsl_lexer.lpp" +#line 142 "glsl_lexer.lpp" return VEC3; YY_BREAK case 37: YY_RULE_SETUP -#line 133 "glsl_lexer.lpp" +#line 143 "glsl_lexer.lpp" return VEC4; YY_BREAK case 38: YY_RULE_SETUP -#line 134 "glsl_lexer.lpp" +#line 144 "glsl_lexer.lpp" return MAT2; YY_BREAK case 39: YY_RULE_SETUP -#line 135 "glsl_lexer.lpp" +#line 145 "glsl_lexer.lpp" return MAT3; YY_BREAK case 40: YY_RULE_SETUP -#line 136 "glsl_lexer.lpp" +#line 146 "glsl_lexer.lpp" return MAT4; YY_BREAK case 41: YY_RULE_SETUP -#line 137 "glsl_lexer.lpp" -return MAT2X2; +#line 147 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, MAT2X2); YY_BREAK case 42: YY_RULE_SETUP -#line 138 "glsl_lexer.lpp" -return MAT2X3; +#line 148 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, MAT2X3); YY_BREAK case 43: YY_RULE_SETUP -#line 139 "glsl_lexer.lpp" -return MAT2X4; +#line 149 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, MAT2X4); YY_BREAK case 44: YY_RULE_SETUP -#line 140 "glsl_lexer.lpp" -return MAT3X2; +#line 150 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, MAT3X2); YY_BREAK case 45: YY_RULE_SETUP -#line 141 "glsl_lexer.lpp" -return MAT3X3; +#line 151 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, MAT3X3); YY_BREAK case 46: YY_RULE_SETUP -#line 142 "glsl_lexer.lpp" -return MAT3X4; +#line 152 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, MAT3X4); YY_BREAK case 47: YY_RULE_SETUP -#line 143 "glsl_lexer.lpp" -return MAT4X2; +#line 153 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, MAT4X2); YY_BREAK case 48: YY_RULE_SETUP -#line 144 "glsl_lexer.lpp" -return MAT4X3; +#line 154 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, MAT4X3); YY_BREAK case 49: YY_RULE_SETUP -#line 145 "glsl_lexer.lpp" -return MAT4X4; +#line 155 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, MAT4X4); YY_BREAK case 50: YY_RULE_SETUP -#line 147 "glsl_lexer.lpp" +#line 157 "glsl_lexer.lpp" return IN; YY_BREAK case 51: YY_RULE_SETUP -#line 148 "glsl_lexer.lpp" +#line 158 "glsl_lexer.lpp" return OUT; YY_BREAK case 52: YY_RULE_SETUP -#line 149 "glsl_lexer.lpp" +#line 159 "glsl_lexer.lpp" return INOUT; YY_BREAK case 53: YY_RULE_SETUP -#line 150 "glsl_lexer.lpp" +#line 160 "glsl_lexer.lpp" return UNIFORM; YY_BREAK case 54: YY_RULE_SETUP -#line 151 "glsl_lexer.lpp" +#line 161 "glsl_lexer.lpp" return VARYING; YY_BREAK case 55: YY_RULE_SETUP -#line 152 "glsl_lexer.lpp" -{ - if (yyextra->language_version >= 120) { - return CENTROID; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +#line 162 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, CENTROID); YY_BREAK case 56: YY_RULE_SETUP -#line 160 "glsl_lexer.lpp" -{ - if (yyextra->language_version >= 120) { - return INVARIANT; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +#line 163 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, INVARIANT); YY_BREAK case 57: YY_RULE_SETUP -#line 169 "glsl_lexer.lpp" -{ - if (yyextra->language_version >= 130) { - return FLAT; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +#line 165 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, FLAT); YY_BREAK case 58: YY_RULE_SETUP -#line 177 "glsl_lexer.lpp" -{ - if (yyextra->language_version >= 130) { - return SMOOTH; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +#line 166 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, SMOOTH); YY_BREAK case 59: YY_RULE_SETUP -#line 185 "glsl_lexer.lpp" -{ - if (yyextra->language_version >= 130) { - return NOPERSPECTIVE; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +#line 167 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, NOPERSPECTIVE); YY_BREAK case 60: YY_RULE_SETUP -#line 194 "glsl_lexer.lpp" +#line 169 "glsl_lexer.lpp" return SAMPLER1D; YY_BREAK case 61: YY_RULE_SETUP -#line 195 "glsl_lexer.lpp" +#line 170 "glsl_lexer.lpp" return SAMPLER2D; YY_BREAK case 62: YY_RULE_SETUP -#line 196 "glsl_lexer.lpp" +#line 171 "glsl_lexer.lpp" return SAMPLER3D; YY_BREAK case 63: YY_RULE_SETUP -#line 197 "glsl_lexer.lpp" +#line 172 "glsl_lexer.lpp" return SAMPLERCUBE; YY_BREAK case 64: YY_RULE_SETUP -#line 198 "glsl_lexer.lpp" +#line 173 "glsl_lexer.lpp" return SAMPLER1DSHADOW; YY_BREAK case 65: YY_RULE_SETUP -#line 199 "glsl_lexer.lpp" +#line 174 "glsl_lexer.lpp" return SAMPLER2DSHADOW; YY_BREAK case 66: YY_RULE_SETUP -#line 201 "glsl_lexer.lpp" +#line 176 "glsl_lexer.lpp" return STRUCT; YY_BREAK case 67: YY_RULE_SETUP -#line 202 "glsl_lexer.lpp" +#line 177 "glsl_lexer.lpp" return VOID; YY_BREAK case 68: YY_RULE_SETUP -#line 204 "glsl_lexer.lpp" +#line 179 "glsl_lexer.lpp" { if ((yyextra->language_version >= 140) || (yyextra->ARB_fragment_coord_conventions_enable)){ @@ -1609,102 +1584,102 @@ YY_RULE_SETUP YY_BREAK case 69: YY_RULE_SETUP -#line 214 "glsl_lexer.lpp" +#line 189 "glsl_lexer.lpp" return INC_OP; YY_BREAK case 70: YY_RULE_SETUP -#line 215 "glsl_lexer.lpp" +#line 190 "glsl_lexer.lpp" return DEC_OP; YY_BREAK case 71: YY_RULE_SETUP -#line 216 "glsl_lexer.lpp" +#line 191 "glsl_lexer.lpp" return LE_OP; YY_BREAK case 72: YY_RULE_SETUP -#line 217 "glsl_lexer.lpp" +#line 192 "glsl_lexer.lpp" return GE_OP; YY_BREAK case 73: YY_RULE_SETUP -#line 218 "glsl_lexer.lpp" +#line 193 "glsl_lexer.lpp" return EQ_OP; YY_BREAK case 74: YY_RULE_SETUP -#line 219 "glsl_lexer.lpp" +#line 194 "glsl_lexer.lpp" return NE_OP; YY_BREAK case 75: YY_RULE_SETUP -#line 220 "glsl_lexer.lpp" +#line 195 "glsl_lexer.lpp" return AND_OP; YY_BREAK case 76: YY_RULE_SETUP -#line 221 "glsl_lexer.lpp" +#line 196 "glsl_lexer.lpp" return OR_OP; YY_BREAK case 77: YY_RULE_SETUP -#line 222 "glsl_lexer.lpp" +#line 197 "glsl_lexer.lpp" return XOR_OP; YY_BREAK case 78: YY_RULE_SETUP -#line 224 "glsl_lexer.lpp" +#line 199 "glsl_lexer.lpp" return MUL_ASSIGN; YY_BREAK case 79: YY_RULE_SETUP -#line 225 "glsl_lexer.lpp" +#line 200 "glsl_lexer.lpp" return DIV_ASSIGN; YY_BREAK case 80: YY_RULE_SETUP -#line 226 "glsl_lexer.lpp" +#line 201 "glsl_lexer.lpp" return ADD_ASSIGN; YY_BREAK case 81: YY_RULE_SETUP -#line 227 "glsl_lexer.lpp" +#line 202 "glsl_lexer.lpp" return MOD_ASSIGN; YY_BREAK case 82: YY_RULE_SETUP -#line 228 "glsl_lexer.lpp" +#line 203 "glsl_lexer.lpp" return LEFT_ASSIGN; YY_BREAK case 83: YY_RULE_SETUP -#line 229 "glsl_lexer.lpp" +#line 204 "glsl_lexer.lpp" return RIGHT_ASSIGN; YY_BREAK case 84: YY_RULE_SETUP -#line 230 "glsl_lexer.lpp" +#line 205 "glsl_lexer.lpp" return AND_ASSIGN; YY_BREAK case 85: YY_RULE_SETUP -#line 231 "glsl_lexer.lpp" +#line 206 "glsl_lexer.lpp" return XOR_ASSIGN; YY_BREAK case 86: YY_RULE_SETUP -#line 232 "glsl_lexer.lpp" +#line 207 "glsl_lexer.lpp" return OR_ASSIGN; YY_BREAK case 87: YY_RULE_SETUP -#line 233 "glsl_lexer.lpp" +#line 208 "glsl_lexer.lpp" return SUB_ASSIGN; YY_BREAK case 88: YY_RULE_SETUP -#line 235 "glsl_lexer.lpp" +#line 210 "glsl_lexer.lpp" { yylval->n = strtol(yytext, NULL, 10); return INTCONSTANT; @@ -1712,7 +1687,7 @@ YY_RULE_SETUP YY_BREAK case 89: YY_RULE_SETUP -#line 239 "glsl_lexer.lpp" +#line 214 "glsl_lexer.lpp" { yylval->n = strtol(yytext + 2, NULL, 16); return INTCONSTANT; @@ -1720,7 +1695,7 @@ YY_RULE_SETUP YY_BREAK case 90: YY_RULE_SETUP -#line 243 "glsl_lexer.lpp" +#line 218 "glsl_lexer.lpp" { yylval->n = strtol(yytext, NULL, 8); return INTCONSTANT; @@ -1728,7 +1703,7 @@ YY_RULE_SETUP YY_BREAK case 91: YY_RULE_SETUP -#line 248 "glsl_lexer.lpp" +#line 223 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; @@ -1736,7 +1711,7 @@ YY_RULE_SETUP YY_BREAK case 92: YY_RULE_SETUP -#line 252 "glsl_lexer.lpp" +#line 227 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; @@ -1744,7 +1719,7 @@ YY_RULE_SETUP YY_BREAK case 93: YY_RULE_SETUP -#line 256 "glsl_lexer.lpp" +#line 231 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; @@ -1752,7 +1727,7 @@ YY_RULE_SETUP YY_BREAK case 94: YY_RULE_SETUP -#line 260 "glsl_lexer.lpp" +#line 235 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; @@ -1760,7 +1735,7 @@ YY_RULE_SETUP YY_BREAK case 95: YY_RULE_SETUP -#line 265 "glsl_lexer.lpp" +#line 240 "glsl_lexer.lpp" { yylval->n = 1; return BOOLCONSTANT; @@ -1768,7 +1743,7 @@ YY_RULE_SETUP YY_BREAK case 96: YY_RULE_SETUP -#line 269 "glsl_lexer.lpp" +#line 244 "glsl_lexer.lpp" { yylval->n = 0; return BOOLCONSTANT; @@ -1777,271 +1752,243 @@ YY_RULE_SETUP /* Reserved words in GLSL 1.10. */ case 97: YY_RULE_SETUP -#line 276 "glsl_lexer.lpp" +#line 251 "glsl_lexer.lpp" return ASM; YY_BREAK case 98: YY_RULE_SETUP -#line 277 "glsl_lexer.lpp" +#line 252 "glsl_lexer.lpp" return CLASS; YY_BREAK case 99: YY_RULE_SETUP -#line 278 "glsl_lexer.lpp" +#line 253 "glsl_lexer.lpp" return UNION; YY_BREAK case 100: YY_RULE_SETUP -#line 279 "glsl_lexer.lpp" +#line 254 "glsl_lexer.lpp" return ENUM; YY_BREAK case 101: YY_RULE_SETUP -#line 280 "glsl_lexer.lpp" +#line 255 "glsl_lexer.lpp" return TYPEDEF; YY_BREAK case 102: YY_RULE_SETUP -#line 281 "glsl_lexer.lpp" +#line 256 "glsl_lexer.lpp" return TEMPLATE; YY_BREAK case 103: YY_RULE_SETUP -#line 282 "glsl_lexer.lpp" +#line 257 "glsl_lexer.lpp" return THIS; YY_BREAK case 104: YY_RULE_SETUP -#line 283 "glsl_lexer.lpp" +#line 258 "glsl_lexer.lpp" return PACKED; YY_BREAK case 105: YY_RULE_SETUP -#line 284 "glsl_lexer.lpp" +#line 259 "glsl_lexer.lpp" return GOTO; YY_BREAK case 106: YY_RULE_SETUP -#line 285 "glsl_lexer.lpp" +#line 260 "glsl_lexer.lpp" return SWITCH; YY_BREAK case 107: YY_RULE_SETUP -#line 286 "glsl_lexer.lpp" +#line 261 "glsl_lexer.lpp" return DEFAULT; YY_BREAK case 108: YY_RULE_SETUP -#line 287 "glsl_lexer.lpp" +#line 262 "glsl_lexer.lpp" return INLINE_TOK; YY_BREAK case 109: YY_RULE_SETUP -#line 288 "glsl_lexer.lpp" +#line 263 "glsl_lexer.lpp" return NOINLINE; YY_BREAK case 110: YY_RULE_SETUP -#line 289 "glsl_lexer.lpp" +#line 264 "glsl_lexer.lpp" return VOLATILE; YY_BREAK case 111: YY_RULE_SETUP -#line 290 "glsl_lexer.lpp" +#line 265 "glsl_lexer.lpp" return PUBLIC_TOK; YY_BREAK case 112: YY_RULE_SETUP -#line 291 "glsl_lexer.lpp" +#line 266 "glsl_lexer.lpp" return STATIC; YY_BREAK case 113: YY_RULE_SETUP -#line 292 "glsl_lexer.lpp" +#line 267 "glsl_lexer.lpp" return EXTERN; YY_BREAK case 114: YY_RULE_SETUP -#line 293 "glsl_lexer.lpp" +#line 268 "glsl_lexer.lpp" return EXTERNAL; YY_BREAK case 115: YY_RULE_SETUP -#line 294 "glsl_lexer.lpp" +#line 269 "glsl_lexer.lpp" return INTERFACE; YY_BREAK case 116: YY_RULE_SETUP -#line 295 "glsl_lexer.lpp" +#line 270 "glsl_lexer.lpp" return LONG; YY_BREAK case 117: YY_RULE_SETUP -#line 296 "glsl_lexer.lpp" +#line 271 "glsl_lexer.lpp" return SHORT; YY_BREAK case 118: YY_RULE_SETUP -#line 297 "glsl_lexer.lpp" +#line 272 "glsl_lexer.lpp" return DOUBLE; YY_BREAK case 119: YY_RULE_SETUP -#line 298 "glsl_lexer.lpp" +#line 273 "glsl_lexer.lpp" return HALF; YY_BREAK case 120: YY_RULE_SETUP -#line 299 "glsl_lexer.lpp" +#line 274 "glsl_lexer.lpp" return FIXED; YY_BREAK case 121: YY_RULE_SETUP -#line 300 "glsl_lexer.lpp" +#line 275 "glsl_lexer.lpp" return UNSIGNED; YY_BREAK case 122: YY_RULE_SETUP -#line 301 "glsl_lexer.lpp" +#line 276 "glsl_lexer.lpp" return INPUT; YY_BREAK case 123: YY_RULE_SETUP -#line 302 "glsl_lexer.lpp" +#line 277 "glsl_lexer.lpp" return OUTPUT; YY_BREAK case 124: YY_RULE_SETUP -#line 303 "glsl_lexer.lpp" +#line 278 "glsl_lexer.lpp" return HVEC2; YY_BREAK case 125: YY_RULE_SETUP -#line 304 "glsl_lexer.lpp" +#line 279 "glsl_lexer.lpp" return HVEC3; YY_BREAK case 126: YY_RULE_SETUP -#line 305 "glsl_lexer.lpp" +#line 280 "glsl_lexer.lpp" return HVEC4; YY_BREAK case 127: YY_RULE_SETUP -#line 306 "glsl_lexer.lpp" +#line 281 "glsl_lexer.lpp" return DVEC2; YY_BREAK case 128: YY_RULE_SETUP -#line 307 "glsl_lexer.lpp" +#line 282 "glsl_lexer.lpp" return DVEC3; YY_BREAK case 129: YY_RULE_SETUP -#line 308 "glsl_lexer.lpp" +#line 283 "glsl_lexer.lpp" return DVEC4; YY_BREAK case 130: YY_RULE_SETUP -#line 309 "glsl_lexer.lpp" +#line 284 "glsl_lexer.lpp" return FVEC2; YY_BREAK case 131: YY_RULE_SETUP -#line 310 "glsl_lexer.lpp" +#line 285 "glsl_lexer.lpp" return FVEC3; YY_BREAK case 132: YY_RULE_SETUP -#line 311 "glsl_lexer.lpp" +#line 286 "glsl_lexer.lpp" return FVEC4; YY_BREAK case 133: YY_RULE_SETUP -#line 312 "glsl_lexer.lpp" +#line 287 "glsl_lexer.lpp" return SAMPLER2DRECT; YY_BREAK case 134: YY_RULE_SETUP -#line 313 "glsl_lexer.lpp" +#line 288 "glsl_lexer.lpp" return SAMPLER3DRECT; YY_BREAK case 135: YY_RULE_SETUP -#line 314 "glsl_lexer.lpp" +#line 289 "glsl_lexer.lpp" return SAMPLER2DRECTSHADOW; YY_BREAK case 136: YY_RULE_SETUP -#line 315 "glsl_lexer.lpp" +#line 290 "glsl_lexer.lpp" return SIZEOF; YY_BREAK case 137: YY_RULE_SETUP -#line 316 "glsl_lexer.lpp" +#line 291 "glsl_lexer.lpp" return CAST; YY_BREAK case 138: YY_RULE_SETUP -#line 317 "glsl_lexer.lpp" +#line 292 "glsl_lexer.lpp" return NAMESPACE; YY_BREAK case 139: YY_RULE_SETUP -#line 318 "glsl_lexer.lpp" +#line 293 "glsl_lexer.lpp" return USING; YY_BREAK /* Additional reserved words in GLSL 1.20. */ case 140: YY_RULE_SETUP -#line 321 "glsl_lexer.lpp" -{ - if (yyextra->language_version >= 120){ - return LOWP; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +#line 296 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, LOWP); YY_BREAK case 141: YY_RULE_SETUP -#line 329 "glsl_lexer.lpp" -{ - if (yyextra->language_version >= 120){ - return MEDIUMP; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - }return MEDIUMP; +#line 297 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, MEDIUMP); YY_BREAK case 142: YY_RULE_SETUP -#line 337 "glsl_lexer.lpp" -{ - if (yyextra->language_version >= 120){ - return HIGHP; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +#line 298 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, HIGHP); YY_BREAK case 143: YY_RULE_SETUP -#line 345 "glsl_lexer.lpp" -{ - if (yyextra->language_version >= 120){ - return PRECISION; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +#line 299 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(120, PRECISION); YY_BREAK case 144: YY_RULE_SETUP -#line 354 "glsl_lexer.lpp" +#line 301 "glsl_lexer.lpp" { struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; @@ -2051,15 +1998,15 @@ YY_RULE_SETUP YY_BREAK case 145: YY_RULE_SETUP -#line 361 "glsl_lexer.lpp" +#line 308 "glsl_lexer.lpp" { return yytext[0]; } YY_BREAK case 146: YY_RULE_SETUP -#line 363 "glsl_lexer.lpp" +#line 310 "glsl_lexer.lpp" ECHO; YY_BREAK -#line 2063 "glsl_lexer.cpp" +#line 2010 "glsl_lexer.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(PP): yyterminate(); @@ -3201,7 +3148,7 @@ void _mesa_glsl_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 363 "glsl_lexer.lpp" +#line 310 "glsl_lexer.lpp" diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index 702e79a363e..21c81a26635 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -36,6 +36,16 @@ #define YY_USER_INIT yylineno = 0; yycolumn = 0; +#define TOKEN_OR_IDENTIFIER(version, token) \ + do { \ + if (yyextra->language_version >= version) { \ + return token; \ + } else { \ + yylval->identifier = strdup(yytext); \ + return IDENTIFIER; \ + } \ + } while (0) + %} %option bison-bridge bison-locations reentrant noyywrap @@ -134,62 +144,27 @@ vec4 return VEC4; mat2 return MAT2; mat3 return MAT3; mat4 return MAT4; -mat2x2 return MAT2X2; -mat2x3 return MAT2X3; -mat2x4 return MAT2X4; -mat3x2 return MAT3X2; -mat3x3 return MAT3X3; -mat3x4 return MAT3X4; -mat4x2 return MAT4X2; -mat4x3 return MAT4X3; -mat4x4 return MAT4X4; +mat2x2 TOKEN_OR_IDENTIFIER(120, MAT2X2); +mat2x3 TOKEN_OR_IDENTIFIER(120, MAT2X3); +mat2x4 TOKEN_OR_IDENTIFIER(120, MAT2X4); +mat3x2 TOKEN_OR_IDENTIFIER(120, MAT3X2); +mat3x3 TOKEN_OR_IDENTIFIER(120, MAT3X3); +mat3x4 TOKEN_OR_IDENTIFIER(120, MAT3X4); +mat4x2 TOKEN_OR_IDENTIFIER(120, MAT4X2); +mat4x3 TOKEN_OR_IDENTIFIER(120, MAT4X3); +mat4x4 TOKEN_OR_IDENTIFIER(120, MAT4X4); in return IN; out return OUT; inout return INOUT; uniform return UNIFORM; varying return VARYING; -centroid { - if (yyextra->language_version >= 120) { - return CENTROID; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } -invariant { - if (yyextra->language_version >= 120) { - return INVARIANT; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +centroid TOKEN_OR_IDENTIFIER(120, CENTROID); +invariant TOKEN_OR_IDENTIFIER(120, INVARIANT); -flat { - if (yyextra->language_version >= 130) { - return FLAT; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } -smooth { - if (yyextra->language_version >= 130) { - return SMOOTH; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } -noperspective { - if (yyextra->language_version >= 130) { - return NOPERSPECTIVE; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +flat TOKEN_OR_IDENTIFIER(130, FLAT); +smooth TOKEN_OR_IDENTIFIER(130, SMOOTH); +noperspective TOKEN_OR_IDENTIFIER(130, NOPERSPECTIVE); sampler1D return SAMPLER1D; sampler2D return SAMPLER2D; @@ -318,38 +293,10 @@ namespace return NAMESPACE; using return USING; /* Additional reserved words in GLSL 1.20. */ -lowp { - if (yyextra->language_version >= 120){ - return LOWP; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } -mediump { - if (yyextra->language_version >= 120){ - return MEDIUMP; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - }return MEDIUMP; -highp { - if (yyextra->language_version >= 120){ - return HIGHP; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } -precision { - if (yyextra->language_version >= 120){ - return PRECISION; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } +lowp TOKEN_OR_IDENTIFIER(120, LOWP); +mediump TOKEN_OR_IDENTIFIER(120, MEDIUMP); +highp TOKEN_OR_IDENTIFIER(120, HIGHP); +precision TOKEN_OR_IDENTIFIER(120, PRECISION); [_a-zA-Z][_a-zA-Z0-9]* { struct _mesa_glsl_parse_state *state = yyextra; -- cgit v1.2.3 From b35703df107b50b2c3f5cd4d56790921e8106324 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Mon, 2 Aug 2010 10:22:26 +0300 Subject: glsl2: initialize is_array and array_size of ast_parameter_declarator The non-array path of glsl_parser.ypp wasn't setting is_array to false. --- src/glsl/ast.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index 655054ff6fa..aa769da3f65 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -455,6 +455,12 @@ public: class ast_parameter_declarator : public ast_node { public: + ast_parameter_declarator() + { + this->is_array = false; + this->array_size = 0; + } + virtual void print(void) const; virtual ir_rvalue *hir(exec_list *instructions, -- cgit v1.2.3 From 31747155ea3a24190277b125bd188ac8689af719 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Thu, 29 Jul 2010 12:40:49 +0300 Subject: glsl2: Give the path within src/mesa/ for headers instead of relying on -I. --- src/glsl/ast_type.cpp | 2 +- src/glsl/glcpp/glcpp.h | 2 +- src/glsl/glsl_types.cpp | 2 +- src/glsl/hir_field_selection.cpp | 2 +- src/glsl/ir_clone.cpp | 2 +- src/glsl/ir_function_inlining.cpp | 2 +- src/glsl/ir_validate.cpp | 2 +- src/glsl/link_functions.cpp | 2 +- src/glsl/linker.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp index e2510a10c62..9a957044e7a 100644 --- a/src/glsl/ast_type.cpp +++ b/src/glsl/ast_type.cpp @@ -24,7 +24,7 @@ #include #include "ast.h" extern "C" { -#include "symbol_table.h" +#include "program/symbol_table.h" } void diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index 869de2efbcc..0ccd957eda3 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -28,7 +28,7 @@ #include -#include "hash_table.h" +#include "program/hash_table.h" #define yyscan_t void* diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 8192b86dfc9..ce47b8167f4 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -28,7 +28,7 @@ #include "glsl_types.h" #include "builtin_types.h" extern "C" { -#include "hash_table.h" +#include "program/hash_table.h" } hash_table *glsl_type::array_types = NULL; diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp index db1e06932f4..6dd910d5816 100644 --- a/src/glsl/hir_field_selection.cpp +++ b/src/glsl/hir_field_selection.cpp @@ -23,7 +23,7 @@ #include "ir.h" #include "main/imports.h" -#include "symbol_table.h" +#include "program/symbol_table.h" #include "glsl_parser_extras.h" #include "ast.h" #include "glsl_types.h" diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 6be3e59a95d..5ea3a79afcd 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -25,7 +25,7 @@ #include "ir.h" #include "glsl_types.h" extern "C" { -#include "hash_table.h" +#include "program/hash_table.h" } /** diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 77c264f288b..95993062435 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -33,7 +33,7 @@ #include "ir_function_inlining.h" #include "ir_expression_flattening.h" #include "glsl_types.h" -#include "hash_table.h" +#include "program/hash_table.h" class ir_function_inlining_visitor : public ir_hierarchical_visitor { public: diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 1fa6e19ce96..85417a1dbc8 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -36,7 +36,7 @@ #include #include "ir.h" #include "ir_hierarchical_visitor.h" -#include "hash_table.h" +#include "program/hash_table.h" #include "glsl_types.h" class ir_validate : public ir_hierarchical_visitor { diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp index 327be73afe6..fdf886f6627 100644 --- a/src/glsl/link_functions.cpp +++ b/src/glsl/link_functions.cpp @@ -34,7 +34,7 @@ extern "C" { #include "glsl_parser_extras.h" #include "ir.h" #include "program.h" -#include "hash_table.h" +#include "program/hash_table.h" #include "linker.h" static ir_function_signature * diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 9d53197fdda..a5faff2be75 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -78,7 +78,7 @@ extern "C" { #include "glsl_symbol_table.h" #include "ir.h" #include "program.h" -#include "hash_table.h" +#include "program/hash_table.h" #include "linker.h" #include "ir_optimization.h" -- cgit v1.2.3 From f311d8e9e9ef79fde762fbd7817f7fe51b37dc45 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 10:49:29 -0700 Subject: glsl2: Don't add mesa/program/ as an include dir. Let includes say program/. --- src/glsl/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 0254fec756b..f98b772a2fb 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -100,7 +100,6 @@ INCLUDES = \ -I. \ -I../mesa \ -I../mapi \ - -I../mesa/program \ -I../../include \ $(LIBRARY_INCLUDES) -- cgit v1.2.3 From 004e924014f749e8ae5cc7a40e1bb431af0b9041 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 10:54:22 -0700 Subject: glsl2: Fix spelling of "precision" in error output. --- src/glsl/glsl_parser.cpp | 6 +++--- src/glsl/glsl_parser.ypp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp index b31f558168f..bf83b81603f 100644 --- a/src/glsl/glsl_parser.cpp +++ b/src/glsl/glsl_parser.cpp @@ -4454,7 +4454,7 @@ yyreduce: { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, - "precission qualifier forbidden " + "precision qualifier forbidden " "in GLSL %d.%d (1.30 or later " "required)\n", state->language_version / 100, @@ -4471,7 +4471,7 @@ yyreduce: { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, - "precission qualifier forbidden " + "precision qualifier forbidden " "in GLSL %d.%d (1.30 or later " "required)\n", state->language_version / 100, @@ -4488,7 +4488,7 @@ yyreduce: { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, - "precission qualifier forbidden " + "precision qualifier forbidden " "in GLSL %d.%d (1.30 or later " "required)\n", state->language_version / 100, diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 53132d9067d..7cabefbd34f 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -1128,7 +1128,7 @@ precision_qualifier: HIGHP { if (state->language_version < 130) _mesa_glsl_error(& @1, state, - "precission qualifier forbidden " + "precision qualifier forbidden " "in GLSL %d.%d (1.30 or later " "required)\n", state->language_version / 100, @@ -1139,7 +1139,7 @@ precision_qualifier: | MEDIUMP { if (state->language_version < 130) _mesa_glsl_error(& @1, state, - "precission qualifier forbidden " + "precision qualifier forbidden " "in GLSL %d.%d (1.30 or later " "required)\n", state->language_version / 100, @@ -1150,7 +1150,7 @@ precision_qualifier: | LOWP { if (state->language_version < 130) _mesa_glsl_error(& @1, state, - "precission qualifier forbidden " + "precision qualifier forbidden " "in GLSL %d.%d (1.30 or later " "required)\n", state->language_version / 100, -- cgit v1.2.3 From b8db38e1c4f639cb0a063250d43f5a0ef6afd50f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 11:04:54 -0700 Subject: glsl2: Also initialize the identifier field of parameter_declarator. The non-named parameter grammar understandably doesn't set the identifier field. Fixes intermittent failures about void main(void) {} having a named void parameter. --- src/glsl/ast.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index aa769da3f65..1de285bb461 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -457,6 +457,7 @@ class ast_parameter_declarator : public ast_node { public: ast_parameter_declarator() { + this->identifier = NULL; this->is_array = false; this->array_size = 0; } -- cgit v1.2.3 From 960ba0014af7009f8543c55f455271cf3cb45cd6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 11:20:32 -0700 Subject: glsl2: Initialize the ARB_fcc fields of ir_variable. Fixes intermittent failure in glsl-arb-fragment-coord-conventions. --- src/glsl/ir.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 2b5f441ddd8..79cbaa9ea07 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -802,6 +802,8 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, this->location = -1; this->warn_extension = NULL; this->constant_value = NULL; + this->origin_upper_left = false; + this->pixel_center_integer = false; if (type && type->base_type == GLSL_TYPE_SAMPLER) this->read_only = true; -- cgit v1.2.3 From 47f3f223119739efd337ce1757c2e00d61be34cb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 11:26:43 -0700 Subject: glsl2: Add support for floating constants like "1f". Fixes glsl-floating-constant-120. --- src/glsl/glsl_lexer.cpp | 860 ++++++++++++++++++++++++------------------------ src/glsl/glsl_lexer.lpp | 4 + 2 files changed, 438 insertions(+), 426 deletions(-) diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp index af29dce3376..43be3170ba8 100644 --- a/src/glsl/glsl_lexer.cpp +++ b/src/glsl/glsl_lexer.cpp @@ -358,8 +358,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 146 -#define YY_END_OF_BUFFER 147 +#define YY_NUM_RULES 147 +#define YY_END_OF_BUFFER 148 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -367,66 +367,66 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[524] = +static yyconst flex_int16_t yy_accept[525] = { 0, - 0, 0, 9, 9, 147, 145, 1, 14, 145, 145, - 145, 145, 145, 145, 145, 145, 90, 88, 145, 145, - 145, 144, 145, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 145, 1, 145, 85, 146, 9, 13, - 146, 12, 10, 11, 1, 74, 81, 75, 84, 78, + 0, 0, 9, 9, 148, 146, 1, 14, 146, 146, + 146, 146, 146, 146, 146, 146, 90, 88, 146, 146, + 146, 145, 146, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 146, 1, 146, 85, 147, 9, 13, + 147, 12, 10, 11, 1, 74, 81, 75, 84, 78, 69, 80, 70, 87, 92, 79, 93, 90, 0, 0, - 0, 88, 0, 71, 73, 72, 0, 144, 77, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 22, 144, 144, 144, 144, 144, 144, 144, 144, 144, - - 144, 144, 144, 144, 26, 50, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 86, 76, 1, 0, 0, 2, - 0, 0, 0, 0, 9, 8, 12, 11, 0, 92, - 91, 0, 93, 0, 94, 89, 82, 83, 97, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 25, 144, - 144, 144, 144, 144, 144, 144, 144, 19, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 51, 144, - - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 0, 0, 0, 0, 8, 0, 92, 0, - 91, 0, 93, 94, 144, 17, 144, 144, 137, 144, - 144, 144, 144, 144, 144, 144, 144, 24, 100, 144, - 144, 144, 57, 144, 144, 105, 119, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 116, 140, 38, 39, - 40, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 103, 95, - 144, 144, 144, 144, 144, 144, 35, 36, 37, 67, - - 144, 144, 0, 0, 0, 0, 0, 91, 144, 20, - 29, 30, 31, 144, 98, 16, 144, 144, 144, 144, - 127, 128, 129, 144, 96, 120, 18, 130, 131, 132, - 142, 124, 125, 126, 144, 52, 122, 144, 144, 32, - 33, 34, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 117, 144, 144, 144, - 144, 144, 144, 144, 144, 99, 144, 139, 144, 144, - 23, 0, 0, 0, 0, 144, 144, 144, 144, 144, - 118, 113, 108, 144, 144, 68, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 144, 144, 144, 144, 123, - - 104, 144, 111, 28, 144, 136, 58, 112, 66, 106, - 144, 144, 144, 144, 144, 144, 0, 0, 0, 0, - 144, 144, 144, 107, 27, 144, 144, 144, 141, 144, - 144, 144, 144, 144, 144, 101, 53, 144, 54, 144, - 0, 0, 0, 7, 0, 144, 55, 21, 114, 144, - 144, 144, 109, 144, 144, 144, 144, 144, 144, 102, - 121, 110, 0, 0, 6, 0, 0, 0, 3, 15, - 115, 56, 138, 144, 143, 60, 61, 62, 144, 0, - 0, 0, 0, 144, 144, 144, 144, 144, 144, 4, - 0, 5, 0, 0, 0, 144, 144, 144, 144, 144, - - 63, 0, 144, 144, 144, 144, 144, 59, 144, 133, - 144, 134, 144, 144, 144, 64, 144, 65, 144, 144, - 144, 135, 0 + 95, 0, 88, 0, 71, 73, 72, 0, 145, 77, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, + 145, 22, 145, 145, 145, 145, 145, 145, 145, 145, + + 145, 145, 145, 145, 145, 26, 50, 145, 145, 145, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 145, 145, 86, 76, 1, 0, 0, + 2, 0, 0, 0, 0, 9, 8, 12, 11, 0, + 92, 91, 0, 93, 0, 94, 89, 82, 83, 98, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 25, + 145, 145, 145, 145, 145, 145, 145, 145, 19, 145, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 51, + + 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 0, 0, 0, 0, 8, 0, 92, + 0, 91, 0, 93, 94, 145, 17, 145, 145, 138, + 145, 145, 145, 145, 145, 145, 145, 145, 24, 101, + 145, 145, 145, 57, 145, 145, 106, 120, 145, 145, + 145, 145, 145, 145, 145, 145, 145, 117, 141, 38, + 39, 40, 145, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 145, 145, 145, 145, 145, 145, 104, + 96, 145, 145, 145, 145, 145, 145, 35, 36, 37, + + 67, 145, 145, 0, 0, 0, 0, 0, 91, 145, + 20, 29, 30, 31, 145, 99, 16, 145, 145, 145, + 145, 128, 129, 130, 145, 97, 121, 18, 131, 132, + 133, 143, 125, 126, 127, 145, 52, 123, 145, 145, + 32, 33, 34, 145, 145, 145, 145, 145, 145, 145, + 145, 145, 145, 145, 145, 145, 145, 118, 145, 145, + 145, 145, 145, 145, 145, 145, 100, 145, 140, 145, + 145, 23, 0, 0, 0, 0, 145, 145, 145, 145, + 145, 119, 114, 109, 145, 145, 68, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 145, 145, 145, 145, + + 124, 105, 145, 112, 28, 145, 137, 58, 113, 66, + 107, 145, 145, 145, 145, 145, 145, 0, 0, 0, + 0, 145, 145, 145, 108, 27, 145, 145, 145, 142, + 145, 145, 145, 145, 145, 145, 102, 53, 145, 54, + 145, 0, 0, 0, 7, 0, 145, 55, 21, 115, + 145, 145, 145, 110, 145, 145, 145, 145, 145, 145, + 103, 122, 111, 0, 0, 6, 0, 0, 0, 3, + 15, 116, 56, 139, 145, 144, 60, 61, 62, 145, + 0, 0, 0, 0, 145, 145, 145, 145, 145, 145, + 4, 0, 5, 0, 0, 0, 145, 145, 145, 145, + + 145, 63, 0, 145, 145, 145, 145, 145, 59, 145, + 134, 145, 135, 145, 145, 145, 64, 145, 65, 145, + 145, 145, 136, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -464,96 +464,96 @@ static yyconst flex_int32_t yy_ec[256] = static yyconst flex_int32_t yy_meta[60] = { 0, 1, 2, 3, 1, 1, 1, 1, 1, 1, 4, - 4, 5, 1, 6, 6, 6, 6, 6, 6, 7, - 1, 1, 1, 1, 8, 8, 8, 9, 10, 11, - 11, 11, 12, 1, 8, 8, 8, 8, 9, 10, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 12, 11, 11, 1 + 4, 1, 1, 5, 5, 5, 5, 5, 5, 6, + 1, 1, 1, 1, 7, 7, 7, 8, 8, 9, + 9, 9, 10, 1, 7, 7, 7, 7, 8, 8, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 10, 9, 9, 1 } ; -static yyconst flex_int16_t yy_base[543] = +static yyconst flex_int16_t yy_base[542] = { 0, 0, 58, 81, 0, 814, 815, 59, 815, 790, 789, - 54, 788, 55, 56, 54, 787, 129, 130, 53, 786, - 127, 0, 774, 101, 106, 126, 116, 128, 143, 759, - 144, 136, 132, 142, 147, 753, 154, 766, 157, 163, - 159, 176, 762, 149, 212, 191, 780, 815, 215, 815, - 789, 232, 815, 0, 219, 815, 815, 815, 815, 815, - 815, 815, 815, 815, 198, 815, 203, 200, 216, 224, - 0, 229, 778, 815, 815, 815, 777, 0, 815, 753, - 746, 749, 757, 756, 743, 746, 757, 744, 750, 738, - 735, 748, 735, 732, 732, 738, 726, 218, 731, 741, - - 727, 733, 736, 737, 0, 213, 736, 717, 216, 721, - 734, 725, 211, 718, 732, 729, 731, 714, 719, 716, - 705, 714, 224, 718, 714, 716, 705, 708, 221, 713, - 705, 717, 230, 710, 815, 815, 274, 267, 279, 815, - 696, 708, 700, 710, 275, 0, 269, 0, 280, 815, - 264, 284, 815, 282, 297, 0, 815, 815, 0, 698, - 702, 711, 708, 692, 691, 691, 258, 706, 703, 703, - 701, 698, 690, 696, 683, 694, 680, 696, 0, 693, - 681, 688, 685, 689, 682, 671, 670, 683, 686, 683, - 671, 677, 668, 297, 673, 676, 667, 674, 663, 667, - - 673, 664, 655, 658, 656, 666, 656, 651, 649, 649, - 651, 648, 659, 658, 271, 653, 648, 637, 313, 655, - 657, 646, 638, 642, 653, 637, 0, 324, 324, 312, - 815, 331, 344, 815, 643, 0, 641, 340, 0, 634, - 632, 630, 638, 627, 644, 633, 343, 0, 0, 627, - 637, 637, 0, 622, 349, 0, 0, 624, 352, 625, - 619, 618, 619, 618, 358, 614, 0, 0, 610, 609, - 608, 610, 611, 616, 610, 606, 619, 614, 613, 605, - 609, 601, 604, 599, 607, 612, 611, 602, 0, 0, - 608, 597, 597, 602, 601, 598, 0, 0, 0, 0, - - 588, 600, 599, 598, 595, 584, 363, 361, 598, 0, - 0, 0, 0, 585, 0, 0, 585, 586, 580, 590, - 0, 0, 0, 581, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 588, 0, 0, 586, 582, 0, - 0, 0, 572, 369, 375, 378, 577, 573, 578, 569, - 567, 580, 566, 579, 568, 575, 0, 573, 570, 574, - 558, 567, 573, 568, 556, 0, 558, 0, 557, 560, - 0, 555, 599, 554, 556, 545, 554, 543, 543, 556, - 0, 551, 0, 550, 546, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 531, 544, 531, 528, 0, - - 0, 532, 0, 0, 524, 0, 0, 0, 0, 0, - 512, 523, 512, 518, 512, 507, 500, 395, 515, 501, - 495, 508, 502, 0, 0, 492, 496, 475, 0, 475, - 470, 464, 450, 390, 441, 0, 0, 437, 0, 435, - 430, 386, 360, 815, 425, 432, 0, 0, 0, 431, - 417, 429, 0, 430, 419, 438, 437, 436, 409, 0, - 0, 0, 413, 415, 815, 418, 0, 396, 815, 0, - 0, 0, 0, 402, 0, 420, 371, 420, 414, 402, - 420, 422, 424, 405, 405, 407, 403, 389, 369, 815, - 428, 815, 441, 0, 436, 350, 365, 315, 301, 295, - - 0, 438, 288, 287, 268, 279, 253, 0, 191, 197, - 177, 0, 167, 159, 141, 0, 131, 0, 125, 32, - 11, 0, 815, 472, 476, 483, 490, 495, 501, 507, - 509, 519, 528, 532, 536, 542, 553, 559, 561, 570, - 581, 583 + 54, 788, 55, 56, 54, 787, 129, 174, 53, 786, + 127, 0, 774, 101, 106, 126, 116, 128, 152, 759, + 161, 158, 128, 142, 131, 753, 166, 766, 175, 181, + 131, 187, 762, 149, 205, 222, 780, 815, 230, 815, + 789, 225, 815, 0, 244, 815, 815, 815, 815, 815, + 815, 815, 815, 815, 223, 815, 225, 200, 265, 218, + 815, 0, 0, 778, 815, 815, 815, 777, 0, 815, + 753, 746, 749, 757, 756, 743, 746, 757, 744, 750, + 738, 735, 748, 735, 732, 732, 738, 726, 132, 731, + + 741, 727, 733, 736, 737, 0, 221, 736, 717, 200, + 721, 734, 725, 225, 718, 732, 729, 731, 714, 719, + 716, 705, 714, 222, 718, 714, 716, 705, 708, 207, + 713, 705, 717, 243, 710, 815, 815, 285, 257, 295, + 815, 696, 708, 700, 710, 288, 0, 298, 0, 226, + 815, 280, 289, 815, 307, 318, 0, 815, 815, 0, + 698, 702, 711, 708, 692, 691, 691, 279, 706, 703, + 703, 701, 698, 690, 696, 683, 694, 680, 696, 0, + 693, 681, 688, 685, 689, 682, 671, 670, 683, 686, + 683, 671, 677, 668, 319, 673, 676, 667, 674, 663, + + 667, 673, 664, 655, 658, 656, 666, 656, 651, 649, + 649, 651, 648, 659, 658, 255, 653, 648, 637, 325, + 655, 657, 646, 638, 642, 653, 637, 0, 336, 328, + 322, 815, 345, 356, 815, 643, 0, 641, 353, 0, + 634, 632, 630, 638, 627, 644, 633, 356, 0, 0, + 627, 637, 637, 0, 622, 359, 0, 0, 624, 362, + 625, 619, 618, 619, 618, 365, 614, 0, 0, 610, + 609, 608, 610, 611, 616, 610, 606, 619, 614, 613, + 605, 609, 601, 604, 599, 607, 612, 611, 602, 0, + 0, 608, 597, 597, 602, 601, 598, 0, 0, 0, + + 0, 588, 600, 599, 598, 595, 584, 372, 383, 598, + 0, 0, 0, 0, 585, 0, 0, 585, 586, 580, + 590, 0, 0, 0, 581, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 588, 0, 0, 586, 582, + 0, 0, 0, 572, 381, 384, 387, 577, 573, 578, + 569, 567, 580, 566, 579, 568, 575, 0, 573, 570, + 574, 558, 567, 573, 568, 556, 0, 558, 0, 557, + 560, 0, 555, 599, 554, 556, 545, 554, 543, 543, + 556, 0, 558, 0, 557, 556, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 541, 554, 541, 538, + + 0, 0, 543, 0, 0, 535, 0, 0, 0, 0, + 0, 532, 543, 536, 542, 539, 534, 527, 411, 542, + 522, 514, 527, 525, 0, 0, 518, 524, 505, 0, + 510, 504, 503, 493, 391, 501, 0, 0, 500, 0, + 480, 465, 407, 343, 815, 457, 449, 0, 0, 0, + 448, 434, 446, 0, 447, 436, 455, 454, 453, 426, + 0, 0, 0, 430, 418, 815, 431, 0, 412, 815, + 0, 0, 0, 0, 425, 0, 444, 387, 444, 438, + 426, 433, 435, 439, 422, 422, 423, 419, 421, 420, + 815, 441, 815, 453, 0, 449, 404, 422, 402, 389, + + 385, 0, 451, 377, 373, 343, 346, 296, 0, 262, + 275, 253, 0, 223, 207, 144, 0, 148, 0, 104, + 32, 11, 0, 815, 485, 491, 497, 501, 506, 508, + 516, 523, 526, 529, 534, 543, 548, 550, 557, 566, + 568 } ; -static yyconst flex_int16_t yy_def[543] = +static yyconst flex_int16_t yy_def[542] = { 0, - 523, 1, 523, 3, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 524, 523, 523, - 523, 525, 523, 525, 525, 525, 525, 525, 525, 525, + 524, 1, 524, 3, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 525, 524, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 526, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 527, 523, 528, 17, 529, 530, - 531, 524, 523, 523, 523, 523, 523, 525, 523, 525, + 525, 525, 525, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 526, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 527, 524, 528, 17, 524, 529, + 524, 530, 18, 524, 524, 524, 524, 524, 525, 524, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 532, 523, 526, 533, 523, - 528, 534, 523, 523, 530, 531, 523, 523, 525, 525, + 525, 525, 525, 525, 525, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 531, 524, 526, 532, + 524, 528, 533, 524, 524, 529, 530, 524, 524, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, @@ -561,8 +561,8 @@ static yyconst flex_int16_t yy_def[543] = 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 523, 523, 523, 523, 532, 523, 533, 535, - 523, 523, 534, 523, 525, 525, 525, 525, 525, 525, + 525, 525, 525, 524, 524, 524, 524, 531, 524, 532, + 534, 524, 524, 533, 524, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, @@ -570,33 +570,33 @@ static yyconst flex_int16_t yy_def[543] = 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 523, 523, 523, 523, 523, 535, 525, 525, + 525, 525, 525, 524, 524, 524, 524, 524, 534, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 523, 523, 523, 523, 525, 525, 525, 525, 525, + 525, 525, 524, 524, 524, 524, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 523, 523, 523, 523, + 525, 525, 525, 525, 525, 525, 525, 524, 524, 524, + 524, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 524, 535, 536, 524, 524, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 523, 536, 537, 523, 523, 525, 525, 525, 525, 525, + 525, 525, 525, 524, 537, 524, 524, 538, 536, 524, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 523, 538, 523, 523, 539, 537, 523, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 523, - 540, 541, 539, 525, 525, 525, 525, 525, 525, 523, - 523, 523, 523, 542, 541, 525, 525, 525, 525, 525, + 524, 539, 540, 538, 525, 525, 525, 525, 525, 525, + 524, 524, 524, 524, 541, 540, 525, 525, 525, 525, - 525, 542, 525, 525, 525, 525, 525, 525, 525, 525, + 525, 525, 541, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 0, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523 + 525, 525, 525, 0, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524 } ; static yyconst flex_int16_t yy_nxt[875] = @@ -607,8 +607,8 @@ static yyconst flex_int16_t yy_nxt[875] = 22, 22, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 22, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 22, 22, 22, 44, 45, - 55, 58, 55, 46, 61, 522, 63, 65, 65, 65, - 65, 65, 65, 65, 73, 74, 59, 62, 64, 521, + 55, 58, 55, 46, 61, 523, 63, 65, 65, 65, + 65, 65, 65, 65, 74, 75, 59, 62, 64, 522, 47, 48, 49, 50, 49, 48, 48, 48, 48, 48, 48, 48, 48, 51, 48, 52, 52, 52, 52, 52, @@ -616,87 +616,87 @@ static yyconst flex_int16_t yy_nxt[875] = 54, 54, 54, 54, 48, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 48, - 67, 67, 68, 68, 68, 68, 68, 68, 69, 76, - 77, 80, 81, 82, 89, 83, 70, 70, 90, 84, - 85, 71, 520, 91, 86, 519, 108, 70, 70, 92, - 87, 135, 93, 88, 94, 105, 110, 96, 102, 109, - 111, 112, 106, 95, 71, 97, 103, 98, 115, 107, - 99, 119, 139, 140, 113, 518, 100, 104, 120, 121, - - 517, 125, 122, 116, 126, 129, 117, 136, 123, 130, - 131, 124, 127, 137, 132, 55, 145, 138, 145, 128, - 55, 516, 55, 133, 515, 149, 150, 67, 514, 141, - 152, 153, 523, 154, 154, 142, 149, 150, 513, 143, - 67, 152, 153, 70, 144, 147, 147, 147, 147, 147, - 147, 147, 177, 197, 70, 523, 70, 185, 208, 198, - 186, 187, 192, 215, 188, 178, 189, 70, 139, 140, - 193, 216, 220, 209, 221, 137, 145, 55, 145, 138, - 139, 140, 147, 147, 147, 147, 147, 147, 147, 228, - 228, 230, 231, 232, 232, 155, 155, 155, 155, 155, - - 155, 155, 230, 231, 512, 141, 523, 523, 242, 243, - 292, 142, 269, 270, 271, 143, 511, 141, 293, 510, - 144, 307, 307, 142, 509, 234, 508, 143, 297, 298, - 299, 507, 144, 523, 523, 506, 234, 229, 229, 229, - 229, 229, 229, 229, 233, 233, 233, 233, 233, 233, - 233, 505, 150, 523, 523, 311, 312, 313, 321, 322, - 323, 464, 465, 150, 328, 329, 330, 332, 333, 334, - 523, 523, 153, 340, 341, 342, 308, 308, 308, 308, - 308, 308, 308, 153, 387, 388, 389, 464, 465, 231, - 390, 391, 392, 393, 394, 395, 418, 464, 465, 504, - - 231, 486, 487, 503, 456, 457, 458, 501, 442, 443, - 443, 443, 443, 443, 443, 459, 464, 465, 467, 464, - 465, 491, 492, 491, 492, 464, 465, 500, 481, 491, - 492, 466, 466, 466, 466, 466, 466, 491, 492, 491, - 492, 467, 491, 492, 499, 498, 497, 496, 490, 489, - 488, 485, 494, 484, 493, 493, 493, 493, 493, 493, - 480, 479, 478, 477, 476, 475, 474, 473, 472, 471, - 470, 469, 463, 462, 461, 494, 72, 72, 72, 460, - 72, 78, 78, 78, 78, 78, 78, 78, 148, 148, - 148, 148, 148, 148, 148, 65, 65, 455, 65, 65, - - 151, 151, 454, 151, 151, 69, 69, 69, 453, 69, - 155, 452, 155, 155, 156, 156, 156, 156, 156, 227, - 227, 451, 227, 227, 227, 227, 227, 227, 227, 227, - 227, 229, 450, 229, 229, 233, 449, 233, 233, 308, - 448, 308, 308, 466, 466, 447, 446, 466, 445, 444, - 441, 440, 439, 466, 468, 468, 438, 437, 468, 468, - 482, 482, 436, 435, 482, 482, 483, 483, 483, 483, - 483, 493, 493, 434, 433, 493, 432, 431, 430, 429, - 428, 493, 495, 495, 427, 426, 495, 495, 502, 502, - 502, 502, 502, 425, 424, 423, 422, 421, 420, 419, - - 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, - 408, 407, 406, 405, 404, 403, 402, 401, 400, 399, - 398, 397, 396, 386, 385, 384, 383, 382, 381, 380, - 379, 378, 377, 376, 375, 374, 373, 372, 371, 370, - 369, 368, 367, 366, 365, 364, 363, 362, 361, 360, - 359, 358, 357, 356, 355, 354, 353, 352, 351, 350, - 349, 348, 347, 346, 345, 344, 343, 339, 338, 337, - 336, 335, 331, 327, 326, 325, 324, 320, 319, 318, - 317, 316, 315, 314, 310, 309, 306, 305, 304, 303, - 302, 301, 300, 296, 295, 294, 291, 290, 289, 288, - - 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, - 277, 276, 275, 274, 273, 272, 268, 267, 266, 265, - 264, 263, 262, 261, 260, 259, 258, 257, 256, 255, - 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, - 244, 241, 240, 239, 238, 237, 236, 235, 226, 225, - 224, 223, 222, 219, 218, 217, 214, 213, 212, 211, - 210, 207, 206, 205, 204, 203, 202, 201, 200, 199, - 196, 195, 194, 191, 190, 184, 183, 182, 181, 180, - 179, 176, 175, 174, 173, 172, 171, 170, 169, 168, - 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, - - 157, 146, 75, 134, 118, 114, 101, 79, 75, 66, - 60, 57, 56, 523, 5, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523 + 67, 521, 68, 68, 68, 68, 68, 68, 69, 77, + 78, 81, 82, 83, 90, 84, 70, 71, 91, 85, + 86, 72, 109, 92, 87, 113, 178, 70, 71, 93, + 88, 136, 94, 89, 95, 110, 111, 130, 114, 179, + 112, 131, 520, 96, 72, 67, 97, 73, 73, 73, + 73, 73, 73, 73, 98, 103, 99, 106, 519, 100, + + 116, 70, 71, 104, 107, 101, 138, 137, 55, 120, + 139, 108, 70, 71, 105, 117, 121, 122, 118, 126, + 123, 132, 127, 140, 141, 133, 124, 155, 155, 125, + 128, 146, 524, 146, 134, 229, 229, 129, 148, 148, + 148, 148, 148, 148, 148, 55, 193, 55, 518, 216, + 150, 151, 153, 154, 194, 524, 209, 217, 140, 141, + 142, 150, 151, 153, 154, 186, 143, 198, 187, 188, + 144, 210, 189, 199, 190, 145, 67, 517, 69, 69, + 69, 69, 69, 69, 69, 221, 138, 222, 55, 146, + 139, 146, 70, 71, 293, 142, 140, 141, 233, 233, + + 516, 143, 294, 70, 71, 144, 515, 231, 232, 514, + 145, 148, 148, 148, 148, 148, 148, 148, 231, 232, + 156, 156, 156, 156, 156, 156, 156, 524, 524, 243, + 244, 308, 308, 142, 270, 271, 272, 524, 524, 143, + 298, 299, 300, 144, 465, 466, 235, 513, 145, 230, + 230, 230, 230, 230, 230, 230, 151, 235, 234, 234, + 234, 234, 234, 234, 234, 524, 524, 151, 312, 313, + 314, 322, 323, 324, 329, 330, 331, 333, 334, 335, + 341, 342, 343, 512, 154, 309, 309, 309, 309, 309, + 309, 309, 524, 524, 511, 154, 388, 389, 390, 391, + + 392, 393, 394, 395, 396, 457, 458, 459, 465, 466, + 510, 232, 419, 465, 466, 509, 460, 487, 488, 465, + 466, 508, 232, 507, 443, 444, 444, 444, 444, 444, + 444, 482, 465, 466, 492, 493, 492, 493, 506, 468, + 465, 466, 492, 493, 467, 467, 467, 467, 467, 467, + 492, 493, 492, 493, 492, 493, 505, 504, 502, 501, + 500, 499, 468, 498, 497, 495, 494, 494, 494, 494, + 494, 494, 491, 490, 489, 486, 485, 481, 480, 479, + 478, 477, 476, 475, 474, 473, 472, 471, 495, 79, + 79, 79, 79, 79, 79, 149, 149, 149, 149, 149, + + 149, 65, 65, 470, 65, 152, 152, 464, 152, 156, + 156, 156, 157, 157, 157, 157, 228, 228, 463, 228, + 228, 228, 228, 228, 228, 228, 230, 230, 230, 234, + 234, 234, 309, 309, 309, 467, 467, 462, 467, 461, + 456, 455, 454, 467, 469, 469, 453, 469, 469, 483, + 483, 452, 483, 483, 484, 484, 484, 484, 494, 494, + 451, 494, 450, 449, 448, 447, 494, 496, 496, 446, + 496, 496, 503, 503, 503, 503, 445, 442, 441, 440, + 439, 438, 437, 436, 435, 434, 433, 432, 431, 430, + 429, 428, 427, 426, 425, 424, 423, 422, 421, 420, + + 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, + 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, + 399, 398, 397, 387, 386, 385, 384, 383, 382, 381, + 380, 379, 378, 377, 376, 375, 374, 373, 372, 371, + 370, 369, 368, 367, 366, 365, 364, 363, 362, 361, + 360, 359, 358, 357, 356, 355, 354, 353, 352, 351, + 350, 349, 348, 347, 346, 345, 344, 340, 339, 338, + 337, 336, 332, 328, 327, 326, 325, 321, 320, 319, + 318, 317, 316, 315, 311, 310, 307, 306, 305, 304, + 303, 302, 301, 297, 296, 295, 292, 291, 290, 289, + + 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, + 278, 277, 276, 275, 274, 273, 269, 268, 267, 266, + 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, + 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, + 245, 242, 241, 240, 239, 238, 237, 236, 227, 226, + 225, 224, 223, 220, 219, 218, 215, 214, 213, 212, + 211, 208, 207, 206, 205, 204, 203, 202, 201, 200, + 197, 196, 195, 192, 191, 185, 184, 183, 182, 181, + 180, 177, 176, 175, 174, 173, 172, 171, 170, 169, + 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, + + 158, 147, 76, 135, 119, 115, 102, 80, 76, 66, + 60, 57, 56, 524, 5, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524 } ; static yyconst flex_int16_t yy_chk[875] = @@ -707,8 +707,8 @@ static yyconst flex_int16_t yy_chk[875] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 7, 11, 7, 2, 13, 521, 14, 15, 15, 15, - 15, 15, 15, 15, 19, 19, 11, 13, 14, 520, + 7, 11, 7, 2, 13, 522, 14, 15, 15, 15, + 15, 15, 15, 15, 19, 19, 11, 13, 14, 521, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -716,87 +716,87 @@ static yyconst flex_int16_t yy_chk[875] = 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 17, 18, 17, 17, 17, 17, 17, 17, 17, 21, - 21, 24, 24, 25, 27, 25, 17, 18, 27, 25, - 26, 17, 519, 27, 26, 517, 33, 17, 18, 27, - 26, 44, 28, 26, 28, 32, 34, 29, 31, 33, - 34, 35, 32, 28, 17, 29, 31, 29, 37, 32, - 29, 39, 46, 46, 35, 515, 29, 31, 39, 39, - - 514, 40, 39, 37, 40, 41, 37, 44, 39, 41, - 42, 39, 40, 45, 42, 45, 49, 45, 49, 40, - 55, 513, 55, 42, 511, 65, 65, 69, 510, 46, - 67, 67, 68, 70, 70, 46, 65, 65, 509, 46, - 72, 67, 67, 69, 46, 52, 52, 52, 52, 52, - 52, 52, 98, 113, 69, 68, 72, 106, 123, 113, - 106, 106, 109, 129, 106, 98, 106, 72, 138, 138, - 109, 129, 133, 123, 133, 137, 145, 137, 145, 137, - 139, 139, 147, 147, 147, 147, 147, 147, 147, 149, - 149, 151, 151, 152, 152, 154, 154, 154, 154, 154, - - 154, 154, 151, 151, 507, 138, 155, 155, 167, 167, - 215, 138, 194, 194, 194, 138, 506, 139, 215, 505, - 138, 230, 230, 139, 504, 155, 503, 139, 219, 219, - 219, 500, 139, 229, 229, 499, 155, 228, 228, 228, - 228, 228, 228, 228, 232, 232, 232, 232, 232, 232, - 232, 498, 229, 233, 233, 238, 238, 238, 247, 247, - 247, 443, 443, 229, 255, 255, 255, 259, 259, 259, - 308, 308, 233, 265, 265, 265, 307, 307, 307, 307, - 307, 307, 307, 233, 344, 344, 344, 442, 442, 308, - 345, 345, 345, 346, 346, 346, 418, 468, 468, 497, - - 308, 477, 477, 496, 434, 434, 434, 489, 418, 418, - 418, 418, 418, 418, 418, 434, 464, 464, 442, 466, - 466, 481, 481, 482, 482, 483, 483, 488, 464, 491, - 491, 466, 466, 466, 466, 466, 466, 495, 495, 502, - 502, 442, 493, 493, 487, 486, 485, 484, 480, 479, - 478, 476, 481, 474, 493, 493, 493, 493, 493, 493, - 463, 459, 458, 457, 456, 455, 454, 452, 451, 450, - 446, 445, 441, 440, 438, 481, 524, 524, 524, 435, - 524, 525, 525, 525, 525, 525, 525, 525, 526, 526, - 526, 526, 526, 526, 526, 527, 527, 433, 527, 527, - - 528, 528, 432, 528, 528, 529, 529, 529, 431, 529, - 530, 430, 530, 530, 531, 531, 531, 531, 531, 532, - 532, 428, 532, 532, 532, 532, 532, 532, 532, 532, - 532, 533, 427, 533, 533, 534, 426, 534, 534, 535, - 423, 535, 535, 536, 536, 422, 421, 536, 420, 419, - 417, 416, 415, 536, 537, 537, 414, 413, 537, 537, - 538, 538, 412, 411, 538, 538, 539, 539, 539, 539, - 539, 540, 540, 405, 402, 540, 399, 398, 397, 396, - 385, 540, 541, 541, 384, 382, 541, 541, 542, 542, - 542, 542, 542, 380, 379, 378, 377, 376, 375, 374, - - 373, 372, 370, 369, 367, 365, 364, 363, 362, 361, - 360, 359, 358, 356, 355, 354, 353, 352, 351, 350, - 349, 348, 347, 343, 339, 338, 335, 324, 320, 319, - 318, 317, 314, 309, 306, 305, 304, 303, 302, 301, - 296, 295, 294, 293, 292, 291, 288, 287, 286, 285, - 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, - 274, 273, 272, 271, 270, 269, 266, 264, 263, 262, - 261, 260, 258, 254, 252, 251, 250, 246, 245, 244, - 243, 242, 241, 240, 237, 235, 226, 225, 224, 223, - 222, 221, 220, 218, 217, 216, 214, 213, 212, 211, - - 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, - 200, 199, 198, 197, 196, 195, 193, 192, 191, 190, - 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, - 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, - 168, 166, 165, 164, 163, 162, 161, 160, 144, 143, - 142, 141, 134, 132, 131, 130, 128, 127, 126, 125, - 124, 122, 121, 120, 119, 118, 117, 116, 115, 114, - 112, 111, 110, 108, 107, 104, 103, 102, 101, 100, - 99, 97, 96, 95, 94, 93, 92, 91, 90, 89, - 88, 87, 86, 85, 84, 83, 82, 81, 80, 77, - - 73, 51, 47, 43, 38, 36, 30, 23, 20, 16, - 12, 10, 9, 5, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, - 523, 523, 523, 523 + 17, 520, 17, 17, 17, 17, 17, 17, 17, 21, + 21, 24, 24, 25, 27, 25, 17, 17, 27, 25, + 26, 17, 33, 27, 26, 35, 99, 17, 17, 27, + 26, 44, 28, 26, 28, 33, 34, 41, 35, 99, + 34, 41, 518, 28, 17, 18, 29, 18, 18, 18, + 18, 18, 18, 18, 29, 31, 29, 32, 516, 29, + + 37, 18, 18, 31, 32, 29, 45, 44, 45, 39, + 45, 32, 18, 18, 31, 37, 39, 39, 37, 40, + 39, 42, 40, 46, 46, 42, 39, 70, 70, 39, + 40, 49, 68, 49, 42, 150, 150, 40, 52, 52, + 52, 52, 52, 52, 52, 55, 110, 55, 515, 130, + 65, 65, 67, 67, 110, 68, 124, 130, 139, 139, + 46, 65, 65, 67, 67, 107, 46, 114, 107, 107, + 46, 124, 107, 114, 107, 46, 69, 514, 69, 69, + 69, 69, 69, 69, 69, 134, 138, 134, 138, 146, + 138, 146, 69, 69, 216, 139, 140, 140, 153, 153, + + 512, 139, 216, 69, 69, 139, 511, 152, 152, 510, + 139, 148, 148, 148, 148, 148, 148, 148, 152, 152, + 155, 155, 155, 155, 155, 155, 155, 156, 156, 168, + 168, 231, 231, 140, 195, 195, 195, 230, 230, 140, + 220, 220, 220, 140, 444, 444, 156, 508, 140, 229, + 229, 229, 229, 229, 229, 229, 230, 156, 233, 233, + 233, 233, 233, 233, 233, 234, 234, 230, 239, 239, + 239, 248, 248, 248, 256, 256, 256, 260, 260, 260, + 266, 266, 266, 507, 234, 308, 308, 308, 308, 308, + 308, 308, 309, 309, 506, 234, 345, 345, 345, 346, + + 346, 346, 347, 347, 347, 435, 435, 435, 443, 443, + 505, 309, 419, 469, 469, 504, 435, 478, 478, 465, + 465, 501, 309, 500, 419, 419, 419, 419, 419, 419, + 419, 465, 467, 467, 482, 482, 483, 483, 499, 443, + 484, 484, 492, 492, 467, 467, 467, 467, 467, 467, + 496, 496, 503, 503, 494, 494, 498, 497, 490, 489, + 488, 487, 443, 486, 485, 482, 494, 494, 494, 494, + 494, 494, 481, 480, 479, 477, 475, 464, 460, 459, + 458, 457, 456, 455, 453, 452, 451, 447, 482, 525, + 525, 525, 525, 525, 525, 526, 526, 526, 526, 526, + + 526, 527, 527, 446, 527, 528, 528, 442, 528, 529, + 529, 529, 530, 530, 530, 530, 531, 531, 441, 531, + 531, 531, 531, 531, 531, 531, 532, 532, 532, 533, + 533, 533, 534, 534, 534, 535, 535, 439, 535, 436, + 434, 433, 432, 535, 536, 536, 431, 536, 536, 537, + 537, 429, 537, 537, 538, 538, 538, 538, 539, 539, + 428, 539, 427, 424, 423, 422, 539, 540, 540, 421, + 540, 540, 541, 541, 541, 541, 420, 418, 417, 416, + 415, 414, 413, 412, 406, 403, 400, 399, 398, 397, + 386, 385, 383, 381, 380, 379, 378, 377, 376, 375, + + 374, 373, 371, 370, 368, 366, 365, 364, 363, 362, + 361, 360, 359, 357, 356, 355, 354, 353, 352, 351, + 350, 349, 348, 344, 340, 339, 336, 325, 321, 320, + 319, 318, 315, 310, 307, 306, 305, 304, 303, 302, + 297, 296, 295, 294, 293, 292, 289, 288, 287, 286, + 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, + 275, 274, 273, 272, 271, 270, 267, 265, 264, 263, + 262, 261, 259, 255, 253, 252, 251, 247, 246, 245, + 244, 243, 242, 241, 238, 236, 227, 226, 225, 224, + 223, 222, 221, 219, 218, 217, 215, 214, 213, 212, + + 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, + 201, 200, 199, 198, 197, 196, 194, 193, 192, 191, + 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, + 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, + 169, 167, 166, 165, 164, 163, 162, 161, 145, 144, + 143, 142, 135, 133, 132, 131, 129, 128, 127, 126, + 125, 123, 122, 121, 120, 119, 118, 117, 116, 115, + 113, 112, 111, 109, 108, 105, 104, 103, 102, 101, + 100, 98, 97, 96, 95, 94, 93, 92, 91, 90, + 89, 88, 87, 86, 85, 84, 83, 82, 81, 78, + + 74, 51, 47, 43, 38, 36, 30, 23, 20, 16, + 12, 10, 9, 5, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 524 } ; /* The intent behind this definition is that it'll catch @@ -1163,13 +1163,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 524 ) + if ( yy_current_state >= 525 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 523 ); + while ( yy_current_state != 524 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1735,260 +1735,268 @@ YY_RULE_SETUP YY_BREAK case 95: YY_RULE_SETUP -#line 240 "glsl_lexer.lpp" +#line 239 "glsl_lexer.lpp" { - yylval->n = 1; - return BOOLCONSTANT; + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; } YY_BREAK case 96: YY_RULE_SETUP #line 244 "glsl_lexer.lpp" +{ + yylval->n = 1; + return BOOLCONSTANT; + } + YY_BREAK +case 97: +YY_RULE_SETUP +#line 248 "glsl_lexer.lpp" { yylval->n = 0; return BOOLCONSTANT; } YY_BREAK /* Reserved words in GLSL 1.10. */ -case 97: +case 98: YY_RULE_SETUP -#line 251 "glsl_lexer.lpp" +#line 255 "glsl_lexer.lpp" return ASM; YY_BREAK -case 98: +case 99: YY_RULE_SETUP -#line 252 "glsl_lexer.lpp" +#line 256 "glsl_lexer.lpp" return CLASS; YY_BREAK -case 99: +case 100: YY_RULE_SETUP -#line 253 "glsl_lexer.lpp" +#line 257 "glsl_lexer.lpp" return UNION; YY_BREAK -case 100: +case 101: YY_RULE_SETUP -#line 254 "glsl_lexer.lpp" +#line 258 "glsl_lexer.lpp" return ENUM; YY_BREAK -case 101: +case 102: YY_RULE_SETUP -#line 255 "glsl_lexer.lpp" +#line 259 "glsl_lexer.lpp" return TYPEDEF; YY_BREAK -case 102: +case 103: YY_RULE_SETUP -#line 256 "glsl_lexer.lpp" +#line 260 "glsl_lexer.lpp" return TEMPLATE; YY_BREAK -case 103: +case 104: YY_RULE_SETUP -#line 257 "glsl_lexer.lpp" +#line 261 "glsl_lexer.lpp" return THIS; YY_BREAK -case 104: +case 105: YY_RULE_SETUP -#line 258 "glsl_lexer.lpp" +#line 262 "glsl_lexer.lpp" return PACKED; YY_BREAK -case 105: +case 106: YY_RULE_SETUP -#line 259 "glsl_lexer.lpp" +#line 263 "glsl_lexer.lpp" return GOTO; YY_BREAK -case 106: +case 107: YY_RULE_SETUP -#line 260 "glsl_lexer.lpp" +#line 264 "glsl_lexer.lpp" return SWITCH; YY_BREAK -case 107: +case 108: YY_RULE_SETUP -#line 261 "glsl_lexer.lpp" +#line 265 "glsl_lexer.lpp" return DEFAULT; YY_BREAK -case 108: +case 109: YY_RULE_SETUP -#line 262 "glsl_lexer.lpp" +#line 266 "glsl_lexer.lpp" return INLINE_TOK; YY_BREAK -case 109: +case 110: YY_RULE_SETUP -#line 263 "glsl_lexer.lpp" +#line 267 "glsl_lexer.lpp" return NOINLINE; YY_BREAK -case 110: +case 111: YY_RULE_SETUP -#line 264 "glsl_lexer.lpp" +#line 268 "glsl_lexer.lpp" return VOLATILE; YY_BREAK -case 111: +case 112: YY_RULE_SETUP -#line 265 "glsl_lexer.lpp" +#line 269 "glsl_lexer.lpp" return PUBLIC_TOK; YY_BREAK -case 112: +case 113: YY_RULE_SETUP -#line 266 "glsl_lexer.lpp" +#line 270 "glsl_lexer.lpp" return STATIC; YY_BREAK -case 113: +case 114: YY_RULE_SETUP -#line 267 "glsl_lexer.lpp" +#line 271 "glsl_lexer.lpp" return EXTERN; YY_BREAK -case 114: +case 115: YY_RULE_SETUP -#line 268 "glsl_lexer.lpp" +#line 272 "glsl_lexer.lpp" return EXTERNAL; YY_BREAK -case 115: +case 116: YY_RULE_SETUP -#line 269 "glsl_lexer.lpp" +#line 273 "glsl_lexer.lpp" return INTERFACE; YY_BREAK -case 116: +case 117: YY_RULE_SETUP -#line 270 "glsl_lexer.lpp" +#line 274 "glsl_lexer.lpp" return LONG; YY_BREAK -case 117: +case 118: YY_RULE_SETUP -#line 271 "glsl_lexer.lpp" +#line 275 "glsl_lexer.lpp" return SHORT; YY_BREAK -case 118: +case 119: YY_RULE_SETUP -#line 272 "glsl_lexer.lpp" +#line 276 "glsl_lexer.lpp" return DOUBLE; YY_BREAK -case 119: +case 120: YY_RULE_SETUP -#line 273 "glsl_lexer.lpp" +#line 277 "glsl_lexer.lpp" return HALF; YY_BREAK -case 120: +case 121: YY_RULE_SETUP -#line 274 "glsl_lexer.lpp" +#line 278 "glsl_lexer.lpp" return FIXED; YY_BREAK -case 121: +case 122: YY_RULE_SETUP -#line 275 "glsl_lexer.lpp" +#line 279 "glsl_lexer.lpp" return UNSIGNED; YY_BREAK -case 122: +case 123: YY_RULE_SETUP -#line 276 "glsl_lexer.lpp" +#line 280 "glsl_lexer.lpp" return INPUT; YY_BREAK -case 123: +case 124: YY_RULE_SETUP -#line 277 "glsl_lexer.lpp" +#line 281 "glsl_lexer.lpp" return OUTPUT; YY_BREAK -case 124: +case 125: YY_RULE_SETUP -#line 278 "glsl_lexer.lpp" +#line 282 "glsl_lexer.lpp" return HVEC2; YY_BREAK -case 125: +case 126: YY_RULE_SETUP -#line 279 "glsl_lexer.lpp" +#line 283 "glsl_lexer.lpp" return HVEC3; YY_BREAK -case 126: +case 127: YY_RULE_SETUP -#line 280 "glsl_lexer.lpp" +#line 284 "glsl_lexer.lpp" return HVEC4; YY_BREAK -case 127: +case 128: YY_RULE_SETUP -#line 281 "glsl_lexer.lpp" +#line 285 "glsl_lexer.lpp" return DVEC2; YY_BREAK -case 128: +case 129: YY_RULE_SETUP -#line 282 "glsl_lexer.lpp" +#line 286 "glsl_lexer.lpp" return DVEC3; YY_BREAK -case 129: +case 130: YY_RULE_SETUP -#line 283 "glsl_lexer.lpp" +#line 287 "glsl_lexer.lpp" return DVEC4; YY_BREAK -case 130: +case 131: YY_RULE_SETUP -#line 284 "glsl_lexer.lpp" +#line 288 "glsl_lexer.lpp" return FVEC2; YY_BREAK -case 131: +case 132: YY_RULE_SETUP -#line 285 "glsl_lexer.lpp" +#line 289 "glsl_lexer.lpp" return FVEC3; YY_BREAK -case 132: +case 133: YY_RULE_SETUP -#line 286 "glsl_lexer.lpp" +#line 290 "glsl_lexer.lpp" return FVEC4; YY_BREAK -case 133: +case 134: YY_RULE_SETUP -#line 287 "glsl_lexer.lpp" +#line 291 "glsl_lexer.lpp" return SAMPLER2DRECT; YY_BREAK -case 134: +case 135: YY_RULE_SETUP -#line 288 "glsl_lexer.lpp" +#line 292 "glsl_lexer.lpp" return SAMPLER3DRECT; YY_BREAK -case 135: +case 136: YY_RULE_SETUP -#line 289 "glsl_lexer.lpp" +#line 293 "glsl_lexer.lpp" return SAMPLER2DRECTSHADOW; YY_BREAK -case 136: +case 137: YY_RULE_SETUP -#line 290 "glsl_lexer.lpp" +#line 294 "glsl_lexer.lpp" return SIZEOF; YY_BREAK -case 137: +case 138: YY_RULE_SETUP -#line 291 "glsl_lexer.lpp" +#line 295 "glsl_lexer.lpp" return CAST; YY_BREAK -case 138: +case 139: YY_RULE_SETUP -#line 292 "glsl_lexer.lpp" +#line 296 "glsl_lexer.lpp" return NAMESPACE; YY_BREAK -case 139: +case 140: YY_RULE_SETUP -#line 293 "glsl_lexer.lpp" +#line 297 "glsl_lexer.lpp" return USING; YY_BREAK /* Additional reserved words in GLSL 1.20. */ -case 140: +case 141: YY_RULE_SETUP -#line 296 "glsl_lexer.lpp" +#line 300 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, LOWP); YY_BREAK -case 141: +case 142: YY_RULE_SETUP -#line 297 "glsl_lexer.lpp" +#line 301 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MEDIUMP); YY_BREAK -case 142: +case 143: YY_RULE_SETUP -#line 298 "glsl_lexer.lpp" +#line 302 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, HIGHP); YY_BREAK -case 143: +case 144: YY_RULE_SETUP -#line 299 "glsl_lexer.lpp" +#line 303 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, PRECISION); YY_BREAK -case 144: +case 145: YY_RULE_SETUP -#line 301 "glsl_lexer.lpp" +#line 305 "glsl_lexer.lpp" { struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; @@ -1996,17 +2004,17 @@ YY_RULE_SETUP return IDENTIFIER; } YY_BREAK -case 145: +case 146: YY_RULE_SETUP -#line 308 "glsl_lexer.lpp" +#line 312 "glsl_lexer.lpp" { return yytext[0]; } YY_BREAK -case 146: +case 147: YY_RULE_SETUP -#line 310 "glsl_lexer.lpp" +#line 314 "glsl_lexer.lpp" ECHO; YY_BREAK -#line 2010 "glsl_lexer.cpp" +#line 2018 "glsl_lexer.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(PP): yyterminate(); @@ -2303,7 +2311,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 524 ) + if ( yy_current_state >= 525 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -2332,11 +2340,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 524 ) + if ( yy_current_state >= 525 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 523); + yy_is_jam = (yy_current_state == 524); return yy_is_jam ? 0 : yy_current_state; } @@ -3148,7 +3156,7 @@ void _mesa_glsl_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 310 "glsl_lexer.lpp" +#line 314 "glsl_lexer.lpp" diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index 21c81a26635..9fd9b53c5c6 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -236,6 +236,10 @@ layout { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; } +[0-9]+[fF] { + yylval->real = strtod(yytext, NULL); + return FLOATCONSTANT; + } true { yylval->n = 1; -- cgit v1.2.3 From e75dbf66d011d76b6944dc4ee55e339ee285510c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 12:06:34 -0700 Subject: glsl2: Fix validation for ir_unop_not. We use vector ir_unop_not to implement builtin not(), and that seems fine. --- src/glsl/ir_validate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 85417a1dbc8..1dfac828269 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -171,8 +171,8 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->operands[0]->type == ir->type); break; case ir_unop_logic_not: - assert(ir->type == glsl_type::bool_type); - assert(ir->operands[0]->type == glsl_type::bool_type); + assert(ir->type->base_type == GLSL_TYPE_BOOL); + assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); break; case ir_unop_neg: -- cgit v1.2.3 From ee7666b5ac2fc7de64baf60835271e15baf89474 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 12:08:52 -0700 Subject: glsl2: Add validation that talloc ownership of ir_* names is right. --- src/glsl/ir_validate.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 1dfac828269..f9f781b36ab 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -139,7 +139,7 @@ ir_validate::visit_enter(ir_function *ir) ir_visitor_status ir_validate::visit_leave(ir_function *ir) { - (void) ir; + assert(talloc_parent(ir->name) == ir); this->current_function = NULL; return visit_continue; @@ -313,6 +313,8 @@ ir_validate::visit(ir_variable *ir) * in the ir_dereference_variable handler to ensure that a variable is * declared before it is dereferenced. */ + assert(talloc_parent(ir->name) == ir); + hash_table_insert(ht, ir, ir); return visit_continue; } -- cgit v1.2.3 From eb7e120f0f342541716882c211eca115c2cd0d21 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 12:28:38 -0700 Subject: glsl2: Fix expression type in builtin tan(). Fixes glsl-fs-tan-1. --- src/glsl/builtin_function.cpp | 6 +++--- src/glsl/builtins/110/tan | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index eade72ad3a5..a8acff47315 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -2097,17 +2097,17 @@ static const char *builtins_110_tan = { " (signature vec2\n" " (parameters\n" " (declare (in) vec2 angle))\n" - " ((return (expression float / (expression float sin (var_ref angle)) (expression vec2 cos (var_ref angle))))))\n" + " ((return (expression vec2 / (expression vec2 sin (var_ref angle)) (expression vec2 cos (var_ref angle))))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 angle))\n" - " ((return (expression float / (expression float sin (var_ref angle)) (expression vec3 cos (var_ref angle))))))\n" + " ((return (expression vec3 / (expression vec3 sin (var_ref angle)) (expression vec3 cos (var_ref angle))))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 angle))\n" - " ((return (expression float / (expression float sin (var_ref angle)) (expression vec4 cos (var_ref angle))))))\n" + " ((return (expression vec4 / (expression vec4 sin (var_ref angle)) (expression vec4 cos (var_ref angle))))))\n" "))\n" }; diff --git a/src/glsl/builtins/110/tan b/src/glsl/builtins/110/tan index 3e04892a76c..99798631859 100644 --- a/src/glsl/builtins/110/tan +++ b/src/glsl/builtins/110/tan @@ -7,15 +7,15 @@ (signature vec2 (parameters (declare (in) vec2 angle)) - ((return (expression float / (expression float sin (var_ref angle)) (expression vec2 cos (var_ref angle)))))) + ((return (expression vec2 / (expression vec2 sin (var_ref angle)) (expression vec2 cos (var_ref angle)))))) (signature vec3 (parameters (declare (in) vec3 angle)) - ((return (expression float / (expression float sin (var_ref angle)) (expression vec3 cos (var_ref angle)))))) + ((return (expression vec3 / (expression vec3 sin (var_ref angle)) (expression vec3 cos (var_ref angle)))))) (signature vec4 (parameters (declare (in) vec4 angle)) - ((return (expression float / (expression float sin (var_ref angle)) (expression vec4 cos (var_ref angle)))))) + ((return (expression vec4 / (expression vec4 sin (var_ref angle)) (expression vec4 cos (var_ref angle)))))) )) -- cgit v1.2.3 From cf41c8a0d8dac52bafb7c3e85171566c492786ab Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 2 Aug 2010 11:35:14 -0700 Subject: glsl2: Make glsl_types::ctx private again --- src/glsl/glsl_types.cpp | 4 ++-- src/glsl/glsl_types.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index ce47b8167f4..d8e291c8814 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -35,8 +35,8 @@ hash_table *glsl_type::array_types = NULL; hash_table *glsl_type::record_types = NULL; void *glsl_type::ctx = NULL; -static void -init_talloc_type_ctx(void) +void +glsl_type::init_talloc_type_ctx(void) { if (glsl_type::ctx == NULL) { glsl_type::ctx = talloc_init("glsl_type"); diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 4bec3181679..bae8cdb2332 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -388,6 +388,7 @@ struct glsl_type { return is_array() ? length : -1; } +private: /** * talloc context for all glsl_type allocations * @@ -395,7 +396,8 @@ struct glsl_type { */ static TALLOC_CTX *ctx; -private: + void init_talloc_type_ctx(void); + /** Constructor for vector and matrix types */ glsl_type(GLenum gl_type, unsigned base_type, unsigned vector_elements, -- cgit v1.2.3 From 7ffe40532f6b22d9b80caeac0fc3b9495619186a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 2 Aug 2010 11:46:22 -0700 Subject: glsl2: Clean-up two 'unused variable' warnings --- src/glsl/ir_validate.cpp | 2 ++ src/glsl/main.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index f9f781b36ab..712e1376fa1 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -336,6 +336,8 @@ ir_validate::validate_ir(ir_instruction *ir, void *data) void check_node_type(ir_instruction *ir, void *data) { + (void) data; + if (ir->ir_type <= ir_type_unset || ir->ir_type >= ir_type_max) { printf("Instruction node with unset type\n"); ir->print(); printf("\n"); diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index d557dcc4933..bc7292d155c 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -45,6 +45,9 @@ struct gl_shader * _mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type) { struct gl_shader *shader; + + (void) ctx; + assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER); shader = talloc_zero(NULL, struct gl_shader); if (shader) { -- cgit v1.2.3 From 955ceef47f2bb8b5005abf11d4a8580c71f19e1b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 2 Aug 2010 12:49:20 -0700 Subject: Keep a local copy of the symbol name in the symbol table The symbol_header structure that tracks symbols with a particular name may have a different (longer) life time than the symbols it tracks. Not keeping a local copy of the name can lead to use-after-free errors. For example, the following sequence would trigger such an error: char *copy = strdup(name); _mesa_symbol_table_push_scope(st); _mesa_symbol_table_add_symbol(st, 0, name, NULL); _mesa_symbol_table_pop_scope(st); free(name); _mesa_symbol_table_find_symbol(st, 0, copy); With this change, the symbol table keeps a local copy of the name that has the same life time as the symbol_header for that name. This resolves some use-after-free errors with built-in functions in the GLSL compiler. --- src/mesa/program/symbol_table.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mesa/program/symbol_table.c b/src/mesa/program/symbol_table.c index 3fea5ee1f1f..09e7cb44ef3 100644 --- a/src/mesa/program/symbol_table.c +++ b/src/mesa/program/symbol_table.c @@ -75,7 +75,7 @@ struct symbol_header { struct symbol_header *next; /** Symbol name. */ - const char *name; + char *name; /** Linked list of symbols with the same name. */ struct symbol *symbols; @@ -337,9 +337,9 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, if (hdr == NULL) { hdr = calloc(1, sizeof(*hdr)); - hdr->name = name; + hdr->name = strdup(name); - hash_table_insert(table->ht, hdr, name); + hash_table_insert(table->ht, hdr, hdr->name); hdr->next = table->hdr; table->hdr = hdr; } @@ -404,6 +404,7 @@ _mesa_symbol_table_dtor(struct _mesa_symbol_table *table) for (hdr = table->hdr; hdr != NULL; hdr = next) { next = hdr->next; + free(hdr->name); free(hdr); } -- cgit v1.2.3 From 42f3e7b6d7b42218feafe85a2328d8ce86fcce93 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 2 Aug 2010 13:41:04 -0700 Subject: glsl_type: Use string key for array type hash --- src/glsl/glsl_types.cpp | 49 ++++++++++++------------------------------------- src/glsl/glsl_types.h | 3 --- 2 files changed, 12 insertions(+), 40 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index d8e291c8814..40a5b6c4827 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -384,53 +384,28 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) } -int -glsl_type::array_key_compare(const void *a, const void *b) -{ - const glsl_type *const key1 = (glsl_type *) a; - const glsl_type *const key2 = (glsl_type *) b; - - /* Return zero is the types match (there is zero difference) or non-zero - * otherwise. - */ - return ((key1->fields.array == key2->fields.array) - && (key1->length == key2->length)) ? 0 : 1; -} - - -unsigned -glsl_type::array_key_hash(const void *a) -{ - const glsl_type *const key = (glsl_type *) a; - - const struct { - const glsl_type *t; - unsigned l; - char nul; - } hash_key = { - key->fields.array, - key->length, - '\0' - }; - - return hash_table_string_hash(& hash_key); -} - - const glsl_type * glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) { - const glsl_type key(base, array_size); if (array_types == NULL) { - array_types = hash_table_ctor(64, array_key_hash, array_key_compare); + array_types = hash_table_ctor(64, hash_table_string_hash, + hash_table_string_compare); } - const glsl_type *t = (glsl_type *) hash_table_find(array_types, & key); + /* Generate a name using the base type pointer in the key. This is + * done because the name of the base type may not be unique across + * shaders. For example, two shaders may have different record types + * named 'foo'. + */ + char key[128]; + snprintf(key, sizeof(key), "%p[%u]", base, array_size); + + const glsl_type *t = (glsl_type *) hash_table_find(array_types, key); if (t == NULL) { t = new glsl_type(base, array_size); - hash_table_insert(array_types, (void *) t, t); + hash_table_insert(array_types, (void *) t, talloc_strdup(ctx, key)); } assert(t->base_type == GLSL_TYPE_ARRAY); diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index bae8cdb2332..c3f81b82aa0 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -418,9 +418,6 @@ private: /** Hash table containing the known array types. */ static struct hash_table *array_types; - static int array_key_compare(const void *a, const void *b); - static unsigned array_key_hash(const void *key); - /** Hash table containing the known record types. */ static struct hash_table *record_types; -- cgit v1.2.3 From 1575070bfeedbc7decb7e44ac81abaeec0497a07 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 2 Aug 2010 17:27:56 -0700 Subject: glsl2: Use talloc_zero_size instead of talloc_size to allocate ast_node objects. This is a zero-ing function, (like calloc), to avoid bugs due to accessing uninitialized values. Thanks to valgrind for noticing the use of uninitialized values. --- src/glsl/ast.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index 1de285bb461..7ce879bb79d 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -42,7 +42,7 @@ public: { void *node; - node = talloc_size(ctx, size); + node = talloc_zero_size(ctx, size); assert(node != NULL); return node; -- cgit v1.2.3 From 9c02412cdc0270f2b0dc64afe709721e049fd5b0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 14:47:10 -0700 Subject: ir_to_mesa: Add a constructor for ir_to_mesa_src_reg. This helps makes sure we don't miss any new fields, and makes totally uninitialized src_regs be PROGRAM_UNDEFINED. --- src/mesa/program/ir_to_mesa.cpp | 82 +++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 48 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 8f790af09ac..5510440475d 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -53,11 +53,30 @@ extern "C" { #include "program/prog_parameter.h" } +static int swizzle_for_size(int size); + /** * This struct is a corresponding struct to Mesa prog_src_register, with * wider fields. */ typedef struct ir_to_mesa_src_reg { + ir_to_mesa_src_reg(int file, int index, const glsl_type *type) + { + this->file = file; + this->index = index; + if (type && (type->is_scalar() || type->is_vector() || type->is_matrix())) + this->swizzle = swizzle_for_size(type->vector_elements); + else + this->swizzle = SWIZZLE_XYZW; + this->negate = 0; + this->reladdr = NULL; + } + + ir_to_mesa_src_reg() + { + this->file = PROGRAM_UNDEFINED; + } + int file; /**< PROGRAM_* from Mesa */ int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ GLuint swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ @@ -242,9 +261,7 @@ public: void *mem_ctx; }; -ir_to_mesa_src_reg ir_to_mesa_undef = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, NEGATE_NONE, NULL, -}; +ir_to_mesa_src_reg ir_to_mesa_undef = ir_to_mesa_src_reg(PROGRAM_UNDEFINED, 0, NULL); ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, COND_TR, NULL, @@ -379,15 +396,7 @@ ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) inline ir_to_mesa_src_reg ir_to_mesa_src_reg_from_dst(ir_to_mesa_dst_reg reg) { - ir_to_mesa_src_reg src_reg; - - src_reg.file = reg.file; - src_reg.index = reg.index; - src_reg.swizzle = SWIZZLE_XYZW; - src_reg.negate = 0; - src_reg.reladdr = reg.reladdr; - - return src_reg; + return ir_to_mesa_src_reg(reg.file, reg.index, NULL); } /** @@ -460,13 +469,10 @@ ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir, struct ir_to_mesa_src_reg ir_to_mesa_visitor::src_reg_for_float(float val) { - ir_to_mesa_src_reg src_reg; + ir_to_mesa_src_reg src_reg(PROGRAM_CONSTANT, -1, NULL); - src_reg.file = PROGRAM_CONSTANT; src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, &val, 1, &src_reg.swizzle); - src_reg.reladdr = NULL; - src_reg.negate = 0; return src_reg; } @@ -1238,7 +1244,6 @@ get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var, void ir_to_mesa_visitor::visit(ir_dereference_variable *ir) { - ir_to_mesa_src_reg src_reg; variable_storage *entry = find_variable_storage(ir->var); unsigned int loc; int len; @@ -1340,17 +1345,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) } } - src_reg.file = entry->file; - src_reg.index = entry->index; - /* If the type is smaller than a vec4, replicate the last channel out. */ - if (ir->type->is_scalar() || ir->type->is_vector()) - src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); - else - src_reg.swizzle = SWIZZLE_NOOP; - src_reg.reladdr = NULL; - src_reg.negate = 0; - - this->result = src_reg; + this->result = ir_to_mesa_src_reg(entry->file, entry->index, ir->var->type); } void @@ -1367,17 +1362,13 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) if (deref_var && strncmp(deref_var->var->name, "gl_TextureMatrix", strlen("gl_TextureMatrix")) == 0) { - ir_to_mesa_src_reg src_reg; struct variable_storage *entry; entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, deref_var->var, ir->array_index); assert(entry); - src_reg.file = entry->file; - src_reg.index = entry->index; - src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); - src_reg.negate = 0; + ir_to_mesa_src_reg src_reg(entry->file, entry->index, ir->type); if (index) { src_reg.reladdr = NULL; @@ -1646,17 +1637,14 @@ ir_to_mesa_visitor::visit(ir_constant *ir) ir_to_mesa_dst_reg mat_column = ir_to_mesa_dst_reg_from_src(mat); for (i = 0; i < ir->type->matrix_columns; i++) { - src_reg.file = PROGRAM_CONSTANT; - assert(ir->type->base_type == GLSL_TYPE_FLOAT); values = &ir->value.f[i * ir->type->vector_elements]; + src_reg = ir_to_mesa_src_reg(PROGRAM_CONSTANT, -1, NULL); src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, - values, - ir->type->vector_elements, - &src_reg.swizzle); - src_reg.reladdr = NULL; - src_reg.negate = 0; + values, + ir->type->vector_elements, + &src_reg.swizzle); ir_to_mesa_emit_op1(ir, OPCODE_MOV, mat_column, src_reg); mat_column.index++; @@ -1689,13 +1677,11 @@ ir_to_mesa_visitor::visit(ir_constant *ir) assert(!"Non-float/uint/int/bool constant"); } - src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, - values, ir->type->vector_elements, - &src_reg.swizzle); - src_reg.reladdr = NULL; - src_reg.negate = 0; - - this->result = src_reg; + this->result = ir_to_mesa_src_reg(PROGRAM_CONSTANT, -1, ir->type); + this->result.index = _mesa_add_unnamed_constant(this->prog->Parameters, + values, + ir->type->vector_elements, + &this->result.swizzle); } function_entry * @@ -1825,7 +1811,7 @@ ir_to_mesa_visitor::visit(ir_call *ir) void ir_to_mesa_visitor::visit(ir_texture *ir) { - ir_to_mesa_src_reg result_src, coord, lod_info = { 0 }, projector; + ir_to_mesa_src_reg result_src, coord, lod_info, projector; ir_to_mesa_dst_reg result_dst, coord_dst; ir_to_mesa_instruction *inst = NULL; prog_opcode opcode = OPCODE_NOP; -- cgit v1.2.3 From 26675e37bc5a086c6df77946d2dada34dc9129f0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 14:32:52 -0700 Subject: ir_to_mesa: Support for struct uniforms. Fixes glsl-uniform-struct. --- src/mesa/program/ir_to_mesa.cpp | 78 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 5510440475d..7d5761f6996 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -252,6 +252,11 @@ public: GLboolean try_emit_mad(ir_expression *ir, int mul_operand); + void add_aggregate_uniform(ir_instruction *ir, + const char *name, + const struct glsl_type *type, + struct ir_to_mesa_dst_reg temp); + int *sampler_map; int sampler_map_size; @@ -1241,6 +1246,62 @@ get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var, return NULL; } +/* Recursively add all the members of the aggregate uniform as uniform names + * to Mesa, moving those uniforms to our structured temporary. + */ +void +ir_to_mesa_visitor::add_aggregate_uniform(ir_instruction *ir, + const char *name, + const struct glsl_type *type, + struct ir_to_mesa_dst_reg temp) +{ + int loc; + + if (type->is_record()) { + void *mem_ctx = talloc_new(NULL); + + for (unsigned int i = 0; i < type->length; i++) { + const glsl_type *field_type = type->fields.structure[i].type; + add_aggregate_uniform(ir, + talloc_asprintf(mem_ctx, "%s.%s", name, + type->fields.structure[i].name), + field_type, temp); + temp.index += type_size(field_type); + } + + talloc_free(mem_ctx); + + return; + } + + assert(type->is_vector() || type->is_scalar() || !"FINISHME: other types"); + + int len; + + if (type->is_vector() || + type->is_scalar()) { + len = type->vector_elements; + } else { + len = type_size(type) * 4; + } + + loc = _mesa_add_uniform(this->prog->Parameters, + name, + len, + type->gl_type, + NULL); + + + ir_to_mesa_src_reg uniform(PROGRAM_UNIFORM, loc, type); + + for (int i = 0; i < type_size(type); i++) { + ir_to_mesa_emit_op1(ir, OPCODE_MOV, temp, uniform); + temp.index++; + uniform.index++; + } +} + + void ir_to_mesa_visitor::visit(ir_dereference_variable *ir) { @@ -1276,6 +1337,23 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) assert(ir->var->type->gl_type != 0 && ir->var->type->gl_type != GL_INVALID_ENUM); + /* Oh, the joy of aggregate types in Mesa. Like constants, + * we can only really do vec4s. So, make a temp, chop the + * aggregate up into vec4s, and move those vec4s to the temp. + */ + if (ir->var->type->is_record()) { + ir_to_mesa_src_reg temp = get_temp(ir->var->type); + + entry = new(mem_ctx) variable_storage(ir->var, + temp.file, + temp.index); + this->variables.push_tail(entry); + + add_aggregate_uniform(ir->var, ir->var->name, ir->var->type, + ir_to_mesa_dst_reg_from_src(temp)); + break; + } + if (ir->var->type->is_vector() || ir->var->type->is_scalar()) { len = ir->var->type->vector_elements; -- cgit v1.2.3 From b10bb527eaf39378da25dd4ad21b1c68ceaa1e2d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 16:59:20 -0700 Subject: Initialize a couple of HasIndex2 fields on Mesa IR src regs. --- src/mesa/drivers/dri/i965/brw_wm_fp.c | 1 + src/mesa/program/ir_to_mesa.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c index 0bef874b887..df9e54c6b4e 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_fp.c +++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c @@ -88,6 +88,7 @@ static struct prog_src_register src_reg(GLuint file, GLuint idx) reg.RelAddr = 0; reg.Negate = NEGATE_NONE; reg.Abs = 0; + reg.HasIndex2 = 0; return reg; } diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 7d5761f6996..af306f05d8b 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2115,6 +2115,7 @@ mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) mesa_reg.RelAddr = reg.reladdr != NULL; mesa_reg.Negate = reg.negate; mesa_reg.Abs = 0; + mesa_reg.HasIndex2 = GL_FALSE; return mesa_reg; } -- cgit v1.2.3 From 5704ed27dd2ebc88639cbd32ac971939ef3c267a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 15:31:28 -0700 Subject: glsl2: Don't consider uniform initializers as constant expressions. We were happily optimizing away the body of glsl-uniform-initializer-* to never use the uniforms. --- src/glsl/ir_constant_expression.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index f02cd3127ee..915d362b152 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -674,6 +674,12 @@ ir_dereference_variable::constant_expression_value() if (!var) return NULL; + /* The constant_value of a uniform variable is its initializer, + * not the lifetime constant value of the uniform. + */ + if (var->mode == ir_var_uniform) + return NULL; + return var->constant_value ? var->constant_value->clone(NULL) : NULL; } -- cgit v1.2.3 From 47f305a4fcd23f859d097c6cc25a739547462939 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 17:05:48 -0700 Subject: ir_to_mesa: Add support for 1.20 uniform initializers. Fixes: glsl-uniform-initializer-1 glsl-uniform-initializer-2 glsl-uniform-initializer-3 glsl-uniform-initializer-4 glsl1-GLSL 1.20 uniform array constructor --- src/mesa/program/ir_to_mesa.cpp | 127 ++++++++++++++++++++++++++++++---------- 1 file changed, 97 insertions(+), 30 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index af306f05d8b..ba0934c446d 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -252,9 +252,13 @@ public: GLboolean try_emit_mad(ir_expression *ir, int mul_operand); + int add_uniform(const char *name, + const glsl_type *type, + ir_constant *constant); void add_aggregate_uniform(ir_instruction *ir, const char *name, const struct glsl_type *type, + ir_constant *constant, struct ir_to_mesa_dst_reg temp); int *sampler_map; @@ -1246,6 +1250,83 @@ get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var, return NULL; } +int +ir_to_mesa_visitor::add_uniform(const char *name, + const glsl_type *type, + ir_constant *constant) +{ + int len; + + if (type->is_vector() || + type->is_scalar()) { + len = type->vector_elements; + } else { + len = type_size(type) * 4; + } + + float *values = NULL; + if (constant && type->is_array()) { + values = (float *)malloc(type->length * 4 * sizeof(float)); + + assert(type->fields.array->is_scalar() || + type->fields.array->is_vector() || + !"FINISHME: uniform array initializers for non-vector"); + + for (unsigned int i = 0; i < type->length; i++) { + ir_constant *element = constant->array_elements[i]; + unsigned int c; + + for (c = 0; c < type->fields.array->vector_elements; c++) { + switch (type->fields.array->base_type) { + case GLSL_TYPE_FLOAT: + values[4 * i + c] = element->value.f[c]; + break; + case GLSL_TYPE_INT: + values[4 * i + c] = element->value.i[c]; + break; + case GLSL_TYPE_UINT: + values[4 * i + c] = element->value.u[c]; + break; + case GLSL_TYPE_BOOL: + values[4 * i + c] = element->value.b[c]; + break; + default: + assert(!"not reached"); + } + } + } + } else if (constant) { + values = (float *)malloc(16 * sizeof(float)); + for (unsigned int i = 0; i < type->components(); i++) { + switch (type->base_type) { + case GLSL_TYPE_FLOAT: + values[i] = constant->value.f[i]; + break; + case GLSL_TYPE_INT: + values[i] = constant->value.i[i]; + break; + case GLSL_TYPE_UINT: + values[i] = constant->value.u[i]; + break; + case GLSL_TYPE_BOOL: + values[i] = constant->value.b[i]; + break; + default: + assert(!"not reached"); + } + } + } + + int loc = _mesa_add_uniform(this->prog->Parameters, + name, + len, + type->gl_type, + values); + free(values); + + return loc; +} + /* Recursively add all the members of the aggregate uniform as uniform names * to Mesa, moving those uniforms to our structured temporary. */ @@ -1253,20 +1334,29 @@ void ir_to_mesa_visitor::add_aggregate_uniform(ir_instruction *ir, const char *name, const struct glsl_type *type, + ir_constant *constant, struct ir_to_mesa_dst_reg temp) { int loc; if (type->is_record()) { void *mem_ctx = talloc_new(NULL); + ir_constant *field_constant = NULL; + + if (constant) + field_constant = (ir_constant *)constant->components.get_head(); for (unsigned int i = 0; i < type->length; i++) { const glsl_type *field_type = type->fields.structure[i].type; + add_aggregate_uniform(ir, talloc_asprintf(mem_ctx, "%s.%s", name, type->fields.structure[i].name), - field_type, temp); + field_type, field_constant, temp); temp.index += type_size(field_type); + + if (constant) + field_constant = (ir_constant *)field_constant->next; } talloc_free(mem_ctx); @@ -1276,21 +1366,7 @@ ir_to_mesa_visitor::add_aggregate_uniform(ir_instruction *ir, assert(type->is_vector() || type->is_scalar() || !"FINISHME: other types"); - int len; - - if (type->is_vector() || - type->is_scalar()) { - len = type->vector_elements; - } else { - len = type_size(type) * 4; - } - - loc = _mesa_add_uniform(this->prog->Parameters, - name, - len, - type->gl_type, - NULL); - + loc = add_uniform(name, type, constant); ir_to_mesa_src_reg uniform(PROGRAM_UNIFORM, loc, type); @@ -1307,7 +1383,6 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) { variable_storage *entry = find_variable_storage(ir->var); unsigned int loc; - int len; if (!entry) { switch (ir->var->mode) { @@ -1350,22 +1425,14 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) this->variables.push_tail(entry); add_aggregate_uniform(ir->var, ir->var->name, ir->var->type, - ir_to_mesa_dst_reg_from_src(temp)); + ir->var->constant_value, + ir_to_mesa_dst_reg_from_src(temp)); break; } - if (ir->var->type->is_vector() || - ir->var->type->is_scalar()) { - len = ir->var->type->vector_elements; - } else { - len = type_size(ir->var->type) * 4; - } - - loc = _mesa_add_uniform(this->prog->Parameters, - ir->var->name, - len, - ir->var->type->gl_type, - NULL); + loc = add_uniform(ir->var->name, + ir->var->type, + ir->var->constant_value); /* Always mark the uniform used at this point. If it isn't * used, dead code elimination should have nuked the decl already. -- cgit v1.2.3 From c8babd5d9bba75c9f38f384f9cb3587e3543cc28 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 2 Aug 2010 17:49:01 -0700 Subject: glsl2: Fix typo in clamp() constant builtin using uint instead of int. I take back the bad things I've said about the signed/unsigned comparison warning now. --- src/glsl/ir_constant_expression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 915d362b152..06bea2bef6e 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -856,7 +856,7 @@ ir_call::constant_expression_value() break; case GLSL_TYPE_INT: data.i[c] = CLAMP(op[0]->value.i[c], op[1]->value.i[c1], - op[2]->value.u[c2]); + op[2]->value.i[c2]); break; case GLSL_TYPE_FLOAT: data.f[c] = CLAMP(op[0]->value.f[c], op[1]->value.f[c1], -- cgit v1.2.3 From 900ab2f564018856133c19b68713a6dfd206c184 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 3 Aug 2010 11:40:26 -0700 Subject: glsl2: No need to strdup the name passed in to ir_variable constructor. ir_variable always strdups the incoming name so that it matches the lifetime of the ir_variable. --- src/glsl/ast_function.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index bbc3bc1a596..661f8f61607 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -554,9 +554,7 @@ emit_inline_vector_constructor(const glsl_type *type, { assert(!parameters->is_empty()); - ir_variable *var = new(ctx) ir_variable(type, - talloc_strdup(ctx, "vec_ctor"), - ir_var_temporary); + ir_variable *var = new(ctx) ir_variable(type, "vec_ctor", ir_var_temporary); instructions->push_tail(var); /* There are two kinds of vector constructors. @@ -667,9 +665,7 @@ emit_inline_matrix_constructor(const glsl_type *type, { assert(!parameters->is_empty()); - ir_variable *var = new(ctx) ir_variable(type, - talloc_strdup(ctx, "mat_ctor"), - ir_var_temporary); + ir_variable *var = new(ctx) ir_variable(type, "mat_ctor", ir_var_temporary); instructions->push_tail(var); /* There are three kinds of matrix constructors. @@ -692,8 +688,7 @@ emit_inline_matrix_constructor(const glsl_type *type, * components with zero. */ ir_variable *rhs_var = - new(ctx) ir_variable(glsl_type::vec4_type, - talloc_strdup(ctx, "mat_ctor_vec"), + new(ctx) ir_variable(glsl_type::vec4_type, "mat_ctor_vec", ir_var_temporary); instructions->push_tail(rhs_var); @@ -807,8 +802,7 @@ emit_inline_matrix_constructor(const glsl_type *type, * generate a temporary and copy the paramter there. */ ir_variable *const rhs_var = - new(ctx) ir_variable(first_param->type, - talloc_strdup(ctx, "mat_ctor_mat"), + new(ctx) ir_variable(first_param->type, "mat_ctor_mat", ir_var_temporary); instructions->push_tail(rhs_var); @@ -874,9 +868,7 @@ emit_inline_matrix_constructor(const glsl_type *type, * generate a temporary and copy the paramter there. */ ir_variable *rhs_var = - new(ctx) ir_variable(rhs->type, - talloc_strdup(ctx, "mat_ctor_vec"), - ir_var_temporary); + new(ctx) ir_variable(rhs->type, "mat_ctor_vec", ir_var_temporary); instructions->push_tail(rhs_var); ir_dereference *rhs_var_ref = -- cgit v1.2.3 From c22dee721695402d9f2678c100d2fff5c0c3f21f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 3 Aug 2010 11:43:25 -0700 Subject: glsl2: Fix ir_validate validating null variable names. An unnamed variable in a prototype will have a NULL ->name, so don't worry about storage then. Fixes: CorrectFunction1.vert CorrectParse1.frag --- src/glsl/ir_validate.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 712e1376fa1..89bcd1c4811 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -313,7 +313,8 @@ ir_validate::visit(ir_variable *ir) * in the ir_dereference_variable handler to ensure that a variable is * declared before it is dereferenced. */ - assert(talloc_parent(ir->name) == ir); + if (ir->name) + assert(talloc_parent(ir->name) == ir); hash_table_insert(ht, ir, ir); return visit_continue; -- cgit v1.2.3 From 84ee01f40acf88185484df386b7715034e7685c9 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Wed, 4 Aug 2010 16:31:04 +0200 Subject: glsl2: Set ir_discard::ir_type when cloning it Fixes unset ir_type after inlining. --- src/glsl/ir.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index bee9f6a2de4..f88a243cc02 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -889,6 +889,7 @@ public: ir_discard(ir_rvalue *cond) { + this->ir_type = ir_type_discard; this->condition = cond; } -- cgit v1.2.3 From 8273bd46877e2ea2b8a02b87a11c68102d07e1f2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 12:34:56 -0700 Subject: glsl2: Make the clone() method take a talloc context. In most cases, we needed to be reparenting the cloned IR to a different context (for example, to the linked shader instead of the unlinked shader), or optimization before the reparent would cause memory usage of the original object to grow and grow. --- src/glsl/ast_to_hir.cpp | 10 +-- src/glsl/ir.h | 47 +++++----- src/glsl/ir_clone.cpp | 150 ++++++++++++++----------------- src/glsl/ir_constant_expression.cpp | 7 +- src/glsl/ir_function_inlining.cpp | 6 +- src/glsl/ir_import_prototypes.cpp | 2 +- src/glsl/ir_vec_index_to_cond_assign.cpp | 8 +- src/glsl/link_functions.cpp | 6 +- src/glsl/linker.cpp | 25 +++--- 9 files changed, 130 insertions(+), 131 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 3522f55aacd..b65a323a8d7 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -966,7 +966,7 @@ ast_expression::hir(exec_list *instructions, op[0], op[1]); result = do_assignment(instructions, state, - op[0]->clone(NULL), temp_rhs, + op[0]->clone(ctx, NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; error_emitted = (op[0]->type->is_error()); @@ -992,7 +992,7 @@ ast_expression::hir(exec_list *instructions, op[0], op[1]); result = do_assignment(instructions, state, - op[0]->clone(NULL), temp_rhs, + op[0]->clone(ctx, NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; error_emitted = type->is_error(); @@ -1113,7 +1113,7 @@ ast_expression::hir(exec_list *instructions, op[0], op[1]); result = do_assignment(instructions, state, - op[0]->clone(NULL), temp_rhs, + op[0]->clone(ctx, NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; error_emitted = op[0]->type->is_error(); @@ -1139,10 +1139,10 @@ ast_expression::hir(exec_list *instructions, /* Get a temporary of a copy of the lvalue before it's modified. * This may get thrown away later. */ - result = get_lvalue_copy(instructions, op[0]->clone(NULL)); + result = get_lvalue_copy(instructions, op[0]->clone(ctx, NULL)); (void)do_assignment(instructions, state, - op[0]->clone(NULL), temp_rhs, + op[0]->clone(ctx, NULL), temp_rhs, this->subexpressions[0]->get_location()); type = result->type; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index f88a243cc02..f964b36083a 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -76,7 +76,8 @@ public: virtual void accept(ir_visitor *) = 0; virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0; - virtual ir_instruction *clone(struct hash_table *ht) const = 0; + virtual ir_instruction *clone(void *mem_ctx, + struct hash_table *ht) const = 0; /** * \name IR instruction downcast functions @@ -113,7 +114,7 @@ protected: class ir_rvalue : public ir_instruction { public: - virtual ir_rvalue *clone(struct hash_table *) const = 0; + virtual ir_rvalue *clone(void *mem_ctx, struct hash_table *) const = 0; virtual ir_constant *constant_expression_value() = 0; @@ -175,7 +176,7 @@ class ir_variable : public ir_instruction { public: ir_variable(const struct glsl_type *, const char *, ir_variable_mode); - virtual ir_variable *clone(struct hash_table *ht) const; + virtual ir_variable *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_variable *as_variable() { @@ -283,7 +284,8 @@ class ir_function_signature : public ir_instruction { public: ir_function_signature(const glsl_type *return_type); - virtual ir_function_signature *clone(struct hash_table *ht) const; + virtual ir_function_signature *clone(void *mem_ctx, + struct hash_table *ht) const; virtual void accept(ir_visitor *v) { @@ -369,7 +371,7 @@ class ir_function : public ir_instruction { public: ir_function(const char *name); - virtual ir_function *clone(struct hash_table *ht) const; + virtual ir_function *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_function *as_function() { @@ -439,7 +441,7 @@ public: ir_type = ir_type_if; } - virtual ir_if *clone(struct hash_table *ht) const; + virtual ir_if *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_if *as_if() { @@ -471,7 +473,7 @@ public: ir_type = ir_type_loop; } - virtual ir_loop *clone(struct hash_table *ht) const; + virtual ir_loop *clone(void *mem_ctx, struct hash_table *ht) const; virtual void accept(ir_visitor *v) { @@ -512,7 +514,7 @@ class ir_assignment : public ir_instruction { public: ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); - virtual ir_assignment *clone(struct hash_table *ht) const; + virtual ir_assignment *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_constant *constant_expression_value(); @@ -662,7 +664,7 @@ public: return this; } - virtual ir_expression *clone(struct hash_table *ht) const; + virtual ir_expression *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_constant *constant_expression_value(); @@ -708,7 +710,7 @@ public: actual_parameters->move_nodes_to(& this->actual_parameters); } - virtual ir_call *clone(struct hash_table *ht) const; + virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_constant *constant_expression_value(); @@ -805,7 +807,7 @@ public: this->ir_type = ir_type_return; } - virtual ir_return *clone(struct hash_table *) const; + virtual ir_return *clone(void *mem_ctx, struct hash_table *) const; virtual ir_return *as_return() { @@ -850,7 +852,7 @@ public: this->loop = loop; } - virtual ir_loop_jump *clone(struct hash_table *) const; + virtual ir_loop_jump *clone(void *mem_ctx, struct hash_table *) const; virtual void accept(ir_visitor *v) { @@ -893,7 +895,7 @@ public: this->condition = cond; } - virtual ir_discard *clone(struct hash_table *ht) const; + virtual ir_discard *clone(void *mem_ctx, struct hash_table *ht) const; virtual void accept(ir_visitor *v) { @@ -945,7 +947,7 @@ public: this->ir_type = ir_type_texture; } - virtual ir_texture *clone(struct hash_table *) const; + virtual ir_texture *clone(void *mem_ctx, struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1037,7 +1039,7 @@ public: ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask); - virtual ir_swizzle *clone(struct hash_table *) const; + virtual ir_swizzle *clone(void *mem_ctx, struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1083,7 +1085,7 @@ private: class ir_dereference : public ir_rvalue { public: - virtual ir_dereference *clone(struct hash_table *) const = 0; + virtual ir_dereference *clone(void *mem_ctx, struct hash_table *) const = 0; virtual ir_dereference *as_dereference() { @@ -1103,7 +1105,8 @@ class ir_dereference_variable : public ir_dereference { public: ir_dereference_variable(ir_variable *var); - virtual ir_dereference_variable *clone(struct hash_table *) const; + virtual ir_dereference_variable *clone(void *mem_ctx, + struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1151,7 +1154,8 @@ public: ir_dereference_array(ir_variable *var, ir_rvalue *array_index); - virtual ir_dereference_array *clone(struct hash_table *) const; + virtual ir_dereference_array *clone(void *mem_ctx, + struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1189,7 +1193,8 @@ public: ir_dereference_record(ir_variable *var, const char *field); - virtual ir_dereference_record *clone(struct hash_table *) const; + virtual ir_dereference_record *clone(void *mem_ctx, + struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1254,7 +1259,7 @@ public: */ static ir_constant *zero(void *mem_ctx, const glsl_type *type); - virtual ir_constant *clone(struct hash_table *) const; + virtual ir_constant *clone(void *mem_ctx, struct hash_table *) const; virtual ir_constant *constant_expression_value(); @@ -1327,7 +1332,7 @@ void validate_ir_tree(exec_list *instructions); * \param out List to hold the cloned instructions */ void -clone_ir_list(exec_list *out, const exec_list *in); +clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in); extern void _mesa_glsl_initialize_variables(exec_list *instructions, diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 5ea3a79afcd..59831834bd7 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -36,11 +36,10 @@ extern "C" { * eventually. */ ir_variable * -ir_variable::clone(struct hash_table *ht) const +ir_variable::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); - ir_variable *var = new(ctx) ir_variable(this->type, this->name, - (ir_variable_mode) this->mode); + ir_variable *var = new(mem_ctx) ir_variable(this->type, this->name, + (ir_variable_mode) this->mode); var->max_array_access = this->max_array_access; var->read_only = this->read_only; @@ -56,7 +55,7 @@ ir_variable::clone(struct hash_table *ht) const var->pixel_center_integer = this->pixel_center_integer; if (this->constant_value) - var->constant_value = this->constant_value->clone(ht); + var->constant_value = this->constant_value->clone(mem_ctx, ht); if (ht) { hash_table_insert(ht, var, (void *)const_cast(this)); @@ -66,118 +65,109 @@ ir_variable::clone(struct hash_table *ht) const } ir_swizzle * -ir_swizzle::clone(struct hash_table *ht) const +ir_swizzle::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); - return new(ctx) ir_swizzle(this->val->clone(ht), this->mask); + return new(mem_ctx) ir_swizzle(this->val->clone(mem_ctx, ht), this->mask); } ir_return * -ir_return::clone(struct hash_table *ht) const +ir_return::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); ir_rvalue *new_value = NULL; if (this->value) - new_value = this->value->clone(ht); + new_value = this->value->clone(mem_ctx, ht); - return new(ctx) ir_return(new_value); + return new(mem_ctx) ir_return(new_value); } ir_discard * -ir_discard::clone(struct hash_table *ht) const +ir_discard::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); ir_rvalue *new_condition = NULL; if (this->condition != NULL) - new_condition = this->condition->clone(ht); + new_condition = this->condition->clone(mem_ctx, ht); - return new(ctx) ir_discard(new_condition); + return new(mem_ctx) ir_discard(new_condition); } ir_loop_jump * -ir_loop_jump::clone(struct hash_table *ht) const +ir_loop_jump::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); (void)ht; - return new(ctx) ir_loop_jump(this->mode); + return new(mem_ctx) ir_loop_jump(this->mode); } ir_if * -ir_if::clone(struct hash_table *ht) const +ir_if::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); - ir_if *new_if = new(ctx) ir_if(this->condition->clone(ht)); + ir_if *new_if = new(mem_ctx) ir_if(this->condition->clone(mem_ctx, ht)); foreach_iter(exec_list_iterator, iter, this->then_instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); - new_if->then_instructions.push_tail(ir->clone(ht)); + new_if->then_instructions.push_tail(ir->clone(mem_ctx, ht)); } foreach_iter(exec_list_iterator, iter, this->else_instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); - new_if->else_instructions.push_tail(ir->clone(ht)); + new_if->else_instructions.push_tail(ir->clone(mem_ctx, ht)); } return new_if; } ir_loop * -ir_loop::clone(struct hash_table *ht) const +ir_loop::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); - ir_loop *new_loop = new(ctx) ir_loop(); + ir_loop *new_loop = new(mem_ctx) ir_loop(); if (this->from) - new_loop->from = this->from->clone(ht); + new_loop->from = this->from->clone(mem_ctx, ht); if (this->to) - new_loop->to = this->to->clone(ht); + new_loop->to = this->to->clone(mem_ctx, ht); if (this->increment) - new_loop->increment = this->increment->clone(ht); + new_loop->increment = this->increment->clone(mem_ctx, ht); new_loop->counter = counter; foreach_iter(exec_list_iterator, iter, this->body_instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); - new_loop->body_instructions.push_tail(ir->clone(ht)); + new_loop->body_instructions.push_tail(ir->clone(mem_ctx, ht)); } return new_loop; } ir_call * -ir_call::clone(struct hash_table *ht) const +ir_call::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); exec_list new_parameters; foreach_iter(exec_list_iterator, iter, this->actual_parameters) { ir_instruction *ir = (ir_instruction *)iter.get(); - new_parameters.push_tail(ir->clone(ht)); + new_parameters.push_tail(ir->clone(mem_ctx, ht)); } - return new(ctx) ir_call(this->callee, &new_parameters); + return new(mem_ctx) ir_call(this->callee, &new_parameters); } ir_expression * -ir_expression::clone(struct hash_table *ht) const +ir_expression::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); ir_rvalue *op[2] = {NULL, NULL}; unsigned int i; for (i = 0; i < get_num_operands(); i++) { - op[i] = this->operands[i]->clone(ht); + op[i] = this->operands[i]->clone(mem_ctx, ht); } - return new(ctx) ir_expression(this->operation, this->type, op[0], op[1]); + return new(mem_ctx) ir_expression(this->operation, this->type, op[0], op[1]); } ir_dereference_variable * -ir_dereference_variable::clone(struct hash_table *ht) const +ir_dereference_variable::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); ir_variable *new_var; if (ht) { @@ -188,38 +178,36 @@ ir_dereference_variable::clone(struct hash_table *ht) const new_var = this->var; } - return new(ctx) ir_dereference_variable(new_var); + return new(mem_ctx) ir_dereference_variable(new_var); } ir_dereference_array * -ir_dereference_array::clone(struct hash_table *ht) const +ir_dereference_array::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); - return new(ctx) ir_dereference_array(this->array->clone(ht), - this->array_index->clone(ht)); + return new(mem_ctx) ir_dereference_array(this->array->clone(mem_ctx, ht), + this->array_index->clone(mem_ctx, + ht)); } ir_dereference_record * -ir_dereference_record::clone(struct hash_table *ht) const +ir_dereference_record::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); - return new(ctx) ir_dereference_record(this->record->clone(ht), - this->field); + return new(mem_ctx) ir_dereference_record(this->record->clone(mem_ctx, ht), + this->field); } ir_texture * -ir_texture::clone(struct hash_table *ht) const +ir_texture::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); - ir_texture *new_tex = new(ctx) ir_texture(this->op); + ir_texture *new_tex = new(mem_ctx) ir_texture(this->op); new_tex->type = this->type; - new_tex->sampler = this->sampler->clone(ht); - new_tex->coordinate = this->coordinate->clone(ht); + new_tex->sampler = this->sampler->clone(mem_ctx, ht); + new_tex->coordinate = this->coordinate->clone(mem_ctx, ht); if (this->projector) - new_tex->projector = this->projector->clone(ht); + new_tex->projector = this->projector->clone(mem_ctx, ht); if (this->shadow_comparitor) { - new_tex->shadow_comparitor = this->shadow_comparitor->clone(ht); + new_tex->shadow_comparitor = this->shadow_comparitor->clone(mem_ctx, ht); } for (int i = 0; i < 3; i++) @@ -229,15 +217,15 @@ ir_texture::clone(struct hash_table *ht) const case ir_tex: break; case ir_txb: - new_tex->lod_info.bias = this->lod_info.bias->clone(ht); + new_tex->lod_info.bias = this->lod_info.bias->clone(mem_ctx, ht); break; case ir_txl: case ir_txf: - new_tex->lod_info.lod = this->lod_info.lod->clone(ht); + new_tex->lod_info.lod = this->lod_info.lod->clone(mem_ctx, ht); break; case ir_txd: - new_tex->lod_info.grad.dPdx = this->lod_info.grad.dPdx->clone(ht); - new_tex->lod_info.grad.dPdy = this->lod_info.grad.dPdy->clone(ht); + new_tex->lod_info.grad.dPdx = this->lod_info.grad.dPdx->clone(mem_ctx, ht); + new_tex->lod_info.grad.dPdy = this->lod_info.grad.dPdy->clone(mem_ctx, ht); break; } @@ -245,30 +233,28 @@ ir_texture::clone(struct hash_table *ht) const } ir_assignment * -ir_assignment::clone(struct hash_table *ht) const +ir_assignment::clone(void *mem_ctx, struct hash_table *ht) const { ir_rvalue *new_condition = NULL; if (this->condition) - new_condition = this->condition->clone(ht); + new_condition = this->condition->clone(mem_ctx, ht); - void *ctx = talloc_parent(this); - return new(ctx) ir_assignment(this->lhs->clone(ht), - this->rhs->clone(ht), - new_condition); + return new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht), + this->rhs->clone(mem_ctx, ht), + new_condition); } ir_function * -ir_function::clone(struct hash_table *ht) const +ir_function::clone(void *mem_ctx, struct hash_table *ht) const { - void *mem_ctx = talloc_parent(this); ir_function *copy = new(mem_ctx) ir_function(this->name); foreach_list_const(node, &this->signatures) { const ir_function_signature *const sig = (const ir_function_signature *const) node; - ir_function_signature *sig_copy = sig->clone(ht); + ir_function_signature *sig_copy = sig->clone(mem_ctx, ht); copy->add_signature(sig_copy); if (ht != NULL) @@ -280,9 +266,8 @@ ir_function::clone(struct hash_table *ht) const } ir_function_signature * -ir_function_signature::clone(struct hash_table *ht) const +ir_function_signature::clone(void *mem_ctx, struct hash_table *ht) const { - void *mem_ctx = talloc_parent(this); ir_function_signature *copy = new(mem_ctx) ir_function_signature(this->return_type); @@ -296,7 +281,7 @@ ir_function_signature::clone(struct hash_table *ht) const assert(const_cast(param)->as_variable() != NULL); - ir_variable *const param_copy = param->clone(ht); + ir_variable *const param_copy = param->clone(mem_ctx, ht); copy->parameters.push_tail(param_copy); } @@ -305,7 +290,7 @@ ir_function_signature::clone(struct hash_table *ht) const foreach_list_const(node, &this->body) { const ir_instruction *const inst = (const ir_instruction *) node; - ir_instruction *const inst_copy = inst->clone(ht); + ir_instruction *const inst_copy = inst->clone(mem_ctx, ht); copy->body.push_tail(inst_copy); } @@ -313,9 +298,8 @@ ir_function_signature::clone(struct hash_table *ht) const } ir_constant * -ir_constant::clone(struct hash_table *ht) const +ir_constant::clone(void *mem_ctx, struct hash_table *ht) const { - void *ctx = talloc_parent(this); (void)ht; switch (this->type->base_type) { @@ -323,10 +307,10 @@ ir_constant::clone(struct hash_table *ht) const case GLSL_TYPE_INT: case GLSL_TYPE_FLOAT: case GLSL_TYPE_BOOL: - return new(ctx) ir_constant(this->type, &this->value); + return new(mem_ctx) ir_constant(this->type, &this->value); case GLSL_TYPE_STRUCT: { - ir_constant *c = new(ctx) ir_constant; + ir_constant *c = new(mem_ctx) ir_constant; c->type = this->type; for (exec_node *node = this->components.head @@ -334,19 +318,19 @@ ir_constant::clone(struct hash_table *ht) const ; node = node->next) { ir_constant *const orig = (ir_constant *) node; - c->components.push_tail(orig->clone(NULL)); + c->components.push_tail(orig->clone(mem_ctx, NULL)); } return c; } case GLSL_TYPE_ARRAY: { - ir_constant *c = new(ctx) ir_constant; + ir_constant *c = new(mem_ctx) ir_constant; c->type = this->type; c->array_elements = talloc_array(c, ir_constant *, this->type->length); for (unsigned i = 0; i < this->type->length; i++) { - c->array_elements[i] = this->array_elements[i]->clone(NULL); + c->array_elements[i] = this->array_elements[i]->clone(mem_ctx, NULL); } return c; } @@ -395,14 +379,14 @@ fixup_function_calls(struct hash_table *ht, exec_list *instructions) void -clone_ir_list(exec_list *out, const exec_list *in) +clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in) { struct hash_table *ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); foreach_list_const(node, in) { const ir_instruction *const original = (ir_instruction *) node; - ir_instruction *copy = original->clone(ht); + ir_instruction *copy = original->clone(mem_ctx, ht); out->push_tail(copy); } diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 06bea2bef6e..677353e5424 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -680,7 +680,10 @@ ir_dereference_variable::constant_expression_value() if (var->mode == ir_var_uniform) return NULL; - return var->constant_value ? var->constant_value->clone(NULL) : NULL; + if (!var->constant_value) + return NULL; + + return var->constant_value->clone(talloc_parent(var), NULL); } @@ -732,7 +735,7 @@ ir_dereference_array::constant_expression_value() return new(ctx) ir_constant(array, component); } else { const unsigned index = idx->value.u[0]; - return array->get_array_element(index)->clone(NULL); + return array->get_array_element(index)->clone(ctx, NULL); } } return NULL; diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 95993062435..973813774e2 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -147,7 +147,7 @@ ir_call::generate_inline(ir_instruction *next_ir) parameters[i] = NULL; hash_table_insert(ht, param->variable_referenced(), sig_param); } else { - parameters[i] = sig_param->clone(ht); + parameters[i] = sig_param->clone(ctx, ht); parameters[i]->mode = ir_var_auto; next_ir->insert_before(parameters[i]); } @@ -169,7 +169,7 @@ ir_call::generate_inline(ir_instruction *next_ir) /* Generate the inlined body of the function. */ foreach_iter(exec_list_iterator, iter, callee->body) { ir_instruction *ir = (ir_instruction *)iter.get(); - ir_instruction *new_ir = ir->clone(ht); + ir_instruction *new_ir = ir->clone(ctx, ht); next_ir->insert_before(new_ir); visit_tree(new_ir, replace_return_with_assignment, retval); @@ -190,7 +190,7 @@ ir_call::generate_inline(ir_instruction *next_ir) sig_param->mode == ir_var_inout)) { ir_assignment *assign; - assign = new(ctx) ir_assignment(param->clone(NULL)->as_rvalue(), + assign = new(ctx) ir_assignment(param->clone(ctx, NULL)->as_rvalue(), new(ctx) ir_dereference_variable(parameters[i]), NULL); next_ir->insert_before(assign); diff --git a/src/glsl/ir_import_prototypes.cpp b/src/glsl/ir_import_prototypes.cpp index 5c5dc00ad71..e553e12a491 100644 --- a/src/glsl/ir_import_prototypes.cpp +++ b/src/glsl/ir_import_prototypes.cpp @@ -95,7 +95,7 @@ public: assert(const_cast(param)->as_variable() != NULL); - ir_variable *const param_copy = param->clone(NULL); + ir_variable *const param_copy = param->clone(mem_ctx, NULL); copy->parameters.push_tail(param_copy); } diff --git a/src/glsl/ir_vec_index_to_cond_assign.cpp b/src/glsl/ir_vec_index_to_cond_assign.cpp index dbc6f9ada89..cd8dedf2fe1 100644 --- a/src/glsl/ir_vec_index_to_cond_assign.cpp +++ b/src/glsl/ir_vec_index_to_cond_assign.cpp @@ -82,6 +82,8 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue orig_deref->array->type->is_array()) return ir; + void *mem_ctx = talloc_parent(ir); + assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); /* Store the index to a temporary to avoid reusing its tree. */ @@ -109,7 +111,7 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue /* Just clone the rest of the deref chain when trying to get at the * underlying variable. */ - swizzle = new(base_ir) ir_swizzle(orig_deref->array->clone(NULL), + swizzle = new(base_ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL), i, 0, 0, 0, 1); deref = new(base_ir) ir_dereference_variable(var); @@ -165,6 +167,8 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) orig_deref->array->type->is_array()) return visit_continue; + void *mem_ctx = talloc_parent(ir); + assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); /* Store the index to a temporary to avoid reusing its tree. */ @@ -196,7 +200,7 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) /* Just clone the rest of the deref chain when trying to get at the * underlying variable. */ - swizzle = new(ir) ir_swizzle(orig_deref->array->clone(NULL), + swizzle = new(ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL), i, 0, 0, 0, 1); deref = new(ir) ir_dereference_variable(var); diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp index fdf886f6627..dfda05fcbe5 100644 --- a/src/glsl/link_functions.cpp +++ b/src/glsl/link_functions.cpp @@ -143,7 +143,7 @@ public: const ir_instruction *const original = (ir_instruction *) node; assert(const_cast(original)->as_variable()); - ir_instruction *copy = original->clone(ht); + ir_instruction *copy = original->clone(linked, ht); formal_parameters.push_tail(copy); } @@ -152,7 +152,7 @@ public: foreach_list_const(node, &sig->body) { const ir_instruction *const original = (ir_instruction *) node; - ir_instruction *copy = original->clone(ht); + ir_instruction *copy = original->clone(linked, ht); linked_sig->body.push_tail(copy); } @@ -182,7 +182,7 @@ public: /* Clone the ir_variable that the dereference already has and add * it to the linked shader. */ - var = ir->var->clone(NULL); + var = ir->var->clone(linked, NULL); linked->symbols->add_variable(var->name, var); linked->ir->push_head(var); } diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index a5faff2be75..65f3697d354 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -323,7 +323,8 @@ cross_validate_globals(struct gl_shader_program *prog, * FINISHME: modify the shader, and linking with the second * FINISHME: will fail. */ - existing->constant_value = var->constant_value->clone(NULL); + existing->constant_value = + var->constant_value->clone(talloc_parent(existing), NULL); } } else variables.add_variable(var->name, var); @@ -488,16 +489,17 @@ populate_symbol_table(gl_shader *sh) * should be added. */ void -remap_variables(ir_instruction *inst, glsl_symbol_table *symbols, - exec_list *instructions, hash_table *temps) +remap_variables(ir_instruction *inst, struct gl_shader *target, + hash_table *temps) { class remap_visitor : public ir_hierarchical_visitor { public: - remap_visitor(glsl_symbol_table *symbols, exec_list *instructions, + remap_visitor(struct gl_shader *target, hash_table *temps) { - this->symbols = symbols; - this->instructions = instructions; + this->target = target; + this->symbols = target->symbols; + this->instructions = target->ir; this->temps = temps; } @@ -516,7 +518,7 @@ remap_variables(ir_instruction *inst, glsl_symbol_table *symbols, if (existing != NULL) ir->var = existing; else { - ir_variable *copy = ir->var->clone(NULL); + ir_variable *copy = ir->var->clone(this->target, NULL); this->symbols->add_variable(copy->name, copy); this->instructions->push_head(copy); @@ -527,12 +529,13 @@ remap_variables(ir_instruction *inst, glsl_symbol_table *symbols, } private: + struct gl_shader *target; glsl_symbol_table *symbols; exec_list *instructions; hash_table *temps; }; - remap_visitor v(symbols, instructions, temps); + remap_visitor v(target, temps); inst->accept(&v); } @@ -583,12 +586,12 @@ move_non_declarations(exec_list *instructions, exec_node *last, || ((var != NULL) && (var->mode == ir_var_temporary))); if (make_copies) { - inst = inst->clone(NULL); + inst = inst->clone(target, NULL); if (var != NULL) hash_table_insert(temps, inst, var); else - remap_variables(inst, target->symbols, target->ir, temps); + remap_variables(inst, target, temps); } else { inst->remove(); } @@ -713,7 +716,7 @@ link_intrastage_shaders(struct gl_shader_program *prog, gl_shader *const linked = _mesa_new_shader(NULL, 0, main->Type); linked->ir = new(linked) exec_list; - clone_ir_list(linked->ir, main->ir); + clone_ir_list(linked, linked->ir, main->ir); populate_symbol_table(linked); -- cgit v1.2.3 From 952d0f88e1741d51b641be75f7c5a6565e245a69 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 12:57:58 -0700 Subject: glsl2: Skip talloc_parent in constant_expression of non-constant arrays. --- src/glsl/ir_constant_expression.cpp | 2 +- src/mesa/program/ir_to_mesa.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 677353e5424..0a924246da1 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -690,11 +690,11 @@ ir_dereference_variable::constant_expression_value() ir_constant * ir_dereference_array::constant_expression_value() { - void *ctx = talloc_parent(this); ir_constant *array = this->array->constant_expression_value(); ir_constant *idx = this->array_index->constant_expression_value(); if ((array != NULL) && (idx != NULL)) { + void *ctx = talloc_parent(this); if (array->type->is_matrix()) { /* Array access of a matrix results in a vector. */ diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index ba0934c446d..dcf8c497c66 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2622,7 +2622,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) progress = do_constant_folding(shader->ir) || progress; progress = do_algebraic(shader->ir) || progress; progress = do_if_return(shader->ir) || progress; - if (ctx->Shader.EmitNoIfs) + if (1 || ctx->Shader.EmitNoIfs) progress = do_if_to_cond_assign(shader->ir) || progress; progress = do_vec_index_to_swizzle(shader->ir) || progress; -- cgit v1.2.3 From 8e181b629f97ada65cc1b8a17ba42edc2ea77254 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 14:13:08 -0700 Subject: mesa: Don't null deref looking for Mesa IR code at compile time. The new compiler doesn't generate Mesa IR at compile time, and that compile time code previously wouldn't have reflected the link time code that actually got used. But do dump the info log of the compile regardless. --- src/mesa/program/prog_print.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c index 6ab199aa02b..b66d709d50f 100644 --- a/src/mesa/program/prog_print.c +++ b/src/mesa/program/prog_print.c @@ -1031,11 +1031,9 @@ _mesa_write_shader_to_file(const struct gl_shader *shader) fprintf(f, "/* Compile status: %s */\n", shader->CompileStatus ? "ok" : "fail"); - if (!shader->CompileStatus) { - fprintf(f, "/* Log Info: */\n"); - fputs(shader->InfoLog, f); - } - else { + fprintf(f, "/* Log Info: */\n"); + fputs(shader->InfoLog, f); + if (shader->CompileStatus && shader->Program) { fprintf(f, "/* GPU code */\n"); fprintf(f, "/*\n"); _mesa_fprint_program_opt(f, shader->Program, PROG_PRINT_DEBUG, GL_TRUE); -- cgit v1.2.3 From fe1918c71c3e387939cef9359d4b31ebc5c11a17 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 14:21:01 -0700 Subject: ir_to_mesa: Clean up the mapping of samplers to Mesa's sampler uniforms. Instead of using a linker-assigned location (since samplers don't actually take up uniform space, being a link-time choice), use the sampler's varaible pointer as a hash key. --- src/mesa/program/ir_to_mesa.cpp | 42 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index dcf8c497c66..777b4d91f48 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -45,6 +45,7 @@ extern "C" { #include "main/mtypes.h" #include "main/shaderobj.h" #include "main/uniforms.h" +#include "program/hash_table.h" #include "program/prog_instruction.h" #include "program/prog_optimize.h" #include "program/prog_print.h" @@ -160,6 +161,7 @@ public: class ir_to_mesa_visitor : public ir_visitor { public: ir_to_mesa_visitor(); + ~ir_to_mesa_visitor(); function_entry *current_function; @@ -261,11 +263,10 @@ public: ir_constant *constant, struct ir_to_mesa_dst_reg temp); - int *sampler_map; - int sampler_map_size; + struct hash_table *sampler_map; - void map_sampler(int location, int sampler); - int get_sampler_number(int location); + void set_sampler_location(ir_variable *sampler, int location); + int get_sampler_location(ir_variable *sampler); void *mem_ctx; }; @@ -370,22 +371,22 @@ ir_to_mesa_visitor::ir_to_mesa_emit_op0(ir_instruction *ir, } void -ir_to_mesa_visitor::map_sampler(int location, int sampler) +ir_to_mesa_visitor::set_sampler_location(ir_variable *sampler, int location) { - if (this->sampler_map_size <= location) { - this->sampler_map = talloc_realloc(this->mem_ctx, this->sampler_map, - int, location + 1); - this->sampler_map_size = location + 1; + if (this->sampler_map == NULL) { + this->sampler_map = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); } - this->sampler_map[location] = sampler; + hash_table_insert(this->sampler_map, (void *)(uintptr_t)location, sampler); } int -ir_to_mesa_visitor::get_sampler_number(int location) +ir_to_mesa_visitor::get_sampler_location(ir_variable *sampler) { - assert(location < this->sampler_map_size); - return this->sampler_map[location]; + void *result = hash_table_find(this->sampler_map, sampler); + + return (int)(uintptr_t)result; } inline ir_to_mesa_dst_reg @@ -1394,14 +1395,10 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) /* FINISHME: Fix up uniform name for arrays and things */ if (ir->var->type->base_type == GLSL_TYPE_SAMPLER) { - /* FINISHME: we whack the location of the var here, which - * is probably not expected. But we need to communicate - * mesa's sampler number to the tex instruction. - */ int sampler = _mesa_add_sampler(this->prog->Parameters, ir->var->name, ir->var->type->gl_type); - map_sampler(ir->var->location, sampler); + set_sampler_location(ir->var, sampler); entry = new(mem_ctx) variable_storage(ir->var, PROGRAM_SAMPLER, sampler); @@ -2059,7 +2056,7 @@ ir_to_mesa_visitor::visit(ir_texture *ir) */ sampler->accept(this); - inst->sampler = get_sampler_number(sampler->var->location); + inst->sampler = get_sampler_location(sampler->var); switch (sampler->type->sampler_dimensionality) { case GLSL_SAMPLER_DIM_1D: @@ -2166,10 +2163,15 @@ ir_to_mesa_visitor::ir_to_mesa_visitor() next_temp = 1; next_signature_id = 1; sampler_map = NULL; - sampler_map_size = 0; current_function = NULL; } +ir_to_mesa_visitor::~ir_to_mesa_visitor() +{ + if (this->sampler_map) + hash_table_dtor(this->sampler_map); +} + static struct prog_src_register mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg) { -- cgit v1.2.3 From b6ceddc371d026dc30f2cc0f377bc0214e11d768 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 14:26:15 -0700 Subject: glsl2: Don't try to assign locations for samplers during linking. Mesa will do the mapping at _mesa_add_sampler() time. Fixes assertion failures in debug builds, which might have caught real problems with multiple samplers linked in a row. --- src/glsl/linker.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 65f3697d354..10fd2d5ab93 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -793,6 +793,9 @@ assign_uniform_locations(struct gl_shader_program *prog) if ((var == NULL) || (var->mode != ir_var_uniform)) continue; + if (var->type->is_sampler()) + continue; + const unsigned vec4_slots = (var->component_slots() + 3) / 4; assert(vec4_slots != 0); -- cgit v1.2.3 From ea3a9eb53a3c9ed99998ead645e2b2e6a3261626 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Wed, 4 Aug 2010 17:11:32 +0200 Subject: glsl2: add gl_LightModel built-in uniform. --- src/glsl/builtin_variables.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/builtin_variables.h b/src/glsl/builtin_variables.h index 9551e1accf9..2ec7d621bbf 100644 --- a/src/glsl/builtin_variables.h +++ b/src/glsl/builtin_variables.h @@ -93,5 +93,6 @@ static const builtin_variable builtin_110_deprecated_uniforms[] = { { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" }, { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, { ir_var_uniform, -1, "float", "gl_NormalScale" }, + { ir_var_uniform, -1, "gl_LightModelParameters", "gl_LightModel"}, }; -- cgit v1.2.3 From ad98aa9d93646600cc95b3e45a40eec26f18988a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 3 Aug 2010 20:05:53 -0700 Subject: glsl2: Remove uses of deprecated TALLOC_CTX type. --- src/glsl/ast_function.cpp | 12 ++++++------ src/glsl/glsl_types.cpp | 26 +++++++++++++------------- src/glsl/glsl_types.h | 12 ++++++------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 661f8f61607..c22dfa81eb8 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -629,20 +629,20 @@ emit_inline_vector_constructor(const glsl_type *type, ir_instruction * assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base, ir_rvalue *src, unsigned src_base, unsigned count, - TALLOC_CTX *ctx) + void *mem_ctx) { const unsigned mask[8] = { 0, 1, 2, 3, 0, 0, 0, 0 }; - ir_constant *col_idx = new(ctx) ir_constant(column); - ir_rvalue *column_ref = new(ctx) ir_dereference_array(var, col_idx); + ir_constant *col_idx = new(mem_ctx) ir_constant(column); + ir_rvalue *column_ref = new(mem_ctx) ir_dereference_array(var, col_idx); assert(column_ref->type->components() >= (row_base + count)); - ir_rvalue *lhs = new(ctx) ir_swizzle(column_ref, &mask[row_base], count); + ir_rvalue *lhs = new(mem_ctx) ir_swizzle(column_ref, &mask[row_base], count); assert(src->type->components() >= (src_base + count)); - ir_rvalue *rhs = new(ctx) ir_swizzle(src, &mask[src_base], count); + ir_rvalue *rhs = new(mem_ctx) ir_swizzle(src, &mask[src_base], count); - return new(ctx) ir_assignment(lhs, rhs, NULL); + return new(mem_ctx) ir_assignment(lhs, rhs, NULL); } diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 40a5b6c4827..88f305ac254 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -33,14 +33,14 @@ extern "C" { hash_table *glsl_type::array_types = NULL; hash_table *glsl_type::record_types = NULL; -void *glsl_type::ctx = NULL; +void *glsl_type::mem_ctx = NULL; void glsl_type::init_talloc_type_ctx(void) { - if (glsl_type::ctx == NULL) { - glsl_type::ctx = talloc_init("glsl_type"); - assert(glsl_type::ctx != NULL); + if (glsl_type::mem_ctx == NULL) { + glsl_type::mem_ctx = talloc_init("glsl_type"); + assert(glsl_type::mem_ctx != NULL); } } @@ -55,7 +55,7 @@ glsl_type::glsl_type(GLenum gl_type, length(0) { init_talloc_type_ctx(); - this->name = talloc_strdup(this->ctx, name); + this->name = talloc_strdup(this->mem_ctx, name); /* Neither dimension is zero or both dimensions are zero. */ assert((vector_elements == 0) == (matrix_columns == 0)); @@ -73,7 +73,7 @@ glsl_type::glsl_type(GLenum gl_type, length(0) { init_talloc_type_ctx(); - this->name = talloc_strdup(this->ctx, name); + this->name = talloc_strdup(this->mem_ctx, name); memset(& fields, 0, sizeof(fields)); } @@ -88,8 +88,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, unsigned int i; init_talloc_type_ctx(); - this->name = talloc_strdup(this->ctx, name); - this->fields.structure = talloc_array(this->ctx, + this->name = talloc_strdup(this->mem_ctx, name); + this->fields.structure = talloc_array(this->mem_ctx, glsl_struct_field, length); for (i = 0; i < length; i++) { this->fields.structure[i].type = fields[i].type; @@ -228,9 +228,9 @@ _mesa_glsl_release_types(void) glsl_type::record_types = NULL; } - if (glsl_type::ctx != NULL) { - talloc_free(glsl_type::ctx); - glsl_type::ctx = NULL; + if (glsl_type::mem_ctx != NULL) { + talloc_free(glsl_type::mem_ctx); + glsl_type::mem_ctx = NULL; } } @@ -315,7 +315,7 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) : * NUL. */ const unsigned name_length = strlen(array->name) + 10 + 3; - char *const n = (char *) talloc_size(this->ctx, name_length); + char *const n = (char *) talloc_size(this->mem_ctx, name_length); if (length == 0) snprintf(n, name_length, "%s[]", array->name); @@ -405,7 +405,7 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) if (t == NULL) { t = new glsl_type(base, array_size); - hash_table_insert(array_types, (void *) t, talloc_strdup(ctx, key)); + hash_table_insert(array_types, (void *) t, talloc_strdup(mem_ctx, key)); } assert(t->base_type == GLSL_TYPE_ARRAY); diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index c3f81b82aa0..97d0d98c624 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -76,17 +76,17 @@ struct glsl_type { */ /* Callers of this talloc-based new need not call delete. It's - * easier to just talloc_free 'ctx' (or any of its ancestors). */ + * easier to just talloc_free 'mem_ctx' (or any of its ancestors). */ static void* operator new(size_t size) { - if (glsl_type::ctx == NULL) { - glsl_type::ctx = talloc_init("glsl_type"); - assert(glsl_type::ctx != NULL); + if (glsl_type::mem_ctx == NULL) { + glsl_type::mem_ctx = talloc_init("glsl_type"); + assert(glsl_type::mem_ctx != NULL); } void *type; - type = talloc_size(glsl_type::ctx, size); + type = talloc_size(glsl_type::mem_ctx, size); assert(type != NULL); return type; @@ -394,7 +394,7 @@ private: * * Set on the first call to \c glsl_type::new. */ - static TALLOC_CTX *ctx; + static void *mem_ctx; void init_talloc_type_ctx(void); -- cgit v1.2.3 From 1ffc1cd86186ae5d03bb28a1e041c4a57761515e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 3 Aug 2010 20:21:52 -0700 Subject: glcpp: Remove xtalloc wrappers in favor of plain talloc. Calling exit() on a memory failure probably made sense for the standalone preprocessor, but doesn't seem too appealing as part of the GL library. Also, we don't use it in the main compiler. --- src/glsl/Makefile | 3 +- src/glsl/glcpp/Makefile.am | 3 +- src/glsl/glcpp/glcpp-lex.l | 14 +++---- src/glsl/glcpp/glcpp-parse.y | 38 ++++++++--------- src/glsl/glcpp/glcpp.h | 24 ----------- src/glsl/glcpp/xtalloc.c | 99 -------------------------------------------- 6 files changed, 28 insertions(+), 153 deletions(-) delete mode 100644 src/glsl/glcpp/xtalloc.c diff --git a/src/glsl/Makefile b/src/glsl/Makefile index f98b772a2fb..3102947494c 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -9,8 +9,7 @@ LIBNAME = glsl LIBGLCPP_SOURCES = \ glcpp/glcpp-lex.c \ glcpp/glcpp-parse.c \ - glcpp/pp.c \ - glcpp/xtalloc.c + glcpp/pp.c GLCPP_SOURCES = \ $(LIBGLCPP_SOURCES) \ diff --git a/src/glsl/glcpp/Makefile.am b/src/glsl/glcpp/Makefile.am index 00c6c5610eb..81147e6e12c 100644 --- a/src/glsl/glcpp/Makefile.am +++ b/src/glsl/glcpp/Makefile.am @@ -25,8 +25,7 @@ libglcpp_la_SOURCES = \ glcpp-lex.l \ glcpp-parse.y \ glcpp.h \ - pp.c \ - xtalloc.c + pp.c BUILT_SOURCES = glcpp-parse.h glcpp-parse.c glcpp-lex.c CLEANFILES = $(BUILT_SOURCES) diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 17a097e633a..1a0052d689a 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -88,7 +88,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } {HASH}(version) { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); yylineno++; yycolumn = 0; yyextra->space_tokens = 0; @@ -98,7 +98,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? /* glcpp doesn't handle #extension, #version, or #pragma directives. * Simply pass them through to the main compiler's lexer/parser. */ {HASH}(extension|pragma)[^\n]+ { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); yylineno++; yycolumn = 0; return OTHER; @@ -186,17 +186,17 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } {DECIMAL_INTEGER} { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; } {OCTAL_INTEGER} { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; } {HEXADECIMAL_INTEGER} { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; } @@ -241,7 +241,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } {IDENTIFIER} { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); return IDENTIFIER; } @@ -250,7 +250,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } {OTHER}+ { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); return OTHER; } diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 855448ff20d..55a8d1761e6 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -503,7 +503,7 @@ _string_list_create (void *ctx) { string_list_t *list; - list = xtalloc (ctx, string_list_t); + list = talloc (ctx, string_list_t); list->head = NULL; list->tail = NULL; @@ -515,8 +515,8 @@ _string_list_append_item (string_list_t *list, const char *str) { string_node_t *node; - node = xtalloc (list, string_node_t); - node->str = xtalloc_strdup (node, str); + node = talloc (list, string_node_t); + node->str = talloc_strdup (node, str); node->next = NULL; @@ -569,7 +569,7 @@ _argument_list_create (void *ctx) { argument_list_t *list; - list = xtalloc (ctx, argument_list_t); + list = talloc (ctx, argument_list_t); list->head = NULL; list->tail = NULL; @@ -581,7 +581,7 @@ _argument_list_append (argument_list_t *list, token_list_t *argument) { argument_node_t *node; - node = xtalloc (list, argument_node_t); + node = talloc (list, argument_node_t); node->argument = argument; node->next = NULL; @@ -638,7 +638,7 @@ _token_create_str (void *ctx, int type, char *str) { token_t *token; - token = xtalloc (ctx, token_t); + token = talloc (ctx, token_t); token->type = type; token->value.str = talloc_steal (token, str); @@ -650,7 +650,7 @@ _token_create_ival (void *ctx, int type, int ival) { token_t *token; - token = xtalloc (ctx, token_t); + token = talloc (ctx, token_t); token->type = type; token->value.ival = ival; @@ -662,7 +662,7 @@ _token_list_create (void *ctx) { token_list_t *list; - list = xtalloc (ctx, token_list_t); + list = talloc (ctx, token_list_t); list->head = NULL; list->tail = NULL; list->non_space_tail = NULL; @@ -675,8 +675,8 @@ _token_list_append (token_list_t *list, token_t *token) { token_node_t *node; - node = xtalloc (list, token_node_t); - node->token = xtalloc_reference (list, token); + node = talloc (list, token_node_t); + node->token = talloc_reference (list, token); node->next = NULL; @@ -871,8 +871,8 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) { char *str; - str = xtalloc_asprintf (token, "%s%s", - token->value.str, other->value.str); + str = talloc_asprintf (token, "%s%s", token->value.str, + other->value.str); combined = _token_create_str (token, token->type, str); combined->location = token->location; return combined; @@ -927,7 +927,7 @@ glcpp_parser_create (const struct gl_extensions *extensions) glcpp_parser_t *parser; int language_version; - parser = xtalloc (NULL, glcpp_parser_t); + parser = talloc (NULL, glcpp_parser_t); glcpp_lex_init_extra (parser, &parser->scanner); parser->defines = hash_table_ctor (32, hash_table_string_hash, @@ -1294,7 +1294,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser, token_list_t *expansion; token_t *final; - str = xtalloc_strdup (parser, token->value.str); + str = talloc_strdup (parser, token->value.str); final = _token_create_str (parser, OTHER, str); expansion = _token_list_create (parser); _token_list_append (expansion, final); @@ -1330,8 +1330,8 @@ _active_list_push (active_list_t *list, { active_list_t *node; - node = xtalloc (list, active_list_t); - node->identifier = xtalloc_strdup (node, identifier); + node = talloc (list, active_list_t); + node->identifier = talloc_strdup (node, identifier); node->marker = marker; node->next = list; @@ -1481,7 +1481,7 @@ _define_object_macro (glcpp_parser_t *parser, if (loc != NULL) _check_for_reserved_macro_name(parser, loc, identifier); - macro = xtalloc (parser, macro_t); + macro = talloc (parser, macro_t); macro->is_function = 0; macro->parameters = NULL; @@ -1502,7 +1502,7 @@ _define_function_macro (glcpp_parser_t *parser, _check_for_reserved_macro_name(parser, loc, identifier); - macro = xtalloc (parser, macro_t); + macro = talloc (parser, macro_t); macro->is_function = 1; macro->parameters = talloc_steal (macro, parameters); @@ -1628,7 +1628,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, if (parser->skip_stack) current = parser->skip_stack->type; - node = xtalloc (parser, skip_node_t); + node = talloc (parser, skip_node_t); node->loc = *loc; if (current == SKIP_NO_SKIP) { diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index 0ccd957eda3..0bebdb9ae8c 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -219,28 +219,4 @@ glcpp_lex_destroy (yyscan_t scanner); int yyparse (glcpp_parser_t *parser); -/* xtalloc - wrappers around talloc to check for out-of-memory */ - -#define xtalloc(ctx, type) (type *)xtalloc_named_const(ctx, sizeof(type), #type) - -#define xtalloc_size(ctx, size) xtalloc_named_const(ctx, size, __location__) - -void * -xtalloc_named_const (const void *context, size_t size, const char *name); - -char * -xtalloc_strdup (const void *t, const char *p); - -char * -xtalloc_strndup (const void *t, const char *p, size_t n); - -char * -xtalloc_asprintf (const void *t, const char *fmt, ...); - -void * -_xtalloc_reference_loc (const void *context, - const void *ptr, const char *location); - -#define xtalloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_xtalloc_reference_loc((ctx),(ptr), __location__) - #endif diff --git a/src/glsl/glcpp/xtalloc.c b/src/glsl/glcpp/xtalloc.c deleted file mode 100644 index a20ea8b93fa..00000000000 --- a/src/glsl/glcpp/xtalloc.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "glcpp.h" - -void * -xtalloc_named_const (const void *context, size_t size, const char *name) -{ - void *ret; - - ret = talloc_named_const (context, size, name); - if (ret == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - return ret; -} - -char * -xtalloc_strdup (const void *t, const char *p) -{ - char *ret; - - ret = talloc_strdup (t, p); - if (ret == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - return ret; -} - -char * -xtalloc_strndup (const void *t, const char *p, size_t n) -{ - char *ret; - - ret = talloc_strndup (t, p, n); - if (ret == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - return ret; -} - -char * -xtalloc_asprintf (const void *t, const char *fmt, ...) -{ - va_list ap; - char *ret; - - va_start(ap, fmt); - - ret = talloc_vasprintf(t, fmt, ap); - if (ret == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - va_end(ap); - return ret; -} - -void * -_xtalloc_reference_loc (const void *context, - const void *ptr, const char *location) -{ - void *ret; - - ret = _talloc_reference_loc (context, ptr, location); - if (ret == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } - - return ret; -} -- cgit v1.2.3 From 0ef79a5f115659b3719a330d01a365e8ca8144c4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 3 Aug 2010 20:25:13 -0700 Subject: glcpp: Refresh autogenerated lexer and parser. --- src/glsl/glcpp/glcpp-lex.c | 44 +++----- src/glsl/glcpp/glcpp-parse.c | 252 ++++++++++++++++++++++--------------------- src/glsl/glcpp/glcpp-parse.h | 7 +- 3 files changed, 148 insertions(+), 155 deletions(-) diff --git a/src/glsl/glcpp/glcpp-lex.c b/src/glsl/glcpp/glcpp-lex.c index 40db2c27c51..d9769041351 100644 --- a/src/glsl/glcpp/glcpp-lex.c +++ b/src/glsl/glcpp/glcpp-lex.c @@ -54,6 +54,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -84,8 +85,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -159,15 +158,7 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -691,7 +682,7 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner); } while(0); #define YY_USER_INIT yylineno = 0; yycolumn = 0; -#line 695 "glcpp/glcpp-lex.c" +#line 686 "glcpp/glcpp-lex.c" #define INITIAL 0 #define DONE 1 @@ -846,12 +837,7 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -859,7 +845,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -870,7 +856,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -962,7 +948,7 @@ YY_DECL /* Single-line comments */ -#line 966 "glcpp/glcpp-lex.c" +#line 952 "glcpp/glcpp-lex.c" yylval = yylval_param; @@ -1133,7 +1119,7 @@ case 8: YY_RULE_SETUP #line 90 "glcpp/glcpp-lex.l" { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); yylineno++; yycolumn = 0; yyextra->space_tokens = 0; @@ -1146,7 +1132,7 @@ case 9: YY_RULE_SETUP #line 100 "glcpp/glcpp-lex.l" { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); yylineno++; yycolumn = 0; return OTHER; @@ -1283,7 +1269,7 @@ case 22: YY_RULE_SETUP #line 188 "glcpp/glcpp-lex.l" { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; } YY_BREAK @@ -1291,7 +1277,7 @@ case 23: YY_RULE_SETUP #line 193 "glcpp/glcpp-lex.l" { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; } YY_BREAK @@ -1299,7 +1285,7 @@ case 24: YY_RULE_SETUP #line 198 "glcpp/glcpp-lex.l" { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; } YY_BREAK @@ -1377,7 +1363,7 @@ case 35: YY_RULE_SETUP #line 243 "glcpp/glcpp-lex.l" { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); return IDENTIFIER; } YY_BREAK @@ -1392,7 +1378,7 @@ case 37: YY_RULE_SETUP #line 252 "glcpp/glcpp-lex.l" { - yylval->str = xtalloc_strdup (yyextra, yytext); + yylval->str = talloc_strdup (yyextra, yytext); return OTHER; } YY_BREAK @@ -1442,7 +1428,7 @@ YY_RULE_SETUP #line 286 "glcpp/glcpp-lex.l" ECHO; YY_BREAK -#line 1446 "glcpp/glcpp-lex.c" +#line 1432 "glcpp/glcpp-lex.c" case YY_STATE_EOF(DONE): case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(UNREACHABLE): @@ -2181,8 +2167,8 @@ YY_BUFFER_STATE glcpp__scan_string (yyconst char * yystr , yyscan_t yyscanner) /** Setup the input buffer state to scan the given bytes. The next call to glcpp_lex() will * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 9dc4bfb3ab1..5ea07c2555e 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1" +#define YYBISON_VERSION "2.4.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -209,7 +208,7 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); /* Line 189 of yacc.c */ -#line 213 "glcpp/glcpp-parse.c" +#line 212 "glcpp/glcpp-parse.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -297,7 +296,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 301 "glcpp/glcpp-parse.c" +#line 300 "glcpp/glcpp-parse.c" #ifdef short # undef short @@ -347,7 +346,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -934,9 +933,18 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -993,7 +1001,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1582,7 +1590,7 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if YYLTYPE_IS_TRIVIAL +#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; @@ -1772,7 +1780,7 @@ yyreduce: { case 4: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 175 "glcpp/glcpp-parse.y" { glcpp_print(parser->output, "\n"); @@ -1781,7 +1789,7 @@ yyreduce: case 5: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 178 "glcpp/glcpp-parse.y" { _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); @@ -1792,7 +1800,7 @@ yyreduce: case 8: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 188 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); @@ -1801,7 +1809,7 @@ yyreduce: case 9: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 191 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); @@ -1810,7 +1818,7 @@ yyreduce: case 10: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 197 "glcpp/glcpp-parse.y" { _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); @@ -1819,7 +1827,7 @@ yyreduce: case 11: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 200 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); @@ -1828,7 +1836,7 @@ yyreduce: case 12: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 203 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); @@ -1837,7 +1845,7 @@ yyreduce: case 13: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 206 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); @@ -1851,7 +1859,7 @@ yyreduce: case 14: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 214 "glcpp/glcpp-parse.y" { token_list_t *expanded; @@ -1869,7 +1877,7 @@ yyreduce: case 15: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 226 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); @@ -1880,7 +1888,7 @@ yyreduce: case 16: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 231 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); @@ -1891,7 +1899,7 @@ yyreduce: case 17: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 236 "glcpp/glcpp-parse.y" { token_list_t *expanded; @@ -1909,7 +1917,7 @@ yyreduce: case 18: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 248 "glcpp/glcpp-parse.y" { /* #elif without an expression results in a warning if the @@ -1926,7 +1934,7 @@ yyreduce: case 19: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 259 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); @@ -1935,7 +1943,7 @@ yyreduce: case 20: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 262 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); @@ -1944,7 +1952,7 @@ yyreduce: case 21: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 265 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); @@ -1959,7 +1967,7 @@ yyreduce: case 23: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 278 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { @@ -1974,7 +1982,7 @@ yyreduce: case 24: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 287 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); @@ -1983,7 +1991,7 @@ yyreduce: case 26: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 293 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); @@ -1992,7 +2000,7 @@ yyreduce: case 27: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 296 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); @@ -2001,7 +2009,7 @@ yyreduce: case 28: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 299 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); @@ -2010,7 +2018,7 @@ yyreduce: case 29: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 302 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); @@ -2019,7 +2027,7 @@ yyreduce: case 30: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 305 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); @@ -2028,7 +2036,7 @@ yyreduce: case 31: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 308 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); @@ -2037,7 +2045,7 @@ yyreduce: case 32: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 311 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); @@ -2046,7 +2054,7 @@ yyreduce: case 33: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 314 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); @@ -2055,7 +2063,7 @@ yyreduce: case 34: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 317 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); @@ -2064,7 +2072,7 @@ yyreduce: case 35: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 320 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); @@ -2073,7 +2081,7 @@ yyreduce: case 36: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 323 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); @@ -2082,7 +2090,7 @@ yyreduce: case 37: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 326 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); @@ -2091,7 +2099,7 @@ yyreduce: case 38: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 329 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); @@ -2100,7 +2108,7 @@ yyreduce: case 39: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 332 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); @@ -2109,7 +2117,7 @@ yyreduce: case 40: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 335 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); @@ -2118,7 +2126,7 @@ yyreduce: case 41: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 338 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); @@ -2127,7 +2135,7 @@ yyreduce: case 42: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 341 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); @@ -2136,7 +2144,7 @@ yyreduce: case 43: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 344 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); @@ -2145,7 +2153,7 @@ yyreduce: case 44: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 347 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); @@ -2154,7 +2162,7 @@ yyreduce: case 45: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 350 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); @@ -2163,7 +2171,7 @@ yyreduce: case 46: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 353 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); @@ -2172,7 +2180,7 @@ yyreduce: case 47: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 356 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); @@ -2181,7 +2189,7 @@ yyreduce: case 48: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 359 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); @@ -2190,7 +2198,7 @@ yyreduce: case 49: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 365 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); @@ -2201,7 +2209,7 @@ yyreduce: case 50: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 370 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); @@ -2212,14 +2220,14 @@ yyreduce: case 51: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 378 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 53: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 383 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); @@ -2228,14 +2236,14 @@ yyreduce: case 54: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 389 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 57: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 395 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); @@ -2244,7 +2252,7 @@ yyreduce: case 58: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 402 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; @@ -2254,7 +2262,7 @@ yyreduce: case 59: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 406 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; @@ -2264,7 +2272,7 @@ yyreduce: case 61: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 415 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; @@ -2276,7 +2284,7 @@ yyreduce: case 62: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 421 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); @@ -2287,7 +2295,7 @@ yyreduce: case 63: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 429 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; @@ -2299,7 +2307,7 @@ yyreduce: case 64: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 435 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); @@ -2310,7 +2318,7 @@ yyreduce: case 65: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 443 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); @@ -2320,7 +2328,7 @@ yyreduce: case 66: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 447 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); @@ -2330,7 +2338,7 @@ yyreduce: case 67: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 451 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); @@ -2340,7 +2348,7 @@ yyreduce: case 68: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 455 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); @@ -2350,7 +2358,7 @@ yyreduce: case 69: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 459 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); @@ -2360,225 +2368,225 @@ yyreduce: case 70: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 466 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 71: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 467 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 72: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 468 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 73: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 469 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 74: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 470 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 75: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 471 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 76: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 472 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 77: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 473 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 78: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 474 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 79: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 475 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 80: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 476 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 81: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 477 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 82: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 478 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 83: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 479 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 84: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 480 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 85: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 481 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 86: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 482 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 87: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 483 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 88: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 484 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 89: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 485 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 90: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 486 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 91: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 487 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 92: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 488 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 93: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 489 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 94: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 490 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 95: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 491 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 96: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 492 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 97: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 493 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 98: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 494 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 99: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 495 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 100: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 496 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; -/* Line 1455 of yacc.c */ -#line 2582 "glcpp/glcpp-parse.c" +/* Line 1464 of yacc.c */ +#line 2590 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2796,7 +2804,7 @@ yyreturn: -/* Line 1675 of yacc.c */ +/* Line 1684 of yacc.c */ #line 499 "glcpp/glcpp-parse.y" @@ -2805,7 +2813,7 @@ _string_list_create (void *ctx) { string_list_t *list; - list = xtalloc (ctx, string_list_t); + list = talloc (ctx, string_list_t); list->head = NULL; list->tail = NULL; @@ -2817,8 +2825,8 @@ _string_list_append_item (string_list_t *list, const char *str) { string_node_t *node; - node = xtalloc (list, string_node_t); - node->str = xtalloc_strdup (node, str); + node = talloc (list, string_node_t); + node->str = talloc_strdup (node, str); node->next = NULL; @@ -2871,7 +2879,7 @@ _argument_list_create (void *ctx) { argument_list_t *list; - list = xtalloc (ctx, argument_list_t); + list = talloc (ctx, argument_list_t); list->head = NULL; list->tail = NULL; @@ -2883,7 +2891,7 @@ _argument_list_append (argument_list_t *list, token_list_t *argument) { argument_node_t *node; - node = xtalloc (list, argument_node_t); + node = talloc (list, argument_node_t); node->argument = argument; node->next = NULL; @@ -2940,7 +2948,7 @@ _token_create_str (void *ctx, int type, char *str) { token_t *token; - token = xtalloc (ctx, token_t); + token = talloc (ctx, token_t); token->type = type; token->value.str = talloc_steal (token, str); @@ -2952,7 +2960,7 @@ _token_create_ival (void *ctx, int type, int ival) { token_t *token; - token = xtalloc (ctx, token_t); + token = talloc (ctx, token_t); token->type = type; token->value.ival = ival; @@ -2964,7 +2972,7 @@ _token_list_create (void *ctx) { token_list_t *list; - list = xtalloc (ctx, token_list_t); + list = talloc (ctx, token_list_t); list->head = NULL; list->tail = NULL; list->non_space_tail = NULL; @@ -2977,8 +2985,8 @@ _token_list_append (token_list_t *list, token_t *token) { token_node_t *node; - node = xtalloc (list, token_node_t); - node->token = xtalloc_reference (list, token); + node = talloc (list, token_node_t); + node->token = talloc_reference (list, token); node->next = NULL; @@ -3173,8 +3181,8 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) { char *str; - str = xtalloc_asprintf (token, "%s%s", - token->value.str, other->value.str); + str = talloc_asprintf (token, "%s%s", token->value.str, + other->value.str); combined = _token_create_str (token, token->type, str); combined->location = token->location; return combined; @@ -3229,7 +3237,7 @@ glcpp_parser_create (const struct gl_extensions *extensions) glcpp_parser_t *parser; int language_version; - parser = xtalloc (NULL, glcpp_parser_t); + parser = talloc (NULL, glcpp_parser_t); glcpp_lex_init_extra (parser, &parser->scanner); parser->defines = hash_table_ctor (32, hash_table_string_hash, @@ -3596,7 +3604,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser, token_list_t *expansion; token_t *final; - str = xtalloc_strdup (parser, token->value.str); + str = talloc_strdup (parser, token->value.str); final = _token_create_str (parser, OTHER, str); expansion = _token_list_create (parser); _token_list_append (expansion, final); @@ -3632,8 +3640,8 @@ _active_list_push (active_list_t *list, { active_list_t *node; - node = xtalloc (list, active_list_t); - node->identifier = xtalloc_strdup (node, identifier); + node = talloc (list, active_list_t); + node->identifier = talloc_strdup (node, identifier); node->marker = marker; node->next = list; @@ -3783,7 +3791,7 @@ _define_object_macro (glcpp_parser_t *parser, if (loc != NULL) _check_for_reserved_macro_name(parser, loc, identifier); - macro = xtalloc (parser, macro_t); + macro = talloc (parser, macro_t); macro->is_function = 0; macro->parameters = NULL; @@ -3804,7 +3812,7 @@ _define_function_macro (glcpp_parser_t *parser, _check_for_reserved_macro_name(parser, loc, identifier); - macro = xtalloc (parser, macro_t); + macro = talloc (parser, macro_t); macro->is_function = 1; macro->parameters = talloc_steal (macro, parameters); @@ -3930,7 +3938,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, if (parser->skip_stack) current = parser->skip_stack->type; - node = xtalloc (parser, skip_node_t); + node = talloc (parser, skip_node_t); node->loc = *loc; if (current == SKIP_NO_SKIP) { diff --git a/src/glsl/glcpp/glcpp-parse.h b/src/glsl/glcpp/glcpp-parse.h index 50758930e9c..53e7af0305d 100644 --- a/src/glsl/glcpp/glcpp-parse.h +++ b/src/glsl/glcpp/glcpp-parse.h @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit v1.2.3 From 3d23f0a90c982ad43a6f18ef69a23b2fcdb1d1d2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 16:06:00 -0700 Subject: glsl2: Refactor constant folding of rvalues to a function. --- src/glsl/ir_constant_folding.cpp | 47 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/glsl/ir_constant_folding.cpp b/src/glsl/ir_constant_folding.cpp index 66a92e9f3b6..492036e9a6b 100644 --- a/src/glsl/ir_constant_folding.cpp +++ b/src/glsl/ir_constant_folding.cpp @@ -73,8 +73,24 @@ public: virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); /*@}*/ + + void fold_constant(ir_rvalue **rvalue); }; +void +ir_constant_folding_visitor::fold_constant(ir_rvalue **rvalue) +{ + if ((*rvalue)->ir_type == ir_type_constant) + return; + + ir_constant *constant = (*rvalue)->constant_expression_value(); + if (constant) { + *rvalue = constant; + } else { + (*rvalue)->accept(this); + } +} + void ir_constant_folding_visitor::visit(ir_variable *ir) { @@ -101,16 +117,10 @@ ir_constant_folding_visitor::visit(ir_function *ir) void ir_constant_folding_visitor::visit(ir_expression *ir) { - ir_constant *op[2]; unsigned int operand; for (operand = 0; operand < ir->get_num_operands(); operand++) { - op[operand] = ir->operands[operand]->constant_expression_value(); - if (op[operand]) { - ir->operands[operand] = op[operand]; - } else { - ir->operands[operand]->accept(this); - } + fold_constant(&ir->operands[operand]); } } @@ -140,14 +150,7 @@ ir_constant_folding_visitor::visit(ir_dereference_variable *ir) void ir_constant_folding_visitor::visit(ir_dereference_array *ir) { - ir_constant *const_val = - ir->array_index->constant_expression_value(); - - if (const_val) - ir->array_index = const_val; - else - ir->array_index->accept(this); - + fold_constant(&ir->array_index); ir->array->accept(this); } @@ -162,17 +165,13 @@ ir_constant_folding_visitor::visit(ir_dereference_record *ir) void ir_constant_folding_visitor::visit(ir_assignment *ir) { - ir_constant *const_val = ir->rhs->constant_expression_value(); - if (const_val) - ir->rhs = const_val; - else - ir->rhs->accept(this); + fold_constant(&ir->rhs); if (ir->condition) { /* If the condition is constant, either remove the condition or * remove the never-executed assignment. */ - const_val = ir->condition->constant_expression_value(); + ir_constant *const_val = ir->condition->constant_expression_value(); if (const_val) { if (const_val->value.b[0]) ir->condition = NULL; @@ -214,11 +213,7 @@ ir_constant_folding_visitor::visit(ir_discard *ir) void ir_constant_folding_visitor::visit(ir_if *ir) { - ir_constant *const_val = ir->condition->constant_expression_value(); - if (const_val) - ir->condition = const_val; - else - ir->condition->accept(this); + fold_constant(&ir->condition); visit_exec_list(&ir->then_instructions, this); visit_exec_list(&ir->else_instructions, this); -- cgit v1.2.3 From 6ecf62f673bf90d0969f8db032781b49a988975a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 16:07:41 -0700 Subject: glsl2: Return a real progress value from constant folding. --- src/glsl/ir_constant_folding.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_constant_folding.cpp b/src/glsl/ir_constant_folding.cpp index 492036e9a6b..a6d82e33ec4 100644 --- a/src/glsl/ir_constant_folding.cpp +++ b/src/glsl/ir_constant_folding.cpp @@ -39,7 +39,7 @@ class ir_constant_folding_visitor : public ir_visitor { public: ir_constant_folding_visitor() { - /* empty */ + this->progress = false; } virtual ~ir_constant_folding_visitor() @@ -75,6 +75,8 @@ public: /*@}*/ void fold_constant(ir_rvalue **rvalue); + + bool progress; }; void @@ -86,6 +88,7 @@ ir_constant_folding_visitor::fold_constant(ir_rvalue **rvalue) ir_constant *constant = (*rvalue)->constant_expression_value(); if (constant) { *rvalue = constant; + this->progress = true; } else { (*rvalue)->accept(this); } @@ -178,6 +181,7 @@ ir_constant_folding_visitor::visit(ir_assignment *ir) else ir->remove(); } + this->progress = true; } } @@ -240,6 +244,5 @@ do_constant_folding(exec_list *instructions) visit_exec_list(instructions, &constant_folding); - /* FINISHME: Return real progress. */ - return false; + return constant_folding.progress; } -- cgit v1.2.3 From 8dbdcb0b43c8749018ff62dd5751190e54fe2445 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 16:18:18 -0700 Subject: glsl2: Constant fold the children of many more ir_instruction types. --- src/glsl/ir_constant_folding.cpp | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/glsl/ir_constant_folding.cpp b/src/glsl/ir_constant_folding.cpp index a6d82e33ec4..11260423d90 100644 --- a/src/glsl/ir_constant_folding.cpp +++ b/src/glsl/ir_constant_folding.cpp @@ -82,7 +82,7 @@ public: void ir_constant_folding_visitor::fold_constant(ir_rvalue **rvalue) { - if ((*rvalue)->ir_type == ir_type_constant) + if (*rvalue == NULL || (*rvalue)->ir_type == ir_type_constant) return; ir_constant *constant = (*rvalue)->constant_expression_value(); @@ -131,15 +131,32 @@ ir_constant_folding_visitor::visit(ir_expression *ir) void ir_constant_folding_visitor::visit(ir_texture *ir) { - // FINISHME: Do stuff with texture lookups - (void) ir; + fold_constant(&ir->coordinate); + fold_constant(&ir->projector); + fold_constant(&ir->shadow_comparitor); + + switch (ir->op) { + case ir_tex: + break; + case ir_txb: + fold_constant(&ir->lod_info.bias); + break; + case ir_txf: + case ir_txl: + fold_constant(&ir->lod_info.lod); + break; + case ir_txd: + fold_constant(&ir->lod_info.grad.dPdx); + fold_constant(&ir->lod_info.grad.dPdy); + break; + } } void ir_constant_folding_visitor::visit(ir_swizzle *ir) { - ir->val->accept(this); + fold_constant(&ir->val); } @@ -180,8 +197,8 @@ ir_constant_folding_visitor::visit(ir_assignment *ir) ir->condition = NULL; else ir->remove(); + this->progress = true; } - this->progress = true; } } @@ -196,14 +213,22 @@ ir_constant_folding_visitor::visit(ir_constant *ir) void ir_constant_folding_visitor::visit(ir_call *ir) { - (void) ir; + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = param; + fold_constant(&new_param); + + if (new_param != param) { + param->replace_with(new_param); + } + } } void ir_constant_folding_visitor::visit(ir_return *ir) { - (void) ir; + fold_constant(&ir->value); } -- cgit v1.2.3 From 8e9ce2eb56a087c2544112700ae1abe3f96648dd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 3 Aug 2010 15:02:35 -0700 Subject: glsl2: Don't try to construct an ir_assignment with an invalid LHS --- src/glsl/ast_to_hir.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index b65a323a8d7..14c528075bb 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -555,9 +555,8 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, NULL)); deref_var = new(ctx) ir_dereference_variable(var); - instructions->push_tail(new(ctx) ir_assignment(lhs, - deref_var, - NULL)); + if (!error_emitted) + instructions->push_tail(new(ctx) ir_assignment(lhs, deref_var, NULL)); return new(ctx) ir_dereference_variable(var); } -- cgit v1.2.3 From 5a7758efbe14dee026245a4f4f4fb3ccf7b2c23b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 2 Aug 2010 18:48:25 -0700 Subject: glsl2: Add ir_assignment::write_mask and associated methods Replace swizzles on the LHS with additional swizzles on the RHS and a write mask in the assignment instruction. As part of this add ir_assignment::set_lhs. Ideally we'd make ir_assignment::lhs private to prevent erroneous writes, but that would require a lot of code butchery at this point. Add ir_assignment constructor that takes an explicit write mask. This is required for ir_assignment::clone, but it can also be used in other places. Without this, ir_assignment clones lose their write masks, and incorrect IR is generated in optimization passes. Add ir_assignment::whole_variable_written method. This method gets the variable on the LHS if the whole variable is written or NULL otherwise. This is different from ir->lhs->whole_variable_referenced() because the latter has no knowledge of the write mask stored in the ir_assignment. Gut all code from ir_to_mesa that handled swizzles on the LHS of assignments. There is probably some other refactoring that could be done here, but that can be left for another day. --- src/glsl/ir.cpp | 113 ++++++++++++++++++++++++++++++++++- src/glsl/ir.h | 44 +++++++++++++- src/glsl/ir_clone.cpp | 3 +- src/glsl/ir_constant_variable.cpp | 2 +- src/glsl/ir_copy_propagation.cpp | 2 +- src/glsl/ir_dead_code_local.cpp | 2 +- src/glsl/ir_print_visitor.cpp | 14 ++++- src/glsl/ir_tree_grafting.cpp | 2 +- src/glsl/ir_vec_index_to_swizzle.cpp | 2 +- src/mesa/program/ir_to_mesa.cpp | 67 ++++++++------------- 10 files changed, 199 insertions(+), 52 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 79cbaa9ea07..c3bade8d549 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -22,6 +22,7 @@ */ #include #include "main/imports.h" +#include "main/macros.h" #include "ir.h" #include "ir_visitor.h" #include "glsl_types.h" @@ -31,13 +32,121 @@ ir_rvalue::ir_rvalue() this->type = glsl_type::error_type; } +/** + * Modify the swizzle make to move one component to another + * + * \param m IR swizzle to be modified + * \param from Component in the RHS that is to be swizzled + * \param to Desired swizzle location of \c from + */ +static void +update_rhs_swizzle(ir_swizzle_mask &m, unsigned from, unsigned to) +{ + switch (to) { + case 0: m.x = from; break; + case 1: m.y = from; break; + case 2: m.z = from; break; + case 3: m.w = from; break; + default: assert(!"Should not get here."); + } + + m.num_components = MAX2(m.num_components, (to + 1)); +} + +void +ir_assignment::set_lhs(ir_rvalue *lhs) +{ + while (lhs != NULL) { + ir_swizzle *swiz = lhs->as_swizzle(); + + if (swiz == NULL) + break; + + unsigned write_mask = 0; + ir_swizzle_mask rhs_swiz = { 0, 0, 0, 0, 0, 0 }; + + for (unsigned i = 0; i < swiz->mask.num_components; i++) { + unsigned c = 0; + + switch (i) { + case 0: c = swiz->mask.x; break; + case 1: c = swiz->mask.y; break; + case 2: c = swiz->mask.z; break; + case 3: c = swiz->mask.w; break; + default: assert(!"Should not get here."); + } + + write_mask |= (((this->write_mask >> i) & 1) << c); + update_rhs_swizzle(rhs_swiz, i, c); + } + + this->write_mask = write_mask; + lhs = swiz->val; + + this->rhs = new(this) ir_swizzle(this->rhs, rhs_swiz); + } + + assert((lhs == NULL) || lhs->as_dereference()); + + this->lhs = (ir_dereference *) lhs; +} + +ir_variable * +ir_assignment::whole_variable_written() +{ + ir_variable *v = this->lhs->whole_variable_referenced(); + + if (v == NULL) + return NULL; + + if (v->type->is_scalar()) + return v; + + if (v->type->is_vector()) { + const unsigned mask = (1U << v->type->vector_elements) - 1; + + if (mask != this->write_mask) + return NULL; + } + + /* Either all the vector components are assigned or the variable is some + * composite type (and the whole thing is assigned. + */ + return v; +} + +ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, + ir_rvalue *condition, unsigned write_mask) +{ + this->ir_type = ir_type_assignment; + this->condition = condition; + this->rhs = rhs; + this->lhs = lhs; + this->write_mask = write_mask; +} + ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition) { this->ir_type = ir_type_assignment; - this->lhs = lhs; - this->rhs = rhs; this->condition = condition; + this->rhs = rhs; + + /* If the RHS is a vector type, assume that all components of the vector + * type are being written to the LHS. The write mask comes from the RHS + * because we can have a case where the LHS is a vec4 and the RHS is a + * vec3. In that case, the assignment is: + * + * (assign (...) (xyz) (var_ref lhs) (var_ref rhs)) + */ + if (rhs->type->is_vector()) + this->write_mask = (1U << rhs->type->vector_elements) - 1; + else if (rhs->type->is_scalar()) + this->write_mask = 1; + else + this->write_mask = 0; + + this->set_lhs(lhs); } diff --git a/src/glsl/ir.h b/src/glsl/ir.h index f964b36083a..98789503e06 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -514,6 +514,16 @@ class ir_assignment : public ir_instruction { public: ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition); + /** + * Construct an assignment with an explicit write mask + * + * \note + * Since a write mask is supplied, the LHS must already be a bare + * \c ir_dereference. The cannot be any swizzles in the LHS. + */ + ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, ir_rvalue *condition, + unsigned write_mask); + virtual ir_assignment *clone(void *mem_ctx, struct hash_table *ht) const; virtual ir_constant *constant_expression_value(); @@ -530,10 +540,32 @@ public: return this; } + /** + * Get a whole variable written by an assignment + * + * If the LHS of the assignment writes a whole variable, the variable is + * returned. Otherwise \c NULL is returned. Examples of whole-variable + * assignment are: + * + * - Assigning to a scalar + * - Assigning to all components of a vector + * - Whole array (or matrix) assignment + * - Whole structure assignment + */ + ir_variable *whole_variable_written(); + + /** + * Set the LHS of an assignment + */ + void set_lhs(ir_rvalue *lhs); + /** * Left-hand side of the assignment. + * + * This should be treated as read only. If you need to set the LHS of an + * assignment, use \c ir_assignment::set_lhs. */ - ir_rvalue *lhs; + ir_dereference *lhs; /** * Value being assigned @@ -544,6 +576,16 @@ public: * Optional condition for the assignment. */ ir_rvalue *condition; + + + /** + * Component mask written + * + * For non-vector types in the LHS, this field will be zero. For vector + * types, a bit will be set for each component that is written. Note that + * for \c vec2 and \c vec3 types only the lower bits will ever be set. + */ + unsigned write_mask:4; }; /* Update ir_expression::num_operands() and operator_strs when diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 59831834bd7..0e202164b32 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -242,7 +242,8 @@ ir_assignment::clone(void *mem_ctx, struct hash_table *ht) const return new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht), this->rhs->clone(mem_ctx, ht), - new_condition); + new_condition, + this->write_mask); } ir_function * diff --git a/src/glsl/ir_constant_variable.cpp b/src/glsl/ir_constant_variable.cpp index 749e2cf809f..1fb73e765e1 100644 --- a/src/glsl/ir_constant_variable.cpp +++ b/src/glsl/ir_constant_variable.cpp @@ -110,7 +110,7 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir) return visit_continue; } - ir_variable *var = ir->lhs->whole_variable_referenced(); + ir_variable *var = ir->whole_variable_written(); if (!var) return visit_continue; diff --git a/src/glsl/ir_copy_propagation.cpp b/src/glsl/ir_copy_propagation.cpp index 57123987322..26588a352c8 100644 --- a/src/glsl/ir_copy_propagation.cpp +++ b/src/glsl/ir_copy_propagation.cpp @@ -224,7 +224,7 @@ add_copy(void *ctx, ir_assignment *ir, exec_list *acp) return; } - ir_variable *lhs_var = ir->lhs->whole_variable_referenced(); + ir_variable *lhs_var = ir->whole_variable_written(); ir_variable *rhs_var = ir->rhs->whole_variable_referenced(); if ((lhs_var != NULL) && (rhs_var != NULL)) { diff --git a/src/glsl/ir_dead_code_local.cpp b/src/glsl/ir_dead_code_local.cpp index 7a44ec8a4a4..b22cc558df6 100644 --- a/src/glsl/ir_dead_code_local.cpp +++ b/src/glsl/ir_dead_code_local.cpp @@ -137,7 +137,7 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments) } /* Now, check if we did a whole-variable assignment. */ - if (always_assign && (ir->lhs->whole_variable_referenced() != NULL)) { + if (always_assign && (ir->whole_variable_written() != NULL)) { /* We did a whole-variable assignment. So, any instruction in * the assignment list with the same LHS is dead. */ diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 73476e7e9b6..39b11bb32cc 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -296,7 +296,19 @@ void ir_print_visitor::visit(ir_assignment *ir) else printf("(constant bool (1))"); - printf(" "); + + char mask[5]; + unsigned j = 0; + + for (unsigned i = 0; i < 4; i++) { + if ((ir->write_mask & (1 << i)) != 0) { + mask[j] = "xyzw"[i]; + j++; + } + } + mask[j] = '\0'; + + printf(" (%s) ", mask); ir->lhs->accept(this); diff --git a/src/glsl/ir_tree_grafting.cpp b/src/glsl/ir_tree_grafting.cpp index 6f62de758b2..38034a61977 100644 --- a/src/glsl/ir_tree_grafting.cpp +++ b/src/glsl/ir_tree_grafting.cpp @@ -315,7 +315,7 @@ tree_grafting_basic_block(ir_instruction *bb_first, if (!assign) continue; - ir_variable *lhs_var = assign->lhs->whole_variable_referenced(); + ir_variable *lhs_var = assign->whole_variable_written(); if (!lhs_var) continue; diff --git a/src/glsl/ir_vec_index_to_swizzle.cpp b/src/glsl/ir_vec_index_to_swizzle.cpp index 1e170cbae61..b3de91f8abd 100644 --- a/src/glsl/ir_vec_index_to_swizzle.cpp +++ b/src/glsl/ir_vec_index_to_swizzle.cpp @@ -107,7 +107,7 @@ ir_vec_index_to_swizzle_visitor::visit_enter(ir_swizzle *ir) ir_visitor_status ir_vec_index_to_swizzle_visitor::visit_enter(ir_assignment *ir) { - ir->lhs = convert_vec_index_to_swizzle(ir->lhs); + ir->set_lhs(convert_vec_index_to_swizzle(ir->lhs)); ir->rhs = convert_vec_index_to_swizzle(ir->rhs); return visit_continue; diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 777b4d91f48..1cec4aa6212 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -356,6 +356,7 @@ ir_to_mesa_visitor::ir_to_mesa_emit_op1(ir_instruction *ir, ir_to_mesa_dst_reg dst, ir_to_mesa_src_reg src0) { + assert(dst.writemask != 0); return ir_to_mesa_emit_op3(ir, op, dst, src0, ir_to_mesa_undef, ir_to_mesa_undef); } @@ -1615,21 +1616,17 @@ ir_to_mesa_visitor::visit(ir_dereference_record *ir) * We want to be careful in assignment setup to hit the actual storage * instead of potentially using a temporary like we might with the * ir_dereference handler. - * - * Thanks to ir_swizzle_swizzle, and ir_vec_index_to_swizzle, we - * should only see potentially one variable array index of a vector, - * and one swizzle, before getting to actual vec4 storage. So handle - * those, then go use ir_dereference to handle the rest. */ static struct ir_to_mesa_dst_reg -get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v, +get_assignment_lhs(ir_dereference *ir, ir_to_mesa_visitor *v, ir_to_mesa_src_reg *r) { - struct ir_to_mesa_dst_reg dst_reg; - ir_swizzle *swiz; - + /* The LHS must be a dereference. If the LHS is a variable indexed array + * access of a vector, it must be separated into a series conditional moves + * before reaching this point (see ir_vec_index_to_cond_assign). + */ + assert(ir->as_dereference()); ir_dereference_array *deref_array = ir->as_dereference_array(); - /* This should have been handled by ir_vec_index_to_cond_assign */ if (deref_array) { assert(!deref_array->array->type->is_vector()); } @@ -1638,38 +1635,7 @@ get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v, * swizzles in it and write swizzles using writemask, though. */ ir->accept(v); - dst_reg = ir_to_mesa_dst_reg_from_src(v->result); - - if ((swiz = ir->as_swizzle())) { - int swizzles[4] = { - swiz->mask.x, - swiz->mask.y, - swiz->mask.z, - swiz->mask.w - }; - int new_r_swizzle[4]; - int orig_r_swizzle = r->swizzle; - int i; - - for (i = 0; i < 4; i++) { - new_r_swizzle[i] = GET_SWZ(orig_r_swizzle, 0); - } - - dst_reg.writemask = 0; - for (i = 0; i < 4; i++) { - if (i < swiz->mask.num_components) { - dst_reg.writemask |= 1 << swizzles[i]; - new_r_swizzle[swizzles[i]] = GET_SWZ(orig_r_swizzle, i); - } - } - - r->swizzle = MAKE_SWIZZLE4(new_r_swizzle[0], - new_r_swizzle[1], - new_r_swizzle[2], - new_r_swizzle[3]); - } - - return dst_reg; + return ir_to_mesa_dst_reg_from_src(v->result); } void @@ -1684,6 +1650,23 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) l = get_assignment_lhs(ir->lhs, this, &r); + /* FINISHME: This should really set to the correct maximal writemask for each + * FINISHME: component written (in the loops below). This case can only + * FINISHME: occur for matrices, arrays, and structures. + */ + if (ir->write_mask == 0) { + assert(!ir->lhs->type->is_scalar() && !ir->lhs->type->is_vector()); + l.writemask = WRITEMASK_XYZW; + } else if (ir->lhs->type->is_scalar()) { + /* FINISHME: This hack makes writing to gl_FragData, which lives in the + * FINISHME: W component of fragment shader output zero, work correctly. + */ + l.writemask = WRITEMASK_XYZW; + } else { + assert(ir->lhs->type->is_vector()); + l.writemask = ir->write_mask; + } + assert(l.file != PROGRAM_UNDEFINED); assert(r.file != PROGRAM_UNDEFINED); -- cgit v1.2.3 From 6235c6a83855fe2818affda3c82e1a245bd0232e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 4 Aug 2010 16:27:17 -0700 Subject: glsl2: Additional validation of write masks --- src/glsl/ir_validate.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 89bcd1c4811..701bf21ea61 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -67,6 +67,8 @@ public: virtual ir_visitor_status visit_leave(ir_expression *ir); + virtual ir_visitor_status visit_enter(ir_assignment *ir); + static void validate_ir(ir_instruction *ir, void *data); ir_function *current_function; @@ -320,6 +322,36 @@ ir_validate::visit(ir_variable *ir) return visit_continue; } +ir_visitor_status +ir_validate::visit_enter(ir_assignment *ir) +{ + const ir_dereference *const lhs = ir->lhs; + if (lhs->type->is_scalar() || lhs->type->is_vector()) { + if (ir->write_mask == 0) { + printf("Assignment LHS is %s, but write mask is 0:\n", + lhs->type->is_scalar() ? "scalar" : "vector"); + ir->print(); + abort(); + } + + /* Mask of fields that do not exist in the destination. These should + * not be written by the assignment. + */ + const unsigned invalid_mask = ~((1U << lhs->type->components()) - 1); + + if ((invalid_mask & ir->write_mask) != 0) { + printf("Assignment write mask enables invalid components for " + "type %s:\n", lhs->type->name); + ir->print(); + abort(); + } + } + + this->validate_ir(ir, this->data); + + return visit_continue; +} + void ir_validate::validate_ir(ir_instruction *ir, void *data) { -- cgit v1.2.3 From 3d58be6135e71e6105ae65850f2dbeaf9ecff5c3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 3 Aug 2010 16:05:54 -0700 Subject: glsl2: Generate masked assignments in vector and matrix constructors Previously the in-line matrix and vector constructors would generate swizzles in the LHS. The code is actually more clear if it just generates the masked assignments instead of relying on the ir_assignment constructor to convert the swizzles to write masks. --- src/glsl/ast_function.cpp | 82 ++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index c22dfa81eb8..1b8b3195e5b 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -572,16 +572,17 @@ emit_inline_vector_constructor(const glsl_type *type, ir_rvalue *rhs = new(ctx) ir_swizzle(first_param, 0, 0, 0, 0, lhs_components); ir_dereference_variable *lhs = new(ctx) ir_dereference_variable(var); + const unsigned mask = (1U << lhs_components) - 1; assert(rhs->type == lhs->type); - ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL); + ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL, mask); instructions->push_tail(inst); } else { unsigned base_component = 0; foreach_list(node, parameters) { - ir_rvalue *rhs = (ir_rvalue *) node; - unsigned rhs_components = rhs->type->components(); + ir_rvalue *param = (ir_rvalue *) node; + unsigned rhs_components = param->type->components(); /* Do not try to assign more components to the vector than it has! */ @@ -589,19 +590,23 @@ emit_inline_vector_constructor(const glsl_type *type, rhs_components = lhs_components - base_component; } - /* Emit an assignment of the constructor parameter to the next set of - * components in the temporary variable. + /* Generate a swizzle that puts the first element of the source at + * the location of the first element of the destination. */ - unsigned mask[4] = { 0, 0, 0, 0 }; - for (unsigned i = 0; i < rhs_components; i++) { - mask[i] = i + base_component; - } + unsigned swiz[4] = { 0, 0, 0, 0 }; + for (unsigned i = 0; i < rhs_components; i++) + swiz[i + base_component] = i; + /* Mask of fields to be written in the assignment. + */ + const unsigned write_mask = ((1U << rhs_components) - 1) + << base_component; - ir_rvalue *lhs_ref = new(ctx) ir_dereference_variable(var); - ir_swizzle *lhs = new(ctx) ir_swizzle(lhs_ref, mask, rhs_components); + ir_dereference *lhs = new(ctx) ir_dereference_variable(var); + ir_rvalue *rhs = new(ctx) ir_swizzle(param, swiz, lhs_components); - ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL); + ir_instruction *inst = + new(ctx) ir_assignment(lhs, rhs, NULL, write_mask); instructions->push_tail(inst); /* Advance the component index by the number of components that were @@ -631,18 +636,27 @@ assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base, ir_rvalue *src, unsigned src_base, unsigned count, void *mem_ctx) { - const unsigned mask[8] = { 0, 1, 2, 3, 0, 0, 0, 0 }; - ir_constant *col_idx = new(mem_ctx) ir_constant(column); - ir_rvalue *column_ref = new(mem_ctx) ir_dereference_array(var, col_idx); + ir_dereference *column_ref = new(mem_ctx) ir_dereference_array(var, col_idx); assert(column_ref->type->components() >= (row_base + count)); - ir_rvalue *lhs = new(mem_ctx) ir_swizzle(column_ref, &mask[row_base], count); - assert(src->type->components() >= (src_base + count)); - ir_rvalue *rhs = new(mem_ctx) ir_swizzle(src, &mask[src_base], count); - return new(mem_ctx) ir_assignment(lhs, rhs, NULL); + /* Generate a swizzle that puts the first element of the source at the + * location of the first element of the destination. + */ + unsigned swiz[4] = { src_base, src_base, src_base, src_base }; + for (unsigned i = 0; i < count; i++) + swiz[i + row_base] = src_base + i; + + ir_rvalue *const rhs = + new(mem_ctx) ir_swizzle(src, swiz, column_ref->type->components()); + + /* Mask of fields to be written in the assignment. + */ + const unsigned write_mask = ((1U << count) - 1) << row_base; + + return new(mem_ctx) ir_assignment(column_ref, rhs, NULL, write_mask); } @@ -704,10 +718,9 @@ emit_inline_matrix_constructor(const glsl_type *type, NULL); instructions->push_tail(inst); - ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); - ir_rvalue *const x_of_rhs = new(ctx) ir_swizzle(rhs_ref, 0, 0, 0, 0, 1); + ir_dereference *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); - inst = new(ctx) ir_assignment(x_of_rhs, first_param, NULL); + inst = new(ctx) ir_assignment(rhs_ref, first_param, NULL, 0x01); instructions->push_tail(inst); /* Assign the temporary vector to each column of the destination matrix @@ -813,11 +826,16 @@ emit_inline_matrix_constructor(const glsl_type *type, instructions->push_tail(inst); - const unsigned swiz[4] = { 0, 1, 2, 3 }; + unsigned swiz[4] = { 0, 0, 0, 0 }; + for (unsigned i = 1; i < src_matrix->type->vector_elements; i++) + swiz[i] = i; + const unsigned last_col = min(src_matrix->type->matrix_columns, var->type->matrix_columns); + const unsigned write_mask = (1U << var->type->vector_elements) - 1; + for (unsigned i = 0; i < last_col; i++) { - ir_rvalue *const lhs_col = + ir_dereference *const lhs = new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i)); ir_rvalue *const rhs_col = new(ctx) ir_dereference_array(rhs_var, new(ctx) ir_constant(i)); @@ -830,26 +848,18 @@ emit_inline_matrix_constructor(const glsl_type *type, * It would be perfectly valid to unconditionally generate the * swizzles, this this will typically result in a more compact IR tree. */ - ir_rvalue *lhs; ir_rvalue *rhs; - if (lhs_col->type->vector_elements < rhs_col->type->vector_elements) { - lhs = lhs_col; - + if (lhs->type->vector_elements != rhs_col->type->vector_elements) { rhs = new(ctx) ir_swizzle(rhs_col, swiz, - lhs_col->type->vector_elements); - } else if (lhs_col->type->vector_elements - > rhs_col->type->vector_elements) { - lhs = new(ctx) ir_swizzle(lhs_col, swiz, - rhs_col->type->vector_elements); - rhs = rhs_col; + lhs->type->vector_elements); } else { - lhs = lhs_col; rhs = rhs_col; } assert(lhs->type == rhs->type); - ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL); + ir_instruction *inst = + new(ctx) ir_assignment(lhs, rhs, NULL, write_mask); instructions->push_tail(inst); } } else { -- cgit v1.2.3 From 83cb310dbb47357c4b3065ca0d6739796d9e371f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 4 Aug 2010 16:27:55 -0700 Subject: glsl2: Generate masked assignments in some expanded matrix operations --- src/glsl/ir_mat_op_to_vec.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/glsl/ir_mat_op_to_vec.cpp b/src/glsl/ir_mat_op_to_vec.cpp index 742fc2a2952..880454c0076 100644 --- a/src/glsl/ir_mat_op_to_vec.cpp +++ b/src/glsl/ir_mat_op_to_vec.cpp @@ -44,7 +44,7 @@ public: ir_visitor_status visit_leave(ir_assignment *); - ir_rvalue *get_column(ir_variable *var, int col); + ir_dereference *get_column(ir_variable *var, int col); ir_rvalue *get_element(ir_variable *var, int col, int row); void do_mul_mat_mat(ir_variable *result_var, @@ -109,7 +109,7 @@ ir_mat_op_to_vec_visitor::get_element(ir_variable *var, int col, int row) return new(base_ir) ir_swizzle(deref, row, 0, 0, 0, 1); } -ir_rvalue * +ir_dereference * ir_mat_op_to_vec_visitor::get_column(ir_variable *var, int row) { ir_dereference *deref; @@ -314,7 +314,9 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign) case ir_binop_add: case ir_binop_sub: case ir_binop_div: - case ir_binop_mod: + case ir_binop_mod: { + const unsigned mask = (1U << result_var->type->vector_elements) - 1; + /* For most operations, the matrix version is just going * column-wise through and applying the operation to each column * if available. @@ -322,7 +324,7 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign) for (i = 0; i < matrix_columns; i++) { ir_rvalue *op0 = get_column(op_var[0], i); ir_rvalue *op1 = get_column(op_var[1], i); - ir_rvalue *result = get_column(result_var, i); + ir_dereference *result = get_column(result_var, i); ir_expression *column_expr; ir_assignment *column_assign; @@ -333,10 +335,13 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign) column_assign = new(base_ir) ir_assignment(result, column_expr, - NULL); + NULL, + mask); + assert(column_assign->write_mask != 0); base_ir->insert_before(column_assign); } break; + } case ir_binop_mul: if (op_var[0]->type->is_matrix()) { if (op_var[1]->type->is_matrix()) { -- cgit v1.2.3 From 022f79e49648d465d2db0240554f58ac42754584 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 16:32:12 -0700 Subject: glsl2: Return progress from ir_vec_index_to_swizzle. --- src/glsl/ir_vec_index_to_swizzle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_vec_index_to_swizzle.cpp b/src/glsl/ir_vec_index_to_swizzle.cpp index b3de91f8abd..969dc8f94a2 100644 --- a/src/glsl/ir_vec_index_to_swizzle.cpp +++ b/src/glsl/ir_vec_index_to_swizzle.cpp @@ -153,5 +153,5 @@ do_vec_index_to_swizzle(exec_list *instructions) v.run(instructions); - return false; + return v.progress; } -- cgit v1.2.3 From e3a90b8e38b1d0de9f473caca96779e215071315 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 17:12:14 -0700 Subject: glsl2: Use linked ir_constant_variable after linking, instead of unlinked. --- src/glsl/linker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 10fd2d5ab93..b2953c67d11 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1293,7 +1293,7 @@ link_shaders(struct gl_shader_program *prog) progress = do_dead_code_local(ir) || progress; progress = do_dead_code(ir) || progress; progress = do_tree_grafting(ir) || progress; - progress = do_constant_variable_unlinked(ir) || progress; + progress = do_constant_variable(ir) || progress; progress = do_constant_folding(ir) || progress; progress = do_algebraic(ir) || progress; progress = do_if_return(ir) || progress; -- cgit v1.2.3 From 455290e4281bf53ce2fe248a2adf5163563c44c8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 19:43:41 -0700 Subject: ir_to_mesa: Print shader source and compiled IR under MESA_GLSL=dump. While the Mesa IR dumping includes some corresponding GLSL IR for correlating Mesa IR to GLSL IR, it doesn't completely express it. This printing includes things like variable declarations and control flow structure that is hard to read otherwise. --- src/mesa/program/ir_to_mesa.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 1cec4aa6212..2fd07ca6115 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2545,7 +2545,14 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, set_branchtargets(&v, mesa_instructions, num_instructions); if (ctx->Shader.Flags & GLSL_DUMP) { - printf("Mesa %s program:\n", target_string); + printf("\n"); + printf("GLSL IR for linked %s program %d:\n", target_string, + shader_program->Name); + _mesa_print_ir(shader->ir, NULL); + printf("\n"); + printf("\n"); + printf("Mesa IR for linked %s program %d:\n", target_string, + shader_program->Name); print_program(mesa_instructions, mesa_instruction_annotation, num_instructions); } @@ -2635,6 +2642,15 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) _mesa_write_shader_to_file(shader); } + if (ctx->Shader.Flags & GLSL_DUMP) { + printf("GLSL source for shader %d:\n", shader->Name); + printf("%s\n", shader->Source); + + printf("GLSL IR for shader %d:\n", shader->Name); + _mesa_print_ir(shader->ir, NULL); + printf("\n\n"); + } + /* Retain any live IR, but trash the rest. */ reparent_ir(shader->ir, shader); -- cgit v1.2.3 From 72fd0568db0ce5f25a1eee0266ec1e7cb3dafab0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 19:55:52 -0700 Subject: i965: Settle on printing our program debug to stdout. Mixing stderr (_mesa_print_program, _mesa_print_instruction, _mesa_print_alu) with stdout means that when writing both to a file, there isn't a consistent ordering between the two. --- src/mesa/drivers/dri/i965/brw_vs.c | 8 ++++---- src/mesa/drivers/dri/i965/brw_vs_emit.c | 3 ++- src/mesa/drivers/dri/i965/brw_wm_fp.c | 10 +++++----- src/mesa/program/prog_print.c | 32 ++++++++++++++++---------------- src/mesa/program/prog_print.h | 7 +++++++ 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index 9a832af9a97..9f90e1e5e5c 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -75,10 +75,10 @@ static void do_vs_prog( struct brw_context *brw, c.prog_data.outputs_written |= BITFIELD64_BIT(VERT_RESULT_TEX0 + i); } - if (0) - _mesa_print_program(&c.vp->program.Base); - - + if (0) { + _mesa_fprint_program_opt(stdout, &c.vp->program.Base, PROG_PRINT_DEBUG, + GL_TRUE); + } /* Emit GEN4 code. */ diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index c1d6525e9b7..d2bd2c7f797 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -1564,7 +1564,8 @@ void brw_vs_emit(struct brw_vs_compile *c ) if (INTEL_DEBUG & DEBUG_VS) { printf("vs-mesa:\n"); - _mesa_print_program(&c->vp->program.Base); + _mesa_fprint_program_opt(stdout, &c->vp->program.Base, PROG_PRINT_DEBUG, + GL_TRUE); printf("\n"); } diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c index df9e54c6b4e..3870bf10fcb 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_fp.c +++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c @@ -1037,13 +1037,12 @@ static void print_insns( const struct prog_instruction *insn, for (i = 0; i < nr; i++, insn++) { printf("%3d: ", i); if (insn->Opcode < MAX_OPCODE) - _mesa_print_instruction(insn); + _mesa_fprint_instruction_opt(stdout, insn, 0, PROG_PRINT_DEBUG, NULL); else if (insn->Opcode < MAX_WM_OPCODE) { GLuint idx = insn->Opcode - MAX_OPCODE; - _mesa_print_alu_instruction(insn, - wm_opcode_strings[idx], - 3); + _mesa_fprint_alu_instruction(stdout, insn, wm_opcode_strings[idx], + 3, PROG_PRINT_DEBUG, NULL); } else printf("965 Opcode %d\n", insn->Opcode); @@ -1062,7 +1061,8 @@ void brw_wm_pass_fp( struct brw_wm_compile *c ) if (INTEL_DEBUG & DEBUG_WM) { printf("pre-fp:\n"); - _mesa_print_program(&fp->program.Base); + _mesa_fprint_program_opt(stdout, &fp->program.Base, PROG_PRINT_DEBUG, + GL_TRUE); printf("\n"); } diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c index b66d709d50f..1ce1bf2f4ed 100644 --- a/src/mesa/program/prog_print.c +++ b/src/mesa/program/prog_print.c @@ -540,12 +540,12 @@ fprint_comment(FILE *f, const struct prog_instruction *inst) } -static void -fprint_alu_instruction(FILE *f, - const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs, - gl_prog_print_mode mode, - const struct gl_program *prog) +void +_mesa_fprint_alu_instruction(FILE *f, + const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs, + gl_prog_print_mode mode, + const struct gl_program *prog) { GLuint j; @@ -582,8 +582,8 @@ void _mesa_print_alu_instruction(const struct prog_instruction *inst, const char *opcode_string, GLuint numRegs) { - fprint_alu_instruction(stderr, inst, opcode_string, - numRegs, PROG_PRINT_DEBUG, NULL); + _mesa_fprint_alu_instruction(stderr, inst, opcode_string, + numRegs, PROG_PRINT_DEBUG, NULL); } @@ -791,16 +791,16 @@ _mesa_fprint_instruction_opt(FILE *f, default: if (inst->Opcode < MAX_OPCODE) { /* typical alu instruction */ - fprint_alu_instruction(f, inst, - _mesa_opcode_string(inst->Opcode), - _mesa_num_inst_src_regs(inst->Opcode), - mode, prog); + _mesa_fprint_alu_instruction(f, inst, + _mesa_opcode_string(inst->Opcode), + _mesa_num_inst_src_regs(inst->Opcode), + mode, prog); } else { - fprint_alu_instruction(f, inst, - _mesa_opcode_string(inst->Opcode), - 3/*_mesa_num_inst_src_regs(inst->Opcode)*/, - mode, prog); + _mesa_fprint_alu_instruction(f, inst, + _mesa_opcode_string(inst->Opcode), + 3/*_mesa_num_inst_src_regs(inst->Opcode)*/, + mode, prog); } break; } diff --git a/src/mesa/program/prog_print.h b/src/mesa/program/prog_print.h index 9ab74560169..4ffd5ab96c6 100644 --- a/src/mesa/program/prog_print.h +++ b/src/mesa/program/prog_print.h @@ -55,6 +55,13 @@ _mesa_writemask_string(GLuint writeMask); extern void _mesa_print_swizzle(GLuint swizzle); +extern void +_mesa_fprint_alu_instruction(FILE *f, + const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs, + gl_prog_print_mode mode, + const struct gl_program *prog); + extern void _mesa_print_alu_instruction(const struct prog_instruction *inst, const char *opcode_string, GLuint numRegs); -- cgit v1.2.3 From a08f27940ac72538ce0b264917207111d629f097 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 20:03:15 -0700 Subject: glsl2: Remove a dead cut and paste member from ir_variable_refcount_visitor. --- src/glsl/ir_variable_refcount.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/glsl/ir_variable_refcount.h b/src/glsl/ir_variable_refcount.h index d69cab563e2..30dd2bd587e 100644 --- a/src/glsl/ir_variable_refcount.h +++ b/src/glsl/ir_variable_refcount.h @@ -78,8 +78,6 @@ public: variable_entry *get_variable_entry(ir_variable *var); - bool (*predicate)(ir_instruction *ir); - /* List of variable_entry */ exec_list variable_list; -- cgit v1.2.3 From 046bef235744e891e4a48076e1a3ff9a61a63092 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 20:33:57 -0700 Subject: glsl2: Remove the shader_in/shader_out tracking separate from var->mode. I introduced this for ir_dead_code to distinguish function parameter outvals from varying outputs. Only, since ast_to_hir's current_function is unset when setting up function parameters (they're needed for making the function signature in the first place), all function parameter outvals were marked as shader outputs anyway. This meant that an inlined function's cloned outval was marked as a shader output and couldn't be dead-code eliminated. Instead, since ir_dead_code doesn't even look at function parameters, just use var->mode. The longest Mesa IR coming out of ir_to_mesa for Yo Frankie drops from 725 instructions to 636. --- src/glsl/ast_to_hir.cpp | 37 ++++++++++--------------------------- src/glsl/ir.cpp | 4 ---- src/glsl/ir.h | 14 ++++---------- src/glsl/ir_clone.cpp | 2 -- src/glsl/ir_dead_code.cpp | 3 ++- src/glsl/ir_variable.cpp | 12 +----------- src/glsl/linker.cpp | 2 -- 7 files changed, 17 insertions(+), 57 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 14c528075bb..292c7be6217 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1510,31 +1510,6 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, else if (qual->uniform) var->mode = ir_var_uniform; - if (qual->uniform) - var->shader_in = true; - - /* Any 'in' or 'inout' variables at global scope must be marked as being - * shader inputs. Likewise, any 'out' or 'inout' variables at global scope - * must be marked as being shader outputs. - */ - if (state->current_function == NULL) { - switch (var->mode) { - case ir_var_in: - case ir_var_uniform: - var->shader_in = true; - break; - case ir_var_out: - var->shader_out = true; - break; - case ir_var_inout: - var->shader_in = true; - var->shader_out = true; - break; - default: - break; - } - } - if (qual->flat) var->interpolation = ir_var_flat; else if (qual->noperspective) @@ -1702,11 +1677,19 @@ ast_declarator_list::hir(exec_list *instructions, & loc); if (this->type->qualifier.invariant) { - if ((state->target == vertex_shader) && !var->shader_out) { + if ((state->target == vertex_shader) && !(var->mode == ir_var_out || + var->mode == ir_var_inout)) { + /* FINISHME: Note that this doesn't work for invariant on + * a function signature outval + */ _mesa_glsl_error(& loc, state, "`%s' cannot be marked invariant, vertex shader " "outputs only\n", var->name); - } else if ((state->target == fragment_shader) && !var->shader_in) { + } else if ((state->target == fragment_shader) && + !(var->mode == ir_var_in || var->mode == ir_var_inout)) { + /* FINISHME: Note that this doesn't work for invariant on + * a function signature inval + */ _mesa_glsl_error(& loc, state, "`%s' cannot be marked invariant, fragment shader " "inputs only\n", var->name); diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index c3bade8d549..dd059e470d5 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -902,7 +902,6 @@ ir_swizzle::variable_referenced() ir_variable::ir_variable(const struct glsl_type *type, const char *name, ir_variable_mode mode) : max_array_access(0), read_only(false), centroid(false), invariant(false), - shader_in(false), shader_out(false), mode(mode), interpolation(ir_var_smooth), array_lvalue(false) { this->ir_type = ir_type_variable; @@ -922,9 +921,6 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, const char * ir_variable::interpolation_string() const { - if (!this->shader_in && !this->shader_out) - return ""; - switch (this->interpolation) { case ir_var_smooth: return "smooth"; case ir_var_flat: return "flat"; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 98789503e06..e61485813dc 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -194,10 +194,10 @@ public: /** * Get the string value for the interpolation qualifier * - * \return - * If none of \c shader_in or \c shader_out is set, an empty string will - * be returned. Otherwise the string that would be used in a shader to - * specify \c mode will be returned. + * \return The string that would be used in a shader to specify \c + * mode will be returned. + * + * This function should only be used on a shader input or output variable. */ const char *interpolation_string() const; @@ -221,12 +221,6 @@ public: unsigned read_only:1; unsigned centroid:1; unsigned invariant:1; - /** If the variable is initialized outside of the scope of the shader */ - unsigned shader_in:1; - /** - * If the variable value is later used outside of the scope of the shader. - */ - unsigned shader_out:1; unsigned mode:3; unsigned interpolation:2; diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 0e202164b32..a72609601ae 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -45,8 +45,6 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const var->read_only = this->read_only; var->centroid = this->centroid; var->invariant = this->invariant; - var->shader_in = this->shader_in; - var->shader_out = this->shader_out; var->interpolation = this->interpolation; var->array_lvalue = this->array_lvalue; var->location = this->location; diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp index 2b971b7aaac..bf032f1dc21 100644 --- a/src/glsl/ir_dead_code.cpp +++ b/src/glsl/ir_dead_code.cpp @@ -68,7 +68,8 @@ do_dead_code(exec_list *instructions) /* Remove a single dead assignment to the variable we found. * Don't do so if it's a shader output, though. */ - if (!entry->var->shader_out) { + if (entry->var->mode != ir_var_out && + entry->var->mode != ir_var_inout) { entry->assign->remove(); progress = true; } diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 478cefc5a6c..d9a16d42879 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -43,22 +43,12 @@ add_variable(const char *name, enum ir_variable_mode mode, int slot, switch (var->mode) { case ir_var_auto: - var->read_only = true; - break; case ir_var_in: - var->shader_in = true; + case ir_var_uniform: var->read_only = true; break; case ir_var_inout: - var->shader_in = true; - var->shader_out = true; - break; case ir_var_out: - var->shader_out = true; - break; - case ir_var_uniform: - var->shader_in = true; - var->read_only = true; break; default: assert(0); diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index b2953c67d11..94db57d6a52 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1124,7 +1124,6 @@ assign_varying_locations(struct gl_shader_program *prog, * by the following stage. */ if (var->location == -1) { - var->shader_out = false; var->mode = ir_var_auto; } } @@ -1158,7 +1157,6 @@ assign_varying_locations(struct gl_shader_program *prog, /* An 'in' variable is only really a shader input if its * value is written by the previous stage. */ - var->shader_in = false; var->mode = ir_var_auto; } } -- cgit v1.2.3 From 16b4eed59a07f5e07587f4f9b0cdc304a08a685c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 4 Aug 2010 16:10:03 -0700 Subject: glcpp: Refactor HASH_IF and HASH_ELIF expansion to reuse code. --- src/glsl/glcpp/glcpp-parse.c | 247 +++++++++++++++++++++---------------------- src/glsl/glcpp/glcpp-parse.y | 39 ++++--- 2 files changed, 142 insertions(+), 144 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 5ea07c2555e..df16cabeebd 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -175,6 +175,9 @@ _active_list_pop (active_list_t *list); int _active_list_contains (active_list_t *list, const char *identifier); +static void +_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list); + static void _glcpp_parser_expand_token_list (glcpp_parser_t *parser, token_list_t *list); @@ -208,7 +211,7 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); /* Line 189 of yacc.c */ -#line 212 "glcpp/glcpp-parse.c" +#line 215 "glcpp/glcpp-parse.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -296,7 +299,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 300 "glcpp/glcpp-parse.c" +#line 303 "glcpp/glcpp-parse.c" #ifdef short # undef short @@ -620,17 +623,17 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 169, 169, 171, 175, 178, 183, 184, 188, 191, - 197, 200, 203, 206, 214, 226, 231, 236, 248, 259, - 262, 265, 274, 278, 287, 292, 293, 296, 299, 302, - 305, 308, 311, 314, 317, 320, 323, 326, 329, 332, - 335, 338, 341, 344, 347, 350, 353, 356, 359, 365, - 370, 378, 379, 383, 389, 390, 393, 395, 402, 406, - 410, 415, 421, 429, 435, 443, 447, 451, 455, 459, - 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, - 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, - 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, - 496 + 0, 172, 172, 174, 178, 181, 186, 187, 191, 194, + 200, 203, 206, 209, 217, 220, 225, 230, 233, 244, + 247, 250, 259, 263, 272, 277, 278, 281, 284, 287, + 290, 293, 296, 299, 302, 305, 308, 311, 314, 317, + 320, 323, 326, 329, 332, 335, 338, 341, 344, 350, + 355, 363, 364, 368, 374, 375, 378, 380, 387, 391, + 395, 400, 406, 414, 420, 428, 432, 436, 440, 444, + 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, + 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, + 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, + 481 }; #endif @@ -1781,7 +1784,7 @@ yyreduce: case 4: /* Line 1464 of yacc.c */ -#line 175 "glcpp/glcpp-parse.y" +#line 178 "glcpp/glcpp-parse.y" { glcpp_print(parser->output, "\n"); ;} @@ -1790,7 +1793,7 @@ yyreduce: case 5: /* Line 1464 of yacc.c */ -#line 178 "glcpp/glcpp-parse.y" +#line 181 "glcpp/glcpp-parse.y" { _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); glcpp_print(parser->output, "\n"); @@ -1801,7 +1804,7 @@ yyreduce: case 8: /* Line 1464 of yacc.c */ -#line 188 "glcpp/glcpp-parse.y" +#line 191 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); ;} @@ -1810,7 +1813,7 @@ yyreduce: case 9: /* Line 1464 of yacc.c */ -#line 191 "glcpp/glcpp-parse.y" +#line 194 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); ;} @@ -1819,7 +1822,7 @@ yyreduce: case 10: /* Line 1464 of yacc.c */ -#line 197 "glcpp/glcpp-parse.y" +#line 200 "glcpp/glcpp-parse.y" { _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); ;} @@ -1828,7 +1831,7 @@ yyreduce: case 11: /* Line 1464 of yacc.c */ -#line 200 "glcpp/glcpp-parse.y" +#line 203 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); ;} @@ -1837,7 +1840,7 @@ yyreduce: case 12: /* Line 1464 of yacc.c */ -#line 203 "glcpp/glcpp-parse.y" +#line 206 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); ;} @@ -1846,7 +1849,7 @@ yyreduce: case 13: /* Line 1464 of yacc.c */ -#line 206 "glcpp/glcpp-parse.y" +#line 209 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); if (macro) { @@ -1860,25 +1863,16 @@ yyreduce: case 14: /* Line 1464 of yacc.c */ -#line 214 "glcpp/glcpp-parse.y" +#line 217 "glcpp/glcpp-parse.y" { - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, IF_EXPANDED, IF_EXPANDED); - _token_list_append (expanded, token); - talloc_unlink (parser, token); - _glcpp_parser_expand_token_list (parser, (yyvsp[(2) - (3)].token_list)); - _token_list_append_list (expanded, (yyvsp[(2) - (3)].token_list)); - glcpp_parser_lex_from (parser, expanded); + _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list)); ;} break; case 15: /* Line 1464 of yacc.c */ -#line 226 "glcpp/glcpp-parse.y" +#line 220 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1889,7 +1883,7 @@ yyreduce: case 16: /* Line 1464 of yacc.c */ -#line 231 "glcpp/glcpp-parse.y" +#line 225 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1900,25 +1894,16 @@ yyreduce: case 17: /* Line 1464 of yacc.c */ -#line 236 "glcpp/glcpp-parse.y" +#line 230 "glcpp/glcpp-parse.y" { - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, ELIF_EXPANDED, ELIF_EXPANDED); - _token_list_append (expanded, token); - talloc_unlink (parser, token); - _glcpp_parser_expand_token_list (parser, (yyvsp[(2) - (3)].token_list)); - _token_list_append_list (expanded, (yyvsp[(2) - (3)].token_list)); - glcpp_parser_lex_from (parser, expanded); + _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list)); ;} break; case 18: /* Line 1464 of yacc.c */ -#line 248 "glcpp/glcpp-parse.y" +#line 233 "glcpp/glcpp-parse.y" { /* #elif without an expression results in a warning if the * condition doesn't matter (we just handled #if 1 or such) @@ -1935,7 +1920,7 @@ yyreduce: case 19: /* Line 1464 of yacc.c */ -#line 259 "glcpp/glcpp-parse.y" +#line 244 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); ;} @@ -1944,7 +1929,7 @@ yyreduce: case 20: /* Line 1464 of yacc.c */ -#line 262 "glcpp/glcpp-parse.y" +#line 247 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); ;} @@ -1953,7 +1938,7 @@ yyreduce: case 21: /* Line 1464 of yacc.c */ -#line 265 "glcpp/glcpp-parse.y" +#line 250 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); if (macro) { @@ -1968,7 +1953,7 @@ yyreduce: case 23: /* Line 1464 of yacc.c */ -#line 278 "glcpp/glcpp-parse.y" +#line 263 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); @@ -1983,7 +1968,7 @@ yyreduce: case 24: /* Line 1464 of yacc.c */ -#line 287 "glcpp/glcpp-parse.y" +#line 272 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} @@ -1992,7 +1977,7 @@ yyreduce: case 26: /* Line 1464 of yacc.c */ -#line 293 "glcpp/glcpp-parse.y" +#line 278 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); ;} @@ -2001,7 +1986,7 @@ yyreduce: case 27: /* Line 1464 of yacc.c */ -#line 296 "glcpp/glcpp-parse.y" +#line 281 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); ;} @@ -2010,7 +1995,7 @@ yyreduce: case 28: /* Line 1464 of yacc.c */ -#line 299 "glcpp/glcpp-parse.y" +#line 284 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); ;} @@ -2019,7 +2004,7 @@ yyreduce: case 29: /* Line 1464 of yacc.c */ -#line 302 "glcpp/glcpp-parse.y" +#line 287 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); ;} @@ -2028,7 +2013,7 @@ yyreduce: case 30: /* Line 1464 of yacc.c */ -#line 305 "glcpp/glcpp-parse.y" +#line 290 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); ;} @@ -2037,7 +2022,7 @@ yyreduce: case 31: /* Line 1464 of yacc.c */ -#line 308 "glcpp/glcpp-parse.y" +#line 293 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); ;} @@ -2046,7 +2031,7 @@ yyreduce: case 32: /* Line 1464 of yacc.c */ -#line 311 "glcpp/glcpp-parse.y" +#line 296 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); ;} @@ -2055,7 +2040,7 @@ yyreduce: case 33: /* Line 1464 of yacc.c */ -#line 314 "glcpp/glcpp-parse.y" +#line 299 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); ;} @@ -2064,7 +2049,7 @@ yyreduce: case 34: /* Line 1464 of yacc.c */ -#line 317 "glcpp/glcpp-parse.y" +#line 302 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); ;} @@ -2073,7 +2058,7 @@ yyreduce: case 35: /* Line 1464 of yacc.c */ -#line 320 "glcpp/glcpp-parse.y" +#line 305 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); ;} @@ -2082,7 +2067,7 @@ yyreduce: case 36: /* Line 1464 of yacc.c */ -#line 323 "glcpp/glcpp-parse.y" +#line 308 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); ;} @@ -2091,7 +2076,7 @@ yyreduce: case 37: /* Line 1464 of yacc.c */ -#line 326 "glcpp/glcpp-parse.y" +#line 311 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); ;} @@ -2100,7 +2085,7 @@ yyreduce: case 38: /* Line 1464 of yacc.c */ -#line 329 "glcpp/glcpp-parse.y" +#line 314 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); ;} @@ -2109,7 +2094,7 @@ yyreduce: case 39: /* Line 1464 of yacc.c */ -#line 332 "glcpp/glcpp-parse.y" +#line 317 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); ;} @@ -2118,7 +2103,7 @@ yyreduce: case 40: /* Line 1464 of yacc.c */ -#line 335 "glcpp/glcpp-parse.y" +#line 320 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); ;} @@ -2127,7 +2112,7 @@ yyreduce: case 41: /* Line 1464 of yacc.c */ -#line 338 "glcpp/glcpp-parse.y" +#line 323 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); ;} @@ -2136,7 +2121,7 @@ yyreduce: case 42: /* Line 1464 of yacc.c */ -#line 341 "glcpp/glcpp-parse.y" +#line 326 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); ;} @@ -2145,7 +2130,7 @@ yyreduce: case 43: /* Line 1464 of yacc.c */ -#line 344 "glcpp/glcpp-parse.y" +#line 329 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); ;} @@ -2154,7 +2139,7 @@ yyreduce: case 44: /* Line 1464 of yacc.c */ -#line 347 "glcpp/glcpp-parse.y" +#line 332 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); ;} @@ -2163,7 +2148,7 @@ yyreduce: case 45: /* Line 1464 of yacc.c */ -#line 350 "glcpp/glcpp-parse.y" +#line 335 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); ;} @@ -2172,7 +2157,7 @@ yyreduce: case 46: /* Line 1464 of yacc.c */ -#line 353 "glcpp/glcpp-parse.y" +#line 338 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); ;} @@ -2181,7 +2166,7 @@ yyreduce: case 47: /* Line 1464 of yacc.c */ -#line 356 "glcpp/glcpp-parse.y" +#line 341 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); ;} @@ -2190,7 +2175,7 @@ yyreduce: case 48: /* Line 1464 of yacc.c */ -#line 359 "glcpp/glcpp-parse.y" +#line 344 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); ;} @@ -2199,7 +2184,7 @@ yyreduce: case 49: /* Line 1464 of yacc.c */ -#line 365 "glcpp/glcpp-parse.y" +#line 350 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); @@ -2210,7 +2195,7 @@ yyreduce: case 50: /* Line 1464 of yacc.c */ -#line 370 "glcpp/glcpp-parse.y" +#line 355 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); @@ -2221,14 +2206,14 @@ yyreduce: case 51: /* Line 1464 of yacc.c */ -#line 378 "glcpp/glcpp-parse.y" +#line 363 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 53: /* Line 1464 of yacc.c */ -#line 383 "glcpp/glcpp-parse.y" +#line 368 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); ;} @@ -2237,14 +2222,14 @@ yyreduce: case 54: /* Line 1464 of yacc.c */ -#line 389 "glcpp/glcpp-parse.y" +#line 374 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 57: /* Line 1464 of yacc.c */ -#line 395 "glcpp/glcpp-parse.y" +#line 380 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); ;} @@ -2253,7 +2238,7 @@ yyreduce: case 58: /* Line 1464 of yacc.c */ -#line 402 "glcpp/glcpp-parse.y" +#line 387 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2263,7 +2248,7 @@ yyreduce: case 59: /* Line 1464 of yacc.c */ -#line 406 "glcpp/glcpp-parse.y" +#line 391 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2273,7 +2258,7 @@ yyreduce: case 61: /* Line 1464 of yacc.c */ -#line 415 "glcpp/glcpp-parse.y" +#line 400 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2285,7 +2270,7 @@ yyreduce: case 62: /* Line 1464 of yacc.c */ -#line 421 "glcpp/glcpp-parse.y" +#line 406 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2296,7 +2281,7 @@ yyreduce: case 63: /* Line 1464 of yacc.c */ -#line 429 "glcpp/glcpp-parse.y" +#line 414 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2308,7 +2293,7 @@ yyreduce: case 64: /* Line 1464 of yacc.c */ -#line 435 "glcpp/glcpp-parse.y" +#line 420 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2319,7 +2304,7 @@ yyreduce: case 65: /* Line 1464 of yacc.c */ -#line 443 "glcpp/glcpp-parse.y" +#line 428 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2329,7 +2314,7 @@ yyreduce: case 66: /* Line 1464 of yacc.c */ -#line 447 "glcpp/glcpp-parse.y" +#line 432 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2339,7 +2324,7 @@ yyreduce: case 67: /* Line 1464 of yacc.c */ -#line 451 "glcpp/glcpp-parse.y" +#line 436 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); (yyval.token)->location = yylloc; @@ -2349,7 +2334,7 @@ yyreduce: case 68: /* Line 1464 of yacc.c */ -#line 455 "glcpp/glcpp-parse.y" +#line 440 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2359,7 +2344,7 @@ yyreduce: case 69: /* Line 1464 of yacc.c */ -#line 459 "glcpp/glcpp-parse.y" +#line 444 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); (yyval.token)->location = yylloc; @@ -2369,224 +2354,224 @@ yyreduce: case 70: /* Line 1464 of yacc.c */ -#line 466 "glcpp/glcpp-parse.y" +#line 451 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 71: /* Line 1464 of yacc.c */ -#line 467 "glcpp/glcpp-parse.y" +#line 452 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 72: /* Line 1464 of yacc.c */ -#line 468 "glcpp/glcpp-parse.y" +#line 453 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 73: /* Line 1464 of yacc.c */ -#line 469 "glcpp/glcpp-parse.y" +#line 454 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 74: /* Line 1464 of yacc.c */ -#line 470 "glcpp/glcpp-parse.y" +#line 455 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 75: /* Line 1464 of yacc.c */ -#line 471 "glcpp/glcpp-parse.y" +#line 456 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 76: /* Line 1464 of yacc.c */ -#line 472 "glcpp/glcpp-parse.y" +#line 457 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 77: /* Line 1464 of yacc.c */ -#line 473 "glcpp/glcpp-parse.y" +#line 458 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 78: /* Line 1464 of yacc.c */ -#line 474 "glcpp/glcpp-parse.y" +#line 459 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 79: /* Line 1464 of yacc.c */ -#line 475 "glcpp/glcpp-parse.y" +#line 460 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 80: /* Line 1464 of yacc.c */ -#line 476 "glcpp/glcpp-parse.y" +#line 461 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 81: /* Line 1464 of yacc.c */ -#line 477 "glcpp/glcpp-parse.y" +#line 462 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 82: /* Line 1464 of yacc.c */ -#line 478 "glcpp/glcpp-parse.y" +#line 463 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 83: /* Line 1464 of yacc.c */ -#line 479 "glcpp/glcpp-parse.y" +#line 464 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 84: /* Line 1464 of yacc.c */ -#line 480 "glcpp/glcpp-parse.y" +#line 465 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 85: /* Line 1464 of yacc.c */ -#line 481 "glcpp/glcpp-parse.y" +#line 466 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 86: /* Line 1464 of yacc.c */ -#line 482 "glcpp/glcpp-parse.y" +#line 467 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 87: /* Line 1464 of yacc.c */ -#line 483 "glcpp/glcpp-parse.y" +#line 468 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 88: /* Line 1464 of yacc.c */ -#line 484 "glcpp/glcpp-parse.y" +#line 469 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 89: /* Line 1464 of yacc.c */ -#line 485 "glcpp/glcpp-parse.y" +#line 470 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 90: /* Line 1464 of yacc.c */ -#line 486 "glcpp/glcpp-parse.y" +#line 471 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 91: /* Line 1464 of yacc.c */ -#line 487 "glcpp/glcpp-parse.y" +#line 472 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 92: /* Line 1464 of yacc.c */ -#line 488 "glcpp/glcpp-parse.y" +#line 473 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 93: /* Line 1464 of yacc.c */ -#line 489 "glcpp/glcpp-parse.y" +#line 474 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 94: /* Line 1464 of yacc.c */ -#line 490 "glcpp/glcpp-parse.y" +#line 475 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 95: /* Line 1464 of yacc.c */ -#line 491 "glcpp/glcpp-parse.y" +#line 476 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 96: /* Line 1464 of yacc.c */ -#line 492 "glcpp/glcpp-parse.y" +#line 477 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 97: /* Line 1464 of yacc.c */ -#line 493 "glcpp/glcpp-parse.y" +#line 478 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 98: /* Line 1464 of yacc.c */ -#line 494 "glcpp/glcpp-parse.y" +#line 479 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 99: /* Line 1464 of yacc.c */ -#line 495 "glcpp/glcpp-parse.y" +#line 480 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 100: /* Line 1464 of yacc.c */ -#line 496 "glcpp/glcpp-parse.y" +#line 481 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; /* Line 1464 of yacc.c */ -#line 2590 "glcpp/glcpp-parse.c" +#line 2575 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2805,7 +2790,7 @@ yyreturn: /* Line 1684 of yacc.c */ -#line 499 "glcpp/glcpp-parse.y" +#line 484 "glcpp/glcpp-parse.y" string_list_t * @@ -3397,6 +3382,20 @@ _token_list_create_with_one_space (void *ctx) return list; } +static void +_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list) +{ + token_list_t *expanded; + token_t *token; + + expanded = _token_list_create (parser); + token = _token_create_ival (parser, type, type); + _token_list_append (expanded, token); + _glcpp_parser_expand_token_list (parser, list); + _token_list_append_list (expanded, list); + glcpp_parser_lex_from (parser, expanded); +} + /* This is a helper function that's essentially part of the * implementation of _glcpp_parser_expand_node. It shouldn't be called * except for by that function. diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 55a8d1761e6..e19da432eec 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -105,6 +105,9 @@ _active_list_pop (active_list_t *list); int _active_list_contains (active_list_t *list, const char *identifier); +static void +_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list); + static void _glcpp_parser_expand_token_list (glcpp_parser_t *parser, token_list_t *list); @@ -212,16 +215,7 @@ control_line: talloc_free ($2); } | HASH_IF conditional_tokens NEWLINE { - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, IF_EXPANDED, IF_EXPANDED); - _token_list_append (expanded, token); - talloc_unlink (parser, token); - _glcpp_parser_expand_token_list (parser, $2); - _token_list_append_list (expanded, $2); - glcpp_parser_lex_from (parser, expanded); + _glcpp_parser_expand_if (parser, IF_EXPANDED, $2); } | HASH_IFDEF IDENTIFIER junk NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); @@ -234,16 +228,7 @@ control_line: _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); } | HASH_ELIF conditional_tokens NEWLINE { - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, ELIF_EXPANDED, ELIF_EXPANDED); - _token_list_append (expanded, token); - talloc_unlink (parser, token); - _glcpp_parser_expand_token_list (parser, $2); - _token_list_append_list (expanded, $2); - glcpp_parser_lex_from (parser, expanded); + _glcpp_parser_expand_if (parser, ELIF_EXPANDED, $2); } | HASH_ELIF NEWLINE { /* #elif without an expression results in a warning if the @@ -1087,6 +1072,20 @@ _token_list_create_with_one_space (void *ctx) return list; } +static void +_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list) +{ + token_list_t *expanded; + token_t *token; + + expanded = _token_list_create (parser); + token = _token_create_ival (parser, type, type); + _token_list_append (expanded, token); + _glcpp_parser_expand_token_list (parser, list); + _token_list_append_list (expanded, list); + glcpp_parser_lex_from (parser, expanded); +} + /* This is a helper function that's essentially part of the * implementation of _glcpp_parser_expand_node. It shouldn't be called * except for by that function. -- cgit v1.2.3 From c52b2be16689fbbe8a8ec190dbe9dc7e469956a0 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 4 Aug 2010 16:21:33 -0700 Subject: glcpp/tests: Fix 073-if-in-ifdef.c to use #ifdef, not #if. The original intention was to use #ifdef. --- src/glsl/glcpp/tests/073-if-in-ifdef.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/glcpp/tests/073-if-in-ifdef.c b/src/glsl/glcpp/tests/073-if-in-ifdef.c index b9155b521e0..61a48097ca3 100644 --- a/src/glsl/glcpp/tests/073-if-in-ifdef.c +++ b/src/glsl/glcpp/tests/073-if-in-ifdef.c @@ -1,4 +1,4 @@ -#if UNDEF +#ifdef UNDEF #if UNDEF > 1 #endif #endif -- cgit v1.2.3 From d65135a7661c320c618151df0a94c852dc9bc621 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 4 Aug 2010 16:22:31 -0700 Subject: glcpp/tests: Add a corollary to testcase 073 for testing #elif. --- src/glsl/glcpp/tests/074-elif-undef.c | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/glsl/glcpp/tests/074-elif-undef.c diff --git a/src/glsl/glcpp/tests/074-elif-undef.c b/src/glsl/glcpp/tests/074-elif-undef.c new file mode 100644 index 00000000000..67aac8977e0 --- /dev/null +++ b/src/glsl/glcpp/tests/074-elif-undef.c @@ -0,0 +1,3 @@ +#ifndef UNDEF +#elif UNDEF < 0 +#endif -- cgit v1.2.3 From f4239872c9cb56d1e5735b62ea53bedf3f39dfb0 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 4 Aug 2010 16:24:39 -0700 Subject: glcpp: Ignore #if and #elif expressions when skipping. Fixes glcpp test cases 073 and 074, as well as piglit test xonotic-vs-generic-diffuse.vert. --- src/glsl/glcpp/glcpp-parse.c | 202 +++++++++++++++++++++++-------------------- src/glsl/glcpp/glcpp-parse.y | 18 +++- 2 files changed, 124 insertions(+), 96 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index df16cabeebd..e93f83263d9 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -624,16 +624,16 @@ static const yytype_int8 yyrhs[] = static const yytype_uint16 yyrline[] = { 0, 172, 172, 174, 178, 181, 186, 187, 191, 194, - 200, 203, 206, 209, 217, 220, 225, 230, 233, 244, - 247, 250, 259, 263, 272, 277, 278, 281, 284, 287, - 290, 293, 296, 299, 302, 305, 308, 311, 314, 317, - 320, 323, 326, 329, 332, 335, 338, 341, 344, 350, - 355, 363, 364, 368, 374, 375, 378, 380, 387, 391, - 395, 400, 406, 414, 420, 428, 432, 436, 440, 444, - 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, - 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, - 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, - 481 + 200, 203, 206, 209, 217, 228, 233, 238, 247, 258, + 261, 264, 273, 277, 286, 291, 292, 295, 298, 301, + 304, 307, 310, 313, 316, 319, 322, 325, 328, 331, + 334, 337, 340, 343, 346, 349, 352, 355, 358, 364, + 369, 377, 378, 382, 388, 389, 392, 394, 401, 405, + 409, 414, 420, 428, 434, 442, 446, 450, 454, 458, + 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, + 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, + 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, + 495 }; #endif @@ -1865,14 +1865,22 @@ yyreduce: /* Line 1464 of yacc.c */ #line 217 "glcpp/glcpp-parse.y" { - _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list)); + /* If we're skipping to the next #elif/#else case or to #endif, + * don't bother expanding or parsing the expression. + */ + if (parser->skip_stack != NULL && parser->skip_stack->type != SKIP_NO_SKIP) { + _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), 0); + parser->skip_stack->type = SKIP_TO_ENDIF; + } else { + _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list)); + } ;} break; case 15: /* Line 1464 of yacc.c */ -#line 220 "glcpp/glcpp-parse.y" +#line 228 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1883,7 +1891,7 @@ yyreduce: case 16: /* Line 1464 of yacc.c */ -#line 225 "glcpp/glcpp-parse.y" +#line 233 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1894,16 +1902,22 @@ yyreduce: case 17: /* Line 1464 of yacc.c */ -#line 230 "glcpp/glcpp-parse.y" +#line 238 "glcpp/glcpp-parse.y" { - _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list)); + /* If we just finished a non-skipped #if/#ifdef/#ifndef block, + * don't bother expanding or parsing the expression. + */ + if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) + parser->skip_stack->type = SKIP_TO_ENDIF; + else + _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list)); ;} break; case 18: /* Line 1464 of yacc.c */ -#line 233 "glcpp/glcpp-parse.y" +#line 247 "glcpp/glcpp-parse.y" { /* #elif without an expression results in a warning if the * condition doesn't matter (we just handled #if 1 or such) @@ -1920,7 +1934,7 @@ yyreduce: case 19: /* Line 1464 of yacc.c */ -#line 244 "glcpp/glcpp-parse.y" +#line 258 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); ;} @@ -1929,7 +1943,7 @@ yyreduce: case 20: /* Line 1464 of yacc.c */ -#line 247 "glcpp/glcpp-parse.y" +#line 261 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); ;} @@ -1938,7 +1952,7 @@ yyreduce: case 21: /* Line 1464 of yacc.c */ -#line 250 "glcpp/glcpp-parse.y" +#line 264 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); if (macro) { @@ -1953,7 +1967,7 @@ yyreduce: case 23: /* Line 1464 of yacc.c */ -#line 263 "glcpp/glcpp-parse.y" +#line 277 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); @@ -1968,7 +1982,7 @@ yyreduce: case 24: /* Line 1464 of yacc.c */ -#line 272 "glcpp/glcpp-parse.y" +#line 286 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} @@ -1977,7 +1991,7 @@ yyreduce: case 26: /* Line 1464 of yacc.c */ -#line 278 "glcpp/glcpp-parse.y" +#line 292 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); ;} @@ -1986,7 +2000,7 @@ yyreduce: case 27: /* Line 1464 of yacc.c */ -#line 281 "glcpp/glcpp-parse.y" +#line 295 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); ;} @@ -1995,7 +2009,7 @@ yyreduce: case 28: /* Line 1464 of yacc.c */ -#line 284 "glcpp/glcpp-parse.y" +#line 298 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); ;} @@ -2004,7 +2018,7 @@ yyreduce: case 29: /* Line 1464 of yacc.c */ -#line 287 "glcpp/glcpp-parse.y" +#line 301 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); ;} @@ -2013,7 +2027,7 @@ yyreduce: case 30: /* Line 1464 of yacc.c */ -#line 290 "glcpp/glcpp-parse.y" +#line 304 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); ;} @@ -2022,7 +2036,7 @@ yyreduce: case 31: /* Line 1464 of yacc.c */ -#line 293 "glcpp/glcpp-parse.y" +#line 307 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); ;} @@ -2031,7 +2045,7 @@ yyreduce: case 32: /* Line 1464 of yacc.c */ -#line 296 "glcpp/glcpp-parse.y" +#line 310 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); ;} @@ -2040,7 +2054,7 @@ yyreduce: case 33: /* Line 1464 of yacc.c */ -#line 299 "glcpp/glcpp-parse.y" +#line 313 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); ;} @@ -2049,7 +2063,7 @@ yyreduce: case 34: /* Line 1464 of yacc.c */ -#line 302 "glcpp/glcpp-parse.y" +#line 316 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); ;} @@ -2058,7 +2072,7 @@ yyreduce: case 35: /* Line 1464 of yacc.c */ -#line 305 "glcpp/glcpp-parse.y" +#line 319 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); ;} @@ -2067,7 +2081,7 @@ yyreduce: case 36: /* Line 1464 of yacc.c */ -#line 308 "glcpp/glcpp-parse.y" +#line 322 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); ;} @@ -2076,7 +2090,7 @@ yyreduce: case 37: /* Line 1464 of yacc.c */ -#line 311 "glcpp/glcpp-parse.y" +#line 325 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); ;} @@ -2085,7 +2099,7 @@ yyreduce: case 38: /* Line 1464 of yacc.c */ -#line 314 "glcpp/glcpp-parse.y" +#line 328 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); ;} @@ -2094,7 +2108,7 @@ yyreduce: case 39: /* Line 1464 of yacc.c */ -#line 317 "glcpp/glcpp-parse.y" +#line 331 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); ;} @@ -2103,7 +2117,7 @@ yyreduce: case 40: /* Line 1464 of yacc.c */ -#line 320 "glcpp/glcpp-parse.y" +#line 334 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); ;} @@ -2112,7 +2126,7 @@ yyreduce: case 41: /* Line 1464 of yacc.c */ -#line 323 "glcpp/glcpp-parse.y" +#line 337 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); ;} @@ -2121,7 +2135,7 @@ yyreduce: case 42: /* Line 1464 of yacc.c */ -#line 326 "glcpp/glcpp-parse.y" +#line 340 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); ;} @@ -2130,7 +2144,7 @@ yyreduce: case 43: /* Line 1464 of yacc.c */ -#line 329 "glcpp/glcpp-parse.y" +#line 343 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); ;} @@ -2139,7 +2153,7 @@ yyreduce: case 44: /* Line 1464 of yacc.c */ -#line 332 "glcpp/glcpp-parse.y" +#line 346 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); ;} @@ -2148,7 +2162,7 @@ yyreduce: case 45: /* Line 1464 of yacc.c */ -#line 335 "glcpp/glcpp-parse.y" +#line 349 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); ;} @@ -2157,7 +2171,7 @@ yyreduce: case 46: /* Line 1464 of yacc.c */ -#line 338 "glcpp/glcpp-parse.y" +#line 352 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); ;} @@ -2166,7 +2180,7 @@ yyreduce: case 47: /* Line 1464 of yacc.c */ -#line 341 "glcpp/glcpp-parse.y" +#line 355 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); ;} @@ -2175,7 +2189,7 @@ yyreduce: case 48: /* Line 1464 of yacc.c */ -#line 344 "glcpp/glcpp-parse.y" +#line 358 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); ;} @@ -2184,7 +2198,7 @@ yyreduce: case 49: /* Line 1464 of yacc.c */ -#line 350 "glcpp/glcpp-parse.y" +#line 364 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); @@ -2195,7 +2209,7 @@ yyreduce: case 50: /* Line 1464 of yacc.c */ -#line 355 "glcpp/glcpp-parse.y" +#line 369 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); @@ -2206,14 +2220,14 @@ yyreduce: case 51: /* Line 1464 of yacc.c */ -#line 363 "glcpp/glcpp-parse.y" +#line 377 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 53: /* Line 1464 of yacc.c */ -#line 368 "glcpp/glcpp-parse.y" +#line 382 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); ;} @@ -2222,14 +2236,14 @@ yyreduce: case 54: /* Line 1464 of yacc.c */ -#line 374 "glcpp/glcpp-parse.y" +#line 388 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 57: /* Line 1464 of yacc.c */ -#line 380 "glcpp/glcpp-parse.y" +#line 394 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); ;} @@ -2238,7 +2252,7 @@ yyreduce: case 58: /* Line 1464 of yacc.c */ -#line 387 "glcpp/glcpp-parse.y" +#line 401 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2248,7 +2262,7 @@ yyreduce: case 59: /* Line 1464 of yacc.c */ -#line 391 "glcpp/glcpp-parse.y" +#line 405 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2258,7 +2272,7 @@ yyreduce: case 61: /* Line 1464 of yacc.c */ -#line 400 "glcpp/glcpp-parse.y" +#line 414 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2270,7 +2284,7 @@ yyreduce: case 62: /* Line 1464 of yacc.c */ -#line 406 "glcpp/glcpp-parse.y" +#line 420 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2281,7 +2295,7 @@ yyreduce: case 63: /* Line 1464 of yacc.c */ -#line 414 "glcpp/glcpp-parse.y" +#line 428 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2293,7 +2307,7 @@ yyreduce: case 64: /* Line 1464 of yacc.c */ -#line 420 "glcpp/glcpp-parse.y" +#line 434 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2304,7 +2318,7 @@ yyreduce: case 65: /* Line 1464 of yacc.c */ -#line 428 "glcpp/glcpp-parse.y" +#line 442 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2314,7 +2328,7 @@ yyreduce: case 66: /* Line 1464 of yacc.c */ -#line 432 "glcpp/glcpp-parse.y" +#line 446 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2324,7 +2338,7 @@ yyreduce: case 67: /* Line 1464 of yacc.c */ -#line 436 "glcpp/glcpp-parse.y" +#line 450 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); (yyval.token)->location = yylloc; @@ -2334,7 +2348,7 @@ yyreduce: case 68: /* Line 1464 of yacc.c */ -#line 440 "glcpp/glcpp-parse.y" +#line 454 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2344,7 +2358,7 @@ yyreduce: case 69: /* Line 1464 of yacc.c */ -#line 444 "glcpp/glcpp-parse.y" +#line 458 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); (yyval.token)->location = yylloc; @@ -2354,224 +2368,224 @@ yyreduce: case 70: /* Line 1464 of yacc.c */ -#line 451 "glcpp/glcpp-parse.y" +#line 465 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 71: /* Line 1464 of yacc.c */ -#line 452 "glcpp/glcpp-parse.y" +#line 466 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 72: /* Line 1464 of yacc.c */ -#line 453 "glcpp/glcpp-parse.y" +#line 467 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 73: /* Line 1464 of yacc.c */ -#line 454 "glcpp/glcpp-parse.y" +#line 468 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 74: /* Line 1464 of yacc.c */ -#line 455 "glcpp/glcpp-parse.y" +#line 469 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 75: /* Line 1464 of yacc.c */ -#line 456 "glcpp/glcpp-parse.y" +#line 470 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 76: /* Line 1464 of yacc.c */ -#line 457 "glcpp/glcpp-parse.y" +#line 471 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 77: /* Line 1464 of yacc.c */ -#line 458 "glcpp/glcpp-parse.y" +#line 472 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 78: /* Line 1464 of yacc.c */ -#line 459 "glcpp/glcpp-parse.y" +#line 473 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 79: /* Line 1464 of yacc.c */ -#line 460 "glcpp/glcpp-parse.y" +#line 474 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 80: /* Line 1464 of yacc.c */ -#line 461 "glcpp/glcpp-parse.y" +#line 475 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 81: /* Line 1464 of yacc.c */ -#line 462 "glcpp/glcpp-parse.y" +#line 476 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 82: /* Line 1464 of yacc.c */ -#line 463 "glcpp/glcpp-parse.y" +#line 477 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 83: /* Line 1464 of yacc.c */ -#line 464 "glcpp/glcpp-parse.y" +#line 478 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 84: /* Line 1464 of yacc.c */ -#line 465 "glcpp/glcpp-parse.y" +#line 479 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 85: /* Line 1464 of yacc.c */ -#line 466 "glcpp/glcpp-parse.y" +#line 480 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 86: /* Line 1464 of yacc.c */ -#line 467 "glcpp/glcpp-parse.y" +#line 481 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 87: /* Line 1464 of yacc.c */ -#line 468 "glcpp/glcpp-parse.y" +#line 482 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 88: /* Line 1464 of yacc.c */ -#line 469 "glcpp/glcpp-parse.y" +#line 483 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 89: /* Line 1464 of yacc.c */ -#line 470 "glcpp/glcpp-parse.y" +#line 484 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 90: /* Line 1464 of yacc.c */ -#line 471 "glcpp/glcpp-parse.y" +#line 485 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 91: /* Line 1464 of yacc.c */ -#line 472 "glcpp/glcpp-parse.y" +#line 486 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 92: /* Line 1464 of yacc.c */ -#line 473 "glcpp/glcpp-parse.y" +#line 487 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 93: /* Line 1464 of yacc.c */ -#line 474 "glcpp/glcpp-parse.y" +#line 488 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 94: /* Line 1464 of yacc.c */ -#line 475 "glcpp/glcpp-parse.y" +#line 489 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 95: /* Line 1464 of yacc.c */ -#line 476 "glcpp/glcpp-parse.y" +#line 490 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 96: /* Line 1464 of yacc.c */ -#line 477 "glcpp/glcpp-parse.y" +#line 491 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 97: /* Line 1464 of yacc.c */ -#line 478 "glcpp/glcpp-parse.y" +#line 492 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 98: /* Line 1464 of yacc.c */ -#line 479 "glcpp/glcpp-parse.y" +#line 493 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 99: /* Line 1464 of yacc.c */ -#line 480 "glcpp/glcpp-parse.y" +#line 494 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 100: /* Line 1464 of yacc.c */ -#line 481 "glcpp/glcpp-parse.y" +#line 495 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; /* Line 1464 of yacc.c */ -#line 2575 "glcpp/glcpp-parse.c" +#line 2589 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2790,7 +2804,7 @@ yyreturn: /* Line 1684 of yacc.c */ -#line 484 "glcpp/glcpp-parse.y" +#line 498 "glcpp/glcpp-parse.y" string_list_t * diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index e19da432eec..df1a649d9bc 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -215,7 +215,15 @@ control_line: talloc_free ($2); } | HASH_IF conditional_tokens NEWLINE { - _glcpp_parser_expand_if (parser, IF_EXPANDED, $2); + /* If we're skipping to the next #elif/#else case or to #endif, + * don't bother expanding or parsing the expression. + */ + if (parser->skip_stack != NULL && parser->skip_stack->type != SKIP_NO_SKIP) { + _glcpp_parser_skip_stack_push_if (parser, & @1, 0); + parser->skip_stack->type = SKIP_TO_ENDIF; + } else { + _glcpp_parser_expand_if (parser, IF_EXPANDED, $2); + } } | HASH_IFDEF IDENTIFIER junk NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); @@ -228,7 +236,13 @@ control_line: _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); } | HASH_ELIF conditional_tokens NEWLINE { - _glcpp_parser_expand_if (parser, ELIF_EXPANDED, $2); + /* If we just finished a non-skipped #if/#ifdef/#ifndef block, + * don't bother expanding or parsing the expression. + */ + if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) + parser->skip_stack->type = SKIP_TO_ENDIF; + else + _glcpp_parser_expand_if (parser, ELIF_EXPANDED, $2); } | HASH_ELIF NEWLINE { /* #elif without an expression results in a warning if the -- cgit v1.2.3 From 9de2c4fc8e620ffe7faecd499c82d9d38ec538a6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 22:35:32 -0700 Subject: ir_to_mesa: Remove debug force-enablement of EmitNoIfs. --- src/mesa/program/ir_to_mesa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 2fd07ca6115..f0e013369aa 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2614,7 +2614,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) progress = do_constant_folding(shader->ir) || progress; progress = do_algebraic(shader->ir) || progress; progress = do_if_return(shader->ir) || progress; - if (1 || ctx->Shader.EmitNoIfs) + if (ctx->Shader.EmitNoIfs) progress = do_if_to_cond_assign(shader->ir) || progress; progress = do_vec_index_to_swizzle(shader->ir) || progress; -- cgit v1.2.3 From 8f6a0c9ed985267c2d202cf85d17ac04bddfb9d2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 22:57:08 -0700 Subject: glsl2: Don't try to dump GLSL IR for a shader that didn't compile. --- src/mesa/program/ir_to_mesa.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index f0e013369aa..74996ae4802 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2646,9 +2646,11 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) printf("GLSL source for shader %d:\n", shader->Name); printf("%s\n", shader->Source); - printf("GLSL IR for shader %d:\n", shader->Name); - _mesa_print_ir(shader->ir, NULL); - printf("\n\n"); + if (shader->CompileStatus) { + printf("GLSL IR for shader %d:\n", shader->Name); + _mesa_print_ir(shader->ir, NULL); + printf("\n\n"); + } } /* Retain any live IR, but trash the rest. */ -- cgit v1.2.3 From c5b9cab49900cbcab78911361976a3678d49e853 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Aug 2010 23:23:15 -0700 Subject: glsl2: Catch pointless copies in copy propagation. We wouldn't want to go rewriting dereferences to variables to point at the same variable it did before. While I didn't find a way to trigger that, a shader in Yo Frankie managed to produce a self-assignment by passing a constant to a function doing self assignment like this. Cleans up the IR for glsl-deadcode-self-assign.shader_test --- src/glsl/ir_copy_propagation.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/glsl/ir_copy_propagation.cpp b/src/glsl/ir_copy_propagation.cpp index 26588a352c8..1d28392d7c3 100644 --- a/src/glsl/ir_copy_propagation.cpp +++ b/src/glsl/ir_copy_propagation.cpp @@ -213,7 +213,7 @@ kill_invalidated_copies(ir_assignment *ir, exec_list *acp) * Adds an entry to the available copy list if it's a plain assignment * of a variable to a variable. */ -static void +static bool add_copy(void *ctx, ir_assignment *ir, exec_list *acp) { acp_entry *entry; @@ -221,16 +221,28 @@ add_copy(void *ctx, ir_assignment *ir, exec_list *acp) if (ir->condition) { ir_constant *condition = ir->condition->as_constant(); if (!condition || !condition->value.b[0]) - return; + return false; } ir_variable *lhs_var = ir->whole_variable_written(); ir_variable *rhs_var = ir->rhs->whole_variable_referenced(); if ((lhs_var != NULL) && (rhs_var != NULL)) { - entry = new(ctx) acp_entry(lhs_var, rhs_var); - acp->push_tail(entry); + if (lhs_var == rhs_var) { + /* This is a dumb assignment, but we've conveniently noticed + * it here. Removing it now would mess up the loop iteration + * calling us. Just flag it to not execute, and someone else + * will clean up the mess. + */ + ir->condition = new(talloc_parent(ir)) ir_constant(false); + return true; + } else { + entry = new(ctx) acp_entry(lhs_var, rhs_var); + acp->push_tail(entry); + } } + + return false; } static void @@ -253,7 +265,7 @@ copy_propagation_basic_block(ir_instruction *first, if (ir_assign) { kill_invalidated_copies(ir_assign, &acp); - add_copy(ctx, ir_assign, &acp); + progress = add_copy(ctx, ir_assign, &acp) || progress; } if (ir == last) break; -- cgit v1.2.3 From 2e853ca23c8670246dd4efcee0706f68097652f7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 10:09:12 -0700 Subject: glsl2: Add a pass for removing unused functions. For a shader involving many small functions, this avoids running optimization across all of them after they've been inlined post-linking. Reduces the runtime of linking and running a fragment shader from Yo Frankie from 1.6 seconds to 0.9 seconds (-44.9%, +/- 3.3%). --- src/glsl/Makefile | 1 + src/glsl/glsl_symbol_table.h | 6 ++ src/glsl/ir.h | 1 - src/glsl/ir_dead_functions.cpp | 151 +++++++++++++++++++++++++++++++++++++++++ src/glsl/ir_optimization.h | 1 + src/glsl/linker.cpp | 1 + 6 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 src/glsl/ir_dead_functions.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 3102947494c..844385792aa 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -39,6 +39,7 @@ CXX_SOURCES = \ ir.cpp \ ir_dead_code.cpp \ ir_dead_code_local.cpp \ + ir_dead_functions.cpp \ ir_div_to_mul_rcp.cpp \ ir_expression_flattening.cpp \ ir_function_can_inline.cpp \ diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h index 27e825597c5..02e4542cf3d 100644 --- a/src/glsl/glsl_symbol_table.h +++ b/src/glsl/glsl_symbol_table.h @@ -133,6 +133,12 @@ public: return _mesa_symbol_table_add_symbol(table, glsl_function_name_space, name, f) == 0; } + + bool remove_function(const char *name, ir_function *f) + { + return _mesa_symbol_table_add_symbol(table, glsl_function_name_space, + name, f) == 0; + } /*@}*/ /** diff --git a/src/glsl/ir.h b/src/glsl/ir.h index e61485813dc..f58602515ef 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -410,7 +410,6 @@ public: */ const char *name; -private: /** * List of ir_function_signature for each overloaded function with this name. */ diff --git a/src/glsl/ir_dead_functions.cpp b/src/glsl/ir_dead_functions.cpp new file mode 100644 index 00000000000..26554441d3a --- /dev/null +++ b/src/glsl/ir_dead_functions.cpp @@ -0,0 +1,151 @@ + /* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + /** + * \file ir_dead_functions.cpp + * + * Eliminates unused functions from the linked program. + */ + + #include "ir.h" + #include "ir_visitor.h" + #include "ir_expression_flattening.h" + #include "glsl_types.h" + + class signature_entry : public exec_node + { + public: + signature_entry(ir_function_signature *sig) + { + this->signature = sig; + this->used = false; + } + + ir_function_signature *signature; + bool used; + }; + + class ir_dead_functions_visitor : public ir_hierarchical_visitor { + public: + ir_dead_functions_visitor() + { + this->mem_ctx = talloc_new(NULL); + } + + ~ir_dead_functions_visitor() + { + talloc_free(this->mem_ctx); + } + + virtual ir_visitor_status visit_enter(ir_function_signature *); + virtual ir_visitor_status visit_enter(ir_call *); + + signature_entry *get_signature_entry(ir_function_signature *var); + + bool (*predicate)(ir_instruction *ir); + + /* List of signature_entry */ + exec_list signature_list; + void *mem_ctx; + }; + + + signature_entry * + ir_dead_functions_visitor::get_signature_entry(ir_function_signature *sig) + { + foreach_iter(exec_list_iterator, iter, this->signature_list) { + signature_entry *entry = (signature_entry *)iter.get(); + if (entry->signature == sig) + return entry; + } + + signature_entry *entry = new(mem_ctx) signature_entry(sig); + this->signature_list.push_tail(entry); + return entry; + } + + + ir_visitor_status + ir_dead_functions_visitor::visit_enter(ir_function_signature *ir) + { + signature_entry *entry = this->get_signature_entry(ir); + + if (strcmp(ir->function_name(), "main") == 0) { + entry->used = true; + } + + return visit_continue; + } + + + ir_visitor_status + ir_dead_functions_visitor::visit_enter(ir_call *ir) + { + signature_entry *entry = this->get_signature_entry(ir->get_callee()); + + entry->used = true; + + return visit_continue; +} + +bool +do_dead_functions(exec_list *instructions) +{ + ir_dead_functions_visitor v; + bool progress = false; + + visit_list_elements(&v, instructions); + + /* Now that we've figured out which function signatures are used, remove + * the unused ones, and remove function definitions that have no more + * signatures. + */ + foreach_iter(exec_list_iterator, iter, v.signature_list) { + signature_entry *entry = (signature_entry *)iter.get(); + + if (!entry->used) { + entry->signature->remove(); + progress = true; + } + delete(entry); + } + + /* We don't just do this above when we nuked a signature because of + * const pointers. + */ + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_function *func = ir->as_function(); + + if (func && func->signatures.is_empty()) { + /* At this point (post-linking), the symbol table is no + * longer in use, so not removing the function from the + * symbol table should be OK. + */ + func->remove(); + progress = true; + } + } + + return progress; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 55ec3271936..e0c0715cf5b 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -36,6 +36,7 @@ bool do_copy_propagation(exec_list *instructions); bool do_dead_code(exec_list *instructions); bool do_dead_code_local(exec_list *instructions); bool do_dead_code_unlinked(exec_list *instructions); +bool do_dead_functions(exec_list *instructions); bool do_div_to_mul_rcp(exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_if_return(exec_list *instructions); diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 94db57d6a52..f9e24ca0f11 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1286,6 +1286,7 @@ link_shaders(struct gl_shader_program *prog) progress = false; progress = do_function_inlining(ir) || progress; + progress = do_dead_functions(ir) || progress; progress = do_if_simplification(ir) || progress; progress = do_copy_propagation(ir) || progress; progress = do_dead_code_local(ir) || progress; -- cgit v1.2.3 From e995f0e10c9ee51f7c8f8fa2193ff99e1b49e40d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 10:13:10 -0700 Subject: ir_to_mesa: Don't do function inlining until linking. Optimizations at compile time should generally be done with the goal of reducing instruction count so that other work, particularly linking, is less time-consuming if the shader is used multiple times. However, function inlining increases instruction count for the inlined function bodies without removing the original function body, since we don't know if it will be used at link time or not. Reduces the runtime of linking and executing a Yo Frankie fragment shader from 0.9 seconds to 0.5 seconds (-45.9%, +/- 2.2%, n=5). --- src/mesa/program/ir_to_mesa.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 74996ae4802..299b11d2741 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2604,7 +2604,6 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) do { progress = false; - progress = do_function_inlining(shader->ir) || progress; progress = do_if_simplification(shader->ir) || progress; progress = do_copy_propagation(shader->ir) || progress; progress = do_dead_code_local(shader->ir) || progress; -- cgit v1.2.3 From 3bd7e70bf7c4a9a52b425284c9f23689f00de93c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 12:07:23 -0700 Subject: glsl2: Add some easy-to-enable debug printfs to ir_dead_code.cpp. --- src/glsl/ir_dead_code.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp index bf032f1dc21..a8d264f39a9 100644 --- a/src/glsl/ir_dead_code.cpp +++ b/src/glsl/ir_dead_code.cpp @@ -32,6 +32,8 @@ #include "ir_variable_refcount.h" #include "glsl_types.h" +static bool debug = false; + /** * Do a dead code pass over instructions and everything that instructions * references. @@ -60,6 +62,13 @@ do_dead_code(exec_list *instructions) */ assert(entry->referenced_count >= entry->assigned_count); + if (debug) { + printf("%s@%p: %d refs, %d assigns, %sdeclared in our scope\n", + entry->var->name, entry->var, + entry->referenced_count, entry->assigned_count, + entry->declaration ? "" : "not "); + } + if ((entry->referenced_count > entry->assigned_count) || !entry->declaration) continue; @@ -72,6 +81,11 @@ do_dead_code(exec_list *instructions) entry->var->mode != ir_var_inout) { entry->assign->remove(); progress = true; + + if (debug) { + printf("Removed assignment to %s@%p\n", + entry->var->name, entry->var); + } } } else { /* If there are no assignments or references to the variable left, @@ -79,6 +93,11 @@ do_dead_code(exec_list *instructions) */ entry->var->remove(); progress = true; + + if (debug) { + printf("Removed declaration of %s@%p\n", + entry->var->name, entry->var); + } } } talloc_free(v.mem_ctx); -- cgit v1.2.3 From 9f82806c7b5109553cf806a5652e6b6198665094 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 12:10:31 -0700 Subject: glsl2: Don't dead-code eliminate a call where the return value is unused. This showed up since the disabling of inlining at compile time, which I apparently didn't regenerate piglit summary for. Fixes: glsl-deadcode-call. --- src/glsl/ir.h | 3 +++ src/glsl/ir_basic_block.cpp | 13 +++++++++---- src/glsl/ir_dead_code.cpp | 3 ++- src/glsl/ir_dead_code_local.cpp | 7 ++++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index f58602515ef..ef8339ce199 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1389,4 +1389,7 @@ extern void import_prototypes(const exec_list *source, exec_list *dest, class glsl_symbol_table *symbols, void *mem_ctx); +extern bool +ir_has_call(ir_instruction *ir); + #endif /* IR_H */ diff --git a/src/glsl/ir_basic_block.cpp b/src/glsl/ir_basic_block.cpp index f9953ea42da..a8338259620 100644 --- a/src/glsl/ir_basic_block.cpp +++ b/src/glsl/ir_basic_block.cpp @@ -49,6 +49,14 @@ public: bool has_call; }; +bool +ir_has_call(ir_instruction *ir) +{ + ir_has_call_visitor v; + ir->accept(&v); + return v.has_call; +} + /** * Calls a user function for every basic block in the instruction stream. * @@ -115,8 +123,6 @@ void call_for_basic_blocks(exec_list *instructions, call_for_basic_blocks(&ir_sig->body, callback, data); } } else if (ir->as_assignment()) { - ir_has_call_visitor v; - /* If there's a call in the expression tree being assigned, * then that ends the BB too. * @@ -130,8 +136,7 @@ void call_for_basic_blocks(exec_list *instructions, * expression flattener may be useful before using the basic * block finder to get more maximal basic blocks out. */ - ir->accept(&v); - if (v.has_call) { + if (ir_has_call(ir)) { callback(leader, ir, data); leader = NULL; } diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp index a8d264f39a9..87988871c7e 100644 --- a/src/glsl/ir_dead_code.cpp +++ b/src/glsl/ir_dead_code.cpp @@ -78,7 +78,8 @@ do_dead_code(exec_list *instructions) * Don't do so if it's a shader output, though. */ if (entry->var->mode != ir_var_out && - entry->var->mode != ir_var_inout) { + entry->var->mode != ir_var_inout && + !ir_has_call(entry->assign)) { entry->assign->remove(); progress = true; diff --git a/src/glsl/ir_dead_code_local.cpp b/src/glsl/ir_dead_code_local.cpp index b22cc558df6..4bbedf0ff94 100644 --- a/src/glsl/ir_dead_code_local.cpp +++ b/src/glsl/ir_dead_code_local.cpp @@ -156,7 +156,12 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments) } } - /* Add this instruction to the assignment list. */ + /* Add this instruction to the assignment list available to be removed. + * But not if the assignment has other side effects. + */ + if (ir_has_call(ir)) + return progress; + assignment_entry *entry = new(ctx) assignment_entry(var, ir); assignments->push_tail(entry); -- cgit v1.2.3 From b259eb28049fc06ebc75a7714834b9ed037a3454 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 12:24:36 -0700 Subject: glsl2: Don't tree-grafting out assignment to an out variable. Fixes: glsl-deadcode-varying. --- src/glsl/ir_tree_grafting.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/glsl/ir_tree_grafting.cpp b/src/glsl/ir_tree_grafting.cpp index 38034a61977..1a742f412cb 100644 --- a/src/glsl/ir_tree_grafting.cpp +++ b/src/glsl/ir_tree_grafting.cpp @@ -319,6 +319,10 @@ tree_grafting_basic_block(ir_instruction *bb_first, if (!lhs_var) continue; + if (lhs_var->mode == ir_var_out || + lhs_var->mode == ir_var_inout) + continue; + struct variable_entry *entry = info->refs->get_variable_entry(lhs_var); if (!entry->declaration || -- cgit v1.2.3 From c314c8f2310fa0ac51b8953e139f9504e08eb48f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 12:52:29 -0700 Subject: glsl2: Fix the dereferences_variable check in ir_tree_grafting. The HV doesn't descend into ir_variable, which is generally a good thing (allowing one to distinguish between variable declarations and refs), but here we never saw tree grafting opportunities killed because we were looking for the ir_variable child of a dereference to get visited. Fixes: glsl1-function call with inout params --- src/glsl/ir_tree_grafting.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_tree_grafting.cpp b/src/glsl/ir_tree_grafting.cpp index 1a742f412cb..e80db31cb30 100644 --- a/src/glsl/ir_tree_grafting.cpp +++ b/src/glsl/ir_tree_grafting.cpp @@ -92,8 +92,9 @@ void dereferences_variable_callback(ir_instruction *ir, void *data) { struct find_deref_info *info = (struct find_deref_info *)data; + ir_dereference_variable *deref = ir->as_dereference_variable(); - if (ir == info->var) + if (deref && deref->var == info->var) info->found = true; } @@ -123,7 +124,7 @@ ir_tree_grafting_visitor::do_graft(ir_rvalue **rvalue) if (debug) { printf("GRAFTING:\n"); - this->graft_assign->rhs->print(); + this->graft_assign->print(); printf("\n"); printf("TO:\n"); (*rvalue)->print(); -- cgit v1.2.3 From 7f7eaf0285d011f7cc7e1a63133184a50b24ecaa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 11:01:09 -0700 Subject: ir_structure_splitting: New pass to chop structures into their components. This doesn't do anything if your structure goes through an uninlined function call or if whole-structure assignment occurs. As such, the impact is limited, at least until we do some global copy propagation to reduce whole-structure assignment. --- src/glsl/Makefile | 1 + src/glsl/ir_optimization.h | 1 + src/glsl/ir_structure_splitting.cpp | 378 ++++++++++++++++++++++++++++++++++++ src/glsl/linker.cpp | 1 + 4 files changed, 381 insertions(+) create mode 100644 src/glsl/ir_structure_splitting.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 844385792aa..53567508a01 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -55,6 +55,7 @@ CXX_SOURCES = \ ir_mod_to_fract.cpp \ ir_print_visitor.cpp \ ir_reader.cpp \ + ir_structure_splitting.cpp \ ir_swizzle_swizzle.cpp \ ir_tree_grafting.cpp \ ir_validate.cpp \ diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index e0c0715cf5b..eac28dc64cb 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -44,6 +44,7 @@ bool do_if_simplification(exec_list *instructions); bool do_if_to_cond_assign(exec_list *instructions); bool do_mat_op_to_vec(exec_list *instructions); bool do_mod_to_fract(exec_list *instructions); +bool do_structure_splitting(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); bool do_tree_grafting(exec_list *instructions); bool do_vec_index_to_cond_assign(exec_list *instructions); diff --git a/src/glsl/ir_structure_splitting.cpp b/src/glsl/ir_structure_splitting.cpp new file mode 100644 index 00000000000..f57ae44aae4 --- /dev/null +++ b/src/glsl/ir_structure_splitting.cpp @@ -0,0 +1,378 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_structure_splitting.cpp + * + * If a structure is only ever referenced by its components, then + * split those components out to individual variables so they can be + * handled normally by other optimization passes. + * + * This skips structures like uniforms, which need to be accessible as + * structures for their access by the GL. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "glsl_types.h" + +class variable_entry : public exec_node +{ +public: + variable_entry(ir_variable *var) + { + this->var = var; + this->whole_structure_access = 0; + this->declaration = false; + this->components = NULL; + this->mem_ctx = NULL; + } + + ir_variable *var; /* The key: the variable's pointer. */ + + /** Number of times the variable is referenced, including assignments. */ + unsigned whole_structure_access; + + bool declaration; /* If the variable had a decl in the instruction stream */ + + ir_variable **components; + + /** talloc_parent(this->var) -- the shader's talloc context. */ + void *mem_ctx; +}; + +class ir_structure_reference_visitor : public ir_hierarchical_visitor { +public: + ir_structure_reference_visitor(void) + { + this->mem_ctx = talloc_new(NULL); + this->variable_list.make_empty(); + } + + ~ir_structure_reference_visitor(void) + { + talloc_free(mem_ctx); + } + + virtual ir_visitor_status visit(ir_variable *); + virtual ir_visitor_status visit(ir_dereference_variable *); + virtual ir_visitor_status visit(ir_dereference_record *); + + virtual ir_visitor_status visit_enter(ir_function_signature *); + + variable_entry *get_variable_entry(ir_variable *var); + + /* List of variable_entry */ + exec_list variable_list; + + void *mem_ctx; +}; + +variable_entry * +ir_structure_reference_visitor::get_variable_entry(ir_variable *var) +{ + assert(var); + + if (!var->type->is_record()) + return NULL; + + foreach_iter(exec_list_iterator, iter, this->variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + if (entry->var == var) + return entry; + } + + variable_entry *entry = new(mem_ctx) variable_entry(var); + this->variable_list.push_tail(entry); + return entry; +} + + +ir_visitor_status +ir_structure_reference_visitor::visit(ir_variable *ir) +{ + variable_entry *entry = this->get_variable_entry(ir); + + if (entry) + entry->declaration = true; + + return visit_continue; +} + +ir_visitor_status +ir_structure_reference_visitor::visit(ir_dereference_variable *ir) +{ + ir_variable *const var = ir->variable_referenced(); + variable_entry *entry = this->get_variable_entry(var); + + if (entry) + entry->whole_structure_access++; + + return visit_continue; +} + +ir_visitor_status +ir_structure_reference_visitor::visit(ir_dereference_record *ir) +{ + /* Don't descend into the ir_dereference_variable below. */ + return visit_continue; +} + +ir_visitor_status +ir_structure_reference_visitor::visit_enter(ir_function_signature *ir) +{ + /* We don't want to descend into the function parameters and + * dead-code eliminate them, so just accept the body here. + */ + visit_list_elements(this, &ir->body); + return visit_continue_with_parent; +} + +class ir_structure_splitting_visitor : public ir_hierarchical_visitor { +public: + ir_structure_splitting_visitor(exec_list *vars) + { + this->variable_list = vars; + } + + virtual ~ir_structure_splitting_visitor() + { + } + + virtual ir_visitor_status visit_leave(ir_assignment *); + virtual ir_visitor_status visit_leave(ir_call *); + virtual ir_visitor_status visit_leave(ir_dereference_array *); + virtual ir_visitor_status visit_leave(ir_expression *); + virtual ir_visitor_status visit_leave(ir_if *); + virtual ir_visitor_status visit_leave(ir_return *); + virtual ir_visitor_status visit_leave(ir_swizzle *); + virtual ir_visitor_status visit_leave(ir_texture *); + + void split_deref(ir_dereference **deref); + void split_rvalue(ir_rvalue **rvalue); + struct variable_entry *get_splitting_entry(ir_variable *var); + + exec_list *variable_list; + void *mem_ctx; +}; + +struct variable_entry * +ir_structure_splitting_visitor::get_splitting_entry(ir_variable *var) +{ + assert(var); + + if (!var->type->is_record()) + return NULL; + + foreach_iter(exec_list_iterator, iter, *this->variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + if (entry->var == var) { + return entry; + } + } + + return NULL; +} + +void +ir_structure_splitting_visitor::split_deref(ir_dereference **deref) +{ + if ((*deref)->ir_type != ir_type_dereference_record) + return; + + ir_dereference_record *deref_record = (ir_dereference_record *)deref; + ir_dereference_variable *deref_var = deref_record->as_dereference_variable(); + if (!deref_var) + return; + + variable_entry *entry = get_splitting_entry(deref_var->var); + if (entry) + return; + + unsigned int i; + for (i = 0; i < entry->var->type->length; i++) { + if (strcmp(deref_record->field, + entry->var->type->fields.structure[i].name) == 0) + break; + } + assert(i != entry->var->type->length); + + *deref = new(entry->mem_ctx) ir_dereference_variable(entry->components[i]); +} + +void +ir_structure_splitting_visitor::split_rvalue(ir_rvalue **rvalue) +{ + ir_dereference *deref = (*rvalue)->as_dereference(); + + if (!deref) + return; + + split_deref(&deref); + *rvalue = deref; +} + +ir_visitor_status +ir_structure_splitting_visitor::visit_leave(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + split_rvalue(&ir->operands[operand]); + } + + return visit_continue; +} + +ir_visitor_status +ir_structure_splitting_visitor::visit_leave(ir_texture *ir) +{ + split_rvalue(&ir->coordinate); + split_rvalue(&ir->projector); + split_rvalue(&ir->shadow_comparitor); + + switch (ir->op) { + case ir_tex: + break; + case ir_txb: + split_rvalue(&ir->lod_info.bias); + break; + case ir_txf: + case ir_txl: + split_rvalue(&ir->lod_info.lod); + break; + case ir_txd: + split_rvalue(&ir->lod_info.grad.dPdx); + split_rvalue(&ir->lod_info.grad.dPdy); + break; + } + + return visit_continue; +} + +ir_visitor_status +ir_structure_splitting_visitor::visit_leave(ir_swizzle *ir) +{ + split_rvalue(&ir->val); + return visit_continue; +} + +ir_visitor_status +ir_structure_splitting_visitor::visit_leave(ir_dereference_array *ir) +{ + split_rvalue(&ir->array_index); + return visit_continue; +} + +ir_visitor_status +ir_structure_splitting_visitor::visit_leave(ir_assignment *ir) +{ + split_rvalue(&ir->rhs); + split_rvalue(&ir->condition); + split_deref(&ir->lhs); + + return visit_continue; +} + +ir_visitor_status +ir_structure_splitting_visitor::visit_leave(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = param; + split_rvalue(&new_param); + + if (new_param != param) { + param->replace_with(new_param); + } + } + return visit_continue; +} + +ir_visitor_status +ir_structure_splitting_visitor::visit_leave(ir_return *ir) +{ + split_rvalue(&ir->value);; + return visit_continue; +} + +ir_visitor_status +ir_structure_splitting_visitor::visit_leave(ir_if *ir) +{ + split_rvalue(&ir->condition); + return visit_continue; +} + + +bool +do_structure_splitting(exec_list *instructions) +{ + ir_structure_reference_visitor refs; + void *mem_ctx = talloc_new(NULL); + + /* Trim out variables we can't split. */ + foreach_iter(exec_list_iterator, iter, refs.variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + if (!entry->declaration || entry->whole_structure_access) { + entry->remove(); + } + } + + if (refs.variable_list.is_empty()) + return false; + + /* Replace the decls of the structures to be split with their split + * components. + */ + foreach_iter(exec_list_iterator, iter, refs.variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + const struct glsl_type *type = entry->var->type; + + entry->mem_ctx = talloc_parent(entry->var); + + entry->components = talloc_array(mem_ctx, + ir_variable *, + type->length); + + for (unsigned int i = 0; i < entry->var->type->length; i++) { + const char *name = talloc_asprintf(mem_ctx, "%s_%s", + type->name, + type->fields.structure[i].name); + + entry->components[i] = + new(entry->mem_ctx) ir_variable(type->fields.structure[i].type, + name, + ir_var_temporary); + entry->var->insert_before(entry->components[i]); + } + + entry->var->remove(); + } + + ir_structure_splitting_visitor split(&refs.variable_list); + visit_list_elements(&split, instructions); + + talloc_free(mem_ctx); + + return true; +} diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index f9e24ca0f11..050116954a1 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1287,6 +1287,7 @@ link_shaders(struct gl_shader_program *prog) progress = do_function_inlining(ir) || progress; progress = do_dead_functions(ir) || progress; + progress = do_structure_splitting(ir) || progress; progress = do_if_simplification(ir) || progress; progress = do_copy_propagation(ir) || progress; progress = do_dead_code_local(ir) || progress; -- cgit v1.2.3 From 748f81a8eacabf07e1d26372a61683e6759a61a3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 13:33:38 -0700 Subject: glsl2: Make the HV actually call ir_texture's visit_leave. --- src/glsl/ir_hv_accept.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp index 8989605e26f..6dae4ed2f3f 100644 --- a/src/glsl/ir_hv_accept.cpp +++ b/src/glsl/ir_hv_accept.cpp @@ -212,7 +212,7 @@ ir_texture::accept(ir_hierarchical_visitor *v) break; } - return visit_continue_with_parent; + return (s == visit_stop) ? s : v->visit_leave(this); } -- cgit v1.2.3 From 0a0ab121f87a3b00e29c20a38fdd28e2fc31bae7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 13:25:39 -0700 Subject: ir_structure_splitting: Massive fixing to this. I'd missed putting in the actual "find structures to split" part, so most of the code didn't do anything. I was running on too large of an app and assuming the lack of progress was elsewhere. --- src/glsl/ir_structure_splitting.cpp | 43 +++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/src/glsl/ir_structure_splitting.cpp b/src/glsl/ir_structure_splitting.cpp index f57ae44aae4..902eeadb2a4 100644 --- a/src/glsl/ir_structure_splitting.cpp +++ b/src/glsl/ir_structure_splitting.cpp @@ -34,8 +34,11 @@ #include "ir.h" #include "ir_visitor.h" +#include "ir_print_visitor.h" #include "glsl_types.h" +static bool debug = false; + class variable_entry : public exec_node { public: @@ -76,7 +79,7 @@ public: virtual ir_visitor_status visit(ir_variable *); virtual ir_visitor_status visit(ir_dereference_variable *); - virtual ir_visitor_status visit(ir_dereference_record *); + virtual ir_visitor_status visit_enter(ir_dereference_record *); virtual ir_visitor_status visit_enter(ir_function_signature *); @@ -93,7 +96,7 @@ ir_structure_reference_visitor::get_variable_entry(ir_variable *var) { assert(var); - if (!var->type->is_record()) + if (!var->type->is_record() || var->mode == ir_var_uniform) return NULL; foreach_iter(exec_list_iterator, iter, this->variable_list) { @@ -132,10 +135,10 @@ ir_structure_reference_visitor::visit(ir_dereference_variable *ir) } ir_visitor_status -ir_structure_reference_visitor::visit(ir_dereference_record *ir) +ir_structure_reference_visitor::visit_enter(ir_dereference_record *ir) { /* Don't descend into the ir_dereference_variable below. */ - return visit_continue; + return visit_continue_with_parent; } ir_visitor_status @@ -162,6 +165,7 @@ public: virtual ir_visitor_status visit_leave(ir_assignment *); virtual ir_visitor_status visit_leave(ir_call *); virtual ir_visitor_status visit_leave(ir_dereference_array *); + virtual ir_visitor_status visit_leave(ir_dereference_record *); virtual ir_visitor_status visit_leave(ir_expression *); virtual ir_visitor_status visit_leave(ir_if *); virtual ir_visitor_status visit_leave(ir_return *); @@ -200,13 +204,13 @@ ir_structure_splitting_visitor::split_deref(ir_dereference **deref) if ((*deref)->ir_type != ir_type_dereference_record) return; - ir_dereference_record *deref_record = (ir_dereference_record *)deref; - ir_dereference_variable *deref_var = deref_record->as_dereference_variable(); + ir_dereference_record *deref_record = (ir_dereference_record *)*deref; + ir_dereference_variable *deref_var = deref_record->record->as_dereference_variable(); if (!deref_var) return; variable_entry *entry = get_splitting_entry(deref_var->var); - if (entry) + if (!entry) return; unsigned int i; @@ -223,6 +227,9 @@ ir_structure_splitting_visitor::split_deref(ir_dereference **deref) void ir_structure_splitting_visitor::split_rvalue(ir_rvalue **rvalue) { + if (!*rvalue) + return; + ir_dereference *deref = (*rvalue)->as_dereference(); if (!deref) @@ -281,6 +288,14 @@ ir_visitor_status ir_structure_splitting_visitor::visit_leave(ir_dereference_array *ir) { split_rvalue(&ir->array_index); + split_rvalue(&ir->array); + return visit_continue; +} + +ir_visitor_status +ir_structure_splitting_visitor::visit_leave(ir_dereference_record *ir) +{ + split_rvalue(&ir->record); return visit_continue; } @@ -328,11 +343,19 @@ bool do_structure_splitting(exec_list *instructions) { ir_structure_reference_visitor refs; - void *mem_ctx = talloc_new(NULL); + + visit_list_elements(&refs, instructions); /* Trim out variables we can't split. */ foreach_iter(exec_list_iterator, iter, refs.variable_list) { variable_entry *entry = (variable_entry *)iter.get(); + + if (debug) { + printf("structure %s@%p: decl %d, whole_access %d\n", + entry->var->name, entry->var, entry->declaration, + entry->whole_structure_access); + } + if (!entry->declaration || entry->whole_structure_access) { entry->remove(); } @@ -341,6 +364,8 @@ do_structure_splitting(exec_list *instructions) if (refs.variable_list.is_empty()) return false; + void *mem_ctx = talloc_new(NULL); + /* Replace the decls of the structures to be split with their split * components. */ @@ -356,7 +381,7 @@ do_structure_splitting(exec_list *instructions) for (unsigned int i = 0; i < entry->var->type->length; i++) { const char *name = talloc_asprintf(mem_ctx, "%s_%s", - type->name, + entry->var->name, type->fields.structure[i].name); entry->components[i] = -- cgit v1.2.3 From 8048226b7b1bbe8fd89f9c32fa4fadca4b8760c4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 14:41:09 -0700 Subject: glsl2: Insert global declarations at the top of the instruction stream. Fixes use-before-decl in glslparsertest shaders. Fixes: CorrectFull.frag CorrectModule.frag --- src/glsl/ast_to_hir.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 292c7be6217..f14341c8f72 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1951,7 +1951,14 @@ ast_declarator_list::hir(exec_list *instructions, decl->identifier); } - instructions->push_tail(var); + /* Push the variable declaration to the top. It means that all + * the variable declarations will appear in a funny + * last-to-first order, but otherwise we run into trouble if a + * function is prototyped, a global var is decled, then the + * function is defined with usage of the global var. See + * glslparsertest's CorrectModule.frag. + */ + instructions->push_head(var); instructions->append_list(&initializer_instructions); /* Add the variable to the symbol table after processing the initializer. -- cgit v1.2.3 From bc4034b243975089c06c4415d4e26edaaaec7a46 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 15:22:05 -0700 Subject: glsl2: Add a pass to convert exp and log to exp2 and log2. Fixes ir_to_mesa handling of unop_log, which used the weird ARB_vp LOG opcode that doesn't do what we want. This also lets the multiplication coefficients in there get constant-folded, possibly. Fixes: glsl-fs-log --- src/glsl/Makefile | 1 + src/glsl/ir.h | 4 +- src/glsl/ir_explog_to_explog2.cpp | 85 +++++++++++++++++++++++++++++++++++++++ src/glsl/ir_optimization.h | 1 + src/glsl/ir_validate.cpp | 4 ++ src/glsl/linker.cpp | 1 + src/mesa/program/ir_to_mesa.cpp | 7 +--- 7 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 src/glsl/ir_explog_to_explog2.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 53567508a01..752e60a79f6 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -41,6 +41,7 @@ CXX_SOURCES = \ ir_dead_code_local.cpp \ ir_dead_functions.cpp \ ir_div_to_mul_rcp.cpp \ + ir_explog_to_explog2.cpp \ ir_expression_flattening.cpp \ ir_function_can_inline.cpp \ ir_function.cpp \ diff --git a/src/glsl/ir.h b/src/glsl/ir.h index ef8339ce199..5dc3c6b9186 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -593,8 +593,8 @@ enum ir_expression_operation { ir_unop_rcp, ir_unop_rsq, ir_unop_sqrt, - ir_unop_exp, - ir_unop_log, + ir_unop_exp, /**< Log base e on gentype */ + ir_unop_log, /**< Natural log on gentype */ ir_unop_exp2, ir_unop_log2, ir_unop_f2i, /**< Float-to-integer conversion. */ diff --git a/src/glsl/ir_explog_to_explog2.cpp b/src/glsl/ir_explog_to_explog2.cpp new file mode 100644 index 00000000000..4fe1daaee91 --- /dev/null +++ b/src/glsl/ir_explog_to_explog2.cpp @@ -0,0 +1,85 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_explog_to_explog2.cpp + * + * Many GPUs don't have a base e log or exponent instruction, but they + * do have base 2 versions, so this pass converts exp and log to exp2 + * and log2 operations. + */ + +#include +#include "ir.h" +#include "glsl_types.h" + +class ir_explog_to_explog2_visitor : public ir_hierarchical_visitor { +public: + ir_explog_to_explog2_visitor() + { + this->progress = false; + } + + ir_visitor_status visit_leave(ir_expression *); + + bool progress; +}; + +bool +do_explog_to_explog2(exec_list *instructions) +{ + ir_explog_to_explog2_visitor v; + + visit_list_elements(&v, instructions); + return v.progress; +} + +ir_visitor_status +ir_explog_to_explog2_visitor::visit_leave(ir_expression *ir) +{ + if (ir->operation == ir_unop_exp) { + void *mem_ctx = talloc_parent(ir); + ir_constant *log2_e = new(mem_ctx) ir_constant(log2f(M_E)); + + ir->operation = ir_unop_exp2; + ir->operands[0] = new(mem_ctx) ir_expression(ir_binop_mul, + ir->operands[0]->type, + ir->operands[0], + log2_e); + this->progress = true; + } + + if (ir->operation == ir_unop_log) { + void *mem_ctx = talloc_parent(ir); + + ir->operation = ir_binop_mul; + ir->operands[0] = new(mem_ctx) ir_expression(ir_unop_log2, + ir->operands[0]->type, + ir->operands[0], + NULL); + ir->operands[1] = new(mem_ctx) ir_constant(1.0f / log2f(M_E)); + this->progress = true; + } + + return visit_continue; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index eac28dc64cb..c6e7beb447f 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -38,6 +38,7 @@ bool do_dead_code_local(exec_list *instructions); bool do_dead_code_unlinked(exec_list *instructions); bool do_dead_functions(exec_list *instructions); bool do_div_to_mul_rcp(exec_list *instructions); +bool do_explog_to_explog2(exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_if_return(exec_list *instructions); bool do_if_simplification(exec_list *instructions); diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 701bf21ea61..545fe2799f3 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -183,10 +183,14 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_rcp: case ir_unop_rsq: case ir_unop_sqrt: + assert(ir->type == ir->operands[0]->type); + break; + case ir_unop_exp: case ir_unop_log: case ir_unop_exp2: case ir_unop_log2: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); assert(ir->type == ir->operands[0]->type); break; diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 050116954a1..9d6de242f5f 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1281,6 +1281,7 @@ link_shaders(struct gl_shader_program *prog) do_mat_op_to_vec(ir); do_mod_to_fract(ir); do_div_to_mul_rcp(ir); + do_explog_to_explog2(ir); do { progress = false; diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 299b11d2741..26fbc4349ab 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -752,15 +752,12 @@ ir_to_mesa_visitor::visit(ir_expression *ir) ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[0]); break; - case ir_unop_exp: - ir_to_mesa_emit_scalar_op2(ir, OPCODE_POW, result_dst, - src_reg_for_float(M_E), op[0]); - break; case ir_unop_exp2: ir_to_mesa_emit_scalar_op1(ir, OPCODE_EX2, result_dst, op[0]); break; + case ir_unop_exp: case ir_unop_log: - ir_to_mesa_emit_scalar_op1(ir, OPCODE_LOG, result_dst, op[0]); + assert(!"not reached: should be handled by ir_explog_to_explog2"); break; case ir_unop_log2: ir_to_mesa_emit_scalar_op1(ir, OPCODE_LG2, result_dst, op[0]); -- cgit v1.2.3 From 1e0f0459e0ca8b9f0c67f8178e5189b8cfd6078c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 5 Aug 2010 17:21:39 -0700 Subject: glsl2: Log a better error message when a matching function cannot be found --- src/glsl/ast_function.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 1b8b3195e5b..ca7d0877271 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -57,6 +57,41 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters, } +/** + * Generate a source prototype for a function signature + * + * \param return_type Return type of the function. May be \c NULL. + * \param name Name of the function. + * \param parameters Parameter list for the function. This may be either a + * formal or actual parameter list. Only the type is used. + * + * \return + * A talloced string representing the prototype of the function. + */ +char * +prototype_string(const glsl_type *return_type, const char *name, + exec_list *parameters) +{ + char *str = NULL; + + if (return_type != NULL) + str = talloc_asprintf(str, "%s ", return_type->name); + + str = talloc_asprintf_append(str, "%s(", name); + + const char *comma = ""; + foreach_list(node, parameters) { + const ir_instruction *const param = (ir_instruction *) node; + + str = talloc_asprintf_append(str, "%s%s", comma, param->type->name); + comma = ", "; + } + + str = talloc_strdup_append(str, ")"); + return str; +} + + static ir_rvalue * process_call(exec_list *instructions, ir_function *f, YYLTYPE *loc, exec_list *actual_parameters, @@ -132,13 +167,23 @@ process_call(exec_list *instructions, ir_function *f, return NULL; } } else { - /* FINISHME: Log a better error message here. G++ will show the types - * FINISHME: of the actual parameters and the set of candidate - * FINISHME: functions. A different error should also be logged when - * FINISHME: multiple functions match. - */ + char *str = prototype_string(NULL, f->name, actual_parameters); + _mesa_glsl_error(loc, state, "no matching function for call to `%s'", - f->name); + str); + talloc_free(str); + + const char *prefix = "candidates are: "; + foreach_list (node, &f->signatures) { + ir_function_signature *sig = (ir_function_signature *) node; + + str = prototype_string(sig->return_type, f->name, &sig->parameters); + _mesa_glsl_error(loc, state, "%s%s\n", prefix, str); + talloc_free(str); + + prefix = " "; + } + return ir_call::get_error_instruction(ctx); } } -- cgit v1.2.3 From 0a09d679ca97dcb634a939df2110a90c9504e2ec Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 5 Aug 2010 17:29:15 -0700 Subject: glsl_type: Don't have two versions of a type with the same name Previously some sampler types were duplicated in GLSL 1.30 and GL_EXT_texture_array. This resulted in not being able to find the built-in sampler functions when the extension was used. When the built-in functions were compiled, they bound to the 1.30 version. This caused a type mismatch when trying to find the function. It also resulted in a confusing error message: 0:0(0): error: no matching function for call to `texture2DArray(sampler2DArray, vec3)' 0:0(0): error: candidates are: vec4 texture2DArray(sampler2DArray, vec3) 0:0(0): error: vec4 texture2DArray(sampler2DArray, vec3, float) --- src/glsl/builtin_types.h | 12 +++--------- src/glsl/glsl_types.cpp | 1 + 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/glsl/builtin_types.h b/src/glsl/builtin_types.h index bd8f8b583a5..bfa4f3f5408 100644 --- a/src/glsl/builtin_types.h +++ b/src/glsl/builtin_types.h @@ -212,23 +212,17 @@ const glsl_type glsl_type::builtin_130_types[] = { glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"), glsl_type(GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1, "uvec4"), - /* 1D and 2D texture arrays */ - glsl_type(GL_SAMPLER_1D_ARRAY, - GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), + /* 1D and 2D texture arrays - several of these are included only in + * builtin_EXT_texture_array_types. + */ glsl_type(GL_INT_SAMPLER_1D_ARRAY, GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"), glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"), - glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW, - GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), - glsl_type(GL_SAMPLER_2D_ARRAY, - GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), glsl_type(GL_INT_SAMPLER_2D_ARRAY, GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"), glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"), - glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW, - GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), /* cube shadow samplers */ glsl_type(GL_SAMPLER_CUBE_SHADOW, diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 88f305ac254..03f84603b55 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -144,6 +144,7 @@ glsl_type::generate_130_types(glsl_symbol_table *symtab) add_types_to_symbol_table(symtab, builtin_130_types, Elements(builtin_130_types), false); + generate_EXT_texture_array_types(symtab, false); } -- cgit v1.2.3 From 4f397e1d641bf265b395f7dec062dab451fb5a54 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 5 Aug 2010 17:50:13 -0700 Subject: glsl2: Enable all supported extensions in stand-alone compiler --- src/glsl/glsl_parser_extras.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 15fa61d9505..dbf6f531569 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -74,6 +74,11 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct __GLcontextRec *ctx, static struct gl_extensions null_extensions; memset(&null_extensions, 0, sizeof(null_extensions)); + null_extensions.ARB_draw_buffers = GL_TRUE; + null_extensions.ARB_fragment_coord_conventions = GL_TRUE; + null_extensions.EXT_texture_array = GL_TRUE; + null_extensions.NV_texture_rectangle = GL_TRUE; + this->extensions = &null_extensions; /* 1.10 minimums. */ -- cgit v1.2.3 From 0a86d766ef0d98abd3373609a637bf137203e994 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 5 Aug 2010 17:57:48 -0700 Subject: ir_to_mesa: Handle texture-array samplers Fixes piglit test array_texture. --- src/mesa/program/ir_to_mesa.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 26fbc4349ab..f5e5f7d7b87 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2040,10 +2040,12 @@ ir_to_mesa_visitor::visit(ir_texture *ir) switch (sampler->type->sampler_dimensionality) { case GLSL_SAMPLER_DIM_1D: - inst->tex_target = TEXTURE_1D_INDEX; + inst->tex_target = (sampler->type->sampler_array) + ? TEXTURE_1D_ARRAY_INDEX : TEXTURE_1D_INDEX; break; case GLSL_SAMPLER_DIM_2D: - inst->tex_target = TEXTURE_2D_INDEX; + inst->tex_target = (sampler->type->sampler_array) + ? TEXTURE_2D_ARRAY_INDEX : TEXTURE_2D_INDEX; break; case GLSL_SAMPLER_DIM_3D: inst->tex_target = TEXTURE_3D_INDEX; -- cgit v1.2.3 From 658e25987fbec3b826f500baa6d4d936b9552b13 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 15:54:56 -0700 Subject: ir_to_mesa: Give the expected size for _mesa_add_attribute(). Fixes a failure in glean shaderAPI. --- src/mesa/program/ir_to_mesa.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index f5e5f7d7b87..9979e6e3e07 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -43,6 +43,7 @@ extern "C" { #include "main/mtypes.h" +#include "main/shaderapi.h" #include "main/shaderobj.h" #include "main/uniforms.h" #include "program/hash_table.h" @@ -1458,7 +1459,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) ir->var->location >= VERT_ATTRIB_GENERIC0) { _mesa_add_attribute(prog->Attributes, ir->var->name, - type_size(ir->var->type) * 4, + _mesa_sizeof_glsl_type(ir->var->type->gl_type), ir->var->type->gl_type, ir->var->location - VERT_ATTRIB_GENERIC0); } -- cgit v1.2.3 From 8d61a23b1a1d0d4b21f0fab64f6d863a8ee3d7f1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 16:00:46 -0700 Subject: glsl2: Don't assert in a couple of places when encountering sampler arrays. Fixes glean shaderAPI. --- src/glsl/linker.cpp | 10 ++++++---- src/mesa/program/ir_to_mesa.cpp | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 9d6de242f5f..e93c2f55549 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -793,11 +793,13 @@ assign_uniform_locations(struct gl_shader_program *prog) if ((var == NULL) || (var->mode != ir_var_uniform)) continue; - if (var->type->is_sampler()) - continue; - const unsigned vec4_slots = (var->component_slots() + 3) / 4; - assert(vec4_slots != 0); + if (vec4_slots == 0) { + /* If we've got a sampler or an aggregate of them, the size can + * end up zero. Don't allocate any space. + */ + continue; + } uniform_node *n = (uniform_node *) hash_table_find(ht, var->name); if (n == NULL) { diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 9979e6e3e07..66b1a2f9d9a 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -518,6 +518,11 @@ type_size(const struct glsl_type *type) size += type_size(type->fields.structure[i].type); } return size; + case GLSL_TYPE_SAMPLER: + /* Samplers take up no register space, since they're baked in at + * link time. + */ + return 0; default: assert(0); } -- cgit v1.2.3 From 199c441239762eec86b3cb4b558aef486907a8b6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 6 Aug 2010 00:21:12 -0700 Subject: glsl2: Fix inlining with sampler array or struct dereferences as arguments. Previously, we'd replace an argument of mysampler[2] with a plain reference to mysampler by using the cloning hash table. Instead, use a visitor to clone whatever complicated sampler dereference into the sampler parameter derefs in the inlined function body. --- src/glsl/ir_function_inlining.cpp | 143 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 138 insertions(+), 5 deletions(-) diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 973813774e2..35eb2b38ea9 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -35,6 +35,11 @@ #include "glsl_types.h" #include "program/hash_table.h" +static void +do_sampler_replacement(exec_list *instructions, + ir_variable *sampler, + ir_dereference *deref); + class ir_function_inlining_visitor : public ir_hierarchical_visitor { public: ir_function_inlining_visitor() @@ -96,7 +101,7 @@ replace_return_with_assignment(ir_instruction *ir, void *data) /* un-valued return has to be the last return, or we shouldn't * have reached here. (see can_inline()). */ - assert(!ret->next->is_tail_sentinel()); + assert(ret->next->is_tail_sentinel()); ret->remove(); } } @@ -142,10 +147,9 @@ ir_call::generate_inline(ir_instruction *next_ir) /* For samplers, we want the inlined sampler references * referencing the passed in sampler variable, since that * will have the location information, which an assignment of - * a sampler wouldn't. + * a sampler wouldn't. Fix it up below. */ parameters[i] = NULL; - hash_table_insert(ht, param->variable_referenced(), sig_param); } else { parameters[i] = sig_param->clone(ctx, ht); parameters[i]->mode = ir_var_auto; @@ -166,15 +170,40 @@ ir_call::generate_inline(ir_instruction *next_ir) param_iter.next(); } - /* Generate the inlined body of the function. */ + exec_list new_instructions; + + /* Generate the inlined body of the function to a new list */ foreach_iter(exec_list_iterator, iter, callee->body) { ir_instruction *ir = (ir_instruction *)iter.get(); ir_instruction *new_ir = ir->clone(ctx, ht); - next_ir->insert_before(new_ir); + new_instructions.push_tail(new_ir); visit_tree(new_ir, replace_return_with_assignment, retval); } + /* If any samplers were passed in, replace any deref of the sampler + * with a deref of the sampler argument. + */ + param_iter = this->actual_parameters.iterator(); + sig_param_iter = this->callee->parameters.iterator(); + for (i = 0; i < num_parameters; i++) { + ir_instruction *const param = (ir_instruction *) param_iter.get(); + ir_variable *sig_param = (ir_variable *) sig_param_iter.get(); + + if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) { + ir_dereference *deref = param->as_dereference(); + + assert(deref); + do_sampler_replacement(&new_instructions, sig_param, deref); + } + } + + /* Now push those new instructions in. */ + foreach_iter(exec_list_iterator, iter, new_instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + next_ir->insert_before(ir); + } + /* Copy back the value of any 'out' parameters from the function body * variables to our own. */ @@ -280,3 +309,107 @@ ir_function_inlining_visitor::visit_enter(ir_assignment *ir) return visit_continue; } + +/** + * Replaces references to the "sampler" variable with a clone of "deref." + * + * From the spec, samplers can appear in the tree as function + * (non-out) parameters and as the result of array indexing and + * structure field selection. In our builtin implementation, they + * also appear in the sampler field of an ir_tex instruction. + */ + +class ir_sampler_replacement_visitor : public ir_hierarchical_visitor { +public: + ir_sampler_replacement_visitor(ir_variable *sampler, ir_dereference *deref) + { + this->sampler = sampler; + this->deref = deref; + } + + virtual ~ir_sampler_replacement_visitor() + { + } + + virtual ir_visitor_status visit_leave(ir_call *); + virtual ir_visitor_status visit_leave(ir_dereference_array *); + virtual ir_visitor_status visit_leave(ir_dereference_record *); + virtual ir_visitor_status visit_leave(ir_texture *); + + void replace_deref(ir_dereference **deref); + void replace_rvalue(ir_rvalue **rvalue); + + ir_variable *sampler; + ir_dereference *deref; +}; + +void +ir_sampler_replacement_visitor::replace_deref(ir_dereference **deref) +{ + ir_dereference_variable *deref_var = (*deref)->as_dereference_variable(); + if (deref_var && deref_var->var == this->sampler) { + *deref = this->deref->clone(talloc_parent(*deref), NULL); + } +} + +void +ir_sampler_replacement_visitor::replace_rvalue(ir_rvalue **rvalue) +{ + if (!*rvalue) + return; + + ir_dereference *deref = (*rvalue)->as_dereference(); + + if (!deref) + return; + + replace_deref(&deref); + *rvalue = deref; +} + +ir_visitor_status +ir_sampler_replacement_visitor::visit_leave(ir_texture *ir) +{ + replace_deref(&ir->sampler); + + return visit_continue; +} + +ir_visitor_status +ir_sampler_replacement_visitor::visit_leave(ir_dereference_array *ir) +{ + replace_rvalue(&ir->array); + return visit_continue; +} + +ir_visitor_status +ir_sampler_replacement_visitor::visit_leave(ir_dereference_record *ir) +{ + replace_rvalue(&ir->record); + return visit_continue; +} + +ir_visitor_status +ir_sampler_replacement_visitor::visit_leave(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = param; + replace_rvalue(&new_param); + + if (new_param != param) { + param->replace_with(new_param); + } + } + return visit_continue; +} + +static void +do_sampler_replacement(exec_list *instructions, + ir_variable *sampler, + ir_dereference *deref) +{ + ir_sampler_replacement_visitor v(sampler, deref); + + visit_list_elements(&v, instructions); +} -- cgit v1.2.3 From c234d0b25f622a7bdd3c40bc72fdbd59d8494c7c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 17:00:12 -0700 Subject: ir_to_mesa: Add support for sampler arrays. Support for samplers in general is still incomplete -- anything in a uniform struct will still be broken. But that doesn't appear to be any different from master. Fixes: glsl-fs-uniform-sampler-array.shader_test --- src/mesa/program/ir_to_mesa.cpp | 47 +++++++++++++++++++++++++++++++-------- src/mesa/program/prog_parameter.c | 7 +++--- src/mesa/program/prog_parameter.h | 2 +- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 66b1a2f9d9a..d8a13220ae2 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1398,10 +1398,19 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) break; /* FINISHME: Fix up uniform name for arrays and things */ - if (ir->var->type->base_type == GLSL_TYPE_SAMPLER) { + if (ir->var->type->base_type == GLSL_TYPE_SAMPLER || + (ir->var->type->base_type == GLSL_TYPE_ARRAY && + ir->var->type->fields.array->base_type == GLSL_TYPE_SAMPLER)) { + int array_length; + + if (ir->var->type->base_type == GLSL_TYPE_ARRAY) + array_length = ir->var->type->length; + else + array_length = 1; int sampler = _mesa_add_sampler(this->prog->Parameters, ir->var->name, - ir->var->type->gl_type); + ir->var->type->gl_type, + array_length); set_sampler_location(ir->var, sampler); entry = new(mem_ctx) variable_storage(ir->var, PROGRAM_SAMPLER, @@ -2035,22 +2044,42 @@ ir_to_mesa_visitor::visit(ir_texture *ir) if (ir->shadow_comparitor) inst->tex_shadow = GL_TRUE; - ir_dereference_variable *sampler = ir->sampler->as_dereference_variable(); - assert(sampler); /* FINISHME: sampler arrays */ + ir_variable *sampler = ir->sampler->variable_referenced(); + /* generate the mapping, remove when we generate storage at * declaration time */ - sampler->accept(this); + ir->sampler->accept(this); + + inst->sampler = get_sampler_location(sampler); + + ir_dereference_array *sampler_array = ir->sampler->as_dereference_array(); + if (sampler_array) { + ir_constant *array_index = + sampler_array->array_index->constant_expression_value(); + + /* GLSL 1.10 and 1.20 allowed variable sampler array indices, + * while GLSL 1.30 requires that the array indices be constant + * integer expressions. We don't expect any driver to actually + * work with a really variable array index, and in 1.20 all that + * would work would be an unrolled loop counter, so assert that + * we ended up with a constant at least.. + */ + assert(array_index); + inst->sampler += array_index->value.i[0]; + } - inst->sampler = get_sampler_location(sampler->var); + const glsl_type *sampler_type = sampler->type; + while (sampler_type->base_type == GLSL_TYPE_ARRAY) + sampler_type = sampler_type->fields.array; - switch (sampler->type->sampler_dimensionality) { + switch (sampler_type->sampler_dimensionality) { case GLSL_SAMPLER_DIM_1D: - inst->tex_target = (sampler->type->sampler_array) + inst->tex_target = (sampler_type->sampler_array) ? TEXTURE_1D_ARRAY_INDEX : TEXTURE_1D_INDEX; break; case GLSL_SAMPLER_DIM_2D: - inst->tex_target = (sampler->type->sampler_array) + inst->tex_target = (sampler_type->sampler_array) ? TEXTURE_2D_ARRAY_INDEX : TEXTURE_2D_INDEX; break; case GLSL_SAMPLER_DIM_3D: diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index ddbfe95c152..fa5deaf127d 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -344,18 +344,19 @@ _mesa_use_uniform(struct gl_program_parameter_list *paramList, */ GLint _mesa_add_sampler(struct gl_program_parameter_list *paramList, - const char *name, GLenum datatype) + const char *name, GLenum datatype, int array_length) { GLint i = _mesa_lookup_parameter_index(paramList, -1, name); if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_SAMPLER) { - ASSERT(paramList->Parameters[i].Size == 1); + ASSERT(paramList->Parameters[i].Size == 4 * array_length); ASSERT(paramList->Parameters[i].DataType == datatype); /* already in list */ return (GLint) paramList->ParameterValues[i][0]; } else { GLuint i; - const GLint size = 1; /* a sampler is basically a texture unit number */ + /* One integer texture unit number goes in each parameter location. */ + const GLint size = 4 * array_length; GLfloat value[4]; GLint numSamplers = 0; for (i = 0; i < paramList->NumParameters; i++) { diff --git a/src/mesa/program/prog_parameter.h b/src/mesa/program/prog_parameter.h index cc3378ae201..1860f312879 100644 --- a/src/mesa/program/prog_parameter.h +++ b/src/mesa/program/prog_parameter.h @@ -142,7 +142,7 @@ _mesa_use_uniform(struct gl_program_parameter_list *paramList, extern GLint _mesa_add_sampler(struct gl_program_parameter_list *paramList, - const char *name, GLenum datatype); + const char *name, GLenum datatype, int array_length); extern GLint _mesa_add_varying(struct gl_program_parameter_list *paramList, -- cgit v1.2.3 From 925b49ff310bf0b307add7c34627cddf87e6a554 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 6 Aug 2010 13:07:25 -0700 Subject: glsl2: Move gl_program->InputsRead/OutputsWritten setting to an ir pass. This lets us handle arrays much better than trying to work backwards from assembly. Fixes fbo-drawbuffers-maxtargets on swrast (i965 needs loop unrolling) --- src/glsl/Makefile | 1 + src/glsl/ir.h | 3 + src/glsl/ir_set_program_inouts.cpp | 167 +++++++++++++++++++++++++++++++++++++ src/mesa/program/ir_to_mesa.cpp | 71 +--------------- 4 files changed, 175 insertions(+), 67 deletions(-) create mode 100644 src/glsl/ir_set_program_inouts.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 752e60a79f6..0f8b290b654 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -56,6 +56,7 @@ CXX_SOURCES = \ ir_mod_to_fract.cpp \ ir_print_visitor.cpp \ ir_reader.cpp \ + ir_set_program_inouts.cpp \ ir_structure_splitting.cpp \ ir_swizzle_swizzle.cpp \ ir_tree_grafting.cpp \ diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 5dc3c6b9186..d852a6a93bf 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1392,4 +1392,7 @@ import_prototypes(const exec_list *source, exec_list *dest, extern bool ir_has_call(ir_instruction *ir); +extern void +do_set_program_inouts(exec_list *instructions, struct gl_program *prog); + #endif /* IR_H */ diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp new file mode 100644 index 00000000000..658637775a4 --- /dev/null +++ b/src/glsl/ir_set_program_inouts.cpp @@ -0,0 +1,167 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_set_program_inouts.cpp + * + * Sets the InputsRead and OutputsWritten of Mesa programs. + * + * Mesa programs (gl_program, not gl_shader_program) have a set of + * flags indicating which varyings are read and written. Computing + * which are actually read from some sort of backend code can be + * tricky when variable array indexing involved. So this pass + * provides support for setting InputsRead and OutputsWritten right + * from the GLSL IR. + */ + +extern "C" { +#include "main/mtypes.h" +#include "program/hash_table.h" +} +#include "ir.h" +#include "ir_visitor.h" +#include "glsl_types.h" + +class ir_set_program_inouts_visitor : public ir_hierarchical_visitor { +public: + ir_set_program_inouts_visitor(struct gl_program *prog) + { + this->prog = prog; + this->ht = hash_table_ctor(0, + hash_table_pointer_hash, + hash_table_pointer_compare); + } + ir_set_program_inouts_visitor() + { + hash_table_dtor(this->ht); + } + + virtual ir_visitor_status visit_enter(ir_dereference_array *); + virtual ir_visitor_status visit_enter(ir_function_signature *); + virtual ir_visitor_status visit(ir_dereference_variable *); + virtual ir_visitor_status visit(ir_variable *); + + struct gl_program *prog; + struct hash_table *ht; +}; + +static void +mark(struct gl_program *prog, ir_variable *var, int index) +{ + /* As of GLSL 1.20, varyings can only be floats, floating-point + * vectors or matrices, or arrays of them. For Mesa programs using + * InputsRead/OutputsWritten, everything but matrices uses one + * slot, while matrices use a slot per column. Presumably + * something doing a more clever packing would use something other + * than InputsRead/OutputsWritten. + */ + const glsl_type *element_type; + int element_size; + + if (var->type->is_array()) + element_type = var->type->fields.array; + else + element_type = var->type; + + if (element_type->is_matrix()) + element_size = element_type->matrix_columns; + else + element_size = 1; + + index *= element_size; + for (int i = 0; i < element_size; i++) { + if (var->mode == ir_var_in) + prog->InputsRead |= BITFIELD64_BIT(var->location + index + i); + else + prog->OutputsWritten |= BITFIELD64_BIT(var->location + index + i); + } +} + +/* Default handler: Mark all the locations in the variable as used. */ +ir_visitor_status +ir_set_program_inouts_visitor::visit(ir_dereference_variable *ir) +{ + if (hash_table_find(this->ht, ir->var) == NULL) + return visit_continue; + + if (ir->type->is_array()) { + for (unsigned int i = 0; i < ir->type->length; i++) { + mark(this->prog, ir->var, i); + } + } else { + mark(this->prog, ir->var, 0); + } + + return visit_continue; +} + +ir_visitor_status +ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir) +{ + ir_dereference_variable *deref_var; + ir_constant *index = ir->array_index->as_constant(); + deref_var = ir->array->as_dereference_variable(); + ir_variable *var = NULL; + + /* Check that we're dereferencing a shader in or out */ + if (deref_var) + var = (ir_variable *)hash_table_find(this->ht, deref_var->var); + + if (index && var) { + mark(this->prog, var, index->value.i[0]); + return visit_continue_with_parent; + } + + return visit_continue; +} + +ir_visitor_status +ir_set_program_inouts_visitor::visit(ir_variable *ir) +{ + if (ir->mode == ir_var_in || + ir->mode == ir_var_out) { + hash_table_insert(this->ht, ir, ir); + } + + return visit_continue; +} + +ir_visitor_status +ir_set_program_inouts_visitor::visit_enter(ir_function_signature *ir) +{ + /* We don't want to descend into the function parameters and + * consider them as shader inputs or outputs. + */ + visit_list_elements(this, &ir->body); + return visit_continue_with_parent; +} + +void +do_set_program_inouts(exec_list *instructions, struct gl_program *prog) +{ + ir_set_program_inouts_visitor v(prog); + + prog->InputsRead = 0; + prog->OutputsWritten = 0; + visit_list_elements(&v, instructions); +} diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index d8a13220ae2..c6856eb5a40 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2323,81 +2323,15 @@ print_program(struct prog_instruction *mesa_instructions, } } -static void -mark_input(struct gl_program *prog, - int index, - GLboolean reladdr) -{ - prog->InputsRead |= BITFIELD64_BIT(index); - int i; - - if (reladdr) { - if (index >= FRAG_ATTRIB_TEX0 && index <= FRAG_ATTRIB_TEX7) { - for (i = 0; i < 8; i++) { - prog->InputsRead |= BITFIELD64_BIT(FRAG_ATTRIB_TEX0 + i); - } - } else { - assert(!"FINISHME: Mark InputsRead for varying arrays"); - } - } -} - -static void -mark_output(struct gl_program *prog, - int index, - GLboolean reladdr) -{ - prog->OutputsWritten |= BITFIELD64_BIT(index); - int i; - - if (reladdr) { - if (index >= VERT_RESULT_TEX0 && index <= VERT_RESULT_TEX7) { - for (i = 0; i < 8; i++) { - prog->OutputsWritten |= BITFIELD64_BIT(FRAG_ATTRIB_TEX0 + i); - } - } else { - assert(!"FINISHME: Mark OutputsWritten for varying arrays"); - } - } -} - static void count_resources(struct gl_program *prog) { unsigned int i; - prog->InputsRead = 0; - prog->OutputsWritten = 0; prog->SamplersUsed = 0; for (i = 0; i < prog->NumInstructions; i++) { struct prog_instruction *inst = &prog->Instructions[i]; - unsigned int reg; - - switch (inst->DstReg.File) { - case PROGRAM_OUTPUT: - mark_output(prog, inst->DstReg.Index, inst->DstReg.RelAddr); - break; - case PROGRAM_INPUT: - mark_input(prog, inst->DstReg.Index, inst->DstReg.RelAddr); - break; - default: - break; - } - - for (reg = 0; reg < _mesa_num_inst_src_regs(inst->Opcode); reg++) { - switch (inst->SrcReg[reg].File) { - case PROGRAM_OUTPUT: - mark_output(prog, inst->SrcReg[reg].Index, - inst->SrcReg[reg].RelAddr); - break; - case PROGRAM_INPUT: - mark_input(prog, inst->SrcReg[reg].Index, inst->SrcReg[reg].RelAddr); - break; - default: - break; - } - } /* Instead of just using the uniform's value to map to a * sampler, Mesa first allocates a separate number for the @@ -2578,6 +2512,7 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, } set_branchtargets(&v, mesa_instructions, num_instructions); + if (ctx->Shader.Flags & GLSL_DUMP) { printf("\n"); printf("GLSL IR for linked %s program %d:\n", target_string, @@ -2594,6 +2529,9 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, prog->Instructions = mesa_instructions; prog->NumInstructions = num_instructions; + do_set_program_inouts(shader->ir, prog); + count_resources(prog); + _mesa_reference_program(ctx, &shader->Program, prog); if ((ctx->Shader.Flags & GLSL_NO_OPT) == 0) { @@ -2731,7 +2669,6 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]); - count_resources(linked_prog); link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog); -- cgit v1.2.3 From 63cddb27d7e0f8d3fd71ccdf719341432a0ca970 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Fri, 6 Aug 2010 16:09:02 +0200 Subject: copy_propagation: do propagation into non-out call params --- src/glsl/ir_copy_propagation.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/glsl/ir_copy_propagation.cpp b/src/glsl/ir_copy_propagation.cpp index 1d28392d7c3..90a49d5a82a 100644 --- a/src/glsl/ir_copy_propagation.cpp +++ b/src/glsl/ir_copy_propagation.cpp @@ -164,11 +164,17 @@ ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) ir_visitor_status ir_copy_propagation_visitor::visit_enter(ir_call *ir) { - (void)ir; - - /* Note, if we were to do copy propagation to parameters of calls, we'd - * have to be careful about out params. - */ + /* Do copy propagation on call parameters, but skip any out params */ + exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { + ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); + ir_instruction *ir = (ir_instruction *)iter.get(); + if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout && + sig_param->mode != ir_var_uniform) { + ir->accept(this); + } + sig_param_iter.next(); + } return visit_continue_with_parent; } -- cgit v1.2.3 From 58f1ffdd7c64c0c0962d2aaacdde8f55edefbb2c Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Fri, 6 Aug 2010 12:31:56 +0200 Subject: ir_function_inlining: Fix missing iter.next() in inlining sampler params. Fixes glsl-fs-function-samplers. --- src/glsl/ir_function_inlining.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 35eb2b38ea9..fd52d106b1b 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -196,6 +196,8 @@ ir_call::generate_inline(ir_instruction *next_ir) assert(deref); do_sampler_replacement(&new_instructions, sig_param, deref); } + param_iter.next(); + sig_param_iter.next(); } /* Now push those new instructions in. */ -- cgit v1.2.3 From b7e63c34e74ecfb1c4af8132471ca9cb70d28d1f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 7 Aug 2010 00:50:08 -0700 Subject: glsl2: Add the 1.30 reserved keywords. --- src/glsl/glsl_lexer.cpp | 1043 +++++++++++------- src/glsl/glsl_lexer.lpp | 32 + src/glsl/glsl_parser.cpp | 2645 ++++++++++++++++++++++++---------------------- src/glsl/glsl_parser.h | 143 ++- src/glsl/glsl_parser.ypp | 9 +- 5 files changed, 2162 insertions(+), 1710 deletions(-) diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp index 43be3170ba8..672b0b13599 100644 --- a/src/glsl/glsl_lexer.cpp +++ b/src/glsl/glsl_lexer.cpp @@ -54,6 +54,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -84,8 +85,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -159,15 +158,7 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -358,8 +349,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 147 -#define YY_END_OF_BUFFER 148 +#define YY_NUM_RULES 177 +#define YY_END_OF_BUFFER 178 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -367,66 +358,81 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[525] = +static yyconst flex_int16_t yy_accept[668] = { 0, - 0, 0, 9, 9, 148, 146, 1, 14, 146, 146, - 146, 146, 146, 146, 146, 146, 90, 88, 146, 146, - 146, 145, 146, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 146, 1, 146, 85, 147, 9, 13, - 147, 12, 10, 11, 1, 74, 81, 75, 84, 78, + 0, 0, 9, 9, 178, 176, 1, 14, 176, 176, + 176, 176, 176, 176, 176, 176, 90, 88, 176, 176, + 176, 175, 176, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 175, 176, 1, 176, 85, 177, 9, 13, + 177, 12, 10, 11, 1, 74, 81, 75, 84, 78, 69, 80, 70, 87, 92, 79, 93, 90, 0, 0, - 95, 0, 88, 0, 71, 73, 72, 0, 145, 77, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 22, 145, 145, 145, 145, 145, 145, 145, 145, - - 145, 145, 145, 145, 145, 26, 50, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 86, 76, 1, 0, 0, - 2, 0, 0, 0, 0, 9, 8, 12, 11, 0, - 92, 91, 0, 93, 0, 94, 89, 82, 83, 98, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 25, - 145, 145, 145, 145, 145, 145, 145, 145, 19, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 51, - - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 0, 0, 0, 0, 8, 0, 92, - 0, 91, 0, 93, 94, 145, 17, 145, 145, 138, - 145, 145, 145, 145, 145, 145, 145, 145, 24, 101, - 145, 145, 145, 57, 145, 145, 106, 120, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 117, 141, 38, - 39, 40, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 104, - 96, 145, 145, 145, 145, 145, 145, 35, 36, 37, - - 67, 145, 145, 0, 0, 0, 0, 0, 91, 145, - 20, 29, 30, 31, 145, 99, 16, 145, 145, 145, - 145, 128, 129, 130, 145, 97, 121, 18, 131, 132, - 133, 143, 125, 126, 127, 145, 52, 123, 145, 145, - 32, 33, 34, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 118, 145, 145, - 145, 145, 145, 145, 145, 145, 100, 145, 140, 145, - 145, 23, 0, 0, 0, 0, 145, 145, 145, 145, - 145, 119, 114, 109, 145, 145, 68, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 145, 145, 145, 145, - - 124, 105, 145, 112, 28, 145, 137, 58, 113, 66, - 107, 145, 145, 145, 145, 145, 145, 0, 0, 0, - 0, 145, 145, 145, 108, 27, 145, 145, 145, 142, - 145, 145, 145, 145, 145, 145, 102, 53, 145, 54, - 145, 0, 0, 0, 7, 0, 145, 55, 21, 115, - 145, 145, 145, 110, 145, 145, 145, 145, 145, 145, - 103, 122, 111, 0, 0, 6, 0, 0, 0, 3, - 15, 116, 56, 139, 145, 144, 60, 61, 62, 145, - 0, 0, 0, 0, 145, 145, 145, 145, 145, 145, - 4, 0, 5, 0, 0, 0, 145, 145, 145, 145, - - 145, 63, 0, 145, 145, 145, 145, 145, 59, 145, - 134, 145, 135, 145, 145, 145, 64, 145, 65, 145, - 145, 145, 136, 0 + 95, 0, 88, 0, 71, 73, 72, 0, 175, 77, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 22, 175, 175, 175, 175, 175, 175, 175, + + 175, 175, 175, 175, 175, 175, 26, 175, 175, 50, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 86, 76, 1, 0, 0, 2, 0, 0, 0, + 0, 9, 8, 12, 11, 0, 92, 91, 0, 93, + 0, 94, 89, 82, 83, 175, 98, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 25, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 19, + + 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 51, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 0, 0, + 0, 0, 8, 0, 92, 0, 91, 0, 93, 94, + 175, 175, 17, 175, 175, 138, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 24, 101, 175, 175, 175, + 175, 57, 175, 175, 106, 120, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 117, 141, 38, + 39, 40, 175, 175, 175, 175, 175, 175, 175, 175, + + 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 104, 96, 175, 175, 175, 175, 175, 175, + 175, 35, 36, 37, 67, 175, 175, 0, 0, 0, + 0, 0, 91, 175, 175, 20, 29, 30, 31, 175, + 99, 175, 16, 175, 175, 175, 175, 128, 129, 130, + 175, 97, 175, 121, 18, 131, 132, 133, 143, 125, + 126, 127, 175, 175, 175, 52, 123, 175, 175, 32, + 33, 34, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 118, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 100, + + 175, 140, 175, 175, 23, 0, 0, 0, 0, 147, + 175, 175, 145, 175, 175, 175, 119, 114, 150, 175, + 175, 175, 175, 175, 175, 109, 175, 175, 68, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 175, 175, + 175, 175, 124, 105, 175, 175, 112, 28, 175, 175, + 137, 58, 113, 66, 148, 107, 175, 175, 175, 175, + 175, 175, 175, 0, 0, 0, 0, 175, 175, 175, + 108, 27, 175, 175, 175, 175, 175, 175, 151, 152, + 153, 175, 175, 175, 175, 142, 175, 175, 175, 175, + 175, 175, 175, 175, 102, 175, 175, 175, 175, 175, + + 53, 175, 54, 175, 0, 0, 0, 7, 0, 175, + 55, 21, 115, 155, 156, 157, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 110, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 103, 159, 160, + 161, 175, 175, 122, 111, 0, 0, 6, 0, 0, + 0, 3, 15, 175, 175, 175, 175, 175, 175, 175, + 175, 175, 154, 116, 56, 139, 175, 146, 144, 174, + 60, 61, 62, 175, 175, 175, 175, 175, 175, 0, + 0, 0, 0, 175, 175, 175, 158, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, + + 175, 175, 162, 4, 0, 5, 0, 0, 0, 175, + 175, 175, 175, 175, 175, 175, 171, 175, 175, 175, + 175, 175, 175, 63, 175, 175, 175, 0, 175, 175, + 172, 163, 175, 164, 175, 175, 175, 175, 175, 175, + 175, 175, 175, 173, 165, 166, 169, 170, 59, 175, + 134, 175, 135, 149, 167, 168, 175, 175, 175, 64, + 175, 65, 175, 175, 175, 136, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -437,14 +443,14 @@ static yyconst flex_int32_t yy_ec[256] = 1, 2, 5, 1, 6, 1, 7, 8, 1, 1, 1, 9, 10, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 19, 20, 20, 21, 1, 22, - 23, 24, 1, 1, 25, 25, 26, 27, 28, 29, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 31, 32, 30, 30, 30, 30, 33, 30, 30, - 1, 1, 1, 34, 30, 1, 35, 36, 37, 38, - - 39, 40, 41, 42, 43, 30, 44, 45, 46, 47, - 48, 49, 30, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 1, 59, 1, 1, 1, 1, 1, 1, + 23, 24, 1, 1, 25, 26, 27, 28, 29, 30, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 32, 33, 31, 31, 31, 31, 34, 31, 31, + 1, 1, 1, 35, 36, 1, 37, 38, 39, 40, + + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 31, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 1, 62, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -461,342 +467,415 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[60] = +static yyconst flex_int32_t yy_meta[63] = { 0, - 1, 2, 3, 1, 1, 1, 1, 1, 1, 4, - 4, 1, 1, 5, 5, 5, 5, 5, 5, 6, - 1, 1, 1, 1, 7, 7, 7, 8, 8, 9, - 9, 9, 10, 1, 7, 7, 7, 7, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 10, 9, 9, 1 + 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 4, 4, 4, 4, 4, 4, 5, + 1, 1, 1, 1, 6, 6, 6, 6, 5, 5, + 7, 7, 7, 8, 1, 7, 6, 6, 6, 6, + 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 1 } ; -static yyconst flex_int16_t yy_base[542] = +static yyconst flex_int16_t yy_base[678] = { 0, - 0, 58, 81, 0, 814, 815, 59, 815, 790, 789, - 54, 788, 55, 56, 54, 787, 129, 174, 53, 786, - 127, 0, 774, 101, 106, 126, 116, 128, 152, 759, - 161, 158, 128, 142, 131, 753, 166, 766, 175, 181, - 131, 187, 762, 149, 205, 222, 780, 815, 230, 815, - 789, 225, 815, 0, 244, 815, 815, 815, 815, 815, - 815, 815, 815, 815, 223, 815, 225, 200, 265, 218, - 815, 0, 0, 778, 815, 815, 815, 777, 0, 815, - 753, 746, 749, 757, 756, 743, 746, 757, 744, 750, - 738, 735, 748, 735, 732, 732, 738, 726, 132, 731, - - 741, 727, 733, 736, 737, 0, 221, 736, 717, 200, - 721, 734, 725, 225, 718, 732, 729, 731, 714, 719, - 716, 705, 714, 222, 718, 714, 716, 705, 708, 207, - 713, 705, 717, 243, 710, 815, 815, 285, 257, 295, - 815, 696, 708, 700, 710, 288, 0, 298, 0, 226, - 815, 280, 289, 815, 307, 318, 0, 815, 815, 0, - 698, 702, 711, 708, 692, 691, 691, 279, 706, 703, - 703, 701, 698, 690, 696, 683, 694, 680, 696, 0, - 693, 681, 688, 685, 689, 682, 671, 670, 683, 686, - 683, 671, 677, 668, 319, 673, 676, 667, 674, 663, - - 667, 673, 664, 655, 658, 656, 666, 656, 651, 649, - 649, 651, 648, 659, 658, 255, 653, 648, 637, 325, - 655, 657, 646, 638, 642, 653, 637, 0, 336, 328, - 322, 815, 345, 356, 815, 643, 0, 641, 353, 0, - 634, 632, 630, 638, 627, 644, 633, 356, 0, 0, - 627, 637, 637, 0, 622, 359, 0, 0, 624, 362, - 625, 619, 618, 619, 618, 365, 614, 0, 0, 610, - 609, 608, 610, 611, 616, 610, 606, 619, 614, 613, - 605, 609, 601, 604, 599, 607, 612, 611, 602, 0, - 0, 608, 597, 597, 602, 601, 598, 0, 0, 0, - - 0, 588, 600, 599, 598, 595, 584, 372, 383, 598, - 0, 0, 0, 0, 585, 0, 0, 585, 586, 580, - 590, 0, 0, 0, 581, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 588, 0, 0, 586, 582, - 0, 0, 0, 572, 381, 384, 387, 577, 573, 578, - 569, 567, 580, 566, 579, 568, 575, 0, 573, 570, - 574, 558, 567, 573, 568, 556, 0, 558, 0, 557, - 560, 0, 555, 599, 554, 556, 545, 554, 543, 543, - 556, 0, 558, 0, 557, 556, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 541, 554, 541, 538, - - 0, 0, 543, 0, 0, 535, 0, 0, 0, 0, - 0, 532, 543, 536, 542, 539, 534, 527, 411, 542, - 522, 514, 527, 525, 0, 0, 518, 524, 505, 0, - 510, 504, 503, 493, 391, 501, 0, 0, 500, 0, - 480, 465, 407, 343, 815, 457, 449, 0, 0, 0, - 448, 434, 446, 0, 447, 436, 455, 454, 453, 426, - 0, 0, 0, 430, 418, 815, 431, 0, 412, 815, - 0, 0, 0, 0, 425, 0, 444, 387, 444, 438, - 426, 433, 435, 439, 422, 422, 423, 419, 421, 420, - 815, 441, 815, 453, 0, 449, 404, 422, 402, 389, - - 385, 0, 451, 377, 373, 343, 346, 296, 0, 262, - 275, 253, 0, 223, 207, 144, 0, 148, 0, 104, - 32, 11, 0, 815, 485, 491, 497, 501, 506, 508, - 516, 523, 526, 529, 534, 543, 548, 550, 557, 566, - 568 + 0, 61, 84, 0, 1012, 1013, 62, 1013, 988, 987, + 57, 986, 58, 59, 57, 985, 135, 183, 56, 984, + 133, 0, 971, 119, 109, 130, 134, 111, 135, 954, + 151, 165, 32, 152, 131, 948, 153, 170, 182, 176, + 178, 193, 959, 125, 237, 243, 979, 1013, 214, 1013, + 988, 233, 1013, 0, 231, 1013, 1013, 1013, 1013, 1013, + 1013, 1013, 1013, 1013, 225, 1013, 227, 224, 289, 260, + 1013, 0, 0, 977, 1013, 1013, 1013, 976, 0, 1013, + 943, 948, 941, 944, 953, 952, 938, 941, 953, 155, + 947, 934, 931, 945, 931, 928, 928, 934, 213, 222, + + 928, 939, 924, 930, 934, 935, 0, 926, 937, 237, + 932, 912, 232, 916, 930, 920, 241, 913, 257, 926, + 928, 910, 906, 914, 911, 900, 909, 228, 907, 913, + 908, 911, 899, 902, 904, 257, 907, 898, 911, 215, + 904, 1013, 1013, 310, 295, 318, 1013, 889, 902, 893, + 904, 260, 0, 308, 0, 362, 1013, 303, 373, 1013, + 380, 387, 0, 1013, 1013, 899, 0, 890, 894, 904, + 901, 884, 883, 883, 887, 280, 898, 895, 895, 893, + 890, 881, 888, 874, 872, 885, 870, 887, 0, 884, + 871, 879, 876, 880, 881, 874, 871, 859, 858, 872, + + 875, 872, 859, 866, 856, 321, 862, 865, 855, 863, + 851, 855, 846, 861, 851, 842, 861, 844, 842, 853, + 842, 837, 835, 849, 834, 836, 833, 845, 844, 847, + 298, 838, 832, 821, 337, 840, 842, 830, 822, 826, + 838, 821, 0, 394, 404, 421, 1013, 433, 440, 1013, + 816, 827, 0, 824, 340, 0, 817, 815, 817, 812, + 821, 809, 827, 815, 344, 0, 0, 809, 820, 819, + 819, 0, 803, 347, 0, 0, 805, 351, 813, 814, + 804, 798, 797, 798, 797, 409, 793, 0, 0, 789, + 788, 787, 789, 790, 795, 789, 785, 799, 794, 793, + + 792, 783, 786, 786, 778, 781, 776, 785, 790, 775, + 788, 778, 0, 0, 785, 781, 772, 772, 778, 777, + 774, 0, 0, 0, 0, 763, 776, 775, 774, 771, + 759, 447, 457, 771, 773, 0, 0, 0, 0, 759, + 0, 759, 0, 758, 759, 753, 764, 0, 0, 0, + 754, 0, 750, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 761, 463, 760, 0, 0, 758, 754, 0, + 0, 0, 743, 426, 467, 475, 748, 744, 750, 740, + 738, 752, 736, 736, 750, 738, 750, 745, 0, 743, + 740, 744, 727, 729, 736, 742, 737, 736, 723, 0, + + 725, 0, 724, 728, 0, 722, 769, 721, 724, 0, + 712, 722, 0, 710, 710, 724, 0, 726, 0, 479, + 734, 733, 732, 703, 702, 0, 720, 719, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 703, 717, + 703, 700, 0, 0, 706, 705, 0, 0, 703, 695, + 0, 0, 0, 0, 0, 0, 692, 704, 485, 696, + 703, 700, 694, 687, 501, 703, 688, 683, 697, 695, + 0, 0, 687, 706, 705, 704, 675, 674, 317, 489, + 0, 687, 690, 688, 676, 0, 686, 683, 682, 671, + 670, 669, 508, 678, 0, 690, 689, 688, 659, 658, + + 0, 673, 0, 671, 666, 495, 524, 1013, 660, 668, + 0, 0, 0, 683, 682, 0, 664, 667, 651, 659, + 649, 657, 658, 658, 657, 642, 655, 0, 656, 644, + 643, 639, 663, 662, 661, 632, 631, 0, 661, 660, + 0, 642, 645, 0, 0, 631, 543, 1013, 534, 0, + 553, 1013, 0, 628, 627, 637, 637, 624, 639, 622, + 637, 632, 0, 0, 0, 0, 617, 0, 0, 0, + 638, 353, 638, 627, 630, 614, 613, 623, 623, 613, + 530, 563, 413, 609, 608, 619, 0, 622, 618, 620, + 616, 602, 609, 605, 607, 603, 598, 596, 596, 575, + + 542, 553, 0, 1013, 466, 1013, 582, 0, 588, 556, + 555, 535, 527, 535, 516, 524, 0, 517, 510, 492, + 493, 489, 472, 0, 473, 472, 451, 505, 428, 426, + 0, 0, 423, 0, 387, 392, 390, 373, 334, 316, + 298, 288, 286, 0, 0, 0, 0, 0, 0, 290, + 296, 266, 0, 0, 0, 0, 257, 269, 241, 0, + 250, 0, 202, 133, 105, 0, 1013, 605, 610, 615, + 617, 619, 625, 632, 637, 642, 647 } ; -static yyconst flex_int16_t yy_def[542] = +static yyconst flex_int16_t yy_def[678] = { 0, - 524, 1, 524, 3, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 525, 524, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 526, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 527, 524, 528, 17, 524, 529, - 524, 530, 18, 524, 524, 524, 524, 524, 525, 524, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 531, 524, 526, 532, - 524, 528, 533, 524, 524, 529, 530, 524, 524, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 524, 524, 524, 524, 531, 524, 532, - 534, 524, 524, 533, 524, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - - 525, 525, 525, 524, 524, 524, 524, 524, 534, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 524, 524, 524, 524, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 524, 524, 524, - 524, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 524, 535, 536, 524, 524, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 524, 537, 524, 524, 538, 536, 524, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 524, 539, 540, 538, 525, 525, 525, 525, 525, 525, - 524, 524, 524, 524, 541, 540, 525, 525, 525, 525, - - 525, 525, 541, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, - 525, 525, 525, 0, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524 + 667, 1, 667, 3, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 668, 667, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 669, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 670, 667, 671, 17, 667, 667, + 667, 672, 18, 667, 667, 667, 667, 667, 668, 667, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 673, 667, 669, 667, 667, 671, 667, 667, + 667, 667, 672, 667, 667, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 667, 667, + 667, 667, 673, 667, 667, 667, 667, 667, 667, 667, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 667, 667, 667, + 667, 667, 667, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + + 668, 668, 668, 668, 668, 667, 667, 667, 667, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 667, 667, 667, 667, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + + 668, 668, 668, 668, 667, 674, 667, 667, 667, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 667, 667, 667, 667, 675, + 667, 667, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 667, + 676, 667, 675, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + + 668, 668, 668, 667, 667, 667, 667, 677, 667, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 677, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, + 668, 668, 668, 668, 668, 668, 0, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667 } ; -static yyconst flex_int16_t yy_nxt[875] = +static yyconst flex_int16_t yy_nxt[1076] = { 0, 6, 7, 8, 7, 9, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 18, 18, 18, 18, 6, 19, 20, 21, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 22, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 22, 22, 22, 44, 45, - 55, 58, 55, 46, 61, 523, 63, 65, 65, 65, - 65, 65, 65, 65, 74, 75, 59, 62, 64, 522, - 47, 48, 49, 50, 49, 48, 48, 48, 48, 48, - 48, 48, 48, 51, 48, 52, 52, 52, 52, 52, - - 52, 53, 48, 48, 48, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 48, 54, 54, 54, 54, 54, + 22, 22, 22, 22, 23, 22, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 22, 22, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 22, 22, + 22, 44, 45, 55, 58, 55, 46, 61, 112, 63, + 65, 65, 65, 65, 65, 65, 65, 74, 75, 59, + 62, 64, 113, 47, 48, 49, 50, 49, 48, 48, + 48, 48, 48, 48, 48, 48, 51, 48, 52, 52, + + 52, 52, 52, 52, 53, 48, 48, 48, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 48, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 48, - 67, 521, 68, 68, 68, 68, 68, 68, 69, 77, - 78, 81, 82, 83, 90, 84, 70, 71, 91, 85, - 86, 72, 109, 92, 87, 113, 178, 70, 71, 93, - 88, 136, 94, 89, 95, 110, 111, 130, 114, 179, - 112, 131, 520, 96, 72, 67, 97, 73, 73, 73, - 73, 73, 73, 73, 98, 103, 99, 106, 519, 100, - - 116, 70, 71, 104, 107, 101, 138, 137, 55, 120, - 139, 108, 70, 71, 105, 117, 121, 122, 118, 126, - 123, 132, 127, 140, 141, 133, 124, 155, 155, 125, - 128, 146, 524, 146, 134, 229, 229, 129, 148, 148, - 148, 148, 148, 148, 148, 55, 193, 55, 518, 216, - 150, 151, 153, 154, 194, 524, 209, 217, 140, 141, - 142, 150, 151, 153, 154, 186, 143, 198, 187, 188, - 144, 210, 189, 199, 190, 145, 67, 517, 69, 69, - 69, 69, 69, 69, 69, 221, 138, 222, 55, 146, - 139, 146, 70, 71, 293, 142, 140, 141, 233, 233, - - 516, 143, 294, 70, 71, 144, 515, 231, 232, 514, - 145, 148, 148, 148, 148, 148, 148, 148, 231, 232, - 156, 156, 156, 156, 156, 156, 156, 524, 524, 243, - 244, 308, 308, 142, 270, 271, 272, 524, 524, 143, - 298, 299, 300, 144, 465, 466, 235, 513, 145, 230, - 230, 230, 230, 230, 230, 230, 151, 235, 234, 234, - 234, 234, 234, 234, 234, 524, 524, 151, 312, 313, - 314, 322, 323, 324, 329, 330, 331, 333, 334, 335, - 341, 342, 343, 512, 154, 309, 309, 309, 309, 309, - 309, 309, 524, 524, 511, 154, 388, 389, 390, 391, - - 392, 393, 394, 395, 396, 457, 458, 459, 465, 466, - 510, 232, 419, 465, 466, 509, 460, 487, 488, 465, - 466, 508, 232, 507, 443, 444, 444, 444, 444, 444, - 444, 482, 465, 466, 492, 493, 492, 493, 506, 468, - 465, 466, 492, 493, 467, 467, 467, 467, 467, 467, - 492, 493, 492, 493, 492, 493, 505, 504, 502, 501, - 500, 499, 468, 498, 497, 495, 494, 494, 494, 494, - 494, 494, 491, 490, 489, 486, 485, 481, 480, 479, - 478, 477, 476, 475, 474, 473, 472, 471, 495, 79, - 79, 79, 79, 79, 79, 149, 149, 149, 149, 149, - - 149, 65, 65, 470, 65, 152, 152, 464, 152, 156, - 156, 156, 157, 157, 157, 157, 228, 228, 463, 228, - 228, 228, 228, 228, 228, 228, 230, 230, 230, 234, - 234, 234, 309, 309, 309, 467, 467, 462, 467, 461, - 456, 455, 454, 467, 469, 469, 453, 469, 469, 483, - 483, 452, 483, 483, 484, 484, 484, 484, 494, 494, - 451, 494, 450, 449, 448, 447, 494, 496, 496, 446, - 496, 496, 503, 503, 503, 503, 445, 442, 441, 440, - 439, 438, 437, 436, 435, 434, 433, 432, 431, 430, - 429, 428, 427, 426, 425, 424, 423, 422, 421, 420, - - 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, - 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, - 399, 398, 397, 387, 386, 385, 384, 383, 382, 381, - 380, 379, 378, 377, 376, 375, 374, 373, 372, 371, - 370, 369, 368, 367, 366, 365, 364, 363, 362, 361, - 360, 359, 358, 357, 356, 355, 354, 353, 352, 351, - 350, 349, 348, 347, 346, 345, 344, 340, 339, 338, - 337, 336, 332, 328, 327, 326, 325, 321, 320, 319, - 318, 317, 316, 315, 311, 310, 307, 306, 305, 304, - 303, 302, 301, 297, 296, 295, 292, 291, 290, 289, - - 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, - 278, 277, 276, 275, 274, 273, 269, 268, 267, 266, - 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, - 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, - 245, 242, 241, 240, 239, 238, 237, 236, 227, 226, - 225, 224, 223, 220, 219, 218, 215, 214, 213, 212, - 211, 208, 207, 206, 205, 204, 203, 202, 201, 200, - 197, 196, 195, 192, 191, 185, 184, 183, 182, 181, - 180, 177, 176, 175, 174, 173, 172, 171, 170, 169, - 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, - - 158, 147, 76, 135, 119, 115, 102, 80, 76, 66, - 60, 57, 56, 524, 5, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524 + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 48, 67, 142, 68, 68, + 68, 68, 68, 68, 69, 77, 78, 81, 95, 84, + 96, 85, 666, 70, 71, 86, 87, 116, 72, 97, + 88, 98, 82, 83, 91, 70, 71, 89, 92, 99, + 90, 117, 100, 665, 93, 101, 143, 104, 114, 119, + 94, 102, 115, 72, 67, 105, 73, 73, 73, 73, + + 73, 73, 73, 175, 176, 120, 107, 106, 121, 108, + 122, 70, 71, 109, 110, 152, 131, 152, 124, 132, + 123, 111, 135, 70, 71, 125, 126, 136, 133, 138, + 127, 137, 55, 139, 55, 134, 128, 129, 144, 130, + 55, 664, 145, 140, 146, 147, 154, 154, 154, 154, + 154, 154, 154, 156, 157, 159, 160, 667, 187, 236, + 185, 152, 237, 152, 222, 156, 157, 159, 160, 161, + 161, 186, 188, 162, 162, 162, 162, 162, 162, 162, + 223, 204, 667, 148, 197, 209, 663, 198, 199, 205, + 149, 200, 210, 201, 150, 212, 146, 147, 662, 151, + + 67, 231, 69, 69, 69, 69, 69, 69, 69, 213, + 232, 144, 661, 55, 660, 145, 659, 70, 71, 146, + 147, 154, 154, 154, 154, 154, 154, 154, 658, 70, + 71, 246, 247, 260, 261, 148, 290, 291, 292, 317, + 657, 519, 149, 246, 247, 656, 150, 655, 318, 520, + 654, 151, 322, 323, 324, 337, 338, 339, 148, 348, + 349, 350, 356, 357, 358, 149, 360, 361, 362, 150, + 653, 244, 244, 652, 151, 245, 245, 245, 245, 245, + 245, 245, 248, 248, 595, 596, 249, 249, 249, 249, + 249, 249, 249, 162, 162, 162, 162, 162, 162, 162, + + 162, 162, 162, 162, 162, 162, 162, 245, 245, 245, + 245, 245, 245, 245, 547, 548, 250, 245, 245, 245, + 245, 245, 245, 245, 370, 371, 372, 651, 250, 650, + 332, 332, 649, 157, 333, 333, 333, 333, 333, 333, + 333, 430, 431, 432, 648, 157, 249, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + 333, 333, 333, 333, 333, 333, 333, 605, 606, 160, + 333, 333, 333, 333, 333, 333, 333, 421, 422, 423, + 647, 160, 433, 434, 435, 646, 247, 645, 424, 425, + 436, 437, 438, 474, 475, 476, 547, 548, 247, 496, + + 497, 498, 465, 644, 477, 478, 605, 606, 643, 642, + 499, 500, 641, 521, 506, 507, 507, 507, 507, 507, + 507, 522, 533, 534, 535, 547, 548, 640, 550, 639, + 638, 605, 606, 536, 537, 547, 548, 551, 551, 551, + 551, 551, 551, 551, 547, 548, 637, 549, 549, 549, + 549, 549, 549, 550, 547, 548, 581, 582, 582, 582, + 582, 582, 582, 608, 605, 606, 551, 551, 551, 551, + 551, 551, 551, 636, 635, 634, 609, 609, 609, 609, + 609, 609, 609, 605, 606, 633, 632, 631, 608, 605, + 606, 630, 629, 627, 626, 607, 607, 607, 607, 607, + + 607, 609, 609, 609, 609, 609, 609, 609, 79, 79, + 79, 79, 79, 155, 155, 155, 155, 155, 65, 65, + 158, 158, 163, 163, 163, 243, 243, 625, 243, 243, + 243, 243, 243, 549, 549, 549, 624, 623, 622, 549, + 583, 583, 583, 607, 607, 607, 621, 620, 619, 607, + 628, 628, 628, 618, 617, 616, 615, 614, 613, 612, + 611, 610, 604, 603, 602, 601, 600, 599, 598, 597, + 594, 593, 592, 591, 590, 589, 588, 587, 586, 585, + 584, 580, 579, 578, 577, 576, 575, 574, 573, 572, + 571, 570, 569, 568, 567, 566, 565, 564, 563, 562, + + 561, 560, 559, 558, 557, 556, 555, 554, 553, 552, + 546, 545, 544, 543, 542, 541, 540, 539, 538, 532, + 531, 530, 529, 528, 527, 526, 525, 524, 523, 518, + 517, 516, 515, 514, 513, 512, 511, 510, 509, 508, + 505, 504, 503, 502, 501, 495, 494, 493, 492, 491, + 490, 489, 488, 487, 486, 485, 484, 483, 482, 481, + 480, 479, 473, 472, 471, 470, 469, 468, 467, 466, + 465, 464, 463, 462, 461, 460, 459, 458, 457, 456, + 455, 454, 453, 452, 451, 450, 449, 448, 447, 446, + 445, 444, 443, 442, 441, 440, 439, 429, 428, 427, + + 426, 420, 419, 418, 417, 416, 415, 414, 413, 412, + 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, + 401, 400, 399, 398, 397, 396, 395, 394, 393, 392, + 391, 390, 389, 388, 387, 386, 385, 384, 383, 382, + 381, 380, 379, 378, 377, 376, 375, 374, 373, 369, + 368, 367, 366, 365, 364, 363, 359, 355, 354, 353, + 352, 351, 347, 346, 345, 344, 343, 342, 341, 340, + 336, 335, 334, 331, 330, 329, 328, 327, 326, 325, + 321, 320, 319, 316, 315, 314, 313, 312, 311, 310, + 309, 308, 307, 306, 305, 304, 303, 302, 301, 300, + + 299, 298, 297, 296, 295, 294, 293, 289, 288, 287, + 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, + 276, 275, 274, 273, 272, 271, 270, 269, 268, 267, + 266, 265, 264, 263, 262, 259, 258, 257, 256, 255, + 254, 253, 252, 251, 242, 241, 240, 239, 238, 235, + 234, 233, 230, 229, 228, 227, 226, 225, 224, 221, + 220, 219, 218, 217, 216, 215, 214, 211, 208, 207, + 206, 203, 202, 196, 195, 194, 193, 192, 191, 190, + 189, 184, 183, 182, 181, 180, 179, 178, 177, 174, + 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, + + 153, 76, 141, 118, 103, 80, 76, 66, 60, 57, + 56, 667, 5, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667 } ; -static yyconst flex_int16_t yy_chk[875] = +static yyconst flex_int16_t yy_chk[1076] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 7, 11, 7, 2, 13, 522, 14, 15, 15, 15, - 15, 15, 15, 15, 19, 19, 11, 13, 14, 521, - 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 7, 11, 7, 2, 13, 33, 14, + 15, 15, 15, 15, 15, 15, 15, 19, 19, 11, + 13, 14, 33, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 17, 520, 17, 17, 17, 17, 17, 17, 17, 21, - 21, 24, 24, 25, 27, 25, 17, 17, 27, 25, - 26, 17, 33, 27, 26, 35, 99, 17, 17, 27, - 26, 44, 28, 26, 28, 33, 34, 41, 35, 99, - 34, 41, 518, 28, 17, 18, 29, 18, 18, 18, - 18, 18, 18, 18, 29, 31, 29, 32, 516, 29, - - 37, 18, 18, 31, 32, 29, 45, 44, 45, 39, - 45, 32, 18, 18, 31, 37, 39, 39, 37, 40, - 39, 42, 40, 46, 46, 42, 39, 70, 70, 39, - 40, 49, 68, 49, 42, 150, 150, 40, 52, 52, - 52, 52, 52, 52, 52, 55, 110, 55, 515, 130, - 65, 65, 67, 67, 110, 68, 124, 130, 139, 139, - 46, 65, 65, 67, 67, 107, 46, 114, 107, 107, - 46, 124, 107, 114, 107, 46, 69, 514, 69, 69, - 69, 69, 69, 69, 69, 134, 138, 134, 138, 146, - 138, 146, 69, 69, 216, 139, 140, 140, 153, 153, - - 512, 139, 216, 69, 69, 139, 511, 152, 152, 510, - 139, 148, 148, 148, 148, 148, 148, 148, 152, 152, - 155, 155, 155, 155, 155, 155, 155, 156, 156, 168, - 168, 231, 231, 140, 195, 195, 195, 230, 230, 140, - 220, 220, 220, 140, 444, 444, 156, 508, 140, 229, - 229, 229, 229, 229, 229, 229, 230, 156, 233, 233, - 233, 233, 233, 233, 233, 234, 234, 230, 239, 239, - 239, 248, 248, 248, 256, 256, 256, 260, 260, 260, - 266, 266, 266, 507, 234, 308, 308, 308, 308, 308, - 308, 308, 309, 309, 506, 234, 345, 345, 345, 346, - - 346, 346, 347, 347, 347, 435, 435, 435, 443, 443, - 505, 309, 419, 469, 469, 504, 435, 478, 478, 465, - 465, 501, 309, 500, 419, 419, 419, 419, 419, 419, - 419, 465, 467, 467, 482, 482, 483, 483, 499, 443, - 484, 484, 492, 492, 467, 467, 467, 467, 467, 467, - 496, 496, 503, 503, 494, 494, 498, 497, 490, 489, - 488, 487, 443, 486, 485, 482, 494, 494, 494, 494, - 494, 494, 481, 480, 479, 477, 475, 464, 460, 459, - 458, 457, 456, 455, 453, 452, 451, 447, 482, 525, - 525, 525, 525, 525, 525, 526, 526, 526, 526, 526, - - 526, 527, 527, 446, 527, 528, 528, 442, 528, 529, - 529, 529, 530, 530, 530, 530, 531, 531, 441, 531, - 531, 531, 531, 531, 531, 531, 532, 532, 532, 533, - 533, 533, 534, 534, 534, 535, 535, 439, 535, 436, - 434, 433, 432, 535, 536, 536, 431, 536, 536, 537, - 537, 429, 537, 537, 538, 538, 538, 538, 539, 539, - 428, 539, 427, 424, 423, 422, 539, 540, 540, 421, - 540, 540, 541, 541, 541, 541, 420, 418, 417, 416, - 415, 414, 413, 412, 406, 403, 400, 399, 398, 397, - 386, 385, 383, 381, 380, 379, 378, 377, 376, 375, - - 374, 373, 371, 370, 368, 366, 365, 364, 363, 362, - 361, 360, 359, 357, 356, 355, 354, 353, 352, 351, - 350, 349, 348, 344, 340, 339, 336, 325, 321, 320, - 319, 318, 315, 310, 307, 306, 305, 304, 303, 302, - 297, 296, 295, 294, 293, 292, 289, 288, 287, 286, - 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, - 275, 274, 273, 272, 271, 270, 267, 265, 264, 263, - 262, 261, 259, 255, 253, 252, 251, 247, 246, 245, - 244, 243, 242, 241, 238, 236, 227, 226, 225, 224, - 223, 222, 221, 219, 218, 217, 215, 214, 213, 212, - - 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, - 201, 200, 199, 198, 197, 196, 194, 193, 192, 191, - 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, - 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, - 169, 167, 166, 165, 164, 163, 162, 161, 145, 144, - 143, 142, 135, 133, 132, 131, 129, 128, 127, 126, - 125, 123, 122, 121, 120, 119, 118, 117, 116, 115, - 113, 112, 111, 109, 108, 105, 104, 103, 102, 101, - 100, 98, 97, 96, 95, 94, 93, 92, 91, 90, - 89, 88, 87, 86, 85, 84, 83, 82, 81, 78, - - 74, 51, 47, 43, 38, 36, 30, 23, 20, 16, - 12, 10, 9, 5, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - 524, 524, 524, 524 + 3, 3, 3, 3, 3, 3, 17, 44, 17, 17, + 17, 17, 17, 17, 17, 21, 21, 24, 28, 25, + 28, 25, 665, 17, 17, 25, 26, 35, 17, 28, + 26, 29, 24, 24, 27, 17, 17, 26, 27, 29, + 26, 35, 29, 664, 27, 29, 44, 31, 34, 37, + 27, 29, 34, 17, 18, 31, 18, 18, 18, 18, + + 18, 18, 18, 90, 90, 37, 32, 31, 37, 32, + 38, 18, 18, 32, 32, 49, 40, 49, 39, 40, + 38, 32, 41, 18, 18, 39, 39, 41, 40, 42, + 39, 41, 55, 42, 55, 40, 39, 39, 45, 39, + 45, 663, 45, 42, 46, 46, 52, 52, 52, 52, + 52, 52, 52, 65, 65, 67, 67, 68, 100, 140, + 99, 152, 140, 152, 128, 65, 65, 67, 67, 70, + 70, 99, 100, 70, 70, 70, 70, 70, 70, 70, + 128, 113, 68, 46, 110, 117, 661, 110, 110, 113, + 46, 110, 117, 110, 46, 119, 145, 145, 659, 46, + + 69, 136, 69, 69, 69, 69, 69, 69, 69, 119, + 136, 144, 658, 144, 657, 144, 652, 69, 69, 146, + 146, 154, 154, 154, 154, 154, 154, 154, 651, 69, + 69, 158, 158, 176, 176, 145, 206, 206, 206, 231, + 650, 479, 145, 158, 158, 643, 145, 642, 231, 479, + 641, 145, 235, 235, 235, 255, 255, 255, 146, 265, + 265, 265, 274, 274, 274, 146, 278, 278, 278, 146, + 640, 156, 156, 639, 146, 156, 156, 156, 156, 156, + 156, 156, 159, 159, 572, 572, 159, 159, 159, 159, + 159, 159, 159, 161, 161, 161, 161, 161, 161, 161, + + 162, 162, 162, 162, 162, 162, 162, 244, 244, 244, + 244, 244, 244, 244, 583, 583, 162, 245, 245, 245, + 245, 245, 245, 245, 286, 286, 286, 638, 162, 637, + 246, 246, 636, 245, 246, 246, 246, 246, 246, 246, + 246, 374, 374, 374, 635, 245, 248, 248, 248, 248, + 248, 248, 248, 249, 249, 249, 249, 249, 249, 249, + 332, 332, 332, 332, 332, 332, 332, 605, 605, 249, + 333, 333, 333, 333, 333, 333, 333, 364, 364, 364, + 633, 249, 375, 375, 375, 630, 333, 629, 364, 364, + 376, 376, 376, 420, 420, 420, 506, 506, 333, 459, + + 459, 459, 465, 627, 420, 420, 628, 628, 626, 625, + 459, 459, 623, 480, 465, 465, 465, 465, 465, 465, + 465, 480, 493, 493, 493, 507, 507, 622, 506, 621, + 620, 581, 581, 493, 493, 549, 549, 507, 507, 507, + 507, 507, 507, 507, 547, 547, 619, 549, 549, 549, + 549, 549, 549, 506, 551, 551, 547, 547, 547, 547, + 547, 547, 547, 581, 582, 582, 551, 551, 551, 551, + 551, 551, 551, 618, 616, 615, 582, 582, 582, 582, + 582, 582, 582, 607, 607, 614, 613, 612, 581, 609, + 609, 611, 610, 602, 601, 607, 607, 607, 607, 607, + + 607, 609, 609, 609, 609, 609, 609, 609, 668, 668, + 668, 668, 668, 669, 669, 669, 669, 669, 670, 670, + 671, 671, 672, 672, 672, 673, 673, 600, 673, 673, + 673, 673, 673, 674, 674, 674, 599, 598, 597, 674, + 675, 675, 675, 676, 676, 676, 596, 595, 594, 676, + 677, 677, 677, 593, 592, 591, 590, 589, 588, 586, + 585, 584, 580, 579, 578, 577, 576, 575, 574, 573, + 571, 567, 562, 561, 560, 559, 558, 557, 556, 555, + 554, 546, 543, 542, 540, 539, 537, 536, 535, 534, + 533, 532, 531, 530, 529, 527, 526, 525, 524, 523, + + 522, 521, 520, 519, 518, 517, 515, 514, 510, 509, + 505, 504, 502, 500, 499, 498, 497, 496, 494, 492, + 491, 490, 489, 488, 487, 485, 484, 483, 482, 478, + 477, 476, 475, 474, 473, 470, 469, 468, 467, 466, + 464, 463, 462, 461, 460, 458, 457, 450, 449, 446, + 445, 442, 441, 440, 439, 428, 427, 425, 424, 423, + 422, 421, 418, 416, 415, 414, 412, 411, 409, 408, + 407, 406, 404, 403, 401, 399, 398, 397, 396, 395, + 394, 393, 392, 391, 390, 388, 387, 386, 385, 384, + 383, 382, 381, 380, 379, 378, 377, 373, 369, 368, + + 365, 363, 353, 351, 347, 346, 345, 344, 342, 340, + 335, 334, 331, 330, 329, 328, 327, 326, 321, 320, + 319, 318, 317, 316, 315, 312, 311, 310, 309, 308, + 307, 306, 305, 304, 303, 302, 301, 300, 299, 298, + 297, 296, 295, 294, 293, 292, 291, 290, 287, 285, + 284, 283, 282, 281, 280, 279, 277, 273, 271, 270, + 269, 268, 264, 263, 262, 261, 260, 259, 258, 257, + 254, 252, 251, 242, 241, 240, 239, 238, 237, 236, + 234, 233, 232, 230, 229, 228, 227, 226, 225, 224, + 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, + + 213, 212, 211, 210, 209, 208, 207, 205, 204, 203, + 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, + 192, 191, 190, 188, 187, 186, 185, 184, 183, 182, + 181, 180, 179, 178, 177, 175, 174, 173, 172, 171, + 170, 169, 168, 166, 151, 150, 149, 148, 141, 139, + 138, 137, 135, 134, 133, 132, 131, 130, 129, 127, + 126, 125, 124, 123, 122, 121, 120, 118, 116, 115, + 114, 112, 111, 109, 108, 106, 105, 104, 103, 102, + 101, 98, 97, 96, 95, 94, 93, 92, 91, 89, + 88, 87, 86, 85, 84, 83, 82, 81, 78, 74, + + 51, 47, 43, 36, 30, 23, 20, 16, 12, 10, + 9, 5, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667, 667, 667, 667, 667, 667, + 667, 667, 667, 667, 667 } ; /* The intent behind this definition is that it'll catch @@ -856,7 +935,7 @@ static yyconst flex_int16_t yy_chk[875] = } while (0) -#line 860 "glsl_lexer.cpp" +#line 939 "glsl_lexer.cpp" #define INITIAL 0 #define PP 1 @@ -990,12 +1069,7 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1003,7 +1077,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1014,7 +1088,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1105,7 +1179,7 @@ YY_DECL #line 66 "glsl_lexer.lpp" -#line 1109 "glsl_lexer.cpp" +#line 1183 "glsl_lexer.cpp" yylval = yylval_param; @@ -1163,13 +1237,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 525 ) + if ( yy_current_state >= 668 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 524 ); + while ( yy_current_state != 667 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1994,9 +2068,160 @@ YY_RULE_SETUP #line 303 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, PRECISION); YY_BREAK +/* Additional reserved words in GLSL 1.30. */ case 145: YY_RULE_SETUP -#line 305 "glsl_lexer.lpp" +#line 306 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, COMMON); + YY_BREAK +case 146: +YY_RULE_SETUP +#line 307 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, PARTITION); + YY_BREAK +case 147: +YY_RULE_SETUP +#line 308 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, ACTIVE); + YY_BREAK +case 148: +YY_RULE_SETUP +#line 309 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, SUPERP); + YY_BREAK +case 149: +YY_RULE_SETUP +#line 310 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, SAMPLERBUFFER); + YY_BREAK +case 150: +YY_RULE_SETUP +#line 311 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, FILTER); + YY_BREAK +case 151: +YY_RULE_SETUP +#line 312 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IMAGE1D); + YY_BREAK +case 152: +YY_RULE_SETUP +#line 313 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IMAGE2D); + YY_BREAK +case 153: +YY_RULE_SETUP +#line 314 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IMAGE3D); + YY_BREAK +case 154: +YY_RULE_SETUP +#line 315 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IMAGECUBE); + YY_BREAK +case 155: +YY_RULE_SETUP +#line 316 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IIMAGE1D); + YY_BREAK +case 156: +YY_RULE_SETUP +#line 317 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IIMAGE2D); + YY_BREAK +case 157: +YY_RULE_SETUP +#line 318 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IIMAGE3D); + YY_BREAK +case 158: +YY_RULE_SETUP +#line 319 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IIMAGECUBE); + YY_BREAK +case 159: +YY_RULE_SETUP +#line 320 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, UIMAGE1D); + YY_BREAK +case 160: +YY_RULE_SETUP +#line 321 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, UIMAGE2D); + YY_BREAK +case 161: +YY_RULE_SETUP +#line 322 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, UIMAGE3D); + YY_BREAK +case 162: +YY_RULE_SETUP +#line 323 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, UIMAGECUBE); + YY_BREAK +case 163: +YY_RULE_SETUP +#line 324 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IMAGE1DARRAY); + YY_BREAK +case 164: +YY_RULE_SETUP +#line 325 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IMAGE2DARRAY); + YY_BREAK +case 165: +YY_RULE_SETUP +#line 326 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IIMAGE1DARRAY); + YY_BREAK +case 166: +YY_RULE_SETUP +#line 327 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IIMAGE2DARRAY); + YY_BREAK +case 167: +YY_RULE_SETUP +#line 328 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, UIMAGE1DARRAY); + YY_BREAK +case 168: +YY_RULE_SETUP +#line 329 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, UIMAGE2DARRAY); + YY_BREAK +case 169: +YY_RULE_SETUP +#line 330 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IMAGE1DSHADOW); + YY_BREAK +case 170: +YY_RULE_SETUP +#line 331 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IMAGE2DSHADOW); + YY_BREAK +case 171: +YY_RULE_SETUP +#line 332 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IMAGEBUFFER); + YY_BREAK +case 172: +YY_RULE_SETUP +#line 333 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, IIMAGEBUFFER); + YY_BREAK +case 173: +YY_RULE_SETUP +#line 334 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, UIMAGEBUFFER); + YY_BREAK +case 174: +YY_RULE_SETUP +#line 335 "glsl_lexer.lpp" +TOKEN_OR_IDENTIFIER(130, ROW_MAJOR); + YY_BREAK +case 175: +YY_RULE_SETUP +#line 337 "glsl_lexer.lpp" { struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; @@ -2004,17 +2229,17 @@ YY_RULE_SETUP return IDENTIFIER; } YY_BREAK -case 146: +case 176: YY_RULE_SETUP -#line 312 "glsl_lexer.lpp" +#line 344 "glsl_lexer.lpp" { return yytext[0]; } YY_BREAK -case 147: +case 177: YY_RULE_SETUP -#line 314 "glsl_lexer.lpp" +#line 346 "glsl_lexer.lpp" ECHO; YY_BREAK -#line 2018 "glsl_lexer.cpp" +#line 2243 "glsl_lexer.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(PP): yyterminate(); @@ -2311,7 +2536,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 525 ) + if ( yy_current_state >= 668 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -2340,11 +2565,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 525 ) + if ( yy_current_state >= 668 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 524); + yy_is_jam = (yy_current_state == 667); return yy_is_jam ? 0 : yy_current_state; } @@ -2749,8 +2974,8 @@ YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char * yystr , yyscan_t yyscann /** Setup the input buffer state to scan the given bytes. The next call to _mesa_glsl_lex() will * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -3156,7 +3381,7 @@ void _mesa_glsl_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 314 "glsl_lexer.lpp" +#line 346 "glsl_lexer.lpp" diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index 9fd9b53c5c6..b78df5d84ff 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -302,6 +302,38 @@ mediump TOKEN_OR_IDENTIFIER(120, MEDIUMP); highp TOKEN_OR_IDENTIFIER(120, HIGHP); precision TOKEN_OR_IDENTIFIER(120, PRECISION); + /* Additional reserved words in GLSL 1.30. */ +common TOKEN_OR_IDENTIFIER(130, COMMON); +partition TOKEN_OR_IDENTIFIER(130, PARTITION); +active TOKEN_OR_IDENTIFIER(130, ACTIVE); +superp TOKEN_OR_IDENTIFIER(130, SUPERP); +samplerBuffer TOKEN_OR_IDENTIFIER(130, SAMPLERBUFFER); +filter TOKEN_OR_IDENTIFIER(130, FILTER); +image1D TOKEN_OR_IDENTIFIER(130, IMAGE1D); +image2D TOKEN_OR_IDENTIFIER(130, IMAGE2D); +image3D TOKEN_OR_IDENTIFIER(130, IMAGE3D); +imageCube TOKEN_OR_IDENTIFIER(130, IMAGECUBE); +iimage1D TOKEN_OR_IDENTIFIER(130, IIMAGE1D); +iimage2D TOKEN_OR_IDENTIFIER(130, IIMAGE2D); +iimage3D TOKEN_OR_IDENTIFIER(130, IIMAGE3D); +iimageCube TOKEN_OR_IDENTIFIER(130, IIMAGECUBE); +uimage1D TOKEN_OR_IDENTIFIER(130, UIMAGE1D); +uimage2D TOKEN_OR_IDENTIFIER(130, UIMAGE2D); +uimage3D TOKEN_OR_IDENTIFIER(130, UIMAGE3D); +uimageCube TOKEN_OR_IDENTIFIER(130, UIMAGECUBE); +image1DArray TOKEN_OR_IDENTIFIER(130, IMAGE1DARRAY); +image2DArray TOKEN_OR_IDENTIFIER(130, IMAGE2DARRAY); +iimage1DArray TOKEN_OR_IDENTIFIER(130, IIMAGE1DARRAY); +iimage2DArray TOKEN_OR_IDENTIFIER(130, IIMAGE2DARRAY); +uimage1DArray TOKEN_OR_IDENTIFIER(130, UIMAGE1DARRAY); +uimage2DArray TOKEN_OR_IDENTIFIER(130, UIMAGE2DARRAY); +image1DShadow TOKEN_OR_IDENTIFIER(130, IMAGE1DSHADOW); +image2DShadow TOKEN_OR_IDENTIFIER(130, IMAGE2DSHADOW); +imageBuffer TOKEN_OR_IDENTIFIER(130, IMAGEBUFFER); +iimageBuffer TOKEN_OR_IDENTIFIER(130, IIMAGEBUFFER); +uimageBuffer TOKEN_OR_IDENTIFIER(130, UIMAGEBUFFER); +row_major TOKEN_OR_IDENTIFIER(130, ROW_MAJOR); + [_a-zA-Z][_a-zA-Z0-9]* { struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp index bf83b81603f..4b5e3614df6 100644 --- a/src/glsl/glsl_parser.cpp +++ b/src/glsl/glsl_parser.cpp @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1" +#define YYBISON_VERSION "2.4.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -114,7 +113,7 @@ /* Line 189 of yacc.c */ -#line 118 "glsl_parser.cpp" +#line 117 "glsl_parser.cpp" /* Enabling traces. */ #ifndef YYDEBUG @@ -248,56 +247,86 @@ LOWP = 362, MEDIUMP = 363, HIGHP = 364, - PRECISION = 365, - VERSION = 366, - EXTENSION = 367, - LINE = 368, - PRAGMA = 369, - COLON = 370, - EOL = 371, - INTERFACE = 372, - OUTPUT = 373, - LAYOUT_TOK = 374, - ASM = 375, - CLASS = 376, - UNION = 377, - ENUM = 378, - TYPEDEF = 379, - TEMPLATE = 380, - THIS = 381, - PACKED = 382, - GOTO = 383, - INLINE_TOK = 384, - NOINLINE = 385, - VOLATILE = 386, - PUBLIC_TOK = 387, - STATIC = 388, - EXTERN = 389, - EXTERNAL = 390, - LONG = 391, - SHORT = 392, - DOUBLE = 393, - HALF = 394, - FIXED = 395, - UNSIGNED = 396, - INPUT = 397, - OUPTUT = 398, - HVEC2 = 399, - HVEC3 = 400, - HVEC4 = 401, - DVEC2 = 402, - DVEC3 = 403, - DVEC4 = 404, - FVEC2 = 405, - FVEC3 = 406, - FVEC4 = 407, - SAMPLER2DRECT = 408, - SAMPLER3DRECT = 409, - SAMPLER2DRECTSHADOW = 410, - SIZEOF = 411, - CAST = 412, - NAMESPACE = 413, - USING = 414 + SUPERP = 365, + PRECISION = 366, + VERSION = 367, + EXTENSION = 368, + LINE = 369, + PRAGMA = 370, + COLON = 371, + EOL = 372, + INTERFACE = 373, + OUTPUT = 374, + LAYOUT_TOK = 375, + ASM = 376, + CLASS = 377, + UNION = 378, + ENUM = 379, + TYPEDEF = 380, + TEMPLATE = 381, + THIS = 382, + PACKED = 383, + GOTO = 384, + INLINE_TOK = 385, + NOINLINE = 386, + VOLATILE = 387, + PUBLIC_TOK = 388, + STATIC = 389, + EXTERN = 390, + EXTERNAL = 391, + LONG = 392, + SHORT = 393, + DOUBLE = 394, + HALF = 395, + FIXED = 396, + UNSIGNED = 397, + INPUT = 398, + OUPTUT = 399, + HVEC2 = 400, + HVEC3 = 401, + HVEC4 = 402, + DVEC2 = 403, + DVEC3 = 404, + DVEC4 = 405, + FVEC2 = 406, + FVEC3 = 407, + FVEC4 = 408, + SAMPLER2DRECT = 409, + SAMPLER3DRECT = 410, + SAMPLER2DRECTSHADOW = 411, + SIZEOF = 412, + CAST = 413, + NAMESPACE = 414, + USING = 415, + COMMON = 416, + PARTITION = 417, + ACTIVE = 418, + SAMPLERBUFFER = 419, + FILTER = 420, + IMAGE1D = 421, + IMAGE2D = 422, + IMAGE3D = 423, + IMAGECUBE = 424, + IMAGE1DARRAY = 425, + IMAGE2DARRAY = 426, + IIMAGE1D = 427, + IIMAGE2D = 428, + IIMAGE3D = 429, + IIMAGECUBE = 430, + IIMAGE1DARRAY = 431, + IIMAGE2DARRAY = 432, + UIMAGE1D = 433, + UIMAGE2D = 434, + UIMAGE3D = 435, + UIMAGECUBE = 436, + UIMAGE1DARRAY = 437, + UIMAGE2DARRAY = 438, + IMAGE1DSHADOW = 439, + IMAGE2DSHADOW = 440, + IMAGEBUFFER = 441, + IIMAGEBUFFER = 442, + UIMAGEBUFFER = 443, + ROW_MAJOR = 444 }; #endif @@ -339,7 +368,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 343 "glsl_parser.cpp" +#line 372 "glsl_parser.cpp" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -364,7 +393,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 368 "glsl_parser.cpp" +#line 397 "glsl_parser.cpp" #ifdef short # undef short @@ -414,7 +443,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -581,10 +610,10 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 5 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 3839 +#define YYLAST 4373 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 184 +#define YYNTOKENS 214 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 89 /* YYNRULES -- Number of rules. */ @@ -594,7 +623,7 @@ union yyalloc /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 414 +#define YYMAXUTOK 444 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -605,16 +634,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 168, 2, 2, 2, 172, 175, 2, - 160, 161, 170, 166, 165, 167, 164, 171, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 179, 181, - 173, 180, 174, 178, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 198, 2, 2, 2, 202, 205, 2, + 190, 191, 200, 196, 195, 197, 194, 201, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 209, 211, + 203, 210, 204, 208, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 162, 2, 163, 176, 2, 2, 2, 2, 2, + 2, 192, 2, 193, 206, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 182, 177, 183, 169, 2, 2, 2, + 2, 2, 2, 212, 207, 213, 199, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -643,7 +672,10 @@ static const yytype_uint8 yytranslate[] = 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, - 155, 156, 157, 158, 159 + 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, + 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, + 185, 186, 187, 188, 189 }; #if YYDEBUG @@ -684,119 +716,119 @@ static const yytype_uint16 yyprhs[] = /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 185, 0, -1, -1, 187, 188, 186, 190, -1, -1, - 111, 81, 116, -1, -1, 188, 189, -1, 112, 79, - 115, 79, 116, -1, 271, -1, 190, 271, -1, 79, - -1, 191, -1, 81, -1, 82, -1, 80, -1, 83, - -1, 160, 218, 161, -1, 192, -1, 193, 162, 194, - 163, -1, 195, -1, 193, 164, 79, -1, 193, 87, - -1, 193, 88, -1, 218, -1, 196, -1, 197, -1, - 193, 164, 197, -1, 199, 161, -1, 198, 161, -1, - 200, 77, -1, 200, -1, 200, 216, -1, 199, 165, - 216, -1, 201, 160, -1, 240, -1, 79, -1, 84, - -1, 193, -1, 87, 202, -1, 88, 202, -1, 203, - 202, -1, 166, -1, 167, -1, 168, -1, 169, -1, - 202, -1, 204, 170, 202, -1, 204, 171, 202, -1, - 204, 172, 202, -1, 204, -1, 205, 166, 204, -1, - 205, 167, 204, -1, 205, -1, 206, 85, 205, -1, - 206, 86, 205, -1, 206, -1, 207, 173, 206, -1, - 207, 174, 206, -1, 207, 89, 206, -1, 207, 90, - 206, -1, 207, -1, 208, 91, 207, -1, 208, 92, - 207, -1, 208, -1, 209, 175, 208, -1, 209, -1, - 210, 176, 209, -1, 210, -1, 211, 177, 210, -1, - 211, -1, 212, 93, 211, -1, 212, -1, 213, 95, - 212, -1, 213, -1, 214, 94, 213, -1, 214, -1, - 214, 178, 218, 179, 216, -1, 215, -1, 202, 217, - 216, -1, 180, -1, 96, -1, 97, -1, 99, -1, + 215, 0, -1, -1, 217, 218, 216, 220, -1, -1, + 112, 81, 117, -1, -1, 218, 219, -1, 113, 79, + 116, 79, 117, -1, 301, -1, 220, 301, -1, 79, + -1, 221, -1, 81, -1, 82, -1, 80, -1, 83, + -1, 190, 248, 191, -1, 222, -1, 223, 192, 224, + 193, -1, 225, -1, 223, 194, 79, -1, 223, 87, + -1, 223, 88, -1, 248, -1, 226, -1, 227, -1, + 223, 194, 227, -1, 229, 191, -1, 228, 191, -1, + 230, 77, -1, 230, -1, 230, 246, -1, 229, 195, + 246, -1, 231, 190, -1, 270, -1, 79, -1, 84, + -1, 223, -1, 87, 232, -1, 88, 232, -1, 233, + 232, -1, 196, -1, 197, -1, 198, -1, 199, -1, + 232, -1, 234, 200, 232, -1, 234, 201, 232, -1, + 234, 202, 232, -1, 234, -1, 235, 196, 234, -1, + 235, 197, 234, -1, 235, -1, 236, 85, 235, -1, + 236, 86, 235, -1, 236, -1, 237, 203, 236, -1, + 237, 204, 236, -1, 237, 89, 236, -1, 237, 90, + 236, -1, 237, -1, 238, 91, 237, -1, 238, 92, + 237, -1, 238, -1, 239, 205, 238, -1, 239, -1, + 240, 206, 239, -1, 240, -1, 241, 207, 240, -1, + 241, -1, 242, 93, 241, -1, 242, -1, 243, 95, + 242, -1, 243, -1, 244, 94, 243, -1, 244, -1, + 244, 208, 248, 209, 246, -1, 245, -1, 232, 247, + 246, -1, 210, -1, 96, -1, 97, -1, 99, -1, 98, -1, 105, -1, 100, -1, 101, -1, 102, -1, - 103, -1, 104, -1, 216, -1, 218, 165, 216, -1, - 215, -1, 221, 181, -1, 229, 181, -1, 110, 244, - 241, 181, -1, 222, 161, -1, 224, -1, 223, -1, - 224, 226, -1, 223, 165, 226, -1, 231, 79, 160, - -1, 240, 79, -1, 240, 79, 162, 219, 163, -1, - 237, 227, 225, -1, 227, 225, -1, 237, 227, 228, - -1, 227, 228, -1, -1, 36, -1, 37, -1, 38, - -1, 240, -1, 230, -1, 229, 165, 79, -1, 229, - 165, 79, 162, 163, -1, 229, 165, 79, 162, 219, - 163, -1, 229, 165, 79, 162, 163, 180, 250, -1, - 229, 165, 79, 162, 219, 163, 180, 250, -1, 229, - 165, 79, 180, 250, -1, 231, -1, 231, 79, -1, - 231, 79, 162, 163, -1, 231, 79, 162, 219, 163, - -1, 231, 79, 162, 163, 180, 250, -1, 231, 79, - 162, 219, 163, 180, 250, -1, 231, 79, 180, 250, - -1, 106, 79, -1, 240, -1, 238, 240, -1, -1, - 233, -1, 119, 160, 234, 161, -1, 235, -1, 234, - 165, 235, -1, 79, -1, 43, -1, 42, -1, 41, - -1, 4, -1, 239, -1, 236, 238, -1, 106, 238, - -1, 4, -1, 3, -1, 232, 40, -1, 35, 40, - -1, 232, 36, -1, 37, -1, 35, 36, -1, 35, - 37, -1, 39, -1, 241, -1, 244, 241, -1, 242, - -1, 242, 162, 163, -1, 242, 162, 219, 163, -1, - 243, -1, 245, -1, 79, -1, 77, -1, 6, -1, + 103, -1, 104, -1, 246, -1, 248, 195, 246, -1, + 245, -1, 251, 211, -1, 259, 211, -1, 111, 274, + 271, 211, -1, 252, 191, -1, 254, -1, 253, -1, + 254, 256, -1, 253, 195, 256, -1, 261, 79, 190, + -1, 270, 79, -1, 270, 79, 192, 249, 193, -1, + 267, 257, 255, -1, 257, 255, -1, 267, 257, 258, + -1, 257, 258, -1, -1, 36, -1, 37, -1, 38, + -1, 270, -1, 260, -1, 259, 195, 79, -1, 259, + 195, 79, 192, 193, -1, 259, 195, 79, 192, 249, + 193, -1, 259, 195, 79, 192, 193, 210, 280, -1, + 259, 195, 79, 192, 249, 193, 210, 280, -1, 259, + 195, 79, 210, 280, -1, 261, -1, 261, 79, -1, + 261, 79, 192, 193, -1, 261, 79, 192, 249, 193, + -1, 261, 79, 192, 193, 210, 280, -1, 261, 79, + 192, 249, 193, 210, 280, -1, 261, 79, 210, 280, + -1, 106, 79, -1, 270, -1, 268, 270, -1, -1, + 263, -1, 120, 190, 264, 191, -1, 265, -1, 264, + 195, 265, -1, 79, -1, 43, -1, 42, -1, 41, + -1, 4, -1, 269, -1, 266, 268, -1, 106, 268, + -1, 4, -1, 3, -1, 262, 40, -1, 35, 40, + -1, 262, 36, -1, 37, -1, 35, 36, -1, 35, + 37, -1, 39, -1, 271, -1, 274, 271, -1, 272, + -1, 272, 192, 193, -1, 272, 192, 249, 193, -1, + 273, -1, 275, -1, 79, -1, 77, -1, 6, -1, 7, -1, 8, -1, 5, -1, 29, -1, 30, -1, 31, -1, 20, -1, 21, -1, 22, -1, 23, -1, 24, -1, 25, -1, 26, -1, 27, -1, 28, -1, 32, -1, 33, -1, 34, -1, 44, -1, 45, -1, 46, -1, 47, -1, 48, -1, 49, -1, 50, -1, - 51, -1, 52, -1, 53, -1, 54, -1, 153, -1, - 55, -1, 56, -1, 57, -1, 58, -1, 155, -1, + 51, -1, 52, -1, 53, -1, 54, -1, 154, -1, + 55, -1, 56, -1, 57, -1, 58, -1, 156, -1, 59, -1, 60, -1, 61, -1, 62, -1, 63, -1, 64, -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, -1, 70, -1, 71, -1, 72, -1, 73, -1, 74, -1, 75, -1, 109, -1, 108, -1, 107, -1, - 76, 79, 182, 246, 183, -1, 76, 182, 246, 183, - -1, 247, -1, 246, 247, -1, 240, 248, 181, -1, - 249, -1, 248, 165, 249, -1, 79, -1, 79, 162, - 219, 163, -1, 216, -1, 220, -1, 253, -1, 254, - -1, 256, -1, 255, -1, 262, -1, 251, -1, 260, - -1, 261, -1, 264, -1, 265, -1, 266, -1, 270, - -1, 182, 183, -1, 182, 259, 183, -1, 258, -1, - 255, -1, 182, 183, -1, 182, 259, 183, -1, 252, - -1, 259, 252, -1, 181, -1, 218, 181, -1, 14, - 160, 218, 161, 253, 12, 253, -1, 14, 160, 218, - 161, 253, -1, 14, 160, 218, 161, 254, -1, 14, - 160, 218, 161, 253, 12, 254, -1, 218, -1, 231, - 79, 180, 250, -1, 17, 160, 218, 161, 256, -1, - 18, 218, 179, -1, 19, 179, -1, 78, 160, 263, - 161, 257, -1, 11, 252, 78, 160, 218, 161, 181, - -1, 13, 160, 267, 269, 161, 257, -1, 260, -1, - 251, -1, 263, -1, -1, 268, 181, -1, 268, 181, - 218, -1, 10, 181, -1, 9, 181, -1, 16, 181, - -1, 16, 218, 181, -1, 15, 181, -1, 272, -1, - 220, -1, 221, 258, -1 + 76, 79, 212, 276, 213, -1, 76, 212, 276, 213, + -1, 277, -1, 276, 277, -1, 270, 278, 211, -1, + 279, -1, 278, 195, 279, -1, 79, -1, 79, 192, + 249, 193, -1, 246, -1, 250, -1, 283, -1, 284, + -1, 286, -1, 285, -1, 292, -1, 281, -1, 290, + -1, 291, -1, 294, -1, 295, -1, 296, -1, 300, + -1, 212, 213, -1, 212, 289, 213, -1, 288, -1, + 285, -1, 212, 213, -1, 212, 289, 213, -1, 282, + -1, 289, 282, -1, 211, -1, 248, 211, -1, 14, + 190, 248, 191, 283, 12, 283, -1, 14, 190, 248, + 191, 283, -1, 14, 190, 248, 191, 284, -1, 14, + 190, 248, 191, 283, 12, 284, -1, 248, -1, 261, + 79, 210, 280, -1, 17, 190, 248, 191, 286, -1, + 18, 248, 209, -1, 19, 209, -1, 78, 190, 293, + 191, 287, -1, 11, 282, 78, 190, 248, 191, 211, + -1, 13, 190, 297, 299, 191, 287, -1, 290, -1, + 281, -1, 293, -1, -1, 298, 211, -1, 298, 211, + 248, -1, 10, 211, -1, 9, 211, -1, 16, 211, + -1, 16, 248, 211, -1, 15, 211, -1, 302, -1, + 250, -1, 251, 288, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 193, 193, 192, 201, 204, 221, 223, 227, 236, - 244, 255, 259, 266, 273, 280, 287, 294, 301, 302, - 308, 312, 319, 325, 334, 338, 342, 343, 352, 353, - 357, 358, 362, 368, 380, 384, 390, 397, 408, 409, - 415, 421, 431, 432, 433, 434, 438, 439, 445, 451, - 460, 461, 467, 476, 477, 483, 492, 493, 499, 505, - 511, 520, 521, 527, 536, 537, 546, 547, 556, 557, - 566, 567, 576, 577, 586, 587, 596, 597, 606, 607, - 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, - 626, 630, 634, 650, 654, 658, 662, 676, 680, 681, - 685, 690, 698, 709, 719, 734, 741, 746, 757, 769, - 770, 771, 772, 776, 780, 781, 790, 799, 808, 817, - 826, 839, 850, 859, 868, 877, 886, 895, 904, 918, - 925, 936, 937, 941, 948, 949, 956, 990, 991, 992, - 996, 1000, 1001, 1005, 1013, 1014, 1015, 1016, 1017, 1018, - 1019, 1020, 1021, 1025, 1026, 1034, 1035, 1041, 1050, 1056, - 1062, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, - 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, - 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, - 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, - 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, - 1120, 1121, 1122, 1123, 1124, 1128, 1139, 1150, 1164, 1170, - 1179, 1184, 1192, 1207, 1212, 1220, 1226, 1235, 1239, 1245, - 1246, 1250, 1251, 1255, 1259, 1260, 1261, 1262, 1263, 1264, - 1265, 1269, 1275, 1284, 1285, 1289, 1295, 1304, 1314, 1326, - 1332, 1341, 1350, 1356, 1362, 1371, 1375, 1389, 1393, 1394, - 1398, 1405, 1412, 1422, 1423, 1427, 1429, 1435, 1440, 1449, - 1455, 1461, 1467, 1473, 1482, 1483, 1487 + 0, 200, 200, 199, 208, 211, 228, 230, 234, 243, + 251, 262, 266, 273, 280, 287, 294, 301, 308, 309, + 315, 319, 326, 332, 341, 345, 349, 350, 359, 360, + 364, 365, 369, 375, 387, 391, 397, 404, 415, 416, + 422, 428, 438, 439, 440, 441, 445, 446, 452, 458, + 467, 468, 474, 483, 484, 490, 499, 500, 506, 512, + 518, 527, 528, 534, 543, 544, 553, 554, 563, 564, + 573, 574, 583, 584, 593, 594, 603, 604, 613, 614, + 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, + 633, 637, 641, 657, 661, 665, 669, 683, 687, 688, + 692, 697, 705, 716, 726, 741, 748, 753, 764, 776, + 777, 778, 779, 783, 787, 788, 797, 806, 815, 824, + 833, 846, 857, 866, 875, 884, 893, 902, 911, 925, + 932, 943, 944, 948, 955, 956, 963, 997, 998, 999, + 1003, 1007, 1008, 1012, 1020, 1021, 1022, 1023, 1024, 1025, + 1026, 1027, 1028, 1032, 1033, 1041, 1042, 1048, 1057, 1063, + 1069, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, + 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, + 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, + 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, + 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, + 1127, 1128, 1129, 1130, 1131, 1135, 1146, 1157, 1171, 1177, + 1186, 1191, 1199, 1214, 1219, 1227, 1233, 1242, 1246, 1252, + 1253, 1257, 1258, 1262, 1266, 1267, 1268, 1269, 1270, 1271, + 1272, 1276, 1282, 1291, 1292, 1296, 1302, 1311, 1321, 1333, + 1339, 1348, 1357, 1363, 1369, 1378, 1382, 1396, 1400, 1401, + 1405, 1412, 1419, 1429, 1430, 1434, 1436, 1442, 1447, 1456, + 1462, 1468, 1474, 1480, 1489, 1490, 1494 }; #endif @@ -824,18 +856,25 @@ static const char *const yytname[] = "GE_OP", "EQ_OP", "NE_OP", "AND_OP", "OR_OP", "XOR_OP", "MUL_ASSIGN", "DIV_ASSIGN", "ADD_ASSIGN", "MOD_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN", "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", "SUB_ASSIGN", "INVARIANT", - "LOWP", "MEDIUMP", "HIGHP", "PRECISION", "VERSION", "EXTENSION", "LINE", - "PRAGMA", "COLON", "EOL", "INTERFACE", "OUTPUT", "LAYOUT_TOK", "ASM", - "CLASS", "UNION", "ENUM", "TYPEDEF", "TEMPLATE", "THIS", "PACKED", - "GOTO", "INLINE_TOK", "NOINLINE", "VOLATILE", "PUBLIC_TOK", "STATIC", - "EXTERN", "EXTERNAL", "LONG", "SHORT", "DOUBLE", "HALF", "FIXED", - "UNSIGNED", "INPUT", "OUPTUT", "HVEC2", "HVEC3", "HVEC4", "DVEC2", - "DVEC3", "DVEC4", "FVEC2", "FVEC3", "FVEC4", "SAMPLER2DRECT", - "SAMPLER3DRECT", "SAMPLER2DRECTSHADOW", "SIZEOF", "CAST", "NAMESPACE", - "USING", "'('", "')'", "'['", "']'", "'.'", "','", "'+'", "'-'", "'!'", - "'~'", "'*'", "'/'", "'%'", "'<'", "'>'", "'&'", "'^'", "'|'", "'?'", - "':'", "'='", "';'", "'{'", "'}'", "$accept", "translation_unit", "$@1", - "version_statement", "extension_statement_list", "extension_statement", + "LOWP", "MEDIUMP", "HIGHP", "SUPERP", "PRECISION", "VERSION", + "EXTENSION", "LINE", "PRAGMA", "COLON", "EOL", "INTERFACE", "OUTPUT", + "LAYOUT_TOK", "ASM", "CLASS", "UNION", "ENUM", "TYPEDEF", "TEMPLATE", + "THIS", "PACKED", "GOTO", "INLINE_TOK", "NOINLINE", "VOLATILE", + "PUBLIC_TOK", "STATIC", "EXTERN", "EXTERNAL", "LONG", "SHORT", "DOUBLE", + "HALF", "FIXED", "UNSIGNED", "INPUT", "OUPTUT", "HVEC2", "HVEC3", + "HVEC4", "DVEC2", "DVEC3", "DVEC4", "FVEC2", "FVEC3", "FVEC4", + "SAMPLER2DRECT", "SAMPLER3DRECT", "SAMPLER2DRECTSHADOW", "SIZEOF", + "CAST", "NAMESPACE", "USING", "COMMON", "PARTITION", "ACTIVE", + "SAMPLERBUFFER", "FILTER", "IMAGE1D", "IMAGE2D", "IMAGE3D", "IMAGECUBE", + "IMAGE1DARRAY", "IMAGE2DARRAY", "IIMAGE1D", "IIMAGE2D", "IIMAGE3D", + "IIMAGECUBE", "IIMAGE1DARRAY", "IIMAGE2DARRAY", "UIMAGE1D", "UIMAGE2D", + "UIMAGE3D", "UIMAGECUBE", "UIMAGE1DARRAY", "UIMAGE2DARRAY", + "IMAGE1DSHADOW", "IMAGE2DSHADOW", "IMAGEBUFFER", "IIMAGEBUFFER", + "UIMAGEBUFFER", "ROW_MAJOR", "'('", "')'", "'['", "']'", "'.'", "','", + "'+'", "'-'", "'!'", "'~'", "'*'", "'/'", "'%'", "'<'", "'>'", "'&'", + "'^'", "'|'", "'?'", "':'", "'='", "';'", "'{'", "'}'", "$accept", + "translation_unit", "$@1", "version_statement", + "extension_statement_list", "extension_statement", "external_declaration_list", "variable_identifier", "primary_expression", "postfix_expression", "integer_expression", "function_call", "function_call_or_method", "function_call_generic", @@ -892,6 +931,9 @@ static const yytype_uint16 yytoknum[] = 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, + 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, + 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 40, 41, 91, 93, 46, 44, 43, 45, 33, 126, 42, 47, 37, 60, 62, 38, 94, 124, 63, 58, 61, 59, 123, 125 @@ -901,34 +943,34 @@ static const yytype_uint16 yytoknum[] = /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { - 0, 184, 186, 185, 187, 187, 188, 188, 189, 190, - 190, 191, 192, 192, 192, 192, 192, 192, 193, 193, - 193, 193, 193, 193, 194, 195, 196, 196, 197, 197, - 198, 198, 199, 199, 200, 201, 201, 201, 202, 202, - 202, 202, 203, 203, 203, 203, 204, 204, 204, 204, - 205, 205, 205, 206, 206, 206, 207, 207, 207, 207, - 207, 208, 208, 208, 209, 209, 210, 210, 211, 211, - 212, 212, 213, 213, 214, 214, 215, 215, 216, 216, - 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, - 217, 218, 218, 219, 220, 220, 220, 221, 222, 222, - 223, 223, 224, 225, 225, 226, 226, 226, 226, 227, - 227, 227, 227, 228, 229, 229, 229, 229, 229, 229, - 229, 230, 230, 230, 230, 230, 230, 230, 230, 231, - 231, 232, 232, 233, 234, 234, 235, 236, 236, 236, - 237, 238, 238, 238, 239, 239, 239, 239, 239, 239, - 239, 239, 239, 240, 240, 241, 241, 241, 242, 242, - 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, - 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, - 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, - 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, - 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, - 243, 243, 243, 243, 243, 244, 244, 244, 245, 245, - 246, 246, 247, 248, 248, 249, 249, 250, 251, 252, - 252, 253, 253, 254, 255, 255, 255, 255, 255, 255, - 255, 256, 256, 257, 257, 258, 258, 259, 259, 260, - 260, 261, 262, 262, 262, 263, 263, 264, 265, 265, - 266, 266, 266, 267, 267, 268, 268, 269, 269, 270, - 270, 270, 270, 270, 271, 271, 272 + 0, 214, 216, 215, 217, 217, 218, 218, 219, 220, + 220, 221, 222, 222, 222, 222, 222, 222, 223, 223, + 223, 223, 223, 223, 224, 225, 226, 226, 227, 227, + 228, 228, 229, 229, 230, 231, 231, 231, 232, 232, + 232, 232, 233, 233, 233, 233, 234, 234, 234, 234, + 235, 235, 235, 236, 236, 236, 237, 237, 237, 237, + 237, 238, 238, 238, 239, 239, 240, 240, 241, 241, + 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, + 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, + 247, 248, 248, 249, 250, 250, 250, 251, 252, 252, + 253, 253, 254, 255, 255, 256, 256, 256, 256, 257, + 257, 257, 257, 258, 259, 259, 259, 259, 259, 259, + 259, 260, 260, 260, 260, 260, 260, 260, 260, 261, + 261, 262, 262, 263, 264, 264, 265, 266, 266, 266, + 267, 268, 268, 268, 269, 269, 269, 269, 269, 269, + 269, 269, 269, 270, 270, 271, 271, 271, 272, 272, + 272, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 274, 274, 274, 275, 275, + 276, 276, 277, 278, 278, 279, 279, 280, 281, 282, + 282, 283, 283, 284, 285, 285, 285, 285, 285, 285, + 285, 286, 286, 287, 287, 288, 288, 289, 289, 290, + 290, 291, 292, 292, 292, 293, 293, 294, 295, 295, + 296, 296, 296, 297, 297, 298, 298, 299, 299, 300, + 300, 300, 300, 300, 301, 301, 302 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -1029,65 +1071,65 @@ static const yytype_int16 yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -353 +#define YYPACT_NINF -351 static const yytype_int16 yypact[] = { - -96, -61, 22, -353, -89, -353, -75, -353, -25, 3345, - -353, -48, -353, -353, -353, -353, -353, -353, -353, -353, - -353, -353, -353, -353, -353, -353, -353, -353, -353, -353, - -353, -353, -353, 106, -353, -353, -353, -353, -353, -353, - -353, -353, -353, -353, -353, -353, -353, -353, -353, -353, - -353, -353, -353, -353, -353, -353, -353, -353, -353, -353, - -353, -353, -353, -353, -353, -353, -353, -353, -353, -353, - -353, -78, -353, -353, 3, -353, -353, -353, 63, -80, - -353, -353, 3228, -353, -55, -92, -54, -2, -133, -353, - -5, 50, -353, 14, 3572, -353, -353, -353, -56, -353, - 3684, -353, -353, -353, 34, -353, -353, -353, -44, 3572, - -353, 14, -353, 3684, 62, -353, -353, 273, -353, -353, - 87, -353, -353, -353, -353, -353, 3572, 176, 85, -353, - -137, -353, -353, -353, -353, 2454, -353, 33, 3572, 89, - 1856, -353, -15, -353, -33, -353, 28, 42, 997, 43, - 64, 44, 2136, 66, 2907, 48, 69, -68, -353, -353, - -353, -353, -353, 2907, 2907, 2907, -353, -353, -353, -353, - -353, 454, -353, -353, -353, -59, -353, -353, -353, 13, - -17, 3058, 71, 270, 2907, 49, -31, 70, -76, 103, - 57, 60, 61, 144, 145, -85, -353, -353, -104, -353, - 58, 83, -353, -353, -353, -353, -353, -353, 635, -353, - -353, -353, -353, -353, -353, -353, -353, -353, -353, 165, - 3572, -102, -353, 2605, 2907, -353, -353, -353, 82, -353, - -353, 1996, 84, -100, -353, -353, -353, -353, -353, 62, - -353, -353, 172, 1524, 2907, -353, -353, -94, 2907, -90, - -353, 2303, -353, -353, -14, -353, 816, -353, -353, 2907, - 3460, -353, -353, 2907, 90, -353, -353, -353, -353, -353, - -353, -353, -353, -353, -353, -353, -353, -353, 2907, -353, - 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, - 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, 2907, - 2907, -353, -353, -353, 91, -353, -353, 2756, 2907, 72, - 93, -353, -353, -353, -353, 2907, 89, -353, -353, 97, - -353, -353, 1691, -7, -353, -4, -353, 94, 179, 99, - -353, -353, 98, 94, 102, -353, -353, -353, -353, -353, - -353, 49, 49, -31, -31, 70, 70, 70, 70, -76, - -76, 103, 57, 60, 61, 144, 145, -58, -353, 2907, - 86, 100, -353, 2907, 88, 101, -353, 2907, -353, 92, - 104, 997, 127, 95, 1177, -353, 2907, 107, 2907, 105, - -353, 2907, -353, 2, 2907, 1177, 255, -353, -353, 2907, - 109, -353, -353, -353, -353, -353, -353, 2907, -353, 130, - 94, -353, 997, -353, 2907, -353, -353, -353, -353, 4, - 1357, 259, 1357 + -85, -52, 36, -351, -60, -351, -30, -351, -31, 3875, + -351, -27, -351, -351, -351, -351, -351, -351, -351, -351, + -351, -351, -351, -351, -351, -351, -351, -351, -351, -351, + -351, -351, -351, 69, -351, -351, -351, -351, -351, -351, + -351, -351, -351, -351, -351, -351, -351, -351, -351, -351, + -351, -351, -351, -351, -351, -351, -351, -351, -351, -351, + -351, -351, -351, -351, -351, -351, -351, -351, -351, -351, + -351, -78, -351, -351, 8, -351, -351, -351, 50, -83, + -351, -351, 3757, -351, -63, 4, -44, 3, -169, -351, + 82, -5, -351, 166, 4104, -351, -351, -351, 14, -351, + 4217, -351, -351, -351, 135, -351, -351, -351, -12, 4104, + -351, 166, -351, 4217, 142, -351, -351, 401, -351, -351, + 18, -351, -351, -351, -351, -351, 4104, 127, 144, -351, + -112, -351, -351, -351, -351, 2857, -351, 107, 4104, 146, + 2254, -351, 20, -351, -99, -351, 21, 25, 1245, 39, + 47, 27, 2480, 49, 3397, 31, 53, -69, -351, -351, + -351, -351, -351, 3397, 3397, 3397, -351, -351, -351, -351, + -351, 612, -351, -351, -351, -68, -351, -351, -351, 54, + -59, 3577, 56, -36, 3397, -34, -25, 112, -81, 121, + 45, 38, 44, 159, 158, -88, -351, -351, -167, -351, + 46, 66, -351, -351, -351, -351, -351, -351, 823, -351, + -351, -351, -351, -351, -351, -351, -351, -351, -351, 179, + 4104, -178, -351, 3037, 3397, -351, -351, -351, 67, -351, + -351, 2367, 70, -121, -351, -351, -351, -351, -351, 142, + -351, -351, 181, 1862, 3397, -351, -351, -114, 3397, -172, + -351, 2677, -351, -351, -58, -351, 1034, -351, -351, 3397, + 3991, -351, -351, 3397, 72, -351, -351, -351, -351, -351, + -351, -351, -351, -351, -351, -351, -351, -351, 3397, -351, + 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, + 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, + 3397, -351, -351, -351, 73, -351, -351, 3217, 3397, 51, + 71, -351, -351, -351, -351, 3397, 146, -351, -351, 76, + -351, -351, 2059, -51, -351, -50, -351, 74, 188, 77, + -351, -351, 78, 74, 80, -351, -351, -351, -351, -351, + -351, -34, -34, -25, -25, 112, 112, 112, 112, -81, + -81, 121, 45, 38, 44, 159, 158, -125, -351, 3397, + 63, 81, -351, 3397, 65, 83, -351, 3397, -351, 68, + 86, 1245, 75, 79, 1455, -351, 3397, 85, 3397, 84, + -351, 3397, -351, -49, 3397, 1455, 268, -351, -351, 3397, + 91, -351, -351, -351, -351, -351, -351, 3397, -351, 87, + 74, -351, 1245, -351, 3397, -351, -351, -351, -351, -48, + 1665, 270, 1665 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -353, -353, -353, -353, -353, -353, -353, -353, -353, -353, - -353, -353, -353, 117, -353, -353, -353, -353, -105, -353, - -86, -69, -82, -91, -21, -20, 68, 108, 67, 80, - -353, -111, -148, -353, -149, -219, 12, 32, -353, -353, - -353, 138, 239, 257, 166, -353, -353, -239, -353, -353, - -353, 146, -353, -353, -27, -353, -9, -74, -353, -353, - 309, -353, 250, -130, -353, 73, -244, 147, -140, -340, - -352, -322, 19, 9, 311, 225, 154, -353, -353, 76, - -353, -353, -353, -353, -353, -353, -353, 317, -353 + -351, -351, -351, -351, -351, -351, -351, -351, -351, -351, + -351, -351, -351, 23, -351, -351, -351, -351, -105, -351, + -67, -66, -134, -65, -8, -10, -7, -6, -4, -3, + -351, -111, -148, -351, -149, -221, 6, 9, -351, -351, + -351, 88, 171, 165, 89, -351, -351, -247, -351, -351, + -351, 57, -351, -351, -40, -351, -9, -75, -351, -351, + 219, -351, 161, -127, -351, -16, -262, 58, -131, -299, + -350, -292, -70, -82, 220, 134, 64, -351, -351, -11, + -351, -351, -351, -351, -351, -351, -351, 224, -351 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -1097,52 +1139,110 @@ static const yytype_int16 yypgoto[] = #define YYTABLE_NINF -267 static const yytype_int16 yytable[] = { - 96, 108, 121, 247, 310, 249, 12, 13, 242, 298, - 236, -160, 328, 287, 288, 1, 254, 12, 13, 387, - 4, 83, 5, 222, 227, 223, 136, 7, 257, 258, - 226, 386, 128, 265, 122, 123, 124, 8, 33, 142, - 34, 84, 35, 224, 36, 37, 38, 112, 129, 33, - 408, 34, 391, 35, 11, 36, 37, 38, 252, 253, - 307, 300, 407, 391, 362, 316, 133, 104, 303, 119, - 411, 300, 407, 96, 130, 300, 311, 301, 308, 279, - 114, 317, 110, 328, 112, 134, 131, 324, 361, 326, - 132, 121, -36, 299, 83, 323, 365, 289, 290, 325, - 139, 236, 327, 259, 109, 260, 135, 300, 201, 111, - 333, 120, 227, 137, 84, 336, 303, 219, 226, 380, - 111, 376, 79, 122, 123, 124, 116, 117, 238, 139, - 337, 139, 239, 79, 396, 283, 284, 398, 138, 201, - 377, 143, 105, 106, 262, 403, 107, 330, 263, 230, - 357, 300, 358, 405, 371, 285, 286, 372, 300, -98, - 311, 300, 201, 399, 221, 410, 237, 300, 232, 300, - 75, 76, 77, 327, 261, 338, 339, 340, 226, 226, + 96, 108, 310, 247, 328, 249, 298, 121, 287, 288, + -160, 12, 13, 236, 307, 83, 254, 242, 84, 257, + 258, 387, 121, 300, 227, 136, 128, 1, 300, 4, + 226, 131, 308, 265, 112, 132, 5, 326, 142, 122, + 123, 124, 129, 33, 301, 34, 362, 35, 11, 36, + 37, 38, 408, 133, 122, 123, 124, 7, 252, 253, + 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, + 300, 112, 386, 96, 316, 328, 311, 303, 222, 279, + 223, 300, 391, 8, 376, 134, 361, 110, 83, 104, + 317, 84, 238, 391, 365, 323, 239, 324, 224, 325, + 139, 380, 327, 407, 236, 105, 106, 114, 201, 107, + 333, 411, 227, 407, 111, 336, 396, 219, 226, 398, + 299, -36, 289, 290, 259, 303, 260, 403, 79, 139, + 337, 139, 262, 330, 109, 405, 263, 300, 377, 201, + 371, 372, 399, 410, 300, 300, 300, 300, 116, 117, + 357, 120, 358, 345, 346, 347, 348, 75, 76, 77, + 311, 130, 201, 122, 123, 124, 280, 281, 282, 12, + 13, 283, 284, 327, 277, 338, 339, 340, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, - 226, 226, 226, 226, 291, 292, 227, 341, 342, 201, - 349, 350, 226, 243, 227, 345, 346, 347, 348, 240, - 226, 219, 122, 123, 124, 311, 343, 344, 383, 280, - 281, 282, 139, 241, 244, 245, 248, 250, 394, 251, - 311, 266, 293, 311, 201, 400, 294, 296, 295, 116, - 297, 311, 201, -35, 304, 313, 315, 201, 227, 311, - 319, -30, 363, 359, 226, 409, 364, 367, 373, 300, - 374, 375, -36, 379, 382, 385, 378, 402, 381, 404, - 395, 412, 351, 384, 352, 389, 12, 13, 14, 15, - 16, 17, 146, 147, 148, 397, 149, 150, 151, 152, + 226, 226, 226, 226, -98, 119, 227, 285, 286, 201, + 138, 33, 226, 34, 227, 35, 135, 36, 37, 38, + 226, 219, 291, 292, 137, 311, 341, 342, 383, 343, + 344, 143, 139, 221, 230, 232, 349, 350, 394, 243, + 311, 237, 240, 311, 201, 400, 241, 244, 245, 248, + 250, 311, 201, 251, 294, 261, 266, 201, 227, 311, + 293, 295, 296, 297, 226, 409, -35, 116, 304, 319, + 313, 363, 315, -30, 364, 359, 367, 373, 374, 300, + -36, 375, 111, 378, 379, 381, 382, 385, 395, 384, + 402, 404, 412, 335, 352, 351, 79, 171, 353, 389, + 354, 216, 220, 355, 397, 356, 318, 113, 406, 231, + 366, 320, 388, 401, 118, 256, 115, 321, 305, 306, + 0, 368, 0, 201, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 201, 0, 0, 201, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 201, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 201, 0, 0, 0, 0, 0, 0, + 0, 201, 0, 201, 12, 13, 14, 15, 16, 17, + 146, 147, 148, 0, 149, 150, 151, 152, 153, 154, + 155, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 0, 34, 0, + 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 156, + 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 74, 75, 76, + 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, + 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, + 169, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 170, 171, 172, 12, 13, 14, 15, 16, + 17, 146, 147, 148, 0, 149, 150, 151, 152, 153, + 154, 155, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 0, 34, + 0, 35, 0, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 156, 157, 158, 159, 160, 161, 162, 0, 0, 163, + 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 74, 75, + 76, 77, 0, 78, 0, 0, 0, 0, 0, 0, + 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 165, 0, 0, 0, 0, 0, 166, 167, + 168, 169, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 170, 171, 255, 12, 13, 14, 15, + 16, 17, 146, 147, 148, 0, 149, 150, 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 171, - 34, 406, 35, 201, 36, 37, 38, 39, 40, 41, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, + 34, 0, 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 156, 157, 158, 159, 160, 161, 162, 305, 216, - 163, 164, 201, 353, 355, 201, 267, 268, 269, 270, - 271, 272, 273, 274, 275, 276, 201, 335, 356, 74, - 75, 76, 77, 78, 220, 318, 306, 113, 231, 366, - 320, 388, 79, 201, 401, 118, 256, 321, 368, 115, - 0, 201, 0, 201, 354, 0, 0, 0, 0, 0, + 72, 156, 157, 158, 159, 160, 161, 162, 0, 0, + 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, + 75, 76, 77, 0, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, 0, 0, 0, 0, 0, 0, 0, - 277, 0, 0, 0, 170, 171, 172, 12, 13, 14, + 0, 0, 0, 0, 170, 171, 302, 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, 149, 150, 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, @@ -1153,14 +1253,17 @@ static const yytype_int16 yytable[] = 71, 72, 156, 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 74, 75, 76, 77, 78, 0, 0, 0, 0, 0, - 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, + 74, 75, 76, 77, 0, 78, 0, 0, 0, 0, + 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, + 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 170, 171, 255, 12, 13, + 0, 0, 0, 0, 0, 170, 171, 331, 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, 149, 150, 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -1171,225 +1274,213 @@ static const yytype_int16 yytable[] = 70, 71, 72, 156, 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 74, 75, 76, 77, 78, 0, 0, 0, 0, - 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, + 0, 74, 75, 76, 77, 0, 78, 0, 0, 0, + 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, - 81, 0, 0, 0, 0, 165, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, + 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 170, 171, 302, 12, - 13, 14, 15, 16, 17, 146, 147, 148, 0, 149, - 150, 151, 152, 153, 154, 155, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 0, 34, 0, 35, 0, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 156, 157, 158, 159, 160, 161, - 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 170, 171, 12, 13, + 14, 15, 16, 17, 146, 147, 148, 0, 149, 390, + 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 0, 34, 0, 35, 0, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 156, 157, 158, 159, 160, 161, 162, + 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 74, 75, 76, 77, 78, 0, 0, 0, + 0, 74, 75, 76, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, - 0, 81, 0, 0, 0, 0, 165, 0, 0, 0, - 0, 0, 166, 167, 168, 169, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 170, 171, 331, - 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, - 149, 150, 151, 152, 153, 154, 155, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 156, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, + 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 74, 75, 76, 77, 78, 0, 0, - 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, + 0, 166, 167, 168, 169, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 170, 117, 12, 13, + 14, 15, 16, 17, 146, 147, 148, 0, 149, 390, + 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 0, 34, 0, 35, 0, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 156, 157, 158, 159, 160, 161, 162, + 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 74, 75, 76, 77, 0, 78, 0, 0, 0, + 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 80, 0, 81, 0, 0, 0, 0, 165, 0, 0, - 0, 0, 0, 166, 167, 168, 169, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 170, 171, - 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, - 149, 390, 151, 152, 153, 154, 155, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 156, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 74, 75, 76, 77, 78, 0, 0, - 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, + 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, + 0, 166, 167, 168, 169, 12, 13, 14, 15, 16, + 17, 0, 0, 0, 0, 0, 170, 171, 0, 0, + 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 0, 34, + 0, 35, 0, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 0, 157, 158, 159, 160, 161, 162, 0, 0, 163, + 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 74, 75, + 76, 77, 0, 78, 0, 0, 0, 0, 0, 0, + 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 80, 0, 81, 0, 0, 0, 0, 165, 0, 0, - 0, 0, 0, 166, 167, 168, 169, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 170, 117, - 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, - 149, 390, 151, 152, 153, 154, 155, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 156, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 74, 75, 76, 77, 78, 0, 0, - 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 165, 0, 0, 0, 0, 0, 166, 167, + 168, 169, 12, 13, 14, 15, 16, 17, 0, 0, + 0, 0, 0, 170, 0, 0, 0, 0, 0, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 0, 34, 0, 35, 0, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 0, 157, 158, + 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 80, 0, 81, 0, 0, 0, 0, 165, 0, 0, - 0, 0, 0, 166, 167, 168, 169, 12, 13, 14, - 15, 16, 17, 0, 0, 0, 0, 0, 170, 171, - 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 0, 34, 0, 35, 0, 36, 37, 38, 39, 40, + 0, 0, 0, 0, 0, 111, 75, 76, 77, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, + 0, 0, 0, 0, 0, 166, 167, 168, 169, 14, + 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, + -266, 0, 0, 0, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 0, 157, 158, 159, 160, 161, 162, 0, - 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, + 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 74, 75, 76, 77, 78, 0, 0, 0, 0, 0, - 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 0, 0, 0, 0, 0, 0, 80, 0, + 81, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 0, 73, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 235, 0, 0, + 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, + 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, + 0, 80, 0, 81, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 0, 157, + 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 314, 0, 0, 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, - 0, 0, 0, 0, 165, 0, 0, 0, 0, 0, - 166, 167, 168, 169, 12, 13, 14, 15, 16, 17, - 0, 0, 0, 0, 0, 170, 0, 0, 0, 0, - 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 0, 34, 0, - 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, - 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 111, 75, 76, - 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, - 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, - 169, 14, 15, 16, 17, 0, 0, 0, 0, 0, - 0, 0, -266, 0, 0, 0, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, + 12, 13, 14, 15, 16, 17, 0, 0, 0, 0, + 0, 246, 0, 0, 0, 0, 0, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 111, 75, 76, 77, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 14, 15, 16, 17, 0, 0, 0, 0, 80, - 0, 81, 0, 0, 0, 0, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 0, 0, 0, 0, 0, 0, 0, 0, 235, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, + 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 15, 16, 17, 0, 165, 0, 0, + 0, 0, 0, 166, 167, 168, 169, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 14, 15, 16, 17, 0, 0, 0, 0, 80, - 0, 81, 0, 0, 0, 0, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 0, 0, 0, 0, 0, 0, 0, 0, 314, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 0, 157, 158, 159, 160, 161, - 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, - 0, 81, 0, 0, 0, 0, 165, 0, 0, 0, - 0, 0, 166, 167, 168, 169, 12, 13, 14, 15, - 16, 17, 0, 0, 0, 0, 0, 246, 0, 0, - 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, - 34, 0, 35, 0, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 0, 157, 158, 159, 160, 161, 162, 0, 0, - 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, - 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 80, 0, 81, 14, - 15, 16, 17, 165, 0, 0, 0, 0, 0, 166, - 167, 168, 169, 0, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 0, 157, 158, 159, 160, 161, 162, 0, - 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 15, 16, 17, 0, 165, 0, 0, + 225, 0, 0, 166, 167, 168, 169, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, - 14, 15, 16, 17, 165, 0, 0, 225, 0, 0, - 166, 167, 168, 169, 0, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 0, 157, 158, 159, 160, 161, 162, - 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, + 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 15, 16, 17, 0, 165, 0, 0, + 309, 0, 0, 166, 167, 168, 169, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, - 81, 14, 15, 16, 17, 165, 0, 0, 309, 0, - 0, 166, 167, 168, 169, 0, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 0, 157, 158, 159, 160, 161, - 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, - 0, 81, 14, 15, 16, 17, 165, 0, 0, 360, - 0, 0, 166, 167, 168, 169, 0, 18, 19, 20, + 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 15, 16, 17, 0, 165, 0, 0, + 360, 0, 0, 166, 167, 168, 169, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, @@ -1403,34 +1494,38 @@ static const yytype_int16 yytable[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 80, 0, 81, 14, 15, 16, 17, 165, 0, 0, - 0, 0, 0, 166, 167, 168, 169, 0, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 264, 0, 157, 158, 159, - 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, + 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 15, 16, 17, 0, 165, 0, 0, + 0, 0, 0, 166, 167, 168, 169, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 264, 0, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 0, 0, 0, 0, 165, 0, - 0, 0, 0, 0, 166, 167, 168, 169, -3, 0, - 0, 12, 13, 14, 15, 16, 17, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 0, 34, 0, 35, 0, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 74, 75, 76, 77, 78, 0, + 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, + 12, 13, 14, 15, 16, 17, 0, 165, 0, 0, + 0, 0, 0, 166, 167, 168, 169, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 0, 73, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 74, 75, 76, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 79, 12, 13, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, @@ -1442,30 +1537,19 @@ static const yytype_int16 yytable[] = 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 74, 75, 76, 77, 78, 0, 0, 0, 0, - 0, 0, 0, 0, 79, 14, 15, 16, 17, 0, + 0, 74, 75, 76, 77, 0, 78, 0, 0, 0, + 0, 0, 0, 0, 0, 79, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 0, 0, 0, 80, 0, - 81, 0, 0, 0, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 0, 334, - 0, 0, 0, 0, 162, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 75, 76, 77, - 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, - 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, - 0, 0, 0, 80, 0, 81, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 0, 0, 0, 80, + 0, 81, 0, 0, 0, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, + 334, 0, 0, 0, 0, 162, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, - 76, 77, 0, 0, 0, 0, 0, 0, 0, 14, + 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, + 77, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, @@ -1474,63 +1558,133 @@ static const yytype_int16 yytable[] = 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 0, 0, 0, 0, 0, 0, 80, 0, + 81, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 80, 0, 81 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 80, 0, 81 }; static const yytype_int16 yycheck[] = { - 9, 79, 4, 152, 223, 154, 3, 4, 148, 94, - 140, 79, 251, 89, 90, 111, 165, 3, 4, 371, - 81, 9, 0, 160, 135, 162, 100, 116, 87, 88, - 135, 371, 165, 181, 36, 37, 38, 112, 35, 113, - 37, 9, 39, 180, 41, 42, 43, 74, 181, 35, - 402, 37, 374, 39, 79, 41, 42, 43, 163, 164, - 162, 165, 402, 385, 308, 165, 93, 115, 208, 161, - 410, 165, 412, 82, 79, 165, 224, 181, 180, 184, - 160, 181, 79, 322, 111, 94, 36, 181, 307, 179, - 40, 4, 160, 178, 82, 244, 315, 173, 174, 248, - 109, 231, 251, 162, 182, 164, 162, 165, 117, 106, - 259, 165, 223, 79, 82, 263, 256, 126, 223, 363, - 106, 179, 119, 36, 37, 38, 181, 182, 161, 138, - 278, 140, 165, 119, 378, 166, 167, 381, 182, 148, - 359, 79, 36, 37, 161, 389, 40, 161, 165, 116, - 299, 165, 300, 397, 161, 85, 86, 161, 165, 161, - 308, 165, 171, 161, 79, 161, 181, 165, 79, 165, - 107, 108, 109, 322, 161, 280, 281, 282, 283, 284, + 9, 79, 223, 152, 251, 154, 94, 4, 89, 90, + 79, 3, 4, 140, 192, 9, 165, 148, 9, 87, + 88, 371, 4, 195, 135, 100, 195, 112, 195, 81, + 135, 36, 210, 181, 74, 40, 0, 209, 113, 36, + 37, 38, 211, 35, 211, 37, 308, 39, 79, 41, + 42, 43, 402, 93, 36, 37, 38, 117, 163, 164, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 195, 111, 371, 82, 195, 322, 224, 208, 190, 184, + 192, 195, 374, 113, 209, 94, 307, 79, 82, 116, + 211, 82, 191, 385, 315, 244, 195, 211, 210, 248, + 109, 363, 251, 402, 231, 36, 37, 190, 117, 40, + 259, 410, 223, 412, 106, 263, 378, 126, 223, 381, + 208, 190, 203, 204, 192, 256, 194, 389, 120, 138, + 278, 140, 191, 191, 212, 397, 195, 195, 359, 148, + 191, 191, 191, 191, 195, 195, 195, 195, 211, 212, + 299, 195, 300, 287, 288, 289, 290, 107, 108, 109, + 308, 79, 171, 36, 37, 38, 200, 201, 202, 3, + 4, 196, 197, 322, 210, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 91, 92, 307, 283, 284, 208, - 291, 292, 307, 160, 315, 287, 288, 289, 290, 181, - 315, 220, 36, 37, 38, 363, 285, 286, 367, 170, - 171, 172, 231, 181, 160, 181, 160, 179, 376, 160, - 378, 160, 175, 381, 243, 384, 176, 93, 177, 181, - 95, 389, 251, 160, 79, 163, 162, 256, 359, 397, - 78, 161, 180, 162, 359, 404, 163, 160, 79, 165, - 161, 163, 160, 163, 163, 161, 180, 12, 180, 160, - 163, 12, 293, 181, 294, 180, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 180, 13, 14, 15, 16, + 295, 296, 297, 298, 191, 191, 307, 85, 86, 208, + 212, 35, 307, 37, 315, 39, 192, 41, 42, 43, + 315, 220, 91, 92, 79, 363, 283, 284, 367, 285, + 286, 79, 231, 79, 117, 79, 291, 292, 376, 190, + 378, 211, 211, 381, 243, 384, 211, 190, 211, 190, + 209, 389, 251, 190, 206, 191, 190, 256, 359, 397, + 205, 207, 93, 95, 359, 404, 190, 211, 79, 78, + 193, 210, 192, 191, 193, 192, 190, 79, 191, 195, + 190, 193, 106, 210, 193, 210, 193, 191, 193, 211, + 12, 190, 12, 260, 294, 293, 120, 212, 295, 210, + 296, 120, 127, 297, 210, 298, 239, 78, 211, 138, + 316, 243, 372, 385, 84, 171, 82, 243, 220, 220, + -1, 322, -1, 322, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 371, -1, -1, 374, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 385, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 402, -1, -1, -1, -1, -1, -1, + -1, 410, -1, 412, 3, 4, 5, 6, 7, 8, + 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, -1, 37, -1, + 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, + 109, -1, 111, -1, -1, -1, -1, -1, -1, -1, + -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 190, -1, -1, -1, -1, -1, 196, 197, 198, + 199, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 211, 212, 213, 3, 4, 5, 6, 7, + 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, -1, 37, + -1, 39, -1, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 82, 83, 84, -1, -1, 87, + 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 106, 107, + 108, 109, -1, 111, -1, -1, -1, -1, -1, -1, + -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 190, -1, -1, -1, -1, -1, 196, 197, + 198, 199, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 211, 212, 213, 3, 4, 5, 6, + 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 182, - 37, 181, 39, 322, 41, 42, 43, 44, 45, 46, + 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, + 37, -1, 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 81, 82, 83, 84, 220, 120, - 87, 88, 371, 295, 297, 374, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 385, 260, 298, 106, - 107, 108, 109, 110, 127, 239, 220, 78, 138, 316, - 243, 372, 119, 402, 385, 84, 171, 243, 322, 82, - -1, 410, -1, 412, 296, -1, -1, -1, -1, -1, + 77, 78, 79, 80, 81, 82, 83, 84, -1, -1, + 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, + 107, 108, 109, -1, 111, -1, -1, -1, -1, -1, + -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 153, -1, 155, -1, - -1, -1, -1, 160, -1, -1, -1, -1, -1, 166, - 167, 168, 169, -1, -1, -1, -1, -1, -1, -1, - 180, -1, -1, -1, 181, 182, 183, 3, 4, 5, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 190, -1, -1, -1, -1, -1, 196, + 197, 198, 199, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 211, 212, 213, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, @@ -1541,14 +1695,17 @@ static const yytype_int16 yycheck[] = 76, 77, 78, 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 106, 107, 108, 109, 110, -1, -1, -1, -1, -1, - -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, + 106, 107, 108, 109, -1, 111, -1, -1, -1, -1, + -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 154, -1, + 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 153, -1, 155, - -1, -1, -1, -1, 160, -1, -1, -1, -1, -1, - 166, 167, 168, 169, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 181, 182, 183, 3, 4, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 190, -1, -1, -1, -1, -1, + 196, 197, 198, 199, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 211, 212, 213, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, @@ -1559,225 +1716,213 @@ static const yytype_int16 yycheck[] = 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 106, 107, 108, 109, 110, -1, -1, -1, -1, - -1, -1, -1, -1, 119, -1, -1, -1, -1, -1, + -1, 106, 107, 108, 109, -1, 111, -1, -1, -1, + -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 153, -1, - 155, -1, -1, -1, -1, 160, -1, -1, -1, -1, - -1, 166, 167, 168, 169, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 181, 182, 183, 3, - 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, -1, 37, -1, 39, -1, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, + -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 106, 107, 108, 109, 110, -1, -1, -1, - -1, -1, -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 190, -1, -1, -1, -1, + -1, 196, 197, 198, 199, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 211, 212, 3, 4, + 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, -1, 37, -1, 39, -1, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 153, - -1, 155, -1, -1, -1, -1, 160, -1, -1, -1, - -1, -1, 166, 167, 168, 169, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 181, 182, 183, - 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, 106, 107, 108, 109, -1, 111, -1, -1, -1, + -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 106, 107, 108, 109, 110, -1, -1, - -1, -1, -1, -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, + -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 153, -1, 155, -1, -1, -1, -1, 160, -1, -1, - -1, -1, -1, 166, 167, 168, 169, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 181, 182, - 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 190, -1, -1, -1, -1, + -1, 196, 197, 198, 199, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 211, 212, 3, 4, + 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, -1, 37, -1, 39, -1, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 106, 107, 108, 109, 110, -1, -1, - -1, -1, -1, -1, -1, -1, 119, -1, -1, -1, + -1, 106, 107, 108, 109, -1, 111, -1, -1, -1, + -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, + -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 153, -1, 155, -1, -1, -1, -1, 160, -1, -1, - -1, -1, -1, 166, 167, 168, 169, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 181, 182, - 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 106, 107, 108, 109, 110, -1, -1, - -1, -1, -1, -1, -1, -1, 119, -1, -1, -1, + -1, -1, -1, -1, -1, 190, -1, -1, -1, -1, + -1, 196, 197, 198, 199, 3, 4, 5, 6, 7, + 8, -1, -1, -1, -1, -1, 211, 212, -1, -1, + -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, -1, 37, + -1, 39, -1, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + -1, 79, 80, 81, 82, 83, 84, -1, -1, 87, + 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 106, 107, + 108, 109, -1, 111, -1, -1, -1, -1, -1, -1, + -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 153, -1, 155, -1, -1, -1, -1, 160, -1, -1, - -1, -1, -1, 166, 167, 168, 169, 3, 4, 5, - 6, 7, 8, -1, -1, -1, -1, -1, 181, 182, - -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - -1, 37, -1, 39, -1, 41, 42, 43, 44, 45, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 190, -1, -1, -1, -1, -1, 196, 197, + 198, 199, 3, 4, 5, 6, 7, 8, -1, -1, + -1, -1, -1, 211, -1, -1, -1, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, -1, 37, -1, 39, -1, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, -1, 79, 80, + 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 106, 107, 108, 109, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 120, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 190, + -1, -1, -1, -1, -1, 196, 197, 198, 199, 5, + 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, + 211, -1, -1, -1, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, -1, 79, 80, 81, 82, 83, 84, -1, - -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, + 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 106, 107, 108, 109, 110, -1, -1, -1, -1, -1, - -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, + -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, -1, -1, -1, -1, -1, -1, 154, -1, + 156, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 153, -1, 155, - -1, -1, -1, -1, 160, -1, -1, -1, -1, -1, - 166, 167, 168, 169, 3, 4, 5, 6, 7, 8, - -1, -1, -1, -1, -1, 181, -1, -1, -1, -1, - -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, -1, 37, -1, - 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, - 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, + -1, -1, -1, -1, -1, -1, -1, 213, -1, -1, + -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, + -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, -1, -1, -1, -1, -1, + -1, 154, -1, 156, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, + 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, - 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 213, -1, -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 153, -1, 155, -1, -1, -1, - -1, 160, -1, -1, -1, -1, -1, 166, 167, 168, - 169, 5, 6, 7, 8, -1, -1, -1, -1, -1, - -1, -1, 181, -1, -1, -1, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, + -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 5, 6, 7, 8, -1, -1, -1, -1, 153, - -1, 155, -1, -1, -1, -1, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, -1, -1, -1, -1, -1, -1, -1, -1, 183, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, + 190, -1, -1, -1, -1, -1, 196, 197, 198, 199, + 3, 4, 5, 6, 7, 8, -1, -1, -1, -1, + -1, 211, -1, -1, -1, -1, -1, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 106, 107, 108, 109, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 5, 6, 7, 8, -1, -1, -1, -1, 153, - -1, 155, -1, -1, -1, -1, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, -1, -1, -1, -1, -1, -1, -1, -1, 183, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, -1, 79, 80, 81, 82, 83, - 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, + -1, -1, 5, 6, 7, 8, -1, 190, -1, -1, + -1, -1, -1, 196, 197, 198, 199, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 153, - -1, 155, -1, -1, -1, -1, 160, -1, -1, -1, - -1, -1, 166, 167, 168, 169, 3, 4, 5, 6, - 7, 8, -1, -1, -1, -1, -1, 181, -1, -1, - -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, - 37, -1, 39, -1, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, - 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, - 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 153, -1, 155, 5, - 6, 7, 8, 160, -1, -1, -1, -1, -1, 166, - 167, 168, 169, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, -1, 79, 80, 81, 82, 83, 84, -1, - -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, + -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 5, 6, 7, 8, -1, 190, -1, -1, + 193, -1, -1, 196, 197, 198, 199, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 153, -1, 155, - 5, 6, 7, 8, 160, -1, -1, 163, -1, -1, - 166, 167, 168, 169, -1, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, - -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 5, 6, 7, 8, -1, 190, -1, -1, + 193, -1, -1, 196, 197, 198, 199, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 153, -1, - 155, 5, 6, 7, 8, 160, -1, -1, 163, -1, - -1, 166, 167, 168, 169, -1, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, -1, 79, 80, 81, 82, 83, - 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 153, - -1, 155, 5, 6, 7, 8, 160, -1, -1, 163, - -1, -1, 166, 167, 168, 169, -1, 20, 21, 22, + -1, -1, 5, 6, 7, 8, -1, 190, -1, -1, + 193, -1, -1, 196, 197, 198, 199, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, @@ -1791,132 +1936,137 @@ static const yytype_int16 yycheck[] = -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 153, -1, 155, 5, 6, 7, 8, 160, -1, -1, - -1, -1, -1, 166, 167, 168, 169, -1, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, -1, 79, 80, 81, - 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, + -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 5, 6, 7, 8, -1, 190, -1, -1, + -1, -1, -1, 196, 197, 198, 199, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 153, -1, 155, -1, -1, -1, -1, 160, -1, - -1, -1, -1, -1, 166, 167, 168, 169, 0, -1, - -1, 3, 4, 5, 6, 7, 8, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, -1, 37, -1, 39, -1, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 106, 107, 108, 109, 110, -1, - -1, -1, -1, -1, -1, -1, -1, 119, 3, 4, + -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, + 3, 4, 5, 6, 7, 8, -1, 190, -1, -1, + -1, -1, -1, 196, 197, 198, 199, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 106, 107, 108, 109, -1, 111, -1, + -1, -1, -1, -1, -1, -1, -1, 120, 3, 4, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 153, 37, 155, 39, -1, 41, 42, 43, 44, + 35, 154, 37, 156, 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 106, 107, 108, 109, 110, -1, -1, -1, -1, - -1, -1, -1, -1, 119, 5, 6, 7, 8, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, -1, -1, -1, 153, -1, - 155, -1, -1, -1, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, - -1, -1, -1, -1, 84, -1, -1, -1, -1, -1, + -1, 106, 107, 108, 109, -1, 111, -1, -1, -1, + -1, -1, -1, -1, -1, 120, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 107, 108, 109, - -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, - 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, -1, -1, -1, - -1, -1, -1, 153, -1, 155, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, -1, -1, -1, 154, + -1, 156, -1, -1, -1, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, + 79, -1, -1, -1, -1, 84, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 107, - 108, 109, -1, -1, -1, -1, -1, -1, -1, 5, + -1, -1, -1, -1, -1, -1, -1, -1, 107, 108, + 109, -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, - -1, -1, -1, -1, -1, 153, -1, 155, 44, 45, + -1, -1, -1, -1, -1, 154, -1, 156, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, + -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, -1, -1, -1, -1, -1, -1, 154, -1, + 156, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 153, -1, 155 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 154, -1, 156 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { - 0, 111, 185, 187, 81, 0, 188, 116, 112, 186, - 189, 79, 3, 4, 5, 6, 7, 8, 20, 21, + 0, 112, 215, 217, 81, 0, 218, 117, 113, 216, + 219, 79, 3, 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 79, 106, 107, 108, 109, 110, 119, - 153, 155, 190, 220, 221, 222, 223, 224, 229, 230, - 231, 232, 233, 236, 238, 239, 240, 241, 242, 243, - 244, 245, 271, 272, 115, 36, 37, 40, 79, 182, - 79, 106, 238, 244, 160, 271, 181, 182, 258, 161, - 165, 4, 36, 37, 38, 226, 227, 237, 165, 181, - 79, 36, 40, 238, 240, 162, 241, 79, 182, 240, - 246, 247, 241, 79, 234, 235, 9, 10, 11, 13, + 75, 76, 77, 79, 106, 107, 108, 109, 111, 120, + 154, 156, 220, 250, 251, 252, 253, 254, 259, 260, + 261, 262, 263, 266, 268, 269, 270, 271, 272, 273, + 274, 275, 301, 302, 116, 36, 37, 40, 79, 212, + 79, 106, 268, 274, 190, 301, 211, 212, 288, 191, + 195, 4, 36, 37, 38, 256, 257, 267, 195, 211, + 79, 36, 40, 268, 270, 192, 271, 79, 212, 270, + 276, 277, 271, 79, 264, 265, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 78, 79, 80, 81, - 82, 83, 84, 87, 88, 160, 166, 167, 168, 169, - 181, 182, 183, 191, 192, 193, 195, 196, 197, 198, - 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, - 209, 210, 211, 212, 213, 214, 215, 216, 218, 220, - 221, 240, 251, 252, 253, 254, 255, 256, 259, 260, - 261, 262, 264, 265, 266, 270, 226, 225, 228, 240, - 227, 79, 160, 162, 180, 163, 202, 215, 219, 240, - 116, 246, 79, 248, 249, 183, 247, 181, 161, 165, - 181, 181, 252, 160, 160, 181, 181, 218, 160, 218, - 179, 160, 202, 202, 218, 183, 259, 87, 88, 162, - 164, 161, 161, 165, 77, 216, 160, 96, 97, 98, - 99, 100, 101, 102, 103, 104, 105, 180, 217, 202, - 170, 171, 172, 166, 167, 85, 86, 89, 90, 173, - 174, 91, 92, 175, 176, 177, 93, 95, 94, 178, - 165, 181, 183, 252, 79, 225, 228, 162, 180, 163, - 219, 216, 250, 163, 183, 162, 165, 181, 235, 78, - 251, 260, 267, 218, 181, 218, 179, 218, 231, 263, - 161, 183, 194, 218, 79, 197, 216, 216, 202, 202, - 202, 204, 204, 205, 205, 206, 206, 206, 206, 207, - 207, 208, 209, 210, 211, 212, 213, 218, 216, 162, - 163, 219, 250, 180, 163, 219, 249, 160, 263, 268, - 269, 161, 161, 79, 161, 163, 179, 219, 180, 163, - 250, 180, 163, 218, 181, 161, 253, 254, 256, 180, - 14, 255, 257, 258, 216, 163, 250, 180, 250, 161, - 218, 257, 12, 250, 160, 250, 181, 253, 254, 218, - 161, 253, 12 + 82, 83, 84, 87, 88, 190, 196, 197, 198, 199, + 211, 212, 213, 221, 222, 223, 225, 226, 227, 228, + 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, + 239, 240, 241, 242, 243, 244, 245, 246, 248, 250, + 251, 270, 281, 282, 283, 284, 285, 286, 289, 290, + 291, 292, 294, 295, 296, 300, 256, 255, 258, 270, + 257, 79, 190, 192, 210, 193, 232, 245, 249, 270, + 117, 276, 79, 278, 279, 213, 277, 211, 191, 195, + 211, 211, 282, 190, 190, 211, 211, 248, 190, 248, + 209, 190, 232, 232, 248, 213, 289, 87, 88, 192, + 194, 191, 191, 195, 77, 246, 190, 96, 97, 98, + 99, 100, 101, 102, 103, 104, 105, 210, 247, 232, + 200, 201, 202, 196, 197, 85, 86, 89, 90, 203, + 204, 91, 92, 205, 206, 207, 93, 95, 94, 208, + 195, 211, 213, 282, 79, 255, 258, 192, 210, 193, + 249, 246, 280, 193, 213, 192, 195, 211, 265, 78, + 281, 290, 297, 248, 211, 248, 209, 248, 261, 293, + 191, 213, 224, 248, 79, 227, 246, 246, 232, 232, + 232, 234, 234, 235, 235, 236, 236, 236, 236, 237, + 237, 238, 239, 240, 241, 242, 243, 248, 246, 192, + 193, 249, 280, 210, 193, 249, 279, 190, 293, 298, + 299, 191, 191, 79, 191, 193, 209, 249, 210, 193, + 280, 210, 193, 248, 211, 191, 283, 284, 286, 210, + 14, 285, 287, 288, 246, 193, 280, 210, 280, 191, + 248, 287, 12, 280, 190, 280, 211, 283, 284, 248, + 191, 283, 12 }; #define yyerrok (yyerrstatus = 0) @@ -1931,9 +2081,18 @@ static const yytype_uint16 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -1990,7 +2149,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -2579,7 +2738,7 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if YYLTYPE_IS_TRIVIAL +#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; @@ -2769,8 +2928,8 @@ yyreduce: { case 2: -/* Line 1455 of yacc.c */ -#line 193 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 200 "glsl_parser.ypp" { _mesa_glsl_initialize_types(state); ;} @@ -2778,8 +2937,8 @@ yyreduce: case 4: -/* Line 1455 of yacc.c */ -#line 201 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 208 "glsl_parser.ypp" { state->language_version = 110; ;} @@ -2787,8 +2946,8 @@ yyreduce: case 5: -/* Line 1455 of yacc.c */ -#line 205 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 212 "glsl_parser.ypp" { switch ((yyvsp[(2) - (3)].n)) { case 110: @@ -2807,8 +2966,8 @@ yyreduce: case 8: -/* Line 1455 of yacc.c */ -#line 228 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 235 "glsl_parser.ypp" { if (!_mesa_glsl_process_extension((yyvsp[(2) - (5)].identifier), & (yylsp[(2) - (5)]), (yyvsp[(4) - (5)].identifier), & (yylsp[(4) - (5)]), state)) { YYERROR; @@ -2818,8 +2977,8 @@ yyreduce: case 9: -/* Line 1455 of yacc.c */ -#line 237 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 244 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -2831,8 +2990,8 @@ yyreduce: case 10: -/* Line 1455 of yacc.c */ -#line 245 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 252 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -2844,8 +3003,8 @@ yyreduce: case 12: -/* Line 1455 of yacc.c */ -#line 260 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 267 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); @@ -2856,8 +3015,8 @@ yyreduce: case 13: -/* Line 1455 of yacc.c */ -#line 267 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 274 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); @@ -2868,8 +3027,8 @@ yyreduce: case 14: -/* Line 1455 of yacc.c */ -#line 274 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 281 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); @@ -2880,8 +3039,8 @@ yyreduce: case 15: -/* Line 1455 of yacc.c */ -#line 281 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 288 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); @@ -2892,8 +3051,8 @@ yyreduce: case 16: -/* Line 1455 of yacc.c */ -#line 288 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 295 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); @@ -2904,8 +3063,8 @@ yyreduce: case 17: -/* Line 1455 of yacc.c */ -#line 295 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 302 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(2) - (3)].expression); ;} @@ -2913,8 +3072,8 @@ yyreduce: case 19: -/* Line 1455 of yacc.c */ -#line 303 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 310 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_array_index, (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression), NULL); @@ -2924,8 +3083,8 @@ yyreduce: case 20: -/* Line 1455 of yacc.c */ -#line 309 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 316 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} @@ -2933,8 +3092,8 @@ yyreduce: case 21: -/* Line 1455 of yacc.c */ -#line 313 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 320 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), NULL, NULL); @@ -2945,8 +3104,8 @@ yyreduce: case 22: -/* Line 1455 of yacc.c */ -#line 320 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 327 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_inc, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -2956,8 +3115,8 @@ yyreduce: case 23: -/* Line 1455 of yacc.c */ -#line 326 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 333 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_dec, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -2967,8 +3126,8 @@ yyreduce: case 27: -/* Line 1455 of yacc.c */ -#line 344 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 351 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -2978,8 +3137,8 @@ yyreduce: case 32: -/* Line 1455 of yacc.c */ -#line 363 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 370 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (2)].expression); (yyval.expression)->set_location(yylloc); @@ -2989,8 +3148,8 @@ yyreduce: case 33: -/* Line 1455 of yacc.c */ -#line 369 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 376 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (3)].expression); (yyval.expression)->set_location(yylloc); @@ -3000,8 +3159,8 @@ yyreduce: case 35: -/* Line 1455 of yacc.c */ -#line 385 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 392 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_function_expression((yyvsp[(1) - (1)].type_specifier)); @@ -3011,8 +3170,8 @@ yyreduce: case 36: -/* Line 1455 of yacc.c */ -#line 391 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 398 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -3023,8 +3182,8 @@ yyreduce: case 37: -/* Line 1455 of yacc.c */ -#line 398 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 405 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -3035,8 +3194,8 @@ yyreduce: case 39: -/* Line 1455 of yacc.c */ -#line 410 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 417 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_inc, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3046,8 +3205,8 @@ yyreduce: case 40: -/* Line 1455 of yacc.c */ -#line 416 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 423 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_dec, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3057,8 +3216,8 @@ yyreduce: case 41: -/* Line 1455 of yacc.c */ -#line 422 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 429 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(1) - (2)].n), (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3068,36 +3227,36 @@ yyreduce: case 42: -/* Line 1455 of yacc.c */ -#line 431 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 438 "glsl_parser.ypp" { (yyval.n) = ast_plus; ;} break; case 43: -/* Line 1455 of yacc.c */ -#line 432 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 439 "glsl_parser.ypp" { (yyval.n) = ast_neg; ;} break; case 44: -/* Line 1455 of yacc.c */ -#line 433 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 440 "glsl_parser.ypp" { (yyval.n) = ast_logic_not; ;} break; case 45: -/* Line 1455 of yacc.c */ -#line 434 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 441 "glsl_parser.ypp" { (yyval.n) = ast_bit_not; ;} break; case 47: -/* Line 1455 of yacc.c */ -#line 440 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 447 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mul, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3107,8 +3266,8 @@ yyreduce: case 48: -/* Line 1455 of yacc.c */ -#line 446 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 453 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_div, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3118,8 +3277,8 @@ yyreduce: case 49: -/* Line 1455 of yacc.c */ -#line 452 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 459 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mod, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3129,8 +3288,8 @@ yyreduce: case 51: -/* Line 1455 of yacc.c */ -#line 462 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 469 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_add, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3140,8 +3299,8 @@ yyreduce: case 52: -/* Line 1455 of yacc.c */ -#line 468 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 475 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_sub, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3151,8 +3310,8 @@ yyreduce: case 54: -/* Line 1455 of yacc.c */ -#line 478 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 485 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3162,8 +3321,8 @@ yyreduce: case 55: -/* Line 1455 of yacc.c */ -#line 484 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 491 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_rshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3173,8 +3332,8 @@ yyreduce: case 57: -/* Line 1455 of yacc.c */ -#line 494 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 501 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_less, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3184,8 +3343,8 @@ yyreduce: case 58: -/* Line 1455 of yacc.c */ -#line 500 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 507 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_greater, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3195,8 +3354,8 @@ yyreduce: case 59: -/* Line 1455 of yacc.c */ -#line 506 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 513 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3206,8 +3365,8 @@ yyreduce: case 60: -/* Line 1455 of yacc.c */ -#line 512 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 519 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_gequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3217,8 +3376,8 @@ yyreduce: case 62: -/* Line 1455 of yacc.c */ -#line 522 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 529 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_equal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3228,8 +3387,8 @@ yyreduce: case 63: -/* Line 1455 of yacc.c */ -#line 528 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 535 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_nequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3239,8 +3398,8 @@ yyreduce: case 65: -/* Line 1455 of yacc.c */ -#line 538 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 545 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3250,8 +3409,8 @@ yyreduce: case 67: -/* Line 1455 of yacc.c */ -#line 548 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 555 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3261,8 +3420,8 @@ yyreduce: case 69: -/* Line 1455 of yacc.c */ -#line 558 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 565 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3272,8 +3431,8 @@ yyreduce: case 71: -/* Line 1455 of yacc.c */ -#line 568 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 575 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3283,8 +3442,8 @@ yyreduce: case 73: -/* Line 1455 of yacc.c */ -#line 578 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 585 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3294,8 +3453,8 @@ yyreduce: case 75: -/* Line 1455 of yacc.c */ -#line 588 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 595 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3305,8 +3464,8 @@ yyreduce: case 77: -/* Line 1455 of yacc.c */ -#line 598 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 605 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_conditional, (yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression)); @@ -3316,8 +3475,8 @@ yyreduce: case 79: -/* Line 1455 of yacc.c */ -#line 608 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 615 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(2) - (3)].n), (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -3327,85 +3486,85 @@ yyreduce: case 80: -/* Line 1455 of yacc.c */ -#line 616 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 623 "glsl_parser.ypp" { (yyval.n) = ast_assign; ;} break; case 81: -/* Line 1455 of yacc.c */ -#line 617 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 624 "glsl_parser.ypp" { (yyval.n) = ast_mul_assign; ;} break; case 82: -/* Line 1455 of yacc.c */ -#line 618 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 625 "glsl_parser.ypp" { (yyval.n) = ast_div_assign; ;} break; case 83: -/* Line 1455 of yacc.c */ -#line 619 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 626 "glsl_parser.ypp" { (yyval.n) = ast_mod_assign; ;} break; case 84: -/* Line 1455 of yacc.c */ -#line 620 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 627 "glsl_parser.ypp" { (yyval.n) = ast_add_assign; ;} break; case 85: -/* Line 1455 of yacc.c */ -#line 621 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 628 "glsl_parser.ypp" { (yyval.n) = ast_sub_assign; ;} break; case 86: -/* Line 1455 of yacc.c */ -#line 622 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 629 "glsl_parser.ypp" { (yyval.n) = ast_ls_assign; ;} break; case 87: -/* Line 1455 of yacc.c */ -#line 623 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 630 "glsl_parser.ypp" { (yyval.n) = ast_rs_assign; ;} break; case 88: -/* Line 1455 of yacc.c */ -#line 624 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 631 "glsl_parser.ypp" { (yyval.n) = ast_and_assign; ;} break; case 89: -/* Line 1455 of yacc.c */ -#line 625 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 632 "glsl_parser.ypp" { (yyval.n) = ast_xor_assign; ;} break; case 90: -/* Line 1455 of yacc.c */ -#line 626 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 633 "glsl_parser.ypp" { (yyval.n) = ast_or_assign; ;} break; case 91: -/* Line 1455 of yacc.c */ -#line 631 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 638 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} @@ -3413,8 +3572,8 @@ yyreduce: case 92: -/* Line 1455 of yacc.c */ -#line 635 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 642 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (3)].expression)->oper != ast_sequence) { @@ -3431,8 +3590,8 @@ yyreduce: case 94: -/* Line 1455 of yacc.c */ -#line 655 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 662 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].function); ;} @@ -3440,8 +3599,8 @@ yyreduce: case 95: -/* Line 1455 of yacc.c */ -#line 659 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 666 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].declarator_list); ;} @@ -3449,8 +3608,8 @@ yyreduce: case 96: -/* Line 1455 of yacc.c */ -#line 663 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 670 "glsl_parser.ypp" { if (((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_float) && ((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_int)) { @@ -3465,8 +3624,8 @@ yyreduce: case 100: -/* Line 1455 of yacc.c */ -#line 686 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 693 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (2)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(2) - (2)].parameter_declarator)->link); @@ -3475,8 +3634,8 @@ yyreduce: case 101: -/* Line 1455 of yacc.c */ -#line 691 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 698 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (3)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(3) - (3)].parameter_declarator)->link); @@ -3485,8 +3644,8 @@ yyreduce: case 102: -/* Line 1455 of yacc.c */ -#line 699 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 706 "glsl_parser.ypp" { void *ctx = state; (yyval.function) = new(ctx) ast_function(); @@ -3498,8 +3657,8 @@ yyreduce: case 103: -/* Line 1455 of yacc.c */ -#line 710 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 717 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3513,8 +3672,8 @@ yyreduce: case 104: -/* Line 1455 of yacc.c */ -#line 720 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 727 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3530,8 +3689,8 @@ yyreduce: case 105: -/* Line 1455 of yacc.c */ -#line 735 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 742 "glsl_parser.ypp" { (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; @@ -3542,8 +3701,8 @@ yyreduce: case 106: -/* Line 1455 of yacc.c */ -#line 742 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 749 "glsl_parser.ypp" { (yyval.parameter_declarator) = (yyvsp[(2) - (2)].parameter_declarator); (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier).q; @@ -3552,8 +3711,8 @@ yyreduce: case 107: -/* Line 1455 of yacc.c */ -#line 747 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 754 "glsl_parser.ypp" { void *ctx = state; (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; @@ -3568,8 +3727,8 @@ yyreduce: case 108: -/* Line 1455 of yacc.c */ -#line 758 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 765 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3582,36 +3741,36 @@ yyreduce: case 109: -/* Line 1455 of yacc.c */ -#line 769 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 776 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; ;} break; case 110: -/* Line 1455 of yacc.c */ -#line 770 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 777 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} break; case 111: -/* Line 1455 of yacc.c */ -#line 771 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 778 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} break; case 112: -/* Line 1455 of yacc.c */ -#line 772 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 779 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; (yyval.type_qualifier).q.out = 1; ;} break; case 115: -/* Line 1455 of yacc.c */ -#line 782 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 789 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (3)].identifier), false, NULL, NULL); @@ -3624,8 +3783,8 @@ yyreduce: case 116: -/* Line 1455 of yacc.c */ -#line 791 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 798 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), true, NULL, NULL); @@ -3638,8 +3797,8 @@ yyreduce: case 117: -/* Line 1455 of yacc.c */ -#line 800 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 807 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (6)].identifier), true, (yyvsp[(5) - (6)].expression), NULL); @@ -3652,8 +3811,8 @@ yyreduce: case 118: -/* Line 1455 of yacc.c */ -#line 809 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 816 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (7)].identifier), true, NULL, (yyvsp[(7) - (7)].expression)); @@ -3666,8 +3825,8 @@ yyreduce: case 119: -/* Line 1455 of yacc.c */ -#line 818 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 825 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (8)].identifier), true, (yyvsp[(5) - (8)].expression), (yyvsp[(8) - (8)].expression)); @@ -3680,8 +3839,8 @@ yyreduce: case 120: -/* Line 1455 of yacc.c */ -#line 827 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 834 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), false, NULL, (yyvsp[(5) - (5)].expression)); @@ -3694,8 +3853,8 @@ yyreduce: case 121: -/* Line 1455 of yacc.c */ -#line 840 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 847 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (1)].fully_specified_type)->specifier->type_specifier != ast_struct) { @@ -3710,8 +3869,8 @@ yyreduce: case 122: -/* Line 1455 of yacc.c */ -#line 851 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 858 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3724,8 +3883,8 @@ yyreduce: case 123: -/* Line 1455 of yacc.c */ -#line 860 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 867 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), true, NULL, NULL); @@ -3738,8 +3897,8 @@ yyreduce: case 124: -/* Line 1455 of yacc.c */ -#line 869 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 876 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (5)].identifier), true, (yyvsp[(4) - (5)].expression), NULL); @@ -3752,8 +3911,8 @@ yyreduce: case 125: -/* Line 1455 of yacc.c */ -#line 878 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 885 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (6)].identifier), true, NULL, (yyvsp[(6) - (6)].expression)); @@ -3766,8 +3925,8 @@ yyreduce: case 126: -/* Line 1455 of yacc.c */ -#line 887 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 894 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (7)].identifier), true, (yyvsp[(4) - (7)].expression), (yyvsp[(7) - (7)].expression)); @@ -3780,8 +3939,8 @@ yyreduce: case 127: -/* Line 1455 of yacc.c */ -#line 896 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 903 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -3794,8 +3953,8 @@ yyreduce: case 128: -/* Line 1455 of yacc.c */ -#line 905 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 912 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3810,8 +3969,8 @@ yyreduce: case 129: -/* Line 1455 of yacc.c */ -#line 919 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 926 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -3822,8 +3981,8 @@ yyreduce: case 130: -/* Line 1455 of yacc.c */ -#line 926 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 933 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -3835,15 +3994,15 @@ yyreduce: case 131: -/* Line 1455 of yacc.c */ -#line 936 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 943 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; ;} break; case 133: -/* Line 1455 of yacc.c */ -#line 942 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 949 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(3) - (4)].type_qualifier); ;} @@ -3851,8 +4010,8 @@ yyreduce: case 135: -/* Line 1455 of yacc.c */ -#line 950 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 957 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (3)].type_qualifier).i | (yyvsp[(3) - (3)].type_qualifier).i; ;} @@ -3860,8 +4019,8 @@ yyreduce: case 136: -/* Line 1455 of yacc.c */ -#line 957 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 964 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; @@ -3896,36 +4055,36 @@ yyreduce: case 137: -/* Line 1455 of yacc.c */ -#line 990 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 997 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.smooth = 1; ;} break; case 138: -/* Line 1455 of yacc.c */ -#line 991 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 998 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.flat = 1; ;} break; case 139: -/* Line 1455 of yacc.c */ -#line 992 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 999 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.noperspective = 1; ;} break; case 140: -/* Line 1455 of yacc.c */ -#line 996 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1003 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} break; case 142: -/* Line 1455 of yacc.c */ -#line 1002 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1009 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i | (yyvsp[(2) - (2)].type_qualifier).i; ;} @@ -3933,8 +4092,8 @@ yyreduce: case 143: -/* Line 1455 of yacc.c */ -#line 1006 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1013 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(2) - (2)].type_qualifier); (yyval.type_qualifier).q.invariant = 1; @@ -3943,71 +4102,71 @@ yyreduce: case 144: -/* Line 1455 of yacc.c */ -#line 1013 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1020 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} break; case 145: -/* Line 1455 of yacc.c */ -#line 1014 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1021 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.attribute = 1; ;} break; case 146: -/* Line 1455 of yacc.c */ -#line 1015 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1022 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i; (yyval.type_qualifier).q.varying = 1; ;} break; case 147: -/* Line 1455 of yacc.c */ -#line 1016 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1023 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.varying = 1; ;} break; case 148: -/* Line 1455 of yacc.c */ -#line 1017 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1024 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} break; case 149: -/* Line 1455 of yacc.c */ -#line 1018 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1025 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} break; case 150: -/* Line 1455 of yacc.c */ -#line 1019 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1026 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.in = 1; ;} break; case 151: -/* Line 1455 of yacc.c */ -#line 1020 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1027 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.out = 1; ;} break; case 152: -/* Line 1455 of yacc.c */ -#line 1021 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1028 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.uniform = 1; ;} break; case 154: -/* Line 1455 of yacc.c */ -#line 1027 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1034 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(2) - (2)].type_specifier); (yyval.type_specifier)->precision = (yyvsp[(1) - (2)].n); @@ -4016,8 +4175,8 @@ yyreduce: case 156: -/* Line 1455 of yacc.c */ -#line 1036 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1043 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (3)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -4027,8 +4186,8 @@ yyreduce: case 157: -/* Line 1455 of yacc.c */ -#line 1042 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1049 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (4)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -4038,8 +4197,8 @@ yyreduce: case 158: -/* Line 1455 of yacc.c */ -#line 1051 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1058 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].n)); @@ -4049,8 +4208,8 @@ yyreduce: case 159: -/* Line 1455 of yacc.c */ -#line 1057 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1064 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].struct_specifier)); @@ -4060,8 +4219,8 @@ yyreduce: case 160: -/* Line 1455 of yacc.c */ -#line 1063 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1070 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].identifier)); @@ -4071,386 +4230,386 @@ yyreduce: case 161: -/* Line 1455 of yacc.c */ -#line 1071 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1078 "glsl_parser.ypp" { (yyval.n) = ast_void; ;} break; case 162: -/* Line 1455 of yacc.c */ -#line 1072 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1079 "glsl_parser.ypp" { (yyval.n) = ast_float; ;} break; case 163: -/* Line 1455 of yacc.c */ -#line 1073 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1080 "glsl_parser.ypp" { (yyval.n) = ast_int; ;} break; case 164: -/* Line 1455 of yacc.c */ -#line 1074 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1081 "glsl_parser.ypp" { (yyval.n) = ast_uint; ;} break; case 165: -/* Line 1455 of yacc.c */ -#line 1075 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1082 "glsl_parser.ypp" { (yyval.n) = ast_bool; ;} break; case 166: -/* Line 1455 of yacc.c */ -#line 1076 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1083 "glsl_parser.ypp" { (yyval.n) = ast_vec2; ;} break; case 167: -/* Line 1455 of yacc.c */ -#line 1077 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1084 "glsl_parser.ypp" { (yyval.n) = ast_vec3; ;} break; case 168: -/* Line 1455 of yacc.c */ -#line 1078 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1085 "glsl_parser.ypp" { (yyval.n) = ast_vec4; ;} break; case 169: -/* Line 1455 of yacc.c */ -#line 1079 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1086 "glsl_parser.ypp" { (yyval.n) = ast_bvec2; ;} break; case 170: -/* Line 1455 of yacc.c */ -#line 1080 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1087 "glsl_parser.ypp" { (yyval.n) = ast_bvec3; ;} break; case 171: -/* Line 1455 of yacc.c */ -#line 1081 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1088 "glsl_parser.ypp" { (yyval.n) = ast_bvec4; ;} break; case 172: -/* Line 1455 of yacc.c */ -#line 1082 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1089 "glsl_parser.ypp" { (yyval.n) = ast_ivec2; ;} break; case 173: -/* Line 1455 of yacc.c */ -#line 1083 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1090 "glsl_parser.ypp" { (yyval.n) = ast_ivec3; ;} break; case 174: -/* Line 1455 of yacc.c */ -#line 1084 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1091 "glsl_parser.ypp" { (yyval.n) = ast_ivec4; ;} break; case 175: -/* Line 1455 of yacc.c */ -#line 1085 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1092 "glsl_parser.ypp" { (yyval.n) = ast_uvec2; ;} break; case 176: -/* Line 1455 of yacc.c */ -#line 1086 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1093 "glsl_parser.ypp" { (yyval.n) = ast_uvec3; ;} break; case 177: -/* Line 1455 of yacc.c */ -#line 1087 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1094 "glsl_parser.ypp" { (yyval.n) = ast_uvec4; ;} break; case 178: -/* Line 1455 of yacc.c */ -#line 1088 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1095 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; case 179: -/* Line 1455 of yacc.c */ -#line 1089 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1096 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; case 180: -/* Line 1455 of yacc.c */ -#line 1090 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1097 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; case 181: -/* Line 1455 of yacc.c */ -#line 1091 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1098 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; case 182: -/* Line 1455 of yacc.c */ -#line 1092 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1099 "glsl_parser.ypp" { (yyval.n) = ast_mat2x3; ;} break; case 183: -/* Line 1455 of yacc.c */ -#line 1093 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1100 "glsl_parser.ypp" { (yyval.n) = ast_mat2x4; ;} break; case 184: -/* Line 1455 of yacc.c */ -#line 1094 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1101 "glsl_parser.ypp" { (yyval.n) = ast_mat3x2; ;} break; case 185: -/* Line 1455 of yacc.c */ -#line 1095 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1102 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; case 186: -/* Line 1455 of yacc.c */ -#line 1096 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1103 "glsl_parser.ypp" { (yyval.n) = ast_mat3x4; ;} break; case 187: -/* Line 1455 of yacc.c */ -#line 1097 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1104 "glsl_parser.ypp" { (yyval.n) = ast_mat4x2; ;} break; case 188: -/* Line 1455 of yacc.c */ -#line 1098 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1105 "glsl_parser.ypp" { (yyval.n) = ast_mat4x3; ;} break; case 189: -/* Line 1455 of yacc.c */ -#line 1099 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1106 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; case 190: -/* Line 1455 of yacc.c */ -#line 1100 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1107 "glsl_parser.ypp" { (yyval.n) = ast_sampler1d; ;} break; case 191: -/* Line 1455 of yacc.c */ -#line 1101 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1108 "glsl_parser.ypp" { (yyval.n) = ast_sampler2d; ;} break; case 192: -/* Line 1455 of yacc.c */ -#line 1102 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1109 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drect; ;} break; case 193: -/* Line 1455 of yacc.c */ -#line 1103 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1110 "glsl_parser.ypp" { (yyval.n) = ast_sampler3d; ;} break; case 194: -/* Line 1455 of yacc.c */ -#line 1104 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1111 "glsl_parser.ypp" { (yyval.n) = ast_samplercube; ;} break; case 195: -/* Line 1455 of yacc.c */ -#line 1105 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1112 "glsl_parser.ypp" { (yyval.n) = ast_sampler1dshadow; ;} break; case 196: -/* Line 1455 of yacc.c */ -#line 1106 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1113 "glsl_parser.ypp" { (yyval.n) = ast_sampler2dshadow; ;} break; case 197: -/* Line 1455 of yacc.c */ -#line 1107 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1114 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drectshadow; ;} break; case 198: -/* Line 1455 of yacc.c */ -#line 1108 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1115 "glsl_parser.ypp" { (yyval.n) = ast_samplercubeshadow; ;} break; case 199: -/* Line 1455 of yacc.c */ -#line 1109 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1116 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darray; ;} break; case 200: -/* Line 1455 of yacc.c */ -#line 1110 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1117 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darray; ;} break; case 201: -/* Line 1455 of yacc.c */ -#line 1111 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1118 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darrayshadow; ;} break; case 202: -/* Line 1455 of yacc.c */ -#line 1112 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1119 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darrayshadow; ;} break; case 203: -/* Line 1455 of yacc.c */ -#line 1113 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1120 "glsl_parser.ypp" { (yyval.n) = ast_isampler1d; ;} break; case 204: -/* Line 1455 of yacc.c */ -#line 1114 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1121 "glsl_parser.ypp" { (yyval.n) = ast_isampler2d; ;} break; case 205: -/* Line 1455 of yacc.c */ -#line 1115 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1122 "glsl_parser.ypp" { (yyval.n) = ast_isampler3d; ;} break; case 206: -/* Line 1455 of yacc.c */ -#line 1116 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1123 "glsl_parser.ypp" { (yyval.n) = ast_isamplercube; ;} break; case 207: -/* Line 1455 of yacc.c */ -#line 1117 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1124 "glsl_parser.ypp" { (yyval.n) = ast_isampler1darray; ;} break; case 208: -/* Line 1455 of yacc.c */ -#line 1118 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1125 "glsl_parser.ypp" { (yyval.n) = ast_isampler2darray; ;} break; case 209: -/* Line 1455 of yacc.c */ -#line 1119 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1126 "glsl_parser.ypp" { (yyval.n) = ast_usampler1d; ;} break; case 210: -/* Line 1455 of yacc.c */ -#line 1120 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1127 "glsl_parser.ypp" { (yyval.n) = ast_usampler2d; ;} break; case 211: -/* Line 1455 of yacc.c */ -#line 1121 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1128 "glsl_parser.ypp" { (yyval.n) = ast_usampler3d; ;} break; case 212: -/* Line 1455 of yacc.c */ -#line 1122 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1129 "glsl_parser.ypp" { (yyval.n) = ast_usamplercube; ;} break; case 213: -/* Line 1455 of yacc.c */ -#line 1123 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1130 "glsl_parser.ypp" { (yyval.n) = ast_usampler1darray; ;} break; case 214: -/* Line 1455 of yacc.c */ -#line 1124 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1131 "glsl_parser.ypp" { (yyval.n) = ast_usampler2darray; ;} break; case 215: -/* Line 1455 of yacc.c */ -#line 1128 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1135 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4466,8 +4625,8 @@ yyreduce: case 216: -/* Line 1455 of yacc.c */ -#line 1139 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1146 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4483,8 +4642,8 @@ yyreduce: case 217: -/* Line 1455 of yacc.c */ -#line 1150 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1157 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4500,8 +4659,8 @@ yyreduce: case 218: -/* Line 1455 of yacc.c */ -#line 1165 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1172 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node)); @@ -4511,8 +4670,8 @@ yyreduce: case 219: -/* Line 1455 of yacc.c */ -#line 1171 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1178 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node)); @@ -4522,8 +4681,8 @@ yyreduce: case 220: -/* Line 1455 of yacc.c */ -#line 1180 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1187 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].declarator_list); (yyvsp[(1) - (1)].declarator_list)->link.self_link(); @@ -4532,8 +4691,8 @@ yyreduce: case 221: -/* Line 1455 of yacc.c */ -#line 1185 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1192 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (2)].node); (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); @@ -4542,8 +4701,8 @@ yyreduce: case 222: -/* Line 1455 of yacc.c */ -#line 1193 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1200 "glsl_parser.ypp" { void *ctx = state; ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); @@ -4559,8 +4718,8 @@ yyreduce: case 223: -/* Line 1455 of yacc.c */ -#line 1208 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1215 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (1)].declaration); (yyvsp[(1) - (1)].declaration)->link.self_link(); @@ -4569,8 +4728,8 @@ yyreduce: case 224: -/* Line 1455 of yacc.c */ -#line 1213 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1220 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (3)].declaration); (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link); @@ -4579,8 +4738,8 @@ yyreduce: case 225: -/* Line 1455 of yacc.c */ -#line 1221 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1228 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL); @@ -4590,8 +4749,8 @@ yyreduce: case 226: -/* Line 1455 of yacc.c */ -#line 1227 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1234 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL); @@ -4601,29 +4760,29 @@ yyreduce: case 231: -/* Line 1455 of yacc.c */ -#line 1250 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1257 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 237: -/* Line 1455 of yacc.c */ -#line 1262 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1269 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; case 238: -/* Line 1455 of yacc.c */ -#line 1263 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1270 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; case 241: -/* Line 1455 of yacc.c */ -#line 1270 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1277 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL); @@ -4633,8 +4792,8 @@ yyreduce: case 242: -/* Line 1455 of yacc.c */ -#line 1276 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1283 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(2) - (3)].node)); @@ -4644,15 +4803,15 @@ yyreduce: case 243: -/* Line 1455 of yacc.c */ -#line 1284 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1291 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 245: -/* Line 1455 of yacc.c */ -#line 1290 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1297 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL); @@ -4662,8 +4821,8 @@ yyreduce: case 246: -/* Line 1455 of yacc.c */ -#line 1296 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1303 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node)); @@ -4673,8 +4832,8 @@ yyreduce: case 247: -/* Line 1455 of yacc.c */ -#line 1305 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1312 "glsl_parser.ypp" { if ((yyvsp[(1) - (1)].node) == NULL) { _mesa_glsl_error(& (yylsp[(1) - (1)]), state, " statement\n"); @@ -4688,8 +4847,8 @@ yyreduce: case 248: -/* Line 1455 of yacc.c */ -#line 1315 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1322 "glsl_parser.ypp" { if ((yyvsp[(2) - (2)].node) == NULL) { _mesa_glsl_error(& (yylsp[(2) - (2)]), state, " statement\n"); @@ -4702,8 +4861,8 @@ yyreduce: case 249: -/* Line 1455 of yacc.c */ -#line 1327 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1334 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement(NULL); @@ -4713,8 +4872,8 @@ yyreduce: case 250: -/* Line 1455 of yacc.c */ -#line 1333 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1340 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression)); @@ -4724,8 +4883,8 @@ yyreduce: case 251: -/* Line 1455 of yacc.c */ -#line 1342 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1349 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4735,8 +4894,8 @@ yyreduce: case 252: -/* Line 1455 of yacc.c */ -#line 1351 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1358 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4746,8 +4905,8 @@ yyreduce: case 253: -/* Line 1455 of yacc.c */ -#line 1357 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1364 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4757,8 +4916,8 @@ yyreduce: case 254: -/* Line 1455 of yacc.c */ -#line 1363 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1370 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4768,8 +4927,8 @@ yyreduce: case 255: -/* Line 1455 of yacc.c */ -#line 1372 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1379 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].expression); ;} @@ -4777,8 +4936,8 @@ yyreduce: case 256: -/* Line 1455 of yacc.c */ -#line 1376 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1383 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -4793,8 +4952,8 @@ yyreduce: case 260: -/* Line 1455 of yacc.c */ -#line 1399 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1406 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, @@ -4805,8 +4964,8 @@ yyreduce: case 261: -/* Line 1455 of yacc.c */ -#line 1406 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1413 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, @@ -4817,8 +4976,8 @@ yyreduce: case 262: -/* Line 1455 of yacc.c */ -#line 1413 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1420 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, @@ -4829,8 +4988,8 @@ yyreduce: case 266: -/* Line 1455 of yacc.c */ -#line 1429 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1436 "glsl_parser.ypp" { (yyval.node) = NULL; ;} @@ -4838,8 +4997,8 @@ yyreduce: case 267: -/* Line 1455 of yacc.c */ -#line 1436 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1443 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node); (yyval.for_rest_statement).rest = NULL; @@ -4848,8 +5007,8 @@ yyreduce: case 268: -/* Line 1455 of yacc.c */ -#line 1441 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1448 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node); (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression); @@ -4858,8 +5017,8 @@ yyreduce: case 269: -/* Line 1455 of yacc.c */ -#line 1450 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1457 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); @@ -4869,8 +5028,8 @@ yyreduce: case 270: -/* Line 1455 of yacc.c */ -#line 1456 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1463 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); @@ -4880,8 +5039,8 @@ yyreduce: case 271: -/* Line 1455 of yacc.c */ -#line 1462 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1469 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); @@ -4891,8 +5050,8 @@ yyreduce: case 272: -/* Line 1455 of yacc.c */ -#line 1468 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1475 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression)); @@ -4902,8 +5061,8 @@ yyreduce: case 273: -/* Line 1455 of yacc.c */ -#line 1474 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1481 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); @@ -4913,22 +5072,22 @@ yyreduce: case 274: -/* Line 1455 of yacc.c */ -#line 1482 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1489 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;} break; case 275: -/* Line 1455 of yacc.c */ -#line 1483 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1490 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); ;} break; case 276: -/* Line 1455 of yacc.c */ -#line 1488 "glsl_parser.ypp" +/* Line 1464 of yacc.c */ +#line 1495 "glsl_parser.ypp" { void *ctx = state; (yyval.function_definition) = new(ctx) ast_function_definition(); @@ -4940,8 +5099,8 @@ yyreduce: -/* Line 1455 of yacc.c */ -#line 4945 "glsl_parser.cpp" +/* Line 1464 of yacc.c */ +#line 5104 "glsl_parser.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h index 9c4e12fd7ef..367b46f49e5 100644 --- a/src/glsl/glsl_parser.h +++ b/src/glsl/glsl_parser.h @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -146,56 +145,86 @@ LOWP = 362, MEDIUMP = 363, HIGHP = 364, - PRECISION = 365, - VERSION = 366, - EXTENSION = 367, - LINE = 368, - PRAGMA = 369, - COLON = 370, - EOL = 371, - INTERFACE = 372, - OUTPUT = 373, - LAYOUT_TOK = 374, - ASM = 375, - CLASS = 376, - UNION = 377, - ENUM = 378, - TYPEDEF = 379, - TEMPLATE = 380, - THIS = 381, - PACKED = 382, - GOTO = 383, - INLINE_TOK = 384, - NOINLINE = 385, - VOLATILE = 386, - PUBLIC_TOK = 387, - STATIC = 388, - EXTERN = 389, - EXTERNAL = 390, - LONG = 391, - SHORT = 392, - DOUBLE = 393, - HALF = 394, - FIXED = 395, - UNSIGNED = 396, - INPUT = 397, - OUPTUT = 398, - HVEC2 = 399, - HVEC3 = 400, - HVEC4 = 401, - DVEC2 = 402, - DVEC3 = 403, - DVEC4 = 404, - FVEC2 = 405, - FVEC3 = 406, - FVEC4 = 407, - SAMPLER2DRECT = 408, - SAMPLER3DRECT = 409, - SAMPLER2DRECTSHADOW = 410, - SIZEOF = 411, - CAST = 412, - NAMESPACE = 413, - USING = 414 + SUPERP = 365, + PRECISION = 366, + VERSION = 367, + EXTENSION = 368, + LINE = 369, + PRAGMA = 370, + COLON = 371, + EOL = 372, + INTERFACE = 373, + OUTPUT = 374, + LAYOUT_TOK = 375, + ASM = 376, + CLASS = 377, + UNION = 378, + ENUM = 379, + TYPEDEF = 380, + TEMPLATE = 381, + THIS = 382, + PACKED = 383, + GOTO = 384, + INLINE_TOK = 385, + NOINLINE = 386, + VOLATILE = 387, + PUBLIC_TOK = 388, + STATIC = 389, + EXTERN = 390, + EXTERNAL = 391, + LONG = 392, + SHORT = 393, + DOUBLE = 394, + HALF = 395, + FIXED = 396, + UNSIGNED = 397, + INPUT = 398, + OUPTUT = 399, + HVEC2 = 400, + HVEC3 = 401, + HVEC4 = 402, + DVEC2 = 403, + DVEC3 = 404, + DVEC4 = 405, + FVEC2 = 406, + FVEC3 = 407, + FVEC4 = 408, + SAMPLER2DRECT = 409, + SAMPLER3DRECT = 410, + SAMPLER2DRECTSHADOW = 411, + SIZEOF = 412, + CAST = 413, + NAMESPACE = 414, + USING = 415, + COMMON = 416, + PARTITION = 417, + ACTIVE = 418, + SAMPLERBUFFER = 419, + FILTER = 420, + IMAGE1D = 421, + IMAGE2D = 422, + IMAGE3D = 423, + IMAGECUBE = 424, + IMAGE1DARRAY = 425, + IMAGE2DARRAY = 426, + IIMAGE1D = 427, + IIMAGE2D = 428, + IIMAGE3D = 429, + IIMAGECUBE = 430, + IIMAGE1DARRAY = 431, + IIMAGE2DARRAY = 432, + UIMAGE1D = 433, + UIMAGE2D = 434, + UIMAGE3D = 435, + UIMAGECUBE = 436, + UIMAGE1DARRAY = 437, + UIMAGE2DARRAY = 438, + IMAGE1DSHADOW = 439, + IMAGE2DSHADOW = 440, + IMAGEBUFFER = 441, + IIMAGEBUFFER = 442, + UIMAGEBUFFER = 443, + ROW_MAJOR = 444 }; #endif @@ -205,7 +234,7 @@ typedef union YYSTYPE { -/* Line 1676 of yacc.c */ +/* Line 1685 of yacc.c */ #line 45 "glsl_parser.ypp" int n; @@ -236,8 +265,8 @@ typedef union YYSTYPE -/* Line 1676 of yacc.c */ -#line 241 "glsl_parser.h" +/* Line 1685 of yacc.c */ +#line 270 "glsl_parser.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 7cabefbd34f..493b74fb692 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -94,7 +94,7 @@ %token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN %token SUB_ASSIGN %token INVARIANT -%token LOWP MEDIUMP HIGHP PRECISION +%token LOWP MEDIUMP HIGHP SUPERP PRECISION %token VERSION EXTENSION LINE PRAGMA COLON EOL INTERFACE OUTPUT %token LAYOUT_TOK @@ -108,6 +108,13 @@ %token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW %token SIZEOF CAST NAMESPACE USING +%token COMMON PARTITION ACTIVE SAMPLERBUFFER FILTER +%token IMAGE1D IMAGE2D IMAGE3D IMAGECUBE IMAGE1DARRAY IMAGE2DARRAY +%token IIMAGE1D IIMAGE2D IIMAGE3D IIMAGECUBE IIMAGE1DARRAY IIMAGE2DARRAY +%token UIMAGE1D UIMAGE2D UIMAGE3D UIMAGECUBE UIMAGE1DARRAY UIMAGE2DARRAY +%token IMAGE1DSHADOW IMAGE2DSHADOW IMAGEBUFFER IIMAGEBUFFER UIMAGEBUFFER +%token ROW_MAJOR + %type variable_identifier %type statement %type statement_list -- cgit v1.2.3 From f8d2cfe4a699faebd42bd1874ef0329d37791dd7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 8 Aug 2010 23:29:54 -0700 Subject: glsl2: Handle plain variable copies in struct splitting. glsl-fs-raytrace goes from 620 Mesa IR instructions out of the compiler to 585. --- src/glsl/ir_structure_splitting.cpp | 54 ++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/glsl/ir_structure_splitting.cpp b/src/glsl/ir_structure_splitting.cpp index 902eeadb2a4..f9931670bdf 100644 --- a/src/glsl/ir_structure_splitting.cpp +++ b/src/glsl/ir_structure_splitting.cpp @@ -80,7 +80,7 @@ public: virtual ir_visitor_status visit(ir_variable *); virtual ir_visitor_status visit(ir_dereference_variable *); virtual ir_visitor_status visit_enter(ir_dereference_record *); - + virtual ir_visitor_status visit_enter(ir_assignment *); virtual ir_visitor_status visit_enter(ir_function_signature *); variable_entry *get_variable_entry(ir_variable *var); @@ -141,6 +141,19 @@ ir_structure_reference_visitor::visit_enter(ir_dereference_record *ir) return visit_continue_with_parent; } +ir_visitor_status +ir_structure_reference_visitor::visit_enter(ir_assignment *ir) +{ + if (ir->lhs->as_dereference_variable() && + ir->rhs->as_dereference_variable() && + !ir->condition) { + /* We'll split copies of a structure to copies of components, so don't + * descend to the ir_dereference_variables. + */ + return visit_continue_with_parent; + } +} + ir_visitor_status ir_structure_reference_visitor::visit_enter(ir_function_signature *ir) { @@ -302,9 +315,44 @@ ir_structure_splitting_visitor::visit_leave(ir_dereference_record *ir) ir_visitor_status ir_structure_splitting_visitor::visit_leave(ir_assignment *ir) { - split_rvalue(&ir->rhs); + ir_dereference_variable *lhs_deref = ir->lhs->as_dereference_variable(); + ir_dereference_variable *rhs_deref = ir->rhs->as_dereference_variable(); + variable_entry *lhs_entry = lhs_deref ? get_splitting_entry(lhs_deref->var) : NULL; + variable_entry *rhs_entry = rhs_deref ? get_splitting_entry(rhs_deref->var) : NULL; + const glsl_type *type = ir->rhs->type; + + if ((lhs_entry || rhs_entry) && !ir->condition) { + for (unsigned int i = 0; i < type->length; i++) { + ir_dereference *new_lhs, *new_rhs; + void *mem_ctx = lhs_entry ? lhs_entry->mem_ctx : rhs_entry->mem_ctx; + + if (lhs_entry) { + new_lhs = new(mem_ctx) ir_dereference_variable(lhs_entry->components[i]); + } else { + new_lhs = new(mem_ctx) + ir_dereference_record(ir->lhs->clone(mem_ctx, NULL), + type->fields.structure[i].name); + } + + if (rhs_entry) { + new_rhs = new(mem_ctx) ir_dereference_variable(rhs_entry->components[i]); + } else { + new_rhs = new(mem_ctx) + ir_dereference_record(ir->rhs->clone(mem_ctx, NULL), + type->fields.structure[i].name); + } + + ir->insert_before(new(mem_ctx) ir_assignment(new_lhs, + new_rhs, + NULL)); + } + ir->remove(); + } else { + split_rvalue(&ir->rhs); + split_deref(&ir->lhs); + } + split_rvalue(&ir->condition); - split_deref(&ir->lhs); return visit_continue; } -- cgit v1.2.3 From 5023edaf5d037c9b71f1795ac4b890f175507576 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Mon, 9 Aug 2010 11:50:24 +0300 Subject: glsl: fix missing return in ir_structure_splitting --- src/glsl/ir_structure_splitting.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/ir_structure_splitting.cpp b/src/glsl/ir_structure_splitting.cpp index f9931670bdf..9dc59412073 100644 --- a/src/glsl/ir_structure_splitting.cpp +++ b/src/glsl/ir_structure_splitting.cpp @@ -152,6 +152,7 @@ ir_structure_reference_visitor::visit_enter(ir_assignment *ir) */ return visit_continue_with_parent; } + return visit_continue; } ir_visitor_status -- cgit v1.2.3 From 3adce986c498539d9a5d8db95926e66e1315da03 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Mon, 9 Aug 2010 11:17:32 +0300 Subject: glsl2: do not use __retval name; two underscores is reserved word according to GLSL spec (and Win7 ATI drivers do complain about that) --- src/glsl/glsl_types.cpp | 8 ++++---- src/glsl/ir_function_inlining.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 03f84603b55..9b1bef6cb85 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -267,11 +267,11 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const } /* Generate the body of the constructor. The body assigns each of the - * parameters to a portion of a local variable called __retval that has - * the same type as the constructor. After initializing __retval, - * __retval is returned. + * parameters to a portion of a local variable called _ret_val that has + * the same type as the constructor. After initializing _ret_val, + * _ret_val is returned. */ - ir_variable *retval = new(ctx) ir_variable(this, "__retval", ir_var_auto); + ir_variable *retval = new(ctx) ir_variable(this, "_ret_val", ir_var_auto); sig->body.push_tail(retval); for (unsigned i = 0; i < length; i++) { diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index fd52d106b1b..874602c84f2 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -127,7 +127,7 @@ ir_call::generate_inline(ir_instruction *next_ir) /* Generate storage for the return value. */ if (this->callee->return_type) { - retval = new(ctx) ir_variable(this->callee->return_type, "__retval", + retval = new(ctx) ir_variable(this->callee->return_type, "_ret_val", ir_var_auto); next_ir->insert_before(retval); } -- cgit v1.2.3 From fe277089c7a9bb402ef40d89f641b69fb508f2dc Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 9 Aug 2010 09:54:47 -0700 Subject: ir_algebraic: Convert ir_unop_logic_not handler to use a switch statement Currently only ir_binop_equal and ir_binop_nequal are supported, but soon all of the relational operators will be added. Making this change now will simplify those commits. --- src/glsl/ir_algebraic.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/glsl/ir_algebraic.cpp b/src/glsl/ir_algebraic.cpp index a6ecad7b659..d9e7b680f7d 100644 --- a/src/glsl/ir_algebraic.cpp +++ b/src/glsl/ir_algebraic.cpp @@ -161,22 +161,32 @@ ir_algebraic_visitor::handle_expression(ir_rvalue *in_ir) } switch (ir->operation) { - case ir_unop_logic_not: - if (op_expr[0] && op_expr[0]->operation == ir_binop_equal) { - this->progress = true; - return new(ir) ir_expression(ir_binop_nequal, - ir->type, - op_expr[0]->operands[0], - op_expr[0]->operands[1]); + case ir_unop_logic_not: { + enum ir_expression_operation new_op = ir_unop_logic_not; + + if (op_expr[0] == NULL) + break; + + switch (op_expr[0]->operation) { + case ir_binop_equal: new_op = ir_binop_nequal; break; + case ir_binop_nequal: new_op = ir_binop_equal; break; + + default: + /* The default case handler is here to silence a warning from GCC. + */ + break; } - if (op_expr[0] && op_expr[0]->operation == ir_binop_nequal) { + + if (new_op != ir_unop_logic_not) { this->progress = true; - return new(ir) ir_expression(ir_binop_equal, + return new(ir) ir_expression(new_op, ir->type, op_expr[0]->operands[0], op_expr[0]->operands[1]); } + break; + } case ir_binop_add: if (is_vec_zero(op_const[0])) { -- cgit v1.2.3 From c88e60a27b8d5675cbf488e754537739c2c40bfd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 9 Aug 2010 10:46:38 -0700 Subject: ir_algebraic: Support other comparisons in ir_unop_logic_not --- src/glsl/ir_algebraic.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/glsl/ir_algebraic.cpp b/src/glsl/ir_algebraic.cpp index d9e7b680f7d..43d8f9e699c 100644 --- a/src/glsl/ir_algebraic.cpp +++ b/src/glsl/ir_algebraic.cpp @@ -168,6 +168,10 @@ ir_algebraic_visitor::handle_expression(ir_rvalue *in_ir) break; switch (op_expr[0]->operation) { + case ir_binop_less: new_op = ir_binop_gequal; break; + case ir_binop_greater: new_op = ir_binop_lequal; break; + case ir_binop_lequal: new_op = ir_binop_greater; break; + case ir_binop_gequal: new_op = ir_binop_less; break; case ir_binop_equal: new_op = ir_binop_nequal; break; case ir_binop_nequal: new_op = ir_binop_equal; break; -- cgit v1.2.3 From dbff7b541e4be26cc9363956af8595ec052c4e56 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 7 Aug 2010 02:28:40 -0700 Subject: glsl2: Use gl_DepthRange's proper name. It was being incorrectly added as gl_DepthRangeParameters, which is the type name, not the variable name. --- src/glsl/ir_variable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index d9a16d42879..d88cb515b47 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -141,7 +141,7 @@ generate_110_uniforms(exec_list *instructions, add_uniform(instructions, state, "gl_TextureMatrix", mat4_array_type); - add_uniform(instructions, state, "gl_DepthRangeParameters", + add_uniform(instructions, state, "gl_DepthRange", state->symbols->get_type("gl_DepthRangeParameters")); add_uniform(instructions, state, "gl_ClipPlane", -- cgit v1.2.3 From 2eed82ebc0435da40dd5b588efc9bef0946e8497 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 7 Aug 2010 01:11:43 -0700 Subject: texture_builtins.py: Fix cut and paste errors in function names. Some signatures were being generated with the wrong function name. --- src/glsl/builtins/130/textureProjGrad | 2 +- src/glsl/builtins/130/textureProjLod | 2 +- src/glsl/builtins/tools/texture_builtins.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/builtins/130/textureProjGrad b/src/glsl/builtins/130/textureProjGrad index a0142c5e683..b4bfa58c123 100644 --- a/src/glsl/builtins/130/textureProjGrad +++ b/src/glsl/builtins/130/textureProjGrad @@ -1,4 +1,4 @@ -((function textureLod +((function textureProjGrad (signature vec4 (parameters (declare (in) sampler1D sampler) diff --git a/src/glsl/builtins/130/textureProjLod b/src/glsl/builtins/130/textureProjLod index 9f4ce1b493d..d242f7e40fc 100644 --- a/src/glsl/builtins/130/textureProjLod +++ b/src/glsl/builtins/130/textureProjLod @@ -1,4 +1,4 @@ -((function textureLod +((function textureProjLod (signature vec4 (parameters (declare (in) sampler1D sampler) diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py index 23d53149161..c4672ae8c12 100755 --- a/src/glsl/builtins/tools/texture_builtins.py +++ b/src/glsl/builtins/tools/texture_builtins.py @@ -156,7 +156,7 @@ with open(path.join(builtins_dir, "130", "texelFetch"), 'w') as sys.stdout: print "))" with open(path.join(builtins_dir, "130", "textureProjLod"), 'w') as sys.stdout: - print "((function textureLod" + print "((function textureProjLod" generate_fiu_sigs("txl", "1D", True) generate_fiu_sigs("txl", "1D", True, 2) generate_fiu_sigs("txl", "2D", True) @@ -175,7 +175,7 @@ with open(path.join(builtins_dir, "130", "textureGrad"), 'w') as sys.stdout: print ")\n)" with open(path.join(builtins_dir, "130", "textureProjGrad"), 'w') as sys.stdout: - print "((function textureLod" + print "((function textureProjGrad" generate_fiu_sigs("txd", "1D", True) generate_fiu_sigs("txd", "1D", True, 2) generate_fiu_sigs("txd", "2D", True) -- cgit v1.2.3 From 8aa7dbacaf61cb4dd9a436a66c138cb865d7406c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 9 Aug 2010 12:45:25 -0700 Subject: glsl2: Refresh autogenerated file builtin_function.cpp. --- src/glsl/builtin_function.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index a8acff47315..12e6909a287 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -4164,7 +4164,7 @@ static const char *builtins_130_textureProj = { }; static const char *builtins_130_textureProjGrad = { - "((function textureLod\n" + "((function textureProjGrad\n" " (signature vec4\n" " (parameters\n" " (declare (in) sampler1D sampler)\n" @@ -4289,7 +4289,7 @@ static const char *builtins_130_textureProjGrad = { }; static const char *builtins_130_textureProjLod = { - "((function textureLod\n" + "((function textureProjLod\n" " (signature vec4\n" " (parameters\n" " (declare (in) sampler1D sampler)\n" -- cgit v1.2.3 From 2dd3ae0d4ae681cd7b6b28caf35ca45965621c79 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 8 Aug 2010 17:56:34 -0700 Subject: glsl2: Teach copy propagation about "if" and "loop" instructions. This lets us track copies across basic block boundaries. The loop doesn't get a filled out list of available copies into it yet, though. glsl-fs-raytrace drops from 585 to 535 Mesa IR instructions out of the compiler, and it appears that Yo Frankie's largest shaders decrease in Mesa IR count by about 10% as well. --- src/glsl/ir_copy_propagation.cpp | 248 +++++++++++++++++++++++++-------------- 1 file changed, 158 insertions(+), 90 deletions(-) diff --git a/src/glsl/ir_copy_propagation.cpp b/src/glsl/ir_copy_propagation.cpp index 90a49d5a82a..6c211f0e70a 100644 --- a/src/glsl/ir_copy_propagation.cpp +++ b/src/glsl/ir_copy_propagation.cpp @@ -25,7 +25,7 @@ * \file ir_copy_propagation.cpp * * Moves usage of recently-copied variables to the previous copy of - * the variable within basic blocks. + * the variable. * * This should reduce the number of MOV instructions in the generated * programs unless copy propagation is also done on the LIR, and may @@ -53,13 +53,31 @@ public: ir_variable *rhs; }; + +class kill_entry : public exec_node +{ +public: + kill_entry(ir_variable *var) + { + assert(var); + this->var = var; + } + + ir_variable *var; +}; + class ir_copy_propagation_visitor : public ir_hierarchical_visitor { public: - ir_copy_propagation_visitor(exec_list *acp) + ir_copy_propagation_visitor() { progress = false; - in_lhs = false; - this->acp = acp; + mem_ctx = talloc_new(0); + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + } + ~ir_copy_propagation_visitor() + { + talloc_free(mem_ctx); } virtual ir_visitor_status visit(class ir_dereference_variable *); @@ -70,26 +88,46 @@ public: virtual ir_visitor_status visit_enter(class ir_call *); virtual ir_visitor_status visit_enter(class ir_if *); - /** List of acp_entry */ + void add_copy(ir_assignment *ir); + void kill(ir_variable *ir); + void handle_if_block(exec_list *instructions); + + /** List of acp_entry: The available copies to propagate */ exec_list *acp; - bool progress; + /** + * List of kill_entry: The variables whose values were killed in this + * block. + */ + exec_list *kills; - /** Currently in the LHS of an assignment? */ - bool in_lhs; -}; + bool progress; + bool killed_all; -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_loop *ir) -{ - (void)ir; - return visit_continue_with_parent; -} + void *mem_ctx; +}; ir_visitor_status ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir) { - (void)ir; + /* Treat entry into a function signature as a completely separate + * block. Any instructions at global scope will be shuffled into + * main() at link time, so they're irrelevant to us. + */ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + visit_list_elements(this, &ir->body); + + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = orig_killed_all; + return visit_continue_with_parent; } @@ -98,34 +136,33 @@ ir_copy_propagation_visitor::visit_enter(ir_assignment *ir) { ir_visitor_status s; - /* Inline the rest of ir_assignment::accept(ir_hv *v), wrapping the - * LHS part with setting in_lhs so that we can avoid copy - * propagating into the LHS. + /* ir_assignment::accept(ir_hv *v), skipping the LHS so that we can + * avoid copy propagating into the LHS. * * Note that this means we won't copy propagate into the derefs of * an array index. Oh well. */ - this->in_lhs = true; - s = ir->lhs->accept(this); - this->in_lhs = false; - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; s = ir->rhs->accept(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; + assert(s == visit_continue); - if (ir->condition) + if (ir->condition) { s = ir->condition->accept(this); + assert(s == visit_continue); + } + + kill(ir->lhs->variable_referenced()); - return (s == visit_stop) ? s : visit_continue_with_parent; + add_copy(ir); + + return visit_continue_with_parent; } ir_visitor_status ir_copy_propagation_visitor::visit_enter(ir_function *ir) { (void) ir; - return visit_continue_with_parent; + return visit_continue; } /** @@ -138,14 +175,7 @@ ir_copy_propagation_visitor::visit_enter(ir_function *ir) ir_visitor_status ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) { - /* Ignores the LHS. Don't want to rewrite the LHS to point at some - * other storage! - */ - if (this->in_lhs) { - return visit_continue; - } - - ir_variable *var = ir->variable_referenced(); + ir_variable *var = ir->var; foreach_iter(exec_list_iterator, iter, *this->acp) { acp_entry *entry = (acp_entry *)iter.get(); @@ -169,43 +199,108 @@ ir_copy_propagation_visitor::visit_enter(ir_call *ir) foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); ir_instruction *ir = (ir_instruction *)iter.get(); - if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout && - sig_param->mode != ir_var_uniform) { + if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout) { ir->accept(this); } sig_param_iter.next(); } + + /* Since we're unlinked, we don't (necssarily) know the side effects of + * this call. So kill all copies. + */ + acp->make_empty(); + this->killed_all = true; + return visit_continue_with_parent; } +void +ir_copy_propagation_visitor::handle_if_block(exec_list *instructions) +{ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + /* Populate the initial acp with a copy of the original */ + foreach_iter(exec_list_iterator, iter, *orig_acp) { + acp_entry *a = (acp_entry *)iter.get(); + this->acp->push_tail(new(this->mem_ctx) acp_entry(a->lhs, a->rhs)); + } + + visit_list_elements(this, instructions); + + if (this->killed_all) { + orig_acp->make_empty(); + } + + exec_list *new_kills = this->kills; + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = this->killed_all || orig_killed_all; + + foreach_iter(exec_list_iterator, iter, *new_kills) { + kill_entry *k = (kill_entry *)iter.get(); + kill(k->var); + } +} ir_visitor_status ir_copy_propagation_visitor::visit_enter(ir_if *ir) { ir->condition->accept(this); - /* Do not traverse into the body of the if-statement since that is a - * different basic block. - */ + handle_if_block(&ir->then_instructions); + handle_if_block(&ir->else_instructions); + + /* handle_if_block() already descended into the children. */ return visit_continue_with_parent; } -static bool -propagate_copies(ir_instruction *ir, exec_list *acp) +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_loop *ir) { - ir_copy_propagation_visitor v(acp); + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; - ir->accept(&v); + /* FINISHME: For now, the initial acp for loops is totally empty. + * We could go through once, then go through again with the acp + * cloned minus the killed entries after the first run through. + */ + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; - return v.progress; + visit_list_elements(this, &ir->body_instructions); + + if (this->killed_all) { + orig_acp->make_empty(); + } + + exec_list *new_kills = this->kills; + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = this->killed_all || orig_killed_all; + + foreach_iter(exec_list_iterator, iter, *new_kills) { + kill_entry *k = (kill_entry *)iter.get(); + kill(k->var); + } + + /* already descended into the children. */ + return visit_continue_with_parent; } -static void -kill_invalidated_copies(ir_assignment *ir, exec_list *acp) +void +ir_copy_propagation_visitor::kill(ir_variable *var) { - ir_variable *var = ir->lhs->variable_referenced(); assert(var != NULL); + /* Remove any entries currently in the ACP for this kill. */ foreach_iter(exec_list_iterator, iter, *acp) { acp_entry *entry = (acp_entry *)iter.get(); @@ -213,21 +308,25 @@ kill_invalidated_copies(ir_assignment *ir, exec_list *acp) entry->remove(); } } + + /* Add the LHS variable to the list of killed variables in this block. + */ + this->kills->push_tail(new(this->mem_ctx) kill_entry(var)); } /** * Adds an entry to the available copy list if it's a plain assignment * of a variable to a variable. */ -static bool -add_copy(void *ctx, ir_assignment *ir, exec_list *acp) +void +ir_copy_propagation_visitor::add_copy(ir_assignment *ir) { acp_entry *entry; if (ir->condition) { ir_constant *condition = ir->condition->as_constant(); if (!condition || !condition->value.b[0]) - return false; + return; } ir_variable *lhs_var = ir->whole_variable_written(); @@ -241,43 +340,12 @@ add_copy(void *ctx, ir_assignment *ir, exec_list *acp) * will clean up the mess. */ ir->condition = new(talloc_parent(ir)) ir_constant(false); - return true; + this->progress = true; } else { - entry = new(ctx) acp_entry(lhs_var, rhs_var); - acp->push_tail(entry); + entry = new(this->mem_ctx) acp_entry(lhs_var, rhs_var); + this->acp->push_tail(entry); } } - - return false; -} - -static void -copy_propagation_basic_block(ir_instruction *first, - ir_instruction *last, - void *data) -{ - ir_instruction *ir; - /* List of avaialble_copy */ - exec_list acp; - bool *out_progress = (bool *)data; - bool progress = false; - - void *ctx = talloc_new(NULL); - for (ir = first;; ir = (ir_instruction *)ir->next) { - ir_assignment *ir_assign = ir->as_assignment(); - - progress = propagate_copies(ir, &acp) || progress; - - if (ir_assign) { - kill_invalidated_copies(ir_assign, &acp); - - progress = add_copy(ctx, ir_assign, &acp) || progress; - } - if (ir == last) - break; - } - *out_progress = progress; - talloc_free(ctx); } /** @@ -286,9 +354,9 @@ copy_propagation_basic_block(ir_instruction *first, bool do_copy_propagation(exec_list *instructions) { - bool progress = false; + ir_copy_propagation_visitor v; - call_for_basic_blocks(instructions, copy_propagation_basic_block, &progress); + visit_list_elements(&v, instructions); - return progress; + return v.progress; } -- cgit v1.2.3 From 81996ae8618759cf7fdd033042a96f3014659f6c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 9 Aug 2010 18:23:58 -0700 Subject: i965: More s/stderr/stdout/ for program debug. --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 2 +- src/mesa/drivers/dri/i965/brw_wm_emit.c | 2 +- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index d2bd2c7f797..fab6b4f3d5a 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -1924,7 +1924,7 @@ void brw_vs_emit(struct brw_vs_compile *c ) printf("vs-native:\n"); for (i = 0; i < p->nr_insn; i++) - brw_disasm(stderr, &p->store[i], intel->gen); + brw_disasm(stdout, &p->store[i], intel->gen); printf("\n"); } } diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index 0c625a4cd02..053cf13a011 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -1775,7 +1775,7 @@ void brw_wm_emit( struct brw_wm_compile *c ) printf("wm-native:\n"); for (i = 0; i < p->nr_insn; i++) - brw_disasm(stderr, &p->store[i], p->brw->intel.gen); + brw_disasm(stdout, &p->store[i], p->brw->intel.gen); printf("\n"); } } diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 2dd346d6dd1..f13b0aaf957 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -2117,7 +2117,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) if (INTEL_DEBUG & DEBUG_WM) { printf("wm-native:\n"); for (i = 0; i < p->nr_insn; i++) - brw_disasm(stderr, &p->store[i], intel->gen); + brw_disasm(stdout, &p->store[i], intel->gen); printf("\n"); } } -- cgit v1.2.3 From 8bebbeb7c5b26ec9166a4644a2c051238d18509b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 9 Aug 2010 17:03:46 -0700 Subject: glsl2: Add constant propagation. Whereas constant folding evaluates constant expressions at rvalue nodes, constant propagation tracks constant components of vectors across execution to replace (possibly swizzled) variable dereferences with constant values, triggering possible constant folding or reduced variable liveness. --- src/glsl/Makefile | 1 + src/glsl/ir_constant_propagation.cpp | 481 +++++++++++++++++++++++++++++++++++ src/glsl/ir_optimization.h | 1 + src/glsl/linker.cpp | 1 + src/glsl/main.cpp | 1 + src/mesa/program/ir_to_mesa.cpp | 1 + 6 files changed, 486 insertions(+) create mode 100644 src/glsl/ir_constant_propagation.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 0f8b290b654..841e2b9ce9c 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -34,6 +34,7 @@ CXX_SOURCES = \ ir_clone.cpp \ ir_constant_expression.cpp \ ir_constant_folding.cpp \ + ir_constant_propagation.cpp \ ir_constant_variable.cpp \ ir_copy_propagation.cpp \ ir.cpp \ diff --git a/src/glsl/ir_constant_propagation.cpp b/src/glsl/ir_constant_propagation.cpp new file mode 100644 index 00000000000..adae0aa1171 --- /dev/null +++ b/src/glsl/ir_constant_propagation.cpp @@ -0,0 +1,481 @@ +/* + * Constantright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * constant of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, constant, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above constantright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR CONSTANTRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_constant_propagation.cpp + * + * Tracks assignments of constants to channels of variables, and + * usage of those constant channels with direct usage of the constants. + * + * This can lead to constant folding and algebraic optimizations in + * those later expressions, while causing no increase in instruction + * count (due to constants being generally free to load from a + * constant push buffer or as instruction immediate values) and + * possibly reducing register pressure. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_basic_block.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +class acp_entry : public exec_node +{ +public: + acp_entry(ir_variable *var, unsigned write_mask, ir_constant *constant) + { + assert(var); + assert(constant); + this->var = var; + this->write_mask = write_mask; + this->constant = constant; + } + + ir_variable *var; + ir_constant *constant; + unsigned write_mask; +}; + + +class kill_entry : public exec_node +{ +public: + kill_entry(ir_variable *var, unsigned write_mask) + { + assert(var); + this->var = var; + this->write_mask = write_mask; + } + + ir_variable *var; + unsigned write_mask; +}; + +class ir_constant_propagation_visitor : public ir_hierarchical_visitor { +public: + ir_constant_propagation_visitor() + { + progress = false; + mem_ctx = talloc_new(0); + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + } + ~ir_constant_propagation_visitor() + { + talloc_free(mem_ctx); + } + + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_enter(class ir_assignment *); + virtual ir_visitor_status visit_leave(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_expression *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_if *); + virtual ir_visitor_status visit_enter(class ir_dereference_array *); + virtual ir_visitor_status visit_enter(class ir_texture *); + + void add_constant(ir_assignment *ir); + void kill(ir_variable *ir, unsigned write_mask); + void handle_if_block(exec_list *instructions); + void handle_rvalue(ir_rvalue **rvalue); + + /** List of acp_entry: The available constants to propagate */ + exec_list *acp; + + /** + * List of kill_entry: The masks of variables whose values were + * killed in this block. + */ + exec_list *kills; + + bool progress; + + bool killed_all; + + void *mem_ctx; +}; + + +void +ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue) +{ + if (!*rvalue) + return; + + const glsl_type *type = (*rvalue)->type; + if (!type->is_scalar() && !type->is_vector()) + return; + + ir_swizzle *swiz = NULL; + ir_dereference_variable *deref = (*rvalue)->as_dereference_variable(); + if (!deref) { + swiz = (*rvalue)->as_swizzle(); + if (!swiz) + return; + + deref = swiz->val->as_dereference_variable(); + if (!deref) + return; + } + + ir_constant_data data; + memset(&data, 0, sizeof(data)); + + for (unsigned int i = 0; i < type->components(); i++) { + int channel; + acp_entry *found = NULL; + + if (swiz) { + switch (i) { + case 0: channel = swiz->mask.x; break; + case 1: channel = swiz->mask.y; break; + case 2: channel = swiz->mask.z; break; + case 3: channel = swiz->mask.w; break; + default: assert(!"shouldn't be reached"); channel = 0; break; + } + } else { + channel = i; + } + + foreach_iter(exec_list_iterator, iter, *this->acp) { + acp_entry *entry = (acp_entry *)iter.get(); + if (entry->var == deref->var && entry->write_mask & (1 << channel)) { + found = entry; + break; + } + } + + if (!found) + return; + + switch (type->base_type) { + case GLSL_TYPE_FLOAT: + data.f[i] = found->constant->value.f[channel]; + break; + case GLSL_TYPE_INT: + data.i[i] = found->constant->value.i[channel]; + break; + case GLSL_TYPE_UINT: + data.u[i] = found->constant->value.u[channel]; + break; + case GLSL_TYPE_BOOL: + data.b[i] = found->constant->value.b[channel]; + break; + default: + assert(!"not reached"); + break; + } + } + + *rvalue = new(talloc_parent(deref)) ir_constant(type, &data); + this->progress = true; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_function_signature *ir) +{ + /* Treat entry into a function signature as a completely separate + * block. Any instructions at global scope will be shuffled into + * main() at link time, so they're irrelevant to us. + */ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + visit_list_elements(this, &ir->body); + + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = orig_killed_all; + + return visit_continue_with_parent; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_assignment *ir) +{ + handle_rvalue(&ir->condition); + handle_rvalue(&ir->rhs); + + return visit_continue; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_leave(ir_assignment *ir) +{ + kill(ir->lhs->variable_referenced(), ir->write_mask); + + add_constant(ir); + + return visit_continue; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_expression *ir) +{ + for (unsigned int i = 0; i < ir->get_num_operands(); i++) { + handle_rvalue(&ir->operands[i]); + } + + return visit_continue; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_function *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_call *ir) +{ + /* Do constant propagation on call parameters, but skip any out params */ + exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { + ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); + ir_rvalue *param = (ir_rvalue *)iter.get(); + if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout) { + ir_rvalue *new_param = param; + handle_rvalue(&new_param); + if (new_param != param) + param->replace_with(new_param); + else + param->accept(this); + } + sig_param_iter.next(); + } + + /* Since we're unlinked, we don't (necssarily) know the side effects of + * this call. So kill all copies. + */ + acp->make_empty(); + this->killed_all = true; + + return visit_continue_with_parent; +} + +void +ir_constant_propagation_visitor::handle_if_block(exec_list *instructions) +{ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + /* Populate the initial acp with a constant of the original */ + foreach_iter(exec_list_iterator, iter, *orig_acp) { + acp_entry *a = (acp_entry *)iter.get(); + this->acp->push_tail(new(this->mem_ctx) acp_entry(a->var, a->write_mask, + a->constant)); + } + + visit_list_elements(this, instructions); + + if (this->killed_all) { + orig_acp->make_empty(); + } + + exec_list *new_kills = this->kills; + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = this->killed_all || orig_killed_all; + + foreach_iter(exec_list_iterator, iter, *new_kills) { + kill_entry *k = (kill_entry *)iter.get(); + kill(k->var, k->write_mask); + } +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_if *ir) +{ + ir->condition->accept(this); + handle_rvalue(&ir->condition); + + handle_if_block(&ir->then_instructions); + handle_if_block(&ir->else_instructions); + + /* handle_if_block() already descended into the children. */ + return visit_continue_with_parent; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_dereference_array *ir) +{ + handle_rvalue(&ir->array_index); + return visit_continue; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_texture *ir) +{ + handle_rvalue(&ir->coordinate); + handle_rvalue(&ir->projector); + handle_rvalue(&ir->shadow_comparitor); + + switch (ir->op) { + case ir_tex: + break; + case ir_txb: + handle_rvalue(&ir->lod_info.bias); + break; + case ir_txf: + case ir_txl: + handle_rvalue(&ir->lod_info.lod); + break; + case ir_txd: + handle_rvalue(&ir->lod_info.grad.dPdx); + handle_rvalue(&ir->lod_info.grad.dPdy); + break; + } + + return visit_continue; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_loop *ir) +{ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + /* FINISHME: For now, the initial acp for loops is totally empty. + * We could go through once, then go through again with the acp + * cloned minus the killed entries after the first run through. + */ + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + visit_list_elements(this, &ir->body_instructions); + + if (this->killed_all) { + orig_acp->make_empty(); + } + + exec_list *new_kills = this->kills; + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = this->killed_all || orig_killed_all; + + foreach_iter(exec_list_iterator, iter, *new_kills) { + kill_entry *k = (kill_entry *)iter.get(); + kill(k->var, k->write_mask); + } + + /* already descended into the children. */ + return visit_continue_with_parent; +} + +void +ir_constant_propagation_visitor::kill(ir_variable *var, unsigned write_mask) +{ + assert(var != NULL); + + /* We don't track non-vectors. */ + if (!var->type->is_vector() && !var->type->is_scalar()) + return; + + /* Remove any entries currently in the ACP for this kill. */ + foreach_iter(exec_list_iterator, iter, *this->acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (entry->var == var) { + entry->write_mask &= ~write_mask; + if (entry->write_mask == 0) + entry->remove(); + } + } + + /* Add this writemask of the variable to the list of killed + * variables in this block. + */ + foreach_iter(exec_list_iterator, iter, *this->kills) { + kill_entry *entry = (kill_entry *)iter.get(); + + if (entry->var == var) { + entry->write_mask |= write_mask; + return; + } + } + /* Not already in the list. Make new entry. */ + this->kills->push_tail(new(this->mem_ctx) kill_entry(var, write_mask)); +} + +/** + * Adds an entry to the available constant list if it's a plain assignment + * of a variable to a variable. + */ +void +ir_constant_propagation_visitor::add_constant(ir_assignment *ir) +{ + acp_entry *entry; + + if (ir->condition) { + ir_constant *condition = ir->condition->as_constant(); + if (!condition || !condition->value.b[0]) + return; + } + + if (!ir->write_mask) + return; + + ir_dereference_variable *deref = ir->lhs->as_dereference_variable(); + ir_constant *constant = ir->rhs->as_constant(); + + if (!deref || !constant) + return; + + /* Only do constant propagation on vectors. Constant matrices, + * arrays, or structures would require more work elsewhere. + */ + if (!deref->var->type->is_vector() && !deref->var->type->is_scalar()) + return; + + entry = new(this->mem_ctx) acp_entry(deref->var, ir->write_mask, constant); + this->acp->push_tail(entry); +} + +/** + * Does a constant propagation pass on the code present in the instruction stream. + */ +bool +do_constant_propagation(exec_list *instructions) +{ + ir_constant_propagation_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index c6e7beb447f..97a0c25216e 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -33,6 +33,7 @@ bool do_constant_folding(exec_list *instructions); bool do_constant_variable(exec_list *instructions); bool do_constant_variable_unlinked(exec_list *instructions); bool do_copy_propagation(exec_list *instructions); +bool do_constant_propagation(exec_list *instructions); bool do_dead_code(exec_list *instructions); bool do_dead_code_local(exec_list *instructions); bool do_dead_code_unlinked(exec_list *instructions); diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e93c2f55549..52c93227888 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1296,6 +1296,7 @@ link_shaders(struct gl_shader_program *prog) progress = do_dead_code_local(ir) || progress; progress = do_dead_code(ir) || progress; progress = do_tree_grafting(ir) || progress; + progress = do_constant_propagation(ir) || progress; progress = do_constant_variable(ir) || progress; progress = do_constant_folding(ir) || progress; progress = do_algebraic(ir) || progress; diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index bc7292d155c..24d6076d07b 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -167,6 +167,7 @@ compile_shader(struct gl_shader *shader) progress = do_dead_code_local(shader->ir) || progress; progress = do_dead_code_unlinked(shader->ir) || progress; progress = do_tree_grafting(shader->ir) || progress; + progress = do_constant_propagation(shader->ir) || progress; progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; progress = do_algebraic(shader->ir) || progress; diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index c6856eb5a40..5a272ab88a1 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2581,6 +2581,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) progress = do_dead_code_local(shader->ir) || progress; progress = do_dead_code_unlinked(shader->ir) || progress; progress = do_tree_grafting(shader->ir) || progress; + progress = do_constant_propagation(shader->ir) || progress; progress = do_constant_variable_unlinked(shader->ir) || progress; progress = do_constant_folding(shader->ir) || progress; progress = do_algebraic(shader->ir) || progress; -- cgit v1.2.3 From 5854d4583c6e8885185e12a0636f77489a62e24c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 9 Aug 2010 21:22:17 -0700 Subject: glsl2: Add a pass to transform ir_binop_sub to add(op0, neg(op1)) All the current HW backends transform subtract to adding the negation, so I haven't bothered peepholing it back out in Mesa IR. This allows some subtract of subtract to get removed in ir_algebraic. --- src/glsl/Makefile | 1 + src/glsl/ir_optimization.h | 1 + src/glsl/ir_sub_to_add_neg.cpp | 76 +++++++++++++++++++++++++++++++++++++++++ src/glsl/linker.cpp | 1 + src/mesa/program/ir_to_mesa.cpp | 1 + 5 files changed, 80 insertions(+) create mode 100644 src/glsl/ir_sub_to_add_neg.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 841e2b9ce9c..85298d06a01 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -59,6 +59,7 @@ CXX_SOURCES = \ ir_reader.cpp \ ir_set_program_inouts.cpp \ ir_structure_splitting.cpp \ + ir_sub_to_add_neg.cpp \ ir_swizzle_swizzle.cpp \ ir_tree_grafting.cpp \ ir_validate.cpp \ diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 97a0c25216e..5997a30eab3 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -47,6 +47,7 @@ bool do_if_to_cond_assign(exec_list *instructions); bool do_mat_op_to_vec(exec_list *instructions); bool do_mod_to_fract(exec_list *instructions); bool do_structure_splitting(exec_list *instructions); +bool do_sub_to_add_neg(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); bool do_tree_grafting(exec_list *instructions); bool do_vec_index_to_cond_assign(exec_list *instructions); diff --git a/src/glsl/ir_sub_to_add_neg.cpp b/src/glsl/ir_sub_to_add_neg.cpp new file mode 100644 index 00000000000..7ed8c1495e3 --- /dev/null +++ b/src/glsl/ir_sub_to_add_neg.cpp @@ -0,0 +1,76 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_sub_to_add_neg.cpp + * + * Breaks an ir_binop_sub expression down to add(op0, neg(op1)) + * + * This simplifies expression reassociation, and for many backends + * there is no subtract operation separate from adding the negation. + * For backends with native subtract operations, they will probably + * want to recognize add(op0, neg(op1)) or the other way around to + * produce a subtract anyway. + */ + +#include "ir.h" + +class ir_sub_to_add_neg_visitor : public ir_hierarchical_visitor { +public: + ir_sub_to_add_neg_visitor() + { + this->progress = false; + } + + ir_visitor_status visit_leave(ir_expression *); + + bool progress; +}; + +bool +do_sub_to_add_neg(exec_list *instructions) +{ + ir_sub_to_add_neg_visitor v; + + visit_list_elements(&v, instructions); + return v.progress; +} + +ir_visitor_status +ir_sub_to_add_neg_visitor::visit_leave(ir_expression *ir) +{ + if (ir->operation != ir_binop_sub) + return visit_continue; + + void *mem_ctx = talloc_parent(ir); + + ir->operation = ir_binop_add; + ir->operands[1] = new(mem_ctx) ir_expression(ir_unop_neg, + ir->operands[1]->type, + ir->operands[1], + NULL); + + this->progress = true; + + return visit_continue; +} diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 52c93227888..c462d31ef3d 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1284,6 +1284,7 @@ link_shaders(struct gl_shader_program *prog) do_mod_to_fract(ir); do_div_to_mul_rcp(ir); do_explog_to_explog2(ir); + do_sub_to_add_neg(ir); do { progress = false; diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 5a272ab88a1..a9a6f977c01 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2570,6 +2570,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) do_mat_op_to_vec(shader->ir); do_mod_to_fract(shader->ir); do_div_to_mul_rcp(shader->ir); + do_sub_to_add_neg(shader->ir); /* Optimization passes */ bool progress; -- cgit v1.2.3 From 0ff3b2b344b21ae4a7b62ebba22d7358755c8dfe Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Jul 2010 23:56:19 -0700 Subject: glsl2: Make ir_algebraic reassociate add/mul operands for constant folding. It's rather easy to produce two constant multiplies separated by other multiplies while writing a BRDF shader, and non-obvious enough in the resulting codegen that I didn't catch it in my demo code until just recently. Cuts 3 965 instructions from my demo (<1%), and 20 from glsl-fs-raytrace (1.3%). --- src/glsl/ir_algebraic.cpp | 108 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir_algebraic.cpp b/src/glsl/ir_algebraic.cpp index 43d8f9e699c..86fb7e49c03 100644 --- a/src/glsl/ir_algebraic.cpp +++ b/src/glsl/ir_algebraic.cpp @@ -58,7 +58,14 @@ public: virtual ir_visitor_status visit_leave(ir_texture *); ir_rvalue *handle_expression(ir_rvalue *in_ir); - + bool reassociate_constant(ir_expression *ir1, + int const_index, + ir_constant *constant, + ir_expression *ir2); + void reassociate_operands(ir_expression *ir1, + int op1, + ir_expression *ir2, + int op2); bool progress; }; @@ -138,6 +145,84 @@ is_vec_one(ir_constant *ir) return true; } +static void +update_type(ir_expression *ir) +{ + if (ir->operands[0]->type->is_vector()) + ir->type = ir->operands[0]->type; + else + ir->type = ir->operands[1]->type; +} + +void +ir_algebraic_visitor::reassociate_operands(ir_expression *ir1, + int op1, + ir_expression *ir2, + int op2) +{ + ir_rvalue *temp = ir2->operands[op2]; + ir2->operands[op2] = ir1->operands[op1]; + ir1->operands[op1] = temp; + + /* Update the type of ir2. The type of ir1 won't have changed -- + * base types matched, and at least one of the operands of the 2 + * binops is still a vector if any of them were. + */ + update_type(ir2); + + this->progress = true; +} + +/** + * Reassociates a constant down a tree of adds or multiplies. + * + * Consider (2 * (a * (b * 0.5))). We want to send up with a * b. + */ +bool +ir_algebraic_visitor::reassociate_constant(ir_expression *ir1, int const_index, + ir_constant *constant, + ir_expression *ir2) +{ + if (!ir2 || ir1->operation != ir2->operation) + return false; + + /* Don't want to even think about matrices. */ + if (ir1->operands[0]->type->is_matrix() || + ir1->operands[0]->type->is_matrix() || + ir2->operands[1]->type->is_matrix() || + ir2->operands[1]->type->is_matrix()) + return false; + + ir_constant *ir2_const[2]; + ir2_const[0] = ir2->operands[0]->constant_expression_value(); + ir2_const[1] = ir2->operands[1]->constant_expression_value(); + + if (ir2_const[0] && ir2_const[1]) + return false; + + if (ir2_const[0]) { + reassociate_operands(ir1, const_index, ir2, 1); + return true; + } else if (ir2_const[1]) { + reassociate_operands(ir1, const_index, ir2, 0); + return true; + } + + if (reassociate_constant(ir1, const_index, constant, + ir2->operands[0]->as_expression())) { + update_type(ir2); + return true; + } + + if (reassociate_constant(ir1, const_index, constant, + ir2->operands[1]->as_expression())) { + update_type(ir2); + return true; + } + + return false; +} + ir_rvalue * ir_algebraic_visitor::handle_expression(ir_rvalue *in_ir) { @@ -201,6 +286,16 @@ ir_algebraic_visitor::handle_expression(ir_rvalue *in_ir) this->progress = true; return ir->operands[0]; } + + /* Reassociate addition of constants so that we can do constant + * folding. + */ + if (op_const[0] && !op_const[1]) + reassociate_constant(ir, 0, op_const[0], + ir->operands[1]->as_expression()); + if (op_const[1] && !op_const[0]) + reassociate_constant(ir, 1, op_const[1], + ir->operands[0]->as_expression()); break; case ir_binop_sub: @@ -231,6 +326,17 @@ ir_algebraic_visitor::handle_expression(ir_rvalue *in_ir) this->progress = true; return ir_constant::zero(ir, ir->type); } + + /* Reassociate multiplication of constants so that we can do + * constant folding. + */ + if (op_const[0] && !op_const[1]) + reassociate_constant(ir, 0, op_const[0], + ir->operands[1]->as_expression()); + if (op_const[1] && !op_const[0]) + reassociate_constant(ir, 1, op_const[1], + ir->operands[0]->as_expression()); + break; case ir_binop_div: -- cgit v1.2.3 From 60d8c46995aa9cf3f80592b9c9bb8e5be6e87502 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 10 Aug 2010 16:52:54 -0700 Subject: glsl2: Initialize location structure at beginning of parse. Since we have a custom structure for YYLTYPE locations, we need to use an %initial-action directive to avoid triggering use of uninitialized memory when, for example, printing error messages. Thanks to valgrind for noticing this bug. --- src/glsl/glsl_parser.ypp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 493b74fb692..3e60454bb24 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -35,9 +35,17 @@ %} %pure-parser -%locations %error-verbose +%locations +%initial-action { + @$.first_line = 1; + @$.first_column = 1; + @$.last_line = 1; + @$.last_column = 1; + @$.source = 0; +} + %lex-param {void *scanner} %parse-param {struct _mesa_glsl_parse_state *state} %name-prefix "_mesa_glsl_" -- cgit v1.2.3 From a7d6c496cfe2165468c4151f0838ebfd2122a990 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 10 Aug 2010 16:54:23 -0700 Subject: glsl2: Regenerate glsl_parser.cpp and glsl_parser.h After making a minor change to the .y file. --- src/glsl/glsl_parser.cpp | 986 ++++++++++++++++++++++++----------------------- src/glsl/glsl_parser.h | 15 +- 2 files changed, 505 insertions(+), 496 deletions(-) diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp index 4b5e3614df6..dc15891f7ec 100644 --- a/src/glsl/glsl_parser.cpp +++ b/src/glsl/glsl_parser.cpp @@ -1,9 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.4.2. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.2" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -113,7 +114,7 @@ /* Line 189 of yacc.c */ -#line 117 "glsl_parser.cpp" +#line 118 "glsl_parser.cpp" /* Enabling traces. */ #ifndef YYDEBUG @@ -337,7 +338,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c */ -#line 45 "glsl_parser.ypp" +#line 53 "glsl_parser.ypp" int n; float real; @@ -368,7 +369,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 372 "glsl_parser.cpp" +#line 373 "glsl_parser.cpp" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -393,7 +394,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 397 "glsl_parser.cpp" +#line 398 "glsl_parser.cpp" #ifdef short # undef short @@ -443,7 +444,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -801,34 +802,34 @@ static const yytype_int16 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 200, 200, 199, 208, 211, 228, 230, 234, 243, - 251, 262, 266, 273, 280, 287, 294, 301, 308, 309, - 315, 319, 326, 332, 341, 345, 349, 350, 359, 360, - 364, 365, 369, 375, 387, 391, 397, 404, 415, 416, - 422, 428, 438, 439, 440, 441, 445, 446, 452, 458, - 467, 468, 474, 483, 484, 490, 499, 500, 506, 512, - 518, 527, 528, 534, 543, 544, 553, 554, 563, 564, - 573, 574, 583, 584, 593, 594, 603, 604, 613, 614, - 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, - 633, 637, 641, 657, 661, 665, 669, 683, 687, 688, - 692, 697, 705, 716, 726, 741, 748, 753, 764, 776, - 777, 778, 779, 783, 787, 788, 797, 806, 815, 824, - 833, 846, 857, 866, 875, 884, 893, 902, 911, 925, - 932, 943, 944, 948, 955, 956, 963, 997, 998, 999, - 1003, 1007, 1008, 1012, 1020, 1021, 1022, 1023, 1024, 1025, - 1026, 1027, 1028, 1032, 1033, 1041, 1042, 1048, 1057, 1063, - 1069, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, - 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, - 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, - 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, - 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, - 1127, 1128, 1129, 1130, 1131, 1135, 1146, 1157, 1171, 1177, - 1186, 1191, 1199, 1214, 1219, 1227, 1233, 1242, 1246, 1252, - 1253, 1257, 1258, 1262, 1266, 1267, 1268, 1269, 1270, 1271, - 1272, 1276, 1282, 1291, 1292, 1296, 1302, 1311, 1321, 1333, - 1339, 1348, 1357, 1363, 1369, 1378, 1382, 1396, 1400, 1401, - 1405, 1412, 1419, 1429, 1430, 1434, 1436, 1442, 1447, 1456, - 1462, 1468, 1474, 1480, 1489, 1490, 1494 + 0, 208, 208, 207, 216, 219, 236, 238, 242, 251, + 259, 270, 274, 281, 288, 295, 302, 309, 316, 317, + 323, 327, 334, 340, 349, 353, 357, 358, 367, 368, + 372, 373, 377, 383, 395, 399, 405, 412, 423, 424, + 430, 436, 446, 447, 448, 449, 453, 454, 460, 466, + 475, 476, 482, 491, 492, 498, 507, 508, 514, 520, + 526, 535, 536, 542, 551, 552, 561, 562, 571, 572, + 581, 582, 591, 592, 601, 602, 611, 612, 621, 622, + 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, + 641, 645, 649, 665, 669, 673, 677, 691, 695, 696, + 700, 705, 713, 724, 734, 749, 756, 761, 772, 784, + 785, 786, 787, 791, 795, 796, 805, 814, 823, 832, + 841, 854, 865, 874, 883, 892, 901, 910, 919, 933, + 940, 951, 952, 956, 963, 964, 971, 1005, 1006, 1007, + 1011, 1015, 1016, 1020, 1028, 1029, 1030, 1031, 1032, 1033, + 1034, 1035, 1036, 1040, 1041, 1049, 1050, 1056, 1065, 1071, + 1077, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, + 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, + 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, + 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, + 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, + 1135, 1136, 1137, 1138, 1139, 1143, 1154, 1165, 1179, 1185, + 1194, 1199, 1207, 1222, 1227, 1235, 1241, 1250, 1254, 1260, + 1261, 1265, 1266, 1270, 1274, 1275, 1276, 1277, 1278, 1279, + 1280, 1284, 1290, 1299, 1300, 1304, 1310, 1319, 1329, 1341, + 1347, 1356, 1365, 1371, 1377, 1386, 1390, 1404, 1408, 1409, + 1413, 1420, 1427, 1437, 1438, 1442, 1444, 1450, 1455, 1464, + 1470, 1476, 1482, 1488, 1497, 1498, 1502 }; #endif @@ -2081,18 +2082,9 @@ static const yytype_uint16 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ + Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) @@ -2149,7 +2141,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -2738,12 +2730,28 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; #endif +/* User initialization code. */ + +/* Line 1242 of yacc.c */ +#line 41 "glsl_parser.ypp" +{ + yylloc.first_line = 1; + yylloc.first_column = 1; + yylloc.last_line = 1; + yylloc.last_column = 1; + yylloc.source = 0; +} + +/* Line 1242 of yacc.c */ +#line 2753 "glsl_parser.cpp" + yylsp[0] = yylloc; + goto yysetstate; /*------------------------------------------------------------. @@ -2928,8 +2936,8 @@ yyreduce: { case 2: -/* Line 1464 of yacc.c */ -#line 200 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 208 "glsl_parser.ypp" { _mesa_glsl_initialize_types(state); ;} @@ -2937,8 +2945,8 @@ yyreduce: case 4: -/* Line 1464 of yacc.c */ -#line 208 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 216 "glsl_parser.ypp" { state->language_version = 110; ;} @@ -2946,8 +2954,8 @@ yyreduce: case 5: -/* Line 1464 of yacc.c */ -#line 212 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 220 "glsl_parser.ypp" { switch ((yyvsp[(2) - (3)].n)) { case 110: @@ -2966,8 +2974,8 @@ yyreduce: case 8: -/* Line 1464 of yacc.c */ -#line 235 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 243 "glsl_parser.ypp" { if (!_mesa_glsl_process_extension((yyvsp[(2) - (5)].identifier), & (yylsp[(2) - (5)]), (yyvsp[(4) - (5)].identifier), & (yylsp[(4) - (5)]), state)) { YYERROR; @@ -2977,8 +2985,8 @@ yyreduce: case 9: -/* Line 1464 of yacc.c */ -#line 244 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 252 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -2990,8 +2998,8 @@ yyreduce: case 10: -/* Line 1464 of yacc.c */ -#line 252 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 260 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -3003,8 +3011,8 @@ yyreduce: case 12: -/* Line 1464 of yacc.c */ -#line 267 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 275 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); @@ -3015,8 +3023,8 @@ yyreduce: case 13: -/* Line 1464 of yacc.c */ -#line 274 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 282 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); @@ -3027,8 +3035,8 @@ yyreduce: case 14: -/* Line 1464 of yacc.c */ -#line 281 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 289 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); @@ -3039,8 +3047,8 @@ yyreduce: case 15: -/* Line 1464 of yacc.c */ -#line 288 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 296 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); @@ -3051,8 +3059,8 @@ yyreduce: case 16: -/* Line 1464 of yacc.c */ -#line 295 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 303 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); @@ -3063,8 +3071,8 @@ yyreduce: case 17: -/* Line 1464 of yacc.c */ -#line 302 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 310 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(2) - (3)].expression); ;} @@ -3072,8 +3080,8 @@ yyreduce: case 19: -/* Line 1464 of yacc.c */ -#line 310 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 318 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_array_index, (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression), NULL); @@ -3083,8 +3091,8 @@ yyreduce: case 20: -/* Line 1464 of yacc.c */ -#line 316 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 324 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} @@ -3092,8 +3100,8 @@ yyreduce: case 21: -/* Line 1464 of yacc.c */ -#line 320 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 328 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), NULL, NULL); @@ -3104,8 +3112,8 @@ yyreduce: case 22: -/* Line 1464 of yacc.c */ -#line 327 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 335 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_inc, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -3115,8 +3123,8 @@ yyreduce: case 23: -/* Line 1464 of yacc.c */ -#line 333 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 341 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_dec, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -3126,8 +3134,8 @@ yyreduce: case 27: -/* Line 1464 of yacc.c */ -#line 351 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 359 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -3137,8 +3145,8 @@ yyreduce: case 32: -/* Line 1464 of yacc.c */ -#line 370 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 378 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (2)].expression); (yyval.expression)->set_location(yylloc); @@ -3148,8 +3156,8 @@ yyreduce: case 33: -/* Line 1464 of yacc.c */ -#line 376 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 384 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (3)].expression); (yyval.expression)->set_location(yylloc); @@ -3159,8 +3167,8 @@ yyreduce: case 35: -/* Line 1464 of yacc.c */ -#line 392 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 400 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_function_expression((yyvsp[(1) - (1)].type_specifier)); @@ -3170,8 +3178,8 @@ yyreduce: case 36: -/* Line 1464 of yacc.c */ -#line 398 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 406 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -3182,8 +3190,8 @@ yyreduce: case 37: -/* Line 1464 of yacc.c */ -#line 405 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 413 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -3194,8 +3202,8 @@ yyreduce: case 39: -/* Line 1464 of yacc.c */ -#line 417 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 425 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_inc, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3205,8 +3213,8 @@ yyreduce: case 40: -/* Line 1464 of yacc.c */ -#line 423 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 431 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_dec, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3216,8 +3224,8 @@ yyreduce: case 41: -/* Line 1464 of yacc.c */ -#line 429 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 437 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(1) - (2)].n), (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3227,36 +3235,36 @@ yyreduce: case 42: -/* Line 1464 of yacc.c */ -#line 438 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 446 "glsl_parser.ypp" { (yyval.n) = ast_plus; ;} break; case 43: -/* Line 1464 of yacc.c */ -#line 439 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 447 "glsl_parser.ypp" { (yyval.n) = ast_neg; ;} break; case 44: -/* Line 1464 of yacc.c */ -#line 440 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 448 "glsl_parser.ypp" { (yyval.n) = ast_logic_not; ;} break; case 45: -/* Line 1464 of yacc.c */ -#line 441 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 449 "glsl_parser.ypp" { (yyval.n) = ast_bit_not; ;} break; case 47: -/* Line 1464 of yacc.c */ -#line 447 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 455 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mul, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3266,8 +3274,8 @@ yyreduce: case 48: -/* Line 1464 of yacc.c */ -#line 453 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 461 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_div, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3277,8 +3285,8 @@ yyreduce: case 49: -/* Line 1464 of yacc.c */ -#line 459 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 467 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mod, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3288,8 +3296,8 @@ yyreduce: case 51: -/* Line 1464 of yacc.c */ -#line 469 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 477 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_add, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3299,8 +3307,8 @@ yyreduce: case 52: -/* Line 1464 of yacc.c */ -#line 475 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 483 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_sub, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3310,8 +3318,8 @@ yyreduce: case 54: -/* Line 1464 of yacc.c */ -#line 485 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 493 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3321,8 +3329,8 @@ yyreduce: case 55: -/* Line 1464 of yacc.c */ -#line 491 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 499 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_rshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3332,8 +3340,8 @@ yyreduce: case 57: -/* Line 1464 of yacc.c */ -#line 501 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 509 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_less, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3343,8 +3351,8 @@ yyreduce: case 58: -/* Line 1464 of yacc.c */ -#line 507 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 515 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_greater, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3354,8 +3362,8 @@ yyreduce: case 59: -/* Line 1464 of yacc.c */ -#line 513 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 521 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3365,8 +3373,8 @@ yyreduce: case 60: -/* Line 1464 of yacc.c */ -#line 519 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 527 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_gequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3376,8 +3384,8 @@ yyreduce: case 62: -/* Line 1464 of yacc.c */ -#line 529 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 537 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_equal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3387,8 +3395,8 @@ yyreduce: case 63: -/* Line 1464 of yacc.c */ -#line 535 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 543 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_nequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3398,8 +3406,8 @@ yyreduce: case 65: -/* Line 1464 of yacc.c */ -#line 545 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 553 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3409,8 +3417,8 @@ yyreduce: case 67: -/* Line 1464 of yacc.c */ -#line 555 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 563 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3420,8 +3428,8 @@ yyreduce: case 69: -/* Line 1464 of yacc.c */ -#line 565 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 573 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3431,8 +3439,8 @@ yyreduce: case 71: -/* Line 1464 of yacc.c */ -#line 575 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 583 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3442,8 +3450,8 @@ yyreduce: case 73: -/* Line 1464 of yacc.c */ -#line 585 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 593 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3453,8 +3461,8 @@ yyreduce: case 75: -/* Line 1464 of yacc.c */ -#line 595 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 603 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3464,8 +3472,8 @@ yyreduce: case 77: -/* Line 1464 of yacc.c */ -#line 605 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 613 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_conditional, (yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression)); @@ -3475,8 +3483,8 @@ yyreduce: case 79: -/* Line 1464 of yacc.c */ -#line 615 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 623 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(2) - (3)].n), (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -3486,85 +3494,85 @@ yyreduce: case 80: -/* Line 1464 of yacc.c */ -#line 623 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 631 "glsl_parser.ypp" { (yyval.n) = ast_assign; ;} break; case 81: -/* Line 1464 of yacc.c */ -#line 624 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 632 "glsl_parser.ypp" { (yyval.n) = ast_mul_assign; ;} break; case 82: -/* Line 1464 of yacc.c */ -#line 625 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 633 "glsl_parser.ypp" { (yyval.n) = ast_div_assign; ;} break; case 83: -/* Line 1464 of yacc.c */ -#line 626 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 634 "glsl_parser.ypp" { (yyval.n) = ast_mod_assign; ;} break; case 84: -/* Line 1464 of yacc.c */ -#line 627 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 635 "glsl_parser.ypp" { (yyval.n) = ast_add_assign; ;} break; case 85: -/* Line 1464 of yacc.c */ -#line 628 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 636 "glsl_parser.ypp" { (yyval.n) = ast_sub_assign; ;} break; case 86: -/* Line 1464 of yacc.c */ -#line 629 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 637 "glsl_parser.ypp" { (yyval.n) = ast_ls_assign; ;} break; case 87: -/* Line 1464 of yacc.c */ -#line 630 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 638 "glsl_parser.ypp" { (yyval.n) = ast_rs_assign; ;} break; case 88: -/* Line 1464 of yacc.c */ -#line 631 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 639 "glsl_parser.ypp" { (yyval.n) = ast_and_assign; ;} break; case 89: -/* Line 1464 of yacc.c */ -#line 632 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 640 "glsl_parser.ypp" { (yyval.n) = ast_xor_assign; ;} break; case 90: -/* Line 1464 of yacc.c */ -#line 633 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 641 "glsl_parser.ypp" { (yyval.n) = ast_or_assign; ;} break; case 91: -/* Line 1464 of yacc.c */ -#line 638 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 646 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} @@ -3572,8 +3580,8 @@ yyreduce: case 92: -/* Line 1464 of yacc.c */ -#line 642 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 650 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (3)].expression)->oper != ast_sequence) { @@ -3590,8 +3598,8 @@ yyreduce: case 94: -/* Line 1464 of yacc.c */ -#line 662 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 670 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].function); ;} @@ -3599,8 +3607,8 @@ yyreduce: case 95: -/* Line 1464 of yacc.c */ -#line 666 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 674 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].declarator_list); ;} @@ -3608,8 +3616,8 @@ yyreduce: case 96: -/* Line 1464 of yacc.c */ -#line 670 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 678 "glsl_parser.ypp" { if (((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_float) && ((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_int)) { @@ -3624,8 +3632,8 @@ yyreduce: case 100: -/* Line 1464 of yacc.c */ -#line 693 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 701 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (2)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(2) - (2)].parameter_declarator)->link); @@ -3634,8 +3642,8 @@ yyreduce: case 101: -/* Line 1464 of yacc.c */ -#line 698 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 706 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (3)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(3) - (3)].parameter_declarator)->link); @@ -3644,8 +3652,8 @@ yyreduce: case 102: -/* Line 1464 of yacc.c */ -#line 706 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 714 "glsl_parser.ypp" { void *ctx = state; (yyval.function) = new(ctx) ast_function(); @@ -3657,8 +3665,8 @@ yyreduce: case 103: -/* Line 1464 of yacc.c */ -#line 717 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 725 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3672,8 +3680,8 @@ yyreduce: case 104: -/* Line 1464 of yacc.c */ -#line 727 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 735 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3689,8 +3697,8 @@ yyreduce: case 105: -/* Line 1464 of yacc.c */ -#line 742 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 750 "glsl_parser.ypp" { (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; @@ -3701,8 +3709,8 @@ yyreduce: case 106: -/* Line 1464 of yacc.c */ -#line 749 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 757 "glsl_parser.ypp" { (yyval.parameter_declarator) = (yyvsp[(2) - (2)].parameter_declarator); (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier).q; @@ -3711,8 +3719,8 @@ yyreduce: case 107: -/* Line 1464 of yacc.c */ -#line 754 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 762 "glsl_parser.ypp" { void *ctx = state; (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; @@ -3727,8 +3735,8 @@ yyreduce: case 108: -/* Line 1464 of yacc.c */ -#line 765 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 773 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3741,36 +3749,36 @@ yyreduce: case 109: -/* Line 1464 of yacc.c */ -#line 776 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 784 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; ;} break; case 110: -/* Line 1464 of yacc.c */ -#line 777 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 785 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} break; case 111: -/* Line 1464 of yacc.c */ -#line 778 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 786 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} break; case 112: -/* Line 1464 of yacc.c */ -#line 779 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 787 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; (yyval.type_qualifier).q.out = 1; ;} break; case 115: -/* Line 1464 of yacc.c */ -#line 789 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 797 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (3)].identifier), false, NULL, NULL); @@ -3783,8 +3791,8 @@ yyreduce: case 116: -/* Line 1464 of yacc.c */ -#line 798 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 806 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), true, NULL, NULL); @@ -3797,8 +3805,8 @@ yyreduce: case 117: -/* Line 1464 of yacc.c */ -#line 807 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 815 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (6)].identifier), true, (yyvsp[(5) - (6)].expression), NULL); @@ -3811,8 +3819,8 @@ yyreduce: case 118: -/* Line 1464 of yacc.c */ -#line 816 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 824 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (7)].identifier), true, NULL, (yyvsp[(7) - (7)].expression)); @@ -3825,8 +3833,8 @@ yyreduce: case 119: -/* Line 1464 of yacc.c */ -#line 825 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 833 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (8)].identifier), true, (yyvsp[(5) - (8)].expression), (yyvsp[(8) - (8)].expression)); @@ -3839,8 +3847,8 @@ yyreduce: case 120: -/* Line 1464 of yacc.c */ -#line 834 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 842 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), false, NULL, (yyvsp[(5) - (5)].expression)); @@ -3853,8 +3861,8 @@ yyreduce: case 121: -/* Line 1464 of yacc.c */ -#line 847 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 855 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (1)].fully_specified_type)->specifier->type_specifier != ast_struct) { @@ -3869,8 +3877,8 @@ yyreduce: case 122: -/* Line 1464 of yacc.c */ -#line 858 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 866 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3883,8 +3891,8 @@ yyreduce: case 123: -/* Line 1464 of yacc.c */ -#line 867 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 875 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), true, NULL, NULL); @@ -3897,8 +3905,8 @@ yyreduce: case 124: -/* Line 1464 of yacc.c */ -#line 876 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 884 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (5)].identifier), true, (yyvsp[(4) - (5)].expression), NULL); @@ -3911,8 +3919,8 @@ yyreduce: case 125: -/* Line 1464 of yacc.c */ -#line 885 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 893 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (6)].identifier), true, NULL, (yyvsp[(6) - (6)].expression)); @@ -3925,8 +3933,8 @@ yyreduce: case 126: -/* Line 1464 of yacc.c */ -#line 894 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 902 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (7)].identifier), true, (yyvsp[(4) - (7)].expression), (yyvsp[(7) - (7)].expression)); @@ -3939,8 +3947,8 @@ yyreduce: case 127: -/* Line 1464 of yacc.c */ -#line 903 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 911 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -3953,8 +3961,8 @@ yyreduce: case 128: -/* Line 1464 of yacc.c */ -#line 912 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 920 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3969,8 +3977,8 @@ yyreduce: case 129: -/* Line 1464 of yacc.c */ -#line 926 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 934 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -3981,8 +3989,8 @@ yyreduce: case 130: -/* Line 1464 of yacc.c */ -#line 933 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 941 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -3994,15 +4002,15 @@ yyreduce: case 131: -/* Line 1464 of yacc.c */ -#line 943 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 951 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; ;} break; case 133: -/* Line 1464 of yacc.c */ -#line 949 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 957 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(3) - (4)].type_qualifier); ;} @@ -4010,8 +4018,8 @@ yyreduce: case 135: -/* Line 1464 of yacc.c */ -#line 957 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 965 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (3)].type_qualifier).i | (yyvsp[(3) - (3)].type_qualifier).i; ;} @@ -4019,8 +4027,8 @@ yyreduce: case 136: -/* Line 1464 of yacc.c */ -#line 964 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 972 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; @@ -4055,36 +4063,36 @@ yyreduce: case 137: -/* Line 1464 of yacc.c */ -#line 997 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1005 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.smooth = 1; ;} break; case 138: -/* Line 1464 of yacc.c */ -#line 998 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1006 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.flat = 1; ;} break; case 139: -/* Line 1464 of yacc.c */ -#line 999 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1007 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.noperspective = 1; ;} break; case 140: -/* Line 1464 of yacc.c */ -#line 1003 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1011 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} break; case 142: -/* Line 1464 of yacc.c */ -#line 1009 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1017 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i | (yyvsp[(2) - (2)].type_qualifier).i; ;} @@ -4092,8 +4100,8 @@ yyreduce: case 143: -/* Line 1464 of yacc.c */ -#line 1013 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1021 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(2) - (2)].type_qualifier); (yyval.type_qualifier).q.invariant = 1; @@ -4102,71 +4110,71 @@ yyreduce: case 144: -/* Line 1464 of yacc.c */ -#line 1020 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1028 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} break; case 145: -/* Line 1464 of yacc.c */ -#line 1021 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1029 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.attribute = 1; ;} break; case 146: -/* Line 1464 of yacc.c */ -#line 1022 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1030 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i; (yyval.type_qualifier).q.varying = 1; ;} break; case 147: -/* Line 1464 of yacc.c */ -#line 1023 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1031 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.varying = 1; ;} break; case 148: -/* Line 1464 of yacc.c */ -#line 1024 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1032 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} break; case 149: -/* Line 1464 of yacc.c */ -#line 1025 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1033 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} break; case 150: -/* Line 1464 of yacc.c */ -#line 1026 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1034 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.in = 1; ;} break; case 151: -/* Line 1464 of yacc.c */ -#line 1027 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1035 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.out = 1; ;} break; case 152: -/* Line 1464 of yacc.c */ -#line 1028 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1036 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.uniform = 1; ;} break; case 154: -/* Line 1464 of yacc.c */ -#line 1034 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1042 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(2) - (2)].type_specifier); (yyval.type_specifier)->precision = (yyvsp[(1) - (2)].n); @@ -4175,8 +4183,8 @@ yyreduce: case 156: -/* Line 1464 of yacc.c */ -#line 1043 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1051 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (3)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -4186,8 +4194,8 @@ yyreduce: case 157: -/* Line 1464 of yacc.c */ -#line 1049 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1057 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (4)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -4197,8 +4205,8 @@ yyreduce: case 158: -/* Line 1464 of yacc.c */ -#line 1058 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1066 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].n)); @@ -4208,8 +4216,8 @@ yyreduce: case 159: -/* Line 1464 of yacc.c */ -#line 1064 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1072 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].struct_specifier)); @@ -4219,8 +4227,8 @@ yyreduce: case 160: -/* Line 1464 of yacc.c */ -#line 1070 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1078 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].identifier)); @@ -4230,386 +4238,386 @@ yyreduce: case 161: -/* Line 1464 of yacc.c */ -#line 1078 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1086 "glsl_parser.ypp" { (yyval.n) = ast_void; ;} break; case 162: -/* Line 1464 of yacc.c */ -#line 1079 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1087 "glsl_parser.ypp" { (yyval.n) = ast_float; ;} break; case 163: -/* Line 1464 of yacc.c */ -#line 1080 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1088 "glsl_parser.ypp" { (yyval.n) = ast_int; ;} break; case 164: -/* Line 1464 of yacc.c */ -#line 1081 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1089 "glsl_parser.ypp" { (yyval.n) = ast_uint; ;} break; case 165: -/* Line 1464 of yacc.c */ -#line 1082 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1090 "glsl_parser.ypp" { (yyval.n) = ast_bool; ;} break; case 166: -/* Line 1464 of yacc.c */ -#line 1083 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1091 "glsl_parser.ypp" { (yyval.n) = ast_vec2; ;} break; case 167: -/* Line 1464 of yacc.c */ -#line 1084 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1092 "glsl_parser.ypp" { (yyval.n) = ast_vec3; ;} break; case 168: -/* Line 1464 of yacc.c */ -#line 1085 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1093 "glsl_parser.ypp" { (yyval.n) = ast_vec4; ;} break; case 169: -/* Line 1464 of yacc.c */ -#line 1086 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1094 "glsl_parser.ypp" { (yyval.n) = ast_bvec2; ;} break; case 170: -/* Line 1464 of yacc.c */ -#line 1087 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1095 "glsl_parser.ypp" { (yyval.n) = ast_bvec3; ;} break; case 171: -/* Line 1464 of yacc.c */ -#line 1088 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1096 "glsl_parser.ypp" { (yyval.n) = ast_bvec4; ;} break; case 172: -/* Line 1464 of yacc.c */ -#line 1089 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1097 "glsl_parser.ypp" { (yyval.n) = ast_ivec2; ;} break; case 173: -/* Line 1464 of yacc.c */ -#line 1090 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1098 "glsl_parser.ypp" { (yyval.n) = ast_ivec3; ;} break; case 174: -/* Line 1464 of yacc.c */ -#line 1091 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1099 "glsl_parser.ypp" { (yyval.n) = ast_ivec4; ;} break; case 175: -/* Line 1464 of yacc.c */ -#line 1092 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1100 "glsl_parser.ypp" { (yyval.n) = ast_uvec2; ;} break; case 176: -/* Line 1464 of yacc.c */ -#line 1093 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1101 "glsl_parser.ypp" { (yyval.n) = ast_uvec3; ;} break; case 177: -/* Line 1464 of yacc.c */ -#line 1094 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1102 "glsl_parser.ypp" { (yyval.n) = ast_uvec4; ;} break; case 178: -/* Line 1464 of yacc.c */ -#line 1095 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1103 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; case 179: -/* Line 1464 of yacc.c */ -#line 1096 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1104 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; case 180: -/* Line 1464 of yacc.c */ -#line 1097 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1105 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; case 181: -/* Line 1464 of yacc.c */ -#line 1098 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1106 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; case 182: -/* Line 1464 of yacc.c */ -#line 1099 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1107 "glsl_parser.ypp" { (yyval.n) = ast_mat2x3; ;} break; case 183: -/* Line 1464 of yacc.c */ -#line 1100 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1108 "glsl_parser.ypp" { (yyval.n) = ast_mat2x4; ;} break; case 184: -/* Line 1464 of yacc.c */ -#line 1101 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1109 "glsl_parser.ypp" { (yyval.n) = ast_mat3x2; ;} break; case 185: -/* Line 1464 of yacc.c */ -#line 1102 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1110 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; case 186: -/* Line 1464 of yacc.c */ -#line 1103 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1111 "glsl_parser.ypp" { (yyval.n) = ast_mat3x4; ;} break; case 187: -/* Line 1464 of yacc.c */ -#line 1104 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1112 "glsl_parser.ypp" { (yyval.n) = ast_mat4x2; ;} break; case 188: -/* Line 1464 of yacc.c */ -#line 1105 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1113 "glsl_parser.ypp" { (yyval.n) = ast_mat4x3; ;} break; case 189: -/* Line 1464 of yacc.c */ -#line 1106 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1114 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; case 190: -/* Line 1464 of yacc.c */ -#line 1107 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1115 "glsl_parser.ypp" { (yyval.n) = ast_sampler1d; ;} break; case 191: -/* Line 1464 of yacc.c */ -#line 1108 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1116 "glsl_parser.ypp" { (yyval.n) = ast_sampler2d; ;} break; case 192: -/* Line 1464 of yacc.c */ -#line 1109 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1117 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drect; ;} break; case 193: -/* Line 1464 of yacc.c */ -#line 1110 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1118 "glsl_parser.ypp" { (yyval.n) = ast_sampler3d; ;} break; case 194: -/* Line 1464 of yacc.c */ -#line 1111 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1119 "glsl_parser.ypp" { (yyval.n) = ast_samplercube; ;} break; case 195: -/* Line 1464 of yacc.c */ -#line 1112 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1120 "glsl_parser.ypp" { (yyval.n) = ast_sampler1dshadow; ;} break; case 196: -/* Line 1464 of yacc.c */ -#line 1113 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1121 "glsl_parser.ypp" { (yyval.n) = ast_sampler2dshadow; ;} break; case 197: -/* Line 1464 of yacc.c */ -#line 1114 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1122 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drectshadow; ;} break; case 198: -/* Line 1464 of yacc.c */ -#line 1115 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1123 "glsl_parser.ypp" { (yyval.n) = ast_samplercubeshadow; ;} break; case 199: -/* Line 1464 of yacc.c */ -#line 1116 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1124 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darray; ;} break; case 200: -/* Line 1464 of yacc.c */ -#line 1117 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1125 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darray; ;} break; case 201: -/* Line 1464 of yacc.c */ -#line 1118 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1126 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darrayshadow; ;} break; case 202: -/* Line 1464 of yacc.c */ -#line 1119 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1127 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darrayshadow; ;} break; case 203: -/* Line 1464 of yacc.c */ -#line 1120 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1128 "glsl_parser.ypp" { (yyval.n) = ast_isampler1d; ;} break; case 204: -/* Line 1464 of yacc.c */ -#line 1121 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1129 "glsl_parser.ypp" { (yyval.n) = ast_isampler2d; ;} break; case 205: -/* Line 1464 of yacc.c */ -#line 1122 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1130 "glsl_parser.ypp" { (yyval.n) = ast_isampler3d; ;} break; case 206: -/* Line 1464 of yacc.c */ -#line 1123 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1131 "glsl_parser.ypp" { (yyval.n) = ast_isamplercube; ;} break; case 207: -/* Line 1464 of yacc.c */ -#line 1124 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1132 "glsl_parser.ypp" { (yyval.n) = ast_isampler1darray; ;} break; case 208: -/* Line 1464 of yacc.c */ -#line 1125 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1133 "glsl_parser.ypp" { (yyval.n) = ast_isampler2darray; ;} break; case 209: -/* Line 1464 of yacc.c */ -#line 1126 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1134 "glsl_parser.ypp" { (yyval.n) = ast_usampler1d; ;} break; case 210: -/* Line 1464 of yacc.c */ -#line 1127 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1135 "glsl_parser.ypp" { (yyval.n) = ast_usampler2d; ;} break; case 211: -/* Line 1464 of yacc.c */ -#line 1128 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1136 "glsl_parser.ypp" { (yyval.n) = ast_usampler3d; ;} break; case 212: -/* Line 1464 of yacc.c */ -#line 1129 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1137 "glsl_parser.ypp" { (yyval.n) = ast_usamplercube; ;} break; case 213: -/* Line 1464 of yacc.c */ -#line 1130 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1138 "glsl_parser.ypp" { (yyval.n) = ast_usampler1darray; ;} break; case 214: -/* Line 1464 of yacc.c */ -#line 1131 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1139 "glsl_parser.ypp" { (yyval.n) = ast_usampler2darray; ;} break; case 215: -/* Line 1464 of yacc.c */ -#line 1135 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1143 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4625,8 +4633,8 @@ yyreduce: case 216: -/* Line 1464 of yacc.c */ -#line 1146 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1154 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4642,8 +4650,8 @@ yyreduce: case 217: -/* Line 1464 of yacc.c */ -#line 1157 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1165 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4659,8 +4667,8 @@ yyreduce: case 218: -/* Line 1464 of yacc.c */ -#line 1172 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1180 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node)); @@ -4670,8 +4678,8 @@ yyreduce: case 219: -/* Line 1464 of yacc.c */ -#line 1178 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1186 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node)); @@ -4681,8 +4689,8 @@ yyreduce: case 220: -/* Line 1464 of yacc.c */ -#line 1187 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1195 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].declarator_list); (yyvsp[(1) - (1)].declarator_list)->link.self_link(); @@ -4691,8 +4699,8 @@ yyreduce: case 221: -/* Line 1464 of yacc.c */ -#line 1192 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1200 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (2)].node); (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); @@ -4701,8 +4709,8 @@ yyreduce: case 222: -/* Line 1464 of yacc.c */ -#line 1200 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1208 "glsl_parser.ypp" { void *ctx = state; ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); @@ -4718,8 +4726,8 @@ yyreduce: case 223: -/* Line 1464 of yacc.c */ -#line 1215 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1223 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (1)].declaration); (yyvsp[(1) - (1)].declaration)->link.self_link(); @@ -4728,8 +4736,8 @@ yyreduce: case 224: -/* Line 1464 of yacc.c */ -#line 1220 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1228 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (3)].declaration); (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link); @@ -4738,8 +4746,8 @@ yyreduce: case 225: -/* Line 1464 of yacc.c */ -#line 1228 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1236 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL); @@ -4749,8 +4757,8 @@ yyreduce: case 226: -/* Line 1464 of yacc.c */ -#line 1234 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1242 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL); @@ -4760,29 +4768,29 @@ yyreduce: case 231: -/* Line 1464 of yacc.c */ -#line 1257 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1265 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 237: -/* Line 1464 of yacc.c */ -#line 1269 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1277 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; case 238: -/* Line 1464 of yacc.c */ -#line 1270 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1278 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; case 241: -/* Line 1464 of yacc.c */ -#line 1277 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1285 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL); @@ -4792,8 +4800,8 @@ yyreduce: case 242: -/* Line 1464 of yacc.c */ -#line 1283 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1291 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(2) - (3)].node)); @@ -4803,15 +4811,15 @@ yyreduce: case 243: -/* Line 1464 of yacc.c */ -#line 1291 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1299 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 245: -/* Line 1464 of yacc.c */ -#line 1297 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1305 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL); @@ -4821,8 +4829,8 @@ yyreduce: case 246: -/* Line 1464 of yacc.c */ -#line 1303 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1311 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node)); @@ -4832,8 +4840,8 @@ yyreduce: case 247: -/* Line 1464 of yacc.c */ -#line 1312 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1320 "glsl_parser.ypp" { if ((yyvsp[(1) - (1)].node) == NULL) { _mesa_glsl_error(& (yylsp[(1) - (1)]), state, " statement\n"); @@ -4847,8 +4855,8 @@ yyreduce: case 248: -/* Line 1464 of yacc.c */ -#line 1322 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1330 "glsl_parser.ypp" { if ((yyvsp[(2) - (2)].node) == NULL) { _mesa_glsl_error(& (yylsp[(2) - (2)]), state, " statement\n"); @@ -4861,8 +4869,8 @@ yyreduce: case 249: -/* Line 1464 of yacc.c */ -#line 1334 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1342 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement(NULL); @@ -4872,8 +4880,8 @@ yyreduce: case 250: -/* Line 1464 of yacc.c */ -#line 1340 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1348 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression)); @@ -4883,8 +4891,8 @@ yyreduce: case 251: -/* Line 1464 of yacc.c */ -#line 1349 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1357 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4894,8 +4902,8 @@ yyreduce: case 252: -/* Line 1464 of yacc.c */ -#line 1358 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1366 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4905,8 +4913,8 @@ yyreduce: case 253: -/* Line 1464 of yacc.c */ -#line 1364 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1372 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4916,8 +4924,8 @@ yyreduce: case 254: -/* Line 1464 of yacc.c */ -#line 1370 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1378 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4927,8 +4935,8 @@ yyreduce: case 255: -/* Line 1464 of yacc.c */ -#line 1379 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1387 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].expression); ;} @@ -4936,8 +4944,8 @@ yyreduce: case 256: -/* Line 1464 of yacc.c */ -#line 1383 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1391 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -4952,8 +4960,8 @@ yyreduce: case 260: -/* Line 1464 of yacc.c */ -#line 1406 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1414 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, @@ -4964,8 +4972,8 @@ yyreduce: case 261: -/* Line 1464 of yacc.c */ -#line 1413 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1421 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, @@ -4976,8 +4984,8 @@ yyreduce: case 262: -/* Line 1464 of yacc.c */ -#line 1420 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1428 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, @@ -4988,8 +4996,8 @@ yyreduce: case 266: -/* Line 1464 of yacc.c */ -#line 1436 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1444 "glsl_parser.ypp" { (yyval.node) = NULL; ;} @@ -4997,8 +5005,8 @@ yyreduce: case 267: -/* Line 1464 of yacc.c */ -#line 1443 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1451 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node); (yyval.for_rest_statement).rest = NULL; @@ -5007,8 +5015,8 @@ yyreduce: case 268: -/* Line 1464 of yacc.c */ -#line 1448 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1456 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node); (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression); @@ -5017,8 +5025,8 @@ yyreduce: case 269: -/* Line 1464 of yacc.c */ -#line 1457 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1465 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); @@ -5028,8 +5036,8 @@ yyreduce: case 270: -/* Line 1464 of yacc.c */ -#line 1463 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1471 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); @@ -5039,8 +5047,8 @@ yyreduce: case 271: -/* Line 1464 of yacc.c */ -#line 1469 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1477 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); @@ -5050,8 +5058,8 @@ yyreduce: case 272: -/* Line 1464 of yacc.c */ -#line 1475 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1483 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression)); @@ -5061,8 +5069,8 @@ yyreduce: case 273: -/* Line 1464 of yacc.c */ -#line 1481 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1489 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); @@ -5072,22 +5080,22 @@ yyreduce: case 274: -/* Line 1464 of yacc.c */ -#line 1489 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1497 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;} break; case 275: -/* Line 1464 of yacc.c */ -#line 1490 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1498 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); ;} break; case 276: -/* Line 1464 of yacc.c */ -#line 1495 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1503 "glsl_parser.ypp" { void *ctx = state; (yyval.function_definition) = new(ctx) ast_function_definition(); @@ -5099,8 +5107,8 @@ yyreduce: -/* Line 1464 of yacc.c */ -#line 5104 "glsl_parser.cpp" +/* Line 1455 of yacc.c */ +#line 5112 "glsl_parser.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h index 367b46f49e5..470c080f723 100644 --- a/src/glsl/glsl_parser.h +++ b/src/glsl/glsl_parser.h @@ -1,9 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.4.2. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -234,8 +235,8 @@ typedef union YYSTYPE { -/* Line 1685 of yacc.c */ -#line 45 "glsl_parser.ypp" +/* Line 1676 of yacc.c */ +#line 53 "glsl_parser.ypp" int n; float real; @@ -265,8 +266,8 @@ typedef union YYSTYPE -/* Line 1685 of yacc.c */ -#line 270 "glsl_parser.h" +/* Line 1676 of yacc.c */ +#line 271 "glsl_parser.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ -- cgit v1.2.3 From 485f84d36608b4545fc5a0061f9ab3ac71b9e36e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 10 Aug 2010 16:58:28 -0700 Subject: glcpp: Initialize location structure at beginning of parse. Since we have a custom structure for YYLTYPE locations, we need to use an %initial-action directive to avoid triggering use of uninitialized memory when, for example, printing error messages. We apparently don't yet have a test case that allowed valgrind to find this bug for us, but valgrind found a similar problem in the other parser, so we fix this one as well. --- src/glsl/glcpp/glcpp-parse.y | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index df1a649d9bc..a4383574506 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -142,7 +142,15 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); %pure-parser %error-verbose + %locations +%initial-action { + @$.first_line = 1; + @$.first_column = 1; + @$.last_line = 1; + @$.last_column = 1; + @$.source = 0; +} %parse-param {glcpp_parser_t *parser} %lex-param {glcpp_parser_t *parser} -- cgit v1.2.3 From e29cd391253230611a26ca58849a1169045dd795 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 10 Aug 2010 16:59:20 -0700 Subject: glcpp: Regnerate glcpp-parse.c and glcpp-parse.h After making a minor change to the .y file. --- src/glsl/glcpp/glcpp-parse.c | 432 ++++++++++++++++++++++--------------------- src/glsl/glcpp/glcpp-parse.h | 7 +- 2 files changed, 224 insertions(+), 215 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index e93f83263d9..2ef00a0c8d7 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -1,9 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.4.2. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.2" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -211,7 +212,7 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); /* Line 189 of yacc.c */ -#line 215 "glcpp/glcpp-parse.c" +#line 216 "glcpp/glcpp-parse.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -299,7 +300,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 303 "glcpp/glcpp-parse.c" +#line 304 "glcpp/glcpp-parse.c" #ifdef short # undef short @@ -349,7 +350,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -623,17 +624,17 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 172, 172, 174, 178, 181, 186, 187, 191, 194, - 200, 203, 206, 209, 217, 228, 233, 238, 247, 258, - 261, 264, 273, 277, 286, 291, 292, 295, 298, 301, - 304, 307, 310, 313, 316, 319, 322, 325, 328, 331, - 334, 337, 340, 343, 346, 349, 352, 355, 358, 364, - 369, 377, 378, 382, 388, 389, 392, 394, 401, 405, - 409, 414, 420, 428, 434, 442, 446, 450, 454, 458, - 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, - 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, - 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, - 495 + 0, 180, 180, 182, 186, 189, 194, 195, 199, 202, + 208, 211, 214, 217, 225, 236, 241, 246, 255, 266, + 269, 272, 281, 285, 294, 299, 300, 303, 306, 309, + 312, 315, 318, 321, 324, 327, 330, 333, 336, 339, + 342, 345, 348, 351, 354, 357, 360, 363, 366, 372, + 377, 385, 386, 390, 396, 397, 400, 402, 409, 413, + 417, 422, 428, 436, 442, 450, 454, 458, 462, 466, + 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, + 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, + 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, + 503 }; #endif @@ -936,18 +937,9 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ + Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) @@ -1004,7 +996,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1593,12 +1585,28 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; #endif +/* User initialization code. */ + +/* Line 1242 of yacc.c */ +#line 147 "glcpp/glcpp-parse.y" +{ + yylloc.first_line = 1; + yylloc.first_column = 1; + yylloc.last_line = 1; + yylloc.last_column = 1; + yylloc.source = 0; +} + +/* Line 1242 of yacc.c */ +#line 1608 "glcpp/glcpp-parse.c" + yylsp[0] = yylloc; + goto yysetstate; /*------------------------------------------------------------. @@ -1783,8 +1791,8 @@ yyreduce: { case 4: -/* Line 1464 of yacc.c */ -#line 178 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 186 "glcpp/glcpp-parse.y" { glcpp_print(parser->output, "\n"); ;} @@ -1792,8 +1800,8 @@ yyreduce: case 5: -/* Line 1464 of yacc.c */ -#line 181 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 189 "glcpp/glcpp-parse.y" { _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); glcpp_print(parser->output, "\n"); @@ -1803,8 +1811,8 @@ yyreduce: case 8: -/* Line 1464 of yacc.c */ -#line 191 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 199 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); ;} @@ -1812,8 +1820,8 @@ yyreduce: case 9: -/* Line 1464 of yacc.c */ -#line 194 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 202 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); ;} @@ -1821,8 +1829,8 @@ yyreduce: case 10: -/* Line 1464 of yacc.c */ -#line 200 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 208 "glcpp/glcpp-parse.y" { _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); ;} @@ -1830,8 +1838,8 @@ yyreduce: case 11: -/* Line 1464 of yacc.c */ -#line 203 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 211 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); ;} @@ -1839,8 +1847,8 @@ yyreduce: case 12: -/* Line 1464 of yacc.c */ -#line 206 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 214 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); ;} @@ -1848,8 +1856,8 @@ yyreduce: case 13: -/* Line 1464 of yacc.c */ -#line 209 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 217 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); if (macro) { @@ -1862,8 +1870,8 @@ yyreduce: case 14: -/* Line 1464 of yacc.c */ -#line 217 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 225 "glcpp/glcpp-parse.y" { /* If we're skipping to the next #elif/#else case or to #endif, * don't bother expanding or parsing the expression. @@ -1879,8 +1887,8 @@ yyreduce: case 15: -/* Line 1464 of yacc.c */ -#line 228 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 236 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1890,8 +1898,8 @@ yyreduce: case 16: -/* Line 1464 of yacc.c */ -#line 233 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 241 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1901,8 +1909,8 @@ yyreduce: case 17: -/* Line 1464 of yacc.c */ -#line 238 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 246 "glcpp/glcpp-parse.y" { /* If we just finished a non-skipped #if/#ifdef/#ifndef block, * don't bother expanding or parsing the expression. @@ -1916,8 +1924,8 @@ yyreduce: case 18: -/* Line 1464 of yacc.c */ -#line 247 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 255 "glcpp/glcpp-parse.y" { /* #elif without an expression results in a warning if the * condition doesn't matter (we just handled #if 1 or such) @@ -1933,8 +1941,8 @@ yyreduce: case 19: -/* Line 1464 of yacc.c */ -#line 258 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 266 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); ;} @@ -1942,8 +1950,8 @@ yyreduce: case 20: -/* Line 1464 of yacc.c */ -#line 261 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 269 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); ;} @@ -1951,8 +1959,8 @@ yyreduce: case 21: -/* Line 1464 of yacc.c */ -#line 264 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 272 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); if (macro) { @@ -1966,8 +1974,8 @@ yyreduce: case 23: -/* Line 1464 of yacc.c */ -#line 277 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 285 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); @@ -1981,8 +1989,8 @@ yyreduce: case 24: -/* Line 1464 of yacc.c */ -#line 286 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 294 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} @@ -1990,8 +1998,8 @@ yyreduce: case 26: -/* Line 1464 of yacc.c */ -#line 292 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 300 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); ;} @@ -1999,8 +2007,8 @@ yyreduce: case 27: -/* Line 1464 of yacc.c */ -#line 295 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 303 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); ;} @@ -2008,8 +2016,8 @@ yyreduce: case 28: -/* Line 1464 of yacc.c */ -#line 298 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 306 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); ;} @@ -2017,8 +2025,8 @@ yyreduce: case 29: -/* Line 1464 of yacc.c */ -#line 301 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 309 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); ;} @@ -2026,8 +2034,8 @@ yyreduce: case 30: -/* Line 1464 of yacc.c */ -#line 304 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 312 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); ;} @@ -2035,8 +2043,8 @@ yyreduce: case 31: -/* Line 1464 of yacc.c */ -#line 307 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 315 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); ;} @@ -2044,8 +2052,8 @@ yyreduce: case 32: -/* Line 1464 of yacc.c */ -#line 310 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 318 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); ;} @@ -2053,8 +2061,8 @@ yyreduce: case 33: -/* Line 1464 of yacc.c */ -#line 313 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 321 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); ;} @@ -2062,8 +2070,8 @@ yyreduce: case 34: -/* Line 1464 of yacc.c */ -#line 316 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 324 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); ;} @@ -2071,8 +2079,8 @@ yyreduce: case 35: -/* Line 1464 of yacc.c */ -#line 319 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 327 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); ;} @@ -2080,8 +2088,8 @@ yyreduce: case 36: -/* Line 1464 of yacc.c */ -#line 322 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 330 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); ;} @@ -2089,8 +2097,8 @@ yyreduce: case 37: -/* Line 1464 of yacc.c */ -#line 325 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 333 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); ;} @@ -2098,8 +2106,8 @@ yyreduce: case 38: -/* Line 1464 of yacc.c */ -#line 328 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 336 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); ;} @@ -2107,8 +2115,8 @@ yyreduce: case 39: -/* Line 1464 of yacc.c */ -#line 331 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 339 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); ;} @@ -2116,8 +2124,8 @@ yyreduce: case 40: -/* Line 1464 of yacc.c */ -#line 334 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 342 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); ;} @@ -2125,8 +2133,8 @@ yyreduce: case 41: -/* Line 1464 of yacc.c */ -#line 337 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 345 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); ;} @@ -2134,8 +2142,8 @@ yyreduce: case 42: -/* Line 1464 of yacc.c */ -#line 340 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 348 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); ;} @@ -2143,8 +2151,8 @@ yyreduce: case 43: -/* Line 1464 of yacc.c */ -#line 343 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 351 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); ;} @@ -2152,8 +2160,8 @@ yyreduce: case 44: -/* Line 1464 of yacc.c */ -#line 346 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 354 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); ;} @@ -2161,8 +2169,8 @@ yyreduce: case 45: -/* Line 1464 of yacc.c */ -#line 349 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 357 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); ;} @@ -2170,8 +2178,8 @@ yyreduce: case 46: -/* Line 1464 of yacc.c */ -#line 352 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 360 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); ;} @@ -2179,8 +2187,8 @@ yyreduce: case 47: -/* Line 1464 of yacc.c */ -#line 355 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 363 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); ;} @@ -2188,8 +2196,8 @@ yyreduce: case 48: -/* Line 1464 of yacc.c */ -#line 358 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 366 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); ;} @@ -2197,8 +2205,8 @@ yyreduce: case 49: -/* Line 1464 of yacc.c */ -#line 364 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 372 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); @@ -2208,8 +2216,8 @@ yyreduce: case 50: -/* Line 1464 of yacc.c */ -#line 369 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 377 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); @@ -2219,15 +2227,15 @@ yyreduce: case 51: -/* Line 1464 of yacc.c */ -#line 377 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 385 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 53: -/* Line 1464 of yacc.c */ -#line 382 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 390 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); ;} @@ -2235,15 +2243,15 @@ yyreduce: case 54: -/* Line 1464 of yacc.c */ -#line 388 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 396 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 57: -/* Line 1464 of yacc.c */ -#line 394 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 402 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); ;} @@ -2251,8 +2259,8 @@ yyreduce: case 58: -/* Line 1464 of yacc.c */ -#line 401 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 409 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2261,8 +2269,8 @@ yyreduce: case 59: -/* Line 1464 of yacc.c */ -#line 405 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 413 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2271,8 +2279,8 @@ yyreduce: case 61: -/* Line 1464 of yacc.c */ -#line 414 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 422 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2283,8 +2291,8 @@ yyreduce: case 62: -/* Line 1464 of yacc.c */ -#line 420 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 428 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2294,8 +2302,8 @@ yyreduce: case 63: -/* Line 1464 of yacc.c */ -#line 428 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 436 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2306,8 +2314,8 @@ yyreduce: case 64: -/* Line 1464 of yacc.c */ -#line 434 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 442 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2317,8 +2325,8 @@ yyreduce: case 65: -/* Line 1464 of yacc.c */ -#line 442 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 450 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2327,8 +2335,8 @@ yyreduce: case 66: -/* Line 1464 of yacc.c */ -#line 446 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 454 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2337,8 +2345,8 @@ yyreduce: case 67: -/* Line 1464 of yacc.c */ -#line 450 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 458 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); (yyval.token)->location = yylloc; @@ -2347,8 +2355,8 @@ yyreduce: case 68: -/* Line 1464 of yacc.c */ -#line 454 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 462 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2357,8 +2365,8 @@ yyreduce: case 69: -/* Line 1464 of yacc.c */ -#line 458 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 466 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); (yyval.token)->location = yylloc; @@ -2367,225 +2375,225 @@ yyreduce: case 70: -/* Line 1464 of yacc.c */ -#line 465 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 473 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 71: -/* Line 1464 of yacc.c */ -#line 466 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 474 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 72: -/* Line 1464 of yacc.c */ -#line 467 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 475 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 73: -/* Line 1464 of yacc.c */ -#line 468 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 476 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 74: -/* Line 1464 of yacc.c */ -#line 469 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 477 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 75: -/* Line 1464 of yacc.c */ -#line 470 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 478 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 76: -/* Line 1464 of yacc.c */ -#line 471 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 479 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 77: -/* Line 1464 of yacc.c */ -#line 472 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 480 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 78: -/* Line 1464 of yacc.c */ -#line 473 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 481 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 79: -/* Line 1464 of yacc.c */ -#line 474 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 482 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 80: -/* Line 1464 of yacc.c */ -#line 475 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 483 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 81: -/* Line 1464 of yacc.c */ -#line 476 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 484 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 82: -/* Line 1464 of yacc.c */ -#line 477 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 485 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 83: -/* Line 1464 of yacc.c */ -#line 478 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 486 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 84: -/* Line 1464 of yacc.c */ -#line 479 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 487 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 85: -/* Line 1464 of yacc.c */ -#line 480 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 488 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 86: -/* Line 1464 of yacc.c */ -#line 481 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 489 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 87: -/* Line 1464 of yacc.c */ -#line 482 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 490 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 88: -/* Line 1464 of yacc.c */ -#line 483 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 491 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 89: -/* Line 1464 of yacc.c */ -#line 484 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 492 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 90: -/* Line 1464 of yacc.c */ -#line 485 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 493 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 91: -/* Line 1464 of yacc.c */ -#line 486 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 494 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 92: -/* Line 1464 of yacc.c */ -#line 487 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 495 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 93: -/* Line 1464 of yacc.c */ -#line 488 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 496 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 94: -/* Line 1464 of yacc.c */ -#line 489 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 497 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 95: -/* Line 1464 of yacc.c */ -#line 490 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 498 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 96: -/* Line 1464 of yacc.c */ -#line 491 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 499 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 97: -/* Line 1464 of yacc.c */ -#line 492 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 500 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 98: -/* Line 1464 of yacc.c */ -#line 493 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 501 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 99: -/* Line 1464 of yacc.c */ -#line 494 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 502 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 100: -/* Line 1464 of yacc.c */ -#line 495 "glcpp/glcpp-parse.y" +/* Line 1455 of yacc.c */ +#line 503 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; -/* Line 1464 of yacc.c */ -#line 2589 "glcpp/glcpp-parse.c" +/* Line 1455 of yacc.c */ +#line 2597 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2803,8 +2811,8 @@ yyreturn: -/* Line 1684 of yacc.c */ -#line 498 "glcpp/glcpp-parse.y" +/* Line 1675 of yacc.c */ +#line 506 "glcpp/glcpp-parse.y" string_list_t * diff --git a/src/glsl/glcpp/glcpp-parse.h b/src/glsl/glcpp/glcpp-parse.h index 53e7af0305d..50758930e9c 100644 --- a/src/glsl/glcpp/glcpp-parse.h +++ b/src/glsl/glcpp/glcpp-parse.h @@ -1,9 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.4.2. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit v1.2.3 From 4f9a64407c948a7a46d23e8d4f7caae6d0e83232 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 10 Aug 2010 18:25:30 -0700 Subject: glcpp: Fix expected result for the 064-version.c test. Commit d4a04f315560704bf1103df0b93723e468725df7 caused this test case to produce an additional blank line, which is otherwise harmless, but does need to be reflected in the .expected file for the test to pass. --- src/glsl/glcpp/tests/064-version.c.expected | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/glcpp/tests/064-version.c.expected b/src/glsl/glcpp/tests/064-version.c.expected index 3af71113c8c..1c534672705 100644 --- a/src/glsl/glcpp/tests/064-version.c.expected +++ b/src/glsl/glcpp/tests/064-version.c.expected @@ -1,3 +1,4 @@ #version 130 + -- cgit v1.2.3 From 9b7fd2099f926b9cc187382ca75eb8dedf3d37ca Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 10 Aug 2010 18:27:31 -0700 Subject: glcpp: Discard output of cmp when running the test suite. We're already using the return-value of cmp to print either PASS or FAIL and in the case of failure, we're subsequently running and showing the output of diff. So any warnings/errors from cmp itself are not actually needed, and can be quite confusing. --- src/glsl/glcpp/tests/glcpp-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/glcpp/tests/glcpp-test b/src/glsl/glcpp/tests/glcpp-test index cfe7e978786..c09e8a96b98 100755 --- a/src/glsl/glcpp/tests/glcpp-test +++ b/src/glsl/glcpp/tests/glcpp-test @@ -9,7 +9,7 @@ for test in *.c; do echo -n "Testing $test..." ../glcpp < $test > $test.out total=$((total+1)) - if cmp $test.expected $test.out; then + if cmp $test.expected $test.out >/dev/null 2>&1; then echo "PASS" pass=$((pass+1)) else -- cgit v1.2.3 From 64b408529aefe0fb5968471431ec0a1b0abd7697 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 9 Aug 2010 14:03:04 -0700 Subject: texture_builtins.py: Remove useless comments. --- src/glsl/builtins/tools/texture_builtins.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py index c4672ae8c12..33d9642ef78 100755 --- a/src/glsl/builtins/tools/texture_builtins.py +++ b/src/glsl/builtins/tools/texture_builtins.py @@ -211,9 +211,9 @@ with open(path.join(builtins_dir, "EXT_texture_array", "textures"), 'w') as sys. with open(path.join(builtins_dir, "EXT_texture_array_fs", "textures"), 'w') as sys.stdout: print "((function texture1DArray" - generate_sigs("", "txb", "1DArray") # MOVE TO _fs + generate_sigs("", "txb", "1DArray") print ")\n (function texture2DArray" - generate_sigs("", "txb", "2DArray") # MOVE TO _fs + generate_sigs("", "txb", "2DArray") print ")\n (function shadow1DArray" generate_sigs("", "txb", "1DArrayShadow") print "))" -- cgit v1.2.3 From 298a6fcddef6a91084ae921fca0b8640eb2e2a16 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 10 Aug 2010 19:16:19 -0700 Subject: glcpp/tests: Commit forgotten file 074-elif-undef.c.expected. --- src/glsl/glcpp/tests/074-elif-undef.c.expected | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/glsl/glcpp/tests/074-elif-undef.c.expected diff --git a/src/glsl/glcpp/tests/074-elif-undef.c.expected b/src/glsl/glcpp/tests/074-elif-undef.c.expected new file mode 100644 index 00000000000..fd40910d9e7 --- /dev/null +++ b/src/glsl/glcpp/tests/074-elif-undef.c.expected @@ -0,0 +1,4 @@ + + + + -- cgit v1.2.3 From 48ba058e7a4b808271ca987b1553efd7e9792da9 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 12:43:44 -0700 Subject: glcpp: Additional fixes for not evaluating skipped #if/#elif expressions. This adds a couple of test cases to expand our coverage of invalid #if and being skipped, (either by being nested inside an #if/#elif that evaluates to zero or by being after an #if/#elif that evaluates to non-zero). --- src/glsl/glcpp/glcpp-parse.y | 60 +++++++++++++++------- src/glsl/glcpp/tests/075-elif-elif-undef.c | 4 ++ .../glcpp/tests/075-elif-elif-undef.c.expected | 5 ++ src/glsl/glcpp/tests/076-elif-undef-nested.c | 5 ++ .../glcpp/tests/076-elif-undef-nested.c.expected | 6 +++ 5 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 src/glsl/glcpp/tests/075-elif-elif-undef.c create mode 100644 src/glsl/glcpp/tests/075-elif-elif-undef.c.expected create mode 100644 src/glsl/glcpp/tests/076-elif-undef-nested.c create mode 100644 src/glsl/glcpp/tests/076-elif-undef-nested.c.expected diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index a4383574506..643c449d0e1 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -223,14 +223,22 @@ control_line: talloc_free ($2); } | HASH_IF conditional_tokens NEWLINE { - /* If we're skipping to the next #elif/#else case or to #endif, - * don't bother expanding or parsing the expression. - */ - if (parser->skip_stack != NULL && parser->skip_stack->type != SKIP_NO_SKIP) { + /* Be careful to only evaluate the 'if' expression if + * we are not skipping. When we are skipping, we + * simply push a new 0-valued 'if' onto the skip + * stack. + * + * This avoids generating diagnostics for invalid + * expressions that are being skipped. */ + if (parser->skip_stack == NULL || + parser->skip_stack->type == SKIP_NO_SKIP) + { + _glcpp_parser_expand_if (parser, IF_EXPANDED, $2); + } + else + { _glcpp_parser_skip_stack_push_if (parser, & @1, 0); parser->skip_stack->type = SKIP_TO_ENDIF; - } else { - _glcpp_parser_expand_if (parser, IF_EXPANDED, $2); } } | HASH_IFDEF IDENTIFIER junk NEWLINE { @@ -244,24 +252,38 @@ control_line: _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); } | HASH_ELIF conditional_tokens NEWLINE { - /* If we just finished a non-skipped #if/#ifdef/#ifndef block, - * don't bother expanding or parsing the expression. - */ - if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) - parser->skip_stack->type = SKIP_TO_ENDIF; - else + /* Be careful to only evaluate the 'elif' expression + * if we are not skipping. When we are skipping, we + * simply change to a 0-valued 'elif' on the skip + * stack. + * + * This avoids generating diagnostics for invalid + * expressions that are being skipped. */ + if (parser->skip_stack && + parser->skip_stack->type == SKIP_TO_ELSE) + { _glcpp_parser_expand_if (parser, ELIF_EXPANDED, $2); + } + else + { + _glcpp_parser_skip_stack_change_if (parser, & @1, + "elif", 0); + } } | HASH_ELIF NEWLINE { - /* #elif without an expression results in a warning if the - * condition doesn't matter (we just handled #if 1 or such) - * but an error otherwise. */ - if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) { - parser->skip_stack->type = SKIP_TO_ENDIF; - glcpp_warning(& @1, parser, "ignoring illegal #elif without expression"); - } else { + /* #elif without an expression is an error unless we + * are skipping. */ + if (parser->skip_stack && + parser->skip_stack->type == SKIP_TO_ELSE) + { glcpp_error(& @1, parser, "#elif needs an expression"); } + else + { + _glcpp_parser_skip_stack_change_if (parser, & @1, + "elif", 0); + glcpp_warning(& @1, parser, "ignoring illegal #elif without expression"); + } } | HASH_ELSE NEWLINE { _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1); diff --git a/src/glsl/glcpp/tests/075-elif-elif-undef.c b/src/glsl/glcpp/tests/075-elif-elif-undef.c new file mode 100644 index 00000000000..264bc4f10ee --- /dev/null +++ b/src/glsl/glcpp/tests/075-elif-elif-undef.c @@ -0,0 +1,4 @@ +#ifndef UNDEF +#elif UNDEF < 0 +#elif UNDEF == 3 +#endif diff --git a/src/glsl/glcpp/tests/075-elif-elif-undef.c.expected b/src/glsl/glcpp/tests/075-elif-elif-undef.c.expected new file mode 100644 index 00000000000..3f2ff2d6cc8 --- /dev/null +++ b/src/glsl/glcpp/tests/075-elif-elif-undef.c.expected @@ -0,0 +1,5 @@ + + + + + diff --git a/src/glsl/glcpp/tests/076-elif-undef-nested.c b/src/glsl/glcpp/tests/076-elif-undef-nested.c new file mode 100644 index 00000000000..ebd550ed005 --- /dev/null +++ b/src/glsl/glcpp/tests/076-elif-undef-nested.c @@ -0,0 +1,5 @@ +#ifdef UNDEF +#if UNDEF == 4 +#elif UNDEF == 5 +#endif +#endif diff --git a/src/glsl/glcpp/tests/076-elif-undef-nested.c.expected b/src/glsl/glcpp/tests/076-elif-undef-nested.c.expected new file mode 100644 index 00000000000..6fb66a5e2f0 --- /dev/null +++ b/src/glsl/glcpp/tests/076-elif-undef-nested.c.expected @@ -0,0 +1,6 @@ + + + + + + -- cgit v1.2.3 From 764e096647ec8c0f20ea3b5191499af806ad23f8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 12:45:55 -0700 Subject: glcpp: Regenerate glcpp-parse.c After a recent change to glcpp-parse.y --- src/glsl/glcpp/glcpp-parse.c | 244 +++++++++++++++++++++++-------------------- 1 file changed, 133 insertions(+), 111 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 2ef00a0c8d7..498d0187640 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -625,16 +625,16 @@ static const yytype_int8 yyrhs[] = static const yytype_uint16 yyrline[] = { 0, 180, 180, 182, 186, 189, 194, 195, 199, 202, - 208, 211, 214, 217, 225, 236, 241, 246, 255, 266, - 269, 272, 281, 285, 294, 299, 300, 303, 306, 309, - 312, 315, 318, 321, 324, 327, 330, 333, 336, 339, - 342, 345, 348, 351, 354, 357, 360, 363, 366, 372, - 377, 385, 386, 390, 396, 397, 400, 402, 409, 413, - 417, 422, 428, 436, 442, 450, 454, 458, 462, 466, - 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, - 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, - 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, - 503 + 208, 211, 214, 217, 225, 244, 249, 254, 273, 288, + 291, 294, 303, 307, 316, 321, 322, 325, 328, 331, + 334, 337, 340, 343, 346, 349, 352, 355, 358, 361, + 364, 367, 370, 373, 376, 379, 382, 385, 388, 394, + 399, 407, 408, 412, 418, 419, 422, 424, 431, 435, + 439, 444, 450, 458, 464, 472, 476, 480, 484, 488, + 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, + 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, + 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, + 525 }; #endif @@ -1873,14 +1873,22 @@ yyreduce: /* Line 1455 of yacc.c */ #line 225 "glcpp/glcpp-parse.y" { - /* If we're skipping to the next #elif/#else case or to #endif, - * don't bother expanding or parsing the expression. - */ - if (parser->skip_stack != NULL && parser->skip_stack->type != SKIP_NO_SKIP) { + /* Be careful to only evaluate the 'if' expression if + * we are not skipping. When we are skipping, we + * simply push a new 0-valued 'if' onto the skip + * stack. + * + * This avoids generating diagnostics for invalid + * expressions that are being skipped. */ + if (parser->skip_stack == NULL || + parser->skip_stack->type == SKIP_NO_SKIP) + { + _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list)); + } + else + { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), 0); parser->skip_stack->type = SKIP_TO_ENDIF; - } else { - _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list)); } ;} break; @@ -1888,7 +1896,7 @@ yyreduce: case 15: /* Line 1455 of yacc.c */ -#line 236 "glcpp/glcpp-parse.y" +#line 244 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1899,7 +1907,7 @@ yyreduce: case 16: /* Line 1455 of yacc.c */ -#line 241 "glcpp/glcpp-parse.y" +#line 249 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1910,39 +1918,53 @@ yyreduce: case 17: /* Line 1455 of yacc.c */ -#line 246 "glcpp/glcpp-parse.y" +#line 254 "glcpp/glcpp-parse.y" { - /* If we just finished a non-skipped #if/#ifdef/#ifndef block, - * don't bother expanding or parsing the expression. - */ - if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) - parser->skip_stack->type = SKIP_TO_ENDIF; - else + /* Be careful to only evaluate the 'elif' expression + * if we are not skipping. When we are skipping, we + * simply change to a 0-valued 'elif' on the skip + * stack. + * + * This avoids generating diagnostics for invalid + * expressions that are being skipped. */ + if (parser->skip_stack && + parser->skip_stack->type == SKIP_TO_ELSE) + { _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list)); + } + else + { + _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), + "elif", 0); + } ;} break; case 18: /* Line 1455 of yacc.c */ -#line 255 "glcpp/glcpp-parse.y" +#line 273 "glcpp/glcpp-parse.y" { - /* #elif without an expression results in a warning if the - * condition doesn't matter (we just handled #if 1 or such) - * but an error otherwise. */ - if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) { - parser->skip_stack->type = SKIP_TO_ENDIF; - glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression"); - } else { + /* #elif without an expression is an error unless we + * are skipping. */ + if (parser->skip_stack && + parser->skip_stack->type == SKIP_TO_ELSE) + { glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif needs an expression"); } + else + { + _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), + "elif", 0); + glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression"); + } ;} break; case 19: /* Line 1455 of yacc.c */ -#line 266 "glcpp/glcpp-parse.y" +#line 288 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); ;} @@ -1951,7 +1973,7 @@ yyreduce: case 20: /* Line 1455 of yacc.c */ -#line 269 "glcpp/glcpp-parse.y" +#line 291 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); ;} @@ -1960,7 +1982,7 @@ yyreduce: case 21: /* Line 1455 of yacc.c */ -#line 272 "glcpp/glcpp-parse.y" +#line 294 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); if (macro) { @@ -1975,7 +1997,7 @@ yyreduce: case 23: /* Line 1455 of yacc.c */ -#line 285 "glcpp/glcpp-parse.y" +#line 307 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); @@ -1990,7 +2012,7 @@ yyreduce: case 24: /* Line 1455 of yacc.c */ -#line 294 "glcpp/glcpp-parse.y" +#line 316 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} @@ -1999,7 +2021,7 @@ yyreduce: case 26: /* Line 1455 of yacc.c */ -#line 300 "glcpp/glcpp-parse.y" +#line 322 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); ;} @@ -2008,7 +2030,7 @@ yyreduce: case 27: /* Line 1455 of yacc.c */ -#line 303 "glcpp/glcpp-parse.y" +#line 325 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); ;} @@ -2017,7 +2039,7 @@ yyreduce: case 28: /* Line 1455 of yacc.c */ -#line 306 "glcpp/glcpp-parse.y" +#line 328 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); ;} @@ -2026,7 +2048,7 @@ yyreduce: case 29: /* Line 1455 of yacc.c */ -#line 309 "glcpp/glcpp-parse.y" +#line 331 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); ;} @@ -2035,7 +2057,7 @@ yyreduce: case 30: /* Line 1455 of yacc.c */ -#line 312 "glcpp/glcpp-parse.y" +#line 334 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); ;} @@ -2044,7 +2066,7 @@ yyreduce: case 31: /* Line 1455 of yacc.c */ -#line 315 "glcpp/glcpp-parse.y" +#line 337 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); ;} @@ -2053,7 +2075,7 @@ yyreduce: case 32: /* Line 1455 of yacc.c */ -#line 318 "glcpp/glcpp-parse.y" +#line 340 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); ;} @@ -2062,7 +2084,7 @@ yyreduce: case 33: /* Line 1455 of yacc.c */ -#line 321 "glcpp/glcpp-parse.y" +#line 343 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); ;} @@ -2071,7 +2093,7 @@ yyreduce: case 34: /* Line 1455 of yacc.c */ -#line 324 "glcpp/glcpp-parse.y" +#line 346 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); ;} @@ -2080,7 +2102,7 @@ yyreduce: case 35: /* Line 1455 of yacc.c */ -#line 327 "glcpp/glcpp-parse.y" +#line 349 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); ;} @@ -2089,7 +2111,7 @@ yyreduce: case 36: /* Line 1455 of yacc.c */ -#line 330 "glcpp/glcpp-parse.y" +#line 352 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); ;} @@ -2098,7 +2120,7 @@ yyreduce: case 37: /* Line 1455 of yacc.c */ -#line 333 "glcpp/glcpp-parse.y" +#line 355 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); ;} @@ -2107,7 +2129,7 @@ yyreduce: case 38: /* Line 1455 of yacc.c */ -#line 336 "glcpp/glcpp-parse.y" +#line 358 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); ;} @@ -2116,7 +2138,7 @@ yyreduce: case 39: /* Line 1455 of yacc.c */ -#line 339 "glcpp/glcpp-parse.y" +#line 361 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); ;} @@ -2125,7 +2147,7 @@ yyreduce: case 40: /* Line 1455 of yacc.c */ -#line 342 "glcpp/glcpp-parse.y" +#line 364 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); ;} @@ -2134,7 +2156,7 @@ yyreduce: case 41: /* Line 1455 of yacc.c */ -#line 345 "glcpp/glcpp-parse.y" +#line 367 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); ;} @@ -2143,7 +2165,7 @@ yyreduce: case 42: /* Line 1455 of yacc.c */ -#line 348 "glcpp/glcpp-parse.y" +#line 370 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); ;} @@ -2152,7 +2174,7 @@ yyreduce: case 43: /* Line 1455 of yacc.c */ -#line 351 "glcpp/glcpp-parse.y" +#line 373 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); ;} @@ -2161,7 +2183,7 @@ yyreduce: case 44: /* Line 1455 of yacc.c */ -#line 354 "glcpp/glcpp-parse.y" +#line 376 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); ;} @@ -2170,7 +2192,7 @@ yyreduce: case 45: /* Line 1455 of yacc.c */ -#line 357 "glcpp/glcpp-parse.y" +#line 379 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); ;} @@ -2179,7 +2201,7 @@ yyreduce: case 46: /* Line 1455 of yacc.c */ -#line 360 "glcpp/glcpp-parse.y" +#line 382 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); ;} @@ -2188,7 +2210,7 @@ yyreduce: case 47: /* Line 1455 of yacc.c */ -#line 363 "glcpp/glcpp-parse.y" +#line 385 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); ;} @@ -2197,7 +2219,7 @@ yyreduce: case 48: /* Line 1455 of yacc.c */ -#line 366 "glcpp/glcpp-parse.y" +#line 388 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); ;} @@ -2206,7 +2228,7 @@ yyreduce: case 49: /* Line 1455 of yacc.c */ -#line 372 "glcpp/glcpp-parse.y" +#line 394 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); @@ -2217,7 +2239,7 @@ yyreduce: case 50: /* Line 1455 of yacc.c */ -#line 377 "glcpp/glcpp-parse.y" +#line 399 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); @@ -2228,14 +2250,14 @@ yyreduce: case 51: /* Line 1455 of yacc.c */ -#line 385 "glcpp/glcpp-parse.y" +#line 407 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 53: /* Line 1455 of yacc.c */ -#line 390 "glcpp/glcpp-parse.y" +#line 412 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); ;} @@ -2244,14 +2266,14 @@ yyreduce: case 54: /* Line 1455 of yacc.c */ -#line 396 "glcpp/glcpp-parse.y" +#line 418 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 57: /* Line 1455 of yacc.c */ -#line 402 "glcpp/glcpp-parse.y" +#line 424 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); ;} @@ -2260,7 +2282,7 @@ yyreduce: case 58: /* Line 1455 of yacc.c */ -#line 409 "glcpp/glcpp-parse.y" +#line 431 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2270,7 +2292,7 @@ yyreduce: case 59: /* Line 1455 of yacc.c */ -#line 413 "glcpp/glcpp-parse.y" +#line 435 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2280,7 +2302,7 @@ yyreduce: case 61: /* Line 1455 of yacc.c */ -#line 422 "glcpp/glcpp-parse.y" +#line 444 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2292,7 +2314,7 @@ yyreduce: case 62: /* Line 1455 of yacc.c */ -#line 428 "glcpp/glcpp-parse.y" +#line 450 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2303,7 +2325,7 @@ yyreduce: case 63: /* Line 1455 of yacc.c */ -#line 436 "glcpp/glcpp-parse.y" +#line 458 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2315,7 +2337,7 @@ yyreduce: case 64: /* Line 1455 of yacc.c */ -#line 442 "glcpp/glcpp-parse.y" +#line 464 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2326,7 +2348,7 @@ yyreduce: case 65: /* Line 1455 of yacc.c */ -#line 450 "glcpp/glcpp-parse.y" +#line 472 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2336,7 +2358,7 @@ yyreduce: case 66: /* Line 1455 of yacc.c */ -#line 454 "glcpp/glcpp-parse.y" +#line 476 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2346,7 +2368,7 @@ yyreduce: case 67: /* Line 1455 of yacc.c */ -#line 458 "glcpp/glcpp-parse.y" +#line 480 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); (yyval.token)->location = yylloc; @@ -2356,7 +2378,7 @@ yyreduce: case 68: /* Line 1455 of yacc.c */ -#line 462 "glcpp/glcpp-parse.y" +#line 484 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2366,7 +2388,7 @@ yyreduce: case 69: /* Line 1455 of yacc.c */ -#line 466 "glcpp/glcpp-parse.y" +#line 488 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); (yyval.token)->location = yylloc; @@ -2376,224 +2398,224 @@ yyreduce: case 70: /* Line 1455 of yacc.c */ -#line 473 "glcpp/glcpp-parse.y" +#line 495 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 71: /* Line 1455 of yacc.c */ -#line 474 "glcpp/glcpp-parse.y" +#line 496 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 72: /* Line 1455 of yacc.c */ -#line 475 "glcpp/glcpp-parse.y" +#line 497 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 73: /* Line 1455 of yacc.c */ -#line 476 "glcpp/glcpp-parse.y" +#line 498 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 74: /* Line 1455 of yacc.c */ -#line 477 "glcpp/glcpp-parse.y" +#line 499 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 75: /* Line 1455 of yacc.c */ -#line 478 "glcpp/glcpp-parse.y" +#line 500 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 76: /* Line 1455 of yacc.c */ -#line 479 "glcpp/glcpp-parse.y" +#line 501 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 77: /* Line 1455 of yacc.c */ -#line 480 "glcpp/glcpp-parse.y" +#line 502 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 78: /* Line 1455 of yacc.c */ -#line 481 "glcpp/glcpp-parse.y" +#line 503 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 79: /* Line 1455 of yacc.c */ -#line 482 "glcpp/glcpp-parse.y" +#line 504 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 80: /* Line 1455 of yacc.c */ -#line 483 "glcpp/glcpp-parse.y" +#line 505 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 81: /* Line 1455 of yacc.c */ -#line 484 "glcpp/glcpp-parse.y" +#line 506 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 82: /* Line 1455 of yacc.c */ -#line 485 "glcpp/glcpp-parse.y" +#line 507 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 83: /* Line 1455 of yacc.c */ -#line 486 "glcpp/glcpp-parse.y" +#line 508 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 84: /* Line 1455 of yacc.c */ -#line 487 "glcpp/glcpp-parse.y" +#line 509 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 85: /* Line 1455 of yacc.c */ -#line 488 "glcpp/glcpp-parse.y" +#line 510 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 86: /* Line 1455 of yacc.c */ -#line 489 "glcpp/glcpp-parse.y" +#line 511 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 87: /* Line 1455 of yacc.c */ -#line 490 "glcpp/glcpp-parse.y" +#line 512 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 88: /* Line 1455 of yacc.c */ -#line 491 "glcpp/glcpp-parse.y" +#line 513 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 89: /* Line 1455 of yacc.c */ -#line 492 "glcpp/glcpp-parse.y" +#line 514 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 90: /* Line 1455 of yacc.c */ -#line 493 "glcpp/glcpp-parse.y" +#line 515 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 91: /* Line 1455 of yacc.c */ -#line 494 "glcpp/glcpp-parse.y" +#line 516 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 92: /* Line 1455 of yacc.c */ -#line 495 "glcpp/glcpp-parse.y" +#line 517 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 93: /* Line 1455 of yacc.c */ -#line 496 "glcpp/glcpp-parse.y" +#line 518 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 94: /* Line 1455 of yacc.c */ -#line 497 "glcpp/glcpp-parse.y" +#line 519 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 95: /* Line 1455 of yacc.c */ -#line 498 "glcpp/glcpp-parse.y" +#line 520 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 96: /* Line 1455 of yacc.c */ -#line 499 "glcpp/glcpp-parse.y" +#line 521 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 97: /* Line 1455 of yacc.c */ -#line 500 "glcpp/glcpp-parse.y" +#line 522 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 98: /* Line 1455 of yacc.c */ -#line 501 "glcpp/glcpp-parse.y" +#line 523 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 99: /* Line 1455 of yacc.c */ -#line 502 "glcpp/glcpp-parse.y" +#line 524 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 100: /* Line 1455 of yacc.c */ -#line 503 "glcpp/glcpp-parse.y" +#line 525 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; /* Line 1455 of yacc.c */ -#line 2597 "glcpp/glcpp-parse.c" +#line 2619 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2812,7 +2834,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 506 "glcpp/glcpp-parse.y" +#line 528 "glcpp/glcpp-parse.y" string_list_t * -- cgit v1.2.3 From 8485f4d9aa6d98304bb0197dc4f1f357d81d1daa Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 12:46:16 -0700 Subject: glcpp: Clean up intermediate file when test suite is interrupted. The glcpp-test script was leaving around bogus *.valgrind-errors files if a valgrind test was interrupted. --- src/glsl/glcpp/tests/glcpp-test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/glcpp/tests/glcpp-test b/src/glsl/glcpp/tests/glcpp-test index c09e8a96b98..2dca848b4a1 100755 --- a/src/glsl/glcpp/tests/glcpp-test +++ b/src/glsl/glcpp/tests/glcpp-test @@ -1,5 +1,7 @@ #!/bin/sh +trap 'rm $test.valgrind-errors; exit 1' INT QUIT + total=0 pass=0 clean=0 -- cgit v1.2.3 From 6dc89d221d43fad5f3edbb903997160af071bec0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Aug 2010 13:59:28 -0600 Subject: glsl2: remove trailing comma to silence warning --- src/glsl/ir.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index d852a6a93bf..eb9e6cdf0e2 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -60,7 +60,7 @@ enum ir_node_type { ir_type_return, ir_type_swizzle, ir_type_texture, - ir_type_max, /**< maximum ir_type enum number, for validation */ + ir_type_max /**< maximum ir_type enum number, for validation */ }; /** -- cgit v1.2.3 From d1dda951c85f65612ed6fe080728f67fdc93d232 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Aug 2010 13:59:45 -0600 Subject: glsl2: move declarations before code --- src/glsl/glcpp/pp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index 7aa1a968de7..3adccf72aab 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -28,6 +28,8 @@ void glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) { + va_list ap; + parser->error = 1; parser->info_log = talloc_asprintf_append(parser->info_log, "%u:%u(%u): " @@ -35,7 +37,6 @@ glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) locp->source, locp->first_line, locp->first_column); - va_list ap; va_start(ap, fmt); parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap); va_end(ap); @@ -45,13 +46,14 @@ glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) void glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) { + va_list ap; + parser->info_log = talloc_asprintf_append(parser->info_log, "%u:%u(%u): " "preprocessor warning: ", locp->source, locp->first_line, locp->first_column); - va_list ap; va_start(ap, fmt); parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap); va_end(ap); -- cgit v1.2.3 From 30d083903f28965122800cc6ba3dc1ad08aff47f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Aug 2010 14:00:02 -0600 Subject: glsl2: remove stray semicolon --- src/mesa/program/hash_table.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/program/hash_table.h b/src/mesa/program/hash_table.h index 228ab948ff4..ec088c7dde1 100644 --- a/src/mesa/program/hash_table.h +++ b/src/mesa/program/hash_table.h @@ -147,6 +147,6 @@ int hash_table_pointer_compare(const void *key1, const void *key2); #ifdef __cplusplus -}; +} #endif #endif /* HASH_TABLE_H */ -- cgit v1.2.3 From ffd3f15e965d451b1aef032015cc2edea66c30fa Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Aug 2010 14:00:15 -0600 Subject: glsl2: add cast to silence warning --- src/glsl/ir_structure_splitting.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_structure_splitting.cpp b/src/glsl/ir_structure_splitting.cpp index 9dc59412073..2f838962631 100644 --- a/src/glsl/ir_structure_splitting.cpp +++ b/src/glsl/ir_structure_splitting.cpp @@ -401,7 +401,7 @@ do_structure_splitting(exec_list *instructions) if (debug) { printf("structure %s@%p: decl %d, whole_access %d\n", - entry->var->name, entry->var, entry->declaration, + entry->var->name, (void *) entry->var, entry->declaration, entry->whole_structure_access); } -- cgit v1.2.3 From d3b66be3c7a3e9e29913ea86880c516e2b7a3ce0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Aug 2010 14:00:36 -0600 Subject: glsl2: added casts to silence warnings --- src/glsl/ir_print_visitor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 39b11bb32cc..83e64032723 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -45,7 +45,7 @@ _mesa_print_ir(exec_list *instructions, const glsl_type *const s = state->user_structures[i]; printf("(structure (%s) (%s@%p) (%u) (\n", - s->name, s->name, s, s->length); + s->name, s->name, (void *) s, s->length); for (unsigned j = 0; j < s->length; j++) { printf("\t(("); @@ -83,7 +83,7 @@ print_type(const glsl_type *t) printf(" %u)", t->length); } else if ((t->base_type == GLSL_TYPE_STRUCT) && (strncmp("gl_", t->name, 3) != 0)) { - printf("%s@%p", t->name, t); + printf("%s@%p", t->name, (void *) t); } else { printf("%s", t->name); } @@ -104,7 +104,7 @@ void ir_print_visitor::visit(ir_variable *ir) cent, inv, mode[ir->mode], interp[ir->interpolation]); print_type(ir->type); - printf(" %s@%p)", ir->name, ir); + printf(" %s@%p)", ir->name, (void *) ir); } @@ -266,7 +266,7 @@ void ir_print_visitor::visit(ir_swizzle *ir) void ir_print_visitor::visit(ir_dereference_variable *ir) { ir_variable *var = ir->variable_referenced(); - printf("(var_ref %s@%p) ", var->name, var); + printf("(var_ref %s@%p) ", var->name, (void *) var); } -- cgit v1.2.3 From 4415a846457622061cd93be2fdce2448b2eeb00b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Aug 2010 14:04:32 -0600 Subject: glsl2: remove stray semicolon --- src/mesa/main/shaderobj.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h index b48244dc0d2..1b96316b67b 100644 --- a/src/mesa/main/shaderobj.h +++ b/src/mesa/main/shaderobj.h @@ -92,7 +92,7 @@ extern void _mesa_free_shader_state(GLcontext *ctx); #ifdef __cplusplus -}; +} #endif #endif /* SHADEROBJ_H */ -- cgit v1.2.3 From 9f9386d22aca8d14d1b1e6d4de9b24dcb183ca10 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Aug 2010 14:04:51 -0600 Subject: glsl2: added casts to silence warnings --- src/glsl/glsl_types.cpp | 4 ++-- src/glsl/ir_dead_code.cpp | 6 +++--- src/glsl/ir_validate.cpp | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 9b1bef6cb85..2aba1e0ac1d 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -400,7 +400,7 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) * named 'foo'. */ char key[128]; - snprintf(key, sizeof(key), "%p[%u]", base, array_size); + snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size); const glsl_type *t = (glsl_type *) hash_table_find(array_types, key); if (t == NULL) { @@ -458,7 +458,7 @@ glsl_type::record_key_hash(const void *a) break; size += snprintf(& hash_key[size], sizeof(hash_key) - size, - "%p", key->fields.structure[i].type); + "%p", (void *) key->fields.structure[i].type); } return hash_table_string_hash(& hash_key); diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp index 87988871c7e..fce921262f4 100644 --- a/src/glsl/ir_dead_code.cpp +++ b/src/glsl/ir_dead_code.cpp @@ -64,7 +64,7 @@ do_dead_code(exec_list *instructions) if (debug) { printf("%s@%p: %d refs, %d assigns, %sdeclared in our scope\n", - entry->var->name, entry->var, + entry->var->name, (void *) entry->var, entry->referenced_count, entry->assigned_count, entry->declaration ? "" : "not "); } @@ -85,7 +85,7 @@ do_dead_code(exec_list *instructions) if (debug) { printf("Removed assignment to %s@%p\n", - entry->var->name, entry->var); + entry->var->name, (void *) entry->var); } } } else { @@ -97,7 +97,7 @@ do_dead_code(exec_list *instructions) if (debug) { printf("Removed declaration of %s@%p\n", - entry->var->name, entry->var); + entry->var->name, (void *) entry->var); } } } diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 545fe2799f3..6e08fa4025a 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -82,14 +82,14 @@ ir_validate::visit(ir_dereference_variable *ir) { if ((ir->var == NULL) || (ir->var->as_variable() == NULL)) { printf("ir_dereference_variable @ %p does not specify a variable %p\n", - ir, ir->var); + (void *) ir, (void *) ir->var); abort(); } if (hash_table_find(ht, ir->var) == NULL) { printf("ir_dereference_variable @ %p specifies undeclared variable " "`%s' @ %p\n", - ir, ir->var->name, ir->var); + (void *) ir, ir->var->name, (void *) ir->var); abort(); } @@ -122,8 +122,8 @@ ir_validate::visit_enter(ir_function *ir) printf("Function definition nested inside another function " "definition:\n"); printf("%s %p inside %s %p\n", - ir->name, ir, - this->current_function->name, this->current_function); + ir->name, (void *) ir, + this->current_function->name, (void *) this->current_function); abort(); } @@ -154,9 +154,9 @@ ir_validate::visit_enter(ir_function_signature *ir) printf("Function signature nested inside wrong function " "definition:\n"); printf("%p inside %s %p instead of %s %p\n", - ir, - this->current_function->name, this->current_function, - ir->function_name(), ir->function()); + (void *) ir, + this->current_function->name, (void *) this->current_function, + ir->function_name(), (void *) ir->function()); abort(); } -- cgit v1.2.3 From 9b2d3c3285596a14a399c8243b1f426d887dc9d7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Aug 2010 14:27:56 -0600 Subject: osmesa: link with new libglsl.a lib --- src/mesa/drivers/osmesa/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mesa/drivers/osmesa/Makefile b/src/mesa/drivers/osmesa/Makefile index c6b4a040851..091e6f66d9b 100644 --- a/src/mesa/drivers/osmesa/Makefile +++ b/src/mesa/drivers/osmesa/Makefile @@ -23,8 +23,7 @@ INCLUDE_DIRS = \ CORE_MESA = \ $(TOP)/src/mesa/libmesa.a \ $(TOP)/src/mapi/glapi/libglapi.a \ - $(TOP)/src/glsl/cl/libglslcl.a \ - $(TOP)/src/glsl/pp/libglslpp.a + $(TOP)/src/glsl/libglsl.a .c.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ -- cgit v1.2.3 From dcb3a2899eb6c6601317500b9fb24c29b5d28299 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Aug 2010 14:28:55 -0600 Subject: configs: added -ltalloc to config files --- configs/default | 2 +- configs/linux-llvm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/default b/configs/default index 8711a382cc0..4f6334b43ba 100644 --- a/configs/default +++ b/configs/default @@ -116,7 +116,7 @@ EGL_CLIENT_APIS = $(GL_LIB) # Library dependencies #EXTRA_LIB_PATH ?= -GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread +GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread -ltalloc EGL_LIB_DEPS = $(EXTRA_LIB_PATH) -ldl -lpthread OSMESA_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) GLU_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm diff --git a/configs/linux-llvm b/configs/linux-llvm index 83d2fc37176..6aa434032dc 100644 --- a/configs/linux-llvm +++ b/configs/linux-llvm @@ -41,4 +41,4 @@ else endif LD = g++ -GL_LIB_DEPS = $(LLVM_LDFLAGS) $(LLVM_LIBS) $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread -lstdc++ -ludis86 +GL_LIB_DEPS = $(LLVM_LDFLAGS) $(LLVM_LIBS) $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread -ltalloc -lstdc++ -ludis86 -- cgit v1.2.3 From 2bcff4c879acec31ef0b39ecf04e9df41c5cbfab Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 13:06:36 -0700 Subject: glcpp-test: Capture the stderr output of the preprocessor. This allows writing tests that verify diagnostics from the preprocessor. --- src/glsl/glcpp/tests/glcpp-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/glcpp/tests/glcpp-test b/src/glsl/glcpp/tests/glcpp-test index 2dca848b4a1..6494d0c0e77 100755 --- a/src/glsl/glcpp/tests/glcpp-test +++ b/src/glsl/glcpp/tests/glcpp-test @@ -9,7 +9,7 @@ clean=0 echo "====== Testing for correctness ======" for test in *.c; do echo -n "Testing $test..." - ../glcpp < $test > $test.out + ../glcpp < $test > $test.out 2>&1 total=$((total+1)) if cmp $test.expected $test.out >/dev/null 2>&1; then echo "PASS" -- cgit v1.2.3 From bc64b8980803a5ba1cc91c63dc2ed1517db800c6 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 13:09:14 -0700 Subject: glcpp: Initialize line and column numbers to 1, not 0. Error messages make more sense this way since the convention is for the first line of a file to be numbered from 1, rather than 0. --- src/glsl/glcpp/glcpp-lex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 1a0052d689a..fa628913540 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -43,7 +43,7 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner); yylloc->first_line = yylineno; \ yycolumn += yyleng; \ } while(0); -#define YY_USER_INIT yylineno = 0; yycolumn = 0; +#define YY_USER_INIT yylineno = 1; yycolumn = 1; %} %option bison-bridge bison-locations reentrant noyywrap -- cgit v1.2.3 From 5a6285cc862df35ef5275c3858f833e0807dee14 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 13:13:41 -0700 Subject: glcpp: Regenerate glcpp-lex.c After a recent change to glcpp-lex.l --- src/glsl/glcpp/glcpp-lex.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/glsl/glcpp/glcpp-lex.c b/src/glsl/glcpp/glcpp-lex.c index d9769041351..bdb3b2c11b0 100644 --- a/src/glsl/glcpp/glcpp-lex.c +++ b/src/glsl/glcpp/glcpp-lex.c @@ -54,7 +54,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -85,6 +84,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -158,7 +159,15 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -680,9 +689,9 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner); yylloc->first_line = yylineno; \ yycolumn += yyleng; \ } while(0); -#define YY_USER_INIT yylineno = 0; yycolumn = 0; +#define YY_USER_INIT yylineno = 1; yycolumn = 1; -#line 686 "glcpp/glcpp-lex.c" +#line 695 "glcpp/glcpp-lex.c" #define INITIAL 0 #define DONE 1 @@ -837,7 +846,12 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -845,7 +859,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -856,7 +870,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -948,7 +962,7 @@ YY_DECL /* Single-line comments */ -#line 952 "glcpp/glcpp-lex.c" +#line 966 "glcpp/glcpp-lex.c" yylval = yylval_param; @@ -1428,7 +1442,7 @@ YY_RULE_SETUP #line 286 "glcpp/glcpp-lex.l" ECHO; YY_BREAK -#line 1432 "glcpp/glcpp-lex.c" +#line 1446 "glcpp/glcpp-lex.c" case YY_STATE_EOF(DONE): case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(UNREACHABLE): @@ -2167,8 +2181,8 @@ YY_BUFFER_STATE glcpp__scan_string (yyconst char * yystr , yyscan_t yyscanner) /** Setup the input buffer state to scan the given bytes. The next call to glcpp_lex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -- cgit v1.2.3 From cb5ea0c79bd74ea6263d54302ed19c243ceb05de Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 13:48:13 -0700 Subject: glcpp: Add several tests for diagnostics. Which are proving to be useful since some of these tests are not yet acting as desired, (in particular, the unterminated if test is not generating any diagnostic). --- src/glsl/glcpp/tests/070-undefined-macro-in-expression.c | 2 ++ .../glcpp/tests/070-undefined-macro-in-expression.c.expected | 2 ++ src/glsl/glcpp/tests/077-else-without-if.c | 1 + src/glsl/glcpp/tests/077-else-without-if.c.expected | 4 ++++ src/glsl/glcpp/tests/078-elif-without-if.c | 1 + src/glsl/glcpp/tests/078-elif-without-if.c.expected | 4 ++++ src/glsl/glcpp/tests/079-endif-without-if.c | 1 + src/glsl/glcpp/tests/079-endif-without-if.c.expected | 4 ++++ src/glsl/glcpp/tests/080-if-without-expression.c | 4 ++++ src/glsl/glcpp/tests/080-if-without-expression.c.expected | 3 +++ src/glsl/glcpp/tests/081-elif-without-expression.c | 3 +++ src/glsl/glcpp/tests/081-elif-without-expression.c.expected | 6 ++++++ src/glsl/glcpp/tests/082-invalid-paste.c | 2 ++ src/glsl/glcpp/tests/082-invalid-paste.c.expected | 5 +++++ src/glsl/glcpp/tests/083-unterminated-if.c | 2 ++ src/glsl/glcpp/tests/084-unbalanced-parentheses.c | 2 ++ src/glsl/glcpp/tests/085-incorrect-argument-count.c | 5 +++++ src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected | 12 ++++++++++++ src/glsl/glcpp/tests/086-reserved-macro-names.c | 2 ++ src/glsl/glcpp/tests/086-reserved-macro-names.c.expected | 7 +++++++ 20 files changed, 72 insertions(+) create mode 100644 src/glsl/glcpp/tests/070-undefined-macro-in-expression.c create mode 100644 src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected create mode 100644 src/glsl/glcpp/tests/077-else-without-if.c create mode 100644 src/glsl/glcpp/tests/077-else-without-if.c.expected create mode 100644 src/glsl/glcpp/tests/078-elif-without-if.c create mode 100644 src/glsl/glcpp/tests/078-elif-without-if.c.expected create mode 100644 src/glsl/glcpp/tests/079-endif-without-if.c create mode 100644 src/glsl/glcpp/tests/079-endif-without-if.c.expected create mode 100644 src/glsl/glcpp/tests/080-if-without-expression.c create mode 100644 src/glsl/glcpp/tests/080-if-without-expression.c.expected create mode 100644 src/glsl/glcpp/tests/081-elif-without-expression.c create mode 100644 src/glsl/glcpp/tests/081-elif-without-expression.c.expected create mode 100644 src/glsl/glcpp/tests/082-invalid-paste.c create mode 100644 src/glsl/glcpp/tests/082-invalid-paste.c.expected create mode 100644 src/glsl/glcpp/tests/083-unterminated-if.c create mode 100644 src/glsl/glcpp/tests/084-unbalanced-parentheses.c create mode 100644 src/glsl/glcpp/tests/085-incorrect-argument-count.c create mode 100644 src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected create mode 100644 src/glsl/glcpp/tests/086-reserved-macro-names.c create mode 100644 src/glsl/glcpp/tests/086-reserved-macro-names.c.expected diff --git a/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c b/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c new file mode 100644 index 00000000000..b6dc2ba075f --- /dev/null +++ b/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c @@ -0,0 +1,2 @@ +#if UNDEFINED_MACRO +#endif diff --git a/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected b/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected new file mode 100644 index 00000000000..2bb38a1411e --- /dev/null +++ b/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected @@ -0,0 +1,2 @@ +0:1(21): preprocessor error: syntax error, unexpected IDENTIFIER + diff --git a/src/glsl/glcpp/tests/077-else-without-if.c b/src/glsl/glcpp/tests/077-else-without-if.c new file mode 100644 index 00000000000..81f00bfe278 --- /dev/null +++ b/src/glsl/glcpp/tests/077-else-without-if.c @@ -0,0 +1 @@ +#else diff --git a/src/glsl/glcpp/tests/077-else-without-if.c.expected b/src/glsl/glcpp/tests/077-else-without-if.c.expected new file mode 100644 index 00000000000..d289b363562 --- /dev/null +++ b/src/glsl/glcpp/tests/077-else-without-if.c.expected @@ -0,0 +1,4 @@ +0:1(2): preprocessor error: else without #if + + + diff --git a/src/glsl/glcpp/tests/078-elif-without-if.c b/src/glsl/glcpp/tests/078-elif-without-if.c new file mode 100644 index 00000000000..60466b3890a --- /dev/null +++ b/src/glsl/glcpp/tests/078-elif-without-if.c @@ -0,0 +1 @@ +#elif defined FOO diff --git a/src/glsl/glcpp/tests/078-elif-without-if.c.expected b/src/glsl/glcpp/tests/078-elif-without-if.c.expected new file mode 100644 index 00000000000..7d41f0ac794 --- /dev/null +++ b/src/glsl/glcpp/tests/078-elif-without-if.c.expected @@ -0,0 +1,4 @@ +0:1(2): preprocessor error: elif without #if + + + diff --git a/src/glsl/glcpp/tests/079-endif-without-if.c b/src/glsl/glcpp/tests/079-endif-without-if.c new file mode 100644 index 00000000000..69331c3ca9d --- /dev/null +++ b/src/glsl/glcpp/tests/079-endif-without-if.c @@ -0,0 +1 @@ +#endif diff --git a/src/glsl/glcpp/tests/079-endif-without-if.c.expected b/src/glsl/glcpp/tests/079-endif-without-if.c.expected new file mode 100644 index 00000000000..08dd33546f2 --- /dev/null +++ b/src/glsl/glcpp/tests/079-endif-without-if.c.expected @@ -0,0 +1,4 @@ +0:1(2): preprocessor error: #endif without #if + + + diff --git a/src/glsl/glcpp/tests/080-if-without-expression.c b/src/glsl/glcpp/tests/080-if-without-expression.c new file mode 100644 index 00000000000..a27ba36a366 --- /dev/null +++ b/src/glsl/glcpp/tests/080-if-without-expression.c @@ -0,0 +1,4 @@ +/* Error message for unskipped #if with no expression. */ +#if +#endif + diff --git a/src/glsl/glcpp/tests/080-if-without-expression.c.expected b/src/glsl/glcpp/tests/080-if-without-expression.c.expected new file mode 100644 index 00000000000..1a3e383e9ad --- /dev/null +++ b/src/glsl/glcpp/tests/080-if-without-expression.c.expected @@ -0,0 +1,3 @@ +0:2(1): preprocessor error: #if with no expression + + diff --git a/src/glsl/glcpp/tests/081-elif-without-expression.c b/src/glsl/glcpp/tests/081-elif-without-expression.c new file mode 100644 index 00000000000..79c78663dd3 --- /dev/null +++ b/src/glsl/glcpp/tests/081-elif-without-expression.c @@ -0,0 +1,3 @@ +#if 0 +#elif +#endif diff --git a/src/glsl/glcpp/tests/081-elif-without-expression.c.expected b/src/glsl/glcpp/tests/081-elif-without-expression.c.expected new file mode 100644 index 00000000000..37dcdc3238a --- /dev/null +++ b/src/glsl/glcpp/tests/081-elif-without-expression.c.expected @@ -0,0 +1,6 @@ +0:2(1): preprocessor error: #elif with no expression + + + + + diff --git a/src/glsl/glcpp/tests/082-invalid-paste.c b/src/glsl/glcpp/tests/082-invalid-paste.c new file mode 100644 index 00000000000..40bf64411c5 --- /dev/null +++ b/src/glsl/glcpp/tests/082-invalid-paste.c @@ -0,0 +1,2 @@ +#define PASTE(x,y) x ## y +PASTE(<,>) diff --git a/src/glsl/glcpp/tests/082-invalid-paste.c.expected b/src/glsl/glcpp/tests/082-invalid-paste.c.expected new file mode 100644 index 00000000000..2c924406b59 --- /dev/null +++ b/src/glsl/glcpp/tests/082-invalid-paste.c.expected @@ -0,0 +1,5 @@ +0:2(7): preprocessor error: +Pasting "<" and ">" does not give a valid preprocessing token. + +< + diff --git a/src/glsl/glcpp/tests/083-unterminated-if.c b/src/glsl/glcpp/tests/083-unterminated-if.c new file mode 100644 index 00000000000..91806350927 --- /dev/null +++ b/src/glsl/glcpp/tests/083-unterminated-if.c @@ -0,0 +1,2 @@ +#if 1 + diff --git a/src/glsl/glcpp/tests/084-unbalanced-parentheses.c b/src/glsl/glcpp/tests/084-unbalanced-parentheses.c new file mode 100644 index 00000000000..0789ba5e525 --- /dev/null +++ b/src/glsl/glcpp/tests/084-unbalanced-parentheses.c @@ -0,0 +1,2 @@ +#define FUNC(x) (2*(x)) +FUNC(23 diff --git a/src/glsl/glcpp/tests/085-incorrect-argument-count.c b/src/glsl/glcpp/tests/085-incorrect-argument-count.c new file mode 100644 index 00000000000..91bea600612 --- /dev/null +++ b/src/glsl/glcpp/tests/085-incorrect-argument-count.c @@ -0,0 +1,5 @@ +#define MULT(x,y) ((x)*(y)) +MULT() +MULT(1) +MULT(1,2,3) + diff --git a/src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected b/src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected new file mode 100644 index 00000000000..1df30cbb56f --- /dev/null +++ b/src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected @@ -0,0 +1,12 @@ +0:2(1): preprocessor error: Error: macro MULT invoked with 1 arguments (expected 2) + +0:3(1): preprocessor error: Error: macro MULT invoked with 1 arguments (expected 2) + +0:4(1): preprocessor error: Error: macro MULT invoked with 3 arguments (expected 2) + + +MULT() +MULT(1) +MULT(1,2,3) + + diff --git a/src/glsl/glcpp/tests/086-reserved-macro-names.c b/src/glsl/glcpp/tests/086-reserved-macro-names.c new file mode 100644 index 00000000000..fd0c29f0c47 --- /dev/null +++ b/src/glsl/glcpp/tests/086-reserved-macro-names.c @@ -0,0 +1,2 @@ +#define __BAD reserved +#define GL_ALSO_BAD() also reserved diff --git a/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected b/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected new file mode 100644 index 00000000000..6a9df682685 --- /dev/null +++ b/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected @@ -0,0 +1,7 @@ +0:1(10): preprocessor error: Macro names starting with "__" are reserved. + +0:2(9): preprocessor error: Macro names starting with "GL_" are reserved. + + + + -- cgit v1.2.3 From 624dd585c72103e5bffbc600cdf7bdfba5305a15 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 13:50:51 -0700 Subject: glcpp: Reword diagnostic for #elif with no expression Rather than telling the user what to fix, the standard convention is to describe what the detected problem is. With this change, test 081-elif-without-expression now passes. --- src/glsl/glcpp/glcpp-parse.c | 2 +- src/glsl/glcpp/glcpp-parse.y | 2 +- src/glsl/glcpp/tests/081-elif-without-expression.c.expected | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 498d0187640..05bb7ca48b5 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -1950,7 +1950,7 @@ yyreduce: if (parser->skip_stack && parser->skip_stack->type == SKIP_TO_ELSE) { - glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif needs an expression"); + glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif with no expression"); } else { diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 643c449d0e1..795030ecfe7 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -276,7 +276,7 @@ control_line: if (parser->skip_stack && parser->skip_stack->type == SKIP_TO_ELSE) { - glcpp_error(& @1, parser, "#elif needs an expression"); + glcpp_error(& @1, parser, "#elif with no expression"); } else { diff --git a/src/glsl/glcpp/tests/081-elif-without-expression.c.expected b/src/glsl/glcpp/tests/081-elif-without-expression.c.expected index 37dcdc3238a..974f0f550eb 100644 --- a/src/glsl/glcpp/tests/081-elif-without-expression.c.expected +++ b/src/glsl/glcpp/tests/081-elif-without-expression.c.expected @@ -3,4 +3,3 @@ - -- cgit v1.2.3 From 253cad3f424f71f6984431e5edbde1694ccfae3f Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 13:59:22 -0700 Subject: glcpp: Add an explicit diagnostic for #if with no expression. This is more clear than the previously-generated diagnostic which was something confusing like "enexpected newline". This change makse test 080-if-witout-expression.c now pass. --- src/glsl/glcpp/glcpp-parse.y | 10 ++++++++++ src/glsl/glcpp/tests/080-if-without-expression.c.expected | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 795030ecfe7..0e0d9d412b6 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -241,6 +241,16 @@ control_line: parser->skip_stack->type = SKIP_TO_ENDIF; } } +| HASH_IF NEWLINE { + /* #if without an expression is only an error if we + * are not skipping */ + if (parser->skip_stack == NULL || + parser->skip_stack->type == SKIP_NO_SKIP) + { + glcpp_error(& @1, parser, "#if with no expression"); + } + _glcpp_parser_skip_stack_push_if (parser, & @1, 0); + } | HASH_IFDEF IDENTIFIER junk NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); talloc_free ($2); diff --git a/src/glsl/glcpp/tests/080-if-without-expression.c.expected b/src/glsl/glcpp/tests/080-if-without-expression.c.expected index 1a3e383e9ad..768ba0f473f 100644 --- a/src/glsl/glcpp/tests/080-if-without-expression.c.expected +++ b/src/glsl/glcpp/tests/080-if-without-expression.c.expected @@ -1,3 +1,6 @@ 0:2(1): preprocessor error: #if with no expression - + + + + -- cgit v1.2.3 From 6b9e7b034ca5d10cd367a2388c5439cdb10a1a68 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 14:00:21 -0700 Subject: glccp: Regenerate glcpp-parse.c Due to a recent change to glcpp-parse.y. --- src/glsl/glcpp/glcpp-parse.c | 769 ++++++++++++++++++++++--------------------- 1 file changed, 393 insertions(+), 376 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 05bb7ca48b5..fe7549e5c5f 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -517,16 +517,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 604 +#define YYLAST 606 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 57 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 17 /* YYNRULES -- Number of rules. */ -#define YYNRULES 100 +#define YYNRULES 101 /* YYNRULES -- Number of states. */ -#define YYNSTATES 161 +#define YYNSTATES 162 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -575,16 +575,16 @@ static const yytype_uint8 yytranslate[] = static const yytype_uint16 yyprhs[] = { 0, 0, 3, 4, 7, 9, 11, 13, 16, 20, - 24, 29, 36, 44, 48, 52, 57, 62, 66, 69, - 72, 75, 79, 82, 84, 86, 88, 92, 96, 100, - 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, - 144, 148, 152, 156, 160, 163, 166, 169, 172, 176, - 178, 182, 184, 187, 190, 191, 193, 194, 196, 199, - 204, 206, 208, 211, 213, 216, 218, 220, 222, 224, - 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, - 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, - 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, - 286 + 24, 29, 36, 44, 48, 52, 55, 60, 65, 69, + 72, 75, 78, 82, 85, 87, 89, 91, 95, 99, + 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, + 143, 147, 151, 155, 159, 163, 166, 169, 172, 175, + 179, 181, 185, 187, 190, 193, 194, 196, 197, 199, + 202, 207, 209, 211, 214, 216, 219, 221, 223, 225, + 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, + 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, + 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, + 287, 289 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -595,46 +595,47 @@ static const yytype_int8 yyrhs[] = 5, 63, 21, -1, 8, 17, 67, 21, -1, 7, 17, 45, 46, 67, 21, -1, 7, 17, 45, 64, 46, 67, 21, -1, 15, 17, 21, -1, 12, 70, - 21, -1, 13, 17, 68, 21, -1, 14, 17, 68, - 21, -1, 9, 70, 21, -1, 9, 21, -1, 10, - 21, -1, 11, 21, -1, 16, 62, 21, -1, 6, - 21, -1, 20, -1, 19, -1, 62, -1, 63, 26, - 63, -1, 63, 27, 63, -1, 63, 28, 63, -1, - 63, 29, 63, -1, 63, 30, 63, -1, 63, 31, - 63, -1, 63, 32, 63, -1, 63, 35, 63, -1, - 63, 36, 63, -1, 63, 34, 63, -1, 63, 33, - 63, -1, 63, 37, 63, -1, 63, 38, 63, -1, - 63, 40, 63, -1, 63, 39, 63, -1, 63, 43, - 63, -1, 63, 42, 63, -1, 63, 41, 63, -1, - 47, 63, -1, 48, 63, -1, 40, 63, -1, 39, - 63, -1, 45, 63, 46, -1, 17, -1, 64, 49, - 17, -1, 21, -1, 71, 21, -1, 71, 21, -1, - -1, 71, -1, -1, 71, -1, 4, 17, -1, 4, - 45, 17, 46, -1, 72, -1, 69, -1, 70, 69, - -1, 72, -1, 71, 72, -1, 17, -1, 20, -1, - 73, -1, 22, -1, 24, -1, 50, -1, 51, -1, - 45, -1, 46, -1, 52, -1, 53, -1, 54, -1, - 30, -1, 41, -1, 39, -1, 40, -1, 48, -1, - 47, -1, 42, -1, 43, -1, 38, -1, 37, -1, - 33, -1, 34, -1, 36, -1, 35, -1, 32, -1, - 31, -1, 29, -1, 28, -1, 27, -1, 26, -1, - 55, -1, 49, -1, 56, -1, 25, -1 + 21, -1, 12, 21, -1, 13, 17, 68, 21, -1, + 14, 17, 68, 21, -1, 9, 70, 21, -1, 9, + 21, -1, 10, 21, -1, 11, 21, -1, 16, 62, + 21, -1, 6, 21, -1, 20, -1, 19, -1, 62, + -1, 63, 26, 63, -1, 63, 27, 63, -1, 63, + 28, 63, -1, 63, 29, 63, -1, 63, 30, 63, + -1, 63, 31, 63, -1, 63, 32, 63, -1, 63, + 35, 63, -1, 63, 36, 63, -1, 63, 34, 63, + -1, 63, 33, 63, -1, 63, 37, 63, -1, 63, + 38, 63, -1, 63, 40, 63, -1, 63, 39, 63, + -1, 63, 43, 63, -1, 63, 42, 63, -1, 63, + 41, 63, -1, 47, 63, -1, 48, 63, -1, 40, + 63, -1, 39, 63, -1, 45, 63, 46, -1, 17, + -1, 64, 49, 17, -1, 21, -1, 71, 21, -1, + 71, 21, -1, -1, 71, -1, -1, 71, -1, 4, + 17, -1, 4, 45, 17, 46, -1, 72, -1, 69, + -1, 70, 69, -1, 72, -1, 71, 72, -1, 17, + -1, 20, -1, 73, -1, 22, -1, 24, -1, 50, + -1, 51, -1, 45, -1, 46, -1, 52, -1, 53, + -1, 54, -1, 30, -1, 41, -1, 39, -1, 40, + -1, 48, -1, 47, -1, 42, -1, 43, -1, 38, + -1, 37, -1, 33, -1, 34, -1, 36, -1, 35, + -1, 32, -1, 31, -1, 29, -1, 28, -1, 27, + -1, 26, -1, 55, -1, 49, -1, 56, -1, 25, + -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 180, 180, 182, 186, 189, 194, 195, 199, 202, - 208, 211, 214, 217, 225, 244, 249, 254, 273, 288, - 291, 294, 303, 307, 316, 321, 322, 325, 328, 331, - 334, 337, 340, 343, 346, 349, 352, 355, 358, 361, - 364, 367, 370, 373, 376, 379, 382, 385, 388, 394, - 399, 407, 408, 412, 418, 419, 422, 424, 431, 435, - 439, 444, 450, 458, 464, 472, 476, 480, 484, 488, - 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, - 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, - 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, - 525 + 208, 211, 214, 217, 225, 244, 254, 259, 264, 283, + 298, 301, 304, 313, 317, 326, 331, 332, 335, 338, + 341, 344, 347, 350, 353, 356, 359, 362, 365, 368, + 371, 374, 377, 380, 383, 386, 389, 392, 395, 398, + 404, 409, 417, 418, 422, 428, 429, 432, 434, 441, + 445, 449, 454, 460, 468, 474, 482, 486, 490, 494, + 498, 505, 506, 507, 508, 509, 510, 511, 512, 513, + 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, + 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, + 534, 535 }; #endif @@ -678,31 +679,31 @@ static const yytype_uint8 yyr1[] = { 0, 57, 58, 58, 59, 59, 59, 59, 60, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 62, 62, 63, 63, 63, 63, 63, + 61, 61, 61, 61, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, - 64, 65, 65, 66, 67, 67, 68, 68, 69, 69, - 69, 70, 70, 71, 71, 72, 72, 72, 72, 72, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 64, 64, 65, 65, 66, 67, 67, 68, 68, 69, + 69, 69, 70, 70, 71, 71, 72, 72, 72, 72, + 72, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73 + 73, 73 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 0, 2, 1, 1, 1, 2, 3, 3, - 4, 6, 7, 3, 3, 4, 4, 3, 2, 2, - 2, 3, 2, 1, 1, 1, 3, 3, 3, 3, + 4, 6, 7, 3, 3, 2, 4, 4, 3, 2, + 2, 2, 3, 2, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 2, 2, 2, 2, 3, 1, - 3, 1, 2, 2, 0, 1, 0, 1, 2, 4, - 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, + 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, + 1, 3, 1, 2, 2, 0, 1, 0, 1, 2, + 4, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1 + 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -711,60 +712,60 @@ static const yytype_uint8 yyr2[] = static const yytype_uint8 yydefact[] = { 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 65, 0, 66, 51, 68, - 69, 100, 96, 95, 94, 93, 77, 92, 91, 87, - 88, 90, 89, 86, 85, 79, 80, 78, 83, 84, - 72, 73, 82, 81, 98, 70, 71, 74, 75, 76, - 97, 99, 3, 6, 4, 5, 0, 63, 67, 24, - 23, 0, 0, 0, 0, 0, 25, 0, 22, 7, - 0, 0, 54, 0, 18, 61, 0, 60, 19, 20, - 0, 56, 56, 0, 0, 0, 52, 64, 47, 46, - 0, 44, 45, 9, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 66, 0, 67, 52, 69, + 70, 101, 97, 96, 95, 94, 78, 93, 92, 88, + 89, 91, 90, 87, 86, 80, 81, 79, 84, 85, + 73, 74, 83, 82, 99, 71, 72, 75, 76, 77, + 98, 100, 3, 6, 4, 5, 0, 64, 68, 25, + 24, 0, 0, 0, 0, 0, 26, 0, 23, 7, + 0, 0, 55, 0, 19, 62, 0, 61, 20, 21, + 15, 0, 57, 57, 0, 0, 0, 53, 65, 48, + 47, 0, 45, 46, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 53, 0, 0, 55, 58, 0, 17, 62, - 14, 0, 57, 0, 13, 21, 8, 48, 26, 27, - 28, 29, 30, 31, 32, 36, 35, 33, 34, 37, - 38, 40, 39, 43, 42, 41, 49, 54, 0, 10, - 0, 15, 16, 0, 54, 0, 59, 11, 0, 50, - 12 + 0, 0, 0, 54, 0, 0, 56, 59, 0, 18, + 63, 14, 0, 58, 0, 13, 22, 8, 49, 27, + 28, 29, 30, 31, 32, 33, 37, 36, 34, 35, + 38, 39, 41, 40, 44, 43, 42, 50, 55, 0, + 10, 0, 16, 17, 0, 55, 0, 60, 11, 0, + 51, 12 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 52, 53, 54, 66, 67, 148, 55, 69, - 114, 121, 75, 76, 115, 57, 58 + -1, 1, 52, 53, 54, 66, 67, 149, 55, 69, + 115, 122, 75, 76, 116, 57, 58 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -146 +#define YYPACT_NINF -147 static const yytype_int16 yypact[] = { - -146, 111, -146, 429, -10, -9, -4, 151, -15, 27, - 271, 54, 63, 86, 82, -146, 429, -146, -146, -146, - -146, -146, -146, -146, -146, -146, -146, -146, -146, -146, - -146, -146, -146, -146, -146, -146, -146, -146, -146, -146, - -146, -146, -146, -146, -146, -146, -146, -146, -146, -146, - -146, -146, -146, -146, -146, -146, 311, -146, -146, -146, - -146, 429, 429, 429, 429, 429, -146, 452, -146, -146, - 351, 59, 391, 17, -146, -146, 191, -146, -146, -146, - 231, 391, 391, 84, 85, 475, -146, -146, -146, -146, - 424, -146, -146, -146, 429, 429, 429, 429, 429, 429, - 429, 429, 429, 429, 429, 429, 429, 429, 429, 429, - 429, 429, -146, 30, 88, 391, -146, 90, -146, -146, - -146, 89, 391, 91, -146, -146, -146, -146, 492, 508, - 523, 537, 550, 561, 561, 18, 18, 18, 18, 25, - 25, 36, 36, -146, -146, -146, -146, 391, 26, -146, - 67, -146, -146, 93, 391, 113, -146, -146, 148, -146, - -146 + -147, 112, -147, 28, -10, 55, 62, 152, -15, 59, + 192, 85, 86, 87, 51, -147, 28, -147, -147, -147, + -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, + -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, + -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, + -147, -147, -147, -147, -147, -147, 312, -147, -147, -147, + -147, 28, 28, 28, 28, 28, -147, 428, -147, -147, + 352, 63, 392, 17, -147, -147, 232, -147, -147, -147, + -147, 272, 392, 392, 84, 89, 451, -147, -147, -147, + -147, 469, -147, -147, -147, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, -147, 60, 90, 392, -147, 96, -147, + -147, -147, 93, 392, 94, -147, -147, -147, -147, 489, + 505, 520, 534, 547, 558, 558, 18, 18, 18, 18, + 563, 563, 23, 23, -147, -147, -147, -147, 392, 32, + -147, 61, -147, -147, 110, 392, 118, -147, -147, 149, + -147, -147 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -146, -146, -146, -146, -146, 120, -11, -146, -146, -146, - -145, 92, -6, 160, 0, -7, -146 + -147, -147, -147, -147, -147, 157, -11, -147, -147, -147, + -146, 92, -68, 200, 0, -7, -147 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -774,132 +775,132 @@ static const yytype_int16 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 77, 56, 153, 77, 70, 85, 78, 15, 71, 158, - 17, 68, 19, 72, 20, 21, 22, 23, 24, 25, + 77, 56, 154, 77, 70, 86, 78, 15, 120, 159, + 17, 68, 19, 120, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 116, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 146, 79, 87, - 88, 89, 90, 91, 92, 105, 106, 107, 108, 109, - 110, 111, 117, 87, 107, 108, 109, 110, 111, 77, - 119, 81, 154, 77, 119, 155, 147, 109, 110, 111, - 82, 122, 122, 128, 129, 130, 131, 132, 133, 134, + 36, 37, 38, 39, 117, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 59, 60, 88, + 89, 90, 91, 92, 93, 106, 107, 108, 109, 110, + 111, 112, 118, 88, 110, 111, 112, 61, 62, 77, + 59, 60, 71, 63, 77, 64, 65, 147, 155, 72, + 79, 156, 123, 123, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 59, 60, 83, 113, 124, 125, 150, 87, 149, - 151, 2, 152, 156, 157, 87, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 159, 17, 18, 19, 84, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 73, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 15, 160, - 80, 17, 74, 19, 123, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 73, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, - 0, 17, 118, 19, 0, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 73, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, - 0, 17, 120, 19, 0, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 73, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, - 0, 17, 0, 19, 0, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 0, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, - 0, 17, 86, 19, 0, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 0, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, - 0, 17, 112, 19, 0, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 0, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 15, 0, - 0, 17, 0, 19, 0, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 0, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 59, 60, - 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 61, 62, - 127, 0, 0, 93, 63, 0, 64, 65, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 126, 0, 0, 0, - 0, 94, 95, 96, 97, 98, 99, 100, 101, 102, - 103, 104, 105, 106, 107, 108, 109, 110, 111, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 98, 99, 100, + 145, 146, 82, 83, 84, 125, 148, 157, 114, 88, + 126, 150, 2, 151, 152, 153, 88, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 158, 17, 18, 19, 160, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 73, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, + 161, 85, 17, 74, 19, 124, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 73, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, + 81, 0, 17, 80, 19, 0, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 73, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, + 0, 0, 17, 119, 19, 0, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 73, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, + 0, 0, 17, 121, 19, 0, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 0, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, + 0, 0, 17, 87, 19, 0, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 0, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, + 0, 0, 17, 113, 19, 0, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 0, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, + 0, 0, 17, 0, 19, 0, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 0, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 94, + 0, 0, 0, 0, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 111, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 111 + 111, 112, 127, 0, 0, 0, 0, 95, 96, 97, + 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 95, 96, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 0, 0, 128, 96, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, 112, 98, + 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, + 109, 110, 111, 112, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 102, 103, 104, 105, 106, 107, 108, 109, 110, + 111, 112, 108, 109, 110, 111, 112 }; static const yytype_int16 yycheck[] = { - 7, 1, 147, 10, 4, 16, 21, 17, 17, 154, - 20, 21, 22, 17, 24, 25, 26, 27, 28, 29, + 7, 1, 148, 10, 4, 16, 21, 17, 76, 155, + 20, 21, 22, 81, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 17, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 17, 21, 56, + 50, 51, 52, 53, 54, 55, 56, 19, 20, 56, 61, 62, 63, 64, 65, 37, 38, 39, 40, 41, - 42, 43, 45, 70, 39, 40, 41, 42, 43, 76, - 76, 17, 46, 80, 80, 49, 46, 41, 42, 43, - 17, 81, 82, 94, 95, 96, 97, 98, 99, 100, + 42, 43, 45, 70, 41, 42, 43, 39, 40, 76, + 19, 20, 17, 45, 81, 47, 48, 17, 46, 17, + 21, 49, 82, 83, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 111, 19, 20, 17, 45, 21, 21, 17, 115, 21, - 21, 0, 21, 46, 21, 122, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 17, 20, 21, 22, 14, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 4, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 17, 21, - 10, 20, 21, 22, 82, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 4, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, - -1, 20, 21, 22, -1, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 4, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, - -1, 20, 21, 22, -1, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 4, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, - -1, 20, -1, 22, -1, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, -1, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, - -1, 20, 21, 22, -1, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, -1, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, - -1, 20, 21, 22, -1, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, -1, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 17, -1, - -1, 20, -1, 22, -1, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, -1, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 19, 20, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 39, 40, - 46, -1, -1, 21, 45, -1, 47, 48, 26, 27, + 111, 112, 17, 17, 17, 21, 46, 46, 45, 116, + 21, 21, 0, 17, 21, 21, 123, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 21, 20, 21, 22, 17, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 4, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, + 21, 14, 20, 21, 22, 83, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 21, -1, -1, -1, - -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 27, + 38, 39, 40, 41, 42, 43, 4, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, + 10, -1, 20, 21, 22, -1, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 28, 29, 30, 31, + 38, 39, 40, 41, 42, 43, 4, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, + -1, -1, 20, 21, 22, -1, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 4, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, + -1, -1, 20, 21, 22, -1, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, + -1, -1, 20, 21, 22, -1, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, + -1, -1, 20, 21, 22, -1, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, + -1, -1, 20, -1, 22, -1, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 21, + -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 30, 31, 32, + 42, 43, 21, -1, -1, -1, -1, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, -1, -1, 46, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43 + 43, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 39, 40, 41, 42, 43 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -914,15 +915,15 @@ static const yytype_uint8 yystos[] = 55, 56, 59, 60, 61, 65, 71, 72, 73, 19, 20, 39, 40, 45, 47, 48, 62, 63, 21, 66, 71, 17, 17, 4, 21, 69, 70, 72, 21, 21, - 70, 17, 17, 17, 62, 63, 21, 72, 63, 63, - 63, 63, 63, 21, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 21, 45, 67, 71, 17, 45, 21, 69, - 21, 68, 71, 68, 21, 21, 21, 46, 63, 63, + 21, 70, 17, 17, 17, 62, 63, 21, 72, 63, + 63, 63, 63, 63, 21, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 21, 45, 67, 71, 17, 45, 21, + 69, 21, 68, 71, 68, 21, 21, 21, 46, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 17, 46, 64, 21, - 17, 21, 21, 67, 46, 49, 46, 21, 67, 17, - 21 + 63, 63, 63, 63, 63, 63, 63, 17, 46, 64, + 21, 17, 21, 21, 67, 46, 49, 46, 21, 67, + 17, 21 }; #define yyerrok (yyerrstatus = 0) @@ -1604,7 +1605,7 @@ YYLTYPE yylloc; } /* Line 1242 of yacc.c */ -#line 1608 "glcpp/glcpp-parse.c" +#line 1609 "glcpp/glcpp-parse.c" yylsp[0] = yylloc; goto yysetstate; @@ -1897,6 +1898,22 @@ yyreduce: /* Line 1455 of yacc.c */ #line 244 "glcpp/glcpp-parse.y" + { + /* #if without an expression is only an error if we + * are not skipping */ + if (parser->skip_stack == NULL || + parser->skip_stack->type == SKIP_NO_SKIP) + { + glcpp_error(& (yylsp[(1) - (2)]), parser, "#if with no expression"); + } + _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (2)]), 0); + ;} + break; + + case 16: + +/* Line 1455 of yacc.c */ +#line 254 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1904,10 +1921,10 @@ yyreduce: ;} break; - case 16: + case 17: /* Line 1455 of yacc.c */ -#line 249 "glcpp/glcpp-parse.y" +#line 259 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1915,10 +1932,10 @@ yyreduce: ;} break; - case 17: + case 18: /* Line 1455 of yacc.c */ -#line 254 "glcpp/glcpp-parse.y" +#line 264 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'elif' expression * if we are not skipping. When we are skipping, we @@ -1940,10 +1957,10 @@ yyreduce: ;} break; - case 18: + case 19: /* Line 1455 of yacc.c */ -#line 273 "glcpp/glcpp-parse.y" +#line 283 "glcpp/glcpp-parse.y" { /* #elif without an expression is an error unless we * are skipping. */ @@ -1961,28 +1978,28 @@ yyreduce: ;} break; - case 19: + case 20: /* Line 1455 of yacc.c */ -#line 288 "glcpp/glcpp-parse.y" +#line 298 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); ;} break; - case 20: + case 21: /* Line 1455 of yacc.c */ -#line 291 "glcpp/glcpp-parse.y" +#line 301 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); ;} break; - case 21: + case 22: /* Line 1455 of yacc.c */ -#line 294 "glcpp/glcpp-parse.y" +#line 304 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); if (macro) { @@ -1994,10 +2011,10 @@ yyreduce: ;} break; - case 23: + case 24: /* Line 1455 of yacc.c */ -#line 307 "glcpp/glcpp-parse.y" +#line 317 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); @@ -2009,226 +2026,226 @@ yyreduce: ;} break; - case 24: + case 25: /* Line 1455 of yacc.c */ -#line 316 "glcpp/glcpp-parse.y" +#line 326 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} break; - case 26: + case 27: /* Line 1455 of yacc.c */ -#line 322 "glcpp/glcpp-parse.y" +#line 332 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); ;} break; - case 27: + case 28: /* Line 1455 of yacc.c */ -#line 325 "glcpp/glcpp-parse.y" +#line 335 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); ;} break; - case 28: + case 29: /* Line 1455 of yacc.c */ -#line 328 "glcpp/glcpp-parse.y" +#line 338 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); ;} break; - case 29: + case 30: /* Line 1455 of yacc.c */ -#line 331 "glcpp/glcpp-parse.y" +#line 341 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); ;} break; - case 30: + case 31: /* Line 1455 of yacc.c */ -#line 334 "glcpp/glcpp-parse.y" +#line 344 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); ;} break; - case 31: + case 32: /* Line 1455 of yacc.c */ -#line 337 "glcpp/glcpp-parse.y" +#line 347 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); ;} break; - case 32: + case 33: /* Line 1455 of yacc.c */ -#line 340 "glcpp/glcpp-parse.y" +#line 350 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); ;} break; - case 33: + case 34: /* Line 1455 of yacc.c */ -#line 343 "glcpp/glcpp-parse.y" +#line 353 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); ;} break; - case 34: + case 35: /* Line 1455 of yacc.c */ -#line 346 "glcpp/glcpp-parse.y" +#line 356 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); ;} break; - case 35: + case 36: /* Line 1455 of yacc.c */ -#line 349 "glcpp/glcpp-parse.y" +#line 359 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); ;} break; - case 36: + case 37: /* Line 1455 of yacc.c */ -#line 352 "glcpp/glcpp-parse.y" +#line 362 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); ;} break; - case 37: + case 38: /* Line 1455 of yacc.c */ -#line 355 "glcpp/glcpp-parse.y" +#line 365 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); ;} break; - case 38: + case 39: /* Line 1455 of yacc.c */ -#line 358 "glcpp/glcpp-parse.y" +#line 368 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); ;} break; - case 39: + case 40: /* Line 1455 of yacc.c */ -#line 361 "glcpp/glcpp-parse.y" +#line 371 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); ;} break; - case 40: + case 41: /* Line 1455 of yacc.c */ -#line 364 "glcpp/glcpp-parse.y" +#line 374 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); ;} break; - case 41: + case 42: /* Line 1455 of yacc.c */ -#line 367 "glcpp/glcpp-parse.y" +#line 377 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); ;} break; - case 42: + case 43: /* Line 1455 of yacc.c */ -#line 370 "glcpp/glcpp-parse.y" +#line 380 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); ;} break; - case 43: + case 44: /* Line 1455 of yacc.c */ -#line 373 "glcpp/glcpp-parse.y" +#line 383 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); ;} break; - case 44: + case 45: /* Line 1455 of yacc.c */ -#line 376 "glcpp/glcpp-parse.y" +#line 386 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); ;} break; - case 45: + case 46: /* Line 1455 of yacc.c */ -#line 379 "glcpp/glcpp-parse.y" +#line 389 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); ;} break; - case 46: + case 47: /* Line 1455 of yacc.c */ -#line 382 "glcpp/glcpp-parse.y" +#line 392 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); ;} break; - case 47: + case 48: /* Line 1455 of yacc.c */ -#line 385 "glcpp/glcpp-parse.y" +#line 395 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); ;} break; - case 48: + case 49: /* Line 1455 of yacc.c */ -#line 388 "glcpp/glcpp-parse.y" +#line 398 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); ;} break; - case 49: + case 50: /* Line 1455 of yacc.c */ -#line 394 "glcpp/glcpp-parse.y" +#line 404 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); @@ -2236,10 +2253,10 @@ yyreduce: ;} break; - case 50: + case 51: /* Line 1455 of yacc.c */ -#line 399 "glcpp/glcpp-parse.y" +#line 409 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); @@ -2247,62 +2264,62 @@ yyreduce: ;} break; - case 51: + case 52: /* Line 1455 of yacc.c */ -#line 407 "glcpp/glcpp-parse.y" +#line 417 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; - case 53: + case 54: /* Line 1455 of yacc.c */ -#line 412 "glcpp/glcpp-parse.y" +#line 422 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); ;} break; - case 54: + case 55: /* Line 1455 of yacc.c */ -#line 418 "glcpp/glcpp-parse.y" +#line 428 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; - case 57: + case 58: /* Line 1455 of yacc.c */ -#line 424 "glcpp/glcpp-parse.y" +#line 434 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); ;} break; - case 58: + case 59: /* Line 1455 of yacc.c */ -#line 431 "glcpp/glcpp-parse.y" +#line 441 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); ;} break; - case 59: + case 60: /* Line 1455 of yacc.c */ -#line 435 "glcpp/glcpp-parse.y" +#line 445 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); ;} break; - case 61: + case 62: /* Line 1455 of yacc.c */ -#line 444 "glcpp/glcpp-parse.y" +#line 454 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2311,10 +2328,10 @@ yyreduce: ;} break; - case 62: + case 63: /* Line 1455 of yacc.c */ -#line 450 "glcpp/glcpp-parse.y" +#line 460 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2322,10 +2339,10 @@ yyreduce: ;} break; - case 63: + case 64: /* Line 1455 of yacc.c */ -#line 458 "glcpp/glcpp-parse.y" +#line 468 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2334,10 +2351,10 @@ yyreduce: ;} break; - case 64: + case 65: /* Line 1455 of yacc.c */ -#line 464 "glcpp/glcpp-parse.y" +#line 474 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2345,277 +2362,277 @@ yyreduce: ;} break; - case 65: + case 66: /* Line 1455 of yacc.c */ -#line 472 "glcpp/glcpp-parse.y" +#line 482 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; ;} break; - case 66: + case 67: /* Line 1455 of yacc.c */ -#line 476 "glcpp/glcpp-parse.y" +#line 486 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; ;} break; - case 67: + case 68: /* Line 1455 of yacc.c */ -#line 480 "glcpp/glcpp-parse.y" +#line 490 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); (yyval.token)->location = yylloc; ;} break; - case 68: + case 69: /* Line 1455 of yacc.c */ -#line 484 "glcpp/glcpp-parse.y" +#line 494 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; ;} break; - case 69: + case 70: /* Line 1455 of yacc.c */ -#line 488 "glcpp/glcpp-parse.y" +#line 498 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); (yyval.token)->location = yylloc; ;} break; - case 70: + case 71: /* Line 1455 of yacc.c */ -#line 495 "glcpp/glcpp-parse.y" +#line 505 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; - case 71: + case 72: /* Line 1455 of yacc.c */ -#line 496 "glcpp/glcpp-parse.y" +#line 506 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; - case 72: + case 73: /* Line 1455 of yacc.c */ -#line 497 "glcpp/glcpp-parse.y" +#line 507 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; - case 73: + case 74: /* Line 1455 of yacc.c */ -#line 498 "glcpp/glcpp-parse.y" +#line 508 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; - case 74: + case 75: /* Line 1455 of yacc.c */ -#line 499 "glcpp/glcpp-parse.y" +#line 509 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; - case 75: + case 76: /* Line 1455 of yacc.c */ -#line 500 "glcpp/glcpp-parse.y" +#line 510 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; - case 76: + case 77: /* Line 1455 of yacc.c */ -#line 501 "glcpp/glcpp-parse.y" +#line 511 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; - case 77: + case 78: /* Line 1455 of yacc.c */ -#line 502 "glcpp/glcpp-parse.y" +#line 512 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; - case 78: + case 79: /* Line 1455 of yacc.c */ -#line 503 "glcpp/glcpp-parse.y" +#line 513 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; - case 79: + case 80: /* Line 1455 of yacc.c */ -#line 504 "glcpp/glcpp-parse.y" +#line 514 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; - case 80: + case 81: /* Line 1455 of yacc.c */ -#line 505 "glcpp/glcpp-parse.y" +#line 515 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; - case 81: + case 82: /* Line 1455 of yacc.c */ -#line 506 "glcpp/glcpp-parse.y" +#line 516 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; - case 82: + case 83: /* Line 1455 of yacc.c */ -#line 507 "glcpp/glcpp-parse.y" +#line 517 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; - case 83: + case 84: /* Line 1455 of yacc.c */ -#line 508 "glcpp/glcpp-parse.y" +#line 518 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; - case 84: + case 85: /* Line 1455 of yacc.c */ -#line 509 "glcpp/glcpp-parse.y" +#line 519 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; - case 85: + case 86: /* Line 1455 of yacc.c */ -#line 510 "glcpp/glcpp-parse.y" +#line 520 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; - case 86: + case 87: /* Line 1455 of yacc.c */ -#line 511 "glcpp/glcpp-parse.y" +#line 521 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; - case 87: + case 88: /* Line 1455 of yacc.c */ -#line 512 "glcpp/glcpp-parse.y" +#line 522 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; - case 88: + case 89: /* Line 1455 of yacc.c */ -#line 513 "glcpp/glcpp-parse.y" +#line 523 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; - case 89: + case 90: /* Line 1455 of yacc.c */ -#line 514 "glcpp/glcpp-parse.y" +#line 524 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; - case 90: + case 91: /* Line 1455 of yacc.c */ -#line 515 "glcpp/glcpp-parse.y" +#line 525 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; - case 91: + case 92: /* Line 1455 of yacc.c */ -#line 516 "glcpp/glcpp-parse.y" +#line 526 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; - case 92: + case 93: /* Line 1455 of yacc.c */ -#line 517 "glcpp/glcpp-parse.y" +#line 527 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; - case 93: + case 94: /* Line 1455 of yacc.c */ -#line 518 "glcpp/glcpp-parse.y" +#line 528 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; - case 94: + case 95: /* Line 1455 of yacc.c */ -#line 519 "glcpp/glcpp-parse.y" +#line 529 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; - case 95: + case 96: /* Line 1455 of yacc.c */ -#line 520 "glcpp/glcpp-parse.y" +#line 530 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; - case 96: + case 97: /* Line 1455 of yacc.c */ -#line 521 "glcpp/glcpp-parse.y" +#line 531 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; - case 97: + case 98: /* Line 1455 of yacc.c */ -#line 522 "glcpp/glcpp-parse.y" +#line 532 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; - case 98: + case 99: /* Line 1455 of yacc.c */ -#line 523 "glcpp/glcpp-parse.y" +#line 533 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; - case 99: + case 100: /* Line 1455 of yacc.c */ -#line 524 "glcpp/glcpp-parse.y" +#line 534 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; - case 100: + case 101: /* Line 1455 of yacc.c */ -#line 525 "glcpp/glcpp-parse.y" +#line 535 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; /* Line 1455 of yacc.c */ -#line 2619 "glcpp/glcpp-parse.c" +#line 2636 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2834,7 +2851,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 528 "glcpp/glcpp-parse.y" +#line 538 "glcpp/glcpp-parse.y" string_list_t * -- cgit v1.2.3 From da6b10a7eb26c8a13056cbae9015d5b84f134142 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 11 Aug 2010 14:09:11 -0700 Subject: glcpp: Fix "unterminated if" diagnostic. This was previously being appended to the output string *after* a copy of the supposedly final string was made and handed to the caller. So the diagnostic was never actually visible to the user. We fix this by moving the check for an unterminated #if from glcpp_parser_destroy to the calling function, preprocess. This fixes the test case 083-unterminated-if.c. --- src/glsl/glcpp/glcpp-parse.c | 2 -- src/glsl/glcpp/glcpp-parse.y | 2 -- src/glsl/glcpp/pp.c | 3 +++ src/glsl/glcpp/tests/083-unterminated-if.c.expected | 5 +++++ 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 src/glsl/glcpp/tests/083-unterminated-if.c.expected diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index fe7549e5c5f..df26899a0f0 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -3333,8 +3333,6 @@ glcpp_parser_parse (glcpp_parser_t *parser) void glcpp_parser_destroy (glcpp_parser_t *parser) { - if (parser->skip_stack) - glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); glcpp_lex_destroy (parser->scanner); hash_table_dtor (parser->defines); talloc_free (parser); diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 0e0d9d412b6..7b08cd5807c 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -1016,8 +1016,6 @@ glcpp_parser_parse (glcpp_parser_t *parser) void glcpp_parser_destroy (glcpp_parser_t *parser) { - if (parser->skip_stack) - glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); glcpp_lex_destroy (parser->scanner); hash_table_dtor (parser->defines); talloc_free (parser); diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index 3adccf72aab..52b6e96a65f 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -151,6 +151,9 @@ preprocess(void *talloc_ctx, const char **shader, char **info_log, glcpp_parser_parse (parser); + if (parser->skip_stack) + glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); + *info_log = talloc_strdup_append(*info_log, parser->info_log); talloc_steal(talloc_ctx, parser->output); diff --git a/src/glsl/glcpp/tests/083-unterminated-if.c.expected b/src/glsl/glcpp/tests/083-unterminated-if.c.expected new file mode 100644 index 00000000000..a69f8bab582 --- /dev/null +++ b/src/glsl/glcpp/tests/083-unterminated-if.c.expected @@ -0,0 +1,5 @@ +0:1(7): preprocessor error: Unterminated #if + + + + -- cgit v1.2.3 From 202604e8160157e4e80b3458175e0170d168e557 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 11 Aug 2010 16:58:25 -0700 Subject: glsl2: Don't declare a variable called sig that shadows the other one Accidentally having a variable called 'sig' within an if-statement cause the higher scope 'sig' to always be NULL. As a result a new function signature was created for a function definition even when one already existed from a prototype declaration. Fixes piglit test case glsl-function-prototype (bugzilla #29520). --- src/glsl/ast_to_hir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index f14341c8f72..9d4448f89a8 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2128,7 +2128,7 @@ ast_function::hir(exec_list *instructions, */ f = state->symbols->get_function(name); if (f != NULL) { - ir_function_signature *sig = f->exact_matching_signature(&hir_parameters); + sig = f->exact_matching_signature(&hir_parameters); if (sig != NULL) { const char *badvar = sig->qualifiers_match(&hir_parameters); if (badvar != NULL) { -- cgit v1.2.3 From 77215e7e7babe73e5d959ab5ad82054a8d73c538 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 11 Aug 2010 17:01:31 -0700 Subject: glsl2: Emit error from lexer when illegal reserved word is encountered Without this, the parser will generate obtuse, useless error diagnostics when reservered word that are not used by the grammar are encountered in a shader. Fixes bugzilla #29519. --- src/glsl/glsl_lexer.lpp | 92 +++++++++++++++++++++++++++--------------------- src/glsl/glsl_parser.ypp | 2 ++ 2 files changed, 53 insertions(+), 41 deletions(-) diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index b78df5d84ff..7ef537b2487 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -46,6 +46,16 @@ } \ } while (0) +#define RESERVED_WORD(version, token) \ + do { \ + if (yyextra->language_version >= version) { \ + return token; \ + } else { \ + _mesa_glsl_error(yylloc, yyextra, \ + "Illegal use of reserved word `%s'", yytext); \ + return ERROR_TOK; \ + } \ + } while (0) %} %option bison-bridge bison-locations reentrant noyywrap @@ -252,49 +262,49 @@ false { /* Reserved words in GLSL 1.10. */ -asm return ASM; -class return CLASS; -union return UNION; -enum return ENUM; -typedef return TYPEDEF; -template return TEMPLATE; -this return THIS; -packed return PACKED; -goto return GOTO; -switch return SWITCH; -default return DEFAULT; -inline return INLINE_TOK; -noinline return NOINLINE; -volatile return VOLATILE; -public return PUBLIC_TOK; -static return STATIC; -extern return EXTERN; -external return EXTERNAL; -interface return INTERFACE; -long return LONG; -short return SHORT; -double return DOUBLE; -half return HALF; -fixed return FIXED; -unsigned return UNSIGNED; -input return INPUT; -output return OUTPUT; -hvec2 return HVEC2; -hvec3 return HVEC3; -hvec4 return HVEC4; -dvec2 return DVEC2; -dvec3 return DVEC3; -dvec4 return DVEC4; -fvec2 return FVEC2; -fvec3 return FVEC3; -fvec4 return FVEC4; +asm RESERVED_WORD(999, ASM); +class RESERVED_WORD(999, CLASS); +union RESERVED_WORD(999, UNION); +enum RESERVED_WORD(999, ENUM); +typedef RESERVED_WORD(999, TYPEDEF); +template RESERVED_WORD(999, TEMPLATE); +this RESERVED_WORD(999, THIS); +packed RESERVED_WORD(999, PACKED); +goto RESERVED_WORD(999, GOTO); +switch RESERVED_WORD(130, SWITCH); +default RESERVED_WORD(130, DEFAULT); +inline RESERVED_WORD(999, INLINE_TOK); +noinline RESERVED_WORD(999, NOINLINE); +volatile RESERVED_WORD(999, VOLATILE); +public RESERVED_WORD(999, PUBLIC_TOK); +static RESERVED_WORD(999, STATIC); +extern RESERVED_WORD(999, EXTERN); +external RESERVED_WORD(999, EXTERNAL); +interface RESERVED_WORD(999, INTERFACE); +long RESERVED_WORD(999, LONG); +short RESERVED_WORD(999, SHORT); +double RESERVED_WORD(999, DOUBLE); +half RESERVED_WORD(999, HALF); +fixed RESERVED_WORD(999, FIXED); +unsigned RESERVED_WORD(999, UNSIGNED); +input RESERVED_WORD(999, INPUT); +output RESERVED_WORD(999, OUTPUT); +hvec2 RESERVED_WORD(999, HVEC2); +hvec3 RESERVED_WORD(999, HVEC3); +hvec4 RESERVED_WORD(999, HVEC4); +dvec2 RESERVED_WORD(999, DVEC2); +dvec3 RESERVED_WORD(999, DVEC3); +dvec4 RESERVED_WORD(999, DVEC4); +fvec2 RESERVED_WORD(999, FVEC2); +fvec3 RESERVED_WORD(999, FVEC3); +fvec4 RESERVED_WORD(999, FVEC4); sampler2DRect return SAMPLER2DRECT; -sampler3DRect return SAMPLER3DRECT; +sampler3DRect RESERVED_WORD(999, SAMPLER3DRECT); sampler2DRectShadow return SAMPLER2DRECTSHADOW; -sizeof return SIZEOF; -cast return CAST; -namespace return NAMESPACE; -using return USING; +sizeof RESERVED_WORD(999, SIZEOF); +cast RESERVED_WORD(999, CAST); +namespace RESERVED_WORD(999, NAMESPACE); +using RESERVED_WORD(999, USING); /* Additional reserved words in GLSL 1.20. */ lowp TOKEN_OR_IDENTIFIER(120, LOWP); diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 3e60454bb24..74971cfb9da 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -116,6 +116,8 @@ %token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW %token SIZEOF CAST NAMESPACE USING +%token ERROR_TOK + %token COMMON PARTITION ACTIVE SAMPLERBUFFER FILTER %token IMAGE1D IMAGE2D IMAGE3D IMAGECUBE IMAGE1DARRAY IMAGE2DARRAY %token IIMAGE1D IIMAGE2D IIMAGE3D IIMAGECUBE IIMAGE1DARRAY IIMAGE2DARRAY -- cgit v1.2.3 From db36e88052918ad383c3acdd24f2b9864e240ddb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 11 Aug 2010 17:03:37 -0700 Subject: glsl2: Commit generated files changed by previous commit --- src/glsl/glsl_lexer.cpp | 480 +++++------ src/glsl/glsl_parser.cpp | 2005 +++++++++++++++++++++++----------------------- src/glsl/glsl_parser.h | 61 +- 3 files changed, 1287 insertions(+), 1259 deletions(-) diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp index 672b0b13599..f75f7b51713 100644 --- a/src/glsl/glsl_lexer.cpp +++ b/src/glsl/glsl_lexer.cpp @@ -54,7 +54,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -85,6 +84,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -158,7 +159,15 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -934,8 +943,18 @@ static yyconst flex_int16_t yy_chk[1076] = } \ } while (0) +#define RESERVED_WORD(version, token) \ + do { \ + if (yyextra->language_version >= version) { \ + return token; \ + } else { \ + _mesa_glsl_error(yylloc, yyextra, \ + "Illegal use of reserved word `%s'", yytext); \ + return ERROR_TOK; \ + } \ + } while (0) -#line 939 "glsl_lexer.cpp" +#line 958 "glsl_lexer.cpp" #define INITIAL 0 #define PP 1 @@ -1069,7 +1088,12 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1077,7 +1101,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1088,7 +1112,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1176,10 +1200,10 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 66 "glsl_lexer.lpp" +#line 76 "glsl_lexer.lpp" -#line 1183 "glsl_lexer.cpp" +#line 1207 "glsl_lexer.cpp" yylval = yylval_param; @@ -1265,7 +1289,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 68 "glsl_lexer.lpp" +#line 78 "glsl_lexer.lpp" ; YY_BREAK /* Preprocessor tokens. */ @@ -1274,17 +1298,17 @@ case 2: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 71 "glsl_lexer.lpp" +#line 81 "glsl_lexer.lpp" ; YY_BREAK case 3: YY_RULE_SETUP -#line 72 "glsl_lexer.lpp" +#line 82 "glsl_lexer.lpp" { BEGIN PP; return VERSION; } YY_BREAK case 4: YY_RULE_SETUP -#line 73 "glsl_lexer.lpp" +#line 83 "glsl_lexer.lpp" { BEGIN PP; return EXTENSION; } YY_BREAK case 5: @@ -1292,7 +1316,7 @@ case 5: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 74 "glsl_lexer.lpp" +#line 84 "glsl_lexer.lpp" { /* Eat characters until the first digit is * encountered @@ -1314,7 +1338,7 @@ case 6: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 89 "glsl_lexer.lpp" +#line 99 "glsl_lexer.lpp" { /* Eat characters until the first digit is * encountered @@ -1332,27 +1356,27 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 103 "glsl_lexer.lpp" +#line 113 "glsl_lexer.lpp" { BEGIN PP; return PRAGMA; } YY_BREAK case 8: YY_RULE_SETUP -#line 104 "glsl_lexer.lpp" +#line 114 "glsl_lexer.lpp" { } YY_BREAK case 9: YY_RULE_SETUP -#line 105 "glsl_lexer.lpp" +#line 115 "glsl_lexer.lpp" { } YY_BREAK case 10: YY_RULE_SETUP -#line 106 "glsl_lexer.lpp" +#line 116 "glsl_lexer.lpp" return COLON; YY_BREAK case 11: YY_RULE_SETUP -#line 107 "glsl_lexer.lpp" +#line 117 "glsl_lexer.lpp" { yylval->identifier = strdup(yytext); return IDENTIFIER; @@ -1360,7 +1384,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 111 "glsl_lexer.lpp" +#line 121 "glsl_lexer.lpp" { yylval->n = strtol(yytext, NULL, 10); return INTCONSTANT; @@ -1369,283 +1393,283 @@ YY_RULE_SETUP case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 115 "glsl_lexer.lpp" +#line 125 "glsl_lexer.lpp" { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } YY_BREAK case 14: /* rule 14 can match eol */ YY_RULE_SETUP -#line 117 "glsl_lexer.lpp" +#line 127 "glsl_lexer.lpp" { yylineno++; yycolumn = 0; } YY_BREAK case 15: YY_RULE_SETUP -#line 119 "glsl_lexer.lpp" +#line 129 "glsl_lexer.lpp" return ATTRIBUTE; YY_BREAK case 16: YY_RULE_SETUP -#line 120 "glsl_lexer.lpp" +#line 130 "glsl_lexer.lpp" return CONST_TOK; YY_BREAK case 17: YY_RULE_SETUP -#line 121 "glsl_lexer.lpp" +#line 131 "glsl_lexer.lpp" return BOOL; YY_BREAK case 18: YY_RULE_SETUP -#line 122 "glsl_lexer.lpp" +#line 132 "glsl_lexer.lpp" return FLOAT; YY_BREAK case 19: YY_RULE_SETUP -#line 123 "glsl_lexer.lpp" +#line 133 "glsl_lexer.lpp" return INT; YY_BREAK case 20: YY_RULE_SETUP -#line 125 "glsl_lexer.lpp" +#line 135 "glsl_lexer.lpp" return BREAK; YY_BREAK case 21: YY_RULE_SETUP -#line 126 "glsl_lexer.lpp" +#line 136 "glsl_lexer.lpp" return CONTINUE; YY_BREAK case 22: YY_RULE_SETUP -#line 127 "glsl_lexer.lpp" +#line 137 "glsl_lexer.lpp" return DO; YY_BREAK case 23: YY_RULE_SETUP -#line 128 "glsl_lexer.lpp" +#line 138 "glsl_lexer.lpp" return WHILE; YY_BREAK case 24: YY_RULE_SETUP -#line 129 "glsl_lexer.lpp" +#line 139 "glsl_lexer.lpp" return ELSE; YY_BREAK case 25: YY_RULE_SETUP -#line 130 "glsl_lexer.lpp" +#line 140 "glsl_lexer.lpp" return FOR; YY_BREAK case 26: YY_RULE_SETUP -#line 131 "glsl_lexer.lpp" +#line 141 "glsl_lexer.lpp" return IF; YY_BREAK case 27: YY_RULE_SETUP -#line 132 "glsl_lexer.lpp" +#line 142 "glsl_lexer.lpp" return DISCARD; YY_BREAK case 28: YY_RULE_SETUP -#line 133 "glsl_lexer.lpp" +#line 143 "glsl_lexer.lpp" return RETURN; YY_BREAK case 29: YY_RULE_SETUP -#line 135 "glsl_lexer.lpp" +#line 145 "glsl_lexer.lpp" return BVEC2; YY_BREAK case 30: YY_RULE_SETUP -#line 136 "glsl_lexer.lpp" +#line 146 "glsl_lexer.lpp" return BVEC3; YY_BREAK case 31: YY_RULE_SETUP -#line 137 "glsl_lexer.lpp" +#line 147 "glsl_lexer.lpp" return BVEC4; YY_BREAK case 32: YY_RULE_SETUP -#line 138 "glsl_lexer.lpp" +#line 148 "glsl_lexer.lpp" return IVEC2; YY_BREAK case 33: YY_RULE_SETUP -#line 139 "glsl_lexer.lpp" +#line 149 "glsl_lexer.lpp" return IVEC3; YY_BREAK case 34: YY_RULE_SETUP -#line 140 "glsl_lexer.lpp" +#line 150 "glsl_lexer.lpp" return IVEC4; YY_BREAK case 35: YY_RULE_SETUP -#line 141 "glsl_lexer.lpp" +#line 151 "glsl_lexer.lpp" return VEC2; YY_BREAK case 36: YY_RULE_SETUP -#line 142 "glsl_lexer.lpp" +#line 152 "glsl_lexer.lpp" return VEC3; YY_BREAK case 37: YY_RULE_SETUP -#line 143 "glsl_lexer.lpp" +#line 153 "glsl_lexer.lpp" return VEC4; YY_BREAK case 38: YY_RULE_SETUP -#line 144 "glsl_lexer.lpp" +#line 154 "glsl_lexer.lpp" return MAT2; YY_BREAK case 39: YY_RULE_SETUP -#line 145 "glsl_lexer.lpp" +#line 155 "glsl_lexer.lpp" return MAT3; YY_BREAK case 40: YY_RULE_SETUP -#line 146 "glsl_lexer.lpp" +#line 156 "glsl_lexer.lpp" return MAT4; YY_BREAK case 41: YY_RULE_SETUP -#line 147 "glsl_lexer.lpp" +#line 157 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MAT2X2); YY_BREAK case 42: YY_RULE_SETUP -#line 148 "glsl_lexer.lpp" +#line 158 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MAT2X3); YY_BREAK case 43: YY_RULE_SETUP -#line 149 "glsl_lexer.lpp" +#line 159 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MAT2X4); YY_BREAK case 44: YY_RULE_SETUP -#line 150 "glsl_lexer.lpp" +#line 160 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MAT3X2); YY_BREAK case 45: YY_RULE_SETUP -#line 151 "glsl_lexer.lpp" +#line 161 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MAT3X3); YY_BREAK case 46: YY_RULE_SETUP -#line 152 "glsl_lexer.lpp" +#line 162 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MAT3X4); YY_BREAK case 47: YY_RULE_SETUP -#line 153 "glsl_lexer.lpp" +#line 163 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MAT4X2); YY_BREAK case 48: YY_RULE_SETUP -#line 154 "glsl_lexer.lpp" +#line 164 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MAT4X3); YY_BREAK case 49: YY_RULE_SETUP -#line 155 "glsl_lexer.lpp" +#line 165 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MAT4X4); YY_BREAK case 50: YY_RULE_SETUP -#line 157 "glsl_lexer.lpp" +#line 167 "glsl_lexer.lpp" return IN; YY_BREAK case 51: YY_RULE_SETUP -#line 158 "glsl_lexer.lpp" +#line 168 "glsl_lexer.lpp" return OUT; YY_BREAK case 52: YY_RULE_SETUP -#line 159 "glsl_lexer.lpp" +#line 169 "glsl_lexer.lpp" return INOUT; YY_BREAK case 53: YY_RULE_SETUP -#line 160 "glsl_lexer.lpp" +#line 170 "glsl_lexer.lpp" return UNIFORM; YY_BREAK case 54: YY_RULE_SETUP -#line 161 "glsl_lexer.lpp" +#line 171 "glsl_lexer.lpp" return VARYING; YY_BREAK case 55: YY_RULE_SETUP -#line 162 "glsl_lexer.lpp" +#line 172 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, CENTROID); YY_BREAK case 56: YY_RULE_SETUP -#line 163 "glsl_lexer.lpp" +#line 173 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, INVARIANT); YY_BREAK case 57: YY_RULE_SETUP -#line 165 "glsl_lexer.lpp" +#line 175 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, FLAT); YY_BREAK case 58: YY_RULE_SETUP -#line 166 "glsl_lexer.lpp" +#line 176 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, SMOOTH); YY_BREAK case 59: YY_RULE_SETUP -#line 167 "glsl_lexer.lpp" +#line 177 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, NOPERSPECTIVE); YY_BREAK case 60: YY_RULE_SETUP -#line 169 "glsl_lexer.lpp" +#line 179 "glsl_lexer.lpp" return SAMPLER1D; YY_BREAK case 61: YY_RULE_SETUP -#line 170 "glsl_lexer.lpp" +#line 180 "glsl_lexer.lpp" return SAMPLER2D; YY_BREAK case 62: YY_RULE_SETUP -#line 171 "glsl_lexer.lpp" +#line 181 "glsl_lexer.lpp" return SAMPLER3D; YY_BREAK case 63: YY_RULE_SETUP -#line 172 "glsl_lexer.lpp" +#line 182 "glsl_lexer.lpp" return SAMPLERCUBE; YY_BREAK case 64: YY_RULE_SETUP -#line 173 "glsl_lexer.lpp" +#line 183 "glsl_lexer.lpp" return SAMPLER1DSHADOW; YY_BREAK case 65: YY_RULE_SETUP -#line 174 "glsl_lexer.lpp" +#line 184 "glsl_lexer.lpp" return SAMPLER2DSHADOW; YY_BREAK case 66: YY_RULE_SETUP -#line 176 "glsl_lexer.lpp" +#line 186 "glsl_lexer.lpp" return STRUCT; YY_BREAK case 67: YY_RULE_SETUP -#line 177 "glsl_lexer.lpp" +#line 187 "glsl_lexer.lpp" return VOID; YY_BREAK case 68: YY_RULE_SETUP -#line 179 "glsl_lexer.lpp" +#line 189 "glsl_lexer.lpp" { if ((yyextra->language_version >= 140) || (yyextra->ARB_fragment_coord_conventions_enable)){ @@ -1658,102 +1682,102 @@ YY_RULE_SETUP YY_BREAK case 69: YY_RULE_SETUP -#line 189 "glsl_lexer.lpp" +#line 199 "glsl_lexer.lpp" return INC_OP; YY_BREAK case 70: YY_RULE_SETUP -#line 190 "glsl_lexer.lpp" +#line 200 "glsl_lexer.lpp" return DEC_OP; YY_BREAK case 71: YY_RULE_SETUP -#line 191 "glsl_lexer.lpp" +#line 201 "glsl_lexer.lpp" return LE_OP; YY_BREAK case 72: YY_RULE_SETUP -#line 192 "glsl_lexer.lpp" +#line 202 "glsl_lexer.lpp" return GE_OP; YY_BREAK case 73: YY_RULE_SETUP -#line 193 "glsl_lexer.lpp" +#line 203 "glsl_lexer.lpp" return EQ_OP; YY_BREAK case 74: YY_RULE_SETUP -#line 194 "glsl_lexer.lpp" +#line 204 "glsl_lexer.lpp" return NE_OP; YY_BREAK case 75: YY_RULE_SETUP -#line 195 "glsl_lexer.lpp" +#line 205 "glsl_lexer.lpp" return AND_OP; YY_BREAK case 76: YY_RULE_SETUP -#line 196 "glsl_lexer.lpp" +#line 206 "glsl_lexer.lpp" return OR_OP; YY_BREAK case 77: YY_RULE_SETUP -#line 197 "glsl_lexer.lpp" +#line 207 "glsl_lexer.lpp" return XOR_OP; YY_BREAK case 78: YY_RULE_SETUP -#line 199 "glsl_lexer.lpp" +#line 209 "glsl_lexer.lpp" return MUL_ASSIGN; YY_BREAK case 79: YY_RULE_SETUP -#line 200 "glsl_lexer.lpp" +#line 210 "glsl_lexer.lpp" return DIV_ASSIGN; YY_BREAK case 80: YY_RULE_SETUP -#line 201 "glsl_lexer.lpp" +#line 211 "glsl_lexer.lpp" return ADD_ASSIGN; YY_BREAK case 81: YY_RULE_SETUP -#line 202 "glsl_lexer.lpp" +#line 212 "glsl_lexer.lpp" return MOD_ASSIGN; YY_BREAK case 82: YY_RULE_SETUP -#line 203 "glsl_lexer.lpp" +#line 213 "glsl_lexer.lpp" return LEFT_ASSIGN; YY_BREAK case 83: YY_RULE_SETUP -#line 204 "glsl_lexer.lpp" +#line 214 "glsl_lexer.lpp" return RIGHT_ASSIGN; YY_BREAK case 84: YY_RULE_SETUP -#line 205 "glsl_lexer.lpp" +#line 215 "glsl_lexer.lpp" return AND_ASSIGN; YY_BREAK case 85: YY_RULE_SETUP -#line 206 "glsl_lexer.lpp" +#line 216 "glsl_lexer.lpp" return XOR_ASSIGN; YY_BREAK case 86: YY_RULE_SETUP -#line 207 "glsl_lexer.lpp" +#line 217 "glsl_lexer.lpp" return OR_ASSIGN; YY_BREAK case 87: YY_RULE_SETUP -#line 208 "glsl_lexer.lpp" +#line 218 "glsl_lexer.lpp" return SUB_ASSIGN; YY_BREAK case 88: YY_RULE_SETUP -#line 210 "glsl_lexer.lpp" +#line 220 "glsl_lexer.lpp" { yylval->n = strtol(yytext, NULL, 10); return INTCONSTANT; @@ -1761,7 +1785,7 @@ YY_RULE_SETUP YY_BREAK case 89: YY_RULE_SETUP -#line 214 "glsl_lexer.lpp" +#line 224 "glsl_lexer.lpp" { yylval->n = strtol(yytext + 2, NULL, 16); return INTCONSTANT; @@ -1769,7 +1793,7 @@ YY_RULE_SETUP YY_BREAK case 90: YY_RULE_SETUP -#line 218 "glsl_lexer.lpp" +#line 228 "glsl_lexer.lpp" { yylval->n = strtol(yytext, NULL, 8); return INTCONSTANT; @@ -1777,7 +1801,7 @@ YY_RULE_SETUP YY_BREAK case 91: YY_RULE_SETUP -#line 223 "glsl_lexer.lpp" +#line 233 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; @@ -1785,7 +1809,7 @@ YY_RULE_SETUP YY_BREAK case 92: YY_RULE_SETUP -#line 227 "glsl_lexer.lpp" +#line 237 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; @@ -1793,7 +1817,7 @@ YY_RULE_SETUP YY_BREAK case 93: YY_RULE_SETUP -#line 231 "glsl_lexer.lpp" +#line 241 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; @@ -1801,7 +1825,7 @@ YY_RULE_SETUP YY_BREAK case 94: YY_RULE_SETUP -#line 235 "glsl_lexer.lpp" +#line 245 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; @@ -1809,7 +1833,7 @@ YY_RULE_SETUP YY_BREAK case 95: YY_RULE_SETUP -#line 239 "glsl_lexer.lpp" +#line 249 "glsl_lexer.lpp" { yylval->real = strtod(yytext, NULL); return FLOATCONSTANT; @@ -1817,7 +1841,7 @@ YY_RULE_SETUP YY_BREAK case 96: YY_RULE_SETUP -#line 244 "glsl_lexer.lpp" +#line 254 "glsl_lexer.lpp" { yylval->n = 1; return BOOLCONSTANT; @@ -1825,7 +1849,7 @@ YY_RULE_SETUP YY_BREAK case 97: YY_RULE_SETUP -#line 248 "glsl_lexer.lpp" +#line 258 "glsl_lexer.lpp" { yylval->n = 0; return BOOLCONSTANT; @@ -1834,394 +1858,394 @@ YY_RULE_SETUP /* Reserved words in GLSL 1.10. */ case 98: YY_RULE_SETUP -#line 255 "glsl_lexer.lpp" -return ASM; +#line 265 "glsl_lexer.lpp" +RESERVED_WORD(999, ASM); YY_BREAK case 99: YY_RULE_SETUP -#line 256 "glsl_lexer.lpp" -return CLASS; +#line 266 "glsl_lexer.lpp" +RESERVED_WORD(999, CLASS); YY_BREAK case 100: YY_RULE_SETUP -#line 257 "glsl_lexer.lpp" -return UNION; +#line 267 "glsl_lexer.lpp" +RESERVED_WORD(999, UNION); YY_BREAK case 101: YY_RULE_SETUP -#line 258 "glsl_lexer.lpp" -return ENUM; +#line 268 "glsl_lexer.lpp" +RESERVED_WORD(999, ENUM); YY_BREAK case 102: YY_RULE_SETUP -#line 259 "glsl_lexer.lpp" -return TYPEDEF; +#line 269 "glsl_lexer.lpp" +RESERVED_WORD(999, TYPEDEF); YY_BREAK case 103: YY_RULE_SETUP -#line 260 "glsl_lexer.lpp" -return TEMPLATE; +#line 270 "glsl_lexer.lpp" +RESERVED_WORD(999, TEMPLATE); YY_BREAK case 104: YY_RULE_SETUP -#line 261 "glsl_lexer.lpp" -return THIS; +#line 271 "glsl_lexer.lpp" +RESERVED_WORD(999, THIS); YY_BREAK case 105: YY_RULE_SETUP -#line 262 "glsl_lexer.lpp" -return PACKED; +#line 272 "glsl_lexer.lpp" +RESERVED_WORD(999, PACKED); YY_BREAK case 106: YY_RULE_SETUP -#line 263 "glsl_lexer.lpp" -return GOTO; +#line 273 "glsl_lexer.lpp" +RESERVED_WORD(999, GOTO); YY_BREAK case 107: YY_RULE_SETUP -#line 264 "glsl_lexer.lpp" -return SWITCH; +#line 274 "glsl_lexer.lpp" +RESERVED_WORD(130, SWITCH); YY_BREAK case 108: YY_RULE_SETUP -#line 265 "glsl_lexer.lpp" -return DEFAULT; +#line 275 "glsl_lexer.lpp" +RESERVED_WORD(130, DEFAULT); YY_BREAK case 109: YY_RULE_SETUP -#line 266 "glsl_lexer.lpp" -return INLINE_TOK; +#line 276 "glsl_lexer.lpp" +RESERVED_WORD(999, INLINE_TOK); YY_BREAK case 110: YY_RULE_SETUP -#line 267 "glsl_lexer.lpp" -return NOINLINE; +#line 277 "glsl_lexer.lpp" +RESERVED_WORD(999, NOINLINE); YY_BREAK case 111: YY_RULE_SETUP -#line 268 "glsl_lexer.lpp" -return VOLATILE; +#line 278 "glsl_lexer.lpp" +RESERVED_WORD(999, VOLATILE); YY_BREAK case 112: YY_RULE_SETUP -#line 269 "glsl_lexer.lpp" -return PUBLIC_TOK; +#line 279 "glsl_lexer.lpp" +RESERVED_WORD(999, PUBLIC_TOK); YY_BREAK case 113: YY_RULE_SETUP -#line 270 "glsl_lexer.lpp" -return STATIC; +#line 280 "glsl_lexer.lpp" +RESERVED_WORD(999, STATIC); YY_BREAK case 114: YY_RULE_SETUP -#line 271 "glsl_lexer.lpp" -return EXTERN; +#line 281 "glsl_lexer.lpp" +RESERVED_WORD(999, EXTERN); YY_BREAK case 115: YY_RULE_SETUP -#line 272 "glsl_lexer.lpp" -return EXTERNAL; +#line 282 "glsl_lexer.lpp" +RESERVED_WORD(999, EXTERNAL); YY_BREAK case 116: YY_RULE_SETUP -#line 273 "glsl_lexer.lpp" -return INTERFACE; +#line 283 "glsl_lexer.lpp" +RESERVED_WORD(999, INTERFACE); YY_BREAK case 117: YY_RULE_SETUP -#line 274 "glsl_lexer.lpp" -return LONG; +#line 284 "glsl_lexer.lpp" +RESERVED_WORD(999, LONG); YY_BREAK case 118: YY_RULE_SETUP -#line 275 "glsl_lexer.lpp" -return SHORT; +#line 285 "glsl_lexer.lpp" +RESERVED_WORD(999, SHORT); YY_BREAK case 119: YY_RULE_SETUP -#line 276 "glsl_lexer.lpp" -return DOUBLE; +#line 286 "glsl_lexer.lpp" +RESERVED_WORD(999, DOUBLE); YY_BREAK case 120: YY_RULE_SETUP -#line 277 "glsl_lexer.lpp" -return HALF; +#line 287 "glsl_lexer.lpp" +RESERVED_WORD(999, HALF); YY_BREAK case 121: YY_RULE_SETUP -#line 278 "glsl_lexer.lpp" -return FIXED; +#line 288 "glsl_lexer.lpp" +RESERVED_WORD(999, FIXED); YY_BREAK case 122: YY_RULE_SETUP -#line 279 "glsl_lexer.lpp" -return UNSIGNED; +#line 289 "glsl_lexer.lpp" +RESERVED_WORD(999, UNSIGNED); YY_BREAK case 123: YY_RULE_SETUP -#line 280 "glsl_lexer.lpp" -return INPUT; +#line 290 "glsl_lexer.lpp" +RESERVED_WORD(999, INPUT); YY_BREAK case 124: YY_RULE_SETUP -#line 281 "glsl_lexer.lpp" -return OUTPUT; +#line 291 "glsl_lexer.lpp" +RESERVED_WORD(999, OUTPUT); YY_BREAK case 125: YY_RULE_SETUP -#line 282 "glsl_lexer.lpp" -return HVEC2; +#line 292 "glsl_lexer.lpp" +RESERVED_WORD(999, HVEC2); YY_BREAK case 126: YY_RULE_SETUP -#line 283 "glsl_lexer.lpp" -return HVEC3; +#line 293 "glsl_lexer.lpp" +RESERVED_WORD(999, HVEC3); YY_BREAK case 127: YY_RULE_SETUP -#line 284 "glsl_lexer.lpp" -return HVEC4; +#line 294 "glsl_lexer.lpp" +RESERVED_WORD(999, HVEC4); YY_BREAK case 128: YY_RULE_SETUP -#line 285 "glsl_lexer.lpp" -return DVEC2; +#line 295 "glsl_lexer.lpp" +RESERVED_WORD(999, DVEC2); YY_BREAK case 129: YY_RULE_SETUP -#line 286 "glsl_lexer.lpp" -return DVEC3; +#line 296 "glsl_lexer.lpp" +RESERVED_WORD(999, DVEC3); YY_BREAK case 130: YY_RULE_SETUP -#line 287 "glsl_lexer.lpp" -return DVEC4; +#line 297 "glsl_lexer.lpp" +RESERVED_WORD(999, DVEC4); YY_BREAK case 131: YY_RULE_SETUP -#line 288 "glsl_lexer.lpp" -return FVEC2; +#line 298 "glsl_lexer.lpp" +RESERVED_WORD(999, FVEC2); YY_BREAK case 132: YY_RULE_SETUP -#line 289 "glsl_lexer.lpp" -return FVEC3; +#line 299 "glsl_lexer.lpp" +RESERVED_WORD(999, FVEC3); YY_BREAK case 133: YY_RULE_SETUP -#line 290 "glsl_lexer.lpp" -return FVEC4; +#line 300 "glsl_lexer.lpp" +RESERVED_WORD(999, FVEC4); YY_BREAK case 134: YY_RULE_SETUP -#line 291 "glsl_lexer.lpp" +#line 301 "glsl_lexer.lpp" return SAMPLER2DRECT; YY_BREAK case 135: YY_RULE_SETUP -#line 292 "glsl_lexer.lpp" -return SAMPLER3DRECT; +#line 302 "glsl_lexer.lpp" +RESERVED_WORD(999, SAMPLER3DRECT); YY_BREAK case 136: YY_RULE_SETUP -#line 293 "glsl_lexer.lpp" +#line 303 "glsl_lexer.lpp" return SAMPLER2DRECTSHADOW; YY_BREAK case 137: YY_RULE_SETUP -#line 294 "glsl_lexer.lpp" -return SIZEOF; +#line 304 "glsl_lexer.lpp" +RESERVED_WORD(999, SIZEOF); YY_BREAK case 138: YY_RULE_SETUP -#line 295 "glsl_lexer.lpp" -return CAST; +#line 305 "glsl_lexer.lpp" +RESERVED_WORD(999, CAST); YY_BREAK case 139: YY_RULE_SETUP -#line 296 "glsl_lexer.lpp" -return NAMESPACE; +#line 306 "glsl_lexer.lpp" +RESERVED_WORD(999, NAMESPACE); YY_BREAK case 140: YY_RULE_SETUP -#line 297 "glsl_lexer.lpp" -return USING; +#line 307 "glsl_lexer.lpp" +RESERVED_WORD(999, USING); YY_BREAK /* Additional reserved words in GLSL 1.20. */ case 141: YY_RULE_SETUP -#line 300 "glsl_lexer.lpp" +#line 310 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, LOWP); YY_BREAK case 142: YY_RULE_SETUP -#line 301 "glsl_lexer.lpp" +#line 311 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, MEDIUMP); YY_BREAK case 143: YY_RULE_SETUP -#line 302 "glsl_lexer.lpp" +#line 312 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, HIGHP); YY_BREAK case 144: YY_RULE_SETUP -#line 303 "glsl_lexer.lpp" +#line 313 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(120, PRECISION); YY_BREAK /* Additional reserved words in GLSL 1.30. */ case 145: YY_RULE_SETUP -#line 306 "glsl_lexer.lpp" +#line 316 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, COMMON); YY_BREAK case 146: YY_RULE_SETUP -#line 307 "glsl_lexer.lpp" +#line 317 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, PARTITION); YY_BREAK case 147: YY_RULE_SETUP -#line 308 "glsl_lexer.lpp" +#line 318 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, ACTIVE); YY_BREAK case 148: YY_RULE_SETUP -#line 309 "glsl_lexer.lpp" +#line 319 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, SUPERP); YY_BREAK case 149: YY_RULE_SETUP -#line 310 "glsl_lexer.lpp" +#line 320 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, SAMPLERBUFFER); YY_BREAK case 150: YY_RULE_SETUP -#line 311 "glsl_lexer.lpp" +#line 321 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, FILTER); YY_BREAK case 151: YY_RULE_SETUP -#line 312 "glsl_lexer.lpp" +#line 322 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IMAGE1D); YY_BREAK case 152: YY_RULE_SETUP -#line 313 "glsl_lexer.lpp" +#line 323 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IMAGE2D); YY_BREAK case 153: YY_RULE_SETUP -#line 314 "glsl_lexer.lpp" +#line 324 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IMAGE3D); YY_BREAK case 154: YY_RULE_SETUP -#line 315 "glsl_lexer.lpp" +#line 325 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IMAGECUBE); YY_BREAK case 155: YY_RULE_SETUP -#line 316 "glsl_lexer.lpp" +#line 326 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IIMAGE1D); YY_BREAK case 156: YY_RULE_SETUP -#line 317 "glsl_lexer.lpp" +#line 327 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IIMAGE2D); YY_BREAK case 157: YY_RULE_SETUP -#line 318 "glsl_lexer.lpp" +#line 328 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IIMAGE3D); YY_BREAK case 158: YY_RULE_SETUP -#line 319 "glsl_lexer.lpp" +#line 329 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IIMAGECUBE); YY_BREAK case 159: YY_RULE_SETUP -#line 320 "glsl_lexer.lpp" +#line 330 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, UIMAGE1D); YY_BREAK case 160: YY_RULE_SETUP -#line 321 "glsl_lexer.lpp" +#line 331 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, UIMAGE2D); YY_BREAK case 161: YY_RULE_SETUP -#line 322 "glsl_lexer.lpp" +#line 332 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, UIMAGE3D); YY_BREAK case 162: YY_RULE_SETUP -#line 323 "glsl_lexer.lpp" +#line 333 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, UIMAGECUBE); YY_BREAK case 163: YY_RULE_SETUP -#line 324 "glsl_lexer.lpp" +#line 334 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IMAGE1DARRAY); YY_BREAK case 164: YY_RULE_SETUP -#line 325 "glsl_lexer.lpp" +#line 335 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IMAGE2DARRAY); YY_BREAK case 165: YY_RULE_SETUP -#line 326 "glsl_lexer.lpp" +#line 336 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IIMAGE1DARRAY); YY_BREAK case 166: YY_RULE_SETUP -#line 327 "glsl_lexer.lpp" +#line 337 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IIMAGE2DARRAY); YY_BREAK case 167: YY_RULE_SETUP -#line 328 "glsl_lexer.lpp" +#line 338 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, UIMAGE1DARRAY); YY_BREAK case 168: YY_RULE_SETUP -#line 329 "glsl_lexer.lpp" +#line 339 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, UIMAGE2DARRAY); YY_BREAK case 169: YY_RULE_SETUP -#line 330 "glsl_lexer.lpp" +#line 340 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IMAGE1DSHADOW); YY_BREAK case 170: YY_RULE_SETUP -#line 331 "glsl_lexer.lpp" +#line 341 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IMAGE2DSHADOW); YY_BREAK case 171: YY_RULE_SETUP -#line 332 "glsl_lexer.lpp" +#line 342 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IMAGEBUFFER); YY_BREAK case 172: YY_RULE_SETUP -#line 333 "glsl_lexer.lpp" +#line 343 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, IIMAGEBUFFER); YY_BREAK case 173: YY_RULE_SETUP -#line 334 "glsl_lexer.lpp" +#line 344 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, UIMAGEBUFFER); YY_BREAK case 174: YY_RULE_SETUP -#line 335 "glsl_lexer.lpp" +#line 345 "glsl_lexer.lpp" TOKEN_OR_IDENTIFIER(130, ROW_MAJOR); YY_BREAK case 175: YY_RULE_SETUP -#line 337 "glsl_lexer.lpp" +#line 347 "glsl_lexer.lpp" { struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; @@ -2231,15 +2255,15 @@ YY_RULE_SETUP YY_BREAK case 176: YY_RULE_SETUP -#line 344 "glsl_lexer.lpp" +#line 354 "glsl_lexer.lpp" { return yytext[0]; } YY_BREAK case 177: YY_RULE_SETUP -#line 346 "glsl_lexer.lpp" +#line 356 "glsl_lexer.lpp" ECHO; YY_BREAK -#line 2243 "glsl_lexer.cpp" +#line 2267 "glsl_lexer.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(PP): yyterminate(); @@ -2974,8 +2998,8 @@ YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char * yystr , yyscan_t yyscann /** Setup the input buffer state to scan the given bytes. The next call to _mesa_glsl_lex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -3381,7 +3405,7 @@ void _mesa_glsl_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 346 "glsl_lexer.lpp" +#line 356 "glsl_lexer.lpp" diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp index dc15891f7ec..92937fdf9ee 100644 --- a/src/glsl/glsl_parser.cpp +++ b/src/glsl/glsl_parser.cpp @@ -299,35 +299,36 @@ CAST = 413, NAMESPACE = 414, USING = 415, - COMMON = 416, - PARTITION = 417, - ACTIVE = 418, - SAMPLERBUFFER = 419, - FILTER = 420, - IMAGE1D = 421, - IMAGE2D = 422, - IMAGE3D = 423, - IMAGECUBE = 424, - IMAGE1DARRAY = 425, - IMAGE2DARRAY = 426, - IIMAGE1D = 427, - IIMAGE2D = 428, - IIMAGE3D = 429, - IIMAGECUBE = 430, - IIMAGE1DARRAY = 431, - IIMAGE2DARRAY = 432, - UIMAGE1D = 433, - UIMAGE2D = 434, - UIMAGE3D = 435, - UIMAGECUBE = 436, - UIMAGE1DARRAY = 437, - UIMAGE2DARRAY = 438, - IMAGE1DSHADOW = 439, - IMAGE2DSHADOW = 440, - IMAGEBUFFER = 441, - IIMAGEBUFFER = 442, - UIMAGEBUFFER = 443, - ROW_MAJOR = 444 + ERROR_TOK = 416, + COMMON = 417, + PARTITION = 418, + ACTIVE = 419, + SAMPLERBUFFER = 420, + FILTER = 421, + IMAGE1D = 422, + IMAGE2D = 423, + IMAGE3D = 424, + IMAGECUBE = 425, + IMAGE1DARRAY = 426, + IMAGE2DARRAY = 427, + IIMAGE1D = 428, + IIMAGE2D = 429, + IIMAGE3D = 430, + IIMAGECUBE = 431, + IIMAGE1DARRAY = 432, + IIMAGE2DARRAY = 433, + UIMAGE1D = 434, + UIMAGE2D = 435, + UIMAGE3D = 436, + UIMAGECUBE = 437, + UIMAGE1DARRAY = 438, + UIMAGE2DARRAY = 439, + IMAGE1DSHADOW = 440, + IMAGE2DSHADOW = 441, + IMAGEBUFFER = 442, + IIMAGEBUFFER = 443, + UIMAGEBUFFER = 444, + ROW_MAJOR = 445 }; #endif @@ -369,7 +370,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 373 "glsl_parser.cpp" +#line 374 "glsl_parser.cpp" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -394,7 +395,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 398 "glsl_parser.cpp" +#line 399 "glsl_parser.cpp" #ifdef short # undef short @@ -611,10 +612,10 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 5 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 4373 +#define YYLAST 4389 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 214 +#define YYNTOKENS 215 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 89 /* YYNRULES -- Number of rules. */ @@ -624,7 +625,7 @@ union yyalloc /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 444 +#define YYMAXUTOK 445 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -635,16 +636,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 198, 2, 2, 2, 202, 205, 2, - 190, 191, 200, 196, 195, 197, 194, 201, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 209, 211, - 203, 210, 204, 208, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 199, 2, 2, 2, 203, 206, 2, + 191, 192, 201, 197, 196, 198, 195, 202, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 210, 212, + 204, 211, 205, 209, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 192, 2, 193, 206, 2, 2, 2, 2, 2, + 2, 193, 2, 194, 207, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 212, 207, 213, 199, 2, 2, 2, + 2, 2, 2, 213, 208, 214, 200, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -676,7 +677,7 @@ static const yytype_uint8 yytranslate[] = 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, - 185, 186, 187, 188, 189 + 185, 186, 187, 188, 189, 190 }; #if YYDEBUG @@ -717,55 +718,55 @@ static const yytype_uint16 yyprhs[] = /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 215, 0, -1, -1, 217, 218, 216, 220, -1, -1, - 112, 81, 117, -1, -1, 218, 219, -1, 113, 79, - 116, 79, 117, -1, 301, -1, 220, 301, -1, 79, - -1, 221, -1, 81, -1, 82, -1, 80, -1, 83, - -1, 190, 248, 191, -1, 222, -1, 223, 192, 224, - 193, -1, 225, -1, 223, 194, 79, -1, 223, 87, - -1, 223, 88, -1, 248, -1, 226, -1, 227, -1, - 223, 194, 227, -1, 229, 191, -1, 228, 191, -1, - 230, 77, -1, 230, -1, 230, 246, -1, 229, 195, - 246, -1, 231, 190, -1, 270, -1, 79, -1, 84, - -1, 223, -1, 87, 232, -1, 88, 232, -1, 233, - 232, -1, 196, -1, 197, -1, 198, -1, 199, -1, - 232, -1, 234, 200, 232, -1, 234, 201, 232, -1, - 234, 202, 232, -1, 234, -1, 235, 196, 234, -1, - 235, 197, 234, -1, 235, -1, 236, 85, 235, -1, - 236, 86, 235, -1, 236, -1, 237, 203, 236, -1, - 237, 204, 236, -1, 237, 89, 236, -1, 237, 90, - 236, -1, 237, -1, 238, 91, 237, -1, 238, 92, - 237, -1, 238, -1, 239, 205, 238, -1, 239, -1, - 240, 206, 239, -1, 240, -1, 241, 207, 240, -1, - 241, -1, 242, 93, 241, -1, 242, -1, 243, 95, - 242, -1, 243, -1, 244, 94, 243, -1, 244, -1, - 244, 208, 248, 209, 246, -1, 245, -1, 232, 247, - 246, -1, 210, -1, 96, -1, 97, -1, 99, -1, + 216, 0, -1, -1, 218, 219, 217, 221, -1, -1, + 112, 81, 117, -1, -1, 219, 220, -1, 113, 79, + 116, 79, 117, -1, 302, -1, 221, 302, -1, 79, + -1, 222, -1, 81, -1, 82, -1, 80, -1, 83, + -1, 191, 249, 192, -1, 223, -1, 224, 193, 225, + 194, -1, 226, -1, 224, 195, 79, -1, 224, 87, + -1, 224, 88, -1, 249, -1, 227, -1, 228, -1, + 224, 195, 228, -1, 230, 192, -1, 229, 192, -1, + 231, 77, -1, 231, -1, 231, 247, -1, 230, 196, + 247, -1, 232, 191, -1, 271, -1, 79, -1, 84, + -1, 224, -1, 87, 233, -1, 88, 233, -1, 234, + 233, -1, 197, -1, 198, -1, 199, -1, 200, -1, + 233, -1, 235, 201, 233, -1, 235, 202, 233, -1, + 235, 203, 233, -1, 235, -1, 236, 197, 235, -1, + 236, 198, 235, -1, 236, -1, 237, 85, 236, -1, + 237, 86, 236, -1, 237, -1, 238, 204, 237, -1, + 238, 205, 237, -1, 238, 89, 237, -1, 238, 90, + 237, -1, 238, -1, 239, 91, 238, -1, 239, 92, + 238, -1, 239, -1, 240, 206, 239, -1, 240, -1, + 241, 207, 240, -1, 241, -1, 242, 208, 241, -1, + 242, -1, 243, 93, 242, -1, 243, -1, 244, 95, + 243, -1, 244, -1, 245, 94, 244, -1, 245, -1, + 245, 209, 249, 210, 247, -1, 246, -1, 233, 248, + 247, -1, 211, -1, 96, -1, 97, -1, 99, -1, 98, -1, 105, -1, 100, -1, 101, -1, 102, -1, - 103, -1, 104, -1, 246, -1, 248, 195, 246, -1, - 245, -1, 251, 211, -1, 259, 211, -1, 111, 274, - 271, 211, -1, 252, 191, -1, 254, -1, 253, -1, - 254, 256, -1, 253, 195, 256, -1, 261, 79, 190, - -1, 270, 79, -1, 270, 79, 192, 249, 193, -1, - 267, 257, 255, -1, 257, 255, -1, 267, 257, 258, - -1, 257, 258, -1, -1, 36, -1, 37, -1, 38, - -1, 270, -1, 260, -1, 259, 195, 79, -1, 259, - 195, 79, 192, 193, -1, 259, 195, 79, 192, 249, - 193, -1, 259, 195, 79, 192, 193, 210, 280, -1, - 259, 195, 79, 192, 249, 193, 210, 280, -1, 259, - 195, 79, 210, 280, -1, 261, -1, 261, 79, -1, - 261, 79, 192, 193, -1, 261, 79, 192, 249, 193, - -1, 261, 79, 192, 193, 210, 280, -1, 261, 79, - 192, 249, 193, 210, 280, -1, 261, 79, 210, 280, - -1, 106, 79, -1, 270, -1, 268, 270, -1, -1, - 263, -1, 120, 190, 264, 191, -1, 265, -1, 264, - 195, 265, -1, 79, -1, 43, -1, 42, -1, 41, - -1, 4, -1, 269, -1, 266, 268, -1, 106, 268, - -1, 4, -1, 3, -1, 262, 40, -1, 35, 40, - -1, 262, 36, -1, 37, -1, 35, 36, -1, 35, - 37, -1, 39, -1, 271, -1, 274, 271, -1, 272, - -1, 272, 192, 193, -1, 272, 192, 249, 193, -1, - 273, -1, 275, -1, 79, -1, 77, -1, 6, -1, + 103, -1, 104, -1, 247, -1, 249, 196, 247, -1, + 246, -1, 252, 212, -1, 260, 212, -1, 111, 275, + 272, 212, -1, 253, 192, -1, 255, -1, 254, -1, + 255, 257, -1, 254, 196, 257, -1, 262, 79, 191, + -1, 271, 79, -1, 271, 79, 193, 250, 194, -1, + 268, 258, 256, -1, 258, 256, -1, 268, 258, 259, + -1, 258, 259, -1, -1, 36, -1, 37, -1, 38, + -1, 271, -1, 261, -1, 260, 196, 79, -1, 260, + 196, 79, 193, 194, -1, 260, 196, 79, 193, 250, + 194, -1, 260, 196, 79, 193, 194, 211, 281, -1, + 260, 196, 79, 193, 250, 194, 211, 281, -1, 260, + 196, 79, 211, 281, -1, 262, -1, 262, 79, -1, + 262, 79, 193, 194, -1, 262, 79, 193, 250, 194, + -1, 262, 79, 193, 194, 211, 281, -1, 262, 79, + 193, 250, 194, 211, 281, -1, 262, 79, 211, 281, + -1, 106, 79, -1, 271, -1, 269, 271, -1, -1, + 264, -1, 120, 191, 265, 192, -1, 266, -1, 265, + 196, 266, -1, 79, -1, 43, -1, 42, -1, 41, + -1, 4, -1, 270, -1, 267, 269, -1, 106, 269, + -1, 4, -1, 3, -1, 263, 40, -1, 35, 40, + -1, 263, 36, -1, 37, -1, 35, 36, -1, 35, + 37, -1, 39, -1, 272, -1, 275, 272, -1, 273, + -1, 273, 193, 194, -1, 273, 193, 250, 194, -1, + 274, -1, 276, -1, 79, -1, 77, -1, 6, -1, 7, -1, 8, -1, 5, -1, 29, -1, 30, -1, 31, -1, 20, -1, 21, -1, 22, -1, 23, -1, 24, -1, 25, -1, 26, -1, 27, -1, 28, -1, @@ -777,59 +778,59 @@ static const yytype_int16 yyrhs[] = 64, -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, -1, 70, -1, 71, -1, 72, -1, 73, -1, 74, -1, 75, -1, 109, -1, 108, -1, 107, -1, - 76, 79, 212, 276, 213, -1, 76, 212, 276, 213, - -1, 277, -1, 276, 277, -1, 270, 278, 211, -1, - 279, -1, 278, 195, 279, -1, 79, -1, 79, 192, - 249, 193, -1, 246, -1, 250, -1, 283, -1, 284, - -1, 286, -1, 285, -1, 292, -1, 281, -1, 290, - -1, 291, -1, 294, -1, 295, -1, 296, -1, 300, - -1, 212, 213, -1, 212, 289, 213, -1, 288, -1, - 285, -1, 212, 213, -1, 212, 289, 213, -1, 282, - -1, 289, 282, -1, 211, -1, 248, 211, -1, 14, - 190, 248, 191, 283, 12, 283, -1, 14, 190, 248, - 191, 283, -1, 14, 190, 248, 191, 284, -1, 14, - 190, 248, 191, 283, 12, 284, -1, 248, -1, 261, - 79, 210, 280, -1, 17, 190, 248, 191, 286, -1, - 18, 248, 209, -1, 19, 209, -1, 78, 190, 293, - 191, 287, -1, 11, 282, 78, 190, 248, 191, 211, - -1, 13, 190, 297, 299, 191, 287, -1, 290, -1, - 281, -1, 293, -1, -1, 298, 211, -1, 298, 211, - 248, -1, 10, 211, -1, 9, 211, -1, 16, 211, - -1, 16, 248, 211, -1, 15, 211, -1, 302, -1, - 250, -1, 251, 288, -1 + 76, 79, 213, 277, 214, -1, 76, 213, 277, 214, + -1, 278, -1, 277, 278, -1, 271, 279, 212, -1, + 280, -1, 279, 196, 280, -1, 79, -1, 79, 193, + 250, 194, -1, 247, -1, 251, -1, 284, -1, 285, + -1, 287, -1, 286, -1, 293, -1, 282, -1, 291, + -1, 292, -1, 295, -1, 296, -1, 297, -1, 301, + -1, 213, 214, -1, 213, 290, 214, -1, 289, -1, + 286, -1, 213, 214, -1, 213, 290, 214, -1, 283, + -1, 290, 283, -1, 212, -1, 249, 212, -1, 14, + 191, 249, 192, 284, 12, 284, -1, 14, 191, 249, + 192, 284, -1, 14, 191, 249, 192, 285, -1, 14, + 191, 249, 192, 284, 12, 285, -1, 249, -1, 262, + 79, 211, 281, -1, 17, 191, 249, 192, 287, -1, + 18, 249, 210, -1, 19, 210, -1, 78, 191, 294, + 192, 288, -1, 11, 283, 78, 191, 249, 192, 212, + -1, 13, 191, 298, 300, 192, 288, -1, 291, -1, + 282, -1, 294, -1, -1, 299, 212, -1, 299, 212, + 249, -1, 10, 212, -1, 9, 212, -1, 16, 212, + -1, 16, 249, 212, -1, 15, 212, -1, 303, -1, + 251, -1, 252, 289, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 208, 208, 207, 216, 219, 236, 238, 242, 251, - 259, 270, 274, 281, 288, 295, 302, 309, 316, 317, - 323, 327, 334, 340, 349, 353, 357, 358, 367, 368, - 372, 373, 377, 383, 395, 399, 405, 412, 423, 424, - 430, 436, 446, 447, 448, 449, 453, 454, 460, 466, - 475, 476, 482, 491, 492, 498, 507, 508, 514, 520, - 526, 535, 536, 542, 551, 552, 561, 562, 571, 572, - 581, 582, 591, 592, 601, 602, 611, 612, 621, 622, - 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, - 641, 645, 649, 665, 669, 673, 677, 691, 695, 696, - 700, 705, 713, 724, 734, 749, 756, 761, 772, 784, - 785, 786, 787, 791, 795, 796, 805, 814, 823, 832, - 841, 854, 865, 874, 883, 892, 901, 910, 919, 933, - 940, 951, 952, 956, 963, 964, 971, 1005, 1006, 1007, - 1011, 1015, 1016, 1020, 1028, 1029, 1030, 1031, 1032, 1033, - 1034, 1035, 1036, 1040, 1041, 1049, 1050, 1056, 1065, 1071, - 1077, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, - 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, - 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, - 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, - 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, - 1135, 1136, 1137, 1138, 1139, 1143, 1154, 1165, 1179, 1185, - 1194, 1199, 1207, 1222, 1227, 1235, 1241, 1250, 1254, 1260, - 1261, 1265, 1266, 1270, 1274, 1275, 1276, 1277, 1278, 1279, - 1280, 1284, 1290, 1299, 1300, 1304, 1310, 1319, 1329, 1341, - 1347, 1356, 1365, 1371, 1377, 1386, 1390, 1404, 1408, 1409, - 1413, 1420, 1427, 1437, 1438, 1442, 1444, 1450, 1455, 1464, - 1470, 1476, 1482, 1488, 1497, 1498, 1502 + 0, 210, 210, 209, 218, 221, 238, 240, 244, 253, + 261, 272, 276, 283, 290, 297, 304, 311, 318, 319, + 325, 329, 336, 342, 351, 355, 359, 360, 369, 370, + 374, 375, 379, 385, 397, 401, 407, 414, 425, 426, + 432, 438, 448, 449, 450, 451, 455, 456, 462, 468, + 477, 478, 484, 493, 494, 500, 509, 510, 516, 522, + 528, 537, 538, 544, 553, 554, 563, 564, 573, 574, + 583, 584, 593, 594, 603, 604, 613, 614, 623, 624, + 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, + 643, 647, 651, 667, 671, 675, 679, 693, 697, 698, + 702, 707, 715, 726, 736, 751, 758, 763, 774, 786, + 787, 788, 789, 793, 797, 798, 807, 816, 825, 834, + 843, 856, 867, 876, 885, 894, 903, 912, 921, 935, + 942, 953, 954, 958, 965, 966, 973, 1007, 1008, 1009, + 1013, 1017, 1018, 1022, 1030, 1031, 1032, 1033, 1034, 1035, + 1036, 1037, 1038, 1042, 1043, 1051, 1052, 1058, 1067, 1073, + 1079, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, + 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, + 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, + 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, + 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, + 1137, 1138, 1139, 1140, 1141, 1145, 1156, 1167, 1181, 1187, + 1196, 1201, 1209, 1224, 1229, 1237, 1243, 1252, 1256, 1262, + 1263, 1267, 1268, 1272, 1276, 1277, 1278, 1279, 1280, 1281, + 1282, 1286, 1292, 1301, 1302, 1306, 1312, 1321, 1331, 1343, + 1349, 1358, 1367, 1373, 1379, 1388, 1392, 1406, 1410, 1411, + 1415, 1422, 1429, 1439, 1440, 1444, 1446, 1452, 1457, 1466, + 1472, 1478, 1484, 1490, 1499, 1500, 1504 }; #endif @@ -865,11 +866,11 @@ static const char *const yytname[] = "HALF", "FIXED", "UNSIGNED", "INPUT", "OUPTUT", "HVEC2", "HVEC3", "HVEC4", "DVEC2", "DVEC3", "DVEC4", "FVEC2", "FVEC3", "FVEC4", "SAMPLER2DRECT", "SAMPLER3DRECT", "SAMPLER2DRECTSHADOW", "SIZEOF", - "CAST", "NAMESPACE", "USING", "COMMON", "PARTITION", "ACTIVE", - "SAMPLERBUFFER", "FILTER", "IMAGE1D", "IMAGE2D", "IMAGE3D", "IMAGECUBE", - "IMAGE1DARRAY", "IMAGE2DARRAY", "IIMAGE1D", "IIMAGE2D", "IIMAGE3D", - "IIMAGECUBE", "IIMAGE1DARRAY", "IIMAGE2DARRAY", "UIMAGE1D", "UIMAGE2D", - "UIMAGE3D", "UIMAGECUBE", "UIMAGE1DARRAY", "UIMAGE2DARRAY", + "CAST", "NAMESPACE", "USING", "ERROR_TOK", "COMMON", "PARTITION", + "ACTIVE", "SAMPLERBUFFER", "FILTER", "IMAGE1D", "IMAGE2D", "IMAGE3D", + "IMAGECUBE", "IMAGE1DARRAY", "IMAGE2DARRAY", "IIMAGE1D", "IIMAGE2D", + "IIMAGE3D", "IIMAGECUBE", "IIMAGE1DARRAY", "IIMAGE2DARRAY", "UIMAGE1D", + "UIMAGE2D", "UIMAGE3D", "UIMAGECUBE", "UIMAGE1DARRAY", "UIMAGE2DARRAY", "IMAGE1DSHADOW", "IMAGE2DSHADOW", "IMAGEBUFFER", "IIMAGEBUFFER", "UIMAGEBUFFER", "ROW_MAJOR", "'('", "')'", "'['", "']'", "'.'", "','", "'+'", "'-'", "'!'", "'~'", "'*'", "'/'", "'%'", "'<'", "'>'", "'&'", @@ -935,43 +936,43 @@ static const yytype_uint16 yytoknum[] = 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, - 40, 41, 91, 93, 46, 44, 43, 45, 33, 126, - 42, 47, 37, 60, 62, 38, 94, 124, 63, 58, - 61, 59, 123, 125 + 445, 40, 41, 91, 93, 46, 44, 43, 45, 33, + 126, 42, 47, 37, 60, 62, 38, 94, 124, 63, + 58, 61, 59, 123, 125 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { - 0, 214, 216, 215, 217, 217, 218, 218, 219, 220, - 220, 221, 222, 222, 222, 222, 222, 222, 223, 223, - 223, 223, 223, 223, 224, 225, 226, 226, 227, 227, - 228, 228, 229, 229, 230, 231, 231, 231, 232, 232, - 232, 232, 233, 233, 233, 233, 234, 234, 234, 234, - 235, 235, 235, 236, 236, 236, 237, 237, 237, 237, - 237, 238, 238, 238, 239, 239, 240, 240, 241, 241, - 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, - 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, - 247, 248, 248, 249, 250, 250, 250, 251, 252, 252, - 253, 253, 254, 255, 255, 256, 256, 256, 256, 257, - 257, 257, 257, 258, 259, 259, 259, 259, 259, 259, - 259, 260, 260, 260, 260, 260, 260, 260, 260, 261, - 261, 262, 262, 263, 264, 264, 265, 266, 266, 266, - 267, 268, 268, 268, 269, 269, 269, 269, 269, 269, - 269, 269, 269, 270, 270, 271, 271, 271, 272, 272, - 272, 273, 273, 273, 273, 273, 273, 273, 273, 273, - 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - 273, 273, 273, 273, 273, 274, 274, 274, 275, 275, - 276, 276, 277, 278, 278, 279, 279, 280, 281, 282, - 282, 283, 283, 284, 285, 285, 285, 285, 285, 285, - 285, 286, 286, 287, 287, 288, 288, 289, 289, 290, - 290, 291, 292, 292, 292, 293, 293, 294, 295, 295, - 296, 296, 296, 297, 297, 298, 298, 299, 299, 300, - 300, 300, 300, 300, 301, 301, 302 + 0, 215, 217, 216, 218, 218, 219, 219, 220, 221, + 221, 222, 223, 223, 223, 223, 223, 223, 224, 224, + 224, 224, 224, 224, 225, 226, 227, 227, 228, 228, + 229, 229, 230, 230, 231, 232, 232, 232, 233, 233, + 233, 233, 234, 234, 234, 234, 235, 235, 235, 235, + 236, 236, 236, 237, 237, 237, 238, 238, 238, 238, + 238, 239, 239, 239, 240, 240, 241, 241, 242, 242, + 243, 243, 244, 244, 245, 245, 246, 246, 247, 247, + 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + 248, 249, 249, 250, 251, 251, 251, 252, 253, 253, + 254, 254, 255, 256, 256, 257, 257, 257, 257, 258, + 258, 258, 258, 259, 260, 260, 260, 260, 260, 260, + 260, 261, 261, 261, 261, 261, 261, 261, 261, 262, + 262, 263, 263, 264, 265, 265, 266, 267, 267, 267, + 268, 269, 269, 269, 270, 270, 270, 270, 270, 270, + 270, 270, 270, 271, 271, 272, 272, 272, 273, 273, + 273, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 275, 275, 275, 276, 276, + 277, 277, 278, 279, 279, 280, 280, 281, 282, 283, + 283, 284, 284, 285, 286, 286, 286, 286, 286, 286, + 286, 287, 287, 288, 288, 289, 289, 290, 290, 291, + 291, 292, 293, 293, 293, 294, 294, 295, 296, 296, + 297, 297, 297, 298, 298, 299, 299, 300, 300, 301, + 301, 301, 301, 301, 302, 302, 303 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -1072,65 +1073,65 @@ static const yytype_int16 yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -351 +#define YYPACT_NINF -361 static const yytype_int16 yypact[] = { - -85, -52, 36, -351, -60, -351, -30, -351, -31, 3875, - -351, -27, -351, -351, -351, -351, -351, -351, -351, -351, - -351, -351, -351, -351, -351, -351, -351, -351, -351, -351, - -351, -351, -351, 69, -351, -351, -351, -351, -351, -351, - -351, -351, -351, -351, -351, -351, -351, -351, -351, -351, - -351, -351, -351, -351, -351, -351, -351, -351, -351, -351, - -351, -351, -351, -351, -351, -351, -351, -351, -351, -351, - -351, -78, -351, -351, 8, -351, -351, -351, 50, -83, - -351, -351, 3757, -351, -63, 4, -44, 3, -169, -351, - 82, -5, -351, 166, 4104, -351, -351, -351, 14, -351, - 4217, -351, -351, -351, 135, -351, -351, -351, -12, 4104, - -351, 166, -351, 4217, 142, -351, -351, 401, -351, -351, - 18, -351, -351, -351, -351, -351, 4104, 127, 144, -351, - -112, -351, -351, -351, -351, 2857, -351, 107, 4104, 146, - 2254, -351, 20, -351, -99, -351, 21, 25, 1245, 39, - 47, 27, 2480, 49, 3397, 31, 53, -69, -351, -351, - -351, -351, -351, 3397, 3397, 3397, -351, -351, -351, -351, - -351, 612, -351, -351, -351, -68, -351, -351, -351, 54, - -59, 3577, 56, -36, 3397, -34, -25, 112, -81, 121, - 45, 38, 44, 159, 158, -88, -351, -351, -167, -351, - 46, 66, -351, -351, -351, -351, -351, -351, 823, -351, - -351, -351, -351, -351, -351, -351, -351, -351, -351, 179, - 4104, -178, -351, 3037, 3397, -351, -351, -351, 67, -351, - -351, 2367, 70, -121, -351, -351, -351, -351, -351, 142, - -351, -351, 181, 1862, 3397, -351, -351, -114, 3397, -172, - -351, 2677, -351, -351, -58, -351, 1034, -351, -351, 3397, - 3991, -351, -351, 3397, 72, -351, -351, -351, -351, -351, - -351, -351, -351, -351, -351, -351, -351, -351, 3397, -351, - 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, - 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, 3397, - 3397, -351, -351, -351, 73, -351, -351, 3217, 3397, 51, - 71, -351, -351, -351, -351, 3397, 146, -351, -351, 76, - -351, -351, 2059, -51, -351, -50, -351, 74, 188, 77, - -351, -351, 78, 74, 80, -351, -351, -351, -351, -351, - -351, -34, -34, -25, -25, 112, 112, 112, 112, -81, - -81, 121, 45, 38, 44, 159, 158, -125, -351, 3397, - 63, 81, -351, 3397, 65, 83, -351, 3397, -351, 68, - 86, 1245, 75, 79, 1455, -351, 3397, 85, 3397, 84, - -351, 3397, -351, -49, 3397, 1455, 268, -351, -351, 3397, - 91, -351, -351, -351, -351, -351, -351, 3397, -351, 87, - 74, -351, 1245, -351, 3397, -351, -351, -351, -351, -48, - 1665, 270, 1665 + -51, -15, 81, -361, -34, -361, -24, -361, 25, 3891, + -361, -19, -361, -361, -361, -361, -361, -361, -361, -361, + -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, + -361, -361, -361, 69, -361, -361, -361, -361, -361, -361, + -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, + -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, + -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, + -361, -78, -361, -361, 8, -361, -361, -361, 49, -80, + -361, -361, 3773, -361, -177, -79, -55, 2, -168, -361, + 70, 56, -361, 28, 4120, -361, -361, -361, -39, -361, + 4233, -361, -361, -361, 80, -361, -361, -361, -67, 4120, + -361, 28, -361, 4233, 95, -361, -361, 401, -361, -361, + 18, -361, -361, -361, -361, -361, 4120, 176, 116, -361, + -113, -361, -361, -361, -361, 2868, -361, 86, 4120, 126, + 2263, -361, 9, -361, -89, -361, 17, 24, 1249, 46, + 47, 27, 2489, 52, 3411, 30, 53, -70, -361, -361, + -361, -361, -361, 3411, 3411, 3411, -361, -361, -361, -361, + -361, 613, -361, -361, -361, -69, -361, -361, -361, 54, + -76, 3592, 59, 67, 3411, 22, 0, 115, -82, 125, + 39, 44, 45, 159, 161, -90, -361, -361, -159, -361, + 48, 66, -361, -361, -361, -361, -361, -361, 825, -361, + -361, -361, -361, -361, -361, -361, -361, -361, -361, 179, + 4120, -170, -361, 3049, 3411, -361, -361, -361, 65, -361, + -361, 2376, 68, -122, -361, -361, -361, -361, -361, 95, + -361, -361, 184, 1869, 3411, -361, -361, -121, 3411, -162, + -361, 2687, -361, -361, -60, -361, 1037, -361, -361, 3411, + 4007, -361, -361, 3411, 71, -361, -361, -361, -361, -361, + -361, -361, -361, -361, -361, -361, -361, -361, 3411, -361, + 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, + 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, + 3411, -361, -361, -361, 72, -361, -361, 3230, 3411, 55, + 73, -361, -361, -361, -361, 3411, 126, -361, -361, 77, + -361, -361, 2067, -59, -361, -52, -361, 74, 185, 79, + -361, -361, 75, 74, 82, -361, -361, -361, -361, -361, + -361, 22, 22, 0, 0, 115, 115, 115, 115, -82, + -82, 125, 39, 44, 45, 159, 161, -128, -361, 3411, + 61, 83, -361, 3411, 63, 85, -361, 3411, -361, 64, + 88, 1249, 62, 76, 1460, -361, 3411, 87, 3411, 78, + -361, 3411, -361, -49, 3411, 1460, 270, -361, -361, 3411, + 92, -361, -361, -361, -361, -361, -361, 3411, -361, 84, + 74, -361, 1249, -361, 3411, -361, -361, -361, -361, -41, + 1671, 272, 1671 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -351, -351, -351, -351, -351, -351, -351, -351, -351, -351, - -351, -351, -351, 23, -351, -351, -351, -351, -105, -351, - -67, -66, -134, -65, -8, -10, -7, -6, -4, -3, - -351, -111, -148, -351, -149, -221, 6, 9, -351, -351, - -351, 88, 171, 165, 89, -351, -351, -247, -351, -351, - -351, 57, -351, -351, -40, -351, -9, -75, -351, -351, - 219, -351, 161, -127, -351, -16, -262, 58, -131, -299, - -350, -292, -70, -82, 220, 134, 64, -351, -351, -11, - -351, -351, -351, -351, -351, -351, -351, 224, -351 + -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, + -361, -361, -361, 26, -361, -361, -361, -361, -105, -361, + -64, -54, -81, -65, -8, -6, -5, -4, -3, -7, + -361, -111, -148, -361, -149, -221, 6, 11, -361, -361, + -361, 89, 173, 168, 90, -361, -361, -238, -361, -361, + -361, 58, -361, -361, -47, -361, -9, -71, -361, -361, + 220, -361, 162, -130, -361, -17, -236, 60, -131, -350, + -345, -360, -68, -84, 218, 134, 91, -361, -361, -16, + -361, -361, -361, -361, -361, -361, -361, 225, -361 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -1140,40 +1141,40 @@ static const yytype_int16 yypgoto[] = #define YYTABLE_NINF -267 static const yytype_int16 yytable[] = { - 96, 108, 310, 247, 328, 249, 298, 121, 287, 288, - -160, 12, 13, 236, 307, 83, 254, 242, 84, 257, - 258, 387, 121, 300, 227, 136, 128, 1, 300, 4, - 226, 131, 308, 265, 112, 132, 5, 326, 142, 122, - 123, 124, 129, 33, 301, 34, 362, 35, 11, 36, - 37, 38, 408, 133, 122, 123, 124, 7, 252, 253, - 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, - 300, 112, 386, 96, 316, 328, 311, 303, 222, 279, - 223, 300, 391, 8, 376, 134, 361, 110, 83, 104, - 317, 84, 238, 391, 365, 323, 239, 324, 224, 325, - 139, 380, 327, 407, 236, 105, 106, 114, 201, 107, - 333, 411, 227, 407, 111, 336, 396, 219, 226, 398, - 299, -36, 289, 290, 259, 303, 260, 403, 79, 139, - 337, 139, 262, 330, 109, 405, 263, 300, 377, 201, - 371, 372, 399, 410, 300, 300, 300, 300, 116, 117, - 357, 120, 358, 345, 346, 347, 348, 75, 76, 77, - 311, 130, 201, 122, 123, 124, 280, 281, 282, 12, - 13, 283, 284, 327, 277, 338, 339, 340, 226, 226, + 96, 108, 310, 247, 298, 249, 121, 287, 288, -160, + 236, 12, 13, 328, 391, 83, 254, 242, 257, 258, + 84, 386, 121, 307, 227, 391, 387, 112, 128, 136, + 226, 12, 13, 265, 300, 116, 117, 300, 122, 123, + 124, 308, 142, 33, 129, 34, 133, 35, 326, 36, + 37, 38, 407, 301, 122, 123, 124, 408, 252, 253, + 411, 1, 407, 33, 112, 34, 4, 35, 300, 36, + 37, 38, 362, 96, 316, 300, 311, 303, 222, 279, + 223, 5, 376, 7, 328, 134, 361, 110, 83, 8, + 317, 324, 131, 84, 365, 323, 132, 104, 224, 325, + 139, 236, 327, 238, 11, 105, 106, 239, 201, 107, + 333, 114, 227, 119, 111, 336, 262, 219, 226, 299, + 263, -36, 289, 290, 259, 303, 260, 380, 79, 139, + 337, 139, 330, 371, 111, 109, 300, 300, 377, 201, + 372, 120, 396, 399, 300, 398, 138, 300, 79, 130, + 357, 410, 358, 403, 135, 300, 75, 76, 77, 137, + 311, 405, 201, 267, 268, 269, 270, 271, 272, 273, + 274, 275, 276, 327, 143, 338, 339, 340, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, - 226, 226, 226, 226, -98, 119, 227, 285, 286, 201, - 138, 33, 226, 34, 227, 35, 135, 36, 37, 38, - 226, 219, 291, 292, 137, 311, 341, 342, 383, 343, - 344, 143, 139, 221, 230, 232, 349, 350, 394, 243, - 311, 237, 240, 311, 201, 400, 241, 244, 245, 248, - 250, 311, 201, 251, 294, 261, 266, 201, 227, 311, - 293, 295, 296, 297, 226, 409, -35, 116, 304, 319, - 313, 363, 315, -30, 364, 359, 367, 373, 374, 300, - -36, 375, 111, 378, 379, 381, 382, 385, 395, 384, - 402, 404, 412, 335, 352, 351, 79, 171, 353, 389, - 354, 216, 220, 355, 397, 356, 318, 113, 406, 231, - 366, 320, 388, 401, 118, 256, 115, 321, 305, 306, - 0, 368, 0, 201, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 226, 226, 226, 226, -98, 221, 227, 283, 284, 201, + 285, 286, 226, 230, 227, 232, 345, 346, 347, 348, + 226, 219, 122, 123, 124, 311, 291, 292, 383, 341, + 342, 237, 139, 280, 281, 282, 349, 350, 394, 240, + 311, 343, 344, 311, 201, 400, 241, 243, 244, 245, + 250, 311, 201, 248, 251, 293, 261, 201, 227, 311, + 266, 294, 296, 295, 226, 409, 297, -35, 304, 313, + 116, 315, 319, -30, 373, 359, 363, 364, 367, 375, + 300, 374, 378, -36, 381, 171, 384, 379, 277, 382, + 385, 395, 402, 404, 412, 351, 335, 389, 352, 397, + 353, 356, 354, 216, 355, 220, 406, 318, 113, 366, + 231, 401, 118, 320, 388, 256, 368, 115, 0, 305, + 306, 0, 0, 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 321, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 201, 0, 0, 201, 0, 0, 0, 0, @@ -1199,30 +1200,9 @@ static const yytype_int16 yytable[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, - 169, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 170, 171, 172, 12, 13, 14, 15, 16, - 17, 146, 147, 148, 0, 149, 150, 151, 152, 153, - 154, 155, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 0, 34, - 0, 35, 0, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 156, 157, 158, 159, 160, 161, 162, 0, 0, 163, - 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 74, 75, - 76, 77, 0, 78, 0, 0, 0, 0, 0, 0, - 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 170, 171, 255, 12, 13, 14, 15, + 0, 0, 0, 170, 171, 172, 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, 149, 150, 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, @@ -1239,32 +1219,11 @@ static const yytype_int16 yytable[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 165, 0, 0, 0, 0, 0, 166, - 167, 168, 169, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 170, 171, 302, 12, 13, 14, - 15, 16, 17, 146, 147, 148, 0, 149, 150, 151, - 152, 153, 154, 155, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 0, 34, 0, 35, 0, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 156, 157, 158, 159, 160, 161, 162, 0, - 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 74, 75, 76, 77, 0, 78, 0, 0, 0, 0, - 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, - 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 170, 171, 331, 12, 13, + 0, 0, 0, 0, 0, 170, 171, 255, 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, 149, 150, 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -1283,71 +1242,94 @@ static const yytype_int16 yytable[] = 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, - 0, 166, 167, 168, 169, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 170, 171, 12, 13, - 14, 15, 16, 17, 146, 147, 148, 0, 149, 390, - 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 0, 34, 0, 35, 0, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 156, 157, 158, 159, 160, 161, 162, - 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 165, 0, 0, 0, + 0, 0, 166, 167, 168, 169, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 170, 171, 302, + 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, + 149, 150, 151, 152, 153, 154, 155, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 156, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 74, 75, 76, 77, 0, 78, 0, 0, 0, - 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, + 0, 0, 0, 74, 75, 76, 77, 0, 78, 0, + 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, - 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, - 0, 166, 167, 168, 169, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 170, 117, 12, 13, - 14, 15, 16, 17, 146, 147, 148, 0, 149, 390, - 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 0, 34, 0, 35, 0, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 156, 157, 158, 159, 160, 161, 162, - 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 74, 75, 76, 77, 0, 78, 0, 0, 0, - 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, + 0, 0, 0, 0, 166, 167, 168, 169, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 170, + 171, 331, 12, 13, 14, 15, 16, 17, 146, 147, + 148, 0, 149, 150, 151, 152, 153, 154, 155, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 0, 34, 0, 35, 0, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 156, 157, 158, + 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 74, 75, 76, 77, 0, + 78, 0, 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, - 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, - 0, 166, 167, 168, 169, 12, 13, 14, 15, 16, - 17, 0, 0, 0, 0, 0, 170, 171, 0, 0, - 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 0, 34, - 0, 35, 0, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 0, 157, 158, 159, 160, 161, 162, 0, 0, 163, - 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 74, 75, - 76, 77, 0, 78, 0, 0, 0, 0, 0, 0, - 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 170, 171, 12, 13, 14, 15, 16, 17, 146, + 147, 148, 0, 149, 390, 151, 152, 153, 154, 155, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 0, 34, 0, 35, + 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 156, 157, + 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 74, 75, 76, 77, + 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, + 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, + 169, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 170, 117, 12, 13, 14, 15, 16, 17, + 146, 147, 148, 0, 149, 390, 151, 152, 153, 154, + 155, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 0, 34, 0, + 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 156, + 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 74, 75, 76, + 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, + 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, 12, 13, 14, 15, 16, 17, 0, 0, - 0, 0, 0, 170, 0, 0, 0, 0, 0, 18, + 0, 0, 0, 170, 171, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, @@ -1356,54 +1338,74 @@ static const yytype_int16 yytable[] = 66, 67, 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 111, 75, 76, 77, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, + 0, 0, 0, 0, 0, 74, 75, 76, 77, 0, + 78, 0, 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, - 0, 0, 0, 0, 0, 166, 167, 168, 169, 14, - 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, - -266, 0, 0, 0, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, - 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, + 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, + 12, 13, 14, 15, 16, 17, 0, 0, 0, 0, + 0, 170, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 0, 0, 0, 0, 0, 80, 0, - 81, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 0, 73, 0, 0, 0, + 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, + 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 235, 0, 0, - 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, - 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, + 0, 0, 0, 111, 75, 76, 77, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 0, 157, - 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 314, 0, 0, 0, 0, 0, 0, 75, 76, 77, + 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, + 0, 0, 0, 0, 166, 167, 168, 169, 14, 15, + 16, 17, 0, 0, 0, 0, 0, 0, 0, -266, + 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, + 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 0, 0, 0, 0, 0, 0, 80, 0, 81, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 235, 0, 0, + 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, + 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 80, 0, 81, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 0, 157, 158, + 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, + 314, 0, 0, 0, 0, 0, 75, 76, 77, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1426,196 +1428,196 @@ static const yytype_int16 yytable[] = 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 14, 15, 16, 17, 0, 165, 0, 0, - 0, 0, 0, 166, 167, 168, 169, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 14, 15, 16, 17, 0, 165, 0, + 0, 0, 0, 0, 166, 167, 168, 169, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 0, 157, 158, 159, + 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 14, 15, 16, 17, 0, 165, 0, 0, - 225, 0, 0, 166, 167, 168, 169, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, + 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 14, 15, 16, 17, 0, 165, + 0, 0, 225, 0, 0, 166, 167, 168, 169, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 0, 157, 158, + 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 14, 15, 16, 17, 0, 165, 0, 0, - 309, 0, 0, 166, 167, 168, 169, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, + 165, 0, 0, 309, 0, 0, 166, 167, 168, 169, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 0, 157, + 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 14, 15, 16, 17, 0, 165, 0, 0, - 360, 0, 0, 166, 167, 168, 169, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, + 0, 165, 0, 0, 360, 0, 0, 166, 167, 168, + 169, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, + 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, + 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 14, 15, 16, 17, 0, 165, 0, 0, - 0, 0, 0, 166, 167, 168, 169, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 264, 0, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, + 17, 0, 165, 0, 0, 0, 0, 0, 166, 167, + 168, 169, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 264, + 0, 157, 158, 159, 160, 161, 162, 0, 0, 163, + 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, + 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, - 12, 13, 14, 15, 16, 17, 0, 165, 0, 0, - 0, 0, 0, 166, 167, 168, 169, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 74, 75, 76, 77, 0, 78, 0, - 0, 0, 0, 0, 0, 0, 0, 79, 12, 13, - 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 80, 34, 81, 35, 0, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -3, 0, 0, 12, 13, 14, 15, + 16, 17, 0, 165, 0, 0, 0, 0, 0, 166, + 167, 168, 169, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, + 34, 0, 35, 0, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 74, 75, 76, 77, 0, 78, 0, 0, 0, - 0, 0, 0, 0, 0, 79, 14, 15, 16, 17, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, + 75, 76, 77, 0, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 79, 12, 13, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 0, 0, 0, 80, - 0, 81, 0, 0, 0, 39, 40, 41, 42, 43, + 27, 28, 29, 30, 31, 32, 33, 80, 34, 81, + 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, - 334, 0, 0, 0, 0, 162, 0, 0, 0, 0, + 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, - 77, 0, 0, 0, 0, 0, 0, 0, 0, 14, - 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, - 0, 0, 0, 0, 0, 80, 0, 81, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, - 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 74, 75, 76, + 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, + 0, 79, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 0, 0, 0, 0, 0, 80, 0, - 81, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 31, 32, 0, 0, 0, 80, 0, 81, 0, 0, + 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 0, 73, 0, 0, 0, + 68, 69, 70, 71, 72, 0, 334, 0, 0, 0, + 0, 162, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, + 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, + 0, 80, 0, 81, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 75, 76, 77, + 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, + 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, + 0, 0, 0, 0, 80, 0, 81, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 81 + 0, 0, 0, 0, 0, 0, 0, 80, 0, 81 }; static const yytype_int16 yycheck[] = { - 9, 79, 223, 152, 251, 154, 94, 4, 89, 90, - 79, 3, 4, 140, 192, 9, 165, 148, 9, 87, - 88, 371, 4, 195, 135, 100, 195, 112, 195, 81, - 135, 36, 210, 181, 74, 40, 0, 209, 113, 36, - 37, 38, 211, 35, 211, 37, 308, 39, 79, 41, - 42, 43, 402, 93, 36, 37, 38, 117, 163, 164, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 195, 111, 371, 82, 195, 322, 224, 208, 190, 184, - 192, 195, 374, 113, 209, 94, 307, 79, 82, 116, - 211, 82, 191, 385, 315, 244, 195, 211, 210, 248, - 109, 363, 251, 402, 231, 36, 37, 190, 117, 40, - 259, 410, 223, 412, 106, 263, 378, 126, 223, 381, - 208, 190, 203, 204, 192, 256, 194, 389, 120, 138, - 278, 140, 191, 191, 212, 397, 195, 195, 359, 148, - 191, 191, 191, 191, 195, 195, 195, 195, 211, 212, - 299, 195, 300, 287, 288, 289, 290, 107, 108, 109, - 308, 79, 171, 36, 37, 38, 200, 201, 202, 3, - 4, 196, 197, 322, 210, 280, 281, 282, 283, 284, + 9, 79, 223, 152, 94, 154, 4, 89, 90, 79, + 140, 3, 4, 251, 374, 9, 165, 148, 87, 88, + 9, 371, 4, 193, 135, 385, 371, 74, 196, 100, + 135, 3, 4, 181, 196, 212, 213, 196, 36, 37, + 38, 211, 113, 35, 212, 37, 93, 39, 210, 41, + 42, 43, 402, 212, 36, 37, 38, 402, 163, 164, + 410, 112, 412, 35, 111, 37, 81, 39, 196, 41, + 42, 43, 308, 82, 196, 196, 224, 208, 191, 184, + 193, 0, 210, 117, 322, 94, 307, 79, 82, 113, + 212, 212, 36, 82, 315, 244, 40, 116, 211, 248, + 109, 231, 251, 192, 79, 36, 37, 196, 117, 40, + 259, 191, 223, 192, 106, 263, 192, 126, 223, 209, + 196, 191, 204, 205, 193, 256, 195, 363, 120, 138, + 278, 140, 192, 192, 106, 213, 196, 196, 359, 148, + 192, 196, 378, 192, 196, 381, 213, 196, 120, 79, + 299, 192, 300, 389, 193, 196, 107, 108, 109, 79, + 308, 397, 171, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 322, 79, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 191, 191, 307, 85, 86, 208, - 212, 35, 307, 37, 315, 39, 192, 41, 42, 43, - 315, 220, 91, 92, 79, 363, 283, 284, 367, 285, - 286, 79, 231, 79, 117, 79, 291, 292, 376, 190, - 378, 211, 211, 381, 243, 384, 211, 190, 211, 190, - 209, 389, 251, 190, 206, 191, 190, 256, 359, 397, - 205, 207, 93, 95, 359, 404, 190, 211, 79, 78, - 193, 210, 192, 191, 193, 192, 190, 79, 191, 195, - 190, 193, 106, 210, 193, 210, 193, 191, 193, 211, - 12, 190, 12, 260, 294, 293, 120, 212, 295, 210, - 296, 120, 127, 297, 210, 298, 239, 78, 211, 138, - 316, 243, 372, 385, 84, 171, 82, 243, 220, 220, - -1, 322, -1, 322, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 295, 296, 297, 298, 192, 79, 307, 197, 198, 208, + 85, 86, 307, 117, 315, 79, 287, 288, 289, 290, + 315, 220, 36, 37, 38, 363, 91, 92, 367, 283, + 284, 212, 231, 201, 202, 203, 291, 292, 376, 212, + 378, 285, 286, 381, 243, 384, 212, 191, 191, 212, + 210, 389, 251, 191, 191, 206, 192, 256, 359, 397, + 191, 207, 93, 208, 359, 404, 95, 191, 79, 194, + 212, 193, 78, 192, 79, 193, 211, 194, 191, 194, + 196, 192, 211, 191, 211, 213, 212, 194, 211, 194, + 192, 194, 12, 191, 12, 293, 260, 211, 294, 211, + 295, 298, 296, 120, 297, 127, 212, 239, 78, 316, + 138, 385, 84, 243, 372, 171, 322, 82, -1, 220, + 220, -1, -1, 322, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 243, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 371, -1, -1, 374, -1, -1, -1, -1, @@ -1641,30 +1643,9 @@ static const yytype_int16 yycheck[] = -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 190, -1, -1, -1, -1, -1, 196, 197, 198, - 199, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 211, 212, 213, 3, 4, 5, 6, 7, - 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, -1, 37, - -1, 39, -1, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, -1, -1, 87, - 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 106, 107, - 108, 109, -1, 111, -1, -1, -1, -1, -1, -1, - -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 190, -1, -1, -1, -1, -1, 196, 197, - 198, 199, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 211, 212, 213, 3, 4, 5, 6, + -1, -1, 191, -1, -1, -1, -1, -1, 197, 198, + 199, 200, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 212, 213, 214, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, @@ -1683,30 +1664,9 @@ static const yytype_int16 yycheck[] = -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 190, -1, -1, -1, -1, -1, 196, - 197, 198, 199, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 211, 212, 213, 3, 4, 5, - 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - -1, 37, -1, 39, -1, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, -1, - -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 106, 107, 108, 109, -1, 111, -1, -1, -1, -1, - -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 154, -1, - 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 190, -1, -1, -1, -1, -1, - 196, 197, 198, 199, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 211, 212, 213, 3, 4, + -1, -1, -1, -1, 191, -1, -1, -1, -1, -1, + 197, 198, 199, 200, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 212, 213, 214, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, @@ -1725,133 +1685,114 @@ static const yytype_int16 yycheck[] = -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 190, -1, -1, -1, -1, - -1, 196, 197, 198, 199, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 211, 212, 3, 4, - 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, -1, 37, -1, 39, -1, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 106, 107, 108, 109, -1, 111, -1, -1, -1, - -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, - -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 190, -1, -1, -1, -1, - -1, 196, 197, 198, 199, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 211, 212, 3, 4, - 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, -1, 37, -1, 39, -1, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 106, 107, 108, 109, -1, 111, -1, -1, -1, - -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, - -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 191, -1, -1, -1, + -1, -1, 197, 198, 199, 200, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 212, 213, 214, + 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 190, -1, -1, -1, -1, - -1, 196, 197, 198, 199, 3, 4, 5, 6, 7, - 8, -1, -1, -1, -1, -1, 211, 212, -1, -1, - -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, -1, 37, - -1, 39, -1, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - -1, 79, 80, 81, 82, 83, 84, -1, -1, 87, - 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 106, 107, - 108, 109, -1, 111, -1, -1, -1, -1, -1, -1, - -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 106, 107, 108, 109, -1, 111, -1, + -1, -1, -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 190, -1, -1, -1, -1, -1, 196, 197, - 198, 199, 3, 4, 5, 6, 7, 8, -1, -1, - -1, -1, -1, 211, -1, -1, -1, -1, -1, 20, + -1, -1, -1, -1, -1, -1, -1, -1, 191, -1, + -1, -1, -1, -1, 197, 198, 199, 200, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 212, + 213, 214, 3, 4, 5, 6, 7, 8, 9, 10, + 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, -1, 79, 80, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, 109, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 120, + 111, -1, -1, -1, -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 190, - -1, -1, -1, -1, -1, 196, 197, 198, 199, 5, - 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, - 211, -1, -1, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 191, -1, -1, -1, -1, -1, 197, 198, 199, 200, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, - -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, -1, -1, -1, -1, -1, 154, -1, - 156, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 213, -1, -1, - -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, - -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 212, 213, 3, 4, 5, 6, 7, 8, 9, + 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, -1, -1, -1, -1, -1, - -1, 154, -1, 156, 44, 45, 46, 47, 48, 49, + 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, + -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 213, -1, -1, -1, -1, -1, -1, 107, 108, 109, + -1, -1, -1, -1, -1, -1, 106, 107, 108, 109, + -1, 111, -1, -1, -1, -1, -1, -1, -1, -1, + 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, + -1, 191, -1, -1, -1, -1, -1, 197, 198, 199, + 200, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 212, 213, 3, 4, 5, 6, 7, 8, + 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, -1, 37, -1, + 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, + 109, -1, 111, -1, -1, -1, -1, -1, -1, -1, + -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 190, -1, -1, -1, -1, -1, 196, 197, 198, 199, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 191, -1, -1, -1, -1, -1, 197, 198, + 199, 200, 3, 4, 5, 6, 7, 8, -1, -1, + -1, -1, -1, 212, 213, -1, -1, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, -1, 37, -1, 39, -1, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, -1, 79, 80, + 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 106, 107, 108, 109, -1, + 111, -1, -1, -1, -1, -1, -1, -1, -1, 120, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 191, -1, -1, -1, -1, -1, 197, 198, 199, 200, 3, 4, 5, 6, 7, 8, -1, -1, -1, -1, - -1, 211, -1, -1, -1, -1, -1, 20, 21, 22, + -1, 212, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, @@ -1868,206 +1809,268 @@ static const yytype_int16 yycheck[] = -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 5, 6, 7, 8, -1, 190, -1, -1, - -1, -1, -1, 196, 197, 198, 199, 20, 21, 22, + -1, -1, -1, -1, -1, -1, -1, -1, 191, -1, + -1, -1, -1, -1, 197, 198, 199, 200, 5, 6, + 7, 8, -1, -1, -1, -1, -1, -1, -1, 212, + -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, + -1, 5, 6, 7, 8, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, -1, -1, -1, -1, -1, 154, -1, 156, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 214, -1, -1, + -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, + -1, -1, -1, -1, 5, 6, 7, 8, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, -1, -1, -1, -1, -1, -1, + 154, -1, 156, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, -1, 79, 80, + 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 214, -1, -1, -1, -1, -1, 107, 108, 109, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 191, -1, -1, -1, -1, -1, 197, 198, 199, 200, + 3, 4, 5, 6, 7, 8, -1, -1, -1, -1, + -1, 212, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 106, 107, 108, 109, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 5, 6, 7, 8, -1, 190, -1, -1, - 193, -1, -1, 196, 197, 198, 199, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, -1, -1, 5, 6, 7, 8, -1, 191, -1, + -1, -1, -1, -1, 197, 198, 199, 200, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, -1, 79, 80, 81, + 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, + -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, + -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 5, 6, 7, 8, -1, 190, -1, -1, - 193, -1, -1, 196, 197, 198, 199, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, -1, -1, -1, 5, 6, 7, 8, -1, 191, + -1, -1, 194, -1, -1, 197, 198, 199, 200, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, -1, 79, 80, + 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 5, 6, 7, 8, -1, 190, -1, -1, - 193, -1, -1, 196, 197, 198, 199, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, + 191, -1, -1, 194, -1, -1, 197, 198, 199, 200, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, + 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 5, 6, 7, 8, -1, 190, -1, -1, - -1, -1, -1, 196, 197, 198, 199, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, + -1, 191, -1, -1, 194, -1, -1, 197, 198, 199, + 200, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, + 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 107, 108, + 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, - 3, 4, 5, 6, 7, 8, -1, 190, -1, -1, - -1, -1, -1, 196, 197, 198, 199, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, + 8, -1, 191, -1, -1, -1, -1, -1, 197, 198, + 199, 200, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + -1, 79, 80, 81, 82, 83, 84, -1, -1, 87, + 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 107, + 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 106, 107, 108, 109, -1, 111, -1, - -1, -1, -1, -1, -1, -1, -1, 120, 3, 4, - 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 154, 37, 156, 39, -1, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 106, 107, 108, 109, -1, 111, -1, -1, -1, - -1, -1, -1, -1, -1, 120, 5, 6, 7, 8, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 0, -1, -1, 3, 4, 5, 6, + 7, 8, -1, 191, -1, -1, -1, -1, -1, 197, + 198, 199, 200, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, + 37, -1, 39, -1, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, + 107, 108, 109, -1, 111, -1, -1, -1, -1, -1, + -1, -1, -1, 120, 3, 4, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, -1, -1, -1, 154, - -1, 156, -1, -1, -1, 44, 45, 46, 47, 48, + 29, 30, 31, 32, 33, 34, 35, 154, 37, 156, + 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, - 79, -1, -1, -1, -1, 84, -1, -1, -1, -1, + 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 107, 108, - 109, -1, -1, -1, -1, -1, -1, -1, -1, 5, - 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, - -1, -1, -1, -1, -1, 154, -1, 156, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, -1, 79, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, - -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, + 109, -1, 111, -1, -1, -1, -1, -1, -1, -1, + -1, 120, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, -1, -1, -1, -1, -1, 154, -1, - 156, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 33, 34, -1, -1, -1, 154, -1, 156, -1, -1, + -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, + -1, 84, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, + -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, -1, -1, -1, -1, -1, + -1, 154, -1, 156, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 107, 108, 109, + -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, + 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, + -1, -1, -1, -1, 154, -1, 156, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, 156 + -1, -1, -1, -1, -1, -1, -1, 154, -1, 156 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { - 0, 112, 215, 217, 81, 0, 218, 117, 113, 216, - 219, 79, 3, 4, 5, 6, 7, 8, 20, 21, + 0, 112, 216, 218, 81, 0, 219, 117, 113, 217, + 220, 79, 3, 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 106, 107, 108, 109, 111, 120, - 154, 156, 220, 250, 251, 252, 253, 254, 259, 260, - 261, 262, 263, 266, 268, 269, 270, 271, 272, 273, - 274, 275, 301, 302, 116, 36, 37, 40, 79, 212, - 79, 106, 268, 274, 190, 301, 211, 212, 288, 191, - 195, 4, 36, 37, 38, 256, 257, 267, 195, 211, - 79, 36, 40, 268, 270, 192, 271, 79, 212, 270, - 276, 277, 271, 79, 264, 265, 9, 10, 11, 13, + 154, 156, 221, 251, 252, 253, 254, 255, 260, 261, + 262, 263, 264, 267, 269, 270, 271, 272, 273, 274, + 275, 276, 302, 303, 116, 36, 37, 40, 79, 213, + 79, 106, 269, 275, 191, 302, 212, 213, 289, 192, + 196, 4, 36, 37, 38, 257, 258, 268, 196, 212, + 79, 36, 40, 269, 271, 193, 272, 79, 213, 271, + 277, 278, 272, 79, 265, 266, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 78, 79, 80, 81, - 82, 83, 84, 87, 88, 190, 196, 197, 198, 199, - 211, 212, 213, 221, 222, 223, 225, 226, 227, 228, - 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, - 239, 240, 241, 242, 243, 244, 245, 246, 248, 250, - 251, 270, 281, 282, 283, 284, 285, 286, 289, 290, - 291, 292, 294, 295, 296, 300, 256, 255, 258, 270, - 257, 79, 190, 192, 210, 193, 232, 245, 249, 270, - 117, 276, 79, 278, 279, 213, 277, 211, 191, 195, - 211, 211, 282, 190, 190, 211, 211, 248, 190, 248, - 209, 190, 232, 232, 248, 213, 289, 87, 88, 192, - 194, 191, 191, 195, 77, 246, 190, 96, 97, 98, - 99, 100, 101, 102, 103, 104, 105, 210, 247, 232, - 200, 201, 202, 196, 197, 85, 86, 89, 90, 203, - 204, 91, 92, 205, 206, 207, 93, 95, 94, 208, - 195, 211, 213, 282, 79, 255, 258, 192, 210, 193, - 249, 246, 280, 193, 213, 192, 195, 211, 265, 78, - 281, 290, 297, 248, 211, 248, 209, 248, 261, 293, - 191, 213, 224, 248, 79, 227, 246, 246, 232, 232, - 232, 234, 234, 235, 235, 236, 236, 236, 236, 237, - 237, 238, 239, 240, 241, 242, 243, 248, 246, 192, - 193, 249, 280, 210, 193, 249, 279, 190, 293, 298, - 299, 191, 191, 79, 191, 193, 209, 249, 210, 193, - 280, 210, 193, 248, 211, 191, 283, 284, 286, 210, - 14, 285, 287, 288, 246, 193, 280, 210, 280, 191, - 248, 287, 12, 280, 190, 280, 211, 283, 284, 248, - 191, 283, 12 + 82, 83, 84, 87, 88, 191, 197, 198, 199, 200, + 212, 213, 214, 222, 223, 224, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 249, 251, + 252, 271, 282, 283, 284, 285, 286, 287, 290, 291, + 292, 293, 295, 296, 297, 301, 257, 256, 259, 271, + 258, 79, 191, 193, 211, 194, 233, 246, 250, 271, + 117, 277, 79, 279, 280, 214, 278, 212, 192, 196, + 212, 212, 283, 191, 191, 212, 212, 249, 191, 249, + 210, 191, 233, 233, 249, 214, 290, 87, 88, 193, + 195, 192, 192, 196, 77, 247, 191, 96, 97, 98, + 99, 100, 101, 102, 103, 104, 105, 211, 248, 233, + 201, 202, 203, 197, 198, 85, 86, 89, 90, 204, + 205, 91, 92, 206, 207, 208, 93, 95, 94, 209, + 196, 212, 214, 283, 79, 256, 259, 193, 211, 194, + 250, 247, 281, 194, 214, 193, 196, 212, 266, 78, + 282, 291, 298, 249, 212, 249, 210, 249, 262, 294, + 192, 214, 225, 249, 79, 228, 247, 247, 233, 233, + 233, 235, 235, 236, 236, 237, 237, 237, 237, 238, + 238, 239, 240, 241, 242, 243, 244, 249, 247, 193, + 194, 250, 281, 211, 194, 250, 280, 191, 294, 299, + 300, 192, 192, 79, 192, 194, 210, 250, 211, 194, + 281, 211, 194, 249, 212, 192, 284, 285, 287, 211, + 14, 286, 288, 289, 247, 194, 281, 211, 281, 192, + 249, 288, 12, 281, 191, 281, 212, 284, 285, 249, + 192, 284, 12 }; #define yyerrok (yyerrstatus = 0) @@ -2749,7 +2752,7 @@ YYLTYPE yylloc; } /* Line 1242 of yacc.c */ -#line 2753 "glsl_parser.cpp" +#line 2756 "glsl_parser.cpp" yylsp[0] = yylloc; goto yysetstate; @@ -2937,7 +2940,7 @@ yyreduce: case 2: /* Line 1455 of yacc.c */ -#line 208 "glsl_parser.ypp" +#line 210 "glsl_parser.ypp" { _mesa_glsl_initialize_types(state); ;} @@ -2946,7 +2949,7 @@ yyreduce: case 4: /* Line 1455 of yacc.c */ -#line 216 "glsl_parser.ypp" +#line 218 "glsl_parser.ypp" { state->language_version = 110; ;} @@ -2955,7 +2958,7 @@ yyreduce: case 5: /* Line 1455 of yacc.c */ -#line 220 "glsl_parser.ypp" +#line 222 "glsl_parser.ypp" { switch ((yyvsp[(2) - (3)].n)) { case 110: @@ -2975,7 +2978,7 @@ yyreduce: case 8: /* Line 1455 of yacc.c */ -#line 243 "glsl_parser.ypp" +#line 245 "glsl_parser.ypp" { if (!_mesa_glsl_process_extension((yyvsp[(2) - (5)].identifier), & (yylsp[(2) - (5)]), (yyvsp[(4) - (5)].identifier), & (yylsp[(4) - (5)]), state)) { YYERROR; @@ -2986,7 +2989,7 @@ yyreduce: case 9: /* Line 1455 of yacc.c */ -#line 252 "glsl_parser.ypp" +#line 254 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -2999,7 +3002,7 @@ yyreduce: case 10: /* Line 1455 of yacc.c */ -#line 260 "glsl_parser.ypp" +#line 262 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -3012,7 +3015,7 @@ yyreduce: case 12: /* Line 1455 of yacc.c */ -#line 275 "glsl_parser.ypp" +#line 277 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); @@ -3024,7 +3027,7 @@ yyreduce: case 13: /* Line 1455 of yacc.c */ -#line 282 "glsl_parser.ypp" +#line 284 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); @@ -3036,7 +3039,7 @@ yyreduce: case 14: /* Line 1455 of yacc.c */ -#line 289 "glsl_parser.ypp" +#line 291 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); @@ -3048,7 +3051,7 @@ yyreduce: case 15: /* Line 1455 of yacc.c */ -#line 296 "glsl_parser.ypp" +#line 298 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); @@ -3060,7 +3063,7 @@ yyreduce: case 16: /* Line 1455 of yacc.c */ -#line 303 "glsl_parser.ypp" +#line 305 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); @@ -3072,7 +3075,7 @@ yyreduce: case 17: /* Line 1455 of yacc.c */ -#line 310 "glsl_parser.ypp" +#line 312 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(2) - (3)].expression); ;} @@ -3081,7 +3084,7 @@ yyreduce: case 19: /* Line 1455 of yacc.c */ -#line 318 "glsl_parser.ypp" +#line 320 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_array_index, (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression), NULL); @@ -3092,7 +3095,7 @@ yyreduce: case 20: /* Line 1455 of yacc.c */ -#line 324 "glsl_parser.ypp" +#line 326 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} @@ -3101,7 +3104,7 @@ yyreduce: case 21: /* Line 1455 of yacc.c */ -#line 328 "glsl_parser.ypp" +#line 330 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), NULL, NULL); @@ -3113,7 +3116,7 @@ yyreduce: case 22: /* Line 1455 of yacc.c */ -#line 335 "glsl_parser.ypp" +#line 337 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_inc, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -3124,7 +3127,7 @@ yyreduce: case 23: /* Line 1455 of yacc.c */ -#line 341 "glsl_parser.ypp" +#line 343 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_dec, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -3135,7 +3138,7 @@ yyreduce: case 27: /* Line 1455 of yacc.c */ -#line 359 "glsl_parser.ypp" +#line 361 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -3146,7 +3149,7 @@ yyreduce: case 32: /* Line 1455 of yacc.c */ -#line 378 "glsl_parser.ypp" +#line 380 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (2)].expression); (yyval.expression)->set_location(yylloc); @@ -3157,7 +3160,7 @@ yyreduce: case 33: /* Line 1455 of yacc.c */ -#line 384 "glsl_parser.ypp" +#line 386 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (3)].expression); (yyval.expression)->set_location(yylloc); @@ -3168,7 +3171,7 @@ yyreduce: case 35: /* Line 1455 of yacc.c */ -#line 400 "glsl_parser.ypp" +#line 402 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_function_expression((yyvsp[(1) - (1)].type_specifier)); @@ -3179,7 +3182,7 @@ yyreduce: case 36: /* Line 1455 of yacc.c */ -#line 406 "glsl_parser.ypp" +#line 408 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -3191,7 +3194,7 @@ yyreduce: case 37: /* Line 1455 of yacc.c */ -#line 413 "glsl_parser.ypp" +#line 415 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -3203,7 +3206,7 @@ yyreduce: case 39: /* Line 1455 of yacc.c */ -#line 425 "glsl_parser.ypp" +#line 427 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_inc, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3214,7 +3217,7 @@ yyreduce: case 40: /* Line 1455 of yacc.c */ -#line 431 "glsl_parser.ypp" +#line 433 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_dec, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3225,7 +3228,7 @@ yyreduce: case 41: /* Line 1455 of yacc.c */ -#line 437 "glsl_parser.ypp" +#line 439 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(1) - (2)].n), (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3236,35 +3239,35 @@ yyreduce: case 42: /* Line 1455 of yacc.c */ -#line 446 "glsl_parser.ypp" +#line 448 "glsl_parser.ypp" { (yyval.n) = ast_plus; ;} break; case 43: /* Line 1455 of yacc.c */ -#line 447 "glsl_parser.ypp" +#line 449 "glsl_parser.ypp" { (yyval.n) = ast_neg; ;} break; case 44: /* Line 1455 of yacc.c */ -#line 448 "glsl_parser.ypp" +#line 450 "glsl_parser.ypp" { (yyval.n) = ast_logic_not; ;} break; case 45: /* Line 1455 of yacc.c */ -#line 449 "glsl_parser.ypp" +#line 451 "glsl_parser.ypp" { (yyval.n) = ast_bit_not; ;} break; case 47: /* Line 1455 of yacc.c */ -#line 455 "glsl_parser.ypp" +#line 457 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mul, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3275,7 +3278,7 @@ yyreduce: case 48: /* Line 1455 of yacc.c */ -#line 461 "glsl_parser.ypp" +#line 463 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_div, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3286,7 +3289,7 @@ yyreduce: case 49: /* Line 1455 of yacc.c */ -#line 467 "glsl_parser.ypp" +#line 469 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mod, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3297,7 +3300,7 @@ yyreduce: case 51: /* Line 1455 of yacc.c */ -#line 477 "glsl_parser.ypp" +#line 479 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_add, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3308,7 +3311,7 @@ yyreduce: case 52: /* Line 1455 of yacc.c */ -#line 483 "glsl_parser.ypp" +#line 485 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_sub, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3319,7 +3322,7 @@ yyreduce: case 54: /* Line 1455 of yacc.c */ -#line 493 "glsl_parser.ypp" +#line 495 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3330,7 +3333,7 @@ yyreduce: case 55: /* Line 1455 of yacc.c */ -#line 499 "glsl_parser.ypp" +#line 501 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_rshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3341,7 +3344,7 @@ yyreduce: case 57: /* Line 1455 of yacc.c */ -#line 509 "glsl_parser.ypp" +#line 511 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_less, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3352,7 +3355,7 @@ yyreduce: case 58: /* Line 1455 of yacc.c */ -#line 515 "glsl_parser.ypp" +#line 517 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_greater, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3363,7 +3366,7 @@ yyreduce: case 59: /* Line 1455 of yacc.c */ -#line 521 "glsl_parser.ypp" +#line 523 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3374,7 +3377,7 @@ yyreduce: case 60: /* Line 1455 of yacc.c */ -#line 527 "glsl_parser.ypp" +#line 529 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_gequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3385,7 +3388,7 @@ yyreduce: case 62: /* Line 1455 of yacc.c */ -#line 537 "glsl_parser.ypp" +#line 539 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_equal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3396,7 +3399,7 @@ yyreduce: case 63: /* Line 1455 of yacc.c */ -#line 543 "glsl_parser.ypp" +#line 545 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_nequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3407,7 +3410,7 @@ yyreduce: case 65: /* Line 1455 of yacc.c */ -#line 553 "glsl_parser.ypp" +#line 555 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3418,7 +3421,7 @@ yyreduce: case 67: /* Line 1455 of yacc.c */ -#line 563 "glsl_parser.ypp" +#line 565 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3429,7 +3432,7 @@ yyreduce: case 69: /* Line 1455 of yacc.c */ -#line 573 "glsl_parser.ypp" +#line 575 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3440,7 +3443,7 @@ yyreduce: case 71: /* Line 1455 of yacc.c */ -#line 583 "glsl_parser.ypp" +#line 585 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3451,7 +3454,7 @@ yyreduce: case 73: /* Line 1455 of yacc.c */ -#line 593 "glsl_parser.ypp" +#line 595 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3462,7 +3465,7 @@ yyreduce: case 75: /* Line 1455 of yacc.c */ -#line 603 "glsl_parser.ypp" +#line 605 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3473,7 +3476,7 @@ yyreduce: case 77: /* Line 1455 of yacc.c */ -#line 613 "glsl_parser.ypp" +#line 615 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_conditional, (yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression)); @@ -3484,7 +3487,7 @@ yyreduce: case 79: /* Line 1455 of yacc.c */ -#line 623 "glsl_parser.ypp" +#line 625 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(2) - (3)].n), (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -3495,84 +3498,84 @@ yyreduce: case 80: /* Line 1455 of yacc.c */ -#line 631 "glsl_parser.ypp" +#line 633 "glsl_parser.ypp" { (yyval.n) = ast_assign; ;} break; case 81: /* Line 1455 of yacc.c */ -#line 632 "glsl_parser.ypp" +#line 634 "glsl_parser.ypp" { (yyval.n) = ast_mul_assign; ;} break; case 82: /* Line 1455 of yacc.c */ -#line 633 "glsl_parser.ypp" +#line 635 "glsl_parser.ypp" { (yyval.n) = ast_div_assign; ;} break; case 83: /* Line 1455 of yacc.c */ -#line 634 "glsl_parser.ypp" +#line 636 "glsl_parser.ypp" { (yyval.n) = ast_mod_assign; ;} break; case 84: /* Line 1455 of yacc.c */ -#line 635 "glsl_parser.ypp" +#line 637 "glsl_parser.ypp" { (yyval.n) = ast_add_assign; ;} break; case 85: /* Line 1455 of yacc.c */ -#line 636 "glsl_parser.ypp" +#line 638 "glsl_parser.ypp" { (yyval.n) = ast_sub_assign; ;} break; case 86: /* Line 1455 of yacc.c */ -#line 637 "glsl_parser.ypp" +#line 639 "glsl_parser.ypp" { (yyval.n) = ast_ls_assign; ;} break; case 87: /* Line 1455 of yacc.c */ -#line 638 "glsl_parser.ypp" +#line 640 "glsl_parser.ypp" { (yyval.n) = ast_rs_assign; ;} break; case 88: /* Line 1455 of yacc.c */ -#line 639 "glsl_parser.ypp" +#line 641 "glsl_parser.ypp" { (yyval.n) = ast_and_assign; ;} break; case 89: /* Line 1455 of yacc.c */ -#line 640 "glsl_parser.ypp" +#line 642 "glsl_parser.ypp" { (yyval.n) = ast_xor_assign; ;} break; case 90: /* Line 1455 of yacc.c */ -#line 641 "glsl_parser.ypp" +#line 643 "glsl_parser.ypp" { (yyval.n) = ast_or_assign; ;} break; case 91: /* Line 1455 of yacc.c */ -#line 646 "glsl_parser.ypp" +#line 648 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} @@ -3581,7 +3584,7 @@ yyreduce: case 92: /* Line 1455 of yacc.c */ -#line 650 "glsl_parser.ypp" +#line 652 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (3)].expression)->oper != ast_sequence) { @@ -3599,7 +3602,7 @@ yyreduce: case 94: /* Line 1455 of yacc.c */ -#line 670 "glsl_parser.ypp" +#line 672 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].function); ;} @@ -3608,7 +3611,7 @@ yyreduce: case 95: /* Line 1455 of yacc.c */ -#line 674 "glsl_parser.ypp" +#line 676 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].declarator_list); ;} @@ -3617,7 +3620,7 @@ yyreduce: case 96: /* Line 1455 of yacc.c */ -#line 678 "glsl_parser.ypp" +#line 680 "glsl_parser.ypp" { if (((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_float) && ((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_int)) { @@ -3633,7 +3636,7 @@ yyreduce: case 100: /* Line 1455 of yacc.c */ -#line 701 "glsl_parser.ypp" +#line 703 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (2)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(2) - (2)].parameter_declarator)->link); @@ -3643,7 +3646,7 @@ yyreduce: case 101: /* Line 1455 of yacc.c */ -#line 706 "glsl_parser.ypp" +#line 708 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (3)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(3) - (3)].parameter_declarator)->link); @@ -3653,7 +3656,7 @@ yyreduce: case 102: /* Line 1455 of yacc.c */ -#line 714 "glsl_parser.ypp" +#line 716 "glsl_parser.ypp" { void *ctx = state; (yyval.function) = new(ctx) ast_function(); @@ -3666,7 +3669,7 @@ yyreduce: case 103: /* Line 1455 of yacc.c */ -#line 725 "glsl_parser.ypp" +#line 727 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3681,7 +3684,7 @@ yyreduce: case 104: /* Line 1455 of yacc.c */ -#line 735 "glsl_parser.ypp" +#line 737 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3698,7 +3701,7 @@ yyreduce: case 105: /* Line 1455 of yacc.c */ -#line 750 "glsl_parser.ypp" +#line 752 "glsl_parser.ypp" { (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; @@ -3710,7 +3713,7 @@ yyreduce: case 106: /* Line 1455 of yacc.c */ -#line 757 "glsl_parser.ypp" +#line 759 "glsl_parser.ypp" { (yyval.parameter_declarator) = (yyvsp[(2) - (2)].parameter_declarator); (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier).q; @@ -3720,7 +3723,7 @@ yyreduce: case 107: /* Line 1455 of yacc.c */ -#line 762 "glsl_parser.ypp" +#line 764 "glsl_parser.ypp" { void *ctx = state; (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; @@ -3736,7 +3739,7 @@ yyreduce: case 108: /* Line 1455 of yacc.c */ -#line 773 "glsl_parser.ypp" +#line 775 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3750,35 +3753,35 @@ yyreduce: case 109: /* Line 1455 of yacc.c */ -#line 784 "glsl_parser.ypp" +#line 786 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; ;} break; case 110: /* Line 1455 of yacc.c */ -#line 785 "glsl_parser.ypp" +#line 787 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} break; case 111: /* Line 1455 of yacc.c */ -#line 786 "glsl_parser.ypp" +#line 788 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} break; case 112: /* Line 1455 of yacc.c */ -#line 787 "glsl_parser.ypp" +#line 789 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; (yyval.type_qualifier).q.out = 1; ;} break; case 115: /* Line 1455 of yacc.c */ -#line 797 "glsl_parser.ypp" +#line 799 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (3)].identifier), false, NULL, NULL); @@ -3792,7 +3795,7 @@ yyreduce: case 116: /* Line 1455 of yacc.c */ -#line 806 "glsl_parser.ypp" +#line 808 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), true, NULL, NULL); @@ -3806,7 +3809,7 @@ yyreduce: case 117: /* Line 1455 of yacc.c */ -#line 815 "glsl_parser.ypp" +#line 817 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (6)].identifier), true, (yyvsp[(5) - (6)].expression), NULL); @@ -3820,7 +3823,7 @@ yyreduce: case 118: /* Line 1455 of yacc.c */ -#line 824 "glsl_parser.ypp" +#line 826 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (7)].identifier), true, NULL, (yyvsp[(7) - (7)].expression)); @@ -3834,7 +3837,7 @@ yyreduce: case 119: /* Line 1455 of yacc.c */ -#line 833 "glsl_parser.ypp" +#line 835 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (8)].identifier), true, (yyvsp[(5) - (8)].expression), (yyvsp[(8) - (8)].expression)); @@ -3848,7 +3851,7 @@ yyreduce: case 120: /* Line 1455 of yacc.c */ -#line 842 "glsl_parser.ypp" +#line 844 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), false, NULL, (yyvsp[(5) - (5)].expression)); @@ -3862,7 +3865,7 @@ yyreduce: case 121: /* Line 1455 of yacc.c */ -#line 855 "glsl_parser.ypp" +#line 857 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (1)].fully_specified_type)->specifier->type_specifier != ast_struct) { @@ -3878,7 +3881,7 @@ yyreduce: case 122: /* Line 1455 of yacc.c */ -#line 866 "glsl_parser.ypp" +#line 868 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3892,7 +3895,7 @@ yyreduce: case 123: /* Line 1455 of yacc.c */ -#line 875 "glsl_parser.ypp" +#line 877 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), true, NULL, NULL); @@ -3906,7 +3909,7 @@ yyreduce: case 124: /* Line 1455 of yacc.c */ -#line 884 "glsl_parser.ypp" +#line 886 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (5)].identifier), true, (yyvsp[(4) - (5)].expression), NULL); @@ -3920,7 +3923,7 @@ yyreduce: case 125: /* Line 1455 of yacc.c */ -#line 893 "glsl_parser.ypp" +#line 895 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (6)].identifier), true, NULL, (yyvsp[(6) - (6)].expression)); @@ -3934,7 +3937,7 @@ yyreduce: case 126: /* Line 1455 of yacc.c */ -#line 902 "glsl_parser.ypp" +#line 904 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (7)].identifier), true, (yyvsp[(4) - (7)].expression), (yyvsp[(7) - (7)].expression)); @@ -3948,7 +3951,7 @@ yyreduce: case 127: /* Line 1455 of yacc.c */ -#line 911 "glsl_parser.ypp" +#line 913 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -3962,7 +3965,7 @@ yyreduce: case 128: /* Line 1455 of yacc.c */ -#line 920 "glsl_parser.ypp" +#line 922 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3978,7 +3981,7 @@ yyreduce: case 129: /* Line 1455 of yacc.c */ -#line 934 "glsl_parser.ypp" +#line 936 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -3990,7 +3993,7 @@ yyreduce: case 130: /* Line 1455 of yacc.c */ -#line 941 "glsl_parser.ypp" +#line 943 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -4003,14 +4006,14 @@ yyreduce: case 131: /* Line 1455 of yacc.c */ -#line 951 "glsl_parser.ypp" +#line 953 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; ;} break; case 133: /* Line 1455 of yacc.c */ -#line 957 "glsl_parser.ypp" +#line 959 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(3) - (4)].type_qualifier); ;} @@ -4019,7 +4022,7 @@ yyreduce: case 135: /* Line 1455 of yacc.c */ -#line 965 "glsl_parser.ypp" +#line 967 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (3)].type_qualifier).i | (yyvsp[(3) - (3)].type_qualifier).i; ;} @@ -4028,7 +4031,7 @@ yyreduce: case 136: /* Line 1455 of yacc.c */ -#line 972 "glsl_parser.ypp" +#line 974 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; @@ -4064,35 +4067,35 @@ yyreduce: case 137: /* Line 1455 of yacc.c */ -#line 1005 "glsl_parser.ypp" +#line 1007 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.smooth = 1; ;} break; case 138: /* Line 1455 of yacc.c */ -#line 1006 "glsl_parser.ypp" +#line 1008 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.flat = 1; ;} break; case 139: /* Line 1455 of yacc.c */ -#line 1007 "glsl_parser.ypp" +#line 1009 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.noperspective = 1; ;} break; case 140: /* Line 1455 of yacc.c */ -#line 1011 "glsl_parser.ypp" +#line 1013 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} break; case 142: /* Line 1455 of yacc.c */ -#line 1017 "glsl_parser.ypp" +#line 1019 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i | (yyvsp[(2) - (2)].type_qualifier).i; ;} @@ -4101,7 +4104,7 @@ yyreduce: case 143: /* Line 1455 of yacc.c */ -#line 1021 "glsl_parser.ypp" +#line 1023 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(2) - (2)].type_qualifier); (yyval.type_qualifier).q.invariant = 1; @@ -4111,70 +4114,70 @@ yyreduce: case 144: /* Line 1455 of yacc.c */ -#line 1028 "glsl_parser.ypp" +#line 1030 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} break; case 145: /* Line 1455 of yacc.c */ -#line 1029 "glsl_parser.ypp" +#line 1031 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.attribute = 1; ;} break; case 146: /* Line 1455 of yacc.c */ -#line 1030 "glsl_parser.ypp" +#line 1032 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i; (yyval.type_qualifier).q.varying = 1; ;} break; case 147: /* Line 1455 of yacc.c */ -#line 1031 "glsl_parser.ypp" +#line 1033 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.varying = 1; ;} break; case 148: /* Line 1455 of yacc.c */ -#line 1032 "glsl_parser.ypp" +#line 1034 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} break; case 149: /* Line 1455 of yacc.c */ -#line 1033 "glsl_parser.ypp" +#line 1035 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} break; case 150: /* Line 1455 of yacc.c */ -#line 1034 "glsl_parser.ypp" +#line 1036 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.in = 1; ;} break; case 151: /* Line 1455 of yacc.c */ -#line 1035 "glsl_parser.ypp" +#line 1037 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.out = 1; ;} break; case 152: /* Line 1455 of yacc.c */ -#line 1036 "glsl_parser.ypp" +#line 1038 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.uniform = 1; ;} break; case 154: /* Line 1455 of yacc.c */ -#line 1042 "glsl_parser.ypp" +#line 1044 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(2) - (2)].type_specifier); (yyval.type_specifier)->precision = (yyvsp[(1) - (2)].n); @@ -4184,7 +4187,7 @@ yyreduce: case 156: /* Line 1455 of yacc.c */ -#line 1051 "glsl_parser.ypp" +#line 1053 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (3)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -4195,7 +4198,7 @@ yyreduce: case 157: /* Line 1455 of yacc.c */ -#line 1057 "glsl_parser.ypp" +#line 1059 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (4)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -4206,7 +4209,7 @@ yyreduce: case 158: /* Line 1455 of yacc.c */ -#line 1066 "glsl_parser.ypp" +#line 1068 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].n)); @@ -4217,7 +4220,7 @@ yyreduce: case 159: /* Line 1455 of yacc.c */ -#line 1072 "glsl_parser.ypp" +#line 1074 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].struct_specifier)); @@ -4228,7 +4231,7 @@ yyreduce: case 160: /* Line 1455 of yacc.c */ -#line 1078 "glsl_parser.ypp" +#line 1080 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].identifier)); @@ -4239,385 +4242,385 @@ yyreduce: case 161: /* Line 1455 of yacc.c */ -#line 1086 "glsl_parser.ypp" +#line 1088 "glsl_parser.ypp" { (yyval.n) = ast_void; ;} break; case 162: /* Line 1455 of yacc.c */ -#line 1087 "glsl_parser.ypp" +#line 1089 "glsl_parser.ypp" { (yyval.n) = ast_float; ;} break; case 163: /* Line 1455 of yacc.c */ -#line 1088 "glsl_parser.ypp" +#line 1090 "glsl_parser.ypp" { (yyval.n) = ast_int; ;} break; case 164: /* Line 1455 of yacc.c */ -#line 1089 "glsl_parser.ypp" +#line 1091 "glsl_parser.ypp" { (yyval.n) = ast_uint; ;} break; case 165: /* Line 1455 of yacc.c */ -#line 1090 "glsl_parser.ypp" +#line 1092 "glsl_parser.ypp" { (yyval.n) = ast_bool; ;} break; case 166: /* Line 1455 of yacc.c */ -#line 1091 "glsl_parser.ypp" +#line 1093 "glsl_parser.ypp" { (yyval.n) = ast_vec2; ;} break; case 167: /* Line 1455 of yacc.c */ -#line 1092 "glsl_parser.ypp" +#line 1094 "glsl_parser.ypp" { (yyval.n) = ast_vec3; ;} break; case 168: /* Line 1455 of yacc.c */ -#line 1093 "glsl_parser.ypp" +#line 1095 "glsl_parser.ypp" { (yyval.n) = ast_vec4; ;} break; case 169: /* Line 1455 of yacc.c */ -#line 1094 "glsl_parser.ypp" +#line 1096 "glsl_parser.ypp" { (yyval.n) = ast_bvec2; ;} break; case 170: /* Line 1455 of yacc.c */ -#line 1095 "glsl_parser.ypp" +#line 1097 "glsl_parser.ypp" { (yyval.n) = ast_bvec3; ;} break; case 171: /* Line 1455 of yacc.c */ -#line 1096 "glsl_parser.ypp" +#line 1098 "glsl_parser.ypp" { (yyval.n) = ast_bvec4; ;} break; case 172: /* Line 1455 of yacc.c */ -#line 1097 "glsl_parser.ypp" +#line 1099 "glsl_parser.ypp" { (yyval.n) = ast_ivec2; ;} break; case 173: /* Line 1455 of yacc.c */ -#line 1098 "glsl_parser.ypp" +#line 1100 "glsl_parser.ypp" { (yyval.n) = ast_ivec3; ;} break; case 174: /* Line 1455 of yacc.c */ -#line 1099 "glsl_parser.ypp" +#line 1101 "glsl_parser.ypp" { (yyval.n) = ast_ivec4; ;} break; case 175: /* Line 1455 of yacc.c */ -#line 1100 "glsl_parser.ypp" +#line 1102 "glsl_parser.ypp" { (yyval.n) = ast_uvec2; ;} break; case 176: /* Line 1455 of yacc.c */ -#line 1101 "glsl_parser.ypp" +#line 1103 "glsl_parser.ypp" { (yyval.n) = ast_uvec3; ;} break; case 177: /* Line 1455 of yacc.c */ -#line 1102 "glsl_parser.ypp" +#line 1104 "glsl_parser.ypp" { (yyval.n) = ast_uvec4; ;} break; case 178: /* Line 1455 of yacc.c */ -#line 1103 "glsl_parser.ypp" +#line 1105 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; case 179: /* Line 1455 of yacc.c */ -#line 1104 "glsl_parser.ypp" +#line 1106 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; case 180: /* Line 1455 of yacc.c */ -#line 1105 "glsl_parser.ypp" +#line 1107 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; case 181: /* Line 1455 of yacc.c */ -#line 1106 "glsl_parser.ypp" +#line 1108 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; case 182: /* Line 1455 of yacc.c */ -#line 1107 "glsl_parser.ypp" +#line 1109 "glsl_parser.ypp" { (yyval.n) = ast_mat2x3; ;} break; case 183: /* Line 1455 of yacc.c */ -#line 1108 "glsl_parser.ypp" +#line 1110 "glsl_parser.ypp" { (yyval.n) = ast_mat2x4; ;} break; case 184: /* Line 1455 of yacc.c */ -#line 1109 "glsl_parser.ypp" +#line 1111 "glsl_parser.ypp" { (yyval.n) = ast_mat3x2; ;} break; case 185: /* Line 1455 of yacc.c */ -#line 1110 "glsl_parser.ypp" +#line 1112 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; case 186: /* Line 1455 of yacc.c */ -#line 1111 "glsl_parser.ypp" +#line 1113 "glsl_parser.ypp" { (yyval.n) = ast_mat3x4; ;} break; case 187: /* Line 1455 of yacc.c */ -#line 1112 "glsl_parser.ypp" +#line 1114 "glsl_parser.ypp" { (yyval.n) = ast_mat4x2; ;} break; case 188: /* Line 1455 of yacc.c */ -#line 1113 "glsl_parser.ypp" +#line 1115 "glsl_parser.ypp" { (yyval.n) = ast_mat4x3; ;} break; case 189: /* Line 1455 of yacc.c */ -#line 1114 "glsl_parser.ypp" +#line 1116 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; case 190: /* Line 1455 of yacc.c */ -#line 1115 "glsl_parser.ypp" +#line 1117 "glsl_parser.ypp" { (yyval.n) = ast_sampler1d; ;} break; case 191: /* Line 1455 of yacc.c */ -#line 1116 "glsl_parser.ypp" +#line 1118 "glsl_parser.ypp" { (yyval.n) = ast_sampler2d; ;} break; case 192: /* Line 1455 of yacc.c */ -#line 1117 "glsl_parser.ypp" +#line 1119 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drect; ;} break; case 193: /* Line 1455 of yacc.c */ -#line 1118 "glsl_parser.ypp" +#line 1120 "glsl_parser.ypp" { (yyval.n) = ast_sampler3d; ;} break; case 194: /* Line 1455 of yacc.c */ -#line 1119 "glsl_parser.ypp" +#line 1121 "glsl_parser.ypp" { (yyval.n) = ast_samplercube; ;} break; case 195: /* Line 1455 of yacc.c */ -#line 1120 "glsl_parser.ypp" +#line 1122 "glsl_parser.ypp" { (yyval.n) = ast_sampler1dshadow; ;} break; case 196: /* Line 1455 of yacc.c */ -#line 1121 "glsl_parser.ypp" +#line 1123 "glsl_parser.ypp" { (yyval.n) = ast_sampler2dshadow; ;} break; case 197: /* Line 1455 of yacc.c */ -#line 1122 "glsl_parser.ypp" +#line 1124 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drectshadow; ;} break; case 198: /* Line 1455 of yacc.c */ -#line 1123 "glsl_parser.ypp" +#line 1125 "glsl_parser.ypp" { (yyval.n) = ast_samplercubeshadow; ;} break; case 199: /* Line 1455 of yacc.c */ -#line 1124 "glsl_parser.ypp" +#line 1126 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darray; ;} break; case 200: /* Line 1455 of yacc.c */ -#line 1125 "glsl_parser.ypp" +#line 1127 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darray; ;} break; case 201: /* Line 1455 of yacc.c */ -#line 1126 "glsl_parser.ypp" +#line 1128 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darrayshadow; ;} break; case 202: /* Line 1455 of yacc.c */ -#line 1127 "glsl_parser.ypp" +#line 1129 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darrayshadow; ;} break; case 203: /* Line 1455 of yacc.c */ -#line 1128 "glsl_parser.ypp" +#line 1130 "glsl_parser.ypp" { (yyval.n) = ast_isampler1d; ;} break; case 204: /* Line 1455 of yacc.c */ -#line 1129 "glsl_parser.ypp" +#line 1131 "glsl_parser.ypp" { (yyval.n) = ast_isampler2d; ;} break; case 205: /* Line 1455 of yacc.c */ -#line 1130 "glsl_parser.ypp" +#line 1132 "glsl_parser.ypp" { (yyval.n) = ast_isampler3d; ;} break; case 206: /* Line 1455 of yacc.c */ -#line 1131 "glsl_parser.ypp" +#line 1133 "glsl_parser.ypp" { (yyval.n) = ast_isamplercube; ;} break; case 207: /* Line 1455 of yacc.c */ -#line 1132 "glsl_parser.ypp" +#line 1134 "glsl_parser.ypp" { (yyval.n) = ast_isampler1darray; ;} break; case 208: /* Line 1455 of yacc.c */ -#line 1133 "glsl_parser.ypp" +#line 1135 "glsl_parser.ypp" { (yyval.n) = ast_isampler2darray; ;} break; case 209: /* Line 1455 of yacc.c */ -#line 1134 "glsl_parser.ypp" +#line 1136 "glsl_parser.ypp" { (yyval.n) = ast_usampler1d; ;} break; case 210: /* Line 1455 of yacc.c */ -#line 1135 "glsl_parser.ypp" +#line 1137 "glsl_parser.ypp" { (yyval.n) = ast_usampler2d; ;} break; case 211: /* Line 1455 of yacc.c */ -#line 1136 "glsl_parser.ypp" +#line 1138 "glsl_parser.ypp" { (yyval.n) = ast_usampler3d; ;} break; case 212: /* Line 1455 of yacc.c */ -#line 1137 "glsl_parser.ypp" +#line 1139 "glsl_parser.ypp" { (yyval.n) = ast_usamplercube; ;} break; case 213: /* Line 1455 of yacc.c */ -#line 1138 "glsl_parser.ypp" +#line 1140 "glsl_parser.ypp" { (yyval.n) = ast_usampler1darray; ;} break; case 214: /* Line 1455 of yacc.c */ -#line 1139 "glsl_parser.ypp" +#line 1141 "glsl_parser.ypp" { (yyval.n) = ast_usampler2darray; ;} break; case 215: /* Line 1455 of yacc.c */ -#line 1143 "glsl_parser.ypp" +#line 1145 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4634,7 +4637,7 @@ yyreduce: case 216: /* Line 1455 of yacc.c */ -#line 1154 "glsl_parser.ypp" +#line 1156 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4651,7 +4654,7 @@ yyreduce: case 217: /* Line 1455 of yacc.c */ -#line 1165 "glsl_parser.ypp" +#line 1167 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4668,7 +4671,7 @@ yyreduce: case 218: /* Line 1455 of yacc.c */ -#line 1180 "glsl_parser.ypp" +#line 1182 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node)); @@ -4679,7 +4682,7 @@ yyreduce: case 219: /* Line 1455 of yacc.c */ -#line 1186 "glsl_parser.ypp" +#line 1188 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node)); @@ -4690,7 +4693,7 @@ yyreduce: case 220: /* Line 1455 of yacc.c */ -#line 1195 "glsl_parser.ypp" +#line 1197 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].declarator_list); (yyvsp[(1) - (1)].declarator_list)->link.self_link(); @@ -4700,7 +4703,7 @@ yyreduce: case 221: /* Line 1455 of yacc.c */ -#line 1200 "glsl_parser.ypp" +#line 1202 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (2)].node); (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); @@ -4710,7 +4713,7 @@ yyreduce: case 222: /* Line 1455 of yacc.c */ -#line 1208 "glsl_parser.ypp" +#line 1210 "glsl_parser.ypp" { void *ctx = state; ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); @@ -4727,7 +4730,7 @@ yyreduce: case 223: /* Line 1455 of yacc.c */ -#line 1223 "glsl_parser.ypp" +#line 1225 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (1)].declaration); (yyvsp[(1) - (1)].declaration)->link.self_link(); @@ -4737,7 +4740,7 @@ yyreduce: case 224: /* Line 1455 of yacc.c */ -#line 1228 "glsl_parser.ypp" +#line 1230 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (3)].declaration); (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link); @@ -4747,7 +4750,7 @@ yyreduce: case 225: /* Line 1455 of yacc.c */ -#line 1236 "glsl_parser.ypp" +#line 1238 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL); @@ -4758,7 +4761,7 @@ yyreduce: case 226: /* Line 1455 of yacc.c */ -#line 1242 "glsl_parser.ypp" +#line 1244 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL); @@ -4769,28 +4772,28 @@ yyreduce: case 231: /* Line 1455 of yacc.c */ -#line 1265 "glsl_parser.ypp" +#line 1267 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 237: /* Line 1455 of yacc.c */ -#line 1277 "glsl_parser.ypp" +#line 1279 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; case 238: /* Line 1455 of yacc.c */ -#line 1278 "glsl_parser.ypp" +#line 1280 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; case 241: /* Line 1455 of yacc.c */ -#line 1285 "glsl_parser.ypp" +#line 1287 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL); @@ -4801,7 +4804,7 @@ yyreduce: case 242: /* Line 1455 of yacc.c */ -#line 1291 "glsl_parser.ypp" +#line 1293 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(2) - (3)].node)); @@ -4812,14 +4815,14 @@ yyreduce: case 243: /* Line 1455 of yacc.c */ -#line 1299 "glsl_parser.ypp" +#line 1301 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 245: /* Line 1455 of yacc.c */ -#line 1305 "glsl_parser.ypp" +#line 1307 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL); @@ -4830,7 +4833,7 @@ yyreduce: case 246: /* Line 1455 of yacc.c */ -#line 1311 "glsl_parser.ypp" +#line 1313 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node)); @@ -4841,7 +4844,7 @@ yyreduce: case 247: /* Line 1455 of yacc.c */ -#line 1320 "glsl_parser.ypp" +#line 1322 "glsl_parser.ypp" { if ((yyvsp[(1) - (1)].node) == NULL) { _mesa_glsl_error(& (yylsp[(1) - (1)]), state, " statement\n"); @@ -4856,7 +4859,7 @@ yyreduce: case 248: /* Line 1455 of yacc.c */ -#line 1330 "glsl_parser.ypp" +#line 1332 "glsl_parser.ypp" { if ((yyvsp[(2) - (2)].node) == NULL) { _mesa_glsl_error(& (yylsp[(2) - (2)]), state, " statement\n"); @@ -4870,7 +4873,7 @@ yyreduce: case 249: /* Line 1455 of yacc.c */ -#line 1342 "glsl_parser.ypp" +#line 1344 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement(NULL); @@ -4881,7 +4884,7 @@ yyreduce: case 250: /* Line 1455 of yacc.c */ -#line 1348 "glsl_parser.ypp" +#line 1350 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression)); @@ -4892,7 +4895,7 @@ yyreduce: case 251: /* Line 1455 of yacc.c */ -#line 1357 "glsl_parser.ypp" +#line 1359 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4903,7 +4906,7 @@ yyreduce: case 252: /* Line 1455 of yacc.c */ -#line 1366 "glsl_parser.ypp" +#line 1368 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4914,7 +4917,7 @@ yyreduce: case 253: /* Line 1455 of yacc.c */ -#line 1372 "glsl_parser.ypp" +#line 1374 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4925,7 +4928,7 @@ yyreduce: case 254: /* Line 1455 of yacc.c */ -#line 1378 "glsl_parser.ypp" +#line 1380 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4936,7 +4939,7 @@ yyreduce: case 255: /* Line 1455 of yacc.c */ -#line 1387 "glsl_parser.ypp" +#line 1389 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].expression); ;} @@ -4945,7 +4948,7 @@ yyreduce: case 256: /* Line 1455 of yacc.c */ -#line 1391 "glsl_parser.ypp" +#line 1393 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -4961,7 +4964,7 @@ yyreduce: case 260: /* Line 1455 of yacc.c */ -#line 1414 "glsl_parser.ypp" +#line 1416 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, @@ -4973,7 +4976,7 @@ yyreduce: case 261: /* Line 1455 of yacc.c */ -#line 1421 "glsl_parser.ypp" +#line 1423 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, @@ -4985,7 +4988,7 @@ yyreduce: case 262: /* Line 1455 of yacc.c */ -#line 1428 "glsl_parser.ypp" +#line 1430 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, @@ -4997,7 +5000,7 @@ yyreduce: case 266: /* Line 1455 of yacc.c */ -#line 1444 "glsl_parser.ypp" +#line 1446 "glsl_parser.ypp" { (yyval.node) = NULL; ;} @@ -5006,7 +5009,7 @@ yyreduce: case 267: /* Line 1455 of yacc.c */ -#line 1451 "glsl_parser.ypp" +#line 1453 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node); (yyval.for_rest_statement).rest = NULL; @@ -5016,7 +5019,7 @@ yyreduce: case 268: /* Line 1455 of yacc.c */ -#line 1456 "glsl_parser.ypp" +#line 1458 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node); (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression); @@ -5026,7 +5029,7 @@ yyreduce: case 269: /* Line 1455 of yacc.c */ -#line 1465 "glsl_parser.ypp" +#line 1467 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); @@ -5037,7 +5040,7 @@ yyreduce: case 270: /* Line 1455 of yacc.c */ -#line 1471 "glsl_parser.ypp" +#line 1473 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); @@ -5048,7 +5051,7 @@ yyreduce: case 271: /* Line 1455 of yacc.c */ -#line 1477 "glsl_parser.ypp" +#line 1479 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); @@ -5059,7 +5062,7 @@ yyreduce: case 272: /* Line 1455 of yacc.c */ -#line 1483 "glsl_parser.ypp" +#line 1485 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression)); @@ -5070,7 +5073,7 @@ yyreduce: case 273: /* Line 1455 of yacc.c */ -#line 1489 "glsl_parser.ypp" +#line 1491 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); @@ -5081,21 +5084,21 @@ yyreduce: case 274: /* Line 1455 of yacc.c */ -#line 1497 "glsl_parser.ypp" +#line 1499 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;} break; case 275: /* Line 1455 of yacc.c */ -#line 1498 "glsl_parser.ypp" +#line 1500 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); ;} break; case 276: /* Line 1455 of yacc.c */ -#line 1503 "glsl_parser.ypp" +#line 1505 "glsl_parser.ypp" { void *ctx = state; (yyval.function_definition) = new(ctx) ast_function_definition(); @@ -5108,7 +5111,7 @@ yyreduce: /* Line 1455 of yacc.c */ -#line 5112 "glsl_parser.cpp" +#line 5115 "glsl_parser.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h index 470c080f723..b9f3e3fe043 100644 --- a/src/glsl/glsl_parser.h +++ b/src/glsl/glsl_parser.h @@ -197,35 +197,36 @@ CAST = 413, NAMESPACE = 414, USING = 415, - COMMON = 416, - PARTITION = 417, - ACTIVE = 418, - SAMPLERBUFFER = 419, - FILTER = 420, - IMAGE1D = 421, - IMAGE2D = 422, - IMAGE3D = 423, - IMAGECUBE = 424, - IMAGE1DARRAY = 425, - IMAGE2DARRAY = 426, - IIMAGE1D = 427, - IIMAGE2D = 428, - IIMAGE3D = 429, - IIMAGECUBE = 430, - IIMAGE1DARRAY = 431, - IIMAGE2DARRAY = 432, - UIMAGE1D = 433, - UIMAGE2D = 434, - UIMAGE3D = 435, - UIMAGECUBE = 436, - UIMAGE1DARRAY = 437, - UIMAGE2DARRAY = 438, - IMAGE1DSHADOW = 439, - IMAGE2DSHADOW = 440, - IMAGEBUFFER = 441, - IIMAGEBUFFER = 442, - UIMAGEBUFFER = 443, - ROW_MAJOR = 444 + ERROR_TOK = 416, + COMMON = 417, + PARTITION = 418, + ACTIVE = 419, + SAMPLERBUFFER = 420, + FILTER = 421, + IMAGE1D = 422, + IMAGE2D = 423, + IMAGE3D = 424, + IMAGECUBE = 425, + IMAGE1DARRAY = 426, + IMAGE2DARRAY = 427, + IIMAGE1D = 428, + IIMAGE2D = 429, + IIMAGE3D = 430, + IIMAGECUBE = 431, + IIMAGE1DARRAY = 432, + IIMAGE2DARRAY = 433, + UIMAGE1D = 434, + UIMAGE2D = 435, + UIMAGE3D = 436, + UIMAGECUBE = 437, + UIMAGE1DARRAY = 438, + UIMAGE2DARRAY = 439, + IMAGE1DSHADOW = 440, + IMAGE2DSHADOW = 441, + IMAGEBUFFER = 442, + IIMAGEBUFFER = 443, + UIMAGEBUFFER = 444, + ROW_MAJOR = 445 }; #endif @@ -267,7 +268,7 @@ typedef union YYSTYPE /* Line 1676 of yacc.c */ -#line 271 "glsl_parser.h" +#line 272 "glsl_parser.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ -- cgit v1.2.3 From 2fb94b37d2ace1170018cc36f50cf6e71fc708c4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 11 Aug 2010 17:14:02 -0700 Subject: glsl2: Use bison command line option to set prefix Bison version 2.3 doesn't seem to support %name-prefix in the source. This should fix bugzilla #29207. --- src/glsl/Makefile | 2 +- src/glsl/glsl_parser.ypp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 85298d06a01..a0ab1d6d401 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -154,7 +154,7 @@ glsl_lexer.cpp: glsl_lexer.lpp flex --never-interactive --outfile="$@" $< glsl_parser.cpp: glsl_parser.ypp - bison -v -o "$@" --defines=glsl_parser.h $< + bison -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $< glcpp/glcpp-lex.c: glcpp/glcpp-lex.l flex --never-interactive --outfile="$@" $< diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 74971cfb9da..7c5dc017d89 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -48,7 +48,6 @@ %lex-param {void *scanner} %parse-param {struct _mesa_glsl_parse_state *state} -%name-prefix "_mesa_glsl_" %union { int n; -- cgit v1.2.3 From a43871f763043a2ed6f3ab9f52d3cff32c63e47e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 11 Aug 2010 17:21:38 -0700 Subject: glsl2: Commit generated files changed by previous commit --- src/glsl/glsl_parser.cpp | 496 +++++++++++++++++++++++------------------------ src/glsl/glsl_parser.h | 2 +- 2 files changed, 249 insertions(+), 249 deletions(-) diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp index 92937fdf9ee..864ab0032ff 100644 --- a/src/glsl/glsl_parser.cpp +++ b/src/glsl/glsl_parser.cpp @@ -339,7 +339,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c */ -#line 53 "glsl_parser.ypp" +#line 52 "glsl_parser.ypp" int n; float real; @@ -803,34 +803,34 @@ static const yytype_int16 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 210, 210, 209, 218, 221, 238, 240, 244, 253, - 261, 272, 276, 283, 290, 297, 304, 311, 318, 319, - 325, 329, 336, 342, 351, 355, 359, 360, 369, 370, - 374, 375, 379, 385, 397, 401, 407, 414, 425, 426, - 432, 438, 448, 449, 450, 451, 455, 456, 462, 468, - 477, 478, 484, 493, 494, 500, 509, 510, 516, 522, - 528, 537, 538, 544, 553, 554, 563, 564, 573, 574, - 583, 584, 593, 594, 603, 604, 613, 614, 623, 624, - 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, - 643, 647, 651, 667, 671, 675, 679, 693, 697, 698, - 702, 707, 715, 726, 736, 751, 758, 763, 774, 786, - 787, 788, 789, 793, 797, 798, 807, 816, 825, 834, - 843, 856, 867, 876, 885, 894, 903, 912, 921, 935, - 942, 953, 954, 958, 965, 966, 973, 1007, 1008, 1009, - 1013, 1017, 1018, 1022, 1030, 1031, 1032, 1033, 1034, 1035, - 1036, 1037, 1038, 1042, 1043, 1051, 1052, 1058, 1067, 1073, - 1079, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, - 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, - 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, - 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, - 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, - 1137, 1138, 1139, 1140, 1141, 1145, 1156, 1167, 1181, 1187, - 1196, 1201, 1209, 1224, 1229, 1237, 1243, 1252, 1256, 1262, - 1263, 1267, 1268, 1272, 1276, 1277, 1278, 1279, 1280, 1281, - 1282, 1286, 1292, 1301, 1302, 1306, 1312, 1321, 1331, 1343, - 1349, 1358, 1367, 1373, 1379, 1388, 1392, 1406, 1410, 1411, - 1415, 1422, 1429, 1439, 1440, 1444, 1446, 1452, 1457, 1466, - 1472, 1478, 1484, 1490, 1499, 1500, 1504 + 0, 209, 209, 208, 217, 220, 237, 239, 243, 252, + 260, 271, 275, 282, 289, 296, 303, 310, 317, 318, + 324, 328, 335, 341, 350, 354, 358, 359, 368, 369, + 373, 374, 378, 384, 396, 400, 406, 413, 424, 425, + 431, 437, 447, 448, 449, 450, 454, 455, 461, 467, + 476, 477, 483, 492, 493, 499, 508, 509, 515, 521, + 527, 536, 537, 543, 552, 553, 562, 563, 572, 573, + 582, 583, 592, 593, 602, 603, 612, 613, 622, 623, + 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, + 642, 646, 650, 666, 670, 674, 678, 692, 696, 697, + 701, 706, 714, 725, 735, 750, 757, 762, 773, 785, + 786, 787, 788, 792, 796, 797, 806, 815, 824, 833, + 842, 855, 866, 875, 884, 893, 902, 911, 920, 934, + 941, 952, 953, 957, 964, 965, 972, 1006, 1007, 1008, + 1012, 1016, 1017, 1021, 1029, 1030, 1031, 1032, 1033, 1034, + 1035, 1036, 1037, 1041, 1042, 1050, 1051, 1057, 1066, 1072, + 1078, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, + 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, + 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, + 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, + 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, + 1136, 1137, 1138, 1139, 1140, 1144, 1155, 1166, 1180, 1186, + 1195, 1200, 1208, 1223, 1228, 1236, 1242, 1251, 1255, 1261, + 1262, 1266, 1267, 1271, 1275, 1276, 1277, 1278, 1279, 1280, + 1281, 1285, 1291, 1300, 1301, 1305, 1311, 1320, 1330, 1342, + 1348, 1357, 1366, 1372, 1378, 1387, 1391, 1405, 1409, 1410, + 1414, 1421, 1428, 1438, 1439, 1443, 1445, 1451, 1456, 1465, + 1471, 1477, 1483, 1489, 1498, 1499, 1503 }; #endif @@ -2940,7 +2940,7 @@ yyreduce: case 2: /* Line 1455 of yacc.c */ -#line 210 "glsl_parser.ypp" +#line 209 "glsl_parser.ypp" { _mesa_glsl_initialize_types(state); ;} @@ -2949,7 +2949,7 @@ yyreduce: case 4: /* Line 1455 of yacc.c */ -#line 218 "glsl_parser.ypp" +#line 217 "glsl_parser.ypp" { state->language_version = 110; ;} @@ -2958,7 +2958,7 @@ yyreduce: case 5: /* Line 1455 of yacc.c */ -#line 222 "glsl_parser.ypp" +#line 221 "glsl_parser.ypp" { switch ((yyvsp[(2) - (3)].n)) { case 110: @@ -2978,7 +2978,7 @@ yyreduce: case 8: /* Line 1455 of yacc.c */ -#line 245 "glsl_parser.ypp" +#line 244 "glsl_parser.ypp" { if (!_mesa_glsl_process_extension((yyvsp[(2) - (5)].identifier), & (yylsp[(2) - (5)]), (yyvsp[(4) - (5)].identifier), & (yylsp[(4) - (5)]), state)) { YYERROR; @@ -2989,7 +2989,7 @@ yyreduce: case 9: /* Line 1455 of yacc.c */ -#line 254 "glsl_parser.ypp" +#line 253 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -3002,7 +3002,7 @@ yyreduce: case 10: /* Line 1455 of yacc.c */ -#line 262 "glsl_parser.ypp" +#line 261 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -3015,7 +3015,7 @@ yyreduce: case 12: /* Line 1455 of yacc.c */ -#line 277 "glsl_parser.ypp" +#line 276 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); @@ -3027,7 +3027,7 @@ yyreduce: case 13: /* Line 1455 of yacc.c */ -#line 284 "glsl_parser.ypp" +#line 283 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); @@ -3039,7 +3039,7 @@ yyreduce: case 14: /* Line 1455 of yacc.c */ -#line 291 "glsl_parser.ypp" +#line 290 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); @@ -3051,7 +3051,7 @@ yyreduce: case 15: /* Line 1455 of yacc.c */ -#line 298 "glsl_parser.ypp" +#line 297 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); @@ -3063,7 +3063,7 @@ yyreduce: case 16: /* Line 1455 of yacc.c */ -#line 305 "glsl_parser.ypp" +#line 304 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); @@ -3075,7 +3075,7 @@ yyreduce: case 17: /* Line 1455 of yacc.c */ -#line 312 "glsl_parser.ypp" +#line 311 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(2) - (3)].expression); ;} @@ -3084,7 +3084,7 @@ yyreduce: case 19: /* Line 1455 of yacc.c */ -#line 320 "glsl_parser.ypp" +#line 319 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_array_index, (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression), NULL); @@ -3095,7 +3095,7 @@ yyreduce: case 20: /* Line 1455 of yacc.c */ -#line 326 "glsl_parser.ypp" +#line 325 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} @@ -3104,7 +3104,7 @@ yyreduce: case 21: /* Line 1455 of yacc.c */ -#line 330 "glsl_parser.ypp" +#line 329 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), NULL, NULL); @@ -3116,7 +3116,7 @@ yyreduce: case 22: /* Line 1455 of yacc.c */ -#line 337 "glsl_parser.ypp" +#line 336 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_inc, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -3127,7 +3127,7 @@ yyreduce: case 23: /* Line 1455 of yacc.c */ -#line 343 "glsl_parser.ypp" +#line 342 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_dec, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -3138,7 +3138,7 @@ yyreduce: case 27: /* Line 1455 of yacc.c */ -#line 361 "glsl_parser.ypp" +#line 360 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -3149,7 +3149,7 @@ yyreduce: case 32: /* Line 1455 of yacc.c */ -#line 380 "glsl_parser.ypp" +#line 379 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (2)].expression); (yyval.expression)->set_location(yylloc); @@ -3160,7 +3160,7 @@ yyreduce: case 33: /* Line 1455 of yacc.c */ -#line 386 "glsl_parser.ypp" +#line 385 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (3)].expression); (yyval.expression)->set_location(yylloc); @@ -3171,7 +3171,7 @@ yyreduce: case 35: /* Line 1455 of yacc.c */ -#line 402 "glsl_parser.ypp" +#line 401 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_function_expression((yyvsp[(1) - (1)].type_specifier)); @@ -3182,7 +3182,7 @@ yyreduce: case 36: /* Line 1455 of yacc.c */ -#line 408 "glsl_parser.ypp" +#line 407 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -3194,7 +3194,7 @@ yyreduce: case 37: /* Line 1455 of yacc.c */ -#line 415 "glsl_parser.ypp" +#line 414 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -3206,7 +3206,7 @@ yyreduce: case 39: /* Line 1455 of yacc.c */ -#line 427 "glsl_parser.ypp" +#line 426 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_inc, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3217,7 +3217,7 @@ yyreduce: case 40: /* Line 1455 of yacc.c */ -#line 433 "glsl_parser.ypp" +#line 432 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_dec, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3228,7 +3228,7 @@ yyreduce: case 41: /* Line 1455 of yacc.c */ -#line 439 "glsl_parser.ypp" +#line 438 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(1) - (2)].n), (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3239,35 +3239,35 @@ yyreduce: case 42: /* Line 1455 of yacc.c */ -#line 448 "glsl_parser.ypp" +#line 447 "glsl_parser.ypp" { (yyval.n) = ast_plus; ;} break; case 43: /* Line 1455 of yacc.c */ -#line 449 "glsl_parser.ypp" +#line 448 "glsl_parser.ypp" { (yyval.n) = ast_neg; ;} break; case 44: /* Line 1455 of yacc.c */ -#line 450 "glsl_parser.ypp" +#line 449 "glsl_parser.ypp" { (yyval.n) = ast_logic_not; ;} break; case 45: /* Line 1455 of yacc.c */ -#line 451 "glsl_parser.ypp" +#line 450 "glsl_parser.ypp" { (yyval.n) = ast_bit_not; ;} break; case 47: /* Line 1455 of yacc.c */ -#line 457 "glsl_parser.ypp" +#line 456 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mul, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3278,7 +3278,7 @@ yyreduce: case 48: /* Line 1455 of yacc.c */ -#line 463 "glsl_parser.ypp" +#line 462 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_div, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3289,7 +3289,7 @@ yyreduce: case 49: /* Line 1455 of yacc.c */ -#line 469 "glsl_parser.ypp" +#line 468 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mod, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3300,7 +3300,7 @@ yyreduce: case 51: /* Line 1455 of yacc.c */ -#line 479 "glsl_parser.ypp" +#line 478 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_add, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3311,7 +3311,7 @@ yyreduce: case 52: /* Line 1455 of yacc.c */ -#line 485 "glsl_parser.ypp" +#line 484 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_sub, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3322,7 +3322,7 @@ yyreduce: case 54: /* Line 1455 of yacc.c */ -#line 495 "glsl_parser.ypp" +#line 494 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3333,7 +3333,7 @@ yyreduce: case 55: /* Line 1455 of yacc.c */ -#line 501 "glsl_parser.ypp" +#line 500 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_rshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3344,7 +3344,7 @@ yyreduce: case 57: /* Line 1455 of yacc.c */ -#line 511 "glsl_parser.ypp" +#line 510 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_less, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3355,7 +3355,7 @@ yyreduce: case 58: /* Line 1455 of yacc.c */ -#line 517 "glsl_parser.ypp" +#line 516 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_greater, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3366,7 +3366,7 @@ yyreduce: case 59: /* Line 1455 of yacc.c */ -#line 523 "glsl_parser.ypp" +#line 522 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3377,7 +3377,7 @@ yyreduce: case 60: /* Line 1455 of yacc.c */ -#line 529 "glsl_parser.ypp" +#line 528 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_gequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3388,7 +3388,7 @@ yyreduce: case 62: /* Line 1455 of yacc.c */ -#line 539 "glsl_parser.ypp" +#line 538 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_equal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3399,7 +3399,7 @@ yyreduce: case 63: /* Line 1455 of yacc.c */ -#line 545 "glsl_parser.ypp" +#line 544 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_nequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3410,7 +3410,7 @@ yyreduce: case 65: /* Line 1455 of yacc.c */ -#line 555 "glsl_parser.ypp" +#line 554 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3421,7 +3421,7 @@ yyreduce: case 67: /* Line 1455 of yacc.c */ -#line 565 "glsl_parser.ypp" +#line 564 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3432,7 +3432,7 @@ yyreduce: case 69: /* Line 1455 of yacc.c */ -#line 575 "glsl_parser.ypp" +#line 574 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3443,7 +3443,7 @@ yyreduce: case 71: /* Line 1455 of yacc.c */ -#line 585 "glsl_parser.ypp" +#line 584 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3454,7 +3454,7 @@ yyreduce: case 73: /* Line 1455 of yacc.c */ -#line 595 "glsl_parser.ypp" +#line 594 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3465,7 +3465,7 @@ yyreduce: case 75: /* Line 1455 of yacc.c */ -#line 605 "glsl_parser.ypp" +#line 604 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3476,7 +3476,7 @@ yyreduce: case 77: /* Line 1455 of yacc.c */ -#line 615 "glsl_parser.ypp" +#line 614 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_conditional, (yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression)); @@ -3487,7 +3487,7 @@ yyreduce: case 79: /* Line 1455 of yacc.c */ -#line 625 "glsl_parser.ypp" +#line 624 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(2) - (3)].n), (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -3498,84 +3498,84 @@ yyreduce: case 80: /* Line 1455 of yacc.c */ -#line 633 "glsl_parser.ypp" +#line 632 "glsl_parser.ypp" { (yyval.n) = ast_assign; ;} break; case 81: /* Line 1455 of yacc.c */ -#line 634 "glsl_parser.ypp" +#line 633 "glsl_parser.ypp" { (yyval.n) = ast_mul_assign; ;} break; case 82: /* Line 1455 of yacc.c */ -#line 635 "glsl_parser.ypp" +#line 634 "glsl_parser.ypp" { (yyval.n) = ast_div_assign; ;} break; case 83: /* Line 1455 of yacc.c */ -#line 636 "glsl_parser.ypp" +#line 635 "glsl_parser.ypp" { (yyval.n) = ast_mod_assign; ;} break; case 84: /* Line 1455 of yacc.c */ -#line 637 "glsl_parser.ypp" +#line 636 "glsl_parser.ypp" { (yyval.n) = ast_add_assign; ;} break; case 85: /* Line 1455 of yacc.c */ -#line 638 "glsl_parser.ypp" +#line 637 "glsl_parser.ypp" { (yyval.n) = ast_sub_assign; ;} break; case 86: /* Line 1455 of yacc.c */ -#line 639 "glsl_parser.ypp" +#line 638 "glsl_parser.ypp" { (yyval.n) = ast_ls_assign; ;} break; case 87: /* Line 1455 of yacc.c */ -#line 640 "glsl_parser.ypp" +#line 639 "glsl_parser.ypp" { (yyval.n) = ast_rs_assign; ;} break; case 88: /* Line 1455 of yacc.c */ -#line 641 "glsl_parser.ypp" +#line 640 "glsl_parser.ypp" { (yyval.n) = ast_and_assign; ;} break; case 89: /* Line 1455 of yacc.c */ -#line 642 "glsl_parser.ypp" +#line 641 "glsl_parser.ypp" { (yyval.n) = ast_xor_assign; ;} break; case 90: /* Line 1455 of yacc.c */ -#line 643 "glsl_parser.ypp" +#line 642 "glsl_parser.ypp" { (yyval.n) = ast_or_assign; ;} break; case 91: /* Line 1455 of yacc.c */ -#line 648 "glsl_parser.ypp" +#line 647 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} @@ -3584,7 +3584,7 @@ yyreduce: case 92: /* Line 1455 of yacc.c */ -#line 652 "glsl_parser.ypp" +#line 651 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (3)].expression)->oper != ast_sequence) { @@ -3602,7 +3602,7 @@ yyreduce: case 94: /* Line 1455 of yacc.c */ -#line 672 "glsl_parser.ypp" +#line 671 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].function); ;} @@ -3611,7 +3611,7 @@ yyreduce: case 95: /* Line 1455 of yacc.c */ -#line 676 "glsl_parser.ypp" +#line 675 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].declarator_list); ;} @@ -3620,7 +3620,7 @@ yyreduce: case 96: /* Line 1455 of yacc.c */ -#line 680 "glsl_parser.ypp" +#line 679 "glsl_parser.ypp" { if (((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_float) && ((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_int)) { @@ -3636,7 +3636,7 @@ yyreduce: case 100: /* Line 1455 of yacc.c */ -#line 703 "glsl_parser.ypp" +#line 702 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (2)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(2) - (2)].parameter_declarator)->link); @@ -3646,7 +3646,7 @@ yyreduce: case 101: /* Line 1455 of yacc.c */ -#line 708 "glsl_parser.ypp" +#line 707 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (3)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(3) - (3)].parameter_declarator)->link); @@ -3656,7 +3656,7 @@ yyreduce: case 102: /* Line 1455 of yacc.c */ -#line 716 "glsl_parser.ypp" +#line 715 "glsl_parser.ypp" { void *ctx = state; (yyval.function) = new(ctx) ast_function(); @@ -3669,7 +3669,7 @@ yyreduce: case 103: /* Line 1455 of yacc.c */ -#line 727 "glsl_parser.ypp" +#line 726 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3684,7 +3684,7 @@ yyreduce: case 104: /* Line 1455 of yacc.c */ -#line 737 "glsl_parser.ypp" +#line 736 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3701,7 +3701,7 @@ yyreduce: case 105: /* Line 1455 of yacc.c */ -#line 752 "glsl_parser.ypp" +#line 751 "glsl_parser.ypp" { (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; @@ -3713,7 +3713,7 @@ yyreduce: case 106: /* Line 1455 of yacc.c */ -#line 759 "glsl_parser.ypp" +#line 758 "glsl_parser.ypp" { (yyval.parameter_declarator) = (yyvsp[(2) - (2)].parameter_declarator); (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier).q; @@ -3723,7 +3723,7 @@ yyreduce: case 107: /* Line 1455 of yacc.c */ -#line 764 "glsl_parser.ypp" +#line 763 "glsl_parser.ypp" { void *ctx = state; (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i; @@ -3739,7 +3739,7 @@ yyreduce: case 108: /* Line 1455 of yacc.c */ -#line 775 "glsl_parser.ypp" +#line 774 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3753,35 +3753,35 @@ yyreduce: case 109: /* Line 1455 of yacc.c */ -#line 786 "glsl_parser.ypp" +#line 785 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; ;} break; case 110: /* Line 1455 of yacc.c */ -#line 787 "glsl_parser.ypp" +#line 786 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} break; case 111: /* Line 1455 of yacc.c */ -#line 788 "glsl_parser.ypp" +#line 787 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} break; case 112: /* Line 1455 of yacc.c */ -#line 789 "glsl_parser.ypp" +#line 788 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; (yyval.type_qualifier).q.out = 1; ;} break; case 115: /* Line 1455 of yacc.c */ -#line 799 "glsl_parser.ypp" +#line 798 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (3)].identifier), false, NULL, NULL); @@ -3795,7 +3795,7 @@ yyreduce: case 116: /* Line 1455 of yacc.c */ -#line 808 "glsl_parser.ypp" +#line 807 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), true, NULL, NULL); @@ -3809,7 +3809,7 @@ yyreduce: case 117: /* Line 1455 of yacc.c */ -#line 817 "glsl_parser.ypp" +#line 816 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (6)].identifier), true, (yyvsp[(5) - (6)].expression), NULL); @@ -3823,7 +3823,7 @@ yyreduce: case 118: /* Line 1455 of yacc.c */ -#line 826 "glsl_parser.ypp" +#line 825 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (7)].identifier), true, NULL, (yyvsp[(7) - (7)].expression)); @@ -3837,7 +3837,7 @@ yyreduce: case 119: /* Line 1455 of yacc.c */ -#line 835 "glsl_parser.ypp" +#line 834 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (8)].identifier), true, (yyvsp[(5) - (8)].expression), (yyvsp[(8) - (8)].expression)); @@ -3851,7 +3851,7 @@ yyreduce: case 120: /* Line 1455 of yacc.c */ -#line 844 "glsl_parser.ypp" +#line 843 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), false, NULL, (yyvsp[(5) - (5)].expression)); @@ -3865,7 +3865,7 @@ yyreduce: case 121: /* Line 1455 of yacc.c */ -#line 857 "glsl_parser.ypp" +#line 856 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (1)].fully_specified_type)->specifier->type_specifier != ast_struct) { @@ -3881,7 +3881,7 @@ yyreduce: case 122: /* Line 1455 of yacc.c */ -#line 868 "glsl_parser.ypp" +#line 867 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3895,7 +3895,7 @@ yyreduce: case 123: /* Line 1455 of yacc.c */ -#line 877 "glsl_parser.ypp" +#line 876 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), true, NULL, NULL); @@ -3909,7 +3909,7 @@ yyreduce: case 124: /* Line 1455 of yacc.c */ -#line 886 "glsl_parser.ypp" +#line 885 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (5)].identifier), true, (yyvsp[(4) - (5)].expression), NULL); @@ -3923,7 +3923,7 @@ yyreduce: case 125: /* Line 1455 of yacc.c */ -#line 895 "glsl_parser.ypp" +#line 894 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (6)].identifier), true, NULL, (yyvsp[(6) - (6)].expression)); @@ -3937,7 +3937,7 @@ yyreduce: case 126: /* Line 1455 of yacc.c */ -#line 904 "glsl_parser.ypp" +#line 903 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (7)].identifier), true, (yyvsp[(4) - (7)].expression), (yyvsp[(7) - (7)].expression)); @@ -3951,7 +3951,7 @@ yyreduce: case 127: /* Line 1455 of yacc.c */ -#line 913 "glsl_parser.ypp" +#line 912 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -3965,7 +3965,7 @@ yyreduce: case 128: /* Line 1455 of yacc.c */ -#line 922 "glsl_parser.ypp" +#line 921 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3981,7 +3981,7 @@ yyreduce: case 129: /* Line 1455 of yacc.c */ -#line 936 "glsl_parser.ypp" +#line 935 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -3993,7 +3993,7 @@ yyreduce: case 130: /* Line 1455 of yacc.c */ -#line 943 "glsl_parser.ypp" +#line 942 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -4006,14 +4006,14 @@ yyreduce: case 131: /* Line 1455 of yacc.c */ -#line 953 "glsl_parser.ypp" +#line 952 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; ;} break; case 133: /* Line 1455 of yacc.c */ -#line 959 "glsl_parser.ypp" +#line 958 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(3) - (4)].type_qualifier); ;} @@ -4022,7 +4022,7 @@ yyreduce: case 135: /* Line 1455 of yacc.c */ -#line 967 "glsl_parser.ypp" +#line 966 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (3)].type_qualifier).i | (yyvsp[(3) - (3)].type_qualifier).i; ;} @@ -4031,7 +4031,7 @@ yyreduce: case 136: /* Line 1455 of yacc.c */ -#line 974 "glsl_parser.ypp" +#line 973 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; @@ -4067,35 +4067,35 @@ yyreduce: case 137: /* Line 1455 of yacc.c */ -#line 1007 "glsl_parser.ypp" +#line 1006 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.smooth = 1; ;} break; case 138: /* Line 1455 of yacc.c */ -#line 1008 "glsl_parser.ypp" +#line 1007 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.flat = 1; ;} break; case 139: /* Line 1455 of yacc.c */ -#line 1009 "glsl_parser.ypp" +#line 1008 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.noperspective = 1; ;} break; case 140: /* Line 1455 of yacc.c */ -#line 1013 "glsl_parser.ypp" +#line 1012 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} break; case 142: /* Line 1455 of yacc.c */ -#line 1019 "glsl_parser.ypp" +#line 1018 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i | (yyvsp[(2) - (2)].type_qualifier).i; ;} @@ -4104,7 +4104,7 @@ yyreduce: case 143: /* Line 1455 of yacc.c */ -#line 1023 "glsl_parser.ypp" +#line 1022 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(2) - (2)].type_qualifier); (yyval.type_qualifier).q.invariant = 1; @@ -4114,70 +4114,70 @@ yyreduce: case 144: /* Line 1455 of yacc.c */ -#line 1030 "glsl_parser.ypp" +#line 1029 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;} break; case 145: /* Line 1455 of yacc.c */ -#line 1031 "glsl_parser.ypp" +#line 1030 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.attribute = 1; ;} break; case 146: /* Line 1455 of yacc.c */ -#line 1032 "glsl_parser.ypp" +#line 1031 "glsl_parser.ypp" { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i; (yyval.type_qualifier).q.varying = 1; ;} break; case 147: /* Line 1455 of yacc.c */ -#line 1033 "glsl_parser.ypp" +#line 1032 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.varying = 1; ;} break; case 148: /* Line 1455 of yacc.c */ -#line 1034 "glsl_parser.ypp" +#line 1033 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;} break; case 149: /* Line 1455 of yacc.c */ -#line 1035 "glsl_parser.ypp" +#line 1034 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;} break; case 150: /* Line 1455 of yacc.c */ -#line 1036 "glsl_parser.ypp" +#line 1035 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.in = 1; ;} break; case 151: /* Line 1455 of yacc.c */ -#line 1037 "glsl_parser.ypp" +#line 1036 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.out = 1; ;} break; case 152: /* Line 1455 of yacc.c */ -#line 1038 "glsl_parser.ypp" +#line 1037 "glsl_parser.ypp" { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.uniform = 1; ;} break; case 154: /* Line 1455 of yacc.c */ -#line 1044 "glsl_parser.ypp" +#line 1043 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(2) - (2)].type_specifier); (yyval.type_specifier)->precision = (yyvsp[(1) - (2)].n); @@ -4187,7 +4187,7 @@ yyreduce: case 156: /* Line 1455 of yacc.c */ -#line 1053 "glsl_parser.ypp" +#line 1052 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (3)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -4198,7 +4198,7 @@ yyreduce: case 157: /* Line 1455 of yacc.c */ -#line 1059 "glsl_parser.ypp" +#line 1058 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (4)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -4209,7 +4209,7 @@ yyreduce: case 158: /* Line 1455 of yacc.c */ -#line 1068 "glsl_parser.ypp" +#line 1067 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].n)); @@ -4220,7 +4220,7 @@ yyreduce: case 159: /* Line 1455 of yacc.c */ -#line 1074 "glsl_parser.ypp" +#line 1073 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].struct_specifier)); @@ -4231,7 +4231,7 @@ yyreduce: case 160: /* Line 1455 of yacc.c */ -#line 1080 "glsl_parser.ypp" +#line 1079 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].identifier)); @@ -4242,385 +4242,385 @@ yyreduce: case 161: /* Line 1455 of yacc.c */ -#line 1088 "glsl_parser.ypp" +#line 1087 "glsl_parser.ypp" { (yyval.n) = ast_void; ;} break; case 162: /* Line 1455 of yacc.c */ -#line 1089 "glsl_parser.ypp" +#line 1088 "glsl_parser.ypp" { (yyval.n) = ast_float; ;} break; case 163: /* Line 1455 of yacc.c */ -#line 1090 "glsl_parser.ypp" +#line 1089 "glsl_parser.ypp" { (yyval.n) = ast_int; ;} break; case 164: /* Line 1455 of yacc.c */ -#line 1091 "glsl_parser.ypp" +#line 1090 "glsl_parser.ypp" { (yyval.n) = ast_uint; ;} break; case 165: /* Line 1455 of yacc.c */ -#line 1092 "glsl_parser.ypp" +#line 1091 "glsl_parser.ypp" { (yyval.n) = ast_bool; ;} break; case 166: /* Line 1455 of yacc.c */ -#line 1093 "glsl_parser.ypp" +#line 1092 "glsl_parser.ypp" { (yyval.n) = ast_vec2; ;} break; case 167: /* Line 1455 of yacc.c */ -#line 1094 "glsl_parser.ypp" +#line 1093 "glsl_parser.ypp" { (yyval.n) = ast_vec3; ;} break; case 168: /* Line 1455 of yacc.c */ -#line 1095 "glsl_parser.ypp" +#line 1094 "glsl_parser.ypp" { (yyval.n) = ast_vec4; ;} break; case 169: /* Line 1455 of yacc.c */ -#line 1096 "glsl_parser.ypp" +#line 1095 "glsl_parser.ypp" { (yyval.n) = ast_bvec2; ;} break; case 170: /* Line 1455 of yacc.c */ -#line 1097 "glsl_parser.ypp" +#line 1096 "glsl_parser.ypp" { (yyval.n) = ast_bvec3; ;} break; case 171: /* Line 1455 of yacc.c */ -#line 1098 "glsl_parser.ypp" +#line 1097 "glsl_parser.ypp" { (yyval.n) = ast_bvec4; ;} break; case 172: /* Line 1455 of yacc.c */ -#line 1099 "glsl_parser.ypp" +#line 1098 "glsl_parser.ypp" { (yyval.n) = ast_ivec2; ;} break; case 173: /* Line 1455 of yacc.c */ -#line 1100 "glsl_parser.ypp" +#line 1099 "glsl_parser.ypp" { (yyval.n) = ast_ivec3; ;} break; case 174: /* Line 1455 of yacc.c */ -#line 1101 "glsl_parser.ypp" +#line 1100 "glsl_parser.ypp" { (yyval.n) = ast_ivec4; ;} break; case 175: /* Line 1455 of yacc.c */ -#line 1102 "glsl_parser.ypp" +#line 1101 "glsl_parser.ypp" { (yyval.n) = ast_uvec2; ;} break; case 176: /* Line 1455 of yacc.c */ -#line 1103 "glsl_parser.ypp" +#line 1102 "glsl_parser.ypp" { (yyval.n) = ast_uvec3; ;} break; case 177: /* Line 1455 of yacc.c */ -#line 1104 "glsl_parser.ypp" +#line 1103 "glsl_parser.ypp" { (yyval.n) = ast_uvec4; ;} break; case 178: /* Line 1455 of yacc.c */ -#line 1105 "glsl_parser.ypp" +#line 1104 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; case 179: /* Line 1455 of yacc.c */ -#line 1106 "glsl_parser.ypp" +#line 1105 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; case 180: /* Line 1455 of yacc.c */ -#line 1107 "glsl_parser.ypp" +#line 1106 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; case 181: /* Line 1455 of yacc.c */ -#line 1108 "glsl_parser.ypp" +#line 1107 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; case 182: /* Line 1455 of yacc.c */ -#line 1109 "glsl_parser.ypp" +#line 1108 "glsl_parser.ypp" { (yyval.n) = ast_mat2x3; ;} break; case 183: /* Line 1455 of yacc.c */ -#line 1110 "glsl_parser.ypp" +#line 1109 "glsl_parser.ypp" { (yyval.n) = ast_mat2x4; ;} break; case 184: /* Line 1455 of yacc.c */ -#line 1111 "glsl_parser.ypp" +#line 1110 "glsl_parser.ypp" { (yyval.n) = ast_mat3x2; ;} break; case 185: /* Line 1455 of yacc.c */ -#line 1112 "glsl_parser.ypp" +#line 1111 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; case 186: /* Line 1455 of yacc.c */ -#line 1113 "glsl_parser.ypp" +#line 1112 "glsl_parser.ypp" { (yyval.n) = ast_mat3x4; ;} break; case 187: /* Line 1455 of yacc.c */ -#line 1114 "glsl_parser.ypp" +#line 1113 "glsl_parser.ypp" { (yyval.n) = ast_mat4x2; ;} break; case 188: /* Line 1455 of yacc.c */ -#line 1115 "glsl_parser.ypp" +#line 1114 "glsl_parser.ypp" { (yyval.n) = ast_mat4x3; ;} break; case 189: /* Line 1455 of yacc.c */ -#line 1116 "glsl_parser.ypp" +#line 1115 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; case 190: /* Line 1455 of yacc.c */ -#line 1117 "glsl_parser.ypp" +#line 1116 "glsl_parser.ypp" { (yyval.n) = ast_sampler1d; ;} break; case 191: /* Line 1455 of yacc.c */ -#line 1118 "glsl_parser.ypp" +#line 1117 "glsl_parser.ypp" { (yyval.n) = ast_sampler2d; ;} break; case 192: /* Line 1455 of yacc.c */ -#line 1119 "glsl_parser.ypp" +#line 1118 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drect; ;} break; case 193: /* Line 1455 of yacc.c */ -#line 1120 "glsl_parser.ypp" +#line 1119 "glsl_parser.ypp" { (yyval.n) = ast_sampler3d; ;} break; case 194: /* Line 1455 of yacc.c */ -#line 1121 "glsl_parser.ypp" +#line 1120 "glsl_parser.ypp" { (yyval.n) = ast_samplercube; ;} break; case 195: /* Line 1455 of yacc.c */ -#line 1122 "glsl_parser.ypp" +#line 1121 "glsl_parser.ypp" { (yyval.n) = ast_sampler1dshadow; ;} break; case 196: /* Line 1455 of yacc.c */ -#line 1123 "glsl_parser.ypp" +#line 1122 "glsl_parser.ypp" { (yyval.n) = ast_sampler2dshadow; ;} break; case 197: /* Line 1455 of yacc.c */ -#line 1124 "glsl_parser.ypp" +#line 1123 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drectshadow; ;} break; case 198: /* Line 1455 of yacc.c */ -#line 1125 "glsl_parser.ypp" +#line 1124 "glsl_parser.ypp" { (yyval.n) = ast_samplercubeshadow; ;} break; case 199: /* Line 1455 of yacc.c */ -#line 1126 "glsl_parser.ypp" +#line 1125 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darray; ;} break; case 200: /* Line 1455 of yacc.c */ -#line 1127 "glsl_parser.ypp" +#line 1126 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darray; ;} break; case 201: /* Line 1455 of yacc.c */ -#line 1128 "glsl_parser.ypp" +#line 1127 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darrayshadow; ;} break; case 202: /* Line 1455 of yacc.c */ -#line 1129 "glsl_parser.ypp" +#line 1128 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darrayshadow; ;} break; case 203: /* Line 1455 of yacc.c */ -#line 1130 "glsl_parser.ypp" +#line 1129 "glsl_parser.ypp" { (yyval.n) = ast_isampler1d; ;} break; case 204: /* Line 1455 of yacc.c */ -#line 1131 "glsl_parser.ypp" +#line 1130 "glsl_parser.ypp" { (yyval.n) = ast_isampler2d; ;} break; case 205: /* Line 1455 of yacc.c */ -#line 1132 "glsl_parser.ypp" +#line 1131 "glsl_parser.ypp" { (yyval.n) = ast_isampler3d; ;} break; case 206: /* Line 1455 of yacc.c */ -#line 1133 "glsl_parser.ypp" +#line 1132 "glsl_parser.ypp" { (yyval.n) = ast_isamplercube; ;} break; case 207: /* Line 1455 of yacc.c */ -#line 1134 "glsl_parser.ypp" +#line 1133 "glsl_parser.ypp" { (yyval.n) = ast_isampler1darray; ;} break; case 208: /* Line 1455 of yacc.c */ -#line 1135 "glsl_parser.ypp" +#line 1134 "glsl_parser.ypp" { (yyval.n) = ast_isampler2darray; ;} break; case 209: /* Line 1455 of yacc.c */ -#line 1136 "glsl_parser.ypp" +#line 1135 "glsl_parser.ypp" { (yyval.n) = ast_usampler1d; ;} break; case 210: /* Line 1455 of yacc.c */ -#line 1137 "glsl_parser.ypp" +#line 1136 "glsl_parser.ypp" { (yyval.n) = ast_usampler2d; ;} break; case 211: /* Line 1455 of yacc.c */ -#line 1138 "glsl_parser.ypp" +#line 1137 "glsl_parser.ypp" { (yyval.n) = ast_usampler3d; ;} break; case 212: /* Line 1455 of yacc.c */ -#line 1139 "glsl_parser.ypp" +#line 1138 "glsl_parser.ypp" { (yyval.n) = ast_usamplercube; ;} break; case 213: /* Line 1455 of yacc.c */ -#line 1140 "glsl_parser.ypp" +#line 1139 "glsl_parser.ypp" { (yyval.n) = ast_usampler1darray; ;} break; case 214: /* Line 1455 of yacc.c */ -#line 1141 "glsl_parser.ypp" +#line 1140 "glsl_parser.ypp" { (yyval.n) = ast_usampler2darray; ;} break; case 215: /* Line 1455 of yacc.c */ -#line 1145 "glsl_parser.ypp" +#line 1144 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4637,7 +4637,7 @@ yyreduce: case 216: /* Line 1455 of yacc.c */ -#line 1156 "glsl_parser.ypp" +#line 1155 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4654,7 +4654,7 @@ yyreduce: case 217: /* Line 1455 of yacc.c */ -#line 1167 "glsl_parser.ypp" +#line 1166 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4671,7 +4671,7 @@ yyreduce: case 218: /* Line 1455 of yacc.c */ -#line 1182 "glsl_parser.ypp" +#line 1181 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node)); @@ -4682,7 +4682,7 @@ yyreduce: case 219: /* Line 1455 of yacc.c */ -#line 1188 "glsl_parser.ypp" +#line 1187 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node)); @@ -4693,7 +4693,7 @@ yyreduce: case 220: /* Line 1455 of yacc.c */ -#line 1197 "glsl_parser.ypp" +#line 1196 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].declarator_list); (yyvsp[(1) - (1)].declarator_list)->link.self_link(); @@ -4703,7 +4703,7 @@ yyreduce: case 221: /* Line 1455 of yacc.c */ -#line 1202 "glsl_parser.ypp" +#line 1201 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (2)].node); (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); @@ -4713,7 +4713,7 @@ yyreduce: case 222: /* Line 1455 of yacc.c */ -#line 1210 "glsl_parser.ypp" +#line 1209 "glsl_parser.ypp" { void *ctx = state; ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); @@ -4730,7 +4730,7 @@ yyreduce: case 223: /* Line 1455 of yacc.c */ -#line 1225 "glsl_parser.ypp" +#line 1224 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (1)].declaration); (yyvsp[(1) - (1)].declaration)->link.self_link(); @@ -4740,7 +4740,7 @@ yyreduce: case 224: /* Line 1455 of yacc.c */ -#line 1230 "glsl_parser.ypp" +#line 1229 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (3)].declaration); (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link); @@ -4750,7 +4750,7 @@ yyreduce: case 225: /* Line 1455 of yacc.c */ -#line 1238 "glsl_parser.ypp" +#line 1237 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL); @@ -4761,7 +4761,7 @@ yyreduce: case 226: /* Line 1455 of yacc.c */ -#line 1244 "glsl_parser.ypp" +#line 1243 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL); @@ -4772,28 +4772,28 @@ yyreduce: case 231: /* Line 1455 of yacc.c */ -#line 1267 "glsl_parser.ypp" +#line 1266 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 237: /* Line 1455 of yacc.c */ -#line 1279 "glsl_parser.ypp" +#line 1278 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; case 238: /* Line 1455 of yacc.c */ -#line 1280 "glsl_parser.ypp" +#line 1279 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; case 241: /* Line 1455 of yacc.c */ -#line 1287 "glsl_parser.ypp" +#line 1286 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL); @@ -4804,7 +4804,7 @@ yyreduce: case 242: /* Line 1455 of yacc.c */ -#line 1293 "glsl_parser.ypp" +#line 1292 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(2) - (3)].node)); @@ -4815,14 +4815,14 @@ yyreduce: case 243: /* Line 1455 of yacc.c */ -#line 1301 "glsl_parser.ypp" +#line 1300 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 245: /* Line 1455 of yacc.c */ -#line 1307 "glsl_parser.ypp" +#line 1306 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL); @@ -4833,7 +4833,7 @@ yyreduce: case 246: /* Line 1455 of yacc.c */ -#line 1313 "glsl_parser.ypp" +#line 1312 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node)); @@ -4844,7 +4844,7 @@ yyreduce: case 247: /* Line 1455 of yacc.c */ -#line 1322 "glsl_parser.ypp" +#line 1321 "glsl_parser.ypp" { if ((yyvsp[(1) - (1)].node) == NULL) { _mesa_glsl_error(& (yylsp[(1) - (1)]), state, " statement\n"); @@ -4859,7 +4859,7 @@ yyreduce: case 248: /* Line 1455 of yacc.c */ -#line 1332 "glsl_parser.ypp" +#line 1331 "glsl_parser.ypp" { if ((yyvsp[(2) - (2)].node) == NULL) { _mesa_glsl_error(& (yylsp[(2) - (2)]), state, " statement\n"); @@ -4873,7 +4873,7 @@ yyreduce: case 249: /* Line 1455 of yacc.c */ -#line 1344 "glsl_parser.ypp" +#line 1343 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement(NULL); @@ -4884,7 +4884,7 @@ yyreduce: case 250: /* Line 1455 of yacc.c */ -#line 1350 "glsl_parser.ypp" +#line 1349 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression)); @@ -4895,7 +4895,7 @@ yyreduce: case 251: /* Line 1455 of yacc.c */ -#line 1359 "glsl_parser.ypp" +#line 1358 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4906,7 +4906,7 @@ yyreduce: case 252: /* Line 1455 of yacc.c */ -#line 1368 "glsl_parser.ypp" +#line 1367 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4917,7 +4917,7 @@ yyreduce: case 253: /* Line 1455 of yacc.c */ -#line 1374 "glsl_parser.ypp" +#line 1373 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4928,7 +4928,7 @@ yyreduce: case 254: /* Line 1455 of yacc.c */ -#line 1380 "glsl_parser.ypp" +#line 1379 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4939,7 +4939,7 @@ yyreduce: case 255: /* Line 1455 of yacc.c */ -#line 1389 "glsl_parser.ypp" +#line 1388 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].expression); ;} @@ -4948,7 +4948,7 @@ yyreduce: case 256: /* Line 1455 of yacc.c */ -#line 1393 "glsl_parser.ypp" +#line 1392 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -4964,7 +4964,7 @@ yyreduce: case 260: /* Line 1455 of yacc.c */ -#line 1416 "glsl_parser.ypp" +#line 1415 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, @@ -4976,7 +4976,7 @@ yyreduce: case 261: /* Line 1455 of yacc.c */ -#line 1423 "glsl_parser.ypp" +#line 1422 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, @@ -4988,7 +4988,7 @@ yyreduce: case 262: /* Line 1455 of yacc.c */ -#line 1430 "glsl_parser.ypp" +#line 1429 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, @@ -5000,7 +5000,7 @@ yyreduce: case 266: /* Line 1455 of yacc.c */ -#line 1446 "glsl_parser.ypp" +#line 1445 "glsl_parser.ypp" { (yyval.node) = NULL; ;} @@ -5009,7 +5009,7 @@ yyreduce: case 267: /* Line 1455 of yacc.c */ -#line 1453 "glsl_parser.ypp" +#line 1452 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node); (yyval.for_rest_statement).rest = NULL; @@ -5019,7 +5019,7 @@ yyreduce: case 268: /* Line 1455 of yacc.c */ -#line 1458 "glsl_parser.ypp" +#line 1457 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node); (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression); @@ -5029,7 +5029,7 @@ yyreduce: case 269: /* Line 1455 of yacc.c */ -#line 1467 "glsl_parser.ypp" +#line 1466 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); @@ -5040,7 +5040,7 @@ yyreduce: case 270: /* Line 1455 of yacc.c */ -#line 1473 "glsl_parser.ypp" +#line 1472 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); @@ -5051,7 +5051,7 @@ yyreduce: case 271: /* Line 1455 of yacc.c */ -#line 1479 "glsl_parser.ypp" +#line 1478 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); @@ -5062,7 +5062,7 @@ yyreduce: case 272: /* Line 1455 of yacc.c */ -#line 1485 "glsl_parser.ypp" +#line 1484 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression)); @@ -5073,7 +5073,7 @@ yyreduce: case 273: /* Line 1455 of yacc.c */ -#line 1491 "glsl_parser.ypp" +#line 1490 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); @@ -5084,21 +5084,21 @@ yyreduce: case 274: /* Line 1455 of yacc.c */ -#line 1499 "glsl_parser.ypp" +#line 1498 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;} break; case 275: /* Line 1455 of yacc.c */ -#line 1500 "glsl_parser.ypp" +#line 1499 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); ;} break; case 276: /* Line 1455 of yacc.c */ -#line 1505 "glsl_parser.ypp" +#line 1504 "glsl_parser.ypp" { void *ctx = state; (yyval.function_definition) = new(ctx) ast_function_definition(); diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h index b9f3e3fe043..2bfca6fa2f9 100644 --- a/src/glsl/glsl_parser.h +++ b/src/glsl/glsl_parser.h @@ -237,7 +237,7 @@ typedef union YYSTYPE { /* Line 1676 of yacc.c */ -#line 53 "glsl_parser.ypp" +#line 52 "glsl_parser.ypp" int n; float real; -- cgit v1.2.3 From 5a805079a8d209e843661941730ecfebb65d2913 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 11 Aug 2010 17:19:05 -0700 Subject: glsl2: Change command line options passed to flex Remove --never-interactive because it is already specified in the source using %option. Use -o instead of --outfile. Some of the %option commands may also need to be removed for compatibility with older versions (e.g., 2.5.4) of flex. This should fix bugzilla #29209. --- src/glsl/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index a0ab1d6d401..3e480685bdf 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -151,7 +151,7 @@ glcpp/glcpp: $(GLCPP_OBJECTS) libglsl.a $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ glsl_lexer.cpp: glsl_lexer.lpp - flex --never-interactive --outfile="$@" $< + flex -o$@ $< glsl_parser.cpp: glsl_parser.ypp bison -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $< -- cgit v1.2.3 From 4f51762b070854901b48e461b76f614da414868d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 12 Aug 2010 13:51:39 +0100 Subject: gallium: Link DRI drivers with g++ and test with CXX New shader compiler need libc++ runtime. This works already if we are using llvm so this just covers the !llvm case. --- src/gallium/targets/Makefile.dri | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri index de05f96d231..59961e982aa 100644 --- a/src/gallium/targets/Makefile.dri +++ b/src/gallium/targets/Makefile.dri @@ -1,11 +1,12 @@ # -*-makefile-*- + ifeq ($(MESA_LLVM),1) PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a LDFLAGS += $(LLVM_LDFLAGS) -LD = g++ DRIVER_EXTRAS = $(LLVM_LIBS) -USE_CXX=1 +else +LDFLAGS += -lstdc++ endif MESA_MODULES = \ @@ -75,15 +76,11 @@ default: depend symlinks $(TOP)/$(LIB_DIR)/gallium $(LIBNAME) $(LIBNAME_STAGING) $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \ $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o - $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + $(MKLIB) -o $@.tmp -noprefix -linker '$(CXX)' -ldflags '$(LDFLAGS)' \ $(OBJECTS) $(PIPE_DRIVERS) \ -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \ $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) - if [ "x${USE_CXX}" == "x" ]; then \ - $(CC) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS); \ - else \ - $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS); \ - fi + $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS); @rm -f $@.test mv -f $@.tmp $@ -- cgit v1.2.3 From 188f60fb0576c8ac06638a8fd080a2ecc551919c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 12 Aug 2010 10:07:05 -0700 Subject: glsl2: Add missing include of string.h Makes the build happy on non-GCC platforms. --- src/glsl/glcpp/glcpp-parse.c | 215 ++++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 107 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index df26899a0f0..a4d46042fff 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -95,6 +95,7 @@ #include #include +#include #include #include @@ -212,7 +213,7 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); /* Line 189 of yacc.c */ -#line 216 "glcpp/glcpp-parse.c" +#line 217 "glcpp/glcpp-parse.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -300,7 +301,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 304 "glcpp/glcpp-parse.c" +#line 305 "glcpp/glcpp-parse.c" #ifdef short # undef short @@ -625,17 +626,17 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 180, 180, 182, 186, 189, 194, 195, 199, 202, - 208, 211, 214, 217, 225, 244, 254, 259, 264, 283, - 298, 301, 304, 313, 317, 326, 331, 332, 335, 338, - 341, 344, 347, 350, 353, 356, 359, 362, 365, 368, - 371, 374, 377, 380, 383, 386, 389, 392, 395, 398, - 404, 409, 417, 418, 422, 428, 429, 432, 434, 441, - 445, 449, 454, 460, 468, 474, 482, 486, 490, 494, - 498, 505, 506, 507, 508, 509, 510, 511, 512, 513, - 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, - 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, - 534, 535 + 0, 181, 181, 183, 187, 190, 195, 196, 200, 203, + 209, 212, 215, 218, 226, 245, 255, 260, 265, 284, + 299, 302, 305, 314, 318, 327, 332, 333, 336, 339, + 342, 345, 348, 351, 354, 357, 360, 363, 366, 369, + 372, 375, 378, 381, 384, 387, 390, 393, 396, 399, + 405, 410, 418, 419, 423, 429, 430, 433, 435, 442, + 446, 450, 455, 461, 469, 475, 483, 487, 491, 495, + 499, 506, 507, 508, 509, 510, 511, 512, 513, 514, + 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, + 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, + 535, 536 }; #endif @@ -1595,7 +1596,7 @@ YYLTYPE yylloc; /* User initialization code. */ /* Line 1242 of yacc.c */ -#line 147 "glcpp/glcpp-parse.y" +#line 148 "glcpp/glcpp-parse.y" { yylloc.first_line = 1; yylloc.first_column = 1; @@ -1605,7 +1606,7 @@ YYLTYPE yylloc; } /* Line 1242 of yacc.c */ -#line 1609 "glcpp/glcpp-parse.c" +#line 1610 "glcpp/glcpp-parse.c" yylsp[0] = yylloc; goto yysetstate; @@ -1793,7 +1794,7 @@ yyreduce: case 4: /* Line 1455 of yacc.c */ -#line 186 "glcpp/glcpp-parse.y" +#line 187 "glcpp/glcpp-parse.y" { glcpp_print(parser->output, "\n"); ;} @@ -1802,7 +1803,7 @@ yyreduce: case 5: /* Line 1455 of yacc.c */ -#line 189 "glcpp/glcpp-parse.y" +#line 190 "glcpp/glcpp-parse.y" { _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); glcpp_print(parser->output, "\n"); @@ -1813,7 +1814,7 @@ yyreduce: case 8: /* Line 1455 of yacc.c */ -#line 199 "glcpp/glcpp-parse.y" +#line 200 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); ;} @@ -1822,7 +1823,7 @@ yyreduce: case 9: /* Line 1455 of yacc.c */ -#line 202 "glcpp/glcpp-parse.y" +#line 203 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); ;} @@ -1831,7 +1832,7 @@ yyreduce: case 10: /* Line 1455 of yacc.c */ -#line 208 "glcpp/glcpp-parse.y" +#line 209 "glcpp/glcpp-parse.y" { _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); ;} @@ -1840,7 +1841,7 @@ yyreduce: case 11: /* Line 1455 of yacc.c */ -#line 211 "glcpp/glcpp-parse.y" +#line 212 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); ;} @@ -1849,7 +1850,7 @@ yyreduce: case 12: /* Line 1455 of yacc.c */ -#line 214 "glcpp/glcpp-parse.y" +#line 215 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); ;} @@ -1858,7 +1859,7 @@ yyreduce: case 13: /* Line 1455 of yacc.c */ -#line 217 "glcpp/glcpp-parse.y" +#line 218 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); if (macro) { @@ -1872,7 +1873,7 @@ yyreduce: case 14: /* Line 1455 of yacc.c */ -#line 225 "glcpp/glcpp-parse.y" +#line 226 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'if' expression if * we are not skipping. When we are skipping, we @@ -1897,7 +1898,7 @@ yyreduce: case 15: /* Line 1455 of yacc.c */ -#line 244 "glcpp/glcpp-parse.y" +#line 245 "glcpp/glcpp-parse.y" { /* #if without an expression is only an error if we * are not skipping */ @@ -1913,7 +1914,7 @@ yyreduce: case 16: /* Line 1455 of yacc.c */ -#line 254 "glcpp/glcpp-parse.y" +#line 255 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1924,7 +1925,7 @@ yyreduce: case 17: /* Line 1455 of yacc.c */ -#line 259 "glcpp/glcpp-parse.y" +#line 260 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1935,7 +1936,7 @@ yyreduce: case 18: /* Line 1455 of yacc.c */ -#line 264 "glcpp/glcpp-parse.y" +#line 265 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'elif' expression * if we are not skipping. When we are skipping, we @@ -1960,7 +1961,7 @@ yyreduce: case 19: /* Line 1455 of yacc.c */ -#line 283 "glcpp/glcpp-parse.y" +#line 284 "glcpp/glcpp-parse.y" { /* #elif without an expression is an error unless we * are skipping. */ @@ -1981,7 +1982,7 @@ yyreduce: case 20: /* Line 1455 of yacc.c */ -#line 298 "glcpp/glcpp-parse.y" +#line 299 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); ;} @@ -1990,7 +1991,7 @@ yyreduce: case 21: /* Line 1455 of yacc.c */ -#line 301 "glcpp/glcpp-parse.y" +#line 302 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); ;} @@ -1999,7 +2000,7 @@ yyreduce: case 22: /* Line 1455 of yacc.c */ -#line 304 "glcpp/glcpp-parse.y" +#line 305 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); if (macro) { @@ -2014,7 +2015,7 @@ yyreduce: case 24: /* Line 1455 of yacc.c */ -#line 317 "glcpp/glcpp-parse.y" +#line 318 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); @@ -2029,7 +2030,7 @@ yyreduce: case 25: /* Line 1455 of yacc.c */ -#line 326 "glcpp/glcpp-parse.y" +#line 327 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} @@ -2038,7 +2039,7 @@ yyreduce: case 27: /* Line 1455 of yacc.c */ -#line 332 "glcpp/glcpp-parse.y" +#line 333 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); ;} @@ -2047,7 +2048,7 @@ yyreduce: case 28: /* Line 1455 of yacc.c */ -#line 335 "glcpp/glcpp-parse.y" +#line 336 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); ;} @@ -2056,7 +2057,7 @@ yyreduce: case 29: /* Line 1455 of yacc.c */ -#line 338 "glcpp/glcpp-parse.y" +#line 339 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); ;} @@ -2065,7 +2066,7 @@ yyreduce: case 30: /* Line 1455 of yacc.c */ -#line 341 "glcpp/glcpp-parse.y" +#line 342 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); ;} @@ -2074,7 +2075,7 @@ yyreduce: case 31: /* Line 1455 of yacc.c */ -#line 344 "glcpp/glcpp-parse.y" +#line 345 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); ;} @@ -2083,7 +2084,7 @@ yyreduce: case 32: /* Line 1455 of yacc.c */ -#line 347 "glcpp/glcpp-parse.y" +#line 348 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); ;} @@ -2092,7 +2093,7 @@ yyreduce: case 33: /* Line 1455 of yacc.c */ -#line 350 "glcpp/glcpp-parse.y" +#line 351 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); ;} @@ -2101,7 +2102,7 @@ yyreduce: case 34: /* Line 1455 of yacc.c */ -#line 353 "glcpp/glcpp-parse.y" +#line 354 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); ;} @@ -2110,7 +2111,7 @@ yyreduce: case 35: /* Line 1455 of yacc.c */ -#line 356 "glcpp/glcpp-parse.y" +#line 357 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); ;} @@ -2119,7 +2120,7 @@ yyreduce: case 36: /* Line 1455 of yacc.c */ -#line 359 "glcpp/glcpp-parse.y" +#line 360 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); ;} @@ -2128,7 +2129,7 @@ yyreduce: case 37: /* Line 1455 of yacc.c */ -#line 362 "glcpp/glcpp-parse.y" +#line 363 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); ;} @@ -2137,7 +2138,7 @@ yyreduce: case 38: /* Line 1455 of yacc.c */ -#line 365 "glcpp/glcpp-parse.y" +#line 366 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); ;} @@ -2146,7 +2147,7 @@ yyreduce: case 39: /* Line 1455 of yacc.c */ -#line 368 "glcpp/glcpp-parse.y" +#line 369 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); ;} @@ -2155,7 +2156,7 @@ yyreduce: case 40: /* Line 1455 of yacc.c */ -#line 371 "glcpp/glcpp-parse.y" +#line 372 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); ;} @@ -2164,7 +2165,7 @@ yyreduce: case 41: /* Line 1455 of yacc.c */ -#line 374 "glcpp/glcpp-parse.y" +#line 375 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); ;} @@ -2173,7 +2174,7 @@ yyreduce: case 42: /* Line 1455 of yacc.c */ -#line 377 "glcpp/glcpp-parse.y" +#line 378 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); ;} @@ -2182,7 +2183,7 @@ yyreduce: case 43: /* Line 1455 of yacc.c */ -#line 380 "glcpp/glcpp-parse.y" +#line 381 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); ;} @@ -2191,7 +2192,7 @@ yyreduce: case 44: /* Line 1455 of yacc.c */ -#line 383 "glcpp/glcpp-parse.y" +#line 384 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); ;} @@ -2200,7 +2201,7 @@ yyreduce: case 45: /* Line 1455 of yacc.c */ -#line 386 "glcpp/glcpp-parse.y" +#line 387 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); ;} @@ -2209,7 +2210,7 @@ yyreduce: case 46: /* Line 1455 of yacc.c */ -#line 389 "glcpp/glcpp-parse.y" +#line 390 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); ;} @@ -2218,7 +2219,7 @@ yyreduce: case 47: /* Line 1455 of yacc.c */ -#line 392 "glcpp/glcpp-parse.y" +#line 393 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); ;} @@ -2227,7 +2228,7 @@ yyreduce: case 48: /* Line 1455 of yacc.c */ -#line 395 "glcpp/glcpp-parse.y" +#line 396 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); ;} @@ -2236,7 +2237,7 @@ yyreduce: case 49: /* Line 1455 of yacc.c */ -#line 398 "glcpp/glcpp-parse.y" +#line 399 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); ;} @@ -2245,7 +2246,7 @@ yyreduce: case 50: /* Line 1455 of yacc.c */ -#line 404 "glcpp/glcpp-parse.y" +#line 405 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); @@ -2256,7 +2257,7 @@ yyreduce: case 51: /* Line 1455 of yacc.c */ -#line 409 "glcpp/glcpp-parse.y" +#line 410 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); @@ -2267,14 +2268,14 @@ yyreduce: case 52: /* Line 1455 of yacc.c */ -#line 417 "glcpp/glcpp-parse.y" +#line 418 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 54: /* Line 1455 of yacc.c */ -#line 422 "glcpp/glcpp-parse.y" +#line 423 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); ;} @@ -2283,14 +2284,14 @@ yyreduce: case 55: /* Line 1455 of yacc.c */ -#line 428 "glcpp/glcpp-parse.y" +#line 429 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 58: /* Line 1455 of yacc.c */ -#line 434 "glcpp/glcpp-parse.y" +#line 435 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); ;} @@ -2299,7 +2300,7 @@ yyreduce: case 59: /* Line 1455 of yacc.c */ -#line 441 "glcpp/glcpp-parse.y" +#line 442 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2309,7 +2310,7 @@ yyreduce: case 60: /* Line 1455 of yacc.c */ -#line 445 "glcpp/glcpp-parse.y" +#line 446 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2319,7 +2320,7 @@ yyreduce: case 62: /* Line 1455 of yacc.c */ -#line 454 "glcpp/glcpp-parse.y" +#line 455 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2331,7 +2332,7 @@ yyreduce: case 63: /* Line 1455 of yacc.c */ -#line 460 "glcpp/glcpp-parse.y" +#line 461 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2342,7 +2343,7 @@ yyreduce: case 64: /* Line 1455 of yacc.c */ -#line 468 "glcpp/glcpp-parse.y" +#line 469 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2354,7 +2355,7 @@ yyreduce: case 65: /* Line 1455 of yacc.c */ -#line 474 "glcpp/glcpp-parse.y" +#line 475 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2365,7 +2366,7 @@ yyreduce: case 66: /* Line 1455 of yacc.c */ -#line 482 "glcpp/glcpp-parse.y" +#line 483 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2375,7 +2376,7 @@ yyreduce: case 67: /* Line 1455 of yacc.c */ -#line 486 "glcpp/glcpp-parse.y" +#line 487 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2385,7 +2386,7 @@ yyreduce: case 68: /* Line 1455 of yacc.c */ -#line 490 "glcpp/glcpp-parse.y" +#line 491 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); (yyval.token)->location = yylloc; @@ -2395,7 +2396,7 @@ yyreduce: case 69: /* Line 1455 of yacc.c */ -#line 494 "glcpp/glcpp-parse.y" +#line 495 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2405,7 +2406,7 @@ yyreduce: case 70: /* Line 1455 of yacc.c */ -#line 498 "glcpp/glcpp-parse.y" +#line 499 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); (yyval.token)->location = yylloc; @@ -2415,224 +2416,224 @@ yyreduce: case 71: /* Line 1455 of yacc.c */ -#line 505 "glcpp/glcpp-parse.y" +#line 506 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 72: /* Line 1455 of yacc.c */ -#line 506 "glcpp/glcpp-parse.y" +#line 507 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 73: /* Line 1455 of yacc.c */ -#line 507 "glcpp/glcpp-parse.y" +#line 508 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 74: /* Line 1455 of yacc.c */ -#line 508 "glcpp/glcpp-parse.y" +#line 509 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 75: /* Line 1455 of yacc.c */ -#line 509 "glcpp/glcpp-parse.y" +#line 510 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 76: /* Line 1455 of yacc.c */ -#line 510 "glcpp/glcpp-parse.y" +#line 511 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 77: /* Line 1455 of yacc.c */ -#line 511 "glcpp/glcpp-parse.y" +#line 512 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 78: /* Line 1455 of yacc.c */ -#line 512 "glcpp/glcpp-parse.y" +#line 513 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 79: /* Line 1455 of yacc.c */ -#line 513 "glcpp/glcpp-parse.y" +#line 514 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 80: /* Line 1455 of yacc.c */ -#line 514 "glcpp/glcpp-parse.y" +#line 515 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 81: /* Line 1455 of yacc.c */ -#line 515 "glcpp/glcpp-parse.y" +#line 516 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 82: /* Line 1455 of yacc.c */ -#line 516 "glcpp/glcpp-parse.y" +#line 517 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 83: /* Line 1455 of yacc.c */ -#line 517 "glcpp/glcpp-parse.y" +#line 518 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 84: /* Line 1455 of yacc.c */ -#line 518 "glcpp/glcpp-parse.y" +#line 519 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 85: /* Line 1455 of yacc.c */ -#line 519 "glcpp/glcpp-parse.y" +#line 520 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 86: /* Line 1455 of yacc.c */ -#line 520 "glcpp/glcpp-parse.y" +#line 521 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 87: /* Line 1455 of yacc.c */ -#line 521 "glcpp/glcpp-parse.y" +#line 522 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 88: /* Line 1455 of yacc.c */ -#line 522 "glcpp/glcpp-parse.y" +#line 523 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 89: /* Line 1455 of yacc.c */ -#line 523 "glcpp/glcpp-parse.y" +#line 524 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 90: /* Line 1455 of yacc.c */ -#line 524 "glcpp/glcpp-parse.y" +#line 525 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 91: /* Line 1455 of yacc.c */ -#line 525 "glcpp/glcpp-parse.y" +#line 526 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 92: /* Line 1455 of yacc.c */ -#line 526 "glcpp/glcpp-parse.y" +#line 527 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 93: /* Line 1455 of yacc.c */ -#line 527 "glcpp/glcpp-parse.y" +#line 528 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 94: /* Line 1455 of yacc.c */ -#line 528 "glcpp/glcpp-parse.y" +#line 529 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 95: /* Line 1455 of yacc.c */ -#line 529 "glcpp/glcpp-parse.y" +#line 530 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 96: /* Line 1455 of yacc.c */ -#line 530 "glcpp/glcpp-parse.y" +#line 531 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 97: /* Line 1455 of yacc.c */ -#line 531 "glcpp/glcpp-parse.y" +#line 532 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 98: /* Line 1455 of yacc.c */ -#line 532 "glcpp/glcpp-parse.y" +#line 533 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 99: /* Line 1455 of yacc.c */ -#line 533 "glcpp/glcpp-parse.y" +#line 534 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 100: /* Line 1455 of yacc.c */ -#line 534 "glcpp/glcpp-parse.y" +#line 535 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 101: /* Line 1455 of yacc.c */ -#line 535 "glcpp/glcpp-parse.y" +#line 536 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; /* Line 1455 of yacc.c */ -#line 2636 "glcpp/glcpp-parse.c" +#line 2637 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2851,7 +2852,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 538 "glcpp/glcpp-parse.y" +#line 539 "glcpp/glcpp-parse.y" string_list_t * -- cgit v1.2.3 From 4ca4edd20e10415d7aabcf2ba6ca89e9401854ef Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 12 Aug 2010 10:07:29 -0700 Subject: glsl2: Commit generated file changed by previous commit --- src/glsl/glcpp/glcpp-parse.y | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 7b08cd5807c..b05a925a098 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -24,6 +24,7 @@ #include #include +#include #include #include -- cgit v1.2.3 From 2d83e3fa0de6e0b39307cdc67725ca88855d68d2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 12 Aug 2010 15:57:54 -0600 Subject: mesa: check for null shader->InfoLog before printing --- src/mesa/program/prog_print.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c index 1ce1bf2f4ed..95db9b0eb34 100644 --- a/src/mesa/program/prog_print.c +++ b/src/mesa/program/prog_print.c @@ -1032,7 +1032,9 @@ _mesa_write_shader_to_file(const struct gl_shader *shader) fprintf(f, "/* Compile status: %s */\n", shader->CompileStatus ? "ok" : "fail"); fprintf(f, "/* Log Info: */\n"); - fputs(shader->InfoLog, f); + if (shader->InfoLog) { + fputs(shader->InfoLog, f); + } if (shader->CompileStatus && shader->Program) { fprintf(f, "/* GPU code */\n"); fprintf(f, "/*\n"); -- cgit v1.2.3 From 261bbc011d11ab9e390cd5fe9f5151821eefaffa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 12 Aug 2010 15:05:39 -0700 Subject: glsl2: Use Elements from main/compiler.h instead of open-coding --- src/glsl/builtin_function.cpp | 5 +---- src/glsl/builtin_types.h | 4 ---- src/glsl/builtins/tools/generate_builtins.pl | 5 +---- src/glsl/glsl_types.cpp | 1 + src/glsl/ir_variable.cpp | 5 +---- src/mesa/program/ir_to_mesa.cpp | 1 + 6 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 12e6909a287..1d9a58a5caf 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -23,6 +23,7 @@ */ #include +#include "main/compiler.h" #include "glsl_parser_extras.h" #include "ir_reader.h" #include "program.h" @@ -4799,10 +4800,6 @@ static const char *functions_for_EXT_texture_array_fs [] = { builtins_EXT_texture_array_fs_textures, }; -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif - void *builtin_mem_ctx = NULL; void diff --git a/src/glsl/builtin_types.h b/src/glsl/builtin_types.h index bfa4f3f5408..7b94aac666b 100644 --- a/src/glsl/builtin_types.h +++ b/src/glsl/builtin_types.h @@ -21,10 +21,6 @@ * DEALINGS IN THE SOFTWARE. */ -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif - const glsl_type glsl_type::_error_type = glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, ""); diff --git a/src/glsl/builtins/tools/generate_builtins.pl b/src/glsl/builtins/tools/generate_builtins.pl index 61d511da1d4..91ef8917b0a 100755 --- a/src/glsl/builtins/tools/generate_builtins.pl +++ b/src/glsl/builtins/tools/generate_builtins.pl @@ -62,6 +62,7 @@ print << 'EOF'; */ #include +#include "main/compiler.h" #include "glsl_parser_extras.h" #include "ir_reader.h" #include "program.h" @@ -110,10 +111,6 @@ foreach $version (@versions) { } print << 'EOF'; -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif - void *builtin_mem_ctx = NULL; void diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 2aba1e0ac1d..8e80cf99e96 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -23,6 +23,7 @@ #include #include +#include "main/compiler.h" #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" #include "glsl_types.h" diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index d88cb515b47..917c06743b4 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -21,15 +21,12 @@ * DEALINGS IN THE SOFTWARE. */ +#include "main/compiler.h" #include "ir.h" #include "glsl_parser_extras.h" #include "glsl_symbol_table.h" #include "builtin_variables.h" -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif - static void generate_ARB_draw_buffers_variables(exec_list *, struct _mesa_glsl_parse_state *, bool, _mesa_glsl_parser_targets); diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index a9a6f977c01..ecb13069cb7 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -31,6 +31,7 @@ */ #include +#include "main/compiler.h" #include "ir.h" #include "ir_visitor.h" #include "ir_print_visitor.h" -- cgit v1.2.3 From 0dc39f481ab98d2114590103928b7403386c13cf Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 12 Aug 2010 18:00:35 -0700 Subject: glsl2: Use MIN2 from macros.h instead of open coding it --- src/glsl/ast_function.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index ca7d0877271..6c36a04889e 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -25,11 +25,7 @@ #include "ast.h" #include "glsl_types.h" #include "ir.h" - -inline unsigned min(unsigned a, unsigned b) -{ - return (a < b) ? a : b; -} +#include "main/macros.h" static ir_rvalue * convert_component(ir_rvalue *src, const glsl_type *desired_type); @@ -781,8 +777,8 @@ emit_inline_matrix_constructor(const glsl_type *type, { 1, 1, 1, 0 } }; - const unsigned cols_to_init = min(type->matrix_columns, - type->vector_elements); + const unsigned cols_to_init = MIN2(type->matrix_columns, + type->vector_elements); for (unsigned i = 0; i < cols_to_init; i++) { ir_constant *const col_idx = new(ctx) ir_constant(i); ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx); @@ -875,8 +871,8 @@ emit_inline_matrix_constructor(const glsl_type *type, for (unsigned i = 1; i < src_matrix->type->vector_elements; i++) swiz[i] = i; - const unsigned last_col = min(src_matrix->type->matrix_columns, - var->type->matrix_columns); + const unsigned last_col = MIN2(src_matrix->type->matrix_columns, + var->type->matrix_columns); const unsigned write_mask = (1U << var->type->vector_elements) - 1; for (unsigned i = 0; i < last_col; i++) { @@ -938,8 +934,8 @@ emit_inline_matrix_constructor(const glsl_type *type, * single vec4, for example, can completely fill a mat2. */ if (rhs_components >= components_remaining_this_column) { - const unsigned count = min(rhs_components, - components_remaining_this_column); + const unsigned count = MIN2(rhs_components, + components_remaining_this_column); rhs_var_ref = new(ctx) ir_dereference_variable(rhs_var); -- cgit v1.2.3 From e6032b1d961715f6dd848058023252e92c36fcde Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 13 Aug 2010 12:31:10 +0100 Subject: talloc: Import 2.0.1 code. --- src/talloc/gpl-3.0.txt | 674 +++++++++++++++ src/talloc/lgpl-3.0.txt | 165 ++++ src/talloc/talloc.c | 1994 +++++++++++++++++++++++++++++++++++++++++++ src/talloc/talloc.h | 202 +++++ src/talloc/talloc_guide.txt | 757 ++++++++++++++++ 5 files changed, 3792 insertions(+) create mode 100644 src/talloc/gpl-3.0.txt create mode 100644 src/talloc/lgpl-3.0.txt create mode 100644 src/talloc/talloc.c create mode 100644 src/talloc/talloc.h create mode 100644 src/talloc/talloc_guide.txt diff --git a/src/talloc/gpl-3.0.txt b/src/talloc/gpl-3.0.txt new file mode 100644 index 00000000000..94a9ed024d3 --- /dev/null +++ b/src/talloc/gpl-3.0.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/src/talloc/lgpl-3.0.txt b/src/talloc/lgpl-3.0.txt new file mode 100644 index 00000000000..65c5ca88a67 --- /dev/null +++ b/src/talloc/lgpl-3.0.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/src/talloc/talloc.c b/src/talloc/talloc.c new file mode 100644 index 00000000000..7beda4b0f58 --- /dev/null +++ b/src/talloc/talloc.c @@ -0,0 +1,1994 @@ +/* + Samba Unix SMB/CIFS implementation. + + Samba trivial allocation library - new interface + + NOTE: Please read talloc_guide.txt for full documentation + + Copyright (C) Andrew Tridgell 2004 + Copyright (C) Stefan Metzmacher 2006 + + ** NOTE! The following LGPL license applies to the talloc + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see . +*/ + +/* + inspired by http://swapped.cc/halloc/ +*/ + +#include "replace.h" +#include "talloc.h" + +#ifdef TALLOC_BUILD_VERSION_MAJOR +#if (TALLOC_VERSION_MAJOR != TALLOC_BUILD_VERSION_MAJOR) +#error "TALLOC_VERSION_MAJOR != TALLOC_BUILD_VERSION_MAJOR" +#endif +#endif + +#ifdef TALLOC_BUILD_VERSION_MINOR +#if (TALLOC_VERSION_MINOR != TALLOC_BUILD_VERSION_MINOR) +#error "TALLOC_VERSION_MINOR != TALLOC_BUILD_VERSION_MINOR" +#endif +#endif + +/* use this to force every realloc to change the pointer, to stress test + code that might not cope */ +#define ALWAYS_REALLOC 0 + + +#define MAX_TALLOC_SIZE 0x10000000 +#define TALLOC_MAGIC_BASE 0xe814ec70 +#define TALLOC_MAGIC ( \ + TALLOC_MAGIC_BASE + \ + (TALLOC_VERSION_MAJOR << 12) + \ + (TALLOC_VERSION_MINOR << 4) \ +) + +#define TALLOC_FLAG_FREE 0x01 +#define TALLOC_FLAG_LOOP 0x02 +#define TALLOC_FLAG_POOL 0x04 /* This is a talloc pool */ +#define TALLOC_FLAG_POOLMEM 0x08 /* This is allocated in a pool */ +#define TALLOC_MAGIC_REFERENCE ((const char *)1) + +/* by default we abort when given a bad pointer (such as when talloc_free() is called + on a pointer that came from malloc() */ +#ifndef TALLOC_ABORT +#define TALLOC_ABORT(reason) abort() +#endif + +#ifndef discard_const_p +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) +# define discard_const_p(type, ptr) ((type *)((intptr_t)(ptr))) +#else +# define discard_const_p(type, ptr) ((type *)(ptr)) +#endif +#endif + +/* these macros gain us a few percent of speed on gcc */ +#if (__GNUC__ >= 3) +/* the strange !! is to ensure that __builtin_expect() takes either 0 or 1 + as its first argument */ +#ifndef likely +#define likely(x) __builtin_expect(!!(x), 1) +#endif +#ifndef unlikely +#define unlikely(x) __builtin_expect(!!(x), 0) +#endif +#else +#ifndef likely +#define likely(x) (x) +#endif +#ifndef unlikely +#define unlikely(x) (x) +#endif +#endif + +/* this null_context is only used if talloc_enable_leak_report() or + talloc_enable_leak_report_full() is called, otherwise it remains + NULL +*/ +static void *null_context; +static void *autofree_context; + +struct talloc_reference_handle { + struct talloc_reference_handle *next, *prev; + void *ptr; + const char *location; +}; + +typedef int (*talloc_destructor_t)(void *); + +struct talloc_chunk { + struct talloc_chunk *next, *prev; + struct talloc_chunk *parent, *child; + struct talloc_reference_handle *refs; + talloc_destructor_t destructor; + const char *name; + size_t size; + unsigned flags; + + /* + * "pool" has dual use: + * + * For the talloc pool itself (i.e. TALLOC_FLAG_POOL is set), "pool" + * marks the end of the currently allocated area. + * + * For members of the pool (i.e. TALLOC_FLAG_POOLMEM is set), "pool" + * is a pointer to the struct talloc_chunk of the pool that it was + * allocated from. This way children can quickly find the pool to chew + * from. + */ + void *pool; +}; + +/* 16 byte alignment seems to keep everyone happy */ +#define TC_HDR_SIZE ((sizeof(struct talloc_chunk)+15)&~15) +#define TC_PTR_FROM_CHUNK(tc) ((void *)(TC_HDR_SIZE + (char*)tc)) + +int talloc_version_major(void) +{ + return TALLOC_VERSION_MAJOR; +} + +int talloc_version_minor(void) +{ + return TALLOC_VERSION_MINOR; +} + +static void (*talloc_log_fn)(const char *message); + +void talloc_set_log_fn(void (*log_fn)(const char *message)) +{ + talloc_log_fn = log_fn; +} + +static void talloc_log(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); +static void talloc_log(const char *fmt, ...) +{ + va_list ap; + char *message; + + if (!talloc_log_fn) { + return; + } + + va_start(ap, fmt); + message = talloc_vasprintf(NULL, fmt, ap); + va_end(ap); + + talloc_log_fn(message); + talloc_free(message); +} + +static void talloc_log_stderr(const char *message) +{ + fprintf(stderr, "%s", message); +} + +void talloc_set_log_stderr(void) +{ + talloc_set_log_fn(talloc_log_stderr); +} + +static void (*talloc_abort_fn)(const char *reason); + +void talloc_set_abort_fn(void (*abort_fn)(const char *reason)) +{ + talloc_abort_fn = abort_fn; +} + +static void talloc_abort(const char *reason) +{ + talloc_log("%s\n", reason); + + if (!talloc_abort_fn) { + TALLOC_ABORT(reason); + } + + talloc_abort_fn(reason); +} + +static void talloc_abort_magic(unsigned magic) +{ + unsigned striped = magic - TALLOC_MAGIC_BASE; + unsigned major = (striped & 0xFFFFF000) >> 12; + unsigned minor = (striped & 0x00000FF0) >> 4; + talloc_log("Bad talloc magic[0x%08X/%u/%u] expected[0x%08X/%u/%u]\n", + magic, major, minor, + TALLOC_MAGIC, TALLOC_VERSION_MAJOR, TALLOC_VERSION_MINOR); + talloc_abort("Bad talloc magic value - wrong talloc version used/mixed"); +} + +static void talloc_abort_double_free(void) +{ + talloc_abort("Bad talloc magic value - double free"); +} + +static void talloc_abort_unknown_value(void) +{ + talloc_abort("Bad talloc magic value - unknown value"); +} + +/* panic if we get a bad magic value */ +static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr) +{ + const char *pp = (const char *)ptr; + struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE); + if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) { + if ((tc->flags & (~0xFFF)) == TALLOC_MAGIC_BASE) { + talloc_abort_magic(tc->flags & (~0xF)); + return NULL; + } + + if (tc->flags & TALLOC_FLAG_FREE) { + talloc_log("talloc: double free error - first free may be at %s\n", tc->name); + talloc_abort_double_free(); + return NULL; + } else { + talloc_abort_unknown_value(); + return NULL; + } + } + return tc; +} + +/* hook into the front of the list */ +#define _TLIST_ADD(list, p) \ +do { \ + if (!(list)) { \ + (list) = (p); \ + (p)->next = (p)->prev = NULL; \ + } else { \ + (list)->prev = (p); \ + (p)->next = (list); \ + (p)->prev = NULL; \ + (list) = (p); \ + }\ +} while (0) + +/* remove an element from a list - element doesn't have to be in list. */ +#define _TLIST_REMOVE(list, p) \ +do { \ + if ((p) == (list)) { \ + (list) = (p)->next; \ + if (list) (list)->prev = NULL; \ + } else { \ + if ((p)->prev) (p)->prev->next = (p)->next; \ + if ((p)->next) (p)->next->prev = (p)->prev; \ + } \ + if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \ +} while (0) + + +/* + return the parent chunk of a pointer +*/ +static inline struct talloc_chunk *talloc_parent_chunk(const void *ptr) +{ + struct talloc_chunk *tc; + + if (unlikely(ptr == NULL)) { + return NULL; + } + + tc = talloc_chunk_from_ptr(ptr); + while (tc->prev) tc=tc->prev; + + return tc->parent; +} + +void *talloc_parent(const void *ptr) +{ + struct talloc_chunk *tc = talloc_parent_chunk(ptr); + return tc? TC_PTR_FROM_CHUNK(tc) : NULL; +} + +/* + find parents name +*/ +const char *talloc_parent_name(const void *ptr) +{ + struct talloc_chunk *tc = talloc_parent_chunk(ptr); + return tc? tc->name : NULL; +} + +/* + A pool carries an in-pool object count count in the first 16 bytes. + bytes. This is done to support talloc_steal() to a parent outside of the + pool. The count includes the pool itself, so a talloc_free() on a pool will + only destroy the pool if the count has dropped to zero. A talloc_free() of a + pool member will reduce the count, and eventually also call free(3) on the + pool memory. + + The object count is not put into "struct talloc_chunk" because it is only + relevant for talloc pools and the alignment to 16 bytes would increase the + memory footprint of each talloc chunk by those 16 bytes. +*/ + +#define TALLOC_POOL_HDR_SIZE 16 + +static unsigned int *talloc_pool_objectcount(struct talloc_chunk *tc) +{ + return (unsigned int *)((char *)tc + sizeof(struct talloc_chunk)); +} + +/* + Allocate from a pool +*/ + +static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent, + size_t size) +{ + struct talloc_chunk *pool_ctx = NULL; + size_t space_left; + struct talloc_chunk *result; + size_t chunk_size; + + if (parent == NULL) { + return NULL; + } + + if (parent->flags & TALLOC_FLAG_POOL) { + pool_ctx = parent; + } + else if (parent->flags & TALLOC_FLAG_POOLMEM) { + pool_ctx = (struct talloc_chunk *)parent->pool; + } + + if (pool_ctx == NULL) { + return NULL; + } + + space_left = ((char *)pool_ctx + TC_HDR_SIZE + pool_ctx->size) + - ((char *)pool_ctx->pool); + + /* + * Align size to 16 bytes + */ + chunk_size = ((size + 15) & ~15); + + if (space_left < chunk_size) { + return NULL; + } + + result = (struct talloc_chunk *)pool_ctx->pool; + +#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED) + VALGRIND_MAKE_MEM_UNDEFINED(result, size); +#endif + + pool_ctx->pool = (void *)((char *)result + chunk_size); + + result->flags = TALLOC_MAGIC | TALLOC_FLAG_POOLMEM; + result->pool = pool_ctx; + + *talloc_pool_objectcount(pool_ctx) += 1; + + return result; +} + +/* + Allocate a bit of memory as a child of an existing pointer +*/ +static inline void *__talloc(const void *context, size_t size) +{ + struct talloc_chunk *tc = NULL; + + if (unlikely(context == NULL)) { + context = null_context; + } + + if (unlikely(size >= MAX_TALLOC_SIZE)) { + return NULL; + } + + if (context != NULL) { + tc = talloc_alloc_pool(talloc_chunk_from_ptr(context), + TC_HDR_SIZE+size); + } + + if (tc == NULL) { + tc = (struct talloc_chunk *)malloc(TC_HDR_SIZE+size); + if (unlikely(tc == NULL)) return NULL; + tc->flags = TALLOC_MAGIC; + tc->pool = NULL; + } + + tc->size = size; + tc->destructor = NULL; + tc->child = NULL; + tc->name = NULL; + tc->refs = NULL; + + if (likely(context)) { + struct talloc_chunk *parent = talloc_chunk_from_ptr(context); + + if (parent->child) { + parent->child->parent = NULL; + tc->next = parent->child; + tc->next->prev = tc; + } else { + tc->next = NULL; + } + tc->parent = parent; + tc->prev = NULL; + parent->child = tc; + } else { + tc->next = tc->prev = tc->parent = NULL; + } + + return TC_PTR_FROM_CHUNK(tc); +} + +/* + * Create a talloc pool + */ + +void *talloc_pool(const void *context, size_t size) +{ + void *result = __talloc(context, size + TALLOC_POOL_HDR_SIZE); + struct talloc_chunk *tc; + + if (unlikely(result == NULL)) { + return NULL; + } + + tc = talloc_chunk_from_ptr(result); + + tc->flags |= TALLOC_FLAG_POOL; + tc->pool = (char *)result + TALLOC_POOL_HDR_SIZE; + + *talloc_pool_objectcount(tc) = 1; + +#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS) + VALGRIND_MAKE_MEM_NOACCESS(tc->pool, size); +#endif + + return result; +} + +/* + setup a destructor to be called on free of a pointer + the destructor should return 0 on success, or -1 on failure. + if the destructor fails then the free is failed, and the memory can + be continued to be used +*/ +void _talloc_set_destructor(const void *ptr, int (*destructor)(void *)) +{ + struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); + tc->destructor = destructor; +} + +/* + increase the reference count on a piece of memory. +*/ +int talloc_increase_ref_count(const void *ptr) +{ + if (unlikely(!talloc_reference(null_context, ptr))) { + return -1; + } + return 0; +} + +/* + helper for talloc_reference() + + this is referenced by a function pointer and should not be inline +*/ +static int talloc_reference_destructor(struct talloc_reference_handle *handle) +{ + struct talloc_chunk *ptr_tc = talloc_chunk_from_ptr(handle->ptr); + _TLIST_REMOVE(ptr_tc->refs, handle); + return 0; +} + +/* + more efficient way to add a name to a pointer - the name must point to a + true string constant +*/ +static inline void _talloc_set_name_const(const void *ptr, const char *name) +{ + struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); + tc->name = name; +} + +/* + internal talloc_named_const() +*/ +static inline void *_talloc_named_const(const void *context, size_t size, const char *name) +{ + void *ptr; + + ptr = __talloc(context, size); + if (unlikely(ptr == NULL)) { + return NULL; + } + + _talloc_set_name_const(ptr, name); + + return ptr; +} + +/* + make a secondary reference to a pointer, hanging off the given context. + the pointer remains valid until both the original caller and this given + context are freed. + + the major use for this is when two different structures need to reference the + same underlying data, and you want to be able to free the two instances separately, + and in either order +*/ +void *_talloc_reference_loc(const void *context, const void *ptr, const char *location) +{ + struct talloc_chunk *tc; + struct talloc_reference_handle *handle; + if (unlikely(ptr == NULL)) return NULL; + + tc = talloc_chunk_from_ptr(ptr); + handle = (struct talloc_reference_handle *)_talloc_named_const(context, + sizeof(struct talloc_reference_handle), + TALLOC_MAGIC_REFERENCE); + if (unlikely(handle == NULL)) return NULL; + + /* note that we hang the destructor off the handle, not the + main context as that allows the caller to still setup their + own destructor on the context if they want to */ + talloc_set_destructor(handle, talloc_reference_destructor); + handle->ptr = discard_const_p(void, ptr); + handle->location = location; + _TLIST_ADD(tc->refs, handle); + return handle->ptr; +} + +static void *_talloc_steal_internal(const void *new_ctx, const void *ptr); + +/* + internal talloc_free call +*/ +static inline int _talloc_free_internal(void *ptr, const char *location) +{ + struct talloc_chunk *tc; + + if (unlikely(ptr == NULL)) { + return -1; + } + + tc = talloc_chunk_from_ptr(ptr); + + if (unlikely(tc->refs)) { + int is_child; + /* check this is a reference from a child or grantchild + * back to it's parent or grantparent + * + * in that case we need to remove the reference and + * call another instance of talloc_free() on the current + * pointer. + */ + is_child = talloc_is_parent(tc->refs, ptr); + _talloc_free_internal(tc->refs, location); + if (is_child) { + return _talloc_free_internal(ptr, location); + } + return -1; + } + + if (unlikely(tc->flags & TALLOC_FLAG_LOOP)) { + /* we have a free loop - stop looping */ + return 0; + } + + if (unlikely(tc->destructor)) { + talloc_destructor_t d = tc->destructor; + if (d == (talloc_destructor_t)-1) { + return -1; + } + tc->destructor = (talloc_destructor_t)-1; + if (d(ptr) == -1) { + tc->destructor = d; + return -1; + } + tc->destructor = NULL; + } + + if (tc->parent) { + _TLIST_REMOVE(tc->parent->child, tc); + if (tc->parent->child) { + tc->parent->child->parent = tc->parent; + } + } else { + if (tc->prev) tc->prev->next = tc->next; + if (tc->next) tc->next->prev = tc->prev; + } + + tc->flags |= TALLOC_FLAG_LOOP; + + while (tc->child) { + /* we need to work out who will own an abandoned child + if it cannot be freed. In priority order, the first + choice is owner of any remaining reference to this + pointer, the second choice is our parent, and the + final choice is the null context. */ + void *child = TC_PTR_FROM_CHUNK(tc->child); + const void *new_parent = null_context; + if (unlikely(tc->child->refs)) { + struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs); + if (p) new_parent = TC_PTR_FROM_CHUNK(p); + } + if (unlikely(_talloc_free_internal(child, location) == -1)) { + if (new_parent == null_context) { + struct talloc_chunk *p = talloc_parent_chunk(ptr); + if (p) new_parent = TC_PTR_FROM_CHUNK(p); + } + _talloc_steal_internal(new_parent, child); + } + } + + tc->flags |= TALLOC_FLAG_FREE; + + /* we mark the freed memory with where we called the free + * from. This means on a double free error we can report where + * the first free came from + */ + tc->name = location; + + if (tc->flags & (TALLOC_FLAG_POOL|TALLOC_FLAG_POOLMEM)) { + struct talloc_chunk *pool; + unsigned int *pool_object_count; + + pool = (tc->flags & TALLOC_FLAG_POOL) + ? tc : (struct talloc_chunk *)tc->pool; + + pool_object_count = talloc_pool_objectcount(pool); + + if (*pool_object_count == 0) { + talloc_abort("Pool object count zero!"); + return 0; + } + + *pool_object_count -= 1; + + if (*pool_object_count == 0) { + free(pool); + } + } + else { + free(tc); + } + return 0; +} + +/* + move a lump of memory from one talloc context to another return the + ptr on success, or NULL if it could not be transferred. + passing NULL as ptr will always return NULL with no side effects. +*/ +static void *_talloc_steal_internal(const void *new_ctx, const void *ptr) +{ + struct talloc_chunk *tc, *new_tc; + + if (unlikely(!ptr)) { + return NULL; + } + + if (unlikely(new_ctx == NULL)) { + new_ctx = null_context; + } + + tc = talloc_chunk_from_ptr(ptr); + + if (unlikely(new_ctx == NULL)) { + if (tc->parent) { + _TLIST_REMOVE(tc->parent->child, tc); + if (tc->parent->child) { + tc->parent->child->parent = tc->parent; + } + } else { + if (tc->prev) tc->prev->next = tc->next; + if (tc->next) tc->next->prev = tc->prev; + } + + tc->parent = tc->next = tc->prev = NULL; + return discard_const_p(void, ptr); + } + + new_tc = talloc_chunk_from_ptr(new_ctx); + + if (unlikely(tc == new_tc || tc->parent == new_tc)) { + return discard_const_p(void, ptr); + } + + if (tc->parent) { + _TLIST_REMOVE(tc->parent->child, tc); + if (tc->parent->child) { + tc->parent->child->parent = tc->parent; + } + } else { + if (tc->prev) tc->prev->next = tc->next; + if (tc->next) tc->next->prev = tc->prev; + } + + tc->parent = new_tc; + if (new_tc->child) new_tc->child->parent = NULL; + _TLIST_ADD(new_tc->child, tc); + + return discard_const_p(void, ptr); +} + +/* + move a lump of memory from one talloc context to another return the + ptr on success, or NULL if it could not be transferred. + passing NULL as ptr will always return NULL with no side effects. +*/ +void *_talloc_steal_loc(const void *new_ctx, const void *ptr, const char *location) +{ + struct talloc_chunk *tc; + + if (unlikely(ptr == NULL)) { + return NULL; + } + + tc = talloc_chunk_from_ptr(ptr); + + if (unlikely(tc->refs != NULL) && talloc_parent(ptr) != new_ctx) { + struct talloc_reference_handle *h; + + talloc_log("WARNING: talloc_steal with references at %s\n", + location); + + for (h=tc->refs; h; h=h->next) { + talloc_log("\treference at %s\n", + h->location); + } + } + + return _talloc_steal_internal(new_ctx, ptr); +} + +/* + this is like a talloc_steal(), but you must supply the old + parent. This resolves the ambiguity in a talloc_steal() which is + called on a context that has more than one parent (via references) + + The old parent can be either a reference or a parent +*/ +void *talloc_reparent(const void *old_parent, const void *new_parent, const void *ptr) +{ + struct talloc_chunk *tc; + struct talloc_reference_handle *h; + + if (unlikely(ptr == NULL)) { + return NULL; + } + + if (old_parent == talloc_parent(ptr)) { + return _talloc_steal_internal(new_parent, ptr); + } + + tc = talloc_chunk_from_ptr(ptr); + for (h=tc->refs;h;h=h->next) { + if (talloc_parent(h) == old_parent) { + if (_talloc_steal_internal(new_parent, h) != h) { + return NULL; + } + return discard_const_p(void, ptr); + } + } + + /* it wasn't a parent */ + return NULL; +} + +/* + remove a secondary reference to a pointer. This undo's what + talloc_reference() has done. The context and pointer arguments + must match those given to a talloc_reference() +*/ +static inline int talloc_unreference(const void *context, const void *ptr) +{ + struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); + struct talloc_reference_handle *h; + + if (unlikely(context == NULL)) { + context = null_context; + } + + for (h=tc->refs;h;h=h->next) { + struct talloc_chunk *p = talloc_parent_chunk(h); + if (p == NULL) { + if (context == NULL) break; + } else if (TC_PTR_FROM_CHUNK(p) == context) { + break; + } + } + if (h == NULL) { + return -1; + } + + return _talloc_free_internal(h, __location__); +} + +/* + remove a specific parent context from a pointer. This is a more + controlled varient of talloc_free() +*/ +int talloc_unlink(const void *context, void *ptr) +{ + struct talloc_chunk *tc_p, *new_p; + void *new_parent; + + if (ptr == NULL) { + return -1; + } + + if (context == NULL) { + context = null_context; + } + + if (talloc_unreference(context, ptr) == 0) { + return 0; + } + + if (context == NULL) { + if (talloc_parent_chunk(ptr) != NULL) { + return -1; + } + } else { + if (talloc_chunk_from_ptr(context) != talloc_parent_chunk(ptr)) { + return -1; + } + } + + tc_p = talloc_chunk_from_ptr(ptr); + + if (tc_p->refs == NULL) { + return _talloc_free_internal(ptr, __location__); + } + + new_p = talloc_parent_chunk(tc_p->refs); + if (new_p) { + new_parent = TC_PTR_FROM_CHUNK(new_p); + } else { + new_parent = NULL; + } + + if (talloc_unreference(new_parent, ptr) != 0) { + return -1; + } + + _talloc_steal_internal(new_parent, ptr); + + return 0; +} + +/* + add a name to an existing pointer - va_list version +*/ +static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); + +static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) +{ + struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); + tc->name = talloc_vasprintf(ptr, fmt, ap); + if (likely(tc->name)) { + _talloc_set_name_const(tc->name, ".name"); + } + return tc->name; +} + +/* + add a name to an existing pointer +*/ +const char *talloc_set_name(const void *ptr, const char *fmt, ...) +{ + const char *name; + va_list ap; + va_start(ap, fmt); + name = talloc_set_name_v(ptr, fmt, ap); + va_end(ap); + return name; +} + + +/* + create a named talloc pointer. Any talloc pointer can be named, and + talloc_named() operates just like talloc() except that it allows you + to name the pointer. +*/ +void *talloc_named(const void *context, size_t size, const char *fmt, ...) +{ + va_list ap; + void *ptr; + const char *name; + + ptr = __talloc(context, size); + if (unlikely(ptr == NULL)) return NULL; + + va_start(ap, fmt); + name = talloc_set_name_v(ptr, fmt, ap); + va_end(ap); + + if (unlikely(name == NULL)) { + _talloc_free_internal(ptr, __location__); + return NULL; + } + + return ptr; +} + +/* + return the name of a talloc ptr, or "UNNAMED" +*/ +const char *talloc_get_name(const void *ptr) +{ + struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); + if (unlikely(tc->name == TALLOC_MAGIC_REFERENCE)) { + return ".reference"; + } + if (likely(tc->name)) { + return tc->name; + } + return "UNNAMED"; +} + + +/* + check if a pointer has the given name. If it does, return the pointer, + otherwise return NULL +*/ +void *talloc_check_name(const void *ptr, const char *name) +{ + const char *pname; + if (unlikely(ptr == NULL)) return NULL; + pname = talloc_get_name(ptr); + if (likely(pname == name || strcmp(pname, name) == 0)) { + return discard_const_p(void, ptr); + } + return NULL; +} + +static void talloc_abort_type_missmatch(const char *location, + const char *name, + const char *expected) +{ + const char *reason; + + reason = talloc_asprintf(NULL, + "%s: Type mismatch: name[%s] expected[%s]", + location, + name?name:"NULL", + expected); + if (!reason) { + reason = "Type mismatch"; + } + + talloc_abort(reason); +} + +void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location) +{ + const char *pname; + + if (unlikely(ptr == NULL)) { + talloc_abort_type_missmatch(location, NULL, name); + return NULL; + } + + pname = talloc_get_name(ptr); + if (likely(pname == name || strcmp(pname, name) == 0)) { + return discard_const_p(void, ptr); + } + + talloc_abort_type_missmatch(location, pname, name); + return NULL; +} + +/* + this is for compatibility with older versions of talloc +*/ +void *talloc_init(const char *fmt, ...) +{ + va_list ap; + void *ptr; + const char *name; + + /* + * samba3 expects talloc_report_depth_cb(NULL, ...) + * reports all talloc'ed memory, so we need to enable + * null_tracking + */ + talloc_enable_null_tracking(); + + ptr = __talloc(NULL, 0); + if (unlikely(ptr == NULL)) return NULL; + + va_start(ap, fmt); + name = talloc_set_name_v(ptr, fmt, ap); + va_end(ap); + + if (unlikely(name == NULL)) { + _talloc_free_internal(ptr, __location__); + return NULL; + } + + return ptr; +} + +/* + this is a replacement for the Samba3 talloc_destroy_pool functionality. It + should probably not be used in new code. It's in here to keep the talloc + code consistent across Samba 3 and 4. +*/ +void talloc_free_children(void *ptr) +{ + struct talloc_chunk *tc; + + if (unlikely(ptr == NULL)) { + return; + } + + tc = talloc_chunk_from_ptr(ptr); + + while (tc->child) { + /* we need to work out who will own an abandoned child + if it cannot be freed. In priority order, the first + choice is owner of any remaining reference to this + pointer, the second choice is our parent, and the + final choice is the null context. */ + void *child = TC_PTR_FROM_CHUNK(tc->child); + const void *new_parent = null_context; + if (unlikely(tc->child->refs)) { + struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs); + if (p) new_parent = TC_PTR_FROM_CHUNK(p); + } + if (unlikely(talloc_free(child) == -1)) { + if (new_parent == null_context) { + struct talloc_chunk *p = talloc_parent_chunk(ptr); + if (p) new_parent = TC_PTR_FROM_CHUNK(p); + } + _talloc_steal_internal(new_parent, child); + } + } + + if ((tc->flags & TALLOC_FLAG_POOL) + && (*talloc_pool_objectcount(tc) == 1)) { + tc->pool = ((char *)tc + TC_HDR_SIZE + TALLOC_POOL_HDR_SIZE); +#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS) + VALGRIND_MAKE_MEM_NOACCESS( + tc->pool, tc->size - TALLOC_POOL_HDR_SIZE); +#endif + } +} + +/* + Allocate a bit of memory as a child of an existing pointer +*/ +void *_talloc(const void *context, size_t size) +{ + return __talloc(context, size); +} + +/* + externally callable talloc_set_name_const() +*/ +void talloc_set_name_const(const void *ptr, const char *name) +{ + _talloc_set_name_const(ptr, name); +} + +/* + create a named talloc pointer. Any talloc pointer can be named, and + talloc_named() operates just like talloc() except that it allows you + to name the pointer. +*/ +void *talloc_named_const(const void *context, size_t size, const char *name) +{ + return _talloc_named_const(context, size, name); +} + +/* + free a talloc pointer. This also frees all child pointers of this + pointer recursively + + return 0 if the memory is actually freed, otherwise -1. The memory + will not be freed if the ref_count is > 1 or the destructor (if + any) returns non-zero +*/ +int _talloc_free(void *ptr, const char *location) +{ + struct talloc_chunk *tc; + + if (unlikely(ptr == NULL)) { + return -1; + } + + tc = talloc_chunk_from_ptr(ptr); + + if (unlikely(tc->refs != NULL)) { + struct talloc_reference_handle *h; + + talloc_log("ERROR: talloc_free with references at %s\n", + location); + + for (h=tc->refs; h; h=h->next) { + talloc_log("\treference at %s\n", + h->location); + } + return -1; + } + + return _talloc_free_internal(ptr, location); +} + + + +/* + A talloc version of realloc. The context argument is only used if + ptr is NULL +*/ +void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name) +{ + struct talloc_chunk *tc; + void *new_ptr; + bool malloced = false; + + /* size zero is equivalent to free() */ + if (unlikely(size == 0)) { + talloc_unlink(context, ptr); + return NULL; + } + + if (unlikely(size >= MAX_TALLOC_SIZE)) { + return NULL; + } + + /* realloc(NULL) is equivalent to malloc() */ + if (ptr == NULL) { + return _talloc_named_const(context, size, name); + } + + tc = talloc_chunk_from_ptr(ptr); + + /* don't allow realloc on referenced pointers */ + if (unlikely(tc->refs)) { + return NULL; + } + + /* don't let anybody try to realloc a talloc_pool */ + if (unlikely(tc->flags & TALLOC_FLAG_POOL)) { + return NULL; + } + + /* don't shrink if we have less than 1k to gain */ + if ((size < tc->size) && ((tc->size - size) < 1024)) { + tc->size = size; + return ptr; + } + + /* by resetting magic we catch users of the old memory */ + tc->flags |= TALLOC_FLAG_FREE; + +#if ALWAYS_REALLOC + new_ptr = malloc(size + TC_HDR_SIZE); + if (new_ptr) { + memcpy(new_ptr, tc, tc->size + TC_HDR_SIZE); + free(tc); + } +#else + if (tc->flags & TALLOC_FLAG_POOLMEM) { + + new_ptr = talloc_alloc_pool(tc, size + TC_HDR_SIZE); + *talloc_pool_objectcount((struct talloc_chunk *) + (tc->pool)) -= 1; + + if (new_ptr == NULL) { + new_ptr = malloc(TC_HDR_SIZE+size); + malloced = true; + } + + if (new_ptr) { + memcpy(new_ptr, tc, MIN(tc->size,size) + TC_HDR_SIZE); + } + } + else { + new_ptr = realloc(tc, size + TC_HDR_SIZE); + } +#endif + if (unlikely(!new_ptr)) { + tc->flags &= ~TALLOC_FLAG_FREE; + return NULL; + } + + tc = (struct talloc_chunk *)new_ptr; + tc->flags &= ~TALLOC_FLAG_FREE; + if (malloced) { + tc->flags &= ~TALLOC_FLAG_POOLMEM; + } + if (tc->parent) { + tc->parent->child = tc; + } + if (tc->child) { + tc->child->parent = tc; + } + + if (tc->prev) { + tc->prev->next = tc; + } + if (tc->next) { + tc->next->prev = tc; + } + + tc->size = size; + _talloc_set_name_const(TC_PTR_FROM_CHUNK(tc), name); + + return TC_PTR_FROM_CHUNK(tc); +} + +/* + a wrapper around talloc_steal() for situations where you are moving a pointer + between two structures, and want the old pointer to be set to NULL +*/ +void *_talloc_move(const void *new_ctx, const void *_pptr) +{ + const void **pptr = discard_const_p(const void *,_pptr); + void *ret = talloc_steal(new_ctx, discard_const_p(void, *pptr)); + (*pptr) = NULL; + return ret; +} + +/* + return the total size of a talloc pool (subtree) +*/ +size_t talloc_total_size(const void *ptr) +{ + size_t total = 0; + struct talloc_chunk *c, *tc; + + if (ptr == NULL) { + ptr = null_context; + } + if (ptr == NULL) { + return 0; + } + + tc = talloc_chunk_from_ptr(ptr); + + if (tc->flags & TALLOC_FLAG_LOOP) { + return 0; + } + + tc->flags |= TALLOC_FLAG_LOOP; + + if (likely(tc->name != TALLOC_MAGIC_REFERENCE)) { + total = tc->size; + } + for (c=tc->child;c;c=c->next) { + total += talloc_total_size(TC_PTR_FROM_CHUNK(c)); + } + + tc->flags &= ~TALLOC_FLAG_LOOP; + + return total; +} + +/* + return the total number of blocks in a talloc pool (subtree) +*/ +size_t talloc_total_blocks(const void *ptr) +{ + size_t total = 0; + struct talloc_chunk *c, *tc; + + if (ptr == NULL) { + ptr = null_context; + } + if (ptr == NULL) { + return 0; + } + + tc = talloc_chunk_from_ptr(ptr); + + if (tc->flags & TALLOC_FLAG_LOOP) { + return 0; + } + + tc->flags |= TALLOC_FLAG_LOOP; + + total++; + for (c=tc->child;c;c=c->next) { + total += talloc_total_blocks(TC_PTR_FROM_CHUNK(c)); + } + + tc->flags &= ~TALLOC_FLAG_LOOP; + + return total; +} + +/* + return the number of external references to a pointer +*/ +size_t talloc_reference_count(const void *ptr) +{ + struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); + struct talloc_reference_handle *h; + size_t ret = 0; + + for (h=tc->refs;h;h=h->next) { + ret++; + } + return ret; +} + +/* + report on memory usage by all children of a pointer, giving a full tree view +*/ +void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, + void (*callback)(const void *ptr, + int depth, int max_depth, + int is_ref, + void *private_data), + void *private_data) +{ + struct talloc_chunk *c, *tc; + + if (ptr == NULL) { + ptr = null_context; + } + if (ptr == NULL) return; + + tc = talloc_chunk_from_ptr(ptr); + + if (tc->flags & TALLOC_FLAG_LOOP) { + return; + } + + callback(ptr, depth, max_depth, 0, private_data); + + if (max_depth >= 0 && depth >= max_depth) { + return; + } + + tc->flags |= TALLOC_FLAG_LOOP; + for (c=tc->child;c;c=c->next) { + if (c->name == TALLOC_MAGIC_REFERENCE) { + struct talloc_reference_handle *h = (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c); + callback(h->ptr, depth + 1, max_depth, 1, private_data); + } else { + talloc_report_depth_cb(TC_PTR_FROM_CHUNK(c), depth + 1, max_depth, callback, private_data); + } + } + tc->flags &= ~TALLOC_FLAG_LOOP; +} + +static void talloc_report_depth_FILE_helper(const void *ptr, int depth, int max_depth, int is_ref, void *_f) +{ + const char *name = talloc_get_name(ptr); + FILE *f = (FILE *)_f; + + if (is_ref) { + fprintf(f, "%*sreference to: %s\n", depth*4, "", name); + return; + } + + if (depth == 0) { + fprintf(f,"%stalloc report on '%s' (total %6lu bytes in %3lu blocks)\n", + (max_depth < 0 ? "full " :""), name, + (unsigned long)talloc_total_size(ptr), + (unsigned long)talloc_total_blocks(ptr)); + return; + } + + fprintf(f, "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d) %p\n", + depth*4, "", + name, + (unsigned long)talloc_total_size(ptr), + (unsigned long)talloc_total_blocks(ptr), + (int)talloc_reference_count(ptr), ptr); + +#if 0 + fprintf(f, "content: "); + if (talloc_total_size(ptr)) { + int tot = talloc_total_size(ptr); + int i; + + for (i = 0; i < tot; i++) { + if ((((char *)ptr)[i] > 31) && (((char *)ptr)[i] < 126)) { + fprintf(f, "%c", ((char *)ptr)[i]); + } else { + fprintf(f, "~%02x", ((char *)ptr)[i]); + } + } + } + fprintf(f, "\n"); +#endif +} + +/* + report on memory usage by all children of a pointer, giving a full tree view +*/ +void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f) +{ + if (f) { + talloc_report_depth_cb(ptr, depth, max_depth, talloc_report_depth_FILE_helper, f); + fflush(f); + } +} + +/* + report on memory usage by all children of a pointer, giving a full tree view +*/ +void talloc_report_full(const void *ptr, FILE *f) +{ + talloc_report_depth_file(ptr, 0, -1, f); +} + +/* + report on memory usage by all children of a pointer +*/ +void talloc_report(const void *ptr, FILE *f) +{ + talloc_report_depth_file(ptr, 0, 1, f); +} + +/* + report on any memory hanging off the null context +*/ +static void talloc_report_null(void) +{ + if (talloc_total_size(null_context) != 0) { + talloc_report(null_context, stderr); + } +} + +/* + report on any memory hanging off the null context +*/ +static void talloc_report_null_full(void) +{ + if (talloc_total_size(null_context) != 0) { + talloc_report_full(null_context, stderr); + } +} + +/* + enable tracking of the NULL context +*/ +void talloc_enable_null_tracking(void) +{ + if (null_context == NULL) { + null_context = _talloc_named_const(NULL, 0, "null_context"); + if (autofree_context != NULL) { + talloc_reparent(NULL, null_context, autofree_context); + } + } +} + +/* + enable tracking of the NULL context, not moving the autofree context + into the NULL context. This is needed for the talloc testsuite +*/ +void talloc_enable_null_tracking_no_autofree(void) +{ + if (null_context == NULL) { + null_context = _talloc_named_const(NULL, 0, "null_context"); + } +} + +/* + disable tracking of the NULL context +*/ +void talloc_disable_null_tracking(void) +{ + if (null_context != NULL) { + /* we have to move any children onto the real NULL + context */ + struct talloc_chunk *tc, *tc2; + tc = talloc_chunk_from_ptr(null_context); + for (tc2 = tc->child; tc2; tc2=tc2->next) { + if (tc2->parent == tc) tc2->parent = NULL; + if (tc2->prev == tc) tc2->prev = NULL; + } + for (tc2 = tc->next; tc2; tc2=tc2->next) { + if (tc2->parent == tc) tc2->parent = NULL; + if (tc2->prev == tc) tc2->prev = NULL; + } + tc->child = NULL; + tc->next = NULL; + } + talloc_free(null_context); + null_context = NULL; +} + +/* + enable leak reporting on exit +*/ +void talloc_enable_leak_report(void) +{ + talloc_enable_null_tracking(); + atexit(talloc_report_null); +} + +/* + enable full leak reporting on exit +*/ +void talloc_enable_leak_report_full(void) +{ + talloc_enable_null_tracking(); + atexit(talloc_report_null_full); +} + +/* + talloc and zero memory. +*/ +void *_talloc_zero(const void *ctx, size_t size, const char *name) +{ + void *p = _talloc_named_const(ctx, size, name); + + if (p) { + memset(p, '\0', size); + } + + return p; +} + +/* + memdup with a talloc. +*/ +void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name) +{ + void *newp = _talloc_named_const(t, size, name); + + if (likely(newp)) { + memcpy(newp, p, size); + } + + return newp; +} + +static inline char *__talloc_strlendup(const void *t, const char *p, size_t len) +{ + char *ret; + + ret = (char *)__talloc(t, len + 1); + if (unlikely(!ret)) return NULL; + + memcpy(ret, p, len); + ret[len] = 0; + + _talloc_set_name_const(ret, ret); + return ret; +} + +/* + strdup with a talloc +*/ +char *talloc_strdup(const void *t, const char *p) +{ + if (unlikely(!p)) return NULL; + return __talloc_strlendup(t, p, strlen(p)); +} + +/* + strndup with a talloc +*/ +char *talloc_strndup(const void *t, const char *p, size_t n) +{ + if (unlikely(!p)) return NULL; + return __talloc_strlendup(t, p, strnlen(p, n)); +} + +static inline char *__talloc_strlendup_append(char *s, size_t slen, + const char *a, size_t alen) +{ + char *ret; + + ret = talloc_realloc(NULL, s, char, slen + alen + 1); + if (unlikely(!ret)) return NULL; + + /* append the string and the trailing \0 */ + memcpy(&ret[slen], a, alen); + ret[slen+alen] = 0; + + _talloc_set_name_const(ret, ret); + return ret; +} + +/* + * Appends at the end of the string. + */ +char *talloc_strdup_append(char *s, const char *a) +{ + if (unlikely(!s)) { + return talloc_strdup(NULL, a); + } + + if (unlikely(!a)) { + return s; + } + + return __talloc_strlendup_append(s, strlen(s), a, strlen(a)); +} + +/* + * Appends at the end of the talloc'ed buffer, + * not the end of the string. + */ +char *talloc_strdup_append_buffer(char *s, const char *a) +{ + size_t slen; + + if (unlikely(!s)) { + return talloc_strdup(NULL, a); + } + + if (unlikely(!a)) { + return s; + } + + slen = talloc_get_size(s); + if (likely(slen > 0)) { + slen--; + } + + return __talloc_strlendup_append(s, slen, a, strlen(a)); +} + +/* + * Appends at the end of the string. + */ +char *talloc_strndup_append(char *s, const char *a, size_t n) +{ + if (unlikely(!s)) { + return talloc_strdup(NULL, a); + } + + if (unlikely(!a)) { + return s; + } + + return __talloc_strlendup_append(s, strlen(s), a, strnlen(a, n)); +} + +/* + * Appends at the end of the talloc'ed buffer, + * not the end of the string. + */ +char *talloc_strndup_append_buffer(char *s, const char *a, size_t n) +{ + size_t slen; + + if (unlikely(!s)) { + return talloc_strdup(NULL, a); + } + + if (unlikely(!a)) { + return s; + } + + slen = talloc_get_size(s); + if (likely(slen > 0)) { + slen--; + } + + return __talloc_strlendup_append(s, slen, a, strnlen(a, n)); +} + +#ifndef HAVE_VA_COPY +#ifdef HAVE___VA_COPY +#define va_copy(dest, src) __va_copy(dest, src) +#else +#define va_copy(dest, src) (dest) = (src) +#endif +#endif + +char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) +{ + int len; + char *ret; + va_list ap2; + char c; + + /* this call looks strange, but it makes it work on older solaris boxes */ + va_copy(ap2, ap); + len = vsnprintf(&c, 1, fmt, ap2); + va_end(ap2); + if (unlikely(len < 0)) { + return NULL; + } + + ret = (char *)__talloc(t, len+1); + if (unlikely(!ret)) return NULL; + + va_copy(ap2, ap); + vsnprintf(ret, len+1, fmt, ap2); + va_end(ap2); + + _talloc_set_name_const(ret, ret); + return ret; +} + + +/* + Perform string formatting, and return a pointer to newly allocated + memory holding the result, inside a memory pool. + */ +char *talloc_asprintf(const void *t, const char *fmt, ...) +{ + va_list ap; + char *ret; + + va_start(ap, fmt); + ret = talloc_vasprintf(t, fmt, ap); + va_end(ap); + return ret; +} + +static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, + const char *fmt, va_list ap) + PRINTF_ATTRIBUTE(3,0); + +static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, + const char *fmt, va_list ap) +{ + ssize_t alen; + va_list ap2; + char c; + + va_copy(ap2, ap); + alen = vsnprintf(&c, 1, fmt, ap2); + va_end(ap2); + + if (alen <= 0) { + /* Either the vsnprintf failed or the format resulted in + * no characters being formatted. In the former case, we + * ought to return NULL, in the latter we ought to return + * the original string. Most current callers of this + * function expect it to never return NULL. + */ + return s; + } + + s = talloc_realloc(NULL, s, char, slen + alen + 1); + if (!s) return NULL; + + va_copy(ap2, ap); + vsnprintf(s + slen, alen + 1, fmt, ap2); + va_end(ap2); + + _talloc_set_name_const(s, s); + return s; +} + +/** + * Realloc @p s to append the formatted result of @p fmt and @p ap, + * and return @p s, which may have moved. Good for gradually + * accumulating output into a string buffer. Appends at the end + * of the string. + **/ +char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) +{ + if (unlikely(!s)) { + return talloc_vasprintf(NULL, fmt, ap); + } + + return __talloc_vaslenprintf_append(s, strlen(s), fmt, ap); +} + +/** + * Realloc @p s to append the formatted result of @p fmt and @p ap, + * and return @p s, which may have moved. Always appends at the + * end of the talloc'ed buffer, not the end of the string. + **/ +char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) +{ + size_t slen; + + if (unlikely(!s)) { + return talloc_vasprintf(NULL, fmt, ap); + } + + slen = talloc_get_size(s); + if (likely(slen > 0)) { + slen--; + } + + return __talloc_vaslenprintf_append(s, slen, fmt, ap); +} + +/* + Realloc @p s to append the formatted result of @p fmt and return @p + s, which may have moved. Good for gradually accumulating output + into a string buffer. + */ +char *talloc_asprintf_append(char *s, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + s = talloc_vasprintf_append(s, fmt, ap); + va_end(ap); + return s; +} + +/* + Realloc @p s to append the formatted result of @p fmt and return @p + s, which may have moved. Good for gradually accumulating output + into a buffer. + */ +char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + s = talloc_vasprintf_append_buffer(s, fmt, ap); + va_end(ap); + return s; +} + +/* + alloc an array, checking for integer overflow in the array size +*/ +void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name) +{ + if (count >= MAX_TALLOC_SIZE/el_size) { + return NULL; + } + return _talloc_named_const(ctx, el_size * count, name); +} + +/* + alloc an zero array, checking for integer overflow in the array size +*/ +void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name) +{ + if (count >= MAX_TALLOC_SIZE/el_size) { + return NULL; + } + return _talloc_zero(ctx, el_size * count, name); +} + +/* + realloc an array, checking for integer overflow in the array size +*/ +void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name) +{ + if (count >= MAX_TALLOC_SIZE/el_size) { + return NULL; + } + return _talloc_realloc(ctx, ptr, el_size * count, name); +} + +/* + a function version of talloc_realloc(), so it can be passed as a function pointer + to libraries that want a realloc function (a realloc function encapsulates + all the basic capabilities of an allocation library, which is why this is useful) +*/ +void *talloc_realloc_fn(const void *context, void *ptr, size_t size) +{ + return _talloc_realloc(context, ptr, size, NULL); +} + + +static int talloc_autofree_destructor(void *ptr) +{ + autofree_context = NULL; + return 0; +} + +static void talloc_autofree(void) +{ + talloc_free(autofree_context); +} + +/* + return a context which will be auto-freed on exit + this is useful for reducing the noise in leak reports +*/ +void *talloc_autofree_context(void) +{ + if (autofree_context == NULL) { + autofree_context = _talloc_named_const(NULL, 0, "autofree_context"); + talloc_set_destructor(autofree_context, talloc_autofree_destructor); + atexit(talloc_autofree); + } + return autofree_context; +} + +size_t talloc_get_size(const void *context) +{ + struct talloc_chunk *tc; + + if (context == NULL) { + context = null_context; + } + if (context == NULL) { + return 0; + } + + tc = talloc_chunk_from_ptr(context); + + return tc->size; +} + +/* + find a parent of this context that has the given name, if any +*/ +void *talloc_find_parent_byname(const void *context, const char *name) +{ + struct talloc_chunk *tc; + + if (context == NULL) { + return NULL; + } + + tc = talloc_chunk_from_ptr(context); + while (tc) { + if (tc->name && strcmp(tc->name, name) == 0) { + return TC_PTR_FROM_CHUNK(tc); + } + while (tc && tc->prev) tc = tc->prev; + if (tc) { + tc = tc->parent; + } + } + return NULL; +} + +/* + show the parentage of a context +*/ +void talloc_show_parents(const void *context, FILE *file) +{ + struct talloc_chunk *tc; + + if (context == NULL) { + fprintf(file, "talloc no parents for NULL\n"); + return; + } + + tc = talloc_chunk_from_ptr(context); + fprintf(file, "talloc parents of '%s'\n", talloc_get_name(context)); + while (tc) { + fprintf(file, "\t'%s'\n", talloc_get_name(TC_PTR_FROM_CHUNK(tc))); + while (tc && tc->prev) tc = tc->prev; + if (tc) { + tc = tc->parent; + } + } + fflush(file); +} + +/* + return 1 if ptr is a parent of context +*/ +int talloc_is_parent(const void *context, const void *ptr) +{ + struct talloc_chunk *tc; + + if (context == NULL) { + return 0; + } + + tc = talloc_chunk_from_ptr(context); + while (tc) { + if (TC_PTR_FROM_CHUNK(tc) == ptr) return 1; + while (tc && tc->prev) tc = tc->prev; + if (tc) { + tc = tc->parent; + } + } + return 0; +} diff --git a/src/talloc/talloc.h b/src/talloc/talloc.h new file mode 100644 index 00000000000..f549a17fba2 --- /dev/null +++ b/src/talloc/talloc.h @@ -0,0 +1,202 @@ +#ifndef _TALLOC_H_ +#define _TALLOC_H_ +/* + Unix SMB/CIFS implementation. + Samba temporary memory allocation functions + + Copyright (C) Andrew Tridgell 2004-2005 + Copyright (C) Stefan Metzmacher 2006 + + ** NOTE! The following LGPL license applies to the talloc + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see . +*/ + +#include +#include +#include + +#define TALLOC_VERSION_MAJOR 2 +#define TALLOC_VERSION_MINOR 0 + +int talloc_version_major(void); +int talloc_version_minor(void); + +/* this is only needed for compatibility with the old talloc */ +typedef void TALLOC_CTX; + +/* + this uses a little trick to allow __LINE__ to be stringified +*/ +#ifndef __location__ +#define __TALLOC_STRING_LINE1__(s) #s +#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s) +#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__) +#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__ +#endif + +#ifndef TALLOC_DEPRECATED +#define TALLOC_DEPRECATED 0 +#endif + +#ifndef PRINTF_ATTRIBUTE +#if (__GNUC__ >= 3) +/** Use gcc attribute to check printf fns. a1 is the 1-based index of + * the parameter containing the format, and a2 the index of the first + * argument. Note that some gcc 2.x versions don't handle this + * properly **/ +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) +#else +#define PRINTF_ATTRIBUTE(a1, a2) +#endif +#endif + +/* try to make talloc_set_destructor() and talloc_steal() type safe, + if we have a recent gcc */ +#if (__GNUC__ >= 3) +#define _TALLOC_TYPEOF(ptr) __typeof__(ptr) +#define talloc_set_destructor(ptr, function) \ + do { \ + int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ + _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ + } while(0) +/* this extremely strange macro is to avoid some braindamaged warning + stupidity in gcc 4.1.x */ +#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal_loc((ctx),(ptr), __location__); __talloc_steal_ret; }) +#else +#define talloc_set_destructor(ptr, function) \ + _talloc_set_destructor((ptr), (int (*)(void *))(function)) +#define _TALLOC_TYPEOF(ptr) void * +#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal_loc((ctx),(ptr), __location__) +#endif + +#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference_loc((ctx),(ptr), __location__) +#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr)) + +/* useful macros for creating type checked pointers */ +#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) +#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) + +#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) + +#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) +#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) + +#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) +#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) +#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) +#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) +#define talloc_array_length(ctx) (talloc_get_size(ctx)/sizeof(*ctx)) + +#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) +#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) + +#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) + +#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) +#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) +#define talloc_get_type_abort(ptr, type) (type *)_talloc_get_type_abort(ptr, #type, __location__) + +#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) +#define talloc_free(ctx) _talloc_free(ctx, __location__) + + +#if TALLOC_DEPRECATED +#define talloc_zero_p(ctx, type) talloc_zero(ctx, type) +#define talloc_p(ctx, type) talloc(ctx, type) +#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) +#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) +#define talloc_destroy(ctx) talloc_free(ctx) +#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a)) +#endif + +#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0) + +/* The following definitions come from talloc.c */ +void *_talloc(const void *context, size_t size); +void *talloc_pool(const void *context, size_t size); +void _talloc_set_destructor(const void *ptr, int (*_destructor)(void *)); +int talloc_increase_ref_count(const void *ptr); +size_t talloc_reference_count(const void *ptr); +void *_talloc_reference_loc(const void *context, const void *ptr, const char *location); +int talloc_unlink(const void *context, void *ptr); +const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +void talloc_set_name_const(const void *ptr, const char *name); +void *talloc_named(const void *context, size_t size, + const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); +void *talloc_named_const(const void *context, size_t size, const char *name); +const char *talloc_get_name(const void *ptr); +void *talloc_check_name(const void *ptr, const char *name); +void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location); +void *talloc_parent(const void *ptr); +const char *talloc_parent_name(const void *ptr); +void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); +int _talloc_free(void *ptr, const char *location); +void talloc_free_children(void *ptr); +void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); +void *_talloc_steal_loc(const void *new_ctx, const void *ptr, const char *location); +void *talloc_reparent(const void *old_parent, const void *new_parent, const void *ptr); +void *_talloc_move(const void *new_ctx, const void *pptr); +size_t talloc_total_size(const void *ptr); +size_t talloc_total_blocks(const void *ptr); +void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, + void (*callback)(const void *ptr, + int depth, int max_depth, + int is_ref, + void *private_data), + void *private_data); +void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); +void talloc_report_full(const void *ptr, FILE *f); +void talloc_report(const void *ptr, FILE *f); +void talloc_enable_null_tracking(void); +void talloc_enable_null_tracking_no_autofree(void); +void talloc_disable_null_tracking(void); +void talloc_enable_leak_report(void); +void talloc_enable_leak_report_full(void); +void *_talloc_zero(const void *ctx, size_t size, const char *name); +void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); +void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); +void *talloc_realloc_fn(const void *context, void *ptr, size_t size); +void *talloc_autofree_context(void); +size_t talloc_get_size(const void *ctx); +void *talloc_find_parent_byname(const void *ctx, const char *name); +void talloc_show_parents(const void *context, FILE *file); +int talloc_is_parent(const void *context, const void *ptr); + +char *talloc_strdup(const void *t, const char *p); +char *talloc_strdup_append(char *s, const char *a); +char *talloc_strdup_append_buffer(char *s, const char *a); + +char *talloc_strndup(const void *t, const char *p, size_t n); +char *talloc_strndup_append(char *s, const char *a, size_t n); +char *talloc_strndup_append_buffer(char *s, const char *a, size_t n); + +char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); + +char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); + +void talloc_set_abort_fn(void (*abort_fn)(const char *reason)); +void talloc_set_log_fn(void (*log_fn)(const char *message)); +void talloc_set_log_stderr(void); + +#endif diff --git a/src/talloc/talloc_guide.txt b/src/talloc/talloc_guide.txt new file mode 100644 index 00000000000..01de806662d --- /dev/null +++ b/src/talloc/talloc_guide.txt @@ -0,0 +1,757 @@ +Using talloc in Samba4 +====================== + +.. contents:: + +Andrew Tridgell +August 2009 + +The most current version of this document is available at + http://samba.org/ftp/unpacked/talloc/talloc_guide.txt + +If you are used to the "old" talloc from Samba3 before 3.0.20 then please read +this carefully, as talloc has changed a lot. With 3.0.20 (or 3.0.14?) the +Samba4 talloc has been ported back to Samba3, so this guide applies to both. + +The new talloc is a hierarchical, reference counted memory pool system +with destructors. Quite a mouthful really, but not too bad once you +get used to it. + +Perhaps the biggest change from Samba3 is that there is no distinction +between a "talloc context" and a "talloc pointer". Any pointer +returned from talloc() is itself a valid talloc context. This means +you can do this:: + + struct foo *X = talloc(mem_ctx, struct foo); + X->name = talloc_strdup(X, "foo"); + +and the pointer X->name would be a "child" of the talloc context "X" +which is itself a child of mem_ctx. So if you do talloc_free(mem_ctx) +then it is all destroyed, whereas if you do talloc_free(X) then just X +and X->name are destroyed, and if you do talloc_free(X->name) then +just the name element of X is destroyed. + +If you think about this, then what this effectively gives you is an +n-ary tree, where you can free any part of the tree with +talloc_free(). + +If you find this confusing, then I suggest you run the testsuite to +watch talloc in action. You may also like to add your own tests to +testsuite.c to clarify how some particular situation is handled. + + +Performance +----------- + +All the additional features of talloc() over malloc() do come at a +price. We have a simple performance test in Samba4 that measures +talloc() versus malloc() performance, and it seems that talloc() is +about 4% slower than malloc() on my x86 Debian Linux box. For Samba, +the great reduction in code complexity that we get by using talloc +makes this worthwhile, especially as the total overhead of +talloc/malloc in Samba is already quite small. + + +talloc API +---------- + +The following is a complete guide to the talloc API. Read it all at +least twice. + +Multi-threading +--------------- + +talloc itself does not deal with threads. It is thread-safe (assuming +the underlying "malloc" is), as long as each thread uses different +memory contexts. +If two threads uses the same context then they need to synchronize in +order to be safe. In particular: +- when using talloc_enable_leak_report(), giving directly NULL as a +parent context implicitly refers to a hidden "null context" global +variable, so this should not be used in a multi-threaded environment +without proper synchronization ; +- the context returned by talloc_autofree_context() is also global so +shouldn't be used by several threads simultaneously without +synchronization. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +(type *)talloc(const void *context, type); + +The talloc() macro is the core of the talloc library. It takes a +memory context and a type, and returns a pointer to a new area of +memory of the given type. + +The returned pointer is itself a talloc context, so you can use it as +the context argument to more calls to talloc if you wish. + +The returned pointer is a "child" of the supplied context. This means +that if you talloc_free() the context then the new child disappears as +well. Alternatively you can free just the child. + +The context argument to talloc() can be NULL, in which case a new top +level context is created. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_size(const void *context, size_t size); + +The function talloc_size() should be used when you don't have a +convenient type to pass to talloc(). Unlike talloc(), it is not type +safe (as it returns a void *), so you are on your own for type checking. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +(typeof(ptr)) talloc_ptrtype(const void *ctx, ptr); + +The talloc_ptrtype() macro should be used when you have a pointer and +want to allocate memory to point at with this pointer. When compiling +with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_size() +and talloc_get_name() will return the current location in the source file. +and not the type. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +int talloc_free(void *ptr); + +The talloc_free() function frees a piece of talloc memory, and all its +children. You can call talloc_free() on any pointer returned by +talloc(). + +The return value of talloc_free() indicates success or failure, with 0 +returned for success and -1 for failure. The only possible failure +condition is if the pointer had a destructor attached to it and the +destructor returned -1. See talloc_set_destructor() for details on +destructors. + +If this pointer has an additional parent when talloc_free() is called +then the memory is not actually released, but instead the most +recently established parent is destroyed. See talloc_reference() for +details on establishing additional parents. + +For more control on which parent is removed, see talloc_unlink() + +talloc_free() operates recursively on its children. + +From the 2.0 version of talloc, as a special case, talloc_free() is +refused on pointers that have more than one parent, as talloc would +have no way of knowing which parent should be removed. To free a +pointer that has more than one parent please use talloc_unlink(). + +To help you find problems in your code caused by this behaviour, if +you do try and free a pointer with more than one parent then the +talloc logging function will be called to give output like this: + + ERROR: talloc_free with references at some_dir/source/foo.c:123 + reference at some_dir/source/other.c:325 + reference at some_dir/source/third.c:121 + +Please see the documentation for talloc_set_log_fn() and +talloc_set_log_stderr() for more information on talloc logging +functions. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +int talloc_free_children(void *ptr); + +The talloc_free_children() walks along the list of all children of a +talloc context and talloc_free()s only the children, not the context +itself. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_reference(const void *context, const void *ptr); + +The talloc_reference() function makes "context" an additional parent +of "ptr". + +The return value of talloc_reference() is always the original pointer +"ptr", unless talloc ran out of memory in creating the reference in +which case it will return NULL (each additional reference consumes +around 48 bytes of memory on intel x86 platforms). + +If "ptr" is NULL, then the function is a no-op, and simply returns NULL. + +After creating a reference you can free it in one of the following +ways: + + - you can talloc_free() any parent of the original pointer. That + will reduce the number of parents of this pointer by 1, and will + cause this pointer to be freed if it runs out of parents. + + - you can talloc_free() the pointer itself. That will destroy the + most recently established parent to the pointer and leave the + pointer as a child of its current parent. + +For more control on which parent to remove, see talloc_unlink() + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +int talloc_unlink(const void *context, const void *ptr); + +The talloc_unlink() function removes a specific parent from ptr. The +context passed must either be a context used in talloc_reference() +with this pointer, or must be a direct parent of ptr. + +Note that if the parent has already been removed using talloc_free() +then this function will fail and will return -1. Likewise, if "ptr" +is NULL, then the function will make no modifications and return -1. + +Usually you can just use talloc_free() instead of talloc_unlink(), but +sometimes it is useful to have the additional control on which parent +is removed. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_set_destructor(const void *ptr, int (*destructor)(void *)); + +The function talloc_set_destructor() sets the "destructor" for the +pointer "ptr". A destructor is a function that is called when the +memory used by a pointer is about to be released. The destructor +receives the pointer as an argument, and should return 0 for success +and -1 for failure. + +The destructor can do anything it wants to, including freeing other +pieces of memory. A common use for destructors is to clean up +operating system resources (such as open file descriptors) contained +in the structure the destructor is placed on. + +You can only place one destructor on a pointer. If you need more than +one destructor then you can create a zero-length child of the pointer +and place an additional destructor on that. + +To remove a destructor call talloc_set_destructor() with NULL for the +destructor. + +If your destructor attempts to talloc_free() the pointer that it is +the destructor for then talloc_free() will return -1 and the free will +be ignored. This would be a pointless operation anyway, as the +destructor is only called when the memory is just about to go away. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +int talloc_increase_ref_count(const void *ptr); + +The talloc_increase_ref_count(ptr) function is exactly equivalent to: + + talloc_reference(NULL, ptr); + +You can use either syntax, depending on which you think is clearer in +your code. + +It returns 0 on success and -1 on failure. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +size_t talloc_reference_count(const void *ptr); + +Return the number of references to the pointer. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_set_name(const void *ptr, const char *fmt, ...); + +Each talloc pointer has a "name". The name is used principally for +debugging purposes, although it is also possible to set and get the +name on a pointer in as a way of "marking" pointers in your code. + +The main use for names on pointer is for "talloc reports". See +talloc_report() and talloc_report_full() for details. Also see +talloc_enable_leak_report() and talloc_enable_leak_report_full(). + +The talloc_set_name() function allocates memory as a child of the +pointer. It is logically equivalent to: + talloc_set_name_const(ptr, talloc_asprintf(ptr, fmt, ...)); + +Note that multiple calls to talloc_set_name() will allocate more +memory without releasing the name. All of the memory is released when +the ptr is freed using talloc_free(). + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_set_name_const(const void *ptr, const char *name); + +The function talloc_set_name_const() is just like talloc_set_name(), +but it takes a string constant, and is much faster. It is extensively +used by the "auto naming" macros, such as talloc_p(). + +This function does not allocate any memory. It just copies the +supplied pointer into the internal representation of the talloc +ptr. This means you must not pass a name pointer to memory that will +disappear before the ptr is freed with talloc_free(). + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_named(const void *context, size_t size, const char *fmt, ...); + +The talloc_named() function creates a named talloc pointer. It is +equivalent to: + + ptr = talloc_size(context, size); + talloc_set_name(ptr, fmt, ....); + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_named_const(const void *context, size_t size, const char *name); + +This is equivalent to:: + + ptr = talloc_size(context, size); + talloc_set_name_const(ptr, name); + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +const char *talloc_get_name(const void *ptr); + +This returns the current name for the given talloc pointer. See +talloc_set_name() for details. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_init(const char *fmt, ...); + +This function creates a zero length named talloc context as a top +level context. It is equivalent to:: + + talloc_named(NULL, 0, fmt, ...); + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_new(void *ctx); + +This is a utility macro that creates a new memory context hanging +off an exiting context, automatically naming it "talloc_new: __location__" +where __location__ is the source line it is called from. It is +particularly useful for creating a new temporary working context. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +(type *)talloc_realloc(const void *context, void *ptr, type, count); + +The talloc_realloc() macro changes the size of a talloc +pointer. The "count" argument is the number of elements of type "type" +that you want the resulting pointer to hold. + +talloc_realloc() has the following equivalences:: + + talloc_realloc(context, NULL, type, 1) ==> talloc(context, type); + talloc_realloc(context, NULL, type, N) ==> talloc_array(context, type, N); + talloc_realloc(context, ptr, type, 0) ==> talloc_free(ptr); + +The "context" argument is only used if "ptr" is NULL, otherwise it is +ignored. + +talloc_realloc() returns the new pointer, or NULL on failure. The call +will fail either due to a lack of memory, or because the pointer has +more than one parent (see talloc_reference()). + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_realloc_size(const void *context, void *ptr, size_t size); + +the talloc_realloc_size() function is useful when the type is not +known so the typesafe talloc_realloc() cannot be used. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_steal(const void *new_ctx, const void *ptr); + +The talloc_steal() function changes the parent context of a talloc +pointer. It is typically used when the context that the pointer is +currently a child of is going to be freed and you wish to keep the +memory for a longer time. + +The talloc_steal() function returns the pointer that you pass it. It +does not have any failure modes. + +NOTE: It is possible to produce loops in the parent/child relationship +if you are not careful with talloc_steal(). No guarantees are provided +as to your sanity or the safety of your data if you do this. + +talloc_steal (new_ctx, NULL) will return NULL with no sideeffects. + +Note that if you try and call talloc_steal() on a pointer that has +more than one parent then the result is ambiguous. Talloc will choose +to remove the parent that is currently indicated by talloc_parent() +and replace it with the chosen parent. You will also get a message +like this via the talloc logging functions: + + WARNING: talloc_steal with references at some_dir/source/foo.c:123 + reference at some_dir/source/other.c:325 + reference at some_dir/source/third.c:121 + +To unambiguously change the parent of a pointer please see the +function talloc_reparent(). See the talloc_set_log_fn() documentation +for more information on talloc logging. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_reparent(const void *old_parent, const void *new_parent, const void *ptr); + +The talloc_reparent() function changes the parent context of a talloc +pointer. It is typically used when the context that the pointer is +currently a child of is going to be freed and you wish to keep the +memory for a longer time. + +The talloc_reparent() function returns the pointer that you pass it. It +does not have any failure modes. + +The difference between talloc_reparent() and talloc_steal() is that +talloc_reparent() can specify which parent you wish to change. This is +useful when a pointer has multiple parents via references. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_parent(const void *ptr); + +The talloc_parent() function returns the current talloc parent. This +is usually the pointer under which this memory was originally created, +but it may have changed due to a talloc_steal() or talloc_reparent() + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +size_t talloc_total_size(const void *ptr); + +The talloc_total_size() function returns the total size in bytes used +by this pointer and all child pointers. Mostly useful for debugging. + +Passing NULL is allowed, but it will only give a meaningful result if +talloc_enable_leak_report() or talloc_enable_leak_report_full() has +been called. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +size_t talloc_total_blocks(const void *ptr); + +The talloc_total_blocks() function returns the total memory block +count used by this pointer and all child pointers. Mostly useful for +debugging. + +Passing NULL is allowed, but it will only give a meaningful result if +talloc_enable_leak_report() or talloc_enable_leak_report_full() has +been called. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, + void (*callback)(const void *ptr, + int depth, int max_depth, + int is_ref, + void *priv), + void *priv); + +This provides a more flexible reports than talloc_report(). It +will recursively call the callback for the entire tree of memory +referenced by the pointer. References in the tree are passed with +is_ref = 1 and the pointer that is referenced. + +You can pass NULL for the pointer, in which case a report is +printed for the top level memory context, but only if +talloc_enable_leak_report() or talloc_enable_leak_report_full() +has been called. + +The recursion is stopped when depth >= max_depth. +max_depth = -1 means only stop at leaf nodes. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); + +This provides a more flexible reports than talloc_report(). It +will let you specify the depth and max_depth. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_report(const void *ptr, FILE *f); + +The talloc_report() function prints a summary report of all memory +used by ptr. One line of report is printed for each immediate child of +ptr, showing the total memory and number of blocks used by that child. + +You can pass NULL for the pointer, in which case a report is printed +for the top level memory context, but only if +talloc_enable_leak_report() or talloc_enable_leak_report_full() has +been called. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_report_full(const void *ptr, FILE *f); + +This provides a more detailed report than talloc_report(). It will +recursively print the ensire tree of memory referenced by the +pointer. References in the tree are shown by giving the name of the +pointer that is referenced. + +You can pass NULL for the pointer, in which case a report is printed +for the top level memory context, but only if +talloc_enable_leak_report() or talloc_enable_leak_report_full() has +been called. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_enable_leak_report(void); + +This enables calling of talloc_report(NULL, stderr) when the program +exits. In Samba4 this is enabled by using the --leak-report command +line option. + +For it to be useful, this function must be called before any other +talloc function as it establishes a "null context" that acts as the +top of the tree. If you don't call this function first then passing +NULL to talloc_report() or talloc_report_full() won't give you the +full tree printout. + +Here is a typical talloc report: + +talloc report on 'null_context' (total 267 bytes in 15 blocks) + libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks + libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks + iconv(UTF8,CP850) contains 42 bytes in 2 blocks + libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks + iconv(CP850,UTF8) contains 42 bytes in 2 blocks + iconv(UTF8,UTF-16LE) contains 45 bytes in 2 blocks + iconv(UTF-16LE,UTF8) contains 45 bytes in 2 blocks + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_enable_leak_report_full(void); + +This enables calling of talloc_report_full(NULL, stderr) when the +program exits. In Samba4 this is enabled by using the +--leak-report-full command line option. + +For it to be useful, this function must be called before any other +talloc function as it establishes a "null context" that acts as the +top of the tree. If you don't call this function first then passing +NULL to talloc_report() or talloc_report_full() won't give you the +full tree printout. + +Here is a typical full report: + +full talloc report on 'root' (total 18 bytes in 8 blocks) + p1 contains 18 bytes in 7 blocks (ref 0) + r1 contains 13 bytes in 2 blocks (ref 0) + reference to: p2 + p2 contains 1 bytes in 1 blocks (ref 1) + x3 contains 1 bytes in 1 blocks (ref 0) + x2 contains 1 bytes in 1 blocks (ref 0) + x1 contains 1 bytes in 1 blocks (ref 0) + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_enable_null_tracking(void); + +This enables tracking of the NULL memory context without enabling leak +reporting on exit. Useful for when you want to do your own leak +reporting call via talloc_report_null_full(); + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_disable_null_tracking(void); + +This disables tracking of the NULL memory context. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +(type *)talloc_zero(const void *ctx, type); + +The talloc_zero() macro is equivalent to:: + + ptr = talloc(ctx, type); + if (ptr) memset(ptr, 0, sizeof(type)); + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_zero_size(const void *ctx, size_t size) + +The talloc_zero_size() function is useful when you don't have a known type + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_memdup(const void *ctx, const void *p, size_t size); + +The talloc_memdup() function is equivalent to:: + + ptr = talloc_size(ctx, size); + if (ptr) memcpy(ptr, p, size); + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +char *talloc_strdup(const void *ctx, const char *p); + +The talloc_strdup() function is equivalent to:: + + ptr = talloc_size(ctx, strlen(p)+1); + if (ptr) memcpy(ptr, p, strlen(p)+1); + +This functions sets the name of the new pointer to the passed +string. This is equivalent to:: + + talloc_set_name_const(ptr, ptr) + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +char *talloc_strndup(const void *t, const char *p, size_t n); + +The talloc_strndup() function is the talloc equivalent of the C +library function strndup() + +This functions sets the name of the new pointer to the passed +string. This is equivalent to: + talloc_set_name_const(ptr, ptr) + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +char *talloc_append_string(const void *t, char *orig, const char *append); + +The talloc_append_string() function appends the given formatted +string to the given string. + +This function sets the name of the new pointer to the new +string. This is equivalent to:: + + talloc_set_name_const(ptr, ptr) + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +char *talloc_vasprintf(const void *t, const char *fmt, va_list ap); + +The talloc_vasprintf() function is the talloc equivalent of the C +library function vasprintf() + +This functions sets the name of the new pointer to the new +string. This is equivalent to:: + + talloc_set_name_const(ptr, ptr) + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +char *talloc_asprintf(const void *t, const char *fmt, ...); + +The talloc_asprintf() function is the talloc equivalent of the C +library function asprintf() + +This functions sets the name of the new pointer to the new +string. This is equivalent to:: + + talloc_set_name_const(ptr, ptr) + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +char *talloc_asprintf_append(char *s, const char *fmt, ...); + +The talloc_asprintf_append() function appends the given formatted +string to the given string. +Use this varient when the string in the current talloc buffer may +have been truncated in length. + +This functions sets the name of the new pointer to the new +string. This is equivalent to:: + + talloc_set_name_const(ptr, ptr) + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...); + +The talloc_asprintf_append() function appends the given formatted +string to the end of the currently allocated talloc buffer. +Use this varient when the string in the current talloc buffer has +not been changed. + +This functions sets the name of the new pointer to the new +string. This is equivalent to:: + + talloc_set_name_const(ptr, ptr) + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +((type *)talloc_array(const void *ctx, type, uint_t count); + +The talloc_array() macro is equivalent to:: + + (type *)talloc_size(ctx, sizeof(type) * count); + +except that it provides integer overflow protection for the multiply, +returning NULL if the multiply overflows. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_array_size(const void *ctx, size_t size, uint_t count); + +The talloc_array_size() function is useful when the type is not +known. It operates in the same way as talloc_array(), but takes a size +instead of a type. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +(typeof(ptr)) talloc_array_ptrtype(const void *ctx, ptr, uint_t count); + +The talloc_ptrtype() macro should be used when you have a pointer to an array +and want to allocate memory of an array to point at with this pointer. When compiling +with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_array_size() +and talloc_get_name() will return the current location in the source file. +and not the type. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_realloc_fn(const void *ctx, void *ptr, size_t size); + +This is a non-macro version of talloc_realloc(), which is useful +as libraries sometimes want a ralloc function pointer. A realloc() +implementation encapsulates the functionality of malloc(), free() and +realloc() in one call, which is why it is useful to be able to pass +around a single function pointer. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_autofree_context(void); + +This is a handy utility function that returns a talloc context +which will be automatically freed on program exit. This can be used +to reduce the noise in memory leak reports. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_check_name(const void *ptr, const char *name); + +This function checks if a pointer has the specified name. If it does +then the pointer is returned. It it doesn't then NULL is returned. + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +(type *)talloc_get_type(const void *ptr, type); + +This macro allows you to do type checking on talloc pointers. It is +particularly useful for void* private pointers. It is equivalent to +this:: + + (type *)talloc_check_name(ptr, #type) + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +talloc_set_type(const void *ptr, type); + +This macro allows you to force the name of a pointer to be a +particular type. This can be used in conjunction with +talloc_get_type() to do type checking on void* pointers. + +It is equivalent to this:: + + talloc_set_name_const(ptr, #type) + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +talloc_get_size(const void *ctx); + +This function lets you know the amount of memory alloced so far by +this context. It does NOT account for subcontext memory. +This can be used to calculate the size of an array. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void *talloc_find_parent_byname(const void *ctx, const char *name); + +Find a parent memory context of the current context that has the given +name. This can be very useful in complex programs where it may be +difficult to pass all information down to the level you need, but you +know the structure you want is a parent of another context. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +(type *)talloc_find_parent_bytype(ctx, type); + +Like talloc_find_parent_byname() but takes a type, making it typesafe. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_set_log_fn(void (*log_fn)(const char *message)); + +This function sets a logging function that talloc will use for +warnings and errors. By default talloc will not print any warnings or +errors. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_set_log_stderr(void) + +This sets the talloc log function to write log messages to stderr -- cgit v1.2.3 From 1ca2945f84e9cb298a7d4ad4ec9a0578097c146d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 13 Aug 2010 13:53:04 +0100 Subject: talloc: Make it compile with MSVC, MinGW, and Xcode/gcc4.0. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on Aras Pranckevičius' patch. --- src/SConscript | 3 +++ src/talloc/SConscript | 20 ++++++++++++++++ src/talloc/talloc.c | 46 ++++++++++++++++++++++++++++++++++--- src/talloc/talloc.def | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 src/talloc/SConscript create mode 100644 src/talloc/talloc.def diff --git a/src/SConscript b/src/SConscript index 2b46186f986..c3e34be6f76 100644 --- a/src/SConscript +++ b/src/SConscript @@ -5,6 +5,9 @@ if 'egl' in env['statetrackers']: SConscript('egl/main/SConscript') if 'mesa' in env['statetrackers']: + if platform == 'windows': + SConscript('talloc/SConscript') + SConscript('glsl/SConscript') SConscript('mapi/glapi/SConscript') SConscript('mesa/SConscript') diff --git a/src/talloc/SConscript b/src/talloc/SConscript new file mode 100644 index 00000000000..a4861a932e5 --- /dev/null +++ b/src/talloc/SConscript @@ -0,0 +1,20 @@ +Import('*') + +if env['platform'] != 'windows': + Return() + +env = env.Clone() + +talloc = env.SharedLibrary( + target = 'talloc', + source = ['talloc.c', 'talloc.def'], +) + +env.InstallSharedLibrary(talloc) + +if env['platform'] != 'windows': + talloc = env.FindIxes(talloc, 'LIBPREFIX', 'LIBSUFFIX') +else: + talloc = env.FindIxes(talloc, 'SHLIBPREFIX', 'SHLIBSUFFIX') + +Export('talloc') diff --git a/src/talloc/talloc.c b/src/talloc/talloc.c index 7beda4b0f58..cc01346a7f0 100644 --- a/src/talloc/talloc.c +++ b/src/talloc/talloc.c @@ -30,8 +30,38 @@ inspired by http://swapped.cc/halloc/ */ -#include "replace.h" #include "talloc.h" +#include + +#define TALLOC_MIN(a,b) ((a)<(b)?(a):(b)) + +/* Visual C++ 2008 compatibility */ +#if defined(_MSC_VER) && !defined(_cplusplus) +typedef size_t ssize_t; +#define inline __inline +#endif + +/* Xcode/gcc4.0 compatibility */ +#if defined(__APPLE__) || defined(__MINGW32__) +static size_t strnlen (const char* s, size_t n) +{ + size_t i; + for (i = 0; i < n; ++i) + { + if (s[i] == '\0') + break; + } + return i; +} +#endif + +/* Visual C++ 2008 & Xcode/gcc4.0 compatibility */ +#if !defined(_cplusplus) && (defined(WIN32) || defined(__APPLE__)) +typedef int bool; +#define false 0 +#define true 1 +#endif + #ifdef TALLOC_BUILD_VERSION_MAJOR #if (TALLOC_VERSION_MAJOR != TALLOC_BUILD_VERSION_MAJOR) @@ -1200,7 +1230,7 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n } if (new_ptr) { - memcpy(new_ptr, tc, MIN(tc->size,size) + TC_HDR_SIZE); + memcpy(new_ptr, tc, TALLOC_MIN(tc->size,size) + TC_HDR_SIZE); } } else { @@ -1686,7 +1716,7 @@ char *talloc_strndup_append_buffer(char *s, const char *a, size_t n) return __talloc_strlendup_append(s, slen, a, strnlen(a, n)); } -#ifndef HAVE_VA_COPY +#ifndef va_copy #ifdef HAVE___VA_COPY #define va_copy(dest, src) __va_copy(dest, src) #else @@ -1703,7 +1733,12 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) /* this call looks strange, but it makes it work on older solaris boxes */ va_copy(ap2, ap); + #ifdef _MSC_VER + /* MSVC runtime needs to use _vcsprintf to return buffer size; vsnprintf would return -1 */ + len = _vscprintf(fmt, ap2); + #else len = vsnprintf(&c, 1, fmt, ap2); + #endif va_end(ap2); if (unlikely(len < 0)) { return NULL; @@ -1748,7 +1783,12 @@ static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, char c; va_copy(ap2, ap); + #ifdef _MSC_VER + /* MSVC runtime needs to use _vcsprintf to return buffer size; vsnprintf would return -1 */ + alen = _vscprintf(fmt, ap2); + #else alen = vsnprintf(&c, 1, fmt, ap2); + #endif va_end(ap2); if (alen <= 0) { diff --git a/src/talloc/talloc.def b/src/talloc/talloc.def new file mode 100644 index 00000000000..13d7a159cef --- /dev/null +++ b/src/talloc/talloc.def @@ -0,0 +1,63 @@ +EXPORTS + _talloc + _talloc_array + _talloc_free + _talloc_get_type_abort + _talloc_memdup + _talloc_move + _talloc_realloc + _talloc_realloc_array + _talloc_reference_loc + _talloc_set_destructor + _talloc_steal_loc + _talloc_zero + _talloc_zero_array + talloc_asprintf + talloc_asprintf_append + talloc_asprintf_append_buffer + talloc_autofree_context + talloc_check_name + talloc_disable_null_tracking + talloc_enable_leak_report + talloc_enable_leak_report_full + talloc_enable_null_tracking + talloc_enable_null_tracking_no_autofree + talloc_find_parent_byname + talloc_free_children + talloc_get_name + talloc_get_size + talloc_increase_ref_count + talloc_init + talloc_is_parent + talloc_named + talloc_named_const + talloc_parent + talloc_parent_name + talloc_pool + talloc_realloc_fn + talloc_reference_count + talloc_reparent + talloc_report + talloc_report_depth_cb + talloc_report_depth_file + talloc_report_full + talloc_set_abort_fn + talloc_set_log_fn + talloc_set_log_stderr + talloc_set_name + talloc_set_name_const + talloc_show_parents + talloc_strdup + talloc_strdup_append + talloc_strdup_append_buffer + talloc_strndup + talloc_strndup_append + talloc_strndup_append_buffer + talloc_total_blocks + talloc_total_size + talloc_unlink + talloc_vasprintf + talloc_vasprintf_append + talloc_vasprintf_append_buffer + talloc_version_major + talloc_version_minor -- cgit v1.2.3 From 3a3cdb909da5b02edf921fcb5a009dfc2868d23d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 13 Aug 2010 13:55:34 +0100 Subject: scons: Build the new glsl2 code. --- SConstruct | 22 ------ src/gallium/targets/libgl-gdi/SConscript | 1 + src/glsl/SConscript | 112 ++++++++++++++++++++----------- src/mesa/SConscript | 8 ++- 4 files changed, 78 insertions(+), 65 deletions(-) diff --git a/SConstruct b/SConstruct index a187d8d1b6f..bb03e5055ea 100644 --- a/SConstruct +++ b/SConstruct @@ -206,28 +206,6 @@ Export('env') # TODO: Build several variants at the same time? # http://www.scons.org/wiki/SimultaneousVariantBuilds -if env['platform'] != common.default_platform: - # GLSL code has to be built twice -- one for the host OS, another for the target OS... - - host_env = Environment( - # options are ignored - # default tool is used - tools = ['default', 'custom'], - toolpath = ['#scons'], - ENV = os.environ, - ) - - host_env['platform'] = common.default_platform - host_env['machine'] = common.default_machine - host_env['debug'] = env['debug'] - - SConscript( - 'src/glsl/SConscript', - variant_dir = os.path.join(env['build'], 'host'), - duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html - exports={'env':host_env}, - ) - SConscript( 'src/SConscript', variant_dir = env['build'], diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 144084f74f8..12fe403f62f 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -17,6 +17,7 @@ if env['platform'] == 'windows': 'user32', 'kernel32', 'ws2_32', + talloc, ]) sources = [] diff --git a/src/glsl/SConscript b/src/glsl/SConscript index 8e18626c404..90759275ca7 100644 --- a/src/glsl/SConscript +++ b/src/glsl/SConscript @@ -4,23 +4,69 @@ Import('*') env = env.Clone() +env.Prepend(CPPPATH = [ + '#src/mapi', + '#src/mesa', +]) + +if env['platform'] == 'windows': + env.Prepend(CPPPATH = ['#src/talloc']) + sources = [ - 'pp/sl_pp_context.c', - 'pp/sl_pp_define.c', - 'pp/sl_pp_dict.c', - 'pp/sl_pp_error.c', - 'pp/sl_pp_expression.c', - 'pp/sl_pp_extension.c', - 'pp/sl_pp_if.c', - 'pp/sl_pp_line.c', - 'pp/sl_pp_macro.c', - 'pp/sl_pp_pragma.c', - 'pp/sl_pp_process.c', - 'pp/sl_pp_purify.c', - 'pp/sl_pp_token.c', - 'pp/sl_pp_token_util.c', - 'pp/sl_pp_version.c', - 'cl/sl_cl_parse.c', + 'glcpp/glcpp-lex.c', + 'glcpp/glcpp-parse.c', + 'glcpp/pp.c', + 'ast_expr.cpp', + 'ast_function.cpp', + 'ast_to_hir.cpp', + 'ast_type.cpp', + 'builtin_function.cpp', + 'glsl_lexer.cpp', + 'glsl_parser.cpp', + 'glsl_parser_extras.cpp', + 'glsl_types.cpp', + 'hir_field_selection.cpp', + 'ir_algebraic.cpp', + 'ir_basic_block.cpp', + 'ir_clone.cpp', + 'ir_constant_expression.cpp', + 'ir_constant_folding.cpp', + 'ir_constant_propagation.cpp', + 'ir_constant_variable.cpp', + 'ir_copy_propagation.cpp', + 'ir.cpp', + 'ir_dead_code.cpp', + 'ir_dead_code_local.cpp', + 'ir_dead_functions.cpp', + 'ir_div_to_mul_rcp.cpp', + 'ir_explog_to_explog2.cpp', + 'ir_expression_flattening.cpp', + 'ir_function_can_inline.cpp', + 'ir_function.cpp', + 'ir_function_inlining.cpp', + 'ir_hierarchical_visitor.cpp', + 'ir_hv_accept.cpp', + 'ir_if_return.cpp', + 'ir_if_simplification.cpp', + 'ir_if_to_cond_assign.cpp', + 'ir_import_prototypes.cpp', + 'ir_mat_op_to_vec.cpp', + 'ir_mod_to_fract.cpp', + 'ir_print_visitor.cpp', + 'ir_reader.cpp', + 'ir_set_program_inouts.cpp', + 'ir_structure_splitting.cpp', + 'ir_sub_to_add_neg.cpp', + 'ir_swizzle_swizzle.cpp', + 'ir_tree_grafting.cpp', + 'ir_validate.cpp', + 'ir_variable.cpp', + 'ir_variable_refcount.cpp', + 'ir_vec_index_to_cond_assign.cpp', + 'ir_vec_index_to_swizzle.cpp', + 'linker.cpp', + 'link_functions.cpp', + 's_expression.cpp', ] glsl = env.ConvenienceLibrary( @@ -30,6 +76,9 @@ glsl = env.ConvenienceLibrary( Export('glsl') +# FIXME: We can't build the programs because there's a cyclic dependency between tis directory and src/mesa +Return() + env = env.Clone() if env['platform'] == 'windows': @@ -37,33 +86,16 @@ if env['platform'] == 'windows': 'user32', ]) -env.Prepend(LIBS = [glsl]) - -env.Program( - target = 'purify', - source = ['apps/purify.c'], -) +env.Prepend(LIBS = [glsl, talloc]) env.Program( - target = 'tokenise', - source = ['apps/tokenise.c'], + target = 'glsl2', + source = [ + 'main.cpp', + ] ) env.Program( - target = 'version', - source = ['apps/version.c'], + target = 'glcpp', + source = ['glcpp/glcpp.c'], ) - -env.Program( - target = 'process', - source = ['apps/process.c'], -) - -glsl_compile = env.Program( - target = 'compile', - source = ['apps/compile.c'], -) - -if env['platform'] == common.default_platform: - # Only export the GLSL compiler when building for the host platform - Export('glsl_compile') diff --git a/src/mesa/SConscript b/src/mesa/SConscript index 79e9b4553b7..5200a244f26 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -10,6 +10,7 @@ if env['platform'] != 'winddk': env.Append(CPPPATH = [ '#/src/mapi', + '#/src/glsl', '#/src/mesa', ]) @@ -19,6 +20,7 @@ if env['platform'] != 'winddk': 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers 'WIN32_THREADS', # use Win32 thread API ]) + env.Prepend(CPPPATH = ['#src/talloc']) # # Source files @@ -200,6 +202,7 @@ if env['platform'] != 'winddk': program_sources = [ 'program/arbprogparse.c', 'program/hash_table.c', + 'program/ir_to_mesa.cpp', 'program/lex.yy.c', 'program/nvfragparse.c', 'program/nvvertparse.c', @@ -248,8 +251,7 @@ if env['platform'] != 'winddk': program_sources + vbo_sources + vf_sources + - statetracker_sources + - slang_sources + statetracker_sources ) # @@ -327,7 +329,7 @@ if env['platform'] != 'winddk': # build dir) to the include path env.Append(CPPPATH = [matypes[0].dir]) - SConscript('slang/library/SConscript') + #SConscript('slang/library/SConscript') # # Libraries -- cgit v1.2.3 From 5b9f3db71996a1296c7da8501dd3b159bfe8c2b2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 09:26:01 -0700 Subject: glsl2: Eliminate tokens for square matrix short names MAT2 and MAT2X2, for example, are treated identically by the parser. The language version based error checking (becuase mat2x2 is not available in GLSL 1.10) is already done in the lexer. --- src/glsl/glsl_lexer.lpp | 6 +++--- src/glsl/glsl_parser.ypp | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index 7ef537b2487..a96078e481a 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -151,9 +151,9 @@ ivec4 return IVEC4; vec2 return VEC2; vec3 return VEC3; vec4 return VEC4; -mat2 return MAT2; -mat3 return MAT3; -mat4 return MAT4; +mat2 return MAT2X2; +mat3 return MAT3X3; +mat4 return MAT4X4; mat2x2 TOKEN_OR_IDENTIFIER(120, MAT2X2); mat2x3 TOKEN_OR_IDENTIFIER(120, MAT2X3); mat2x4 TOKEN_OR_IDENTIFIER(120, MAT2X4); diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 7c5dc017d89..30c43d24749 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -80,7 +80,7 @@ %token ATTRIBUTE CONST_TOK BOOL FLOAT INT UINT %token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT %token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 -%token MAT2 MAT3 MAT4 CENTROID IN OUT INOUT UNIFORM VARYING +%token CENTROID IN OUT INOUT UNIFORM VARYING %token NOPERSPECTIVE FLAT SMOOTH %token MAT2X2 MAT2X3 MAT2X4 %token MAT3X2 MAT3X3 MAT3X4 @@ -1101,9 +1101,6 @@ basic_type_specifier_nonarray: | UVEC2 { $$ = ast_uvec2; } | UVEC3 { $$ = ast_uvec3; } | UVEC4 { $$ = ast_uvec4; } - | MAT2 { $$ = ast_mat2; } - | MAT3 { $$ = ast_mat3; } - | MAT4 { $$ = ast_mat4; } | MAT2X2 { $$ = ast_mat2; } | MAT2X3 { $$ = ast_mat2x3; } | MAT2X4 { $$ = ast_mat2x4; } -- cgit v1.2.3 From 5c77efc0b28dceaa2420b900822f475422a378d1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 09:23:54 -0700 Subject: glsl2: Avoid token name collisions with names used by Windows header files --- src/glsl/glsl_lexer.lpp | 26 +++++++++++++------------- src/glsl/glsl_parser.ypp | 36 ++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index a96078e481a..3128cdd3a78 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -128,9 +128,9 @@ HASH ^{SPC}#{SPC} attribute return ATTRIBUTE; const return CONST_TOK; -bool return BOOL; -float return FLOAT; -int return INT; +bool return BOOL_TOK; +float return FLOAT_TOK; +int return INT_TOK; break return BREAK; continue return CONTINUE; @@ -164,9 +164,9 @@ mat4x2 TOKEN_OR_IDENTIFIER(120, MAT4X2); mat4x3 TOKEN_OR_IDENTIFIER(120, MAT4X3); mat4x4 TOKEN_OR_IDENTIFIER(120, MAT4X4); -in return IN; -out return OUT; -inout return INOUT; +in return IN_TOK; +out return OUT_TOK; +inout return INOUT_TOK; uniform return UNIFORM; varying return VARYING; centroid TOKEN_OR_IDENTIFIER(120, CENTROID); @@ -184,7 +184,7 @@ sampler1DShadow return SAMPLER1DSHADOW; sampler2DShadow return SAMPLER2DSHADOW; struct return STRUCT; -void return VOID; +void return VOID_TOK; layout { if ((yyextra->language_version >= 140) @@ -269,7 +269,7 @@ enum RESERVED_WORD(999, ENUM); typedef RESERVED_WORD(999, TYPEDEF); template RESERVED_WORD(999, TEMPLATE); this RESERVED_WORD(999, THIS); -packed RESERVED_WORD(999, PACKED); +packed RESERVED_WORD(999, PACKED_TOK); goto RESERVED_WORD(999, GOTO); switch RESERVED_WORD(130, SWITCH); default RESERVED_WORD(130, DEFAULT); @@ -281,13 +281,13 @@ static RESERVED_WORD(999, STATIC); extern RESERVED_WORD(999, EXTERN); external RESERVED_WORD(999, EXTERNAL); interface RESERVED_WORD(999, INTERFACE); -long RESERVED_WORD(999, LONG); -short RESERVED_WORD(999, SHORT); -double RESERVED_WORD(999, DOUBLE); +long RESERVED_WORD(999, LONG_TOK); +short RESERVED_WORD(999, SHORT_TOK); +double RESERVED_WORD(999, DOUBLE_TOK); half RESERVED_WORD(999, HALF); -fixed RESERVED_WORD(999, FIXED); +fixed RESERVED_WORD(999, FIXED_TOK); unsigned RESERVED_WORD(999, UNSIGNED); -input RESERVED_WORD(999, INPUT); +input RESERVED_WORD(999, INPUT_TOK); output RESERVED_WORD(999, OUTPUT); hvec2 RESERVED_WORD(999, HVEC2); hvec3 RESERVED_WORD(999, HVEC3); diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 30c43d24749..1ee6da1d23a 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -77,10 +77,10 @@ } for_rest_statement; } -%token ATTRIBUTE CONST_TOK BOOL FLOAT INT UINT +%token ATTRIBUTE CONST_TOK BOOL_TOK FLOAT_TOK INT_TOK UINT_TOK %token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT %token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 -%token CENTROID IN OUT INOUT UNIFORM VARYING +%token CENTROID IN_TOK OUT_TOK INOUT_TOK UNIFORM VARYING %token NOPERSPECTIVE FLAT SMOOTH %token MAT2X2 MAT2X3 MAT2X4 %token MAT3X2 MAT3X3 MAT3X4 @@ -90,7 +90,7 @@ %token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE %token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D %token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY -%token STRUCT VOID WHILE +%token STRUCT VOID_TOK WHILE %token IDENTIFIER %token FLOATCONSTANT %token INTCONSTANT UINTCONSTANT BOOLCONSTANT @@ -108,9 +108,9 @@ /* Reserved words that are not actually used in the grammar. */ -%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED GOTO +%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED_TOK GOTO %token INLINE_TOK NOINLINE VOLATILE PUBLIC_TOK STATIC EXTERN EXTERNAL -%token LONG SHORT DOUBLE HALF FIXED UNSIGNED INPUT OUPTUT +%token LONG_TOK SHORT_TOK DOUBLE_TOK HALF FIXED_TOK UNSIGNED INPUT_TOK OUPTUT %token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 %token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW %token SIZEOF CAST NAMESPACE USING @@ -370,7 +370,7 @@ function_call_generic: ; function_call_header_no_parameters: - function_call_header VOID + function_call_header VOID_TOK | function_call_header ; @@ -783,9 +783,9 @@ parameter_declaration: parameter_qualifier: /* empty */ { $$.i = 0; } - | IN { $$.i = 0; $$.q.in = 1; } - | OUT { $$.i = 0; $$.q.out = 1; } - | INOUT { $$.i = 0; $$.q.in = 1; $$.q.out = 1; } + | IN_TOK { $$.i = 0; $$.q.in = 1; } + | OUT_TOK { $$.i = 0; $$.q.out = 1; } + | INOUT_TOK { $$.i = 0; $$.q.in = 1; $$.q.out = 1; } ; parameter_type_specifier: @@ -1030,10 +1030,10 @@ storage_qualifier: | ATTRIBUTE { $$.i = 0; $$.q.attribute = 1; } | opt_layout_qualifier VARYING { $$.i = $1.i; $$.q.varying = 1; } | CENTROID VARYING { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; } - | opt_layout_qualifier IN { $$.i = 0; $$.q.in = 1; } - | OUT { $$.i = 0; $$.q.out = 1; } - | CENTROID IN { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; } - | CENTROID OUT { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; } + | opt_layout_qualifier IN_TOK { $$.i = 0; $$.q.in = 1; } + | OUT_TOK { $$.i = 0; $$.q.out = 1; } + | CENTROID IN_TOK { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; } + | CENTROID OUT_TOK { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; } | UNIFORM { $$.i = 0; $$.q.uniform = 1; } ; @@ -1084,11 +1084,11 @@ type_specifier_nonarray: ; basic_type_specifier_nonarray: - VOID { $$ = ast_void; } - | FLOAT { $$ = ast_float; } - | INT { $$ = ast_int; } - | UINT { $$ = ast_uint; } - | BOOL { $$ = ast_bool; } + VOID_TOK { $$ = ast_void; } + | FLOAT_TOK { $$ = ast_float; } + | INT_TOK { $$ = ast_int; } + | UINT_TOK { $$ = ast_uint; } + | BOOL_TOK { $$ = ast_bool; } | VEC2 { $$ = ast_vec2; } | VEC3 { $$ = ast_vec3; } | VEC4 { $$ = ast_vec4; } -- cgit v1.2.3 From 103453659dbb21dd49e700e4b6ba9aac83b5a3f4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 09:34:52 -0700 Subject: glsl2: Commit generated files changed by previous two commits --- src/glsl/glsl_lexer.cpp | 32 +- src/glsl/glsl_parser.cpp | 2360 ++++++++++++++++++++++------------------------ src/glsl/glsl_parser.h | 325 ++++--- 3 files changed, 1314 insertions(+), 1403 deletions(-) diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp index f75f7b51713..2c502e88030 100644 --- a/src/glsl/glsl_lexer.cpp +++ b/src/glsl/glsl_lexer.cpp @@ -1415,17 +1415,17 @@ return CONST_TOK; case 17: YY_RULE_SETUP #line 131 "glsl_lexer.lpp" -return BOOL; +return BOOL_TOK; YY_BREAK case 18: YY_RULE_SETUP #line 132 "glsl_lexer.lpp" -return FLOAT; +return FLOAT_TOK; YY_BREAK case 19: YY_RULE_SETUP #line 133 "glsl_lexer.lpp" -return INT; +return INT_TOK; YY_BREAK case 20: YY_RULE_SETUP @@ -1520,17 +1520,17 @@ return VEC4; case 38: YY_RULE_SETUP #line 154 "glsl_lexer.lpp" -return MAT2; +return MAT2X2; YY_BREAK case 39: YY_RULE_SETUP #line 155 "glsl_lexer.lpp" -return MAT3; +return MAT3X3; YY_BREAK case 40: YY_RULE_SETUP #line 156 "glsl_lexer.lpp" -return MAT4; +return MAT4X4; YY_BREAK case 41: YY_RULE_SETUP @@ -1580,17 +1580,17 @@ TOKEN_OR_IDENTIFIER(120, MAT4X4); case 50: YY_RULE_SETUP #line 167 "glsl_lexer.lpp" -return IN; +return IN_TOK; YY_BREAK case 51: YY_RULE_SETUP #line 168 "glsl_lexer.lpp" -return OUT; +return OUT_TOK; YY_BREAK case 52: YY_RULE_SETUP #line 169 "glsl_lexer.lpp" -return INOUT; +return INOUT_TOK; YY_BREAK case 53: YY_RULE_SETUP @@ -1665,7 +1665,7 @@ return STRUCT; case 67: YY_RULE_SETUP #line 187 "glsl_lexer.lpp" -return VOID; +return VOID_TOK; YY_BREAK case 68: YY_RULE_SETUP @@ -1894,7 +1894,7 @@ RESERVED_WORD(999, THIS); case 105: YY_RULE_SETUP #line 272 "glsl_lexer.lpp" -RESERVED_WORD(999, PACKED); +RESERVED_WORD(999, PACKED_TOK); YY_BREAK case 106: YY_RULE_SETUP @@ -1954,17 +1954,17 @@ RESERVED_WORD(999, INTERFACE); case 117: YY_RULE_SETUP #line 284 "glsl_lexer.lpp" -RESERVED_WORD(999, LONG); +RESERVED_WORD(999, LONG_TOK); YY_BREAK case 118: YY_RULE_SETUP #line 285 "glsl_lexer.lpp" -RESERVED_WORD(999, SHORT); +RESERVED_WORD(999, SHORT_TOK); YY_BREAK case 119: YY_RULE_SETUP #line 286 "glsl_lexer.lpp" -RESERVED_WORD(999, DOUBLE); +RESERVED_WORD(999, DOUBLE_TOK); YY_BREAK case 120: YY_RULE_SETUP @@ -1974,7 +1974,7 @@ RESERVED_WORD(999, HALF); case 121: YY_RULE_SETUP #line 288 "glsl_lexer.lpp" -RESERVED_WORD(999, FIXED); +RESERVED_WORD(999, FIXED_TOK); YY_BREAK case 122: YY_RULE_SETUP @@ -1984,7 +1984,7 @@ RESERVED_WORD(999, UNSIGNED); case 123: YY_RULE_SETUP #line 290 "glsl_lexer.lpp" -RESERVED_WORD(999, INPUT); +RESERVED_WORD(999, INPUT_TOK); YY_BREAK case 124: YY_RULE_SETUP diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp index 864ab0032ff..8756fcb721a 100644 --- a/src/glsl/glsl_parser.cpp +++ b/src/glsl/glsl_parser.cpp @@ -143,10 +143,10 @@ enum yytokentype { ATTRIBUTE = 258, CONST_TOK = 259, - BOOL = 260, - FLOAT = 261, - INT = 262, - UINT = 263, + BOOL_TOK = 260, + FLOAT_TOK = 261, + INT_TOK = 262, + UINT_TOK = 263, BREAK = 264, CONTINUE = 265, DO = 266, @@ -170,165 +170,162 @@ VEC2 = 284, VEC3 = 285, VEC4 = 286, - MAT2 = 287, - MAT3 = 288, - MAT4 = 289, - CENTROID = 290, - IN = 291, - OUT = 292, - INOUT = 293, - UNIFORM = 294, - VARYING = 295, - NOPERSPECTIVE = 296, - FLAT = 297, - SMOOTH = 298, - MAT2X2 = 299, - MAT2X3 = 300, - MAT2X4 = 301, - MAT3X2 = 302, - MAT3X3 = 303, - MAT3X4 = 304, - MAT4X2 = 305, - MAT4X3 = 306, - MAT4X4 = 307, - SAMPLER1D = 308, - SAMPLER2D = 309, - SAMPLER3D = 310, - SAMPLERCUBE = 311, - SAMPLER1DSHADOW = 312, - SAMPLER2DSHADOW = 313, - SAMPLERCUBESHADOW = 314, - SAMPLER1DARRAY = 315, - SAMPLER2DARRAY = 316, - SAMPLER1DARRAYSHADOW = 317, - SAMPLER2DARRAYSHADOW = 318, - ISAMPLER1D = 319, - ISAMPLER2D = 320, - ISAMPLER3D = 321, - ISAMPLERCUBE = 322, - ISAMPLER1DARRAY = 323, - ISAMPLER2DARRAY = 324, - USAMPLER1D = 325, - USAMPLER2D = 326, - USAMPLER3D = 327, - USAMPLERCUBE = 328, - USAMPLER1DARRAY = 329, - USAMPLER2DARRAY = 330, - STRUCT = 331, - VOID = 332, - WHILE = 333, - IDENTIFIER = 334, - FLOATCONSTANT = 335, - INTCONSTANT = 336, - UINTCONSTANT = 337, - BOOLCONSTANT = 338, - FIELD_SELECTION = 339, - LEFT_OP = 340, - RIGHT_OP = 341, - INC_OP = 342, - DEC_OP = 343, - LE_OP = 344, - GE_OP = 345, - EQ_OP = 346, - NE_OP = 347, - AND_OP = 348, - OR_OP = 349, - XOR_OP = 350, - MUL_ASSIGN = 351, - DIV_ASSIGN = 352, - ADD_ASSIGN = 353, - MOD_ASSIGN = 354, - LEFT_ASSIGN = 355, - RIGHT_ASSIGN = 356, - AND_ASSIGN = 357, - XOR_ASSIGN = 358, - OR_ASSIGN = 359, - SUB_ASSIGN = 360, - INVARIANT = 361, - LOWP = 362, - MEDIUMP = 363, - HIGHP = 364, - SUPERP = 365, - PRECISION = 366, - VERSION = 367, - EXTENSION = 368, - LINE = 369, - PRAGMA = 370, - COLON = 371, - EOL = 372, - INTERFACE = 373, - OUTPUT = 374, - LAYOUT_TOK = 375, - ASM = 376, - CLASS = 377, - UNION = 378, - ENUM = 379, - TYPEDEF = 380, - TEMPLATE = 381, - THIS = 382, - PACKED = 383, - GOTO = 384, - INLINE_TOK = 385, - NOINLINE = 386, - VOLATILE = 387, - PUBLIC_TOK = 388, - STATIC = 389, - EXTERN = 390, - EXTERNAL = 391, - LONG = 392, - SHORT = 393, - DOUBLE = 394, - HALF = 395, - FIXED = 396, - UNSIGNED = 397, - INPUT = 398, - OUPTUT = 399, - HVEC2 = 400, - HVEC3 = 401, - HVEC4 = 402, - DVEC2 = 403, - DVEC3 = 404, - DVEC4 = 405, - FVEC2 = 406, - FVEC3 = 407, - FVEC4 = 408, - SAMPLER2DRECT = 409, - SAMPLER3DRECT = 410, - SAMPLER2DRECTSHADOW = 411, - SIZEOF = 412, - CAST = 413, - NAMESPACE = 414, - USING = 415, - ERROR_TOK = 416, - COMMON = 417, - PARTITION = 418, - ACTIVE = 419, - SAMPLERBUFFER = 420, - FILTER = 421, - IMAGE1D = 422, - IMAGE2D = 423, - IMAGE3D = 424, - IMAGECUBE = 425, - IMAGE1DARRAY = 426, - IMAGE2DARRAY = 427, - IIMAGE1D = 428, - IIMAGE2D = 429, - IIMAGE3D = 430, - IIMAGECUBE = 431, - IIMAGE1DARRAY = 432, - IIMAGE2DARRAY = 433, - UIMAGE1D = 434, - UIMAGE2D = 435, - UIMAGE3D = 436, - UIMAGECUBE = 437, - UIMAGE1DARRAY = 438, - UIMAGE2DARRAY = 439, - IMAGE1DSHADOW = 440, - IMAGE2DSHADOW = 441, - IMAGEBUFFER = 442, - IIMAGEBUFFER = 443, - UIMAGEBUFFER = 444, - ROW_MAJOR = 445 + CENTROID = 287, + IN_TOK = 288, + OUT_TOK = 289, + INOUT_TOK = 290, + UNIFORM = 291, + VARYING = 292, + NOPERSPECTIVE = 293, + FLAT = 294, + SMOOTH = 295, + MAT2X2 = 296, + MAT2X3 = 297, + MAT2X4 = 298, + MAT3X2 = 299, + MAT3X3 = 300, + MAT3X4 = 301, + MAT4X2 = 302, + MAT4X3 = 303, + MAT4X4 = 304, + SAMPLER1D = 305, + SAMPLER2D = 306, + SAMPLER3D = 307, + SAMPLERCUBE = 308, + SAMPLER1DSHADOW = 309, + SAMPLER2DSHADOW = 310, + SAMPLERCUBESHADOW = 311, + SAMPLER1DARRAY = 312, + SAMPLER2DARRAY = 313, + SAMPLER1DARRAYSHADOW = 314, + SAMPLER2DARRAYSHADOW = 315, + ISAMPLER1D = 316, + ISAMPLER2D = 317, + ISAMPLER3D = 318, + ISAMPLERCUBE = 319, + ISAMPLER1DARRAY = 320, + ISAMPLER2DARRAY = 321, + USAMPLER1D = 322, + USAMPLER2D = 323, + USAMPLER3D = 324, + USAMPLERCUBE = 325, + USAMPLER1DARRAY = 326, + USAMPLER2DARRAY = 327, + STRUCT = 328, + VOID_TOK = 329, + WHILE = 330, + IDENTIFIER = 331, + FLOATCONSTANT = 332, + INTCONSTANT = 333, + UINTCONSTANT = 334, + BOOLCONSTANT = 335, + FIELD_SELECTION = 336, + LEFT_OP = 337, + RIGHT_OP = 338, + INC_OP = 339, + DEC_OP = 340, + LE_OP = 341, + GE_OP = 342, + EQ_OP = 343, + NE_OP = 344, + AND_OP = 345, + OR_OP = 346, + XOR_OP = 347, + MUL_ASSIGN = 348, + DIV_ASSIGN = 349, + ADD_ASSIGN = 350, + MOD_ASSIGN = 351, + LEFT_ASSIGN = 352, + RIGHT_ASSIGN = 353, + AND_ASSIGN = 354, + XOR_ASSIGN = 355, + OR_ASSIGN = 356, + SUB_ASSIGN = 357, + INVARIANT = 358, + LOWP = 359, + MEDIUMP = 360, + HIGHP = 361, + SUPERP = 362, + PRECISION = 363, + VERSION = 364, + EXTENSION = 365, + LINE = 366, + PRAGMA = 367, + COLON = 368, + EOL = 369, + INTERFACE = 370, + OUTPUT = 371, + LAYOUT_TOK = 372, + ASM = 373, + CLASS = 374, + UNION = 375, + ENUM = 376, + TYPEDEF = 377, + TEMPLATE = 378, + THIS = 379, + PACKED_TOK = 380, + GOTO = 381, + INLINE_TOK = 382, + NOINLINE = 383, + VOLATILE = 384, + PUBLIC_TOK = 385, + STATIC = 386, + EXTERN = 387, + EXTERNAL = 388, + LONG_TOK = 389, + SHORT_TOK = 390, + DOUBLE_TOK = 391, + HALF = 392, + FIXED_TOK = 393, + UNSIGNED = 394, + INPUT_TOK = 395, + OUPTUT = 396, + HVEC2 = 397, + HVEC3 = 398, + HVEC4 = 399, + DVEC2 = 400, + DVEC3 = 401, + DVEC4 = 402, + FVEC2 = 403, + FVEC3 = 404, + FVEC4 = 405, + SAMPLER2DRECT = 406, + SAMPLER3DRECT = 407, + SAMPLER2DRECTSHADOW = 408, + SIZEOF = 409, + CAST = 410, + NAMESPACE = 411, + USING = 412, + ERROR_TOK = 413, + COMMON = 414, + PARTITION = 415, + ACTIVE = 416, + SAMPLERBUFFER = 417, + FILTER = 418, + IMAGE1D = 419, + IMAGE2D = 420, + IMAGE3D = 421, + IMAGECUBE = 422, + IMAGE1DARRAY = 423, + IMAGE2DARRAY = 424, + IIMAGE1D = 425, + IIMAGE2D = 426, + IIMAGE3D = 427, + IIMAGECUBE = 428, + IIMAGE1DARRAY = 429, + IIMAGE2DARRAY = 430, + UIMAGE1D = 431, + UIMAGE2D = 432, + UIMAGE3D = 433, + UIMAGECUBE = 434, + UIMAGE1DARRAY = 435, + UIMAGE2DARRAY = 436, + IMAGE1DSHADOW = 437, + IMAGE2DSHADOW = 438, + IMAGEBUFFER = 439, + IIMAGEBUFFER = 440, + UIMAGEBUFFER = 441, + ROW_MAJOR = 442 }; #endif @@ -370,7 +367,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 374 "glsl_parser.cpp" +#line 371 "glsl_parser.cpp" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -395,7 +392,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 399 "glsl_parser.cpp" +#line 396 "glsl_parser.cpp" #ifdef short # undef short @@ -612,20 +609,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 5 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 4389 +#define YYLAST 4096 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 215 +#define YYNTOKENS 212 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 89 /* YYNRULES -- Number of rules. */ -#define YYNRULES 276 +#define YYNRULES 273 /* YYNRULES -- Number of states. */ -#define YYNSTATES 413 +#define YYNSTATES 410 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 445 +#define YYMAXUTOK 442 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -636,16 +633,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 199, 2, 2, 2, 203, 206, 2, - 191, 192, 201, 197, 196, 198, 195, 202, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 210, 212, - 204, 211, 205, 209, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 196, 2, 2, 2, 200, 203, 2, + 188, 189, 198, 194, 193, 195, 192, 199, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 207, 209, + 201, 208, 202, 206, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 193, 2, 194, 207, 2, 2, 2, 2, 2, + 2, 190, 2, 191, 204, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 213, 208, 214, 200, 2, 2, 2, + 2, 2, 2, 210, 205, 211, 197, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -677,7 +674,7 @@ static const yytype_uint8 yytranslate[] = 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, - 185, 186, 187, 188, 189, 190 + 185, 186, 187 }; #if YYDEBUG @@ -706,98 +703,97 @@ static const yytype_uint16 yyprhs[] = 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, - 584, 586, 588, 590, 592, 594, 596, 598, 600, 606, - 611, 613, 616, 620, 622, 626, 628, 633, 635, 637, - 639, 641, 643, 645, 647, 649, 651, 653, 655, 657, - 659, 661, 664, 668, 670, 672, 675, 679, 681, 684, - 686, 689, 697, 703, 709, 717, 719, 724, 730, 734, - 737, 743, 751, 758, 760, 762, 764, 765, 768, 772, - 775, 778, 781, 785, 788, 790, 792 + 584, 586, 588, 590, 592, 594, 600, 605, 607, 610, + 614, 616, 620, 622, 627, 629, 631, 633, 635, 637, + 639, 641, 643, 645, 647, 649, 651, 653, 655, 658, + 662, 664, 666, 669, 673, 675, 678, 680, 683, 691, + 697, 703, 711, 713, 718, 724, 728, 731, 737, 745, + 752, 754, 756, 758, 759, 762, 766, 769, 772, 775, + 779, 782, 784, 786 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 216, 0, -1, -1, 218, 219, 217, 221, -1, -1, - 112, 81, 117, -1, -1, 219, 220, -1, 113, 79, - 116, 79, 117, -1, 302, -1, 221, 302, -1, 79, - -1, 222, -1, 81, -1, 82, -1, 80, -1, 83, - -1, 191, 249, 192, -1, 223, -1, 224, 193, 225, - 194, -1, 226, -1, 224, 195, 79, -1, 224, 87, - -1, 224, 88, -1, 249, -1, 227, -1, 228, -1, - 224, 195, 228, -1, 230, 192, -1, 229, 192, -1, - 231, 77, -1, 231, -1, 231, 247, -1, 230, 196, - 247, -1, 232, 191, -1, 271, -1, 79, -1, 84, - -1, 224, -1, 87, 233, -1, 88, 233, -1, 234, - 233, -1, 197, -1, 198, -1, 199, -1, 200, -1, - 233, -1, 235, 201, 233, -1, 235, 202, 233, -1, - 235, 203, 233, -1, 235, -1, 236, 197, 235, -1, - 236, 198, 235, -1, 236, -1, 237, 85, 236, -1, - 237, 86, 236, -1, 237, -1, 238, 204, 237, -1, - 238, 205, 237, -1, 238, 89, 237, -1, 238, 90, - 237, -1, 238, -1, 239, 91, 238, -1, 239, 92, - 238, -1, 239, -1, 240, 206, 239, -1, 240, -1, - 241, 207, 240, -1, 241, -1, 242, 208, 241, -1, - 242, -1, 243, 93, 242, -1, 243, -1, 244, 95, - 243, -1, 244, -1, 245, 94, 244, -1, 245, -1, - 245, 209, 249, 210, 247, -1, 246, -1, 233, 248, - 247, -1, 211, -1, 96, -1, 97, -1, 99, -1, - 98, -1, 105, -1, 100, -1, 101, -1, 102, -1, - 103, -1, 104, -1, 247, -1, 249, 196, 247, -1, - 246, -1, 252, 212, -1, 260, 212, -1, 111, 275, - 272, 212, -1, 253, 192, -1, 255, -1, 254, -1, - 255, 257, -1, 254, 196, 257, -1, 262, 79, 191, - -1, 271, 79, -1, 271, 79, 193, 250, 194, -1, - 268, 258, 256, -1, 258, 256, -1, 268, 258, 259, - -1, 258, 259, -1, -1, 36, -1, 37, -1, 38, - -1, 271, -1, 261, -1, 260, 196, 79, -1, 260, - 196, 79, 193, 194, -1, 260, 196, 79, 193, 250, - 194, -1, 260, 196, 79, 193, 194, 211, 281, -1, - 260, 196, 79, 193, 250, 194, 211, 281, -1, 260, - 196, 79, 211, 281, -1, 262, -1, 262, 79, -1, - 262, 79, 193, 194, -1, 262, 79, 193, 250, 194, - -1, 262, 79, 193, 194, 211, 281, -1, 262, 79, - 193, 250, 194, 211, 281, -1, 262, 79, 211, 281, - -1, 106, 79, -1, 271, -1, 269, 271, -1, -1, - 264, -1, 120, 191, 265, 192, -1, 266, -1, 265, - 196, 266, -1, 79, -1, 43, -1, 42, -1, 41, - -1, 4, -1, 270, -1, 267, 269, -1, 106, 269, - -1, 4, -1, 3, -1, 263, 40, -1, 35, 40, - -1, 263, 36, -1, 37, -1, 35, 36, -1, 35, - 37, -1, 39, -1, 272, -1, 275, 272, -1, 273, - -1, 273, 193, 194, -1, 273, 193, 250, 194, -1, - 274, -1, 276, -1, 79, -1, 77, -1, 6, -1, + 213, 0, -1, -1, 215, 216, 214, 218, -1, -1, + 109, 78, 114, -1, -1, 216, 217, -1, 110, 76, + 113, 76, 114, -1, 299, -1, 218, 299, -1, 76, + -1, 219, -1, 78, -1, 79, -1, 77, -1, 80, + -1, 188, 246, 189, -1, 220, -1, 221, 190, 222, + 191, -1, 223, -1, 221, 192, 76, -1, 221, 84, + -1, 221, 85, -1, 246, -1, 224, -1, 225, -1, + 221, 192, 225, -1, 227, 189, -1, 226, 189, -1, + 228, 74, -1, 228, -1, 228, 244, -1, 227, 193, + 244, -1, 229, 188, -1, 268, -1, 76, -1, 81, + -1, 221, -1, 84, 230, -1, 85, 230, -1, 231, + 230, -1, 194, -1, 195, -1, 196, -1, 197, -1, + 230, -1, 232, 198, 230, -1, 232, 199, 230, -1, + 232, 200, 230, -1, 232, -1, 233, 194, 232, -1, + 233, 195, 232, -1, 233, -1, 234, 82, 233, -1, + 234, 83, 233, -1, 234, -1, 235, 201, 234, -1, + 235, 202, 234, -1, 235, 86, 234, -1, 235, 87, + 234, -1, 235, -1, 236, 88, 235, -1, 236, 89, + 235, -1, 236, -1, 237, 203, 236, -1, 237, -1, + 238, 204, 237, -1, 238, -1, 239, 205, 238, -1, + 239, -1, 240, 90, 239, -1, 240, -1, 241, 92, + 240, -1, 241, -1, 242, 91, 241, -1, 242, -1, + 242, 206, 246, 207, 244, -1, 243, -1, 230, 245, + 244, -1, 208, -1, 93, -1, 94, -1, 96, -1, + 95, -1, 102, -1, 97, -1, 98, -1, 99, -1, + 100, -1, 101, -1, 244, -1, 246, 193, 244, -1, + 243, -1, 249, 209, -1, 257, 209, -1, 108, 272, + 269, 209, -1, 250, 189, -1, 252, -1, 251, -1, + 252, 254, -1, 251, 193, 254, -1, 259, 76, 188, + -1, 268, 76, -1, 268, 76, 190, 247, 191, -1, + 265, 255, 253, -1, 255, 253, -1, 265, 255, 256, + -1, 255, 256, -1, -1, 33, -1, 34, -1, 35, + -1, 268, -1, 258, -1, 257, 193, 76, -1, 257, + 193, 76, 190, 191, -1, 257, 193, 76, 190, 247, + 191, -1, 257, 193, 76, 190, 191, 208, 278, -1, + 257, 193, 76, 190, 247, 191, 208, 278, -1, 257, + 193, 76, 208, 278, -1, 259, -1, 259, 76, -1, + 259, 76, 190, 191, -1, 259, 76, 190, 247, 191, + -1, 259, 76, 190, 191, 208, 278, -1, 259, 76, + 190, 247, 191, 208, 278, -1, 259, 76, 208, 278, + -1, 103, 76, -1, 268, -1, 266, 268, -1, -1, + 261, -1, 117, 188, 262, 189, -1, 263, -1, 262, + 193, 263, -1, 76, -1, 40, -1, 39, -1, 38, + -1, 4, -1, 267, -1, 264, 266, -1, 103, 266, + -1, 4, -1, 3, -1, 260, 37, -1, 32, 37, + -1, 260, 33, -1, 34, -1, 32, 33, -1, 32, + 34, -1, 36, -1, 269, -1, 272, 269, -1, 270, + -1, 270, 190, 191, -1, 270, 190, 247, 191, -1, + 271, -1, 273, -1, 76, -1, 74, -1, 6, -1, 7, -1, 8, -1, 5, -1, 29, -1, 30, -1, 31, -1, 20, -1, 21, -1, 22, -1, 23, -1, 24, -1, 25, -1, 26, -1, 27, -1, 28, -1, - 32, -1, 33, -1, 34, -1, 44, -1, 45, -1, + 41, -1, 42, -1, 43, -1, 44, -1, 45, -1, 46, -1, 47, -1, 48, -1, 49, -1, 50, -1, - 51, -1, 52, -1, 53, -1, 54, -1, 154, -1, - 55, -1, 56, -1, 57, -1, 58, -1, 156, -1, + 51, -1, 151, -1, 52, -1, 53, -1, 54, -1, + 55, -1, 153, -1, 56, -1, 57, -1, 58, -1, 59, -1, 60, -1, 61, -1, 62, -1, 63, -1, 64, -1, 65, -1, 66, -1, 67, -1, 68, -1, - 69, -1, 70, -1, 71, -1, 72, -1, 73, -1, - 74, -1, 75, -1, 109, -1, 108, -1, 107, -1, - 76, 79, 213, 277, 214, -1, 76, 213, 277, 214, - -1, 278, -1, 277, 278, -1, 271, 279, 212, -1, - 280, -1, 279, 196, 280, -1, 79, -1, 79, 193, - 250, 194, -1, 247, -1, 251, -1, 284, -1, 285, - -1, 287, -1, 286, -1, 293, -1, 282, -1, 291, - -1, 292, -1, 295, -1, 296, -1, 297, -1, 301, - -1, 213, 214, -1, 213, 290, 214, -1, 289, -1, - 286, -1, 213, 214, -1, 213, 290, 214, -1, 283, - -1, 290, 283, -1, 212, -1, 249, 212, -1, 14, - 191, 249, 192, 284, 12, 284, -1, 14, 191, 249, - 192, 284, -1, 14, 191, 249, 192, 285, -1, 14, - 191, 249, 192, 284, 12, 285, -1, 249, -1, 262, - 79, 211, 281, -1, 17, 191, 249, 192, 287, -1, - 18, 249, 210, -1, 19, 210, -1, 78, 191, 294, - 192, 288, -1, 11, 283, 78, 191, 249, 192, 212, - -1, 13, 191, 298, 300, 192, 288, -1, 291, -1, - 282, -1, 294, -1, -1, 299, 212, -1, 299, 212, - 249, -1, 10, 212, -1, 9, 212, -1, 16, 212, - -1, 16, 249, 212, -1, 15, 212, -1, 303, -1, - 251, -1, 252, 289, -1 + 69, -1, 70, -1, 71, -1, 72, -1, 106, -1, + 105, -1, 104, -1, 73, 76, 210, 274, 211, -1, + 73, 210, 274, 211, -1, 275, -1, 274, 275, -1, + 268, 276, 209, -1, 277, -1, 276, 193, 277, -1, + 76, -1, 76, 190, 247, 191, -1, 244, -1, 248, + -1, 281, -1, 282, -1, 284, -1, 283, -1, 290, + -1, 279, -1, 288, -1, 289, -1, 292, -1, 293, + -1, 294, -1, 298, -1, 210, 211, -1, 210, 287, + 211, -1, 286, -1, 283, -1, 210, 211, -1, 210, + 287, 211, -1, 280, -1, 287, 280, -1, 209, -1, + 246, 209, -1, 14, 188, 246, 189, 281, 12, 281, + -1, 14, 188, 246, 189, 281, -1, 14, 188, 246, + 189, 282, -1, 14, 188, 246, 189, 281, 12, 282, + -1, 246, -1, 259, 76, 208, 278, -1, 17, 188, + 246, 189, 284, -1, 18, 246, 207, -1, 19, 207, + -1, 75, 188, 291, 189, 285, -1, 11, 280, 75, + 188, 246, 189, 209, -1, 13, 188, 295, 297, 189, + 285, -1, 288, -1, 279, -1, 291, -1, -1, 296, + 209, -1, 296, 209, 246, -1, 10, 209, -1, 9, + 209, -1, 16, 209, -1, 16, 246, 209, -1, 15, + 209, -1, 300, -1, 248, -1, 249, 286, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -824,13 +820,13 @@ static const yytype_uint16 yyrline[] = 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, - 1136, 1137, 1138, 1139, 1140, 1144, 1155, 1166, 1180, 1186, - 1195, 1200, 1208, 1223, 1228, 1236, 1242, 1251, 1255, 1261, - 1262, 1266, 1267, 1271, 1275, 1276, 1277, 1278, 1279, 1280, - 1281, 1285, 1291, 1300, 1301, 1305, 1311, 1320, 1330, 1342, - 1348, 1357, 1366, 1372, 1378, 1387, 1391, 1405, 1409, 1410, - 1414, 1421, 1428, 1438, 1439, 1443, 1445, 1451, 1456, 1465, - 1471, 1477, 1483, 1489, 1498, 1499, 1503 + 1136, 1137, 1141, 1152, 1163, 1177, 1183, 1192, 1197, 1205, + 1220, 1225, 1233, 1239, 1248, 1252, 1258, 1259, 1263, 1264, + 1268, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1282, 1288, + 1297, 1298, 1302, 1308, 1317, 1327, 1339, 1345, 1354, 1363, + 1369, 1375, 1384, 1388, 1402, 1406, 1407, 1411, 1418, 1425, + 1435, 1436, 1440, 1442, 1448, 1453, 1462, 1468, 1474, 1480, + 1486, 1495, 1496, 1500 }; #endif @@ -839,11 +835,11 @@ static const yytype_uint16 yyrline[] = First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "ATTRIBUTE", "CONST_TOK", "BOOL", - "FLOAT", "INT", "UINT", "BREAK", "CONTINUE", "DO", "ELSE", "FOR", "IF", - "DISCARD", "RETURN", "SWITCH", "CASE", "DEFAULT", "BVEC2", "BVEC3", - "BVEC4", "IVEC2", "IVEC3", "IVEC4", "UVEC2", "UVEC3", "UVEC4", "VEC2", - "VEC3", "VEC4", "MAT2", "MAT3", "MAT4", "CENTROID", "IN", "OUT", "INOUT", + "$end", "error", "$undefined", "ATTRIBUTE", "CONST_TOK", "BOOL_TOK", + "FLOAT_TOK", "INT_TOK", "UINT_TOK", "BREAK", "CONTINUE", "DO", "ELSE", + "FOR", "IF", "DISCARD", "RETURN", "SWITCH", "CASE", "DEFAULT", "BVEC2", + "BVEC3", "BVEC4", "IVEC2", "IVEC3", "IVEC4", "UVEC2", "UVEC3", "UVEC4", + "VEC2", "VEC3", "VEC4", "CENTROID", "IN_TOK", "OUT_TOK", "INOUT_TOK", "UNIFORM", "VARYING", "NOPERSPECTIVE", "FLAT", "SMOOTH", "MAT2X2", "MAT2X3", "MAT2X4", "MAT3X2", "MAT3X3", "MAT3X4", "MAT4X2", "MAT4X3", "MAT4X4", "SAMPLER1D", "SAMPLER2D", "SAMPLER3D", "SAMPLERCUBE", @@ -852,7 +848,7 @@ static const char *const yytname[] = "SAMPLER2DARRAYSHADOW", "ISAMPLER1D", "ISAMPLER2D", "ISAMPLER3D", "ISAMPLERCUBE", "ISAMPLER1DARRAY", "ISAMPLER2DARRAY", "USAMPLER1D", "USAMPLER2D", "USAMPLER3D", "USAMPLERCUBE", "USAMPLER1DARRAY", - "USAMPLER2DARRAY", "STRUCT", "VOID", "WHILE", "IDENTIFIER", + "USAMPLER2DARRAY", "STRUCT", "VOID_TOK", "WHILE", "IDENTIFIER", "FLOATCONSTANT", "INTCONSTANT", "UINTCONSTANT", "BOOLCONSTANT", "FIELD_SELECTION", "LEFT_OP", "RIGHT_OP", "INC_OP", "DEC_OP", "LE_OP", "GE_OP", "EQ_OP", "NE_OP", "AND_OP", "OR_OP", "XOR_OP", "MUL_ASSIGN", @@ -861,21 +857,21 @@ static const char *const yytname[] = "LOWP", "MEDIUMP", "HIGHP", "SUPERP", "PRECISION", "VERSION", "EXTENSION", "LINE", "PRAGMA", "COLON", "EOL", "INTERFACE", "OUTPUT", "LAYOUT_TOK", "ASM", "CLASS", "UNION", "ENUM", "TYPEDEF", "TEMPLATE", - "THIS", "PACKED", "GOTO", "INLINE_TOK", "NOINLINE", "VOLATILE", - "PUBLIC_TOK", "STATIC", "EXTERN", "EXTERNAL", "LONG", "SHORT", "DOUBLE", - "HALF", "FIXED", "UNSIGNED", "INPUT", "OUPTUT", "HVEC2", "HVEC3", - "HVEC4", "DVEC2", "DVEC3", "DVEC4", "FVEC2", "FVEC3", "FVEC4", - "SAMPLER2DRECT", "SAMPLER3DRECT", "SAMPLER2DRECTSHADOW", "SIZEOF", - "CAST", "NAMESPACE", "USING", "ERROR_TOK", "COMMON", "PARTITION", - "ACTIVE", "SAMPLERBUFFER", "FILTER", "IMAGE1D", "IMAGE2D", "IMAGE3D", - "IMAGECUBE", "IMAGE1DARRAY", "IMAGE2DARRAY", "IIMAGE1D", "IIMAGE2D", - "IIMAGE3D", "IIMAGECUBE", "IIMAGE1DARRAY", "IIMAGE2DARRAY", "UIMAGE1D", - "UIMAGE2D", "UIMAGE3D", "UIMAGECUBE", "UIMAGE1DARRAY", "UIMAGE2DARRAY", - "IMAGE1DSHADOW", "IMAGE2DSHADOW", "IMAGEBUFFER", "IIMAGEBUFFER", - "UIMAGEBUFFER", "ROW_MAJOR", "'('", "')'", "'['", "']'", "'.'", "','", - "'+'", "'-'", "'!'", "'~'", "'*'", "'/'", "'%'", "'<'", "'>'", "'&'", - "'^'", "'|'", "'?'", "':'", "'='", "';'", "'{'", "'}'", "$accept", - "translation_unit", "$@1", "version_statement", + "THIS", "PACKED_TOK", "GOTO", "INLINE_TOK", "NOINLINE", "VOLATILE", + "PUBLIC_TOK", "STATIC", "EXTERN", "EXTERNAL", "LONG_TOK", "SHORT_TOK", + "DOUBLE_TOK", "HALF", "FIXED_TOK", "UNSIGNED", "INPUT_TOK", "OUPTUT", + "HVEC2", "HVEC3", "HVEC4", "DVEC2", "DVEC3", "DVEC4", "FVEC2", "FVEC3", + "FVEC4", "SAMPLER2DRECT", "SAMPLER3DRECT", "SAMPLER2DRECTSHADOW", + "SIZEOF", "CAST", "NAMESPACE", "USING", "ERROR_TOK", "COMMON", + "PARTITION", "ACTIVE", "SAMPLERBUFFER", "FILTER", "IMAGE1D", "IMAGE2D", + "IMAGE3D", "IMAGECUBE", "IMAGE1DARRAY", "IMAGE2DARRAY", "IIMAGE1D", + "IIMAGE2D", "IIMAGE3D", "IIMAGECUBE", "IIMAGE1DARRAY", "IIMAGE2DARRAY", + "UIMAGE1D", "UIMAGE2D", "UIMAGE3D", "UIMAGECUBE", "UIMAGE1DARRAY", + "UIMAGE2DARRAY", "IMAGE1DSHADOW", "IMAGE2DSHADOW", "IMAGEBUFFER", + "IIMAGEBUFFER", "UIMAGEBUFFER", "ROW_MAJOR", "'('", "')'", "'['", "']'", + "'.'", "','", "'+'", "'-'", "'!'", "'~'", "'*'", "'/'", "'%'", "'<'", + "'>'", "'&'", "'^'", "'|'", "'?'", "':'", "'='", "';'", "'{'", "'}'", + "$accept", "translation_unit", "$@1", "version_statement", "extension_statement_list", "extension_statement", "external_declaration_list", "variable_identifier", "primary_expression", "postfix_expression", "integer_expression", "function_call", @@ -935,44 +931,44 @@ static const yytype_uint16 yytoknum[] = 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, - 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, - 445, 40, 41, 91, 93, 46, 44, 43, 45, 33, - 126, 42, 47, 37, 60, 62, 38, 94, 124, 63, - 58, 61, 59, 123, 125 + 435, 436, 437, 438, 439, 440, 441, 442, 40, 41, + 91, 93, 46, 44, 43, 45, 33, 126, 42, 47, + 37, 60, 62, 38, 94, 124, 63, 58, 61, 59, + 123, 125 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { - 0, 215, 217, 216, 218, 218, 219, 219, 220, 221, - 221, 222, 223, 223, 223, 223, 223, 223, 224, 224, - 224, 224, 224, 224, 225, 226, 227, 227, 228, 228, - 229, 229, 230, 230, 231, 232, 232, 232, 233, 233, - 233, 233, 234, 234, 234, 234, 235, 235, 235, 235, - 236, 236, 236, 237, 237, 237, 238, 238, 238, 238, - 238, 239, 239, 239, 240, 240, 241, 241, 242, 242, - 243, 243, 244, 244, 245, 245, 246, 246, 247, 247, - 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - 248, 249, 249, 250, 251, 251, 251, 252, 253, 253, - 254, 254, 255, 256, 256, 257, 257, 257, 257, 258, - 258, 258, 258, 259, 260, 260, 260, 260, 260, 260, - 260, 261, 261, 261, 261, 261, 261, 261, 261, 262, - 262, 263, 263, 264, 265, 265, 266, 267, 267, 267, - 268, 269, 269, 269, 270, 270, 270, 270, 270, 270, - 270, 270, 270, 271, 271, 272, 272, 272, 273, 273, - 273, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 275, 275, 275, 276, 276, - 277, 277, 278, 279, 279, 280, 280, 281, 282, 283, - 283, 284, 284, 285, 286, 286, 286, 286, 286, 286, - 286, 287, 287, 288, 288, 289, 289, 290, 290, 291, - 291, 292, 293, 293, 293, 294, 294, 295, 296, 296, - 297, 297, 297, 298, 298, 299, 299, 300, 300, 301, - 301, 301, 301, 301, 302, 302, 303 + 0, 212, 214, 213, 215, 215, 216, 216, 217, 218, + 218, 219, 220, 220, 220, 220, 220, 220, 221, 221, + 221, 221, 221, 221, 222, 223, 224, 224, 225, 225, + 226, 226, 227, 227, 228, 229, 229, 229, 230, 230, + 230, 230, 231, 231, 231, 231, 232, 232, 232, 232, + 233, 233, 233, 234, 234, 234, 235, 235, 235, 235, + 235, 236, 236, 236, 237, 237, 238, 238, 239, 239, + 240, 240, 241, 241, 242, 242, 243, 243, 244, 244, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 246, 246, 247, 248, 248, 248, 249, 250, 250, + 251, 251, 252, 253, 253, 254, 254, 254, 254, 255, + 255, 255, 255, 256, 257, 257, 257, 257, 257, 257, + 257, 258, 258, 258, 258, 258, 258, 258, 258, 259, + 259, 260, 260, 261, 262, 262, 263, 264, 264, 264, + 265, 266, 266, 266, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 268, 268, 269, 269, 269, 270, 270, + 270, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 272, 272, 272, 273, 273, 274, 274, 275, + 276, 276, 277, 277, 278, 279, 280, 280, 281, 281, + 282, 283, 283, 283, 283, 283, 283, 283, 284, 284, + 285, 285, 286, 286, 287, 287, 288, 288, 289, 290, + 290, 290, 291, 291, 292, 293, 293, 294, 294, 294, + 295, 295, 296, 296, 297, 297, 298, 298, 298, 298, + 298, 299, 299, 300 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -999,13 +995,13 @@ static const yytype_uint8 yyr2[] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 5, 4, - 1, 2, 3, 1, 3, 1, 4, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 3, 1, 1, 2, 3, 1, 2, 1, - 2, 7, 5, 5, 7, 1, 4, 5, 3, 2, - 5, 7, 6, 1, 1, 1, 0, 2, 3, 2, - 2, 2, 3, 2, 1, 1, 2 + 1, 1, 1, 1, 1, 5, 4, 1, 2, 3, + 1, 3, 1, 4, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 3, 1, 2, 1, 2, 7, 5, + 5, 7, 1, 4, 5, 3, 2, 5, 7, 6, + 1, 1, 1, 0, 2, 3, 2, 2, 2, 3, + 2, 1, 1, 2 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -1016,1061 +1012,1000 @@ static const yytype_uint16 yydefact[] = 4, 0, 0, 6, 0, 1, 2, 5, 0, 131, 7, 0, 145, 144, 165, 162, 163, 164, 169, 170, 171, 172, 173, 174, 175, 176, 177, 166, 167, 168, - 178, 179, 180, 0, 149, 152, 139, 138, 137, 181, - 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 193, 194, 195, 196, 198, 199, 200, 201, 202, 203, - 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, - 214, 0, 161, 160, 131, 217, 216, 215, 0, 0, - 192, 197, 131, 275, 0, 0, 99, 109, 0, 114, - 121, 0, 132, 131, 0, 141, 129, 153, 155, 158, - 0, 159, 9, 274, 0, 150, 151, 147, 0, 0, - 128, 131, 143, 0, 0, 10, 94, 131, 276, 97, - 109, 140, 110, 111, 112, 100, 0, 109, 0, 95, - 122, 148, 146, 142, 130, 0, 154, 0, 0, 0, - 0, 220, 0, 136, 0, 134, 0, 0, 131, 0, - 0, 0, 0, 0, 0, 0, 0, 11, 15, 13, - 14, 16, 37, 0, 0, 0, 42, 43, 44, 45, - 249, 131, 245, 12, 18, 38, 20, 25, 26, 0, - 0, 31, 0, 46, 0, 50, 53, 56, 61, 64, - 66, 68, 70, 72, 74, 76, 78, 91, 0, 228, - 0, 129, 234, 247, 229, 230, 232, 231, 131, 235, - 236, 233, 237, 238, 239, 240, 101, 106, 108, 113, - 0, 115, 102, 0, 0, 156, 46, 93, 0, 35, - 8, 0, 225, 0, 223, 219, 221, 96, 133, 0, - 270, 269, 0, 131, 0, 273, 271, 0, 0, 0, - 259, 131, 39, 40, 0, 241, 131, 22, 23, 0, - 0, 29, 28, 0, 161, 32, 34, 81, 82, 84, - 83, 86, 87, 88, 89, 90, 85, 80, 0, 41, + 0, 149, 152, 139, 138, 137, 178, 179, 180, 181, + 182, 183, 184, 185, 186, 187, 188, 190, 191, 192, + 193, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 209, 210, 211, 0, 161, + 160, 131, 214, 213, 212, 0, 0, 189, 194, 131, + 272, 0, 0, 99, 109, 0, 114, 121, 0, 132, + 131, 0, 141, 129, 153, 155, 158, 0, 159, 9, + 271, 0, 150, 151, 147, 0, 0, 128, 131, 143, + 0, 0, 10, 94, 131, 273, 97, 109, 140, 110, + 111, 112, 100, 0, 109, 0, 95, 122, 148, 146, + 142, 130, 0, 154, 0, 0, 0, 0, 217, 0, + 136, 0, 134, 0, 0, 131, 0, 0, 0, 0, + 0, 0, 0, 0, 11, 15, 13, 14, 16, 37, + 0, 0, 0, 42, 43, 44, 45, 246, 131, 242, + 12, 18, 38, 20, 25, 26, 0, 0, 31, 0, + 46, 0, 50, 53, 56, 61, 64, 66, 68, 70, + 72, 74, 76, 78, 91, 0, 225, 0, 129, 231, + 244, 226, 227, 229, 228, 131, 232, 233, 230, 234, + 235, 236, 237, 101, 106, 108, 113, 0, 115, 102, + 0, 0, 156, 46, 93, 0, 35, 8, 0, 222, + 0, 220, 216, 218, 96, 133, 0, 267, 266, 0, + 131, 0, 270, 268, 0, 0, 0, 256, 131, 39, + 40, 0, 238, 131, 22, 23, 0, 0, 29, 28, + 0, 161, 32, 34, 81, 82, 84, 83, 86, 87, + 88, 89, 90, 85, 80, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 250, 246, 248, 103, 105, 107, 0, 0, 123, - 0, 227, 127, 157, 218, 0, 0, 222, 135, 0, - 264, 263, 131, 0, 272, 0, 258, 255, 0, 0, - 17, 242, 0, 24, 21, 27, 33, 79, 47, 48, - 49, 51, 52, 54, 55, 59, 60, 57, 58, 62, - 63, 65, 67, 69, 71, 73, 75, 0, 92, 0, - 116, 0, 120, 0, 124, 0, 224, 0, 265, 0, - 0, 131, 0, 0, 131, 19, 0, 0, 0, 117, - 125, 0, 226, 0, 267, 131, 252, 253, 257, 0, - 0, 244, 260, 243, 77, 104, 118, 0, 126, 0, - 268, 262, 131, 256, 0, 119, 261, 251, 254, 0, - 131, 0, 131 + 0, 0, 0, 0, 0, 0, 0, 0, 247, 243, + 245, 103, 105, 107, 0, 0, 123, 0, 224, 127, + 157, 215, 0, 0, 219, 135, 0, 261, 260, 131, + 0, 269, 0, 255, 252, 0, 0, 17, 239, 0, + 24, 21, 27, 33, 79, 47, 48, 49, 51, 52, + 54, 55, 59, 60, 57, 58, 62, 63, 65, 67, + 69, 71, 73, 75, 0, 92, 0, 116, 0, 120, + 0, 124, 0, 221, 0, 262, 0, 0, 131, 0, + 0, 131, 19, 0, 0, 0, 117, 125, 0, 223, + 0, 264, 131, 249, 250, 254, 0, 0, 241, 257, + 240, 77, 104, 118, 0, 126, 0, 265, 259, 131, + 253, 0, 119, 258, 248, 251, 0, 131, 0, 131 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 2, 9, 3, 6, 10, 82, 173, 174, 175, - 332, 176, 177, 178, 179, 180, 181, 182, 183, 184, - 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, - 195, 196, 197, 278, 198, 228, 199, 200, 85, 86, - 87, 217, 125, 126, 218, 88, 89, 90, 91, 92, - 144, 145, 93, 127, 94, 95, 229, 97, 98, 99, - 100, 101, 140, 141, 233, 234, 312, 202, 203, 204, - 205, 206, 207, 392, 393, 208, 209, 210, 211, 329, - 212, 213, 214, 322, 369, 370, 215, 102, 103 + -1, 2, 9, 3, 6, 10, 79, 170, 171, 172, + 329, 173, 174, 175, 176, 177, 178, 179, 180, 181, + 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 275, 195, 225, 196, 197, 82, 83, + 84, 214, 122, 123, 215, 85, 86, 87, 88, 89, + 141, 142, 90, 124, 91, 92, 226, 94, 95, 96, + 97, 98, 137, 138, 230, 231, 309, 199, 200, 201, + 202, 203, 204, 389, 390, 205, 206, 207, 208, 326, + 209, 210, 211, 319, 366, 367, 212, 99, 100 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -361 +#define YYPACT_NINF -345 static const yytype_int16 yypact[] = { - -51, -15, 81, -361, -34, -361, -24, -361, 25, 3891, - -361, -19, -361, -361, -361, -361, -361, -361, -361, -361, - -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, - -361, -361, -361, 69, -361, -361, -361, -361, -361, -361, - -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, - -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, - -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, - -361, -78, -361, -361, 8, -361, -361, -361, 49, -80, - -361, -361, 3773, -361, -177, -79, -55, 2, -168, -361, - 70, 56, -361, 28, 4120, -361, -361, -361, -39, -361, - 4233, -361, -361, -361, 80, -361, -361, -361, -67, 4120, - -361, 28, -361, 4233, 95, -361, -361, 401, -361, -361, - 18, -361, -361, -361, -361, -361, 4120, 176, 116, -361, - -113, -361, -361, -361, -361, 2868, -361, 86, 4120, 126, - 2263, -361, 9, -361, -89, -361, 17, 24, 1249, 46, - 47, 27, 2489, 52, 3411, 30, 53, -70, -361, -361, - -361, -361, -361, 3411, 3411, 3411, -361, -361, -361, -361, - -361, 613, -361, -361, -361, -69, -361, -361, -361, 54, - -76, 3592, 59, 67, 3411, 22, 0, 115, -82, 125, - 39, 44, 45, 159, 161, -90, -361, -361, -159, -361, - 48, 66, -361, -361, -361, -361, -361, -361, 825, -361, - -361, -361, -361, -361, -361, -361, -361, -361, -361, 179, - 4120, -170, -361, 3049, 3411, -361, -361, -361, 65, -361, - -361, 2376, 68, -122, -361, -361, -361, -361, -361, 95, - -361, -361, 184, 1869, 3411, -361, -361, -121, 3411, -162, - -361, 2687, -361, -361, -60, -361, 1037, -361, -361, 3411, - 4007, -361, -361, 3411, 71, -361, -361, -361, -361, -361, - -361, -361, -361, -361, -361, -361, -361, -361, 3411, -361, - 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, - 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, - 3411, -361, -361, -361, 72, -361, -361, 3230, 3411, 55, - 73, -361, -361, -361, -361, 3411, 126, -361, -361, 77, - -361, -361, 2067, -59, -361, -52, -361, 74, 185, 79, - -361, -361, 75, 74, 82, -361, -361, -361, -361, -361, - -361, 22, 22, 0, 0, 115, 115, 115, 115, -82, - -82, 125, 39, 44, 45, 159, 161, -128, -361, 3411, - 61, 83, -361, 3411, 63, 85, -361, 3411, -361, 64, - 88, 1249, 62, 76, 1460, -361, 3411, 87, 3411, 78, - -361, 3411, -361, -49, 3411, 1460, 270, -361, -361, 3411, - 92, -361, -361, -361, -361, -361, -361, 3411, -361, 84, - 74, -361, 1249, -361, 3411, -361, -361, -361, -361, -41, - 1671, 272, 1671 + -30, 29, 120, -345, 15, -345, 22, -345, 59, 3758, + -345, 25, -345, -345, -345, -345, -345, -345, -345, -345, + -345, -345, -345, -345, -345, -345, -345, -345, -345, -345, + 79, -345, -345, -345, -345, -345, -345, -345, -345, -345, + -345, -345, -345, -345, -345, -345, -345, -345, -345, -345, + -345, -345, -345, -345, -345, -345, -345, -345, -345, -345, + -345, -345, -345, -345, -345, -345, -345, -345, -71, -345, + -345, 130, -345, -345, -345, -79, -42, -345, -345, 3642, + -345, -5, -38, -32, 4, -181, -345, 87, 62, -345, + 27, 3871, -345, -345, -345, -25, -345, 3943, -345, -345, + -345, 91, -345, -345, -345, -37, 3871, -345, 27, -345, + 3943, 95, -345, -345, 398, -345, -345, 19, -345, -345, + -345, -345, -345, 3871, 0, 119, -345, -128, -345, -345, + -345, -345, 2752, -345, 86, 3871, 131, 2153, -345, 11, + -345, -87, -345, 21, 23, 1234, 40, 50, 36, 2379, + 63, 3286, 43, 64, -73, -345, -345, -345, -345, -345, + 3286, 3286, 3286, -345, -345, -345, -345, -345, 607, -345, + -345, -345, -67, -345, -345, -345, 78, -62, 3464, 80, + -53, 3286, -1, 20, 140, -80, 136, 66, 67, 65, + 182, 181, -82, -345, -345, -173, -345, 103, 125, -345, + -345, -345, -345, -345, -345, 816, -345, -345, -345, -345, + -345, -345, -345, -345, -345, -345, 198, 3871, -140, -345, + 2930, 3286, -345, -345, -345, 84, -345, -345, 2266, 124, + -137, -345, -345, -345, -345, -345, 95, -345, -345, 240, + 1845, 3286, -345, -345, -118, 3286, -120, -345, 2574, -345, + -345, -48, -345, 1025, -345, -345, 3286, 235, -345, -345, + 3286, 128, -345, -345, -345, -345, -345, -345, -345, -345, + -345, -345, -345, -345, -345, 3286, -345, 3286, 3286, 3286, + 3286, 3286, 3286, 3286, 3286, 3286, 3286, 3286, 3286, 3286, + 3286, 3286, 3286, 3286, 3286, 3286, 3286, 3286, -345, -345, + -345, 129, -345, -345, 3108, 3286, 110, 132, -345, -345, + -345, -345, 3286, 131, -345, -345, 133, -345, -345, 2040, + -46, -345, -36, -345, 127, 246, 135, -345, -345, 134, + 127, 138, -345, -345, -345, -345, -345, -345, -1, -1, + 20, 20, 140, 140, 140, 140, -80, -80, 136, 66, + 67, 65, 182, 181, -117, -345, 3286, 121, 137, -345, + 3286, 122, 141, -345, 3286, -345, 118, 142, 1234, 123, + 126, 1442, -345, 3286, 144, 3286, 139, -345, 3286, -345, + -35, 3286, 1442, 324, -345, -345, 3286, 149, -345, -345, + -345, -345, -345, -345, 3286, -345, 143, 127, -345, 1234, + -345, 3286, -345, -345, -345, -345, -33, 1650, 326, 1650 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -361, -361, -361, -361, -361, -361, -361, -361, -361, -361, - -361, -361, -361, 26, -361, -361, -361, -361, -105, -361, - -64, -54, -81, -65, -8, -6, -5, -4, -3, -7, - -361, -111, -148, -361, -149, -221, 6, 11, -361, -361, - -361, 89, 173, 168, 90, -361, -361, -238, -361, -361, - -361, 58, -361, -361, -47, -361, -9, -71, -361, -361, - 220, -361, 162, -130, -361, -17, -236, 60, -131, -350, - -345, -360, -68, -84, 218, 134, 91, -361, -361, -16, - -361, -361, -361, -361, -361, -361, -361, 225, -361 + -345, -345, -345, -345, -345, -345, -345, -345, -345, -345, + -345, -345, -345, 85, -345, -345, -345, -345, -103, -345, + -54, -47, -74, -40, 53, 54, 52, 55, 56, 51, + -345, -110, -157, -345, -147, -219, 5, 7, -345, -345, + -345, 146, 232, 227, 147, -345, -345, -238, -345, -345, + -345, 117, -345, -345, -39, -345, -9, -14, -345, -345, + 279, -345, 220, -124, -345, 44, -286, 116, -134, -257, + -344, -294, -11, -22, 280, 197, 145, -345, -345, 47, + -345, -345, -345, -345, -345, -345, -345, 288, -345 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -267 +#define YYTABLE_NINF -264 static const yytype_int16 yytable[] = { - 96, 108, 310, 247, 298, 249, 121, 287, 288, -160, - 236, 12, 13, 328, 391, 83, 254, 242, 257, 258, - 84, 386, 121, 307, 227, 391, 387, 112, 128, 136, - 226, 12, 13, 265, 300, 116, 117, 300, 122, 123, - 124, 308, 142, 33, 129, 34, 133, 35, 326, 36, - 37, 38, 407, 301, 122, 123, 124, 408, 252, 253, - 411, 1, 407, 33, 112, 34, 4, 35, 300, 36, - 37, 38, 362, 96, 316, 300, 311, 303, 222, 279, - 223, 5, 376, 7, 328, 134, 361, 110, 83, 8, - 317, 324, 131, 84, 365, 323, 132, 104, 224, 325, - 139, 236, 327, 238, 11, 105, 106, 239, 201, 107, - 333, 114, 227, 119, 111, 336, 262, 219, 226, 299, - 263, -36, 289, 290, 259, 303, 260, 380, 79, 139, - 337, 139, 330, 371, 111, 109, 300, 300, 377, 201, - 372, 120, 396, 399, 300, 398, 138, 300, 79, 130, - 357, 410, 358, 403, 135, 300, 75, 76, 77, 137, - 311, 405, 201, 267, 268, 269, 270, 271, 272, 273, - 274, 275, 276, 327, 143, 338, 339, 340, 226, 226, - 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, - 226, 226, 226, 226, -98, 221, 227, 283, 284, 201, - 285, 286, 226, 230, 227, 232, 345, 346, 347, 348, - 226, 219, 122, 123, 124, 311, 291, 292, 383, 341, - 342, 237, 139, 280, 281, 282, 349, 350, 394, 240, - 311, 343, 344, 311, 201, 400, 241, 243, 244, 245, - 250, 311, 201, 248, 251, 293, 261, 201, 227, 311, - 266, 294, 296, 295, 226, 409, 297, -35, 304, 313, - 116, 315, 319, -30, 373, 359, 363, 364, 367, 375, - 300, 374, 378, -36, 381, 171, 384, 379, 277, 382, - 385, 395, 402, 404, 412, 351, 335, 389, 352, 397, - 353, 356, 354, 216, 355, 220, 406, 318, 113, 366, - 231, 401, 118, 320, 388, 256, 368, 115, 0, 305, - 306, 0, 0, 201, 0, 0, 0, 0, 0, 0, + 93, 307, 244, -160, 246, 105, 284, 285, 118, 295, + 325, 239, 125, 233, 80, 251, 81, 254, 255, 359, + 297, 262, 224, 118, 384, 72, 73, 74, 126, 223, + 12, 13, 109, 119, 120, 121, 298, 119, 120, 121, + 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, + 304, 130, 119, 120, 121, 405, 313, 249, 250, 30, + 219, 31, 220, 32, 308, 33, 34, 35, 305, 109, + 93, 300, 314, 297, 377, 297, 297, 388, 276, 1, + 221, 325, 131, 133, 80, 358, 81, 323, 388, 393, + 373, 321, 395, 362, 320, 128, 139, 136, 322, 129, + 400, 324, 235, 333, 233, 198, 236, 4, 402, 330, + 224, 383, 102, 103, 216, -36, 104, 223, 334, 300, + 5, 286, 287, 256, 296, 257, 136, 259, 136, 7, + 108, 260, 8, 12, 13, 11, 198, 374, 101, 106, + 355, 327, 404, 368, 76, 297, 111, 297, 308, 354, + 408, 116, 404, 369, 396, 274, 407, 297, 297, 198, + 297, 117, 30, 127, 31, 132, 32, 134, 33, 34, + 35, 140, 324, 135, 335, 336, 337, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, -98, 224, 218, 198, 277, 278, 279, + 227, 223, 224, 308, 113, 114, 107, 229, 216, 223, + 342, 343, 344, 345, 280, 281, 391, 380, 308, 136, + 234, 308, 282, 283, 288, 289, 338, 339, 240, 308, + 237, 198, 238, 108, 397, 340, 341, 308, 241, 198, + 14, 15, 16, 17, 198, 242, 224, 76, 346, 347, + 247, 245, 248, 223, 406, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 258, 263, 290, + 292, 291, 293, 294, 301, 310, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 198, 331, 113, -35, 312, 316, 159, -30, 360, 356, + 297, 364, 370, 361, 371, 372, -36, 381, 376, 375, + 378, 382, 379, 168, 386, 392, 399, 401, 409, 72, + 73, 74, 332, 348, 350, 349, 353, 394, 351, 213, + 352, 217, 403, 315, 110, 228, 317, 363, 385, 198, + 398, 115, 198, 302, 303, 253, 365, 112, 0, 0, + 0, 0, 0, 198, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 318, 77, 0, 78, 0, + 198, 0, 0, 0, 0, 0, 0, 0, 198, 0, + 198, 12, 13, 14, 15, 16, 17, 143, 144, 145, + 0, 146, 147, 148, 149, 150, 151, 152, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 0, 31, 0, 32, 0, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 153, 154, 155, 156, 157, 158, 159, + 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 321, 0, 0, 0, 0, 0, + 0, 71, 72, 73, 74, 0, 75, 0, 0, 0, + 0, 0, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 201, 0, 0, 201, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 201, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, + 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 201, 0, 0, 0, 0, 0, 0, - 0, 201, 0, 201, 12, 13, 14, 15, 16, 17, - 146, 147, 148, 0, 149, 150, 151, 152, 153, 154, - 155, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 0, 34, 0, - 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 156, - 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 74, 75, 76, - 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, - 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 162, 0, 0, 0, + 0, 0, 163, 164, 165, 166, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 167, 168, 169, + 12, 13, 14, 15, 16, 17, 143, 144, 145, 0, + 146, 147, 148, 149, 150, 151, 152, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 0, 31, 0, 32, 0, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 153, 154, 155, 156, 157, 158, 159, 0, + 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 71, 72, 73, 74, 0, 75, 0, 0, 0, 0, + 0, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 77, 0, + 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 165, 0, 0, 0, 0, 0, 166, 167, - 168, 169, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 170, 171, 172, 12, 13, 14, 15, - 16, 17, 146, 147, 148, 0, 149, 150, 151, 152, - 153, 154, 155, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, - 34, 0, 35, 0, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 156, 157, 158, 159, 160, 161, 162, 0, 0, - 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 76, 77, 0, 78, 0, 0, 0, 0, 0, - 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 162, 0, 0, 0, 0, + 0, 163, 164, 165, 166, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 167, 168, 252, 12, + 13, 14, 15, 16, 17, 143, 144, 145, 0, 146, + 147, 148, 149, 150, 151, 152, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, + 31, 0, 32, 0, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 153, 154, 155, 156, 157, 158, 159, 0, 0, + 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, + 72, 73, 74, 0, 75, 0, 0, 0, 0, 0, + 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 80, 0, 81, + 0, 0, 0, 0, 0, 0, 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 165, 0, 0, 0, 0, 0, - 166, 167, 168, 169, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 170, 171, 255, 12, 13, - 14, 15, 16, 17, 146, 147, 148, 0, 149, 150, - 151, 152, 153, 154, 155, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 0, 34, 0, 35, 0, 36, 37, 38, 39, + 0, 0, 0, 0, 162, 0, 0, 0, 0, 0, + 163, 164, 165, 166, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 167, 168, 299, 12, 13, + 14, 15, 16, 17, 143, 144, 145, 0, 146, 147, + 148, 149, 150, 151, 152, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 0, 31, + 0, 32, 0, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 156, 157, 158, 159, 160, 161, 162, - 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, + 153, 154, 155, 156, 157, 158, 159, 0, 0, 160, + 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 71, 72, + 73, 74, 0, 75, 0, 0, 0, 0, 0, 0, + 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 74, 75, 76, 77, 0, 78, 0, 0, 0, - 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, - 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 165, 0, 0, 0, - 0, 0, 166, 167, 168, 169, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 170, 171, 302, - 12, 13, 14, 15, 16, 17, 146, 147, 148, 0, - 149, 150, 151, 152, 153, 154, 155, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 156, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, + 0, 0, 0, 162, 0, 0, 0, 0, 0, 163, + 164, 165, 166, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 167, 168, 328, 12, 13, 14, + 15, 16, 17, 143, 144, 145, 0, 146, 147, 148, + 149, 150, 151, 152, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 0, 31, 0, + 32, 0, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 153, + 154, 155, 156, 157, 158, 159, 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 74, 75, 76, 77, 0, 78, 0, - 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 71, 72, 73, + 74, 0, 75, 0, 0, 0, 0, 0, 0, 0, + 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, - 0, 0, 0, 0, 166, 167, 168, 169, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 170, - 171, 331, 12, 13, 14, 15, 16, 17, 146, 147, - 148, 0, 149, 150, 151, 152, 153, 154, 155, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 0, 34, 0, 35, 0, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 156, 157, 158, - 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, + 0, 0, 162, 0, 0, 0, 0, 0, 163, 164, + 165, 166, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 167, 168, 12, 13, 14, 15, 16, + 17, 143, 144, 145, 0, 146, 387, 148, 149, 150, + 151, 152, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 0, 31, 0, 32, 0, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 153, 154, 155, + 156, 157, 158, 159, 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 74, 75, 76, 77, 0, - 78, 0, 0, 0, 0, 0, 0, 0, 0, 79, + 0, 0, 0, 0, 0, 71, 72, 73, 74, 0, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, + 0, 0, 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, + 162, 0, 0, 0, 0, 0, 163, 164, 165, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 170, 171, 12, 13, 14, 15, 16, 17, 146, - 147, 148, 0, 149, 390, 151, 152, 153, 154, 155, + 0, 167, 114, 12, 13, 14, 15, 16, 17, 143, + 144, 145, 0, 146, 387, 148, 149, 150, 151, 152, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 0, 34, 0, 35, - 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 28, 29, 30, 0, 31, 0, 32, 0, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 156, 157, - 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 74, 75, 76, 77, - 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, - 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 65, 66, 67, 68, 69, 153, 154, 155, 156, 157, + 158, 159, 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, + 0, 0, 0, 71, 72, 73, 74, 0, 75, 0, + 0, 0, 0, 0, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 165, 0, 0, 0, 0, 0, 166, 167, 168, - 169, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 170, 117, 12, 13, 14, 15, 16, 17, - 146, 147, 148, 0, 149, 390, 151, 152, 153, 154, - 155, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 0, 34, 0, - 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 156, - 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 74, 75, 76, - 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, - 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 162, 0, + 0, 0, 0, 0, 163, 164, 165, 166, 12, 13, + 14, 15, 16, 17, 0, 0, 0, 0, 0, 167, + 168, 0, 0, 0, 0, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 0, 31, + 0, 32, 0, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 0, 154, 155, 156, 157, 158, 159, 0, 0, 160, + 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 71, 72, + 73, 74, 0, 75, 0, 0, 0, 0, 0, 0, + 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 165, 0, 0, 0, 0, 0, 166, 167, - 168, 169, 12, 13, 14, 15, 16, 17, 0, 0, - 0, 0, 0, 170, 171, 0, 0, 0, 0, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 0, 34, 0, 35, 0, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 0, 157, 158, - 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 74, 75, 76, 77, 0, - 78, 0, 0, 0, 0, 0, 0, 0, 0, 79, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, - 12, 13, 14, 15, 16, 17, 0, 0, 0, 0, - 0, 170, 0, 0, 0, 0, 0, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 111, 75, 76, 77, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 162, 0, 0, 0, 0, 0, 163, + 164, 165, 166, 12, 13, 14, 15, 16, 17, 0, + 0, 0, 0, 0, 167, 0, 0, 0, 0, 0, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 0, 31, 0, 32, 0, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 0, 154, 155, 156, 157, + 158, 159, 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, - 0, 0, 0, 0, 166, 167, 168, 169, 14, 15, - 16, 17, 0, 0, 0, 0, 0, 0, 0, -266, + 0, 0, 0, 108, 72, 73, 74, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 76, 14, 15, + 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 39, 40, 41, + 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, + 0, 77, 0, 78, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, + 62, 63, 64, 65, 66, 67, 68, 69, 162, 70, + 0, 0, 0, 0, 163, 164, 165, 166, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -263, + 0, 0, 0, 0, 0, 0, 0, 72, 73, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 0, 0, 0, 0, 0, 0, 80, 0, 81, + 22, 23, 24, 25, 26, 27, 28, 29, 0, 0, + 0, 0, 0, 0, 77, 0, 78, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 0, 73, 0, 0, 0, 0, + 69, 0, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 235, 0, 0, - 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, + 0, 0, 0, 0, 232, 0, 0, 0, 0, 0, + 72, 73, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, - 80, 0, 81, 39, 40, 41, 42, 43, 44, 45, + 29, 0, 0, 0, 0, 0, 0, 77, 0, 78, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 0, 157, 158, - 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, + 66, 67, 68, 69, 0, 154, 155, 156, 157, 158, + 159, 0, 0, 160, 161, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 311, 0, 0, + 0, 0, 0, 72, 73, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 314, 0, 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 162, 0, 0, + 0, 0, 0, 163, 164, 165, 166, 12, 13, 14, + 15, 16, 17, 0, 0, 0, 0, 0, 243, 0, + 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 0, 31, 0, + 32, 0, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 0, + 154, 155, 156, 157, 158, 159, 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 108, 72, 73, + 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 165, 0, 0, 0, 0, 0, 166, 167, 168, 169, - 12, 13, 14, 15, 16, 17, 0, 0, 0, 0, - 0, 246, 0, 0, 0, 0, 0, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 0, 34, 0, 35, 0, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 0, 157, 158, 159, 160, - 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 111, 75, 76, 77, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, + 0, 0, 0, 0, 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, + 17, 0, 162, 0, 0, 0, 0, 0, 163, 164, + 165, 166, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 0, 154, 155, + 156, 157, 158, 159, 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 72, 73, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 14, 15, 16, 17, 0, 165, 0, - 0, 0, 0, 0, 166, 167, 168, 169, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 0, 157, 158, 159, - 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, + 162, 0, 0, 222, 0, 0, 163, 164, 165, 166, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 0, 154, 155, 156, 157, + 158, 159, 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 72, 73, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 14, 15, 16, 17, 0, 165, - 0, 0, 225, 0, 0, 166, 167, 168, 169, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 0, 157, 158, - 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 14, 15, 16, 17, 0, 162, 0, + 0, 306, 0, 0, 163, 164, 165, 166, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 0, 154, 155, 156, 157, 158, 159, + 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, + 0, 0, 72, 73, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, - 165, 0, 0, 309, 0, 0, 166, 167, 168, 169, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 0, 157, - 158, 159, 160, 161, 162, 0, 0, 163, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 75, 76, 77, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, + 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 14, 15, 16, 17, 0, 162, 0, 0, 357, + 0, 0, 163, 164, 165, 166, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 0, 154, 155, 156, 157, 158, 159, 0, 0, + 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 72, 73, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, - 0, 165, 0, 0, 360, 0, 0, 166, 167, 168, - 169, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, - 157, 158, 159, 160, 161, 162, 0, 0, 163, 164, + 0, 0, 0, 0, 0, 0, 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, - 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, + 15, 16, 17, 0, 162, 0, 0, 0, 0, 0, + 163, 164, 165, 166, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 261, 0, + 154, 155, 156, 157, 158, 159, 0, 0, 160, 161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 72, 73, + 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, - 17, 0, 165, 0, 0, 0, 0, 0, 166, 167, - 168, 169, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 264, - 0, 157, 158, 159, 160, 161, 162, 0, 0, 163, - 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, - 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -3, 0, 0, 12, 13, 14, 15, 16, + 17, 0, 162, 0, 0, 0, 0, 0, 163, 164, + 165, 166, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 0, 31, 0, 32, 0, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 0, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 80, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 71, 72, 73, 74, 0, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 76, + 0, 12, 13, 14, 15, 16, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 0, 31, 77, 32, 78, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 0, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -3, 0, 0, 12, 13, 14, 15, - 16, 17, 0, 165, 0, 0, 0, 0, 0, 166, - 167, 168, 169, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, - 34, 0, 35, 0, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 76, 77, 0, 78, 0, 0, 0, 0, 0, - 0, 0, 0, 79, 12, 13, 14, 15, 16, 17, + 0, 71, 72, 73, 74, 0, 75, 0, 0, 0, + 0, 0, 0, 0, 0, 76, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 80, 34, 81, - 35, 0, 36, 37, 38, 39, 40, 41, 42, 43, + 27, 28, 29, 0, 0, 0, 0, 0, 0, 77, + 0, 78, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, - 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 74, 75, 76, - 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, - 0, 79, 14, 15, 16, 17, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 0, 0, 80, 0, 81, 0, 0, - 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 0, 334, 0, 0, 0, - 0, 162, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, - 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, - 0, 80, 0, 81, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 0, 73, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 75, 76, 77, - 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, + 64, 65, 66, 67, 68, 69, 0, 70, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, - 0, 0, 0, 0, 80, 0, 81, 39, 40, 41, + 25, 26, 27, 28, 29, 72, 73, 74, 0, 0, + 0, 0, 0, 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 0, 73, 0, 0, 0, 0, 0, 0, 0, + 62, 63, 64, 65, 66, 67, 68, 69, 0, 70, + 0, 0, 77, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 80, 0, 81 + 0, 0, 0, 0, 77, 0, 78 }; static const yytype_int16 yycheck[] = { - 9, 79, 223, 152, 94, 154, 4, 89, 90, 79, - 140, 3, 4, 251, 374, 9, 165, 148, 87, 88, - 9, 371, 4, 193, 135, 385, 371, 74, 196, 100, - 135, 3, 4, 181, 196, 212, 213, 196, 36, 37, - 38, 211, 113, 35, 212, 37, 93, 39, 210, 41, - 42, 43, 402, 212, 36, 37, 38, 402, 163, 164, - 410, 112, 412, 35, 111, 37, 81, 39, 196, 41, - 42, 43, 308, 82, 196, 196, 224, 208, 191, 184, - 193, 0, 210, 117, 322, 94, 307, 79, 82, 113, - 212, 212, 36, 82, 315, 244, 40, 116, 211, 248, - 109, 231, 251, 192, 79, 36, 37, 196, 117, 40, - 259, 191, 223, 192, 106, 263, 192, 126, 223, 209, - 196, 191, 204, 205, 193, 256, 195, 363, 120, 138, - 278, 140, 192, 192, 106, 213, 196, 196, 359, 148, - 192, 196, 378, 192, 196, 381, 213, 196, 120, 79, - 299, 192, 300, 389, 193, 196, 107, 108, 109, 79, - 308, 397, 171, 96, 97, 98, 99, 100, 101, 102, - 103, 104, 105, 322, 79, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 192, 79, 307, 197, 198, 208, - 85, 86, 307, 117, 315, 79, 287, 288, 289, 290, - 315, 220, 36, 37, 38, 363, 91, 92, 367, 283, - 284, 212, 231, 201, 202, 203, 291, 292, 376, 212, - 378, 285, 286, 381, 243, 384, 212, 191, 191, 212, - 210, 389, 251, 191, 191, 206, 192, 256, 359, 397, - 191, 207, 93, 208, 359, 404, 95, 191, 79, 194, - 212, 193, 78, 192, 79, 193, 211, 194, 191, 194, - 196, 192, 211, 191, 211, 213, 212, 194, 211, 194, - 192, 194, 12, 191, 12, 293, 260, 211, 294, 211, - 295, 298, 296, 120, 297, 127, 212, 239, 78, 316, - 138, 385, 84, 243, 372, 171, 322, 82, -1, 220, - 220, -1, -1, 322, -1, -1, -1, -1, -1, -1, + 9, 220, 149, 76, 151, 76, 86, 87, 4, 91, + 248, 145, 193, 137, 9, 162, 9, 84, 85, 305, + 193, 178, 132, 4, 368, 104, 105, 106, 209, 132, + 3, 4, 71, 33, 34, 35, 209, 33, 34, 35, + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 190, 90, 33, 34, 35, 399, 193, 160, 161, 32, + 188, 34, 190, 36, 221, 38, 39, 40, 208, 108, + 79, 205, 209, 193, 360, 193, 193, 371, 181, 109, + 208, 319, 91, 97, 79, 304, 79, 207, 382, 375, + 207, 209, 378, 312, 241, 33, 110, 106, 245, 37, + 386, 248, 189, 260, 228, 114, 193, 78, 394, 256, + 220, 368, 33, 34, 123, 188, 37, 220, 275, 253, + 0, 201, 202, 190, 206, 192, 135, 189, 137, 114, + 103, 193, 110, 3, 4, 76, 145, 356, 113, 210, + 297, 189, 399, 189, 117, 193, 188, 193, 305, 296, + 407, 189, 409, 189, 189, 208, 189, 193, 193, 168, + 193, 193, 32, 76, 34, 190, 36, 76, 38, 39, + 40, 76, 319, 210, 277, 278, 279, 280, 281, 282, + 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, + 293, 294, 295, 189, 304, 76, 205, 198, 199, 200, + 114, 304, 312, 360, 209, 210, 76, 76, 217, 312, + 284, 285, 286, 287, 194, 195, 373, 364, 375, 228, + 209, 378, 82, 83, 88, 89, 280, 281, 188, 386, + 209, 240, 209, 103, 381, 282, 283, 394, 188, 248, + 5, 6, 7, 8, 253, 209, 356, 117, 288, 289, + 207, 188, 188, 356, 401, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 189, 188, 203, + 205, 204, 90, 92, 76, 191, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 319, 76, 209, 188, 190, 75, 81, 189, 208, 190, + 193, 188, 76, 191, 189, 191, 188, 209, 191, 208, + 208, 189, 191, 210, 208, 191, 12, 188, 12, 104, + 105, 106, 257, 290, 292, 291, 295, 208, 293, 117, + 294, 124, 209, 236, 75, 135, 240, 313, 369, 368, + 382, 81, 371, 217, 217, 168, 319, 79, -1, -1, + -1, -1, -1, 382, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 240, 151, -1, 153, -1, + 399, -1, -1, -1, -1, -1, -1, -1, 407, -1, + 409, 3, 4, 5, 6, 7, 8, 9, 10, 11, + -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, -1, 34, -1, 36, -1, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 243, -1, -1, -1, -1, -1, + -1, 103, 104, 105, 106, -1, 108, -1, -1, -1, + -1, -1, -1, -1, -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 371, -1, -1, 374, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 385, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 151, + -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 402, -1, -1, -1, -1, -1, -1, - -1, 410, -1, 412, 3, 4, 5, 6, 7, 8, - 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, -1, 37, -1, - 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, - 109, -1, 111, -1, -1, -1, -1, -1, -1, -1, - -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 188, -1, -1, -1, + -1, -1, 194, 195, 196, 197, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 209, 210, 211, + 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + -1, 34, -1, 36, -1, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, -1, + -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 103, 104, 105, 106, -1, 108, -1, -1, -1, -1, + -1, -1, -1, -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 151, -1, + 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 191, -1, -1, -1, -1, -1, 197, 198, - 199, 200, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 212, 213, 214, 3, 4, 5, 6, - 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, - 37, -1, 39, -1, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 81, 82, 83, 84, -1, -1, - 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, - 107, 108, 109, -1, 111, -1, -1, -1, -1, -1, - -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 188, -1, -1, -1, -1, + -1, 194, 195, 196, 197, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 209, 210, 211, 3, + 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, + 34, -1, 36, -1, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, -1, -1, + 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, + 104, 105, 106, -1, 108, -1, -1, -1, -1, -1, + -1, -1, -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 154, -1, 156, + -1, -1, -1, -1, -1, -1, -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 191, -1, -1, -1, -1, -1, - 197, 198, 199, 200, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 212, 213, 214, 3, 4, + -1, -1, -1, -1, 188, -1, -1, -1, -1, -1, + 194, 195, 196, 197, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 209, 210, 211, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, -1, 37, -1, 39, -1, 41, 42, 43, 44, + 25, 26, 27, 28, 29, 30, 31, 32, -1, 34, + -1, 36, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, + 75, 76, 77, 78, 79, 80, 81, -1, -1, 84, + 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 103, 104, + 105, 106, -1, 108, -1, -1, -1, -1, -1, -1, + -1, -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 106, 107, 108, 109, -1, 111, -1, -1, -1, - -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, - -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 191, -1, -1, -1, - -1, -1, 197, 198, 199, 200, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 212, 213, 214, - 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, + -1, -1, -1, 188, -1, -1, -1, -1, -1, 194, + 195, 196, 197, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 209, 210, 211, 3, 4, 5, + 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, -1, 34, -1, + 36, -1, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 106, 107, 108, 109, -1, 111, -1, - -1, -1, -1, -1, -1, -1, -1, 120, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 103, 104, 105, + 106, -1, 108, -1, -1, -1, -1, -1, -1, -1, + -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 191, -1, - -1, -1, -1, -1, 197, 198, 199, 200, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 212, - 213, 214, 3, 4, 5, 6, 7, 8, 9, 10, - 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, -1, 37, -1, 39, -1, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, + -1, -1, 188, -1, -1, -1, -1, -1, 194, 195, + 196, 197, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 209, 210, 3, 4, 5, 6, 7, + 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, -1, 34, -1, 36, -1, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 106, 107, 108, 109, -1, - 111, -1, -1, -1, -1, -1, -1, -1, -1, 120, + -1, -1, -1, -1, -1, 103, 104, 105, 106, -1, + 108, -1, -1, -1, -1, -1, -1, -1, -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, + -1, -1, -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 191, -1, -1, -1, -1, -1, 197, 198, 199, 200, + 188, -1, -1, -1, -1, -1, 194, 195, 196, 197, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 212, 213, 3, 4, 5, 6, 7, 8, 9, + -1, 209, 210, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, - -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 30, 31, 32, -1, 34, -1, 36, -1, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 106, 107, 108, 109, - -1, 111, -1, -1, -1, -1, -1, -1, -1, -1, - 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, + 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 103, 104, 105, 106, -1, 108, -1, + -1, -1, -1, -1, -1, -1, -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 191, -1, -1, -1, -1, -1, 197, 198, 199, - 200, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 212, 213, 3, 4, 5, 6, 7, 8, - 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, -1, 37, -1, - 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, - 109, -1, 111, -1, -1, -1, -1, -1, -1, -1, - -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 191, -1, -1, -1, -1, -1, 197, 198, - 199, 200, 3, 4, 5, 6, 7, 8, -1, -1, - -1, -1, -1, 212, 213, -1, -1, -1, -1, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, -1, 37, -1, 39, -1, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, -1, 79, 80, - 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 106, 107, 108, 109, -1, - 111, -1, -1, -1, -1, -1, -1, -1, -1, 120, + -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 188, -1, + -1, -1, -1, -1, 194, 195, 196, 197, 3, 4, + 5, 6, 7, 8, -1, -1, -1, -1, -1, 209, + 210, -1, -1, -1, -1, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, -1, 34, + -1, 36, -1, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + -1, 76, 77, 78, 79, 80, 81, -1, -1, 84, + 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 103, 104, + 105, 106, -1, 108, -1, -1, -1, -1, -1, -1, + -1, -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 191, -1, -1, -1, -1, -1, 197, 198, 199, 200, - 3, 4, 5, 6, 7, 8, -1, -1, -1, -1, - -1, 212, -1, -1, -1, -1, -1, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 106, 107, 108, 109, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 188, -1, -1, -1, -1, -1, 194, + 195, 196, 197, 3, 4, 5, 6, 7, 8, -1, + -1, -1, -1, -1, 209, -1, -1, -1, -1, -1, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, -1, 34, -1, 36, -1, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, -1, 76, 77, 78, 79, + 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 191, -1, - -1, -1, -1, -1, 197, 198, 199, 200, 5, 6, - 7, 8, -1, -1, -1, -1, -1, -1, -1, 212, + -1, -1, -1, 103, 104, 105, 106, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 117, 5, 6, + 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 44, 45, 46, + 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, + -1, 151, -1, 153, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 67, 68, 69, 70, 71, 72, 73, 74, 188, 76, + -1, -1, -1, -1, 194, 195, 196, 197, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 209, + -1, -1, -1, -1, -1, -1, -1, 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, -1, -1, -1, -1, -1, -1, 154, -1, 156, + 24, 25, 26, 27, 28, 29, 30, 31, -1, -1, + -1, -1, -1, -1, 151, -1, 153, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, -1, 79, -1, -1, -1, -1, + 74, -1, 76, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 214, -1, -1, - -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, + -1, -1, -1, -1, 211, -1, -1, -1, -1, -1, + 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, -1, -1, -1, -1, -1, -1, - 154, -1, 156, 44, 45, 46, 47, 48, 49, 50, + 31, -1, -1, -1, -1, -1, -1, 151, -1, 153, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, -1, 79, 80, - 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, + 71, 72, 73, 74, -1, 76, 77, 78, 79, 80, + 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 211, -1, -1, + -1, -1, -1, 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 214, -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 188, -1, -1, + -1, -1, -1, 194, 195, 196, 197, 3, 4, 5, + 6, 7, 8, -1, -1, -1, -1, -1, 209, -1, + -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, -1, 34, -1, + 36, -1, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, + 76, 77, 78, 79, 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 103, 104, 105, + 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 191, -1, -1, -1, -1, -1, 197, 198, 199, 200, - 3, 4, 5, 6, 7, 8, -1, -1, -1, -1, - -1, 212, -1, -1, -1, -1, -1, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, -1, 37, -1, 39, -1, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, 79, 80, 81, 82, - 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 106, 107, 108, 109, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 120, -1, -1, + -1, -1, -1, -1, -1, 151, -1, 153, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, + 8, -1, 188, -1, -1, -1, -1, -1, 194, 195, + 196, 197, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, -1, 76, 77, + 78, 79, 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 5, 6, 7, 8, -1, 191, -1, - -1, -1, -1, -1, 197, 198, 199, 200, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, -1, 79, 80, 81, - 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, + -1, -1, -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, + 188, -1, -1, 191, -1, -1, 194, 195, 196, 197, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, -1, 76, 77, 78, 79, + 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 5, 6, 7, 8, -1, 191, - -1, -1, 194, -1, -1, 197, 198, 199, 200, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, -1, 79, 80, - 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 107, 108, 109, -1, + -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 5, 6, 7, 8, -1, 188, -1, + -1, 191, -1, -1, 194, 195, 196, 197, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, -1, 76, 77, 78, 79, 80, 81, + -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, - 191, -1, -1, 194, -1, -1, 197, 198, 199, 200, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, - 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 151, + -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 5, 6, 7, 8, -1, 188, -1, -1, 191, + -1, -1, 194, 195, 196, 197, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, -1, 76, 77, 78, 79, 80, 81, -1, -1, + 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, - -1, 191, -1, -1, 194, -1, -1, 197, 198, 199, - 200, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, - 79, 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 107, 108, - 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, + 6, 7, 8, -1, 188, -1, -1, -1, -1, -1, + 194, 195, 196, 197, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, + 76, 77, 78, 79, 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 104, 105, + 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, - 8, -1, 191, -1, -1, -1, -1, -1, 197, 198, - 199, 200, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 44, 45, 46, 47, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 0, -1, -1, 3, 4, 5, 6, 7, + 8, -1, 188, -1, -1, -1, -1, -1, 194, 195, + 196, 197, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, -1, 34, -1, 36, -1, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - -1, 79, 80, 81, 82, 83, 84, -1, -1, 87, - 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 107, - 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 68, 69, 70, 71, 72, 73, 74, -1, 76, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 103, 104, 105, 106, -1, + 108, -1, -1, -1, -1, -1, -1, -1, -1, 117, + -1, 3, 4, 5, 6, 7, 8, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, -1, 34, 151, 36, 153, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, -1, 76, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 0, -1, -1, 3, 4, 5, 6, - 7, 8, -1, 191, -1, -1, -1, -1, -1, 197, - 198, 199, 200, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, - 37, -1, 39, -1, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, - 107, 108, 109, -1, 111, -1, -1, -1, -1, -1, - -1, -1, -1, 120, 3, 4, 5, 6, 7, 8, + -1, 103, 104, 105, 106, -1, 108, -1, -1, -1, + -1, -1, -1, -1, -1, 117, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 154, 37, 156, - 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, + 29, 30, 31, -1, -1, -1, -1, -1, -1, 151, + -1, 153, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, - 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, - 109, -1, 111, -1, -1, -1, -1, -1, -1, -1, - -1, 120, 5, 6, 7, 8, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, -1, -1, 154, -1, 156, -1, -1, - -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, 79, -1, -1, -1, - -1, 84, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 107, 108, 109, -1, -1, -1, - -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, -1, -1, -1, -1, -1, - -1, 154, -1, 156, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, -1, 79, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 107, 108, 109, - -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, + 69, 70, 71, 72, 73, 74, -1, 76, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, -1, -1, - -1, -1, -1, -1, 154, -1, 156, 44, 45, 46, + 27, 28, 29, 30, 31, 104, 105, 106, -1, -1, + -1, -1, -1, -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, + 67, 68, 69, 70, 71, 72, 73, 74, -1, 76, + -1, -1, 151, -1, 153, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 154, -1, 156 + -1, -1, -1, -1, 151, -1, 153 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { - 0, 112, 216, 218, 81, 0, 219, 117, 113, 217, - 220, 79, 3, 4, 5, 6, 7, 8, 20, 21, + 0, 109, 213, 215, 78, 0, 216, 114, 110, 214, + 217, 76, 3, 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 37, 39, 41, 42, 43, 44, + 32, 34, 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 79, 106, 107, 108, 109, 111, 120, - 154, 156, 221, 251, 252, 253, 254, 255, 260, 261, - 262, 263, 264, 267, 269, 270, 271, 272, 273, 274, - 275, 276, 302, 303, 116, 36, 37, 40, 79, 213, - 79, 106, 269, 275, 191, 302, 212, 213, 289, 192, - 196, 4, 36, 37, 38, 257, 258, 268, 196, 212, - 79, 36, 40, 269, 271, 193, 272, 79, 213, 271, - 277, 278, 272, 79, 265, 266, 9, 10, 11, 13, - 14, 15, 16, 17, 18, 19, 78, 79, 80, 81, - 82, 83, 84, 87, 88, 191, 197, 198, 199, 200, - 212, 213, 214, 222, 223, 224, 226, 227, 228, 229, + 76, 103, 104, 105, 106, 108, 117, 151, 153, 218, + 248, 249, 250, 251, 252, 257, 258, 259, 260, 261, + 264, 266, 267, 268, 269, 270, 271, 272, 273, 299, + 300, 113, 33, 34, 37, 76, 210, 76, 103, 266, + 272, 188, 299, 209, 210, 286, 189, 193, 4, 33, + 34, 35, 254, 255, 265, 193, 209, 76, 33, 37, + 266, 268, 190, 269, 76, 210, 268, 274, 275, 269, + 76, 262, 263, 9, 10, 11, 13, 14, 15, 16, + 17, 18, 19, 75, 76, 77, 78, 79, 80, 81, + 84, 85, 188, 194, 195, 196, 197, 209, 210, 211, + 219, 220, 221, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 249, 251, - 252, 271, 282, 283, 284, 285, 286, 287, 290, 291, - 292, 293, 295, 296, 297, 301, 257, 256, 259, 271, - 258, 79, 191, 193, 211, 194, 233, 246, 250, 271, - 117, 277, 79, 279, 280, 214, 278, 212, 192, 196, - 212, 212, 283, 191, 191, 212, 212, 249, 191, 249, - 210, 191, 233, 233, 249, 214, 290, 87, 88, 193, - 195, 192, 192, 196, 77, 247, 191, 96, 97, 98, - 99, 100, 101, 102, 103, 104, 105, 211, 248, 233, - 201, 202, 203, 197, 198, 85, 86, 89, 90, 204, - 205, 91, 92, 206, 207, 208, 93, 95, 94, 209, - 196, 212, 214, 283, 79, 256, 259, 193, 211, 194, - 250, 247, 281, 194, 214, 193, 196, 212, 266, 78, - 282, 291, 298, 249, 212, 249, 210, 249, 262, 294, - 192, 214, 225, 249, 79, 228, 247, 247, 233, 233, - 233, 235, 235, 236, 236, 237, 237, 237, 237, 238, - 238, 239, 240, 241, 242, 243, 244, 249, 247, 193, - 194, 250, 281, 211, 194, 250, 280, 191, 294, 299, - 300, 192, 192, 79, 192, 194, 210, 250, 211, 194, - 281, 211, 194, 249, 212, 192, 284, 285, 287, 211, - 14, 286, 288, 289, 247, 194, 281, 211, 281, 192, - 249, 288, 12, 281, 191, 281, 212, 284, 285, 249, - 192, 284, 12 + 240, 241, 242, 243, 244, 246, 248, 249, 268, 279, + 280, 281, 282, 283, 284, 287, 288, 289, 290, 292, + 293, 294, 298, 254, 253, 256, 268, 255, 76, 188, + 190, 208, 191, 230, 243, 247, 268, 114, 274, 76, + 276, 277, 211, 275, 209, 189, 193, 209, 209, 280, + 188, 188, 209, 209, 246, 188, 246, 207, 188, 230, + 230, 246, 211, 287, 84, 85, 190, 192, 189, 189, + 193, 74, 244, 188, 93, 94, 95, 96, 97, 98, + 99, 100, 101, 102, 208, 245, 230, 198, 199, 200, + 194, 195, 82, 83, 86, 87, 201, 202, 88, 89, + 203, 204, 205, 90, 92, 91, 206, 193, 209, 211, + 280, 76, 253, 256, 190, 208, 191, 247, 244, 278, + 191, 211, 190, 193, 209, 263, 75, 279, 288, 295, + 246, 209, 246, 207, 246, 259, 291, 189, 211, 222, + 246, 76, 225, 244, 244, 230, 230, 230, 232, 232, + 233, 233, 234, 234, 234, 234, 235, 235, 236, 237, + 238, 239, 240, 241, 246, 244, 190, 191, 247, 278, + 208, 191, 247, 277, 188, 291, 296, 297, 189, 189, + 76, 189, 191, 207, 247, 208, 191, 278, 208, 191, + 246, 209, 189, 281, 282, 284, 208, 14, 283, 285, + 286, 244, 191, 278, 208, 278, 189, 246, 285, 12, + 278, 188, 278, 209, 281, 282, 246, 189, 281, 12 }; #define yyerrok (yyerrstatus = 0) @@ -2752,7 +2687,7 @@ YYLTYPE yylloc; } /* Line 1242 of yacc.c */ -#line 2756 "glsl_parser.cpp" +#line 2691 "glsl_parser.cpp" yylsp[0] = yylloc; goto yysetstate; @@ -4369,258 +4304,237 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1105 "glsl_parser.ypp" - { (yyval.n) = ast_mat3; ;} + { (yyval.n) = ast_mat2x3; ;} break; case 180: /* Line 1455 of yacc.c */ #line 1106 "glsl_parser.ypp" - { (yyval.n) = ast_mat4; ;} + { (yyval.n) = ast_mat2x4; ;} break; case 181: /* Line 1455 of yacc.c */ #line 1107 "glsl_parser.ypp" - { (yyval.n) = ast_mat2; ;} + { (yyval.n) = ast_mat3x2; ;} break; case 182: /* Line 1455 of yacc.c */ #line 1108 "glsl_parser.ypp" - { (yyval.n) = ast_mat2x3; ;} + { (yyval.n) = ast_mat3; ;} break; case 183: /* Line 1455 of yacc.c */ #line 1109 "glsl_parser.ypp" - { (yyval.n) = ast_mat2x4; ;} + { (yyval.n) = ast_mat3x4; ;} break; case 184: /* Line 1455 of yacc.c */ #line 1110 "glsl_parser.ypp" - { (yyval.n) = ast_mat3x2; ;} + { (yyval.n) = ast_mat4x2; ;} break; case 185: /* Line 1455 of yacc.c */ #line 1111 "glsl_parser.ypp" - { (yyval.n) = ast_mat3; ;} + { (yyval.n) = ast_mat4x3; ;} break; case 186: /* Line 1455 of yacc.c */ #line 1112 "glsl_parser.ypp" - { (yyval.n) = ast_mat3x4; ;} + { (yyval.n) = ast_mat4; ;} break; case 187: /* Line 1455 of yacc.c */ #line 1113 "glsl_parser.ypp" - { (yyval.n) = ast_mat4x2; ;} + { (yyval.n) = ast_sampler1d; ;} break; case 188: /* Line 1455 of yacc.c */ #line 1114 "glsl_parser.ypp" - { (yyval.n) = ast_mat4x3; ;} + { (yyval.n) = ast_sampler2d; ;} break; case 189: /* Line 1455 of yacc.c */ #line 1115 "glsl_parser.ypp" - { (yyval.n) = ast_mat4; ;} + { (yyval.n) = ast_sampler2drect; ;} break; case 190: /* Line 1455 of yacc.c */ #line 1116 "glsl_parser.ypp" - { (yyval.n) = ast_sampler1d; ;} + { (yyval.n) = ast_sampler3d; ;} break; case 191: /* Line 1455 of yacc.c */ #line 1117 "glsl_parser.ypp" - { (yyval.n) = ast_sampler2d; ;} + { (yyval.n) = ast_samplercube; ;} break; case 192: /* Line 1455 of yacc.c */ #line 1118 "glsl_parser.ypp" - { (yyval.n) = ast_sampler2drect; ;} + { (yyval.n) = ast_sampler1dshadow; ;} break; case 193: /* Line 1455 of yacc.c */ #line 1119 "glsl_parser.ypp" - { (yyval.n) = ast_sampler3d; ;} + { (yyval.n) = ast_sampler2dshadow; ;} break; case 194: /* Line 1455 of yacc.c */ #line 1120 "glsl_parser.ypp" - { (yyval.n) = ast_samplercube; ;} + { (yyval.n) = ast_sampler2drectshadow; ;} break; case 195: /* Line 1455 of yacc.c */ #line 1121 "glsl_parser.ypp" - { (yyval.n) = ast_sampler1dshadow; ;} + { (yyval.n) = ast_samplercubeshadow; ;} break; case 196: /* Line 1455 of yacc.c */ #line 1122 "glsl_parser.ypp" - { (yyval.n) = ast_sampler2dshadow; ;} + { (yyval.n) = ast_sampler1darray; ;} break; case 197: /* Line 1455 of yacc.c */ #line 1123 "glsl_parser.ypp" - { (yyval.n) = ast_sampler2drectshadow; ;} + { (yyval.n) = ast_sampler2darray; ;} break; case 198: /* Line 1455 of yacc.c */ #line 1124 "glsl_parser.ypp" - { (yyval.n) = ast_samplercubeshadow; ;} + { (yyval.n) = ast_sampler1darrayshadow; ;} break; case 199: /* Line 1455 of yacc.c */ #line 1125 "glsl_parser.ypp" - { (yyval.n) = ast_sampler1darray; ;} + { (yyval.n) = ast_sampler2darrayshadow; ;} break; case 200: /* Line 1455 of yacc.c */ #line 1126 "glsl_parser.ypp" - { (yyval.n) = ast_sampler2darray; ;} + { (yyval.n) = ast_isampler1d; ;} break; case 201: /* Line 1455 of yacc.c */ #line 1127 "glsl_parser.ypp" - { (yyval.n) = ast_sampler1darrayshadow; ;} + { (yyval.n) = ast_isampler2d; ;} break; case 202: /* Line 1455 of yacc.c */ #line 1128 "glsl_parser.ypp" - { (yyval.n) = ast_sampler2darrayshadow; ;} + { (yyval.n) = ast_isampler3d; ;} break; case 203: /* Line 1455 of yacc.c */ #line 1129 "glsl_parser.ypp" - { (yyval.n) = ast_isampler1d; ;} + { (yyval.n) = ast_isamplercube; ;} break; case 204: /* Line 1455 of yacc.c */ #line 1130 "glsl_parser.ypp" - { (yyval.n) = ast_isampler2d; ;} + { (yyval.n) = ast_isampler1darray; ;} break; case 205: /* Line 1455 of yacc.c */ #line 1131 "glsl_parser.ypp" - { (yyval.n) = ast_isampler3d; ;} + { (yyval.n) = ast_isampler2darray; ;} break; case 206: /* Line 1455 of yacc.c */ #line 1132 "glsl_parser.ypp" - { (yyval.n) = ast_isamplercube; ;} + { (yyval.n) = ast_usampler1d; ;} break; case 207: /* Line 1455 of yacc.c */ #line 1133 "glsl_parser.ypp" - { (yyval.n) = ast_isampler1darray; ;} + { (yyval.n) = ast_usampler2d; ;} break; case 208: /* Line 1455 of yacc.c */ #line 1134 "glsl_parser.ypp" - { (yyval.n) = ast_isampler2darray; ;} + { (yyval.n) = ast_usampler3d; ;} break; case 209: /* Line 1455 of yacc.c */ #line 1135 "glsl_parser.ypp" - { (yyval.n) = ast_usampler1d; ;} + { (yyval.n) = ast_usamplercube; ;} break; case 210: /* Line 1455 of yacc.c */ #line 1136 "glsl_parser.ypp" - { (yyval.n) = ast_usampler2d; ;} + { (yyval.n) = ast_usampler1darray; ;} break; case 211: /* Line 1455 of yacc.c */ #line 1137 "glsl_parser.ypp" - { (yyval.n) = ast_usampler3d; ;} - break; - - case 212: - -/* Line 1455 of yacc.c */ -#line 1138 "glsl_parser.ypp" - { (yyval.n) = ast_usamplercube; ;} - break; - - case 213: - -/* Line 1455 of yacc.c */ -#line 1139 "glsl_parser.ypp" - { (yyval.n) = ast_usampler1darray; ;} - break; - - case 214: - -/* Line 1455 of yacc.c */ -#line 1140 "glsl_parser.ypp" { (yyval.n) = ast_usampler2darray; ;} break; - case 215: + case 212: /* Line 1455 of yacc.c */ -#line 1144 "glsl_parser.ypp" +#line 1141 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4634,10 +4548,10 @@ yyreduce: ;} break; - case 216: + case 213: /* Line 1455 of yacc.c */ -#line 1155 "glsl_parser.ypp" +#line 1152 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4651,10 +4565,10 @@ yyreduce: ;} break; - case 217: + case 214: /* Line 1455 of yacc.c */ -#line 1166 "glsl_parser.ypp" +#line 1163 "glsl_parser.ypp" { if (state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4668,10 +4582,10 @@ yyreduce: ;} break; - case 218: + case 215: /* Line 1455 of yacc.c */ -#line 1181 "glsl_parser.ypp" +#line 1178 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node)); @@ -4679,10 +4593,10 @@ yyreduce: ;} break; - case 219: + case 216: /* Line 1455 of yacc.c */ -#line 1187 "glsl_parser.ypp" +#line 1184 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node)); @@ -4690,30 +4604,30 @@ yyreduce: ;} break; - case 220: + case 217: /* Line 1455 of yacc.c */ -#line 1196 "glsl_parser.ypp" +#line 1193 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].declarator_list); (yyvsp[(1) - (1)].declarator_list)->link.self_link(); ;} break; - case 221: + case 218: /* Line 1455 of yacc.c */ -#line 1201 "glsl_parser.ypp" +#line 1198 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (2)].node); (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); ;} break; - case 222: + case 219: /* Line 1455 of yacc.c */ -#line 1209 "glsl_parser.ypp" +#line 1206 "glsl_parser.ypp" { void *ctx = state; ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); @@ -4727,30 +4641,30 @@ yyreduce: ;} break; - case 223: + case 220: /* Line 1455 of yacc.c */ -#line 1224 "glsl_parser.ypp" +#line 1221 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (1)].declaration); (yyvsp[(1) - (1)].declaration)->link.self_link(); ;} break; - case 224: + case 221: /* Line 1455 of yacc.c */ -#line 1229 "glsl_parser.ypp" +#line 1226 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (3)].declaration); (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link); ;} break; - case 225: + case 222: /* Line 1455 of yacc.c */ -#line 1237 "glsl_parser.ypp" +#line 1234 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL); @@ -4758,10 +4672,10 @@ yyreduce: ;} break; - case 226: + case 223: /* Line 1455 of yacc.c */ -#line 1243 "glsl_parser.ypp" +#line 1240 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL); @@ -4769,31 +4683,31 @@ yyreduce: ;} break; - case 231: + case 228: /* Line 1455 of yacc.c */ -#line 1266 "glsl_parser.ypp" +#line 1263 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; - case 237: + case 234: /* Line 1455 of yacc.c */ -#line 1278 "glsl_parser.ypp" +#line 1275 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; - case 238: + case 235: /* Line 1455 of yacc.c */ -#line 1279 "glsl_parser.ypp" +#line 1276 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; - case 241: + case 238: /* Line 1455 of yacc.c */ -#line 1286 "glsl_parser.ypp" +#line 1283 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL); @@ -4801,10 +4715,10 @@ yyreduce: ;} break; - case 242: + case 239: /* Line 1455 of yacc.c */ -#line 1292 "glsl_parser.ypp" +#line 1289 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(2) - (3)].node)); @@ -4812,17 +4726,17 @@ yyreduce: ;} break; - case 243: + case 240: /* Line 1455 of yacc.c */ -#line 1300 "glsl_parser.ypp" +#line 1297 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; - case 245: + case 242: /* Line 1455 of yacc.c */ -#line 1306 "glsl_parser.ypp" +#line 1303 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL); @@ -4830,10 +4744,10 @@ yyreduce: ;} break; - case 246: + case 243: /* Line 1455 of yacc.c */ -#line 1312 "glsl_parser.ypp" +#line 1309 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node)); @@ -4841,10 +4755,10 @@ yyreduce: ;} break; - case 247: + case 244: /* Line 1455 of yacc.c */ -#line 1321 "glsl_parser.ypp" +#line 1318 "glsl_parser.ypp" { if ((yyvsp[(1) - (1)].node) == NULL) { _mesa_glsl_error(& (yylsp[(1) - (1)]), state, " statement\n"); @@ -4856,10 +4770,10 @@ yyreduce: ;} break; - case 248: + case 245: /* Line 1455 of yacc.c */ -#line 1331 "glsl_parser.ypp" +#line 1328 "glsl_parser.ypp" { if ((yyvsp[(2) - (2)].node) == NULL) { _mesa_glsl_error(& (yylsp[(2) - (2)]), state, " statement\n"); @@ -4870,10 +4784,10 @@ yyreduce: ;} break; - case 249: + case 246: /* Line 1455 of yacc.c */ -#line 1343 "glsl_parser.ypp" +#line 1340 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement(NULL); @@ -4881,10 +4795,10 @@ yyreduce: ;} break; - case 250: + case 247: /* Line 1455 of yacc.c */ -#line 1349 "glsl_parser.ypp" +#line 1346 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression)); @@ -4892,10 +4806,10 @@ yyreduce: ;} break; - case 251: + case 248: /* Line 1455 of yacc.c */ -#line 1358 "glsl_parser.ypp" +#line 1355 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4903,10 +4817,10 @@ yyreduce: ;} break; - case 252: + case 249: /* Line 1455 of yacc.c */ -#line 1367 "glsl_parser.ypp" +#line 1364 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4914,10 +4828,10 @@ yyreduce: ;} break; - case 253: + case 250: /* Line 1455 of yacc.c */ -#line 1373 "glsl_parser.ypp" +#line 1370 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL); @@ -4925,10 +4839,10 @@ yyreduce: ;} break; - case 254: + case 251: /* Line 1455 of yacc.c */ -#line 1379 "glsl_parser.ypp" +#line 1376 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node)); @@ -4936,19 +4850,19 @@ yyreduce: ;} break; - case 255: + case 252: /* Line 1455 of yacc.c */ -#line 1388 "glsl_parser.ypp" +#line 1385 "glsl_parser.ypp" { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].expression); ;} break; - case 256: + case 253: /* Line 1455 of yacc.c */ -#line 1392 "glsl_parser.ypp" +#line 1389 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -4961,10 +4875,10 @@ yyreduce: ;} break; - case 260: + case 257: /* Line 1455 of yacc.c */ -#line 1415 "glsl_parser.ypp" +#line 1412 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, @@ -4973,10 +4887,10 @@ yyreduce: ;} break; - case 261: + case 258: /* Line 1455 of yacc.c */ -#line 1422 "glsl_parser.ypp" +#line 1419 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, @@ -4985,10 +4899,10 @@ yyreduce: ;} break; - case 262: + case 259: /* Line 1455 of yacc.c */ -#line 1429 "glsl_parser.ypp" +#line 1426 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, @@ -4997,39 +4911,39 @@ yyreduce: ;} break; - case 266: + case 263: /* Line 1455 of yacc.c */ -#line 1445 "glsl_parser.ypp" +#line 1442 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; - case 267: + case 264: /* Line 1455 of yacc.c */ -#line 1452 "glsl_parser.ypp" +#line 1449 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node); (yyval.for_rest_statement).rest = NULL; ;} break; - case 268: + case 265: /* Line 1455 of yacc.c */ -#line 1457 "glsl_parser.ypp" +#line 1454 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node); (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression); ;} break; - case 269: + case 266: /* Line 1455 of yacc.c */ -#line 1466 "glsl_parser.ypp" +#line 1463 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); @@ -5037,10 +4951,10 @@ yyreduce: ;} break; - case 270: + case 267: /* Line 1455 of yacc.c */ -#line 1472 "glsl_parser.ypp" +#line 1469 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); @@ -5048,10 +4962,10 @@ yyreduce: ;} break; - case 271: + case 268: /* Line 1455 of yacc.c */ -#line 1478 "glsl_parser.ypp" +#line 1475 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); @@ -5059,10 +4973,10 @@ yyreduce: ;} break; - case 272: + case 269: /* Line 1455 of yacc.c */ -#line 1484 "glsl_parser.ypp" +#line 1481 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression)); @@ -5070,10 +4984,10 @@ yyreduce: ;} break; - case 273: + case 270: /* Line 1455 of yacc.c */ -#line 1490 "glsl_parser.ypp" +#line 1487 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); @@ -5081,24 +4995,24 @@ yyreduce: ;} break; - case 274: + case 271: /* Line 1455 of yacc.c */ -#line 1498 "glsl_parser.ypp" +#line 1495 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;} break; - case 275: + case 272: /* Line 1455 of yacc.c */ -#line 1499 "glsl_parser.ypp" +#line 1496 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); ;} break; - case 276: + case 273: /* Line 1455 of yacc.c */ -#line 1504 "glsl_parser.ypp" +#line 1501 "glsl_parser.ypp" { void *ctx = state; (yyval.function_definition) = new(ctx) ast_function_definition(); @@ -5111,7 +5025,7 @@ yyreduce: /* Line 1455 of yacc.c */ -#line 5115 "glsl_parser.cpp" +#line 5029 "glsl_parser.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h index 2bfca6fa2f9..4124c7f1d2d 100644 --- a/src/glsl/glsl_parser.h +++ b/src/glsl/glsl_parser.h @@ -41,10 +41,10 @@ enum yytokentype { ATTRIBUTE = 258, CONST_TOK = 259, - BOOL = 260, - FLOAT = 261, - INT = 262, - UINT = 263, + BOOL_TOK = 260, + FLOAT_TOK = 261, + INT_TOK = 262, + UINT_TOK = 263, BREAK = 264, CONTINUE = 265, DO = 266, @@ -68,165 +68,162 @@ VEC2 = 284, VEC3 = 285, VEC4 = 286, - MAT2 = 287, - MAT3 = 288, - MAT4 = 289, - CENTROID = 290, - IN = 291, - OUT = 292, - INOUT = 293, - UNIFORM = 294, - VARYING = 295, - NOPERSPECTIVE = 296, - FLAT = 297, - SMOOTH = 298, - MAT2X2 = 299, - MAT2X3 = 300, - MAT2X4 = 301, - MAT3X2 = 302, - MAT3X3 = 303, - MAT3X4 = 304, - MAT4X2 = 305, - MAT4X3 = 306, - MAT4X4 = 307, - SAMPLER1D = 308, - SAMPLER2D = 309, - SAMPLER3D = 310, - SAMPLERCUBE = 311, - SAMPLER1DSHADOW = 312, - SAMPLER2DSHADOW = 313, - SAMPLERCUBESHADOW = 314, - SAMPLER1DARRAY = 315, - SAMPLER2DARRAY = 316, - SAMPLER1DARRAYSHADOW = 317, - SAMPLER2DARRAYSHADOW = 318, - ISAMPLER1D = 319, - ISAMPLER2D = 320, - ISAMPLER3D = 321, - ISAMPLERCUBE = 322, - ISAMPLER1DARRAY = 323, - ISAMPLER2DARRAY = 324, - USAMPLER1D = 325, - USAMPLER2D = 326, - USAMPLER3D = 327, - USAMPLERCUBE = 328, - USAMPLER1DARRAY = 329, - USAMPLER2DARRAY = 330, - STRUCT = 331, - VOID = 332, - WHILE = 333, - IDENTIFIER = 334, - FLOATCONSTANT = 335, - INTCONSTANT = 336, - UINTCONSTANT = 337, - BOOLCONSTANT = 338, - FIELD_SELECTION = 339, - LEFT_OP = 340, - RIGHT_OP = 341, - INC_OP = 342, - DEC_OP = 343, - LE_OP = 344, - GE_OP = 345, - EQ_OP = 346, - NE_OP = 347, - AND_OP = 348, - OR_OP = 349, - XOR_OP = 350, - MUL_ASSIGN = 351, - DIV_ASSIGN = 352, - ADD_ASSIGN = 353, - MOD_ASSIGN = 354, - LEFT_ASSIGN = 355, - RIGHT_ASSIGN = 356, - AND_ASSIGN = 357, - XOR_ASSIGN = 358, - OR_ASSIGN = 359, - SUB_ASSIGN = 360, - INVARIANT = 361, - LOWP = 362, - MEDIUMP = 363, - HIGHP = 364, - SUPERP = 365, - PRECISION = 366, - VERSION = 367, - EXTENSION = 368, - LINE = 369, - PRAGMA = 370, - COLON = 371, - EOL = 372, - INTERFACE = 373, - OUTPUT = 374, - LAYOUT_TOK = 375, - ASM = 376, - CLASS = 377, - UNION = 378, - ENUM = 379, - TYPEDEF = 380, - TEMPLATE = 381, - THIS = 382, - PACKED = 383, - GOTO = 384, - INLINE_TOK = 385, - NOINLINE = 386, - VOLATILE = 387, - PUBLIC_TOK = 388, - STATIC = 389, - EXTERN = 390, - EXTERNAL = 391, - LONG = 392, - SHORT = 393, - DOUBLE = 394, - HALF = 395, - FIXED = 396, - UNSIGNED = 397, - INPUT = 398, - OUPTUT = 399, - HVEC2 = 400, - HVEC3 = 401, - HVEC4 = 402, - DVEC2 = 403, - DVEC3 = 404, - DVEC4 = 405, - FVEC2 = 406, - FVEC3 = 407, - FVEC4 = 408, - SAMPLER2DRECT = 409, - SAMPLER3DRECT = 410, - SAMPLER2DRECTSHADOW = 411, - SIZEOF = 412, - CAST = 413, - NAMESPACE = 414, - USING = 415, - ERROR_TOK = 416, - COMMON = 417, - PARTITION = 418, - ACTIVE = 419, - SAMPLERBUFFER = 420, - FILTER = 421, - IMAGE1D = 422, - IMAGE2D = 423, - IMAGE3D = 424, - IMAGECUBE = 425, - IMAGE1DARRAY = 426, - IMAGE2DARRAY = 427, - IIMAGE1D = 428, - IIMAGE2D = 429, - IIMAGE3D = 430, - IIMAGECUBE = 431, - IIMAGE1DARRAY = 432, - IIMAGE2DARRAY = 433, - UIMAGE1D = 434, - UIMAGE2D = 435, - UIMAGE3D = 436, - UIMAGECUBE = 437, - UIMAGE1DARRAY = 438, - UIMAGE2DARRAY = 439, - IMAGE1DSHADOW = 440, - IMAGE2DSHADOW = 441, - IMAGEBUFFER = 442, - IIMAGEBUFFER = 443, - UIMAGEBUFFER = 444, - ROW_MAJOR = 445 + CENTROID = 287, + IN_TOK = 288, + OUT_TOK = 289, + INOUT_TOK = 290, + UNIFORM = 291, + VARYING = 292, + NOPERSPECTIVE = 293, + FLAT = 294, + SMOOTH = 295, + MAT2X2 = 296, + MAT2X3 = 297, + MAT2X4 = 298, + MAT3X2 = 299, + MAT3X3 = 300, + MAT3X4 = 301, + MAT4X2 = 302, + MAT4X3 = 303, + MAT4X4 = 304, + SAMPLER1D = 305, + SAMPLER2D = 306, + SAMPLER3D = 307, + SAMPLERCUBE = 308, + SAMPLER1DSHADOW = 309, + SAMPLER2DSHADOW = 310, + SAMPLERCUBESHADOW = 311, + SAMPLER1DARRAY = 312, + SAMPLER2DARRAY = 313, + SAMPLER1DARRAYSHADOW = 314, + SAMPLER2DARRAYSHADOW = 315, + ISAMPLER1D = 316, + ISAMPLER2D = 317, + ISAMPLER3D = 318, + ISAMPLERCUBE = 319, + ISAMPLER1DARRAY = 320, + ISAMPLER2DARRAY = 321, + USAMPLER1D = 322, + USAMPLER2D = 323, + USAMPLER3D = 324, + USAMPLERCUBE = 325, + USAMPLER1DARRAY = 326, + USAMPLER2DARRAY = 327, + STRUCT = 328, + VOID_TOK = 329, + WHILE = 330, + IDENTIFIER = 331, + FLOATCONSTANT = 332, + INTCONSTANT = 333, + UINTCONSTANT = 334, + BOOLCONSTANT = 335, + FIELD_SELECTION = 336, + LEFT_OP = 337, + RIGHT_OP = 338, + INC_OP = 339, + DEC_OP = 340, + LE_OP = 341, + GE_OP = 342, + EQ_OP = 343, + NE_OP = 344, + AND_OP = 345, + OR_OP = 346, + XOR_OP = 347, + MUL_ASSIGN = 348, + DIV_ASSIGN = 349, + ADD_ASSIGN = 350, + MOD_ASSIGN = 351, + LEFT_ASSIGN = 352, + RIGHT_ASSIGN = 353, + AND_ASSIGN = 354, + XOR_ASSIGN = 355, + OR_ASSIGN = 356, + SUB_ASSIGN = 357, + INVARIANT = 358, + LOWP = 359, + MEDIUMP = 360, + HIGHP = 361, + SUPERP = 362, + PRECISION = 363, + VERSION = 364, + EXTENSION = 365, + LINE = 366, + PRAGMA = 367, + COLON = 368, + EOL = 369, + INTERFACE = 370, + OUTPUT = 371, + LAYOUT_TOK = 372, + ASM = 373, + CLASS = 374, + UNION = 375, + ENUM = 376, + TYPEDEF = 377, + TEMPLATE = 378, + THIS = 379, + PACKED_TOK = 380, + GOTO = 381, + INLINE_TOK = 382, + NOINLINE = 383, + VOLATILE = 384, + PUBLIC_TOK = 385, + STATIC = 386, + EXTERN = 387, + EXTERNAL = 388, + LONG_TOK = 389, + SHORT_TOK = 390, + DOUBLE_TOK = 391, + HALF = 392, + FIXED_TOK = 393, + UNSIGNED = 394, + INPUT_TOK = 395, + OUPTUT = 396, + HVEC2 = 397, + HVEC3 = 398, + HVEC4 = 399, + DVEC2 = 400, + DVEC3 = 401, + DVEC4 = 402, + FVEC2 = 403, + FVEC3 = 404, + FVEC4 = 405, + SAMPLER2DRECT = 406, + SAMPLER3DRECT = 407, + SAMPLER2DRECTSHADOW = 408, + SIZEOF = 409, + CAST = 410, + NAMESPACE = 411, + USING = 412, + ERROR_TOK = 413, + COMMON = 414, + PARTITION = 415, + ACTIVE = 416, + SAMPLERBUFFER = 417, + FILTER = 418, + IMAGE1D = 419, + IMAGE2D = 420, + IMAGE3D = 421, + IMAGECUBE = 422, + IMAGE1DARRAY = 423, + IMAGE2DARRAY = 424, + IIMAGE1D = 425, + IIMAGE2D = 426, + IIMAGE3D = 427, + IIMAGECUBE = 428, + IIMAGE1DARRAY = 429, + IIMAGE2DARRAY = 430, + UIMAGE1D = 431, + UIMAGE2D = 432, + UIMAGE3D = 433, + UIMAGECUBE = 434, + UIMAGE1DARRAY = 435, + UIMAGE2DARRAY = 436, + IMAGE1DSHADOW = 437, + IMAGE2DSHADOW = 438, + IMAGEBUFFER = 439, + IIMAGEBUFFER = 440, + UIMAGEBUFFER = 441, + ROW_MAJOR = 442 }; #endif @@ -268,7 +265,7 @@ typedef union YYSTYPE /* Line 1676 of yacc.c */ -#line 272 "glsl_parser.h" +#line 269 "glsl_parser.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ -- cgit v1.2.3 From 204d4cbea0de81f6f162ae0348e476de6c916ca8 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 13 Aug 2010 18:36:55 +0100 Subject: glsl2: Include string.h in preprocessor --- src/glsl/glcpp/pp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index 52b6e96a65f..7672490958d 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -22,6 +22,7 @@ */ #include +#include #include #include "glcpp.h" -- cgit v1.2.3 From c33e78f62bed762d8e5987e111a6e0424dc26c76 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 12:30:41 -0700 Subject: linker: Assign attrib location 0 if gl_Vertex is not used If gl_Vertex is not used in the shader, then attribute location 0 is available for use. Fixes piglit test case glsl-getattriblocation (bugzilla #29540). --- src/glsl/linker.cpp | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index c462d31ef3d..7bff859d554 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -116,6 +116,38 @@ private: }; +/** + * Visitor that determines whether or not a variable is ever read. + */ +class find_deref_visitor : public ir_hierarchical_visitor { +public: + find_deref_visitor(const char *name) + : name(name), found(false) + { + /* empty */ + } + + virtual ir_visitor_status visit(ir_dereference_variable *ir) + { + if (strcmp(this->name, ir->var->name) == 0) { + this->found = true; + return visit_stop; + } + + return visit_continue; + } + + bool variable_found() const + { + return this->found; + } + +private: + const char *name; /**< Find writes to a variable with this name. */ + bool found; /**< Was a write to the variable found? */ +}; + + void linker_error_printf(gl_shader_program *prog, const char *fmt, ...) { @@ -1042,7 +1074,10 @@ assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index * be explicitly assigned by via glBindAttribLocation. Mark it as reserved * to prevent it from being automatically allocated below. */ - used_locations |= (1 << 0); + find_deref_visitor find("gl_Vertex"); + find.run(sh->ir); + if (find.variable_found()) + used_locations |= (1 << 0); for (unsigned i = 0; i < num_attr; i++) { /* Mask representing the contiguous slots that will be used by this -- cgit v1.2.3 From ab18be74ac5f95ba1ebe6a52259d77e0940b2dbd Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 13:08:54 -0700 Subject: glsl2: Use --nounistd to fix MSVC build Also remove the --never-interactive command line option for the preprocessor lexer. This was already done for main compiler lexer. --- src/glsl/Makefile | 4 ++-- src/glsl/glcpp/glcpp-lex.l | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 3e480685bdf..2f62517e95d 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -151,13 +151,13 @@ glcpp/glcpp: $(GLCPP_OBJECTS) libglsl.a $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ glsl_lexer.cpp: glsl_lexer.lpp - flex -o$@ $< + flex --nounistd -o$@ $< glsl_parser.cpp: glsl_parser.ypp bison -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $< glcpp/glcpp-lex.c: glcpp/glcpp-lex.l - flex --never-interactive --outfile="$@" $< + flex --nounistd -o$@ $< glcpp/glcpp-parse.c: glcpp/glcpp-parse.y bison -v -o "$@" --defines=glcpp/glcpp-parse.h $< diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index fa628913540..1cd95b238d2 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -50,6 +50,7 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner); %option extra-type="glcpp_parser_t *" %option prefix="glcpp_" %option stack +%option never-interactive %x DONE COMMENT UNREACHABLE -- cgit v1.2.3 From 23f6017d70a705479b9bc3a1bf2ef401ac519fb9 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 13:13:24 -0700 Subject: glsl2: Commit generated file changed by previous commit --- src/glsl/glcpp/glcpp-lex.c | 102 +++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 55 deletions(-) diff --git a/src/glsl/glcpp/glcpp-lex.c b/src/glsl/glcpp/glcpp-lex.c index bdb3b2c11b0..6b6aa12d8f7 100644 --- a/src/glsl/glcpp/glcpp-lex.c +++ b/src/glsl/glcpp/glcpp-lex.c @@ -698,14 +698,6 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner); #define COMMENT 2 #define UNREACHABLE 3 -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - #define YY_EXTRA_TYPE glcpp_parser_t * /* Holds the entire state of the reentrant scanner. */ @@ -958,11 +950,11 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 69 "glcpp/glcpp-lex.l" +#line 70 "glcpp/glcpp-lex.l" /* Single-line comments */ -#line 966 "glcpp/glcpp-lex.c" +#line 958 "glcpp/glcpp-lex.c" yylval = yylval_param; @@ -1032,7 +1024,7 @@ yy_match: *yyg->yy_state_ptr++ = yy_current_state; ++yy_cp; } - while ( yy_base[yy_current_state] != 549 ); + while ( yy_current_state != 150 ); yy_find_action: yy_current_state = *--yyg->yy_state_ptr; @@ -1085,7 +1077,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 72 "glcpp/glcpp-lex.l" +#line 73 "glcpp/glcpp-lex.l" { yylineno++; yycolumn = 0; @@ -1095,34 +1087,34 @@ YY_RULE_SETUP /* Multi-line comments */ case 2: YY_RULE_SETUP -#line 79 "glcpp/glcpp-lex.l" +#line 80 "glcpp/glcpp-lex.l" { yy_push_state(COMMENT, yyscanner); } YY_BREAK case 3: YY_RULE_SETUP -#line 80 "glcpp/glcpp-lex.l" +#line 81 "glcpp/glcpp-lex.l" YY_BREAK case 4: /* rule 4 can match eol */ YY_RULE_SETUP -#line 81 "glcpp/glcpp-lex.l" +#line 82 "glcpp/glcpp-lex.l" { yylineno++; yycolumn = 0; } YY_BREAK case 5: YY_RULE_SETUP -#line 82 "glcpp/glcpp-lex.l" +#line 83 "glcpp/glcpp-lex.l" YY_BREAK case 6: /* rule 6 can match eol */ YY_RULE_SETUP -#line 83 "glcpp/glcpp-lex.l" +#line 84 "glcpp/glcpp-lex.l" { yylineno++; yycolumn = 0; } YY_BREAK case 7: YY_RULE_SETUP -#line 84 "glcpp/glcpp-lex.l" +#line 85 "glcpp/glcpp-lex.l" { yy_pop_state(yyscanner); if (yyextra->space_tokens) @@ -1131,7 +1123,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 90 "glcpp/glcpp-lex.l" +#line 91 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); yylineno++; @@ -1144,7 +1136,7 @@ YY_RULE_SETUP * Simply pass them through to the main compiler's lexer/parser. */ case 9: YY_RULE_SETUP -#line 100 "glcpp/glcpp-lex.l" +#line 101 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); yylineno++; @@ -1155,7 +1147,7 @@ YY_RULE_SETUP case 10: /* rule 10 can match eol */ YY_RULE_SETUP -#line 107 "glcpp/glcpp-lex.l" +#line 108 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; @@ -1165,7 +1157,7 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 113 "glcpp/glcpp-lex.l" +#line 114 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; @@ -1175,7 +1167,7 @@ YY_RULE_SETUP case 12: /* rule 12 can match eol */ YY_RULE_SETUP -#line 119 "glcpp/glcpp-lex.l" +#line 120 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; @@ -1185,7 +1177,7 @@ YY_RULE_SETUP case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 125 "glcpp/glcpp-lex.l" +#line 126 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; @@ -1195,7 +1187,7 @@ YY_RULE_SETUP case 14: /* rule 14 can match eol */ YY_RULE_SETUP -#line 131 "glcpp/glcpp-lex.l" +#line 132 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_ELSE; @@ -1204,7 +1196,7 @@ YY_RULE_SETUP case 15: /* rule 15 can match eol */ YY_RULE_SETUP -#line 136 "glcpp/glcpp-lex.l" +#line 137 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_ENDIF; @@ -1224,7 +1216,7 @@ case 16: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 149 "glcpp/glcpp-lex.l" +#line 150 "glcpp/glcpp-lex.l" { /* Since this rule always matches, YY_USER_ACTION gets called for it, * wrongly incrementing yycolumn. We undo that effect here. */ @@ -1239,7 +1231,7 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 161 "glcpp/glcpp-lex.l" +#line 162 "glcpp/glcpp-lex.l" { char *p; for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */ @@ -1249,7 +1241,7 @@ YY_RULE_SETUP YY_BREAK case 18: YY_RULE_SETUP -#line 168 "glcpp/glcpp-lex.l" +#line 169 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_DEFINE_FUNC; @@ -1257,7 +1249,7 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 173 "glcpp/glcpp-lex.l" +#line 174 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_DEFINE_OBJ; @@ -1265,7 +1257,7 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 178 "glcpp/glcpp-lex.l" +#line 179 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_UNDEF; @@ -1273,7 +1265,7 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 183 "glcpp/glcpp-lex.l" +#line 184 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH; @@ -1281,7 +1273,7 @@ YY_RULE_SETUP YY_BREAK case 22: YY_RULE_SETUP -#line 188 "glcpp/glcpp-lex.l" +#line 189 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; @@ -1289,7 +1281,7 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 193 "glcpp/glcpp-lex.l" +#line 194 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; @@ -1297,7 +1289,7 @@ YY_RULE_SETUP YY_BREAK case 24: YY_RULE_SETUP -#line 198 "glcpp/glcpp-lex.l" +#line 199 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; @@ -1305,77 +1297,77 @@ YY_RULE_SETUP YY_BREAK case 25: YY_RULE_SETUP -#line 203 "glcpp/glcpp-lex.l" +#line 204 "glcpp/glcpp-lex.l" { return LEFT_SHIFT; } YY_BREAK case 26: YY_RULE_SETUP -#line 207 "glcpp/glcpp-lex.l" +#line 208 "glcpp/glcpp-lex.l" { return RIGHT_SHIFT; } YY_BREAK case 27: YY_RULE_SETUP -#line 211 "glcpp/glcpp-lex.l" +#line 212 "glcpp/glcpp-lex.l" { return LESS_OR_EQUAL; } YY_BREAK case 28: YY_RULE_SETUP -#line 215 "glcpp/glcpp-lex.l" +#line 216 "glcpp/glcpp-lex.l" { return GREATER_OR_EQUAL; } YY_BREAK case 29: YY_RULE_SETUP -#line 219 "glcpp/glcpp-lex.l" +#line 220 "glcpp/glcpp-lex.l" { return EQUAL; } YY_BREAK case 30: YY_RULE_SETUP -#line 223 "glcpp/glcpp-lex.l" +#line 224 "glcpp/glcpp-lex.l" { return NOT_EQUAL; } YY_BREAK case 31: YY_RULE_SETUP -#line 227 "glcpp/glcpp-lex.l" +#line 228 "glcpp/glcpp-lex.l" { return AND; } YY_BREAK case 32: YY_RULE_SETUP -#line 231 "glcpp/glcpp-lex.l" +#line 232 "glcpp/glcpp-lex.l" { return OR; } YY_BREAK case 33: YY_RULE_SETUP -#line 235 "glcpp/glcpp-lex.l" +#line 236 "glcpp/glcpp-lex.l" { return PASTE; } YY_BREAK case 34: YY_RULE_SETUP -#line 239 "glcpp/glcpp-lex.l" +#line 240 "glcpp/glcpp-lex.l" { return DEFINED; } YY_BREAK case 35: YY_RULE_SETUP -#line 243 "glcpp/glcpp-lex.l" +#line 244 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); return IDENTIFIER; @@ -1383,14 +1375,14 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 248 "glcpp/glcpp-lex.l" +#line 249 "glcpp/glcpp-lex.l" { return yytext[0]; } YY_BREAK case 37: YY_RULE_SETUP -#line 252 "glcpp/glcpp-lex.l" +#line 253 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); return OTHER; @@ -1398,7 +1390,7 @@ YY_RULE_SETUP YY_BREAK case 38: YY_RULE_SETUP -#line 257 "glcpp/glcpp-lex.l" +#line 258 "glcpp/glcpp-lex.l" { if (yyextra->space_tokens) { return SPACE; @@ -1408,7 +1400,7 @@ YY_RULE_SETUP case 39: /* rule 39 can match eol */ YY_RULE_SETUP -#line 263 "glcpp/glcpp-lex.l" +#line 264 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 0; yylineno++; @@ -1418,7 +1410,7 @@ YY_RULE_SETUP YY_BREAK /* Handle missing newline at EOF. */ case YY_STATE_EOF(INITIAL): -#line 271 "glcpp/glcpp-lex.l" +#line 272 "glcpp/glcpp-lex.l" { BEGIN DONE; /* Don't keep matching this rule forever. */ yyextra->lexing_if = 0; @@ -1431,7 +1423,7 @@ case YY_STATE_EOF(INITIAL): warnings. */ case 40: YY_RULE_SETUP -#line 281 "glcpp/glcpp-lex.l" +#line 282 "glcpp/glcpp-lex.l" { unput('.'); yy_top_state(yyextra); @@ -1439,10 +1431,10 @@ YY_RULE_SETUP YY_BREAK case 41: YY_RULE_SETUP -#line 286 "glcpp/glcpp-lex.l" +#line 287 "glcpp/glcpp-lex.l" ECHO; YY_BREAK -#line 1446 "glcpp/glcpp-lex.c" +#line 1438 "glcpp/glcpp-lex.c" case YY_STATE_EOF(DONE): case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(UNREACHABLE): @@ -2636,7 +2628,7 @@ void glcpp_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 286 "glcpp/glcpp-lex.l" +#line 287 "glcpp/glcpp-lex.l" -- cgit v1.2.3 From a77a6bc008b3146c56431fa520a00e1f8dfa3938 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 16:22:21 -0700 Subject: glsl2: Use stdint.h instead of inttypes.h --- src/glsl/glcpp/glcpp-parse.c | 2 +- src/glsl/glcpp/glcpp-parse.y | 2 +- src/glsl/ir_function_inlining.cpp | 2 +- src/glsl/ir_validate.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index a4d46042fff..b081d22e752 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -97,7 +97,7 @@ #include #include #include -#include +#include #include "glcpp.h" #include "main/mtypes.h" diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index b05a925a098..0d70afd779c 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include "glcpp.h" #include "main/mtypes.h" diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 874602c84f2..56d29e3fd16 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -27,7 +27,7 @@ * Replaces calls to functions with the body of the function. */ -#include +#include #include "ir.h" #include "ir_visitor.h" #include "ir_function_inlining.h" diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 6e08fa4025a..905b3c76721 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -33,7 +33,7 @@ * a dereference chain. */ -#include +#include #include "ir.h" #include "ir_hierarchical_visitor.h" #include "program/hash_table.h" -- cgit v1.2.3 From d960b61ea3d2ed749a41a0d0fea621415d656848 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 16:22:38 -0700 Subject: Add missing intmax_t and uintmax_t --- include/c99/stdint.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/c99/stdint.h b/include/c99/stdint.h index fc6459d03d2..6f40e0c74a2 100644 --- a/include/c99/stdint.h +++ b/include/c99/stdint.h @@ -110,6 +110,9 @@ typedef unsigned __int32 uintptr_t; #define INT64_C(__val) __val##i64 #define UINT64_C(__val) __val##ui64 +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + #else #error "Unsupported compiler" #endif -- cgit v1.2.3 From 768b55a5268572ff9fd03e57e92775882eb0a821 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 16:46:43 -0700 Subject: glsl2: Remove unnecessary use of 'struct' before type names In C++ you don't have to say 'struct' or 'class' if the declaration of the type has been seen. Some compilers will complain if you use 'struct' when 'class' should have been used and vice versa. Fixes bugzilla #29539. --- src/glsl/ast.h | 5 ++--- src/glsl/ast_to_hir.cpp | 10 +++++----- src/glsl/glsl_parser.cpp | 36 ++++++++++++++++++------------------ src/glsl/glsl_parser.h | 26 +++++++++++++------------- src/glsl/glsl_parser.ypp | 36 ++++++++++++++++++------------------ src/glsl/hir_field_selection.cpp | 2 +- 6 files changed, 57 insertions(+), 58 deletions(-) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index 7ce879bb79d..44c31b6e627 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -29,7 +29,6 @@ #include "list.h" #include "glsl_parser_extras.h" -struct ir_instruction; struct _mesa_glsl_parse_state; struct YYLTYPE; @@ -657,8 +656,8 @@ public: extern void _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); -extern struct ir_rvalue * -_mesa_ast_field_selection_to_hir(const struct ast_expression *expr, +extern ir_rvalue * +_mesa_ast_field_selection_to_hir(const ast_expression *expr, exec_list *instructions, struct _mesa_glsl_parse_state *state); diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 9d4448f89a8..6e5d01ee265 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -986,7 +986,7 @@ ast_expression::hir(exec_list *instructions, assert(operations[this->oper] == ir_binop_mod); - struct ir_rvalue *temp_rhs; + ir_rvalue *temp_rhs; temp_rhs = new(ctx) ir_expression(operations[this->oper], type, op[0], op[1]); @@ -1107,7 +1107,7 @@ ast_expression::hir(exec_list *instructions, type = arithmetic_result_type(op[0], op[1], false, state, & loc); - struct ir_rvalue *temp_rhs; + ir_rvalue *temp_rhs; temp_rhs = new(ctx) ir_expression(operations[this->oper], type, op[0], op[1]); @@ -1131,7 +1131,7 @@ ast_expression::hir(exec_list *instructions, type = arithmetic_result_type(op[0], op[1], false, state, & loc); - struct ir_rvalue *temp_rhs; + ir_rvalue *temp_rhs; temp_rhs = new(ctx) ir_expression(operations[this->oper], type, op[0], op[1]); @@ -1453,7 +1453,7 @@ ast_type_specifier::glsl_type(const char **name, static void apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, - struct ir_variable *var, + ir_variable *var, struct _mesa_glsl_parse_state *state, YYLTYPE *loc) { @@ -1620,7 +1620,7 @@ ast_declarator_list::hir(exec_list *instructions, foreach_list_typed (ast_declaration, decl, link, &this->declarations) { const struct glsl_type *var_type; - struct ir_variable *var; + ir_variable *var; /* FINISHME: Emit a warning if a variable declaration shadows a * FINISHME: declaration at a higher scope. diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp index 8756fcb721a..7df9e96d16f 100644 --- a/src/glsl/glsl_parser.cpp +++ b/src/glsl/glsl_parser.cpp @@ -347,21 +347,21 @@ typedef union YYSTYPE unsigned i; } type_qualifier; - struct ast_node *node; - struct ast_type_specifier *type_specifier; - struct ast_fully_specified_type *fully_specified_type; - struct ast_function *function; - struct ast_parameter_declarator *parameter_declarator; - struct ast_function_definition *function_definition; - struct ast_compound_statement *compound_statement; - struct ast_expression *expression; - struct ast_declarator_list *declarator_list; - struct ast_struct_specifier *struct_specifier; - struct ast_declaration *declaration; + ast_node *node; + ast_type_specifier *type_specifier; + ast_fully_specified_type *fully_specified_type; + ast_function *function; + ast_parameter_declarator *parameter_declarator; + ast_function_definition *function_definition; + ast_compound_statement *compound_statement; + ast_expression *expression; + ast_declarator_list *declarator_list; + ast_struct_specifier *struct_specifier; + ast_declaration *declaration; struct { - struct ast_node *cond; - struct ast_expression *rest; + ast_node *cond; + ast_expression *rest; } for_rest_statement; @@ -4609,7 +4609,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1193 "glsl_parser.ypp" { - (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].declarator_list); + (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].declarator_list); (yyvsp[(1) - (1)].declarator_list)->link.self_link(); ;} break; @@ -4619,7 +4619,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1198 "glsl_parser.ypp" { - (yyval.node) = (struct ast_node *) (yyvsp[(1) - (2)].node); + (yyval.node) = (ast_node *) (yyvsp[(1) - (2)].node); (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); ;} break; @@ -4687,7 +4687,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1263 "glsl_parser.ypp" - { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} + { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 234: @@ -4730,7 +4730,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1297 "glsl_parser.ypp" - { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} + { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 242: @@ -4855,7 +4855,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1385 "glsl_parser.ypp" { - (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].expression); + (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].expression); ;} break; diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h index 4124c7f1d2d..48a0a5fb3a3 100644 --- a/src/glsl/glsl_parser.h +++ b/src/glsl/glsl_parser.h @@ -245,21 +245,21 @@ typedef union YYSTYPE unsigned i; } type_qualifier; - struct ast_node *node; - struct ast_type_specifier *type_specifier; - struct ast_fully_specified_type *fully_specified_type; - struct ast_function *function; - struct ast_parameter_declarator *parameter_declarator; - struct ast_function_definition *function_definition; - struct ast_compound_statement *compound_statement; - struct ast_expression *expression; - struct ast_declarator_list *declarator_list; - struct ast_struct_specifier *struct_specifier; - struct ast_declaration *declaration; + ast_node *node; + ast_type_specifier *type_specifier; + ast_fully_specified_type *fully_specified_type; + ast_function *function; + ast_parameter_declarator *parameter_declarator; + ast_function_definition *function_definition; + ast_compound_statement *compound_statement; + ast_expression *expression; + ast_declarator_list *declarator_list; + ast_struct_specifier *struct_specifier; + ast_declaration *declaration; struct { - struct ast_node *cond; - struct ast_expression *rest; + ast_node *cond; + ast_expression *rest; } for_rest_statement; diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 1ee6da1d23a..e0b1d285046 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -59,21 +59,21 @@ unsigned i; } type_qualifier; - struct ast_node *node; - struct ast_type_specifier *type_specifier; - struct ast_fully_specified_type *fully_specified_type; - struct ast_function *function; - struct ast_parameter_declarator *parameter_declarator; - struct ast_function_definition *function_definition; - struct ast_compound_statement *compound_statement; - struct ast_expression *expression; - struct ast_declarator_list *declarator_list; - struct ast_struct_specifier *struct_specifier; - struct ast_declaration *declaration; + ast_node *node; + ast_type_specifier *type_specifier; + ast_fully_specified_type *fully_specified_type; + ast_function *function; + ast_parameter_declarator *parameter_declarator; + ast_function_definition *function_definition; + ast_compound_statement *compound_statement; + ast_expression *expression; + ast_declarator_list *declarator_list; + ast_struct_specifier *struct_specifier; + ast_declaration *declaration; struct { - struct ast_node *cond; - struct ast_expression *rest; + ast_node *cond; + ast_expression *rest; } for_rest_statement; } @@ -1191,12 +1191,12 @@ struct_specifier: struct_declaration_list: struct_declaration { - $$ = (struct ast_node *) $1; + $$ = (ast_node *) $1; $1->link.self_link(); } | struct_declaration_list struct_declaration { - $$ = (struct ast_node *) $1; + $$ = (ast_node *) $1; $$->link.insert_before(& $2->link); } ; @@ -1260,7 +1260,7 @@ statement: ; statement_matched: - compound_statement { $$ = (struct ast_node *) $1; } + compound_statement { $$ = (ast_node *) $1; } | simple_statement ; @@ -1294,7 +1294,7 @@ compound_statement: ; statement_no_new_scope: - compound_statement_no_new_scope { $$ = (struct ast_node *) $1; } + compound_statement_no_new_scope { $$ = (ast_node *) $1; } | simple_statement ; @@ -1383,7 +1383,7 @@ selection_statement_unmatched: condition: expression { - $$ = (struct ast_node *) $1; + $$ = (ast_node *) $1; } | fully_specified_type IDENTIFIER '=' initializer { diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp index 6dd910d5816..23045ff1827 100644 --- a/src/glsl/hir_field_selection.cpp +++ b/src/glsl/hir_field_selection.cpp @@ -28,7 +28,7 @@ #include "ast.h" #include "glsl_types.h" -struct ir_rvalue * +ir_rvalue * _mesa_ast_field_selection_to_hir(const ast_expression *expr, exec_list *instructions, struct _mesa_glsl_parse_state *state) -- cgit v1.2.3 From 07ca55b7fa09b8b5c08f8e2e45f9060020593783 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 13 Aug 2010 17:11:21 -0700 Subject: Fix an MSVC build error (bugzilla 29570). --- src/glsl/glcpp/glcpp-parse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 0d70afd779c..ce4197e240c 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -32,7 +32,7 @@ #include "main/mtypes.h" #define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) -#define glcpp_printf(stream, fmt, args...) \ +#define glcpp_printf(stream, fmt, args, ...) \ stream = talloc_asprintf_append(stream, fmt, args) static void -- cgit v1.2.3 From c55aa4292f35a6d08b0660e23f248a37988a5f99 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 13 Aug 2010 17:16:43 -0700 Subject: glsl2: Refresh autogenerated bison parser. --- src/glsl/glcpp/glcpp-parse.c | 236 ++++++++++++++++++++++--------------------- src/glsl/glcpp/glcpp-parse.h | 7 +- 2 files changed, 125 insertions(+), 118 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index b081d22e752..579fe7c7ad8 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1" +#define YYBISON_VERSION "2.4.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -103,7 +102,7 @@ #include "main/mtypes.h" #define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) -#define glcpp_printf(stream, fmt, args...) \ +#define glcpp_printf(stream, fmt, args, ...) \ stream = talloc_asprintf_append(stream, fmt, args) static void @@ -213,7 +212,7 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); /* Line 189 of yacc.c */ -#line 217 "glcpp/glcpp-parse.c" +#line 216 "glcpp/glcpp-parse.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -301,7 +300,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 305 "glcpp/glcpp-parse.c" +#line 304 "glcpp/glcpp-parse.c" #ifdef short # undef short @@ -351,7 +350,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -939,9 +938,18 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -998,7 +1006,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1540,7 +1548,7 @@ YYLTYPE yylloc; YYLTYPE *yylsp; /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; + YYLTYPE yyerror_range[3]; YYSIZE_T yystacksize; @@ -1587,7 +1595,7 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if YYLTYPE_IS_TRIVIAL +#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; @@ -1595,7 +1603,7 @@ YYLTYPE yylloc; /* User initialization code. */ -/* Line 1242 of yacc.c */ +/* Line 1251 of yacc.c */ #line 148 "glcpp/glcpp-parse.y" { yylloc.first_line = 1; @@ -1605,8 +1613,8 @@ YYLTYPE yylloc; yylloc.source = 0; } -/* Line 1242 of yacc.c */ -#line 1610 "glcpp/glcpp-parse.c" +/* Line 1251 of yacc.c */ +#line 1618 "glcpp/glcpp-parse.c" yylsp[0] = yylloc; goto yysetstate; @@ -1793,7 +1801,7 @@ yyreduce: { case 4: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 187 "glcpp/glcpp-parse.y" { glcpp_print(parser->output, "\n"); @@ -1802,7 +1810,7 @@ yyreduce: case 5: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 190 "glcpp/glcpp-parse.y" { _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); @@ -1813,7 +1821,7 @@ yyreduce: case 8: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 200 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); @@ -1822,7 +1830,7 @@ yyreduce: case 9: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 203 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); @@ -1831,7 +1839,7 @@ yyreduce: case 10: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 209 "glcpp/glcpp-parse.y" { _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); @@ -1840,7 +1848,7 @@ yyreduce: case 11: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 212 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); @@ -1849,7 +1857,7 @@ yyreduce: case 12: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 215 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); @@ -1858,7 +1866,7 @@ yyreduce: case 13: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 218 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); @@ -1872,7 +1880,7 @@ yyreduce: case 14: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 226 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'if' expression if @@ -1897,7 +1905,7 @@ yyreduce: case 15: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 245 "glcpp/glcpp-parse.y" { /* #if without an expression is only an error if we @@ -1913,7 +1921,7 @@ yyreduce: case 16: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 255 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); @@ -1924,7 +1932,7 @@ yyreduce: case 17: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 260 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); @@ -1935,7 +1943,7 @@ yyreduce: case 18: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 265 "glcpp/glcpp-parse.y" { /* Be careful to only evaluate the 'elif' expression @@ -1960,7 +1968,7 @@ yyreduce: case 19: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 284 "glcpp/glcpp-parse.y" { /* #elif without an expression is an error unless we @@ -1981,7 +1989,7 @@ yyreduce: case 20: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 299 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); @@ -1990,7 +1998,7 @@ yyreduce: case 21: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 302 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); @@ -1999,7 +2007,7 @@ yyreduce: case 22: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 305 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); @@ -2014,7 +2022,7 @@ yyreduce: case 24: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 318 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { @@ -2029,7 +2037,7 @@ yyreduce: case 25: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 327 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); @@ -2038,7 +2046,7 @@ yyreduce: case 27: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 333 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); @@ -2047,7 +2055,7 @@ yyreduce: case 28: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 336 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); @@ -2056,7 +2064,7 @@ yyreduce: case 29: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 339 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); @@ -2065,7 +2073,7 @@ yyreduce: case 30: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 342 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); @@ -2074,7 +2082,7 @@ yyreduce: case 31: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 345 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); @@ -2083,7 +2091,7 @@ yyreduce: case 32: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 348 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); @@ -2092,7 +2100,7 @@ yyreduce: case 33: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 351 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); @@ -2101,7 +2109,7 @@ yyreduce: case 34: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 354 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); @@ -2110,7 +2118,7 @@ yyreduce: case 35: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 357 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); @@ -2119,7 +2127,7 @@ yyreduce: case 36: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 360 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); @@ -2128,7 +2136,7 @@ yyreduce: case 37: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 363 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); @@ -2137,7 +2145,7 @@ yyreduce: case 38: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 366 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); @@ -2146,7 +2154,7 @@ yyreduce: case 39: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 369 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); @@ -2155,7 +2163,7 @@ yyreduce: case 40: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 372 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); @@ -2164,7 +2172,7 @@ yyreduce: case 41: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 375 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); @@ -2173,7 +2181,7 @@ yyreduce: case 42: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 378 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); @@ -2182,7 +2190,7 @@ yyreduce: case 43: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 381 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); @@ -2191,7 +2199,7 @@ yyreduce: case 44: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 384 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); @@ -2200,7 +2208,7 @@ yyreduce: case 45: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 387 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); @@ -2209,7 +2217,7 @@ yyreduce: case 46: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 390 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); @@ -2218,7 +2226,7 @@ yyreduce: case 47: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 393 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); @@ -2227,7 +2235,7 @@ yyreduce: case 48: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 396 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); @@ -2236,7 +2244,7 @@ yyreduce: case 49: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 399 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); @@ -2245,7 +2253,7 @@ yyreduce: case 50: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 405 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); @@ -2256,7 +2264,7 @@ yyreduce: case 51: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 410 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); @@ -2267,14 +2275,14 @@ yyreduce: case 52: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 418 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 54: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 423 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); @@ -2283,14 +2291,14 @@ yyreduce: case 55: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 429 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 58: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 435 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); @@ -2299,7 +2307,7 @@ yyreduce: case 59: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 442 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; @@ -2309,7 +2317,7 @@ yyreduce: case 60: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 446 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; @@ -2319,7 +2327,7 @@ yyreduce: case 62: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 455 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; @@ -2331,7 +2339,7 @@ yyreduce: case 63: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 461 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); @@ -2342,7 +2350,7 @@ yyreduce: case 64: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 469 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; @@ -2354,7 +2362,7 @@ yyreduce: case 65: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 475 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); @@ -2365,7 +2373,7 @@ yyreduce: case 66: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 483 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); @@ -2375,7 +2383,7 @@ yyreduce: case 67: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 487 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); @@ -2385,7 +2393,7 @@ yyreduce: case 68: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 491 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); @@ -2395,7 +2403,7 @@ yyreduce: case 69: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 495 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); @@ -2405,7 +2413,7 @@ yyreduce: case 70: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 499 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); @@ -2415,225 +2423,225 @@ yyreduce: case 71: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 506 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 72: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 507 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 73: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 508 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 74: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 509 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 75: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 510 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 76: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 511 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 77: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 512 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 78: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 513 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 79: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 514 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 80: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 515 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 81: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 516 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 82: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 517 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 83: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 518 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 84: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 519 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 85: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 520 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 86: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 521 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 87: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 522 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 88: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 523 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 89: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 524 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 90: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 525 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 91: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 526 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 92: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 527 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 93: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 528 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 94: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 529 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 95: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 530 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 96: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 531 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 97: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 532 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 98: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 533 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 99: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 534 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 100: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 535 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 101: -/* Line 1455 of yacc.c */ +/* Line 1464 of yacc.c */ #line 536 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; -/* Line 1455 of yacc.c */ -#line 2637 "glcpp/glcpp-parse.c" +/* Line 1464 of yacc.c */ +#line 2645 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2705,7 +2713,7 @@ yyerrlab: #endif } - yyerror_range[0] = yylloc; + yyerror_range[1] = yylloc; if (yyerrstatus == 3) { @@ -2742,7 +2750,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[0] = yylsp[1-yylen]; + yyerror_range[1] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); @@ -2776,7 +2784,7 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - yyerror_range[0] = *yylsp; + yyerror_range[1] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp, parser); YYPOPSTACK (1); @@ -2786,10 +2794,10 @@ yyerrlab1: *++yyvsp = yylval; - yyerror_range[1] = yylloc; + yyerror_range[2] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + YYLLOC_DEFAULT (yyloc, yyerror_range, 2); *++yylsp = yyloc; /* Shift the error token. */ @@ -2851,7 +2859,7 @@ yyreturn: -/* Line 1675 of yacc.c */ +/* Line 1684 of yacc.c */ #line 539 "glcpp/glcpp-parse.y" diff --git a/src/glsl/glcpp/glcpp-parse.h b/src/glsl/glcpp/glcpp-parse.h index 50758930e9c..40556854f38 100644 --- a/src/glsl/glcpp/glcpp-parse.h +++ b/src/glsl/glcpp/glcpp-parse.h @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit v1.2.3 From 2f4fe151681a6f6afe1d452eece6cf4144f44e49 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 10 Aug 2010 13:06:49 -0700 Subject: glsl2: Move the common optimization passes to a helper function. These are passes that we expect all codegen to be happy with. The other lowering passes for Mesa IR are moved to the Mesa IR generator. --- src/glsl/glsl_parser_extras.cpp | 35 +++++++++++++++++++++++ src/glsl/ir_optimization.h | 2 ++ src/glsl/linker.cpp | 47 ++++--------------------------- src/mesa/program/ir_to_mesa.cpp | 61 ++++++++++++++++++++--------------------- 4 files changed, 72 insertions(+), 73 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index dbf6f531569..2ed3905abc9 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -33,6 +33,7 @@ extern "C" { #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" +#include "ir_optimization.h" _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct __GLcontextRec *ctx, GLenum target, void *mem_ctx) @@ -705,3 +706,37 @@ ast_struct_specifier::ast_struct_specifier(char *identifier, name = identifier; this->declarations.push_degenerate_list_at_head(&declarator_list->link); } + +bool +do_common_optimization(exec_list *ir, bool linked) +{ + GLboolean progress = GL_FALSE; + + progress = do_sub_to_add_neg(ir) || progress; + + if (linked) { + progress = do_function_inlining(ir) || progress; + progress = do_dead_functions(ir) || progress; + } + progress = do_structure_splitting(ir) || progress; + progress = do_if_simplification(ir) || progress; + progress = do_copy_propagation(ir) || progress; + if (linked) + progress = do_dead_code(ir) || progress; + else + progress = do_dead_code_unlinked(ir) || progress; + progress = do_dead_code_local(ir) || progress; + progress = do_tree_grafting(ir) || progress; + progress = do_constant_propagation(ir) || progress; + if (linked) + progress = do_constant_variable(ir) || progress; + else + progress = do_constant_variable_unlinked(ir) || progress; + progress = do_constant_folding(ir) || progress; + progress = do_algebraic(ir) || progress; + progress = do_if_return(ir) || progress; + progress = do_vec_index_to_swizzle(ir) || progress; + progress = do_swizzle_swizzle(ir) || progress; + + return progress; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 5997a30eab3..0c4e548e44c 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -28,6 +28,8 @@ * Prototypes for optimization passes to be called by the compiler and drivers. */ +bool do_common_optimization(exec_list *ir, bool linked); + bool do_algebraic(exec_list *instructions); bool do_constant_folding(exec_list *instructions); bool do_constant_variable(exec_list *instructions); diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 7bff859d554..9931251f404 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1308,48 +1308,13 @@ link_shaders(struct gl_shader_program *prog) prog->LinkStatus = true; } - /* FINISHME: Perform whole-program optimization here. */ + /* Do common optimization before assigning storage for attributes, + * uniforms, and varyings. Later optimization could possibly make + * some of that unused. + */ for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { - /* Optimization passes */ - bool progress; - exec_list *ir = prog->_LinkedShaders[i]->ir; - - /* Lowering */ - do_mat_op_to_vec(ir); - do_mod_to_fract(ir); - do_div_to_mul_rcp(ir); - do_explog_to_explog2(ir); - do_sub_to_add_neg(ir); - - do { - progress = false; - - progress = do_function_inlining(ir) || progress; - progress = do_dead_functions(ir) || progress; - progress = do_structure_splitting(ir) || progress; - progress = do_if_simplification(ir) || progress; - progress = do_copy_propagation(ir) || progress; - progress = do_dead_code_local(ir) || progress; - progress = do_dead_code(ir) || progress; - progress = do_tree_grafting(ir) || progress; - progress = do_constant_propagation(ir) || progress; - progress = do_constant_variable(ir) || progress; - progress = do_constant_folding(ir) || progress; - progress = do_algebraic(ir) || progress; - progress = do_if_return(ir) || progress; -#if 0 - if (ctx->Shader.EmitNoIfs) - progress = do_if_to_cond_assign(ir) || progress; -#endif - - progress = do_vec_index_to_swizzle(ir) || progress; - /* Do this one after the previous to let the easier pass handle - * constant vector indexing. - */ - progress = do_vec_index_to_cond_assign(ir) || progress; - - progress = do_swizzle_swizzle(ir) || progress; - } while (progress); + while (do_common_optimization(prog->_LinkedShaders[i]->ir, true)) + ; } assign_uniform_locations(prog); diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index ecb13069cb7..c8c655b2967 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2567,38 +2567,11 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) if (!state->error && !shader->ir->is_empty()) { validate_ir_tree(shader->ir); - /* Lowering */ - do_mat_op_to_vec(shader->ir); - do_mod_to_fract(shader->ir); - do_div_to_mul_rcp(shader->ir); - do_sub_to_add_neg(shader->ir); - - /* Optimization passes */ - bool progress; - do { - progress = false; - - progress = do_if_simplification(shader->ir) || progress; - progress = do_copy_propagation(shader->ir) || progress; - progress = do_dead_code_local(shader->ir) || progress; - progress = do_dead_code_unlinked(shader->ir) || progress; - progress = do_tree_grafting(shader->ir) || progress; - progress = do_constant_propagation(shader->ir) || progress; - progress = do_constant_variable_unlinked(shader->ir) || progress; - progress = do_constant_folding(shader->ir) || progress; - progress = do_algebraic(shader->ir) || progress; - progress = do_if_return(shader->ir) || progress; - if (ctx->Shader.EmitNoIfs) - progress = do_if_to_cond_assign(shader->ir) || progress; - - progress = do_vec_index_to_swizzle(shader->ir) || progress; - /* Do this one after the previous to let the easier pass handle - * constant vector indexing. - */ - progress = do_vec_index_to_cond_assign(shader->ir) || progress; - - progress = do_swizzle_swizzle(shader->ir) || progress; - } while (progress); + /* Do some optimization at compile time to reduce shader IR size + * and reduce later work if the same shader is linked multiple times + */ + while (do_common_optimization(shader->ir, false)) + ; validate_ir_tree(shader->ir); } @@ -2665,6 +2638,30 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) prog->Uniforms = _mesa_new_uniform_list(); } + if (prog->LinkStatus) { + for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { + bool progress; + exec_list *ir = prog->_LinkedShaders[i]->ir; + + do { + progress = false; + + /* Lowering */ + do_mat_op_to_vec(ir); + do_mod_to_fract(ir); + do_div_to_mul_rcp(ir); + do_explog_to_explog2(ir); + + progress = do_common_optimization(ir, true) || progress; + + if (ctx->Shader.EmitNoIfs) + progress = do_if_to_cond_assign(ir) || progress; + + progress = do_vec_index_to_cond_assign(ir) || progress; + } while (progress); + } + } + if (prog->LinkStatus) { for (i = 0; i < prog->_NumLinkedShaders; i++) { struct gl_program *linked_prog; -- cgit v1.2.3 From 013bbbbb0ac52a12d1e4413700dc40dee70186f8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 10 Aug 2010 19:52:02 -0700 Subject: glsl2: Add support for ir_unop_neg to ir_mat_op_to_vec --- src/glsl/ir_mat_op_to_vec.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/glsl/ir_mat_op_to_vec.cpp b/src/glsl/ir_mat_op_to_vec.cpp index 880454c0076..80e05799861 100644 --- a/src/glsl/ir_mat_op_to_vec.cpp +++ b/src/glsl/ir_mat_op_to_vec.cpp @@ -311,6 +311,30 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign) /* OK, time to break down this matrix operation. */ switch (expr->operation) { + case ir_unop_neg: { + const unsigned mask = (1U << result_var->type->vector_elements) - 1; + + /* Apply the operation to each column.*/ + for (i = 0; i < matrix_columns; i++) { + ir_rvalue *op0 = get_column(op_var[0], i); + ir_dereference *result = get_column(result_var, i); + ir_expression *column_expr; + ir_assignment *column_assign; + + column_expr = new(base_ir) ir_expression(expr->operation, + result->type, + op0, + NULL); + + column_assign = new(base_ir) ir_assignment(result, + column_expr, + NULL, + mask); + assert(column_assign->write_mask != 0); + base_ir->insert_before(column_assign); + } + break; + } case ir_binop_add: case ir_binop_sub: case ir_binop_div: -- cgit v1.2.3 From d19eecef54384c163af27a470496ed885a5a271b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 10 Aug 2010 20:11:44 -0700 Subject: glsl2: Move ir_to_mesa handling to driver CompileShader and LinkShader hooks. This lets drivers override ir_to_mesa with their own codegen, or at least have a native alternative. --- src/mesa/main/dd.h | 21 +++++++ src/mesa/main/shaderobj.c | 2 + src/mesa/program/ir_to_mesa.cpp | 126 +++++++++++++++++++++++----------------- src/mesa/program/ir_to_mesa.h | 2 + 4 files changed, 99 insertions(+), 52 deletions(-) diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 825073ca886..71d0f570e4b 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -595,6 +595,27 @@ struct dd_function_table { /*@}*/ + /** + * \name GLSL shader/program functions. + */ + /*@{*/ + /** + * Called when a shader is compiled. + * + * Note that not all shader objects get ShaderCompile called on + * them. Notably, the shaders containing builtin functions do not + * have CompileShader() called, so if lowering passes are done they + * need to also be performed in LinkShader(). + */ + GLboolean (*CompileShader)(GLcontext *ctx, struct gl_shader *shader); + /** + * Called when a shader program is linked. + * + * This gives drivers an opportunity to clone the IR and make their + * own transformations on it for the purposes of code generation. + */ + GLboolean (*LinkShader)(GLcontext *ctx, struct gl_shader_program *shader); + /*@}*/ /** * \name State-changing functions. diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index 129d9742247..863d50fbe55 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -387,4 +387,6 @@ _mesa_init_shader_object_functions(struct dd_function_table *driver) driver->DeleteShader = __mesa_delete_shader; driver->NewShaderProgram = _mesa_new_shader_program; driver->DeleteShaderProgram = __mesa_delete_shader_program; + driver->CompileShader = _mesa_ir_compile_shader; + driver->LinkShader = _mesa_ir_link_shader; } diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index c8c655b2967..7490ffa4fe7 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2543,6 +2543,72 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program, } extern "C" { +GLboolean +_mesa_ir_compile_shader(GLcontext *ctx, struct gl_shader *shader) +{ + assert(shader->CompileStatus); + + return GL_TRUE; +} + +GLboolean +_mesa_ir_link_shader(GLcontext *ctx, struct gl_shader_program *prog) +{ + assert(prog->LinkStatus); + + for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { + bool progress; + exec_list *ir = prog->_LinkedShaders[i]->ir; + + do { + progress = false; + + /* Lowering */ + do_mat_op_to_vec(ir); + do_mod_to_fract(ir); + do_div_to_mul_rcp(ir); + do_explog_to_explog2(ir); + + progress = do_common_optimization(ir, true) || progress; + + if (ctx->Shader.EmitNoIfs) + progress = do_if_to_cond_assign(ir) || progress; + + progress = do_vec_index_to_cond_assign(ir) || progress; + } while (progress); + + validate_ir_tree(ir); + } + + for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { + struct gl_program *linked_prog; + bool ok = true; + + linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]); + + link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog); + + switch (prog->_LinkedShaders[i]->Type) { + case GL_VERTEX_SHADER: + _mesa_reference_vertprog(ctx, &prog->VertexProgram, + (struct gl_vertex_program *)linked_prog); + ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, + linked_prog); + break; + case GL_FRAGMENT_SHADER: + _mesa_reference_fragprog(ctx, &prog->FragmentProgram, + (struct gl_fragment_program *)linked_prog); + ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB, + linked_prog); + break; + } + if (!ok) { + return GL_FALSE; + } + } + + return GL_TRUE; +} void _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) @@ -2604,7 +2670,12 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader) reparent_ir(shader->ir, shader); talloc_free(state); - } + + if (shader->CompileStatus) { + if (!ctx->Driver.CompileShader(ctx, shader)) + shader->CompileStatus = GL_FALSE; + } +} void _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) @@ -2639,57 +2710,8 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) } if (prog->LinkStatus) { - for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) { - bool progress; - exec_list *ir = prog->_LinkedShaders[i]->ir; - - do { - progress = false; - - /* Lowering */ - do_mat_op_to_vec(ir); - do_mod_to_fract(ir); - do_div_to_mul_rcp(ir); - do_explog_to_explog2(ir); - - progress = do_common_optimization(ir, true) || progress; - - if (ctx->Shader.EmitNoIfs) - progress = do_if_to_cond_assign(ir) || progress; - - progress = do_vec_index_to_cond_assign(ir) || progress; - } while (progress); - } - } - - if (prog->LinkStatus) { - for (i = 0; i < prog->_NumLinkedShaders; i++) { - struct gl_program *linked_prog; - bool ok = true; - - linked_prog = get_mesa_program(ctx, prog, - prog->_LinkedShaders[i]); - - link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog); - - switch (prog->_LinkedShaders[i]->Type) { - case GL_VERTEX_SHADER: - _mesa_reference_vertprog(ctx, &prog->VertexProgram, - (struct gl_vertex_program *)linked_prog); - ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, - linked_prog); - break; - case GL_FRAGMENT_SHADER: - _mesa_reference_fragprog(ctx, &prog->FragmentProgram, - (struct gl_fragment_program *)linked_prog); - ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB, - linked_prog); - break; - } - if (!ok) { - prog->LinkStatus = GL_FALSE; - } - } + if (!ctx->Driver.LinkShader(ctx, prog)) + prog->LinkStatus = GL_FALSE; } } diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h index e832f84e754..ecaacde4bb0 100644 --- a/src/mesa/program/ir_to_mesa.h +++ b/src/mesa/program/ir_to_mesa.h @@ -30,6 +30,8 @@ extern "C" { void _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *sh); void _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog); +GLboolean _mesa_ir_compile_shader(GLcontext *ctx, struct gl_shader *shader); +GLboolean _mesa_ir_link_shader(GLcontext *ctx, struct gl_shader_program *prog); #ifdef __cplusplus } -- cgit v1.2.3 From c374487a54aca2dd1053645092367c1cf0414ef7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 10 Aug 2010 22:21:59 -0700 Subject: intel: Remove include of texmem.h, since we haven't used it in ages. --- src/mesa/drivers/dri/i965/brw_wm.c | 2 +- src/mesa/drivers/dri/intel/intel_context.h | 1 - src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 1 + src/mesa/drivers/dri/intel/intel_tex.h | 2 -- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index e182fc32029..34cefeea32a 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -32,7 +32,7 @@ #include "brw_context.h" #include "brw_wm.h" #include "brw_state.h" - +#include "main/formats.h" /** Return number of src args for given instruction */ GLuint brw_wm_nr_args( GLuint opcode ) diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index c7ac2de01e6..f245ba843bd 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -32,7 +32,6 @@ #include "main/mtypes.h" #include "main/mm.h" -#include "texmem.h" #include "dri_metaops.h" #include "drm.h" #include "intel_bufmgr.h" diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 39ac0205fa1..42adb4cb4a7 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -30,6 +30,7 @@ #include "intel_regions.h" #include "intel_tex_layout.h" #include "main/enums.h" +#include "main/formats.h" #define FILE_DEBUG_FLAG DEBUG_MIPTREE diff --git a/src/mesa/drivers/dri/intel/intel_tex.h b/src/mesa/drivers/dri/intel/intel_tex.h index 4bb012dc65e..cd77dd5b8e4 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.h +++ b/src/mesa/drivers/dri/intel/intel_tex.h @@ -31,8 +31,6 @@ #include "main/mtypes.h" #include "main/formats.h" #include "intel_context.h" -#include "texmem.h" - void intelInitTextureFuncs(struct dd_function_table *functions); -- cgit v1.2.3 From 9c3acce68001fdf7f5c77d1819d576b4cf92410a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 10 Aug 2010 22:33:39 -0700 Subject: mesa: Avoid using c++ keyword in dri_util.h when compiled with c++. --- src/mesa/drivers/dri/common/dri_util.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index bc647ff8130..e2fcdaa6389 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -513,7 +513,11 @@ struct __DRIscreenRec { * * This pointer is never touched by the DRI layer. */ +#ifdef __cplusplus + void *priv; +#else void *private; +#endif /* Extensions provided by the loader. */ const __DRIgetDrawableInfoExtension *getDrawableInfo; -- cgit v1.2.3 From b3b0cf6a4c6b23e0ebe7e5f5ab1b7cacf27268b1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 13 Aug 2010 20:39:24 -0700 Subject: glsl2: Add a generic visitor class to call back with pointers to each rvalue. I keep copy and pasting this code all over, so consolidate it in one place. --- src/glsl/Makefile | 1 + src/glsl/ir_algebraic.cpp | 120 ++++---------------------------- src/glsl/ir_rvalue_visitor.cpp | 134 ++++++++++++++++++++++++++++++++++++ src/glsl/ir_rvalue_visitor.h | 47 +++++++++++++ src/glsl/ir_structure_splitting.cpp | 109 ++--------------------------- 5 files changed, 203 insertions(+), 208 deletions(-) create mode 100644 src/glsl/ir_rvalue_visitor.cpp create mode 100644 src/glsl/ir_rvalue_visitor.h diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 2f62517e95d..48b7c8f66b5 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -57,6 +57,7 @@ CXX_SOURCES = \ ir_mod_to_fract.cpp \ ir_print_visitor.cpp \ ir_reader.cpp \ + ir_rvalue_visitor.cpp \ ir_set_program_inouts.cpp \ ir_structure_splitting.cpp \ ir_sub_to_add_neg.cpp \ diff --git a/src/glsl/ir_algebraic.cpp b/src/glsl/ir_algebraic.cpp index 86fb7e49c03..a66c820a278 100644 --- a/src/glsl/ir_algebraic.cpp +++ b/src/glsl/ir_algebraic.cpp @@ -30,6 +30,7 @@ #include "ir.h" #include "ir_visitor.h" +#include "ir_rvalue_visitor.h" #include "ir_optimization.h" #include "glsl_types.h" @@ -37,7 +38,7 @@ * Visitor class for replacing expressions with ir_constant values. */ -class ir_algebraic_visitor : public ir_hierarchical_visitor { +class ir_algebraic_visitor : public ir_rvalue_visitor { public: ir_algebraic_visitor() { @@ -48,16 +49,8 @@ public: { } - virtual ir_visitor_status visit_leave(ir_assignment *); - virtual ir_visitor_status visit_leave(ir_call *); - virtual ir_visitor_status visit_leave(ir_dereference_array *); - virtual ir_visitor_status visit_leave(ir_expression *); - virtual ir_visitor_status visit_leave(ir_if *); - virtual ir_visitor_status visit_leave(ir_return *); - virtual ir_visitor_status visit_leave(ir_swizzle *); - virtual ir_visitor_status visit_leave(ir_texture *); - - ir_rvalue *handle_expression(ir_rvalue *in_ir); + ir_rvalue *handle_expression(ir_expression *ir); + void handle_rvalue(ir_rvalue **rvalue); bool reassociate_constant(ir_expression *ir1, int const_index, ir_constant *constant, @@ -224,22 +217,15 @@ ir_algebraic_visitor::reassociate_constant(ir_expression *ir1, int const_index, } ir_rvalue * -ir_algebraic_visitor::handle_expression(ir_rvalue *in_ir) +ir_algebraic_visitor::handle_expression(ir_expression *ir) { - ir_expression *ir = (ir_expression *)in_ir; ir_constant *op_const[2] = {NULL, NULL}; ir_expression *op_expr[2] = {NULL, NULL}; unsigned int i; - if (!in_ir) - return NULL; - - if (in_ir->ir_type != ir_type_expression) - return in_ir; - for (i = 0; i < ir->get_num_operands(); i++) { if (ir->operands[i]->type->is_matrix()) - return in_ir; + return ir; op_const[i] = ir->operands[i]->constant_expression_value(); op_expr[i] = ir->operands[i]->as_expression(); @@ -379,98 +365,22 @@ ir_algebraic_visitor::handle_expression(ir_rvalue *in_ir) break; } - return in_ir; -} - -ir_visitor_status -ir_algebraic_visitor::visit_leave(ir_expression *ir) -{ - unsigned int operand; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - ir->operands[operand] = handle_expression(ir->operands[operand]); - } - - return visit_continue; -} - -ir_visitor_status -ir_algebraic_visitor::visit_leave(ir_texture *ir) -{ - ir->coordinate = handle_expression(ir->coordinate); - ir->projector = handle_expression(ir->projector); - ir->shadow_comparitor = handle_expression(ir->shadow_comparitor); - - switch (ir->op) { - case ir_tex: - break; - case ir_txb: - ir->lod_info.bias = handle_expression(ir->lod_info.bias); - break; - case ir_txf: - case ir_txl: - ir->lod_info.lod = handle_expression(ir->lod_info.lod); - break; - case ir_txd: - ir->lod_info.grad.dPdx = handle_expression(ir->lod_info.grad.dPdx); - ir->lod_info.grad.dPdy = handle_expression(ir->lod_info.grad.dPdy); - break; - } - - return visit_continue; + return ir; } -ir_visitor_status -ir_algebraic_visitor::visit_leave(ir_swizzle *ir) -{ - ir->val = handle_expression(ir->val); - return visit_continue; -} - -ir_visitor_status -ir_algebraic_visitor::visit_leave(ir_dereference_array *ir) -{ - ir->array_index = handle_expression(ir->array_index); - return visit_continue; -} - -ir_visitor_status -ir_algebraic_visitor::visit_leave(ir_assignment *ir) -{ - ir->rhs = handle_expression(ir->rhs); - ir->condition = handle_expression(ir->condition); - return visit_continue; -} - -ir_visitor_status -ir_algebraic_visitor::visit_leave(ir_call *ir) +void +ir_algebraic_visitor::handle_rvalue(ir_rvalue **rvalue) { - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - ir_rvalue *new_param = handle_expression(param); + if (!*rvalue) + return; - if (new_param != param) { - param->replace_with(new_param); - } - } - return visit_continue; -} + ir_expression *expr = (*rvalue)->as_expression(); + if (!expr) + return; -ir_visitor_status -ir_algebraic_visitor::visit_leave(ir_return *ir) -{ - ir->value = handle_expression(ir->value);; - return visit_continue; + *rvalue = handle_expression(expr); } -ir_visitor_status -ir_algebraic_visitor::visit_leave(ir_if *ir) -{ - ir->condition = handle_expression(ir->condition); - return visit_continue; -} - - bool do_algebraic(exec_list *instructions) { diff --git a/src/glsl/ir_rvalue_visitor.cpp b/src/glsl/ir_rvalue_visitor.cpp new file mode 100644 index 00000000000..613b07c3029 --- /dev/null +++ b/src/glsl/ir_rvalue_visitor.cpp @@ -0,0 +1,134 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_rvalue_visitor.cpp + * + * Generic class to implement the common pattern we have of wanting to + * visit each ir_rvalue * and possibly change that node to a different + * class. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_rvalue_visitor.h" +#include "ir_print_visitor.h" +#include "glsl_types.h" + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + handle_rvalue(&ir->operands[operand]); + } + + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_texture *ir) +{ + handle_rvalue(&ir->coordinate); + handle_rvalue(&ir->projector); + handle_rvalue(&ir->shadow_comparitor); + + switch (ir->op) { + case ir_tex: + break; + case ir_txb: + handle_rvalue(&ir->lod_info.bias); + break; + case ir_txf: + case ir_txl: + handle_rvalue(&ir->lod_info.lod); + break; + case ir_txd: + handle_rvalue(&ir->lod_info.grad.dPdx); + handle_rvalue(&ir->lod_info.grad.dPdy); + break; + } + + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_swizzle *ir) +{ + handle_rvalue(&ir->val); + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_dereference_array *ir) +{ + handle_rvalue(&ir->array_index); + handle_rvalue(&ir->array); + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_dereference_record *ir) +{ + handle_rvalue(&ir->record); + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_assignment *ir) +{ + handle_rvalue(&ir->rhs); + handle_rvalue(&ir->condition); + + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = param; + handle_rvalue(&new_param); + + if (new_param != param) { + param->replace_with(new_param); + } + } + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_return *ir) +{ + handle_rvalue(&ir->value);; + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_if *ir) +{ + handle_rvalue(&ir->condition); + return visit_continue; +} diff --git a/src/glsl/ir_rvalue_visitor.h b/src/glsl/ir_rvalue_visitor.h new file mode 100644 index 00000000000..31a56beb9b8 --- /dev/null +++ b/src/glsl/ir_rvalue_visitor.h @@ -0,0 +1,47 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_rvalue_visitor.h + * + * Generic class to implement the common pattern we have of wanting to + * visit each ir_rvalue * and possibly change that node to a different + * class. Just implement handle_rvalue() and you will be called with + * a pointer to each rvalue in the tree. + */ + +class ir_rvalue_visitor : public ir_hierarchical_visitor { +public: + + virtual ir_visitor_status visit_leave(ir_assignment *); + virtual ir_visitor_status visit_leave(ir_call *); + virtual ir_visitor_status visit_leave(ir_dereference_array *); + virtual ir_visitor_status visit_leave(ir_dereference_record *); + virtual ir_visitor_status visit_leave(ir_expression *); + virtual ir_visitor_status visit_leave(ir_if *); + virtual ir_visitor_status visit_leave(ir_return *); + virtual ir_visitor_status visit_leave(ir_swizzle *); + virtual ir_visitor_status visit_leave(ir_texture *); + + virtual void handle_rvalue(ir_rvalue **rvalue) = 0; +}; diff --git a/src/glsl/ir_structure_splitting.cpp b/src/glsl/ir_structure_splitting.cpp index 2f838962631..e257defb1a1 100644 --- a/src/glsl/ir_structure_splitting.cpp +++ b/src/glsl/ir_structure_splitting.cpp @@ -35,6 +35,7 @@ #include "ir.h" #include "ir_visitor.h" #include "ir_print_visitor.h" +#include "ir_rvalue_visitor.h" #include "glsl_types.h" static bool debug = false; @@ -165,7 +166,7 @@ ir_structure_reference_visitor::visit_enter(ir_function_signature *ir) return visit_continue_with_parent; } -class ir_structure_splitting_visitor : public ir_hierarchical_visitor { +class ir_structure_splitting_visitor : public ir_rvalue_visitor { public: ir_structure_splitting_visitor(exec_list *vars) { @@ -177,17 +178,9 @@ public: } virtual ir_visitor_status visit_leave(ir_assignment *); - virtual ir_visitor_status visit_leave(ir_call *); - virtual ir_visitor_status visit_leave(ir_dereference_array *); - virtual ir_visitor_status visit_leave(ir_dereference_record *); - virtual ir_visitor_status visit_leave(ir_expression *); - virtual ir_visitor_status visit_leave(ir_if *); - virtual ir_visitor_status visit_leave(ir_return *); - virtual ir_visitor_status visit_leave(ir_swizzle *); - virtual ir_visitor_status visit_leave(ir_texture *); void split_deref(ir_dereference **deref); - void split_rvalue(ir_rvalue **rvalue); + void handle_rvalue(ir_rvalue **rvalue); struct variable_entry *get_splitting_entry(ir_variable *var); exec_list *variable_list; @@ -239,7 +232,7 @@ ir_structure_splitting_visitor::split_deref(ir_dereference **deref) } void -ir_structure_splitting_visitor::split_rvalue(ir_rvalue **rvalue) +ir_structure_splitting_visitor::handle_rvalue(ir_rvalue **rvalue) { if (!*rvalue) return; @@ -253,66 +246,6 @@ ir_structure_splitting_visitor::split_rvalue(ir_rvalue **rvalue) *rvalue = deref; } -ir_visitor_status -ir_structure_splitting_visitor::visit_leave(ir_expression *ir) -{ - unsigned int operand; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - split_rvalue(&ir->operands[operand]); - } - - return visit_continue; -} - -ir_visitor_status -ir_structure_splitting_visitor::visit_leave(ir_texture *ir) -{ - split_rvalue(&ir->coordinate); - split_rvalue(&ir->projector); - split_rvalue(&ir->shadow_comparitor); - - switch (ir->op) { - case ir_tex: - break; - case ir_txb: - split_rvalue(&ir->lod_info.bias); - break; - case ir_txf: - case ir_txl: - split_rvalue(&ir->lod_info.lod); - break; - case ir_txd: - split_rvalue(&ir->lod_info.grad.dPdx); - split_rvalue(&ir->lod_info.grad.dPdy); - break; - } - - return visit_continue; -} - -ir_visitor_status -ir_structure_splitting_visitor::visit_leave(ir_swizzle *ir) -{ - split_rvalue(&ir->val); - return visit_continue; -} - -ir_visitor_status -ir_structure_splitting_visitor::visit_leave(ir_dereference_array *ir) -{ - split_rvalue(&ir->array_index); - split_rvalue(&ir->array); - return visit_continue; -} - -ir_visitor_status -ir_structure_splitting_visitor::visit_leave(ir_dereference_record *ir) -{ - split_rvalue(&ir->record); - return visit_continue; -} - ir_visitor_status ir_structure_splitting_visitor::visit_leave(ir_assignment *ir) { @@ -349,45 +282,15 @@ ir_structure_splitting_visitor::visit_leave(ir_assignment *ir) } ir->remove(); } else { - split_rvalue(&ir->rhs); + handle_rvalue(&ir->rhs); split_deref(&ir->lhs); } - split_rvalue(&ir->condition); - - return visit_continue; -} - -ir_visitor_status -ir_structure_splitting_visitor::visit_leave(ir_call *ir) -{ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - ir_rvalue *new_param = param; - split_rvalue(&new_param); - - if (new_param != param) { - param->replace_with(new_param); - } - } - return visit_continue; -} - -ir_visitor_status -ir_structure_splitting_visitor::visit_leave(ir_return *ir) -{ - split_rvalue(&ir->value);; - return visit_continue; -} + handle_rvalue(&ir->condition); -ir_visitor_status -ir_structure_splitting_visitor::visit_leave(ir_if *ir) -{ - split_rvalue(&ir->condition); return visit_continue; } - bool do_structure_splitting(exec_list *instructions) { -- cgit v1.2.3 From 42cab131dac469475c67ab38a2c29f2f66e6ff49 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 13 Aug 2010 20:50:10 -0700 Subject: glsl2: Convert ir_constant_propagation to ir_rvalue_visitor. This one is a little tricky because of the LHS handling. --- src/glsl/ir_constant_propagation.cpp | 64 +++++------------------------------- 1 file changed, 9 insertions(+), 55 deletions(-) diff --git a/src/glsl/ir_constant_propagation.cpp b/src/glsl/ir_constant_propagation.cpp index adae0aa1171..76c1ce7013f 100644 --- a/src/glsl/ir_constant_propagation.cpp +++ b/src/glsl/ir_constant_propagation.cpp @@ -36,6 +36,7 @@ #include "ir.h" #include "ir_visitor.h" +#include "ir_rvalue_visitor.h" #include "ir_basic_block.h" #include "ir_optimization.h" #include "glsl_types.h" @@ -72,7 +73,7 @@ public: unsigned write_mask; }; -class ir_constant_propagation_visitor : public ir_hierarchical_visitor { +class ir_constant_propagation_visitor : public ir_rvalue_visitor { public: ir_constant_propagation_visitor() { @@ -90,12 +91,8 @@ public: virtual ir_visitor_status visit_enter(class ir_function_signature *); virtual ir_visitor_status visit_enter(class ir_function *); virtual ir_visitor_status visit_enter(class ir_assignment *); - virtual ir_visitor_status visit_leave(class ir_assignment *); - virtual ir_visitor_status visit_enter(class ir_expression *); virtual ir_visitor_status visit_enter(class ir_call *); virtual ir_visitor_status visit_enter(class ir_if *); - virtual ir_visitor_status visit_enter(class ir_dereference_array *); - virtual ir_visitor_status visit_enter(class ir_texture *); void add_constant(ir_assignment *ir); void kill(ir_variable *ir, unsigned write_mask); @@ -221,30 +218,20 @@ ir_constant_propagation_visitor::visit_enter(ir_function_signature *ir) ir_visitor_status ir_constant_propagation_visitor::visit_enter(ir_assignment *ir) { - handle_rvalue(&ir->condition); + /* Inline accepting children, skipping the LHS. */ + ir->rhs->accept(this); handle_rvalue(&ir->rhs); - return visit_continue; -} + if (ir->condition) { + ir->condition->accept(this); + handle_rvalue(&ir->condition); + } -ir_visitor_status -ir_constant_propagation_visitor::visit_leave(ir_assignment *ir) -{ kill(ir->lhs->variable_referenced(), ir->write_mask); add_constant(ir); - return visit_continue; -} - -ir_visitor_status -ir_constant_propagation_visitor::visit_enter(ir_expression *ir) -{ - for (unsigned int i = 0; i < ir->get_num_operands(); i++) { - handle_rvalue(&ir->operands[i]); - } - - return visit_continue; + return visit_continue_with_parent; } ir_visitor_status @@ -330,39 +317,6 @@ ir_constant_propagation_visitor::visit_enter(ir_if *ir) return visit_continue_with_parent; } -ir_visitor_status -ir_constant_propagation_visitor::visit_enter(ir_dereference_array *ir) -{ - handle_rvalue(&ir->array_index); - return visit_continue; -} - -ir_visitor_status -ir_constant_propagation_visitor::visit_enter(ir_texture *ir) -{ - handle_rvalue(&ir->coordinate); - handle_rvalue(&ir->projector); - handle_rvalue(&ir->shadow_comparitor); - - switch (ir->op) { - case ir_tex: - break; - case ir_txb: - handle_rvalue(&ir->lod_info.bias); - break; - case ir_txf: - case ir_txl: - handle_rvalue(&ir->lod_info.lod); - break; - case ir_txd: - handle_rvalue(&ir->lod_info.grad.dPdx); - handle_rvalue(&ir->lod_info.grad.dPdy); - break; - } - - return visit_continue; -} - ir_visitor_status ir_constant_propagation_visitor::visit_enter(ir_loop *ir) { -- cgit v1.2.3 From 8f8cdbfba43550d0b8985fb087961864e4cd92b6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 13 Aug 2010 07:16:38 -0700 Subject: glsl2: Add a pass to strip out noop swizzles. With the glsl2-965 branch, the optimization of glsl-algebraic-rcp-rcp regressed due to noop swizzles hiding information from ir_algebraic. This cleans up those noop swizzles for us. --- src/glsl/Makefile | 1 + src/glsl/glsl_parser_extras.cpp | 1 + src/glsl/ir_noop_swizzle.cpp | 80 +++++++++++++++++++++++++++++++++++++++++ src/glsl/ir_optimization.h | 1 + 4 files changed, 83 insertions(+) create mode 100644 src/glsl/ir_noop_swizzle.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 48b7c8f66b5..110228e72a1 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -55,6 +55,7 @@ CXX_SOURCES = \ ir_import_prototypes.cpp \ ir_mat_op_to_vec.cpp \ ir_mod_to_fract.cpp \ + ir_noop_swizzle.cpp \ ir_print_visitor.cpp \ ir_reader.cpp \ ir_rvalue_visitor.cpp \ diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 2ed3905abc9..d1bb1ae5ecc 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -737,6 +737,7 @@ do_common_optimization(exec_list *ir, bool linked) progress = do_if_return(ir) || progress; progress = do_vec_index_to_swizzle(ir) || progress; progress = do_swizzle_swizzle(ir) || progress; + progress = do_noop_swizzle(ir) || progress; return progress; } diff --git a/src/glsl/ir_noop_swizzle.cpp b/src/glsl/ir_noop_swizzle.cpp new file mode 100644 index 00000000000..b78c87b47f3 --- /dev/null +++ b/src/glsl/ir_noop_swizzle.cpp @@ -0,0 +1,80 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_noop_swizzle.cpp + * + * If a swizzle doesn't change the order or count of components, then + * remove the swizzle so that other optimization passes see the value + * behind it. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_rvalue_visitor.h" +#include "ir_print_visitor.h" +#include "glsl_types.h" + +class ir_noop_swizzle_visitor : public ir_rvalue_visitor { +public: + ir_noop_swizzle_visitor() + { + this->progress = false; + } + + void handle_rvalue(ir_rvalue **rvalue); + bool progress; +}; + +void +ir_noop_swizzle_visitor::handle_rvalue(ir_rvalue **rvalue) +{ + if (!*rvalue) + return; + + ir_swizzle *swiz = (*rvalue)->as_swizzle(); + if (!swiz || swiz->type != swiz->val->type) + return; + + int elems = swiz->val->type->vector_elements; + if (swiz->mask.x != 0) + return; + if (elems >= 2 && swiz->mask.y != 1) + return; + if (elems >= 3 && swiz->mask.z != 1) + return; + if (elems >= 4 && swiz->mask.w != 1) + return; + + this->progress = true; + *rvalue = swiz->val; +} + +bool +do_noop_swizzle(exec_list *instructions) +{ + ir_noop_swizzle_visitor v; + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 0c4e548e44c..33f4bc78f79 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -48,6 +48,7 @@ bool do_if_simplification(exec_list *instructions); bool do_if_to_cond_assign(exec_list *instructions); bool do_mat_op_to_vec(exec_list *instructions); bool do_mod_to_fract(exec_list *instructions); +bool do_noop_swizzle(exec_list *instructions); bool do_structure_splitting(exec_list *instructions); bool do_sub_to_add_neg(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); -- cgit v1.2.3 From d01bf822dd7f28dc56705407e7c3b9de1f292794 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 19:05:54 -0700 Subject: glsl2: Commit generated file change by commit ab18be74 This would have been included in commit 23f6017d, but make wisely did not regenerate the file when the .lpp file did not change. --- src/glsl/glsl_lexer.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp index 2c502e88030..3cdce995e28 100644 --- a/src/glsl/glsl_lexer.cpp +++ b/src/glsl/glsl_lexer.cpp @@ -959,14 +959,6 @@ static yyconst flex_int16_t yy_chk[1076] = #define INITIAL 0 #define PP 1 -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - #define YY_EXTRA_TYPE struct _mesa_glsl_parse_state * /* Holds the entire state of the reentrant scanner. */ @@ -1203,7 +1195,7 @@ YY_DECL #line 76 "glsl_lexer.lpp" -#line 1207 "glsl_lexer.cpp" +#line 1199 "glsl_lexer.cpp" yylval = yylval_param; @@ -2263,7 +2255,7 @@ YY_RULE_SETUP #line 356 "glsl_lexer.lpp" ECHO; YY_BREAK -#line 2267 "glsl_lexer.cpp" +#line 2259 "glsl_lexer.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(PP): yyterminate(); -- cgit v1.2.3 From d802ba110f78c3eee9541867cde819ada1b2c449 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 12 Aug 2010 13:17:53 -0700 Subject: ir_reader: Don't mark functions as defined if their body is empty. --- src/glsl/ir_reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 14bd2d62fd7..2def3efff56 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -297,7 +297,7 @@ read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list, sig->replace_parameters(&hir_parameters); - if (!skip_body) { + if (!skip_body && !body_list->subexpressions.is_empty()) { if (sig->is_defined) { ir_read_error(st, list, "function %s redefined", f->name); return; -- cgit v1.2.3 From 43ff8f1a4b90554eae489cebb7e05f983dd9ad66 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 11 Aug 2010 16:53:52 -0700 Subject: glsl2: Rework builtin function generation. Each language version/extension and target now has a "profile" containing all of the available builtin function prototypes. These are written in GLSL, and come directly out of the GLSL spec (except for expanding genType). A new builtins/ir/ folder contains the hand-written IR for each builtin, regardless of what version includes it. Only those definitions that have prototypes in the profile will be included. The autogenerated IR for texture builtins is no longer written to disk, so there's no longer any confusion as to what's hand-written or generated. All scripts are now in python instead of perl. --- src/glsl/Makefile | 5 +- src/glsl/builtin_function.cpp | 17087 +++++++++++++++---- src/glsl/builtins/110/abs | 21 - src/glsl/builtins/110/all | 16 - src/glsl/builtins/110/any | 16 - src/glsl/builtins/110/asin | 120 - src/glsl/builtins/110/atan | 154 - src/glsl/builtins/110/ceil | 21 - src/glsl/builtins/110/clamp | 50 - src/glsl/builtins/110/cos | 21 - src/glsl/builtins/110/cross | 7 - src/glsl/builtins/110/degrees | 21 - src/glsl/builtins/110/distance | 33 - src/glsl/builtins/110/dot | 25 - src/glsl/builtins/110/equal | 61 - src/glsl/builtins/110/exp | 21 - src/glsl/builtins/110/exp2 | 21 - src/glsl/builtins/110/faceforward | 37 - src/glsl/builtins/110/floor | 21 - src/glsl/builtins/110/fract | 22 - src/glsl/builtins/110/greaterThan | 61 - src/glsl/builtins/110/greaterThanEqual | 61 - src/glsl/builtins/110/inversesqrt | 21 - src/glsl/builtins/110/length | 21 - src/glsl/builtins/110/lessThan | 61 - src/glsl/builtins/110/lessThanEqual | 61 - src/glsl/builtins/110/log | 21 - src/glsl/builtins/110/log2 | 21 - src/glsl/builtins/110/matrixCompMult | 32 - src/glsl/builtins/110/max | 43 - src/glsl/builtins/110/min | 43 - src/glsl/builtins/110/mix | 50 - src/glsl/builtins/110/mod | 43 - src/glsl/builtins/110/noise_fake | 76 - src/glsl/builtins/110/normalize | 21 - src/glsl/builtins/110/not | 16 - src/glsl/builtins/110/notEqual | 61 - src/glsl/builtins/110/pow | 25 - src/glsl/builtins/110/radians | 21 - src/glsl/builtins/110/reflect | 58 - src/glsl/builtins/110/refract | 102 - src/glsl/builtins/110/sign | 21 - src/glsl/builtins/110/sin | 21 - src/glsl/builtins/110/smoothstep | 153 - src/glsl/builtins/110/sqrt | 21 - src/glsl/builtins/110/step | 68 - src/glsl/builtins/110/tan | 21 - src/glsl/builtins/110/textures | 213 - src/glsl/builtins/110_fs/derivatives | 73 - src/glsl/builtins/110_fs/textures | 113 - src/glsl/builtins/110_vs/ftransform | 9 - src/glsl/builtins/120/matrixCompMult | 61 - src/glsl/builtins/120/outerProduct | 92 - src/glsl/builtins/120/transpose | 139 - src/glsl/builtins/130/clamp | 99 - src/glsl/builtins/130/cosh | 30 - src/glsl/builtins/130/equal | 31 - src/glsl/builtins/130/greaterThan | 31 - src/glsl/builtins/130/greaterThanEqual | 31 - src/glsl/builtins/130/lessThan | 31 - src/glsl/builtins/130/lessThanEqual | 31 - src/glsl/builtins/130/max | 85 - src/glsl/builtins/130/min | 85 - src/glsl/builtins/130/mix | 39 - src/glsl/builtins/130/notEqual | 31 - src/glsl/builtins/130/sign | 22 - src/glsl/builtins/130/sinh | 30 - src/glsl/builtins/130/tanh | 42 - src/glsl/builtins/130/texelFetch | 107 - src/glsl/builtins/130/texture | 110 - src/glsl/builtins/130/textureGrad | 147 - src/glsl/builtins/130/textureLod | 128 - src/glsl/builtins/130/textureProj | 92 - src/glsl/builtins/130/textureProjGrad | 122 - src/glsl/builtins/130/textureProjLod | 107 - src/glsl/builtins/130_fs/texture | 128 - src/glsl/builtins/130_fs/textureProj | 107 - src/glsl/builtins/ARB_texture_rectangle/textures | 16 - src/glsl/builtins/EXT_texture_array/textures | 59 - src/glsl/builtins/EXT_texture_array_fs/textures | 27 - src/glsl/builtins/ir/abs | 21 + src/glsl/builtins/ir/acos | 22 + src/glsl/builtins/ir/all | 16 + src/glsl/builtins/ir/any | 16 + src/glsl/builtins/ir/asin | 97 + src/glsl/builtins/ir/atan | 154 + src/glsl/builtins/ir/ceil | 21 + src/glsl/builtins/ir/clamp | 148 + src/glsl/builtins/ir/cos | 21 + src/glsl/builtins/ir/cosh | 30 + src/glsl/builtins/ir/cross | 7 + src/glsl/builtins/ir/dFdx | 21 + src/glsl/builtins/ir/dFdy | 21 + src/glsl/builtins/ir/degrees | 21 + src/glsl/builtins/ir/distance | 33 + src/glsl/builtins/ir/dot | 25 + src/glsl/builtins/ir/equal | 91 + src/glsl/builtins/ir/exp | 21 + src/glsl/builtins/ir/exp2 | 21 + src/glsl/builtins/ir/faceforward | 37 + src/glsl/builtins/ir/floor | 21 + src/glsl/builtins/ir/fract | 22 + src/glsl/builtins/ir/ftransform | 9 + src/glsl/builtins/ir/fwidth | 29 + src/glsl/builtins/ir/greaterThan | 91 + src/glsl/builtins/ir/greaterThanEqual | 91 + src/glsl/builtins/ir/inversesqrt | 21 + src/glsl/builtins/ir/length | 21 + src/glsl/builtins/ir/lessThan | 91 + src/glsl/builtins/ir/lessThanEqual | 91 + src/glsl/builtins/ir/log | 21 + src/glsl/builtins/ir/log2 | 21 + src/glsl/builtins/ir/matrixCompMult | 91 + src/glsl/builtins/ir/max | 127 + src/glsl/builtins/ir/min | 127 + src/glsl/builtins/ir/mix | 88 + src/glsl/builtins/ir/mod | 43 + src/glsl/builtins/ir/noise1 | 18 + src/glsl/builtins/ir/noise2 | 18 + src/glsl/builtins/ir/noise3 | 18 + src/glsl/builtins/ir/noise4 | 18 + src/glsl/builtins/ir/normalize | 21 + src/glsl/builtins/ir/not | 16 + src/glsl/builtins/ir/notEqual | 91 + src/glsl/builtins/ir/outerProduct | 92 + src/glsl/builtins/ir/pow | 25 + src/glsl/builtins/ir/radians | 21 + src/glsl/builtins/ir/reflect | 58 + src/glsl/builtins/ir/refract | 102 + src/glsl/builtins/ir/sign | 42 + src/glsl/builtins/ir/sin | 21 + src/glsl/builtins/ir/sinh | 30 + src/glsl/builtins/ir/smoothstep | 153 + src/glsl/builtins/ir/sqrt | 21 + src/glsl/builtins/ir/step | 68 + src/glsl/builtins/ir/tan | 21 + src/glsl/builtins/ir/tanh | 42 + src/glsl/builtins/ir/transpose | 139 + src/glsl/builtins/profiles/110.frag | 364 + src/glsl/builtins/profiles/110.vert | 351 + src/glsl/builtins/profiles/120.frag | 396 + src/glsl/builtins/profiles/120.vert | 383 + .../builtins/profiles/ARB_texture_rectangle.frag | 7 + .../builtins/profiles/ARB_texture_rectangle.vert | 7 + src/glsl/builtins/profiles/EXT_texture_array.frag | 11 + src/glsl/builtins/profiles/EXT_texture_array.vert | 11 + src/glsl/builtins/tools/builtin_function.cpp | 39 + src/glsl/builtins/tools/generate_builtins.pl | 164 - src/glsl/builtins/tools/generate_builtins.py | 207 + src/glsl/builtins/tools/texture_builtins.py | 261 +- src/glsl/ir_reader.cpp | 24 +- src/glsl/ir_reader.h | 2 +- 152 files changed, 18318 insertions(+), 8265 deletions(-) delete mode 100644 src/glsl/builtins/110/abs delete mode 100644 src/glsl/builtins/110/all delete mode 100644 src/glsl/builtins/110/any delete mode 100644 src/glsl/builtins/110/asin delete mode 100644 src/glsl/builtins/110/atan delete mode 100644 src/glsl/builtins/110/ceil delete mode 100644 src/glsl/builtins/110/clamp delete mode 100644 src/glsl/builtins/110/cos delete mode 100644 src/glsl/builtins/110/cross delete mode 100644 src/glsl/builtins/110/degrees delete mode 100644 src/glsl/builtins/110/distance delete mode 100644 src/glsl/builtins/110/dot delete mode 100644 src/glsl/builtins/110/equal delete mode 100644 src/glsl/builtins/110/exp delete mode 100644 src/glsl/builtins/110/exp2 delete mode 100644 src/glsl/builtins/110/faceforward delete mode 100644 src/glsl/builtins/110/floor delete mode 100644 src/glsl/builtins/110/fract delete mode 100644 src/glsl/builtins/110/greaterThan delete mode 100644 src/glsl/builtins/110/greaterThanEqual delete mode 100644 src/glsl/builtins/110/inversesqrt delete mode 100644 src/glsl/builtins/110/length delete mode 100644 src/glsl/builtins/110/lessThan delete mode 100644 src/glsl/builtins/110/lessThanEqual delete mode 100644 src/glsl/builtins/110/log delete mode 100644 src/glsl/builtins/110/log2 delete mode 100644 src/glsl/builtins/110/matrixCompMult delete mode 100644 src/glsl/builtins/110/max delete mode 100644 src/glsl/builtins/110/min delete mode 100644 src/glsl/builtins/110/mix delete mode 100644 src/glsl/builtins/110/mod delete mode 100644 src/glsl/builtins/110/noise_fake delete mode 100644 src/glsl/builtins/110/normalize delete mode 100644 src/glsl/builtins/110/not delete mode 100644 src/glsl/builtins/110/notEqual delete mode 100644 src/glsl/builtins/110/pow delete mode 100644 src/glsl/builtins/110/radians delete mode 100644 src/glsl/builtins/110/reflect delete mode 100644 src/glsl/builtins/110/refract delete mode 100644 src/glsl/builtins/110/sign delete mode 100644 src/glsl/builtins/110/sin delete mode 100644 src/glsl/builtins/110/smoothstep delete mode 100644 src/glsl/builtins/110/sqrt delete mode 100644 src/glsl/builtins/110/step delete mode 100644 src/glsl/builtins/110/tan delete mode 100644 src/glsl/builtins/110/textures delete mode 100644 src/glsl/builtins/110_fs/derivatives delete mode 100644 src/glsl/builtins/110_fs/textures delete mode 100644 src/glsl/builtins/110_vs/ftransform delete mode 100644 src/glsl/builtins/120/matrixCompMult delete mode 100644 src/glsl/builtins/120/outerProduct delete mode 100644 src/glsl/builtins/120/transpose delete mode 100644 src/glsl/builtins/130/clamp delete mode 100644 src/glsl/builtins/130/cosh delete mode 100644 src/glsl/builtins/130/equal delete mode 100644 src/glsl/builtins/130/greaterThan delete mode 100644 src/glsl/builtins/130/greaterThanEqual delete mode 100644 src/glsl/builtins/130/lessThan delete mode 100644 src/glsl/builtins/130/lessThanEqual delete mode 100644 src/glsl/builtins/130/max delete mode 100644 src/glsl/builtins/130/min delete mode 100644 src/glsl/builtins/130/mix delete mode 100644 src/glsl/builtins/130/notEqual delete mode 100644 src/glsl/builtins/130/sign delete mode 100644 src/glsl/builtins/130/sinh delete mode 100644 src/glsl/builtins/130/tanh delete mode 100644 src/glsl/builtins/130/texelFetch delete mode 100644 src/glsl/builtins/130/texture delete mode 100644 src/glsl/builtins/130/textureGrad delete mode 100644 src/glsl/builtins/130/textureLod delete mode 100644 src/glsl/builtins/130/textureProj delete mode 100644 src/glsl/builtins/130/textureProjGrad delete mode 100644 src/glsl/builtins/130/textureProjLod delete mode 100644 src/glsl/builtins/130_fs/texture delete mode 100644 src/glsl/builtins/130_fs/textureProj delete mode 100644 src/glsl/builtins/ARB_texture_rectangle/textures delete mode 100644 src/glsl/builtins/EXT_texture_array/textures delete mode 100644 src/glsl/builtins/EXT_texture_array_fs/textures create mode 100644 src/glsl/builtins/ir/abs create mode 100644 src/glsl/builtins/ir/acos create mode 100644 src/glsl/builtins/ir/all create mode 100644 src/glsl/builtins/ir/any create mode 100644 src/glsl/builtins/ir/asin create mode 100644 src/glsl/builtins/ir/atan create mode 100644 src/glsl/builtins/ir/ceil create mode 100644 src/glsl/builtins/ir/clamp create mode 100644 src/glsl/builtins/ir/cos create mode 100644 src/glsl/builtins/ir/cosh create mode 100644 src/glsl/builtins/ir/cross create mode 100644 src/glsl/builtins/ir/dFdx create mode 100644 src/glsl/builtins/ir/dFdy create mode 100644 src/glsl/builtins/ir/degrees create mode 100644 src/glsl/builtins/ir/distance create mode 100644 src/glsl/builtins/ir/dot create mode 100644 src/glsl/builtins/ir/equal create mode 100644 src/glsl/builtins/ir/exp create mode 100644 src/glsl/builtins/ir/exp2 create mode 100644 src/glsl/builtins/ir/faceforward create mode 100644 src/glsl/builtins/ir/floor create mode 100644 src/glsl/builtins/ir/fract create mode 100644 src/glsl/builtins/ir/ftransform create mode 100644 src/glsl/builtins/ir/fwidth create mode 100644 src/glsl/builtins/ir/greaterThan create mode 100644 src/glsl/builtins/ir/greaterThanEqual create mode 100644 src/glsl/builtins/ir/inversesqrt create mode 100644 src/glsl/builtins/ir/length create mode 100644 src/glsl/builtins/ir/lessThan create mode 100644 src/glsl/builtins/ir/lessThanEqual create mode 100644 src/glsl/builtins/ir/log create mode 100644 src/glsl/builtins/ir/log2 create mode 100644 src/glsl/builtins/ir/matrixCompMult create mode 100644 src/glsl/builtins/ir/max create mode 100644 src/glsl/builtins/ir/min create mode 100644 src/glsl/builtins/ir/mix create mode 100644 src/glsl/builtins/ir/mod create mode 100644 src/glsl/builtins/ir/noise1 create mode 100644 src/glsl/builtins/ir/noise2 create mode 100644 src/glsl/builtins/ir/noise3 create mode 100644 src/glsl/builtins/ir/noise4 create mode 100644 src/glsl/builtins/ir/normalize create mode 100644 src/glsl/builtins/ir/not create mode 100644 src/glsl/builtins/ir/notEqual create mode 100644 src/glsl/builtins/ir/outerProduct create mode 100644 src/glsl/builtins/ir/pow create mode 100644 src/glsl/builtins/ir/radians create mode 100644 src/glsl/builtins/ir/reflect create mode 100644 src/glsl/builtins/ir/refract create mode 100644 src/glsl/builtins/ir/sign create mode 100644 src/glsl/builtins/ir/sin create mode 100644 src/glsl/builtins/ir/sinh create mode 100644 src/glsl/builtins/ir/smoothstep create mode 100644 src/glsl/builtins/ir/sqrt create mode 100644 src/glsl/builtins/ir/step create mode 100644 src/glsl/builtins/ir/tan create mode 100644 src/glsl/builtins/ir/tanh create mode 100644 src/glsl/builtins/ir/transpose create mode 100644 src/glsl/builtins/profiles/110.frag create mode 100644 src/glsl/builtins/profiles/110.vert create mode 100644 src/glsl/builtins/profiles/120.frag create mode 100644 src/glsl/builtins/profiles/120.vert create mode 100644 src/glsl/builtins/profiles/ARB_texture_rectangle.frag create mode 100644 src/glsl/builtins/profiles/ARB_texture_rectangle.vert create mode 100644 src/glsl/builtins/profiles/EXT_texture_array.frag create mode 100644 src/glsl/builtins/profiles/EXT_texture_array.vert create mode 100644 src/glsl/builtins/tools/builtin_function.cpp delete mode 100755 src/glsl/builtins/tools/generate_builtins.pl create mode 100755 src/glsl/builtins/tools/generate_builtins.py diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 110228e72a1..b13a612591b 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -164,7 +164,8 @@ glcpp/glcpp-lex.c: glcpp/glcpp-lex.l glcpp/glcpp-parse.c: glcpp/glcpp-parse.y bison -v -o "$@" --defines=glcpp/glcpp-parse.h $< -builtin_function.cpp: builtins/*/* - ./builtins/tools/generate_builtins.pl > builtin_function.cpp +builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py + cp builtins/tools/builtin_function.cpp . + ./builtins/tools/generate_builtins.py > builtin_function.cpp -include depend diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 1d9a58a5caf..f2abea961d2 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -1,4 +1,4 @@ -/* DO NOT MODIFY - automatically generated by generate_builtins.pl */ +/* DO NOT MODIFY - automatically generated by generate_builtins.py */ /* * Copyright © 2010 Intel Corporation * @@ -27,12 +27,13 @@ #include "glsl_parser_extras.h" #include "ir_reader.h" #include "program.h" +#include "ast.h" extern "C" struct gl_shader * _mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type); gl_shader * -read_builtins(GLenum target, const char **functions, unsigned count) +read_builtins(GLenum target, const char *protos, const char **functions, unsigned count) { gl_shader *sh = _mesa_new_shader(NULL, 0, target); struct _mesa_glsl_parse_state *st = @@ -46,13 +47,19 @@ read_builtins(GLenum target, const char **functions, unsigned count) sh->ir = new(sh) exec_list; sh->symbols = st->symbols; + /* Read the IR containing the prototypes */ + _mesa_glsl_read_ir(st, sh->ir, protos, true); + + /* Read ALL the function bodies, telling the IR reader not to scan for + * prototypes (we've already created them). The IR reader will skip any + * signature that does not already exist as a prototype. + */ for (unsigned i = 0; i < count; i++) { - _mesa_glsl_read_ir(st, sh->ir, functions[i]); + _mesa_glsl_read_ir(st, sh->ir, functions[i], false); if (st->error) { - printf("error reading builtin: %.35s ...\n", functions[i]); - delete st; - talloc_free(sh); + printf("error reading builtin: %.35s ...\n", functions[i]); + talloc_free(sh); return NULL; } } @@ -63,33 +70,7 @@ read_builtins(GLenum target, const char **functions, unsigned count) return sh; } -/* 110 builtins */ - -static const char *builtins_110_abs = { - "((function abs\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float abs (var_ref arg0)))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 abs (var_ref arg0)))))\n" - "\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 abs (var_ref arg0)))))\n" - "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 abs (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_all = { +static const char *builtin_all = "((function all\n" " (signature bool\n" " (parameters\n" @@ -106,2498 +87,2450 @@ static const char *builtins_110_all = { " (declare (in) bvec4 arg0))\n" " ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n" "))\n" -}; - -static const char *builtins_110_any = { - "((function any\n" - " (signature bool\n" + "" +; +static const char *builtin_textureProj = + "((function textureProj\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) bvec2 arg0))\n" - " ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" "\n" - " (signature bool\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) bvec3 arg0))\n" - " ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" "\n" - " (signature bool\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) bvec4 arg0))\n" - " ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n" - "))\n" -}; - -static const char *builtins_110_asin = { - "((function asin\n" - " (signature float\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float *\n" - " (expression float sign (var_ref x))\n" - " (expression float -\n" - " (expression float *\n" - " (constant float (3.1415926))\n" - " (constant float (0.5)))\n" - " (expression float *\n" - " (expression float sqrt\n" - " (expression float -\n" - " (constant float (1.0))\n" - " (expression float abs (var_ref x))))\n" - " (expression float +\n" - " (constant float (1.5707288))\n" - " (expression float *\n" - " (expression float abs (var_ref x))\n" - " (expression float +\n" - " (constant float (-0.2121144))\n" - " (expression float *\n" - " (constant float (0.0742610))\n" - " (expression float abs (var_ref x))))))))))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 *\n" - " (expression vec2 sign (var_ref x))\n" - " (expression vec2 -\n" - " (expression float *\n" - " (constant float (3.1415926))\n" - " (constant float (0.5)))\n" - " (expression vec2 *\n" - " (expression vec2 sqrt\n" - " (expression vec2 -\n" - " (constant float (1.0))\n" - " (expression vec2 abs (var_ref x))))\n" - " (expression vec2 +\n" - " (constant float (1.5707288))\n" - " (expression vec2 *\n" - " (expression vec2 abs (var_ref x))\n" - " (expression vec2 +\n" - " (constant float (-0.2121144))\n" - " (expression vec2 *\n" - " (constant float (0.0742610))\n" - " (expression vec2 abs (var_ref x))))))))))))\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 *\n" - " (expression vec3 sign (var_ref x))\n" - " (expression vec3 -\n" - " (expression float *\n" - " (constant float (3.1415926))\n" - " (constant float (0.5)))\n" - " (expression vec3 *\n" - " (expression vec3 sqrt\n" - " (expression vec3 -\n" - " (constant float (1.0))\n" - " (expression vec3 abs (var_ref x))))\n" - " (expression vec3 +\n" - " (constant float (1.5707288))\n" - " (expression vec3 *\n" - " (expression vec3 abs (var_ref x))\n" - " (expression vec3 +\n" - " (constant float (-0.2121144))\n" - " (expression vec3 *\n" - " (constant float (0.0742610))\n" - " (expression vec3 abs (var_ref x))))))))))))\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 *\n" - " (expression vec4 sign (var_ref x))\n" - " (expression vec4 -\n" - " (expression float *\n" - " (constant float (3.1415926))\n" - " (constant float (0.5)))\n" - " (expression vec4 *\n" - " (expression vec4 sqrt\n" - " (expression vec4 -\n" - " (constant float (1.0))\n" - " (expression vec4 abs (var_ref x))))\n" - " (expression vec4 +\n" - " (constant float (1.5707288))\n" - " (expression vec4 *\n" - " (expression vec4 abs (var_ref x))\n" - " (expression vec4 +\n" - " (constant float (-0.2121144))\n" - " (expression vec4 *\n" - " (constant float (0.0742610))\n" - " (expression vec4 abs (var_ref x)))))))))))\n" - "))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" "\n" - " (function acos\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float - (constant float (1.5707963))\n" - " (call asin ((var_ref x)))))))\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 - (constant float (1.5707963))\n" - " (call asin ((var_ref x)))))))\n" - " (signature vec3\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 - (constant float (1.5707963))\n" - " (call asin ((var_ref x)))))))\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 - (constant float (1.5707963))\n" - " (call asin ((var_ref x)))))))\n" - "))\n" -}; - -static const char *builtins_110_atan = { - "((function atan\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (call asin ((expression float *\n" - " (var_ref x)\n" - " (expression float rsq\n" - " (expression float +\n" - " (expression float *\n" - " (var_ref x)\n" - " (var_ref x))\n" - " (constant float (1.0))))))))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 y_over_x))\n" - " ((return (call asin ((expression vec2 *\n" - " (var_ref y_over_x)\n" - " (expression vec2 rsq\n" - " (expression vec2 +\n" - " (expression vec2 *\n" - " (var_ref y_over_x)\n" - " (var_ref y_over_x))\n" - " (constant float (1.0))))))))))\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 y_over_x))\n" - " ((return (call asin ((expression vec3 *\n" - " (var_ref y_over_x)\n" - " (expression vec3 rsq\n" - " (expression vec3 +\n" - " (expression vec3 *\n" - " (var_ref y_over_x)\n" - " (var_ref y_over_x))\n" - " (constant float (1.0))))))))))\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 y_over_x))\n" - " ((return (call asin ((expression vec4 *\n" - " (var_ref y_over_x)\n" - " (expression vec4 rsq\n" - " (expression vec4 +\n" - " (expression vec4 *\n" - " (var_ref y_over_x)\n" - " (var_ref y_over_x))\n" - " (constant float (1.0))))))))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" - " (signature float\n" - " (parameters\n" - " (declare (in ) float y)\n" - " (declare (in ) float x)\n" - " )\n" - " (\n" - " (declare () float r)\n" - " (declare ( ) float abs_retval)\n" - " (assign (constant bool (1)) (var_ref abs_retval) (call abs ((var_ref x) ))\n" - ") \n" - " (if (expression bool > (var_ref abs_retval) (constant float (0.000100)) ) (\n" - " (declare ( ) float atan_retval)\n" - " (assign (constant bool (1)) (var_ref atan_retval) (call atan ((expression float / (var_ref y) (var_ref x) ) ))\n" - ") \n" - " (assign (constant bool (1)) (var_ref r) (var_ref atan_retval) ) \n" - " (if (expression bool < (var_ref x) (constant float (0.000000)) ) (\n" - " (if (expression bool >= (var_ref y) (constant float (0.000000)) ) (\n" - " (declare ( ) float assignment_tmp)\n" - " (assign (constant bool (1)) (var_ref assignment_tmp) (expression float + (var_ref r) (constant float (3.141593)) ) ) \n" - " (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) \n" - " )\n" - " (\n" - " (declare ( ) float assignment_tmp)\n" - " (assign (constant bool (1)) (var_ref assignment_tmp) (expression float - (var_ref r) (constant float (3.141593)) ) ) \n" - " (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) \n" - " ))\n" - "\n" - " )\n" - " (\n" - " ))\n" - "\n" - " )\n" - " (\n" - " (if (expression bool >= (var_ref y) (constant float (0.000000)) ) (\n" - " (assign (constant bool (1)) (var_ref r) (constant float (1.570796)) ) \n" - " )\n" - " (\n" - " (assign (constant bool (1)) (var_ref r) (constant float (-1.570796)) ) \n" - " ))\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" - " ))\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" - " (return (var_ref r) )\n" - " ))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec2\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec2 y)\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 r)\n" - " (assign (constant bool (1))\n" - " (swiz x (var_ref r))\n" - " (call atan ((swiz x (var_ref y))\n" - " (swiz x (var_ref x)))))\n" - " (assign (constant bool (1))\n" - " (swiz y (var_ref r))\n" - " (call atan ((swiz y (var_ref y))\n" - " (swiz y (var_ref x)))))\n" - " (return (var_ref r))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec3\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec3 y)\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 r)\n" - " (assign (constant bool (1))\n" - " (swiz x (var_ref r))\n" - " (call atan ((swiz x (var_ref y))\n" - " (swiz x (var_ref x)))))\n" - " (assign (constant bool (1))\n" - " (swiz y (var_ref r))\n" - " (call atan ((swiz y (var_ref y))\n" - " (swiz y (var_ref x)))))\n" - " (assign (constant bool (1))\n" - " (swiz z (var_ref r))\n" - " (call atan ((swiz z (var_ref y))\n" - " (swiz z (var_ref x)))))\n" - " (return (var_ref r))))\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec4\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec4 y)\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 r)\n" - " (assign (constant bool (1))\n" - " (swiz x (var_ref r))\n" - " (call atan ((swiz x (var_ref y))\n" - " (swiz x (var_ref x)))))\n" - " (assign (constant bool (1))\n" - " (swiz y (var_ref r))\n" - " (call atan ((swiz y (var_ref y))\n" - " (swiz y (var_ref x)))))\n" - " (assign (constant bool (1))\n" - " (swiz z (var_ref r))\n" - " (call atan ((swiz z (var_ref y))\n" - " (swiz z (var_ref x)))))\n" - " (assign (constant bool (1))\n" - " (swiz w (var_ref r))\n" - " (call atan ((swiz w (var_ref y))\n" - " (swiz w (var_ref x)))))\n" - " (return (var_ref r)))))\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" "\n" - "))\n" -}; - -static const char *builtins_110_ceil = { - "((function ceil\n" - " (signature float\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float ceil (var_ref arg0)))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 ceil (var_ref arg0)))))\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 ceil (var_ref arg0)))))\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 ceil (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_clamp = { - "((function clamp\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1)\n" - " (declare (in) vec2 arg2))\n" - " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1)\n" - " (declare (in) vec3 arg2))\n" - " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1)\n" - " (declare (in) vec4 arg2))\n" - " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) float arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) float arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) float arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "))\n" -}; - -static const char *builtins_110_cos = { - "((function cos\n" + "" +; +static const char *builtin_fwidth = + "((function fwidth\n" " (signature float\n" " (parameters\n" - " (declare (in) float angle))\n" - " ((return (expression float cos (var_ref angle)))))\n" + " (declare (in) float p))\n" + " ((return (expression float +\n" + " (expression float abs (expression float dFdx (var_ref p)))\n" + " (expression float abs (expression float dFdy (var_ref p)))))))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 angle))\n" - " ((return (expression vec2 cos (var_ref angle)))))\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 +\n" + " (expression vec2 abs (expression vec2 dFdx (var_ref p)))\n" + " (expression vec2 abs (expression vec2 dFdy (var_ref p)))))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 angle))\n" - " ((return (expression vec3 cos (var_ref angle)))))\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 +\n" + " (expression vec3 abs (expression vec3 dFdx (var_ref p)))\n" + " (expression vec3 abs (expression vec3 dFdy (var_ref p)))))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 angle))\n" - " ((return (expression vec4 cos (var_ref angle)))))\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 +\n" + " (expression vec4 abs (expression vec4 dFdx (var_ref p)))\n" + " (expression vec4 abs (expression vec4 dFdy (var_ref p)))))))\n" "))\n" -}; - -static const char *builtins_110_cross = { - "((function cross\n" - " (signature vec3\n" + "" +; +static const char *builtin_texture2DProj = + "((function texture2DProj\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression vec3 cross (var_ref arg0) (var_ref arg1)))))\n" - "))\n" -}; - -static const char *builtins_110_degrees = { - "((function degrees\n" - " (signature float\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float * (var_ref arg0) (constant float (57.295780))))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" - " (signature vec2\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 * (var_ref arg0) (constant float (57.295780))))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" "\n" - " (signature vec3\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 * (var_ref arg0) (constant float (57.295780))))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" "\n" + "))\n" + "" +; +static const char *builtin_shadow1DProjLod = + "((function shadow1DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 * (var_ref arg0) (constant float (57.295780))))))\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" "))\n" -}; - -static const char *builtins_110_distance = { - "((function distance\n" - " (signature float\n" + "" +; +static const char *builtin_texture3DLod = + "((function texture3DLod\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) float p0)\n" - " (declare (in) float p1))\n" - " ((declare () float p)\n" - " (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1)))\n" - " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (signature float\n" + "))\n" + "" +; +static const char *builtin_textureCubeLod = + "((function textureCubeLod\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec2 p0)\n" - " (declare (in) vec2 p1))\n" - " ((declare () vec2 p)\n" - " (assign (constant bool (1)) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))\n" - " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (signature float\n" + "))\n" + "" +; +static const char *builtin_texture = + "((function texture\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec3 p0)\n" - " (declare (in) vec3 p1))\n" - " ((declare () vec3 p)\n" - " (assign (constant bool (1)) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))\n" - " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature float\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec4 p0)\n" - " (declare (in) vec4 p1))\n" - " ((declare () vec4 p)\n" - " (assign (constant bool (1)) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))\n" - " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" - "))\n" -}; - -static const char *builtins_110_dot = { - "((function dot\n" - " (signature float\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature float\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature float\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature float\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" - "))\n" -}; - -static const char *builtins_110_equal = { - "((function equal\n" - " (signature bvec2\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature bvec3\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature bvec4\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature bvec2\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature bvec3\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature bvec4\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_110_exp = { - "((function exp\n" - " (signature float\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float exp (var_ref arg0)))))\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 exp (var_ref arg0)))))\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 exp (var_ref arg0)))))\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 exp (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_exp2 = { - "((function exp2\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float exp2 (var_ref arg0)))))\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 exp2 (var_ref arg0)))))\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 exp2 (var_ref arg0)))))\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 exp2 (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_faceforward = { - "((function faceforward\n" - " (signature float\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) float N)\n" - " (declare (in) float I)\n" - " (declare (in) float Nref))\n" - " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" - " ((return (var_ref N)))\n" - " ((return (expression float neg (var_ref N)))))))\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" "\n" - " (signature vec2\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec2 N)\n" - " (declare (in) vec2 I)\n" - " (declare (in) vec2 Nref))\n" - " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" - " ((return (var_ref N)))\n" - " ((return (expression vec2 neg (var_ref N)))))))\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" "\n" - " (signature vec3\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec3 N)\n" - " (declare (in) vec3 I)\n" - " (declare (in) vec3 Nref))\n" - " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" - " ((return (var_ref N)))\n" - " ((return (expression vec3 neg (var_ref N)))))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 N)\n" - " (declare (in) vec4 I)\n" - " (declare (in) vec4 Nref))\n" - " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" - " ((return (var_ref N)))\n" - " ((return (expression vec4 neg (var_ref N)))))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" "))\n" -}; - -static const char *builtins_110_floor = { - "((function floor\n" + "" +; +static const char *builtin_degrees = + "((function degrees\n" " (signature float\n" " (parameters\n" " (declare (in) float arg0))\n" - " ((return (expression float floor (var_ref arg0)))))\n" + " ((return (expression float * (var_ref arg0) (constant float (57.295780))))))\n" "\n" " (signature vec2\n" " (parameters\n" " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 floor (var_ref arg0)))))\n" + " ((return (expression vec2 * (var_ref arg0) (constant float (57.295780))))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 floor (var_ref arg0)))))\n" + " ((return (expression vec3 * (var_ref arg0) (constant float (57.295780))))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 floor (var_ref arg0)))))\n" + " ((return (expression vec4 * (var_ref arg0) (constant float (57.295780))))))\n" "))\n" -}; - -static const char *builtins_110_fract = { - "((function fract\n" + "" +; +static const char *builtin_texture2DArrayLod = + "((function texture2DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char *builtin_ceil = + "((function ceil\n" " (signature float\n" " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float fract (var_ref x)))))\n" + " (declare (in) float arg0))\n" + " ((return (expression float ceil (var_ref arg0)))))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 fract (var_ref x)))))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 ceil (var_ref arg0)))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 fract (var_ref x)))))\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 ceil (var_ref arg0)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 fract (var_ref x)))))\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 ceil (var_ref arg0)))))\n" "))\n" - "\n" -}; - -static const char *builtins_110_greaterThan = { - "((function greaterThan\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" + "" +; +static const char *builtin_texture1D = + "((function texture1D\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature bvec4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" "\n" + "))\n" + "" +; +static const char *builtin_not = + "((function not\n" " (signature bvec2\n" " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bvec2 ! (var_ref arg0)))))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bvec3 ! (var_ref arg0)))))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bvec4 ! (var_ref arg0)))))\n" "))\n" -}; - -static const char *builtins_110_greaterThanEqual = { - "((function greaterThanEqual\n" - " (signature bvec2\n" + "" +; +static const char *builtin_texture2DRectProj = + "((function texture2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + "))\n" + "" +; +static const char *builtin_mod = + "((function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" " (parameters\n" " (declare (in) vec2 arg0)\n" " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature bvec3\n" + " (signature vec3\n" " (parameters\n" " (declare (in) vec3 arg0)\n" " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature bvec4\n" + " (signature vec4\n" " (parameters\n" " (declare (in) vec4 arg0)\n" " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature bvec2\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature bvec3\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature bvec4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" "))\n" -}; - -static const char *builtins_110_inversesqrt = { - "((function inversesqrt\n" + "" +; +static const char *builtin_radians = + "((function radians\n" " (signature float\n" " (parameters\n" " (declare (in) float arg0))\n" - " ((return (expression float rsq (var_ref arg0)))))\n" + " ((return (expression float * (var_ref arg0) (constant float (0.017453))))))\n" "\n" " (signature vec2\n" " (parameters\n" " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 rsq (var_ref arg0)))))\n" + " ((return (expression vec2 * (var_ref arg0) (constant float (0.017453))))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 rsq (var_ref arg0)))))\n" + " ((return (expression vec3 * (var_ref arg0) (constant float (0.017453))))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 rsq (var_ref arg0)))))\n" + " ((return (expression vec4 * (var_ref arg0) (constant float (0.017453))))))\n" "))\n" -}; - -static const char *builtins_110_length = { - "((function length\n" + "" +; +static const char *builtin_smoothstep = + "((function smoothstep\n" " (signature float\n" " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) float x))\n" + " ((declare () float t)\n" "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + " (assign (constant bool (1)) (var_ref t)\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t))))))))\n" "\n" - " (signature float\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (declare () vec2 retval)\n" "\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" - "))\n" -}; - -static const char *builtins_110_lessThan = { - "((function lessThan\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" "\n" - " (signature bvec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (declare () vec3 retval)\n" "\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_110_lessThanEqual = { - "((function lessThanEqual\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" "\n" - " (signature bvec4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (declare () vec4 retval)\n" "\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (assign (constant bool (1)) (swiz x (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" "\n" - " (signature bvec3\n" - " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_110_log = { - "((function log\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float log (var_ref arg0)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + "\n" + " (assign (constant bool (1)) (swiz w (var_ref t))\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n" + " (return (var_ref retval))\n" + " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 log (var_ref arg0)))))\n" + " (declare (in) vec2 edge0)\n" + " (declare (in) vec2 edge1)\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 max\n" + " (expression vec2 min\n" + " (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0)))\n" + " (constant vec2 (1.0 1.0)))\n" + " (constant vec2 (0.0 0.0))))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 log (var_ref arg0)))))\n" + " (declare (in) vec3 edge0)\n" + " (declare (in) vec3 edge1)\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 max\n" + " (expression vec3 min\n" + " (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0)))\n" + " (constant vec3 (1.0 1.0 1.0)))\n" + " (constant vec3 (0.0 0.0 0.0))))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 log (var_ref arg0)))))\n" + " (declare (in) vec4 edge0)\n" + " (declare (in) vec4 edge1)\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 max\n" + " (expression vec4 min\n" + " (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0)))\n" + " (constant vec4 (1.0 1.0 1.0 1.0)))\n" + " (constant vec4 (0.0 0.0 0.0 0.0))))))\n" "))\n" -}; - -static const char *builtins_110_log2 = { - "((function log2\n" - " (signature float\n" + "\n" + "" +; +static const char *builtin_textureProjGrad = + "((function textureProjGrad\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float log2 (var_ref arg0)))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 log2 (var_ref arg0)))))\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 log2 (var_ref arg0)))))\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 log2 (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_matrixCompMult = { - "((function matrixCompMult\n" - " (signature mat2\n" - " (parameters\n" - " (declare (in) mat2 x)\n" - " (declare (in) mat2 y))\n" - " ((declare () mat2 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature mat3\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) mat3 x)\n" - " (declare (in) mat3 y))\n" - " ((declare () mat3 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature mat4\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) mat4 x)\n" - " (declare (in) mat4 y))\n" - " ((declare () mat4 z)\n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - " (assign (constant bool (1)) (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))))) \n" - "(return (var_ref z))))\n" - "))\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" -}; - -static const char *builtins_110_max = { - "((function max\n" - " (signature float\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression float max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" - "))\n" -}; - -static const char *builtins_110_min = { - "((function min\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression float min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec4\n" + "))\n" + "" +; +static const char *builtin_dFdx = + "((function dFdx\n" + " (signature float\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) float p))\n" + " ((return (expression float dFdx (var_ref p)))))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 dFdx (var_ref p)))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 dFdx (var_ref p)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 dFdx (var_ref p)))))\n" "))\n" -}; - -static const char *builtins_110_mix = { - "((function mix\n" + "" +; +static const char *builtin_dFdy = + "((function dFdy\n" " (signature float\n" " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2))))))\n" + " (declare (in) float p))\n" + " ((return (expression float dFdy (var_ref p)))))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1)\n" - " (declare (in) vec2 arg2))\n" - " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 dFdy (var_ref p)))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1)\n" - " (declare (in) vec3 arg2))\n" - " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 dFdy (var_ref p)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1)\n" - " (declare (in) vec4 arg2))\n" - " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 dFdy (var_ref p)))))\n" + "))\n" + "" +; +static const char *builtin_textureGrad = + "((function textureGrad\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1)\n" - " (declare (in) float arg2))\n" - " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" - "))\n" -}; - -static const char *builtins_110_mod = { - "((function mod\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression float % (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" - "))\n" -}; - -static const char *builtins_110_noise_fake = { - "((function noise1\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (constant float (0)))))\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (constant float (0)))))\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (constant float (0)))))\n" - " (signature float\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (constant float (0)))))\n" - " )\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (function noise2\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (constant vec2 (0 0)))))\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (constant vec2 (0 0)))))\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (constant vec2 (0 0)))))\n" - " (signature vec2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (constant vec2 (0 0)))))\n" - " )\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (function noise3\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (constant vec3 (0 0 0)))))\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (constant vec3 (0 0 0)))))\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (constant vec3 (0 0 0)))))\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (constant vec3 (0 0 0)))))\n" - " )\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" "\n" - " (function noise4\n" " (signature vec4\n" " (parameters\n" - " (declare (in) float x))\n" - " ((return (constant vec4 (0 0 0 0)))))\n" - " (signature vec4\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (constant vec4 (0 0 0 0)))))\n" - " (signature vec4\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (constant vec4 (0 0 0 0)))))\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (constant vec4 (0 0 0 0)))))\n" - " )\n" - ")\n" -}; - -static const char *builtins_110_normalize = { - "((function normalize\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char *builtin_clamp = + "((function clamp\n" " (signature float\n" " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) vec2 arg2))\n" + " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) vec3 arg2))\n" + " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" - "))\n" -}; - -static const char *builtins_110_not = { - "((function not\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) bvec2 arg0))\n" - " ((return (expression bvec2 ! (var_ref arg0)))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) vec4 arg2))\n" + " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature bvec3\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) bvec3 arg0))\n" - " ((return (expression bvec3 ! (var_ref arg0)))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) bvec4 arg0))\n" - " ((return (expression bvec4 ! (var_ref arg0)))))\n" - "))\n" -}; - -static const char *builtins_110_notEqual = { - "((function notEqual\n" - " (signature bvec2\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" - " (return (var_ref temp))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature bvec3\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" - " (return (var_ref temp))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature bvec4\n" + " (signature int\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))\n" - " (return (var_ref temp))))\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature bvec2\n" + " (signature ivec2\n" " (parameters\n" " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" - " (return (var_ref temp))))\n" + " (declare (in) ivec2 arg1)\n" + " (declare (in) ivec2 arg2))\n" + " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature bvec3\n" + " (signature ivec3\n" " (parameters\n" " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" - " (return (var_ref temp))))\n" + " (declare (in) ivec3 arg1)\n" + " (declare (in) ivec3 arg2))\n" + " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature bvec4\n" + " (signature ivec4\n" " (parameters\n" " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))\n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_110_pow = { - "((function pow\n" - " (signature float\n" + " (declare (in) ivec4 arg1)\n" + " (declare (in) ivec4 arg2))\n" + " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" " (parameters\n" - " (declare (in) float arg0)\n" - " (declare (in) float arg1))\n" - " ((return (expression float pow (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature vec2\n" + " (signature ivec3\n" " (parameters\n" - " (declare (in) vec2 arg0)\n" - " (declare (in) vec2 arg1))\n" - " ((return (expression vec2 pow (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature vec3\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec3 arg0)\n" - " (declare (in) vec3 arg1))\n" - " ((return (expression vec3 pow (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature vec4\n" + " (signature uint\n" " (parameters\n" - " (declare (in) vec4 arg0)\n" - " (declare (in) vec4 arg1))\n" - " ((return (expression vec4 pow (var_ref arg0) (var_ref arg1)))))\n" - "))\n" -}; - -static const char *builtins_110_radians = { - "((function radians\n" - " (signature float\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float * (var_ref arg0) (constant float (0.017453))))))\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1)\n" + " (declare (in) uvec2 arg2))\n" + " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature vec2\n" + " (signature uvec3\n" " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 * (var_ref arg0) (constant float (0.017453))))))\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1)\n" + " (declare (in) uvec3 arg2))\n" + " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 * (var_ref arg0) (constant float (0.017453))))))\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1)\n" + " (declare (in) uvec4 arg2))\n" + " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature vec4\n" + " (signature uvec2\n" " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 * (var_ref arg0) (constant float (0.017453))))))\n" - "))\n" -}; - -static const char *builtins_110_reflect = { - "((function reflect\n" - " (signature float\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" " (parameters\n" - " (declare (in) float i)\n" - " (declare (in) float n))\n" - " ((return (expression float -\n" - " (var_ref i)\n" - " (expression float *\n" - " (constant float (2.0))\n" - " (expression float *\n" - " (expression float dot\n" - " (var_ref n)\n" - " (var_ref i))\n" - " (var_ref n)))))))\n" - "\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 i)\n" - " (declare (in) vec2 n))\n" - " ((return (expression vec2 -\n" - " (var_ref i)\n" - " (expression vec2 *\n" - " (constant float (2.0))\n" - " (expression vec2 *\n" - " (expression float dot\n" - " (var_ref n)\n" - " (var_ref i))\n" - " (var_ref n)))))))\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" "\n" - " (signature vec3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec3 i)\n" - " (declare (in) vec3 n))\n" - " ((return (expression vec3 -\n" - " (var_ref i)\n" - " (expression vec3 *\n" - " (constant float (2.0))\n" - " (expression vec3 *\n" - " (expression float dot\n" - " (var_ref n)\n" - " (var_ref i))\n" - " (var_ref n)))))))\n" - "\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char *builtin_texture2DRect = + "((function texture2DRect\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 i)\n" - " (declare (in) vec4 n))\n" - " ((return (expression vec4 -\n" - " (var_ref i)\n" - " (expression vec4 *\n" - " (constant float (2.0))\n" - " (expression vec4 *\n" - " (expression float dot\n" - " (var_ref n)\n" - " (var_ref i))\n" - " (var_ref n)))))))\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" "))\n" -}; - -static const char *builtins_110_refract = { - "((function refract\n" + "" +; +static const char *builtin_cosh = + "((function cosh\n" " (signature float\n" " (parameters\n" - " (declare (in) float i)\n" - " (declare (in) float n)\n" - " (declare (in) float eta))\n" - " ((declare () float k)\n" - " (assign (constant bool (1)) (var_ref k)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * (var_ref eta)\n" - " (expression float * (var_ref eta)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * \n" - " (expression float dot (var_ref n) (var_ref i))\n" - " (expression float dot (var_ref n) (var_ref i))))))))\n" - " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant float (0.0))))\n" - " ((return (expression float -\n" - " (expression float * (var_ref eta) (var_ref i))\n" - " (expression float *\n" - " (expression float +\n" - " (expression float * (var_ref eta)\n" - " (expression float dot (var_ref n) (var_ref i)))\n" - " (expression float sqrt (var_ref k)))\n" - " (var_ref n))))))))\n" - "\n" + " (declare (in) float x))\n" + " ((return (expression float * (constant float (0.5))\n" + " (expression float +\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 i)\n" - " (declare (in) vec2 n)\n" - " (declare (in) float eta))\n" - " ((declare () float k)\n" - " (assign (constant bool (1)) (var_ref k)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * (var_ref eta)\n" - " (expression float * (var_ref eta)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * \n" - " (expression float dot (var_ref n) (var_ref i))\n" - " (expression float dot (var_ref n) (var_ref i))))))))\n" - " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant vec2 (0.0 0.0))))\n" - " ((return (expression vec2 -\n" - " (expression vec2 * (var_ref eta) (var_ref i))\n" - " (expression vec2 *\n" - " (expression float +\n" - " (expression float * (var_ref eta)\n" - " (expression float dot (var_ref n) (var_ref i)))\n" - " (expression float sqrt (var_ref k)))\n" - " (var_ref n))))))))\n" - "\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 * (constant vec2 (0.5))\n" + " (expression vec2 +\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 i)\n" - " (declare (in) vec3 n)\n" - " (declare (in) float eta))\n" - " ((declare () float k)\n" - " (assign (constant bool (1)) (var_ref k)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * (var_ref eta)\n" - " (expression float * (var_ref eta)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * \n" - " (expression float dot (var_ref n) (var_ref i))\n" - " (expression float dot (var_ref n) (var_ref i))))))))\n" - " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant vec3 (0.0 0.0 0.0))))\n" - " ((return (expression vec3 -\n" - " (expression vec3 * (var_ref eta) (var_ref i))\n" - " (expression vec3 *\n" - " (expression float +\n" - " (expression float * (var_ref eta)\n" - " (expression float dot (var_ref n) (var_ref i)))\n" - " (expression float sqrt (var_ref k)))\n" - " (var_ref n))))))))\n" - "\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 * (constant vec3 (0.5))\n" + " (expression vec3 +\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 i)\n" - " (declare (in) vec4 n)\n" - " (declare (in) float eta))\n" - " ((declare () float k)\n" - " (assign (constant bool (1)) (var_ref k)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * (var_ref eta)\n" - " (expression float * (var_ref eta)\n" - " (expression float - (constant float (1.0))\n" - " (expression float * \n" - " (expression float dot (var_ref n) (var_ref i))\n" - " (expression float dot (var_ref n) (var_ref i))))))))\n" - " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant vec4 (0.0 0.0 0.0 0.0))))\n" - " ((return (expression vec4 -\n" - " (expression vec4 * (var_ref eta) (var_ref i))\n" - " (expression vec4 *\n" - " (expression float +\n" - " (expression float * (var_ref eta)\n" - " (expression float dot (var_ref n) (var_ref i)))\n" - " (expression float sqrt (var_ref k)))\n" - " (var_ref n))))))))\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 * (constant vec4 (0.5))\n" + " (expression vec4 +\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" + "" +; +static const char *builtin_texture1DArrayLod = + "((function texture1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" "))\n" -}; - -static const char *builtins_110_sign = { - "((function sign\n" + "" +; +static const char *builtin_asin = + "((function asin\n" " (signature float\n" " (parameters\n" " (declare (in) float x))\n" - " ((return (expression float sign (var_ref x)))))\n" + " ((return (expression float *\n" + " (expression float sign (var_ref x))\n" + " (expression float -\n" + " (expression float *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression float *\n" + " (expression float sqrt\n" + " (expression float -\n" + " (constant float (1.0))\n" + " (expression float abs (var_ref x))))\n" + " (expression float +\n" + " (constant float (1.5707288))\n" + " (expression float *\n" + " (expression float abs (var_ref x))\n" + " (expression float +\n" + " (constant float (-0.2121144))\n" + " (expression float *\n" + " (constant float (0.0742610))\n" + " (expression float abs (var_ref x))))))))))))\n" "\n" " (signature vec2\n" " (parameters\n" " (declare (in) vec2 x))\n" - " ((return (expression vec2 sign (var_ref x)))))\n" + " ((return (expression vec2 *\n" + " (expression vec2 sign (var_ref x))\n" + " (expression vec2 -\n" + " (expression float *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression vec2 *\n" + " (expression vec2 sqrt\n" + " (expression vec2 -\n" + " (constant float (1.0))\n" + " (expression vec2 abs (var_ref x))))\n" + " (expression vec2 +\n" + " (constant float (1.5707288))\n" + " (expression vec2 *\n" + " (expression vec2 abs (var_ref x))\n" + " (expression vec2 +\n" + " (constant float (-0.2121144))\n" + " (expression vec2 *\n" + " (constant float (0.0742610))\n" + " (expression vec2 abs (var_ref x))))))))))))\n" "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 x))\n" - " ((return (expression vec3 sign (var_ref x)))))\n" + " ((return (expression vec3 *\n" + " (expression vec3 sign (var_ref x))\n" + " (expression vec3 -\n" + " (expression float *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression vec3 *\n" + " (expression vec3 sqrt\n" + " (expression vec3 -\n" + " (constant float (1.0))\n" + " (expression vec3 abs (var_ref x))))\n" + " (expression vec3 +\n" + " (constant float (1.5707288))\n" + " (expression vec3 *\n" + " (expression vec3 abs (var_ref x))\n" + " (expression vec3 +\n" + " (constant float (-0.2121144))\n" + " (expression vec3 *\n" + " (constant float (0.0742610))\n" + " (expression vec3 abs (var_ref x))))))))))))\n" "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 x))\n" - " ((return (expression vec4 sign (var_ref x)))))\n" - "))\n" -}; - -static const char *builtins_110_sin = { - "((function sin\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float angle))\n" - " ((return (expression float sin (var_ref angle)))))\n" + " ((return (expression vec4 *\n" + " (expression vec4 sign (var_ref x))\n" + " (expression vec4 -\n" + " (expression float *\n" + " (constant float (3.1415926))\n" + " (constant float (0.5)))\n" + " (expression vec4 *\n" + " (expression vec4 sqrt\n" + " (expression vec4 -\n" + " (constant float (1.0))\n" + " (expression vec4 abs (var_ref x))))\n" + " (expression vec4 +\n" + " (constant float (1.5707288))\n" + " (expression vec4 *\n" + " (expression vec4 abs (var_ref x))\n" + " (expression vec4 +\n" + " (constant float (-0.2121144))\n" + " (expression vec4 *\n" + " (constant float (0.0742610))\n" + " (expression vec4 abs (var_ref x))))))))))))\n" + "))\n" + "" +; +static const char *builtin_texture1DProj = + "((function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" "\n" - " (signature vec2\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec2 angle))\n" - " ((return (expression vec2 sin (var_ref angle)))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" "\n" - " (signature vec3\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec3 angle))\n" - " ((return (expression vec3 sin (var_ref angle)))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 angle))\n" - " ((return (expression vec4 sin (var_ref angle)))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" "))\n" -}; - -static const char *builtins_110_smoothstep = { - "((function smoothstep\n" - " (signature float\n" + "" +; +static const char *builtin_lessThan = + "((function lessThan\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) float edge0)\n" - " (declare (in) float edge1)\n" - " (declare (in) float x))\n" - " ((declare () float t)\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (assign (constant bool (1)) (var_ref t)\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t))))))))\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature vec2\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) float edge0)\n" - " (declare (in) float edge1)\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (declare () vec2 retval)\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature vec3\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) float edge0)\n" - " (declare (in) float edge1)\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (declare () vec3 retval)\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (assign (constant bool (1)) (swiz z (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" + "" +; +static const char *builtin_shadow2DProj = + "((function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" "\n" + "))\n" + "" +; +static const char *builtin_textureLod = + "((function textureLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in) float edge0)\n" - " (declare (in) float edge1)\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (declare () vec4 retval)\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (assign (constant bool (1)) (swiz x (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (assign (constant bool (1)) (swiz y (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (assign (constant bool (1)) (swiz z (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (assign (constant bool (1)) (swiz w (var_ref t))\n" - " (expression float max\n" - " (expression float min\n" - " (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" - " (constant float (1.0)))\n" - " (constant float (0.0))))\n" - " (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n" - " (return (var_ref retval))\n" - " ))\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (signature vec2\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec2 edge0)\n" - " (declare (in) vec2 edge1)\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 max\n" - " (expression vec2 min\n" - " (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0)))\n" - " (constant vec2 (1.0 1.0)))\n" - " (constant vec2 (0.0 0.0))))))\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (signature vec3\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec3 edge0)\n" - " (declare (in) vec3 edge1)\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 max\n" - " (expression vec3 min\n" - " (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0)))\n" - " (constant vec3 (1.0 1.0 1.0)))\n" - " (constant vec3 (0.0 0.0 0.0))))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 edge0)\n" - " (declare (in) vec4 edge1)\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 max\n" - " (expression vec4 min\n" - " (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0)))\n" - " (constant vec4 (1.0 1.0 1.0 1.0)))\n" - " (constant vec4 (0.0 0.0 0.0 0.0))))))\n" - "))\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" -}; - -static const char *builtins_110_sqrt = { - "((function sqrt\n" - " (signature float\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) float arg0))\n" - " ((return (expression float sqrt (var_ref arg0)))))\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (signature vec2\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec2 arg0))\n" - " ((return (expression vec2 sqrt (var_ref arg0)))))\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (signature vec3\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec3 arg0))\n" - " ((return (expression vec3 sqrt (var_ref arg0)))))\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 arg0))\n" - " ((return (expression vec4 sqrt (var_ref arg0)))))\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" "))\n" -}; - -static const char *builtins_110_step = { - "((function step\n" + "" +; +static const char *builtin_faceforward = + "((function faceforward\n" " (signature float\n" " (parameters\n" - " (declare (in) float edge)\n" - " (declare (in) float x))\n" - " ((return (expression float b2f (expression bool >= (var_ref x) (var_ref edge))))))\n" + " (declare (in) float N)\n" + " (declare (in) float I)\n" + " (declare (in) float Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression float neg (var_ref N)))))))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) float edge)\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" - " (return (var_ref t))))\n" + " (declare (in) vec2 N)\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec2 neg (var_ref N)))))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) float edge)\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))\n" - " (return (var_ref t))))\n" + " (declare (in) vec3 N)\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec3 neg (var_ref N)))))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) float edge)\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge))))\n" - " (return (var_ref t))))\n" + " (declare (in) vec4 N)\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec4 neg (var_ref N)))))))\n" + "))\n" + "" +; +static const char *builtin_abs = + "((function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float abs (var_ref arg0)))))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 edge)\n" - " (declare (in) vec2 x))\n" - " ((declare () vec2 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" - " (return (var_ref t))))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 abs (var_ref arg0)))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 edge)\n" - " (declare (in) vec3 x))\n" - " ((declare () vec3 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))\n" - " (return (var_ref t))))\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 abs (var_ref arg0)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 edge)\n" - " (declare (in) vec4 x))\n" - " ((declare () vec4 t)\n" - " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz z (var_ref edge)))))\n" - " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(swiz w (var_ref edge)))))\n" - " (return (var_ref t))))\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 abs (var_ref arg0)))))\n" "))\n" - "\n" -}; - -static const char *builtins_110_tan = { - "((function tan\n" + "" +; +static const char *builtin_log2 = + "((function log2\n" " (signature float\n" " (parameters\n" - " (declare (in) float angle))\n" - " ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle))))))\n" + " (declare (in) float arg0))\n" + " ((return (expression float log2 (var_ref arg0)))))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 angle))\n" - " ((return (expression vec2 / (expression vec2 sin (var_ref angle)) (expression vec2 cos (var_ref angle))))))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 log2 (var_ref arg0)))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 angle))\n" - " ((return (expression vec3 / (expression vec3 sin (var_ref angle)) (expression vec3 cos (var_ref angle))))))\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 log2 (var_ref arg0)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 angle))\n" - " ((return (expression vec4 / (expression vec4 sin (var_ref angle)) (expression vec4 cos (var_ref angle))))))\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 log2 (var_ref arg0)))))\n" "))\n" -}; - -static const char *builtins_110_textures = { - "((function texture1D\n" + "" +; +static const char *builtin_shadow2DRect = + "((function shadow2DRect\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" "\n" - ")\n" - " (function texture1DLod\n" - " (signature vec4\n" + "))\n" + "" +; +static const char *builtin_lessThanEqual = + "((function lessThanEqual\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function texture1DProj\n" - " (signature vec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature vec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function texture1DProjLod\n" - " (signature vec4\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature vec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function texture2D\n" - " (signature vec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - "(function texture2DLod\n" - " (signature vec4\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function texture2DProj\n" - " (signature vec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature vec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - ")\n" - " (function texture2DProjLod\n" - " (signature vec4\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" + "" +; +static const char *builtin_transpose = + "((function transpose\n" + " (signature mat2\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) mat2 m))\n" + " ((declare () mat2 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + "(return (var_ref t))))\n" "\n" - " (signature vec4\n" + " (signature mat3x2\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) mat2x3 m))\n" + " ((declare () mat3x2 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + "(return (var_ref t))))\n" "\n" - ")\n" - " (function texture3D\n" - " (signature vec4\n" + " (signature mat4x2\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) mat2x4 m))\n" + " ((declare () mat4x2 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" + "(return (var_ref t))))\n" "\n" - ")\n" - " (function texture3DLod\n" - " (signature vec4\n" + " (signature mat2x3\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) mat3x2 m))\n" + " ((declare () mat2x3 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + "(return (var_ref t))))\n" "\n" - ")\n" - " (function texture3DProj\n" - " (signature vec4\n" + " (signature mat3\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + " (declare (in) mat3 m))\n" + " ((declare () mat3 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + "(return (var_ref t))))\n" "\n" - ")\n" - " (function texture3DProjLod\n" - " (signature vec4\n" + " (signature mat4x3\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) mat3x4 m))\n" + " ((declare () mat4x3 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n" + "(return (var_ref t))))\n" "\n" - ")\n" - " (function textureCube\n" - " (signature vec4\n" + " (signature mat2x4\n" " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) mat4x2 m))\n" + " ((declare () mat2x4 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" + "(return (var_ref t))))\n" "\n" - ")\n" - " (function textureCubeLod\n" - " (signature vec4\n" + " (signature mat3x4\n" " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) mat4x3 m))\n" + " ((declare () mat3x4 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n" + "(return (var_ref t))))\n" "\n" - ")\n" - " (function shadow1D\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" - "\n" - ")\n" - " (function shadow1DLod\n" - " (signature vec4\n" + " (signature mat4\n" " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" - "\n" + " (declare (in) mat4 m))\n" + " ((declare () mat4 t)\n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n" + " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (3))))) \n" + "(return (var_ref t))))\n" ")\n" - " (function shadow1DProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" "\n" ")\n" - " (function shadow1DProjLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" "\n" - ")\n" - " (function shadow2D\n" - " (signature vec4\n" + "" +; +static const char *builtin_step = + "((function step\n" + " (signature float\n" " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" + " (declare (in) float edge)\n" + " (declare (in) float x))\n" + " ((return (expression float b2f (expression bool >= (var_ref x) (var_ref edge))))))\n" "\n" - ")\n" - " (function shadow2DLod\n" - " (signature vec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + " (declare (in) float edge)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" "\n" - ")\n" - " (function shadow2DProj\n" - " (signature vec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + " (declare (in) float edge)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" "\n" - ")\n" - " (function shadow2DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" - "\n" - "))\n" -}; - -static const char *functions_for_110 [] = { - builtins_110_abs, - builtins_110_all, - builtins_110_any, - builtins_110_asin, - builtins_110_atan, - builtins_110_ceil, - builtins_110_clamp, - builtins_110_cos, - builtins_110_cross, - builtins_110_degrees, - builtins_110_distance, - builtins_110_dot, - builtins_110_equal, - builtins_110_exp, - builtins_110_exp2, - builtins_110_faceforward, - builtins_110_floor, - builtins_110_fract, - builtins_110_greaterThan, - builtins_110_greaterThanEqual, - builtins_110_inversesqrt, - builtins_110_length, - builtins_110_lessThan, - builtins_110_lessThanEqual, - builtins_110_log, - builtins_110_log2, - builtins_110_matrixCompMult, - builtins_110_max, - builtins_110_min, - builtins_110_mix, - builtins_110_mod, - builtins_110_noise_fake, - builtins_110_normalize, - builtins_110_not, - builtins_110_notEqual, - builtins_110_pow, - builtins_110_radians, - builtins_110_reflect, - builtins_110_refract, - builtins_110_sign, - builtins_110_sin, - builtins_110_smoothstep, - builtins_110_sqrt, - builtins_110_step, - builtins_110_tan, - builtins_110_textures, -}; - -/* 110_fs builtins */ - -static const char *builtins_110_fs_derivatives = { - "((function dFdx\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float p))\n" - " ((return (expression float dFdx (var_ref p)))))\n" + " (declare (in) float edge)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 p))\n" - " ((return (expression vec2 dFdx (var_ref p)))))\n" + " (declare (in) vec2 edge)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (return (var_ref t))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 p))\n" - " ((return (expression vec3 dFdx (var_ref p)))))\n" + " (declare (in) vec3 edge)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))\n" + " (return (var_ref t))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 p))\n" - " ((return (expression vec4 dFdx (var_ref p)))))\n" - " )\n" + " (declare (in) vec4 edge)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz z (var_ref edge)))))\n" + " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(swiz w (var_ref edge)))))\n" + " (return (var_ref t))))\n" + "))\n" "\n" - " (function dFdy\n" + "" +; +static const char *builtin_sinh = + "((function sinh\n" " (signature float\n" " (parameters\n" - " (declare (in) float p))\n" - " ((return (expression float dFdy (var_ref p)))))\n" - "\n" + " (declare (in) float x))\n" + " ((return (expression float * (constant float (0.5))\n" + " (expression float -\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 p))\n" - " ((return (expression vec2 dFdy (var_ref p)))))\n" - "\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 * (constant vec2 (0.5))\n" + " (expression vec2 -\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 p))\n" - " ((return (expression vec3 dFdy (var_ref p)))))\n" - "\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 * (constant vec3 (0.5))\n" + " (expression vec3 -\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 p))\n" - " ((return (expression vec4 dFdy (var_ref p)))))\n" - " )\n" - "\n" - " (function fwidth\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 * (constant vec4 (0.5))\n" + " (expression vec4 -\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" + "" +; +static const char *builtin_cos = + "((function cos\n" " (signature float\n" " (parameters\n" - " (declare (in) float p))\n" - " ((return (expression float +\n" - " (expression float abs (expression float dFdx (var_ref p)))\n" - " (expression float abs (expression float dFdy (var_ref p)))))))\n" + " (declare (in) float angle))\n" + " ((return (expression float cos (var_ref angle)))))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 p))\n" - " ((return (expression vec2 +\n" - " (expression vec2 abs (expression vec2 dFdx (var_ref p)))\n" - " (expression vec2 abs (expression vec2 dFdy (var_ref p)))))))\n" + " (declare (in) vec2 angle))\n" + " ((return (expression vec2 cos (var_ref angle)))))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 p))\n" - " ((return (expression vec3 +\n" - " (expression vec3 abs (expression vec3 dFdx (var_ref p)))\n" - " (expression vec3 abs (expression vec3 dFdy (var_ref p)))))))\n" + " (declare (in) vec3 angle))\n" + " ((return (expression vec3 cos (var_ref angle)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 p))\n" - " ((return (expression vec4 +\n" - " (expression vec4 abs (expression vec4 dFdx (var_ref p)))\n" - " (expression vec4 abs (expression vec4 dFdy (var_ref p)))))))\n" + " (declare (in) vec4 angle))\n" + " ((return (expression vec4 cos (var_ref angle)))))\n" "))\n" -}; - -static const char *builtins_110_fs_textures = { - "((function texture1D\n" + "" +; +static const char *builtin_shadow2DProjLod = + "((function shadow2DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" "\n" - ")\n" - " (function texture1DProj\n" + "))\n" + "" +; +static const char *builtin_shadow2DArray = + "((function shadow2DArray\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + " (declare (in) sampler2DArrayShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) 1 (swiz w (var_ref P)) ))))\n" "\n" - " (signature vec4\n" + "))\n" + "" +; +static const char *builtin_equal = + "((function equal\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function texture2D\n" - " (signature vec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function texture2DProj\n" - " (signature vec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature vec4\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function texture3D\n" - " (signature vec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function texture3DProj\n" - " (signature vec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function textureCube\n" - " (signature vec4\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function shadow1D\n" - " (signature vec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - ")\n" - " (function shadow1DProj\n" - " (signature vec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) sampler1DShadow sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" + "" +; +static const char *builtin_length = + "((function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" "\n" - ")\n" - " (function shadow2D\n" - " (signature vec4\n" + " (signature float\n" " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" "\n" - ")\n" - " (function shadow2DProj\n" - " (signature vec4\n" + " (signature float\n" " (parameters\n" - " (declare (in) sampler2DShadow sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" "))\n" -}; - -static const char *functions_for_110_fs [] = { - builtins_110_fs_derivatives, - builtins_110_fs_textures, -}; - -/* 110_vs builtins */ - -static const char *builtins_110_vs_ftransform = { - "((declare (uniform) mat4 gl_ModelViewProjectionMatrix)\n" - " (declare (in) vec4 gl_Vertex)\n" - " (function ftransform\n" + "" +; +static const char *builtin_acos = + "((function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" " (signature vec4\n" - " (parameters)\n" - " ((return (expression vec4 *\n" - " (var_ref gl_ModelViewProjectionMatrix)\n" - " (var_ref gl_Vertex)))))\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" "))\n" -}; - -static const char *functions_for_110_vs [] = { - builtins_110_vs_ftransform, -}; - -/* 120 builtins */ - -static const char *builtins_120_matrixCompMult = { + "" +; +static const char *builtin_matrixCompMult = "((function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 x)\n" + " (declare (in) mat2 y))\n" + " ((declare () mat2 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 x)\n" + " (declare (in) mat3 y))\n" + " ((declare () mat3 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 x)\n" + " (declare (in) mat4 y))\n" + " ((declare () mat4 z)\n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + " (assign (constant bool (1)) (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))))) \n" + "(return (var_ref z))))\n" + "\n" " (signature mat2x3\n" " (parameters\n" " (declare (in) mat2x3 x)\n" @@ -2658,533 +2591,593 @@ static const char *builtins_120_matrixCompMult = { " (assign (constant bool (1)) (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))))) \n" "(return (var_ref z))))\n" "))\n" -}; - -static const char *builtins_120_outerProduct = { - "((function outerProduct\n" - " (signature mat2\n" + "" +; +static const char *builtin_pow = + "((function pow\n" + " (signature float\n" " (parameters\n" - " (declare (in) vec2 u)\n" - " (declare (in) vec2 v))\n" - " ((declare () mat2 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" - " (return (var_ref m))))\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float pow (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature mat2x3\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) vec3 u)\n" - " (declare (in) vec2 v))\n" - " ((declare () mat2x3 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" - " (return (var_ref m))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 pow (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature mat2x4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) vec4 u)\n" - " (declare (in) vec2 v))\n" - " ((declare () mat2x4 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" - " (return (var_ref m))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 pow (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature mat3x2\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec2 u)\n" - " (declare (in) vec3 v))\n" - " ((declare () mat3x2 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))\n" - " (return (var_ref m))\n" - " ))\n" - "\n" - " (signature mat3\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 pow (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char *builtin_texture2DProjLod = + "((function texture2DProjLod\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec3 u)\n" - " (declare (in) vec3 v))\n" - " ((declare () mat3 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))\n" - " (return (var_ref m))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat3x4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 u)\n" - " (declare (in) vec3 v))\n" - " ((declare () mat3x4 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))\n" - " (return (var_ref m))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat4x2\n" + "))\n" + "" +; +static const char *builtin_textureProjLod = + "((function textureProjLod\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) vec2 u)\n" - " (declare (in) vec4 v))\n" - " ((declare () mat4x2 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v))))\n" - " (return (var_ref m))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat4x3\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) vec3 u)\n" - " (declare (in) vec4 v))\n" - " ((declare () mat4x3 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v))))\n" - " (return (var_ref m))))\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat4\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) vec4 u)\n" - " (declare (in) vec4 v))\n" - " ((declare () mat4 m)\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))\n" - " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref u) (swiz w (var_ref v))))\n" - " (return (var_ref m))))\n" - "))\n" -}; - -static const char *builtins_120_transpose = { - "((function transpose\n" - " (signature mat2\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) mat2 m))\n" - " ((declare () mat2 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - "(return (var_ref t))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat3x2\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) mat2x3 m))\n" - " ((declare () mat3x2 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - "(return (var_ref t))))\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat4x2\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) mat2x4 m))\n" - " ((declare () mat4x2 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" - "(return (var_ref t))))\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat2x3\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) mat3x2 m))\n" - " ((declare () mat2x3 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - "(return (var_ref t))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat3\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) mat3 m))\n" - " ((declare () mat3 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" - "(return (var_ref t))))\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat4x3\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) mat3x4 m))\n" - " ((declare () mat4x3 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n" - "(return (var_ref t))))\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat2x4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) mat4x2 m))\n" - " ((declare () mat2x4 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" - "(return (var_ref t))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat3x4\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) mat4x3 m))\n" - " ((declare () mat3x4 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n" - "(return (var_ref t))))\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature mat4\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) mat4 m))\n" - " ((declare () mat4 t)\n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n" - " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (3))))) \n" - "(return (var_ref t))))\n" - ")\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" - ")\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" -}; - -static const char *functions_for_120 [] = { - builtins_120_matrixCompMult, - builtins_120_outerProduct, - builtins_120_transpose, -}; - -/* 130 builtins */ - -static const char *builtins_130_clamp = { - "((function clamp\n" - " (signature int\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) int arg0)\n" - " (declare (in) int arg1)\n" - " (declare (in) int arg2))\n" - " ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature ivec2\n" + " (signature uvec4\n" " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1)\n" - " (declare (in) ivec2 arg2))\n" - " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature ivec3\n" + "))\n" + "" +; +static const char *builtin_log = + "((function log\n" + " (signature float\n" " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1)\n" - " (declare (in) ivec3 arg2))\n" - " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) float arg0))\n" + " ((return (expression float log (var_ref arg0)))))\n" "\n" - " (signature ivec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1)\n" - " (declare (in) ivec4 arg2))\n" - " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 log (var_ref arg0)))))\n" "\n" - " (signature ivec2\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) int arg1)\n" - " (declare (in) int arg2))\n" - " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 log (var_ref arg0)))))\n" "\n" - " (signature ivec3\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) int arg1)\n" - " (declare (in) int arg2))\n" - " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 log (var_ref arg0)))))\n" + "))\n" + "" +; +static const char *builtin_exp2 = + "((function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float exp2 (var_ref arg0)))))\n" "\n" - " (signature ivec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) int arg1)\n" - " (declare (in) int arg2))\n" - " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 exp2 (var_ref arg0)))))\n" "\n" - " (signature uint\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) uint arg0)\n" - " (declare (in) uint arg1)\n" - " (declare (in) uint arg2))\n" - " ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 exp2 (var_ref arg0)))))\n" "\n" - " (signature uvec2\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1)\n" - " (declare (in) uvec2 arg2))\n" - " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 exp2 (var_ref arg0)))))\n" + "))\n" + "" +; +static const char *builtin_fract = + "((function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float fract (var_ref x)))))\n" "\n" - " (signature uvec3\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1)\n" - " (declare (in) uvec3 arg2))\n" - " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 fract (var_ref x)))))\n" "\n" - " (signature uvec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1)\n" - " (declare (in) uvec4 arg2))\n" - " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 fract (var_ref x)))))\n" "\n" - " (signature uvec2\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uint arg1)\n" - " (declare (in) uint arg2))\n" - " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 fract (var_ref x)))))\n" + "))\n" "\n" - " (signature uvec3\n" + "" +; +static const char *builtin_shadow1DLod = + "((function shadow1DLod\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uint arg1)\n" - " (declare (in) uint arg2))\n" - " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" "\n" - " (signature uvec4\n" + "))\n" + "" +; +static const char *builtin_texture1DLod = + "((function texture1DLod\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uint arg1)\n" - " (declare (in) uint arg2))\n" - " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + "\n" "))\n" -}; - -static const char *builtins_130_cosh = { - "((function cosh\n" + "" +; +static const char *builtin_texture2DArray = + "((function texture2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char *builtin_texture3DProj = + "((function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char *builtin_sign = + "((function sign\n" " (signature float\n" " (parameters\n" " (declare (in) float x))\n" - " ((return (expression float * (constant float (0.5))\n" - " (expression float +\n" - " (expression float exp (var_ref x))\n" - " (expression float exp (expression float neg (var_ref x))))))))\n" + " ((return (expression float sign (var_ref x)))))\n" + "\n" " (signature vec2\n" " (parameters\n" " (declare (in) vec2 x))\n" - " ((return (expression vec2 * (constant vec2 (0.5))\n" - " (expression vec2 +\n" - " (expression vec2 exp (var_ref x))\n" - " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " ((return (expression vec2 sign (var_ref x)))))\n" + "\n" " (signature vec3\n" " (parameters\n" " (declare (in) vec3 x))\n" - " ((return (expression vec3 * (constant vec3 (0.5))\n" - " (expression vec3 +\n" - " (expression vec3 exp (var_ref x))\n" - " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " ((return (expression vec3 sign (var_ref x)))))\n" + "\n" " (signature vec4\n" " (parameters\n" " (declare (in) vec4 x))\n" - " ((return (expression vec4 * (constant vec4 (0.5))\n" - " (expression vec4 +\n" - " (expression vec4 exp (var_ref x))\n" - " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" - "))\n" -}; - -static const char *builtins_130_equal = { - "((function equal\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " ((return (expression vec4 sign (var_ref x)))))\n" "\n" - " (signature bvec3\n" + " (signature int\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) int x))\n" + " ((return (expression int sign (var_ref x)))))\n" "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_130_greaterThan = { - "((function greaterThan\n" - " (signature bvec2\n" + " (signature ivec2\n" " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) ivec2 x))\n" + " ((return (expression ivec2 sign (var_ref x)))))\n" "\n" - " (signature bvec3\n" + " (signature ivec3\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) ivec3 x))\n" + " ((return (expression ivec3 sign (var_ref x)))))\n" "\n" - " (signature bvec4\n" + " (signature ivec4\n" " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) ivec4 x))\n" + " ((return (expression ivec4 sign (var_ref x)))))\n" "))\n" -}; - -static const char *builtins_130_greaterThanEqual = { - "((function greaterThanEqual\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" "\n" - " (signature bvec3\n" + "" +; +static const char *builtin_inversesqrt = + "((function inversesqrt\n" + " (signature float\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) float arg0))\n" + " ((return (expression float rsq (var_ref arg0)))))\n" "\n" - " (signature bvec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 rsq (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 rsq (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 rsq (var_ref arg0)))))\n" + "))\n" + "" +; +static const char *builtin_distance = + "((function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p0)\n" + " (declare (in) float p1))\n" + " ((declare () float p)\n" + " (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 p0)\n" + " (declare (in) vec2 p1))\n" + " ((declare () vec2 p)\n" + " (assign (constant bool (1)) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 p0)\n" + " (declare (in) vec3 p1))\n" + " ((declare () vec3 p)\n" + " (assign (constant bool (1)) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 p0)\n" + " (declare (in) vec4 p1))\n" + " ((declare () vec4 p)\n" + " (assign (constant bool (1)) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "))\n" + "" +; +static const char *builtin_noise2 = + "((function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (constant vec2 (0 0)))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (constant vec2 (0 0)))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant vec2 (0 0)))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant vec2 (0 0)))))\n" + "))\n" + "" +; +static const char *builtin_tanh = + "((function tanh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float /\n" + " (expression float -\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))\n" + " (expression float +\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 /\n" + " (expression vec2 -\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))\n" + " (expression vec2 +\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 /\n" + " (expression vec3 -\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))\n" + " (expression vec3 +\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 /\n" + " (expression vec4 -\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))\n" + " (expression vec4 +\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" + "" +; +static const char *builtin_texture1DProjLod = + "((function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char *builtin_texture1DArray = + "((function texture1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char *builtin_texture2D = + "((function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char *builtin_greaterThanEqual = + "((function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" " ((declare () bvec4 temp)\n" " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_130_lessThan = { - "((function lessThan\n" + "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_130_lessThanEqual = { - "((function lessThanEqual\n" + "\n" " (signature bvec2\n" " (parameters\n" " (declare (in) uvec2 arg0)\n" " (declare (in) uvec2 arg1))\n" " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec3\n" @@ -3192,9 +3185,9 @@ static const char *builtins_130_lessThanEqual = { " (declare (in) uvec3 arg0)\n" " (declare (in) uvec3 arg1))\n" " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "\n" " (signature bvec4\n" @@ -3202,192 +3195,220 @@ static const char *builtins_130_lessThanEqual = { " (declare (in) uvec4 arg0)\n" " (declare (in) uvec4 arg1))\n" " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" " (return (var_ref temp))))\n" "))\n" -}; - -static const char *builtins_130_max = { - "((function max\n" - " (signature int\n" + "" +; +static const char *builtin_texture3DProjLod = + "((function texture3DProjLod\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) int arg0)\n" - " (declare (in) int arg1))\n" - " ((return (expression int max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" "\n" - " (signature ivec2\n" + "))\n" + "" +; +static const char *builtin_tan = + "((function tan\n" + " (signature float\n" " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) float angle))\n" + " ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle))))))\n" "\n" - " (signature ivec3\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec2 angle))\n" + " ((return (expression vec2 / (expression vec2 sin (var_ref angle)) (expression vec2 cos (var_ref angle))))))\n" "\n" - " (signature ivec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec3 angle))\n" + " ((return (expression vec3 / (expression vec3 sin (var_ref angle)) (expression vec3 cos (var_ref angle))))))\n" "\n" - " (signature ivec2\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) int arg1))\n" - " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature ivec3\n" + " (declare (in) vec4 angle))\n" + " ((return (expression vec4 / (expression vec4 sin (var_ref angle)) (expression vec4 cos (var_ref angle))))))\n" + "))\n" + "" +; +static const char *builtin_any = + "((function any\n" + " (signature bool\n" " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) int arg1))\n" - " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n" "\n" - " (signature ivec4\n" + " (signature bool\n" " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) int arg1))\n" - " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n" "\n" - " (signature uint\n" + " (signature bool\n" " (parameters\n" - " (declare (in) uint arg0)\n" - " (declare (in) uint arg1))\n" - " ((return (expression uint max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature uvec2\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n" + "))\n" + "" +; +static const char *builtin_normalize = + "((function normalize\n" + " (signature float\n" " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) float arg0))\n" + " ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" "\n" - " (signature uvec3\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" "\n" - " (signature uvec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" "\n" - " (signature uvec2\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uint arg1))\n" - " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature uvec3\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "))\n" + "" +; +static const char *builtin_shadow1DProj = + "((function shadow1DProj\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uint arg1))\n" - " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" "\n" - " (signature uvec4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uint arg1))\n" - " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" "))\n" -}; - -static const char *builtins_130_min = { - "((function min\n" - " (signature int\n" + "" +; +static const char *builtin_floor = + "((function floor\n" + " (signature float\n" " (parameters\n" - " (declare (in) int arg0)\n" - " (declare (in) int arg1))\n" - " ((return (expression int min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) float arg0))\n" + " ((return (expression float floor (var_ref arg0)))))\n" "\n" - " (signature ivec2\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) ivec2 arg1))\n" - " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 floor (var_ref arg0)))))\n" "\n" - " (signature ivec3\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) ivec3 arg1))\n" - " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 floor (var_ref arg0)))))\n" "\n" - " (signature ivec4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) ivec4 arg1))\n" - " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n" - "\n" - " (signature ivec2\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 floor (var_ref arg0)))))\n" + "))\n" + "" +; +static const char *builtin_cross = + "((function cross\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) ivec2 arg0)\n" - " (declare (in) int arg1))\n" - " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 cross (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char *builtin_sqrt = + "((function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float sqrt (var_ref arg0)))))\n" "\n" - " (signature ivec3\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) ivec3 arg0)\n" - " (declare (in) int arg1))\n" - " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 sqrt (var_ref arg0)))))\n" "\n" - " (signature ivec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) ivec4 arg0)\n" - " (declare (in) int arg1))\n" - " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 sqrt (var_ref arg0)))))\n" "\n" - " (signature uint\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uint arg0)\n" - " (declare (in) uint arg1))\n" - " ((return (expression uint min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 sqrt (var_ref arg0)))))\n" + "))\n" + "" +; +static const char *builtin_mix = + "((function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2))))))\n" "\n" - " (signature uvec2\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) vec2 arg2))\n" + " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" "\n" - " (signature uvec3\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) vec3 arg2))\n" + " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" "\n" - " (signature uvec4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) vec4 arg2))\n" + " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" "\n" - " (signature uvec2\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uint arg1))\n" - " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" "\n" - " (signature uvec3\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uint arg1))\n" - " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" "\n" - " (signature uvec4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uint arg1))\n" - " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n" - "))\n" -}; - -static const char *builtins_130_mix = { - "((function mix\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" " (signature float\n" " (parameters\n" " (declare (in) float v1)\n" @@ -3426,1378 +3447,11231 @@ static const char *builtins_130_mix = { " (assign (swiz w (var_ref a)) (swiz w (var_ref v1)) (swiz w (var_ref v2)))\n" " (return (var_ref v1))))\n" "))\n" -}; - -static const char *builtins_130_notEqual = { - "((function notEqual\n" - " (signature bvec2\n" - " (parameters\n" - " (declare (in) uvec2 arg0)\n" - " (declare (in) uvec2 arg1))\n" - " ((declare () bvec2 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "\n" - " (signature bvec3\n" + "" +; +static const char *builtin_shadow1DArrayLod = + "((function shadow1DArrayLod\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) uvec3 arg0)\n" - " (declare (in) uvec3 arg1))\n" - " ((declare () bvec3 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" "\n" - " (signature bvec4\n" - " (parameters\n" - " (declare (in) uvec4 arg0)\n" - " (declare (in) uvec4 arg1))\n" - " ((declare () bvec4 temp)\n" - " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" - " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" - " (return (var_ref temp))))\n" - "))\n" -}; - -static const char *builtins_130_sign = { - "((function sign\n" - " (signature int\n" - " (parameters\n" - " (declare (in) int x))\n" - " ((return (expression int sign (var_ref x)))))\n" - "\n" - " (signature ivec2\n" - " (parameters\n" - " (declare (in) ivec2 x))\n" - " ((return (expression ivec2 sign (var_ref x)))))\n" - "\n" - " (signature ivec3\n" - " (parameters\n" - " (declare (in) ivec3 x))\n" - " ((return (expression ivec3 sign (var_ref x)))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) ivec4 x))\n" - " ((return (expression ivec4 sign (var_ref x)))))\n" "))\n" - "\n" -}; - -static const char *builtins_130_sinh = { - "((function sinh\n" - " (signature float\n" - " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float * (constant float (0.5))\n" - " (expression float -\n" - " (expression float exp (var_ref x))\n" - " (expression float exp (expression float neg (var_ref x))))))))\n" - " (signature vec2\n" - " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 * (constant vec2 (0.5))\n" - " (expression vec2 -\n" - " (expression vec2 exp (var_ref x))\n" - " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" - " (signature vec3\n" - " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 * (constant vec3 (0.5))\n" - " (expression vec3 -\n" - " (expression vec3 exp (var_ref x))\n" - " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + "" +; +static const char *builtin_ftransform = + "((declare (uniform) mat4 gl_ModelViewProjectionMatrix)\n" + " (declare (in) vec4 gl_Vertex)\n" + " (function ftransform\n" " (signature vec4\n" - " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 * (constant vec4 (0.5))\n" - " (expression vec4 -\n" - " (expression vec4 exp (var_ref x))\n" - " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + " (parameters)\n" + " ((return (expression vec4 *\n" + " (var_ref gl_ModelViewProjectionMatrix)\n" + " (var_ref gl_Vertex)))))\n" "))\n" -}; - -static const char *builtins_130_tanh = { - "((function tanh\n" + "" +; +static const char *builtin_sin = + "((function sin\n" " (signature float\n" " (parameters\n" - " (declare (in) float x))\n" - " ((return (expression float /\n" - " (expression float -\n" - " (expression float exp (var_ref x))\n" - " (expression float exp (expression float neg (var_ref x))))\n" - " (expression float +\n" - " (expression float exp (var_ref x))\n" - " (expression float exp (expression float neg (var_ref x))))))))\n" + " (declare (in) float angle))\n" + " ((return (expression float sin (var_ref angle)))))\n" + "\n" " (signature vec2\n" " (parameters\n" - " (declare (in) vec2 x))\n" - " ((return (expression vec2 /\n" - " (expression vec2 -\n" - " (expression vec2 exp (var_ref x))\n" - " (expression vec2 exp (expression vec2 neg (var_ref x))))\n" - " (expression vec2 +\n" - " (expression vec2 exp (var_ref x))\n" - " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (declare (in) vec2 angle))\n" + " ((return (expression vec2 sin (var_ref angle)))))\n" + "\n" " (signature vec3\n" " (parameters\n" - " (declare (in) vec3 x))\n" - " ((return (expression vec3 /\n" - " (expression vec3 -\n" - " (expression vec3 exp (var_ref x))\n" - " (expression vec3 exp (expression vec3 neg (var_ref x))))\n" - " (expression vec3 +\n" - " (expression vec3 exp (var_ref x))\n" - " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (declare (in) vec3 angle))\n" + " ((return (expression vec3 sin (var_ref angle)))))\n" + "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) vec4 x))\n" - " ((return (expression vec4 /\n" - " (expression vec4 -\n" - " (expression vec4 exp (var_ref x))\n" - " (expression vec4 exp (expression vec4 neg (var_ref x))))\n" - " (expression vec4 +\n" - " (expression vec4 exp (var_ref x))\n" - " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + " (declare (in) vec4 angle))\n" + " ((return (expression vec4 sin (var_ref angle)))))\n" "))\n" -}; - -static const char *builtins_130_texelFetch = { - "((function texelFetch\n" + "" +; +static const char *builtin_shadow2D = + "((function shadow2D\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) int P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) int P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) int P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" "\n" + "))\n" + "" +; +static const char *builtin_shadow2DLod = + "((function shadow2DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" "\n" + "))\n" + "" +; +static const char *builtin_shadow2DRectProj = + "((function shadow2DRectProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" "\n" - " (signature ivec4\n" + "))\n" + "" +; +static const char *builtin_atan = + "((function atan\n" + " (signature float\n" " (parameters\n" - " (declare (in) isampler1DArray sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + " (declare (in) float x))\n" + " ((return (call asin ((expression float *\n" + " (var_ref x)\n" + " (expression float rsq\n" + " (expression float +\n" + " (expression float *\n" + " (var_ref x)\n" + " (var_ref x))\n" + " (constant float (1.0))))))))))\n" "\n" - " (signature uvec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) usampler1DArray sampler)\n" - " (declare (in) ivec2 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + " (declare (in) vec2 y_over_x))\n" + " ((return (call asin ((expression vec2 *\n" + " (var_ref y_over_x)\n" + " (expression vec2 rsq\n" + " (expression vec2 +\n" + " (expression vec2 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" "\n" - " (signature vec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + " (declare (in) vec3 y_over_x))\n" + " ((return (call asin ((expression vec3 *\n" + " (var_ref y_over_x)\n" + " (expression vec3 rsq\n" + " (expression vec3 +\n" + " (expression vec3 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" "\n" - " (signature ivec4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) isampler2DArray sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + " (declare (in) vec4 y_over_x))\n" + " ((return (call asin ((expression vec4 *\n" + " (var_ref y_over_x)\n" + " (expression vec4 rsq\n" + " (expression vec4 +\n" + " (expression vec4 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" "\n" - " (signature uvec4\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y)\n" + " (declare (in ) float x)\n" + " )\n" + " (\n" + " (declare () float r)\n" + " (declare ( ) float abs_retval)\n" + " (assign (constant bool (1)) (var_ref abs_retval) (call abs ((var_ref x) ))\n" + ") \n" + " (if (expression bool > (var_ref abs_retval) (constant float (0.000100)) ) (\n" + " (declare ( ) float atan_retval)\n" + " (assign (constant bool (1)) (var_ref atan_retval) (call atan ((expression float / (var_ref y) (var_ref x) ) ))\n" + ") \n" + " (assign (constant bool (1)) (var_ref r) (var_ref atan_retval) ) \n" + " (if (expression bool < (var_ref x) (constant float (0.000000)) ) (\n" + " (if (expression bool >= (var_ref y) (constant float (0.000000)) ) (\n" + " (declare ( ) float assignment_tmp)\n" + " (assign (constant bool (1)) (var_ref assignment_tmp) (expression float + (var_ref r) (constant float (3.141593)) ) ) \n" + " (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) \n" + " )\n" + " (\n" + " (declare ( ) float assignment_tmp)\n" + " (assign (constant bool (1)) (var_ref assignment_tmp) (expression float - (var_ref r) (constant float (3.141593)) ) ) \n" + " (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) \n" + " ))\n" + "\n" + " )\n" + " (\n" + " ))\n" + "\n" + " )\n" + " (\n" + " (if (expression bool >= (var_ref y) (constant float (0.000000)) ) (\n" + " (assign (constant bool (1)) (var_ref r) (constant float (1.570796)) ) \n" + " )\n" + " (\n" + " (assign (constant bool (1)) (var_ref r) (constant float (-1.570796)) ) \n" + " ))\n" + "\n" + " ))\n" + "\n" + " (return (var_ref r) )\n" + " ))\n" + "\n" + "\n" + "\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) usampler2DArray sampler)\n" - " (declare (in) ivec3 P) \n" - " (declare (in) int lod) )\n" - " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 r)\n" + " (assign (constant bool (1))\n" + " (swiz x (var_ref r))\n" + " (call atan ((swiz x (var_ref y))\n" + " (swiz x (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz y (var_ref r))\n" + " (call atan ((swiz y (var_ref y))\n" + " (swiz y (var_ref x)))))\n" + " (return (var_ref r))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 r)\n" + " (assign (constant bool (1))\n" + " (swiz x (var_ref r))\n" + " (call atan ((swiz x (var_ref y))\n" + " (swiz x (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz y (var_ref r))\n" + " (call atan ((swiz y (var_ref y))\n" + " (swiz y (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz z (var_ref r))\n" + " (call atan ((swiz z (var_ref y))\n" + " (swiz z (var_ref x)))))\n" + " (return (var_ref r))))\n" "\n" - "))\n" -}; - -static const char *builtins_130_texture = { - "((function texture\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 r)\n" + " (assign (constant bool (1))\n" + " (swiz x (var_ref r))\n" + " (call atan ((swiz x (var_ref y))\n" + " (swiz x (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz y (var_ref r))\n" + " (call atan ((swiz y (var_ref y))\n" + " (swiz y (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz z (var_ref r))\n" + " (call atan ((swiz z (var_ref y))\n" + " (swiz z (var_ref x)))))\n" + " (assign (constant bool (1))\n" + " (swiz w (var_ref r))\n" + " (call atan ((swiz w (var_ref y))\n" + " (swiz w (var_ref x)))))\n" + " (return (var_ref r)))))\n" "\n" - " (signature ivec4\n" + "))\n" + "" +; +static const char *builtin_max = + "((function max\n" + " (signature float\n" " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) float P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) float P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature ivec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature ivec4\n" + " (signature int\n" " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression int max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature ivec2\n" " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature vec4\n" + " (signature ivec3\n" " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature ivec4\n" " (parameters\n" - " (declare (in) isamplerCube sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature ivec2\n" " (parameters\n" - " (declare (in) usamplerCube sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature vec4\n" + " (signature ivec3\n" " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature ivec4\n" " (parameters\n" - " (declare (in) isampler1DArray sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature uint\n" " (parameters\n" - " (declare (in) usampler1DArray sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uint max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature vec4\n" + " (signature uvec2\n" " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature ivec4\n" + " (signature uvec3\n" " (parameters\n" - " (declare (in) isampler2DArray sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature uvec4\n" " (parameters\n" - " (declare (in) usampler2DArray sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n" "\n" - "))\n" -}; - -static const char *builtins_130_textureGrad = { - "((function textureGrad\n" - " (signature vec4\n" + " (signature uvec2\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature ivec4\n" + " (signature uvec3\n" " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature uvec4\n" " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" - "\n" - " (signature vec4\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char *builtin_reflect = + "((function reflect\n" + " (signature float\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) float i)\n" + " (declare (in) float n))\n" + " ((return (expression float -\n" + " (var_ref i)\n" + " (expression float *\n" + " (constant float (2.0))\n" + " (expression float *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" "\n" - " (signature ivec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec2 i)\n" + " (declare (in) vec2 n))\n" + " ((return (expression vec2 -\n" + " (var_ref i)\n" + " (expression vec2 *\n" + " (constant float (2.0))\n" + " (expression vec2 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" "\n" - " (signature uvec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec3 i)\n" + " (declare (in) vec3 n))\n" + " ((return (expression vec3 -\n" + " (var_ref i)\n" + " (expression vec3 *\n" + " (constant float (2.0))\n" + " (expression vec3 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec4 i)\n" + " (declare (in) vec4 n))\n" + " ((return (expression vec4 -\n" + " (var_ref i)\n" + " (expression vec4 *\n" + " (constant float (2.0))\n" + " (expression vec4 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" "\n" - " (signature ivec4\n" + "))\n" + "" +; +static const char *builtin_texture3D = + "((function texture3D\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" - " (signature uvec4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) usampler3D sampler)\n" + " (declare (in) sampler3D sampler)\n" " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" "\n" + "))\n" + "" +; +static const char *builtin_texelFetch = + "((function texelFetch\n" " (signature vec4\n" " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature ivec4\n" " (parameters\n" - " (declare (in) isamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature uvec4\n" " (parameters\n" - " (declare (in) usamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature ivec4\n" " (parameters\n" - " (declare (in) isampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature uvec4\n" " (parameters\n" - " (declare (in) usampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature ivec4\n" " (parameters\n" - " (declare (in) isampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature uvec4\n" " (parameters\n" - " (declare (in) usampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" - ")\n" - ")\n" -}; - -static const char *builtins_130_textureLod = { - "((function textureLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature ivec4\n" " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature uvec4\n" " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature ivec4\n" " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" " (signature uvec4\n" " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n" "\n" + "))\n" + "" +; +static const char *builtin_noise4 = + "((function noise4\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" + " (declare (in) float x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" + " (declare (in) vec2 x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" " (signature vec4\n" " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" + " (declare (in) vec3 x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) isamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" + " (declare (in) vec4 x))\n" + " ((return (constant vec4 (0 0 0 0)))))\n" + "))\n" + "" +; +static const char *builtin_notEqual = + "((function notEqual\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) usamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" + " (return (var_ref temp))))\n" "\n" - " (signature vec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" + " (return (var_ref temp))))\n" "\n" - " (signature ivec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) isampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))\n" + " (return (var_ref temp))))\n" "\n" - " (signature uvec4\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) usampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" + " (return (var_ref temp))))\n" "\n" - " (signature vec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" + " (return (var_ref temp))))\n" "\n" - " (signature ivec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) isampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))\n" + " (return (var_ref temp))))\n" "\n" - " (signature uvec4\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) usampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - "))\n" -}; - -static const char *builtins_130_textureProj = { - "((function textureProj\n" - " (signature vec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature ivec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" - "\n" - " (signature uvec4\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" + "" +; +static const char *builtin_outerProduct = + "((function outerProduct\n" + " (signature mat2\n" " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat2 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" - " (signature vec4\n" + " (signature mat2x3\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat2x3 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" - " (signature ivec4\n" + " (signature mat2x4\n" " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat2x4 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" - " (signature uvec4\n" + " (signature mat3x2\n" " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat3x2 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))\n" + " (return (var_ref m))\n" + " ))\n" "\n" - " (signature vec4\n" + " (signature mat3\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat3 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" - " (signature ivec4\n" + " (signature mat3x4\n" " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat3x4 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" - " (signature uvec4\n" + " (signature mat4x2\n" " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat4x2 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" - " (signature vec4\n" + " (signature mat4x3\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat4x3 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v))))\n" + " (return (var_ref m))))\n" "\n" - " (signature ivec4\n" + " (signature mat4\n" " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - " (signature uvec4\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat4 m)\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))\n" + " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref u) (swiz w (var_ref v))))\n" + " (return (var_ref m))))\n" + "))\n" + "" +; +static const char *builtin_shadow1D = + "((function shadow1D\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" "\n" - " (signature ivec4\n" + "))\n" + "" +; +static const char *builtin_noise1 = + "((function noise1\n" + " (signature float\n" " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" - " (signature uvec4\n" + " (declare (in) float x))\n" + " ((return (constant float (0)))))\n" + " (signature float\n" " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n" - "\n" + " (declare (in) vec2 x))\n" + " ((return (constant float (0)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant float (0)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant float (0)))))\n" "))\n" -}; - -static const char *builtins_130_textureProjGrad = { - "((function textureProjGrad\n" - " (signature vec4\n" + "" +; +static const char *builtin_refract = + "((function refract\n" + " (signature float\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) float i)\n" + " (declare (in) float n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant float (0.0))))\n" + " ((return (expression float -\n" + " (expression float * (var_ref eta) (var_ref i))\n" + " (expression float *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" "\n" - " (signature ivec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec2 i)\n" + " (declare (in) vec2 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec2 (0.0 0.0))))\n" + " ((return (expression vec2 -\n" + " (expression vec2 * (var_ref eta) (var_ref i))\n" + " (expression vec2 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" "\n" - " (signature uvec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec3 i)\n" + " (declare (in) vec3 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec3 (0.0 0.0 0.0))))\n" + " ((return (expression vec3 -\n" + " (expression vec3 * (var_ref eta) (var_ref i))\n" + " (expression vec3 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec4 i)\n" + " (declare (in) vec4 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (constant bool (1)) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec4 (0.0 0.0 0.0 0.0))))\n" + " ((return (expression vec4 -\n" + " (expression vec4 * (var_ref eta) (var_ref i))\n" + " (expression vec4 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" "\n" - " (signature ivec4\n" + "))\n" + "" +; +static const char *builtin_noise3 = + "((function noise3\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) float x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (constant vec3 (0 0 0)))))\n" + "))\n" + "" +; +static const char *builtin_min = + "((function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float dPdx) \n" - " (declare (in) float dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature ivec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature ivec4\n" + " (signature int\n" " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression int min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature ivec2\n" " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec2 dPdx) \n" - " (declare (in) vec2 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature vec4\n" + " (signature ivec3\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature ivec4\n" " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature ivec2\n" " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) vec3 dPdx) \n" - " (declare (in) vec3 dPdy) )\n" - " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n" "\n" - "))\n" -}; - -static const char *builtins_130_textureProjLod = { - "((function textureProjLod\n" - " (signature vec4\n" + " (signature ivec3\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature ivec4\n" " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature uint\n" " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uint min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature vec4\n" + " (signature uvec2\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature ivec4\n" + " (signature uvec3\n" " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature uvec4\n" " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature vec4\n" + " (signature uvec2\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature ivec4\n" + " (signature uvec3\n" " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n" "\n" " (signature uvec4\n" " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n" - "\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char *builtin_textureCube = + "((function textureCube\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" - "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" "\n" - " (signature ivec4\n" + "))\n" + "" +; +static const char *builtin_shadow1DArray = + "((function shadow1DArray\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" "\n" - " (signature uvec4\n" + " (signature vec4\n" " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" "\n" "))\n" -}; - -static const char *functions_for_130 [] = { - builtins_130_clamp, - builtins_130_cosh, - builtins_130_equal, - builtins_130_greaterThan, - builtins_130_greaterThanEqual, - builtins_130_lessThan, - builtins_130_lessThanEqual, - builtins_130_max, - builtins_130_min, - builtins_130_mix, - builtins_130_notEqual, - builtins_130_sign, - builtins_130_sinh, - builtins_130_tanh, - builtins_130_texelFetch, - builtins_130_texture, - builtins_130_textureGrad, - builtins_130_textureLod, - builtins_130_textureProj, - builtins_130_textureProjGrad, - builtins_130_textureProjLod, -}; - -/* 130_fs builtins */ - -static const char *builtins_130_fs_texture = { - "((function texture\n" - " (signature vec4\n" + "" +; +static const char *builtin_exp = + "((function exp\n" + " (signature float\n" " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) float arg0))\n" + " ((return (expression float exp (var_ref arg0)))))\n" "\n" - " (signature ivec4\n" + " (signature vec2\n" " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 exp (var_ref arg0)))))\n" "\n" - " (signature uvec4\n" + " (signature vec3\n" " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) float P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 exp (var_ref arg0)))))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" - "\n" - " (signature ivec4\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 exp (var_ref arg0)))))\n" + "))\n" + "" +; +static const char *builtin_greaterThan = + "((function greaterThan\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature uvec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature vec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature ivec4\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature uvec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature vec4\n" + " (signature bvec4\n" " (parameters\n" - " (declare (in) samplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature ivec4\n" + " (signature bvec2\n" " (parameters\n" - " (declare (in) isamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((declare () bvec2 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" - " (signature uvec4\n" + " (signature bvec3\n" " (parameters\n" - " (declare (in) usamplerCube sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((declare () bvec3 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((declare () bvec4 temp)\n" + " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n" + " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n" + " (return (var_ref temp))))\n" + "))\n" + "" +; +static const char *builtin_texture2DLod = + "((function texture2DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" + " (declare (in) sampler2D sampler)\n" " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) float lod) )\n" + " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" "\n" - " (signature ivec4\n" + "))\n" + "" +; +static const char *builtin_dot = + "((function dot\n" + " (signature float\n" " (parameters\n" - " (declare (in) isampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature uvec4\n" + " (signature float\n" " (parameters\n" - " (declare (in) usampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature vec4\n" + " (signature float\n" " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" "\n" - " (signature ivec4\n" + " (signature float\n" " (parameters\n" - " (declare (in) isampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char *prototypes_for_120_vert = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float degrees@0x22143e0)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 degrees@0x22147b0)\n" + " )\n" + " (\n" + " ))\n" "\n" - "))\n" -}; - -static const char *builtins_130_fs_textureProj = { - "((function textureProj\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 degrees@0x22149a0)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 degrees@0x2214b90)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + ")\n" "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float radians@0x2214d80)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 radians@0x2215150)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 radians@0x2215340)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 radians@0x2215530)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x2215720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x2215ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x2215cb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x2215e90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x2216070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x2216420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x2216600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x22167e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x22169c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x2216d70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x2216f50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x2217130)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x2217310)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x22176c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x22178a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x2217a80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x2217c60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x2218010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x22181f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x22183d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y@0x22185b0)\n" + " (declare (in ) float x@0x22186c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y@0x2218a70)\n" + " (declare (in ) vec2 x@0x2218b80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y@0x2218d60)\n" + " (declare (in ) vec3 x@0x2218e70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y@0x2219050)\n" + " (declare (in ) vec4 x@0x2219160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y_over_x@0x2219340)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y_over_x@0x2219530)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y_over_x@0x2219720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y_over_x@0x2219910)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x2219b00)\n" + " (declare (in ) float y@0x2219c10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2219fc0)\n" + " (declare (in ) vec2 y@0x221a0d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x221a2b0)\n" + " (declare (in ) vec3 y@0x221a3c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x221a5a0)\n" + " (declare (in ) vec4 y@0x221a6b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x221a890)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x221ac40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x221ae20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x221b000)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x221b1e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x221b590)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x221b770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x221b950)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x221bb30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x221bee0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x221c0c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x221c2a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x221c480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x221c830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x221ca10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x221cbf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x221cdd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x221d180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x221d360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x221d540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x221d720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x221dae0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x221dcc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x221dea0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x221e080)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x221e430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x221e610)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x221e7f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x221e9d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x221ed80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x221ef60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x221f140)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x221f320)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x221f6d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x221f8b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x221fa90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x221fc70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2220020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2220200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x22203e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x22205c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2220970)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2220b50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2220d30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x2220f10)\n" + " (declare (in ) float y@0x2221020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x22213d0)\n" + " (declare (in ) float y@0x22214e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x22216c0)\n" + " (declare (in ) float y@0x22217d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x22219b0)\n" + " (declare (in ) float y@0x2221ac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2221ca0)\n" + " (declare (in ) vec2 y@0x2221db0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2221f90)\n" + " (declare (in ) vec3 y@0x22220a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2222280)\n" + " (declare (in ) vec4 y@0x2222390)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x2222570)\n" + " (declare (in ) float y@0x2222680)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2222a30)\n" + " (declare (in ) vec2 y@0x2222b40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2222d20)\n" + " (declare (in ) vec3 y@0x2222e30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2223010)\n" + " (declare (in ) vec4 y@0x2223120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2223300)\n" + " (declare (in ) float y@0x2223410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x22235f0)\n" + " (declare (in ) float y@0x2223700)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x22238e0)\n" + " (declare (in ) float y@0x22239f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x2223bd0)\n" + " (declare (in ) float y@0x2223ce0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2224090)\n" + " (declare (in ) vec2 y@0x22241a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2224380)\n" + " (declare (in ) vec3 y@0x2224490)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2224670)\n" + " (declare (in ) vec4 y@0x2224780)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2224960)\n" + " (declare (in ) float y@0x2224a70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2224c50)\n" + " (declare (in ) float y@0x2224d60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2224f40)\n" + " (declare (in ) float y@0x2225050)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x2225230)\n" + " (declare (in ) float minVal@0x2225340)\n" + " (declare (in ) float maxVal@0x2225450)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2225800)\n" + " (declare (in ) vec2 minVal@0x2225910)\n" + " (declare (in ) vec2 maxVal@0x2225a20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2225c00)\n" + " (declare (in ) vec3 minVal@0x2225d10)\n" + " (declare (in ) vec3 maxVal@0x2225e20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2226000)\n" + " (declare (in ) vec4 minVal@0x2226110)\n" + " (declare (in ) vec4 maxVal@0x2226220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2226400)\n" + " (declare (in ) float minVal@0x2226510)\n" + " (declare (in ) float maxVal@0x2226620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2226800)\n" + " (declare (in ) float minVal@0x2226910)\n" + " (declare (in ) float maxVal@0x2226a20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2226c00)\n" + " (declare (in ) float minVal@0x2226d10)\n" + " (declare (in ) float maxVal@0x2226e20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x2227000)\n" + " (declare (in ) float y@0x2227110)\n" + " (declare (in ) float a@0x2227220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x22275d0)\n" + " (declare (in ) vec2 y@0x22276e0)\n" + " (declare (in ) vec2 a@0x22277f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x22279d0)\n" + " (declare (in ) vec3 y@0x2227ae0)\n" + " (declare (in ) vec3 a@0x2227bf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2227dd0)\n" + " (declare (in ) vec4 y@0x2227ee0)\n" + " (declare (in ) vec4 a@0x2227ff0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x22281d0)\n" + " (declare (in ) vec2 y@0x22282e0)\n" + " (declare (in ) float a@0x22283f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x22285d0)\n" + " (declare (in ) vec3 y@0x22286e0)\n" + " (declare (in ) float a@0x22287f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x22289d0)\n" + " (declare (in ) vec4 y@0x2228ae0)\n" + " (declare (in ) float a@0x2228bf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge@0x2228dd0)\n" + " (declare (in ) float x@0x2228ee0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge@0x2229290)\n" + " (declare (in ) vec2 x@0x22293a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge@0x2229580)\n" + " (declare (in ) vec3 x@0x2229690)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge@0x2229870)\n" + " (declare (in ) vec4 x@0x2229980)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge@0x2229b60)\n" + " (declare (in ) vec2 x@0x2229c70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge@0x2229e50)\n" + " (declare (in ) vec3 x@0x2229f60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge@0x222a140)\n" + " (declare (in ) vec4 x@0x222a250)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge0@0x222a430)\n" + " (declare (in ) float edge1@0x222a540)\n" + " (declare (in ) float x@0x222a650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge0@0x222aa10)\n" + " (declare (in ) vec2 edge1@0x222ab20)\n" + " (declare (in ) vec2 x@0x222ac30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge0@0x222ae10)\n" + " (declare (in ) vec3 edge1@0x222af20)\n" + " (declare (in ) vec3 x@0x222b030)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge0@0x222b210)\n" + " (declare (in ) vec4 edge1@0x222b320)\n" + " (declare (in ) vec4 x@0x222b430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge0@0x222b610)\n" + " (declare (in ) float edge1@0x222b720)\n" + " (declare (in ) vec2 x@0x222b830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge0@0x222ba10)\n" + " (declare (in ) float edge1@0x222bb20)\n" + " (declare (in ) vec3 x@0x222bc30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge0@0x222be10)\n" + " (declare (in ) float edge1@0x222bf20)\n" + " (declare (in ) vec4 x@0x222c030)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x222c210)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x222c5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x222c7a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x222c980)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p0@0x222cb60)\n" + " (declare (in ) float p1@0x222cc70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 p0@0x222d030)\n" + " (declare (in ) vec2 p1@0x222d140)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 p0@0x222d320)\n" + " (declare (in ) vec3 p1@0x222d430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 p0@0x222d610)\n" + " (declare (in ) vec4 p1@0x222d720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x222d900)\n" + " (declare (in ) float y@0x222da10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x222ddc0)\n" + " (declare (in ) vec2 y@0x222ded0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x222e0b0)\n" + " (declare (in ) vec3 y@0x222e1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x222e3a0)\n" + " (declare (in ) vec4 y@0x222e4b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x222e690)\n" + " (declare (in ) vec3 y@0x222e7a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x222eb50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x222ef10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x222f0f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x222f2d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function ftransform\n" + " (signature vec4\n" + " (parameters\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float N@0x222f760)\n" + " (declare (in ) float I@0x222f870)\n" + " (declare (in ) float Nref@0x222f980)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 N@0x222fd40)\n" + " (declare (in ) vec2 I@0x222fe50)\n" + " (declare (in ) vec2 Nref@0x222ff60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 N@0x2230140)\n" + " (declare (in ) vec3 I@0x2230250)\n" + " (declare (in ) vec3 Nref@0x2230360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 N@0x2230540)\n" + " (declare (in ) vec4 I@0x2230650)\n" + " (declare (in ) vec4 Nref@0x2230760)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0x2230940)\n" + " (declare (in ) float N@0x2230a50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0x2230e10)\n" + " (declare (in ) vec2 N@0x2230f20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0x2231100)\n" + " (declare (in ) vec3 N@0x2231210)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0x22313f0)\n" + " (declare (in ) vec4 N@0x2231500)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0x22316e0)\n" + " (declare (in ) float N@0x22317f0)\n" + " (declare (in ) float eta@0x2231900)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0x2231cc0)\n" + " (declare (in ) vec2 N@0x2231dd0)\n" + " (declare (in ) float eta@0x2231ee0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0x22320c0)\n" + " (declare (in ) vec3 N@0x22321d0)\n" + " (declare (in ) float eta@0x22322e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0x22324c0)\n" + " (declare (in ) vec4 N@0x22325d0)\n" + " (declare (in ) float eta@0x22326e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) mat2 x@0x22328c0)\n" + " (declare (in ) mat2 y@0x22329d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) mat3 x@0x2232d90)\n" + " (declare (in ) mat3 y@0x2232ea0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) mat4 x@0x2233080)\n" + " (declare (in ) mat4 y@0x2233190)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) mat2x3 x@0x2233370)\n" + " (declare (in ) mat2x3 y@0x2233480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) mat2x4 x@0x2233660)\n" + " (declare (in ) mat2x4 y@0x2233770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) mat3x2 x@0x2233950)\n" + " (declare (in ) mat3x2 y@0x2233a60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) mat3x4 x@0x2233c40)\n" + " (declare (in ) mat3x4 y@0x2233d50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) mat4x2 x@0x2233f30)\n" + " (declare (in ) mat4x2 y@0x2234040)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) mat4x3 x@0x2234220)\n" + " (declare (in ) mat4x3 y@0x2234330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function outerProduct\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x2234510)\n" + " (declare (in ) vec2 r@0x2234620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x22349e0)\n" + " (declare (in ) vec3 r@0x2234af0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x2234cd0)\n" + " (declare (in ) vec4 r@0x2234de0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x2234fc0)\n" + " (declare (in ) vec2 r@0x22350d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x22352b0)\n" + " (declare (in ) vec3 r@0x22353c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x22355a0)\n" + " (declare (in ) vec2 r@0x22356b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x2235890)\n" + " (declare (in ) vec4 r@0x22359a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x2235b80)\n" + " (declare (in ) vec3 r@0x2235c90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x2235e70)\n" + " (declare (in ) vec4 r@0x2235f80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function transpose\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) mat2 m@0x2236160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) mat3 m@0x2236520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) mat4 m@0x2236700)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) mat3x2 m@0x22368e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) mat2x3 m@0x2236ac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) mat4x2 m@0x2236ca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) mat2x4 m@0x2236e80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) mat4x3 m@0x2237060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) mat3x4 m@0x2237240)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2237420)\n" + " (declare (in ) vec2 y@0x2237530)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x22378f0)\n" + " (declare (in ) vec3 y@0x2237a00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2237be0)\n" + " (declare (in ) vec4 y@0x2237cf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x2237ed0)\n" + " (declare (in ) ivec2 y@0x2237fe0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x22381c0)\n" + " (declare (in ) ivec3 y@0x22382d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x22384b0)\n" + " (declare (in ) ivec4 y@0x22385c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x22387a0)\n" + " (declare (in ) vec2 y@0x22388b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2238c70)\n" + " (declare (in ) vec3 y@0x2238d80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2238f60)\n" + " (declare (in ) vec4 y@0x2239070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x2239250)\n" + " (declare (in ) ivec2 y@0x2239360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x2239540)\n" + " (declare (in ) ivec3 y@0x2239650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x2239830)\n" + " (declare (in ) ivec4 y@0x2239940)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x2239b20)\n" + " (declare (in ) vec2 y@0x2239c30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2239ff0)\n" + " (declare (in ) vec3 y@0x223a100)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x223a2e0)\n" + " (declare (in ) vec4 y@0x223a3f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x223a5d0)\n" + " (declare (in ) ivec2 y@0x223a6e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x223a8c0)\n" + " (declare (in ) ivec3 y@0x223a9d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x223abb0)\n" + " (declare (in ) ivec4 y@0x223acc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x223aea0)\n" + " (declare (in ) vec2 y@0x223afb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x223b370)\n" + " (declare (in ) vec3 y@0x223b480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x223b660)\n" + " (declare (in ) vec4 y@0x223b770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x223b950)\n" + " (declare (in ) ivec2 y@0x223ba60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x223bc40)\n" + " (declare (in ) ivec3 y@0x223bd50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x223bf30)\n" + " (declare (in ) ivec4 y@0x223c040)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x223c220)\n" + " (declare (in ) vec2 y@0x223c330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x223c6e0)\n" + " (declare (in ) vec3 y@0x223c7f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x223c9d0)\n" + " (declare (in ) vec4 y@0x223cae0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x223ccc0)\n" + " (declare (in ) ivec2 y@0x223cdd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x223cfb0)\n" + " (declare (in ) ivec3 y@0x223d0c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x223d2a0)\n" + " (declare (in ) ivec4 y@0x223d3b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x223d590)\n" + " (declare (in ) bvec2 y@0x223d6a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x223d880)\n" + " (declare (in ) bvec3 y@0x223d990)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x223db70)\n" + " (declare (in ) bvec4 y@0x223dc80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x223de60)\n" + " (declare (in ) vec2 y@0x223df70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x223e330)\n" + " (declare (in ) vec3 y@0x223e440)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x223e620)\n" + " (declare (in ) vec4 y@0x223e730)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x223e910)\n" + " (declare (in ) ivec2 y@0x223ea20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x223ec00)\n" + " (declare (in ) ivec3 y@0x223ed10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x223eef0)\n" + " (declare (in ) ivec4 y@0x223f000)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x223f1e0)\n" + " (declare (in ) bvec2 y@0x223f2f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x223f4d0)\n" + " (declare (in ) bvec3 y@0x223f5e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x223f7c0)\n" + " (declare (in ) bvec4 y@0x223f8d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x223fab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x223fe60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x2240040)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x2240220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x22405d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x22407b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x2240990)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x2240d40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x2240f20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x2241100)\n" + " (declare (in ) float coord@0x2241220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x22415e0)\n" + " (declare (in ) vec2 coord@0x2241700)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x2241ac0)\n" + " (declare (in ) vec4 coord@0x2241be0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x2241dc0)\n" + " (declare (in ) float coord@0x2241ee0)\n" + " (declare (in ) float lod@0x2241ff0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x22423b0)\n" + " (declare (in ) vec2 coord@0x22424d0)\n" + " (declare (in ) float lod@0x22425e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x22429a0)\n" + " (declare (in ) vec4 coord@0x2242ac0)\n" + " (declare (in ) float lod@0x2242bd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x2242db0)\n" + " (declare (in ) vec2 coord@0x2242ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x2243290)\n" + " (declare (in ) vec3 coord@0x22433b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x2243770)\n" + " (declare (in ) vec4 coord@0x2243890)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x2243a70)\n" + " (declare (in ) vec2 coord@0x2243b90)\n" + " (declare (in ) float lod@0x2243ca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x2244060)\n" + " (declare (in ) vec3 coord@0x2244180)\n" + " (declare (in ) float lod@0x2244290)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x2244650)\n" + " (declare (in ) vec4 coord@0x2244770)\n" + " (declare (in ) float lod@0x2244880)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x2244a60)\n" + " (declare (in ) vec3 coord@0x2244b80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x2244f40)\n" + " (declare (in ) vec4 coord@0x2245060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x2245420)\n" + " (declare (in ) vec3 coord@0x2245540)\n" + " (declare (in ) float lod@0x2245650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x2245a10)\n" + " (declare (in ) vec4 coord@0x2245b30)\n" + " (declare (in ) float lod@0x2245c40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x2246000)\n" + " (declare (in ) vec3 coord@0x2246120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x22464e0)\n" + " (declare (in ) vec3 coord@0x2246600)\n" + " (declare (in ) float lod@0x2246710)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x2246ad0)\n" + " (declare (in ) vec3 coord@0x2246bf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x2246fb0)\n" + " (declare (in ) vec3 coord@0x22470d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x2247490)\n" + " (declare (in ) vec4 coord@0x22475b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x2247970)\n" + " (declare (in ) vec4 coord@0x2247a90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x2247e50)\n" + " (declare (in ) vec3 coord@0x2247f70)\n" + " (declare (in ) float lod@0x2248080)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x2248440)\n" + " (declare (in ) vec3 coord@0x2248560)\n" + " (declare (in ) float lod@0x2248670)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x2248a30)\n" + " (declare (in ) vec4 coord@0x2248b50)\n" + " (declare (in ) float lod@0x2248c60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x2249020)\n" + " (declare (in ) vec4 coord@0x2249140)\n" + " (declare (in ) float lod@0x2249250)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x2249610)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x22499c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x2249ba0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x2249d80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float x@0x2249f60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x224a310)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec3 x@0x224a4f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec4 x@0x224a6d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float x@0x224a8b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec2 x@0x224ac60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x224ae40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec4 x@0x224b020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float x@0x224b200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec2 x@0x224b5b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec3 x@0x224b790)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x224b970)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "\n" + ")" +; +static const char *functions_for_120_vert [] = { + builtin_clamp, + builtin_matrixCompMult, + builtin_shadow2DProjLod, + builtin_noise2, + builtin_texture3DProjLod, + builtin_pow, + builtin_texture2DProj, + builtin_greaterThanEqual, + builtin_sign, + builtin_texture3DProj, + builtin_texture2D, + builtin_equal, + builtin_faceforward, + builtin_tan, + builtin_shadow2DProj, + builtin_shadow1DProjLod, + builtin_any, + builtin_shadow1DProj, + builtin_normalize, + builtin_asin, + builtin_texture1DProj, + builtin_log, + builtin_floor, + builtin_exp2, + builtin_lessThan, + builtin_cross, + builtin_sqrt, + builtin_texture3DLod, + builtin_fract, + builtin_abs, + builtin_degrees, + builtin_shadow1DLod, + builtin_ftransform, + builtin_sin, + builtin_shadow2D, + builtin_shadow2DLod, + builtin_all, + builtin_log2, + builtin_atan, + builtin_notEqual, + builtin_max, + builtin_lessThanEqual, + builtin_transpose, + builtin_outerProduct, + builtin_ceil, + builtin_reflect, + builtin_textureCubeLod, + builtin_step, + builtin_texture1D, + builtin_greaterThan, + builtin_texture3D, + builtin_not, + builtin_texture2DProjLod, + builtin_inversesqrt, + builtin_mod, + builtin_noise4, + builtin_distance, + builtin_cos, + builtin_shadow1D, + builtin_noise1, + builtin_refract, + builtin_noise3, + builtin_texture2DLod, + builtin_min, + builtin_radians, + builtin_smoothstep, + builtin_texture1DProjLod, + builtin_textureCube, + builtin_length, + builtin_texture1DLod, + builtin_exp, + builtin_acos, + builtin_mix, + builtin_dot, +}; +static const char *prototypes_for_EXT_texture_array_frag = + "(\n" + "(function texture1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0xb9bd60)\n" + " (declare (in ) vec2 coord@0xb9be80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0xb9c240)\n" + " (declare (in ) vec2 coord@0xb9c360)\n" + " (declare (in ) float bias@0xb9c470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0xb9c650)\n" + " (declare (in ) vec2 coord@0xb9c770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0xb9cb30)\n" + " (declare (in ) vec2 coord@0xb9cc50)\n" + " (declare (in ) float bias@0xb9cd60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0xb9cf40)\n" + " (declare (in ) vec3 coord@0xb9d060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0xb9d420)\n" + " (declare (in ) vec3 coord@0xb9d540)\n" + " (declare (in ) float bias@0xb9d650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArrayShadow sampler@0xb9d830)\n" + " (declare (in ) vec4 coord@0xb9d950)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "\n" + ")" +; +static const char *functions_for_EXT_texture_array_frag [] = { + builtin_shadow2DArray, + builtin_shadow1DArray, + builtin_texture1DArray, + builtin_texture2DArray, +}; +static const char *prototypes_for_110_vert = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float degrees@0x9e3c50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 degrees@0x9e4020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 degrees@0x9e4210)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 degrees@0x9e4400)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float radians@0x9e45f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 radians@0x9e49c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 radians@0x9e4bb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 radians@0x9e4da0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x9e4f90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x9e5340)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x9e5520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x9e5700)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x9e58e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x9e5c90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x9e5e70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x9e6050)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x9e6230)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x9e65e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x9e67c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x9e69a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x9e6b80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x9e6f30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x9e7110)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x9e72f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x9e74d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x9e7880)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x9e7a60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x9e7c40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y@0x9e7e20)\n" + " (declare (in ) float x@0x9e7f30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y@0x9e82e0)\n" + " (declare (in ) vec2 x@0x9e83f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y@0x9e85d0)\n" + " (declare (in ) vec3 x@0x9e86e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y@0x9e88c0)\n" + " (declare (in ) vec4 x@0x9e89d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y_over_x@0x9e8bb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y_over_x@0x9e8da0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y_over_x@0x9e8f90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y_over_x@0x9e9180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9e9370)\n" + " (declare (in ) float y@0x9e9480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9e9830)\n" + " (declare (in ) vec2 y@0x9e9940)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9e9b20)\n" + " (declare (in ) vec3 y@0x9e9c30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9e9e10)\n" + " (declare (in ) vec4 y@0x9e9f20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9ea100)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9ea4b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9ea690)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9ea870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9eaa50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9eae00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9eafe0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9eb1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9eb3a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9eb750)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9eb930)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9ebb10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9ebcf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9ec0a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9ec280)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9ec460)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9ec640)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9ec9f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9ecbd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9ecdb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9ecf90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9ed350)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9ed530)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9ed710)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9ed8f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9edca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9ede80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9ee060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9ee240)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9ee5f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9ee7d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9ee9b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9eeb90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9eef40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9ef120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9ef300)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9ef4e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9ef890)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9efa70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9efc50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9efe30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f01e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f03c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f05a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9f0780)\n" + " (declare (in ) float y@0x9f0890)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f0c40)\n" + " (declare (in ) float y@0x9f0d50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f0f30)\n" + " (declare (in ) float y@0x9f1040)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f1220)\n" + " (declare (in ) float y@0x9f1330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f1510)\n" + " (declare (in ) vec2 y@0x9f1620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f1800)\n" + " (declare (in ) vec3 y@0x9f1910)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f1af0)\n" + " (declare (in ) vec4 y@0x9f1c00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9f1de0)\n" + " (declare (in ) float y@0x9f1ef0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f22a0)\n" + " (declare (in ) vec2 y@0x9f23b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f2590)\n" + " (declare (in ) vec3 y@0x9f26a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f2880)\n" + " (declare (in ) vec4 y@0x9f2990)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f2b70)\n" + " (declare (in ) float y@0x9f2c80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f2e60)\n" + " (declare (in ) float y@0x9f2f70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f3150)\n" + " (declare (in ) float y@0x9f3260)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9f3440)\n" + " (declare (in ) float y@0x9f3550)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f3900)\n" + " (declare (in ) vec2 y@0x9f3a10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f3bf0)\n" + " (declare (in ) vec3 y@0x9f3d00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f3ee0)\n" + " (declare (in ) vec4 y@0x9f3ff0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f41d0)\n" + " (declare (in ) float y@0x9f42e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f44c0)\n" + " (declare (in ) float y@0x9f45d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f47b0)\n" + " (declare (in ) float y@0x9f48c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9f4aa0)\n" + " (declare (in ) float minVal@0x9f4bb0)\n" + " (declare (in ) float maxVal@0x9f4cc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f5070)\n" + " (declare (in ) vec2 minVal@0x9f5180)\n" + " (declare (in ) vec2 maxVal@0x9f5290)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f5470)\n" + " (declare (in ) vec3 minVal@0x9f5580)\n" + " (declare (in ) vec3 maxVal@0x9f5690)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f5870)\n" + " (declare (in ) vec4 minVal@0x9f5980)\n" + " (declare (in ) vec4 maxVal@0x9f5a90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f5c70)\n" + " (declare (in ) float minVal@0x9f5d80)\n" + " (declare (in ) float maxVal@0x9f5e90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f6070)\n" + " (declare (in ) float minVal@0x9f6180)\n" + " (declare (in ) float maxVal@0x9f6290)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f6470)\n" + " (declare (in ) float minVal@0x9f6580)\n" + " (declare (in ) float maxVal@0x9f6690)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9f6870)\n" + " (declare (in ) float y@0x9f6980)\n" + " (declare (in ) float a@0x9f6a90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f6e40)\n" + " (declare (in ) vec2 y@0x9f6f50)\n" + " (declare (in ) vec2 a@0x9f7060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f7240)\n" + " (declare (in ) vec3 y@0x9f7350)\n" + " (declare (in ) vec3 a@0x9f7460)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f7640)\n" + " (declare (in ) vec4 y@0x9f7750)\n" + " (declare (in ) vec4 a@0x9f7860)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9f7a40)\n" + " (declare (in ) vec2 y@0x9f7b50)\n" + " (declare (in ) float a@0x9f7c60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9f7e40)\n" + " (declare (in ) vec3 y@0x9f7f50)\n" + " (declare (in ) float a@0x9f8060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9f8240)\n" + " (declare (in ) vec4 y@0x9f8350)\n" + " (declare (in ) float a@0x9f8460)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge@0x9f8640)\n" + " (declare (in ) float x@0x9f8750)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge@0x9f8b00)\n" + " (declare (in ) vec2 x@0x9f8c10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge@0x9f8df0)\n" + " (declare (in ) vec3 x@0x9f8f00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge@0x9f90e0)\n" + " (declare (in ) vec4 x@0x9f91f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge@0x9f93d0)\n" + " (declare (in ) vec2 x@0x9f94e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge@0x9f96c0)\n" + " (declare (in ) vec3 x@0x9f97d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge@0x9f99b0)\n" + " (declare (in ) vec4 x@0x9f9ac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge0@0x9f9ca0)\n" + " (declare (in ) float edge1@0x9f9db0)\n" + " (declare (in ) float x@0x9f9ec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge0@0x9fa280)\n" + " (declare (in ) vec2 edge1@0x9fa390)\n" + " (declare (in ) vec2 x@0x9fa4a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge0@0x9fa680)\n" + " (declare (in ) vec3 edge1@0x9fa790)\n" + " (declare (in ) vec3 x@0x9fa8a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge0@0x9faa80)\n" + " (declare (in ) vec4 edge1@0x9fab90)\n" + " (declare (in ) vec4 x@0x9faca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge0@0x9fae80)\n" + " (declare (in ) float edge1@0x9faf90)\n" + " (declare (in ) vec2 x@0x9fb0a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge0@0x9fb280)\n" + " (declare (in ) float edge1@0x9fb390)\n" + " (declare (in ) vec3 x@0x9fb4a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge0@0x9fb680)\n" + " (declare (in ) float edge1@0x9fb790)\n" + " (declare (in ) vec4 x@0x9fb8a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9fba80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9fbe30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9fc010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9fc1f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p0@0x9fc3d0)\n" + " (declare (in ) float p1@0x9fc4e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 p0@0x9fc8a0)\n" + " (declare (in ) vec2 p1@0x9fc9b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 p0@0x9fcb90)\n" + " (declare (in ) vec3 p1@0x9fcca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 p0@0x9fce80)\n" + " (declare (in ) vec4 p1@0x9fcf90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9fd170)\n" + " (declare (in ) float y@0x9fd280)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9fd630)\n" + " (declare (in ) vec2 y@0x9fd740)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9fd920)\n" + " (declare (in ) vec3 y@0x9fda30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9fdc10)\n" + " (declare (in ) vec4 y@0x9fdd20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9fdf00)\n" + " (declare (in ) vec3 y@0x9fe010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x9fe3c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x9fe780)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x9fe960)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x9feb40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function ftransform\n" + " (signature vec4\n" + " (parameters\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float N@0x9fefd0)\n" + " (declare (in ) float I@0x9ff0e0)\n" + " (declare (in ) float Nref@0x9ff1f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 N@0x9ff5b0)\n" + " (declare (in ) vec2 I@0x9ff6c0)\n" + " (declare (in ) vec2 Nref@0x9ff7d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 N@0x9ff9b0)\n" + " (declare (in ) vec3 I@0x9ffac0)\n" + " (declare (in ) vec3 Nref@0x9ffbd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 N@0x9ffdb0)\n" + " (declare (in ) vec4 I@0x9ffec0)\n" + " (declare (in ) vec4 Nref@0x9fffd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0xa001b0)\n" + " (declare (in ) float N@0xa002c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0xa00680)\n" + " (declare (in ) vec2 N@0xa00790)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0xa00970)\n" + " (declare (in ) vec3 N@0xa00a80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0xa00c60)\n" + " (declare (in ) vec4 N@0xa00d70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0xa00f50)\n" + " (declare (in ) float N@0xa01060)\n" + " (declare (in ) float eta@0xa01170)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0xa01530)\n" + " (declare (in ) vec2 N@0xa01640)\n" + " (declare (in ) float eta@0xa01750)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0xa01930)\n" + " (declare (in ) vec3 N@0xa01a40)\n" + " (declare (in ) float eta@0xa01b50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0xa01d30)\n" + " (declare (in ) vec4 N@0xa01e40)\n" + " (declare (in ) float eta@0xa01f50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) mat2 x@0xa02130)\n" + " (declare (in ) mat2 y@0xa02240)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) mat3 x@0xa02600)\n" + " (declare (in ) mat3 y@0xa02710)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) mat4 x@0xa028f0)\n" + " (declare (in ) mat4 y@0xa02a00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0xa02be0)\n" + " (declare (in ) vec2 y@0xa02cf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0xa030b0)\n" + " (declare (in ) vec3 y@0xa031c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0xa033a0)\n" + " (declare (in ) vec4 y@0xa034b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0xa03690)\n" + " (declare (in ) ivec2 y@0xa037a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0xa03980)\n" + " (declare (in ) ivec3 y@0xa03a90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0xa03c70)\n" + " (declare (in ) ivec4 y@0xa03d80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0xa03f60)\n" + " (declare (in ) vec2 y@0xa04070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0xa04430)\n" + " (declare (in ) vec3 y@0xa04540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0xa04720)\n" + " (declare (in ) vec4 y@0xa04830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0xa04a10)\n" + " (declare (in ) ivec2 y@0xa04b20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0xa04d00)\n" + " (declare (in ) ivec3 y@0xa04e10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0xa04ff0)\n" + " (declare (in ) ivec4 y@0xa05100)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0xa052e0)\n" + " (declare (in ) vec2 y@0xa053f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0xa057b0)\n" + " (declare (in ) vec3 y@0xa058c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0xa05aa0)\n" + " (declare (in ) vec4 y@0xa05bb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0xa05d90)\n" + " (declare (in ) ivec2 y@0xa05ea0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0xa06080)\n" + " (declare (in ) ivec3 y@0xa06190)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0xa06370)\n" + " (declare (in ) ivec4 y@0xa06480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0xa06660)\n" + " (declare (in ) vec2 y@0xa06770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0xa06b30)\n" + " (declare (in ) vec3 y@0xa06c40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0xa06e20)\n" + " (declare (in ) vec4 y@0xa06f30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0xa07110)\n" + " (declare (in ) ivec2 y@0xa07220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0xa07400)\n" + " (declare (in ) ivec3 y@0xa07510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0xa076f0)\n" + " (declare (in ) ivec4 y@0xa07800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0xa079e0)\n" + " (declare (in ) vec2 y@0xa07af0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0xa07ea0)\n" + " (declare (in ) vec3 y@0xa07fb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0xa08190)\n" + " (declare (in ) vec4 y@0xa082a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0xa08480)\n" + " (declare (in ) ivec2 y@0xa08590)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0xa08770)\n" + " (declare (in ) ivec3 y@0xa08880)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0xa08a60)\n" + " (declare (in ) ivec4 y@0xa08b70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0xa08d50)\n" + " (declare (in ) bvec2 y@0xa08e60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0xa09040)\n" + " (declare (in ) bvec3 y@0xa09150)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0xa09330)\n" + " (declare (in ) bvec4 y@0xa09440)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0xa09620)\n" + " (declare (in ) vec2 y@0xa09730)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0xa09af0)\n" + " (declare (in ) vec3 y@0xa09c00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0xa09de0)\n" + " (declare (in ) vec4 y@0xa09ef0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0xa0a0d0)\n" + " (declare (in ) ivec2 y@0xa0a1e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0xa0a3c0)\n" + " (declare (in ) ivec3 y@0xa0a4d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0xa0a6b0)\n" + " (declare (in ) ivec4 y@0xa0a7c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0xa0a9a0)\n" + " (declare (in ) bvec2 y@0xa0aab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0xa0ac90)\n" + " (declare (in ) bvec3 y@0xa0ada0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0xa0af80)\n" + " (declare (in ) bvec4 y@0xa0b090)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0xa0b270)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0xa0b620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0xa0b800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0xa0b9e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0xa0bd90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0xa0bf70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0xa0c150)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0xa0c500)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0xa0c6e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0xa0c8c0)\n" + " (declare (in ) float coord@0xa0c9e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0xa0cda0)\n" + " (declare (in ) vec2 coord@0xa0cec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0xa0d280)\n" + " (declare (in ) vec4 coord@0xa0d3a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0xa0d580)\n" + " (declare (in ) float coord@0xa0d6a0)\n" + " (declare (in ) float lod@0xa0d7b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0xa0db70)\n" + " (declare (in ) vec2 coord@0xa0dc90)\n" + " (declare (in ) float lod@0xa0dda0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0xa0e160)\n" + " (declare (in ) vec4 coord@0xa0e280)\n" + " (declare (in ) float lod@0xa0e390)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0xa0e570)\n" + " (declare (in ) vec2 coord@0xa0e690)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0xa0ea50)\n" + " (declare (in ) vec3 coord@0xa0eb70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0xa0ef30)\n" + " (declare (in ) vec4 coord@0xa0f050)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0xa0f230)\n" + " (declare (in ) vec2 coord@0xa0f350)\n" + " (declare (in ) float lod@0xa0f460)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0xa0f820)\n" + " (declare (in ) vec3 coord@0xa0f940)\n" + " (declare (in ) float lod@0xa0fa50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0xa0fe10)\n" + " (declare (in ) vec4 coord@0xa0ff30)\n" + " (declare (in ) float lod@0xa10040)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0xa10220)\n" + " (declare (in ) vec3 coord@0xa10340)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0xa10700)\n" + " (declare (in ) vec4 coord@0xa10820)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0xa10be0)\n" + " (declare (in ) vec3 coord@0xa10d00)\n" + " (declare (in ) float lod@0xa10e10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0xa111d0)\n" + " (declare (in ) vec4 coord@0xa112f0)\n" + " (declare (in ) float lod@0xa11400)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0xa117c0)\n" + " (declare (in ) vec3 coord@0xa118e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0xa11ca0)\n" + " (declare (in ) vec3 coord@0xa11dc0)\n" + " (declare (in ) float lod@0xa11ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0xa12290)\n" + " (declare (in ) vec3 coord@0xa123b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0xa12770)\n" + " (declare (in ) vec3 coord@0xa12890)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0xa12c50)\n" + " (declare (in ) vec4 coord@0xa12d70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0xa13130)\n" + " (declare (in ) vec4 coord@0xa13250)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0xa13610)\n" + " (declare (in ) vec3 coord@0xa13730)\n" + " (declare (in ) float lod@0xa13840)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0xa13c00)\n" + " (declare (in ) vec3 coord@0xa13d20)\n" + " (declare (in ) float lod@0xa13e30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0xa141f0)\n" + " (declare (in ) vec4 coord@0xa14310)\n" + " (declare (in ) float lod@0xa14420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0xa147e0)\n" + " (declare (in ) vec4 coord@0xa14900)\n" + " (declare (in ) float lod@0xa14a10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0xa14dd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0xa15180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0xa15360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0xa15540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float x@0xa15720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0xa15ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec3 x@0xa15cb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec4 x@0xa15e90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float x@0xa16070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec2 x@0xa16420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0xa16600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec4 x@0xa167e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float x@0xa169c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec2 x@0xa16d70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec3 x@0xa16f50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0xa17130)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "\n" + ")" +; +static const char *functions_for_110_vert [] = { + builtin_clamp, + builtin_matrixCompMult, + builtin_shadow2DProjLod, + builtin_noise2, + builtin_texture3DProjLod, + builtin_pow, + builtin_texture2DProj, + builtin_greaterThanEqual, + builtin_sign, + builtin_texture3DProj, + builtin_texture2D, + builtin_equal, + builtin_faceforward, + builtin_tan, + builtin_shadow2DProj, + builtin_shadow1DProjLod, + builtin_any, + builtin_normalize, + builtin_asin, + builtin_texture1DProj, + builtin_log, + builtin_floor, + builtin_exp2, + builtin_lessThan, + builtin_cross, + builtin_sqrt, + builtin_texture3DLod, + builtin_fract, + builtin_abs, + builtin_degrees, + builtin_shadow1DLod, + builtin_ftransform, + builtin_sin, + builtin_shadow2D, + builtin_shadow2DLod, + builtin_all, + builtin_log2, + builtin_atan, + builtin_notEqual, + builtin_max, + builtin_lessThanEqual, + builtin_shadow1DProj, + builtin_ceil, + builtin_reflect, + builtin_textureCubeLod, + builtin_step, + builtin_texture1D, + builtin_greaterThan, + builtin_texture3D, + builtin_not, + builtin_texture2DProjLod, + builtin_inversesqrt, + builtin_mod, + builtin_noise4, + builtin_distance, + builtin_cos, + builtin_shadow1D, + builtin_noise1, + builtin_refract, + builtin_noise3, + builtin_texture2DLod, + builtin_min, + builtin_radians, + builtin_smoothstep, + builtin_texture1DProjLod, + builtin_textureCube, + builtin_length, + builtin_texture1DLod, + builtin_exp, + builtin_acos, + builtin_mix, + builtin_dot, +}; +static const char *prototypes_for_110_frag = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float degrees@0x151ee40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 degrees@0x151f210)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 degrees@0x151f400)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 degrees@0x151f5f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float radians@0x151f7e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 radians@0x151fbb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 radians@0x151fda0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 radians@0x151ff90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x1520180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x1520530)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x1520710)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x15208f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x1520ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x1520e80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x1521060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x1521240)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x1521420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x15217d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x15219b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x1521b90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x1521d70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x1522120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x1522300)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x15224e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x15226c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x1522a70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x1522c50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x1522e30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y@0x1523010)\n" + " (declare (in ) float x@0x1523120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y@0x15234d0)\n" + " (declare (in ) vec2 x@0x15235e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y@0x15237c0)\n" + " (declare (in ) vec3 x@0x15238d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y@0x1523ab0)\n" + " (declare (in ) vec4 x@0x1523bc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y_over_x@0x1523da0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y_over_x@0x1523f90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y_over_x@0x1524180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y_over_x@0x1524370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1524560)\n" + " (declare (in ) float y@0x1524670)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1524a20)\n" + " (declare (in ) vec2 y@0x1524b30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1524d10)\n" + " (declare (in ) vec3 y@0x1524e20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1525000)\n" + " (declare (in ) vec4 y@0x1525110)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x15252f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x15256a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1525880)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1525a60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1525c40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1525ff0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x15261d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x15263b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1526590)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1526940)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1526b20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1526d00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1526ee0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1527290)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1527470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1527650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1527830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1527be0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1527dc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1527fa0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1528180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1528540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1528720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1528900)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1528ae0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1528e90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1529070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1529250)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1529430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x15297e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x15299c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1529ba0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1529d80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x152a130)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x152a310)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x152a4f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x152a6d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x152aa80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x152ac60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x152ae40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x152b020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x152b3d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x152b5b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x152b790)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x152b970)\n" + " (declare (in ) float y@0x152ba80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x152be30)\n" + " (declare (in ) float y@0x152bf40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x152c120)\n" + " (declare (in ) float y@0x152c230)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x152c410)\n" + " (declare (in ) float y@0x152c520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x152c700)\n" + " (declare (in ) vec2 y@0x152c810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x152c9f0)\n" + " (declare (in ) vec3 y@0x152cb00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x152cce0)\n" + " (declare (in ) vec4 y@0x152cdf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x152cfd0)\n" + " (declare (in ) float y@0x152d0e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x152d490)\n" + " (declare (in ) vec2 y@0x152d5a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x152d780)\n" + " (declare (in ) vec3 y@0x152d890)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x152da70)\n" + " (declare (in ) vec4 y@0x152db80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x152dd60)\n" + " (declare (in ) float y@0x152de70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x152e050)\n" + " (declare (in ) float y@0x152e160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x152e340)\n" + " (declare (in ) float y@0x152e450)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x152e630)\n" + " (declare (in ) float y@0x152e740)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x152eaf0)\n" + " (declare (in ) vec2 y@0x152ec00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x152ede0)\n" + " (declare (in ) vec3 y@0x152eef0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x152f0d0)\n" + " (declare (in ) vec4 y@0x152f1e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x152f3c0)\n" + " (declare (in ) float y@0x152f4d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x152f6b0)\n" + " (declare (in ) float y@0x152f7c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x152f9a0)\n" + " (declare (in ) float y@0x152fab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x152fc90)\n" + " (declare (in ) float minVal@0x152fda0)\n" + " (declare (in ) float maxVal@0x152feb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1530260)\n" + " (declare (in ) vec2 minVal@0x1530370)\n" + " (declare (in ) vec2 maxVal@0x1530480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1530660)\n" + " (declare (in ) vec3 minVal@0x1530770)\n" + " (declare (in ) vec3 maxVal@0x1530880)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1530a60)\n" + " (declare (in ) vec4 minVal@0x1530b70)\n" + " (declare (in ) vec4 maxVal@0x1530c80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1530e60)\n" + " (declare (in ) float minVal@0x1530f70)\n" + " (declare (in ) float maxVal@0x1531080)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1531260)\n" + " (declare (in ) float minVal@0x1531370)\n" + " (declare (in ) float maxVal@0x1531480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1531660)\n" + " (declare (in ) float minVal@0x1531770)\n" + " (declare (in ) float maxVal@0x1531880)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1531a60)\n" + " (declare (in ) float y@0x1531b70)\n" + " (declare (in ) float a@0x1531c80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1532030)\n" + " (declare (in ) vec2 y@0x1532140)\n" + " (declare (in ) vec2 a@0x1532250)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1532430)\n" + " (declare (in ) vec3 y@0x1532540)\n" + " (declare (in ) vec3 a@0x1532650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1532830)\n" + " (declare (in ) vec4 y@0x1532940)\n" + " (declare (in ) vec4 a@0x1532a50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1532c30)\n" + " (declare (in ) vec2 y@0x1532d40)\n" + " (declare (in ) float a@0x1532e50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1533030)\n" + " (declare (in ) vec3 y@0x1533140)\n" + " (declare (in ) float a@0x1533250)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1533430)\n" + " (declare (in ) vec4 y@0x1533540)\n" + " (declare (in ) float a@0x1533650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge@0x1533830)\n" + " (declare (in ) float x@0x1533940)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge@0x1533cf0)\n" + " (declare (in ) vec2 x@0x1533e00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge@0x1533fe0)\n" + " (declare (in ) vec3 x@0x15340f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge@0x15342d0)\n" + " (declare (in ) vec4 x@0x15343e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge@0x15345c0)\n" + " (declare (in ) vec2 x@0x15346d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge@0x15348b0)\n" + " (declare (in ) vec3 x@0x15349c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge@0x1534ba0)\n" + " (declare (in ) vec4 x@0x1534cb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge0@0x1534e90)\n" + " (declare (in ) float edge1@0x1534fa0)\n" + " (declare (in ) float x@0x15350b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge0@0x1535470)\n" + " (declare (in ) vec2 edge1@0x1535580)\n" + " (declare (in ) vec2 x@0x1535690)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge0@0x1535870)\n" + " (declare (in ) vec3 edge1@0x1535980)\n" + " (declare (in ) vec3 x@0x1535a90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge0@0x1535c70)\n" + " (declare (in ) vec4 edge1@0x1535d80)\n" + " (declare (in ) vec4 x@0x1535e90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge0@0x1536070)\n" + " (declare (in ) float edge1@0x1536180)\n" + " (declare (in ) vec2 x@0x1536290)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge0@0x1536470)\n" + " (declare (in ) float edge1@0x1536580)\n" + " (declare (in ) vec3 x@0x1536690)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge0@0x1536870)\n" + " (declare (in ) float edge1@0x1536980)\n" + " (declare (in ) vec4 x@0x1536a90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1536c70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1537020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1537200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x15373e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p0@0x15375c0)\n" + " (declare (in ) float p1@0x15376d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 p0@0x1537a90)\n" + " (declare (in ) vec2 p1@0x1537ba0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 p0@0x1537d80)\n" + " (declare (in ) vec3 p1@0x1537e90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 p0@0x1538070)\n" + " (declare (in ) vec4 p1@0x1538180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1538360)\n" + " (declare (in ) float y@0x1538470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1538820)\n" + " (declare (in ) vec2 y@0x1538930)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1538b10)\n" + " (declare (in ) vec3 y@0x1538c20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1538e00)\n" + " (declare (in ) vec4 y@0x1538f10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x15390f0)\n" + " (declare (in ) vec3 y@0x1539200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x15395b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1539970)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1539b50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1539d30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float N@0x1539f10)\n" + " (declare (in ) float I@0x153a020)\n" + " (declare (in ) float Nref@0x153a130)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 N@0x153a4f0)\n" + " (declare (in ) vec2 I@0x153a600)\n" + " (declare (in ) vec2 Nref@0x153a710)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 N@0x153a8f0)\n" + " (declare (in ) vec3 I@0x153aa00)\n" + " (declare (in ) vec3 Nref@0x153ab10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 N@0x153acf0)\n" + " (declare (in ) vec4 I@0x153ae00)\n" + " (declare (in ) vec4 Nref@0x153af10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0x153b0f0)\n" + " (declare (in ) float N@0x153b200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0x153b5c0)\n" + " (declare (in ) vec2 N@0x153b6d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0x153b8b0)\n" + " (declare (in ) vec3 N@0x153b9c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0x153bba0)\n" + " (declare (in ) vec4 N@0x153bcb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0x153be90)\n" + " (declare (in ) float N@0x153bfa0)\n" + " (declare (in ) float eta@0x153c0b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0x153c470)\n" + " (declare (in ) vec2 N@0x153c580)\n" + " (declare (in ) float eta@0x153c690)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0x153c870)\n" + " (declare (in ) vec3 N@0x153c980)\n" + " (declare (in ) float eta@0x153ca90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0x153cc70)\n" + " (declare (in ) vec4 N@0x153cd80)\n" + " (declare (in ) float eta@0x153ce90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) mat2 x@0x153d070)\n" + " (declare (in ) mat2 y@0x153d180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) mat3 x@0x153d540)\n" + " (declare (in ) mat3 y@0x153d650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) mat4 x@0x153d830)\n" + " (declare (in ) mat4 y@0x153d940)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x153db20)\n" + " (declare (in ) vec2 y@0x153dc30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x153dff0)\n" + " (declare (in ) vec3 y@0x153e100)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x153e2e0)\n" + " (declare (in ) vec4 y@0x153e3f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x153e5d0)\n" + " (declare (in ) ivec2 y@0x153e6e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x153e8c0)\n" + " (declare (in ) ivec3 y@0x153e9d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x153ebb0)\n" + " (declare (in ) ivec4 y@0x153ecc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x153eea0)\n" + " (declare (in ) vec2 y@0x153efb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x153f370)\n" + " (declare (in ) vec3 y@0x153f480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x153f660)\n" + " (declare (in ) vec4 y@0x153f770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x153f950)\n" + " (declare (in ) ivec2 y@0x153fa60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x153fc40)\n" + " (declare (in ) ivec3 y@0x153fd50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x153ff30)\n" + " (declare (in ) ivec4 y@0x1540040)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1540220)\n" + " (declare (in ) vec2 y@0x1540330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x15406f0)\n" + " (declare (in ) vec3 y@0x1540800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x15409e0)\n" + " (declare (in ) vec4 y@0x1540af0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x1540cd0)\n" + " (declare (in ) ivec2 y@0x1540de0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x1540fc0)\n" + " (declare (in ) ivec3 y@0x15410d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x15412b0)\n" + " (declare (in ) ivec4 y@0x15413c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x15415a0)\n" + " (declare (in ) vec2 y@0x15416b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1541a70)\n" + " (declare (in ) vec3 y@0x1541b80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1541d60)\n" + " (declare (in ) vec4 y@0x1541e70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x1542050)\n" + " (declare (in ) ivec2 y@0x1542160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x1542340)\n" + " (declare (in ) ivec3 y@0x1542450)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x1542630)\n" + " (declare (in ) ivec4 y@0x1542740)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1542920)\n" + " (declare (in ) vec2 y@0x1542a30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1542de0)\n" + " (declare (in ) vec3 y@0x1542ef0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x15430d0)\n" + " (declare (in ) vec4 y@0x15431e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x15433c0)\n" + " (declare (in ) ivec2 y@0x15434d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x15436b0)\n" + " (declare (in ) ivec3 y@0x15437c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x15439a0)\n" + " (declare (in ) ivec4 y@0x1543ab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x1543c90)\n" + " (declare (in ) bvec2 y@0x1543da0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x1543f80)\n" + " (declare (in ) bvec3 y@0x1544090)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x1544270)\n" + " (declare (in ) bvec4 y@0x1544380)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1544560)\n" + " (declare (in ) vec2 y@0x1544670)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1544a30)\n" + " (declare (in ) vec3 y@0x1544b40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1544d20)\n" + " (declare (in ) vec4 y@0x1544e30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x1545010)\n" + " (declare (in ) ivec2 y@0x1545120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x1545300)\n" + " (declare (in ) ivec3 y@0x1545410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x15455f0)\n" + " (declare (in ) ivec4 y@0x1545700)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x15458e0)\n" + " (declare (in ) bvec2 y@0x15459f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x1545bd0)\n" + " (declare (in ) bvec3 y@0x1545ce0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x1545ec0)\n" + " (declare (in ) bvec4 y@0x1545fd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x15461b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x1546560)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x1546740)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x1546920)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x1546cd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x1546eb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x1547090)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x1547440)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x1547620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1547800)\n" + " (declare (in ) float coord@0x1547920)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x15484c0)\n" + " (declare (in ) float coord@0x15485e0)\n" + " (declare (in ) float bias@0x15486f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1547ce0)\n" + " (declare (in ) vec2 coord@0x1547e00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x15481c0)\n" + " (declare (in ) vec4 coord@0x15482e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x15488d0)\n" + " (declare (in ) vec2 coord@0x15489f0)\n" + " (declare (in ) float bias@0x1548b00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1548ce0)\n" + " (declare (in ) vec4 coord@0x1548e00)\n" + " (declare (in ) float bias@0x1548f10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x15490f0)\n" + " (declare (in ) vec2 coord@0x1549210)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1549db0)\n" + " (declare (in ) vec2 coord@0x1549ed0)\n" + " (declare (in ) float bias@0x1549fe0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x15495d0)\n" + " (declare (in ) vec3 coord@0x15496f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1549ab0)\n" + " (declare (in ) vec4 coord@0x1549bd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x154a1c0)\n" + " (declare (in ) vec3 coord@0x154a2e0)\n" + " (declare (in ) float bias@0x154a3f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x154a5d0)\n" + " (declare (in ) vec4 coord@0x154a6f0)\n" + " (declare (in ) float bias@0x154a800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x154a9e0)\n" + " (declare (in ) vec3 coord@0x154ab00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x154b3a0)\n" + " (declare (in ) vec3 coord@0x154b4c0)\n" + " (declare (in ) float bias@0x154b5d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x154aec0)\n" + " (declare (in ) vec4 coord@0x154afe0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x154b7b0)\n" + " (declare (in ) vec4 coord@0x154b8d0)\n" + " (declare (in ) float bias@0x154b9e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x154bbc0)\n" + " (declare (in ) vec3 coord@0x154bce0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x154c0a0)\n" + " (declare (in ) vec3 coord@0x154c1c0)\n" + " (declare (in ) float bias@0x154c2d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x154c4b0)\n" + " (declare (in ) vec3 coord@0x154c5d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x154d830)\n" + " (declare (in ) vec3 coord@0x154d950)\n" + " (declare (in ) float bias@0x154da60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x154c990)\n" + " (declare (in ) vec3 coord@0x154cab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x154dc40)\n" + " (declare (in ) vec3 coord@0x154dd60)\n" + " (declare (in ) float bias@0x154de70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x154ce70)\n" + " (declare (in ) vec4 coord@0x154cf90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x154e050)\n" + " (declare (in ) vec4 coord@0x154e170)\n" + " (declare (in ) float bias@0x154e280)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x154d350)\n" + " (declare (in ) vec4 coord@0x154d470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x154e460)\n" + " (declare (in ) vec4 coord@0x154e580)\n" + " (declare (in ) float bias@0x154e690)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dFdx\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p@0x154e870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 p@0x154ec20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 p@0x154ee00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 p@0x154efe0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dFdy\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p@0x154f1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 p@0x154f570)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 p@0x154f750)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 p@0x154f930)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function fwidth\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p@0x154fb10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 p@0x154fec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 p@0x15500a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 p@0x1550280)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1550460)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1550810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x15509f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1550bd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float x@0x1550db0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1551160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1551340)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1551520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float x@0x1551700)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1551ab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1551c90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1551e70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float x@0x1552050)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1552400)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec3 x@0x15525e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x15527c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "\n" + ")" +; +static const char *functions_for_110_frag [] = { + builtin_clamp, + builtin_matrixCompMult, + builtin_noise2, + builtin_pow, + builtin_texture2DProj, + builtin_fwidth, + builtin_greaterThanEqual, + builtin_sign, + builtin_texture3DProj, + builtin_texture2D, + builtin_equal, + builtin_faceforward, + builtin_tan, + builtin_any, + builtin_normalize, + builtin_asin, + builtin_texture1DProj, + builtin_log, + builtin_floor, + builtin_exp2, + builtin_lessThan, + builtin_cross, + builtin_sqrt, + builtin_shadow2DProj, + builtin_fract, + builtin_abs, + builtin_degrees, + builtin_dFdx, + builtin_sin, + builtin_shadow2D, + builtin_all, + builtin_log2, + builtin_atan, + builtin_notEqual, + builtin_max, + builtin_lessThanEqual, + builtin_shadow1DProj, + builtin_ceil, + builtin_reflect, + builtin_step, + builtin_texture1D, + builtin_greaterThan, + builtin_texture3D, + builtin_not, + builtin_inversesqrt, + builtin_mod, + builtin_noise4, + builtin_distance, + builtin_cos, + builtin_shadow1D, + builtin_noise1, + builtin_refract, + builtin_noise3, + builtin_min, + builtin_radians, + builtin_smoothstep, + builtin_textureCube, + builtin_length, + builtin_dFdy, + builtin_exp, + builtin_acos, + builtin_mix, + builtin_dot, +}; +static const char *prototypes_for_EXT_texture_array_vert = + "(\n" + "(function texture1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x25ee5c0)\n" + " (declare (in ) vec2 coord@0x25ee6e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x25eeaa0)\n" + " (declare (in ) vec2 coord@0x25eebc0)\n" + " (declare (in ) float lod@0x25eecd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x25ef090)\n" + " (declare (in ) vec2 coord@0x25ef1b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x25ef570)\n" + " (declare (in ) vec2 coord@0x25ef690)\n" + " (declare (in ) float lod@0x25ef7a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0x25efb60)\n" + " (declare (in ) vec3 coord@0x25efc80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0x25f0040)\n" + " (declare (in ) vec3 coord@0x25f0160)\n" + " (declare (in ) float lod@0x25f0270)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArrayShadow sampler@0x25f0630)\n" + " (declare (in ) vec4 coord@0x25f0750)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "\n" + ")" +; +static const char *functions_for_EXT_texture_array_vert [] = { + builtin_texture1DArrayLod, + builtin_shadow2DArray, + builtin_texture2DArrayLod, + builtin_shadow1DArrayLod, + builtin_shadow1DArray, + builtin_texture2DArray, + builtin_texture1DArray, +}; +static const char *prototypes_for_ARB_texture_rectangle_vert = + "(\n" + "(function texture2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRect sampler@0x1cc28a0)\n" + " (declare (in ) vec2 coord@0x1cc29c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRect sampler@0x1cc2d80)\n" + " (declare (in ) vec3 coord@0x1cc2ea0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRect sampler@0x1cc3260)\n" + " (declare (in ) vec4 coord@0x1cc3380)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRectShadow sampler@0x1cc3560)\n" + " (declare (in ) vec3 coord@0x1cc3680)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRectShadow sampler@0x1cc3a40)\n" + " (declare (in ) vec4 coord@0x1cc3b60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "\n" + ")" +; +static const char *functions_for_ARB_texture_rectangle_vert [] = { + builtin_texture2DRect, + builtin_shadow2DRectProj, + builtin_shadow2DRect, + builtin_texture2DRectProj, +}; +static const char *prototypes_for_ARB_texture_rectangle_frag = + "(\n" + "(function texture2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRect sampler@0x13d0040)\n" + " (declare (in ) vec2 coord@0x13d0160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRect sampler@0x13d0520)\n" + " (declare (in ) vec3 coord@0x13d0640)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRect sampler@0x13d0a00)\n" + " (declare (in ) vec4 coord@0x13d0b20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRectShadow sampler@0x13d0d00)\n" + " (declare (in ) vec3 coord@0x13d0e20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRectShadow sampler@0x13d11e0)\n" + " (declare (in ) vec4 coord@0x13d1300)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "\n" + ")" +; +static const char *functions_for_ARB_texture_rectangle_frag [] = { + builtin_texture2DRect, + builtin_shadow2DRectProj, + builtin_shadow2DRect, + builtin_texture2DRectProj, +}; +static const char *prototypes_for_120_frag = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float degrees@0x8b57e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 degrees@0x8b5bb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 degrees@0x8b5da0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 degrees@0x8b5f90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float radians@0x8b6180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 radians@0x8b6550)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 radians@0x8b6740)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 radians@0x8b6930)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x8b6b20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x8b6ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x8b70b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x8b7290)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x8b7470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x8b7820)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x8b7a00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x8b7be0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x8b7dc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x8b8170)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x8b8350)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x8b8530)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x8b8710)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x8b8ac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x8b8ca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x8b8e80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x8b9060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x8b9410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x8b95f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x8b97d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y@0x8b99b0)\n" + " (declare (in ) float x@0x8b9ac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y@0x8b9e70)\n" + " (declare (in ) vec2 x@0x8b9f80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y@0x8ba160)\n" + " (declare (in ) vec3 x@0x8ba270)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y@0x8ba450)\n" + " (declare (in ) vec4 x@0x8ba560)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y_over_x@0x8ba740)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y_over_x@0x8ba930)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y_over_x@0x8bab20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y_over_x@0x8bad10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8baf00)\n" + " (declare (in ) float y@0x8bb010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8bb3c0)\n" + " (declare (in ) vec2 y@0x8bb4d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8bb6b0)\n" + " (declare (in ) vec3 y@0x8bb7c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8bb9a0)\n" + " (declare (in ) vec4 y@0x8bbab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8bbc90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8bc040)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8bc220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8bc400)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8bc5e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8bc990)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8bcb70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8bcd50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8bcf30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8bd2e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8bd4c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8bd6a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8bd880)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8bdc30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8bde10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8bdff0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8be1d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8be580)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8be760)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8be940)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8beb20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8beee0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8bf0c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8bf2a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8bf480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8bf830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8bfa10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8bfbf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8bfdd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c0180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c0360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c0540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8c0720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c0ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c0cb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c0e90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8c1070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c1420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c1600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c17e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8c19c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c1d70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c1f50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c2130)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8c2310)\n" + " (declare (in ) float y@0x8c2420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c27d0)\n" + " (declare (in ) float y@0x8c28e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c2ac0)\n" + " (declare (in ) float y@0x8c2bd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c2db0)\n" + " (declare (in ) float y@0x8c2ec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c30a0)\n" + " (declare (in ) vec2 y@0x8c31b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c3390)\n" + " (declare (in ) vec3 y@0x8c34a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c3680)\n" + " (declare (in ) vec4 y@0x8c3790)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8c3970)\n" + " (declare (in ) float y@0x8c3a80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c3e30)\n" + " (declare (in ) vec2 y@0x8c3f40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c4120)\n" + " (declare (in ) vec3 y@0x8c4230)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c4410)\n" + " (declare (in ) vec4 y@0x8c4520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c4700)\n" + " (declare (in ) float y@0x8c4810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c49f0)\n" + " (declare (in ) float y@0x8c4b00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c4ce0)\n" + " (declare (in ) float y@0x8c4df0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8c4fd0)\n" + " (declare (in ) float y@0x8c50e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c5490)\n" + " (declare (in ) vec2 y@0x8c55a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c5780)\n" + " (declare (in ) vec3 y@0x8c5890)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c5a70)\n" + " (declare (in ) vec4 y@0x8c5b80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c5d60)\n" + " (declare (in ) float y@0x8c5e70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c6050)\n" + " (declare (in ) float y@0x8c6160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c6340)\n" + " (declare (in ) float y@0x8c6450)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8c6630)\n" + " (declare (in ) float minVal@0x8c6740)\n" + " (declare (in ) float maxVal@0x8c6850)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c6c00)\n" + " (declare (in ) vec2 minVal@0x8c6d10)\n" + " (declare (in ) vec2 maxVal@0x8c6e20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c7000)\n" + " (declare (in ) vec3 minVal@0x8c7110)\n" + " (declare (in ) vec3 maxVal@0x8c7220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c7400)\n" + " (declare (in ) vec4 minVal@0x8c7510)\n" + " (declare (in ) vec4 maxVal@0x8c7620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c7800)\n" + " (declare (in ) float minVal@0x8c7910)\n" + " (declare (in ) float maxVal@0x8c7a20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c7c00)\n" + " (declare (in ) float minVal@0x8c7d10)\n" + " (declare (in ) float maxVal@0x8c7e20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c8000)\n" + " (declare (in ) float minVal@0x8c8110)\n" + " (declare (in ) float maxVal@0x8c8220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8c8400)\n" + " (declare (in ) float y@0x8c8510)\n" + " (declare (in ) float a@0x8c8620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c89d0)\n" + " (declare (in ) vec2 y@0x8c8ae0)\n" + " (declare (in ) vec2 a@0x8c8bf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c8dd0)\n" + " (declare (in ) vec3 y@0x8c8ee0)\n" + " (declare (in ) vec3 a@0x8c8ff0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c91d0)\n" + " (declare (in ) vec4 y@0x8c92e0)\n" + " (declare (in ) vec4 a@0x8c93f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8c95d0)\n" + " (declare (in ) vec2 y@0x8c96e0)\n" + " (declare (in ) float a@0x8c97f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8c99d0)\n" + " (declare (in ) vec3 y@0x8c9ae0)\n" + " (declare (in ) float a@0x8c9bf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8c9dd0)\n" + " (declare (in ) vec4 y@0x8c9ee0)\n" + " (declare (in ) float a@0x8c9ff0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge@0x8ca1d0)\n" + " (declare (in ) float x@0x8ca2e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge@0x8ca690)\n" + " (declare (in ) vec2 x@0x8ca7a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge@0x8ca980)\n" + " (declare (in ) vec3 x@0x8caa90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge@0x8cac70)\n" + " (declare (in ) vec4 x@0x8cad80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge@0x8caf60)\n" + " (declare (in ) vec2 x@0x8cb070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge@0x8cb250)\n" + " (declare (in ) vec3 x@0x8cb360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge@0x8cb540)\n" + " (declare (in ) vec4 x@0x8cb650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge0@0x8cb830)\n" + " (declare (in ) float edge1@0x8cb940)\n" + " (declare (in ) float x@0x8cba50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge0@0x8cbe10)\n" + " (declare (in ) vec2 edge1@0x8cbf20)\n" + " (declare (in ) vec2 x@0x8cc030)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge0@0x8cc210)\n" + " (declare (in ) vec3 edge1@0x8cc320)\n" + " (declare (in ) vec3 x@0x8cc430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge0@0x8cc610)\n" + " (declare (in ) vec4 edge1@0x8cc720)\n" + " (declare (in ) vec4 x@0x8cc830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge0@0x8cca10)\n" + " (declare (in ) float edge1@0x8ccb20)\n" + " (declare (in ) vec2 x@0x8ccc30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge0@0x8cce10)\n" + " (declare (in ) float edge1@0x8ccf20)\n" + " (declare (in ) vec3 x@0x8cd030)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge0@0x8cd210)\n" + " (declare (in ) float edge1@0x8cd320)\n" + " (declare (in ) vec4 x@0x8cd430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8cd610)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8cd9c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8cdba0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8cdd80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p0@0x8cdf60)\n" + " (declare (in ) float p1@0x8ce070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 p0@0x8ce430)\n" + " (declare (in ) vec2 p1@0x8ce540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 p0@0x8ce720)\n" + " (declare (in ) vec3 p1@0x8ce830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 p0@0x8cea10)\n" + " (declare (in ) vec4 p1@0x8ceb20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8ced00)\n" + " (declare (in ) float y@0x8cee10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8cf1c0)\n" + " (declare (in ) vec2 y@0x8cf2d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8cf4b0)\n" + " (declare (in ) vec3 y@0x8cf5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8cf7a0)\n" + " (declare (in ) vec4 y@0x8cf8b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8cfa90)\n" + " (declare (in ) vec3 y@0x8cfba0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8cff50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8d0310)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8d04f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8d06d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float N@0x8d08b0)\n" + " (declare (in ) float I@0x8d09c0)\n" + " (declare (in ) float Nref@0x8d0ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 N@0x8d0e90)\n" + " (declare (in ) vec2 I@0x8d0fa0)\n" + " (declare (in ) vec2 Nref@0x8d10b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 N@0x8d1290)\n" + " (declare (in ) vec3 I@0x8d13a0)\n" + " (declare (in ) vec3 Nref@0x8d14b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 N@0x8d1690)\n" + " (declare (in ) vec4 I@0x8d17a0)\n" + " (declare (in ) vec4 Nref@0x8d18b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0x8d1a90)\n" + " (declare (in ) float N@0x8d1ba0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0x8d1f60)\n" + " (declare (in ) vec2 N@0x8d2070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0x8d2250)\n" + " (declare (in ) vec3 N@0x8d2360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0x8d2540)\n" + " (declare (in ) vec4 N@0x8d2650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0x8d2830)\n" + " (declare (in ) float N@0x8d2940)\n" + " (declare (in ) float eta@0x8d2a50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0x8d2e10)\n" + " (declare (in ) vec2 N@0x8d2f20)\n" + " (declare (in ) float eta@0x8d3030)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0x8d3210)\n" + " (declare (in ) vec3 N@0x8d3320)\n" + " (declare (in ) float eta@0x8d3430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0x8d3610)\n" + " (declare (in ) vec4 N@0x8d3720)\n" + " (declare (in ) float eta@0x8d3830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) mat2 x@0x8d3a10)\n" + " (declare (in ) mat2 y@0x8d3b20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) mat3 x@0x8d3ee0)\n" + " (declare (in ) mat3 y@0x8d3ff0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) mat4 x@0x8d41d0)\n" + " (declare (in ) mat4 y@0x8d42e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) mat2x3 x@0x8d44c0)\n" + " (declare (in ) mat2x3 y@0x8d45d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) mat2x4 x@0x8d47b0)\n" + " (declare (in ) mat2x4 y@0x8d48c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) mat3x2 x@0x8d4aa0)\n" + " (declare (in ) mat3x2 y@0x8d4bb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) mat3x4 x@0x8d4d90)\n" + " (declare (in ) mat3x4 y@0x8d4ea0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) mat4x2 x@0x8d5080)\n" + " (declare (in ) mat4x2 y@0x8d5190)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) mat4x3 x@0x8d5370)\n" + " (declare (in ) mat4x3 y@0x8d5480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function outerProduct\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x8d5660)\n" + " (declare (in ) vec2 r@0x8d5770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x8d5b30)\n" + " (declare (in ) vec3 r@0x8d5c40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x8d5e20)\n" + " (declare (in ) vec4 r@0x8d5f30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x8d6110)\n" + " (declare (in ) vec2 r@0x8d6220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x8d6400)\n" + " (declare (in ) vec3 r@0x8d6510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x8d66f0)\n" + " (declare (in ) vec2 r@0x8d6800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x8d69e0)\n" + " (declare (in ) vec4 r@0x8d6af0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x8d6cd0)\n" + " (declare (in ) vec3 r@0x8d6de0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x8d6fc0)\n" + " (declare (in ) vec4 r@0x8d70d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function transpose\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) mat2 m@0x8d72b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) mat3 m@0x8d7670)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) mat4 m@0x8d7850)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) mat3x2 m@0x8d7a30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) mat2x3 m@0x8d7c10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) mat4x2 m@0x8d7df0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) mat2x4 m@0x8d7fd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) mat4x3 m@0x8d81b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) mat3x4 m@0x8d8390)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8d8570)\n" + " (declare (in ) vec2 y@0x8d8680)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8d8a40)\n" + " (declare (in ) vec3 y@0x8d8b50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8d8d30)\n" + " (declare (in ) vec4 y@0x8d8e40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x8d9020)\n" + " (declare (in ) ivec2 y@0x8d9130)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x8d9310)\n" + " (declare (in ) ivec3 y@0x8d9420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x8d9600)\n" + " (declare (in ) ivec4 y@0x8d9710)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8d98f0)\n" + " (declare (in ) vec2 y@0x8d9a00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8d9dc0)\n" + " (declare (in ) vec3 y@0x8d9ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8da0b0)\n" + " (declare (in ) vec4 y@0x8da1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x8da3a0)\n" + " (declare (in ) ivec2 y@0x8da4b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x8da690)\n" + " (declare (in ) ivec3 y@0x8da7a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x8da980)\n" + " (declare (in ) ivec4 y@0x8daa90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8dac70)\n" + " (declare (in ) vec2 y@0x8dad80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8db140)\n" + " (declare (in ) vec3 y@0x8db250)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8db430)\n" + " (declare (in ) vec4 y@0x8db540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x8db720)\n" + " (declare (in ) ivec2 y@0x8db830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x8dba10)\n" + " (declare (in ) ivec3 y@0x8dbb20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x8dbd00)\n" + " (declare (in ) ivec4 y@0x8dbe10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8dbff0)\n" + " (declare (in ) vec2 y@0x8dc100)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8dc4c0)\n" + " (declare (in ) vec3 y@0x8dc5d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8dc7b0)\n" + " (declare (in ) vec4 y@0x8dc8c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x8dcaa0)\n" + " (declare (in ) ivec2 y@0x8dcbb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x8dcd90)\n" + " (declare (in ) ivec3 y@0x8dcea0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x8dd080)\n" + " (declare (in ) ivec4 y@0x8dd190)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8dd370)\n" + " (declare (in ) vec2 y@0x8dd480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8dd830)\n" + " (declare (in ) vec3 y@0x8dd940)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8ddb20)\n" + " (declare (in ) vec4 y@0x8ddc30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x8dde10)\n" + " (declare (in ) ivec2 y@0x8ddf20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x8de100)\n" + " (declare (in ) ivec3 y@0x8de210)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x8de3f0)\n" + " (declare (in ) ivec4 y@0x8de500)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x8de6e0)\n" + " (declare (in ) bvec2 y@0x8de7f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x8de9d0)\n" + " (declare (in ) bvec3 y@0x8deae0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x8decc0)\n" + " (declare (in ) bvec4 y@0x8dedd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8defb0)\n" + " (declare (in ) vec2 y@0x8df0c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8df480)\n" + " (declare (in ) vec3 y@0x8df590)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8df770)\n" + " (declare (in ) vec4 y@0x8df880)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x8dfa60)\n" + " (declare (in ) ivec2 y@0x8dfb70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x8dfd50)\n" + " (declare (in ) ivec3 y@0x8dfe60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x8e0040)\n" + " (declare (in ) ivec4 y@0x8e0150)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x8e0330)\n" + " (declare (in ) bvec2 y@0x8e0440)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x8e0620)\n" + " (declare (in ) bvec3 y@0x8e0730)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x8e0910)\n" + " (declare (in ) bvec4 y@0x8e0a20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x8e0c00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x8e0fb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x8e1190)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x8e1370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x8e1720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x8e1900)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x8e1ae0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x8e1e90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x8e2070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x8e2250)\n" + " (declare (in ) float coord@0x8e2370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x8e2f10)\n" + " (declare (in ) float coord@0x8e3030)\n" + " (declare (in ) float bias@0x8e3140)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x8e2730)\n" + " (declare (in ) vec2 coord@0x8e2850)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x8e2c10)\n" + " (declare (in ) vec4 coord@0x8e2d30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x8e3320)\n" + " (declare (in ) vec2 coord@0x8e3440)\n" + " (declare (in ) float bias@0x8e3550)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x8e3730)\n" + " (declare (in ) vec4 coord@0x8e3850)\n" + " (declare (in ) float bias@0x8e3960)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x8e3b40)\n" + " (declare (in ) vec2 coord@0x8e3c60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x8e4800)\n" + " (declare (in ) vec2 coord@0x8e4920)\n" + " (declare (in ) float bias@0x8e4a30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x8e4020)\n" + " (declare (in ) vec3 coord@0x8e4140)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x8e4500)\n" + " (declare (in ) vec4 coord@0x8e4620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x8e4c10)\n" + " (declare (in ) vec3 coord@0x8e4d30)\n" + " (declare (in ) float bias@0x8e4e40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x8e5020)\n" + " (declare (in ) vec4 coord@0x8e5140)\n" + " (declare (in ) float bias@0x8e5250)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x8e5430)\n" + " (declare (in ) vec3 coord@0x8e5550)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x8e5df0)\n" + " (declare (in ) vec3 coord@0x8e5f10)\n" + " (declare (in ) float bias@0x8e6020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x8e5910)\n" + " (declare (in ) vec4 coord@0x8e5a30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x8e6200)\n" + " (declare (in ) vec4 coord@0x8e6320)\n" + " (declare (in ) float bias@0x8e6430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x8e6610)\n" + " (declare (in ) vec3 coord@0x8e6730)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x8e6af0)\n" + " (declare (in ) vec3 coord@0x8e6c10)\n" + " (declare (in ) float bias@0x8e6d20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x8e6f00)\n" + " (declare (in ) vec3 coord@0x8e7020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x8e8280)\n" + " (declare (in ) vec3 coord@0x8e83a0)\n" + " (declare (in ) float bias@0x8e84b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x8e73e0)\n" + " (declare (in ) vec3 coord@0x8e7500)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x8e8690)\n" + " (declare (in ) vec3 coord@0x8e87b0)\n" + " (declare (in ) float bias@0x8e88c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x8e78c0)\n" + " (declare (in ) vec4 coord@0x8e79e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x8e8aa0)\n" + " (declare (in ) vec4 coord@0x8e8bc0)\n" + " (declare (in ) float bias@0x8e8cd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x8e7da0)\n" + " (declare (in ) vec4 coord@0x8e7ec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x8e8eb0)\n" + " (declare (in ) vec4 coord@0x8e8fd0)\n" + " (declare (in ) float bias@0x8e90e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dFdx\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p@0x8e92c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 p@0x8e9670)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 p@0x8e9850)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 p@0x8e9a30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dFdy\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p@0x8e9c10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 p@0x8e9fc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 p@0x8ea1a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 p@0x8ea380)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function fwidth\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p@0x8ea560)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 p@0x8ea910)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler1D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 p@0x8eaaf0)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 p@0x8eacd0)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + ")\n" "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "(function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x8eaeb0)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8eb260)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8eb440)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler2D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8eb620)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + ")\n" "\n" - " (signature ivec4\n" - " (parameters\n" - " (declare (in) isampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "(function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float x@0x8eb800)\n" + " )\n" + " (\n" + " ))\n" "\n" - " (signature uvec4\n" - " (parameters\n" - " (declare (in) usampler3D sampler)\n" - " (declare (in) vec4 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8ebbb0)\n" + " )\n" + " (\n" + " ))\n" "\n" - "))\n" -}; - -static const char *functions_for_130_fs [] = { - builtins_130_fs_texture, - builtins_130_fs_textureProj, -}; - -/* ARB_texture_rectangle builtins */ - -static const char *builtins_ARB_texture_rectangle_textures = { - "((function texture2DRect\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DRect sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8ebd90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8ebf70)\n" + " )\n" + " (\n" + " ))\n" "\n" ")\n" - " (function shadow2DRect\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DRectShadow sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" "\n" - "))\n" -}; - -static const char *functions_for_ARB_texture_rectangle [] = { - builtins_ARB_texture_rectangle_textures, -}; - -/* EXT_texture_array builtins */ - -static const char *builtins_EXT_texture_array_textures = { - "((function texture1DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + "(function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float x@0x8ec150)\n" + " )\n" + " (\n" + " ))\n" "\n" - ")\n" - " (function texture1DArrayLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8ec500)\n" + " )\n" + " (\n" + " ))\n" "\n" - ")\n" - " (function texture2DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8ec6e0)\n" + " )\n" + " (\n" + " ))\n" "\n" - ")\n" - " (function texture2DArrayLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8ec8c0)\n" + " )\n" + " (\n" + " ))\n" "\n" ")\n" - " (function shadow1DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArrayShadow sampler)\n" - " (declare (in) vec3 P) )\n" - " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n" "\n" - ")\n" - " (function shadow1DArrayLod\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArrayShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float lod) )\n" - " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "(function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float x@0x8ecaa0)\n" + " )\n" + " (\n" + " ))\n" "\n" - ")\n" - " (function shadow2DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArrayShadow sampler)\n" - " (declare (in) vec4 P) )\n" - " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) 1 (swiz w (var_ref P)) ))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec2 x@0x8ece50)\n" + " )\n" + " (\n" + " ))\n" "\n" - "))\n" -}; - -static const char *functions_for_EXT_texture_array [] = { - builtins_EXT_texture_array_textures, -}; - -/* EXT_texture_array_fs builtins */ - -static const char *builtins_EXT_texture_array_fs_textures = { - "((function texture1DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArray sampler)\n" - " (declare (in) vec2 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec3 x@0x8ed030)\n" + " )\n" + " (\n" + " ))\n" "\n" - ")\n" - " (function texture2DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler2DArray sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x8ed210)\n" + " )\n" + " (\n" + " ))\n" "\n" ")\n" - " (function shadow1DArray\n" - " (signature vec4\n" - " (parameters\n" - " (declare (in) sampler1DArrayShadow sampler)\n" - " (declare (in) vec3 P) \n" - " (declare (in) float bias) )\n" - " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" "\n" - "))\n" -}; - -static const char *functions_for_EXT_texture_array_fs [] = { - builtins_EXT_texture_array_fs_textures, + "\n" + ")" +; +static const char *functions_for_120_frag [] = { + builtin_clamp, + builtin_matrixCompMult, + builtin_noise2, + builtin_pow, + builtin_texture2DProj, + builtin_fwidth, + builtin_greaterThanEqual, + builtin_sign, + builtin_texture3DProj, + builtin_texture2D, + builtin_equal, + builtin_faceforward, + builtin_tan, + builtin_any, + builtin_shadow1DProj, + builtin_normalize, + builtin_asin, + builtin_texture1DProj, + builtin_log, + builtin_floor, + builtin_exp2, + builtin_lessThan, + builtin_cross, + builtin_sqrt, + builtin_shadow2DProj, + builtin_fract, + builtin_abs, + builtin_degrees, + builtin_dFdx, + builtin_sin, + builtin_shadow2D, + builtin_all, + builtin_log2, + builtin_atan, + builtin_notEqual, + builtin_max, + builtin_lessThanEqual, + builtin_transpose, + builtin_outerProduct, + builtin_ceil, + builtin_reflect, + builtin_step, + builtin_texture1D, + builtin_greaterThan, + builtin_texture3D, + builtin_not, + builtin_inversesqrt, + builtin_mod, + builtin_noise4, + builtin_distance, + builtin_cos, + builtin_shadow1D, + builtin_noise1, + builtin_refract, + builtin_noise3, + builtin_min, + builtin_radians, + builtin_smoothstep, + builtin_textureCube, + builtin_length, + builtin_dFdy, + builtin_exp, + builtin_acos, + builtin_mix, + builtin_dot, }; void *builtin_mem_ctx = NULL; @@ -4810,134 +14684,137 @@ _mesa_glsl_release_functions(void) void _mesa_glsl_initialize_functions(exec_list *instructions, - struct _mesa_glsl_parse_state *state) + struct _mesa_glsl_parse_state *state) { if (builtin_mem_ctx == NULL) builtin_mem_ctx = talloc_init("GLSL built-in functions"); state->num_builtins_to_link = 0; - if (state->language_version >= 110) { - static gl_shader *sh = NULL; - - if (sh == NULL) { - sh = read_builtins(GL_VERTEX_SHADER, functions_for_110, - Elements(functions_for_110)); - talloc_steal(builtin_mem_ctx, sh); - } - - import_prototypes(sh->ir, instructions, state->symbols, state); - state->builtins_to_link[state->num_builtins_to_link] = sh; - state->num_builtins_to_link++; - } - if (state->target == fragment_shader && state->language_version >= 110) { + if (state->target == vertex_shader && state->language_version == 120) { static gl_shader *sh = NULL; - if (sh == NULL) { - sh = read_builtins(GL_VERTEX_SHADER, functions_for_110_fs, - Elements(functions_for_110_fs)); - talloc_steal(builtin_mem_ctx, sh); + sh = read_builtins(GL_VERTEX_SHADER, + prototypes_for_120_vert, + functions_for_120_vert, + Elements(functions_for_120_vert )); + talloc_steal(builtin_mem_ctx, sh); } - import_prototypes(sh->ir, instructions, state->symbols, state); + import_prototypes(sh->ir, instructions, state->symbols, + state); state->builtins_to_link[state->num_builtins_to_link] = sh; state->num_builtins_to_link++; } - if (state->target == vertex_shader && state->language_version >= 110) { + if (state->target == fragment_shader && state->EXT_texture_array_enable) { static gl_shader *sh = NULL; - if (sh == NULL) { - sh = read_builtins(GL_VERTEX_SHADER, functions_for_110_vs, - Elements(functions_for_110_vs)); - talloc_steal(builtin_mem_ctx, sh); + sh = read_builtins(GL_VERTEX_SHADER, + prototypes_for_EXT_texture_array_frag, + functions_for_EXT_texture_array_frag, + Elements(functions_for_EXT_texture_array_frag )); + talloc_steal(builtin_mem_ctx, sh); } - import_prototypes(sh->ir, instructions, state->symbols, state); + import_prototypes(sh->ir, instructions, state->symbols, + state); state->builtins_to_link[state->num_builtins_to_link] = sh; state->num_builtins_to_link++; } - if (state->language_version >= 120) { + if (state->target == vertex_shader && state->language_version == 110) { static gl_shader *sh = NULL; - if (sh == NULL) { - sh = read_builtins(GL_VERTEX_SHADER, functions_for_120, - Elements(functions_for_120)); - talloc_steal(builtin_mem_ctx, sh); + sh = read_builtins(GL_VERTEX_SHADER, + prototypes_for_110_vert, + functions_for_110_vert, + Elements(functions_for_110_vert )); + talloc_steal(builtin_mem_ctx, sh); } - import_prototypes(sh->ir, instructions, state->symbols, state); + import_prototypes(sh->ir, instructions, state->symbols, + state); state->builtins_to_link[state->num_builtins_to_link] = sh; state->num_builtins_to_link++; } - if (state->language_version >= 130) { + if (state->target == fragment_shader && state->language_version == 110) { static gl_shader *sh = NULL; - if (sh == NULL) { - sh = read_builtins(GL_VERTEX_SHADER, functions_for_130, - Elements(functions_for_130)); - talloc_steal(builtin_mem_ctx, sh); + sh = read_builtins(GL_VERTEX_SHADER, + prototypes_for_110_frag, + functions_for_110_frag, + Elements(functions_for_110_frag )); + talloc_steal(builtin_mem_ctx, sh); } - import_prototypes(sh->ir, instructions, state->symbols, state); + import_prototypes(sh->ir, instructions, state->symbols, + state); state->builtins_to_link[state->num_builtins_to_link] = sh; state->num_builtins_to_link++; } - if (state->target == fragment_shader && state->language_version >= 130) { + if (state->target == vertex_shader && state->EXT_texture_array_enable) { static gl_shader *sh = NULL; - if (sh == NULL) { - sh = read_builtins(GL_VERTEX_SHADER, functions_for_130_fs, - Elements(functions_for_130_fs)); - talloc_steal(builtin_mem_ctx, sh); + sh = read_builtins(GL_VERTEX_SHADER, + prototypes_for_EXT_texture_array_vert, + functions_for_EXT_texture_array_vert, + Elements(functions_for_EXT_texture_array_vert )); + talloc_steal(builtin_mem_ctx, sh); } - import_prototypes(sh->ir, instructions, state->symbols, state); + import_prototypes(sh->ir, instructions, state->symbols, + state); state->builtins_to_link[state->num_builtins_to_link] = sh; state->num_builtins_to_link++; } - if (state->ARB_texture_rectangle_enable) { + if (state->target == vertex_shader && state->ARB_texture_rectangle_enable) { static gl_shader *sh = NULL; - if (sh == NULL) { - sh = read_builtins(GL_VERTEX_SHADER, functions_for_ARB_texture_rectangle, - Elements(functions_for_ARB_texture_rectangle)); - talloc_steal(builtin_mem_ctx, sh); + sh = read_builtins(GL_VERTEX_SHADER, + prototypes_for_ARB_texture_rectangle_vert, + functions_for_ARB_texture_rectangle_vert, + Elements(functions_for_ARB_texture_rectangle_vert )); + talloc_steal(builtin_mem_ctx, sh); } - import_prototypes(sh->ir, instructions, state->symbols, state); + import_prototypes(sh->ir, instructions, state->symbols, + state); state->builtins_to_link[state->num_builtins_to_link] = sh; state->num_builtins_to_link++; } - if (state->EXT_texture_array_enable) { + if (state->target == fragment_shader && state->ARB_texture_rectangle_enable) { static gl_shader *sh = NULL; - if (sh == NULL) { - sh = read_builtins(GL_VERTEX_SHADER, functions_for_EXT_texture_array, - Elements(functions_for_EXT_texture_array)); - talloc_steal(builtin_mem_ctx, sh); + sh = read_builtins(GL_VERTEX_SHADER, + prototypes_for_ARB_texture_rectangle_frag, + functions_for_ARB_texture_rectangle_frag, + Elements(functions_for_ARB_texture_rectangle_frag )); + talloc_steal(builtin_mem_ctx, sh); } - import_prototypes(sh->ir, instructions, state->symbols, state); + import_prototypes(sh->ir, instructions, state->symbols, + state); state->builtins_to_link[state->num_builtins_to_link] = sh; state->num_builtins_to_link++; } - if (state->target == fragment_shader && state->EXT_texture_array_enable) { + if (state->target == fragment_shader && state->language_version == 120) { static gl_shader *sh = NULL; - if (sh == NULL) { - sh = read_builtins(GL_VERTEX_SHADER, functions_for_EXT_texture_array_fs, - Elements(functions_for_EXT_texture_array_fs)); - talloc_steal(builtin_mem_ctx, sh); + sh = read_builtins(GL_VERTEX_SHADER, + prototypes_for_120_frag, + functions_for_120_frag, + Elements(functions_for_120_frag )); + talloc_steal(builtin_mem_ctx, sh); } - import_prototypes(sh->ir, instructions, state->symbols, state); + import_prototypes(sh->ir, instructions, state->symbols, + state); state->builtins_to_link[state->num_builtins_to_link] = sh; state->num_builtins_to_link++; } diff --git a/src/glsl/builtins/110/abs b/src/glsl/builtins/110/abs deleted file mode 100644 index 904845307c4..00000000000 --- a/src/glsl/builtins/110/abs +++ /dev/null @@ -1,21 +0,0 @@ -((function abs - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float abs (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 abs (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 abs (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 abs (var_ref arg0))))) -)) diff --git a/src/glsl/builtins/110/all b/src/glsl/builtins/110/all deleted file mode 100644 index 2cac0dfb684..00000000000 --- a/src/glsl/builtins/110/all +++ /dev/null @@ -1,16 +0,0 @@ -((function all - (signature bool - (parameters - (declare (in) bvec2 arg0)) - ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) - - (signature bool - (parameters - (declare (in) bvec3 arg0)) - ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) - - (signature bool - (parameters - (declare (in) bvec4 arg0)) - ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) -)) diff --git a/src/glsl/builtins/110/any b/src/glsl/builtins/110/any deleted file mode 100644 index f10e8a7b478..00000000000 --- a/src/glsl/builtins/110/any +++ /dev/null @@ -1,16 +0,0 @@ -((function any - (signature bool - (parameters - (declare (in) bvec2 arg0)) - ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) - - (signature bool - (parameters - (declare (in) bvec3 arg0)) - ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) - - (signature bool - (parameters - (declare (in) bvec4 arg0)) - ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) -)) diff --git a/src/glsl/builtins/110/asin b/src/glsl/builtins/110/asin deleted file mode 100644 index d26bde364b1..00000000000 --- a/src/glsl/builtins/110/asin +++ /dev/null @@ -1,120 +0,0 @@ -((function asin - (signature float - (parameters - (declare (in) float x)) - ((return (expression float * - (expression float sign (var_ref x)) - (expression float - - (expression float * - (constant float (3.1415926)) - (constant float (0.5))) - (expression float * - (expression float sqrt - (expression float - - (constant float (1.0)) - (expression float abs (var_ref x)))) - (expression float + - (constant float (1.5707288)) - (expression float * - (expression float abs (var_ref x)) - (expression float + - (constant float (-0.2121144)) - (expression float * - (constant float (0.0742610)) - (expression float abs (var_ref x)))))))))))) - - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 * - (expression vec2 sign (var_ref x)) - (expression vec2 - - (expression float * - (constant float (3.1415926)) - (constant float (0.5))) - (expression vec2 * - (expression vec2 sqrt - (expression vec2 - - (constant float (1.0)) - (expression vec2 abs (var_ref x)))) - (expression vec2 + - (constant float (1.5707288)) - (expression vec2 * - (expression vec2 abs (var_ref x)) - (expression vec2 + - (constant float (-0.2121144)) - (expression vec2 * - (constant float (0.0742610)) - (expression vec2 abs (var_ref x)))))))))))) - - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 * - (expression vec3 sign (var_ref x)) - (expression vec3 - - (expression float * - (constant float (3.1415926)) - (constant float (0.5))) - (expression vec3 * - (expression vec3 sqrt - (expression vec3 - - (constant float (1.0)) - (expression vec3 abs (var_ref x)))) - (expression vec3 + - (constant float (1.5707288)) - (expression vec3 * - (expression vec3 abs (var_ref x)) - (expression vec3 + - (constant float (-0.2121144)) - (expression vec3 * - (constant float (0.0742610)) - (expression vec3 abs (var_ref x)))))))))))) - - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 * - (expression vec4 sign (var_ref x)) - (expression vec4 - - (expression float * - (constant float (3.1415926)) - (constant float (0.5))) - (expression vec4 * - (expression vec4 sqrt - (expression vec4 - - (constant float (1.0)) - (expression vec4 abs (var_ref x)))) - (expression vec4 + - (constant float (1.5707288)) - (expression vec4 * - (expression vec4 abs (var_ref x)) - (expression vec4 + - (constant float (-0.2121144)) - (expression vec4 * - (constant float (0.0742610)) - (expression vec4 abs (var_ref x))))))))))) -)) - - (function acos - (signature float - (parameters - (declare (in) float x)) - ((return (expression float - (constant float (1.5707963)) - (call asin ((var_ref x))))))) - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 - (constant float (1.5707963)) - (call asin ((var_ref x))))))) - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 - (constant float (1.5707963)) - (call asin ((var_ref x))))))) - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 - (constant float (1.5707963)) - (call asin ((var_ref x))))))) -)) diff --git a/src/glsl/builtins/110/atan b/src/glsl/builtins/110/atan deleted file mode 100644 index 84048293870..00000000000 --- a/src/glsl/builtins/110/atan +++ /dev/null @@ -1,154 +0,0 @@ -((function atan - (signature float - (parameters - (declare (in) float x)) - ((return (call asin ((expression float * - (var_ref x) - (expression float rsq - (expression float + - (expression float * - (var_ref x) - (var_ref x)) - (constant float (1.0)))))))))) - - (signature vec2 - (parameters - (declare (in) vec2 y_over_x)) - ((return (call asin ((expression vec2 * - (var_ref y_over_x) - (expression vec2 rsq - (expression vec2 + - (expression vec2 * - (var_ref y_over_x) - (var_ref y_over_x)) - (constant float (1.0)))))))))) - - (signature vec3 - (parameters - (declare (in) vec3 y_over_x)) - ((return (call asin ((expression vec3 * - (var_ref y_over_x) - (expression vec3 rsq - (expression vec3 + - (expression vec3 * - (var_ref y_over_x) - (var_ref y_over_x)) - (constant float (1.0)))))))))) - - (signature vec4 - (parameters - (declare (in) vec4 y_over_x)) - ((return (call asin ((expression vec4 * - (var_ref y_over_x) - (expression vec4 rsq - (expression vec4 + - (expression vec4 * - (var_ref y_over_x) - (var_ref y_over_x)) - (constant float (1.0)))))))))) - - (signature float - (parameters - (declare (in ) float y) - (declare (in ) float x) - ) - ( - (declare () float r) - (declare ( ) float abs_retval) - (assign (constant bool (1)) (var_ref abs_retval) (call abs ((var_ref x) )) -) - (if (expression bool > (var_ref abs_retval) (constant float (0.000100)) ) ( - (declare ( ) float atan_retval) - (assign (constant bool (1)) (var_ref atan_retval) (call atan ((expression float / (var_ref y) (var_ref x) ) )) -) - (assign (constant bool (1)) (var_ref r) (var_ref atan_retval) ) - (if (expression bool < (var_ref x) (constant float (0.000000)) ) ( - (if (expression bool >= (var_ref y) (constant float (0.000000)) ) ( - (declare ( ) float assignment_tmp) - (assign (constant bool (1)) (var_ref assignment_tmp) (expression float + (var_ref r) (constant float (3.141593)) ) ) - (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) - ) - ( - (declare ( ) float assignment_tmp) - (assign (constant bool (1)) (var_ref assignment_tmp) (expression float - (var_ref r) (constant float (3.141593)) ) ) - (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) - )) - - ) - ( - )) - - ) - ( - (if (expression bool >= (var_ref y) (constant float (0.000000)) ) ( - (assign (constant bool (1)) (var_ref r) (constant float (1.570796)) ) - ) - ( - (assign (constant bool (1)) (var_ref r) (constant float (-1.570796)) ) - )) - - )) - - (return (var_ref r) ) - )) - - - - (signature vec2 - (parameters - (declare (in) vec2 y) - (declare (in) vec2 x)) - ((declare () vec2 r) - (assign (constant bool (1)) - (swiz x (var_ref r)) - (call atan ((swiz x (var_ref y)) - (swiz x (var_ref x))))) - (assign (constant bool (1)) - (swiz y (var_ref r)) - (call atan ((swiz y (var_ref y)) - (swiz y (var_ref x))))) - (return (var_ref r)))) - - (signature vec3 - (parameters - (declare (in) vec3 y) - (declare (in) vec3 x)) - ((declare () vec3 r) - (assign (constant bool (1)) - (swiz x (var_ref r)) - (call atan ((swiz x (var_ref y)) - (swiz x (var_ref x))))) - (assign (constant bool (1)) - (swiz y (var_ref r)) - (call atan ((swiz y (var_ref y)) - (swiz y (var_ref x))))) - (assign (constant bool (1)) - (swiz z (var_ref r)) - (call atan ((swiz z (var_ref y)) - (swiz z (var_ref x))))) - (return (var_ref r)))) - - (signature vec4 - (parameters - (declare (in) vec4 y) - (declare (in) vec4 x)) - ((declare () vec4 r) - (assign (constant bool (1)) - (swiz x (var_ref r)) - (call atan ((swiz x (var_ref y)) - (swiz x (var_ref x))))) - (assign (constant bool (1)) - (swiz y (var_ref r)) - (call atan ((swiz y (var_ref y)) - (swiz y (var_ref x))))) - (assign (constant bool (1)) - (swiz z (var_ref r)) - (call atan ((swiz z (var_ref y)) - (swiz z (var_ref x))))) - (assign (constant bool (1)) - (swiz 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/110/ceil b/src/glsl/builtins/110/ceil deleted file mode 100644 index a26a7750493..00000000000 --- a/src/glsl/builtins/110/ceil +++ /dev/null @@ -1,21 +0,0 @@ -((function ceil - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float ceil (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 ceil (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 ceil (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 ceil (var_ref arg0))))) -)) diff --git a/src/glsl/builtins/110/clamp b/src/glsl/builtins/110/clamp deleted file mode 100644 index d05cc76dc23..00000000000 --- a/src/glsl/builtins/110/clamp +++ /dev/null @@ -1,50 +0,0 @@ -((function clamp - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1) - (declare (in) float arg2)) - ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1) - (declare (in) vec2 arg2)) - ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1) - (declare (in) vec3 arg2)) - ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1) - (declare (in) vec4 arg2)) - ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) float arg1) - (declare (in) float arg2)) - ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) float arg1) - (declare (in) float arg2)) - ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) float arg1) - (declare (in) float arg2)) - ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) -)) diff --git a/src/glsl/builtins/110/cos b/src/glsl/builtins/110/cos deleted file mode 100644 index 88f266eccbe..00000000000 --- a/src/glsl/builtins/110/cos +++ /dev/null @@ -1,21 +0,0 @@ -((function cos - (signature float - (parameters - (declare (in) float angle)) - ((return (expression float cos (var_ref angle))))) - - (signature vec2 - (parameters - (declare (in) vec2 angle)) - ((return (expression vec2 cos (var_ref angle))))) - - (signature vec3 - (parameters - (declare (in) vec3 angle)) - ((return (expression vec3 cos (var_ref angle))))) - - (signature vec4 - (parameters - (declare (in) vec4 angle)) - ((return (expression vec4 cos (var_ref angle))))) -)) diff --git a/src/glsl/builtins/110/cross b/src/glsl/builtins/110/cross deleted file mode 100644 index 24717a2183d..00000000000 --- a/src/glsl/builtins/110/cross +++ /dev/null @@ -1,7 +0,0 @@ -((function cross - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression vec3 cross (var_ref arg0) (var_ref arg1))))) -)) diff --git a/src/glsl/builtins/110/degrees b/src/glsl/builtins/110/degrees deleted file mode 100644 index dc0d7b9e20d..00000000000 --- a/src/glsl/builtins/110/degrees +++ /dev/null @@ -1,21 +0,0 @@ -((function degrees - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float * (var_ref arg0) (constant float (57.295780)))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 * (var_ref arg0) (constant float (57.295780)))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 * (var_ref arg0) (constant float (57.295780)))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 * (var_ref arg0) (constant float (57.295780)))))) -)) diff --git a/src/glsl/builtins/110/distance b/src/glsl/builtins/110/distance deleted file mode 100644 index a2309c484f9..00000000000 --- a/src/glsl/builtins/110/distance +++ /dev/null @@ -1,33 +0,0 @@ -((function distance - (signature float - (parameters - (declare (in) float p0) - (declare (in) float p1)) - ((declare () float p) - (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1))) - (return (expression float sqrt (expression float dot (var_ref p) (var_ref p)))))) - - (signature float - (parameters - (declare (in) vec2 p0) - (declare (in) vec2 p1)) - ((declare () vec2 p) - (assign (constant bool (1)) (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 - (parameters - (declare (in) vec3 p0) - (declare (in) vec3 p1)) - ((declare () vec3 p) - (assign (constant bool (1)) (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 - (parameters - (declare (in) vec4 p0) - (declare (in) vec4 p1)) - ((declare () vec4 p) - (assign (constant bool (1)) (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/110/dot b/src/glsl/builtins/110/dot deleted file mode 100644 index a91a6d2c56d..00000000000 --- a/src/glsl/builtins/110/dot +++ /dev/null @@ -1,25 +0,0 @@ -((function dot - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1)) - ((return (expression float dot (var_ref arg0) (var_ref arg1))))) - - (signature float - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((return (expression float dot (var_ref arg0) (var_ref arg1))))) - - (signature float - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression float dot (var_ref arg0) (var_ref arg1))))) - - (signature float - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((return (expression float dot (var_ref arg0) (var_ref arg1))))) -)) diff --git a/src/glsl/builtins/110/equal b/src/glsl/builtins/110/equal deleted file mode 100644 index ae7ddc53bdc..00000000000 --- a/src/glsl/builtins/110/equal +++ /dev/null @@ -1,61 +0,0 @@ -((function equal - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/110/exp b/src/glsl/builtins/110/exp deleted file mode 100644 index a73bd6a7f84..00000000000 --- a/src/glsl/builtins/110/exp +++ /dev/null @@ -1,21 +0,0 @@ -((function exp - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float exp (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 exp (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 exp (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 exp (var_ref arg0))))) -)) diff --git a/src/glsl/builtins/110/exp2 b/src/glsl/builtins/110/exp2 deleted file mode 100644 index a842d3fe65b..00000000000 --- a/src/glsl/builtins/110/exp2 +++ /dev/null @@ -1,21 +0,0 @@ -((function exp2 - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float exp2 (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 exp2 (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 exp2 (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 exp2 (var_ref arg0))))) -)) diff --git a/src/glsl/builtins/110/faceforward b/src/glsl/builtins/110/faceforward deleted file mode 100644 index d1703972388..00000000000 --- a/src/glsl/builtins/110/faceforward +++ /dev/null @@ -1,37 +0,0 @@ -((function faceforward - (signature float - (parameters - (declare (in) float N) - (declare (in) float I) - (declare (in) float Nref)) - ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) - ((return (var_ref N))) - ((return (expression float neg (var_ref N))))))) - - (signature vec2 - (parameters - (declare (in) vec2 N) - (declare (in) vec2 I) - (declare (in) vec2 Nref)) - ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) - ((return (var_ref N))) - ((return (expression vec2 neg (var_ref N))))))) - - (signature vec3 - (parameters - (declare (in) vec3 N) - (declare (in) vec3 I) - (declare (in) vec3 Nref)) - ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) - ((return (var_ref N))) - ((return (expression vec3 neg (var_ref N))))))) - - (signature vec4 - (parameters - (declare (in) vec4 N) - (declare (in) vec4 I) - (declare (in) vec4 Nref)) - ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) - ((return (var_ref N))) - ((return (expression vec4 neg (var_ref N))))))) -)) diff --git a/src/glsl/builtins/110/floor b/src/glsl/builtins/110/floor deleted file mode 100644 index 8dd8052799b..00000000000 --- a/src/glsl/builtins/110/floor +++ /dev/null @@ -1,21 +0,0 @@ -((function floor - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float floor (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 floor (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 floor (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 floor (var_ref arg0))))) -)) diff --git a/src/glsl/builtins/110/fract b/src/glsl/builtins/110/fract deleted file mode 100644 index 3f0763d1b3e..00000000000 --- a/src/glsl/builtins/110/fract +++ /dev/null @@ -1,22 +0,0 @@ -((function fract - (signature float - (parameters - (declare (in) float x)) - ((return (expression float fract (var_ref x))))) - - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 fract (var_ref x))))) - - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 fract (var_ref x))))) - - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 fract (var_ref x))))) -)) - diff --git a/src/glsl/builtins/110/greaterThan b/src/glsl/builtins/110/greaterThan deleted file mode 100644 index ae03030e495..00000000000 --- a/src/glsl/builtins/110/greaterThan +++ /dev/null @@ -1,61 +0,0 @@ -((function greaterThan - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/110/greaterThanEqual b/src/glsl/builtins/110/greaterThanEqual deleted file mode 100644 index 204d5fd1439..00000000000 --- a/src/glsl/builtins/110/greaterThanEqual +++ /dev/null @@ -1,61 +0,0 @@ -((function greaterThanEqual - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/110/inversesqrt b/src/glsl/builtins/110/inversesqrt deleted file mode 100644 index 5b66d2b3695..00000000000 --- a/src/glsl/builtins/110/inversesqrt +++ /dev/null @@ -1,21 +0,0 @@ -((function inversesqrt - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float rsq (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 rsq (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 rsq (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 rsq (var_ref arg0))))) -)) diff --git a/src/glsl/builtins/110/length b/src/glsl/builtins/110/length deleted file mode 100644 index 89ff7f3ef12..00000000000 --- a/src/glsl/builtins/110/length +++ /dev/null @@ -1,21 +0,0 @@ -((function length - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) - - (signature float - (parameters - (declare (in) vec2 arg0)) - ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) - - (signature float - (parameters - (declare (in) vec3 arg0)) - ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) - - (signature float - (parameters - (declare (in) vec4 arg0)) - ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) -)) diff --git a/src/glsl/builtins/110/lessThan b/src/glsl/builtins/110/lessThan deleted file mode 100644 index 5c4254165c7..00000000000 --- a/src/glsl/builtins/110/lessThan +++ /dev/null @@ -1,61 +0,0 @@ -((function lessThan - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/110/lessThanEqual b/src/glsl/builtins/110/lessThanEqual deleted file mode 100644 index ccb955b8a76..00000000000 --- a/src/glsl/builtins/110/lessThanEqual +++ /dev/null @@ -1,61 +0,0 @@ -((function lessThanEqual - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/110/log b/src/glsl/builtins/110/log deleted file mode 100644 index d168abb5a73..00000000000 --- a/src/glsl/builtins/110/log +++ /dev/null @@ -1,21 +0,0 @@ -((function log - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float log (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 log (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 log (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 log (var_ref arg0))))) -)) diff --git a/src/glsl/builtins/110/log2 b/src/glsl/builtins/110/log2 deleted file mode 100644 index b96c6276f0a..00000000000 --- a/src/glsl/builtins/110/log2 +++ /dev/null @@ -1,21 +0,0 @@ -((function log2 - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float log2 (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 log2 (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 log2 (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 log2 (var_ref arg0))))) -)) diff --git a/src/glsl/builtins/110/matrixCompMult b/src/glsl/builtins/110/matrixCompMult deleted file mode 100644 index cb5a2cb1f7b..00000000000 --- a/src/glsl/builtins/110/matrixCompMult +++ /dev/null @@ -1,32 +0,0 @@ -((function matrixCompMult - (signature mat2 - (parameters - (declare (in) mat2 x) - (declare (in) mat2 y)) - ((declare () mat2 z) - (assign (constant bool (1)) (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)) (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 - (parameters - (declare (in) mat3 x) - (declare (in) mat3 y)) - ((declare () mat3 z) - (assign (constant bool (1)) (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)) (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)) (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 - (parameters - (declare (in) mat4 x) - (declare (in) mat4 y)) - ((declare () mat4 z) - (assign (constant bool (1)) (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)) (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)) (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)) (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)))) -)) - diff --git a/src/glsl/builtins/110/max b/src/glsl/builtins/110/max deleted file mode 100644 index f91ae417e4b..00000000000 --- a/src/glsl/builtins/110/max +++ /dev/null @@ -1,43 +0,0 @@ -((function max - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1)) - ((return (expression float max (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((return (expression vec2 max (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression vec3 max (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) float arg1)) - ((return (expression vec2 max (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) float arg1)) - ((return (expression vec3 max (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) float arg1)) - ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) -)) diff --git a/src/glsl/builtins/110/min b/src/glsl/builtins/110/min deleted file mode 100644 index 78fc44120af..00000000000 --- a/src/glsl/builtins/110/min +++ /dev/null @@ -1,43 +0,0 @@ -((function min - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1)) - ((return (expression float min (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((return (expression vec2 min (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression vec3 min (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) float arg1)) - ((return (expression vec2 min (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) float arg1)) - ((return (expression vec3 min (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) float arg1)) - ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) -)) diff --git a/src/glsl/builtins/110/mix b/src/glsl/builtins/110/mix deleted file mode 100644 index 8638d06887c..00000000000 --- a/src/glsl/builtins/110/mix +++ /dev/null @@ -1,50 +0,0 @@ -((function mix - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1) - (declare (in) float arg2)) - ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2)))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1) - (declare (in) vec2 arg2)) - ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1) - (declare (in) vec3 arg2)) - ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1) - (declare (in) vec4 arg2)) - ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1) - (declare (in) float arg2)) - ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1) - (declare (in) float arg2)) - ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1) - (declare (in) float arg2)) - ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) -)) diff --git a/src/glsl/builtins/110/mod b/src/glsl/builtins/110/mod deleted file mode 100644 index aeaea240e2d..00000000000 --- a/src/glsl/builtins/110/mod +++ /dev/null @@ -1,43 +0,0 @@ -((function mod - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1)) - ((return (expression float % (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((return (expression vec2 % (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression vec3 % (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) float arg1)) - ((return (expression vec2 % (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) float arg1)) - ((return (expression vec3 % (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) float arg1)) - ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) -)) diff --git a/src/glsl/builtins/110/noise_fake b/src/glsl/builtins/110/noise_fake deleted file mode 100644 index bcfb17b04b8..00000000000 --- a/src/glsl/builtins/110/noise_fake +++ /dev/null @@ -1,76 +0,0 @@ -((function noise1 - (signature float - (parameters - (declare (in) float x)) - ((return (constant float (0))))) - (signature float - (parameters - (declare (in) vec2 x)) - ((return (constant float (0))))) - (signature float - (parameters - (declare (in) vec3 x)) - ((return (constant float (0))))) - (signature float - (parameters - (declare (in) vec4 x)) - ((return (constant float (0))))) - ) - - (function noise2 - (signature vec2 - (parameters - (declare (in) float x)) - ((return (constant vec2 (0 0))))) - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (constant vec2 (0 0))))) - (signature vec2 - (parameters - (declare (in) vec3 x)) - ((return (constant vec2 (0 0))))) - (signature vec2 - (parameters - (declare (in) vec4 x)) - ((return (constant vec2 (0 0))))) - ) - - (function noise3 - (signature vec3 - (parameters - (declare (in) float x)) - ((return (constant vec3 (0 0 0))))) - (signature vec3 - (parameters - (declare (in) vec2 x)) - ((return (constant vec3 (0 0 0))))) - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (constant vec3 (0 0 0))))) - (signature vec3 - (parameters - (declare (in) vec4 x)) - ((return (constant vec3 (0 0 0))))) - ) - - (function noise4 - (signature vec4 - (parameters - (declare (in) float x)) - ((return (constant vec4 (0 0 0 0))))) - (signature vec4 - (parameters - (declare (in) vec2 x)) - ((return (constant vec4 (0 0 0 0))))) - (signature vec4 - (parameters - (declare (in) vec3 x)) - ((return (constant vec4 (0 0 0 0))))) - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (constant vec4 (0 0 0 0))))) - ) -) diff --git a/src/glsl/builtins/110/normalize b/src/glsl/builtins/110/normalize deleted file mode 100644 index be88a9830d1..00000000000 --- a/src/glsl/builtins/110/normalize +++ /dev/null @@ -1,21 +0,0 @@ -((function normalize - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) -)) diff --git a/src/glsl/builtins/110/not b/src/glsl/builtins/110/not deleted file mode 100644 index b696b06557f..00000000000 --- a/src/glsl/builtins/110/not +++ /dev/null @@ -1,16 +0,0 @@ -((function not - (signature bvec2 - (parameters - (declare (in) bvec2 arg0)) - ((return (expression bvec2 ! (var_ref arg0))))) - - (signature bvec3 - (parameters - (declare (in) bvec3 arg0)) - ((return (expression bvec3 ! (var_ref arg0))))) - - (signature bvec4 - (parameters - (declare (in) bvec4 arg0)) - ((return (expression bvec4 ! (var_ref arg0))))) -)) diff --git a/src/glsl/builtins/110/notEqual b/src/glsl/builtins/110/notEqual deleted file mode 100644 index ccdcaa3aafa..00000000000 --- a/src/glsl/builtins/110/notEqual +++ /dev/null @@ -1,61 +0,0 @@ -((function notEqual - (signature bvec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/110/pow b/src/glsl/builtins/110/pow deleted file mode 100644 index a61bc4418e3..00000000000 --- a/src/glsl/builtins/110/pow +++ /dev/null @@ -1,25 +0,0 @@ -((function pow - (signature float - (parameters - (declare (in) float arg0) - (declare (in) float arg1)) - ((return (expression float pow (var_ref arg0) (var_ref arg1))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0) - (declare (in) vec2 arg1)) - ((return (expression vec2 pow (var_ref arg0) (var_ref arg1))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0) - (declare (in) vec3 arg1)) - ((return (expression vec3 pow (var_ref arg0) (var_ref arg1))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0) - (declare (in) vec4 arg1)) - ((return (expression vec4 pow (var_ref arg0) (var_ref arg1))))) -)) diff --git a/src/glsl/builtins/110/radians b/src/glsl/builtins/110/radians deleted file mode 100644 index 6a0f5d2e219..00000000000 --- a/src/glsl/builtins/110/radians +++ /dev/null @@ -1,21 +0,0 @@ -((function radians - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float * (var_ref arg0) (constant float (0.017453)))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 * (var_ref arg0) (constant float (0.017453)))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 * (var_ref arg0) (constant float (0.017453)))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 * (var_ref arg0) (constant float (0.017453)))))) -)) diff --git a/src/glsl/builtins/110/reflect b/src/glsl/builtins/110/reflect deleted file mode 100644 index 8238fdc93fd..00000000000 --- a/src/glsl/builtins/110/reflect +++ /dev/null @@ -1,58 +0,0 @@ -((function reflect - (signature float - (parameters - (declare (in) float i) - (declare (in) float n)) - ((return (expression float - - (var_ref i) - (expression float * - (constant float (2.0)) - (expression float * - (expression float dot - (var_ref n) - (var_ref i)) - (var_ref n))))))) - - (signature vec2 - (parameters - (declare (in) vec2 i) - (declare (in) vec2 n)) - ((return (expression vec2 - - (var_ref i) - (expression vec2 * - (constant float (2.0)) - (expression vec2 * - (expression float dot - (var_ref n) - (var_ref i)) - (var_ref n))))))) - - (signature vec3 - (parameters - (declare (in) vec3 i) - (declare (in) vec3 n)) - ((return (expression vec3 - - (var_ref i) - (expression vec3 * - (constant float (2.0)) - (expression vec3 * - (expression float dot - (var_ref n) - (var_ref i)) - (var_ref n))))))) - - (signature vec4 - (parameters - (declare (in) vec4 i) - (declare (in) vec4 n)) - ((return (expression vec4 - - (var_ref i) - (expression vec4 * - (constant float (2.0)) - (expression vec4 * - (expression float dot - (var_ref n) - (var_ref i)) - (var_ref n))))))) - -)) diff --git a/src/glsl/builtins/110/refract b/src/glsl/builtins/110/refract deleted file mode 100644 index 522ab411734..00000000000 --- a/src/glsl/builtins/110/refract +++ /dev/null @@ -1,102 +0,0 @@ -((function refract - (signature float - (parameters - (declare (in) float i) - (declare (in) float n) - (declare (in) float eta)) - ((declare () float k) - (assign (constant bool (1)) (var_ref k) - (expression float - (constant float (1.0)) - (expression float * (var_ref eta) - (expression float * (var_ref eta) - (expression float - (constant float (1.0)) - (expression float * - (expression float dot (var_ref n) (var_ref i)) - (expression float dot (var_ref n) (var_ref i)))))))) - (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant float (0.0)))) - ((return (expression float - - (expression float * (var_ref eta) (var_ref i)) - (expression float * - (expression float + - (expression float * (var_ref eta) - (expression float dot (var_ref n) (var_ref i))) - (expression float sqrt (var_ref k))) - (var_ref n)))))))) - - (signature vec2 - (parameters - (declare (in) vec2 i) - (declare (in) vec2 n) - (declare (in) float eta)) - ((declare () float k) - (assign (constant bool (1)) (var_ref k) - (expression float - (constant float (1.0)) - (expression float * (var_ref eta) - (expression float * (var_ref eta) - (expression float - (constant float (1.0)) - (expression float * - (expression float dot (var_ref n) (var_ref i)) - (expression float dot (var_ref n) (var_ref i)))))))) - (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant vec2 (0.0 0.0)))) - ((return (expression vec2 - - (expression vec2 * (var_ref eta) (var_ref i)) - (expression vec2 * - (expression float + - (expression float * (var_ref eta) - (expression float dot (var_ref n) (var_ref i))) - (expression float sqrt (var_ref k))) - (var_ref n)))))))) - - (signature vec3 - (parameters - (declare (in) vec3 i) - (declare (in) vec3 n) - (declare (in) float eta)) - ((declare () float k) - (assign (constant bool (1)) (var_ref k) - (expression float - (constant float (1.0)) - (expression float * (var_ref eta) - (expression float * (var_ref eta) - (expression float - (constant float (1.0)) - (expression float * - (expression float dot (var_ref n) (var_ref i)) - (expression float dot (var_ref n) (var_ref i)))))))) - (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant vec3 (0.0 0.0 0.0)))) - ((return (expression vec3 - - (expression vec3 * (var_ref eta) (var_ref i)) - (expression vec3 * - (expression float + - (expression float * (var_ref eta) - (expression float dot (var_ref n) (var_ref i))) - (expression float sqrt (var_ref k))) - (var_ref n)))))))) - - (signature vec4 - (parameters - (declare (in) vec4 i) - (declare (in) vec4 n) - (declare (in) float eta)) - ((declare () float k) - (assign (constant bool (1)) (var_ref k) - (expression float - (constant float (1.0)) - (expression float * (var_ref eta) - (expression float * (var_ref eta) - (expression float - (constant float (1.0)) - (expression float * - (expression float dot (var_ref n) (var_ref i)) - (expression float dot (var_ref n) (var_ref i)))))))) - (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant vec4 (0.0 0.0 0.0 0.0)))) - ((return (expression vec4 - - (expression vec4 * (var_ref eta) (var_ref i)) - (expression vec4 * - (expression float + - (expression float * (var_ref eta) - (expression float dot (var_ref n) (var_ref i))) - (expression float sqrt (var_ref k))) - (var_ref n)))))))) - -)) diff --git a/src/glsl/builtins/110/sign b/src/glsl/builtins/110/sign deleted file mode 100644 index fa475197cf5..00000000000 --- a/src/glsl/builtins/110/sign +++ /dev/null @@ -1,21 +0,0 @@ -((function sign - (signature float - (parameters - (declare (in) float x)) - ((return (expression float sign (var_ref x))))) - - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 sign (var_ref x))))) - - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 sign (var_ref x))))) - - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 sign (var_ref x))))) -)) diff --git a/src/glsl/builtins/110/sin b/src/glsl/builtins/110/sin deleted file mode 100644 index e6009d8ef12..00000000000 --- a/src/glsl/builtins/110/sin +++ /dev/null @@ -1,21 +0,0 @@ -((function sin - (signature float - (parameters - (declare (in) float angle)) - ((return (expression float sin (var_ref angle))))) - - (signature vec2 - (parameters - (declare (in) vec2 angle)) - ((return (expression vec2 sin (var_ref angle))))) - - (signature vec3 - (parameters - (declare (in) vec3 angle)) - ((return (expression vec3 sin (var_ref angle))))) - - (signature vec4 - (parameters - (declare (in) vec4 angle)) - ((return (expression vec4 sin (var_ref angle))))) -)) diff --git a/src/glsl/builtins/110/smoothstep b/src/glsl/builtins/110/smoothstep deleted file mode 100644 index 663eec63419..00000000000 --- a/src/glsl/builtins/110/smoothstep +++ /dev/null @@ -1,153 +0,0 @@ -((function smoothstep - (signature float - (parameters - (declare (in) float edge0) - (declare (in) float edge1) - (declare (in) float x)) - ((declare () float t) - - (assign (constant bool (1)) (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))) - (constant float (1.0))) - (constant float (0.0)))) - (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t)))))))) - - (signature vec2 - (parameters - (declare (in) float edge0) - (declare (in) float edge1) - (declare (in) vec2 x)) - ((declare () vec2 t) - (declare () vec2 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - (return (var_ref retval)) - )) - - (signature vec3 - (parameters - (declare (in) float edge0) - (declare (in) float edge1) - (declare (in) vec3 x)) - ((declare () vec3 t) - (declare () vec3 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - - (assign (constant bool (1)) (swiz z (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) - (return (var_ref retval)) - )) - - - (signature vec4 - (parameters - (declare (in) float edge0) - (declare (in) float edge1) - (declare (in) vec4 x)) - ((declare () vec4 t) - (declare () vec4 retval) - - (assign (constant bool (1)) (swiz x (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) - - (assign (constant bool (1)) (swiz y (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) - - (assign (constant bool (1)) (swiz z (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) - - (assign (constant bool (1)) (swiz w (var_ref t)) - (expression float max - (expression float min - (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) - (constant float (1.0))) - (constant float (0.0)))) - (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t))))))) - (return (var_ref retval)) - )) - - (signature vec2 - (parameters - (declare (in) vec2 edge0) - (declare (in) vec2 edge1) - (declare (in) vec2 x)) - ((return (expression vec2 max - (expression vec2 min - (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0))) - (constant vec2 (1.0 1.0))) - (constant vec2 (0.0 0.0)))))) - - (signature vec3 - (parameters - (declare (in) vec3 edge0) - (declare (in) vec3 edge1) - (declare (in) vec3 x)) - ((return (expression vec3 max - (expression vec3 min - (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0))) - (constant vec3 (1.0 1.0 1.0))) - (constant vec3 (0.0 0.0 0.0)))))) - - (signature vec4 - (parameters - (declare (in) vec4 edge0) - (declare (in) vec4 edge1) - (declare (in) vec4 x)) - ((return (expression vec4 max - (expression vec4 min - (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0))) - (constant vec4 (1.0 1.0 1.0 1.0))) - (constant vec4 (0.0 0.0 0.0 0.0)))))) -)) - diff --git a/src/glsl/builtins/110/sqrt b/src/glsl/builtins/110/sqrt deleted file mode 100644 index 0302d164ae5..00000000000 --- a/src/glsl/builtins/110/sqrt +++ /dev/null @@ -1,21 +0,0 @@ -((function sqrt - (signature float - (parameters - (declare (in) float arg0)) - ((return (expression float sqrt (var_ref arg0))))) - - (signature vec2 - (parameters - (declare (in) vec2 arg0)) - ((return (expression vec2 sqrt (var_ref arg0))))) - - (signature vec3 - (parameters - (declare (in) vec3 arg0)) - ((return (expression vec3 sqrt (var_ref arg0))))) - - (signature vec4 - (parameters - (declare (in) vec4 arg0)) - ((return (expression vec4 sqrt (var_ref arg0))))) -)) diff --git a/src/glsl/builtins/110/step b/src/glsl/builtins/110/step deleted file mode 100644 index ce6f4354228..00000000000 --- a/src/glsl/builtins/110/step +++ /dev/null @@ -1,68 +0,0 @@ -((function step - (signature float - (parameters - (declare (in) float edge) - (declare (in) float x)) - ((return (expression float b2f (expression bool >= (var_ref x) (var_ref edge)))))) - - (signature vec2 - (parameters - (declare (in) float edge) - (declare (in) vec2 x)) - ((declare () vec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) - (return (var_ref t)))) - - (signature vec3 - (parameters - (declare (in) float edge) - (declare (in) vec3 x)) - ((declare () vec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge)))) - (return (var_ref t)))) - - (signature vec4 - (parameters - (declare (in) float edge) - (declare (in) vec4 x)) - ((declare () vec4 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge)))) - (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge)))) - (return (var_ref t)))) - - (signature vec2 - (parameters - (declare (in) vec2 edge) - (declare (in) vec2 x)) - ((declare () vec2 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) - (assign (constant bool (1)) (swiz 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 - (parameters - (declare (in) vec3 edge) - (declare (in) vec3 x)) - ((declare () vec3 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge))))) - (assign (constant bool (1)) (swiz 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 - (parameters - (declare (in) vec4 edge) - (declare (in) vec4 x)) - ((declare () vec4 t) - (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) - (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge))))) - (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz z (var_ref edge))))) - (assign (constant bool (1)) (swiz 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/110/tan b/src/glsl/builtins/110/tan deleted file mode 100644 index 99798631859..00000000000 --- a/src/glsl/builtins/110/tan +++ /dev/null @@ -1,21 +0,0 @@ -((function tan - (signature float - (parameters - (declare (in) float angle)) - ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle)))))) - - (signature vec2 - (parameters - (declare (in) vec2 angle)) - ((return (expression vec2 / (expression vec2 sin (var_ref angle)) (expression vec2 cos (var_ref angle)))))) - - (signature vec3 - (parameters - (declare (in) vec3 angle)) - ((return (expression vec3 / (expression vec3 sin (var_ref angle)) (expression vec3 cos (var_ref angle)))))) - - (signature vec4 - (parameters - (declare (in) vec4 angle)) - ((return (expression vec4 / (expression vec4 sin (var_ref angle)) (expression vec4 cos (var_ref angle)))))) -)) diff --git a/src/glsl/builtins/110/textures b/src/glsl/builtins/110/textures deleted file mode 100644 index c81b7e8ad49..00000000000 --- a/src/glsl/builtins/110/textures +++ /dev/null @@ -1,213 +0,0 @@ -((function texture1D - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function texture1DLod - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function texture1DProj - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - -) - (function texture1DProjLod - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - -) - (function texture2D - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) -(function texture2DLod - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function texture2DProj - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - -) - (function texture2DProjLod - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - -) - (function texture3D - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function texture3DLod - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function texture3DProj - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - -) - (function texture3DProjLod - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - -) - (function textureCube - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function textureCubeLod - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function shadow1D - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) - -) - (function shadow1DLod - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) - -) - (function shadow1DProj - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) )))) - -) - (function shadow1DProjLod - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) )))) - -) - (function shadow2D - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) - -) - (function shadow2DLod - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) - -) - (function shadow2DProj - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) )))) - -) - (function shadow2DProjLod - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) )))) - -)) diff --git a/src/glsl/builtins/110_fs/derivatives b/src/glsl/builtins/110_fs/derivatives deleted file mode 100644 index b79852ee1ff..00000000000 --- a/src/glsl/builtins/110_fs/derivatives +++ /dev/null @@ -1,73 +0,0 @@ -((function dFdx - (signature float - (parameters - (declare (in) float p)) - ((return (expression float dFdx (var_ref p))))) - - (signature vec2 - (parameters - (declare (in) vec2 p)) - ((return (expression vec2 dFdx (var_ref p))))) - - (signature vec3 - (parameters - (declare (in) vec3 p)) - ((return (expression vec3 dFdx (var_ref p))))) - - (signature vec4 - (parameters - (declare (in) vec4 p)) - ((return (expression vec4 dFdx (var_ref p))))) - ) - - (function dFdy - (signature float - (parameters - (declare (in) float p)) - ((return (expression float dFdy (var_ref p))))) - - (signature vec2 - (parameters - (declare (in) vec2 p)) - ((return (expression vec2 dFdy (var_ref p))))) - - (signature vec3 - (parameters - (declare (in) vec3 p)) - ((return (expression vec3 dFdy (var_ref p))))) - - (signature vec4 - (parameters - (declare (in) vec4 p)) - ((return (expression vec4 dFdy (var_ref p))))) - ) - - (function fwidth - (signature float - (parameters - (declare (in) float p)) - ((return (expression float + - (expression float abs (expression float dFdx (var_ref p))) - (expression float abs (expression float dFdy (var_ref p))))))) - - (signature vec2 - (parameters - (declare (in) vec2 p)) - ((return (expression vec2 + - (expression vec2 abs (expression vec2 dFdx (var_ref p))) - (expression vec2 abs (expression vec2 dFdy (var_ref p))))))) - - (signature vec3 - (parameters - (declare (in) vec3 p)) - ((return (expression vec3 + - (expression vec3 abs (expression vec3 dFdx (var_ref p))) - (expression vec3 abs (expression vec3 dFdy (var_ref p))))))) - - (signature vec4 - (parameters - (declare (in) vec4 p)) - ((return (expression vec4 + - (expression vec4 abs (expression vec4 dFdx (var_ref p))) - (expression vec4 abs (expression vec4 dFdy (var_ref p))))))) -)) diff --git a/src/glsl/builtins/110_fs/textures b/src/glsl/builtins/110_fs/textures deleted file mode 100644 index 38f3787e9ef..00000000000 --- a/src/glsl/builtins/110_fs/textures +++ /dev/null @@ -1,113 +0,0 @@ -((function texture1D - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function texture1DProj - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - -) - (function texture2D - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function texture2DProj - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - -) - (function texture3D - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function texture3DProj - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - -) - (function textureCube - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function shadow1D - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) - -) - (function shadow1DProj - (signature vec4 - (parameters - (declare (in) sampler1DShadow sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) )))) - -) - (function shadow2D - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) - -) - (function shadow2DProj - (signature vec4 - (parameters - (declare (in) sampler2DShadow sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) )))) - -)) diff --git a/src/glsl/builtins/110_vs/ftransform b/src/glsl/builtins/110_vs/ftransform deleted file mode 100644 index 9ca63dc1e34..00000000000 --- a/src/glsl/builtins/110_vs/ftransform +++ /dev/null @@ -1,9 +0,0 @@ -((declare (uniform) mat4 gl_ModelViewProjectionMatrix) - (declare (in) vec4 gl_Vertex) - (function ftransform - (signature vec4 - (parameters) - ((return (expression vec4 * - (var_ref gl_ModelViewProjectionMatrix) - (var_ref gl_Vertex))))) -)) diff --git a/src/glsl/builtins/120/matrixCompMult b/src/glsl/builtins/120/matrixCompMult deleted file mode 100644 index 69331e26525..00000000000 --- a/src/glsl/builtins/120/matrixCompMult +++ /dev/null @@ -1,61 +0,0 @@ -((function matrixCompMult - (signature mat2x3 - (parameters - (declare (in) mat2x3 x) - (declare (in) mat2x3 y)) - ((declare () mat2x3 z) - (assign (constant bool (1)) (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)) (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 - (parameters - (declare (in) mat3x2 x) - (declare (in) mat3x2 y)) - ((declare () mat3x2 z) - (assign (constant bool (1)) (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)) (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)) (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 - (parameters - (declare (in) mat2x4 x) - (declare (in) mat2x4 y)) - ((declare () mat2x4 z) - (assign (constant bool (1)) (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)) (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 - (parameters - (declare (in) mat4x2 x) - (declare (in) mat4x2 y)) - ((declare () mat4x2 z) - (assign (constant bool (1)) (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)) (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)) (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)) (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 - (parameters - (declare (in) mat3x4 x) - (declare (in) mat3x4 y)) - ((declare () mat3x4 z) - (assign (constant bool (1)) (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)) (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)) (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 - (parameters - (declare (in) mat4x3 x) - (declare (in) mat4x3 y)) - ((declare () mat4x3 z) - (assign (constant bool (1)) (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)) (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)) (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)) (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/120/outerProduct b/src/glsl/builtins/120/outerProduct deleted file mode 100644 index 69ae741e176..00000000000 --- a/src/glsl/builtins/120/outerProduct +++ /dev/null @@ -1,92 +0,0 @@ -((function outerProduct - (signature mat2 - (parameters - (declare (in) vec2 u) - (declare (in) vec2 v)) - ((declare () mat2 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) - (return (var_ref m)))) - - (signature mat2x3 - (parameters - (declare (in) vec3 u) - (declare (in) vec2 v)) - ((declare () mat2x3 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) - (return (var_ref m)))) - - (signature mat2x4 - (parameters - (declare (in) vec4 u) - (declare (in) vec2 v)) - ((declare () mat2x4 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) - (return (var_ref m)))) - - (signature mat3x2 - (parameters - (declare (in) vec2 u) - (declare (in) vec3 v)) - ((declare () mat3x2 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v)))) - (return (var_ref m)) - )) - - (signature mat3 - (parameters - (declare (in) vec3 u) - (declare (in) vec3 v)) - ((declare () mat3 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v)))) - (return (var_ref m)))) - - (signature mat3x4 - (parameters - (declare (in) vec4 u) - (declare (in) vec3 v)) - ((declare () mat3x4 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v)))) - (return (var_ref m)))) - - (signature mat4x2 - (parameters - (declare (in) vec2 u) - (declare (in) vec4 v)) - ((declare () mat4x2 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v)))) - (return (var_ref m)))) - - (signature mat4x3 - (parameters - (declare (in) vec3 u) - (declare (in) vec4 v)) - ((declare () mat4x3 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v)))) - (return (var_ref m)))) - - (signature mat4 - (parameters - (declare (in) vec4 u) - (declare (in) vec4 v)) - ((declare () mat4 m) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) - (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v)))) - (assign (constant bool (1)) (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/120/transpose b/src/glsl/builtins/120/transpose deleted file mode 100644 index 416a0ee4677..00000000000 --- a/src/glsl/builtins/120/transpose +++ /dev/null @@ -1,139 +0,0 @@ -((function transpose - (signature mat2 - (parameters - (declare (in) mat2 m)) - ((declare () mat2 t) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) - (assign (constant bool (1)) (swiz 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/130/clamp b/src/glsl/builtins/130/clamp deleted file mode 100644 index e1aad5c8d98..00000000000 --- a/src/glsl/builtins/130/clamp +++ /dev/null @@ -1,99 +0,0 @@ -((function clamp - (signature int - (parameters - (declare (in) int arg0) - (declare (in) int arg1) - (declare (in) int arg2)) - ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1) - (declare (in) ivec2 arg2)) - ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1) - (declare (in) ivec3 arg2)) - ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1) - (declare (in) ivec4 arg2)) - ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) int arg1) - (declare (in) int arg2)) - ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) int arg1) - (declare (in) int arg2)) - ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) int arg1) - (declare (in) int arg2)) - ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uint - (parameters - (declare (in) uint arg0) - (declare (in) uint arg1) - (declare (in) uint arg2)) - ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1) - (declare (in) uvec2 arg2)) - ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1) - (declare (in) uvec3 arg2)) - ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1) - (declare (in) uvec4 arg2)) - ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uint arg1) - (declare (in) uint arg2)) - ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uint arg1) - (declare (in) uint arg2)) - ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uint arg1) - (declare (in) uint arg2)) - ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) -)) diff --git a/src/glsl/builtins/130/cosh b/src/glsl/builtins/130/cosh deleted file mode 100644 index 45e0ae427d6..00000000000 --- a/src/glsl/builtins/130/cosh +++ /dev/null @@ -1,30 +0,0 @@ -((function cosh - (signature float - (parameters - (declare (in) float x)) - ((return (expression float * (constant float (0.5)) - (expression float + - (expression float exp (var_ref x)) - (expression float exp (expression float neg (var_ref x)))))))) - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 * (constant vec2 (0.5)) - (expression vec2 + - (expression vec2 exp (var_ref x)) - (expression vec2 exp (expression vec2 neg (var_ref x)))))))) - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 * (constant vec3 (0.5)) - (expression vec3 + - (expression vec3 exp (var_ref x)) - (expression vec3 exp (expression vec3 neg (var_ref x)))))))) - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 * (constant vec4 (0.5)) - (expression vec4 + - (expression vec4 exp (var_ref x)) - (expression vec4 exp (expression vec4 neg (var_ref x)))))))) -)) diff --git a/src/glsl/builtins/130/equal b/src/glsl/builtins/130/equal deleted file mode 100644 index 079c3e97fb2..00000000000 --- a/src/glsl/builtins/130/equal +++ /dev/null @@ -1,31 +0,0 @@ -((function equal - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/130/greaterThan b/src/glsl/builtins/130/greaterThan deleted file mode 100644 index a9fb7b3a43e..00000000000 --- a/src/glsl/builtins/130/greaterThan +++ /dev/null @@ -1,31 +0,0 @@ -((function greaterThan - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/130/greaterThanEqual b/src/glsl/builtins/130/greaterThanEqual deleted file mode 100644 index 293c93c7cca..00000000000 --- a/src/glsl/builtins/130/greaterThanEqual +++ /dev/null @@ -1,31 +0,0 @@ -((function greaterThanEqual - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/130/lessThan b/src/glsl/builtins/130/lessThan deleted file mode 100644 index d9f693fd63f..00000000000 --- a/src/glsl/builtins/130/lessThan +++ /dev/null @@ -1,31 +0,0 @@ -((function lessThan - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/130/lessThanEqual b/src/glsl/builtins/130/lessThanEqual deleted file mode 100644 index 494411b869a..00000000000 --- a/src/glsl/builtins/130/lessThanEqual +++ /dev/null @@ -1,31 +0,0 @@ -((function lessThanEqual - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/130/max b/src/glsl/builtins/130/max deleted file mode 100644 index 0863e411a32..00000000000 --- a/src/glsl/builtins/130/max +++ /dev/null @@ -1,85 +0,0 @@ -((function max - (signature int - (parameters - (declare (in) int arg0) - (declare (in) int arg1)) - ((return (expression int max (var_ref arg0) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((return (expression ivec2 max (var_ref arg0) (var_ref arg1))))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((return (expression ivec3 max (var_ref arg0) (var_ref arg1))))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((return (expression ivec4 max (var_ref arg0) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) int arg1)) - ((return (expression ivec2 max (var_ref arg0) (var_ref arg1))))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) int arg1)) - ((return (expression ivec3 max (var_ref arg0) (var_ref arg1))))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) int arg1)) - ((return (expression ivec4 max (var_ref arg0) (var_ref arg1))))) - - (signature uint - (parameters - (declare (in) uint arg0) - (declare (in) uint arg1)) - ((return (expression uint max (var_ref arg0) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((return (expression uvec2 max (var_ref arg0) (var_ref arg1))))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((return (expression uvec3 max (var_ref arg0) (var_ref arg1))))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((return (expression uvec4 max (var_ref arg0) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uint arg1)) - ((return (expression uvec2 max (var_ref arg0) (var_ref arg1))))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uint arg1)) - ((return (expression uvec3 max (var_ref arg0) (var_ref arg1))))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uint arg1)) - ((return (expression uvec4 max (var_ref arg0) (var_ref arg1))))) -)) diff --git a/src/glsl/builtins/130/min b/src/glsl/builtins/130/min deleted file mode 100644 index 576546f6f20..00000000000 --- a/src/glsl/builtins/130/min +++ /dev/null @@ -1,85 +0,0 @@ -((function min - (signature int - (parameters - (declare (in) int arg0) - (declare (in) int arg1)) - ((return (expression int min (var_ref arg0) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) ivec2 arg1)) - ((return (expression ivec2 min (var_ref arg0) (var_ref arg1))))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) ivec3 arg1)) - ((return (expression ivec3 min (var_ref arg0) (var_ref arg1))))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) ivec4 arg1)) - ((return (expression ivec4 min (var_ref arg0) (var_ref arg1))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 arg0) - (declare (in) int arg1)) - ((return (expression ivec2 min (var_ref arg0) (var_ref arg1))))) - - (signature ivec3 - (parameters - (declare (in) ivec3 arg0) - (declare (in) int arg1)) - ((return (expression ivec3 min (var_ref arg0) (var_ref arg1))))) - - (signature ivec4 - (parameters - (declare (in) ivec4 arg0) - (declare (in) int arg1)) - ((return (expression ivec4 min (var_ref arg0) (var_ref arg1))))) - - (signature uint - (parameters - (declare (in) uint arg0) - (declare (in) uint arg1)) - ((return (expression uint min (var_ref arg0) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((return (expression uvec2 min (var_ref arg0) (var_ref arg1))))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((return (expression uvec3 min (var_ref arg0) (var_ref arg1))))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((return (expression uvec4 min (var_ref arg0) (var_ref arg1))))) - - (signature uvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uint arg1)) - ((return (expression uvec2 min (var_ref arg0) (var_ref arg1))))) - - (signature uvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uint arg1)) - ((return (expression uvec3 min (var_ref arg0) (var_ref arg1))))) - - (signature uvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uint arg1)) - ((return (expression uvec4 min (var_ref arg0) (var_ref arg1))))) -)) diff --git a/src/glsl/builtins/130/mix b/src/glsl/builtins/130/mix deleted file mode 100644 index 9a1fcd70ffa..00000000000 --- a/src/glsl/builtins/130/mix +++ /dev/null @@ -1,39 +0,0 @@ -((function mix - (signature float - (parameters - (declare (in) float v1) - (declare (in) float v2) - (declare (in) bool a)) - ((assign (var_ref a) (var_ref v1) (var_ref v2)) - (return (var_ref v1)))) - - (signature vec2 - (parameters - (declare (in) vec2 v1) - (declare (in) vec2 v2) - (declare (in) bvec2 a)) - ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2))) - (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2))) - (return (var_ref v1)))) - - (signature vec3 - (parameters - (declare (in) vec3 v1) - (declare (in) vec3 v2) - (declare (in) bvec3 a)) - ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2))) - (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2))) - (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2))) - (return (var_ref v1)))) - - (signature vec4 - (parameters - (declare (in) vec4 v1) - (declare (in) vec4 v2) - (declare (in) bvec4 a)) - ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2))) - (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2))) - (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2))) - (assign (swiz w (var_ref a)) (swiz w (var_ref v1)) (swiz w (var_ref v2))) - (return (var_ref v1)))) -)) diff --git a/src/glsl/builtins/130/notEqual b/src/glsl/builtins/130/notEqual deleted file mode 100644 index 81e6376bd9c..00000000000 --- a/src/glsl/builtins/130/notEqual +++ /dev/null @@ -1,31 +0,0 @@ -((function notEqual - (signature bvec2 - (parameters - (declare (in) uvec2 arg0) - (declare (in) uvec2 arg1)) - ((declare () bvec2 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec3 - (parameters - (declare (in) uvec3 arg0) - (declare (in) uvec3 arg1)) - ((declare () bvec3 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (return (var_ref temp)))) - - (signature bvec4 - (parameters - (declare (in) uvec4 arg0) - (declare (in) uvec4 arg1)) - ((declare () bvec4 temp) - (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) - (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) - (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) - (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) - (return (var_ref temp)))) -)) diff --git a/src/glsl/builtins/130/sign b/src/glsl/builtins/130/sign deleted file mode 100644 index f86062a2443..00000000000 --- a/src/glsl/builtins/130/sign +++ /dev/null @@ -1,22 +0,0 @@ -((function sign - (signature int - (parameters - (declare (in) int x)) - ((return (expression int sign (var_ref x))))) - - (signature ivec2 - (parameters - (declare (in) ivec2 x)) - ((return (expression ivec2 sign (var_ref x))))) - - (signature ivec3 - (parameters - (declare (in) ivec3 x)) - ((return (expression ivec3 sign (var_ref x))))) - - (signature ivec4 - (parameters - (declare (in) ivec4 x)) - ((return (expression ivec4 sign (var_ref x))))) -)) - diff --git a/src/glsl/builtins/130/sinh b/src/glsl/builtins/130/sinh deleted file mode 100644 index 7ad4f58e204..00000000000 --- a/src/glsl/builtins/130/sinh +++ /dev/null @@ -1,30 +0,0 @@ -((function sinh - (signature float - (parameters - (declare (in) float x)) - ((return (expression float * (constant float (0.5)) - (expression float - - (expression float exp (var_ref x)) - (expression float exp (expression float neg (var_ref x)))))))) - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 * (constant vec2 (0.5)) - (expression vec2 - - (expression vec2 exp (var_ref x)) - (expression vec2 exp (expression vec2 neg (var_ref x)))))))) - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 * (constant vec3 (0.5)) - (expression vec3 - - (expression vec3 exp (var_ref x)) - (expression vec3 exp (expression vec3 neg (var_ref x)))))))) - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 * (constant vec4 (0.5)) - (expression vec4 - - (expression vec4 exp (var_ref x)) - (expression vec4 exp (expression vec4 neg (var_ref x)))))))) -)) diff --git a/src/glsl/builtins/130/tanh b/src/glsl/builtins/130/tanh deleted file mode 100644 index 3b7271bf779..00000000000 --- a/src/glsl/builtins/130/tanh +++ /dev/null @@ -1,42 +0,0 @@ -((function tanh - (signature float - (parameters - (declare (in) float x)) - ((return (expression float / - (expression float - - (expression float exp (var_ref x)) - (expression float exp (expression float neg (var_ref x)))) - (expression float + - (expression float exp (var_ref x)) - (expression float exp (expression float neg (var_ref x)))))))) - (signature vec2 - (parameters - (declare (in) vec2 x)) - ((return (expression vec2 / - (expression vec2 - - (expression vec2 exp (var_ref x)) - (expression vec2 exp (expression vec2 neg (var_ref x)))) - (expression vec2 + - (expression vec2 exp (var_ref x)) - (expression vec2 exp (expression vec2 neg (var_ref x)))))))) - (signature vec3 - (parameters - (declare (in) vec3 x)) - ((return (expression vec3 / - (expression vec3 - - (expression vec3 exp (var_ref x)) - (expression vec3 exp (expression vec3 neg (var_ref x)))) - (expression vec3 + - (expression vec3 exp (var_ref x)) - (expression vec3 exp (expression vec3 neg (var_ref x)))))))) - (signature vec4 - (parameters - (declare (in) vec4 x)) - ((return (expression vec4 / - (expression vec4 - - (expression vec4 exp (var_ref x)) - (expression vec4 exp (expression vec4 neg (var_ref x)))) - (expression vec4 + - (expression vec4 exp (var_ref x)) - (expression vec4 exp (expression vec4 neg (var_ref x)))))))) -)) diff --git a/src/glsl/builtins/130/texelFetch b/src/glsl/builtins/130/texelFetch deleted file mode 100644 index d51ce65a897..00000000000 --- a/src/glsl/builtins/130/texelFetch +++ /dev/null @@ -1,107 +0,0 @@ -((function texelFetch - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) int P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) int P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) int P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1DArray sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1DArray sampler) - (declare (in) ivec2 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2DArray sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2DArray sampler) - (declare (in) ivec3 P) - (declare (in) int lod) ) - ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) )))) - -)) diff --git a/src/glsl/builtins/130/texture b/src/glsl/builtins/130/texture deleted file mode 100644 index b170b583094..00000000000 --- a/src/glsl/builtins/130/texture +++ /dev/null @@ -1,110 +0,0 @@ -((function texture - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) float P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) float P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isamplerCube sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usamplerCube sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isampler1DArray sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usampler1DArray sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature ivec4 - (parameters - (declare (in) isampler2DArray sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - - (signature uvec4 - (parameters - (declare (in) usampler2DArray sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -)) diff --git a/src/glsl/builtins/130/textureGrad b/src/glsl/builtins/130/textureGrad deleted file mode 100644 index 0ef428c224a..00000000000 --- a/src/glsl/builtins/130/textureGrad +++ /dev/null @@ -1,147 +0,0 @@ -((function textureGrad - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) float P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) float P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isamplerCube sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usamplerCube sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) )))) - -) -) diff --git a/src/glsl/builtins/130/textureLod b/src/glsl/builtins/130/textureLod deleted file mode 100644 index 7d7059d848c..00000000000 --- a/src/glsl/builtins/130/textureLod +++ /dev/null @@ -1,128 +0,0 @@ -((function textureLod - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) float P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) float P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isamplerCube sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usamplerCube sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -)) diff --git a/src/glsl/builtins/130/textureProj b/src/glsl/builtins/130/textureProj deleted file mode 100644 index 40ea1c2af68..00000000000 --- a/src/glsl/builtins/130/textureProj +++ /dev/null @@ -1,92 +0,0 @@ -((function textureProj - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () )))) - -)) diff --git a/src/glsl/builtins/130/textureProjGrad b/src/glsl/builtins/130/textureProjGrad deleted file mode 100644 index b4bfa58c123..00000000000 --- a/src/glsl/builtins/130/textureProjGrad +++ /dev/null @@ -1,122 +0,0 @@ -((function textureProjGrad - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec2 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec2 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec4 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec4 P) - (declare (in) float dPdx) - (declare (in) float dPdy) ) - ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec3 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec3 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec4 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec4 P) - (declare (in) vec2 dPdx) - (declare (in) vec2 dPdy) ) - ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec4 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec4 P) - (declare (in) vec3 dPdx) - (declare (in) vec3 dPdy) ) - ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) )))) - -)) diff --git a/src/glsl/builtins/130/textureProjLod b/src/glsl/builtins/130/textureProjLod deleted file mode 100644 index d242f7e40fc..00000000000 --- a/src/glsl/builtins/130/textureProjLod +++ /dev/null @@ -1,107 +0,0 @@ -((function textureProjLod - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec4 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) )))) - -)) diff --git a/src/glsl/builtins/130_fs/texture b/src/glsl/builtins/130_fs/texture deleted file mode 100644 index 0de981397f0..00000000000 --- a/src/glsl/builtins/130_fs/texture +++ /dev/null @@ -1,128 +0,0 @@ -((function texture - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) float P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) float P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) float P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) samplerCube sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isamplerCube sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usamplerCube sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -)) diff --git a/src/glsl/builtins/130_fs/textureProj b/src/glsl/builtins/130_fs/textureProj deleted file mode 100644 index b1d8f0a2f33..00000000000 --- a/src/glsl/builtins/130_fs/textureProj +++ /dev/null @@ -1,107 +0,0 @@ -((function textureProj - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler1D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler1D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler1D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler2D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler2D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler2D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature vec4 - (parameters - (declare (in) sampler3D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature ivec4 - (parameters - (declare (in) isampler3D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - - (signature uvec4 - (parameters - (declare (in) usampler3D sampler) - (declare (in) vec4 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) )))) - -)) diff --git a/src/glsl/builtins/ARB_texture_rectangle/textures b/src/glsl/builtins/ARB_texture_rectangle/textures deleted file mode 100644 index 161d8c4a541..00000000000 --- a/src/glsl/builtins/ARB_texture_rectangle/textures +++ /dev/null @@ -1,16 +0,0 @@ -((function texture2DRect - (signature vec4 - (parameters - (declare (in) sampler2DRect sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function shadow2DRect - (signature vec4 - (parameters - (declare (in) sampler2DRectShadow sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) - -)) diff --git a/src/glsl/builtins/EXT_texture_array/textures b/src/glsl/builtins/EXT_texture_array/textures deleted file mode 100644 index 8a91f901401..00000000000 --- a/src/glsl/builtins/EXT_texture_array/textures +++ /dev/null @@ -1,59 +0,0 @@ -((function texture1DArray - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function texture1DArrayLod - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function texture2DArray - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () )))) - -) - (function texture2DArrayLod - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) )))) - -) - (function shadow1DArray - (signature vec4 - (parameters - (declare (in) sampler1DArrayShadow sampler) - (declare (in) vec3 P) ) - ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) )))) - -) - (function shadow1DArrayLod - (signature vec4 - (parameters - (declare (in) sampler1DArrayShadow sampler) - (declare (in) vec3 P) - (declare (in) float lod) ) - ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) )))) - -) - (function shadow2DArray - (signature vec4 - (parameters - (declare (in) sampler2DArrayShadow sampler) - (declare (in) vec4 P) ) - ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) 1 (swiz w (var_ref P)) )))) - -)) diff --git a/src/glsl/builtins/EXT_texture_array_fs/textures b/src/glsl/builtins/EXT_texture_array_fs/textures deleted file mode 100644 index 74e184387ac..00000000000 --- a/src/glsl/builtins/EXT_texture_array_fs/textures +++ /dev/null @@ -1,27 +0,0 @@ -((function texture1DArray - (signature vec4 - (parameters - (declare (in) sampler1DArray sampler) - (declare (in) vec2 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function texture2DArray - (signature vec4 - (parameters - (declare (in) sampler2DArray sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) )))) - -) - (function shadow1DArray - (signature vec4 - (parameters - (declare (in) sampler1DArrayShadow sampler) - (declare (in) vec3 P) - (declare (in) float bias) ) - ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) )))) - -)) diff --git a/src/glsl/builtins/ir/abs b/src/glsl/builtins/ir/abs new file mode 100644 index 00000000000..904845307c4 --- /dev/null +++ b/src/glsl/builtins/ir/abs @@ -0,0 +1,21 @@ +((function abs + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float abs (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 abs (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 abs (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 abs (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/ir/acos b/src/glsl/builtins/ir/acos new file mode 100644 index 00000000000..d1cfebeff8a --- /dev/null +++ b/src/glsl/builtins/ir/acos @@ -0,0 +1,22 @@ +((function acos + (signature float + (parameters + (declare (in) float x)) + ((return (expression float - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) +)) diff --git a/src/glsl/builtins/ir/all b/src/glsl/builtins/ir/all new file mode 100644 index 00000000000..2cac0dfb684 --- /dev/null +++ b/src/glsl/builtins/ir/all @@ -0,0 +1,16 @@ +((function all + (signature bool + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) +)) diff --git a/src/glsl/builtins/ir/any b/src/glsl/builtins/ir/any new file mode 100644 index 00000000000..f10e8a7b478 --- /dev/null +++ b/src/glsl/builtins/ir/any @@ -0,0 +1,16 @@ +((function any + (signature bool + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) +)) diff --git a/src/glsl/builtins/ir/asin b/src/glsl/builtins/ir/asin new file mode 100644 index 00000000000..e230ad614ee --- /dev/null +++ b/src/glsl/builtins/ir/asin @@ -0,0 +1,97 @@ +((function asin + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * + (expression float sign (var_ref x)) + (expression float - + (expression float * + (constant float (3.1415926)) + (constant float (0.5))) + (expression float * + (expression float sqrt + (expression float - + (constant float (1.0)) + (expression float abs (var_ref x)))) + (expression float + + (constant float (1.5707288)) + (expression float * + (expression float abs (var_ref x)) + (expression float + + (constant float (-0.2121144)) + (expression float * + (constant float (0.0742610)) + (expression float abs (var_ref x)))))))))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * + (expression vec2 sign (var_ref x)) + (expression vec2 - + (expression float * + (constant float (3.1415926)) + (constant float (0.5))) + (expression vec2 * + (expression vec2 sqrt + (expression vec2 - + (constant float (1.0)) + (expression vec2 abs (var_ref x)))) + (expression vec2 + + (constant float (1.5707288)) + (expression vec2 * + (expression vec2 abs (var_ref x)) + (expression vec2 + + (constant float (-0.2121144)) + (expression vec2 * + (constant float (0.0742610)) + (expression vec2 abs (var_ref x)))))))))))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * + (expression vec3 sign (var_ref x)) + (expression vec3 - + (expression float * + (constant float (3.1415926)) + (constant float (0.5))) + (expression vec3 * + (expression vec3 sqrt + (expression vec3 - + (constant float (1.0)) + (expression vec3 abs (var_ref x)))) + (expression vec3 + + (constant float (1.5707288)) + (expression vec3 * + (expression vec3 abs (var_ref x)) + (expression vec3 + + (constant float (-0.2121144)) + (expression vec3 * + (constant float (0.0742610)) + (expression vec3 abs (var_ref x)))))))))))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * + (expression vec4 sign (var_ref x)) + (expression vec4 - + (expression float * + (constant float (3.1415926)) + (constant float (0.5))) + (expression vec4 * + (expression vec4 sqrt + (expression vec4 - + (constant float (1.0)) + (expression vec4 abs (var_ref x)))) + (expression vec4 + + (constant float (1.5707288)) + (expression vec4 * + (expression vec4 abs (var_ref x)) + (expression vec4 + + (constant float (-0.2121144)) + (expression vec4 * + (constant float (0.0742610)) + (expression vec4 abs (var_ref x)))))))))))) +)) diff --git a/src/glsl/builtins/ir/atan b/src/glsl/builtins/ir/atan new file mode 100644 index 00000000000..84048293870 --- /dev/null +++ b/src/glsl/builtins/ir/atan @@ -0,0 +1,154 @@ +((function atan + (signature float + (parameters + (declare (in) float x)) + ((return (call asin ((expression float * + (var_ref x) + (expression float rsq + (expression float + + (expression float * + (var_ref x) + (var_ref x)) + (constant float (1.0)))))))))) + + (signature vec2 + (parameters + (declare (in) vec2 y_over_x)) + ((return (call asin ((expression vec2 * + (var_ref y_over_x) + (expression vec2 rsq + (expression vec2 + + (expression vec2 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature vec3 + (parameters + (declare (in) vec3 y_over_x)) + ((return (call asin ((expression vec3 * + (var_ref y_over_x) + (expression vec3 rsq + (expression vec3 + + (expression vec3 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature vec4 + (parameters + (declare (in) vec4 y_over_x)) + ((return (call asin ((expression vec4 * + (var_ref y_over_x) + (expression vec4 rsq + (expression vec4 + + (expression vec4 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature float + (parameters + (declare (in ) float y) + (declare (in ) float x) + ) + ( + (declare () float r) + (declare ( ) float abs_retval) + (assign (constant bool (1)) (var_ref abs_retval) (call abs ((var_ref x) )) +) + (if (expression bool > (var_ref abs_retval) (constant float (0.000100)) ) ( + (declare ( ) float atan_retval) + (assign (constant bool (1)) (var_ref atan_retval) (call atan ((expression float / (var_ref y) (var_ref x) ) )) +) + (assign (constant bool (1)) (var_ref r) (var_ref atan_retval) ) + (if (expression bool < (var_ref x) (constant float (0.000000)) ) ( + (if (expression bool >= (var_ref y) (constant float (0.000000)) ) ( + (declare ( ) float assignment_tmp) + (assign (constant bool (1)) (var_ref assignment_tmp) (expression float + (var_ref r) (constant float (3.141593)) ) ) + (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) + ) + ( + (declare ( ) float assignment_tmp) + (assign (constant bool (1)) (var_ref assignment_tmp) (expression float - (var_ref r) (constant float (3.141593)) ) ) + (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) + )) + + ) + ( + )) + + ) + ( + (if (expression bool >= (var_ref y) (constant float (0.000000)) ) ( + (assign (constant bool (1)) (var_ref r) (constant float (1.570796)) ) + ) + ( + (assign (constant bool (1)) (var_ref r) (constant float (-1.570796)) ) + )) + + )) + + (return (var_ref r) ) + )) + + + + (signature vec2 + (parameters + (declare (in) vec2 y) + (declare (in) vec2 x)) + ((declare () vec2 r) + (assign (constant bool (1)) + (swiz x (var_ref r)) + (call atan ((swiz x (var_ref y)) + (swiz x (var_ref x))))) + (assign (constant bool (1)) + (swiz y (var_ref r)) + (call atan ((swiz y (var_ref y)) + (swiz y (var_ref x))))) + (return (var_ref r)))) + + (signature vec3 + (parameters + (declare (in) vec3 y) + (declare (in) vec3 x)) + ((declare () vec3 r) + (assign (constant bool (1)) + (swiz x (var_ref r)) + (call atan ((swiz x (var_ref y)) + (swiz x (var_ref x))))) + (assign (constant bool (1)) + (swiz y (var_ref r)) + (call atan ((swiz y (var_ref y)) + (swiz y (var_ref x))))) + (assign (constant bool (1)) + (swiz z (var_ref r)) + (call atan ((swiz z (var_ref y)) + (swiz z (var_ref x))))) + (return (var_ref r)))) + + (signature vec4 + (parameters + (declare (in) vec4 y) + (declare (in) vec4 x)) + ((declare () vec4 r) + (assign (constant bool (1)) + (swiz x (var_ref r)) + (call atan ((swiz x (var_ref y)) + (swiz x (var_ref x))))) + (assign (constant bool (1)) + (swiz y (var_ref r)) + (call atan ((swiz y (var_ref y)) + (swiz y (var_ref x))))) + (assign (constant bool (1)) + (swiz z (var_ref r)) + (call atan ((swiz z (var_ref y)) + (swiz z (var_ref x))))) + (assign (constant bool (1)) + (swiz 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/ceil b/src/glsl/builtins/ir/ceil new file mode 100644 index 00000000000..a26a7750493 --- /dev/null +++ b/src/glsl/builtins/ir/ceil @@ -0,0 +1,21 @@ +((function ceil + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float ceil (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 ceil (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 ceil (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 ceil (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/ir/clamp b/src/glsl/builtins/ir/clamp new file mode 100644 index 00000000000..2bdc466b269 --- /dev/null +++ b/src/glsl/builtins/ir/clamp @@ -0,0 +1,148 @@ +((function clamp + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) vec2 arg2)) + ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) vec3 arg2)) + ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) vec4 arg2)) + ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1) + (declare (in) ivec2 arg2)) + ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1) + (declare (in) ivec3 arg2)) + ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1) + (declare (in) ivec4 arg2)) + ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1) + (declare (in) uvec2 arg2)) + ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1) + (declare (in) uvec3 arg2)) + ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1) + (declare (in) uvec4 arg2)) + ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) +)) diff --git a/src/glsl/builtins/ir/cos b/src/glsl/builtins/ir/cos new file mode 100644 index 00000000000..88f266eccbe --- /dev/null +++ b/src/glsl/builtins/ir/cos @@ -0,0 +1,21 @@ +((function cos + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float cos (var_ref angle))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 cos (var_ref angle))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 cos (var_ref angle))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 cos (var_ref angle))))) +)) diff --git a/src/glsl/builtins/ir/cosh b/src/glsl/builtins/ir/cosh new file mode 100644 index 00000000000..45e0ae427d6 --- /dev/null +++ b/src/glsl/builtins/ir/cosh @@ -0,0 +1,30 @@ +((function cosh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * (constant float (0.5)) + (expression float + + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * (constant vec2 (0.5)) + (expression vec2 + + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * (constant vec3 (0.5)) + (expression vec3 + + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * (constant vec4 (0.5)) + (expression vec4 + + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/src/glsl/builtins/ir/cross b/src/glsl/builtins/ir/cross new file mode 100644 index 00000000000..24717a2183d --- /dev/null +++ b/src/glsl/builtins/ir/cross @@ -0,0 +1,7 @@ +((function cross + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 cross (var_ref arg0) (var_ref arg1))))) +)) diff --git a/src/glsl/builtins/ir/dFdx b/src/glsl/builtins/ir/dFdx new file mode 100644 index 00000000000..30594d33c74 --- /dev/null +++ b/src/glsl/builtins/ir/dFdx @@ -0,0 +1,21 @@ +((function dFdx + (signature float + (parameters + (declare (in) float p)) + ((return (expression float dFdx (var_ref p))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 dFdx (var_ref p))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 dFdx (var_ref p))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 dFdx (var_ref p))))) +)) diff --git a/src/glsl/builtins/ir/dFdy b/src/glsl/builtins/ir/dFdy new file mode 100644 index 00000000000..fb5798d3cbe --- /dev/null +++ b/src/glsl/builtins/ir/dFdy @@ -0,0 +1,21 @@ +((function dFdy + (signature float + (parameters + (declare (in) float p)) + ((return (expression float dFdy (var_ref p))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 dFdy (var_ref p))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 dFdy (var_ref p))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 dFdy (var_ref p))))) +)) diff --git a/src/glsl/builtins/ir/degrees b/src/glsl/builtins/ir/degrees new file mode 100644 index 00000000000..dc0d7b9e20d --- /dev/null +++ b/src/glsl/builtins/ir/degrees @@ -0,0 +1,21 @@ +((function degrees + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (constant float (57.295780)))))) +)) diff --git a/src/glsl/builtins/ir/distance b/src/glsl/builtins/ir/distance new file mode 100644 index 00000000000..a2309c484f9 --- /dev/null +++ b/src/glsl/builtins/ir/distance @@ -0,0 +1,33 @@ +((function distance + (signature float + (parameters + (declare (in) float p0) + (declare (in) float p1)) + ((declare () float p) + (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1))) + (return (expression float sqrt (expression float dot (var_ref p) (var_ref p)))))) + + (signature float + (parameters + (declare (in) vec2 p0) + (declare (in) vec2 p1)) + ((declare () vec2 p) + (assign (constant bool (1)) (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 + (parameters + (declare (in) vec3 p0) + (declare (in) vec3 p1)) + ((declare () vec3 p) + (assign (constant bool (1)) (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 + (parameters + (declare (in) vec4 p0) + (declare (in) vec4 p1)) + ((declare () vec4 p) + (assign (constant bool (1)) (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/dot b/src/glsl/builtins/ir/dot new file mode 100644 index 00000000000..a91a6d2c56d --- /dev/null +++ b/src/glsl/builtins/ir/dot @@ -0,0 +1,25 @@ +((function dot + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) +)) diff --git a/src/glsl/builtins/ir/equal b/src/glsl/builtins/ir/equal new file mode 100644 index 00000000000..d7a4bc6063f --- /dev/null +++ b/src/glsl/builtins/ir/equal @@ -0,0 +1,91 @@ +((function equal + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/ir/exp b/src/glsl/builtins/ir/exp new file mode 100644 index 00000000000..a73bd6a7f84 --- /dev/null +++ b/src/glsl/builtins/ir/exp @@ -0,0 +1,21 @@ +((function exp + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float exp (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 exp (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 exp (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 exp (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/ir/exp2 b/src/glsl/builtins/ir/exp2 new file mode 100644 index 00000000000..a842d3fe65b --- /dev/null +++ b/src/glsl/builtins/ir/exp2 @@ -0,0 +1,21 @@ +((function exp2 + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float exp2 (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 exp2 (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 exp2 (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 exp2 (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/ir/faceforward b/src/glsl/builtins/ir/faceforward new file mode 100644 index 00000000000..d1703972388 --- /dev/null +++ b/src/glsl/builtins/ir/faceforward @@ -0,0 +1,37 @@ +((function faceforward + (signature float + (parameters + (declare (in) float N) + (declare (in) float I) + (declare (in) float Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression float neg (var_ref N))))))) + + (signature vec2 + (parameters + (declare (in) vec2 N) + (declare (in) vec2 I) + (declare (in) vec2 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec2 neg (var_ref N))))))) + + (signature vec3 + (parameters + (declare (in) vec3 N) + (declare (in) vec3 I) + (declare (in) vec3 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec3 neg (var_ref N))))))) + + (signature vec4 + (parameters + (declare (in) vec4 N) + (declare (in) vec4 I) + (declare (in) vec4 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec4 neg (var_ref N))))))) +)) diff --git a/src/glsl/builtins/ir/floor b/src/glsl/builtins/ir/floor new file mode 100644 index 00000000000..8dd8052799b --- /dev/null +++ b/src/glsl/builtins/ir/floor @@ -0,0 +1,21 @@ +((function floor + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float floor (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 floor (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 floor (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 floor (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/ir/fract b/src/glsl/builtins/ir/fract new file mode 100644 index 00000000000..3f0763d1b3e --- /dev/null +++ b/src/glsl/builtins/ir/fract @@ -0,0 +1,22 @@ +((function fract + (signature float + (parameters + (declare (in) float x)) + ((return (expression float fract (var_ref x))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 fract (var_ref x))))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 fract (var_ref x))))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 fract (var_ref x))))) +)) + diff --git a/src/glsl/builtins/ir/ftransform b/src/glsl/builtins/ir/ftransform new file mode 100644 index 00000000000..9ca63dc1e34 --- /dev/null +++ b/src/glsl/builtins/ir/ftransform @@ -0,0 +1,9 @@ +((declare (uniform) mat4 gl_ModelViewProjectionMatrix) + (declare (in) vec4 gl_Vertex) + (function ftransform + (signature vec4 + (parameters) + ((return (expression vec4 * + (var_ref gl_ModelViewProjectionMatrix) + (var_ref gl_Vertex))))) +)) diff --git a/src/glsl/builtins/ir/fwidth b/src/glsl/builtins/ir/fwidth new file mode 100644 index 00000000000..385e05d6a1a --- /dev/null +++ b/src/glsl/builtins/ir/fwidth @@ -0,0 +1,29 @@ +((function fwidth + (signature float + (parameters + (declare (in) float p)) + ((return (expression float + + (expression float abs (expression float dFdx (var_ref p))) + (expression float abs (expression float dFdy (var_ref p))))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 + + (expression vec2 abs (expression vec2 dFdx (var_ref p))) + (expression vec2 abs (expression vec2 dFdy (var_ref p))))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 + + (expression vec3 abs (expression vec3 dFdx (var_ref p))) + (expression vec3 abs (expression vec3 dFdy (var_ref p))))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 + + (expression vec4 abs (expression vec4 dFdx (var_ref p))) + (expression vec4 abs (expression vec4 dFdy (var_ref p))))))) +)) diff --git a/src/glsl/builtins/ir/greaterThan b/src/glsl/builtins/ir/greaterThan new file mode 100644 index 00000000000..ce7bd29bed8 --- /dev/null +++ b/src/glsl/builtins/ir/greaterThan @@ -0,0 +1,91 @@ +((function greaterThan + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/ir/greaterThanEqual b/src/glsl/builtins/ir/greaterThanEqual new file mode 100644 index 00000000000..de1a9f9516e --- /dev/null +++ b/src/glsl/builtins/ir/greaterThanEqual @@ -0,0 +1,91 @@ +((function greaterThanEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/ir/inversesqrt b/src/glsl/builtins/ir/inversesqrt new file mode 100644 index 00000000000..5b66d2b3695 --- /dev/null +++ b/src/glsl/builtins/ir/inversesqrt @@ -0,0 +1,21 @@ +((function inversesqrt + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float rsq (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 rsq (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 rsq (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 rsq (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/ir/length b/src/glsl/builtins/ir/length new file mode 100644 index 00000000000..89ff7f3ef12 --- /dev/null +++ b/src/glsl/builtins/ir/length @@ -0,0 +1,21 @@ +((function length + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec2 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec3 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec4 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) +)) diff --git a/src/glsl/builtins/ir/lessThan b/src/glsl/builtins/ir/lessThan new file mode 100644 index 00000000000..52113b70466 --- /dev/null +++ b/src/glsl/builtins/ir/lessThan @@ -0,0 +1,91 @@ +((function lessThan + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/ir/lessThanEqual b/src/glsl/builtins/ir/lessThanEqual new file mode 100644 index 00000000000..4b240be5d19 --- /dev/null +++ b/src/glsl/builtins/ir/lessThanEqual @@ -0,0 +1,91 @@ +((function lessThanEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/ir/log b/src/glsl/builtins/ir/log new file mode 100644 index 00000000000..d168abb5a73 --- /dev/null +++ b/src/glsl/builtins/ir/log @@ -0,0 +1,21 @@ +((function log + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float log (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 log (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 log (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 log (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/ir/log2 b/src/glsl/builtins/ir/log2 new file mode 100644 index 00000000000..b96c6276f0a --- /dev/null +++ b/src/glsl/builtins/ir/log2 @@ -0,0 +1,21 @@ +((function log2 + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float log2 (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 log2 (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 log2 (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 log2 (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/ir/matrixCompMult b/src/glsl/builtins/ir/matrixCompMult new file mode 100644 index 00000000000..538da18a794 --- /dev/null +++ b/src/glsl/builtins/ir/matrixCompMult @@ -0,0 +1,91 @@ +((function matrixCompMult + (signature mat2 + (parameters + (declare (in) mat2 x) + (declare (in) mat2 y)) + ((declare () mat2 z) + (assign (constant bool (1)) (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)) (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 + (parameters + (declare (in) mat3 x) + (declare (in) mat3 y)) + ((declare () mat3 z) + (assign (constant bool (1)) (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)) (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)) (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 + (parameters + (declare (in) mat4 x) + (declare (in) mat4 y)) + ((declare () mat4 z) + (assign (constant bool (1)) (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)) (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)) (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)) (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 + (parameters + (declare (in) mat2x3 x) + (declare (in) mat2x3 y)) + ((declare () mat2x3 z) + (assign (constant bool (1)) (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)) (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 + (parameters + (declare (in) mat3x2 x) + (declare (in) mat3x2 y)) + ((declare () mat3x2 z) + (assign (constant bool (1)) (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)) (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)) (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 + (parameters + (declare (in) mat2x4 x) + (declare (in) mat2x4 y)) + ((declare () mat2x4 z) + (assign (constant bool (1)) (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)) (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 + (parameters + (declare (in) mat4x2 x) + (declare (in) mat4x2 y)) + ((declare () mat4x2 z) + (assign (constant bool (1)) (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)) (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)) (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)) (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 + (parameters + (declare (in) mat3x4 x) + (declare (in) mat3x4 y)) + ((declare () mat3x4 z) + (assign (constant bool (1)) (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)) (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)) (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 + (parameters + (declare (in) mat4x3 x) + (declare (in) mat4x3 y)) + ((declare () mat4x3 z) + (assign (constant bool (1)) (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)) (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)) (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)) (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/max b/src/glsl/builtins/ir/max new file mode 100644 index 00000000000..2b5a02868cc --- /dev/null +++ b/src/glsl/builtins/ir/max @@ -0,0 +1,127 @@ +((function max + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float max (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 max (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 max (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((return (expression vec2 max (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((return (expression vec3 max (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) + + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1)) + ((return (expression int max (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression ivec2 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression ivec3 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression ivec4 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1)) + ((return (expression ivec2 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1)) + ((return (expression ivec3 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1)) + ((return (expression ivec4 max (var_ref arg0) (var_ref arg1))))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1)) + ((return (expression uint max (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression uvec2 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression uvec3 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression uvec4 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1)) + ((return (expression uvec2 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1)) + ((return (expression uvec3 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1)) + ((return (expression uvec4 max (var_ref arg0) (var_ref arg1))))) +)) diff --git a/src/glsl/builtins/ir/min b/src/glsl/builtins/ir/min new file mode 100644 index 00000000000..2deef1118a7 --- /dev/null +++ b/src/glsl/builtins/ir/min @@ -0,0 +1,127 @@ +((function min + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float min (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 min (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 min (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((return (expression vec2 min (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((return (expression vec3 min (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) + + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1)) + ((return (expression int min (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression ivec2 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression ivec3 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression ivec4 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1)) + ((return (expression ivec2 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1)) + ((return (expression ivec3 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1)) + ((return (expression ivec4 min (var_ref arg0) (var_ref arg1))))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1)) + ((return (expression uint min (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression uvec2 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression uvec3 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression uvec4 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1)) + ((return (expression uvec2 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1)) + ((return (expression uvec3 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1)) + ((return (expression uvec4 min (var_ref arg0) (var_ref arg1))))) +)) diff --git a/src/glsl/builtins/ir/mix b/src/glsl/builtins/ir/mix new file mode 100644 index 00000000000..6bc6f0a43e8 --- /dev/null +++ b/src/glsl/builtins/ir/mix @@ -0,0 +1,88 @@ +((function mix + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) vec2 arg2)) + ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) vec3 arg2)) + ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) vec4 arg2)) + ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) float arg2)) + ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) float arg2)) + ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) float arg2)) + ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) + + (signature float + (parameters + (declare (in) float v1) + (declare (in) float v2) + (declare (in) bool a)) + ((assign (var_ref a) (var_ref v1) (var_ref v2)) + (return (var_ref v1)))) + + (signature vec2 + (parameters + (declare (in) vec2 v1) + (declare (in) vec2 v2) + (declare (in) bvec2 a)) + ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2))) + (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2))) + (return (var_ref v1)))) + + (signature vec3 + (parameters + (declare (in) vec3 v1) + (declare (in) vec3 v2) + (declare (in) bvec3 a)) + ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2))) + (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2))) + (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2))) + (return (var_ref v1)))) + + (signature vec4 + (parameters + (declare (in) vec4 v1) + (declare (in) vec4 v2) + (declare (in) bvec4 a)) + ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2))) + (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2))) + (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2))) + (assign (swiz w (var_ref a)) (swiz w (var_ref v1)) (swiz w (var_ref v2))) + (return (var_ref v1)))) +)) diff --git a/src/glsl/builtins/ir/mod b/src/glsl/builtins/ir/mod new file mode 100644 index 00000000000..aeaea240e2d --- /dev/null +++ b/src/glsl/builtins/ir/mod @@ -0,0 +1,43 @@ +((function mod + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float % (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 % (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 % (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((return (expression vec2 % (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((return (expression vec3 % (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) +)) diff --git a/src/glsl/builtins/ir/noise1 b/src/glsl/builtins/ir/noise1 new file mode 100644 index 00000000000..eb7be358575 --- /dev/null +++ b/src/glsl/builtins/ir/noise1 @@ -0,0 +1,18 @@ +((function noise1 + (signature float + (parameters + (declare (in) float x)) + ((return (constant float (0))))) + (signature float + (parameters + (declare (in) vec2 x)) + ((return (constant float (0))))) + (signature float + (parameters + (declare (in) vec3 x)) + ((return (constant float (0))))) + (signature float + (parameters + (declare (in) vec4 x)) + ((return (constant float (0))))) +)) diff --git a/src/glsl/builtins/ir/noise2 b/src/glsl/builtins/ir/noise2 new file mode 100644 index 00000000000..ae4443a704a --- /dev/null +++ b/src/glsl/builtins/ir/noise2 @@ -0,0 +1,18 @@ +((function noise2 + (signature vec2 + (parameters + (declare (in) float x)) + ((return (constant vec2 (0 0))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (constant vec2 (0 0))))) + (signature vec2 + (parameters + (declare (in) vec3 x)) + ((return (constant vec2 (0 0))))) + (signature vec2 + (parameters + (declare (in) vec4 x)) + ((return (constant vec2 (0 0))))) +)) diff --git a/src/glsl/builtins/ir/noise3 b/src/glsl/builtins/ir/noise3 new file mode 100644 index 00000000000..30d9681890e --- /dev/null +++ b/src/glsl/builtins/ir/noise3 @@ -0,0 +1,18 @@ +((function noise3 + (signature vec3 + (parameters + (declare (in) float x)) + ((return (constant vec3 (0 0 0))))) + (signature vec3 + (parameters + (declare (in) vec2 x)) + ((return (constant vec3 (0 0 0))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (constant vec3 (0 0 0))))) + (signature vec3 + (parameters + (declare (in) vec4 x)) + ((return (constant vec3 (0 0 0))))) +)) diff --git a/src/glsl/builtins/ir/noise4 b/src/glsl/builtins/ir/noise4 new file mode 100644 index 00000000000..913bef2aa1b --- /dev/null +++ b/src/glsl/builtins/ir/noise4 @@ -0,0 +1,18 @@ +((function noise4 + (signature vec4 + (parameters + (declare (in) float x)) + ((return (constant vec4 (0 0 0 0))))) + (signature vec4 + (parameters + (declare (in) vec2 x)) + ((return (constant vec4 (0 0 0 0))))) + (signature vec4 + (parameters + (declare (in) vec3 x)) + ((return (constant vec4 (0 0 0 0))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (constant vec4 (0 0 0 0))))) +)) diff --git a/src/glsl/builtins/ir/normalize b/src/glsl/builtins/ir/normalize new file mode 100644 index 00000000000..be88a9830d1 --- /dev/null +++ b/src/glsl/builtins/ir/normalize @@ -0,0 +1,21 @@ +((function normalize + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) +)) diff --git a/src/glsl/builtins/ir/not b/src/glsl/builtins/ir/not new file mode 100644 index 00000000000..b696b06557f --- /dev/null +++ b/src/glsl/builtins/ir/not @@ -0,0 +1,16 @@ +((function not + (signature bvec2 + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bvec2 ! (var_ref arg0))))) + + (signature bvec3 + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bvec3 ! (var_ref arg0))))) + + (signature bvec4 + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bvec4 ! (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/ir/notEqual b/src/glsl/builtins/ir/notEqual new file mode 100644 index 00000000000..bcc7339bb6e --- /dev/null +++ b/src/glsl/builtins/ir/notEqual @@ -0,0 +1,91 @@ +((function notEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((declare () bvec2 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((declare () bvec3 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (return (var_ref temp)))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((declare () bvec4 temp) + (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) + (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) + (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) + (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) + (return (var_ref temp)))) +)) diff --git a/src/glsl/builtins/ir/outerProduct b/src/glsl/builtins/ir/outerProduct new file mode 100644 index 00000000000..69ae741e176 --- /dev/null +++ b/src/glsl/builtins/ir/outerProduct @@ -0,0 +1,92 @@ +((function outerProduct + (signature mat2 + (parameters + (declare (in) vec2 u) + (declare (in) vec2 v)) + ((declare () mat2 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) + (return (var_ref m)))) + + (signature mat2x3 + (parameters + (declare (in) vec3 u) + (declare (in) vec2 v)) + ((declare () mat2x3 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) + (return (var_ref m)))) + + (signature mat2x4 + (parameters + (declare (in) vec4 u) + (declare (in) vec2 v)) + ((declare () mat2x4 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) + (return (var_ref m)))) + + (signature mat3x2 + (parameters + (declare (in) vec2 u) + (declare (in) vec3 v)) + ((declare () mat3x2 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v)))) + (return (var_ref m)) + )) + + (signature mat3 + (parameters + (declare (in) vec3 u) + (declare (in) vec3 v)) + ((declare () mat3 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v)))) + (return (var_ref m)))) + + (signature mat3x4 + (parameters + (declare (in) vec4 u) + (declare (in) vec3 v)) + ((declare () mat3x4 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v)))) + (return (var_ref m)))) + + (signature mat4x2 + (parameters + (declare (in) vec2 u) + (declare (in) vec4 v)) + ((declare () mat4x2 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v)))) + (return (var_ref m)))) + + (signature mat4x3 + (parameters + (declare (in) vec3 u) + (declare (in) vec4 v)) + ((declare () mat4x3 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v)))) + (return (var_ref m)))) + + (signature mat4 + (parameters + (declare (in) vec4 u) + (declare (in) vec4 v)) + ((declare () mat4 m) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) + (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v)))) + (assign (constant bool (1)) (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/pow b/src/glsl/builtins/ir/pow new file mode 100644 index 00000000000..a61bc4418e3 --- /dev/null +++ b/src/glsl/builtins/ir/pow @@ -0,0 +1,25 @@ +((function pow + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float pow (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 pow (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 pow (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 pow (var_ref arg0) (var_ref arg1))))) +)) diff --git a/src/glsl/builtins/ir/radians b/src/glsl/builtins/ir/radians new file mode 100644 index 00000000000..6a0f5d2e219 --- /dev/null +++ b/src/glsl/builtins/ir/radians @@ -0,0 +1,21 @@ +((function radians + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (constant float (0.017453)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (constant float (0.017453)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (constant float (0.017453)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (constant float (0.017453)))))) +)) diff --git a/src/glsl/builtins/ir/reflect b/src/glsl/builtins/ir/reflect new file mode 100644 index 00000000000..8238fdc93fd --- /dev/null +++ b/src/glsl/builtins/ir/reflect @@ -0,0 +1,58 @@ +((function reflect + (signature float + (parameters + (declare (in) float i) + (declare (in) float n)) + ((return (expression float - + (var_ref i) + (expression float * + (constant float (2.0)) + (expression float * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec2 + (parameters + (declare (in) vec2 i) + (declare (in) vec2 n)) + ((return (expression vec2 - + (var_ref i) + (expression vec2 * + (constant float (2.0)) + (expression vec2 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec3 + (parameters + (declare (in) vec3 i) + (declare (in) vec3 n)) + ((return (expression vec3 - + (var_ref i) + (expression vec3 * + (constant float (2.0)) + (expression vec3 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec4 + (parameters + (declare (in) vec4 i) + (declare (in) vec4 n)) + ((return (expression vec4 - + (var_ref i) + (expression vec4 * + (constant float (2.0)) + (expression vec4 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + +)) diff --git a/src/glsl/builtins/ir/refract b/src/glsl/builtins/ir/refract new file mode 100644 index 00000000000..522ab411734 --- /dev/null +++ b/src/glsl/builtins/ir/refract @@ -0,0 +1,102 @@ +((function refract + (signature float + (parameters + (declare (in) float i) + (declare (in) float n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant float (0.0)))) + ((return (expression float - + (expression float * (var_ref eta) (var_ref i)) + (expression float * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec2 + (parameters + (declare (in) vec2 i) + (declare (in) vec2 n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec2 (0.0 0.0)))) + ((return (expression vec2 - + (expression vec2 * (var_ref eta) (var_ref i)) + (expression vec2 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec3 + (parameters + (declare (in) vec3 i) + (declare (in) vec3 n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec3 (0.0 0.0 0.0)))) + ((return (expression vec3 - + (expression vec3 * (var_ref eta) (var_ref i)) + (expression vec3 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec4 + (parameters + (declare (in) vec4 i) + (declare (in) vec4 n) + (declare (in) float eta)) + ((declare () float k) + (assign (constant bool (1)) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec4 (0.0 0.0 0.0 0.0)))) + ((return (expression vec4 - + (expression vec4 * (var_ref eta) (var_ref i)) + (expression vec4 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + +)) diff --git a/src/glsl/builtins/ir/sign b/src/glsl/builtins/ir/sign new file mode 100644 index 00000000000..1f51718dab1 --- /dev/null +++ b/src/glsl/builtins/ir/sign @@ -0,0 +1,42 @@ +((function sign + (signature float + (parameters + (declare (in) float x)) + ((return (expression float sign (var_ref x))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 sign (var_ref x))))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 sign (var_ref x))))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 sign (var_ref x))))) + + (signature int + (parameters + (declare (in) int x)) + ((return (expression int sign (var_ref x))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 x)) + ((return (expression ivec2 sign (var_ref x))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 x)) + ((return (expression ivec3 sign (var_ref x))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 x)) + ((return (expression ivec4 sign (var_ref x))))) +)) + diff --git a/src/glsl/builtins/ir/sin b/src/glsl/builtins/ir/sin new file mode 100644 index 00000000000..e6009d8ef12 --- /dev/null +++ b/src/glsl/builtins/ir/sin @@ -0,0 +1,21 @@ +((function sin + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float sin (var_ref angle))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 sin (var_ref angle))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 sin (var_ref angle))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 sin (var_ref angle))))) +)) diff --git a/src/glsl/builtins/ir/sinh b/src/glsl/builtins/ir/sinh new file mode 100644 index 00000000000..7ad4f58e204 --- /dev/null +++ b/src/glsl/builtins/ir/sinh @@ -0,0 +1,30 @@ +((function sinh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * (constant float (0.5)) + (expression float - + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * (constant vec2 (0.5)) + (expression vec2 - + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * (constant vec3 (0.5)) + (expression vec3 - + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * (constant vec4 (0.5)) + (expression vec4 - + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/src/glsl/builtins/ir/smoothstep b/src/glsl/builtins/ir/smoothstep new file mode 100644 index 00000000000..663eec63419 --- /dev/null +++ b/src/glsl/builtins/ir/smoothstep @@ -0,0 +1,153 @@ +((function smoothstep + (signature float + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) float x)) + ((declare () float t) + + (assign (constant bool (1)) (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))) + (constant float (1.0))) + (constant float (0.0)))) + (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t)))))))) + + (signature vec2 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec2 x)) + ((declare () vec2 t) + (declare () vec2 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + (return (var_ref retval)) + )) + + (signature vec3 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec3 x)) + ((declare () vec3 t) + (declare () vec3 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) + (return (var_ref retval)) + )) + + + (signature vec4 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec4 x)) + ((declare () vec4 t) + (declare () vec4 retval) + + (assign (constant bool (1)) (swiz x (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t))))))) + + (assign (constant bool (1)) (swiz y (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t))))))) + + (assign (constant bool (1)) (swiz z (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t))))))) + + (assign (constant bool (1)) (swiz w (var_ref t)) + (expression float max + (expression float min + (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t))))))) + (return (var_ref retval)) + )) + + (signature vec2 + (parameters + (declare (in) vec2 edge0) + (declare (in) vec2 edge1) + (declare (in) vec2 x)) + ((return (expression vec2 max + (expression vec2 min + (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0))) + (constant vec2 (1.0 1.0))) + (constant vec2 (0.0 0.0)))))) + + (signature vec3 + (parameters + (declare (in) vec3 edge0) + (declare (in) vec3 edge1) + (declare (in) vec3 x)) + ((return (expression vec3 max + (expression vec3 min + (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0))) + (constant vec3 (1.0 1.0 1.0))) + (constant vec3 (0.0 0.0 0.0)))))) + + (signature vec4 + (parameters + (declare (in) vec4 edge0) + (declare (in) vec4 edge1) + (declare (in) vec4 x)) + ((return (expression vec4 max + (expression vec4 min + (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0))) + (constant vec4 (1.0 1.0 1.0 1.0))) + (constant vec4 (0.0 0.0 0.0 0.0)))))) +)) + diff --git a/src/glsl/builtins/ir/sqrt b/src/glsl/builtins/ir/sqrt new file mode 100644 index 00000000000..0302d164ae5 --- /dev/null +++ b/src/glsl/builtins/ir/sqrt @@ -0,0 +1,21 @@ +((function sqrt + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float sqrt (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 sqrt (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 sqrt (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 sqrt (var_ref arg0))))) +)) diff --git a/src/glsl/builtins/ir/step b/src/glsl/builtins/ir/step new file mode 100644 index 00000000000..ce6f4354228 --- /dev/null +++ b/src/glsl/builtins/ir/step @@ -0,0 +1,68 @@ +((function step + (signature float + (parameters + (declare (in) float edge) + (declare (in) float x)) + ((return (expression float b2f (expression bool >= (var_ref x) (var_ref edge)))))) + + (signature vec2 + (parameters + (declare (in) float edge) + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec3 + (parameters + (declare (in) float edge) + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec4 + (parameters + (declare (in) float edge) + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge)))) + (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec2 + (parameters + (declare (in) vec2 edge) + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz 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 + (parameters + (declare (in) vec3 edge) + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (constant bool (1)) (swiz 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 + (parameters + (declare (in) vec4 edge) + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz z (var_ref edge))))) + (assign (constant bool (1)) (swiz 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/tan b/src/glsl/builtins/ir/tan new file mode 100644 index 00000000000..99798631859 --- /dev/null +++ b/src/glsl/builtins/ir/tan @@ -0,0 +1,21 @@ +((function tan + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle)))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 / (expression vec2 sin (var_ref angle)) (expression vec2 cos (var_ref angle)))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 / (expression vec3 sin (var_ref angle)) (expression vec3 cos (var_ref angle)))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 / (expression vec4 sin (var_ref angle)) (expression vec4 cos (var_ref angle)))))) +)) diff --git a/src/glsl/builtins/ir/tanh b/src/glsl/builtins/ir/tanh new file mode 100644 index 00000000000..3b7271bf779 --- /dev/null +++ b/src/glsl/builtins/ir/tanh @@ -0,0 +1,42 @@ +((function tanh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float / + (expression float - + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))) + (expression float + + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 / + (expression vec2 - + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))) + (expression vec2 + + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 / + (expression vec3 - + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))) + (expression vec3 + + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 / + (expression vec4 - + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))) + (expression vec4 + + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/src/glsl/builtins/ir/transpose b/src/glsl/builtins/ir/transpose new file mode 100644 index 00000000000..416a0ee4677 --- /dev/null +++ b/src/glsl/builtins/ir/transpose @@ -0,0 +1,139 @@ +((function transpose + (signature mat2 + (parameters + (declare (in) mat2 m)) + ((declare () mat2 t) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz 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)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) + (assign (constant bool (1)) (swiz 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/profiles/110.frag b/src/glsl/builtins/profiles/110.frag new file mode 100644 index 00000000000..25bc62c093c --- /dev/null +++ b/src/glsl/builtins/profiles/110.frag @@ -0,0 +1,364 @@ +#version 110 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1D (sampler1D sampler, float coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2D (sampler2D sampler, vec2 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3D (sampler3D sampler, vec3 coord, float bias); +vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCube (samplerCube sampler, vec3 coord, float bias); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias); + + +/* + * 8.8 - Fragment Processing Functions + */ +float dFdx(float p); +vec2 dFdx(vec2 p); +vec3 dFdx(vec3 p); +vec4 dFdx(vec4 p); + +float dFdy(float p); +vec2 dFdy(vec2 p); +vec3 dFdy(vec3 p); +vec4 dFdy(vec4 p); + +float fwidth(float p); +vec2 fwidth(vec2 p); +vec3 fwidth(vec3 p); +vec4 fwidth(vec4 p); + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/src/glsl/builtins/profiles/110.vert b/src/glsl/builtins/profiles/110.vert new file mode 100644 index 00000000000..545e59c5397 --- /dev/null +++ b/src/glsl/builtins/profiles/110.vert @@ -0,0 +1,351 @@ +#version 110 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +vec4 ftransform(); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1DLod (sampler1D sampler, float coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod); +vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod); +vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod); +vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod); +vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod); + +/* + * 8.8 - Fragment Processing Functions (none in vertex shader) + */ + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/src/glsl/builtins/profiles/120.frag b/src/glsl/builtins/profiles/120.frag new file mode 100644 index 00000000000..a207435f337 --- /dev/null +++ b/src/glsl/builtins/profiles/120.frag @@ -0,0 +1,396 @@ +#version 120 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); +mat2x3 matrixCompMult(mat2x3 x, mat2x3 y); +mat2x4 matrixCompMult(mat2x4 x, mat2x4 y); +mat3x2 matrixCompMult(mat3x2 x, mat3x2 y); +mat3x4 matrixCompMult(mat3x4 x, mat3x4 y); +mat4x2 matrixCompMult(mat4x2 x, mat4x2 y); +mat4x3 matrixCompMult(mat4x3 x, mat4x3 y); + +mat2 outerProduct(vec2 c, vec2 r); +mat3 outerProduct(vec3 c, vec3 r); +mat4 outerProduct(vec4 c, vec4 r); + +mat2x3 outerProduct(vec3 c, vec2 r); +mat3x2 outerProduct(vec2 c, vec3 r); + +mat2x4 outerProduct(vec4 c, vec2 r); +mat4x2 outerProduct(vec2 c, vec4 r); + +mat3x4 outerProduct(vec4 c, vec3 r); +mat4x3 outerProduct(vec3 c, vec4 r); + +mat2 transpose(mat2 m); +mat3 transpose(mat3 m); +mat4 transpose(mat4 m); + +mat2x3 transpose(mat3x2 m); +mat3x2 transpose(mat2x3 m); + +mat2x4 transpose(mat4x2 m); +mat4x2 transpose(mat2x4 m); + +mat3x4 transpose(mat4x3 m); +mat4x3 transpose(mat3x4 m); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1D (sampler1D sampler, float coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2D (sampler2D sampler, vec2 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3D (sampler3D sampler, vec3 coord, float bias); +vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCube (samplerCube sampler, vec3 coord, float bias); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias); + + +/* + * 8.8 - Fragment Processing Functions + */ +float dFdx(float p); +vec2 dFdx(vec2 p); +vec3 dFdx(vec3 p); +vec4 dFdx(vec4 p); + +float dFdy(float p); +vec2 dFdy(vec2 p); +vec3 dFdy(vec3 p); +vec4 dFdy(vec4 p); + +float fwidth(float p); +vec2 fwidth(vec2 p); +vec3 fwidth(vec3 p); +vec4 fwidth(vec4 p); + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/src/glsl/builtins/profiles/120.vert b/src/glsl/builtins/profiles/120.vert new file mode 100644 index 00000000000..e14c931647f --- /dev/null +++ b/src/glsl/builtins/profiles/120.vert @@ -0,0 +1,383 @@ +#version 120 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +vec4 ftransform(); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); +mat2x3 matrixCompMult(mat2x3 x, mat2x3 y); +mat2x4 matrixCompMult(mat2x4 x, mat2x4 y); +mat3x2 matrixCompMult(mat3x2 x, mat3x2 y); +mat3x4 matrixCompMult(mat3x4 x, mat3x4 y); +mat4x2 matrixCompMult(mat4x2 x, mat4x2 y); +mat4x3 matrixCompMult(mat4x3 x, mat4x3 y); + +mat2 outerProduct(vec2 c, vec2 r); +mat3 outerProduct(vec3 c, vec3 r); +mat4 outerProduct(vec4 c, vec4 r); + +mat2x3 outerProduct(vec3 c, vec2 r); +mat3x2 outerProduct(vec2 c, vec3 r); + +mat2x4 outerProduct(vec4 c, vec2 r); +mat4x2 outerProduct(vec2 c, vec4 r); + +mat3x4 outerProduct(vec4 c, vec3 r); +mat4x3 outerProduct(vec3 c, vec4 r); + +mat2 transpose(mat2 m); +mat3 transpose(mat3 m); +mat4 transpose(mat4 m); + +mat2x3 transpose(mat3x2 m); +mat3x2 transpose(mat2x3 m); + +mat2x4 transpose(mat4x2 m); +mat4x2 transpose(mat2x4 m); + +mat3x4 transpose(mat4x3 m); +mat4x3 transpose(mat3x4 m); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1DLod (sampler1D sampler, float coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod); +vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod); +vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod); +vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod); +vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod); + +/* + * 8.8 - Fragment Processing Functions (none in vertex shader) + */ + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/src/glsl/builtins/profiles/ARB_texture_rectangle.frag b/src/glsl/builtins/profiles/ARB_texture_rectangle.frag new file mode 100644 index 00000000000..8938aa3e97c --- /dev/null +++ b/src/glsl/builtins/profiles/ARB_texture_rectangle.frag @@ -0,0 +1,7 @@ +#extension GL_ARB_texture_rectangle : enable +vec4 texture2DRect(sampler2DRect sampler, vec2 coord); +vec4 texture2DRectProj(sampler2DRect sampler, vec3 coord); +vec4 texture2DRectProj(sampler2DRect sampler, vec4 coord); + +vec4 shadow2DRect(sampler2DRectShadow sampler, vec3 coord); +vec4 shadow2DRectProj(sampler2DRectShadow sampler, vec4 coord); diff --git a/src/glsl/builtins/profiles/ARB_texture_rectangle.vert b/src/glsl/builtins/profiles/ARB_texture_rectangle.vert new file mode 100644 index 00000000000..8938aa3e97c --- /dev/null +++ b/src/glsl/builtins/profiles/ARB_texture_rectangle.vert @@ -0,0 +1,7 @@ +#extension GL_ARB_texture_rectangle : enable +vec4 texture2DRect(sampler2DRect sampler, vec2 coord); +vec4 texture2DRectProj(sampler2DRect sampler, vec3 coord); +vec4 texture2DRectProj(sampler2DRect sampler, vec4 coord); + +vec4 shadow2DRect(sampler2DRectShadow sampler, vec3 coord); +vec4 shadow2DRectProj(sampler2DRectShadow sampler, vec4 coord); diff --git a/src/glsl/builtins/profiles/EXT_texture_array.frag b/src/glsl/builtins/profiles/EXT_texture_array.frag new file mode 100644 index 00000000000..d133132191b --- /dev/null +++ b/src/glsl/builtins/profiles/EXT_texture_array.frag @@ -0,0 +1,11 @@ +#extension GL_EXT_texture_array : enable +vec4 texture1DArray(sampler1DArray sampler, vec2 coord); +vec4 texture1DArray(sampler1DArray sampler, vec2 coord, float bias); + +vec4 texture2DArray(sampler1DArray sampler, vec2 coord); +vec4 texture2DArray(sampler1DArray sampler, vec2 coord, float bias); + +vec4 shadow1DArray(sampler1DArrayShadow sampler, vec3 coord); +vec4 shadow1DArray(sampler1DArrayShadow sampler, vec3 coord, float bias); + +vec4 shadow2DArray(sampler2DArrayShadow sampler, vec4 coord); diff --git a/src/glsl/builtins/profiles/EXT_texture_array.vert b/src/glsl/builtins/profiles/EXT_texture_array.vert new file mode 100644 index 00000000000..4f7b2b5f8b1 --- /dev/null +++ b/src/glsl/builtins/profiles/EXT_texture_array.vert @@ -0,0 +1,11 @@ +#extension GL_EXT_texture_array : enable +vec4 texture1DArray(sampler1DArray sampler, vec2 coord); +vec4 texture1DArrayLod(sampler1DArray sampler, vec2 coord, float lod); + +vec4 texture2DArray(sampler1DArray sampler, vec2 coord); +vec4 texture2DArrayLod(sampler1DArray sampler, vec2 coord, float lod); + +vec4 shadow1DArray(sampler1DArrayShadow sampler, vec3 coord); +vec4 shadow1DArrayLod(sampler1DArrayShadow sampler, vec3 coord, float lod); + +vec4 shadow2DArray(sampler2DArrayShadow sampler, vec4 coord); diff --git a/src/glsl/builtins/tools/builtin_function.cpp b/src/glsl/builtins/tools/builtin_function.cpp new file mode 100644 index 00000000000..c44804f2ef7 --- /dev/null +++ b/src/glsl/builtins/tools/builtin_function.cpp @@ -0,0 +1,39 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "glsl_parser_extras.h" + +/* A dummy file. When compiling prototypes, we don't care about builtins. + * We really don't want to half-compile builtin_functions.cpp and fail, though. + */ +void +_mesa_glsl_release_functions(void) +{ +} + +void +_mesa_glsl_initialize_functions(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ +} diff --git a/src/glsl/builtins/tools/generate_builtins.pl b/src/glsl/builtins/tools/generate_builtins.pl deleted file mode 100755 index 91ef8917b0a..00000000000 --- a/src/glsl/builtins/tools/generate_builtins.pl +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env perl - -sub process_version { - my ($version) = @_; - my @vars; - print "/* $version builtins */\n\n"; - - my @files = ; - foreach $file (@files) { - push(@vars, process_file($file)); - } - - print "static const char *functions_for_$version [] = {\n"; - foreach $var (@vars) { - print " $var,\n"; - } - print "};\n\n" -} - -sub process_file { - my ($file) = @_; - - # Change from builtins/110/foo to builtins_110_foo - my $var = $file; $var =~ s!/!_!g; - - print "static const char *$var = {\n"; - open SRC, "<", "$file" or die $!; - while () { - s/\\/\\\\/g; - s/\"/\\\"/g; - s/\n/\\n/g; - print " \"$_\"\n"; - } - print "};\n\n"; - close SRC or die $!; - return $var; -} - -print << 'EOF'; -/* DO NOT MODIFY - automatically generated by generate_builtins.pl */ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include "main/compiler.h" -#include "glsl_parser_extras.h" -#include "ir_reader.h" -#include "program.h" - -extern "C" struct gl_shader * -_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type); - -gl_shader * -read_builtins(GLenum target, const char **functions, unsigned count) -{ - gl_shader *sh = _mesa_new_shader(NULL, 0, target); - struct _mesa_glsl_parse_state *st = - new(sh) _mesa_glsl_parse_state(NULL, target, sh); - - st->language_version = 130; - st->ARB_texture_rectangle_enable = true; - st->EXT_texture_array_enable = true; - _mesa_glsl_initialize_types(st); - - sh->ir = new(sh) exec_list; - sh->symbols = st->symbols; - - for (unsigned i = 0; i < count; i++) { - _mesa_glsl_read_ir(st, sh->ir, functions[i]); - - if (st->error) { - printf("error reading builtin: %.35s ...\n", functions[i]); - delete st; - talloc_free(sh); - return NULL; - } - } - - reparent_ir(sh->ir, sh); - delete st; - - return sh; -} - -EOF - -@versions = sort(); -foreach $version (@versions) { - $version =~ s!builtins/!!g; - process_version($version); -} - -print << 'EOF'; -void *builtin_mem_ctx = NULL; - -void -_mesa_glsl_release_functions(void) -{ - talloc_free(builtin_mem_ctx); -} - -void -_mesa_glsl_initialize_functions(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (builtin_mem_ctx == NULL) - builtin_mem_ctx = talloc_init("GLSL built-in functions"); - - state->num_builtins_to_link = 0; -EOF - -foreach $version_xs (@versions) { - $check = ""; - if ($version_xs =~ /_vs/) { - $check = "state->target == vertex_shader && "; - } elsif ($version_xs =~ /_fs/) { - $check = "state->target == fragment_shader && "; - } - $version = $version_xs; - $version =~ s/_[vf]s//g; - - if ($version =~ /^[1-9][0-9][0-9]/) { - $check = "${check}state->language_version >= $version"; - } else { - # Not a version...an extension name - $check = "${check}state->${version}_enable"; - } - print " if ($check) {\n"; - print " static gl_shader *sh = NULL;\n"; - print "\n"; - print " if (sh == NULL) {\n"; - print " sh = read_builtins(GL_VERTEX_SHADER, functions_for_$version_xs,\n"; - print " Elements(functions_for_$version_xs));\n"; - print " talloc_steal(builtin_mem_ctx, sh);\n"; - print " }\n"; - print "\n"; - print " import_prototypes(sh->ir, instructions, state->symbols, state);\n"; - print " state->builtins_to_link[state->num_builtins_to_link] = sh;\n"; - print " state->num_builtins_to_link++;\n"; - print " }\n"; - print "\n"; -} - -print "}\n"; diff --git a/src/glsl/builtins/tools/generate_builtins.py b/src/glsl/builtins/tools/generate_builtins.py new file mode 100755 index 00000000000..2eb67e398a6 --- /dev/null +++ b/src/glsl/builtins/tools/generate_builtins.py @@ -0,0 +1,207 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +import re, glob, sys +from os import path +from subprocess import Popen, PIPE + +# Local module: generator for texture lookup builtins +from texture_builtins import generate_texture_functions + +builtins_dir = path.join(path.dirname(path.abspath(__file__)), "..") + +# Read the files in builtins/ir/*...add them to the supplied dictionary. +def read_ir_files(fs): + for filename in glob.glob(path.join(path.join(builtins_dir, 'ir'), '*')): + with open(filename) as f: + fs[path.basename(filename)] = f.read() + +# Return a dictionary containing all builtin definitions (even generated) +def get_builtin_definitions(): + fs = {} + generate_texture_functions(fs) + read_ir_files(fs) + return fs + +def stringify(s): + t = s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n"\n "') + return ' "' + t + '"\n' + +def write_function_definitions(): + fs = get_builtin_definitions() + for k, v in fs.iteritems(): + print 'static const char *builtin_' + k + ' =' + print stringify(v), ';' + +def run_compiler(args): + compiler_path = path.join(path.join(builtins_dir, '..'), 'glsl_compiler') + command = [compiler_path, '--dump-lir'] + args + p = Popen(command, 1, stdout=PIPE, shell=False) + output = p.communicate()[0] + return (output, p.returncode) + +def write_profile(filename, profile): + (proto_ir, returncode) = run_compiler([filename]) + + if returncode != 0: + print '#error builtins profile', profile, 'failed to compile' + return + + # Kill any global variable declarations. We don't want them. + kill_globals = re.compile(r'^\(declare.*\n', re.MULTILINE); + proto_ir = kill_globals.sub('', proto_ir) + + print 'static const char *prototypes_for_' + profile + ' =' + print stringify(proto_ir), ';' + + # Print a table of all the functions (not signatures) referenced. + # This is done so we can avoid bothering with a hash table in the C++ code. + + function_names = set() + for func in re.finditer(r'\(function (.+)\n', proto_ir): + function_names.add(func.group(1)) + + print 'static const char *functions_for_' + profile + ' [] = {' + for func in function_names: + print ' builtin_' + func + ',' + print '};' + +def write_profiles(): + profiles = get_profile_list() + for (filename, profile) in profiles: + write_profile(filename, profile) + +def get_profile_list(): + profiles = [] + for pfile in glob.glob(path.join(path.join(builtins_dir, 'profiles'), '*')): + profiles.append((pfile, path.basename(pfile).replace('.', '_'))) + return profiles + +if __name__ == "__main__": + print """/* DO NOT MODIFY - automatically generated by generate_builtins.py */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "main/compiler.h" +#include "glsl_parser_extras.h" +#include "ir_reader.h" +#include "program.h" +#include "ast.h" + +extern "C" struct gl_shader * +_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type); + +gl_shader * +read_builtins(GLenum target, const char *protos, const char **functions, unsigned count) +{ + gl_shader *sh = _mesa_new_shader(NULL, 0, target); + struct _mesa_glsl_parse_state *st = + new(sh) _mesa_glsl_parse_state(NULL, target, sh); + + st->language_version = 130; + st->ARB_texture_rectangle_enable = true; + st->EXT_texture_array_enable = true; + _mesa_glsl_initialize_types(st); + + sh->ir = new(sh) exec_list; + sh->symbols = st->symbols; + + /* Read the IR containing the prototypes */ + _mesa_glsl_read_ir(st, sh->ir, protos, true); + + /* Read ALL the function bodies, telling the IR reader not to scan for + * prototypes (we've already created them). The IR reader will skip any + * signature that does not already exist as a prototype. + */ + for (unsigned i = 0; i < count; i++) { + _mesa_glsl_read_ir(st, sh->ir, functions[i], false); + + if (st->error) { + printf("error reading builtin: %.35s ...\\n", functions[i]); + talloc_free(sh); + return NULL; + } + } + + reparent_ir(sh->ir, sh); + delete st; + + return sh; +} +""" + + write_function_definitions() + write_profiles() + + print """ +void *builtin_mem_ctx = NULL; + +void +_mesa_glsl_release_functions(void) +{ + talloc_free(builtin_mem_ctx); +} + +void +_mesa_glsl_initialize_functions(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + if (builtin_mem_ctx == NULL) + builtin_mem_ctx = talloc_init("GLSL built-in functions"); + + state->num_builtins_to_link = 0; +""" + + profiles = get_profile_list() + for (filename, profile) in profiles: + if profile.endswith('_vert'): + check = 'state->target == vertex_shader && ' + elif profile.endswith('_frag'): + check = 'state->target == fragment_shader && ' + + version = re.sub(r'_(vert|frag)$', '', profile) + if version.isdigit(): + check += 'state->language_version == ' + version + else: # an extension name + check += 'state->' + version + '_enable' + + print ' if (' + check + ') {' + print ' static gl_shader *sh = NULL;' + print ' if (sh == NULL) {' + print ' sh = read_builtins(GL_VERTEX_SHADER,' + print ' prototypes_for_' + profile + ',' + print ' functions_for_' + profile + ',' + print ' Elements(functions_for_' + profile, + print '));' + print ' talloc_steal(builtin_mem_ctx, sh);' + print ' }' + print + print ' import_prototypes(sh->ir, instructions, state->symbols,' + print ' state);' + print ' state->builtins_to_link[state->num_builtins_to_link] = sh;' + print ' state->num_builtins_to_link++;' + print ' }' + print + print '}' + diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py index 33d9642ef78..8bf708b5aac 100755 --- a/src/glsl/builtins/tools/texture_builtins.py +++ b/src/glsl/builtins/tools/texture_builtins.py @@ -1,7 +1,7 @@ #!/usr/bin/python -from os import path import sys +import StringIO def vec_type(g, size): if size == 1: @@ -95,204 +95,255 @@ def generate_fiu_sigs(tex_inst, sampler_type, use_proj = False, unused_fields = generate_sigs("i", tex_inst, sampler_type, use_proj, unused_fields) generate_sigs("u", tex_inst, sampler_type, use_proj, unused_fields) -builtins_dir = path.join(path.dirname(path.abspath(__file__)), "..") +def start_function(name): + sys.stdout = StringIO.StringIO() + print "((function " + name -with open(path.join(builtins_dir, "130", "texture"), 'w') as sys.stdout: - print "((function texture" +def end_function(fs, name): + print "))" + fs[name] = sys.stdout.getvalue(); + sys.stdout.close() + +# Generate all the functions and store them in the supplied dictionary. +# This is better than writing them to actual files since they should never be +# edited; it'd also be easy to confuse them with the many hand-generated files. +# +# Takes a dictionary as an argument. +def generate_texture_functions(fs): + start_function("texture") generate_fiu_sigs("tex", "1D") generate_fiu_sigs("tex", "2D") generate_fiu_sigs("tex", "3D") generate_fiu_sigs("tex", "Cube") generate_fiu_sigs("tex", "1DArray") generate_fiu_sigs("tex", "2DArray") - print "))" -# txb variants are only allowed within a fragment shader (GLSL 1.30 p. 86) -with open(path.join(builtins_dir, "130_fs", "texture"), 'w') as sys.stdout: - print "((function texture" generate_fiu_sigs("txb", "1D") generate_fiu_sigs("txb", "2D") generate_fiu_sigs("txb", "3D") generate_fiu_sigs("txb", "Cube") generate_fiu_sigs("txb", "1DArray") generate_fiu_sigs("txb", "2DArray") - print "))" + end_function(fs, "texture") -with open(path.join(builtins_dir, "130", "textureProj"), 'w') as sys.stdout: - print "((function textureProj" + start_function("textureProj") generate_fiu_sigs("tex", "1D", True) generate_fiu_sigs("tex", "1D", True, 2) generate_fiu_sigs("tex", "2D", True) generate_fiu_sigs("tex", "2D", True, 1) generate_fiu_sigs("tex", "3D", True) - print "))" -with open(path.join(builtins_dir, "130_fs", "textureProj"), 'w') as sys.stdout: - print "((function textureProj" generate_fiu_sigs("txb", "1D", True) generate_fiu_sigs("txb", "1D", True, 2) generate_fiu_sigs("txb", "2D", True) generate_fiu_sigs("txb", "2D", True, 1) generate_fiu_sigs("txb", "3D", True) - print "))" + end_function(fs, "textureProj") -with open(path.join(builtins_dir, "130", "textureLod"), 'w') as sys.stdout: - print "((function textureLod" + start_function("textureLod") generate_fiu_sigs("txl", "1D") generate_fiu_sigs("txl", "2D") generate_fiu_sigs("txl", "3D") generate_fiu_sigs("txl", "Cube") generate_fiu_sigs("txl", "1DArray") generate_fiu_sigs("txl", "2DArray") - print "))" + end_function(fs, "textureLod") -with open(path.join(builtins_dir, "130", "texelFetch"), 'w') as sys.stdout: - print "((function texelFetch" + start_function("texelFetch") generate_fiu_sigs("txf", "1D") generate_fiu_sigs("txf", "2D") generate_fiu_sigs("txf", "3D") generate_fiu_sigs("txf", "1DArray") generate_fiu_sigs("txf", "2DArray") - print "))" + end_function(fs, "texelFetch") -with open(path.join(builtins_dir, "130", "textureProjLod"), 'w') as sys.stdout: - print "((function textureProjLod" + start_function("textureProjLod") generate_fiu_sigs("txl", "1D", True) generate_fiu_sigs("txl", "1D", True, 2) generate_fiu_sigs("txl", "2D", True) generate_fiu_sigs("txl", "2D", True, 1) generate_fiu_sigs("txl", "3D", True) - print "))" + end_function(fs, "textureProjLod") -with open(path.join(builtins_dir, "130", "textureGrad"), 'w') as sys.stdout: - print "((function textureGrad" + start_function("textureGrad") generate_fiu_sigs("txd", "1D") generate_fiu_sigs("txd", "2D") generate_fiu_sigs("txd", "3D") generate_fiu_sigs("txd", "Cube") generate_fiu_sigs("txd", "1DArray") generate_fiu_sigs("txd", "2DArray") - print ")\n)" + end_function(fs, "textureGrad") -with open(path.join(builtins_dir, "130", "textureProjGrad"), 'w') as sys.stdout: - print "((function textureProjGrad" + start_function("textureProjGrad") generate_fiu_sigs("txd", "1D", True) generate_fiu_sigs("txd", "1D", True, 2) generate_fiu_sigs("txd", "2D", True) generate_fiu_sigs("txd", "2D", True, 1) generate_fiu_sigs("txd", "3D", True) - print "))" + end_function(fs, "textureProjGrad") -# ARB_texture_rectangle extension -with open(path.join(builtins_dir, "ARB_texture_rectangle", "textures"), 'w') as sys.stdout: - print "((function texture2DRect" + # ARB_texture_rectangle extension + start_function("texture2DRect") generate_sigs("", "tex", "2DRect") - print ")\n (function shadow2DRect" + end_function(fs, "texture2DRect") + + start_function("texture2DRectProj") + generate_sigs("", "tex", "2DRect", True) + generate_sigs("", "tex", "2DRect", True, 1) + end_function(fs, "texture2DRectProj") + + start_function("shadow2DRect") generate_sigs("", "tex", "2DRectShadow") - print "))" + end_function(fs, "shadow2DRect") -# EXT_texture_array extension -with open(path.join(builtins_dir, "EXT_texture_array", "textures"), 'w') as sys.stdout: - print "((function texture1DArray" + start_function("shadow2DRectProj") + generate_sigs("", "tex", "2DRectShadow", True) + end_function(fs, "shadow2DRectProj") + + # EXT_texture_array extension + start_function("texture1DArray") generate_sigs("", "tex", "1DArray") - print ")\n (function texture1DArrayLod" + generate_sigs("", "txb", "1DArray") + end_function(fs, "texture1DArray") + + start_function("texture1DArrayLod") generate_sigs("", "txl", "1DArray") - print ")\n (function texture2DArray" + end_function(fs, "texture1DArrayLod") + + start_function("texture2DArray") generate_sigs("", "tex", "2DArray") - print ")\n (function texture2DArrayLod" + generate_sigs("", "txb", "2DArray") + end_function(fs, "texture2DArray") + + start_function("texture2DArrayLod") generate_sigs("", "txl", "2DArray") - print ")\n (function shadow1DArray" + end_function(fs, "texture2DArrayLod") + + start_function("shadow1DArray") generate_sigs("", "tex", "1DArrayShadow") - print ")\n (function shadow1DArrayLod" + generate_sigs("", "txb", "1DArrayShadow") + end_function(fs, "shadow1DArray") + + start_function("shadow1DArrayLod") generate_sigs("", "txl", "1DArrayShadow") - print ")\n (function shadow2DArray" - generate_sigs("", "tex", "2DArrayShadow") - print "))" + end_function(fs, "shadow1DArrayLod") -with open(path.join(builtins_dir, "EXT_texture_array_fs", "textures"), 'w') as sys.stdout: - print "((function texture1DArray" - generate_sigs("", "txb", "1DArray") - print ")\n (function texture2DArray" - generate_sigs("", "txb", "2DArray") - print ")\n (function shadow1DArray" - generate_sigs("", "txb", "1DArrayShadow") - print "))" + start_function("shadow2DArray") + generate_sigs("", "tex", "2DArrayShadow") + end_function(fs, "shadow2DArray") -# Deprecated (110/120 style) functions with silly names: -with open(path.join(builtins_dir, "110", "textures"), 'w') as sys.stdout: - print "((function texture1D" + # Deprecated (110/120 style) functions with silly names: + start_function("texture1D") generate_sigs("", "tex", "1D") - print ")\n (function texture1DLod" + generate_sigs("", "txb", "1D") + end_function(fs, "texture1D") + + start_function("texture1DLod") generate_sigs("", "txl", "1D") - print ")\n (function texture1DProj" + end_function(fs, "texture1DLod") + + start_function("texture1DProj") generate_sigs("", "tex", "1D", True) generate_sigs("", "tex", "1D", True, 2) - print ")\n (function texture1DProjLod" + generate_sigs("", "txb", "1D", True) + generate_sigs("", "txb", "1D", True, 2) + end_function(fs, "texture1DProj") + + start_function("texture1DProjLod") generate_sigs("", "txl", "1D", True) generate_sigs("", "txl", "1D", True, 2) - print ")\n (function texture2D" + end_function(fs, "texture1DProjLod") + + start_function("texture2D") generate_sigs("", "tex", "2D") - print ")\n(function texture2DLod" + generate_sigs("", "txb", "2D") + end_function(fs, "texture2D") + + start_function("texture2DLod") generate_sigs("", "txl", "2D") - print ")\n (function texture2DProj" + end_function(fs, "texture2DLod") + + start_function("texture2DProj") generate_sigs("", "tex", "2D", True) generate_sigs("", "tex", "2D", True, 1) - print ")\n (function texture2DProjLod" + generate_sigs("", "txb", "2D", True) + generate_sigs("", "txb", "2D", True, 1) + end_function(fs, "texture2DProj") + + start_function("texture2DProjLod") generate_sigs("", "txl", "2D", True) generate_sigs("", "txl", "2D", True, 1) - print ")\n (function texture3D" + end_function(fs, "texture2DProjLod") + + start_function("texture3D") generate_sigs("", "tex", "3D") - print ")\n (function texture3DLod" + generate_sigs("", "txb", "3D") + end_function(fs, "texture3D") + + start_function("texture3DLod") generate_sigs("", "txl", "3D") - print ")\n (function texture3DProj" + end_function(fs, "texture3DLod") + + start_function("texture3DProj") generate_sigs("", "tex", "3D", True) - print ")\n (function texture3DProjLod" + generate_sigs("", "txb", "3D", True) + end_function(fs, "texture3DProj") + + start_function("texture3DProjLod") generate_sigs("", "txl", "3D", True) - print ")\n (function textureCube" + end_function(fs, "texture3DProjLod") + + start_function("textureCube") generate_sigs("", "tex", "Cube") - print ")\n (function textureCubeLod" + generate_sigs("", "txb", "Cube") + end_function(fs, "textureCube") + + start_function("textureCubeLod") generate_sigs("", "txl", "Cube") - print ")\n (function shadow1D" + end_function(fs, "textureCubeLod") + + start_function("shadow1D") generate_sigs("", "tex", "1DShadow", False, 1) - print ")\n (function shadow1DLod" + generate_sigs("", "txb", "1DShadow", False, 1) + end_function(fs, "shadow1D") + + start_function("shadow1DLod") generate_sigs("", "txl", "1DShadow", False, 1) - print ")\n (function shadow1DProj" + end_function(fs, "shadow1DLod") + + start_function("shadow1DProj") generate_sigs("", "tex", "1DShadow", True, 1) - print ")\n (function shadow1DProjLod" + generate_sigs("", "txb", "1DShadow", True, 1) + end_function(fs, "shadow1DProj") + + start_function("shadow1DProjLod") generate_sigs("", "txl", "1DShadow", True, 1) - print ")\n (function shadow2D" + end_function(fs, "shadow1DProjLod") + + start_function("shadow2D") generate_sigs("", "tex", "2DShadow") - print ")\n (function shadow2DLod" + generate_sigs("", "txb", "2DShadow") + end_function(fs, "shadow2D") + + start_function("shadow2DLod") generate_sigs("", "txl", "2DShadow") - print ")\n (function shadow2DProj" + end_function(fs, "shadow2DLod") + + start_function("shadow2DProj") generate_sigs("", "tex", "2DShadow", True) - print ")\n (function shadow2DProjLod" + generate_sigs("", "txb", "2DShadow", True) + end_function(fs, "shadow2DProj") + + start_function("shadow2DProjLod") generate_sigs("", "txl", "2DShadow", True) - print "))" + end_function(fs, "shadow2DProjLod") -with open(path.join(builtins_dir, "110_fs", "textures"), 'w') as sys.stdout: - print "((function texture1D" - generate_sigs("", "txb", "1D") - print ")\n (function texture1DProj" - generate_sigs("", "txb", "1D", True) - generate_sigs("", "txb", "1D", True, 2) - print ")\n (function texture2D" - generate_sigs("", "txb", "2D") - print ")\n (function texture2DProj" - generate_sigs("", "txb", "2D", True) - generate_sigs("", "txb", "2D", True, 1) - print ")\n (function texture3D" - generate_sigs("", "txb", "3D") - print ")\n (function texture3DProj" - generate_sigs("", "txb", "3D", True) - print ")\n (function textureCube" - generate_sigs("", "txb", "Cube") - print ")\n (function shadow1D" - generate_sigs("", "txb", "1DShadow", False, 1) - print ")\n (function shadow1DProj" - generate_sigs("", "txb", "1DShadow", True, 1) - print ")\n (function shadow2D" - generate_sigs("", "txb", "2DShadow") - print ")\n (function shadow2DProj" - generate_sigs("", "txb", "2DShadow", True) - print "))" + sys.stdout = sys.__stdout__ + return fs + +# If you actually run this script, it'll print out all the functions. +if __name__ == "__main__": + fs = {} + generate_texture_functions(fs); + for k, v in fs.iteritems(): + print v diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 2def3efff56..3e221c0e5ff 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -68,7 +68,7 @@ static ir_dereference *read_record_ref(_mesa_glsl_parse_state *, s_list *); void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, - const char *src) + const char *src, bool scan_for_protos) { s_expression *expr = s_expression::read_expression(state, src); if (expr == NULL) { @@ -76,9 +76,11 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, return; } - scan_for_prototypes(state, instructions, expr); - if (state->error) - return; + if (scan_for_protos) { + scan_for_prototypes(state, instructions, expr); + if (state->error) + return; + } read_instructions(state, instructions, expr, NULL); talloc_free(expr); @@ -276,7 +278,12 @@ 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) { + if (sig == NULL && skip_body) { + /* If scanning for prototypes, generate a new signature. */ + sig = new(ctx) ir_function_signature(return_type); + sig->is_built_in = 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 " @@ -290,10 +297,11 @@ read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list, return; } } else { - sig = new(ctx) ir_function_signature(return_type); - sig->is_built_in = true; - f->add_signature(sig); + /* No prototype for this body exists - skip it. */ + st->symbols->pop_scope(); + return; } + assert(sig != NULL); sig->replace_parameters(&hir_parameters); diff --git a/src/glsl/ir_reader.h b/src/glsl/ir_reader.h index b6afdc81ab1..aef2ca23bd2 100644 --- a/src/glsl/ir_reader.h +++ b/src/glsl/ir_reader.h @@ -29,6 +29,6 @@ #include "ir.h" void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, - const char *src); + const char *src, bool scan_for_prototypes); #endif /* IR_READER_H */ -- cgit v1.2.3 From 9364ad8528b8482afd01aab9b5ebe8c9176883df Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 13 Aug 2010 17:46:25 -0700 Subject: glsl2/Makefile: Add a 'make builtins' target. This copies over a dummy builtin_functions.cpp and rebuilds a bootstrapped version of the compiler, then uses that to generate the proper list of builtins. Finally, it rebuilds the compiler with the new list. Unfortunately, it's no longer automatic, but at least it works. --- src/glsl/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index b13a612591b..1d200b47b40 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -164,8 +164,13 @@ glcpp/glcpp-lex.c: glcpp/glcpp-lex.l glcpp/glcpp-parse.c: glcpp/glcpp-parse.y bison -v -o "$@" --defines=glcpp/glcpp-parse.h $< -builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py +builtins: builtin_function.cpp builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py + @echo Bootstrapping the compiler... cp builtins/tools/builtin_function.cpp . + make glsl_compiler + @echo Regenerating builtin_function.cpp... ./builtins/tools/generate_builtins.py > builtin_function.cpp + @echo Rebuilding the real compiler... + make glsl_compiler -include depend -- cgit v1.2.3 From 2f8ee757ab324d599fcb8287789eb5f1a7890d74 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 20:18:08 -0700 Subject: mesa: Work-arounds for platforms that lack C99 math functions --- src/mesa/main/imports.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 9c2ffd66d69..846a9a0faf4 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -116,6 +116,34 @@ typedef union { GLfloat f; GLint i; } fi_type; #endif +/** + * \name Work-arounds for platforms that lack C99 math functions + */ +/*@{*/ +#if (_XOPEN_SOURCE < 600) && !defined(_ISOC99_SOURCE) \ + && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) +#define acosf(f) ((float) acos(f)) +#define asinf(f) ((float) asin(f)) +#define atan2f(f) ((float) atan2(f)) +#define atanf(f) ((float) atan(f)) +#define cielf(f) ((float) ciel(f)) +#define cosf(f) ((float) cos(f)) +#define coshf(f) ((float) cosh(f)) +#define expf(f) ((float) exp(f)) +#define exp2f(f) ((float) exp2(f)) +#define floorf(f) ((float) floor(f)) +#define logf(f) ((float) log(f)) +#define log2f(f) ((float) log2(f)) +#define powf(f) ((float) pow(f)) +#define sinf(f) ((float) sin(f)) +#define sinhf(f) ((float) sinh(f)) +#define sqrtf(f) ((float) sqrt(f)) +#define tanf(f) ((float) tan(f)) +#define tanhf(f) ((float) tanh(f)) +#define truncf(f) ((float) trunc(f)) +#endif +/*@}*/ + /*** *** LOG2: Log base 2 of float ***/ -- cgit v1.2.3 From 68f602afb1423eecf6d56bc91fc8ac7419969990 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 14 Aug 2010 12:43:56 +0100 Subject: mesa: atan2f and powf need two args. --- src/mesa/main/imports.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 846a9a0faf4..42eba33d258 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -124,7 +124,7 @@ typedef union { GLfloat f; GLint i; } fi_type; && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) #define acosf(f) ((float) acos(f)) #define asinf(f) ((float) asin(f)) -#define atan2f(f) ((float) atan2(f)) +#define atan2f(x,y) ((float) atan2(x,y)) #define atanf(f) ((float) atan(f)) #define cielf(f) ((float) ciel(f)) #define cosf(f) ((float) cos(f)) @@ -134,7 +134,7 @@ typedef union { GLfloat f; GLint i; } fi_type; #define floorf(f) ((float) floor(f)) #define logf(f) ((float) log(f)) #define log2f(f) ((float) log2(f)) -#define powf(f) ((float) pow(f)) +#define powf(x,y) ((float) pow(x,y)) #define sinf(f) ((float) sin(f)) #define sinhf(f) ((float) sinh(f)) #define sqrtf(f) ((float) sqrt(f)) -- cgit v1.2.3 From 2322404b5537b04c111bb985e07826d6b898dbcf Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 14 Aug 2010 12:45:14 +0100 Subject: scons: Add new source files. --- src/glsl/SConscript | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/SConscript b/src/glsl/SConscript index 90759275ca7..96a226d0dd2 100644 --- a/src/glsl/SConscript +++ b/src/glsl/SConscript @@ -52,8 +52,10 @@ sources = [ 'ir_import_prototypes.cpp', 'ir_mat_op_to_vec.cpp', 'ir_mod_to_fract.cpp', + 'ir_noop_swizzle.cpp', 'ir_print_visitor.cpp', 'ir_reader.cpp', + 'ir_rvalue_visitor.cpp', 'ir_set_program_inouts.cpp', 'ir_structure_splitting.cpp', 'ir_sub_to_add_neg.cpp', -- cgit v1.2.3 From 8881b0fe43540c44c1b6ba95d51651fc6b612ffb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 14 Aug 2010 13:10:24 +0100 Subject: mesa: Recent versions of MSVC define the single precision functions already. --- src/mesa/main/imports.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 42eba33d258..a439370bc4c 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -121,7 +121,8 @@ typedef union { GLfloat f; GLint i; } fi_type; */ /*@{*/ #if (_XOPEN_SOURCE < 600) && !defined(_ISOC99_SOURCE) \ - && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) + && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \ + && (!defined(_MSC_VER) || (_MSC_VER < 1400)) #define acosf(f) ((float) acos(f)) #define asinf(f) ((float) asin(f)) #define atan2f(x,y) ((float) atan2(x,y)) -- cgit v1.2.3 From 325aa1b3cd3fa2dcfc936d2024a4493c06f3b3f4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 14 Aug 2010 14:38:09 +0100 Subject: mesa: Silence gcc warning "missing initializer for member". --- src/mesa/program/ir_to_mesa.cpp | 56 ++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 7490ffa4fe7..cf1fb91a70b 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -980,51 +980,51 @@ static const struct { bool array_indexed; } statevars[] = { {"gl_DepthRange", "near", - {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX}, + {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX, false}, {"gl_DepthRange", "far", - {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_YYYY}, + {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_YYYY, false}, {"gl_DepthRange", "diff", - {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_ZZZZ}, + {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_ZZZZ, false}, {"gl_ClipPlane", NULL, {STATE_CLIPPLANE, 0, 0}, SWIZZLE_XYZW, true} , {"gl_Point", "size", - {STATE_POINT_SIZE}, SWIZZLE_XXXX}, + {STATE_POINT_SIZE}, SWIZZLE_XXXX, false}, {"gl_Point", "sizeMin", - {STATE_POINT_SIZE}, SWIZZLE_YYYY}, + {STATE_POINT_SIZE}, SWIZZLE_YYYY, false}, {"gl_Point", "sizeMax", - {STATE_POINT_SIZE}, SWIZZLE_ZZZZ}, + {STATE_POINT_SIZE}, SWIZZLE_ZZZZ, false}, {"gl_Point", "fadeThresholdSize", - {STATE_POINT_SIZE}, SWIZZLE_WWWW}, + {STATE_POINT_SIZE}, SWIZZLE_WWWW, false}, {"gl_Point", "distanceConstantAttenuation", - {STATE_POINT_ATTENUATION}, SWIZZLE_XXXX}, + {STATE_POINT_ATTENUATION}, SWIZZLE_XXXX, false}, {"gl_Point", "distanceLinearAttenuation", - {STATE_POINT_ATTENUATION}, SWIZZLE_YYYY}, + {STATE_POINT_ATTENUATION}, SWIZZLE_YYYY, false}, {"gl_Point", "distanceQuadraticAttenuation", - {STATE_POINT_ATTENUATION}, SWIZZLE_ZZZZ}, + {STATE_POINT_ATTENUATION}, SWIZZLE_ZZZZ, false}, {"gl_FrontMaterial", "emission", - {STATE_MATERIAL, 0, STATE_EMISSION}, SWIZZLE_XYZW}, + {STATE_MATERIAL, 0, STATE_EMISSION}, SWIZZLE_XYZW, false}, {"gl_FrontMaterial", "ambient", - {STATE_MATERIAL, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, + {STATE_MATERIAL, 0, STATE_AMBIENT}, SWIZZLE_XYZW, false}, {"gl_FrontMaterial", "diffuse", - {STATE_MATERIAL, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {STATE_MATERIAL, 0, STATE_DIFFUSE}, SWIZZLE_XYZW, false}, {"gl_FrontMaterial", "specular", - {STATE_MATERIAL, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, + {STATE_MATERIAL, 0, STATE_SPECULAR}, SWIZZLE_XYZW, false}, {"gl_FrontMaterial", "shininess", - {STATE_MATERIAL, 0, STATE_SHININESS}, SWIZZLE_XXXX}, + {STATE_MATERIAL, 0, STATE_SHININESS}, SWIZZLE_XXXX, false}, {"gl_BackMaterial", "emission", - {STATE_MATERIAL, 1, STATE_EMISSION}, SWIZZLE_XYZW}, + {STATE_MATERIAL, 1, STATE_EMISSION}, SWIZZLE_XYZW, false}, {"gl_BackMaterial", "ambient", - {STATE_MATERIAL, 1, STATE_AMBIENT}, SWIZZLE_XYZW}, + {STATE_MATERIAL, 1, STATE_AMBIENT}, SWIZZLE_XYZW, false}, {"gl_BackMaterial", "diffuse", - {STATE_MATERIAL, 1, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {STATE_MATERIAL, 1, STATE_DIFFUSE}, SWIZZLE_XYZW, false}, {"gl_BackMaterial", "specular", - {STATE_MATERIAL, 1, STATE_SPECULAR}, SWIZZLE_XYZW}, + {STATE_MATERIAL, 1, STATE_SPECULAR}, SWIZZLE_XYZW, false}, {"gl_BackMaterial", "shininess", - {STATE_MATERIAL, 1, STATE_SHININESS}, SWIZZLE_XXXX}, + {STATE_MATERIAL, 1, STATE_SHININESS}, SWIZZLE_XXXX, false}, {"gl_LightSource", "ambient", {STATE_LIGHT, 0, STATE_AMBIENT}, SWIZZLE_XYZW, true}, @@ -1052,12 +1052,12 @@ static const struct { {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_ZZZZ, true}, {"gl_LightModel", NULL, - {STATE_LIGHTMODEL_AMBIENT, 0}, SWIZZLE_XYZW}, + {STATE_LIGHTMODEL_AMBIENT, 0}, SWIZZLE_XYZW, false}, {"gl_FrontLightModelProduct", NULL, - {STATE_LIGHTMODEL_SCENECOLOR, 0}, SWIZZLE_XYZW}, + {STATE_LIGHTMODEL_SCENECOLOR, 0}, SWIZZLE_XYZW, false}, {"gl_BackLightModelProduct", NULL, - {STATE_LIGHTMODEL_SCENECOLOR, 1}, SWIZZLE_XYZW}, + {STATE_LIGHTMODEL_SCENECOLOR, 1}, SWIZZLE_XYZW, false}, {"gl_FrontLightProduct", "ambient", {STATE_LIGHTPROD, 0, 0, STATE_AMBIENT}, SWIZZLE_XYZW, true}, @@ -1095,15 +1095,15 @@ static const struct { {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_Q}, SWIZZLE_XYZW, true}, {"gl_Fog", "color", - {STATE_FOG_COLOR}, SWIZZLE_XYZW}, + {STATE_FOG_COLOR}, SWIZZLE_XYZW, false}, {"gl_Fog", "density", - {STATE_FOG_PARAMS}, SWIZZLE_XXXX}, + {STATE_FOG_PARAMS}, SWIZZLE_XXXX, false}, {"gl_Fog", "start", - {STATE_FOG_PARAMS}, SWIZZLE_YYYY}, + {STATE_FOG_PARAMS}, SWIZZLE_YYYY, false}, {"gl_Fog", "end", - {STATE_FOG_PARAMS}, SWIZZLE_ZZZZ}, + {STATE_FOG_PARAMS}, SWIZZLE_ZZZZ, false}, {"gl_Fog", "scale", - {STATE_FOG_PARAMS}, SWIZZLE_WWWW}, + {STATE_FOG_PARAMS}, SWIZZLE_WWWW, false}, }; static ir_to_mesa_src_reg -- cgit v1.2.3 From 19acfa42ed47edb63f5ec3de8051a3102e62e96b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 14 Aug 2010 14:40:06 +0100 Subject: mesa: Silence gcc warning "control reaches end of non-void function". --- src/mesa/program/ir_to_mesa.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index cf1fb91a70b..2208bc1ce81 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -526,6 +526,7 @@ type_size(const struct glsl_type *type) return 0; default: assert(0); + return 0; } } -- cgit v1.2.3 From 4b1721eaf35ccb60d90850ab34a99d6ab1f89a05 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 14 Aug 2010 14:40:39 +0100 Subject: glsl: Silence gcc warning "control reaches end of non-void function". --- src/glsl/ir_clone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index a72609601ae..0a9e25a295a 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -335,7 +335,7 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const } default: - assert(!"Should not get here."); break; + assert(!"Should not get here."); return NULL; } } -- cgit v1.2.3 From 1d22923fae7f4c749b3820844110e3d8ee4d26c0 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 14 Aug 2010 15:29:15 +0100 Subject: scons: Link talloc. --- src/gallium/targets/libgl-xlib/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 78703fd096d..88e216a65be 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -35,6 +35,7 @@ env.Prepend(LIBS = [ mesa, glsl, gallium, + 'talloc' ]) sources = [ -- cgit v1.2.3 From 1cbcf6693aa490c4dcb56712bfb9998deb270f08 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 14 Aug 2010 15:35:57 +0100 Subject: glsl: Standardize a few more uses of struct vs class keyword. --- src/glsl/glsl_symbol_table.h | 2 +- src/glsl/glsl_types.h | 13 +++++++------ src/glsl/ir.h | 4 ++-- src/glsl/ir_structure_splitting.cpp | 4 ++-- src/glsl/ir_tree_grafting.cpp | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h index 02e4542cf3d..4cb7559e9a0 100644 --- a/src/glsl/glsl_symbol_table.h +++ b/src/glsl/glsl_symbol_table.h @@ -40,7 +40,7 @@ extern "C" { * Wraps the existing \c _mesa_symbol_table data structure to enforce some * type safe and some symbol table invariants. */ -class glsl_symbol_table { +struct glsl_symbol_table { private: enum glsl_symbol_name_space { glsl_variable_name_space = 0, diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 97d0d98c624..80cec635d99 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -35,6 +35,7 @@ extern "C" { } struct _mesa_glsl_parse_state; +struct glsl_symbol_table; extern "C" void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); @@ -209,7 +210,7 @@ struct glsl_type { /** * Generate the constructor for this type and add it to the symbol table */ - class ir_function *generate_constructor(class glsl_symbol_table *) const; + class ir_function *generate_constructor(glsl_symbol_table *) const; /** * Query the total number of scalars that make up a scalar, vector or matrix @@ -449,12 +450,12 @@ private: * the world in a public header file. */ /*@{*/ - static void generate_110_types(class glsl_symbol_table *); - static void generate_120_types(class glsl_symbol_table *); - static void generate_130_types(class glsl_symbol_table *); - static void generate_ARB_texture_rectangle_types(class glsl_symbol_table *, + static void generate_110_types(glsl_symbol_table *); + static void generate_120_types(glsl_symbol_table *); + static void generate_130_types(glsl_symbol_table *); + static void generate_ARB_texture_rectangle_types(glsl_symbol_table *, bool); - static void generate_EXT_texture_array_types(class glsl_symbol_table *, + static void generate_EXT_texture_array_types(glsl_symbol_table *, bool); /*@}*/ diff --git a/src/glsl/ir.h b/src/glsl/ir.h index eb9e6cdf0e2..b04222893cf 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1383,11 +1383,11 @@ _mesa_glsl_release_functions(void); extern void reparent_ir(exec_list *list, void *mem_ctx); -class glsl_symbol_table; +struct glsl_symbol_table; extern void import_prototypes(const exec_list *source, exec_list *dest, - class glsl_symbol_table *symbols, void *mem_ctx); + struct glsl_symbol_table *symbols, void *mem_ctx); extern bool ir_has_call(ir_instruction *ir); diff --git a/src/glsl/ir_structure_splitting.cpp b/src/glsl/ir_structure_splitting.cpp index e257defb1a1..c0244071ee2 100644 --- a/src/glsl/ir_structure_splitting.cpp +++ b/src/glsl/ir_structure_splitting.cpp @@ -181,13 +181,13 @@ public: void split_deref(ir_dereference **deref); void handle_rvalue(ir_rvalue **rvalue); - struct variable_entry *get_splitting_entry(ir_variable *var); + variable_entry *get_splitting_entry(ir_variable *var); exec_list *variable_list; void *mem_ctx; }; -struct variable_entry * +variable_entry * ir_structure_splitting_visitor::get_splitting_entry(ir_variable *var) { assert(var); diff --git a/src/glsl/ir_tree_grafting.cpp b/src/glsl/ir_tree_grafting.cpp index e80db31cb30..6acc5b86c51 100644 --- a/src/glsl/ir_tree_grafting.cpp +++ b/src/glsl/ir_tree_grafting.cpp @@ -324,7 +324,7 @@ tree_grafting_basic_block(ir_instruction *bb_first, lhs_var->mode == ir_var_inout) continue; - struct variable_entry *entry = info->refs->get_variable_entry(lhs_var); + variable_entry *entry = info->refs->get_variable_entry(lhs_var); if (!entry->declaration || entry->assigned_count != 1 || -- cgit v1.2.3 From 8df0bea9c58e983ded6819914c532edf52737cb7 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 14 Aug 2010 16:00:52 +0100 Subject: Replace our custom C99 headers with http://code.google.com/p/msinttypes/ Perhaps http://www.azillionmonkeys.com/qed/pstdint.h would be a better (more portable) choice, but only MSVC uses this anyway, and we can always change later. --- include/c99/inttypes.h | 305 ++++++++++++++++++++++++++++++++++++++++++++ include/c99/stdint.h | 339 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 538 insertions(+), 106 deletions(-) create mode 100644 include/c99/inttypes.h diff --git a/include/c99/inttypes.h b/include/c99/inttypes.h new file mode 100644 index 00000000000..4b3828a2162 --- /dev/null +++ b/include/c99/inttypes.h @@ -0,0 +1,305 @@ +// ISO C9x compliant inttypes.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_INTTYPES_H_ // [ +#define _MSC_INTTYPES_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include "stdint.h" + +// 7.8 Format conversion of integer types + +typedef struct { + intmax_t quot; + intmax_t rem; +} imaxdiv_t; + +// 7.8.1 Macros for format specifiers + +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 + +// The fprintf macros for signed integers are: +#define PRId8 "d" +#define PRIi8 "i" +#define PRIdLEAST8 "d" +#define PRIiLEAST8 "i" +#define PRIdFAST8 "d" +#define PRIiFAST8 "i" + +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIdLEAST16 "hd" +#define PRIiLEAST16 "hi" +#define PRIdFAST16 "hd" +#define PRIiFAST16 "hi" + +#define PRId32 "I32d" +#define PRIi32 "I32i" +#define PRIdLEAST32 "I32d" +#define PRIiLEAST32 "I32i" +#define PRIdFAST32 "I32d" +#define PRIiFAST32 "I32i" + +#define PRId64 "I64d" +#define PRIi64 "I64i" +#define PRIdLEAST64 "I64d" +#define PRIiLEAST64 "I64i" +#define PRIdFAST64 "I64d" +#define PRIiFAST64 "I64i" + +#define PRIdMAX "I64d" +#define PRIiMAX "I64i" + +#define PRIdPTR "Id" +#define PRIiPTR "Ii" + +// The fprintf macros for unsigned integers are: +#define PRIo8 "o" +#define PRIu8 "u" +#define PRIx8 "x" +#define PRIX8 "X" +#define PRIoLEAST8 "o" +#define PRIuLEAST8 "u" +#define PRIxLEAST8 "x" +#define PRIXLEAST8 "X" +#define PRIoFAST8 "o" +#define PRIuFAST8 "u" +#define PRIxFAST8 "x" +#define PRIXFAST8 "X" + +#define PRIo16 "ho" +#define PRIu16 "hu" +#define PRIx16 "hx" +#define PRIX16 "hX" +#define PRIoLEAST16 "ho" +#define PRIuLEAST16 "hu" +#define PRIxLEAST16 "hx" +#define PRIXLEAST16 "hX" +#define PRIoFAST16 "ho" +#define PRIuFAST16 "hu" +#define PRIxFAST16 "hx" +#define PRIXFAST16 "hX" + +#define PRIo32 "I32o" +#define PRIu32 "I32u" +#define PRIx32 "I32x" +#define PRIX32 "I32X" +#define PRIoLEAST32 "I32o" +#define PRIuLEAST32 "I32u" +#define PRIxLEAST32 "I32x" +#define PRIXLEAST32 "I32X" +#define PRIoFAST32 "I32o" +#define PRIuFAST32 "I32u" +#define PRIxFAST32 "I32x" +#define PRIXFAST32 "I32X" + +#define PRIo64 "I64o" +#define PRIu64 "I64u" +#define PRIx64 "I64x" +#define PRIX64 "I64X" +#define PRIoLEAST64 "I64o" +#define PRIuLEAST64 "I64u" +#define PRIxLEAST64 "I64x" +#define PRIXLEAST64 "I64X" +#define PRIoFAST64 "I64o" +#define PRIuFAST64 "I64u" +#define PRIxFAST64 "I64x" +#define PRIXFAST64 "I64X" + +#define PRIoMAX "I64o" +#define PRIuMAX "I64u" +#define PRIxMAX "I64x" +#define PRIXMAX "I64X" + +#define PRIoPTR "Io" +#define PRIuPTR "Iu" +#define PRIxPTR "Ix" +#define PRIXPTR "IX" + +// The fscanf macros for signed integers are: +#define SCNd8 "d" +#define SCNi8 "i" +#define SCNdLEAST8 "d" +#define SCNiLEAST8 "i" +#define SCNdFAST8 "d" +#define SCNiFAST8 "i" + +#define SCNd16 "hd" +#define SCNi16 "hi" +#define SCNdLEAST16 "hd" +#define SCNiLEAST16 "hi" +#define SCNdFAST16 "hd" +#define SCNiFAST16 "hi" + +#define SCNd32 "ld" +#define SCNi32 "li" +#define SCNdLEAST32 "ld" +#define SCNiLEAST32 "li" +#define SCNdFAST32 "ld" +#define SCNiFAST32 "li" + +#define SCNd64 "I64d" +#define SCNi64 "I64i" +#define SCNdLEAST64 "I64d" +#define SCNiLEAST64 "I64i" +#define SCNdFAST64 "I64d" +#define SCNiFAST64 "I64i" + +#define SCNdMAX "I64d" +#define SCNiMAX "I64i" + +#ifdef _WIN64 // [ +# define SCNdPTR "I64d" +# define SCNiPTR "I64i" +#else // _WIN64 ][ +# define SCNdPTR "ld" +# define SCNiPTR "li" +#endif // _WIN64 ] + +// The fscanf macros for unsigned integers are: +#define SCNo8 "o" +#define SCNu8 "u" +#define SCNx8 "x" +#define SCNX8 "X" +#define SCNoLEAST8 "o" +#define SCNuLEAST8 "u" +#define SCNxLEAST8 "x" +#define SCNXLEAST8 "X" +#define SCNoFAST8 "o" +#define SCNuFAST8 "u" +#define SCNxFAST8 "x" +#define SCNXFAST8 "X" + +#define SCNo16 "ho" +#define SCNu16 "hu" +#define SCNx16 "hx" +#define SCNX16 "hX" +#define SCNoLEAST16 "ho" +#define SCNuLEAST16 "hu" +#define SCNxLEAST16 "hx" +#define SCNXLEAST16 "hX" +#define SCNoFAST16 "ho" +#define SCNuFAST16 "hu" +#define SCNxFAST16 "hx" +#define SCNXFAST16 "hX" + +#define SCNo32 "lo" +#define SCNu32 "lu" +#define SCNx32 "lx" +#define SCNX32 "lX" +#define SCNoLEAST32 "lo" +#define SCNuLEAST32 "lu" +#define SCNxLEAST32 "lx" +#define SCNXLEAST32 "lX" +#define SCNoFAST32 "lo" +#define SCNuFAST32 "lu" +#define SCNxFAST32 "lx" +#define SCNXFAST32 "lX" + +#define SCNo64 "I64o" +#define SCNu64 "I64u" +#define SCNx64 "I64x" +#define SCNX64 "I64X" +#define SCNoLEAST64 "I64o" +#define SCNuLEAST64 "I64u" +#define SCNxLEAST64 "I64x" +#define SCNXLEAST64 "I64X" +#define SCNoFAST64 "I64o" +#define SCNuFAST64 "I64u" +#define SCNxFAST64 "I64x" +#define SCNXFAST64 "I64X" + +#define SCNoMAX "I64o" +#define SCNuMAX "I64u" +#define SCNxMAX "I64x" +#define SCNXMAX "I64X" + +#ifdef _WIN64 // [ +# define SCNoPTR "I64o" +# define SCNuPTR "I64u" +# define SCNxPTR "I64x" +# define SCNXPTR "I64X" +#else // _WIN64 ][ +# define SCNoPTR "lo" +# define SCNuPTR "lu" +# define SCNxPTR "lx" +# define SCNXPTR "lX" +#endif // _WIN64 ] + +#endif // __STDC_FORMAT_MACROS ] + +// 7.8.2 Functions for greatest-width integer types + +// 7.8.2.1 The imaxabs function +#define imaxabs _abs64 + +// 7.8.2.2 The imaxdiv function + +// This is modified version of div() function from Microsoft's div.c found +// in %MSVC.NET%\crt\src\div.c +#ifdef STATIC_IMAXDIV // [ +static +#else // STATIC_IMAXDIV ][ +_inline +#endif // STATIC_IMAXDIV ] +imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) +{ + imaxdiv_t result; + + result.quot = numer / denom; + result.rem = numer % denom; + + if (numer < 0 && result.rem > 0) { + // did division wrong; must fix up + ++result.quot; + result.rem -= denom; + } + + return result; +} + +// 7.8.2.3 The strtoimax and strtoumax functions +#define strtoimax _strtoi64 +#define strtoumax _strtoui64 + +// 7.8.2.4 The wcstoimax and wcstoumax functions +#define wcstoimax _wcstoi64 +#define wcstoumax _wcstoui64 + + +#endif // _MSC_INTTYPES_H_ ] diff --git a/include/c99/stdint.h b/include/c99/stdint.h index 6f40e0c74a2..d02608a5972 100644 --- a/include/c99/stdint.h +++ b/include/c99/stdint.h @@ -1,120 +1,247 @@ -/************************************************************************** - * - * Copyright 2007-2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - **************************************************************************/ - -/* - * stdint.h -- - * - * Portable subset of C99's stdint.h. - * - * At the moment it only supports MSVC, given all other mainstream compilers - * already support C99. If this is necessary for other compilers then it - * might be worth to replace this with - * http://www.azillionmonkeys.com/qed/pstdint.h. - */ - -#ifndef _STDINT_H_ -#define _STDINT_H_ - - -#ifndef INT8_MAX -#define INT8_MAX 127 -#endif -#ifndef INT8_MIN -#define INT8_MIN -128 -#endif -#ifndef UINT8_MAX -#define UINT8_MAX 255 -#endif -#ifndef INT16_MAX -#define INT16_MAX 32767 -#endif -#ifndef INT16_MIN -#define INT16_MIN -32768 -#endif -#ifndef UINT16_MAX -#define UINT16_MAX 65535 -#endif -#ifndef INT32_MAX -#define INT32_MAX 2147483647 -#endif -#ifndef INT32_MIN -#define INT32_MIN -2147483648 -#endif -#ifndef UINT32_MAX -#define UINT32_MAX 4294967295U -#endif +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// -#ifndef INT8_C -#define INT8_C(__val) __val -#endif -#ifndef UINT8_C -#define UINT8_C(__val) __val -#endif -#ifndef INT16_C -#define INT16_C(__val) __val +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once #endif -#ifndef UINT16_C -#define UINT16_C(__val) __val + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { #endif -#ifndef INT32_C -#define INT32_C(__val) __val +# include +#ifdef __cplusplus +} #endif -#ifndef UINT32_C -#define UINT32_C(__val) __val##U + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif #endif -#if defined(_MSC_VER) +// 7.18.1 Integer types -typedef __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; +// 7.18.1.1 Exact-width integer types -#if defined(_WIN64) -typedef __int64 intptr_t; -typedef unsigned __int64 uintptr_t; +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; #else -typedef __int32 intptr_t; -typedef unsigned __int32 uintptr_t; -#endif + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; -#define INT64_C(__val) __val##i64 -#define UINT64_C(__val) __val##ui64 -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] -#else -#error "Unsupported compiler" -#endif -#endif /* _STDINT_H_ */ +#endif // _MSC_STDINT_H_ ] -- cgit v1.2.3 From 9349379d1acca23e7a2442549e49e9b58515d731 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 14 Aug 2010 16:01:24 +0100 Subject: Revert "glsl2: Use stdint.h instead of inttypes.h" This reverts commit a77a6bc008b3146c56431fa520a00e1f8dfa3938. --- src/glsl/glcpp/glcpp-parse.c | 2 +- src/glsl/glcpp/glcpp-parse.y | 2 +- src/glsl/ir_function_inlining.cpp | 2 +- src/glsl/ir_validate.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 579fe7c7ad8..bd0fbc4fcf2 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -96,7 +96,7 @@ #include #include #include -#include +#include #include "glcpp.h" #include "main/mtypes.h" diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index ce4197e240c..3d08ce6c75f 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include "glcpp.h" #include "main/mtypes.h" diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 56d29e3fd16..874602c84f2 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -27,7 +27,7 @@ * Replaces calls to functions with the body of the function. */ -#include +#include #include "ir.h" #include "ir_visitor.h" #include "ir_function_inlining.h" diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 905b3c76721..6e08fa4025a 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -33,7 +33,7 @@ * a dereference chain. */ -#include +#include #include "ir.h" #include "ir_hierarchical_visitor.h" #include "program/hash_table.h" -- cgit v1.2.3 From a0b0afc6944b00df27145a96ad2727a36752e1d6 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 15 Aug 2010 13:08:15 -0700 Subject: mesa: Check that _XOPEN_SOURCE is defined before using it. --- src/mesa/main/imports.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index a439370bc4c..e967b147311 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -120,7 +120,7 @@ typedef union { GLfloat f; GLint i; } fi_type; * \name Work-arounds for platforms that lack C99 math functions */ /*@{*/ -#if (_XOPEN_SOURCE < 600) && !defined(_ISOC99_SOURCE) \ +#if (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \ && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \ && (!defined(_MSC_VER) || (_MSC_VER < 1400)) #define acosf(f) ((float) acos(f)) -- cgit v1.2.3 From 83baa8a6c5541829003bbffe1d2b8cee5a0263fd Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 16 Aug 2010 01:53:30 +0200 Subject: st/mesa: remove output register reads inside shaders This is a GLSL2 regression fix. --- src/mesa/state_tracker/st_program.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 91528c227b2..8c2d8b6154b 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -207,6 +207,9 @@ st_translate_vertex_program(struct st_context *st, enum pipe_error error; unsigned num_outputs; + _mesa_remove_output_reads(&stvp->Base.Base, PROGRAM_OUTPUT); + _mesa_remove_output_reads(&stvp->Base.Base, PROGRAM_VARYING); + ureg = ureg_create( TGSI_PROCESSOR_VERTEX ); if (ureg == NULL) { FREE(vpv); @@ -298,6 +301,8 @@ st_translate_fragment_program(struct st_context *st, ubyte fs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; uint fs_num_outputs = 0; + _mesa_remove_output_reads(&stfp->Base.Base, PROGRAM_OUTPUT); + /* * Convert Mesa program inputs to TGSI input register semantics. */ @@ -485,6 +490,9 @@ st_translate_geometry_program(struct st_context *st, GLuint maxSlot = 0; struct ureg_program *ureg; + _mesa_remove_output_reads(&stgp->Base.Base, PROGRAM_OUTPUT); + _mesa_remove_output_reads(&stgp->Base.Base, PROGRAM_VARYING); + ureg = ureg_create( TGSI_PROCESSOR_GEOMETRY ); if (ureg == NULL) { return; -- cgit v1.2.3 From 0bf63733e54b47daf9f50c32a1fca4039c82def2 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 16 Aug 2010 09:39:58 -0700 Subject: ir_to_mesa: Support texture rectangle targets --- src/mesa/program/ir_to_mesa.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 2208bc1ce81..b8a35ce162b 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2090,6 +2090,9 @@ ir_to_mesa_visitor::visit(ir_texture *ir) case GLSL_SAMPLER_DIM_CUBE: inst->tex_target = TEXTURE_CUBE_INDEX; break; + case GLSL_SAMPLER_DIM_RECT: + inst->tex_target = TEXTURE_RECT_INDEX; + break; default: assert(!"FINISHME: other texture targets"); } -- cgit v1.2.3 From 68772031e6242aa78864dc9c7c1a607aec5ee7b9 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 16 Aug 2010 09:43:00 -0700 Subject: ir_to_mesa: Clean up assertions in ir_to_mesa_visitor::visit(ir_texture *) --- src/mesa/program/ir_to_mesa.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index b8a35ce162b..06a6bc33206 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2093,8 +2093,11 @@ ir_to_mesa_visitor::visit(ir_texture *ir) case GLSL_SAMPLER_DIM_RECT: inst->tex_target = TEXTURE_RECT_INDEX; break; + case GLSL_SAMPLER_DIM_BUF: + assert(!"FINISHME: Implement ARB_texture_buffer_object"); + break; default: - assert(!"FINISHME: other texture targets"); + assert(!"Should not get here."); } this->result = result_src; -- cgit v1.2.3 From fc63e37b971b641dfdff000ba353c4810414c20e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 16 Aug 2010 09:45:01 -0700 Subject: ir_to_mesa: Silence unused variable warnings --- src/mesa/program/ir_to_mesa.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 06a6bc33206..1fb578516ce 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1632,8 +1632,7 @@ ir_to_mesa_visitor::visit(ir_dereference_record *ir) * ir_dereference handler. */ static struct ir_to_mesa_dst_reg -get_assignment_lhs(ir_dereference *ir, ir_to_mesa_visitor *v, - ir_to_mesa_src_reg *r) +get_assignment_lhs(ir_dereference *ir, ir_to_mesa_visitor *v) { /* The LHS must be a dereference. If the LHS is a variable indexed array * access of a vector, it must be separated into a series conditional moves @@ -1662,7 +1661,7 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) ir->rhs->accept(this); r = this->result; - l = get_assignment_lhs(ir->lhs, this, &r); + l = get_assignment_lhs(ir->lhs, this); /* FINISHME: This should really set to the correct maximal writemask for each * FINISHME: component written (in the loops below). This case can only @@ -2554,6 +2553,7 @@ GLboolean _mesa_ir_compile_shader(GLcontext *ctx, struct gl_shader *shader) { assert(shader->CompileStatus); + (void) ctx; return GL_TRUE; } -- cgit v1.2.3 From 6be3a8b70af4ba4fa4d037d54ecf6d5f055edbc9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 16 Aug 2010 13:42:04 -0700 Subject: glcpp: Remove spurious newline generated by #version handling. This was causing line numbering to be off by one. The newline comes from the NEWLINE token at the end of the line; there's no need to insert one. --- src/glsl/glcpp/glcpp-lex.l | 4 +--- src/glsl/glcpp/glcpp-parse.y | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 1cd95b238d2..9187926146a 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -88,10 +88,8 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return SPACE; } -{HASH}(version) { +{HASH}version { yylval->str = talloc_strdup (yyextra, yytext); - yylineno++; - yycolumn = 0; yyextra->space_tokens = 0; return HASH_VERSION; } diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 3d08ce6c75f..c91da15519e 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -309,7 +309,7 @@ control_line: talloc_free (macro); } add_builtin_define (parser, "__VERSION__", $2); - glcpp_printf(parser->output, "#version %" PRIiMAX "\n", $2); + glcpp_printf(parser->output, "#version %" PRIiMAX, $2); } | HASH NEWLINE ; -- cgit v1.2.3 From 2e2614586225b3fff3c21f37817064a90dd320ad Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 16 Aug 2010 13:43:10 -0700 Subject: glcpp: Refresh autogenerated lexer and parser. --- src/glsl/glcpp/glcpp-lex.c | 102 ++++++++++++++++++------------------------- src/glsl/glcpp/glcpp-parse.c | 2 +- 2 files changed, 44 insertions(+), 60 deletions(-) diff --git a/src/glsl/glcpp/glcpp-lex.c b/src/glsl/glcpp/glcpp-lex.c index 6b6aa12d8f7..de37c11be8b 100644 --- a/src/glsl/glcpp/glcpp-lex.c +++ b/src/glsl/glcpp/glcpp-lex.c @@ -54,6 +54,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -84,8 +85,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -159,15 +158,7 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -691,7 +682,7 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner); } while(0); #define YY_USER_INIT yylineno = 1; yycolumn = 1; -#line 695 "glcpp/glcpp-lex.c" +#line 686 "glcpp/glcpp-lex.c" #define INITIAL 0 #define DONE 1 @@ -838,12 +829,7 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -851,7 +837,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -862,7 +848,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -954,7 +940,7 @@ YY_DECL /* Single-line comments */ -#line 958 "glcpp/glcpp-lex.c" +#line 944 "glcpp/glcpp-lex.c" yylval = yylval_param; @@ -1126,8 +1112,6 @@ YY_RULE_SETUP #line 91 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); - yylineno++; - yycolumn = 0; yyextra->space_tokens = 0; return HASH_VERSION; } @@ -1136,7 +1120,7 @@ YY_RULE_SETUP * Simply pass them through to the main compiler's lexer/parser. */ case 9: YY_RULE_SETUP -#line 101 "glcpp/glcpp-lex.l" +#line 99 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); yylineno++; @@ -1147,7 +1131,7 @@ YY_RULE_SETUP case 10: /* rule 10 can match eol */ YY_RULE_SETUP -#line 108 "glcpp/glcpp-lex.l" +#line 106 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; @@ -1157,7 +1141,7 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 114 "glcpp/glcpp-lex.l" +#line 112 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; @@ -1167,7 +1151,7 @@ YY_RULE_SETUP case 12: /* rule 12 can match eol */ YY_RULE_SETUP -#line 120 "glcpp/glcpp-lex.l" +#line 118 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; @@ -1177,7 +1161,7 @@ YY_RULE_SETUP case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 126 "glcpp/glcpp-lex.l" +#line 124 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 1; yyextra->space_tokens = 0; @@ -1187,7 +1171,7 @@ YY_RULE_SETUP case 14: /* rule 14 can match eol */ YY_RULE_SETUP -#line 132 "glcpp/glcpp-lex.l" +#line 130 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_ELSE; @@ -1196,7 +1180,7 @@ YY_RULE_SETUP case 15: /* rule 15 can match eol */ YY_RULE_SETUP -#line 137 "glcpp/glcpp-lex.l" +#line 135 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_ENDIF; @@ -1216,7 +1200,7 @@ case 16: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 150 "glcpp/glcpp-lex.l" +#line 148 "glcpp/glcpp-lex.l" { /* Since this rule always matches, YY_USER_ACTION gets called for it, * wrongly incrementing yycolumn. We undo that effect here. */ @@ -1231,7 +1215,7 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 162 "glcpp/glcpp-lex.l" +#line 160 "glcpp/glcpp-lex.l" { char *p; for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */ @@ -1241,7 +1225,7 @@ YY_RULE_SETUP YY_BREAK case 18: YY_RULE_SETUP -#line 169 "glcpp/glcpp-lex.l" +#line 167 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_DEFINE_FUNC; @@ -1249,7 +1233,7 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 174 "glcpp/glcpp-lex.l" +#line 172 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_DEFINE_OBJ; @@ -1257,7 +1241,7 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 179 "glcpp/glcpp-lex.l" +#line 177 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH_UNDEF; @@ -1265,7 +1249,7 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 184 "glcpp/glcpp-lex.l" +#line 182 "glcpp/glcpp-lex.l" { yyextra->space_tokens = 0; return HASH; @@ -1273,7 +1257,7 @@ YY_RULE_SETUP YY_BREAK case 22: YY_RULE_SETUP -#line 189 "glcpp/glcpp-lex.l" +#line 187 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; @@ -1281,7 +1265,7 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 194 "glcpp/glcpp-lex.l" +#line 192 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; @@ -1289,7 +1273,7 @@ YY_RULE_SETUP YY_BREAK case 24: YY_RULE_SETUP -#line 199 "glcpp/glcpp-lex.l" +#line 197 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); return INTEGER_STRING; @@ -1297,77 +1281,77 @@ YY_RULE_SETUP YY_BREAK case 25: YY_RULE_SETUP -#line 204 "glcpp/glcpp-lex.l" +#line 202 "glcpp/glcpp-lex.l" { return LEFT_SHIFT; } YY_BREAK case 26: YY_RULE_SETUP -#line 208 "glcpp/glcpp-lex.l" +#line 206 "glcpp/glcpp-lex.l" { return RIGHT_SHIFT; } YY_BREAK case 27: YY_RULE_SETUP -#line 212 "glcpp/glcpp-lex.l" +#line 210 "glcpp/glcpp-lex.l" { return LESS_OR_EQUAL; } YY_BREAK case 28: YY_RULE_SETUP -#line 216 "glcpp/glcpp-lex.l" +#line 214 "glcpp/glcpp-lex.l" { return GREATER_OR_EQUAL; } YY_BREAK case 29: YY_RULE_SETUP -#line 220 "glcpp/glcpp-lex.l" +#line 218 "glcpp/glcpp-lex.l" { return EQUAL; } YY_BREAK case 30: YY_RULE_SETUP -#line 224 "glcpp/glcpp-lex.l" +#line 222 "glcpp/glcpp-lex.l" { return NOT_EQUAL; } YY_BREAK case 31: YY_RULE_SETUP -#line 228 "glcpp/glcpp-lex.l" +#line 226 "glcpp/glcpp-lex.l" { return AND; } YY_BREAK case 32: YY_RULE_SETUP -#line 232 "glcpp/glcpp-lex.l" +#line 230 "glcpp/glcpp-lex.l" { return OR; } YY_BREAK case 33: YY_RULE_SETUP -#line 236 "glcpp/glcpp-lex.l" +#line 234 "glcpp/glcpp-lex.l" { return PASTE; } YY_BREAK case 34: YY_RULE_SETUP -#line 240 "glcpp/glcpp-lex.l" +#line 238 "glcpp/glcpp-lex.l" { return DEFINED; } YY_BREAK case 35: YY_RULE_SETUP -#line 244 "glcpp/glcpp-lex.l" +#line 242 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); return IDENTIFIER; @@ -1375,14 +1359,14 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 249 "glcpp/glcpp-lex.l" +#line 247 "glcpp/glcpp-lex.l" { return yytext[0]; } YY_BREAK case 37: YY_RULE_SETUP -#line 253 "glcpp/glcpp-lex.l" +#line 251 "glcpp/glcpp-lex.l" { yylval->str = talloc_strdup (yyextra, yytext); return OTHER; @@ -1390,7 +1374,7 @@ YY_RULE_SETUP YY_BREAK case 38: YY_RULE_SETUP -#line 258 "glcpp/glcpp-lex.l" +#line 256 "glcpp/glcpp-lex.l" { if (yyextra->space_tokens) { return SPACE; @@ -1400,7 +1384,7 @@ YY_RULE_SETUP case 39: /* rule 39 can match eol */ YY_RULE_SETUP -#line 264 "glcpp/glcpp-lex.l" +#line 262 "glcpp/glcpp-lex.l" { yyextra->lexing_if = 0; yylineno++; @@ -1410,7 +1394,7 @@ YY_RULE_SETUP YY_BREAK /* Handle missing newline at EOF. */ case YY_STATE_EOF(INITIAL): -#line 272 "glcpp/glcpp-lex.l" +#line 270 "glcpp/glcpp-lex.l" { BEGIN DONE; /* Don't keep matching this rule forever. */ yyextra->lexing_if = 0; @@ -1423,7 +1407,7 @@ case YY_STATE_EOF(INITIAL): warnings. */ case 40: YY_RULE_SETUP -#line 282 "glcpp/glcpp-lex.l" +#line 280 "glcpp/glcpp-lex.l" { unput('.'); yy_top_state(yyextra); @@ -1431,10 +1415,10 @@ YY_RULE_SETUP YY_BREAK case 41: YY_RULE_SETUP -#line 287 "glcpp/glcpp-lex.l" +#line 285 "glcpp/glcpp-lex.l" ECHO; YY_BREAK -#line 1438 "glcpp/glcpp-lex.c" +#line 1422 "glcpp/glcpp-lex.c" case YY_STATE_EOF(DONE): case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(UNREACHABLE): @@ -2173,8 +2157,8 @@ YY_BUFFER_STATE glcpp__scan_string (yyconst char * yystr , yyscan_t yyscanner) /** Setup the input buffer state to scan the given bytes. The next call to glcpp_lex() will * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -2628,7 +2612,7 @@ void glcpp_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 287 "glcpp/glcpp-lex.l" +#line 285 "glcpp/glcpp-lex.l" diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index bd0fbc4fcf2..a19a02a867d 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -2016,7 +2016,7 @@ yyreduce: talloc_free (macro); } add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival)); - glcpp_printf(parser->output, "#version %" PRIiMAX "\n", (yyvsp[(2) - (3)].ival)); + glcpp_printf(parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival)); ;} break; -- cgit v1.2.3 From d0a9cbd20ee0a1b5c350fed1c470946e4500f793 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 16 Aug 2010 13:59:01 -0700 Subject: glsl2: Silence unused variable warning --- src/glsl/ir_structure_splitting.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/ir_structure_splitting.cpp b/src/glsl/ir_structure_splitting.cpp index c0244071ee2..91f6dac23e0 100644 --- a/src/glsl/ir_structure_splitting.cpp +++ b/src/glsl/ir_structure_splitting.cpp @@ -138,6 +138,7 @@ ir_structure_reference_visitor::visit(ir_dereference_variable *ir) ir_visitor_status ir_structure_reference_visitor::visit_enter(ir_dereference_record *ir) { + (void) ir; /* Don't descend into the ir_dereference_variable below. */ return visit_continue_with_parent; } -- cgit v1.2.3 From 45d97dd6d5467d96acee1ba33052836b45668564 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 16 Aug 2010 13:59:34 -0700 Subject: linker: Include compiler.h to avoid spurious warnings about INLINE --- src/glsl/linker.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 9931251f404..22cdd76015a 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -72,6 +72,7 @@ extern "C" { #include } +#include "main/compiler.h" #include "main/mtypes.h" #include "main/macros.h" #include "main/shaderobj.h" -- cgit v1.2.3 From 2f9ecc818d67b8ea7496fd1dd0cb8bc7b9f8f8a4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 16 Aug 2010 15:14:04 -0700 Subject: glsl2: Add builtins profile for GLSL 1.30. Many functions are currently wrapped with #if 0 since we haven't implemented them yet. --- src/glsl/builtins/profiles/130.frag | 999 ++++++++++++++++++++++++++++++++++++ src/glsl/builtins/profiles/130.vert | 987 +++++++++++++++++++++++++++++++++++ 2 files changed, 1986 insertions(+) create mode 100644 src/glsl/builtins/profiles/130.frag create mode 100644 src/glsl/builtins/profiles/130.vert diff --git a/src/glsl/builtins/profiles/130.frag b/src/glsl/builtins/profiles/130.frag new file mode 100644 index 00000000000..39c73c4eefa --- /dev/null +++ b/src/glsl/builtins/profiles/130.frag @@ -0,0 +1,999 @@ +#version 130 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); +int abs(int x); +ivec2 abs(ivec2 x); +ivec3 abs(ivec3 x); +ivec4 abs(ivec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); +int sign(int x); +ivec2 sign(ivec2 x); +ivec3 sign(ivec3 x); +ivec4 sign(ivec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +int min(int x, int y); +ivec2 min(ivec2 x, ivec2 y); +ivec3 min(ivec3 x, ivec3 y); +ivec4 min(ivec4 x, ivec4 y); + +ivec2 min(ivec2 x, int y); +ivec3 min(ivec3 x, int y); +ivec4 min(ivec4 x, int y); + +uint min(uint x, uint y); +uvec2 min(uvec2 x, uvec2 y); +uvec3 min(uvec3 x, uvec3 y); +uvec4 min(uvec4 x, uvec4 y); + +uvec2 min(uvec2 x, uint y); +uvec3 min(uvec3 x, uint y); +uvec4 min(uvec4 x, uint y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +int max(int x, int y); +ivec2 max(ivec2 x, ivec2 y); +ivec3 max(ivec3 x, ivec3 y); +ivec4 max(ivec4 x, ivec4 y); + +ivec2 max(ivec2 x, int y); +ivec3 max(ivec3 x, int y); +ivec4 max(ivec4 x, int y); + +uint max(uint x, uint y); +uvec2 max(uvec2 x, uvec2 y); +uvec3 max(uvec3 x, uvec3 y); +uvec4 max(uvec4 x, uvec4 y); + +uvec2 max(uvec2 x, uint y); +uvec3 max(uvec3 x, uint y); +uvec4 max(uvec4 x, uint y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +int clamp(int x, int minVal, int maxVal); +ivec2 clamp(ivec2 x, ivec2 minVal, ivec2 maxVal); +ivec3 clamp(ivec3 x, ivec3 minVal, ivec3 maxVal); +ivec4 clamp(ivec4 x, ivec4 minVal, ivec4 maxVal); + +ivec2 clamp(ivec2 x, int minVal, int maxVal); +ivec3 clamp(ivec3 x, int minVal, int maxVal); +ivec4 clamp(ivec4 x, int minVal, int maxVal); + +uint clamp(uint x, uint minVal, uint maxVal); +uvec2 clamp(uvec2 x, uvec2 minVal, uvec2 maxVal); +uvec3 clamp(uvec3 x, uvec3 minVal, uvec3 maxVal); +uvec4 clamp(uvec4 x, uvec4 minVal, uvec4 maxVal); + +uvec2 clamp(uvec2 x, uint minVal, uint maxVal); +uvec3 clamp(uvec3 x, uint minVal, uint maxVal); +uvec4 clamp(uvec4 x, uint minVal, uint maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +#if 0 +bool isnan(float x); +bvec2 isnan(vec2 x); +bvec3 isnan(vec3 x); +bvec4 isnan(vec4 x); + +bool isinf(float x); +bvec2 isinf(vec2 x); +bvec3 isinf(vec3 x); +bvec4 isinf(vec4 x); +#endif + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); +mat2x3 matrixCompMult(mat2x3 x, mat2x3 y); +mat2x4 matrixCompMult(mat2x4 x, mat2x4 y); +mat3x2 matrixCompMult(mat3x2 x, mat3x2 y); +mat3x4 matrixCompMult(mat3x4 x, mat3x4 y); +mat4x2 matrixCompMult(mat4x2 x, mat4x2 y); +mat4x3 matrixCompMult(mat4x3 x, mat4x3 y); + +mat2 outerProduct(vec2 c, vec2 r); +mat3 outerProduct(vec3 c, vec3 r); +mat4 outerProduct(vec4 c, vec4 r); + +mat2x3 outerProduct(vec3 c, vec2 r); +mat3x2 outerProduct(vec2 c, vec3 r); + +mat2x4 outerProduct(vec4 c, vec2 r); +mat4x2 outerProduct(vec2 c, vec4 r); + +mat3x4 outerProduct(vec4 c, vec3 r); +mat4x3 outerProduct(vec3 c, vec4 r); + +mat2 transpose(mat2 m); +mat3 transpose(mat3 m); +mat4 transpose(mat4 m); + +mat2x3 transpose(mat3x2 m); +mat3x2 transpose(mat2x3 m); + +mat2x4 transpose(mat4x2 m); +mat4x2 transpose(mat2x4 m); + +mat3x4 transpose(mat4x3 m); +mat4x3 transpose(mat3x4 m); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); +bvec2 lessThan(uvec2 x, uvec2 y); +bvec3 lessThan(uvec3 x, uvec3 y); +bvec4 lessThan(uvec4 x, uvec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); +bvec2 lessThanEqual(uvec2 x, uvec2 y); +bvec3 lessThanEqual(uvec3 x, uvec3 y); +bvec4 lessThanEqual(uvec4 x, uvec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); +bvec2 greaterThan(uvec2 x, uvec2 y); +bvec3 greaterThan(uvec3 x, uvec3 y); +bvec4 greaterThan(uvec4 x, uvec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); +bvec2 greaterThanEqual(uvec2 x, uvec2 y); +bvec3 greaterThanEqual(uvec3 x, uvec3 y); +bvec4 greaterThanEqual(uvec4 x, uvec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(uvec2 x, uvec2 y); +bvec3 equal(uvec3 x, uvec3 y); +bvec4 equal(uvec4 x, uvec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(uvec2 x, uvec2 y); +bvec3 notEqual(uvec3 x, uvec3 y); +bvec4 notEqual(uvec4 x, uvec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ + +#if 0 +/* textureSize */ +int textureSize( sampler1D sampler, int lod); +int textureSize(isampler1D sampler, int lod); +int textureSize(usampler1D sampler, int lod); + +ivec2 textureSize( sampler2D sampler, int lod); +ivec2 textureSize(isampler2D sampler, int lod); +ivec2 textureSize(usampler2D sampler, int lod); + +ivec3 textureSize( sampler3D sampler, int lod); +ivec3 textureSize(isampler3D sampler, int lod); +ivec3 textureSize(usampler3D sampler, int lod); + +ivec2 textureSize( samplerCube sampler, int lod); +ivec2 textureSize(isamplerCube sampler, int lod); +ivec2 textureSize(usamplerCube sampler, int lod); + +int textureSize(sampler1DShadow sampler, int lod); +ivec2 textureSize(sampler2DShadow sampler, int lod); +ivec2 textureSize(samplerCubeShadow sampler, int lod); + +ivec2 textureSize( sampler1DArray sampler, int lod); +ivec2 textureSize(isampler1DArray sampler, int lod); +ivec2 textureSize(usampler1DArray sampler, int lod); +ivec3 textureSize( sampler2DArray sampler, int lod); +ivec2 textureSize(isampler2DArray sampler, int lod); +ivec2 textureSize(usampler2DArray sampler, int lod); + +ivec2 textureSize(sampler1DArrayShadow sampler, int lod); +ivec3 textureSize(sampler2DArrayShadow sampler, int lod); +#endif + +/* texture - no bias */ + vec4 texture( sampler1D sampler, float P); +ivec4 texture(isampler1D sampler, float P); +uvec4 texture(usampler1D sampler, float P); + + vec4 texture( sampler2D sampler, vec2 P); +ivec4 texture(isampler2D sampler, vec2 P); +uvec4 texture(usampler2D sampler, vec2 P); + + vec4 texture( sampler3D sampler, vec3 P); +ivec4 texture(isampler3D sampler, vec3 P); +uvec4 texture(usampler3D sampler, vec3 P); + + vec4 texture( samplerCube sampler, vec3 P); +ivec4 texture(isamplerCube sampler, vec3 P); +uvec4 texture(usamplerCube sampler, vec3 P); + +float texture(sampler1DShadow sampler, vec3 P); +float texture(sampler2DShadow sampler, vec3 P); +float texture(samplerCubeShadow sampler, vec4 P); + + vec4 texture( sampler1DArray sampler, vec2 P); +ivec4 texture(isampler1DArray sampler, vec2 P); +uvec4 texture(usampler1DArray sampler, vec2 P); + + vec4 texture( sampler2DArray sampler, vec3 P); +ivec4 texture(isampler2DArray sampler, vec3 P); +uvec4 texture(usampler2DArray sampler, vec3 P); + +float texture(sampler1DArrayShadow sampler, vec3 P); +float texture(sampler2DArrayShadow sampler, vec4 P); + +/* texture - bias variants */ + vec4 texture( sampler1D sampler, float P, float bias); +ivec4 texture(isampler1D sampler, float P, float bias); +uvec4 texture(usampler1D sampler, float P, float bias); + + vec4 texture( sampler2D sampler, vec2 P, float bias); +ivec4 texture(isampler2D sampler, vec2 P, float bias); +uvec4 texture(usampler2D sampler, vec2 P, float bias); + + vec4 texture( sampler3D sampler, vec3 P, float bias); +ivec4 texture(isampler3D sampler, vec3 P, float bias); +uvec4 texture(usampler3D sampler, vec3 P, float bias); + + vec4 texture( samplerCube sampler, vec3 P, float bias); +ivec4 texture(isamplerCube sampler, vec3 P, float bias); +uvec4 texture(usamplerCube sampler, vec3 P, float bias); + +float texture(sampler1DShadow sampler, vec3 P, float bias); +float texture(sampler2DShadow sampler, vec3 P, float bias); +float texture(samplerCubeShadow sampler, vec4 P, float bias); + + vec4 texture( sampler1DArray sampler, vec2 P, float bias); +ivec4 texture(isampler1DArray sampler, vec2 P, float bias); +uvec4 texture(usampler1DArray sampler, vec2 P, float bias); + + vec4 texture( sampler2DArray sampler, vec3 P, float bias); +ivec4 texture(isampler2DArray sampler, vec3 P, float bias); +uvec4 texture(usampler2DArray sampler, vec3 P, float bias); + +float texture(sampler1DArrayShadow sampler, vec3 P, float bias); + +/* textureProj - no bias */ + vec4 textureProj( sampler1D sampler, vec2 P); +ivec4 textureProj(isampler1D sampler, vec2 P); +uvec4 textureProj(usampler1D sampler, vec2 P); + vec4 textureProj( sampler1D sampler, vec4 P); +ivec4 textureProj(isampler1D sampler, vec4 P); +uvec4 textureProj(usampler1D sampler, vec4 P); + + vec4 textureProj( sampler2D sampler, vec3 P); +ivec4 textureProj(isampler2D sampler, vec3 P); +uvec4 textureProj(usampler2D sampler, vec3 P); + vec4 textureProj( sampler2D sampler, vec4 P); +ivec4 textureProj(isampler2D sampler, vec4 P); +uvec4 textureProj(usampler2D sampler, vec4 P); + + vec4 textureProj( sampler3D sampler, vec4 P); +ivec4 textureProj(isampler3D sampler, vec4 P); +uvec4 textureProj(usampler3D sampler, vec4 P); + +float textureProj(sampler1DShadow sampler, vec4 P); +float textureProj(sampler2DShadow sampler, vec4 P); + +/* textureProj - bias variants */ + vec4 textureProj( sampler1D sampler, vec2 P, float bias); +ivec4 textureProj(isampler1D sampler, vec2 P, float bias); +uvec4 textureProj(usampler1D sampler, vec2 P, float bias); + vec4 textureProj( sampler1D sampler, vec4 P, float bias); +ivec4 textureProj(isampler1D sampler, vec4 P, float bias); +uvec4 textureProj(usampler1D sampler, vec4 P, float bias); + + vec4 textureProj( sampler2D sampler, vec3 P, float bias); +ivec4 textureProj(isampler2D sampler, vec3 P, float bias); +uvec4 textureProj(usampler2D sampler, vec3 P, float bias); + vec4 textureProj( sampler2D sampler, vec4 P, float bias); +ivec4 textureProj(isampler2D sampler, vec4 P, float bias); +uvec4 textureProj(usampler2D sampler, vec4 P, float bias); + + vec4 textureProj( sampler3D sampler, vec4 P, float bias); +ivec4 textureProj(isampler3D sampler, vec4 P, float bias); +uvec4 textureProj(usampler3D sampler, vec4 P, float bias); + +float textureProj(sampler1DShadow sampler, vec4 P, float bias); +float textureProj(sampler2DShadow sampler, vec4 P, float bias); + +/* textureLod */ + vec4 textureLod( sampler1D sampler, float P, float lod); +ivec4 textureLod(isampler1D sampler, float P, float lod); +uvec4 textureLod(usampler1D sampler, float P, float lod); + + vec4 textureLod( sampler2D sampler, vec2 P, float lod); +ivec4 textureLod(isampler2D sampler, vec2 P, float lod); +uvec4 textureLod(usampler2D sampler, vec2 P, float lod); + + vec4 textureLod( sampler3D sampler, vec3 P, float lod); +ivec4 textureLod(isampler3D sampler, vec3 P, float lod); +uvec4 textureLod(usampler3D sampler, vec3 P, float lod); + + vec4 textureLod( samplerCube sampler, vec3 P, float lod); +ivec4 textureLod(isamplerCube sampler, vec3 P, float lod); +uvec4 textureLod(usamplerCube sampler, vec3 P, float lod); + +float textureLod(sampler1DShadow sampler, vec3 P, float lod); +float textureLod(sampler2DShadow sampler, vec3 P, float lod); + + vec4 textureLod( sampler1DArray sampler, vec2 P, float lod); +ivec4 textureLod(isampler1DArray sampler, vec2 P, float lod); +uvec4 textureLod(usampler1DArray sampler, vec2 P, float lod); + + vec4 textureLod( sampler2DArray sampler, vec3 P, float lod); +ivec4 textureLod(isampler2DArray sampler, vec3 P, float lod); +uvec4 textureLod(usampler2DArray sampler, vec3 P, float lod); + +float textureLod(sampler1DArrayShadow sampler, vec3 P, float lod); + +#if 0 +/* textureOffset - no bias */ + vec4 textureOffset( sampler1D sampler, float P, int offset); +ivec4 textureOffset(isampler1D sampler, float P, int offset); +uvec4 textureOffset(usampler1D sampler, float P, int offset); + + vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset); +ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset); +uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset); + + vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset); +ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset); +uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset); + +float textureOffset(sampler1DShadow sampler, vec3 P, int offset); +float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset); + + vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset); +ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset); +uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset); + + vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset); +ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset); +uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset); + +float textureOffset(sampler1DArrayShadow sampler, vec3 P, int offset); + +/* textureOffset - bias variants */ + vec4 textureOffset( sampler1D sampler, float P, int offset, float bias); +ivec4 textureOffset(isampler1D sampler, float P, int offset, float bias); +uvec4 textureOffset(usampler1D sampler, float P, int offset, float bias); + + vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset, float bias); +ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset, float bias); +uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset, float bias); + + vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset, float bias); +ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset, float bias); +uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset, float bias); + +float textureOffset(sampler1DShadow sampler, vec3 P, int offset, float bias); +float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset, float bias); + + vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset, float bias); +ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset, float bias); +uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset, float bias); + + vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset, float bias); +ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset, float bias); +uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset, float bias); + +float textureOffset(sampler1DArrayShadow samp, vec3 P, int offset, float bias); +#endif + +/* texelFetch */ + vec4 texelFetch( sampler1D sampler, int P, int lod); +ivec4 texelFetch(isampler1D sampler, int P, int lod); +uvec4 texelFetch(usampler1D sampler, int P, int lod); + + vec4 texelFetch( sampler2D sampler, ivec2 P, int lod); +ivec4 texelFetch(isampler2D sampler, ivec2 P, int lod); +uvec4 texelFetch(usampler2D sampler, ivec2 P, int lod); + + vec4 texelFetch( sampler3D sampler, ivec3 P, int lod); +ivec4 texelFetch(isampler3D sampler, ivec3 P, int lod); +uvec4 texelFetch(usampler3D sampler, ivec3 P, int lod); + + vec4 texelFetch( sampler1DArray sampler, ivec2 P, int lod); +ivec4 texelFetch(isampler1DArray sampler, ivec2 P, int lod); +uvec4 texelFetch(usampler1DArray sampler, ivec2 P, int lod); + + vec4 texelFetch( sampler2DArray sampler, ivec3 P, int lod); +ivec4 texelFetch(isampler2DArray sampler, ivec3 P, int lod); +uvec4 texelFetch(usampler2DArray sampler, ivec3 P, int lod); + +#if 0 +/* texelFetchOffset */ + vec4 texelFetchOffset( sampler1D sampler, int P, int lod, int offset); +ivec4 texelFetchOffset(isampler1D sampler, int P, int lod, int offset); +uvec4 texelFetchOffset(usampler1D sampler, int P, int lod, int offset); + + vec4 texelFetchOffset( sampler2D sampler, ivec2 P, int lod, ivec2 offset); +ivec4 texelFetchOffset(isampler2D sampler, ivec2 P, int lod, ivec2 offset); +uvec4 texelFetchOffset(usampler2D sampler, ivec2 P, int lod, ivec2 offset); + + vec4 texelFetchOffset( sampler3D sampler, ivec3 P, int lod, ivec3 offset); +ivec4 texelFetchOffset(isampler3D sampler, ivec3 P, int lod, ivec3 offset); +uvec4 texelFetchOffset(usampler3D sampler, ivec3 P, int lod, ivec3 offset); + + vec4 texelFetchOffset( sampler1DArray sampler, ivec2 P, int lod, int offset); +ivec4 texelFetchOffset(isampler1DArray sampler, ivec2 P, int lod, int offset); +uvec4 texelFetchOffset(usampler1DArray sampler, ivec2 P, int lod, int offset); + + vec4 texelFetchOffset( sampler2DArray sampler, ivec3 P, int lod, ivec2 offset); +ivec4 texelFetchOffset(isampler2DArray sampler, ivec3 P, int lod, ivec2 offset); +uvec4 texelFetchOffset(usampler2DArray sampler, ivec3 P, int lod, ivec2 offset); + +/* textureProjOffset - no bias */ + vec4 textureProj( sampler1D sampler, vec2 P, int offset); +ivec4 textureProj(isampler1D sampler, vec2 P, int offset); +uvec4 textureProj(usampler1D sampler, vec2 P, int offset); + vec4 textureProj( sampler1D sampler, vec4 P, int offset); +ivec4 textureProj(isampler1D sampler, vec4 P, int offset); +uvec4 textureProj(usampler1D sampler, vec4 P, int offset); + + vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset); +ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset); +uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset); + vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset); +ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset); +uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset); + + vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset); +ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset); +uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset); + +float textureProj(sampler1DShadow sampler, vec4 P, int offset); +float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset); + +/* textureProjOffset - bias variants */ + vec4 textureProj( sampler1D sampler, vec2 P, int offset, float bias); +ivec4 textureProj(isampler1D sampler, vec2 P, int offset, float bias); +uvec4 textureProj(usampler1D sampler, vec2 P, int offset, float bias); + vec4 textureProj( sampler1D sampler, vec4 P, int offset, float bias); +ivec4 textureProj(isampler1D sampler, vec4 P, int offset, float bias); +uvec4 textureProj(usampler1D sampler, vec4 P, int offset, float bias); + + vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset, float bias); +ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset, float bias); +uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset, float bias); + vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset, float bias); +ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset, float bias); +uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset, float bias); + + vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset, float bias); +ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset, float bias); +uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset, float bias); + +float textureProj(sampler1DShadow sampler, vec4 P, int offset, float bias); +float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset, float bias); + +/* textureLodOffset */ + vec4 textureLodOffset( sampler1D sampler, float P, float lod, int offset); +ivec4 textureLodOffset(isampler1D sampler, float P, float lod, int offset); +uvec4 textureLodOffset(usampler1D sampler, float P, float lod, int offset); + + vec4 textureLodOffset( sampler2D sampler, vec2 P, float lod, ivec2 offset); +ivec4 textureLodOffset(isampler2D sampler, vec2 P, float lod, ivec2 offset); +uvec4 textureLodOffset(usampler2D sampler, vec2 P, float lod, ivec2 offset); + + vec4 textureLodOffset( sampler3D sampler, vec3 P, float lod, ivec3 offset); +ivec4 textureLodOffset(isampler3D sampler, vec3 P, float lod, ivec3 offset); +uvec4 textureLodOffset(usampler3D sampler, vec3 P, float lod, ivec3 offset); + +float textureLodOffset(sampler1DShadow samp, vec3 P, float lod, int offset); +float textureLodOffset(sampler2DShadow samp, vec3 P, float lod, ivec2 offset); + + vec4 textureLodOffset( sampler1DArray sampler, vec2 P, float lod, int offset); +ivec4 textureLodOffset(isampler1DArray sampler, vec2 P, float lod, int offset); +uvec4 textureLodOffset(usampler1DArray sampler, vec2 P, float lod, int offset); + + vec4 textureLodOffset( sampler2DArray samp, vec3 P, float lod, ivec2 offset); +ivec4 textureLodOffset(isampler2DArray samp, vec3 P, float lod, ivec2 offset); +uvec4 textureLodOffset(usampler2DArray samp, vec3 P, float lod, ivec2 offset); + +float textureLodOffset(sampler1DArrayShadow s, vec3 P, float lod, int offset); +#endif + +/* textureProjLod */ + vec4 textureProjLod( sampler1D sampler, vec2 P, float lod); +ivec4 textureProjLod(isampler1D sampler, vec2 P, float lod); +uvec4 textureProjLod(usampler1D sampler, vec2 P, float lod); + vec4 textureProjLod( sampler1D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler1D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler1D sampler, vec4 P, float lod); + + vec4 textureProjLod( sampler2D sampler, vec3 P, float lod); +ivec4 textureProjLod(isampler2D sampler, vec3 P, float lod); +uvec4 textureProjLod(usampler2D sampler, vec3 P, float lod); + vec4 textureProjLod( sampler2D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler2D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler2D sampler, vec4 P, float lod); + + vec4 textureProjLod( sampler3D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler3D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler3D sampler, vec4 P, float lod); + +float textureProjLod(sampler1DShadow sampler, vec4 P, float lod); +float textureProjLod(sampler2DShadow sampler, vec4 P, float lod); + +#if 0 +/* textureProjLodOffset */ + vec4 textureProjLodOffset( sampler1D sampler, vec2 P, float lod, int offset); +ivec4 textureProjLodOffset(isampler1D sampler, vec2 P, float lod, int offset); +uvec4 textureProjLodOffset(usampler1D sampler, vec2 P, float lod, int offset); + vec4 textureProjLodOffset( sampler1D sampler, vec4 P, float lod, int offset); +ivec4 textureProjLodOffset(isampler1D sampler, vec4 P, float lod, int offset); +uvec4 textureProjLodOffset(usampler1D sampler, vec4 P, float lod, int offset); + + vec4 textureProjLodOffset( sampler2D sampler, vec3 P, float lod, ivec2 offset); +ivec4 textureProjLodOffset(isampler2D sampler, vec3 P, float lod, ivec2 offset); +uvec4 textureProjLodOffset(usampler2D sampler, vec3 P, float lod, ivec2 offset); + vec4 textureProjLodOffset( sampler2D sampler, vec4 P, float lod, ivec2 offset); +ivec4 textureProjLodOffset(isampler2D sampler, vec4 P, float lod, ivec2 offset); +uvec4 textureProjLodOffset(usampler2D sampler, vec4 P, float lod, ivec2 offset); + + vec4 textureProjLodOffset( sampler3D sampler, vec4 P, float lod, ivec3 offset); +ivec4 textureProjLodOffset(isampler3D sampler, vec4 P, float lod, ivec3 offset); +uvec4 textureProjLodOffset(usampler3D sampler, vec4 P, float lod, ivec3 offset); + +float textureProjLodOffset(sampler1DShadow s, vec4 P, float lod, int offset); +float textureProjLodOffset(sampler2DShadow s, vec4 P, float lod, ivec2 offset); +#endif + +/* textureGrad */ + vec4 textureGrad( sampler1D sampler, float P, float dPdx, float dPdy); +ivec4 textureGrad(isampler1D sampler, float P, float dPdx, float dPdy); +uvec4 textureGrad(usampler1D sampler, float P, float dPdx, float dPdy); + + vec4 textureGrad( sampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); +ivec4 textureGrad(isampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); +uvec4 textureGrad(usampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); + + vec4 textureGrad( sampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); +ivec4 textureGrad(isampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); +uvec4 textureGrad(usampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); + + vec4 textureGrad( samplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); +ivec4 textureGrad(isamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); +uvec4 textureGrad(usamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); + +float textureGrad(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy); +float textureGrad(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy); +float textureGrad(samplerCubeShadow sampler, vec4 P, vec3 dPdx, vec3 dPdy); + + vec4 textureGrad( sampler1DArray sampler, vec2 P, float dPdx, float dPdy); +ivec4 textureGrad(isampler1DArray sampler, vec2 P, float dPdx, float dPdy); +uvec4 textureGrad(usampler1DArray sampler, vec2 P, float dPdx, float dPdy); + + vec4 textureGrad( sampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); +ivec4 textureGrad(isampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); +uvec4 textureGrad(usampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); + +float textureGrad(sampler1DArrayShadow sampler, vec3 P, float dPdx, float dPdy); +float textureGrad(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy); + +#if 0 +/* textureGradOffset */ + vec4 textureGradOffset( sampler1D s, float P, float dx, float dy, int off); +ivec4 textureGradOffset(isampler1D s, float P, float dx, float dy, int offset); +uvec4 textureGradOffset(usampler1D s, float P, float dx, float dy, int offset); + + vec4 textureGradOffset( sampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); +ivec4 textureGradOffset(isampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); +uvec4 textureGradOffset(usampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); + + vec4 textureGradOffset( sampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +ivec4 textureGradOffset(isampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +uvec4 textureGradOffset(usampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); + + vec4 textureGradOffset( samplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +ivec4 textureGradOffset(isamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +uvec4 textureGradOffset(usamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); + +float textureGradOffset(sampler1DShadow s, vec3 P, float dx, float dy, int off); +float textureGradOffset(sampler2DShadow s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + + vec4 textureGradOffset( sampler1DArray s, vec2 P, float dx, float dy, int off); +ivec4 textureGradOffset(isampler1DArray s, vec2 P, float dx, float dy, int off); +uvec4 textureGradOffset(usampler1DArray s, vec2 P, float dx, float dy, int off); + + vec4 textureGradOffset( sampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureGradOffset(isampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureGradOffset(usampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + +float textureGradOffset(sampler1DArrayShadow s, vec3 P, float dx, float dy, int o); +float textureGradOffset(sampler2DArrayShadow s, vec4 P, vec2 dx, vec2 dy, ivec2 o); +#endif + +/* textureProjGrad */ + vec4 textureProjGrad( sampler1D sampler, vec2 P, float dPdx, float dPdy); +ivec4 textureProjGrad(isampler1D sampler, vec2 P, float dPdx, float dPdy); +uvec4 textureProjGrad(usampler1D sampler, vec2 P, float dPdx, float dPdy); + vec4 textureProjGrad( sampler1D sampler, vec4 P, float dPdx, float dPdy); +ivec4 textureProjGrad(isampler1D sampler, vec4 P, float dPdx, float dPdy); +uvec4 textureProjGrad(usampler1D sampler, vec4 P, float dPdx, float dPdy); + + vec4 textureProjGrad( sampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); +ivec4 textureProjGrad(isampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); +uvec4 textureProjGrad(usampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); + vec4 textureProjGrad( sampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); +ivec4 textureProjGrad(isampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); +uvec4 textureProjGrad(usampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); + + vec4 textureProjGrad( sampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); +ivec4 textureProjGrad(isampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); +uvec4 textureProjGrad(usampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); + +float textureProjGrad(sampler1DShadow sampler, vec4 P, float dPdx, float dPdy); +float textureProjGrad(sampler2DShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy); + +#if 0 +/* textureProjGradOffset */ + vec4 textureProjGradOffset( sampler1D s, vec2 P, float dx, float dy, int off); +ivec4 textureProjGradOffset(isampler1D s, vec2 P, float dx, float dy, int off); +uvec4 textureProjGradOffset(usampler1D s, vec2 P, float dx, float dy, int off); + vec4 textureProjGradOffset( sampler1D s, vec4 P, float dx, float dy, int off); +ivec4 textureProjGradOffset(isampler1D s, vec4 P, float dx, float dy, int off); +uvec4 textureProjGradOffset(usampler1D s, vec4 P, float dx, float dy, int off); + + vec4 textureProjGradOffset( sampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureProjGradOffset(isampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureProjGradOffset(usampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + vec4 textureProjGradOffset( sampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureProjGradOffset(isampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureProjGradOffset(usampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); + + vec4 textureProjGradOffset( sampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); +ivec4 textureProjGradOffset(isampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); +uvec4 textureProjGradOffset(usampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); + +float textureProjGradOffset(sampler1DShadow s, vec4 P, float dx, float dy, int o); +float textureProjGradOffset(sampler2DShadow s, vec4 P, vec2 dx, vec2 dy, vec2 o); +#endif + +/* + * The following texture functions are deprecated: + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1D (sampler1D sampler, float coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias); +vec4 texture1DLod (sampler1D sampler, float coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2D (sampler2D sampler, vec2 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias); +vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3D (sampler3D sampler, vec3 coord, float bias); +vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias); +vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod); +vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCube (samplerCube sampler, vec3 coord, float bias); +vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias); +vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod); +vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod); +vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod); +vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod); + +/* + * 8.8 - Fragment Processing Functions + */ +float dFdx(float p); +vec2 dFdx(vec2 p); +vec3 dFdx(vec3 p); +vec4 dFdx(vec4 p); + +float dFdy(float p); +vec2 dFdy(vec2 p); +vec3 dFdy(vec3 p); +vec4 dFdy(vec4 p); + +float fwidth(float p); +vec2 fwidth(vec2 p); +vec3 fwidth(vec3 p); +vec4 fwidth(vec4 p); + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/src/glsl/builtins/profiles/130.vert b/src/glsl/builtins/profiles/130.vert new file mode 100644 index 00000000000..1aaad190d59 --- /dev/null +++ b/src/glsl/builtins/profiles/130.vert @@ -0,0 +1,987 @@ +#version 130 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); +int abs(int x); +ivec2 abs(ivec2 x); +ivec3 abs(ivec3 x); +ivec4 abs(ivec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); +int sign(int x); +ivec2 sign(ivec2 x); +ivec3 sign(ivec3 x); +ivec4 sign(ivec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +int min(int x, int y); +ivec2 min(ivec2 x, ivec2 y); +ivec3 min(ivec3 x, ivec3 y); +ivec4 min(ivec4 x, ivec4 y); + +ivec2 min(ivec2 x, int y); +ivec3 min(ivec3 x, int y); +ivec4 min(ivec4 x, int y); + +uint min(uint x, uint y); +uvec2 min(uvec2 x, uvec2 y); +uvec3 min(uvec3 x, uvec3 y); +uvec4 min(uvec4 x, uvec4 y); + +uvec2 min(uvec2 x, uint y); +uvec3 min(uvec3 x, uint y); +uvec4 min(uvec4 x, uint y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +int max(int x, int y); +ivec2 max(ivec2 x, ivec2 y); +ivec3 max(ivec3 x, ivec3 y); +ivec4 max(ivec4 x, ivec4 y); + +ivec2 max(ivec2 x, int y); +ivec3 max(ivec3 x, int y); +ivec4 max(ivec4 x, int y); + +uint max(uint x, uint y); +uvec2 max(uvec2 x, uvec2 y); +uvec3 max(uvec3 x, uvec3 y); +uvec4 max(uvec4 x, uvec4 y); + +uvec2 max(uvec2 x, uint y); +uvec3 max(uvec3 x, uint y); +uvec4 max(uvec4 x, uint y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +int clamp(int x, int minVal, int maxVal); +ivec2 clamp(ivec2 x, ivec2 minVal, ivec2 maxVal); +ivec3 clamp(ivec3 x, ivec3 minVal, ivec3 maxVal); +ivec4 clamp(ivec4 x, ivec4 minVal, ivec4 maxVal); + +ivec2 clamp(ivec2 x, int minVal, int maxVal); +ivec3 clamp(ivec3 x, int minVal, int maxVal); +ivec4 clamp(ivec4 x, int minVal, int maxVal); + +uint clamp(uint x, uint minVal, uint maxVal); +uvec2 clamp(uvec2 x, uvec2 minVal, uvec2 maxVal); +uvec3 clamp(uvec3 x, uvec3 minVal, uvec3 maxVal); +uvec4 clamp(uvec4 x, uvec4 minVal, uvec4 maxVal); + +uvec2 clamp(uvec2 x, uint minVal, uint maxVal); +uvec3 clamp(uvec3 x, uint minVal, uint maxVal); +uvec4 clamp(uvec4 x, uint minVal, uint maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +#if 0 +bool isnan(float x); +bvec2 isnan(vec2 x); +bvec3 isnan(vec3 x); +bvec4 isnan(vec4 x); + +bool isinf(float x); +bvec2 isinf(vec2 x); +bvec3 isinf(vec3 x); +bvec4 isinf(vec4 x); +#endif + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +vec4 ftransform(); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); +mat2x3 matrixCompMult(mat2x3 x, mat2x3 y); +mat2x4 matrixCompMult(mat2x4 x, mat2x4 y); +mat3x2 matrixCompMult(mat3x2 x, mat3x2 y); +mat3x4 matrixCompMult(mat3x4 x, mat3x4 y); +mat4x2 matrixCompMult(mat4x2 x, mat4x2 y); +mat4x3 matrixCompMult(mat4x3 x, mat4x3 y); + +mat2 outerProduct(vec2 c, vec2 r); +mat3 outerProduct(vec3 c, vec3 r); +mat4 outerProduct(vec4 c, vec4 r); + +mat2x3 outerProduct(vec3 c, vec2 r); +mat3x2 outerProduct(vec2 c, vec3 r); + +mat2x4 outerProduct(vec4 c, vec2 r); +mat4x2 outerProduct(vec2 c, vec4 r); + +mat3x4 outerProduct(vec4 c, vec3 r); +mat4x3 outerProduct(vec3 c, vec4 r); + +mat2 transpose(mat2 m); +mat3 transpose(mat3 m); +mat4 transpose(mat4 m); + +mat2x3 transpose(mat3x2 m); +mat3x2 transpose(mat2x3 m); + +mat2x4 transpose(mat4x2 m); +mat4x2 transpose(mat2x4 m); + +mat3x4 transpose(mat4x3 m); +mat4x3 transpose(mat3x4 m); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); +bvec2 lessThan(uvec2 x, uvec2 y); +bvec3 lessThan(uvec3 x, uvec3 y); +bvec4 lessThan(uvec4 x, uvec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); +bvec2 lessThanEqual(uvec2 x, uvec2 y); +bvec3 lessThanEqual(uvec3 x, uvec3 y); +bvec4 lessThanEqual(uvec4 x, uvec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); +bvec2 greaterThan(uvec2 x, uvec2 y); +bvec3 greaterThan(uvec3 x, uvec3 y); +bvec4 greaterThan(uvec4 x, uvec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); +bvec2 greaterThanEqual(uvec2 x, uvec2 y); +bvec3 greaterThanEqual(uvec3 x, uvec3 y); +bvec4 greaterThanEqual(uvec4 x, uvec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(uvec2 x, uvec2 y); +bvec3 equal(uvec3 x, uvec3 y); +bvec4 equal(uvec4 x, uvec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(uvec2 x, uvec2 y); +bvec3 notEqual(uvec3 x, uvec3 y); +bvec4 notEqual(uvec4 x, uvec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ + +#if 0 +/* textureSize */ +int textureSize( sampler1D sampler, int lod); +int textureSize(isampler1D sampler, int lod); +int textureSize(usampler1D sampler, int lod); + +ivec2 textureSize( sampler2D sampler, int lod); +ivec2 textureSize(isampler2D sampler, int lod); +ivec2 textureSize(usampler2D sampler, int lod); + +ivec3 textureSize( sampler3D sampler, int lod); +ivec3 textureSize(isampler3D sampler, int lod); +ivec3 textureSize(usampler3D sampler, int lod); + +ivec2 textureSize( samplerCube sampler, int lod); +ivec2 textureSize(isamplerCube sampler, int lod); +ivec2 textureSize(usamplerCube sampler, int lod); + +int textureSize(sampler1DShadow sampler, int lod); +ivec2 textureSize(sampler2DShadow sampler, int lod); +ivec2 textureSize(samplerCubeShadow sampler, int lod); + +ivec2 textureSize( sampler1DArray sampler, int lod); +ivec2 textureSize(isampler1DArray sampler, int lod); +ivec2 textureSize(usampler1DArray sampler, int lod); +ivec3 textureSize( sampler2DArray sampler, int lod); +ivec2 textureSize(isampler2DArray sampler, int lod); +ivec2 textureSize(usampler2DArray sampler, int lod); + +ivec2 textureSize(sampler1DArrayShadow sampler, int lod); +ivec3 textureSize(sampler2DArrayShadow sampler, int lod); +#endif + +/* texture - no bias */ + vec4 texture( sampler1D sampler, float P); +ivec4 texture(isampler1D sampler, float P); +uvec4 texture(usampler1D sampler, float P); + + vec4 texture( sampler2D sampler, vec2 P); +ivec4 texture(isampler2D sampler, vec2 P); +uvec4 texture(usampler2D sampler, vec2 P); + + vec4 texture( sampler3D sampler, vec3 P); +ivec4 texture(isampler3D sampler, vec3 P); +uvec4 texture(usampler3D sampler, vec3 P); + + vec4 texture( samplerCube sampler, vec3 P); +ivec4 texture(isamplerCube sampler, vec3 P); +uvec4 texture(usamplerCube sampler, vec3 P); + +float texture(sampler1DShadow sampler, vec3 P); +float texture(sampler2DShadow sampler, vec3 P); +float texture(samplerCubeShadow sampler, vec4 P); + + vec4 texture( sampler1DArray sampler, vec2 P); +ivec4 texture(isampler1DArray sampler, vec2 P); +uvec4 texture(usampler1DArray sampler, vec2 P); + + vec4 texture( sampler2DArray sampler, vec3 P); +ivec4 texture(isampler2DArray sampler, vec3 P); +uvec4 texture(usampler2DArray sampler, vec3 P); + +float texture(sampler1DArrayShadow sampler, vec3 P); +float texture(sampler2DArrayShadow sampler, vec4 P); + +/* texture - bias variants */ + vec4 texture( sampler1D sampler, float P, float bias); +ivec4 texture(isampler1D sampler, float P, float bias); +uvec4 texture(usampler1D sampler, float P, float bias); + + vec4 texture( sampler2D sampler, vec2 P, float bias); +ivec4 texture(isampler2D sampler, vec2 P, float bias); +uvec4 texture(usampler2D sampler, vec2 P, float bias); + + vec4 texture( sampler3D sampler, vec3 P, float bias); +ivec4 texture(isampler3D sampler, vec3 P, float bias); +uvec4 texture(usampler3D sampler, vec3 P, float bias); + + vec4 texture( samplerCube sampler, vec3 P, float bias); +ivec4 texture(isamplerCube sampler, vec3 P, float bias); +uvec4 texture(usamplerCube sampler, vec3 P, float bias); + +float texture(sampler1DShadow sampler, vec3 P, float bias); +float texture(sampler2DShadow sampler, vec3 P, float bias); +float texture(samplerCubeShadow sampler, vec4 P, float bias); + + vec4 texture( sampler1DArray sampler, vec2 P, float bias); +ivec4 texture(isampler1DArray sampler, vec2 P, float bias); +uvec4 texture(usampler1DArray sampler, vec2 P, float bias); + + vec4 texture( sampler2DArray sampler, vec3 P, float bias); +ivec4 texture(isampler2DArray sampler, vec3 P, float bias); +uvec4 texture(usampler2DArray sampler, vec3 P, float bias); + +float texture(sampler1DArrayShadow sampler, vec3 P, float bias); + +/* textureProj - no bias */ + vec4 textureProj( sampler1D sampler, vec2 P); +ivec4 textureProj(isampler1D sampler, vec2 P); +uvec4 textureProj(usampler1D sampler, vec2 P); + vec4 textureProj( sampler1D sampler, vec4 P); +ivec4 textureProj(isampler1D sampler, vec4 P); +uvec4 textureProj(usampler1D sampler, vec4 P); + + vec4 textureProj( sampler2D sampler, vec3 P); +ivec4 textureProj(isampler2D sampler, vec3 P); +uvec4 textureProj(usampler2D sampler, vec3 P); + vec4 textureProj( sampler2D sampler, vec4 P); +ivec4 textureProj(isampler2D sampler, vec4 P); +uvec4 textureProj(usampler2D sampler, vec4 P); + + vec4 textureProj( sampler3D sampler, vec4 P); +ivec4 textureProj(isampler3D sampler, vec4 P); +uvec4 textureProj(usampler3D sampler, vec4 P); + +float textureProj(sampler1DShadow sampler, vec4 P); +float textureProj(sampler2DShadow sampler, vec4 P); + +/* textureProj - bias variants */ + vec4 textureProj( sampler1D sampler, vec2 P, float bias); +ivec4 textureProj(isampler1D sampler, vec2 P, float bias); +uvec4 textureProj(usampler1D sampler, vec2 P, float bias); + vec4 textureProj( sampler1D sampler, vec4 P, float bias); +ivec4 textureProj(isampler1D sampler, vec4 P, float bias); +uvec4 textureProj(usampler1D sampler, vec4 P, float bias); + + vec4 textureProj( sampler2D sampler, vec3 P, float bias); +ivec4 textureProj(isampler2D sampler, vec3 P, float bias); +uvec4 textureProj(usampler2D sampler, vec3 P, float bias); + vec4 textureProj( sampler2D sampler, vec4 P, float bias); +ivec4 textureProj(isampler2D sampler, vec4 P, float bias); +uvec4 textureProj(usampler2D sampler, vec4 P, float bias); + + vec4 textureProj( sampler3D sampler, vec4 P, float bias); +ivec4 textureProj(isampler3D sampler, vec4 P, float bias); +uvec4 textureProj(usampler3D sampler, vec4 P, float bias); + +float textureProj(sampler1DShadow sampler, vec4 P, float bias); +float textureProj(sampler2DShadow sampler, vec4 P, float bias); + +/* textureLod */ + vec4 textureLod( sampler1D sampler, float P, float lod); +ivec4 textureLod(isampler1D sampler, float P, float lod); +uvec4 textureLod(usampler1D sampler, float P, float lod); + + vec4 textureLod( sampler2D sampler, vec2 P, float lod); +ivec4 textureLod(isampler2D sampler, vec2 P, float lod); +uvec4 textureLod(usampler2D sampler, vec2 P, float lod); + + vec4 textureLod( sampler3D sampler, vec3 P, float lod); +ivec4 textureLod(isampler3D sampler, vec3 P, float lod); +uvec4 textureLod(usampler3D sampler, vec3 P, float lod); + + vec4 textureLod( samplerCube sampler, vec3 P, float lod); +ivec4 textureLod(isamplerCube sampler, vec3 P, float lod); +uvec4 textureLod(usamplerCube sampler, vec3 P, float lod); + +float textureLod(sampler1DShadow sampler, vec3 P, float lod); +float textureLod(sampler2DShadow sampler, vec3 P, float lod); + + vec4 textureLod( sampler1DArray sampler, vec2 P, float lod); +ivec4 textureLod(isampler1DArray sampler, vec2 P, float lod); +uvec4 textureLod(usampler1DArray sampler, vec2 P, float lod); + + vec4 textureLod( sampler2DArray sampler, vec3 P, float lod); +ivec4 textureLod(isampler2DArray sampler, vec3 P, float lod); +uvec4 textureLod(usampler2DArray sampler, vec3 P, float lod); + +float textureLod(sampler1DArrayShadow sampler, vec3 P, float lod); + +#if 0 +/* textureOffset - no bias */ + vec4 textureOffset( sampler1D sampler, float P, int offset); +ivec4 textureOffset(isampler1D sampler, float P, int offset); +uvec4 textureOffset(usampler1D sampler, float P, int offset); + + vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset); +ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset); +uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset); + + vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset); +ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset); +uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset); + +float textureOffset(sampler1DShadow sampler, vec3 P, int offset); +float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset); + + vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset); +ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset); +uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset); + + vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset); +ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset); +uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset); + +float textureOffset(sampler1DArrayShadow sampler, vec3 P, int offset); + +/* textureOffset - bias variants */ + vec4 textureOffset( sampler1D sampler, float P, int offset, float bias); +ivec4 textureOffset(isampler1D sampler, float P, int offset, float bias); +uvec4 textureOffset(usampler1D sampler, float P, int offset, float bias); + + vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset, float bias); +ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset, float bias); +uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset, float bias); + + vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset, float bias); +ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset, float bias); +uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset, float bias); + +float textureOffset(sampler1DShadow sampler, vec3 P, int offset, float bias); +float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset, float bias); + + vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset, float bias); +ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset, float bias); +uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset, float bias); + + vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset, float bias); +ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset, float bias); +uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset, float bias); + +float textureOffset(sampler1DArrayShadow samp, vec3 P, int offset, float bias); +#endif + +/* texelFetch */ + vec4 texelFetch( sampler1D sampler, int P, int lod); +ivec4 texelFetch(isampler1D sampler, int P, int lod); +uvec4 texelFetch(usampler1D sampler, int P, int lod); + + vec4 texelFetch( sampler2D sampler, ivec2 P, int lod); +ivec4 texelFetch(isampler2D sampler, ivec2 P, int lod); +uvec4 texelFetch(usampler2D sampler, ivec2 P, int lod); + + vec4 texelFetch( sampler3D sampler, ivec3 P, int lod); +ivec4 texelFetch(isampler3D sampler, ivec3 P, int lod); +uvec4 texelFetch(usampler3D sampler, ivec3 P, int lod); + + vec4 texelFetch( sampler1DArray sampler, ivec2 P, int lod); +ivec4 texelFetch(isampler1DArray sampler, ivec2 P, int lod); +uvec4 texelFetch(usampler1DArray sampler, ivec2 P, int lod); + + vec4 texelFetch( sampler2DArray sampler, ivec3 P, int lod); +ivec4 texelFetch(isampler2DArray sampler, ivec3 P, int lod); +uvec4 texelFetch(usampler2DArray sampler, ivec3 P, int lod); + +#if 0 +/* texelFetchOffset */ + vec4 texelFetchOffset( sampler1D sampler, int P, int lod, int offset); +ivec4 texelFetchOffset(isampler1D sampler, int P, int lod, int offset); +uvec4 texelFetchOffset(usampler1D sampler, int P, int lod, int offset); + + vec4 texelFetchOffset( sampler2D sampler, ivec2 P, int lod, ivec2 offset); +ivec4 texelFetchOffset(isampler2D sampler, ivec2 P, int lod, ivec2 offset); +uvec4 texelFetchOffset(usampler2D sampler, ivec2 P, int lod, ivec2 offset); + + vec4 texelFetchOffset( sampler3D sampler, ivec3 P, int lod, ivec3 offset); +ivec4 texelFetchOffset(isampler3D sampler, ivec3 P, int lod, ivec3 offset); +uvec4 texelFetchOffset(usampler3D sampler, ivec3 P, int lod, ivec3 offset); + + vec4 texelFetchOffset( sampler1DArray sampler, ivec2 P, int lod, int offset); +ivec4 texelFetchOffset(isampler1DArray sampler, ivec2 P, int lod, int offset); +uvec4 texelFetchOffset(usampler1DArray sampler, ivec2 P, int lod, int offset); + + vec4 texelFetchOffset( sampler2DArray sampler, ivec3 P, int lod, ivec2 offset); +ivec4 texelFetchOffset(isampler2DArray sampler, ivec3 P, int lod, ivec2 offset); +uvec4 texelFetchOffset(usampler2DArray sampler, ivec3 P, int lod, ivec2 offset); + +/* textureProjOffset - no bias */ + vec4 textureProj( sampler1D sampler, vec2 P, int offset); +ivec4 textureProj(isampler1D sampler, vec2 P, int offset); +uvec4 textureProj(usampler1D sampler, vec2 P, int offset); + vec4 textureProj( sampler1D sampler, vec4 P, int offset); +ivec4 textureProj(isampler1D sampler, vec4 P, int offset); +uvec4 textureProj(usampler1D sampler, vec4 P, int offset); + + vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset); +ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset); +uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset); + vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset); +ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset); +uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset); + + vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset); +ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset); +uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset); + +float textureProj(sampler1DShadow sampler, vec4 P, int offset); +float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset); + +/* textureProjOffset - bias variants */ + vec4 textureProj( sampler1D sampler, vec2 P, int offset, float bias); +ivec4 textureProj(isampler1D sampler, vec2 P, int offset, float bias); +uvec4 textureProj(usampler1D sampler, vec2 P, int offset, float bias); + vec4 textureProj( sampler1D sampler, vec4 P, int offset, float bias); +ivec4 textureProj(isampler1D sampler, vec4 P, int offset, float bias); +uvec4 textureProj(usampler1D sampler, vec4 P, int offset, float bias); + + vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset, float bias); +ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset, float bias); +uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset, float bias); + vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset, float bias); +ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset, float bias); +uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset, float bias); + + vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset, float bias); +ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset, float bias); +uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset, float bias); + +float textureProj(sampler1DShadow sampler, vec4 P, int offset, float bias); +float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset, float bias); + +/* textureLodOffset */ + vec4 textureLodOffset( sampler1D sampler, float P, float lod, int offset); +ivec4 textureLodOffset(isampler1D sampler, float P, float lod, int offset); +uvec4 textureLodOffset(usampler1D sampler, float P, float lod, int offset); + + vec4 textureLodOffset( sampler2D sampler, vec2 P, float lod, ivec2 offset); +ivec4 textureLodOffset(isampler2D sampler, vec2 P, float lod, ivec2 offset); +uvec4 textureLodOffset(usampler2D sampler, vec2 P, float lod, ivec2 offset); + + vec4 textureLodOffset( sampler3D sampler, vec3 P, float lod, ivec3 offset); +ivec4 textureLodOffset(isampler3D sampler, vec3 P, float lod, ivec3 offset); +uvec4 textureLodOffset(usampler3D sampler, vec3 P, float lod, ivec3 offset); + +float textureLodOffset(sampler1DShadow samp, vec3 P, float lod, int offset); +float textureLodOffset(sampler2DShadow samp, vec3 P, float lod, ivec2 offset); + + vec4 textureLodOffset( sampler1DArray sampler, vec2 P, float lod, int offset); +ivec4 textureLodOffset(isampler1DArray sampler, vec2 P, float lod, int offset); +uvec4 textureLodOffset(usampler1DArray sampler, vec2 P, float lod, int offset); + + vec4 textureLodOffset( sampler2DArray samp, vec3 P, float lod, ivec2 offset); +ivec4 textureLodOffset(isampler2DArray samp, vec3 P, float lod, ivec2 offset); +uvec4 textureLodOffset(usampler2DArray samp, vec3 P, float lod, ivec2 offset); + +float textureLodOffset(sampler1DArrayShadow s, vec3 P, float lod, int offset); +#endif + +/* textureProjLod */ + vec4 textureProjLod( sampler1D sampler, vec2 P, float lod); +ivec4 textureProjLod(isampler1D sampler, vec2 P, float lod); +uvec4 textureProjLod(usampler1D sampler, vec2 P, float lod); + vec4 textureProjLod( sampler1D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler1D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler1D sampler, vec4 P, float lod); + + vec4 textureProjLod( sampler2D sampler, vec3 P, float lod); +ivec4 textureProjLod(isampler2D sampler, vec3 P, float lod); +uvec4 textureProjLod(usampler2D sampler, vec3 P, float lod); + vec4 textureProjLod( sampler2D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler2D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler2D sampler, vec4 P, float lod); + + vec4 textureProjLod( sampler3D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler3D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler3D sampler, vec4 P, float lod); + +float textureProjLod(sampler1DShadow sampler, vec4 P, float lod); +float textureProjLod(sampler2DShadow sampler, vec4 P, float lod); + +#if 0 +/* textureProjLodOffset */ + vec4 textureProjLodOffset( sampler1D sampler, vec2 P, float lod, int offset); +ivec4 textureProjLodOffset(isampler1D sampler, vec2 P, float lod, int offset); +uvec4 textureProjLodOffset(usampler1D sampler, vec2 P, float lod, int offset); + vec4 textureProjLodOffset( sampler1D sampler, vec4 P, float lod, int offset); +ivec4 textureProjLodOffset(isampler1D sampler, vec4 P, float lod, int offset); +uvec4 textureProjLodOffset(usampler1D sampler, vec4 P, float lod, int offset); + + vec4 textureProjLodOffset( sampler2D sampler, vec3 P, float lod, ivec2 offset); +ivec4 textureProjLodOffset(isampler2D sampler, vec3 P, float lod, ivec2 offset); +uvec4 textureProjLodOffset(usampler2D sampler, vec3 P, float lod, ivec2 offset); + vec4 textureProjLodOffset( sampler2D sampler, vec4 P, float lod, ivec2 offset); +ivec4 textureProjLodOffset(isampler2D sampler, vec4 P, float lod, ivec2 offset); +uvec4 textureProjLodOffset(usampler2D sampler, vec4 P, float lod, ivec2 offset); + + vec4 textureProjLodOffset( sampler3D sampler, vec4 P, float lod, ivec3 offset); +ivec4 textureProjLodOffset(isampler3D sampler, vec4 P, float lod, ivec3 offset); +uvec4 textureProjLodOffset(usampler3D sampler, vec4 P, float lod, ivec3 offset); + +float textureProjLodOffset(sampler1DShadow s, vec4 P, float lod, int offset); +float textureProjLodOffset(sampler2DShadow s, vec4 P, float lod, ivec2 offset); +#endif + +/* textureGrad */ + vec4 textureGrad( sampler1D sampler, float P, float dPdx, float dPdy); +ivec4 textureGrad(isampler1D sampler, float P, float dPdx, float dPdy); +uvec4 textureGrad(usampler1D sampler, float P, float dPdx, float dPdy); + + vec4 textureGrad( sampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); +ivec4 textureGrad(isampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); +uvec4 textureGrad(usampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); + + vec4 textureGrad( sampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); +ivec4 textureGrad(isampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); +uvec4 textureGrad(usampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); + + vec4 textureGrad( samplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); +ivec4 textureGrad(isamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); +uvec4 textureGrad(usamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); + +float textureGrad(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy); +float textureGrad(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy); +float textureGrad(samplerCubeShadow sampler, vec4 P, vec3 dPdx, vec3 dPdy); + + vec4 textureGrad( sampler1DArray sampler, vec2 P, float dPdx, float dPdy); +ivec4 textureGrad(isampler1DArray sampler, vec2 P, float dPdx, float dPdy); +uvec4 textureGrad(usampler1DArray sampler, vec2 P, float dPdx, float dPdy); + + vec4 textureGrad( sampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); +ivec4 textureGrad(isampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); +uvec4 textureGrad(usampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); + +float textureGrad(sampler1DArrayShadow sampler, vec3 P, float dPdx, float dPdy); +float textureGrad(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy); + +#if 0 +/* textureGradOffset */ + vec4 textureGradOffset( sampler1D s, float P, float dx, float dy, int off); +ivec4 textureGradOffset(isampler1D s, float P, float dx, float dy, int offset); +uvec4 textureGradOffset(usampler1D s, float P, float dx, float dy, int offset); + + vec4 textureGradOffset( sampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); +ivec4 textureGradOffset(isampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); +uvec4 textureGradOffset(usampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); + + vec4 textureGradOffset( sampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +ivec4 textureGradOffset(isampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +uvec4 textureGradOffset(usampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); + + vec4 textureGradOffset( samplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +ivec4 textureGradOffset(isamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +uvec4 textureGradOffset(usamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); + +float textureGradOffset(sampler1DShadow s, vec3 P, float dx, float dy, int off); +float textureGradOffset(sampler2DShadow s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + + vec4 textureGradOffset( sampler1DArray s, vec2 P, float dx, float dy, int off); +ivec4 textureGradOffset(isampler1DArray s, vec2 P, float dx, float dy, int off); +uvec4 textureGradOffset(usampler1DArray s, vec2 P, float dx, float dy, int off); + + vec4 textureGradOffset( sampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureGradOffset(isampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureGradOffset(usampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + +float textureGradOffset(sampler1DArrayShadow s, vec3 P, float dx, float dy, int o); +float textureGradOffset(sampler2DArrayShadow s, vec4 P, vec2 dx, vec2 dy, ivec2 o); +#endif + +/* textureProjGrad */ + vec4 textureProjGrad( sampler1D sampler, vec2 P, float dPdx, float dPdy); +ivec4 textureProjGrad(isampler1D sampler, vec2 P, float dPdx, float dPdy); +uvec4 textureProjGrad(usampler1D sampler, vec2 P, float dPdx, float dPdy); + vec4 textureProjGrad( sampler1D sampler, vec4 P, float dPdx, float dPdy); +ivec4 textureProjGrad(isampler1D sampler, vec4 P, float dPdx, float dPdy); +uvec4 textureProjGrad(usampler1D sampler, vec4 P, float dPdx, float dPdy); + + vec4 textureProjGrad( sampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); +ivec4 textureProjGrad(isampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); +uvec4 textureProjGrad(usampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); + vec4 textureProjGrad( sampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); +ivec4 textureProjGrad(isampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); +uvec4 textureProjGrad(usampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); + + vec4 textureProjGrad( sampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); +ivec4 textureProjGrad(isampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); +uvec4 textureProjGrad(usampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); + +float textureProjGrad(sampler1DShadow sampler, vec4 P, float dPdx, float dPdy); +float textureProjGrad(sampler2DShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy); + +#if 0 +/* textureProjGradOffset */ + vec4 textureProjGradOffset( sampler1D s, vec2 P, float dx, float dy, int off); +ivec4 textureProjGradOffset(isampler1D s, vec2 P, float dx, float dy, int off); +uvec4 textureProjGradOffset(usampler1D s, vec2 P, float dx, float dy, int off); + vec4 textureProjGradOffset( sampler1D s, vec4 P, float dx, float dy, int off); +ivec4 textureProjGradOffset(isampler1D s, vec4 P, float dx, float dy, int off); +uvec4 textureProjGradOffset(usampler1D s, vec4 P, float dx, float dy, int off); + + vec4 textureProjGradOffset( sampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureProjGradOffset(isampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureProjGradOffset(usampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + vec4 textureProjGradOffset( sampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureProjGradOffset(isampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureProjGradOffset(usampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); + + vec4 textureProjGradOffset( sampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); +ivec4 textureProjGradOffset(isampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); +uvec4 textureProjGradOffset(usampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); + +float textureProjGradOffset(sampler1DShadow s, vec4 P, float dx, float dy, int o); +float textureProjGradOffset(sampler2DShadow s, vec4 P, vec2 dx, vec2 dy, vec2 o); +#endif + +/* + * The following texture functions are deprecated: + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1D (sampler1D sampler, float coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias); +vec4 texture1DLod (sampler1D sampler, float coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2D (sampler2D sampler, vec2 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias); +vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3D (sampler3D sampler, vec3 coord, float bias); +vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias); +vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod); +vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCube (samplerCube sampler, vec3 coord, float bias); +vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias); +vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod); +vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod); +vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod); +vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod); + +/* + * 8.8 - Fragment Processing Functions (none in vertex shader) + */ + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); -- cgit v1.2.3 From a433cd286c60eb9d4c2114f042709eda0f3de676 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 16 Aug 2010 15:18:23 -0700 Subject: glsl2: Refresh autogenerated file builtin_function.cpp. --- src/glsl/builtin_function.cpp | 13506 ++++++++++++++++++++++++++++++++++------ 1 file changed, 11544 insertions(+), 1962 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index f2abea961d2..652e4f61bb5 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -4718,28 +4718,28 @@ static const char *prototypes_for_120_vert = "(function radians\n" " (signature float\n" " (parameters\n" - " (declare (in ) float degrees@0x22143e0)\n" + " (declare (in ) float degrees@0x13d20b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 degrees@0x22147b0)\n" + " (declare (in ) vec2 degrees@0x13d2430)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 degrees@0x22149a0)\n" + " (declare (in ) vec3 degrees@0x13d2610)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 degrees@0x2214b90)\n" + " (declare (in ) vec4 degrees@0x13d27f0)\n" " )\n" " (\n" " ))\n" @@ -4749,28 +4749,28 @@ static const char *prototypes_for_120_vert = "(function degrees\n" " (signature float\n" " (parameters\n" - " (declare (in ) float radians@0x2214d80)\n" + " (declare (in ) float radians@0x13d29d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 radians@0x2215150)\n" + " (declare (in ) vec2 radians@0x13d2d50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 radians@0x2215340)\n" + " (declare (in ) vec3 radians@0x13d2f30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 radians@0x2215530)\n" + " (declare (in ) vec4 radians@0x13d3110)\n" " )\n" " (\n" " ))\n" @@ -4780,28 +4780,28 @@ static const char *prototypes_for_120_vert = "(function sin\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x2215720)\n" + " (declare (in ) float angle@0x13d32f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x2215ad0)\n" + " (declare (in ) vec2 angle@0x13d3670)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x2215cb0)\n" + " (declare (in ) vec3 angle@0x13d3850)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x2215e90)\n" + " (declare (in ) vec4 angle@0x13d3a30)\n" " )\n" " (\n" " ))\n" @@ -4811,28 +4811,28 @@ static const char *prototypes_for_120_vert = "(function cos\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x2216070)\n" + " (declare (in ) float angle@0x13d3c10)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x2216420)\n" + " (declare (in ) vec2 angle@0x13d3f90)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x2216600)\n" + " (declare (in ) vec3 angle@0x13d4170)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x22167e0)\n" + " (declare (in ) vec4 angle@0x13d4350)\n" " )\n" " (\n" " ))\n" @@ -4842,28 +4842,28 @@ static const char *prototypes_for_120_vert = "(function tan\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x22169c0)\n" + " (declare (in ) float angle@0x13d4530)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x2216d70)\n" + " (declare (in ) vec2 angle@0x13d48b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x2216f50)\n" + " (declare (in ) vec3 angle@0x13d4a90)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x2217130)\n" + " (declare (in ) vec4 angle@0x13d4c70)\n" " )\n" " (\n" " ))\n" @@ -4873,28 +4873,28 @@ static const char *prototypes_for_120_vert = "(function asin\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x2217310)\n" + " (declare (in ) float angle@0x13d4e50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x22176c0)\n" + " (declare (in ) vec2 angle@0x13d51d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x22178a0)\n" + " (declare (in ) vec3 angle@0x13d53b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x2217a80)\n" + " (declare (in ) vec4 angle@0x13d5590)\n" " )\n" " (\n" " ))\n" @@ -4904,28 +4904,28 @@ static const char *prototypes_for_120_vert = "(function acos\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x2217c60)\n" + " (declare (in ) float angle@0x13d5770)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x2218010)\n" + " (declare (in ) vec2 angle@0x13d5af0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x22181f0)\n" + " (declare (in ) vec3 angle@0x13d5cd0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x22183d0)\n" + " (declare (in ) vec4 angle@0x13d5eb0)\n" " )\n" " (\n" " ))\n" @@ -4935,60 +4935,60 @@ static const char *prototypes_for_120_vert = "(function atan\n" " (signature float\n" " (parameters\n" - " (declare (in ) float y@0x22185b0)\n" - " (declare (in ) float x@0x22186c0)\n" + " (declare (in ) float y@0x13d6090)\n" + " (declare (in ) float x@0x13d61a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 y@0x2218a70)\n" - " (declare (in ) vec2 x@0x2218b80)\n" + " (declare (in ) vec2 y@0x13d6520)\n" + " (declare (in ) vec2 x@0x13d6630)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 y@0x2218d60)\n" - " (declare (in ) vec3 x@0x2218e70)\n" + " (declare (in ) vec3 y@0x13d6810)\n" + " (declare (in ) vec3 x@0x13d6920)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 y@0x2219050)\n" - " (declare (in ) vec4 x@0x2219160)\n" + " (declare (in ) vec4 y@0x13d6b00)\n" + " (declare (in ) vec4 x@0x13d6c10)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) float y_over_x@0x2219340)\n" + " (declare (in ) float y_over_x@0x13d6df0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 y_over_x@0x2219530)\n" + " (declare (in ) vec2 y_over_x@0x13d6fe0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 y_over_x@0x2219720)\n" + " (declare (in ) vec3 y_over_x@0x13d71d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 y_over_x@0x2219910)\n" + " (declare (in ) vec4 y_over_x@0x13d73c0)\n" " )\n" " (\n" " ))\n" @@ -4998,32 +4998,32 @@ static const char *prototypes_for_120_vert = "(function pow\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x2219b00)\n" - " (declare (in ) float y@0x2219c10)\n" + " (declare (in ) float x@0x13d75b0)\n" + " (declare (in ) float y@0x13d76c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2219fc0)\n" - " (declare (in ) vec2 y@0x221a0d0)\n" + " (declare (in ) vec2 x@0x13d7a40)\n" + " (declare (in ) vec2 y@0x13d7b50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x221a2b0)\n" - " (declare (in ) vec3 y@0x221a3c0)\n" + " (declare (in ) vec3 x@0x13d7d30)\n" + " (declare (in ) vec3 y@0x13d7e40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x221a5a0)\n" - " (declare (in ) vec4 y@0x221a6b0)\n" + " (declare (in ) vec4 x@0x13d8020)\n" + " (declare (in ) vec4 y@0x13d8130)\n" " )\n" " (\n" " ))\n" @@ -5033,28 +5033,28 @@ static const char *prototypes_for_120_vert = "(function exp\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x221a890)\n" + " (declare (in ) float x@0x13d8310)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x221ac40)\n" + " (declare (in ) vec2 x@0x13d8690)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x221ae20)\n" + " (declare (in ) vec3 x@0x13d8870)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x221b000)\n" + " (declare (in ) vec4 x@0x13d8a50)\n" " )\n" " (\n" " ))\n" @@ -5064,28 +5064,28 @@ static const char *prototypes_for_120_vert = "(function log\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x221b1e0)\n" + " (declare (in ) float x@0x13d8c30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x221b590)\n" + " (declare (in ) vec2 x@0x13d8fb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x221b770)\n" + " (declare (in ) vec3 x@0x13d9190)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x221b950)\n" + " (declare (in ) vec4 x@0x13d9370)\n" " )\n" " (\n" " ))\n" @@ -5095,28 +5095,28 @@ static const char *prototypes_for_120_vert = "(function exp2\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x221bb30)\n" + " (declare (in ) float x@0x13d9550)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x221bee0)\n" + " (declare (in ) vec2 x@0x13d98d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x221c0c0)\n" + " (declare (in ) vec3 x@0x13d9ab0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x221c2a0)\n" + " (declare (in ) vec4 x@0x13d9c90)\n" " )\n" " (\n" " ))\n" @@ -5126,28 +5126,28 @@ static const char *prototypes_for_120_vert = "(function log2\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x221c480)\n" + " (declare (in ) float x@0x13d9e70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x221c830)\n" + " (declare (in ) vec2 x@0x13da1f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x221ca10)\n" + " (declare (in ) vec3 x@0x13da3d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x221cbf0)\n" + " (declare (in ) vec4 x@0x13da5b0)\n" " )\n" " (\n" " ))\n" @@ -5157,28 +5157,28 @@ static const char *prototypes_for_120_vert = "(function sqrt\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x221cdd0)\n" + " (declare (in ) float x@0x13da790)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x221d180)\n" + " (declare (in ) vec2 x@0x13dab10)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x221d360)\n" + " (declare (in ) vec3 x@0x13dacf0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x221d540)\n" + " (declare (in ) vec4 x@0x13daed0)\n" " )\n" " (\n" " ))\n" @@ -5188,28 +5188,28 @@ static const char *prototypes_for_120_vert = "(function inversesqrt\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x221d720)\n" + " (declare (in ) float x@0x13db0b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x221dae0)\n" + " (declare (in ) vec2 x@0x13db440)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x221dcc0)\n" + " (declare (in ) vec3 x@0x13db620)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x221dea0)\n" + " (declare (in ) vec4 x@0x13db800)\n" " )\n" " (\n" " ))\n" @@ -5219,28 +5219,28 @@ static const char *prototypes_for_120_vert = "(function abs\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x221e080)\n" + " (declare (in ) float x@0x13db9e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x221e430)\n" + " (declare (in ) vec2 x@0x13dbd60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x221e610)\n" + " (declare (in ) vec3 x@0x13dbf40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x221e7f0)\n" + " (declare (in ) vec4 x@0x13dc120)\n" " )\n" " (\n" " ))\n" @@ -5250,28 +5250,28 @@ static const char *prototypes_for_120_vert = "(function sign\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x221e9d0)\n" + " (declare (in ) float x@0x13dc300)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x221ed80)\n" + " (declare (in ) vec2 x@0x13dc680)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x221ef60)\n" + " (declare (in ) vec3 x@0x13dc860)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x221f140)\n" + " (declare (in ) vec4 x@0x13dca40)\n" " )\n" " (\n" " ))\n" @@ -5281,28 +5281,28 @@ static const char *prototypes_for_120_vert = "(function floor\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x221f320)\n" + " (declare (in ) float x@0x13dcc20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x221f6d0)\n" + " (declare (in ) vec2 x@0x13dcfa0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x221f8b0)\n" + " (declare (in ) vec3 x@0x13dd180)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x221fa90)\n" + " (declare (in ) vec4 x@0x13dd360)\n" " )\n" " (\n" " ))\n" @@ -5312,28 +5312,28 @@ static const char *prototypes_for_120_vert = "(function ceil\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x221fc70)\n" + " (declare (in ) float x@0x13dd540)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2220020)\n" + " (declare (in ) vec2 x@0x13dd8c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x2220200)\n" + " (declare (in ) vec3 x@0x13ddaa0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x22203e0)\n" + " (declare (in ) vec4 x@0x13ddc80)\n" " )\n" " (\n" " ))\n" @@ -5343,28 +5343,28 @@ static const char *prototypes_for_120_vert = "(function fract\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x22205c0)\n" + " (declare (in ) float x@0x13dde60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2220970)\n" + " (declare (in ) vec2 x@0x13de1e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x2220b50)\n" + " (declare (in ) vec3 x@0x13de3c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x2220d30)\n" + " (declare (in ) vec4 x@0x13de5a0)\n" " )\n" " (\n" " ))\n" @@ -5374,56 +5374,56 @@ static const char *prototypes_for_120_vert = "(function mod\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x2220f10)\n" - " (declare (in ) float y@0x2221020)\n" + " (declare (in ) float x@0x13de780)\n" + " (declare (in ) float y@0x13de890)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x22213d0)\n" - " (declare (in ) float y@0x22214e0)\n" + " (declare (in ) vec2 x@0x13dec10)\n" + " (declare (in ) float y@0x13ded20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x22216c0)\n" - " (declare (in ) float y@0x22217d0)\n" + " (declare (in ) vec3 x@0x13def00)\n" + " (declare (in ) float y@0x13df010)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x22219b0)\n" - " (declare (in ) float y@0x2221ac0)\n" + " (declare (in ) vec4 x@0x13df1f0)\n" + " (declare (in ) float y@0x13df300)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2221ca0)\n" - " (declare (in ) vec2 y@0x2221db0)\n" + " (declare (in ) vec2 x@0x13df4e0)\n" + " (declare (in ) vec2 y@0x13df5f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x2221f90)\n" - " (declare (in ) vec3 y@0x22220a0)\n" + " (declare (in ) vec3 x@0x13df7d0)\n" + " (declare (in ) vec3 y@0x13df8e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x2222280)\n" - " (declare (in ) vec4 y@0x2222390)\n" + " (declare (in ) vec4 x@0x13dfac0)\n" + " (declare (in ) vec4 y@0x13dfbd0)\n" " )\n" " (\n" " ))\n" @@ -5433,56 +5433,56 @@ static const char *prototypes_for_120_vert = "(function min\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x2222570)\n" - " (declare (in ) float y@0x2222680)\n" + " (declare (in ) float x@0x13dfdb0)\n" + " (declare (in ) float y@0x13dfec0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2222a30)\n" - " (declare (in ) vec2 y@0x2222b40)\n" + " (declare (in ) vec2 x@0x13e0240)\n" + " (declare (in ) vec2 y@0x13e0350)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x2222d20)\n" - " (declare (in ) vec3 y@0x2222e30)\n" + " (declare (in ) vec3 x@0x13e0530)\n" + " (declare (in ) vec3 y@0x13e0640)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x2223010)\n" - " (declare (in ) vec4 y@0x2223120)\n" + " (declare (in ) vec4 x@0x13e0820)\n" + " (declare (in ) vec4 y@0x13e0930)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2223300)\n" - " (declare (in ) float y@0x2223410)\n" + " (declare (in ) vec2 x@0x13e0b10)\n" + " (declare (in ) float y@0x13e0c20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x22235f0)\n" - " (declare (in ) float y@0x2223700)\n" + " (declare (in ) vec3 x@0x13e0e00)\n" + " (declare (in ) float y@0x13e0f10)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x22238e0)\n" - " (declare (in ) float y@0x22239f0)\n" + " (declare (in ) vec4 x@0x13e10f0)\n" + " (declare (in ) float y@0x13e1200)\n" " )\n" " (\n" " ))\n" @@ -5492,56 +5492,56 @@ static const char *prototypes_for_120_vert = "(function max\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x2223bd0)\n" - " (declare (in ) float y@0x2223ce0)\n" + " (declare (in ) float x@0x13e13e0)\n" + " (declare (in ) float y@0x13e14f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2224090)\n" - " (declare (in ) vec2 y@0x22241a0)\n" + " (declare (in ) vec2 x@0x13e1870)\n" + " (declare (in ) vec2 y@0x13e1980)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x2224380)\n" - " (declare (in ) vec3 y@0x2224490)\n" + " (declare (in ) vec3 x@0x13e1b60)\n" + " (declare (in ) vec3 y@0x13e1c70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x2224670)\n" - " (declare (in ) vec4 y@0x2224780)\n" + " (declare (in ) vec4 x@0x13e1e50)\n" + " (declare (in ) vec4 y@0x13e1f60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2224960)\n" - " (declare (in ) float y@0x2224a70)\n" + " (declare (in ) vec2 x@0x13e2140)\n" + " (declare (in ) float y@0x13e2250)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x2224c50)\n" - " (declare (in ) float y@0x2224d60)\n" + " (declare (in ) vec3 x@0x13e2430)\n" + " (declare (in ) float y@0x13e2540)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x2224f40)\n" - " (declare (in ) float y@0x2225050)\n" + " (declare (in ) vec4 x@0x13e2720)\n" + " (declare (in ) float y@0x13e2830)\n" " )\n" " (\n" " ))\n" @@ -5551,63 +5551,63 @@ static const char *prototypes_for_120_vert = "(function clamp\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x2225230)\n" - " (declare (in ) float minVal@0x2225340)\n" - " (declare (in ) float maxVal@0x2225450)\n" + " (declare (in ) float x@0x13e2a10)\n" + " (declare (in ) float minVal@0x13e2b20)\n" + " (declare (in ) float maxVal@0x13e2c30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2225800)\n" - " (declare (in ) vec2 minVal@0x2225910)\n" - " (declare (in ) vec2 maxVal@0x2225a20)\n" + " (declare (in ) vec2 x@0x13e2fb0)\n" + " (declare (in ) vec2 minVal@0x13e30c0)\n" + " (declare (in ) vec2 maxVal@0x13e31d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x2225c00)\n" - " (declare (in ) vec3 minVal@0x2225d10)\n" - " (declare (in ) vec3 maxVal@0x2225e20)\n" + " (declare (in ) vec3 x@0x13e33b0)\n" + " (declare (in ) vec3 minVal@0x13e34c0)\n" + " (declare (in ) vec3 maxVal@0x13e35d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x2226000)\n" - " (declare (in ) vec4 minVal@0x2226110)\n" - " (declare (in ) vec4 maxVal@0x2226220)\n" + " (declare (in ) vec4 x@0x13e37b0)\n" + " (declare (in ) vec4 minVal@0x13e38c0)\n" + " (declare (in ) vec4 maxVal@0x13e39d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2226400)\n" - " (declare (in ) float minVal@0x2226510)\n" - " (declare (in ) float maxVal@0x2226620)\n" + " (declare (in ) vec2 x@0x13e3bb0)\n" + " (declare (in ) float minVal@0x13e3cc0)\n" + " (declare (in ) float maxVal@0x13e3dd0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x2226800)\n" - " (declare (in ) float minVal@0x2226910)\n" - " (declare (in ) float maxVal@0x2226a20)\n" + " (declare (in ) vec3 x@0x13e3fb0)\n" + " (declare (in ) float minVal@0x13e40c0)\n" + " (declare (in ) float maxVal@0x13e41d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x2226c00)\n" - " (declare (in ) float minVal@0x2226d10)\n" - " (declare (in ) float maxVal@0x2226e20)\n" + " (declare (in ) vec4 x@0x13e43b0)\n" + " (declare (in ) float minVal@0x13e44c0)\n" + " (declare (in ) float maxVal@0x13e45d0)\n" " )\n" " (\n" " ))\n" @@ -5617,63 +5617,63 @@ static const char *prototypes_for_120_vert = "(function mix\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x2227000)\n" - " (declare (in ) float y@0x2227110)\n" - " (declare (in ) float a@0x2227220)\n" + " (declare (in ) float x@0x13e47b0)\n" + " (declare (in ) float y@0x13e48c0)\n" + " (declare (in ) float a@0x13e49d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x22275d0)\n" - " (declare (in ) vec2 y@0x22276e0)\n" - " (declare (in ) vec2 a@0x22277f0)\n" + " (declare (in ) vec2 x@0x13e4d50)\n" + " (declare (in ) vec2 y@0x13e4e60)\n" + " (declare (in ) vec2 a@0x13e4f70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x22279d0)\n" - " (declare (in ) vec3 y@0x2227ae0)\n" - " (declare (in ) vec3 a@0x2227bf0)\n" + " (declare (in ) vec3 x@0x13e5150)\n" + " (declare (in ) vec3 y@0x13e5260)\n" + " (declare (in ) vec3 a@0x13e5370)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x2227dd0)\n" - " (declare (in ) vec4 y@0x2227ee0)\n" - " (declare (in ) vec4 a@0x2227ff0)\n" + " (declare (in ) vec4 x@0x13e5550)\n" + " (declare (in ) vec4 y@0x13e5660)\n" + " (declare (in ) vec4 a@0x13e5770)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x22281d0)\n" - " (declare (in ) vec2 y@0x22282e0)\n" - " (declare (in ) float a@0x22283f0)\n" + " (declare (in ) vec2 x@0x13e5950)\n" + " (declare (in ) vec2 y@0x13e5a60)\n" + " (declare (in ) float a@0x13e5b70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x22285d0)\n" - " (declare (in ) vec3 y@0x22286e0)\n" - " (declare (in ) float a@0x22287f0)\n" + " (declare (in ) vec3 x@0x13e5d50)\n" + " (declare (in ) vec3 y@0x13e5e60)\n" + " (declare (in ) float a@0x13e5f70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x22289d0)\n" - " (declare (in ) vec4 y@0x2228ae0)\n" - " (declare (in ) float a@0x2228bf0)\n" + " (declare (in ) vec4 x@0x13e6150)\n" + " (declare (in ) vec4 y@0x13e6260)\n" + " (declare (in ) float a@0x13e6370)\n" " )\n" " (\n" " ))\n" @@ -5683,56 +5683,56 @@ static const char *prototypes_for_120_vert = "(function step\n" " (signature float\n" " (parameters\n" - " (declare (in ) float edge@0x2228dd0)\n" - " (declare (in ) float x@0x2228ee0)\n" + " (declare (in ) float edge@0x13e6550)\n" + " (declare (in ) float x@0x13e6660)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 edge@0x2229290)\n" - " (declare (in ) vec2 x@0x22293a0)\n" + " (declare (in ) vec2 edge@0x13e69e0)\n" + " (declare (in ) vec2 x@0x13e6af0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 edge@0x2229580)\n" - " (declare (in ) vec3 x@0x2229690)\n" + " (declare (in ) vec3 edge@0x13e6cd0)\n" + " (declare (in ) vec3 x@0x13e6de0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 edge@0x2229870)\n" - " (declare (in ) vec4 x@0x2229980)\n" + " (declare (in ) vec4 edge@0x13e6fc0)\n" + " (declare (in ) vec4 x@0x13e70d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float edge@0x2229b60)\n" - " (declare (in ) vec2 x@0x2229c70)\n" + " (declare (in ) float edge@0x13e72b0)\n" + " (declare (in ) vec2 x@0x13e73c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float edge@0x2229e50)\n" - " (declare (in ) vec3 x@0x2229f60)\n" + " (declare (in ) float edge@0x13e75a0)\n" + " (declare (in ) vec3 x@0x13e76b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float edge@0x222a140)\n" - " (declare (in ) vec4 x@0x222a250)\n" + " (declare (in ) float edge@0x13e7890)\n" + " (declare (in ) vec4 x@0x13e79a0)\n" " )\n" " (\n" " ))\n" @@ -5742,63 +5742,63 @@ static const char *prototypes_for_120_vert = "(function smoothstep\n" " (signature float\n" " (parameters\n" - " (declare (in ) float edge0@0x222a430)\n" - " (declare (in ) float edge1@0x222a540)\n" - " (declare (in ) float x@0x222a650)\n" + " (declare (in ) float edge0@0x13e7b80)\n" + " (declare (in ) float edge1@0x13e7c90)\n" + " (declare (in ) float x@0x13e7da0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 edge0@0x222aa10)\n" - " (declare (in ) vec2 edge1@0x222ab20)\n" - " (declare (in ) vec2 x@0x222ac30)\n" + " (declare (in ) vec2 edge0@0x13e8130)\n" + " (declare (in ) vec2 edge1@0x13e8240)\n" + " (declare (in ) vec2 x@0x13e8350)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 edge0@0x222ae10)\n" - " (declare (in ) vec3 edge1@0x222af20)\n" - " (declare (in ) vec3 x@0x222b030)\n" + " (declare (in ) vec3 edge0@0x13e8530)\n" + " (declare (in ) vec3 edge1@0x13e8640)\n" + " (declare (in ) vec3 x@0x13e8750)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 edge0@0x222b210)\n" - " (declare (in ) vec4 edge1@0x222b320)\n" - " (declare (in ) vec4 x@0x222b430)\n" + " (declare (in ) vec4 edge0@0x13e8930)\n" + " (declare (in ) vec4 edge1@0x13e8a40)\n" + " (declare (in ) vec4 x@0x13e8b50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float edge0@0x222b610)\n" - " (declare (in ) float edge1@0x222b720)\n" - " (declare (in ) vec2 x@0x222b830)\n" + " (declare (in ) float edge0@0x13e8d30)\n" + " (declare (in ) float edge1@0x13e8e40)\n" + " (declare (in ) vec2 x@0x13e8f50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float edge0@0x222ba10)\n" - " (declare (in ) float edge1@0x222bb20)\n" - " (declare (in ) vec3 x@0x222bc30)\n" + " (declare (in ) float edge0@0x13e9130)\n" + " (declare (in ) float edge1@0x13e9240)\n" + " (declare (in ) vec3 x@0x13e9350)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float edge0@0x222be10)\n" - " (declare (in ) float edge1@0x222bf20)\n" - " (declare (in ) vec4 x@0x222c030)\n" + " (declare (in ) float edge0@0x13e9530)\n" + " (declare (in ) float edge1@0x13e9640)\n" + " (declare (in ) vec4 x@0x13e9750)\n" " )\n" " (\n" " ))\n" @@ -5808,28 +5808,28 @@ static const char *prototypes_for_120_vert = "(function length\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x222c210)\n" + " (declare (in ) float x@0x13e9930)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x222c5c0)\n" + " (declare (in ) vec2 x@0x13e9cb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x222c7a0)\n" + " (declare (in ) vec3 x@0x13e9e90)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x222c980)\n" + " (declare (in ) vec4 x@0x13ea070)\n" " )\n" " (\n" " ))\n" @@ -5839,32 +5839,32 @@ static const char *prototypes_for_120_vert = "(function distance\n" " (signature float\n" " (parameters\n" - " (declare (in ) float p0@0x222cb60)\n" - " (declare (in ) float p1@0x222cc70)\n" + " (declare (in ) float p0@0x13ea250)\n" + " (declare (in ) float p1@0x13ea360)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 p0@0x222d030)\n" - " (declare (in ) vec2 p1@0x222d140)\n" + " (declare (in ) vec2 p0@0x13ea6f0)\n" + " (declare (in ) vec2 p1@0x13ea800)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 p0@0x222d320)\n" - " (declare (in ) vec3 p1@0x222d430)\n" + " (declare (in ) vec3 p0@0x13ea9e0)\n" + " (declare (in ) vec3 p1@0x13eaaf0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 p0@0x222d610)\n" - " (declare (in ) vec4 p1@0x222d720)\n" + " (declare (in ) vec4 p0@0x13eacd0)\n" + " (declare (in ) vec4 p1@0x13eade0)\n" " )\n" " (\n" " ))\n" @@ -5874,32 +5874,32 @@ static const char *prototypes_for_120_vert = "(function dot\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x222d900)\n" - " (declare (in ) float y@0x222da10)\n" + " (declare (in ) float x@0x13eafc0)\n" + " (declare (in ) float y@0x13eb0d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x222ddc0)\n" - " (declare (in ) vec2 y@0x222ded0)\n" + " (declare (in ) vec2 x@0x13eb450)\n" + " (declare (in ) vec2 y@0x13eb560)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x222e0b0)\n" - " (declare (in ) vec3 y@0x222e1c0)\n" + " (declare (in ) vec3 x@0x13eb740)\n" + " (declare (in ) vec3 y@0x13eb850)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x222e3a0)\n" - " (declare (in ) vec4 y@0x222e4b0)\n" + " (declare (in ) vec4 x@0x13eba30)\n" + " (declare (in ) vec4 y@0x13ebb40)\n" " )\n" " (\n" " ))\n" @@ -5909,8 +5909,8 @@ static const char *prototypes_for_120_vert = "(function cross\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x222e690)\n" - " (declare (in ) vec3 y@0x222e7a0)\n" + " (declare (in ) vec3 x@0x13ebd20)\n" + " (declare (in ) vec3 y@0x13ebe30)\n" " )\n" " (\n" " ))\n" @@ -5920,28 +5920,28 @@ static const char *prototypes_for_120_vert = "(function normalize\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x222eb50)\n" + " (declare (in ) float x@0x13ec1b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x222ef10)\n" + " (declare (in ) vec2 x@0x13ec540)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x222f0f0)\n" + " (declare (in ) vec3 x@0x13ec720)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x222f2d0)\n" + " (declare (in ) vec4 x@0x13ec900)\n" " )\n" " (\n" " ))\n" @@ -5960,36 +5960,36 @@ static const char *prototypes_for_120_vert = "(function faceforward\n" " (signature float\n" " (parameters\n" - " (declare (in ) float N@0x222f760)\n" - " (declare (in ) float I@0x222f870)\n" - " (declare (in ) float Nref@0x222f980)\n" + " (declare (in ) float N@0x13ecd60)\n" + " (declare (in ) float I@0x13ece70)\n" + " (declare (in ) float Nref@0x13ecf80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 N@0x222fd40)\n" - " (declare (in ) vec2 I@0x222fe50)\n" - " (declare (in ) vec2 Nref@0x222ff60)\n" + " (declare (in ) vec2 N@0x13ed310)\n" + " (declare (in ) vec2 I@0x13ed420)\n" + " (declare (in ) vec2 Nref@0x13ed530)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 N@0x2230140)\n" - " (declare (in ) vec3 I@0x2230250)\n" - " (declare (in ) vec3 Nref@0x2230360)\n" + " (declare (in ) vec3 N@0x13ed710)\n" + " (declare (in ) vec3 I@0x13ed820)\n" + " (declare (in ) vec3 Nref@0x13ed930)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 N@0x2230540)\n" - " (declare (in ) vec4 I@0x2230650)\n" - " (declare (in ) vec4 Nref@0x2230760)\n" + " (declare (in ) vec4 N@0x13edb10)\n" + " (declare (in ) vec4 I@0x13edc20)\n" + " (declare (in ) vec4 Nref@0x13edd30)\n" " )\n" " (\n" " ))\n" @@ -5999,32 +5999,32 @@ static const char *prototypes_for_120_vert = "(function reflect\n" " (signature float\n" " (parameters\n" - " (declare (in ) float I@0x2230940)\n" - " (declare (in ) float N@0x2230a50)\n" + " (declare (in ) float I@0x13edf10)\n" + " (declare (in ) float N@0x13ee020)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 I@0x2230e10)\n" - " (declare (in ) vec2 N@0x2230f20)\n" + " (declare (in ) vec2 I@0x13ee3a0)\n" + " (declare (in ) vec2 N@0x13ee4b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 I@0x2231100)\n" - " (declare (in ) vec3 N@0x2231210)\n" + " (declare (in ) vec3 I@0x13ee690)\n" + " (declare (in ) vec3 N@0x13ee7a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 I@0x22313f0)\n" - " (declare (in ) vec4 N@0x2231500)\n" + " (declare (in ) vec4 I@0x13ee980)\n" + " (declare (in ) vec4 N@0x13eea90)\n" " )\n" " (\n" " ))\n" @@ -6034,36 +6034,36 @@ static const char *prototypes_for_120_vert = "(function refract\n" " (signature float\n" " (parameters\n" - " (declare (in ) float I@0x22316e0)\n" - " (declare (in ) float N@0x22317f0)\n" - " (declare (in ) float eta@0x2231900)\n" + " (declare (in ) float I@0x13eec70)\n" + " (declare (in ) float N@0x13eed80)\n" + " (declare (in ) float eta@0x13eee90)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 I@0x2231cc0)\n" - " (declare (in ) vec2 N@0x2231dd0)\n" - " (declare (in ) float eta@0x2231ee0)\n" + " (declare (in ) vec2 I@0x13ef210)\n" + " (declare (in ) vec2 N@0x13ef320)\n" + " (declare (in ) float eta@0x13ef430)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 I@0x22320c0)\n" - " (declare (in ) vec3 N@0x22321d0)\n" - " (declare (in ) float eta@0x22322e0)\n" + " (declare (in ) vec3 I@0x13ef610)\n" + " (declare (in ) vec3 N@0x13ef720)\n" + " (declare (in ) float eta@0x13ef830)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 I@0x22324c0)\n" - " (declare (in ) vec4 N@0x22325d0)\n" - " (declare (in ) float eta@0x22326e0)\n" + " (declare (in ) vec4 I@0x13efa10)\n" + " (declare (in ) vec4 N@0x13efb20)\n" + " (declare (in ) float eta@0x13efc30)\n" " )\n" " (\n" " ))\n" @@ -6073,72 +6073,72 @@ static const char *prototypes_for_120_vert = "(function matrixCompMult\n" " (signature mat2\n" " (parameters\n" - " (declare (in ) mat2 x@0x22328c0)\n" - " (declare (in ) mat2 y@0x22329d0)\n" + " (declare (in ) mat2 x@0x13efe10)\n" + " (declare (in ) mat2 y@0x13eff20)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3\n" " (parameters\n" - " (declare (in ) mat3 x@0x2232d90)\n" - " (declare (in ) mat3 y@0x2232ea0)\n" + " (declare (in ) mat3 x@0x13f02b0)\n" + " (declare (in ) mat3 y@0x13f03c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4\n" " (parameters\n" - " (declare (in ) mat4 x@0x2233080)\n" - " (declare (in ) mat4 y@0x2233190)\n" + " (declare (in ) mat4 x@0x13f05a0)\n" + " (declare (in ) mat4 y@0x13f06b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x3\n" " (parameters\n" - " (declare (in ) mat2x3 x@0x2233370)\n" - " (declare (in ) mat2x3 y@0x2233480)\n" + " (declare (in ) mat2x3 x@0x13f0890)\n" + " (declare (in ) mat2x3 y@0x13f09a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x4\n" " (parameters\n" - " (declare (in ) mat2x4 x@0x2233660)\n" - " (declare (in ) mat2x4 y@0x2233770)\n" + " (declare (in ) mat2x4 x@0x13f0b80)\n" + " (declare (in ) mat2x4 y@0x13f0c90)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x2\n" " (parameters\n" - " (declare (in ) mat3x2 x@0x2233950)\n" - " (declare (in ) mat3x2 y@0x2233a60)\n" + " (declare (in ) mat3x2 x@0x13f0e70)\n" + " (declare (in ) mat3x2 y@0x13f0f80)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x4\n" " (parameters\n" - " (declare (in ) mat3x4 x@0x2233c40)\n" - " (declare (in ) mat3x4 y@0x2233d50)\n" + " (declare (in ) mat3x4 x@0x13f1160)\n" + " (declare (in ) mat3x4 y@0x13f1270)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x2\n" " (parameters\n" - " (declare (in ) mat4x2 x@0x2233f30)\n" - " (declare (in ) mat4x2 y@0x2234040)\n" + " (declare (in ) mat4x2 x@0x13f1450)\n" + " (declare (in ) mat4x2 y@0x13f1560)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x3\n" " (parameters\n" - " (declare (in ) mat4x3 x@0x2234220)\n" - " (declare (in ) mat4x3 y@0x2234330)\n" + " (declare (in ) mat4x3 x@0x13f1740)\n" + " (declare (in ) mat4x3 y@0x13f1850)\n" " )\n" " (\n" " ))\n" @@ -6148,72 +6148,72 @@ static const char *prototypes_for_120_vert = "(function outerProduct\n" " (signature mat2\n" " (parameters\n" - " (declare (in ) vec2 c@0x2234510)\n" - " (declare (in ) vec2 r@0x2234620)\n" + " (declare (in ) vec2 c@0x13f1a30)\n" + " (declare (in ) vec2 r@0x13f1b40)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3\n" " (parameters\n" - " (declare (in ) vec3 c@0x22349e0)\n" - " (declare (in ) vec3 r@0x2234af0)\n" + " (declare (in ) vec3 c@0x13f1ed0)\n" + " (declare (in ) vec3 r@0x13f1fe0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4\n" " (parameters\n" - " (declare (in ) vec4 c@0x2234cd0)\n" - " (declare (in ) vec4 r@0x2234de0)\n" + " (declare (in ) vec4 c@0x13f21c0)\n" + " (declare (in ) vec4 r@0x13f22d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x3\n" " (parameters\n" - " (declare (in ) vec3 c@0x2234fc0)\n" - " (declare (in ) vec2 r@0x22350d0)\n" + " (declare (in ) vec3 c@0x13f24b0)\n" + " (declare (in ) vec2 r@0x13f25c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x2\n" " (parameters\n" - " (declare (in ) vec2 c@0x22352b0)\n" - " (declare (in ) vec3 r@0x22353c0)\n" + " (declare (in ) vec2 c@0x13f27a0)\n" + " (declare (in ) vec3 r@0x13f28b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x4\n" " (parameters\n" - " (declare (in ) vec4 c@0x22355a0)\n" - " (declare (in ) vec2 r@0x22356b0)\n" + " (declare (in ) vec4 c@0x13f2a90)\n" + " (declare (in ) vec2 r@0x13f2ba0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x2\n" " (parameters\n" - " (declare (in ) vec2 c@0x2235890)\n" - " (declare (in ) vec4 r@0x22359a0)\n" + " (declare (in ) vec2 c@0x13f2d80)\n" + " (declare (in ) vec4 r@0x13f2e90)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x4\n" " (parameters\n" - " (declare (in ) vec4 c@0x2235b80)\n" - " (declare (in ) vec3 r@0x2235c90)\n" + " (declare (in ) vec4 c@0x13f3070)\n" + " (declare (in ) vec3 r@0x13f3180)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x3\n" " (parameters\n" - " (declare (in ) vec3 c@0x2235e70)\n" - " (declare (in ) vec4 r@0x2235f80)\n" + " (declare (in ) vec3 c@0x13f3360)\n" + " (declare (in ) vec4 r@0x13f3470)\n" " )\n" " (\n" " ))\n" @@ -6223,63 +6223,63 @@ static const char *prototypes_for_120_vert = "(function transpose\n" " (signature mat2\n" " (parameters\n" - " (declare (in ) mat2 m@0x2236160)\n" + " (declare (in ) mat2 m@0x13f3650)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3\n" " (parameters\n" - " (declare (in ) mat3 m@0x2236520)\n" + " (declare (in ) mat3 m@0x13f39e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4\n" " (parameters\n" - " (declare (in ) mat4 m@0x2236700)\n" + " (declare (in ) mat4 m@0x13f3bc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x3\n" " (parameters\n" - " (declare (in ) mat3x2 m@0x22368e0)\n" + " (declare (in ) mat3x2 m@0x13f3da0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x2\n" " (parameters\n" - " (declare (in ) mat2x3 m@0x2236ac0)\n" + " (declare (in ) mat2x3 m@0x13f3f80)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x4\n" " (parameters\n" - " (declare (in ) mat4x2 m@0x2236ca0)\n" + " (declare (in ) mat4x2 m@0x13f4160)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x2\n" " (parameters\n" - " (declare (in ) mat2x4 m@0x2236e80)\n" + " (declare (in ) mat2x4 m@0x13f4340)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x4\n" " (parameters\n" - " (declare (in ) mat4x3 m@0x2237060)\n" + " (declare (in ) mat4x3 m@0x13f4520)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x3\n" " (parameters\n" - " (declare (in ) mat3x4 m@0x2237240)\n" + " (declare (in ) mat3x4 m@0x13f4700)\n" " )\n" " (\n" " ))\n" @@ -6289,48 +6289,48 @@ static const char *prototypes_for_120_vert = "(function lessThan\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2237420)\n" - " (declare (in ) vec2 y@0x2237530)\n" + " (declare (in ) vec2 x@0x13f48e0)\n" + " (declare (in ) vec2 y@0x13f49f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x22378f0)\n" - " (declare (in ) vec3 y@0x2237a00)\n" + " (declare (in ) vec3 x@0x13f4d80)\n" + " (declare (in ) vec3 y@0x13f4e90)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x2237be0)\n" - " (declare (in ) vec4 y@0x2237cf0)\n" + " (declare (in ) vec4 x@0x13f5070)\n" + " (declare (in ) vec4 y@0x13f5180)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x2237ed0)\n" - " (declare (in ) ivec2 y@0x2237fe0)\n" + " (declare (in ) ivec2 x@0x13f5360)\n" + " (declare (in ) ivec2 y@0x13f5470)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x22381c0)\n" - " (declare (in ) ivec3 y@0x22382d0)\n" + " (declare (in ) ivec3 x@0x13f5650)\n" + " (declare (in ) ivec3 y@0x13f5760)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x22384b0)\n" - " (declare (in ) ivec4 y@0x22385c0)\n" + " (declare (in ) ivec4 x@0x13f5940)\n" + " (declare (in ) ivec4 y@0x13f5a50)\n" " )\n" " (\n" " ))\n" @@ -6340,48 +6340,48 @@ static const char *prototypes_for_120_vert = "(function lessThanEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x22387a0)\n" - " (declare (in ) vec2 y@0x22388b0)\n" + " (declare (in ) vec2 x@0x13f5c30)\n" + " (declare (in ) vec2 y@0x13f5d40)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x2238c70)\n" - " (declare (in ) vec3 y@0x2238d80)\n" + " (declare (in ) vec3 x@0x13f60d0)\n" + " (declare (in ) vec3 y@0x13f61e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x2238f60)\n" - " (declare (in ) vec4 y@0x2239070)\n" + " (declare (in ) vec4 x@0x13f63c0)\n" + " (declare (in ) vec4 y@0x13f64d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x2239250)\n" - " (declare (in ) ivec2 y@0x2239360)\n" + " (declare (in ) ivec2 x@0x13f66b0)\n" + " (declare (in ) ivec2 y@0x13f67c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x2239540)\n" - " (declare (in ) ivec3 y@0x2239650)\n" + " (declare (in ) ivec3 x@0x13f69a0)\n" + " (declare (in ) ivec3 y@0x13f6ab0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x2239830)\n" - " (declare (in ) ivec4 y@0x2239940)\n" + " (declare (in ) ivec4 x@0x13f6c90)\n" + " (declare (in ) ivec4 y@0x13f6da0)\n" " )\n" " (\n" " ))\n" @@ -6391,48 +6391,48 @@ static const char *prototypes_for_120_vert = "(function greaterThan\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x2239b20)\n" - " (declare (in ) vec2 y@0x2239c30)\n" + " (declare (in ) vec2 x@0x13f6f80)\n" + " (declare (in ) vec2 y@0x13f7090)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x2239ff0)\n" - " (declare (in ) vec3 y@0x223a100)\n" + " (declare (in ) vec3 x@0x13f7420)\n" + " (declare (in ) vec3 y@0x13f7530)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x223a2e0)\n" - " (declare (in ) vec4 y@0x223a3f0)\n" + " (declare (in ) vec4 x@0x13f7710)\n" + " (declare (in ) vec4 y@0x13f7820)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x223a5d0)\n" - " (declare (in ) ivec2 y@0x223a6e0)\n" + " (declare (in ) ivec2 x@0x13f7a00)\n" + " (declare (in ) ivec2 y@0x13f7b10)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x223a8c0)\n" - " (declare (in ) ivec3 y@0x223a9d0)\n" + " (declare (in ) ivec3 x@0x13f7cf0)\n" + " (declare (in ) ivec3 y@0x13f7e00)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x223abb0)\n" - " (declare (in ) ivec4 y@0x223acc0)\n" + " (declare (in ) ivec4 x@0x13f7fe0)\n" + " (declare (in ) ivec4 y@0x13f80f0)\n" " )\n" " (\n" " ))\n" @@ -6442,48 +6442,48 @@ static const char *prototypes_for_120_vert = "(function greaterThanEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x223aea0)\n" - " (declare (in ) vec2 y@0x223afb0)\n" + " (declare (in ) vec2 x@0x13f82d0)\n" + " (declare (in ) vec2 y@0x13f83e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x223b370)\n" - " (declare (in ) vec3 y@0x223b480)\n" + " (declare (in ) vec3 x@0x13f8770)\n" + " (declare (in ) vec3 y@0x13f8880)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x223b660)\n" - " (declare (in ) vec4 y@0x223b770)\n" + " (declare (in ) vec4 x@0x13f8a60)\n" + " (declare (in ) vec4 y@0x13f8b70)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x223b950)\n" - " (declare (in ) ivec2 y@0x223ba60)\n" + " (declare (in ) ivec2 x@0x13f8d50)\n" + " (declare (in ) ivec2 y@0x13f8e60)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x223bc40)\n" - " (declare (in ) ivec3 y@0x223bd50)\n" + " (declare (in ) ivec3 x@0x13f9040)\n" + " (declare (in ) ivec3 y@0x13f9150)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x223bf30)\n" - " (declare (in ) ivec4 y@0x223c040)\n" + " (declare (in ) ivec4 x@0x13f9330)\n" + " (declare (in ) ivec4 y@0x13f9440)\n" " )\n" " (\n" " ))\n" @@ -6493,72 +6493,72 @@ static const char *prototypes_for_120_vert = "(function equal\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x223c220)\n" - " (declare (in ) vec2 y@0x223c330)\n" + " (declare (in ) vec2 x@0x13f9620)\n" + " (declare (in ) vec2 y@0x13f9730)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x223c6e0)\n" - " (declare (in ) vec3 y@0x223c7f0)\n" + " (declare (in ) vec3 x@0x13f9ab0)\n" + " (declare (in ) vec3 y@0x13f9bc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x223c9d0)\n" - " (declare (in ) vec4 y@0x223cae0)\n" + " (declare (in ) vec4 x@0x13f9da0)\n" + " (declare (in ) vec4 y@0x13f9eb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x223ccc0)\n" - " (declare (in ) ivec2 y@0x223cdd0)\n" + " (declare (in ) ivec2 x@0x13fa090)\n" + " (declare (in ) ivec2 y@0x13fa1a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x223cfb0)\n" - " (declare (in ) ivec3 y@0x223d0c0)\n" + " (declare (in ) ivec3 x@0x13fa380)\n" + " (declare (in ) ivec3 y@0x13fa490)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x223d2a0)\n" - " (declare (in ) ivec4 y@0x223d3b0)\n" + " (declare (in ) ivec4 x@0x13fa670)\n" + " (declare (in ) ivec4 y@0x13fa780)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0x223d590)\n" - " (declare (in ) bvec2 y@0x223d6a0)\n" + " (declare (in ) bvec2 x@0x13fa960)\n" + " (declare (in ) bvec2 y@0x13faa70)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0x223d880)\n" - " (declare (in ) bvec3 y@0x223d990)\n" + " (declare (in ) bvec3 x@0x13fac50)\n" + " (declare (in ) bvec3 y@0x13fad60)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0x223db70)\n" - " (declare (in ) bvec4 y@0x223dc80)\n" + " (declare (in ) bvec4 x@0x13faf40)\n" + " (declare (in ) bvec4 y@0x13fb050)\n" " )\n" " (\n" " ))\n" @@ -6568,72 +6568,72 @@ static const char *prototypes_for_120_vert = "(function notEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x223de60)\n" - " (declare (in ) vec2 y@0x223df70)\n" + " (declare (in ) vec2 x@0x13fb230)\n" + " (declare (in ) vec2 y@0x13fb340)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x223e330)\n" - " (declare (in ) vec3 y@0x223e440)\n" + " (declare (in ) vec3 x@0x13fb6d0)\n" + " (declare (in ) vec3 y@0x13fb7e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x223e620)\n" - " (declare (in ) vec4 y@0x223e730)\n" + " (declare (in ) vec4 x@0x13fb9c0)\n" + " (declare (in ) vec4 y@0x13fbad0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x223e910)\n" - " (declare (in ) ivec2 y@0x223ea20)\n" + " (declare (in ) ivec2 x@0x13fbcb0)\n" + " (declare (in ) ivec2 y@0x13fbdc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x223ec00)\n" - " (declare (in ) ivec3 y@0x223ed10)\n" + " (declare (in ) ivec3 x@0x13fbfa0)\n" + " (declare (in ) ivec3 y@0x13fc0b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x223eef0)\n" - " (declare (in ) ivec4 y@0x223f000)\n" + " (declare (in ) ivec4 x@0x13fc290)\n" + " (declare (in ) ivec4 y@0x13fc3a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0x223f1e0)\n" - " (declare (in ) bvec2 y@0x223f2f0)\n" + " (declare (in ) bvec2 x@0x13fc580)\n" + " (declare (in ) bvec2 y@0x13fc690)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0x223f4d0)\n" - " (declare (in ) bvec3 y@0x223f5e0)\n" + " (declare (in ) bvec3 x@0x13fc870)\n" + " (declare (in ) bvec3 y@0x13fc980)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0x223f7c0)\n" - " (declare (in ) bvec4 y@0x223f8d0)\n" + " (declare (in ) bvec4 x@0x13fcb60)\n" + " (declare (in ) bvec4 y@0x13fcc70)\n" " )\n" " (\n" " ))\n" @@ -6643,21 +6643,21 @@ static const char *prototypes_for_120_vert = "(function any\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec2 x@0x223fab0)\n" + " (declare (in ) bvec2 x@0x13fce50)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec3 x@0x223fe60)\n" + " (declare (in ) bvec3 x@0x13fd1d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec4 x@0x2240040)\n" + " (declare (in ) bvec4 x@0x13fd3b0)\n" " )\n" " (\n" " ))\n" @@ -6667,21 +6667,21 @@ static const char *prototypes_for_120_vert = "(function all\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec2 x@0x2240220)\n" + " (declare (in ) bvec2 x@0x13fd590)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec3 x@0x22405d0)\n" + " (declare (in ) bvec3 x@0x13fd910)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec4 x@0x22407b0)\n" + " (declare (in ) bvec4 x@0x13fdaf0)\n" " )\n" " (\n" " ))\n" @@ -6691,21 +6691,21 @@ static const char *prototypes_for_120_vert = "(function not\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0x2240990)\n" + " (declare (in ) bvec2 x@0x13fdcd0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0x2240d40)\n" + " (declare (in ) bvec3 x@0x13fe050)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0x2240f20)\n" + " (declare (in ) bvec4 x@0x13fe230)\n" " )\n" " (\n" " ))\n" @@ -6715,8 +6715,8 @@ static const char *prototypes_for_120_vert = "(function texture1D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x2241100)\n" - " (declare (in ) float coord@0x2241220)\n" + " (declare (in ) sampler1D sampler@0x13fe410)\n" + " (declare (in ) float coord@0x13fe520)\n" " )\n" " (\n" " ))\n" @@ -6726,16 +6726,16 @@ static const char *prototypes_for_120_vert = "(function texture1DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x22415e0)\n" - " (declare (in ) vec2 coord@0x2241700)\n" + " (declare (in ) sampler1D sampler@0x13fe8b0)\n" + " (declare (in ) vec2 coord@0x13fe9c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x2241ac0)\n" - " (declare (in ) vec4 coord@0x2241be0)\n" + " (declare (in ) sampler1D sampler@0x13fed50)\n" + " (declare (in ) vec4 coord@0x13fee60)\n" " )\n" " (\n" " ))\n" @@ -6745,9 +6745,9 @@ static const char *prototypes_for_120_vert = "(function texture1DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x2241dc0)\n" - " (declare (in ) float coord@0x2241ee0)\n" - " (declare (in ) float lod@0x2241ff0)\n" + " (declare (in ) sampler1D sampler@0x13ff040)\n" + " (declare (in ) float coord@0x13ff150)\n" + " (declare (in ) float lod@0x13ff260)\n" " )\n" " (\n" " ))\n" @@ -6757,18 +6757,18 @@ static const char *prototypes_for_120_vert = "(function texture1DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x22423b0)\n" - " (declare (in ) vec2 coord@0x22424d0)\n" - " (declare (in ) float lod@0x22425e0)\n" + " (declare (in ) sampler1D sampler@0x13ff5f0)\n" + " (declare (in ) vec2 coord@0x13ff700)\n" + " (declare (in ) float lod@0x13ff810)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x22429a0)\n" - " (declare (in ) vec4 coord@0x2242ac0)\n" - " (declare (in ) float lod@0x2242bd0)\n" + " (declare (in ) sampler1D sampler@0x13ffba0)\n" + " (declare (in ) vec4 coord@0x13ffcb0)\n" + " (declare (in ) float lod@0x13ffdc0)\n" " )\n" " (\n" " ))\n" @@ -6778,8 +6778,8 @@ static const char *prototypes_for_120_vert = "(function texture2D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x2242db0)\n" - " (declare (in ) vec2 coord@0x2242ed0)\n" + " (declare (in ) sampler2D sampler@0x13fffa0)\n" + " (declare (in ) vec2 coord@0x14000b0)\n" " )\n" " (\n" " ))\n" @@ -6789,16 +6789,16 @@ static const char *prototypes_for_120_vert = "(function texture2DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x2243290)\n" - " (declare (in ) vec3 coord@0x22433b0)\n" + " (declare (in ) sampler2D sampler@0x1400440)\n" + " (declare (in ) vec3 coord@0x1400550)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x2243770)\n" - " (declare (in ) vec4 coord@0x2243890)\n" + " (declare (in ) sampler2D sampler@0x14008e0)\n" + " (declare (in ) vec4 coord@0x14009f0)\n" " )\n" " (\n" " ))\n" @@ -6808,9 +6808,9 @@ static const char *prototypes_for_120_vert = "(function texture2DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x2243a70)\n" - " (declare (in ) vec2 coord@0x2243b90)\n" - " (declare (in ) float lod@0x2243ca0)\n" + " (declare (in ) sampler2D sampler@0x1400bd0)\n" + " (declare (in ) vec2 coord@0x1400ce0)\n" + " (declare (in ) float lod@0x1400df0)\n" " )\n" " (\n" " ))\n" @@ -6820,18 +6820,18 @@ static const char *prototypes_for_120_vert = "(function texture2DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x2244060)\n" - " (declare (in ) vec3 coord@0x2244180)\n" - " (declare (in ) float lod@0x2244290)\n" + " (declare (in ) sampler2D sampler@0x1401180)\n" + " (declare (in ) vec3 coord@0x1401290)\n" + " (declare (in ) float lod@0x14013a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x2244650)\n" - " (declare (in ) vec4 coord@0x2244770)\n" - " (declare (in ) float lod@0x2244880)\n" + " (declare (in ) sampler2D sampler@0x1401730)\n" + " (declare (in ) vec4 coord@0x1401840)\n" + " (declare (in ) float lod@0x1401950)\n" " )\n" " (\n" " ))\n" @@ -6841,8 +6841,8 @@ static const char *prototypes_for_120_vert = "(function texture3D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x2244a60)\n" - " (declare (in ) vec3 coord@0x2244b80)\n" + " (declare (in ) sampler3D sampler@0x1401b30)\n" + " (declare (in ) vec3 coord@0x1401c40)\n" " )\n" " (\n" " ))\n" @@ -6852,8 +6852,8 @@ static const char *prototypes_for_120_vert = "(function texture3DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x2244f40)\n" - " (declare (in ) vec4 coord@0x2245060)\n" + " (declare (in ) sampler3D sampler@0x1401fd0)\n" + " (declare (in ) vec4 coord@0x14020e0)\n" " )\n" " (\n" " ))\n" @@ -6863,9 +6863,9 @@ static const char *prototypes_for_120_vert = "(function texture3DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x2245420)\n" - " (declare (in ) vec3 coord@0x2245540)\n" - " (declare (in ) float lod@0x2245650)\n" + " (declare (in ) sampler3D sampler@0x1402470)\n" + " (declare (in ) vec3 coord@0x1402580)\n" + " (declare (in ) float lod@0x1402690)\n" " )\n" " (\n" " ))\n" @@ -6875,9 +6875,9 @@ static const char *prototypes_for_120_vert = "(function texture3DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x2245a10)\n" - " (declare (in ) vec4 coord@0x2245b30)\n" - " (declare (in ) float lod@0x2245c40)\n" + " (declare (in ) sampler3D sampler@0x1402a20)\n" + " (declare (in ) vec4 coord@0x1402b30)\n" + " (declare (in ) float lod@0x1402c40)\n" " )\n" " (\n" " ))\n" @@ -6887,8 +6887,8 @@ static const char *prototypes_for_120_vert = "(function textureCube\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) samplerCube sampler@0x2246000)\n" - " (declare (in ) vec3 coord@0x2246120)\n" + " (declare (in ) samplerCube sampler@0x1402fd0)\n" + " (declare (in ) vec3 coord@0x14030e0)\n" " )\n" " (\n" " ))\n" @@ -6898,9 +6898,9 @@ static const char *prototypes_for_120_vert = "(function textureCubeLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) samplerCube sampler@0x22464e0)\n" - " (declare (in ) vec3 coord@0x2246600)\n" - " (declare (in ) float lod@0x2246710)\n" + " (declare (in ) samplerCube sampler@0x1403470)\n" + " (declare (in ) vec3 coord@0x1403580)\n" + " (declare (in ) float lod@0x1403690)\n" " )\n" " (\n" " ))\n" @@ -6910,8 +6910,8 @@ static const char *prototypes_for_120_vert = "(function shadow1D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x2246ad0)\n" - " (declare (in ) vec3 coord@0x2246bf0)\n" + " (declare (in ) sampler1DShadow sampler@0x1403a20)\n" + " (declare (in ) vec3 coord@0x1403b30)\n" " )\n" " (\n" " ))\n" @@ -6921,8 +6921,8 @@ static const char *prototypes_for_120_vert = "(function shadow2D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x2246fb0)\n" - " (declare (in ) vec3 coord@0x22470d0)\n" + " (declare (in ) sampler2DShadow sampler@0x1403ec0)\n" + " (declare (in ) vec3 coord@0x1403fd0)\n" " )\n" " (\n" " ))\n" @@ -6932,8 +6932,8 @@ static const char *prototypes_for_120_vert = "(function shadow1DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x2247490)\n" - " (declare (in ) vec4 coord@0x22475b0)\n" + " (declare (in ) sampler1DShadow sampler@0x1404360)\n" + " (declare (in ) vec4 coord@0x1404470)\n" " )\n" " (\n" " ))\n" @@ -6943,8 +6943,8 @@ static const char *prototypes_for_120_vert = "(function shadow2DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x2247970)\n" - " (declare (in ) vec4 coord@0x2247a90)\n" + " (declare (in ) sampler2DShadow sampler@0x1404800)\n" + " (declare (in ) vec4 coord@0x1404910)\n" " )\n" " (\n" " ))\n" @@ -6954,9 +6954,9 @@ static const char *prototypes_for_120_vert = "(function shadow1DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x2247e50)\n" - " (declare (in ) vec3 coord@0x2247f70)\n" - " (declare (in ) float lod@0x2248080)\n" + " (declare (in ) sampler1DShadow sampler@0x1404ca0)\n" + " (declare (in ) vec3 coord@0x1404db0)\n" + " (declare (in ) float lod@0x1404ec0)\n" " )\n" " (\n" " ))\n" @@ -6966,9 +6966,9 @@ static const char *prototypes_for_120_vert = "(function shadow2DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x2248440)\n" - " (declare (in ) vec3 coord@0x2248560)\n" - " (declare (in ) float lod@0x2248670)\n" + " (declare (in ) sampler2DShadow sampler@0x1405250)\n" + " (declare (in ) vec3 coord@0x1405360)\n" + " (declare (in ) float lod@0x1405470)\n" " )\n" " (\n" " ))\n" @@ -6978,9 +6978,9 @@ static const char *prototypes_for_120_vert = "(function shadow1DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x2248a30)\n" - " (declare (in ) vec4 coord@0x2248b50)\n" - " (declare (in ) float lod@0x2248c60)\n" + " (declare (in ) sampler1DShadow sampler@0x1405800)\n" + " (declare (in ) vec4 coord@0x1405910)\n" + " (declare (in ) float lod@0x1405a20)\n" " )\n" " (\n" " ))\n" @@ -6990,9 +6990,9 @@ static const char *prototypes_for_120_vert = "(function shadow2DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x2249020)\n" - " (declare (in ) vec4 coord@0x2249140)\n" - " (declare (in ) float lod@0x2249250)\n" + " (declare (in ) sampler2DShadow sampler@0x1405db0)\n" + " (declare (in ) vec4 coord@0x1405ec0)\n" + " (declare (in ) float lod@0x1405fd0)\n" " )\n" " (\n" " ))\n" @@ -7002,28 +7002,28 @@ static const char *prototypes_for_120_vert = "(function noise1\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x2249610)\n" + " (declare (in ) float x@0x1406360)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x22499c0)\n" + " (declare (in ) vec2 x@0x14066e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x2249ba0)\n" + " (declare (in ) vec3 x@0x14068c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x2249d80)\n" + " (declare (in ) vec4 x@0x1406aa0)\n" " )\n" " (\n" " ))\n" @@ -7033,28 +7033,28 @@ static const char *prototypes_for_120_vert = "(function noise2\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float x@0x2249f60)\n" + " (declare (in ) float x@0x1406c80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x224a310)\n" + " (declare (in ) vec2 x@0x1407000)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec3 x@0x224a4f0)\n" + " (declare (in ) vec3 x@0x14071e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec4 x@0x224a6d0)\n" + " (declare (in ) vec4 x@0x14073c0)\n" " )\n" " (\n" " ))\n" @@ -7064,28 +7064,28 @@ static const char *prototypes_for_120_vert = "(function noise3\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float x@0x224a8b0)\n" + " (declare (in ) float x@0x14075a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec2 x@0x224ac60)\n" + " (declare (in ) vec2 x@0x1407920)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x224ae40)\n" + " (declare (in ) vec3 x@0x1407b00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec4 x@0x224b020)\n" + " (declare (in ) vec4 x@0x1407ce0)\n" " )\n" " (\n" " ))\n" @@ -7095,28 +7095,28 @@ static const char *prototypes_for_120_vert = "(function noise4\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float x@0x224b200)\n" + " (declare (in ) float x@0x1407ec0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec2 x@0x224b5b0)\n" + " (declare (in ) vec2 x@0x1408240)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec3 x@0x224b790)\n" + " (declare (in ) vec3 x@0x1408420)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x224b970)\n" + " (declare (in ) vec4 x@0x1408600)\n" " )\n" " (\n" " ))\n" @@ -7207,17 +7207,17 @@ static const char *prototypes_for_EXT_texture_array_frag = "(function texture1DArray\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArray sampler@0xb9bd60)\n" - " (declare (in ) vec2 coord@0xb9be80)\n" + " (declare (in ) sampler1DArray sampler@0xbe3bd0)\n" + " (declare (in ) vec2 coord@0xbe3ce0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArray sampler@0xb9c240)\n" - " (declare (in ) vec2 coord@0xb9c360)\n" - " (declare (in ) float bias@0xb9c470)\n" + " (declare (in ) sampler1DArray sampler@0xbe4070)\n" + " (declare (in ) vec2 coord@0xbe4180)\n" + " (declare (in ) float bias@0xbe4290)\n" " )\n" " (\n" " ))\n" @@ -7227,17 +7227,17 @@ static const char *prototypes_for_EXT_texture_array_frag = "(function texture2DArray\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArray sampler@0xb9c650)\n" - " (declare (in ) vec2 coord@0xb9c770)\n" + " (declare (in ) sampler1DArray sampler@0xbe4470)\n" + " (declare (in ) vec2 coord@0xbe4580)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArray sampler@0xb9cb30)\n" - " (declare (in ) vec2 coord@0xb9cc50)\n" - " (declare (in ) float bias@0xb9cd60)\n" + " (declare (in ) sampler1DArray sampler@0xbe4910)\n" + " (declare (in ) vec2 coord@0xbe4a20)\n" + " (declare (in ) float bias@0xbe4b30)\n" " )\n" " (\n" " ))\n" @@ -7247,17 +7247,17 @@ static const char *prototypes_for_EXT_texture_array_frag = "(function shadow1DArray\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArrayShadow sampler@0xb9cf40)\n" - " (declare (in ) vec3 coord@0xb9d060)\n" + " (declare (in ) sampler1DArrayShadow sampler@0xbe4d10)\n" + " (declare (in ) vec3 coord@0xbe4e20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArrayShadow sampler@0xb9d420)\n" - " (declare (in ) vec3 coord@0xb9d540)\n" - " (declare (in ) float bias@0xb9d650)\n" + " (declare (in ) sampler1DArrayShadow sampler@0xbe51b0)\n" + " (declare (in ) vec3 coord@0xbe52c0)\n" + " (declare (in ) float bias@0xbe53d0)\n" " )\n" " (\n" " ))\n" @@ -7267,8 +7267,8 @@ static const char *prototypes_for_EXT_texture_array_frag = "(function shadow2DArray\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DArrayShadow sampler@0xb9d830)\n" - " (declare (in ) vec4 coord@0xb9d950)\n" + " (declare (in ) sampler2DArrayShadow sampler@0xbe55b0)\n" + " (declare (in ) vec4 coord@0xbe56c0)\n" " )\n" " (\n" " ))\n" @@ -7289,28 +7289,28 @@ static const char *prototypes_for_110_vert = "(function radians\n" " (signature float\n" " (parameters\n" - " (declare (in ) float degrees@0x9e3c50)\n" + " (declare (in ) float degrees@0x1aa51c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 degrees@0x9e4020)\n" + " (declare (in ) vec2 degrees@0x1aa5540)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 degrees@0x9e4210)\n" + " (declare (in ) vec3 degrees@0x1aa5720)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 degrees@0x9e4400)\n" + " (declare (in ) vec4 degrees@0x1aa5900)\n" " )\n" " (\n" " ))\n" @@ -7320,28 +7320,28 @@ static const char *prototypes_for_110_vert = "(function degrees\n" " (signature float\n" " (parameters\n" - " (declare (in ) float radians@0x9e45f0)\n" + " (declare (in ) float radians@0x1aa5ae0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 radians@0x9e49c0)\n" + " (declare (in ) vec2 radians@0x1aa5e60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 radians@0x9e4bb0)\n" + " (declare (in ) vec3 radians@0x1aa6040)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 radians@0x9e4da0)\n" + " (declare (in ) vec4 radians@0x1aa6220)\n" " )\n" " (\n" " ))\n" @@ -7351,28 +7351,28 @@ static const char *prototypes_for_110_vert = "(function sin\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x9e4f90)\n" + " (declare (in ) float angle@0x1aa6400)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x9e5340)\n" + " (declare (in ) vec2 angle@0x1aa6780)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x9e5520)\n" + " (declare (in ) vec3 angle@0x1aa6960)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x9e5700)\n" + " (declare (in ) vec4 angle@0x1aa6b40)\n" " )\n" " (\n" " ))\n" @@ -7382,28 +7382,28 @@ static const char *prototypes_for_110_vert = "(function cos\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x9e58e0)\n" + " (declare (in ) float angle@0x1aa6d20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x9e5c90)\n" + " (declare (in ) vec2 angle@0x1aa70a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x9e5e70)\n" + " (declare (in ) vec3 angle@0x1aa7280)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x9e6050)\n" + " (declare (in ) vec4 angle@0x1aa7460)\n" " )\n" " (\n" " ))\n" @@ -7413,28 +7413,28 @@ static const char *prototypes_for_110_vert = "(function tan\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x9e6230)\n" + " (declare (in ) float angle@0x1aa7640)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x9e65e0)\n" + " (declare (in ) vec2 angle@0x1aa79c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x9e67c0)\n" + " (declare (in ) vec3 angle@0x1aa7ba0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x9e69a0)\n" + " (declare (in ) vec4 angle@0x1aa7d80)\n" " )\n" " (\n" " ))\n" @@ -7444,28 +7444,28 @@ static const char *prototypes_for_110_vert = "(function asin\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x9e6b80)\n" + " (declare (in ) float angle@0x1aa7f60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x9e6f30)\n" + " (declare (in ) vec2 angle@0x1aa82e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x9e7110)\n" + " (declare (in ) vec3 angle@0x1aa84c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x9e72f0)\n" + " (declare (in ) vec4 angle@0x1aa86a0)\n" " )\n" " (\n" " ))\n" @@ -7475,28 +7475,28 @@ static const char *prototypes_for_110_vert = "(function acos\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x9e74d0)\n" + " (declare (in ) float angle@0x1aa8880)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x9e7880)\n" + " (declare (in ) vec2 angle@0x1aa8c00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x9e7a60)\n" + " (declare (in ) vec3 angle@0x1aa8de0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x9e7c40)\n" + " (declare (in ) vec4 angle@0x1aa8fc0)\n" " )\n" " (\n" " ))\n" @@ -7506,60 +7506,60 @@ static const char *prototypes_for_110_vert = "(function atan\n" " (signature float\n" " (parameters\n" - " (declare (in ) float y@0x9e7e20)\n" - " (declare (in ) float x@0x9e7f30)\n" + " (declare (in ) float y@0x1aa91a0)\n" + " (declare (in ) float x@0x1aa92b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 y@0x9e82e0)\n" - " (declare (in ) vec2 x@0x9e83f0)\n" + " (declare (in ) vec2 y@0x1aa9630)\n" + " (declare (in ) vec2 x@0x1aa9740)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 y@0x9e85d0)\n" - " (declare (in ) vec3 x@0x9e86e0)\n" + " (declare (in ) vec3 y@0x1aa9920)\n" + " (declare (in ) vec3 x@0x1aa9a30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 y@0x9e88c0)\n" - " (declare (in ) vec4 x@0x9e89d0)\n" + " (declare (in ) vec4 y@0x1aa9c10)\n" + " (declare (in ) vec4 x@0x1aa9d20)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) float y_over_x@0x9e8bb0)\n" + " (declare (in ) float y_over_x@0x1aa9f00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 y_over_x@0x9e8da0)\n" + " (declare (in ) vec2 y_over_x@0x1aaa0f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 y_over_x@0x9e8f90)\n" + " (declare (in ) vec3 y_over_x@0x1aaa2e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 y_over_x@0x9e9180)\n" + " (declare (in ) vec4 y_over_x@0x1aaa4d0)\n" " )\n" " (\n" " ))\n" @@ -7569,32 +7569,32 @@ static const char *prototypes_for_110_vert = "(function pow\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9e9370)\n" - " (declare (in ) float y@0x9e9480)\n" + " (declare (in ) float x@0x1aaa6c0)\n" + " (declare (in ) float y@0x1aaa7d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9e9830)\n" - " (declare (in ) vec2 y@0x9e9940)\n" + " (declare (in ) vec2 x@0x1aaab50)\n" + " (declare (in ) vec2 y@0x1aaac60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9e9b20)\n" - " (declare (in ) vec3 y@0x9e9c30)\n" + " (declare (in ) vec3 x@0x1aaae40)\n" + " (declare (in ) vec3 y@0x1aaaf50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9e9e10)\n" - " (declare (in ) vec4 y@0x9e9f20)\n" + " (declare (in ) vec4 x@0x1aab130)\n" + " (declare (in ) vec4 y@0x1aab240)\n" " )\n" " (\n" " ))\n" @@ -7604,28 +7604,28 @@ static const char *prototypes_for_110_vert = "(function exp\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9ea100)\n" + " (declare (in ) float x@0x1aab420)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9ea4b0)\n" + " (declare (in ) vec2 x@0x1aab7a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9ea690)\n" + " (declare (in ) vec3 x@0x1aab980)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9ea870)\n" + " (declare (in ) vec4 x@0x1aabb60)\n" " )\n" " (\n" " ))\n" @@ -7635,28 +7635,28 @@ static const char *prototypes_for_110_vert = "(function log\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9eaa50)\n" + " (declare (in ) float x@0x1aabd40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9eae00)\n" + " (declare (in ) vec2 x@0x1aac0c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9eafe0)\n" + " (declare (in ) vec3 x@0x1aac2a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9eb1c0)\n" + " (declare (in ) vec4 x@0x1aac480)\n" " )\n" " (\n" " ))\n" @@ -7666,28 +7666,28 @@ static const char *prototypes_for_110_vert = "(function exp2\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9eb3a0)\n" + " (declare (in ) float x@0x1aac660)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9eb750)\n" + " (declare (in ) vec2 x@0x1aac9e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9eb930)\n" + " (declare (in ) vec3 x@0x1aacbc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9ebb10)\n" + " (declare (in ) vec4 x@0x1aacda0)\n" " )\n" " (\n" " ))\n" @@ -7697,28 +7697,28 @@ static const char *prototypes_for_110_vert = "(function log2\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9ebcf0)\n" + " (declare (in ) float x@0x1aacf80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9ec0a0)\n" + " (declare (in ) vec2 x@0x1aad300)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9ec280)\n" + " (declare (in ) vec3 x@0x1aad4e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9ec460)\n" + " (declare (in ) vec4 x@0x1aad6c0)\n" " )\n" " (\n" " ))\n" @@ -7728,28 +7728,28 @@ static const char *prototypes_for_110_vert = "(function sqrt\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9ec640)\n" + " (declare (in ) float x@0x1aad8a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9ec9f0)\n" + " (declare (in ) vec2 x@0x1aadc20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9ecbd0)\n" + " (declare (in ) vec3 x@0x1aade00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9ecdb0)\n" + " (declare (in ) vec4 x@0x1aadfe0)\n" " )\n" " (\n" " ))\n" @@ -7759,28 +7759,28 @@ static const char *prototypes_for_110_vert = "(function inversesqrt\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9ecf90)\n" + " (declare (in ) float x@0x1aae1c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9ed350)\n" + " (declare (in ) vec2 x@0x1aae550)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9ed530)\n" + " (declare (in ) vec3 x@0x1aae730)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9ed710)\n" + " (declare (in ) vec4 x@0x1aae910)\n" " )\n" " (\n" " ))\n" @@ -7790,28 +7790,28 @@ static const char *prototypes_for_110_vert = "(function abs\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9ed8f0)\n" + " (declare (in ) float x@0x1aaeaf0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9edca0)\n" + " (declare (in ) vec2 x@0x1aaee70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9ede80)\n" + " (declare (in ) vec3 x@0x1aaf050)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9ee060)\n" + " (declare (in ) vec4 x@0x1aaf230)\n" " )\n" " (\n" " ))\n" @@ -7821,28 +7821,28 @@ static const char *prototypes_for_110_vert = "(function sign\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9ee240)\n" + " (declare (in ) float x@0x1aaf410)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9ee5f0)\n" + " (declare (in ) vec2 x@0x1aaf790)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9ee7d0)\n" + " (declare (in ) vec3 x@0x1aaf970)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9ee9b0)\n" + " (declare (in ) vec4 x@0x1aafb50)\n" " )\n" " (\n" " ))\n" @@ -7852,28 +7852,28 @@ static const char *prototypes_for_110_vert = "(function floor\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9eeb90)\n" + " (declare (in ) float x@0x1aafd30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9eef40)\n" + " (declare (in ) vec2 x@0x1ab00b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9ef120)\n" + " (declare (in ) vec3 x@0x1ab0290)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9ef300)\n" + " (declare (in ) vec4 x@0x1ab0470)\n" " )\n" " (\n" " ))\n" @@ -7883,28 +7883,28 @@ static const char *prototypes_for_110_vert = "(function ceil\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9ef4e0)\n" + " (declare (in ) float x@0x1ab0650)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9ef890)\n" + " (declare (in ) vec2 x@0x1ab09d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9efa70)\n" + " (declare (in ) vec3 x@0x1ab0bb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9efc50)\n" + " (declare (in ) vec4 x@0x1ab0d90)\n" " )\n" " (\n" " ))\n" @@ -7914,28 +7914,28 @@ static const char *prototypes_for_110_vert = "(function fract\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9efe30)\n" + " (declare (in ) float x@0x1ab0f70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f01e0)\n" + " (declare (in ) vec2 x@0x1ab12f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f03c0)\n" + " (declare (in ) vec3 x@0x1ab14d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f05a0)\n" + " (declare (in ) vec4 x@0x1ab16b0)\n" " )\n" " (\n" " ))\n" @@ -7945,56 +7945,56 @@ static const char *prototypes_for_110_vert = "(function mod\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9f0780)\n" - " (declare (in ) float y@0x9f0890)\n" + " (declare (in ) float x@0x1ab1890)\n" + " (declare (in ) float y@0x1ab19a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f0c40)\n" - " (declare (in ) float y@0x9f0d50)\n" + " (declare (in ) vec2 x@0x1ab1d20)\n" + " (declare (in ) float y@0x1ab1e30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f0f30)\n" - " (declare (in ) float y@0x9f1040)\n" + " (declare (in ) vec3 x@0x1ab2010)\n" + " (declare (in ) float y@0x1ab2120)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f1220)\n" - " (declare (in ) float y@0x9f1330)\n" + " (declare (in ) vec4 x@0x1ab2300)\n" + " (declare (in ) float y@0x1ab2410)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f1510)\n" - " (declare (in ) vec2 y@0x9f1620)\n" + " (declare (in ) vec2 x@0x1ab25f0)\n" + " (declare (in ) vec2 y@0x1ab2700)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f1800)\n" - " (declare (in ) vec3 y@0x9f1910)\n" + " (declare (in ) vec3 x@0x1ab28e0)\n" + " (declare (in ) vec3 y@0x1ab29f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f1af0)\n" - " (declare (in ) vec4 y@0x9f1c00)\n" + " (declare (in ) vec4 x@0x1ab2bd0)\n" + " (declare (in ) vec4 y@0x1ab2ce0)\n" " )\n" " (\n" " ))\n" @@ -8004,56 +8004,56 @@ static const char *prototypes_for_110_vert = "(function min\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9f1de0)\n" - " (declare (in ) float y@0x9f1ef0)\n" + " (declare (in ) float x@0x1ab2ec0)\n" + " (declare (in ) float y@0x1ab2fd0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f22a0)\n" - " (declare (in ) vec2 y@0x9f23b0)\n" + " (declare (in ) vec2 x@0x1ab3350)\n" + " (declare (in ) vec2 y@0x1ab3460)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f2590)\n" - " (declare (in ) vec3 y@0x9f26a0)\n" + " (declare (in ) vec3 x@0x1ab3640)\n" + " (declare (in ) vec3 y@0x1ab3750)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f2880)\n" - " (declare (in ) vec4 y@0x9f2990)\n" + " (declare (in ) vec4 x@0x1ab3930)\n" + " (declare (in ) vec4 y@0x1ab3a40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f2b70)\n" - " (declare (in ) float y@0x9f2c80)\n" + " (declare (in ) vec2 x@0x1ab3c20)\n" + " (declare (in ) float y@0x1ab3d30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f2e60)\n" - " (declare (in ) float y@0x9f2f70)\n" + " (declare (in ) vec3 x@0x1ab3f10)\n" + " (declare (in ) float y@0x1ab4020)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f3150)\n" - " (declare (in ) float y@0x9f3260)\n" + " (declare (in ) vec4 x@0x1ab4200)\n" + " (declare (in ) float y@0x1ab4310)\n" " )\n" " (\n" " ))\n" @@ -8063,56 +8063,56 @@ static const char *prototypes_for_110_vert = "(function max\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9f3440)\n" - " (declare (in ) float y@0x9f3550)\n" + " (declare (in ) float x@0x1ab44f0)\n" + " (declare (in ) float y@0x1ab4600)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f3900)\n" - " (declare (in ) vec2 y@0x9f3a10)\n" + " (declare (in ) vec2 x@0x1ab4980)\n" + " (declare (in ) vec2 y@0x1ab4a90)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f3bf0)\n" - " (declare (in ) vec3 y@0x9f3d00)\n" + " (declare (in ) vec3 x@0x1ab4c70)\n" + " (declare (in ) vec3 y@0x1ab4d80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f3ee0)\n" - " (declare (in ) vec4 y@0x9f3ff0)\n" + " (declare (in ) vec4 x@0x1ab4f60)\n" + " (declare (in ) vec4 y@0x1ab5070)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f41d0)\n" - " (declare (in ) float y@0x9f42e0)\n" + " (declare (in ) vec2 x@0x1ab5250)\n" + " (declare (in ) float y@0x1ab5360)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f44c0)\n" - " (declare (in ) float y@0x9f45d0)\n" + " (declare (in ) vec3 x@0x1ab5540)\n" + " (declare (in ) float y@0x1ab5650)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f47b0)\n" - " (declare (in ) float y@0x9f48c0)\n" + " (declare (in ) vec4 x@0x1ab5830)\n" + " (declare (in ) float y@0x1ab5940)\n" " )\n" " (\n" " ))\n" @@ -8122,63 +8122,63 @@ static const char *prototypes_for_110_vert = "(function clamp\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9f4aa0)\n" - " (declare (in ) float minVal@0x9f4bb0)\n" - " (declare (in ) float maxVal@0x9f4cc0)\n" + " (declare (in ) float x@0x1ab5b20)\n" + " (declare (in ) float minVal@0x1ab5c30)\n" + " (declare (in ) float maxVal@0x1ab5d40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f5070)\n" - " (declare (in ) vec2 minVal@0x9f5180)\n" - " (declare (in ) vec2 maxVal@0x9f5290)\n" + " (declare (in ) vec2 x@0x1ab60c0)\n" + " (declare (in ) vec2 minVal@0x1ab61d0)\n" + " (declare (in ) vec2 maxVal@0x1ab62e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f5470)\n" - " (declare (in ) vec3 minVal@0x9f5580)\n" - " (declare (in ) vec3 maxVal@0x9f5690)\n" + " (declare (in ) vec3 x@0x1ab64c0)\n" + " (declare (in ) vec3 minVal@0x1ab65d0)\n" + " (declare (in ) vec3 maxVal@0x1ab66e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f5870)\n" - " (declare (in ) vec4 minVal@0x9f5980)\n" - " (declare (in ) vec4 maxVal@0x9f5a90)\n" + " (declare (in ) vec4 x@0x1ab68c0)\n" + " (declare (in ) vec4 minVal@0x1ab69d0)\n" + " (declare (in ) vec4 maxVal@0x1ab6ae0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f5c70)\n" - " (declare (in ) float minVal@0x9f5d80)\n" - " (declare (in ) float maxVal@0x9f5e90)\n" + " (declare (in ) vec2 x@0x1ab6cc0)\n" + " (declare (in ) float minVal@0x1ab6dd0)\n" + " (declare (in ) float maxVal@0x1ab6ee0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f6070)\n" - " (declare (in ) float minVal@0x9f6180)\n" - " (declare (in ) float maxVal@0x9f6290)\n" + " (declare (in ) vec3 x@0x1ab70c0)\n" + " (declare (in ) float minVal@0x1ab71d0)\n" + " (declare (in ) float maxVal@0x1ab72e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f6470)\n" - " (declare (in ) float minVal@0x9f6580)\n" - " (declare (in ) float maxVal@0x9f6690)\n" + " (declare (in ) vec4 x@0x1ab74c0)\n" + " (declare (in ) float minVal@0x1ab75d0)\n" + " (declare (in ) float maxVal@0x1ab76e0)\n" " )\n" " (\n" " ))\n" @@ -8188,63 +8188,63 @@ static const char *prototypes_for_110_vert = "(function mix\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9f6870)\n" - " (declare (in ) float y@0x9f6980)\n" - " (declare (in ) float a@0x9f6a90)\n" + " (declare (in ) float x@0x1ab78c0)\n" + " (declare (in ) float y@0x1ab79d0)\n" + " (declare (in ) float a@0x1ab7ae0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f6e40)\n" - " (declare (in ) vec2 y@0x9f6f50)\n" - " (declare (in ) vec2 a@0x9f7060)\n" + " (declare (in ) vec2 x@0x1ab7e60)\n" + " (declare (in ) vec2 y@0x1ab7f70)\n" + " (declare (in ) vec2 a@0x1ab8080)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f7240)\n" - " (declare (in ) vec3 y@0x9f7350)\n" - " (declare (in ) vec3 a@0x9f7460)\n" + " (declare (in ) vec3 x@0x1ab8260)\n" + " (declare (in ) vec3 y@0x1ab8370)\n" + " (declare (in ) vec3 a@0x1ab8480)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f7640)\n" - " (declare (in ) vec4 y@0x9f7750)\n" - " (declare (in ) vec4 a@0x9f7860)\n" + " (declare (in ) vec4 x@0x1ab8660)\n" + " (declare (in ) vec4 y@0x1ab8770)\n" + " (declare (in ) vec4 a@0x1ab8880)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9f7a40)\n" - " (declare (in ) vec2 y@0x9f7b50)\n" - " (declare (in ) float a@0x9f7c60)\n" + " (declare (in ) vec2 x@0x1ab8a60)\n" + " (declare (in ) vec2 y@0x1ab8b70)\n" + " (declare (in ) float a@0x1ab8c80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9f7e40)\n" - " (declare (in ) vec3 y@0x9f7f50)\n" - " (declare (in ) float a@0x9f8060)\n" + " (declare (in ) vec3 x@0x1ab8e60)\n" + " (declare (in ) vec3 y@0x1ab8f70)\n" + " (declare (in ) float a@0x1ab9080)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9f8240)\n" - " (declare (in ) vec4 y@0x9f8350)\n" - " (declare (in ) float a@0x9f8460)\n" + " (declare (in ) vec4 x@0x1ab9260)\n" + " (declare (in ) vec4 y@0x1ab9370)\n" + " (declare (in ) float a@0x1ab9480)\n" " )\n" " (\n" " ))\n" @@ -8254,56 +8254,56 @@ static const char *prototypes_for_110_vert = "(function step\n" " (signature float\n" " (parameters\n" - " (declare (in ) float edge@0x9f8640)\n" - " (declare (in ) float x@0x9f8750)\n" + " (declare (in ) float edge@0x1ab9660)\n" + " (declare (in ) float x@0x1ab9770)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 edge@0x9f8b00)\n" - " (declare (in ) vec2 x@0x9f8c10)\n" + " (declare (in ) vec2 edge@0x1ab9af0)\n" + " (declare (in ) vec2 x@0x1ab9c00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 edge@0x9f8df0)\n" - " (declare (in ) vec3 x@0x9f8f00)\n" + " (declare (in ) vec3 edge@0x1ab9de0)\n" + " (declare (in ) vec3 x@0x1ab9ef0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 edge@0x9f90e0)\n" - " (declare (in ) vec4 x@0x9f91f0)\n" + " (declare (in ) vec4 edge@0x1aba0d0)\n" + " (declare (in ) vec4 x@0x1aba1e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float edge@0x9f93d0)\n" - " (declare (in ) vec2 x@0x9f94e0)\n" + " (declare (in ) float edge@0x1aba3c0)\n" + " (declare (in ) vec2 x@0x1aba4d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float edge@0x9f96c0)\n" - " (declare (in ) vec3 x@0x9f97d0)\n" + " (declare (in ) float edge@0x1aba6b0)\n" + " (declare (in ) vec3 x@0x1aba7c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float edge@0x9f99b0)\n" - " (declare (in ) vec4 x@0x9f9ac0)\n" + " (declare (in ) float edge@0x1aba9a0)\n" + " (declare (in ) vec4 x@0x1abaab0)\n" " )\n" " (\n" " ))\n" @@ -8313,63 +8313,63 @@ static const char *prototypes_for_110_vert = "(function smoothstep\n" " (signature float\n" " (parameters\n" - " (declare (in ) float edge0@0x9f9ca0)\n" - " (declare (in ) float edge1@0x9f9db0)\n" - " (declare (in ) float x@0x9f9ec0)\n" + " (declare (in ) float edge0@0x1abac90)\n" + " (declare (in ) float edge1@0x1abada0)\n" + " (declare (in ) float x@0x1abaeb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 edge0@0x9fa280)\n" - " (declare (in ) vec2 edge1@0x9fa390)\n" - " (declare (in ) vec2 x@0x9fa4a0)\n" + " (declare (in ) vec2 edge0@0x1abb240)\n" + " (declare (in ) vec2 edge1@0x1abb350)\n" + " (declare (in ) vec2 x@0x1abb460)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 edge0@0x9fa680)\n" - " (declare (in ) vec3 edge1@0x9fa790)\n" - " (declare (in ) vec3 x@0x9fa8a0)\n" + " (declare (in ) vec3 edge0@0x1abb640)\n" + " (declare (in ) vec3 edge1@0x1abb750)\n" + " (declare (in ) vec3 x@0x1abb860)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 edge0@0x9faa80)\n" - " (declare (in ) vec4 edge1@0x9fab90)\n" - " (declare (in ) vec4 x@0x9faca0)\n" + " (declare (in ) vec4 edge0@0x1abba40)\n" + " (declare (in ) vec4 edge1@0x1abbb50)\n" + " (declare (in ) vec4 x@0x1abbc60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float edge0@0x9fae80)\n" - " (declare (in ) float edge1@0x9faf90)\n" - " (declare (in ) vec2 x@0x9fb0a0)\n" + " (declare (in ) float edge0@0x1abbe40)\n" + " (declare (in ) float edge1@0x1abbf50)\n" + " (declare (in ) vec2 x@0x1abc060)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float edge0@0x9fb280)\n" - " (declare (in ) float edge1@0x9fb390)\n" - " (declare (in ) vec3 x@0x9fb4a0)\n" + " (declare (in ) float edge0@0x1abc240)\n" + " (declare (in ) float edge1@0x1abc350)\n" + " (declare (in ) vec3 x@0x1abc460)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float edge0@0x9fb680)\n" - " (declare (in ) float edge1@0x9fb790)\n" - " (declare (in ) vec4 x@0x9fb8a0)\n" + " (declare (in ) float edge0@0x1abc640)\n" + " (declare (in ) float edge1@0x1abc750)\n" + " (declare (in ) vec4 x@0x1abc860)\n" " )\n" " (\n" " ))\n" @@ -8379,28 +8379,28 @@ static const char *prototypes_for_110_vert = "(function length\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9fba80)\n" + " (declare (in ) float x@0x1abca40)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x9fbe30)\n" + " (declare (in ) vec2 x@0x1abcdc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x9fc010)\n" + " (declare (in ) vec3 x@0x1abcfa0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x9fc1f0)\n" + " (declare (in ) vec4 x@0x1abd180)\n" " )\n" " (\n" " ))\n" @@ -8410,32 +8410,32 @@ static const char *prototypes_for_110_vert = "(function distance\n" " (signature float\n" " (parameters\n" - " (declare (in ) float p0@0x9fc3d0)\n" - " (declare (in ) float p1@0x9fc4e0)\n" + " (declare (in ) float p0@0x1abd360)\n" + " (declare (in ) float p1@0x1abd470)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 p0@0x9fc8a0)\n" - " (declare (in ) vec2 p1@0x9fc9b0)\n" + " (declare (in ) vec2 p0@0x1abd800)\n" + " (declare (in ) vec2 p1@0x1abd910)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 p0@0x9fcb90)\n" - " (declare (in ) vec3 p1@0x9fcca0)\n" + " (declare (in ) vec3 p0@0x1abdaf0)\n" + " (declare (in ) vec3 p1@0x1abdc00)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 p0@0x9fce80)\n" - " (declare (in ) vec4 p1@0x9fcf90)\n" + " (declare (in ) vec4 p0@0x1abdde0)\n" + " (declare (in ) vec4 p1@0x1abdef0)\n" " )\n" " (\n" " ))\n" @@ -8445,32 +8445,32 @@ static const char *prototypes_for_110_vert = "(function dot\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9fd170)\n" - " (declare (in ) float y@0x9fd280)\n" + " (declare (in ) float x@0x1abe0d0)\n" + " (declare (in ) float y@0x1abe1e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x9fd630)\n" - " (declare (in ) vec2 y@0x9fd740)\n" + " (declare (in ) vec2 x@0x1abe560)\n" + " (declare (in ) vec2 y@0x1abe670)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x9fd920)\n" - " (declare (in ) vec3 y@0x9fda30)\n" + " (declare (in ) vec3 x@0x1abe850)\n" + " (declare (in ) vec3 y@0x1abe960)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x9fdc10)\n" - " (declare (in ) vec4 y@0x9fdd20)\n" + " (declare (in ) vec4 x@0x1abeb40)\n" + " (declare (in ) vec4 y@0x1abec50)\n" " )\n" " (\n" " ))\n" @@ -8480,8 +8480,8 @@ static const char *prototypes_for_110_vert = "(function cross\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9fdf00)\n" - " (declare (in ) vec3 y@0x9fe010)\n" + " (declare (in ) vec3 x@0x1abee30)\n" + " (declare (in ) vec3 y@0x1abef40)\n" " )\n" " (\n" " ))\n" @@ -8491,28 +8491,28 @@ static const char *prototypes_for_110_vert = "(function normalize\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x9fe3c0)\n" + " (declare (in ) float x@0x1abf2c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x9fe780)\n" + " (declare (in ) vec2 x@0x1abf650)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x9fe960)\n" + " (declare (in ) vec3 x@0x1abf830)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x9feb40)\n" + " (declare (in ) vec4 x@0x1abfa10)\n" " )\n" " (\n" " ))\n" @@ -8531,36 +8531,36 @@ static const char *prototypes_for_110_vert = "(function faceforward\n" " (signature float\n" " (parameters\n" - " (declare (in ) float N@0x9fefd0)\n" - " (declare (in ) float I@0x9ff0e0)\n" - " (declare (in ) float Nref@0x9ff1f0)\n" + " (declare (in ) float N@0x1abfe70)\n" + " (declare (in ) float I@0x1abff80)\n" + " (declare (in ) float Nref@0x1ac0090)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 N@0x9ff5b0)\n" - " (declare (in ) vec2 I@0x9ff6c0)\n" - " (declare (in ) vec2 Nref@0x9ff7d0)\n" + " (declare (in ) vec2 N@0x1ac0420)\n" + " (declare (in ) vec2 I@0x1ac0530)\n" + " (declare (in ) vec2 Nref@0x1ac0640)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 N@0x9ff9b0)\n" - " (declare (in ) vec3 I@0x9ffac0)\n" - " (declare (in ) vec3 Nref@0x9ffbd0)\n" + " (declare (in ) vec3 N@0x1ac0820)\n" + " (declare (in ) vec3 I@0x1ac0930)\n" + " (declare (in ) vec3 Nref@0x1ac0a40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 N@0x9ffdb0)\n" - " (declare (in ) vec4 I@0x9ffec0)\n" - " (declare (in ) vec4 Nref@0x9fffd0)\n" + " (declare (in ) vec4 N@0x1ac0c20)\n" + " (declare (in ) vec4 I@0x1ac0d30)\n" + " (declare (in ) vec4 Nref@0x1ac0e40)\n" " )\n" " (\n" " ))\n" @@ -8570,32 +8570,32 @@ static const char *prototypes_for_110_vert = "(function reflect\n" " (signature float\n" " (parameters\n" - " (declare (in ) float I@0xa001b0)\n" - " (declare (in ) float N@0xa002c0)\n" + " (declare (in ) float I@0x1ac1020)\n" + " (declare (in ) float N@0x1ac1130)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 I@0xa00680)\n" - " (declare (in ) vec2 N@0xa00790)\n" + " (declare (in ) vec2 I@0x1ac14b0)\n" + " (declare (in ) vec2 N@0x1ac15c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 I@0xa00970)\n" - " (declare (in ) vec3 N@0xa00a80)\n" + " (declare (in ) vec3 I@0x1ac17a0)\n" + " (declare (in ) vec3 N@0x1ac18b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 I@0xa00c60)\n" - " (declare (in ) vec4 N@0xa00d70)\n" + " (declare (in ) vec4 I@0x1ac1a90)\n" + " (declare (in ) vec4 N@0x1ac1ba0)\n" " )\n" " (\n" " ))\n" @@ -8605,36 +8605,36 @@ static const char *prototypes_for_110_vert = "(function refract\n" " (signature float\n" " (parameters\n" - " (declare (in ) float I@0xa00f50)\n" - " (declare (in ) float N@0xa01060)\n" - " (declare (in ) float eta@0xa01170)\n" + " (declare (in ) float I@0x1ac1d80)\n" + " (declare (in ) float N@0x1ac1e90)\n" + " (declare (in ) float eta@0x1ac1fa0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 I@0xa01530)\n" - " (declare (in ) vec2 N@0xa01640)\n" - " (declare (in ) float eta@0xa01750)\n" + " (declare (in ) vec2 I@0x1ac2320)\n" + " (declare (in ) vec2 N@0x1ac2430)\n" + " (declare (in ) float eta@0x1ac2540)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 I@0xa01930)\n" - " (declare (in ) vec3 N@0xa01a40)\n" - " (declare (in ) float eta@0xa01b50)\n" + " (declare (in ) vec3 I@0x1ac2720)\n" + " (declare (in ) vec3 N@0x1ac2830)\n" + " (declare (in ) float eta@0x1ac2940)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 I@0xa01d30)\n" - " (declare (in ) vec4 N@0xa01e40)\n" - " (declare (in ) float eta@0xa01f50)\n" + " (declare (in ) vec4 I@0x1ac2b20)\n" + " (declare (in ) vec4 N@0x1ac2c30)\n" + " (declare (in ) float eta@0x1ac2d40)\n" " )\n" " (\n" " ))\n" @@ -8644,24 +8644,24 @@ static const char *prototypes_for_110_vert = "(function matrixCompMult\n" " (signature mat2\n" " (parameters\n" - " (declare (in ) mat2 x@0xa02130)\n" - " (declare (in ) mat2 y@0xa02240)\n" + " (declare (in ) mat2 x@0x1ac2f20)\n" + " (declare (in ) mat2 y@0x1ac3030)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3\n" " (parameters\n" - " (declare (in ) mat3 x@0xa02600)\n" - " (declare (in ) mat3 y@0xa02710)\n" + " (declare (in ) mat3 x@0x1ac33c0)\n" + " (declare (in ) mat3 y@0x1ac34d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4\n" " (parameters\n" - " (declare (in ) mat4 x@0xa028f0)\n" - " (declare (in ) mat4 y@0xa02a00)\n" + " (declare (in ) mat4 x@0x1ac36b0)\n" + " (declare (in ) mat4 y@0x1ac37c0)\n" " )\n" " (\n" " ))\n" @@ -8671,48 +8671,48 @@ static const char *prototypes_for_110_vert = "(function lessThan\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0xa02be0)\n" - " (declare (in ) vec2 y@0xa02cf0)\n" + " (declare (in ) vec2 x@0x1ac39a0)\n" + " (declare (in ) vec2 y@0x1ac3ab0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0xa030b0)\n" - " (declare (in ) vec3 y@0xa031c0)\n" + " (declare (in ) vec3 x@0x1ac3e40)\n" + " (declare (in ) vec3 y@0x1ac3f50)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0xa033a0)\n" - " (declare (in ) vec4 y@0xa034b0)\n" + " (declare (in ) vec4 x@0x1ac4130)\n" + " (declare (in ) vec4 y@0x1ac4240)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0xa03690)\n" - " (declare (in ) ivec2 y@0xa037a0)\n" + " (declare (in ) ivec2 x@0x1ac4420)\n" + " (declare (in ) ivec2 y@0x1ac4530)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0xa03980)\n" - " (declare (in ) ivec3 y@0xa03a90)\n" + " (declare (in ) ivec3 x@0x1ac4710)\n" + " (declare (in ) ivec3 y@0x1ac4820)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0xa03c70)\n" - " (declare (in ) ivec4 y@0xa03d80)\n" + " (declare (in ) ivec4 x@0x1ac4a00)\n" + " (declare (in ) ivec4 y@0x1ac4b10)\n" " )\n" " (\n" " ))\n" @@ -8722,48 +8722,48 @@ static const char *prototypes_for_110_vert = "(function lessThanEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0xa03f60)\n" - " (declare (in ) vec2 y@0xa04070)\n" + " (declare (in ) vec2 x@0x1ac4cf0)\n" + " (declare (in ) vec2 y@0x1ac4e00)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0xa04430)\n" - " (declare (in ) vec3 y@0xa04540)\n" + " (declare (in ) vec3 x@0x1ac5190)\n" + " (declare (in ) vec3 y@0x1ac52a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0xa04720)\n" - " (declare (in ) vec4 y@0xa04830)\n" + " (declare (in ) vec4 x@0x1ac5480)\n" + " (declare (in ) vec4 y@0x1ac5590)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0xa04a10)\n" - " (declare (in ) ivec2 y@0xa04b20)\n" + " (declare (in ) ivec2 x@0x1ac5770)\n" + " (declare (in ) ivec2 y@0x1ac5880)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0xa04d00)\n" - " (declare (in ) ivec3 y@0xa04e10)\n" + " (declare (in ) ivec3 x@0x1ac5a60)\n" + " (declare (in ) ivec3 y@0x1ac5b70)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0xa04ff0)\n" - " (declare (in ) ivec4 y@0xa05100)\n" + " (declare (in ) ivec4 x@0x1ac5d50)\n" + " (declare (in ) ivec4 y@0x1ac5e60)\n" " )\n" " (\n" " ))\n" @@ -8773,48 +8773,48 @@ static const char *prototypes_for_110_vert = "(function greaterThan\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0xa052e0)\n" - " (declare (in ) vec2 y@0xa053f0)\n" + " (declare (in ) vec2 x@0x1ac6040)\n" + " (declare (in ) vec2 y@0x1ac6150)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0xa057b0)\n" - " (declare (in ) vec3 y@0xa058c0)\n" + " (declare (in ) vec3 x@0x1ac64e0)\n" + " (declare (in ) vec3 y@0x1ac65f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0xa05aa0)\n" - " (declare (in ) vec4 y@0xa05bb0)\n" + " (declare (in ) vec4 x@0x1ac67d0)\n" + " (declare (in ) vec4 y@0x1ac68e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0xa05d90)\n" - " (declare (in ) ivec2 y@0xa05ea0)\n" + " (declare (in ) ivec2 x@0x1ac6ac0)\n" + " (declare (in ) ivec2 y@0x1ac6bd0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0xa06080)\n" - " (declare (in ) ivec3 y@0xa06190)\n" + " (declare (in ) ivec3 x@0x1ac6db0)\n" + " (declare (in ) ivec3 y@0x1ac6ec0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0xa06370)\n" - " (declare (in ) ivec4 y@0xa06480)\n" + " (declare (in ) ivec4 x@0x1ac70a0)\n" + " (declare (in ) ivec4 y@0x1ac71b0)\n" " )\n" " (\n" " ))\n" @@ -8824,48 +8824,48 @@ static const char *prototypes_for_110_vert = "(function greaterThanEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0xa06660)\n" - " (declare (in ) vec2 y@0xa06770)\n" + " (declare (in ) vec2 x@0x1ac7390)\n" + " (declare (in ) vec2 y@0x1ac74a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0xa06b30)\n" - " (declare (in ) vec3 y@0xa06c40)\n" + " (declare (in ) vec3 x@0x1ac7830)\n" + " (declare (in ) vec3 y@0x1ac7940)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0xa06e20)\n" - " (declare (in ) vec4 y@0xa06f30)\n" + " (declare (in ) vec4 x@0x1ac7b20)\n" + " (declare (in ) vec4 y@0x1ac7c30)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0xa07110)\n" - " (declare (in ) ivec2 y@0xa07220)\n" + " (declare (in ) ivec2 x@0x1ac7e10)\n" + " (declare (in ) ivec2 y@0x1ac7f20)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0xa07400)\n" - " (declare (in ) ivec3 y@0xa07510)\n" + " (declare (in ) ivec3 x@0x1ac8100)\n" + " (declare (in ) ivec3 y@0x1ac8210)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0xa076f0)\n" - " (declare (in ) ivec4 y@0xa07800)\n" + " (declare (in ) ivec4 x@0x1ac83f0)\n" + " (declare (in ) ivec4 y@0x1ac8500)\n" " )\n" " (\n" " ))\n" @@ -8875,72 +8875,72 @@ static const char *prototypes_for_110_vert = "(function equal\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0xa079e0)\n" - " (declare (in ) vec2 y@0xa07af0)\n" + " (declare (in ) vec2 x@0x1ac86e0)\n" + " (declare (in ) vec2 y@0x1ac87f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0xa07ea0)\n" - " (declare (in ) vec3 y@0xa07fb0)\n" + " (declare (in ) vec3 x@0x1ac8b70)\n" + " (declare (in ) vec3 y@0x1ac8c80)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0xa08190)\n" - " (declare (in ) vec4 y@0xa082a0)\n" + " (declare (in ) vec4 x@0x1ac8e60)\n" + " (declare (in ) vec4 y@0x1ac8f70)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0xa08480)\n" - " (declare (in ) ivec2 y@0xa08590)\n" + " (declare (in ) ivec2 x@0x1ac9150)\n" + " (declare (in ) ivec2 y@0x1ac9260)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0xa08770)\n" - " (declare (in ) ivec3 y@0xa08880)\n" + " (declare (in ) ivec3 x@0x1ac9440)\n" + " (declare (in ) ivec3 y@0x1ac9550)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0xa08a60)\n" - " (declare (in ) ivec4 y@0xa08b70)\n" + " (declare (in ) ivec4 x@0x1ac9730)\n" + " (declare (in ) ivec4 y@0x1ac9840)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0xa08d50)\n" - " (declare (in ) bvec2 y@0xa08e60)\n" + " (declare (in ) bvec2 x@0x1ac9a20)\n" + " (declare (in ) bvec2 y@0x1ac9b30)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0xa09040)\n" - " (declare (in ) bvec3 y@0xa09150)\n" + " (declare (in ) bvec3 x@0x1ac9d10)\n" + " (declare (in ) bvec3 y@0x1ac9e20)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0xa09330)\n" - " (declare (in ) bvec4 y@0xa09440)\n" + " (declare (in ) bvec4 x@0x1aca000)\n" + " (declare (in ) bvec4 y@0x1aca110)\n" " )\n" " (\n" " ))\n" @@ -8950,72 +8950,72 @@ static const char *prototypes_for_110_vert = "(function notEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0xa09620)\n" - " (declare (in ) vec2 y@0xa09730)\n" + " (declare (in ) vec2 x@0x1aca2f0)\n" + " (declare (in ) vec2 y@0x1aca400)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0xa09af0)\n" - " (declare (in ) vec3 y@0xa09c00)\n" + " (declare (in ) vec3 x@0x1aca790)\n" + " (declare (in ) vec3 y@0x1aca8a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0xa09de0)\n" - " (declare (in ) vec4 y@0xa09ef0)\n" + " (declare (in ) vec4 x@0x1acaa80)\n" + " (declare (in ) vec4 y@0x1acab90)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0xa0a0d0)\n" - " (declare (in ) ivec2 y@0xa0a1e0)\n" + " (declare (in ) ivec2 x@0x1acad70)\n" + " (declare (in ) ivec2 y@0x1acae80)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0xa0a3c0)\n" - " (declare (in ) ivec3 y@0xa0a4d0)\n" + " (declare (in ) ivec3 x@0x1acb060)\n" + " (declare (in ) ivec3 y@0x1acb170)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0xa0a6b0)\n" - " (declare (in ) ivec4 y@0xa0a7c0)\n" + " (declare (in ) ivec4 x@0x1acb350)\n" + " (declare (in ) ivec4 y@0x1acb460)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0xa0a9a0)\n" - " (declare (in ) bvec2 y@0xa0aab0)\n" + " (declare (in ) bvec2 x@0x1acb640)\n" + " (declare (in ) bvec2 y@0x1acb750)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0xa0ac90)\n" - " (declare (in ) bvec3 y@0xa0ada0)\n" + " (declare (in ) bvec3 x@0x1acb930)\n" + " (declare (in ) bvec3 y@0x1acba40)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0xa0af80)\n" - " (declare (in ) bvec4 y@0xa0b090)\n" + " (declare (in ) bvec4 x@0x1acbc20)\n" + " (declare (in ) bvec4 y@0x1acbd30)\n" " )\n" " (\n" " ))\n" @@ -9025,21 +9025,21 @@ static const char *prototypes_for_110_vert = "(function any\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec2 x@0xa0b270)\n" + " (declare (in ) bvec2 x@0x1acbf10)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec3 x@0xa0b620)\n" + " (declare (in ) bvec3 x@0x1acc290)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec4 x@0xa0b800)\n" + " (declare (in ) bvec4 x@0x1acc470)\n" " )\n" " (\n" " ))\n" @@ -9049,21 +9049,21 @@ static const char *prototypes_for_110_vert = "(function all\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec2 x@0xa0b9e0)\n" + " (declare (in ) bvec2 x@0x1acc650)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec3 x@0xa0bd90)\n" + " (declare (in ) bvec3 x@0x1acc9d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec4 x@0xa0bf70)\n" + " (declare (in ) bvec4 x@0x1accbb0)\n" " )\n" " (\n" " ))\n" @@ -9073,21 +9073,21 @@ static const char *prototypes_for_110_vert = "(function not\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0xa0c150)\n" + " (declare (in ) bvec2 x@0x1accd90)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0xa0c500)\n" + " (declare (in ) bvec3 x@0x1acd110)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0xa0c6e0)\n" + " (declare (in ) bvec4 x@0x1acd2f0)\n" " )\n" " (\n" " ))\n" @@ -9097,8 +9097,8 @@ static const char *prototypes_for_110_vert = "(function texture1D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0xa0c8c0)\n" - " (declare (in ) float coord@0xa0c9e0)\n" + " (declare (in ) sampler1D sampler@0x1acd4d0)\n" + " (declare (in ) float coord@0x1acd5e0)\n" " )\n" " (\n" " ))\n" @@ -9108,16 +9108,16 @@ static const char *prototypes_for_110_vert = "(function texture1DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0xa0cda0)\n" - " (declare (in ) vec2 coord@0xa0cec0)\n" + " (declare (in ) sampler1D sampler@0x1acd970)\n" + " (declare (in ) vec2 coord@0x1acda80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0xa0d280)\n" - " (declare (in ) vec4 coord@0xa0d3a0)\n" + " (declare (in ) sampler1D sampler@0x1acde10)\n" + " (declare (in ) vec4 coord@0x1acdf20)\n" " )\n" " (\n" " ))\n" @@ -9127,9 +9127,9 @@ static const char *prototypes_for_110_vert = "(function texture1DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0xa0d580)\n" - " (declare (in ) float coord@0xa0d6a0)\n" - " (declare (in ) float lod@0xa0d7b0)\n" + " (declare (in ) sampler1D sampler@0x1ace100)\n" + " (declare (in ) float coord@0x1ace210)\n" + " (declare (in ) float lod@0x1ace320)\n" " )\n" " (\n" " ))\n" @@ -9139,18 +9139,18 @@ static const char *prototypes_for_110_vert = "(function texture1DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0xa0db70)\n" - " (declare (in ) vec2 coord@0xa0dc90)\n" - " (declare (in ) float lod@0xa0dda0)\n" + " (declare (in ) sampler1D sampler@0x1ace6b0)\n" + " (declare (in ) vec2 coord@0x1ace7c0)\n" + " (declare (in ) float lod@0x1ace8d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0xa0e160)\n" - " (declare (in ) vec4 coord@0xa0e280)\n" - " (declare (in ) float lod@0xa0e390)\n" + " (declare (in ) sampler1D sampler@0x1acec60)\n" + " (declare (in ) vec4 coord@0x1aced70)\n" + " (declare (in ) float lod@0x1acee80)\n" " )\n" " (\n" " ))\n" @@ -9160,8 +9160,8 @@ static const char *prototypes_for_110_vert = "(function texture2D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0xa0e570)\n" - " (declare (in ) vec2 coord@0xa0e690)\n" + " (declare (in ) sampler2D sampler@0x1acf060)\n" + " (declare (in ) vec2 coord@0x1acf170)\n" " )\n" " (\n" " ))\n" @@ -9171,16 +9171,16 @@ static const char *prototypes_for_110_vert = "(function texture2DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0xa0ea50)\n" - " (declare (in ) vec3 coord@0xa0eb70)\n" + " (declare (in ) sampler2D sampler@0x1acf500)\n" + " (declare (in ) vec3 coord@0x1acf610)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0xa0ef30)\n" - " (declare (in ) vec4 coord@0xa0f050)\n" + " (declare (in ) sampler2D sampler@0x1acf9a0)\n" + " (declare (in ) vec4 coord@0x1acfab0)\n" " )\n" " (\n" " ))\n" @@ -9190,9 +9190,9 @@ static const char *prototypes_for_110_vert = "(function texture2DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0xa0f230)\n" - " (declare (in ) vec2 coord@0xa0f350)\n" - " (declare (in ) float lod@0xa0f460)\n" + " (declare (in ) sampler2D sampler@0x1acfc90)\n" + " (declare (in ) vec2 coord@0x1acfda0)\n" + " (declare (in ) float lod@0x1acfeb0)\n" " )\n" " (\n" " ))\n" @@ -9202,18 +9202,18 @@ static const char *prototypes_for_110_vert = "(function texture2DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0xa0f820)\n" - " (declare (in ) vec3 coord@0xa0f940)\n" - " (declare (in ) float lod@0xa0fa50)\n" + " (declare (in ) sampler2D sampler@0x1ad0240)\n" + " (declare (in ) vec3 coord@0x1ad0350)\n" + " (declare (in ) float lod@0x1ad0460)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0xa0fe10)\n" - " (declare (in ) vec4 coord@0xa0ff30)\n" - " (declare (in ) float lod@0xa10040)\n" + " (declare (in ) sampler2D sampler@0x1ad07f0)\n" + " (declare (in ) vec4 coord@0x1ad0900)\n" + " (declare (in ) float lod@0x1ad0a10)\n" " )\n" " (\n" " ))\n" @@ -9223,8 +9223,8 @@ static const char *prototypes_for_110_vert = "(function texture3D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0xa10220)\n" - " (declare (in ) vec3 coord@0xa10340)\n" + " (declare (in ) sampler3D sampler@0x1ad0bf0)\n" + " (declare (in ) vec3 coord@0x1ad0d00)\n" " )\n" " (\n" " ))\n" @@ -9234,8 +9234,8 @@ static const char *prototypes_for_110_vert = "(function texture3DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0xa10700)\n" - " (declare (in ) vec4 coord@0xa10820)\n" + " (declare (in ) sampler3D sampler@0x1ad1090)\n" + " (declare (in ) vec4 coord@0x1ad11a0)\n" " )\n" " (\n" " ))\n" @@ -9245,9 +9245,9 @@ static const char *prototypes_for_110_vert = "(function texture3DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0xa10be0)\n" - " (declare (in ) vec3 coord@0xa10d00)\n" - " (declare (in ) float lod@0xa10e10)\n" + " (declare (in ) sampler3D sampler@0x1ad1530)\n" + " (declare (in ) vec3 coord@0x1ad1640)\n" + " (declare (in ) float lod@0x1ad1750)\n" " )\n" " (\n" " ))\n" @@ -9257,9 +9257,9 @@ static const char *prototypes_for_110_vert = "(function texture3DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0xa111d0)\n" - " (declare (in ) vec4 coord@0xa112f0)\n" - " (declare (in ) float lod@0xa11400)\n" + " (declare (in ) sampler3D sampler@0x1ad1ae0)\n" + " (declare (in ) vec4 coord@0x1ad1bf0)\n" + " (declare (in ) float lod@0x1ad1d00)\n" " )\n" " (\n" " ))\n" @@ -9269,8 +9269,8 @@ static const char *prototypes_for_110_vert = "(function textureCube\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) samplerCube sampler@0xa117c0)\n" - " (declare (in ) vec3 coord@0xa118e0)\n" + " (declare (in ) samplerCube sampler@0x1ad2090)\n" + " (declare (in ) vec3 coord@0x1ad21a0)\n" " )\n" " (\n" " ))\n" @@ -9280,9 +9280,9 @@ static const char *prototypes_for_110_vert = "(function textureCubeLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) samplerCube sampler@0xa11ca0)\n" - " (declare (in ) vec3 coord@0xa11dc0)\n" - " (declare (in ) float lod@0xa11ed0)\n" + " (declare (in ) samplerCube sampler@0x1ad2530)\n" + " (declare (in ) vec3 coord@0x1ad2640)\n" + " (declare (in ) float lod@0x1ad2750)\n" " )\n" " (\n" " ))\n" @@ -9292,8 +9292,8 @@ static const char *prototypes_for_110_vert = "(function shadow1D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0xa12290)\n" - " (declare (in ) vec3 coord@0xa123b0)\n" + " (declare (in ) sampler1DShadow sampler@0x1ad2ae0)\n" + " (declare (in ) vec3 coord@0x1ad2bf0)\n" " )\n" " (\n" " ))\n" @@ -9303,8 +9303,8 @@ static const char *prototypes_for_110_vert = "(function shadow2D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0xa12770)\n" - " (declare (in ) vec3 coord@0xa12890)\n" + " (declare (in ) sampler2DShadow sampler@0x1ad2f80)\n" + " (declare (in ) vec3 coord@0x1ad3090)\n" " )\n" " (\n" " ))\n" @@ -9314,8 +9314,8 @@ static const char *prototypes_for_110_vert = "(function shadow1DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0xa12c50)\n" - " (declare (in ) vec4 coord@0xa12d70)\n" + " (declare (in ) sampler1DShadow sampler@0x1ad3420)\n" + " (declare (in ) vec4 coord@0x1ad3530)\n" " )\n" " (\n" " ))\n" @@ -9325,8 +9325,8 @@ static const char *prototypes_for_110_vert = "(function shadow2DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0xa13130)\n" - " (declare (in ) vec4 coord@0xa13250)\n" + " (declare (in ) sampler2DShadow sampler@0x1ad38c0)\n" + " (declare (in ) vec4 coord@0x1ad39d0)\n" " )\n" " (\n" " ))\n" @@ -9336,9 +9336,9 @@ static const char *prototypes_for_110_vert = "(function shadow1DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0xa13610)\n" - " (declare (in ) vec3 coord@0xa13730)\n" - " (declare (in ) float lod@0xa13840)\n" + " (declare (in ) sampler1DShadow sampler@0x1ad3d60)\n" + " (declare (in ) vec3 coord@0x1ad3e70)\n" + " (declare (in ) float lod@0x1ad3f80)\n" " )\n" " (\n" " ))\n" @@ -9348,9 +9348,9 @@ static const char *prototypes_for_110_vert = "(function shadow2DLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0xa13c00)\n" - " (declare (in ) vec3 coord@0xa13d20)\n" - " (declare (in ) float lod@0xa13e30)\n" + " (declare (in ) sampler2DShadow sampler@0x1ad4310)\n" + " (declare (in ) vec3 coord@0x1ad4420)\n" + " (declare (in ) float lod@0x1ad4530)\n" " )\n" " (\n" " ))\n" @@ -9360,9 +9360,9 @@ static const char *prototypes_for_110_vert = "(function shadow1DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0xa141f0)\n" - " (declare (in ) vec4 coord@0xa14310)\n" - " (declare (in ) float lod@0xa14420)\n" + " (declare (in ) sampler1DShadow sampler@0x1ad48c0)\n" + " (declare (in ) vec4 coord@0x1ad49d0)\n" + " (declare (in ) float lod@0x1ad4ae0)\n" " )\n" " (\n" " ))\n" @@ -9372,9 +9372,9 @@ static const char *prototypes_for_110_vert = "(function shadow2DProjLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0xa147e0)\n" - " (declare (in ) vec4 coord@0xa14900)\n" - " (declare (in ) float lod@0xa14a10)\n" + " (declare (in ) sampler2DShadow sampler@0x1ad4e70)\n" + " (declare (in ) vec4 coord@0x1ad4f80)\n" + " (declare (in ) float lod@0x1ad5090)\n" " )\n" " (\n" " ))\n" @@ -9384,28 +9384,28 @@ static const char *prototypes_for_110_vert = "(function noise1\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0xa14dd0)\n" + " (declare (in ) float x@0x1ad5420)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0xa15180)\n" + " (declare (in ) vec2 x@0x1ad57a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0xa15360)\n" + " (declare (in ) vec3 x@0x1ad5980)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0xa15540)\n" + " (declare (in ) vec4 x@0x1ad5b60)\n" " )\n" " (\n" " ))\n" @@ -9415,28 +9415,28 @@ static const char *prototypes_for_110_vert = "(function noise2\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float x@0xa15720)\n" + " (declare (in ) float x@0x1ad5d40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0xa15ad0)\n" + " (declare (in ) vec2 x@0x1ad60c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec3 x@0xa15cb0)\n" + " (declare (in ) vec3 x@0x1ad62a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec4 x@0xa15e90)\n" + " (declare (in ) vec4 x@0x1ad6480)\n" " )\n" " (\n" " ))\n" @@ -9446,28 +9446,28 @@ static const char *prototypes_for_110_vert = "(function noise3\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float x@0xa16070)\n" + " (declare (in ) float x@0x1ad6660)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec2 x@0xa16420)\n" + " (declare (in ) vec2 x@0x1ad69e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0xa16600)\n" + " (declare (in ) vec3 x@0x1ad6bc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec4 x@0xa167e0)\n" + " (declare (in ) vec4 x@0x1ad6da0)\n" " )\n" " (\n" " ))\n" @@ -9477,28 +9477,28 @@ static const char *prototypes_for_110_vert = "(function noise4\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float x@0xa169c0)\n" + " (declare (in ) float x@0x1ad6f80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec2 x@0xa16d70)\n" + " (declare (in ) vec2 x@0x1ad7300)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec3 x@0xa16f50)\n" + " (declare (in ) vec3 x@0x1ad74e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0xa17130)\n" + " (declare (in ) vec4 x@0x1ad76c0)\n" " )\n" " (\n" " ))\n" @@ -9587,28 +9587,28 @@ static const char *prototypes_for_110_frag = "(function radians\n" " (signature float\n" " (parameters\n" - " (declare (in ) float degrees@0x151ee40)\n" + " (declare (in ) float degrees@0x26c9280)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 degrees@0x151f210)\n" + " (declare (in ) vec2 degrees@0x26c9600)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 degrees@0x151f400)\n" + " (declare (in ) vec3 degrees@0x26c97e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 degrees@0x151f5f0)\n" + " (declare (in ) vec4 degrees@0x26c99c0)\n" " )\n" " (\n" " ))\n" @@ -9618,28 +9618,28 @@ static const char *prototypes_for_110_frag = "(function degrees\n" " (signature float\n" " (parameters\n" - " (declare (in ) float radians@0x151f7e0)\n" + " (declare (in ) float radians@0x26c9ba0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 radians@0x151fbb0)\n" + " (declare (in ) vec2 radians@0x26c9f20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 radians@0x151fda0)\n" + " (declare (in ) vec3 radians@0x26ca100)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 radians@0x151ff90)\n" + " (declare (in ) vec4 radians@0x26ca2e0)\n" " )\n" " (\n" " ))\n" @@ -9649,28 +9649,28 @@ static const char *prototypes_for_110_frag = "(function sin\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x1520180)\n" + " (declare (in ) float angle@0x26ca4c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x1520530)\n" + " (declare (in ) vec2 angle@0x26ca840)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x1520710)\n" + " (declare (in ) vec3 angle@0x26caa20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x15208f0)\n" + " (declare (in ) vec4 angle@0x26cac00)\n" " )\n" " (\n" " ))\n" @@ -9680,28 +9680,28 @@ static const char *prototypes_for_110_frag = "(function cos\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x1520ad0)\n" + " (declare (in ) float angle@0x26cade0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x1520e80)\n" + " (declare (in ) vec2 angle@0x26cb160)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x1521060)\n" + " (declare (in ) vec3 angle@0x26cb340)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x1521240)\n" + " (declare (in ) vec4 angle@0x26cb520)\n" " )\n" " (\n" " ))\n" @@ -9711,28 +9711,28 @@ static const char *prototypes_for_110_frag = "(function tan\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x1521420)\n" + " (declare (in ) float angle@0x26cb700)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x15217d0)\n" + " (declare (in ) vec2 angle@0x26cba80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x15219b0)\n" + " (declare (in ) vec3 angle@0x26cbc60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x1521b90)\n" + " (declare (in ) vec4 angle@0x26cbe40)\n" " )\n" " (\n" " ))\n" @@ -9742,28 +9742,28 @@ static const char *prototypes_for_110_frag = "(function asin\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x1521d70)\n" + " (declare (in ) float angle@0x26cc020)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x1522120)\n" + " (declare (in ) vec2 angle@0x26cc3a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x1522300)\n" + " (declare (in ) vec3 angle@0x26cc580)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x15224e0)\n" + " (declare (in ) vec4 angle@0x26cc760)\n" " )\n" " (\n" " ))\n" @@ -9773,28 +9773,28 @@ static const char *prototypes_for_110_frag = "(function acos\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x15226c0)\n" + " (declare (in ) float angle@0x26cc940)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x1522a70)\n" + " (declare (in ) vec2 angle@0x26cccc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x1522c50)\n" + " (declare (in ) vec3 angle@0x26ccea0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x1522e30)\n" + " (declare (in ) vec4 angle@0x26cd080)\n" " )\n" " (\n" " ))\n" @@ -9804,60 +9804,60 @@ static const char *prototypes_for_110_frag = "(function atan\n" " (signature float\n" " (parameters\n" - " (declare (in ) float y@0x1523010)\n" - " (declare (in ) float x@0x1523120)\n" + " (declare (in ) float y@0x26cd260)\n" + " (declare (in ) float x@0x26cd370)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 y@0x15234d0)\n" - " (declare (in ) vec2 x@0x15235e0)\n" + " (declare (in ) vec2 y@0x26cd6f0)\n" + " (declare (in ) vec2 x@0x26cd800)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 y@0x15237c0)\n" - " (declare (in ) vec3 x@0x15238d0)\n" + " (declare (in ) vec3 y@0x26cd9e0)\n" + " (declare (in ) vec3 x@0x26cdaf0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 y@0x1523ab0)\n" - " (declare (in ) vec4 x@0x1523bc0)\n" + " (declare (in ) vec4 y@0x26cdcd0)\n" + " (declare (in ) vec4 x@0x26cdde0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) float y_over_x@0x1523da0)\n" + " (declare (in ) float y_over_x@0x26cdfc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 y_over_x@0x1523f90)\n" + " (declare (in ) vec2 y_over_x@0x26ce1b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 y_over_x@0x1524180)\n" + " (declare (in ) vec3 y_over_x@0x26ce3a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 y_over_x@0x1524370)\n" + " (declare (in ) vec4 y_over_x@0x26ce590)\n" " )\n" " (\n" " ))\n" @@ -9867,32 +9867,32 @@ static const char *prototypes_for_110_frag = "(function pow\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1524560)\n" - " (declare (in ) float y@0x1524670)\n" + " (declare (in ) float x@0x26ce780)\n" + " (declare (in ) float y@0x26ce890)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1524a20)\n" - " (declare (in ) vec2 y@0x1524b30)\n" + " (declare (in ) vec2 x@0x26cec10)\n" + " (declare (in ) vec2 y@0x26ced20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1524d10)\n" - " (declare (in ) vec3 y@0x1524e20)\n" + " (declare (in ) vec3 x@0x26cef00)\n" + " (declare (in ) vec3 y@0x26cf010)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1525000)\n" - " (declare (in ) vec4 y@0x1525110)\n" + " (declare (in ) vec4 x@0x26cf1f0)\n" + " (declare (in ) vec4 y@0x26cf300)\n" " )\n" " (\n" " ))\n" @@ -9902,28 +9902,28 @@ static const char *prototypes_for_110_frag = "(function exp\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x15252f0)\n" + " (declare (in ) float x@0x26cf4e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x15256a0)\n" + " (declare (in ) vec2 x@0x26cf860)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1525880)\n" + " (declare (in ) vec3 x@0x26cfa40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1525a60)\n" + " (declare (in ) vec4 x@0x26cfc20)\n" " )\n" " (\n" " ))\n" @@ -9933,28 +9933,28 @@ static const char *prototypes_for_110_frag = "(function log\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1525c40)\n" + " (declare (in ) float x@0x26cfe00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1525ff0)\n" + " (declare (in ) vec2 x@0x26d0180)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x15261d0)\n" + " (declare (in ) vec3 x@0x26d0360)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x15263b0)\n" + " (declare (in ) vec4 x@0x26d0540)\n" " )\n" " (\n" " ))\n" @@ -9964,28 +9964,28 @@ static const char *prototypes_for_110_frag = "(function exp2\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1526590)\n" + " (declare (in ) float x@0x26d0720)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1526940)\n" + " (declare (in ) vec2 x@0x26d0aa0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1526b20)\n" + " (declare (in ) vec3 x@0x26d0c80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1526d00)\n" + " (declare (in ) vec4 x@0x26d0e60)\n" " )\n" " (\n" " ))\n" @@ -9995,28 +9995,28 @@ static const char *prototypes_for_110_frag = "(function log2\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1526ee0)\n" + " (declare (in ) float x@0x26d1040)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1527290)\n" + " (declare (in ) vec2 x@0x26d13c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1527470)\n" + " (declare (in ) vec3 x@0x26d15a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1527650)\n" + " (declare (in ) vec4 x@0x26d1780)\n" " )\n" " (\n" " ))\n" @@ -10026,28 +10026,28 @@ static const char *prototypes_for_110_frag = "(function sqrt\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1527830)\n" + " (declare (in ) float x@0x26d1960)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1527be0)\n" + " (declare (in ) vec2 x@0x26d1ce0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1527dc0)\n" + " (declare (in ) vec3 x@0x26d1ec0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1527fa0)\n" + " (declare (in ) vec4 x@0x26d20a0)\n" " )\n" " (\n" " ))\n" @@ -10057,28 +10057,28 @@ static const char *prototypes_for_110_frag = "(function inversesqrt\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1528180)\n" + " (declare (in ) float x@0x26d2280)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1528540)\n" + " (declare (in ) vec2 x@0x26d2610)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1528720)\n" + " (declare (in ) vec3 x@0x26d27f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1528900)\n" + " (declare (in ) vec4 x@0x26d29d0)\n" " )\n" " (\n" " ))\n" @@ -10088,28 +10088,28 @@ static const char *prototypes_for_110_frag = "(function abs\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1528ae0)\n" + " (declare (in ) float x@0x26d2bb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1528e90)\n" + " (declare (in ) vec2 x@0x26d2f30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1529070)\n" + " (declare (in ) vec3 x@0x26d3110)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1529250)\n" + " (declare (in ) vec4 x@0x26d32f0)\n" " )\n" " (\n" " ))\n" @@ -10119,28 +10119,28 @@ static const char *prototypes_for_110_frag = "(function sign\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1529430)\n" + " (declare (in ) float x@0x26d34d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x15297e0)\n" + " (declare (in ) vec2 x@0x26d3850)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x15299c0)\n" + " (declare (in ) vec3 x@0x26d3a30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1529ba0)\n" + " (declare (in ) vec4 x@0x26d3c10)\n" " )\n" " (\n" " ))\n" @@ -10150,28 +10150,28 @@ static const char *prototypes_for_110_frag = "(function floor\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1529d80)\n" + " (declare (in ) float x@0x26d3df0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x152a130)\n" + " (declare (in ) vec2 x@0x26d4170)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x152a310)\n" + " (declare (in ) vec3 x@0x26d4350)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x152a4f0)\n" + " (declare (in ) vec4 x@0x26d4530)\n" " )\n" " (\n" " ))\n" @@ -10181,28 +10181,28 @@ static const char *prototypes_for_110_frag = "(function ceil\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x152a6d0)\n" + " (declare (in ) float x@0x26d4710)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x152aa80)\n" + " (declare (in ) vec2 x@0x26d4a90)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x152ac60)\n" + " (declare (in ) vec3 x@0x26d4c70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x152ae40)\n" + " (declare (in ) vec4 x@0x26d4e50)\n" " )\n" " (\n" " ))\n" @@ -10212,28 +10212,28 @@ static const char *prototypes_for_110_frag = "(function fract\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x152b020)\n" + " (declare (in ) float x@0x26d5030)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x152b3d0)\n" + " (declare (in ) vec2 x@0x26d53b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x152b5b0)\n" + " (declare (in ) vec3 x@0x26d5590)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x152b790)\n" + " (declare (in ) vec4 x@0x26d5770)\n" " )\n" " (\n" " ))\n" @@ -10243,56 +10243,56 @@ static const char *prototypes_for_110_frag = "(function mod\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x152b970)\n" - " (declare (in ) float y@0x152ba80)\n" + " (declare (in ) float x@0x26d5950)\n" + " (declare (in ) float y@0x26d5a60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x152be30)\n" - " (declare (in ) float y@0x152bf40)\n" + " (declare (in ) vec2 x@0x26d5de0)\n" + " (declare (in ) float y@0x26d5ef0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x152c120)\n" - " (declare (in ) float y@0x152c230)\n" + " (declare (in ) vec3 x@0x26d60d0)\n" + " (declare (in ) float y@0x26d61e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x152c410)\n" - " (declare (in ) float y@0x152c520)\n" + " (declare (in ) vec4 x@0x26d63c0)\n" + " (declare (in ) float y@0x26d64d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x152c700)\n" - " (declare (in ) vec2 y@0x152c810)\n" + " (declare (in ) vec2 x@0x26d66b0)\n" + " (declare (in ) vec2 y@0x26d67c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x152c9f0)\n" - " (declare (in ) vec3 y@0x152cb00)\n" + " (declare (in ) vec3 x@0x26d69a0)\n" + " (declare (in ) vec3 y@0x26d6ab0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x152cce0)\n" - " (declare (in ) vec4 y@0x152cdf0)\n" + " (declare (in ) vec4 x@0x26d6c90)\n" + " (declare (in ) vec4 y@0x26d6da0)\n" " )\n" " (\n" " ))\n" @@ -10302,56 +10302,56 @@ static const char *prototypes_for_110_frag = "(function min\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x152cfd0)\n" - " (declare (in ) float y@0x152d0e0)\n" + " (declare (in ) float x@0x26d6f80)\n" + " (declare (in ) float y@0x26d7090)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x152d490)\n" - " (declare (in ) vec2 y@0x152d5a0)\n" + " (declare (in ) vec2 x@0x26d7410)\n" + " (declare (in ) vec2 y@0x26d7520)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x152d780)\n" - " (declare (in ) vec3 y@0x152d890)\n" + " (declare (in ) vec3 x@0x26d7700)\n" + " (declare (in ) vec3 y@0x26d7810)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x152da70)\n" - " (declare (in ) vec4 y@0x152db80)\n" + " (declare (in ) vec4 x@0x26d79f0)\n" + " (declare (in ) vec4 y@0x26d7b00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x152dd60)\n" - " (declare (in ) float y@0x152de70)\n" + " (declare (in ) vec2 x@0x26d7ce0)\n" + " (declare (in ) float y@0x26d7df0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x152e050)\n" - " (declare (in ) float y@0x152e160)\n" + " (declare (in ) vec3 x@0x26d7fd0)\n" + " (declare (in ) float y@0x26d80e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x152e340)\n" - " (declare (in ) float y@0x152e450)\n" + " (declare (in ) vec4 x@0x26d82c0)\n" + " (declare (in ) float y@0x26d83d0)\n" " )\n" " (\n" " ))\n" @@ -10361,56 +10361,56 @@ static const char *prototypes_for_110_frag = "(function max\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x152e630)\n" - " (declare (in ) float y@0x152e740)\n" + " (declare (in ) float x@0x26d85b0)\n" + " (declare (in ) float y@0x26d86c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x152eaf0)\n" - " (declare (in ) vec2 y@0x152ec00)\n" + " (declare (in ) vec2 x@0x26d8a40)\n" + " (declare (in ) vec2 y@0x26d8b50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x152ede0)\n" - " (declare (in ) vec3 y@0x152eef0)\n" + " (declare (in ) vec3 x@0x26d8d30)\n" + " (declare (in ) vec3 y@0x26d8e40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x152f0d0)\n" - " (declare (in ) vec4 y@0x152f1e0)\n" + " (declare (in ) vec4 x@0x26d9020)\n" + " (declare (in ) vec4 y@0x26d9130)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x152f3c0)\n" - " (declare (in ) float y@0x152f4d0)\n" + " (declare (in ) vec2 x@0x26d9310)\n" + " (declare (in ) float y@0x26d9420)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x152f6b0)\n" - " (declare (in ) float y@0x152f7c0)\n" + " (declare (in ) vec3 x@0x26d9600)\n" + " (declare (in ) float y@0x26d9710)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x152f9a0)\n" - " (declare (in ) float y@0x152fab0)\n" + " (declare (in ) vec4 x@0x26d98f0)\n" + " (declare (in ) float y@0x26d9a00)\n" " )\n" " (\n" " ))\n" @@ -10420,63 +10420,63 @@ static const char *prototypes_for_110_frag = "(function clamp\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x152fc90)\n" - " (declare (in ) float minVal@0x152fda0)\n" - " (declare (in ) float maxVal@0x152feb0)\n" + " (declare (in ) float x@0x26d9be0)\n" + " (declare (in ) float minVal@0x26d9cf0)\n" + " (declare (in ) float maxVal@0x26d9e00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1530260)\n" - " (declare (in ) vec2 minVal@0x1530370)\n" - " (declare (in ) vec2 maxVal@0x1530480)\n" + " (declare (in ) vec2 x@0x26da180)\n" + " (declare (in ) vec2 minVal@0x26da290)\n" + " (declare (in ) vec2 maxVal@0x26da3a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1530660)\n" - " (declare (in ) vec3 minVal@0x1530770)\n" - " (declare (in ) vec3 maxVal@0x1530880)\n" + " (declare (in ) vec3 x@0x26da580)\n" + " (declare (in ) vec3 minVal@0x26da690)\n" + " (declare (in ) vec3 maxVal@0x26da7a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1530a60)\n" - " (declare (in ) vec4 minVal@0x1530b70)\n" - " (declare (in ) vec4 maxVal@0x1530c80)\n" + " (declare (in ) vec4 x@0x26da980)\n" + " (declare (in ) vec4 minVal@0x26daa90)\n" + " (declare (in ) vec4 maxVal@0x26daba0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1530e60)\n" - " (declare (in ) float minVal@0x1530f70)\n" - " (declare (in ) float maxVal@0x1531080)\n" + " (declare (in ) vec2 x@0x26dad80)\n" + " (declare (in ) float minVal@0x26dae90)\n" + " (declare (in ) float maxVal@0x26dafa0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1531260)\n" - " (declare (in ) float minVal@0x1531370)\n" - " (declare (in ) float maxVal@0x1531480)\n" + " (declare (in ) vec3 x@0x26db180)\n" + " (declare (in ) float minVal@0x26db290)\n" + " (declare (in ) float maxVal@0x26db3a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1531660)\n" - " (declare (in ) float minVal@0x1531770)\n" - " (declare (in ) float maxVal@0x1531880)\n" + " (declare (in ) vec4 x@0x26db580)\n" + " (declare (in ) float minVal@0x26db690)\n" + " (declare (in ) float maxVal@0x26db7a0)\n" " )\n" " (\n" " ))\n" @@ -10486,63 +10486,63 @@ static const char *prototypes_for_110_frag = "(function mix\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1531a60)\n" - " (declare (in ) float y@0x1531b70)\n" - " (declare (in ) float a@0x1531c80)\n" + " (declare (in ) float x@0x26db980)\n" + " (declare (in ) float y@0x26dba90)\n" + " (declare (in ) float a@0x26dbba0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1532030)\n" - " (declare (in ) vec2 y@0x1532140)\n" - " (declare (in ) vec2 a@0x1532250)\n" + " (declare (in ) vec2 x@0x26dbf20)\n" + " (declare (in ) vec2 y@0x26dc030)\n" + " (declare (in ) vec2 a@0x26dc140)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1532430)\n" - " (declare (in ) vec3 y@0x1532540)\n" - " (declare (in ) vec3 a@0x1532650)\n" + " (declare (in ) vec3 x@0x26dc320)\n" + " (declare (in ) vec3 y@0x26dc430)\n" + " (declare (in ) vec3 a@0x26dc540)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1532830)\n" - " (declare (in ) vec4 y@0x1532940)\n" - " (declare (in ) vec4 a@0x1532a50)\n" + " (declare (in ) vec4 x@0x26dc720)\n" + " (declare (in ) vec4 y@0x26dc830)\n" + " (declare (in ) vec4 a@0x26dc940)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1532c30)\n" - " (declare (in ) vec2 y@0x1532d40)\n" - " (declare (in ) float a@0x1532e50)\n" + " (declare (in ) vec2 x@0x26dcb20)\n" + " (declare (in ) vec2 y@0x26dcc30)\n" + " (declare (in ) float a@0x26dcd40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1533030)\n" - " (declare (in ) vec3 y@0x1533140)\n" - " (declare (in ) float a@0x1533250)\n" + " (declare (in ) vec3 x@0x26dcf20)\n" + " (declare (in ) vec3 y@0x26dd030)\n" + " (declare (in ) float a@0x26dd140)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1533430)\n" - " (declare (in ) vec4 y@0x1533540)\n" - " (declare (in ) float a@0x1533650)\n" + " (declare (in ) vec4 x@0x26dd320)\n" + " (declare (in ) vec4 y@0x26dd430)\n" + " (declare (in ) float a@0x26dd540)\n" " )\n" " (\n" " ))\n" @@ -10552,56 +10552,56 @@ static const char *prototypes_for_110_frag = "(function step\n" " (signature float\n" " (parameters\n" - " (declare (in ) float edge@0x1533830)\n" - " (declare (in ) float x@0x1533940)\n" + " (declare (in ) float edge@0x26dd720)\n" + " (declare (in ) float x@0x26dd830)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 edge@0x1533cf0)\n" - " (declare (in ) vec2 x@0x1533e00)\n" + " (declare (in ) vec2 edge@0x26ddbb0)\n" + " (declare (in ) vec2 x@0x26ddcc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 edge@0x1533fe0)\n" - " (declare (in ) vec3 x@0x15340f0)\n" + " (declare (in ) vec3 edge@0x26ddea0)\n" + " (declare (in ) vec3 x@0x26ddfb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 edge@0x15342d0)\n" - " (declare (in ) vec4 x@0x15343e0)\n" + " (declare (in ) vec4 edge@0x26de190)\n" + " (declare (in ) vec4 x@0x26de2a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float edge@0x15345c0)\n" - " (declare (in ) vec2 x@0x15346d0)\n" + " (declare (in ) float edge@0x26de480)\n" + " (declare (in ) vec2 x@0x26de590)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float edge@0x15348b0)\n" - " (declare (in ) vec3 x@0x15349c0)\n" + " (declare (in ) float edge@0x26de770)\n" + " (declare (in ) vec3 x@0x26de880)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float edge@0x1534ba0)\n" - " (declare (in ) vec4 x@0x1534cb0)\n" + " (declare (in ) float edge@0x26dea60)\n" + " (declare (in ) vec4 x@0x26deb70)\n" " )\n" " (\n" " ))\n" @@ -10611,63 +10611,63 @@ static const char *prototypes_for_110_frag = "(function smoothstep\n" " (signature float\n" " (parameters\n" - " (declare (in ) float edge0@0x1534e90)\n" - " (declare (in ) float edge1@0x1534fa0)\n" - " (declare (in ) float x@0x15350b0)\n" + " (declare (in ) float edge0@0x26ded50)\n" + " (declare (in ) float edge1@0x26dee60)\n" + " (declare (in ) float x@0x26def70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 edge0@0x1535470)\n" - " (declare (in ) vec2 edge1@0x1535580)\n" - " (declare (in ) vec2 x@0x1535690)\n" + " (declare (in ) vec2 edge0@0x26df300)\n" + " (declare (in ) vec2 edge1@0x26df410)\n" + " (declare (in ) vec2 x@0x26df520)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 edge0@0x1535870)\n" - " (declare (in ) vec3 edge1@0x1535980)\n" - " (declare (in ) vec3 x@0x1535a90)\n" + " (declare (in ) vec3 edge0@0x26df700)\n" + " (declare (in ) vec3 edge1@0x26df810)\n" + " (declare (in ) vec3 x@0x26df920)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 edge0@0x1535c70)\n" - " (declare (in ) vec4 edge1@0x1535d80)\n" - " (declare (in ) vec4 x@0x1535e90)\n" + " (declare (in ) vec4 edge0@0x26dfb00)\n" + " (declare (in ) vec4 edge1@0x26dfc10)\n" + " (declare (in ) vec4 x@0x26dfd20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float edge0@0x1536070)\n" - " (declare (in ) float edge1@0x1536180)\n" - " (declare (in ) vec2 x@0x1536290)\n" + " (declare (in ) float edge0@0x26dff00)\n" + " (declare (in ) float edge1@0x26e0010)\n" + " (declare (in ) vec2 x@0x26e0120)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float edge0@0x1536470)\n" - " (declare (in ) float edge1@0x1536580)\n" - " (declare (in ) vec3 x@0x1536690)\n" + " (declare (in ) float edge0@0x26e0300)\n" + " (declare (in ) float edge1@0x26e0410)\n" + " (declare (in ) vec3 x@0x26e0520)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float edge0@0x1536870)\n" - " (declare (in ) float edge1@0x1536980)\n" - " (declare (in ) vec4 x@0x1536a90)\n" + " (declare (in ) float edge0@0x26e0700)\n" + " (declare (in ) float edge1@0x26e0810)\n" + " (declare (in ) vec4 x@0x26e0920)\n" " )\n" " (\n" " ))\n" @@ -10677,28 +10677,28 @@ static const char *prototypes_for_110_frag = "(function length\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1536c70)\n" + " (declare (in ) float x@0x26e0b00)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x1537020)\n" + " (declare (in ) vec2 x@0x26e0e80)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x1537200)\n" + " (declare (in ) vec3 x@0x26e1060)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x15373e0)\n" + " (declare (in ) vec4 x@0x26e1240)\n" " )\n" " (\n" " ))\n" @@ -10708,32 +10708,32 @@ static const char *prototypes_for_110_frag = "(function distance\n" " (signature float\n" " (parameters\n" - " (declare (in ) float p0@0x15375c0)\n" - " (declare (in ) float p1@0x15376d0)\n" + " (declare (in ) float p0@0x26e1420)\n" + " (declare (in ) float p1@0x26e1530)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 p0@0x1537a90)\n" - " (declare (in ) vec2 p1@0x1537ba0)\n" + " (declare (in ) vec2 p0@0x26e18c0)\n" + " (declare (in ) vec2 p1@0x26e19d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 p0@0x1537d80)\n" - " (declare (in ) vec3 p1@0x1537e90)\n" + " (declare (in ) vec3 p0@0x26e1bb0)\n" + " (declare (in ) vec3 p1@0x26e1cc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 p0@0x1538070)\n" - " (declare (in ) vec4 p1@0x1538180)\n" + " (declare (in ) vec4 p0@0x26e1ea0)\n" + " (declare (in ) vec4 p1@0x26e1fb0)\n" " )\n" " (\n" " ))\n" @@ -10743,32 +10743,32 @@ static const char *prototypes_for_110_frag = "(function dot\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1538360)\n" - " (declare (in ) float y@0x1538470)\n" + " (declare (in ) float x@0x26e2190)\n" + " (declare (in ) float y@0x26e22a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x1538820)\n" - " (declare (in ) vec2 y@0x1538930)\n" + " (declare (in ) vec2 x@0x26e2620)\n" + " (declare (in ) vec2 y@0x26e2730)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x1538b10)\n" - " (declare (in ) vec3 y@0x1538c20)\n" + " (declare (in ) vec3 x@0x26e2910)\n" + " (declare (in ) vec3 y@0x26e2a20)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x1538e00)\n" - " (declare (in ) vec4 y@0x1538f10)\n" + " (declare (in ) vec4 x@0x26e2c00)\n" + " (declare (in ) vec4 y@0x26e2d10)\n" " )\n" " (\n" " ))\n" @@ -10778,8 +10778,8 @@ static const char *prototypes_for_110_frag = "(function cross\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x15390f0)\n" - " (declare (in ) vec3 y@0x1539200)\n" + " (declare (in ) vec3 x@0x26e2ef0)\n" + " (declare (in ) vec3 y@0x26e3000)\n" " )\n" " (\n" " ))\n" @@ -10789,28 +10789,28 @@ static const char *prototypes_for_110_frag = "(function normalize\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x15395b0)\n" + " (declare (in ) float x@0x26e3380)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1539970)\n" + " (declare (in ) vec2 x@0x26e3710)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1539b50)\n" + " (declare (in ) vec3 x@0x26e38f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1539d30)\n" + " (declare (in ) vec4 x@0x26e3ad0)\n" " )\n" " (\n" " ))\n" @@ -10820,36 +10820,36 @@ static const char *prototypes_for_110_frag = "(function faceforward\n" " (signature float\n" " (parameters\n" - " (declare (in ) float N@0x1539f10)\n" - " (declare (in ) float I@0x153a020)\n" - " (declare (in ) float Nref@0x153a130)\n" + " (declare (in ) float N@0x26e3cb0)\n" + " (declare (in ) float I@0x26e3dc0)\n" + " (declare (in ) float Nref@0x26e3ed0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 N@0x153a4f0)\n" - " (declare (in ) vec2 I@0x153a600)\n" - " (declare (in ) vec2 Nref@0x153a710)\n" + " (declare (in ) vec2 N@0x26e4260)\n" + " (declare (in ) vec2 I@0x26e4370)\n" + " (declare (in ) vec2 Nref@0x26e4480)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 N@0x153a8f0)\n" - " (declare (in ) vec3 I@0x153aa00)\n" - " (declare (in ) vec3 Nref@0x153ab10)\n" + " (declare (in ) vec3 N@0x26e4660)\n" + " (declare (in ) vec3 I@0x26e4770)\n" + " (declare (in ) vec3 Nref@0x26e4880)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 N@0x153acf0)\n" - " (declare (in ) vec4 I@0x153ae00)\n" - " (declare (in ) vec4 Nref@0x153af10)\n" + " (declare (in ) vec4 N@0x26e4a60)\n" + " (declare (in ) vec4 I@0x26e4b70)\n" + " (declare (in ) vec4 Nref@0x26e4c80)\n" " )\n" " (\n" " ))\n" @@ -10859,32 +10859,32 @@ static const char *prototypes_for_110_frag = "(function reflect\n" " (signature float\n" " (parameters\n" - " (declare (in ) float I@0x153b0f0)\n" - " (declare (in ) float N@0x153b200)\n" + " (declare (in ) float I@0x26e4e60)\n" + " (declare (in ) float N@0x26e4f70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 I@0x153b5c0)\n" - " (declare (in ) vec2 N@0x153b6d0)\n" + " (declare (in ) vec2 I@0x26e52f0)\n" + " (declare (in ) vec2 N@0x26e5400)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 I@0x153b8b0)\n" - " (declare (in ) vec3 N@0x153b9c0)\n" + " (declare (in ) vec3 I@0x26e55e0)\n" + " (declare (in ) vec3 N@0x26e56f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 I@0x153bba0)\n" - " (declare (in ) vec4 N@0x153bcb0)\n" + " (declare (in ) vec4 I@0x26e58d0)\n" + " (declare (in ) vec4 N@0x26e59e0)\n" " )\n" " (\n" " ))\n" @@ -10894,36 +10894,36 @@ static const char *prototypes_for_110_frag = "(function refract\n" " (signature float\n" " (parameters\n" - " (declare (in ) float I@0x153be90)\n" - " (declare (in ) float N@0x153bfa0)\n" - " (declare (in ) float eta@0x153c0b0)\n" + " (declare (in ) float I@0x26e5bc0)\n" + " (declare (in ) float N@0x26e5cd0)\n" + " (declare (in ) float eta@0x26e5de0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 I@0x153c470)\n" - " (declare (in ) vec2 N@0x153c580)\n" - " (declare (in ) float eta@0x153c690)\n" + " (declare (in ) vec2 I@0x26e6160)\n" + " (declare (in ) vec2 N@0x26e6270)\n" + " (declare (in ) float eta@0x26e6380)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 I@0x153c870)\n" - " (declare (in ) vec3 N@0x153c980)\n" - " (declare (in ) float eta@0x153ca90)\n" + " (declare (in ) vec3 I@0x26e6560)\n" + " (declare (in ) vec3 N@0x26e6670)\n" + " (declare (in ) float eta@0x26e6780)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 I@0x153cc70)\n" - " (declare (in ) vec4 N@0x153cd80)\n" - " (declare (in ) float eta@0x153ce90)\n" + " (declare (in ) vec4 I@0x26e6960)\n" + " (declare (in ) vec4 N@0x26e6a70)\n" + " (declare (in ) float eta@0x26e6b80)\n" " )\n" " (\n" " ))\n" @@ -10933,24 +10933,24 @@ static const char *prototypes_for_110_frag = "(function matrixCompMult\n" " (signature mat2\n" " (parameters\n" - " (declare (in ) mat2 x@0x153d070)\n" - " (declare (in ) mat2 y@0x153d180)\n" + " (declare (in ) mat2 x@0x26e6d60)\n" + " (declare (in ) mat2 y@0x26e6e70)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3\n" " (parameters\n" - " (declare (in ) mat3 x@0x153d540)\n" - " (declare (in ) mat3 y@0x153d650)\n" + " (declare (in ) mat3 x@0x26e7200)\n" + " (declare (in ) mat3 y@0x26e7310)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4\n" " (parameters\n" - " (declare (in ) mat4 x@0x153d830)\n" - " (declare (in ) mat4 y@0x153d940)\n" + " (declare (in ) mat4 x@0x26e74f0)\n" + " (declare (in ) mat4 y@0x26e7600)\n" " )\n" " (\n" " ))\n" @@ -10960,48 +10960,48 @@ static const char *prototypes_for_110_frag = "(function lessThan\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x153db20)\n" - " (declare (in ) vec2 y@0x153dc30)\n" + " (declare (in ) vec2 x@0x26e77e0)\n" + " (declare (in ) vec2 y@0x26e78f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x153dff0)\n" - " (declare (in ) vec3 y@0x153e100)\n" + " (declare (in ) vec3 x@0x26e7c80)\n" + " (declare (in ) vec3 y@0x26e7d90)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x153e2e0)\n" - " (declare (in ) vec4 y@0x153e3f0)\n" + " (declare (in ) vec4 x@0x26e7f70)\n" + " (declare (in ) vec4 y@0x26e8080)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x153e5d0)\n" - " (declare (in ) ivec2 y@0x153e6e0)\n" + " (declare (in ) ivec2 x@0x26e8260)\n" + " (declare (in ) ivec2 y@0x26e8370)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x153e8c0)\n" - " (declare (in ) ivec3 y@0x153e9d0)\n" + " (declare (in ) ivec3 x@0x26e8550)\n" + " (declare (in ) ivec3 y@0x26e8660)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x153ebb0)\n" - " (declare (in ) ivec4 y@0x153ecc0)\n" + " (declare (in ) ivec4 x@0x26e8840)\n" + " (declare (in ) ivec4 y@0x26e8950)\n" " )\n" " (\n" " ))\n" @@ -11011,48 +11011,48 @@ static const char *prototypes_for_110_frag = "(function lessThanEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x153eea0)\n" - " (declare (in ) vec2 y@0x153efb0)\n" + " (declare (in ) vec2 x@0x26e8b30)\n" + " (declare (in ) vec2 y@0x26e8c40)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x153f370)\n" - " (declare (in ) vec3 y@0x153f480)\n" + " (declare (in ) vec3 x@0x26e8fd0)\n" + " (declare (in ) vec3 y@0x26e90e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x153f660)\n" - " (declare (in ) vec4 y@0x153f770)\n" + " (declare (in ) vec4 x@0x26e92c0)\n" + " (declare (in ) vec4 y@0x26e93d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x153f950)\n" - " (declare (in ) ivec2 y@0x153fa60)\n" + " (declare (in ) ivec2 x@0x26e95b0)\n" + " (declare (in ) ivec2 y@0x26e96c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x153fc40)\n" - " (declare (in ) ivec3 y@0x153fd50)\n" + " (declare (in ) ivec3 x@0x26e98a0)\n" + " (declare (in ) ivec3 y@0x26e99b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x153ff30)\n" - " (declare (in ) ivec4 y@0x1540040)\n" + " (declare (in ) ivec4 x@0x26e9b90)\n" + " (declare (in ) ivec4 y@0x26e9ca0)\n" " )\n" " (\n" " ))\n" @@ -11062,48 +11062,48 @@ static const char *prototypes_for_110_frag = "(function greaterThan\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1540220)\n" - " (declare (in ) vec2 y@0x1540330)\n" + " (declare (in ) vec2 x@0x26e9e80)\n" + " (declare (in ) vec2 y@0x26e9f90)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x15406f0)\n" - " (declare (in ) vec3 y@0x1540800)\n" + " (declare (in ) vec3 x@0x26ea320)\n" + " (declare (in ) vec3 y@0x26ea430)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x15409e0)\n" - " (declare (in ) vec4 y@0x1540af0)\n" + " (declare (in ) vec4 x@0x26ea610)\n" + " (declare (in ) vec4 y@0x26ea720)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x1540cd0)\n" - " (declare (in ) ivec2 y@0x1540de0)\n" + " (declare (in ) ivec2 x@0x26ea900)\n" + " (declare (in ) ivec2 y@0x26eaa10)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x1540fc0)\n" - " (declare (in ) ivec3 y@0x15410d0)\n" + " (declare (in ) ivec3 x@0x26eabf0)\n" + " (declare (in ) ivec3 y@0x26ead00)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x15412b0)\n" - " (declare (in ) ivec4 y@0x15413c0)\n" + " (declare (in ) ivec4 x@0x26eaee0)\n" + " (declare (in ) ivec4 y@0x26eaff0)\n" " )\n" " (\n" " ))\n" @@ -11113,48 +11113,48 @@ static const char *prototypes_for_110_frag = "(function greaterThanEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x15415a0)\n" - " (declare (in ) vec2 y@0x15416b0)\n" + " (declare (in ) vec2 x@0x26eb1d0)\n" + " (declare (in ) vec2 y@0x26eb2e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1541a70)\n" - " (declare (in ) vec3 y@0x1541b80)\n" + " (declare (in ) vec3 x@0x26eb670)\n" + " (declare (in ) vec3 y@0x26eb780)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1541d60)\n" - " (declare (in ) vec4 y@0x1541e70)\n" + " (declare (in ) vec4 x@0x26eb960)\n" + " (declare (in ) vec4 y@0x26eba70)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x1542050)\n" - " (declare (in ) ivec2 y@0x1542160)\n" + " (declare (in ) ivec2 x@0x26ebc50)\n" + " (declare (in ) ivec2 y@0x26ebd60)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x1542340)\n" - " (declare (in ) ivec3 y@0x1542450)\n" + " (declare (in ) ivec3 x@0x26ebf40)\n" + " (declare (in ) ivec3 y@0x26ec050)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x1542630)\n" - " (declare (in ) ivec4 y@0x1542740)\n" + " (declare (in ) ivec4 x@0x26ec230)\n" + " (declare (in ) ivec4 y@0x26ec340)\n" " )\n" " (\n" " ))\n" @@ -11164,72 +11164,72 @@ static const char *prototypes_for_110_frag = "(function equal\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1542920)\n" - " (declare (in ) vec2 y@0x1542a30)\n" + " (declare (in ) vec2 x@0x26ec520)\n" + " (declare (in ) vec2 y@0x26ec630)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1542de0)\n" - " (declare (in ) vec3 y@0x1542ef0)\n" + " (declare (in ) vec3 x@0x26ec9b0)\n" + " (declare (in ) vec3 y@0x26ecac0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x15430d0)\n" - " (declare (in ) vec4 y@0x15431e0)\n" + " (declare (in ) vec4 x@0x26ecca0)\n" + " (declare (in ) vec4 y@0x26ecdb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x15433c0)\n" - " (declare (in ) ivec2 y@0x15434d0)\n" + " (declare (in ) ivec2 x@0x26ecf90)\n" + " (declare (in ) ivec2 y@0x26ed0a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x15436b0)\n" - " (declare (in ) ivec3 y@0x15437c0)\n" + " (declare (in ) ivec3 x@0x26ed280)\n" + " (declare (in ) ivec3 y@0x26ed390)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x15439a0)\n" - " (declare (in ) ivec4 y@0x1543ab0)\n" + " (declare (in ) ivec4 x@0x26ed570)\n" + " (declare (in ) ivec4 y@0x26ed680)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0x1543c90)\n" - " (declare (in ) bvec2 y@0x1543da0)\n" + " (declare (in ) bvec2 x@0x26ed860)\n" + " (declare (in ) bvec2 y@0x26ed970)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0x1543f80)\n" - " (declare (in ) bvec3 y@0x1544090)\n" + " (declare (in ) bvec3 x@0x26edb50)\n" + " (declare (in ) bvec3 y@0x26edc60)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0x1544270)\n" - " (declare (in ) bvec4 y@0x1544380)\n" + " (declare (in ) bvec4 x@0x26ede40)\n" + " (declare (in ) bvec4 y@0x26edf50)\n" " )\n" " (\n" " ))\n" @@ -11239,72 +11239,72 @@ static const char *prototypes_for_110_frag = "(function notEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1544560)\n" - " (declare (in ) vec2 y@0x1544670)\n" + " (declare (in ) vec2 x@0x26ee130)\n" + " (declare (in ) vec2 y@0x26ee240)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1544a30)\n" - " (declare (in ) vec3 y@0x1544b40)\n" + " (declare (in ) vec3 x@0x26ee5d0)\n" + " (declare (in ) vec3 y@0x26ee6e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x1544d20)\n" - " (declare (in ) vec4 y@0x1544e30)\n" + " (declare (in ) vec4 x@0x26ee8c0)\n" + " (declare (in ) vec4 y@0x26ee9d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x1545010)\n" - " (declare (in ) ivec2 y@0x1545120)\n" + " (declare (in ) ivec2 x@0x26eebb0)\n" + " (declare (in ) ivec2 y@0x26eecc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x1545300)\n" - " (declare (in ) ivec3 y@0x1545410)\n" + " (declare (in ) ivec3 x@0x26eeea0)\n" + " (declare (in ) ivec3 y@0x26eefb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x15455f0)\n" - " (declare (in ) ivec4 y@0x1545700)\n" + " (declare (in ) ivec4 x@0x26ef190)\n" + " (declare (in ) ivec4 y@0x26ef2a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0x15458e0)\n" - " (declare (in ) bvec2 y@0x15459f0)\n" + " (declare (in ) bvec2 x@0x26ef480)\n" + " (declare (in ) bvec2 y@0x26ef590)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0x1545bd0)\n" - " (declare (in ) bvec3 y@0x1545ce0)\n" + " (declare (in ) bvec3 x@0x26ef770)\n" + " (declare (in ) bvec3 y@0x26ef880)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0x1545ec0)\n" - " (declare (in ) bvec4 y@0x1545fd0)\n" + " (declare (in ) bvec4 x@0x26efa60)\n" + " (declare (in ) bvec4 y@0x26efb70)\n" " )\n" " (\n" " ))\n" @@ -11314,21 +11314,21 @@ static const char *prototypes_for_110_frag = "(function any\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec2 x@0x15461b0)\n" + " (declare (in ) bvec2 x@0x26efd50)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec3 x@0x1546560)\n" + " (declare (in ) bvec3 x@0x26f00d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec4 x@0x1546740)\n" + " (declare (in ) bvec4 x@0x26f02b0)\n" " )\n" " (\n" " ))\n" @@ -11338,21 +11338,21 @@ static const char *prototypes_for_110_frag = "(function all\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec2 x@0x1546920)\n" + " (declare (in ) bvec2 x@0x26f0490)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec3 x@0x1546cd0)\n" + " (declare (in ) bvec3 x@0x26f0810)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec4 x@0x1546eb0)\n" + " (declare (in ) bvec4 x@0x26f09f0)\n" " )\n" " (\n" " ))\n" @@ -11362,21 +11362,21 @@ static const char *prototypes_for_110_frag = "(function not\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0x1547090)\n" + " (declare (in ) bvec2 x@0x26f0bd0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0x1547440)\n" + " (declare (in ) bvec3 x@0x26f0f50)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0x1547620)\n" + " (declare (in ) bvec4 x@0x26f1130)\n" " )\n" " (\n" " ))\n" @@ -11386,17 +11386,17 @@ static const char *prototypes_for_110_frag = "(function texture1D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x1547800)\n" - " (declare (in ) float coord@0x1547920)\n" + " (declare (in ) sampler1D sampler@0x26f1310)\n" + " (declare (in ) float coord@0x26f1420)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x15484c0)\n" - " (declare (in ) float coord@0x15485e0)\n" - " (declare (in ) float bias@0x15486f0)\n" + " (declare (in ) sampler1D sampler@0x26f1f40)\n" + " (declare (in ) float coord@0x26f2050)\n" + " (declare (in ) float bias@0x26f2160)\n" " )\n" " (\n" " ))\n" @@ -11406,34 +11406,34 @@ static const char *prototypes_for_110_frag = "(function texture1DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x1547ce0)\n" - " (declare (in ) vec2 coord@0x1547e00)\n" + " (declare (in ) sampler1D sampler@0x26f17b0)\n" + " (declare (in ) vec2 coord@0x26f18c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x15481c0)\n" - " (declare (in ) vec4 coord@0x15482e0)\n" + " (declare (in ) sampler1D sampler@0x26f1c50)\n" + " (declare (in ) vec4 coord@0x26f1d60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x15488d0)\n" - " (declare (in ) vec2 coord@0x15489f0)\n" - " (declare (in ) float bias@0x1548b00)\n" + " (declare (in ) sampler1D sampler@0x26f2340)\n" + " (declare (in ) vec2 coord@0x26f2450)\n" + " (declare (in ) float bias@0x26f2560)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x1548ce0)\n" - " (declare (in ) vec4 coord@0x1548e00)\n" - " (declare (in ) float bias@0x1548f10)\n" + " (declare (in ) sampler1D sampler@0x26f2740)\n" + " (declare (in ) vec4 coord@0x26f2850)\n" + " (declare (in ) float bias@0x26f2960)\n" " )\n" " (\n" " ))\n" @@ -11443,17 +11443,17 @@ static const char *prototypes_for_110_frag = "(function texture2D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x15490f0)\n" - " (declare (in ) vec2 coord@0x1549210)\n" + " (declare (in ) sampler2D sampler@0x26f2b40)\n" + " (declare (in ) vec2 coord@0x26f2c50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x1549db0)\n" - " (declare (in ) vec2 coord@0x1549ed0)\n" - " (declare (in ) float bias@0x1549fe0)\n" + " (declare (in ) sampler2D sampler@0x26f3770)\n" + " (declare (in ) vec2 coord@0x26f3880)\n" + " (declare (in ) float bias@0x26f3990)\n" " )\n" " (\n" " ))\n" @@ -11463,34 +11463,34 @@ static const char *prototypes_for_110_frag = "(function texture2DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x15495d0)\n" - " (declare (in ) vec3 coord@0x15496f0)\n" + " (declare (in ) sampler2D sampler@0x26f2fe0)\n" + " (declare (in ) vec3 coord@0x26f30f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x1549ab0)\n" - " (declare (in ) vec4 coord@0x1549bd0)\n" + " (declare (in ) sampler2D sampler@0x26f3480)\n" + " (declare (in ) vec4 coord@0x26f3590)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x154a1c0)\n" - " (declare (in ) vec3 coord@0x154a2e0)\n" - " (declare (in ) float bias@0x154a3f0)\n" + " (declare (in ) sampler2D sampler@0x26f3b70)\n" + " (declare (in ) vec3 coord@0x26f3c80)\n" + " (declare (in ) float bias@0x26f3d90)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x154a5d0)\n" - " (declare (in ) vec4 coord@0x154a6f0)\n" - " (declare (in ) float bias@0x154a800)\n" + " (declare (in ) sampler2D sampler@0x26f3f70)\n" + " (declare (in ) vec4 coord@0x26f4080)\n" + " (declare (in ) float bias@0x26f4190)\n" " )\n" " (\n" " ))\n" @@ -11500,17 +11500,17 @@ static const char *prototypes_for_110_frag = "(function texture3D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x154a9e0)\n" - " (declare (in ) vec3 coord@0x154ab00)\n" + " (declare (in ) sampler3D sampler@0x26f4370)\n" + " (declare (in ) vec3 coord@0x26f4480)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x154b3a0)\n" - " (declare (in ) vec3 coord@0x154b4c0)\n" - " (declare (in ) float bias@0x154b5d0)\n" + " (declare (in ) sampler3D sampler@0x26f4cb0)\n" + " (declare (in ) vec3 coord@0x26f4dc0)\n" + " (declare (in ) float bias@0x26f4ed0)\n" " )\n" " (\n" " ))\n" @@ -11520,17 +11520,17 @@ static const char *prototypes_for_110_frag = "(function texture3DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x154aec0)\n" - " (declare (in ) vec4 coord@0x154afe0)\n" + " (declare (in ) sampler3D sampler@0x26f4810)\n" + " (declare (in ) vec4 coord@0x26f4920)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x154b7b0)\n" - " (declare (in ) vec4 coord@0x154b8d0)\n" - " (declare (in ) float bias@0x154b9e0)\n" + " (declare (in ) sampler3D sampler@0x26f50b0)\n" + " (declare (in ) vec4 coord@0x26f51c0)\n" + " (declare (in ) float bias@0x26f52d0)\n" " )\n" " (\n" " ))\n" @@ -11540,17 +11540,17 @@ static const char *prototypes_for_110_frag = "(function textureCube\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) samplerCube sampler@0x154bbc0)\n" - " (declare (in ) vec3 coord@0x154bce0)\n" + " (declare (in ) samplerCube sampler@0x26f54b0)\n" + " (declare (in ) vec3 coord@0x26f55c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) samplerCube sampler@0x154c0a0)\n" - " (declare (in ) vec3 coord@0x154c1c0)\n" - " (declare (in ) float bias@0x154c2d0)\n" + " (declare (in ) samplerCube sampler@0x26f5950)\n" + " (declare (in ) vec3 coord@0x26f5a60)\n" + " (declare (in ) float bias@0x26f5b70)\n" " )\n" " (\n" " ))\n" @@ -11560,17 +11560,17 @@ static const char *prototypes_for_110_frag = "(function shadow1D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x154c4b0)\n" - " (declare (in ) vec3 coord@0x154c5d0)\n" + " (declare (in ) sampler1DShadow sampler@0x26f5d50)\n" + " (declare (in ) vec3 coord@0x26f5e60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x154d830)\n" - " (declare (in ) vec3 coord@0x154d950)\n" - " (declare (in ) float bias@0x154da60)\n" + " (declare (in ) sampler1DShadow sampler@0x26f6fd0)\n" + " (declare (in ) vec3 coord@0x26f70e0)\n" + " (declare (in ) float bias@0x26f71f0)\n" " )\n" " (\n" " ))\n" @@ -11580,17 +11580,17 @@ static const char *prototypes_for_110_frag = "(function shadow2D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x154c990)\n" - " (declare (in ) vec3 coord@0x154cab0)\n" + " (declare (in ) sampler2DShadow sampler@0x26f61f0)\n" + " (declare (in ) vec3 coord@0x26f6300)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x154dc40)\n" - " (declare (in ) vec3 coord@0x154dd60)\n" - " (declare (in ) float bias@0x154de70)\n" + " (declare (in ) sampler2DShadow sampler@0x26f73d0)\n" + " (declare (in ) vec3 coord@0x26f74e0)\n" + " (declare (in ) float bias@0x26f75f0)\n" " )\n" " (\n" " ))\n" @@ -11600,17 +11600,17 @@ static const char *prototypes_for_110_frag = "(function shadow1DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x154ce70)\n" - " (declare (in ) vec4 coord@0x154cf90)\n" + " (declare (in ) sampler1DShadow sampler@0x26f6690)\n" + " (declare (in ) vec4 coord@0x26f67a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x154e050)\n" - " (declare (in ) vec4 coord@0x154e170)\n" - " (declare (in ) float bias@0x154e280)\n" + " (declare (in ) sampler1DShadow sampler@0x26f77d0)\n" + " (declare (in ) vec4 coord@0x26f78e0)\n" + " (declare (in ) float bias@0x26f79f0)\n" " )\n" " (\n" " ))\n" @@ -11620,17 +11620,17 @@ static const char *prototypes_for_110_frag = "(function shadow2DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x154d350)\n" - " (declare (in ) vec4 coord@0x154d470)\n" + " (declare (in ) sampler2DShadow sampler@0x26f6b30)\n" + " (declare (in ) vec4 coord@0x26f6c40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x154e460)\n" - " (declare (in ) vec4 coord@0x154e580)\n" - " (declare (in ) float bias@0x154e690)\n" + " (declare (in ) sampler2DShadow sampler@0x26f7bd0)\n" + " (declare (in ) vec4 coord@0x26f7ce0)\n" + " (declare (in ) float bias@0x26f7df0)\n" " )\n" " (\n" " ))\n" @@ -11640,28 +11640,28 @@ static const char *prototypes_for_110_frag = "(function dFdx\n" " (signature float\n" " (parameters\n" - " (declare (in ) float p@0x154e870)\n" + " (declare (in ) float p@0x26f7fd0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 p@0x154ec20)\n" + " (declare (in ) vec2 p@0x26f8350)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 p@0x154ee00)\n" + " (declare (in ) vec3 p@0x26f8530)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 p@0x154efe0)\n" + " (declare (in ) vec4 p@0x26f8710)\n" " )\n" " (\n" " ))\n" @@ -11671,28 +11671,28 @@ static const char *prototypes_for_110_frag = "(function dFdy\n" " (signature float\n" " (parameters\n" - " (declare (in ) float p@0x154f1c0)\n" + " (declare (in ) float p@0x26f88f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 p@0x154f570)\n" + " (declare (in ) vec2 p@0x26f8c70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 p@0x154f750)\n" + " (declare (in ) vec3 p@0x26f8e50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 p@0x154f930)\n" + " (declare (in ) vec4 p@0x26f9030)\n" " )\n" " (\n" " ))\n" @@ -11702,28 +11702,28 @@ static const char *prototypes_for_110_frag = "(function fwidth\n" " (signature float\n" " (parameters\n" - " (declare (in ) float p@0x154fb10)\n" + " (declare (in ) float p@0x26f9210)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 p@0x154fec0)\n" + " (declare (in ) vec2 p@0x26f9590)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 p@0x15500a0)\n" + " (declare (in ) vec3 p@0x26f9770)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 p@0x1550280)\n" + " (declare (in ) vec4 p@0x26f9950)\n" " )\n" " (\n" " ))\n" @@ -11733,28 +11733,28 @@ static const char *prototypes_for_110_frag = "(function noise1\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x1550460)\n" + " (declare (in ) float x@0x26f9b30)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x1550810)\n" + " (declare (in ) vec2 x@0x26f9eb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x15509f0)\n" + " (declare (in ) vec3 x@0x26fa090)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x1550bd0)\n" + " (declare (in ) vec4 x@0x26fa270)\n" " )\n" " (\n" " ))\n" @@ -11764,28 +11764,28 @@ static const char *prototypes_for_110_frag = "(function noise2\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float x@0x1550db0)\n" + " (declare (in ) float x@0x26fa450)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x1551160)\n" + " (declare (in ) vec2 x@0x26fa7d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec3 x@0x1551340)\n" + " (declare (in ) vec3 x@0x26fa9b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec4 x@0x1551520)\n" + " (declare (in ) vec4 x@0x26fab90)\n" " )\n" " (\n" " ))\n" @@ -11795,28 +11795,28 @@ static const char *prototypes_for_110_frag = "(function noise3\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float x@0x1551700)\n" + " (declare (in ) float x@0x26fad70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec2 x@0x1551ab0)\n" + " (declare (in ) vec2 x@0x26fb0f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x1551c90)\n" + " (declare (in ) vec3 x@0x26fb2d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec4 x@0x1551e70)\n" + " (declare (in ) vec4 x@0x26fb4b0)\n" " )\n" " (\n" " ))\n" @@ -11826,28 +11826,28 @@ static const char *prototypes_for_110_frag = "(function noise4\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float x@0x1552050)\n" + " (declare (in ) float x@0x26fb690)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec2 x@0x1552400)\n" + " (declare (in ) vec2 x@0x26fba10)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec3 x@0x15525e0)\n" + " (declare (in ) vec3 x@0x26fbbf0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x15527c0)\n" + " (declare (in ) vec4 x@0x26fbdd0)\n" " )\n" " (\n" " ))\n" @@ -11927,8 +11927,8 @@ static const char *prototypes_for_EXT_texture_array_vert = "(function texture1DArray\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArray sampler@0x25ee5c0)\n" - " (declare (in ) vec2 coord@0x25ee6e0)\n" + " (declare (in ) sampler1DArray sampler@0x2378290)\n" + " (declare (in ) vec2 coord@0x23783a0)\n" " )\n" " (\n" " ))\n" @@ -11938,9 +11938,9 @@ static const char *prototypes_for_EXT_texture_array_vert = "(function texture1DArrayLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArray sampler@0x25eeaa0)\n" - " (declare (in ) vec2 coord@0x25eebc0)\n" - " (declare (in ) float lod@0x25eecd0)\n" + " (declare (in ) sampler1DArray sampler@0x2378730)\n" + " (declare (in ) vec2 coord@0x2378840)\n" + " (declare (in ) float lod@0x2378950)\n" " )\n" " (\n" " ))\n" @@ -11950,8 +11950,8 @@ static const char *prototypes_for_EXT_texture_array_vert = "(function texture2DArray\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArray sampler@0x25ef090)\n" - " (declare (in ) vec2 coord@0x25ef1b0)\n" + " (declare (in ) sampler1DArray sampler@0x2378ce0)\n" + " (declare (in ) vec2 coord@0x2378df0)\n" " )\n" " (\n" " ))\n" @@ -11961,9 +11961,9 @@ static const char *prototypes_for_EXT_texture_array_vert = "(function texture2DArrayLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArray sampler@0x25ef570)\n" - " (declare (in ) vec2 coord@0x25ef690)\n" - " (declare (in ) float lod@0x25ef7a0)\n" + " (declare (in ) sampler1DArray sampler@0x2379180)\n" + " (declare (in ) vec2 coord@0x2379290)\n" + " (declare (in ) float lod@0x23793a0)\n" " )\n" " (\n" " ))\n" @@ -11973,8 +11973,8 @@ static const char *prototypes_for_EXT_texture_array_vert = "(function shadow1DArray\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArrayShadow sampler@0x25efb60)\n" - " (declare (in ) vec3 coord@0x25efc80)\n" + " (declare (in ) sampler1DArrayShadow sampler@0x2379730)\n" + " (declare (in ) vec3 coord@0x2379840)\n" " )\n" " (\n" " ))\n" @@ -11984,9 +11984,9 @@ static const char *prototypes_for_EXT_texture_array_vert = "(function shadow1DArrayLod\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DArrayShadow sampler@0x25f0040)\n" - " (declare (in ) vec3 coord@0x25f0160)\n" - " (declare (in ) float lod@0x25f0270)\n" + " (declare (in ) sampler1DArrayShadow sampler@0x2379bd0)\n" + " (declare (in ) vec3 coord@0x2379ce0)\n" + " (declare (in ) float lod@0x2379df0)\n" " )\n" " (\n" " ))\n" @@ -11996,8 +11996,8 @@ static const char *prototypes_for_EXT_texture_array_vert = "(function shadow2DArray\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DArrayShadow sampler@0x25f0630)\n" - " (declare (in ) vec4 coord@0x25f0750)\n" + " (declare (in ) sampler2DArrayShadow sampler@0x237a180)\n" + " (declare (in ) vec4 coord@0x237a290)\n" " )\n" " (\n" " ))\n" @@ -12016,54 +12016,9527 @@ static const char *functions_for_EXT_texture_array_vert [] = { builtin_texture2DArray, builtin_texture1DArray, }; -static const char *prototypes_for_ARB_texture_rectangle_vert = +static const char *prototypes_for_130_frag = "(\n" - "(function texture2DRect\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float degrees@0x141d070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 degrees@0x141d3f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 degrees@0x141d5d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 degrees@0x141d7b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float radians@0x141d990)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 radians@0x141dd10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 radians@0x141def0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 radians@0x141e0d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x141e2b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x141e630)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x141e810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x141e9f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x141ebd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x141ef50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x141f130)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x141f310)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x141f4f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x141f870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x141fa50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x141fc30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x141fe10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x1420190)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x1420370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x1420550)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x1420730)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x1420ab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x1420c90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x1420e70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y@0x1421050)\n" + " (declare (in ) float x@0x1421160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y@0x14214e0)\n" + " (declare (in ) vec2 x@0x14215f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y@0x14217d0)\n" + " (declare (in ) vec3 x@0x14218e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y@0x1421ac0)\n" + " (declare (in ) vec4 x@0x1421bd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y_over_x@0x1421db0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y_over_x@0x1421fa0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y_over_x@0x1422190)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y_over_x@0x1422380)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1422570)\n" + " (declare (in ) float y@0x1422680)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1422a00)\n" + " (declare (in ) vec2 y@0x1422b10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1422cf0)\n" + " (declare (in ) vec3 y@0x1422e00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1422fe0)\n" + " (declare (in ) vec4 y@0x14230f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x14232d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1423650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1423830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1423a10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1423bf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1423f70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1424150)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1424330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1424510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1424890)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1424a70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1424c50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1424e30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x14251b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1425390)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1425570)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1425750)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1425ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1425cb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1425e90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1426070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1426400)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x14265e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x14267c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x14269a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1426d20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1426f00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x14270e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in ) int x@0x14272c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x14274a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x1427680)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x1427860)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1427a40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1427dc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1427fa0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1428180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in ) int x@0x1428360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x1428540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x1428720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x1428900)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1428ae0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1428e60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1429040)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1429220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1429400)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1429780)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1429960)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1429b40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1429d20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x142a0a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x142a280)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x142a460)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x142a640)\n" + " (declare (in ) float y@0x142a750)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x142aad0)\n" + " (declare (in ) float y@0x142abe0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x142adc0)\n" + " (declare (in ) float y@0x142aed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x142b0b0)\n" + " (declare (in ) float y@0x142b1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x142b3a0)\n" + " (declare (in ) vec2 y@0x142b4b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x142b690)\n" + " (declare (in ) vec3 y@0x142b7a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x142b980)\n" + " (declare (in ) vec4 y@0x142ba90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x142bc70)\n" + " (declare (in ) float y@0x142bd80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x142c100)\n" + " (declare (in ) vec2 y@0x142c210)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x142c3f0)\n" + " (declare (in ) vec3 y@0x142c500)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x142c6e0)\n" + " (declare (in ) vec4 y@0x142c7f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x142c9d0)\n" + " (declare (in ) float y@0x142cae0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x142ccc0)\n" + " (declare (in ) float y@0x142cdd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x142cfb0)\n" + " (declare (in ) float y@0x142d0c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in ) int x@0x142d2a0)\n" + " (declare (in ) int y@0x142d3b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x142d590)\n" + " (declare (in ) ivec2 y@0x142d6a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x142d880)\n" + " (declare (in ) ivec3 y@0x142d990)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x142db70)\n" + " (declare (in ) ivec4 y@0x142dc80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x142de60)\n" + " (declare (in ) int y@0x142df70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x142e150)\n" + " (declare (in ) int y@0x142e260)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x142e440)\n" + " (declare (in ) int y@0x142e550)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in ) uint x@0x142e730)\n" + " (declare (in ) uint y@0x142e840)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x142ea20)\n" + " (declare (in ) uvec2 y@0x142eb30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x142ed10)\n" + " (declare (in ) uvec3 y@0x142ee20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x142f000)\n" + " (declare (in ) uvec4 y@0x142f110)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x142f2f0)\n" + " (declare (in ) uint y@0x142f400)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x142f5e0)\n" + " (declare (in ) uint y@0x142f6f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x142f8d0)\n" + " (declare (in ) uint y@0x142f9e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x142fbc0)\n" + " (declare (in ) float y@0x142fcd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1430050)\n" + " (declare (in ) vec2 y@0x1430160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1430340)\n" + " (declare (in ) vec3 y@0x1430450)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1430630)\n" + " (declare (in ) vec4 y@0x1430740)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1430920)\n" + " (declare (in ) float y@0x1430a30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1430c10)\n" + " (declare (in ) float y@0x1430d20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1430f00)\n" + " (declare (in ) float y@0x1431010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in ) int x@0x14311f0)\n" + " (declare (in ) int y@0x1431300)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x14314e0)\n" + " (declare (in ) ivec2 y@0x14315f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x14317d0)\n" + " (declare (in ) ivec3 y@0x14318e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x1431ac0)\n" + " (declare (in ) ivec4 y@0x1431bd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x1431db0)\n" + " (declare (in ) int y@0x1431ec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x14320a0)\n" + " (declare (in ) int y@0x14321b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x1432390)\n" + " (declare (in ) int y@0x14324a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in ) uint x@0x1432680)\n" + " (declare (in ) uint y@0x1432790)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x1432970)\n" + " (declare (in ) uvec2 y@0x1432a80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x1432c60)\n" + " (declare (in ) uvec3 y@0x1432d70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x1432f50)\n" + " (declare (in ) uvec4 y@0x1433060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x1433240)\n" + " (declare (in ) uint y@0x1433350)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x1433530)\n" + " (declare (in ) uint y@0x1433640)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x1433820)\n" + " (declare (in ) uint y@0x1433930)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1433b10)\n" + " (declare (in ) float minVal@0x1433c20)\n" + " (declare (in ) float maxVal@0x1433d30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x14340b0)\n" + " (declare (in ) vec2 minVal@0x14341c0)\n" + " (declare (in ) vec2 maxVal@0x14342d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x14344b0)\n" + " (declare (in ) vec3 minVal@0x14345c0)\n" + " (declare (in ) vec3 maxVal@0x14346d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x14348b0)\n" + " (declare (in ) vec4 minVal@0x14349c0)\n" + " (declare (in ) vec4 maxVal@0x1434ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1434cb0)\n" + " (declare (in ) float minVal@0x1434dc0)\n" + " (declare (in ) float maxVal@0x1434ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x14350b0)\n" + " (declare (in ) float minVal@0x14351c0)\n" + " (declare (in ) float maxVal@0x14352d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x14354b0)\n" + " (declare (in ) float minVal@0x14355c0)\n" + " (declare (in ) float maxVal@0x14356d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in ) int x@0x14358b0)\n" + " (declare (in ) int minVal@0x14359c0)\n" + " (declare (in ) int maxVal@0x1435ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x1435cb0)\n" + " (declare (in ) ivec2 minVal@0x1435dc0)\n" + " (declare (in ) ivec2 maxVal@0x1435ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x14360b0)\n" + " (declare (in ) ivec3 minVal@0x14361c0)\n" + " (declare (in ) ivec3 maxVal@0x14362d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x14364b0)\n" + " (declare (in ) ivec4 minVal@0x14365c0)\n" + " (declare (in ) ivec4 maxVal@0x14366d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x14368b0)\n" + " (declare (in ) int minVal@0x14369c0)\n" + " (declare (in ) int maxVal@0x1436ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x1436cb0)\n" + " (declare (in ) int minVal@0x1436dc0)\n" + " (declare (in ) int maxVal@0x1436ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x14370b0)\n" + " (declare (in ) int minVal@0x14371c0)\n" + " (declare (in ) int maxVal@0x14372d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in ) uint x@0x14374b0)\n" + " (declare (in ) uint minVal@0x14375c0)\n" + " (declare (in ) uint maxVal@0x14376d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x14378b0)\n" + " (declare (in ) uvec2 minVal@0x14379c0)\n" + " (declare (in ) uvec2 maxVal@0x1437ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x1437cb0)\n" + " (declare (in ) uvec3 minVal@0x1437dc0)\n" + " (declare (in ) uvec3 maxVal@0x1437ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x14380b0)\n" + " (declare (in ) uvec4 minVal@0x14381c0)\n" + " (declare (in ) uvec4 maxVal@0x14382d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x14384b0)\n" + " (declare (in ) uint minVal@0x14385c0)\n" + " (declare (in ) uint maxVal@0x14386d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x14388b0)\n" + " (declare (in ) uint minVal@0x14389c0)\n" + " (declare (in ) uint maxVal@0x1438ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x1438cb0)\n" + " (declare (in ) uint minVal@0x1438dc0)\n" + " (declare (in ) uint maxVal@0x1438ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x14390b0)\n" + " (declare (in ) float y@0x14391c0)\n" + " (declare (in ) float a@0x14392d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1439650)\n" + " (declare (in ) vec2 y@0x1439760)\n" + " (declare (in ) vec2 a@0x1439870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1439a50)\n" + " (declare (in ) vec3 y@0x1439b60)\n" + " (declare (in ) vec3 a@0x1439c70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1439e50)\n" + " (declare (in ) vec4 y@0x1439f60)\n" + " (declare (in ) vec4 a@0x143a070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x143a250)\n" + " (declare (in ) vec2 y@0x143a360)\n" + " (declare (in ) float a@0x143a470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x143a650)\n" + " (declare (in ) vec3 y@0x143a760)\n" + " (declare (in ) float a@0x143a870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x143aa50)\n" + " (declare (in ) vec4 y@0x143ab60)\n" + " (declare (in ) float a@0x143ac70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge@0x143ae50)\n" + " (declare (in ) float x@0x143af60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge@0x143b2e0)\n" + " (declare (in ) vec2 x@0x143b3f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge@0x143b5d0)\n" + " (declare (in ) vec3 x@0x143b6e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge@0x143b8c0)\n" + " (declare (in ) vec4 x@0x143b9d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge@0x143bbb0)\n" + " (declare (in ) vec2 x@0x143bcc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge@0x143bea0)\n" + " (declare (in ) vec3 x@0x143bfb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge@0x143c190)\n" + " (declare (in ) vec4 x@0x143c2a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge0@0x143c480)\n" + " (declare (in ) float edge1@0x143c590)\n" + " (declare (in ) float x@0x143c6a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge0@0x143ca30)\n" + " (declare (in ) vec2 edge1@0x143cb40)\n" + " (declare (in ) vec2 x@0x143cc50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge0@0x143ce30)\n" + " (declare (in ) vec3 edge1@0x143cf40)\n" + " (declare (in ) vec3 x@0x143d050)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge0@0x143d230)\n" + " (declare (in ) vec4 edge1@0x143d340)\n" + " (declare (in ) vec4 x@0x143d450)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge0@0x143d630)\n" + " (declare (in ) float edge1@0x143d740)\n" + " (declare (in ) vec2 x@0x143d850)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge0@0x143da30)\n" + " (declare (in ) float edge1@0x143db40)\n" + " (declare (in ) vec3 x@0x143dc50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge0@0x143de30)\n" + " (declare (in ) float edge1@0x143df40)\n" + " (declare (in ) vec4 x@0x143e050)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x143e230)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x143e5b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x143e790)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x143e970)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p0@0x143eb50)\n" + " (declare (in ) float p1@0x143ec60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 p0@0x143eff0)\n" + " (declare (in ) vec2 p1@0x143f100)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 p0@0x143f2e0)\n" + " (declare (in ) vec3 p1@0x143f3f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 p0@0x143f5d0)\n" + " (declare (in ) vec4 p1@0x143f6e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x143f8c0)\n" + " (declare (in ) float y@0x143f9d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x143fd50)\n" + " (declare (in ) vec2 y@0x143fe60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1440040)\n" + " (declare (in ) vec3 y@0x1440150)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1440330)\n" + " (declare (in ) vec4 y@0x1440440)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1440620)\n" + " (declare (in ) vec3 y@0x1440730)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1440ab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1440e40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1441020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1441200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float N@0x14413e0)\n" + " (declare (in ) float I@0x14414f0)\n" + " (declare (in ) float Nref@0x1441600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 N@0x1441990)\n" + " (declare (in ) vec2 I@0x1441aa0)\n" + " (declare (in ) vec2 Nref@0x1441bb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 N@0x1441d90)\n" + " (declare (in ) vec3 I@0x1441ea0)\n" + " (declare (in ) vec3 Nref@0x1441fb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 N@0x1442190)\n" + " (declare (in ) vec4 I@0x14422a0)\n" + " (declare (in ) vec4 Nref@0x14423b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0x1442590)\n" + " (declare (in ) float N@0x14426a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0x1442a20)\n" + " (declare (in ) vec2 N@0x1442b30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0x1442d10)\n" + " (declare (in ) vec3 N@0x1442e20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0x1443000)\n" + " (declare (in ) vec4 N@0x1443110)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0x14432f0)\n" + " (declare (in ) float N@0x1443400)\n" + " (declare (in ) float eta@0x1443510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0x1443890)\n" + " (declare (in ) vec2 N@0x14439a0)\n" + " (declare (in ) float eta@0x1443ab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0x1443c90)\n" + " (declare (in ) vec3 N@0x1443da0)\n" + " (declare (in ) float eta@0x1443eb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0x1444090)\n" + " (declare (in ) vec4 N@0x14441a0)\n" + " (declare (in ) float eta@0x14442b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) mat2 x@0x1444490)\n" + " (declare (in ) mat2 y@0x14445a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) mat3 x@0x1444930)\n" + " (declare (in ) mat3 y@0x1444a40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) mat4 x@0x1444c20)\n" + " (declare (in ) mat4 y@0x1444d30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) mat2x3 x@0x1444f10)\n" + " (declare (in ) mat2x3 y@0x1445020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) mat2x4 x@0x1445200)\n" + " (declare (in ) mat2x4 y@0x1445310)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) mat3x2 x@0x14454f0)\n" + " (declare (in ) mat3x2 y@0x1445600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) mat3x4 x@0x14457e0)\n" + " (declare (in ) mat3x4 y@0x14458f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) mat4x2 x@0x1445ad0)\n" + " (declare (in ) mat4x2 y@0x1445be0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) mat4x3 x@0x1445dc0)\n" + " (declare (in ) mat4x3 y@0x1445ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function outerProduct\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x14460b0)\n" + " (declare (in ) vec2 r@0x14461c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x1446550)\n" + " (declare (in ) vec3 r@0x1446660)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x1446840)\n" + " (declare (in ) vec4 r@0x1446950)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x1446b30)\n" + " (declare (in ) vec2 r@0x1446c40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x1446e20)\n" + " (declare (in ) vec3 r@0x1446f30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x1447110)\n" + " (declare (in ) vec2 r@0x1447220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x1447400)\n" + " (declare (in ) vec4 r@0x1447510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x14476f0)\n" + " (declare (in ) vec3 r@0x1447800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x14479e0)\n" + " (declare (in ) vec4 r@0x1447af0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function transpose\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) mat2 m@0x1447cd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) mat3 m@0x1448060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) mat4 m@0x1448240)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) mat3x2 m@0x1448420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) mat2x3 m@0x1448600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) mat4x2 m@0x14487e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) mat2x4 m@0x14489c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) mat4x3 m@0x1448ba0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) mat3x4 m@0x1448d80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1448f60)\n" + " (declare (in ) vec2 y@0x1449070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1449400)\n" + " (declare (in ) vec3 y@0x1449510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x14496f0)\n" + " (declare (in ) vec4 y@0x1449800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x14499e0)\n" + " (declare (in ) ivec2 y@0x1449af0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x1449cd0)\n" + " (declare (in ) ivec3 y@0x1449de0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x1449fc0)\n" + " (declare (in ) ivec4 y@0x144a0d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x144a2b0)\n" + " (declare (in ) uvec2 y@0x144a3c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x144a5a0)\n" + " (declare (in ) uvec3 y@0x144a6b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x144a890)\n" + " (declare (in ) uvec4 y@0x144a9a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x144ab80)\n" + " (declare (in ) vec2 y@0x144ac90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x144b020)\n" + " (declare (in ) vec3 y@0x144b130)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x144b310)\n" + " (declare (in ) vec4 y@0x144b420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x144b600)\n" + " (declare (in ) ivec2 y@0x144b710)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x144b8f0)\n" + " (declare (in ) ivec3 y@0x144ba00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x144bbe0)\n" + " (declare (in ) ivec4 y@0x144bcf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x144bed0)\n" + " (declare (in ) uvec2 y@0x144bfe0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x144c1c0)\n" + " (declare (in ) uvec3 y@0x144c2d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x144c4b0)\n" + " (declare (in ) uvec4 y@0x144c5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x144c7a0)\n" + " (declare (in ) vec2 y@0x144c8b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x144cc40)\n" + " (declare (in ) vec3 y@0x144cd50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x144cf30)\n" + " (declare (in ) vec4 y@0x144d040)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x144d220)\n" + " (declare (in ) ivec2 y@0x144d330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x144d510)\n" + " (declare (in ) ivec3 y@0x144d620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x144d800)\n" + " (declare (in ) ivec4 y@0x144d910)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x144daf0)\n" + " (declare (in ) uvec2 y@0x144dc00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x144dde0)\n" + " (declare (in ) uvec3 y@0x144def0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x144e0d0)\n" + " (declare (in ) uvec4 y@0x144e1e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x144e3c0)\n" + " (declare (in ) vec2 y@0x144e4d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x144e860)\n" + " (declare (in ) vec3 y@0x144e970)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x144eb50)\n" + " (declare (in ) vec4 y@0x144ec60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x144ee40)\n" + " (declare (in ) ivec2 y@0x144ef50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x144f130)\n" + " (declare (in ) ivec3 y@0x144f240)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x144f420)\n" + " (declare (in ) ivec4 y@0x144f530)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x144f710)\n" + " (declare (in ) uvec2 y@0x144f820)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x144fa00)\n" + " (declare (in ) uvec3 y@0x144fb10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x144fcf0)\n" + " (declare (in ) uvec4 y@0x144fe00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x144ffe0)\n" + " (declare (in ) vec2 y@0x14500f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1450470)\n" + " (declare (in ) vec3 y@0x1450580)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1450760)\n" + " (declare (in ) vec4 y@0x1450870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x1450a50)\n" + " (declare (in ) ivec2 y@0x1450b60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x1450d40)\n" + " (declare (in ) ivec3 y@0x1450e50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x1451030)\n" + " (declare (in ) ivec4 y@0x1451140)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x1451320)\n" + " (declare (in ) uvec2 y@0x1451430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x1451610)\n" + " (declare (in ) uvec3 y@0x1451720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x1451900)\n" + " (declare (in ) uvec4 y@0x1451a10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x1451bf0)\n" + " (declare (in ) bvec2 y@0x1451d00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x1451ee0)\n" + " (declare (in ) bvec3 y@0x1451ff0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x14521d0)\n" + " (declare (in ) bvec4 y@0x14522e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x14524c0)\n" + " (declare (in ) vec2 y@0x14525d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1452960)\n" + " (declare (in ) vec3 y@0x1452a70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1452c50)\n" + " (declare (in ) vec4 y@0x1452d60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x1452f40)\n" + " (declare (in ) ivec2 y@0x1453050)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x1453230)\n" + " (declare (in ) ivec3 y@0x1453340)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x1453520)\n" + " (declare (in ) ivec4 y@0x1453630)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x1453810)\n" + " (declare (in ) uvec2 y@0x1453920)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x1453b00)\n" + " (declare (in ) uvec3 y@0x1453c10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x1453df0)\n" + " (declare (in ) uvec4 y@0x1453f00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x14540e0)\n" + " (declare (in ) bvec2 y@0x14541f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x14543d0)\n" + " (declare (in ) bvec3 y@0x14544e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x14546c0)\n" + " (declare (in ) bvec4 y@0x14547d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x14549b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x1454d30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x1454f10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x14550f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x1455470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x1455650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x1455830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x1455bb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x1455d90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1455f70)\n" + " (declare (in ) float P@0x1456080)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x1456400)\n" + " (declare (in ) float P@0x1456510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x14566f0)\n" + " (declare (in ) float P@0x1456800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x14569e0)\n" + " (declare (in ) vec2 P@0x1456af0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x1456cd0)\n" + " (declare (in ) vec2 P@0x1456de0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x1456fc0)\n" + " (declare (in ) vec2 P@0x14570d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x14572b0)\n" + " (declare (in ) vec3 P@0x14573c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x14575a0)\n" + " (declare (in ) vec3 P@0x14576b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x1457890)\n" + " (declare (in ) vec3 P@0x14579a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x1457b80)\n" + " (declare (in ) vec3 P@0x1457c90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isamplerCube sampler@0x1457e70)\n" + " (declare (in ) vec3 P@0x1457f80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usamplerCube sampler@0x1458160)\n" + " (declare (in ) vec3 P@0x1458270)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x1458450)\n" + " (declare (in ) vec3 P@0x1458560)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x1458740)\n" + " (declare (in ) vec3 P@0x1458850)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) samplerCubeShadow sampler@0x1458a30)\n" + " (declare (in ) vec4 P@0x1458b40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x1458d20)\n" + " (declare (in ) vec2 P@0x1458e30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1DArray sampler@0x1459010)\n" + " (declare (in ) vec2 P@0x1459120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1DArray sampler@0x1459300)\n" + " (declare (in ) vec2 P@0x1459410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArray sampler@0x14595f0)\n" + " (declare (in ) vec3 P@0x1459700)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2DArray sampler@0x14598e0)\n" + " (declare (in ) vec3 P@0x14599f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2DArray sampler@0x1459bd0)\n" + " (declare (in ) vec3 P@0x1459ce0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0x1459ec0)\n" + " (declare (in ) vec3 P@0x1459fd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DArrayShadow sampler@0x145a1b0)\n" + " (declare (in ) vec4 P@0x145a2c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x145a4a0)\n" + " (declare (in ) float P@0x145a5b0)\n" + " (declare (in ) float bias@0x145a6c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x145a8a0)\n" + " (declare (in ) float P@0x145a9b0)\n" + " (declare (in ) float bias@0x145aac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x145aca0)\n" + " (declare (in ) float P@0x145adb0)\n" + " (declare (in ) float bias@0x145aec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x145b0a0)\n" + " (declare (in ) vec2 P@0x145b1b0)\n" + " (declare (in ) float bias@0x145b2c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x145b4a0)\n" + " (declare (in ) vec2 P@0x145b5b0)\n" + " (declare (in ) float bias@0x145b6c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x145b8a0)\n" + " (declare (in ) vec2 P@0x145b9b0)\n" + " (declare (in ) float bias@0x145bac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x145bca0)\n" + " (declare (in ) vec3 P@0x145bdb0)\n" + " (declare (in ) float bias@0x145bec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x145c0a0)\n" + " (declare (in ) vec3 P@0x145c1b0)\n" + " (declare (in ) float bias@0x145c2c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x145c4a0)\n" + " (declare (in ) vec3 P@0x145c5b0)\n" + " (declare (in ) float bias@0x145c6c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x145c8a0)\n" + " (declare (in ) vec3 P@0x145c9b0)\n" + " (declare (in ) float bias@0x145cac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isamplerCube sampler@0x145cca0)\n" + " (declare (in ) vec3 P@0x145cdb0)\n" + " (declare (in ) float bias@0x145cec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usamplerCube sampler@0x145d0a0)\n" + " (declare (in ) vec3 P@0x145d1b0)\n" + " (declare (in ) float bias@0x145d2c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x145d4a0)\n" + " (declare (in ) vec3 P@0x145d5b0)\n" + " (declare (in ) float bias@0x145d6c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x145d8a0)\n" + " (declare (in ) vec3 P@0x145d9b0)\n" + " (declare (in ) float bias@0x145dac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) samplerCubeShadow sampler@0x145dca0)\n" + " (declare (in ) vec4 P@0x145ddb0)\n" + " (declare (in ) float bias@0x145dec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x145e0a0)\n" + " (declare (in ) vec2 P@0x145e1b0)\n" + " (declare (in ) float bias@0x145e2c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1DArray sampler@0x145e4a0)\n" + " (declare (in ) vec2 P@0x145e5b0)\n" + " (declare (in ) float bias@0x145e6c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1DArray sampler@0x145e8a0)\n" + " (declare (in ) vec2 P@0x145e9b0)\n" + " (declare (in ) float bias@0x145eac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArray sampler@0x145eca0)\n" + " (declare (in ) vec3 P@0x145edb0)\n" + " (declare (in ) float bias@0x145eec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2DArray sampler@0x145f0a0)\n" + " (declare (in ) vec3 P@0x145f1b0)\n" + " (declare (in ) float bias@0x145f2c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2DArray sampler@0x145f4a0)\n" + " (declare (in ) vec3 P@0x145f5b0)\n" + " (declare (in ) float bias@0x145f6c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0x145f8a0)\n" + " (declare (in ) vec3 P@0x145f9b0)\n" + " (declare (in ) float bias@0x145fac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x145fca0)\n" + " (declare (in ) vec2 P@0x145fdb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x1460140)\n" + " (declare (in ) vec2 P@0x1460250)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x1460430)\n" + " (declare (in ) vec2 P@0x1460540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1460720)\n" + " (declare (in ) vec4 P@0x1460830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x1460a10)\n" + " (declare (in ) vec4 P@0x1460b20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x1460d00)\n" + " (declare (in ) vec4 P@0x1460e10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1460ff0)\n" + " (declare (in ) vec3 P@0x1461100)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x14612e0)\n" + " (declare (in ) vec3 P@0x14613f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x14615d0)\n" + " (declare (in ) vec3 P@0x14616e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x14618c0)\n" + " (declare (in ) vec4 P@0x14619d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x1461bb0)\n" + " (declare (in ) vec4 P@0x1461cc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x1461ea0)\n" + " (declare (in ) vec4 P@0x1461fb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1462190)\n" + " (declare (in ) vec4 P@0x14622a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x1462480)\n" + " (declare (in ) vec4 P@0x1462590)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x1462770)\n" + " (declare (in ) vec4 P@0x1462880)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x1462a60)\n" + " (declare (in ) vec4 P@0x1462b70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x1462d50)\n" + " (declare (in ) vec4 P@0x1462e60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1463040)\n" + " (declare (in ) vec2 P@0x1463150)\n" + " (declare (in ) float bias@0x1463260)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x1463440)\n" + " (declare (in ) vec2 P@0x1463550)\n" + " (declare (in ) float bias@0x1463660)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x1463840)\n" + " (declare (in ) vec2 P@0x1463950)\n" + " (declare (in ) float bias@0x1463a60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1463c40)\n" + " (declare (in ) vec4 P@0x1463d50)\n" + " (declare (in ) float bias@0x1463e60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x1464040)\n" + " (declare (in ) vec4 P@0x1464150)\n" + " (declare (in ) float bias@0x1464260)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x1464440)\n" + " (declare (in ) vec4 P@0x1464550)\n" + " (declare (in ) float bias@0x1464660)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1464840)\n" + " (declare (in ) vec3 P@0x1464950)\n" + " (declare (in ) float bias@0x1464a60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x1464c40)\n" + " (declare (in ) vec3 P@0x1464d50)\n" + " (declare (in ) float bias@0x1464e60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x1465040)\n" + " (declare (in ) vec3 P@0x1465150)\n" + " (declare (in ) float bias@0x1465260)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1465440)\n" + " (declare (in ) vec4 P@0x1465550)\n" + " (declare (in ) float bias@0x1465660)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x1465840)\n" + " (declare (in ) vec4 P@0x1465950)\n" + " (declare (in ) float bias@0x1465a60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x1465c40)\n" + " (declare (in ) vec4 P@0x1465d50)\n" + " (declare (in ) float bias@0x1465e60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1466040)\n" + " (declare (in ) vec4 P@0x1466150)\n" + " (declare (in ) float bias@0x1466260)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x1466440)\n" + " (declare (in ) vec4 P@0x1466550)\n" + " (declare (in ) float bias@0x1466660)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x1466840)\n" + " (declare (in ) vec4 P@0x1466950)\n" + " (declare (in ) float bias@0x1466a60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x1466c40)\n" + " (declare (in ) vec4 P@0x1466d50)\n" + " (declare (in ) float bias@0x1466e60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x1467040)\n" + " (declare (in ) vec4 P@0x1467150)\n" + " (declare (in ) float bias@0x1467260)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1467440)\n" + " (declare (in ) float P@0x1467550)\n" + " (declare (in ) float lod@0x1467660)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x14679f0)\n" + " (declare (in ) float P@0x1467b00)\n" + " (declare (in ) float lod@0x1467c10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x1467df0)\n" + " (declare (in ) float P@0x1467f00)\n" + " (declare (in ) float lod@0x1468010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x14681f0)\n" + " (declare (in ) vec2 P@0x1468300)\n" + " (declare (in ) float lod@0x1468410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x14685f0)\n" + " (declare (in ) vec2 P@0x1468700)\n" + " (declare (in ) float lod@0x1468810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x14689f0)\n" + " (declare (in ) vec2 P@0x1468b00)\n" + " (declare (in ) float lod@0x1468c10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1468df0)\n" + " (declare (in ) vec3 P@0x1468f00)\n" + " (declare (in ) float lod@0x1469010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x14691f0)\n" + " (declare (in ) vec3 P@0x1469300)\n" + " (declare (in ) float lod@0x1469410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x14695f0)\n" + " (declare (in ) vec3 P@0x1469700)\n" + " (declare (in ) float lod@0x1469810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x14699f0)\n" + " (declare (in ) vec3 P@0x1469b00)\n" + " (declare (in ) float lod@0x1469c10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isamplerCube sampler@0x1469df0)\n" + " (declare (in ) vec3 P@0x1469f00)\n" + " (declare (in ) float lod@0x146a010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usamplerCube sampler@0x146a1f0)\n" + " (declare (in ) vec3 P@0x146a300)\n" + " (declare (in ) float lod@0x146a410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x146a5f0)\n" + " (declare (in ) vec3 P@0x146a700)\n" + " (declare (in ) float lod@0x146a810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x146a9f0)\n" + " (declare (in ) vec3 P@0x146ab00)\n" + " (declare (in ) float lod@0x146ac10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x146adf0)\n" + " (declare (in ) vec2 P@0x146af00)\n" + " (declare (in ) float lod@0x146b010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1DArray sampler@0x146b1f0)\n" + " (declare (in ) vec2 P@0x146b300)\n" + " (declare (in ) float lod@0x146b410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1DArray sampler@0x146b5f0)\n" + " (declare (in ) vec2 P@0x146b700)\n" + " (declare (in ) float lod@0x146b810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArray sampler@0x146b9f0)\n" + " (declare (in ) vec3 P@0x146bb00)\n" + " (declare (in ) float lod@0x146bc10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2DArray sampler@0x146bdf0)\n" + " (declare (in ) vec3 P@0x146bf00)\n" + " (declare (in ) float lod@0x146c010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2DArray sampler@0x146c1f0)\n" + " (declare (in ) vec3 P@0x146c300)\n" + " (declare (in ) float lod@0x146c410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0x146c5f0)\n" + " (declare (in ) vec3 P@0x146c700)\n" + " (declare (in ) float lod@0x146c810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texelFetch\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x146c9f0)\n" + " (declare (in ) int P@0x146cb00)\n" + " (declare (in ) int lod@0x146cc10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x146cfa0)\n" + " (declare (in ) int P@0x146d0b0)\n" + " (declare (in ) int lod@0x146d1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x146d3a0)\n" + " (declare (in ) int P@0x146d4b0)\n" + " (declare (in ) int lod@0x146d5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x146d7a0)\n" + " (declare (in ) ivec2 P@0x146d8b0)\n" + " (declare (in ) int lod@0x146d9c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x146dba0)\n" + " (declare (in ) ivec2 P@0x146dcb0)\n" + " (declare (in ) int lod@0x146ddc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x146dfa0)\n" + " (declare (in ) ivec2 P@0x146e0b0)\n" + " (declare (in ) int lod@0x146e1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x146e3a0)\n" + " (declare (in ) ivec3 P@0x146e4b0)\n" + " (declare (in ) int lod@0x146e5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x146e7a0)\n" + " (declare (in ) ivec3 P@0x146e8b0)\n" + " (declare (in ) int lod@0x146e9c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x146eba0)\n" + " (declare (in ) ivec3 P@0x146ecb0)\n" + " (declare (in ) int lod@0x146edc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x146efa0)\n" + " (declare (in ) ivec2 P@0x146f0b0)\n" + " (declare (in ) int lod@0x146f1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1DArray sampler@0x146f3a0)\n" + " (declare (in ) ivec2 P@0x146f4b0)\n" + " (declare (in ) int lod@0x146f5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1DArray sampler@0x146f7a0)\n" + " (declare (in ) ivec2 P@0x146f8b0)\n" + " (declare (in ) int lod@0x146f9c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArray sampler@0x146fba0)\n" + " (declare (in ) ivec3 P@0x146fcb0)\n" + " (declare (in ) int lod@0x146fdc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2DArray sampler@0x146ffa0)\n" + " (declare (in ) ivec3 P@0x14700b0)\n" + " (declare (in ) int lod@0x14701c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2DArray sampler@0x14703a0)\n" + " (declare (in ) ivec3 P@0x14704b0)\n" + " (declare (in ) int lod@0x14705c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x14707a0)\n" + " (declare (in ) vec2 P@0x14708b0)\n" + " (declare (in ) float lod@0x14709c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x1470d50)\n" + " (declare (in ) vec2 P@0x1470e60)\n" + " (declare (in ) float lod@0x1470f70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x1471150)\n" + " (declare (in ) vec2 P@0x1471260)\n" + " (declare (in ) float lod@0x1471370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1471550)\n" + " (declare (in ) vec4 P@0x1471660)\n" + " (declare (in ) float lod@0x1471770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x1471950)\n" + " (declare (in ) vec4 P@0x1471a60)\n" + " (declare (in ) float lod@0x1471b70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x1471d50)\n" + " (declare (in ) vec4 P@0x1471e60)\n" + " (declare (in ) float lod@0x1471f70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1472150)\n" + " (declare (in ) vec3 P@0x1472260)\n" + " (declare (in ) float lod@0x1472370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x1472550)\n" + " (declare (in ) vec3 P@0x1472660)\n" + " (declare (in ) float lod@0x1472770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x1472950)\n" + " (declare (in ) vec3 P@0x1472a60)\n" + " (declare (in ) float lod@0x1472b70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1472d50)\n" + " (declare (in ) vec4 P@0x1472e60)\n" + " (declare (in ) float lod@0x1472f70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x1473150)\n" + " (declare (in ) vec4 P@0x1473260)\n" + " (declare (in ) float lod@0x1473370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x1473550)\n" + " (declare (in ) vec4 P@0x1473660)\n" + " (declare (in ) float lod@0x1473770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1473950)\n" + " (declare (in ) vec4 P@0x1473a60)\n" + " (declare (in ) float lod@0x1473b70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x1473d50)\n" + " (declare (in ) vec4 P@0x1473e60)\n" + " (declare (in ) float lod@0x1473f70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x1474150)\n" + " (declare (in ) vec4 P@0x1474260)\n" + " (declare (in ) float lod@0x1474370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x1474550)\n" + " (declare (in ) vec4 P@0x1474660)\n" + " (declare (in ) float lod@0x1474770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x1474950)\n" + " (declare (in ) vec4 P@0x1474a60)\n" + " (declare (in ) float lod@0x1474b70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureGrad\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1474d50)\n" + " (declare (in ) float P@0x1474e60)\n" + " (declare (in ) float dPdx@0x1474f70)\n" + " (declare (in ) float dPdy@0x1475080)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x1475410)\n" + " (declare (in ) float P@0x1475520)\n" + " (declare (in ) float dPdx@0x1475630)\n" + " (declare (in ) float dPdy@0x1475740)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x1475920)\n" + " (declare (in ) float P@0x1475a30)\n" + " (declare (in ) float dPdx@0x1475b40)\n" + " (declare (in ) float dPdy@0x1475c50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1475e30)\n" + " (declare (in ) vec2 P@0x1475f40)\n" + " (declare (in ) vec2 dPdx@0x1476050)\n" + " (declare (in ) vec2 dPdy@0x1476160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x1476340)\n" + " (declare (in ) vec2 P@0x1476450)\n" + " (declare (in ) vec2 dPdx@0x1476560)\n" + " (declare (in ) vec2 dPdy@0x1476670)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x1476850)\n" + " (declare (in ) vec2 P@0x1476960)\n" + " (declare (in ) vec2 dPdx@0x1476a70)\n" + " (declare (in ) vec2 dPdy@0x1476b80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1476d60)\n" + " (declare (in ) vec3 P@0x1476e70)\n" + " (declare (in ) vec3 dPdx@0x1476f80)\n" + " (declare (in ) vec3 dPdy@0x1477090)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x1477270)\n" + " (declare (in ) vec3 P@0x1477380)\n" + " (declare (in ) vec3 dPdx@0x1477490)\n" + " (declare (in ) vec3 dPdy@0x14775a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x1477780)\n" + " (declare (in ) vec3 P@0x1477890)\n" + " (declare (in ) vec3 dPdx@0x14779a0)\n" + " (declare (in ) vec3 dPdy@0x1477ab0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x1477c90)\n" + " (declare (in ) vec3 P@0x1477da0)\n" + " (declare (in ) vec3 dPdx@0x1477eb0)\n" + " (declare (in ) vec3 dPdy@0x1477fc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isamplerCube sampler@0x14781a0)\n" + " (declare (in ) vec3 P@0x14782b0)\n" + " (declare (in ) vec3 dPdx@0x14783c0)\n" + " (declare (in ) vec3 dPdy@0x14784d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usamplerCube sampler@0x14786b0)\n" + " (declare (in ) vec3 P@0x14787c0)\n" + " (declare (in ) vec3 dPdx@0x14788d0)\n" + " (declare (in ) vec3 dPdy@0x14789e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x1478bc0)\n" + " (declare (in ) vec3 P@0x1478cd0)\n" + " (declare (in ) float dPdx@0x1478de0)\n" + " (declare (in ) float dPdy@0x1478ef0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x14790d0)\n" + " (declare (in ) vec3 P@0x14791e0)\n" + " (declare (in ) vec2 dPdx@0x14792f0)\n" + " (declare (in ) vec2 dPdy@0x1479400)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) samplerCubeShadow sampler@0x14795e0)\n" + " (declare (in ) vec4 P@0x14796f0)\n" + " (declare (in ) vec3 dPdx@0x1479800)\n" + " (declare (in ) vec3 dPdy@0x1479910)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x1479af0)\n" + " (declare (in ) vec2 P@0x1479c00)\n" + " (declare (in ) float dPdx@0x1479d10)\n" + " (declare (in ) float dPdy@0x1479e20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1DArray sampler@0x147a000)\n" + " (declare (in ) vec2 P@0x147a110)\n" + " (declare (in ) float dPdx@0x147a220)\n" + " (declare (in ) float dPdy@0x147a330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1DArray sampler@0x147a510)\n" + " (declare (in ) vec2 P@0x147a620)\n" + " (declare (in ) float dPdx@0x147a730)\n" + " (declare (in ) float dPdy@0x147a840)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArray sampler@0x147aa20)\n" + " (declare (in ) vec3 P@0x147ab30)\n" + " (declare (in ) vec2 dPdx@0x147ac40)\n" + " (declare (in ) vec2 dPdy@0x147ad50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2DArray sampler@0x147af30)\n" + " (declare (in ) vec3 P@0x147b040)\n" + " (declare (in ) vec2 dPdx@0x147b150)\n" + " (declare (in ) vec2 dPdy@0x147b260)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2DArray sampler@0x147b440)\n" + " (declare (in ) vec3 P@0x147b550)\n" + " (declare (in ) vec2 dPdx@0x147b660)\n" + " (declare (in ) vec2 dPdy@0x147b770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0x147b950)\n" + " (declare (in ) vec3 P@0x147ba60)\n" + " (declare (in ) float dPdx@0x147bb70)\n" + " (declare (in ) float dPdy@0x147bc80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DArrayShadow sampler@0x147be60)\n" + " (declare (in ) vec4 P@0x147bf70)\n" + " (declare (in ) vec2 dPdx@0x147c080)\n" + " (declare (in ) vec2 dPdy@0x147c190)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureProjGrad\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x147c370)\n" + " (declare (in ) vec2 P@0x147c480)\n" + " (declare (in ) float dPdx@0x147c590)\n" + " (declare (in ) float dPdy@0x147c6a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x147ca30)\n" + " (declare (in ) vec2 P@0x147cb40)\n" + " (declare (in ) float dPdx@0x147cc50)\n" + " (declare (in ) float dPdy@0x147cd60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x147cf40)\n" + " (declare (in ) vec2 P@0x147d050)\n" + " (declare (in ) float dPdx@0x147d160)\n" + " (declare (in ) float dPdy@0x147d270)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x147d450)\n" + " (declare (in ) vec4 P@0x147d560)\n" + " (declare (in ) float dPdx@0x147d670)\n" + " (declare (in ) float dPdy@0x147d780)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x147d960)\n" + " (declare (in ) vec4 P@0x147da70)\n" + " (declare (in ) float dPdx@0x147db80)\n" + " (declare (in ) float dPdy@0x147dc90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x147de70)\n" + " (declare (in ) vec4 P@0x147df80)\n" + " (declare (in ) float dPdx@0x147e090)\n" + " (declare (in ) float dPdy@0x147e1a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x147e380)\n" + " (declare (in ) vec3 P@0x147e490)\n" + " (declare (in ) vec2 dPdx@0x147e5a0)\n" + " (declare (in ) vec2 dPdy@0x147e6b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x147e890)\n" + " (declare (in ) vec3 P@0x147e9a0)\n" + " (declare (in ) vec2 dPdx@0x147eab0)\n" + " (declare (in ) vec2 dPdy@0x147ebc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x147eda0)\n" + " (declare (in ) vec3 P@0x147eeb0)\n" + " (declare (in ) vec2 dPdx@0x147efc0)\n" + " (declare (in ) vec2 dPdy@0x147f0d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x147f2b0)\n" + " (declare (in ) vec4 P@0x147f3c0)\n" + " (declare (in ) vec2 dPdx@0x147f4d0)\n" + " (declare (in ) vec2 dPdy@0x147f5e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x147f7c0)\n" + " (declare (in ) vec4 P@0x147f8d0)\n" + " (declare (in ) vec2 dPdx@0x147f9e0)\n" + " (declare (in ) vec2 dPdy@0x147faf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x147fcd0)\n" + " (declare (in ) vec4 P@0x147fde0)\n" + " (declare (in ) vec2 dPdx@0x147fef0)\n" + " (declare (in ) vec2 dPdy@0x1480000)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x14801e0)\n" + " (declare (in ) vec4 P@0x14802f0)\n" + " (declare (in ) vec3 dPdx@0x1480400)\n" + " (declare (in ) vec3 dPdy@0x1480510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x14806f0)\n" + " (declare (in ) vec4 P@0x1480800)\n" + " (declare (in ) vec3 dPdx@0x1480910)\n" + " (declare (in ) vec3 dPdy@0x1480a20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x1480c00)\n" + " (declare (in ) vec4 P@0x1480d10)\n" + " (declare (in ) vec3 dPdx@0x1480e20)\n" + " (declare (in ) vec3 dPdy@0x1480f30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x1481110)\n" + " (declare (in ) vec4 P@0x1481220)\n" + " (declare (in ) float dPdx@0x1481330)\n" + " (declare (in ) float dPdy@0x1481440)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x1481620)\n" + " (declare (in ) vec4 P@0x1481730)\n" + " (declare (in ) vec2 dPdx@0x1481840)\n" + " (declare (in ) vec2 dPdy@0x1481950)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1481b30)\n" + " (declare (in ) float coord@0x1481c40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1482760)\n" + " (declare (in ) float coord@0x1482870)\n" + " (declare (in ) float bias@0x1482980)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1481fd0)\n" + " (declare (in ) vec2 coord@0x14820e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1482470)\n" + " (declare (in ) vec4 coord@0x1482580)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1482b60)\n" + " (declare (in ) vec2 coord@0x1482c70)\n" + " (declare (in ) float bias@0x1482d80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1482f60)\n" + " (declare (in ) vec4 coord@0x1483070)\n" + " (declare (in ) float bias@0x1483180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1483360)\n" + " (declare (in ) float coord@0x1483470)\n" + " (declare (in ) float lod@0x1483580)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1483910)\n" + " (declare (in ) vec2 coord@0x1483a20)\n" + " (declare (in ) float lod@0x1483b30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1483ec0)\n" + " (declare (in ) vec4 coord@0x1483fd0)\n" + " (declare (in ) float lod@0x14840e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x14842c0)\n" + " (declare (in ) vec2 coord@0x14843d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1484ef0)\n" + " (declare (in ) vec2 coord@0x1485000)\n" + " (declare (in ) float bias@0x1485110)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1484760)\n" + " (declare (in ) vec3 coord@0x1484870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1484c00)\n" + " (declare (in ) vec4 coord@0x1484d10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x14852f0)\n" + " (declare (in ) vec3 coord@0x1485400)\n" + " (declare (in ) float bias@0x1485510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x14856f0)\n" + " (declare (in ) vec4 coord@0x1485800)\n" + " (declare (in ) float bias@0x1485910)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1485af0)\n" + " (declare (in ) vec2 coord@0x1485c00)\n" + " (declare (in ) float lod@0x1485d10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x14860a0)\n" + " (declare (in ) vec3 coord@0x14861b0)\n" + " (declare (in ) float lod@0x14862c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1486650)\n" + " (declare (in ) vec4 coord@0x1486760)\n" + " (declare (in ) float lod@0x1486870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1486a50)\n" + " (declare (in ) vec3 coord@0x1486b60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1487390)\n" + " (declare (in ) vec3 coord@0x14874a0)\n" + " (declare (in ) float bias@0x14875b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1486ef0)\n" + " (declare (in ) vec4 coord@0x1487000)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1487790)\n" + " (declare (in ) vec4 coord@0x14878a0)\n" + " (declare (in ) float bias@0x14879b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1487b90)\n" + " (declare (in ) vec3 coord@0x1487ca0)\n" + " (declare (in ) float lod@0x1487db0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1488140)\n" + " (declare (in ) vec4 coord@0x1488250)\n" + " (declare (in ) float lod@0x1488360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x14886f0)\n" + " (declare (in ) vec3 coord@0x1488800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x1488b90)\n" + " (declare (in ) vec3 coord@0x1488ca0)\n" + " (declare (in ) float bias@0x1488db0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x1488f90)\n" + " (declare (in ) vec3 coord@0x14890a0)\n" + " (declare (in ) float lod@0x14891b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x1489540)\n" + " (declare (in ) vec3 coord@0x1489650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x148a7c0)\n" + " (declare (in ) vec3 coord@0x148a8d0)\n" + " (declare (in ) float bias@0x148a9e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x14899e0)\n" + " (declare (in ) vec3 coord@0x1489af0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x148abc0)\n" + " (declare (in ) vec3 coord@0x148acd0)\n" + " (declare (in ) float bias@0x148ade0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x1489e80)\n" + " (declare (in ) vec4 coord@0x1489f90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x148afc0)\n" + " (declare (in ) vec4 coord@0x148b0d0)\n" + " (declare (in ) float bias@0x148b1e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x148a320)\n" + " (declare (in ) vec4 coord@0x148a430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x148b3c0)\n" + " (declare (in ) vec4 coord@0x148b4d0)\n" + " (declare (in ) float bias@0x148b5e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x148b7c0)\n" + " (declare (in ) vec3 coord@0x148b8d0)\n" + " (declare (in ) float lod@0x148b9e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x148bd70)\n" + " (declare (in ) vec3 coord@0x148be80)\n" + " (declare (in ) float lod@0x148bf90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x148c320)\n" + " (declare (in ) vec4 coord@0x148c430)\n" + " (declare (in ) float lod@0x148c540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x148c8d0)\n" + " (declare (in ) vec4 coord@0x148c9e0)\n" + " (declare (in ) float lod@0x148caf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dFdx\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p@0x148ce80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 p@0x148d200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 p@0x148d3e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 p@0x148d5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dFdy\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p@0x148d7a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 p@0x148db20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 p@0x148dd00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 p@0x148dee0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function fwidth\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p@0x148e0c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 p@0x148e440)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 p@0x148e620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 p@0x148e800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x148e9e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x148ed60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x148ef40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x148f120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float x@0x148f300)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x148f680)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec3 x@0x148f860)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec4 x@0x148fa40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float x@0x148fc20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec2 x@0x148ffa0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1490180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1490360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float x@0x1490540)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec2 x@0x14908c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1490aa0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1490c80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "\n" + ")" +; +static const char *functions_for_130_frag [] = { + builtin_clamp, + builtin_matrixCompMult, + builtin_textureProj, + builtin_noise2, + builtin_texture3DProjLod, + builtin_pow, + builtin_texture2DProj, + builtin_fwidth, + builtin_greaterThanEqual, + builtin_sign, + builtin_texture3DProj, + builtin_textureProjLod, + builtin_texture, + builtin_texture2D, + builtin_equal, + builtin_faceforward, + builtin_tan, + builtin_shadow2DProj, + builtin_shadow1DProjLod, + builtin_any, + builtin_shadow1DProj, + builtin_normalize, + builtin_asin, + builtin_texture1DProj, + builtin_log, + builtin_floor, + builtin_exp2, + builtin_lessThan, + builtin_cross, + builtin_sqrt, + builtin_texture3DLod, + builtin_textureLod, + builtin_fract, + builtin_abs, + builtin_degrees, + builtin_shadow1DLod, + builtin_dFdx, + builtin_sin, + builtin_shadow2D, + builtin_shadow2DLod, + builtin_all, + builtin_log2, + builtin_textureGrad, + builtin_atan, + builtin_notEqual, + builtin_max, + builtin_lessThanEqual, + builtin_transpose, + builtin_outerProduct, + builtin_ceil, + builtin_reflect, + builtin_textureCubeLod, + builtin_step, + builtin_texture1D, + builtin_greaterThan, + builtin_texture3D, + builtin_shadow2DProjLod, + builtin_not, + builtin_texture2DProjLod, + builtin_dFdy, + builtin_inversesqrt, + builtin_mod, + builtin_noise4, + builtin_distance, + builtin_cos, + builtin_shadow1D, + builtin_noise1, + builtin_refract, + builtin_noise3, + builtin_texelFetch, + builtin_min, + builtin_radians, + builtin_smoothstep, + builtin_textureProjGrad, + builtin_texture1DProjLod, + builtin_textureCube, + builtin_length, + builtin_texture1DLod, + builtin_texture2DLod, + builtin_exp, + builtin_acos, + builtin_mix, + builtin_dot, +}; +static const char *prototypes_for_ARB_texture_rectangle_vert = + "(\n" + "(function texture2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRect sampler@0x9f07b0)\n" + " (declare (in ) vec2 coord@0x9f08c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRect sampler@0x9f0c50)\n" + " (declare (in ) vec3 coord@0x9f0d60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRect sampler@0x9f10f0)\n" + " (declare (in ) vec4 coord@0x9f1200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRectShadow sampler@0x9f13e0)\n" + " (declare (in ) vec3 coord@0x9f14f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DRectShadow sampler@0x9f1880)\n" + " (declare (in ) vec4 coord@0x9f1990)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "\n" + ")" +; +static const char *functions_for_ARB_texture_rectangle_vert [] = { + builtin_texture2DRect, + builtin_shadow2DRectProj, + builtin_shadow2DRect, + builtin_texture2DRectProj, +}; +static const char *prototypes_for_130_vert = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float degrees@0x16a1fa0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 degrees@0x16a2320)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 degrees@0x16a2500)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 degrees@0x16a26e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float radians@0x16a28c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 radians@0x16a2c40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 radians@0x16a2e20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 radians@0x16a3000)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x16a31e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x16a3560)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x16a3740)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x16a3920)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x16a3b00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x16a3e80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x16a4060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x16a4240)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x16a4420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x16a47a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x16a4980)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x16a4b60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x16a4d40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x16a50c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x16a52a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x16a5480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float angle@0x16a5660)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 angle@0x16a59e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 angle@0x16a5bc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 angle@0x16a5da0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y@0x16a5f80)\n" + " (declare (in ) float x@0x16a6090)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y@0x16a6410)\n" + " (declare (in ) vec2 x@0x16a6520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y@0x16a6700)\n" + " (declare (in ) vec3 x@0x16a6810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y@0x16a69f0)\n" + " (declare (in ) vec4 x@0x16a6b00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y_over_x@0x16a6ce0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 y_over_x@0x16a6ed0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 y_over_x@0x16a70c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 y_over_x@0x16a72b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16a74a0)\n" + " (declare (in ) float y@0x16a75b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16a7930)\n" + " (declare (in ) vec2 y@0x16a7a40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16a7c20)\n" + " (declare (in ) vec3 y@0x16a7d30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16a7f10)\n" + " (declare (in ) vec4 y@0x16a8020)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16a8200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16a8580)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16a8760)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16a8940)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16a8b20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16a8ea0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16a9080)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16a9260)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16a9440)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16a97c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16a99a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16a9b80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16a9d60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16aa0e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16aa2c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16aa4a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16aa680)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16aaa00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16aabe0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16aadc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16aafa0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16ab330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16ab510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16ab6f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16ab8d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16abc50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16abe30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16ac010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in ) int x@0x16ac1f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16ac3d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16ac5b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16ac790)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16ac970)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16accf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16aced0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16ad0b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in ) int x@0x16ad290)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16ad470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16ad650)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16ad830)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16ada10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16add90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16adf70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16ae150)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16ae330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16ae6b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16ae890)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16aea70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16aec50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16aefd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16af1b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16af390)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16af570)\n" + " (declare (in ) float y@0x16af680)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16afa00)\n" + " (declare (in ) float y@0x16afb10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16afcf0)\n" + " (declare (in ) float y@0x16afe00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16affe0)\n" + " (declare (in ) float y@0x16b00f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16b02d0)\n" + " (declare (in ) vec2 y@0x16b03e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16b05c0)\n" + " (declare (in ) vec3 y@0x16b06d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16b08b0)\n" + " (declare (in ) vec4 y@0x16b09c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16b0ba0)\n" + " (declare (in ) float y@0x16b0cb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16b1030)\n" + " (declare (in ) vec2 y@0x16b1140)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16b1320)\n" + " (declare (in ) vec3 y@0x16b1430)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16b1610)\n" + " (declare (in ) vec4 y@0x16b1720)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16b1900)\n" + " (declare (in ) float y@0x16b1a10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16b1bf0)\n" + " (declare (in ) float y@0x16b1d00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16b1ee0)\n" + " (declare (in ) float y@0x16b1ff0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in ) int x@0x16b21d0)\n" + " (declare (in ) int y@0x16b22e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16b24c0)\n" + " (declare (in ) ivec2 y@0x16b25d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16b27b0)\n" + " (declare (in ) ivec3 y@0x16b28c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16b2aa0)\n" + " (declare (in ) ivec4 y@0x16b2bb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16b2d90)\n" + " (declare (in ) int y@0x16b2ea0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16b3080)\n" + " (declare (in ) int y@0x16b3190)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16b3370)\n" + " (declare (in ) int y@0x16b3480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in ) uint x@0x16b3660)\n" + " (declare (in ) uint y@0x16b3770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16b3950)\n" + " (declare (in ) uvec2 y@0x16b3a60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16b3c40)\n" + " (declare (in ) uvec3 y@0x16b3d50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16b3f30)\n" + " (declare (in ) uvec4 y@0x16b4040)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16b4220)\n" + " (declare (in ) uint y@0x16b4330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16b4510)\n" + " (declare (in ) uint y@0x16b4620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16b4800)\n" + " (declare (in ) uint y@0x16b4910)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16b4af0)\n" + " (declare (in ) float y@0x16b4c00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16b4f80)\n" + " (declare (in ) vec2 y@0x16b5090)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16b5270)\n" + " (declare (in ) vec3 y@0x16b5380)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16b5560)\n" + " (declare (in ) vec4 y@0x16b5670)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16b5850)\n" + " (declare (in ) float y@0x16b5960)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16b5b40)\n" + " (declare (in ) float y@0x16b5c50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16b5e30)\n" + " (declare (in ) float y@0x16b5f40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in ) int x@0x16b6120)\n" + " (declare (in ) int y@0x16b6230)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16b6410)\n" + " (declare (in ) ivec2 y@0x16b6520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16b6700)\n" + " (declare (in ) ivec3 y@0x16b6810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16b69f0)\n" + " (declare (in ) ivec4 y@0x16b6b00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16b6ce0)\n" + " (declare (in ) int y@0x16b6df0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16b6fd0)\n" + " (declare (in ) int y@0x16b70e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16b72c0)\n" + " (declare (in ) int y@0x16b73d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in ) uint x@0x16b75b0)\n" + " (declare (in ) uint y@0x16b76c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16b78a0)\n" + " (declare (in ) uvec2 y@0x16b79b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16b7b90)\n" + " (declare (in ) uvec3 y@0x16b7ca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16b7e80)\n" + " (declare (in ) uvec4 y@0x16b7f90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16b8170)\n" + " (declare (in ) uint y@0x16b8280)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16b8460)\n" + " (declare (in ) uint y@0x16b8570)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16b8750)\n" + " (declare (in ) uint y@0x16b8860)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16b8a40)\n" + " (declare (in ) float minVal@0x16b8b50)\n" + " (declare (in ) float maxVal@0x16b8c60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16b8fe0)\n" + " (declare (in ) vec2 minVal@0x16b90f0)\n" + " (declare (in ) vec2 maxVal@0x16b9200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16b93e0)\n" + " (declare (in ) vec3 minVal@0x16b94f0)\n" + " (declare (in ) vec3 maxVal@0x16b9600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16b97e0)\n" + " (declare (in ) vec4 minVal@0x16b98f0)\n" + " (declare (in ) vec4 maxVal@0x16b9a00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16b9be0)\n" + " (declare (in ) float minVal@0x16b9cf0)\n" + " (declare (in ) float maxVal@0x16b9e00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16b9fe0)\n" + " (declare (in ) float minVal@0x16ba0f0)\n" + " (declare (in ) float maxVal@0x16ba200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16ba3e0)\n" + " (declare (in ) float minVal@0x16ba4f0)\n" + " (declare (in ) float maxVal@0x16ba600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in ) int x@0x16ba7e0)\n" + " (declare (in ) int minVal@0x16ba8f0)\n" + " (declare (in ) int maxVal@0x16baa00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16babe0)\n" + " (declare (in ) ivec2 minVal@0x16bacf0)\n" + " (declare (in ) ivec2 maxVal@0x16bae00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16bafe0)\n" + " (declare (in ) ivec3 minVal@0x16bb0f0)\n" + " (declare (in ) ivec3 maxVal@0x16bb200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16bb3e0)\n" + " (declare (in ) ivec4 minVal@0x16bb4f0)\n" + " (declare (in ) ivec4 maxVal@0x16bb600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16bb7e0)\n" + " (declare (in ) int minVal@0x16bb8f0)\n" + " (declare (in ) int maxVal@0x16bba00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16bbbe0)\n" + " (declare (in ) int minVal@0x16bbcf0)\n" + " (declare (in ) int maxVal@0x16bbe00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16bbfe0)\n" + " (declare (in ) int minVal@0x16bc0f0)\n" + " (declare (in ) int maxVal@0x16bc200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in ) uint x@0x16bc3e0)\n" + " (declare (in ) uint minVal@0x16bc4f0)\n" + " (declare (in ) uint maxVal@0x16bc600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16bc7e0)\n" + " (declare (in ) uvec2 minVal@0x16bc8f0)\n" + " (declare (in ) uvec2 maxVal@0x16bca00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16bcbe0)\n" + " (declare (in ) uvec3 minVal@0x16bccf0)\n" + " (declare (in ) uvec3 maxVal@0x16bce00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16bcfe0)\n" + " (declare (in ) uvec4 minVal@0x16bd0f0)\n" + " (declare (in ) uvec4 maxVal@0x16bd200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16bd3e0)\n" + " (declare (in ) uint minVal@0x16bd4f0)\n" + " (declare (in ) uint maxVal@0x16bd600)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16bd7e0)\n" + " (declare (in ) uint minVal@0x16bd8f0)\n" + " (declare (in ) uint maxVal@0x16bda00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16bdbe0)\n" + " (declare (in ) uint minVal@0x16bdcf0)\n" + " (declare (in ) uint maxVal@0x16bde00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16bdfe0)\n" + " (declare (in ) float y@0x16be0f0)\n" + " (declare (in ) float a@0x16be200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16be580)\n" + " (declare (in ) vec2 y@0x16be690)\n" + " (declare (in ) vec2 a@0x16be7a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16be980)\n" + " (declare (in ) vec3 y@0x16bea90)\n" + " (declare (in ) vec3 a@0x16beba0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16bed80)\n" + " (declare (in ) vec4 y@0x16bee90)\n" + " (declare (in ) vec4 a@0x16befa0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16bf180)\n" + " (declare (in ) vec2 y@0x16bf290)\n" + " (declare (in ) float a@0x16bf3a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16bf580)\n" + " (declare (in ) vec3 y@0x16bf690)\n" + " (declare (in ) float a@0x16bf7a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16bf980)\n" + " (declare (in ) vec4 y@0x16bfa90)\n" + " (declare (in ) float a@0x16bfba0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge@0x16bfd80)\n" + " (declare (in ) float x@0x16bfe90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge@0x16c0210)\n" + " (declare (in ) vec2 x@0x16c0320)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge@0x16c0500)\n" + " (declare (in ) vec3 x@0x16c0610)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge@0x16c07f0)\n" + " (declare (in ) vec4 x@0x16c0900)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge@0x16c0ae0)\n" + " (declare (in ) vec2 x@0x16c0bf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge@0x16c0dd0)\n" + " (declare (in ) vec3 x@0x16c0ee0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge@0x16c10c0)\n" + " (declare (in ) vec4 x@0x16c11d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float edge0@0x16c13b0)\n" + " (declare (in ) float edge1@0x16c14c0)\n" + " (declare (in ) float x@0x16c15d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 edge0@0x16c1960)\n" + " (declare (in ) vec2 edge1@0x16c1a70)\n" + " (declare (in ) vec2 x@0x16c1b80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 edge0@0x16c1d60)\n" + " (declare (in ) vec3 edge1@0x16c1e70)\n" + " (declare (in ) vec3 x@0x16c1f80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 edge0@0x16c2160)\n" + " (declare (in ) vec4 edge1@0x16c2270)\n" + " (declare (in ) vec4 x@0x16c2380)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float edge0@0x16c2560)\n" + " (declare (in ) float edge1@0x16c2670)\n" + " (declare (in ) vec2 x@0x16c2780)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float edge0@0x16c2960)\n" + " (declare (in ) float edge1@0x16c2a70)\n" + " (declare (in ) vec3 x@0x16c2b80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float edge0@0x16c2d60)\n" + " (declare (in ) float edge1@0x16c2e70)\n" + " (declare (in ) vec4 x@0x16c2f80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16c3160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16c34e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16c36c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16c38a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float p0@0x16c3a80)\n" + " (declare (in ) float p1@0x16c3b90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 p0@0x16c3f20)\n" + " (declare (in ) vec2 p1@0x16c4030)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 p0@0x16c4210)\n" + " (declare (in ) vec3 p1@0x16c4320)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 p0@0x16c4500)\n" + " (declare (in ) vec4 p1@0x16c4610)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16c47f0)\n" + " (declare (in ) float y@0x16c4900)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16c4c80)\n" + " (declare (in ) vec2 y@0x16c4d90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16c4f70)\n" + " (declare (in ) vec3 y@0x16c5080)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16c5260)\n" + " (declare (in ) vec4 y@0x16c5370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16c5550)\n" + " (declare (in ) vec3 y@0x16c5660)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x16c59e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16c5d70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16c5f50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16c6130)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function ftransform\n" + " (signature vec4\n" + " (parameters\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float N@0x16c6590)\n" + " (declare (in ) float I@0x16c66a0)\n" + " (declare (in ) float Nref@0x16c67b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 N@0x16c6b40)\n" + " (declare (in ) vec2 I@0x16c6c50)\n" + " (declare (in ) vec2 Nref@0x16c6d60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 N@0x16c6f40)\n" + " (declare (in ) vec3 I@0x16c7050)\n" + " (declare (in ) vec3 Nref@0x16c7160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 N@0x16c7340)\n" + " (declare (in ) vec4 I@0x16c7450)\n" + " (declare (in ) vec4 Nref@0x16c7560)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0x16c7740)\n" + " (declare (in ) float N@0x16c7850)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0x16c7bd0)\n" + " (declare (in ) vec2 N@0x16c7ce0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0x16c7ec0)\n" + " (declare (in ) vec3 N@0x16c7fd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0x16c81b0)\n" + " (declare (in ) vec4 N@0x16c82c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float I@0x16c84a0)\n" + " (declare (in ) float N@0x16c85b0)\n" + " (declare (in ) float eta@0x16c86c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 I@0x16c8a40)\n" + " (declare (in ) vec2 N@0x16c8b50)\n" + " (declare (in ) float eta@0x16c8c60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 I@0x16c8e40)\n" + " (declare (in ) vec3 N@0x16c8f50)\n" + " (declare (in ) float eta@0x16c9060)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec4 I@0x16c9240)\n" + " (declare (in ) vec4 N@0x16c9350)\n" + " (declare (in ) float eta@0x16c9460)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) mat2 x@0x16c9640)\n" + " (declare (in ) mat2 y@0x16c9750)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) mat3 x@0x16c9ae0)\n" + " (declare (in ) mat3 y@0x16c9bf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) mat4 x@0x16c9dd0)\n" + " (declare (in ) mat4 y@0x16c9ee0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) mat2x3 x@0x16ca0c0)\n" + " (declare (in ) mat2x3 y@0x16ca1d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) mat2x4 x@0x16ca3b0)\n" + " (declare (in ) mat2x4 y@0x16ca4c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) mat3x2 x@0x16ca6a0)\n" + " (declare (in ) mat3x2 y@0x16ca7b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) mat3x4 x@0x16ca990)\n" + " (declare (in ) mat3x4 y@0x16caaa0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) mat4x2 x@0x16cac80)\n" + " (declare (in ) mat4x2 y@0x16cad90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) mat4x3 x@0x16caf70)\n" + " (declare (in ) mat4x3 y@0x16cb080)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function outerProduct\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x16cb260)\n" + " (declare (in ) vec2 r@0x16cb370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x16cb700)\n" + " (declare (in ) vec3 r@0x16cb810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x16cb9f0)\n" + " (declare (in ) vec4 r@0x16cbb00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x16cbce0)\n" + " (declare (in ) vec2 r@0x16cbdf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x16cbfd0)\n" + " (declare (in ) vec3 r@0x16cc0e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x16cc2c0)\n" + " (declare (in ) vec2 r@0x16cc3d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) vec2 c@0x16cc5b0)\n" + " (declare (in ) vec4 r@0x16cc6c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) vec4 c@0x16cc8a0)\n" + " (declare (in ) vec3 r@0x16cc9b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) vec3 c@0x16ccb90)\n" + " (declare (in ) vec4 r@0x16ccca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function transpose\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in ) mat2 m@0x16cce80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in ) mat3 m@0x16cd210)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in ) mat4 m@0x16cd3f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in ) mat3x2 m@0x16cd5d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in ) mat2x3 m@0x16cd7b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in ) mat4x2 m@0x16cd990)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in ) mat2x4 m@0x16cdb70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in ) mat4x3 m@0x16cdd50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in ) mat3x4 m@0x16cdf30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16ce110)\n" + " (declare (in ) vec2 y@0x16ce220)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16ce5b0)\n" + " (declare (in ) vec3 y@0x16ce6c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16ce8a0)\n" + " (declare (in ) vec4 y@0x16ce9b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16ceb90)\n" + " (declare (in ) ivec2 y@0x16ceca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16cee80)\n" + " (declare (in ) ivec3 y@0x16cef90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16cf170)\n" + " (declare (in ) ivec4 y@0x16cf280)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16cf460)\n" + " (declare (in ) uvec2 y@0x16cf570)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16cf750)\n" + " (declare (in ) uvec3 y@0x16cf860)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16cfa40)\n" + " (declare (in ) uvec4 y@0x16cfb50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16cfd30)\n" + " (declare (in ) vec2 y@0x16cfe40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16d01d0)\n" + " (declare (in ) vec3 y@0x16d02e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16d04c0)\n" + " (declare (in ) vec4 y@0x16d05d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16d07b0)\n" + " (declare (in ) ivec2 y@0x16d08c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16d0aa0)\n" + " (declare (in ) ivec3 y@0x16d0bb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16d0d90)\n" + " (declare (in ) ivec4 y@0x16d0ea0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16d1080)\n" + " (declare (in ) uvec2 y@0x16d1190)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16d1370)\n" + " (declare (in ) uvec3 y@0x16d1480)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16d1660)\n" + " (declare (in ) uvec4 y@0x16d1770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16d1950)\n" + " (declare (in ) vec2 y@0x16d1a60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16d1df0)\n" + " (declare (in ) vec3 y@0x16d1f00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16d20e0)\n" + " (declare (in ) vec4 y@0x16d21f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16d23d0)\n" + " (declare (in ) ivec2 y@0x16d24e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16d26c0)\n" + " (declare (in ) ivec3 y@0x16d27d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16d29b0)\n" + " (declare (in ) ivec4 y@0x16d2ac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16d2ca0)\n" + " (declare (in ) uvec2 y@0x16d2db0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16d2f90)\n" + " (declare (in ) uvec3 y@0x16d30a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16d3280)\n" + " (declare (in ) uvec4 y@0x16d3390)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16d3570)\n" + " (declare (in ) vec2 y@0x16d3680)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16d3a10)\n" + " (declare (in ) vec3 y@0x16d3b20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16d3d00)\n" + " (declare (in ) vec4 y@0x16d3e10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16d3ff0)\n" + " (declare (in ) ivec2 y@0x16d4100)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16d42e0)\n" + " (declare (in ) ivec3 y@0x16d43f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16d45d0)\n" + " (declare (in ) ivec4 y@0x16d46e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16d48c0)\n" + " (declare (in ) uvec2 y@0x16d49d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16d4bb0)\n" + " (declare (in ) uvec3 y@0x16d4cc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16d4ea0)\n" + " (declare (in ) uvec4 y@0x16d4fb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16d5190)\n" + " (declare (in ) vec2 y@0x16d52a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16d5620)\n" + " (declare (in ) vec3 y@0x16d5730)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16d5910)\n" + " (declare (in ) vec4 y@0x16d5a20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16d5c00)\n" + " (declare (in ) ivec2 y@0x16d5d10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16d5ef0)\n" + " (declare (in ) ivec3 y@0x16d6000)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16d61e0)\n" + " (declare (in ) ivec4 y@0x16d62f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16d64d0)\n" + " (declare (in ) uvec2 y@0x16d65e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16d67c0)\n" + " (declare (in ) uvec3 y@0x16d68d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16d6ab0)\n" + " (declare (in ) uvec4 y@0x16d6bc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x16d6da0)\n" + " (declare (in ) bvec2 y@0x16d6eb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x16d7090)\n" + " (declare (in ) bvec3 y@0x16d71a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x16d7380)\n" + " (declare (in ) bvec4 y@0x16d7490)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x16d7670)\n" + " (declare (in ) vec2 y@0x16d7780)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x16d7b10)\n" + " (declare (in ) vec3 y@0x16d7c20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) vec4 x@0x16d7e00)\n" + " (declare (in ) vec4 y@0x16d7f10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) ivec2 x@0x16d80f0)\n" + " (declare (in ) ivec2 y@0x16d8200)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) ivec3 x@0x16d83e0)\n" + " (declare (in ) ivec3 y@0x16d84f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) ivec4 x@0x16d86d0)\n" + " (declare (in ) ivec4 y@0x16d87e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) uvec2 x@0x16d89c0)\n" + " (declare (in ) uvec2 y@0x16d8ad0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) uvec3 x@0x16d8cb0)\n" + " (declare (in ) uvec3 y@0x16d8dc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) uvec4 x@0x16d8fa0)\n" + " (declare (in ) uvec4 y@0x16d90b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x16d9290)\n" + " (declare (in ) bvec2 y@0x16d93a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x16d9580)\n" + " (declare (in ) bvec3 y@0x16d9690)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x16d9870)\n" + " (declare (in ) bvec4 y@0x16d9980)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x16d9b60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x16d9ee0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x16da0c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x16da2a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x16da620)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x16da800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in ) bvec2 x@0x16da9e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in ) bvec3 x@0x16dad60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in ) bvec4 x@0x16daf40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16db120)\n" + " (declare (in ) float P@0x16db230)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16db5b0)\n" + " (declare (in ) float P@0x16db6c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16db8a0)\n" + " (declare (in ) float P@0x16db9b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16dbb90)\n" + " (declare (in ) vec2 P@0x16dbca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16dbe80)\n" + " (declare (in ) vec2 P@0x16dbf90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16dc170)\n" + " (declare (in ) vec2 P@0x16dc280)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x16dc460)\n" + " (declare (in ) vec3 P@0x16dc570)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x16dc750)\n" + " (declare (in ) vec3 P@0x16dc860)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x16dca40)\n" + " (declare (in ) vec3 P@0x16dcb50)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x16dcd30)\n" + " (declare (in ) vec3 P@0x16dce40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isamplerCube sampler@0x16dd020)\n" + " (declare (in ) vec3 P@0x16dd130)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usamplerCube sampler@0x16dd310)\n" + " (declare (in ) vec3 P@0x16dd420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x16dd600)\n" + " (declare (in ) vec3 P@0x16dd710)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x16dd8f0)\n" + " (declare (in ) vec3 P@0x16dda00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) samplerCubeShadow sampler@0x16ddbe0)\n" + " (declare (in ) vec4 P@0x16ddcf0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x16dded0)\n" + " (declare (in ) vec2 P@0x16ddfe0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1DArray sampler@0x16de1c0)\n" + " (declare (in ) vec2 P@0x16de2d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1DArray sampler@0x16de4b0)\n" + " (declare (in ) vec2 P@0x16de5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArray sampler@0x16de7a0)\n" + " (declare (in ) vec3 P@0x16de8b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2DArray sampler@0x16dea90)\n" + " (declare (in ) vec3 P@0x16deba0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2DArray sampler@0x16ded80)\n" + " (declare (in ) vec3 P@0x16dee90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0x16df070)\n" + " (declare (in ) vec3 P@0x16df180)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DArrayShadow sampler@0x16df360)\n" + " (declare (in ) vec4 P@0x16df470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16df650)\n" + " (declare (in ) float P@0x16df760)\n" + " (declare (in ) float bias@0x16df870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16dfa50)\n" + " (declare (in ) float P@0x16dfb60)\n" + " (declare (in ) float bias@0x16dfc70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16dfe50)\n" + " (declare (in ) float P@0x16dff60)\n" + " (declare (in ) float bias@0x16e0070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16e0250)\n" + " (declare (in ) vec2 P@0x16e0360)\n" + " (declare (in ) float bias@0x16e0470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16e0650)\n" + " (declare (in ) vec2 P@0x16e0760)\n" + " (declare (in ) float bias@0x16e0870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16e0a50)\n" + " (declare (in ) vec2 P@0x16e0b60)\n" + " (declare (in ) float bias@0x16e0c70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x16e0e50)\n" + " (declare (in ) vec3 P@0x16e0f60)\n" + " (declare (in ) float bias@0x16e1070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x16e1250)\n" + " (declare (in ) vec3 P@0x16e1360)\n" + " (declare (in ) float bias@0x16e1470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x16e1650)\n" + " (declare (in ) vec3 P@0x16e1760)\n" + " (declare (in ) float bias@0x16e1870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x16e1a50)\n" + " (declare (in ) vec3 P@0x16e1b60)\n" + " (declare (in ) float bias@0x16e1c70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isamplerCube sampler@0x16e1e50)\n" + " (declare (in ) vec3 P@0x16e1f60)\n" + " (declare (in ) float bias@0x16e2070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usamplerCube sampler@0x16e2250)\n" + " (declare (in ) vec3 P@0x16e2360)\n" + " (declare (in ) float bias@0x16e2470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x16e2650)\n" + " (declare (in ) vec3 P@0x16e2760)\n" + " (declare (in ) float bias@0x16e2870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x16e2a50)\n" + " (declare (in ) vec3 P@0x16e2b60)\n" + " (declare (in ) float bias@0x16e2c70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) samplerCubeShadow sampler@0x16e2e50)\n" + " (declare (in ) vec4 P@0x16e2f60)\n" + " (declare (in ) float bias@0x16e3070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x16e3250)\n" + " (declare (in ) vec2 P@0x16e3360)\n" + " (declare (in ) float bias@0x16e3470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1DArray sampler@0x16e3650)\n" + " (declare (in ) vec2 P@0x16e3760)\n" + " (declare (in ) float bias@0x16e3870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1DArray sampler@0x16e3a50)\n" + " (declare (in ) vec2 P@0x16e3b60)\n" + " (declare (in ) float bias@0x16e3c70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArray sampler@0x16e3e50)\n" + " (declare (in ) vec3 P@0x16e3f60)\n" + " (declare (in ) float bias@0x16e4070)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2DArray sampler@0x16e4250)\n" + " (declare (in ) vec3 P@0x16e4360)\n" + " (declare (in ) float bias@0x16e4470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2DArray sampler@0x16e4650)\n" + " (declare (in ) vec3 P@0x16e4760)\n" + " (declare (in ) float bias@0x16e4870)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0x16e4a50)\n" + " (declare (in ) vec3 P@0x16e4b60)\n" + " (declare (in ) float bias@0x16e4c70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16e4e50)\n" + " (declare (in ) vec2 P@0x16e4f60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16e52f0)\n" + " (declare (in ) vec2 P@0x16e5400)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16e55e0)\n" + " (declare (in ) vec2 P@0x16e56f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16e58d0)\n" + " (declare (in ) vec4 P@0x16e59e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16e5bc0)\n" + " (declare (in ) vec4 P@0x16e5cd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16e5eb0)\n" + " (declare (in ) vec4 P@0x16e5fc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16e61a0)\n" + " (declare (in ) vec3 P@0x16e62b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16e6490)\n" + " (declare (in ) vec3 P@0x16e65a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16e6780)\n" + " (declare (in ) vec3 P@0x16e6890)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16e6a70)\n" + " (declare (in ) vec4 P@0x16e6b80)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16e6d60)\n" + " (declare (in ) vec4 P@0x16e6e70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16e7050)\n" + " (declare (in ) vec4 P@0x16e7160)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x16e7340)\n" + " (declare (in ) vec4 P@0x16e7450)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x16e7630)\n" + " (declare (in ) vec4 P@0x16e7740)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x16e7920)\n" + " (declare (in ) vec4 P@0x16e7a30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x16e7c10)\n" + " (declare (in ) vec4 P@0x16e7d20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x16e7f00)\n" + " (declare (in ) vec4 P@0x16e8010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16e81f0)\n" + " (declare (in ) vec2 P@0x16e8300)\n" + " (declare (in ) float bias@0x16e8410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16e85f0)\n" + " (declare (in ) vec2 P@0x16e8700)\n" + " (declare (in ) float bias@0x16e8810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16e89f0)\n" + " (declare (in ) vec2 P@0x16e8b00)\n" + " (declare (in ) float bias@0x16e8c10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16e8df0)\n" + " (declare (in ) vec4 P@0x16e8f00)\n" + " (declare (in ) float bias@0x16e9010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16e91f0)\n" + " (declare (in ) vec4 P@0x16e9300)\n" + " (declare (in ) float bias@0x16e9410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16e95f0)\n" + " (declare (in ) vec4 P@0x16e9700)\n" + " (declare (in ) float bias@0x16e9810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16e99f0)\n" + " (declare (in ) vec3 P@0x16e9b00)\n" + " (declare (in ) float bias@0x16e9c10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16e9df0)\n" + " (declare (in ) vec3 P@0x16e9f00)\n" + " (declare (in ) float bias@0x16ea010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16ea1f0)\n" + " (declare (in ) vec3 P@0x16ea300)\n" + " (declare (in ) float bias@0x16ea410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16ea5f0)\n" + " (declare (in ) vec4 P@0x16ea700)\n" + " (declare (in ) float bias@0x16ea810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16ea9f0)\n" + " (declare (in ) vec4 P@0x16eab00)\n" + " (declare (in ) float bias@0x16eac10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16eadf0)\n" + " (declare (in ) vec4 P@0x16eaf00)\n" + " (declare (in ) float bias@0x16eb010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x16eb1f0)\n" + " (declare (in ) vec4 P@0x16eb300)\n" + " (declare (in ) float bias@0x16eb410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x16eb5f0)\n" + " (declare (in ) vec4 P@0x16eb700)\n" + " (declare (in ) float bias@0x16eb810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x16eb9f0)\n" + " (declare (in ) vec4 P@0x16ebb00)\n" + " (declare (in ) float bias@0x16ebc10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x16ebdf0)\n" + " (declare (in ) vec4 P@0x16ebf00)\n" + " (declare (in ) float bias@0x16ec010)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x16ec1f0)\n" + " (declare (in ) vec4 P@0x16ec300)\n" + " (declare (in ) float bias@0x16ec410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16ec5f0)\n" + " (declare (in ) float P@0x16ec700)\n" + " (declare (in ) float lod@0x16ec810)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16ecba0)\n" + " (declare (in ) float P@0x16eccb0)\n" + " (declare (in ) float lod@0x16ecdc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16ecfa0)\n" + " (declare (in ) float P@0x16ed0b0)\n" + " (declare (in ) float lod@0x16ed1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16ed3a0)\n" + " (declare (in ) vec2 P@0x16ed4b0)\n" + " (declare (in ) float lod@0x16ed5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16ed7a0)\n" + " (declare (in ) vec2 P@0x16ed8b0)\n" + " (declare (in ) float lod@0x16ed9c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16edba0)\n" + " (declare (in ) vec2 P@0x16edcb0)\n" + " (declare (in ) float lod@0x16eddc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x16edfa0)\n" + " (declare (in ) vec3 P@0x16ee0b0)\n" + " (declare (in ) float lod@0x16ee1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x16ee3a0)\n" + " (declare (in ) vec3 P@0x16ee4b0)\n" + " (declare (in ) float lod@0x16ee5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x16ee7a0)\n" + " (declare (in ) vec3 P@0x16ee8b0)\n" + " (declare (in ) float lod@0x16ee9c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x16eeba0)\n" + " (declare (in ) vec3 P@0x16eecb0)\n" + " (declare (in ) float lod@0x16eedc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isamplerCube sampler@0x16eefa0)\n" + " (declare (in ) vec3 P@0x16ef0b0)\n" + " (declare (in ) float lod@0x16ef1c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usamplerCube sampler@0x16ef3a0)\n" + " (declare (in ) vec3 P@0x16ef4b0)\n" + " (declare (in ) float lod@0x16ef5c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x16ef7a0)\n" + " (declare (in ) vec3 P@0x16ef8b0)\n" + " (declare (in ) float lod@0x16ef9c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x16efba0)\n" + " (declare (in ) vec3 P@0x16efcb0)\n" + " (declare (in ) float lod@0x16efdc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x16effa0)\n" + " (declare (in ) vec2 P@0x16f00b0)\n" + " (declare (in ) float lod@0x16f01c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1DArray sampler@0x16f03a0)\n" + " (declare (in ) vec2 P@0x16f04b0)\n" + " (declare (in ) float lod@0x16f05c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1DArray sampler@0x16f07a0)\n" + " (declare (in ) vec2 P@0x16f08b0)\n" + " (declare (in ) float lod@0x16f09c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArray sampler@0x16f0ba0)\n" + " (declare (in ) vec3 P@0x16f0cb0)\n" + " (declare (in ) float lod@0x16f0dc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2DArray sampler@0x16f0fa0)\n" + " (declare (in ) vec3 P@0x16f10b0)\n" + " (declare (in ) float lod@0x16f11c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2DArray sampler@0x16f13a0)\n" + " (declare (in ) vec3 P@0x16f14b0)\n" + " (declare (in ) float lod@0x16f15c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0x16f17a0)\n" + " (declare (in ) vec3 P@0x16f18b0)\n" + " (declare (in ) float lod@0x16f19c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texelFetch\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16f1ba0)\n" + " (declare (in ) int P@0x16f1cb0)\n" + " (declare (in ) int lod@0x16f1dc0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16f2150)\n" + " (declare (in ) int P@0x16f2260)\n" + " (declare (in ) int lod@0x16f2370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16f2550)\n" + " (declare (in ) int P@0x16f2660)\n" + " (declare (in ) int lod@0x16f2770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16f2950)\n" + " (declare (in ) ivec2 P@0x16f2a60)\n" + " (declare (in ) int lod@0x16f2b70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16f2d50)\n" + " (declare (in ) ivec2 P@0x16f2e60)\n" + " (declare (in ) int lod@0x16f2f70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16f3150)\n" + " (declare (in ) ivec2 P@0x16f3260)\n" + " (declare (in ) int lod@0x16f3370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x16f3550)\n" + " (declare (in ) ivec3 P@0x16f3660)\n" + " (declare (in ) int lod@0x16f3770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x16f3950)\n" + " (declare (in ) ivec3 P@0x16f3a60)\n" + " (declare (in ) int lod@0x16f3b70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x16f3d50)\n" + " (declare (in ) ivec3 P@0x16f3e60)\n" + " (declare (in ) int lod@0x16f3f70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x16f4150)\n" + " (declare (in ) ivec2 P@0x16f4260)\n" + " (declare (in ) int lod@0x16f4370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1DArray sampler@0x16f4550)\n" + " (declare (in ) ivec2 P@0x16f4660)\n" + " (declare (in ) int lod@0x16f4770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1DArray sampler@0x16f4950)\n" + " (declare (in ) ivec2 P@0x16f4a60)\n" + " (declare (in ) int lod@0x16f4b70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArray sampler@0x16f4d50)\n" + " (declare (in ) ivec3 P@0x16f4e60)\n" + " (declare (in ) int lod@0x16f4f70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2DArray sampler@0x16f5150)\n" + " (declare (in ) ivec3 P@0x16f5260)\n" + " (declare (in ) int lod@0x16f5370)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2DArray sampler@0x16f5550)\n" + " (declare (in ) ivec3 P@0x16f5660)\n" + " (declare (in ) int lod@0x16f5770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16f5950)\n" + " (declare (in ) vec2 P@0x16f5a60)\n" + " (declare (in ) float lod@0x16f5b70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16f5f00)\n" + " (declare (in ) vec2 P@0x16f6010)\n" + " (declare (in ) float lod@0x16f6120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16f6300)\n" + " (declare (in ) vec2 P@0x16f6410)\n" + " (declare (in ) float lod@0x16f6520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16f6700)\n" + " (declare (in ) vec4 P@0x16f6810)\n" + " (declare (in ) float lod@0x16f6920)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16f6b00)\n" + " (declare (in ) vec4 P@0x16f6c10)\n" + " (declare (in ) float lod@0x16f6d20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16f6f00)\n" + " (declare (in ) vec4 P@0x16f7010)\n" + " (declare (in ) float lod@0x16f7120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16f7300)\n" + " (declare (in ) vec3 P@0x16f7410)\n" + " (declare (in ) float lod@0x16f7520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16f7700)\n" + " (declare (in ) vec3 P@0x16f7810)\n" + " (declare (in ) float lod@0x16f7920)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16f7b00)\n" + " (declare (in ) vec3 P@0x16f7c10)\n" + " (declare (in ) float lod@0x16f7d20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16f7f00)\n" + " (declare (in ) vec4 P@0x16f8010)\n" + " (declare (in ) float lod@0x16f8120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16f8300)\n" + " (declare (in ) vec4 P@0x16f8410)\n" + " (declare (in ) float lod@0x16f8520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16f8700)\n" + " (declare (in ) vec4 P@0x16f8810)\n" + " (declare (in ) float lod@0x16f8920)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x16f8b00)\n" + " (declare (in ) vec4 P@0x16f8c10)\n" + " (declare (in ) float lod@0x16f8d20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x16f8f00)\n" + " (declare (in ) vec4 P@0x16f9010)\n" + " (declare (in ) float lod@0x16f9120)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x16f9300)\n" + " (declare (in ) vec4 P@0x16f9410)\n" + " (declare (in ) float lod@0x16f9520)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x16f9700)\n" + " (declare (in ) vec4 P@0x16f9810)\n" + " (declare (in ) float lod@0x16f9920)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x16f9b00)\n" + " (declare (in ) vec4 P@0x16f9c10)\n" + " (declare (in ) float lod@0x16f9d20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureGrad\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x16f9f00)\n" + " (declare (in ) float P@0x16fa010)\n" + " (declare (in ) float dPdx@0x16fa120)\n" + " (declare (in ) float dPdy@0x16fa230)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x16fa5c0)\n" + " (declare (in ) float P@0x16fa6d0)\n" + " (declare (in ) float dPdx@0x16fa7e0)\n" + " (declare (in ) float dPdy@0x16fa8f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x16faad0)\n" + " (declare (in ) float P@0x16fabe0)\n" + " (declare (in ) float dPdx@0x16facf0)\n" + " (declare (in ) float dPdy@0x16fae00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x16fafe0)\n" + " (declare (in ) vec2 P@0x16fb0f0)\n" + " (declare (in ) vec2 dPdx@0x16fb200)\n" + " (declare (in ) vec2 dPdy@0x16fb310)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x16fb4f0)\n" + " (declare (in ) vec2 P@0x16fb600)\n" + " (declare (in ) vec2 dPdx@0x16fb710)\n" + " (declare (in ) vec2 dPdy@0x16fb820)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x16fba00)\n" + " (declare (in ) vec2 P@0x16fbb10)\n" + " (declare (in ) vec2 dPdx@0x16fbc20)\n" + " (declare (in ) vec2 dPdy@0x16fbd30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x16fbf10)\n" + " (declare (in ) vec3 P@0x16fc020)\n" + " (declare (in ) vec3 dPdx@0x16fc130)\n" + " (declare (in ) vec3 dPdy@0x16fc240)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x16fc420)\n" + " (declare (in ) vec3 P@0x16fc530)\n" + " (declare (in ) vec3 dPdx@0x16fc640)\n" + " (declare (in ) vec3 dPdy@0x16fc750)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x16fc930)\n" + " (declare (in ) vec3 P@0x16fca40)\n" + " (declare (in ) vec3 dPdx@0x16fcb50)\n" + " (declare (in ) vec3 dPdy@0x16fcc60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x16fce40)\n" + " (declare (in ) vec3 P@0x16fcf50)\n" + " (declare (in ) vec3 dPdx@0x16fd060)\n" + " (declare (in ) vec3 dPdy@0x16fd170)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isamplerCube sampler@0x16fd350)\n" + " (declare (in ) vec3 P@0x16fd460)\n" + " (declare (in ) vec3 dPdx@0x16fd570)\n" + " (declare (in ) vec3 dPdy@0x16fd680)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usamplerCube sampler@0x16fd860)\n" + " (declare (in ) vec3 P@0x16fd970)\n" + " (declare (in ) vec3 dPdx@0x16fda80)\n" + " (declare (in ) vec3 dPdy@0x16fdb90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x16fdd70)\n" + " (declare (in ) vec3 P@0x16fde80)\n" + " (declare (in ) float dPdx@0x16fdf90)\n" + " (declare (in ) float dPdy@0x16fe0a0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x16fe280)\n" + " (declare (in ) vec3 P@0x16fe390)\n" + " (declare (in ) vec2 dPdx@0x16fe4a0)\n" + " (declare (in ) vec2 dPdy@0x16fe5b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) samplerCubeShadow sampler@0x16fe790)\n" + " (declare (in ) vec4 P@0x16fe8a0)\n" + " (declare (in ) vec3 dPdx@0x16fe9b0)\n" + " (declare (in ) vec3 dPdy@0x16feac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DArray sampler@0x16feca0)\n" + " (declare (in ) vec2 P@0x16fedb0)\n" + " (declare (in ) float dPdx@0x16feec0)\n" + " (declare (in ) float dPdy@0x16fefd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1DArray sampler@0x16ff1b0)\n" + " (declare (in ) vec2 P@0x16ff2c0)\n" + " (declare (in ) float dPdx@0x16ff3d0)\n" + " (declare (in ) float dPdy@0x16ff4e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1DArray sampler@0x16ff6c0)\n" + " (declare (in ) vec2 P@0x16ff7d0)\n" + " (declare (in ) float dPdx@0x16ff8e0)\n" + " (declare (in ) float dPdy@0x16ff9f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DArray sampler@0x16ffbd0)\n" + " (declare (in ) vec3 P@0x16ffce0)\n" + " (declare (in ) vec2 dPdx@0x16ffdf0)\n" + " (declare (in ) vec2 dPdy@0x16fff00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2DArray sampler@0x17000e0)\n" + " (declare (in ) vec3 P@0x17001f0)\n" + " (declare (in ) vec2 dPdx@0x1700300)\n" + " (declare (in ) vec2 dPdy@0x1700410)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2DArray sampler@0x17005f0)\n" + " (declare (in ) vec3 P@0x1700700)\n" + " (declare (in ) vec2 dPdx@0x1700810)\n" + " (declare (in ) vec2 dPdy@0x1700920)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DArrayShadow sampler@0x1700b00)\n" + " (declare (in ) vec3 P@0x1700c10)\n" + " (declare (in ) float dPdx@0x1700d20)\n" + " (declare (in ) float dPdy@0x1700e30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DArrayShadow sampler@0x1701010)\n" + " (declare (in ) vec4 P@0x1701120)\n" + " (declare (in ) vec2 dPdx@0x1701230)\n" + " (declare (in ) vec2 dPdy@0x1701340)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureProjGrad\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1701520)\n" + " (declare (in ) vec2 P@0x1701630)\n" + " (declare (in ) float dPdx@0x1701740)\n" + " (declare (in ) float dPdy@0x1701850)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x1701be0)\n" + " (declare (in ) vec2 P@0x1701cf0)\n" + " (declare (in ) float dPdx@0x1701e00)\n" + " (declare (in ) float dPdy@0x1701f10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x17020f0)\n" + " (declare (in ) vec2 P@0x1702200)\n" + " (declare (in ) float dPdx@0x1702310)\n" + " (declare (in ) float dPdy@0x1702420)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1702600)\n" + " (declare (in ) vec4 P@0x1702710)\n" + " (declare (in ) float dPdx@0x1702820)\n" + " (declare (in ) float dPdy@0x1702930)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler1D sampler@0x1702b10)\n" + " (declare (in ) vec4 P@0x1702c20)\n" + " (declare (in ) float dPdx@0x1702d30)\n" + " (declare (in ) float dPdy@0x1702e40)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler1D sampler@0x1703020)\n" + " (declare (in ) vec4 P@0x1703130)\n" + " (declare (in ) float dPdx@0x1703240)\n" + " (declare (in ) float dPdy@0x1703350)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1703530)\n" + " (declare (in ) vec3 P@0x1703640)\n" + " (declare (in ) vec2 dPdx@0x1703750)\n" + " (declare (in ) vec2 dPdy@0x1703860)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x1703a40)\n" + " (declare (in ) vec3 P@0x1703b50)\n" + " (declare (in ) vec2 dPdx@0x1703c60)\n" + " (declare (in ) vec2 dPdy@0x1703d70)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x1703f50)\n" + " (declare (in ) vec3 P@0x1704060)\n" + " (declare (in ) vec2 dPdx@0x1704170)\n" + " (declare (in ) vec2 dPdy@0x1704280)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1704460)\n" + " (declare (in ) vec4 P@0x1704570)\n" + " (declare (in ) vec2 dPdx@0x1704680)\n" + " (declare (in ) vec2 dPdy@0x1704790)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler2D sampler@0x1704970)\n" + " (declare (in ) vec4 P@0x1704a80)\n" + " (declare (in ) vec2 dPdx@0x1704b90)\n" + " (declare (in ) vec2 dPdy@0x1704ca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler2D sampler@0x1704e80)\n" + " (declare (in ) vec4 P@0x1704f90)\n" + " (declare (in ) vec2 dPdx@0x17050a0)\n" + " (declare (in ) vec2 dPdy@0x17051b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x1705390)\n" + " (declare (in ) vec4 P@0x17054a0)\n" + " (declare (in ) vec3 dPdx@0x17055b0)\n" + " (declare (in ) vec3 dPdy@0x17056c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in ) isampler3D sampler@0x17058a0)\n" + " (declare (in ) vec4 P@0x17059b0)\n" + " (declare (in ) vec3 dPdx@0x1705ac0)\n" + " (declare (in ) vec3 dPdy@0x1705bd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in ) usampler3D sampler@0x1705db0)\n" + " (declare (in ) vec4 P@0x1705ec0)\n" + " (declare (in ) vec3 dPdx@0x1705fd0)\n" + " (declare (in ) vec3 dPdy@0x17060e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x17062c0)\n" + " (declare (in ) vec4 P@0x17063d0)\n" + " (declare (in ) float dPdx@0x17064e0)\n" + " (declare (in ) float dPdy@0x17065f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x17067d0)\n" + " (declare (in ) vec4 P@0x17068e0)\n" + " (declare (in ) vec2 dPdx@0x17069f0)\n" + " (declare (in ) vec2 dPdy@0x1706b00)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1706ce0)\n" + " (declare (in ) float coord@0x1706df0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1707910)\n" + " (declare (in ) float coord@0x1707a20)\n" + " (declare (in ) float bias@0x1707b30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1707180)\n" + " (declare (in ) vec2 coord@0x1707290)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1707620)\n" + " (declare (in ) vec4 coord@0x1707730)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1707d10)\n" + " (declare (in ) vec2 coord@0x1707e20)\n" + " (declare (in ) float bias@0x1707f30)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1708110)\n" + " (declare (in ) vec4 coord@0x1708220)\n" + " (declare (in ) float bias@0x1708330)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1708510)\n" + " (declare (in ) float coord@0x1708620)\n" + " (declare (in ) float lod@0x1708730)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1708ac0)\n" + " (declare (in ) vec2 coord@0x1708bd0)\n" + " (declare (in ) float lod@0x1708ce0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1D sampler@0x1709070)\n" + " (declare (in ) vec4 coord@0x1709180)\n" + " (declare (in ) float lod@0x1709290)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1709470)\n" + " (declare (in ) vec2 coord@0x1709580)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x170a0a0)\n" + " (declare (in ) vec2 coord@0x170a1b0)\n" + " (declare (in ) float bias@0x170a2c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1709910)\n" + " (declare (in ) vec3 coord@0x1709a20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x1709db0)\n" + " (declare (in ) vec4 coord@0x1709ec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x170a4a0)\n" + " (declare (in ) vec3 coord@0x170a5b0)\n" + " (declare (in ) float bias@0x170a6c0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x170a8a0)\n" + " (declare (in ) vec4 coord@0x170a9b0)\n" + " (declare (in ) float bias@0x170aac0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x170aca0)\n" + " (declare (in ) vec2 coord@0x170adb0)\n" + " (declare (in ) float lod@0x170aec0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x170b250)\n" + " (declare (in ) vec3 coord@0x170b360)\n" + " (declare (in ) float lod@0x170b470)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2D sampler@0x170b800)\n" + " (declare (in ) vec4 coord@0x170b910)\n" + " (declare (in ) float lod@0x170ba20)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x170bc00)\n" + " (declare (in ) vec3 coord@0x170bd10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x170c540)\n" + " (declare (in ) vec3 coord@0x170c650)\n" + " (declare (in ) float bias@0x170c760)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x170c0a0)\n" + " (declare (in ) vec4 coord@0x170c1b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x170c940)\n" + " (declare (in ) vec4 coord@0x170ca50)\n" + " (declare (in ) float bias@0x170cb60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x170cd40)\n" + " (declare (in ) vec3 coord@0x170ce50)\n" + " (declare (in ) float lod@0x170cf60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler3D sampler@0x170d2f0)\n" + " (declare (in ) vec4 coord@0x170d400)\n" + " (declare (in ) float lod@0x170d510)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x170d8a0)\n" + " (declare (in ) vec3 coord@0x170d9b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x170dd40)\n" + " (declare (in ) vec3 coord@0x170de50)\n" + " (declare (in ) float bias@0x170df60)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) samplerCube sampler@0x170e140)\n" + " (declare (in ) vec3 coord@0x170e250)\n" + " (declare (in ) float lod@0x170e360)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x170e6f0)\n" + " (declare (in ) vec3 coord@0x170e800)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x170f970)\n" + " (declare (in ) vec3 coord@0x170fa80)\n" + " (declare (in ) float bias@0x170fb90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DRect sampler@0x1cc28a0)\n" - " (declare (in ) vec2 coord@0x1cc29c0)\n" + " (declare (in ) sampler2DShadow sampler@0x170eb90)\n" + " (declare (in ) vec3 coord@0x170eca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x170fd70)\n" + " (declare (in ) vec3 coord@0x170fe80)\n" + " (declare (in ) float bias@0x170ff90)\n" " )\n" " (\n" " ))\n" "\n" ")\n" "\n" - "(function texture2DRectProj\n" + "(function shadow1DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DRect sampler@0x1cc2d80)\n" - " (declare (in ) vec3 coord@0x1cc2ea0)\n" + " (declare (in ) sampler1DShadow sampler@0x170f030)\n" + " (declare (in ) vec4 coord@0x170f140)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DRect sampler@0x1cc3260)\n" - " (declare (in ) vec4 coord@0x1cc3380)\n" + " (declare (in ) sampler1DShadow sampler@0x1710170)\n" + " (declare (in ) vec4 coord@0x1710280)\n" + " (declare (in ) float bias@0x1710390)\n" " )\n" " (\n" " ))\n" "\n" ")\n" "\n" - "(function shadow2DRect\n" + "(function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x170f4d0)\n" + " (declare (in ) vec4 coord@0x170f5e0)\n" + " )\n" + " (\n" + " ))\n" + "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DRectShadow sampler@0x1cc3560)\n" - " (declare (in ) vec3 coord@0x1cc3680)\n" + " (declare (in ) sampler2DShadow sampler@0x1710570)\n" + " (declare (in ) vec4 coord@0x1710680)\n" + " (declare (in ) float bias@0x1710790)\n" " )\n" " (\n" " ))\n" "\n" ")\n" "\n" - "(function shadow2DRectProj\n" + "(function shadow1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x1710970)\n" + " (declare (in ) vec3 coord@0x1710a80)\n" + " (declare (in ) float lod@0x1710b90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x1710f20)\n" + " (declare (in ) vec3 coord@0x1711030)\n" + " (declare (in ) float lod@0x1711140)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler1DShadow sampler@0x17114d0)\n" + " (declare (in ) vec4 coord@0x17115e0)\n" + " (declare (in ) float lod@0x17116f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function shadow2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) sampler2DShadow sampler@0x1711a80)\n" + " (declare (in ) vec4 coord@0x1711b90)\n" + " (declare (in ) float lod@0x1711ca0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float x@0x1712030)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec2 x@0x17123b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1712590)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1712770)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float x@0x1712950)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1712cd0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec3 x@0x1712eb0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec4 x@0x1713090)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) float x@0x1713270)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec2 x@0x17135f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec3 x@0x17137d0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in ) vec4 x@0x17139b0)\n" + " )\n" + " (\n" + " ))\n" + "\n" + ")\n" + "\n" + "(function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) float x@0x1713b90)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec2 x@0x1713f10)\n" + " )\n" + " (\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in ) vec3 x@0x17140f0)\n" + " )\n" + " (\n" + " ))\n" + "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DRectShadow sampler@0x1cc3a40)\n" - " (declare (in ) vec4 coord@0x1cc3b60)\n" + " (declare (in ) vec4 x@0x17142d0)\n" " )\n" " (\n" " ))\n" @@ -12073,19 +21546,96 @@ static const char *prototypes_for_ARB_texture_rectangle_vert = "\n" ")" ; -static const char *functions_for_ARB_texture_rectangle_vert [] = { - builtin_texture2DRect, - builtin_shadow2DRectProj, - builtin_shadow2DRect, - builtin_texture2DRectProj, +static const char *functions_for_130_vert [] = { + builtin_clamp, + builtin_matrixCompMult, + builtin_textureProj, + builtin_noise2, + builtin_texture3DProjLod, + builtin_pow, + builtin_texture2DProj, + builtin_greaterThanEqual, + builtin_sign, + builtin_texture3DProj, + builtin_textureProjLod, + builtin_texture, + builtin_texture2D, + builtin_equal, + builtin_faceforward, + builtin_tan, + builtin_shadow2DProj, + builtin_shadow1DProjLod, + builtin_any, + builtin_shadow1DProj, + builtin_normalize, + builtin_asin, + builtin_texture1DProj, + builtin_log, + builtin_floor, + builtin_exp2, + builtin_lessThan, + builtin_cross, + builtin_sqrt, + builtin_texture3DLod, + builtin_textureLod, + builtin_fract, + builtin_abs, + builtin_degrees, + builtin_shadow1DLod, + builtin_ftransform, + builtin_sin, + builtin_shadow2D, + builtin_shadow2DLod, + builtin_all, + builtin_log2, + builtin_textureGrad, + builtin_atan, + builtin_notEqual, + builtin_max, + builtin_lessThanEqual, + builtin_transpose, + builtin_outerProduct, + builtin_ceil, + builtin_reflect, + builtin_textureCubeLod, + builtin_step, + builtin_texture1D, + builtin_greaterThan, + builtin_texture3D, + builtin_shadow2DProjLod, + builtin_not, + builtin_texture2DProjLod, + builtin_inversesqrt, + builtin_mod, + builtin_noise4, + builtin_distance, + builtin_cos, + builtin_shadow1D, + builtin_noise1, + builtin_refract, + builtin_noise3, + builtin_texelFetch, + builtin_min, + builtin_radians, + builtin_smoothstep, + builtin_textureProjGrad, + builtin_texture1DProjLod, + builtin_textureCube, + builtin_length, + builtin_texture1DLod, + builtin_texture2DLod, + builtin_exp, + builtin_acos, + builtin_mix, + builtin_dot, }; static const char *prototypes_for_ARB_texture_rectangle_frag = "(\n" "(function texture2DRect\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DRect sampler@0x13d0040)\n" - " (declare (in ) vec2 coord@0x13d0160)\n" + " (declare (in ) sampler2DRect sampler@0x225e0f0)\n" + " (declare (in ) vec2 coord@0x225e200)\n" " )\n" " (\n" " ))\n" @@ -12095,16 +21645,16 @@ static const char *prototypes_for_ARB_texture_rectangle_frag = "(function texture2DRectProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DRect sampler@0x13d0520)\n" - " (declare (in ) vec3 coord@0x13d0640)\n" + " (declare (in ) sampler2DRect sampler@0x225e590)\n" + " (declare (in ) vec3 coord@0x225e6a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DRect sampler@0x13d0a00)\n" - " (declare (in ) vec4 coord@0x13d0b20)\n" + " (declare (in ) sampler2DRect sampler@0x225ea30)\n" + " (declare (in ) vec4 coord@0x225eb40)\n" " )\n" " (\n" " ))\n" @@ -12114,8 +21664,8 @@ static const char *prototypes_for_ARB_texture_rectangle_frag = "(function shadow2DRect\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DRectShadow sampler@0x13d0d00)\n" - " (declare (in ) vec3 coord@0x13d0e20)\n" + " (declare (in ) sampler2DRectShadow sampler@0x225ed20)\n" + " (declare (in ) vec3 coord@0x225ee30)\n" " )\n" " (\n" " ))\n" @@ -12125,8 +21675,8 @@ static const char *prototypes_for_ARB_texture_rectangle_frag = "(function shadow2DRectProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DRectShadow sampler@0x13d11e0)\n" - " (declare (in ) vec4 coord@0x13d1300)\n" + " (declare (in ) sampler2DRectShadow sampler@0x225f1c0)\n" + " (declare (in ) vec4 coord@0x225f2d0)\n" " )\n" " (\n" " ))\n" @@ -12147,28 +21697,28 @@ static const char *prototypes_for_120_frag = "(function radians\n" " (signature float\n" " (parameters\n" - " (declare (in ) float degrees@0x8b57e0)\n" + " (declare (in ) float degrees@0xaf8340)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 degrees@0x8b5bb0)\n" + " (declare (in ) vec2 degrees@0xaf86c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 degrees@0x8b5da0)\n" + " (declare (in ) vec3 degrees@0xaf88a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 degrees@0x8b5f90)\n" + " (declare (in ) vec4 degrees@0xaf8a80)\n" " )\n" " (\n" " ))\n" @@ -12178,28 +21728,28 @@ static const char *prototypes_for_120_frag = "(function degrees\n" " (signature float\n" " (parameters\n" - " (declare (in ) float radians@0x8b6180)\n" + " (declare (in ) float radians@0xaf8c60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 radians@0x8b6550)\n" + " (declare (in ) vec2 radians@0xaf8fe0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 radians@0x8b6740)\n" + " (declare (in ) vec3 radians@0xaf91c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 radians@0x8b6930)\n" + " (declare (in ) vec4 radians@0xaf93a0)\n" " )\n" " (\n" " ))\n" @@ -12209,28 +21759,28 @@ static const char *prototypes_for_120_frag = "(function sin\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x8b6b20)\n" + " (declare (in ) float angle@0xaf9580)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x8b6ed0)\n" + " (declare (in ) vec2 angle@0xaf9900)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x8b70b0)\n" + " (declare (in ) vec3 angle@0xaf9ae0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x8b7290)\n" + " (declare (in ) vec4 angle@0xaf9cc0)\n" " )\n" " (\n" " ))\n" @@ -12240,28 +21790,28 @@ static const char *prototypes_for_120_frag = "(function cos\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x8b7470)\n" + " (declare (in ) float angle@0xaf9ea0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x8b7820)\n" + " (declare (in ) vec2 angle@0xafa220)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x8b7a00)\n" + " (declare (in ) vec3 angle@0xafa400)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x8b7be0)\n" + " (declare (in ) vec4 angle@0xafa5e0)\n" " )\n" " (\n" " ))\n" @@ -12271,28 +21821,28 @@ static const char *prototypes_for_120_frag = "(function tan\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x8b7dc0)\n" + " (declare (in ) float angle@0xafa7c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x8b8170)\n" + " (declare (in ) vec2 angle@0xafab40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x8b8350)\n" + " (declare (in ) vec3 angle@0xafad20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x8b8530)\n" + " (declare (in ) vec4 angle@0xafaf00)\n" " )\n" " (\n" " ))\n" @@ -12302,28 +21852,28 @@ static const char *prototypes_for_120_frag = "(function asin\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x8b8710)\n" + " (declare (in ) float angle@0xafb0e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x8b8ac0)\n" + " (declare (in ) vec2 angle@0xafb460)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x8b8ca0)\n" + " (declare (in ) vec3 angle@0xafb640)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x8b8e80)\n" + " (declare (in ) vec4 angle@0xafb820)\n" " )\n" " (\n" " ))\n" @@ -12333,28 +21883,28 @@ static const char *prototypes_for_120_frag = "(function acos\n" " (signature float\n" " (parameters\n" - " (declare (in ) float angle@0x8b9060)\n" + " (declare (in ) float angle@0xafba00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 angle@0x8b9410)\n" + " (declare (in ) vec2 angle@0xafbd80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 angle@0x8b95f0)\n" + " (declare (in ) vec3 angle@0xafbf60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 angle@0x8b97d0)\n" + " (declare (in ) vec4 angle@0xafc140)\n" " )\n" " (\n" " ))\n" @@ -12364,60 +21914,60 @@ static const char *prototypes_for_120_frag = "(function atan\n" " (signature float\n" " (parameters\n" - " (declare (in ) float y@0x8b99b0)\n" - " (declare (in ) float x@0x8b9ac0)\n" + " (declare (in ) float y@0xafc320)\n" + " (declare (in ) float x@0xafc430)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 y@0x8b9e70)\n" - " (declare (in ) vec2 x@0x8b9f80)\n" + " (declare (in ) vec2 y@0xafc7b0)\n" + " (declare (in ) vec2 x@0xafc8c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 y@0x8ba160)\n" - " (declare (in ) vec3 x@0x8ba270)\n" + " (declare (in ) vec3 y@0xafcaa0)\n" + " (declare (in ) vec3 x@0xafcbb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 y@0x8ba450)\n" - " (declare (in ) vec4 x@0x8ba560)\n" + " (declare (in ) vec4 y@0xafcd90)\n" + " (declare (in ) vec4 x@0xafcea0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) float y_over_x@0x8ba740)\n" + " (declare (in ) float y_over_x@0xafd080)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 y_over_x@0x8ba930)\n" + " (declare (in ) vec2 y_over_x@0xafd270)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 y_over_x@0x8bab20)\n" + " (declare (in ) vec3 y_over_x@0xafd460)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 y_over_x@0x8bad10)\n" + " (declare (in ) vec4 y_over_x@0xafd650)\n" " )\n" " (\n" " ))\n" @@ -12427,32 +21977,32 @@ static const char *prototypes_for_120_frag = "(function pow\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8baf00)\n" - " (declare (in ) float y@0x8bb010)\n" + " (declare (in ) float x@0xafd840)\n" + " (declare (in ) float y@0xafd950)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8bb3c0)\n" - " (declare (in ) vec2 y@0x8bb4d0)\n" + " (declare (in ) vec2 x@0xafdcd0)\n" + " (declare (in ) vec2 y@0xafdde0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8bb6b0)\n" - " (declare (in ) vec3 y@0x8bb7c0)\n" + " (declare (in ) vec3 x@0xafdfc0)\n" + " (declare (in ) vec3 y@0xafe0d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8bb9a0)\n" - " (declare (in ) vec4 y@0x8bbab0)\n" + " (declare (in ) vec4 x@0xafe2b0)\n" + " (declare (in ) vec4 y@0xafe3c0)\n" " )\n" " (\n" " ))\n" @@ -12462,28 +22012,28 @@ static const char *prototypes_for_120_frag = "(function exp\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8bbc90)\n" + " (declare (in ) float x@0xafe5a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8bc040)\n" + " (declare (in ) vec2 x@0xafe920)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8bc220)\n" + " (declare (in ) vec3 x@0xafeb00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8bc400)\n" + " (declare (in ) vec4 x@0xafece0)\n" " )\n" " (\n" " ))\n" @@ -12493,28 +22043,28 @@ static const char *prototypes_for_120_frag = "(function log\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8bc5e0)\n" + " (declare (in ) float x@0xafeec0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8bc990)\n" + " (declare (in ) vec2 x@0xaff240)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8bcb70)\n" + " (declare (in ) vec3 x@0xaff420)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8bcd50)\n" + " (declare (in ) vec4 x@0xaff600)\n" " )\n" " (\n" " ))\n" @@ -12524,28 +22074,28 @@ static const char *prototypes_for_120_frag = "(function exp2\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8bcf30)\n" + " (declare (in ) float x@0xaff7e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8bd2e0)\n" + " (declare (in ) vec2 x@0xaffb60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8bd4c0)\n" + " (declare (in ) vec3 x@0xaffd40)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8bd6a0)\n" + " (declare (in ) vec4 x@0xafff20)\n" " )\n" " (\n" " ))\n" @@ -12555,28 +22105,28 @@ static const char *prototypes_for_120_frag = "(function log2\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8bd880)\n" + " (declare (in ) float x@0xb00100)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8bdc30)\n" + " (declare (in ) vec2 x@0xb00480)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8bde10)\n" + " (declare (in ) vec3 x@0xb00660)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8bdff0)\n" + " (declare (in ) vec4 x@0xb00840)\n" " )\n" " (\n" " ))\n" @@ -12586,28 +22136,28 @@ static const char *prototypes_for_120_frag = "(function sqrt\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8be1d0)\n" + " (declare (in ) float x@0xb00a20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8be580)\n" + " (declare (in ) vec2 x@0xb00da0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8be760)\n" + " (declare (in ) vec3 x@0xb00f80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8be940)\n" + " (declare (in ) vec4 x@0xb01160)\n" " )\n" " (\n" " ))\n" @@ -12617,28 +22167,28 @@ static const char *prototypes_for_120_frag = "(function inversesqrt\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8beb20)\n" + " (declare (in ) float x@0xb01340)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8beee0)\n" + " (declare (in ) vec2 x@0xb016d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8bf0c0)\n" + " (declare (in ) vec3 x@0xb018b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8bf2a0)\n" + " (declare (in ) vec4 x@0xb01a90)\n" " )\n" " (\n" " ))\n" @@ -12648,28 +22198,28 @@ static const char *prototypes_for_120_frag = "(function abs\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8bf480)\n" + " (declare (in ) float x@0xb01c70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8bf830)\n" + " (declare (in ) vec2 x@0xb01ff0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8bfa10)\n" + " (declare (in ) vec3 x@0xb021d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8bfbf0)\n" + " (declare (in ) vec4 x@0xb023b0)\n" " )\n" " (\n" " ))\n" @@ -12679,28 +22229,28 @@ static const char *prototypes_for_120_frag = "(function sign\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8bfdd0)\n" + " (declare (in ) float x@0xb02590)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c0180)\n" + " (declare (in ) vec2 x@0xb02910)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c0360)\n" + " (declare (in ) vec3 x@0xb02af0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c0540)\n" + " (declare (in ) vec4 x@0xb02cd0)\n" " )\n" " (\n" " ))\n" @@ -12710,28 +22260,28 @@ static const char *prototypes_for_120_frag = "(function floor\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8c0720)\n" + " (declare (in ) float x@0xb02eb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c0ad0)\n" + " (declare (in ) vec2 x@0xb03230)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c0cb0)\n" + " (declare (in ) vec3 x@0xb03410)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c0e90)\n" + " (declare (in ) vec4 x@0xb035f0)\n" " )\n" " (\n" " ))\n" @@ -12741,28 +22291,28 @@ static const char *prototypes_for_120_frag = "(function ceil\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8c1070)\n" + " (declare (in ) float x@0xb037d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c1420)\n" + " (declare (in ) vec2 x@0xb03b50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c1600)\n" + " (declare (in ) vec3 x@0xb03d30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c17e0)\n" + " (declare (in ) vec4 x@0xb03f10)\n" " )\n" " (\n" " ))\n" @@ -12772,28 +22322,28 @@ static const char *prototypes_for_120_frag = "(function fract\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8c19c0)\n" + " (declare (in ) float x@0xb040f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c1d70)\n" + " (declare (in ) vec2 x@0xb04470)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c1f50)\n" + " (declare (in ) vec3 x@0xb04650)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c2130)\n" + " (declare (in ) vec4 x@0xb04830)\n" " )\n" " (\n" " ))\n" @@ -12803,56 +22353,56 @@ static const char *prototypes_for_120_frag = "(function mod\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8c2310)\n" - " (declare (in ) float y@0x8c2420)\n" + " (declare (in ) float x@0xb04a10)\n" + " (declare (in ) float y@0xb04b20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c27d0)\n" - " (declare (in ) float y@0x8c28e0)\n" + " (declare (in ) vec2 x@0xb04ea0)\n" + " (declare (in ) float y@0xb04fb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c2ac0)\n" - " (declare (in ) float y@0x8c2bd0)\n" + " (declare (in ) vec3 x@0xb05190)\n" + " (declare (in ) float y@0xb052a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c2db0)\n" - " (declare (in ) float y@0x8c2ec0)\n" + " (declare (in ) vec4 x@0xb05480)\n" + " (declare (in ) float y@0xb05590)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c30a0)\n" - " (declare (in ) vec2 y@0x8c31b0)\n" + " (declare (in ) vec2 x@0xb05770)\n" + " (declare (in ) vec2 y@0xb05880)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c3390)\n" - " (declare (in ) vec3 y@0x8c34a0)\n" + " (declare (in ) vec3 x@0xb05a60)\n" + " (declare (in ) vec3 y@0xb05b70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c3680)\n" - " (declare (in ) vec4 y@0x8c3790)\n" + " (declare (in ) vec4 x@0xb05d50)\n" + " (declare (in ) vec4 y@0xb05e60)\n" " )\n" " (\n" " ))\n" @@ -12862,56 +22412,56 @@ static const char *prototypes_for_120_frag = "(function min\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8c3970)\n" - " (declare (in ) float y@0x8c3a80)\n" + " (declare (in ) float x@0xb06040)\n" + " (declare (in ) float y@0xb06150)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c3e30)\n" - " (declare (in ) vec2 y@0x8c3f40)\n" + " (declare (in ) vec2 x@0xb064d0)\n" + " (declare (in ) vec2 y@0xb065e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c4120)\n" - " (declare (in ) vec3 y@0x8c4230)\n" + " (declare (in ) vec3 x@0xb067c0)\n" + " (declare (in ) vec3 y@0xb068d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c4410)\n" - " (declare (in ) vec4 y@0x8c4520)\n" + " (declare (in ) vec4 x@0xb06ab0)\n" + " (declare (in ) vec4 y@0xb06bc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c4700)\n" - " (declare (in ) float y@0x8c4810)\n" + " (declare (in ) vec2 x@0xb06da0)\n" + " (declare (in ) float y@0xb06eb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c49f0)\n" - " (declare (in ) float y@0x8c4b00)\n" + " (declare (in ) vec3 x@0xb07090)\n" + " (declare (in ) float y@0xb071a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c4ce0)\n" - " (declare (in ) float y@0x8c4df0)\n" + " (declare (in ) vec4 x@0xb07380)\n" + " (declare (in ) float y@0xb07490)\n" " )\n" " (\n" " ))\n" @@ -12921,56 +22471,56 @@ static const char *prototypes_for_120_frag = "(function max\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8c4fd0)\n" - " (declare (in ) float y@0x8c50e0)\n" + " (declare (in ) float x@0xb07670)\n" + " (declare (in ) float y@0xb07780)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c5490)\n" - " (declare (in ) vec2 y@0x8c55a0)\n" + " (declare (in ) vec2 x@0xb07b00)\n" + " (declare (in ) vec2 y@0xb07c10)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c5780)\n" - " (declare (in ) vec3 y@0x8c5890)\n" + " (declare (in ) vec3 x@0xb07df0)\n" + " (declare (in ) vec3 y@0xb07f00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c5a70)\n" - " (declare (in ) vec4 y@0x8c5b80)\n" + " (declare (in ) vec4 x@0xb080e0)\n" + " (declare (in ) vec4 y@0xb081f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c5d60)\n" - " (declare (in ) float y@0x8c5e70)\n" + " (declare (in ) vec2 x@0xb083d0)\n" + " (declare (in ) float y@0xb084e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c6050)\n" - " (declare (in ) float y@0x8c6160)\n" + " (declare (in ) vec3 x@0xb086c0)\n" + " (declare (in ) float y@0xb087d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c6340)\n" - " (declare (in ) float y@0x8c6450)\n" + " (declare (in ) vec4 x@0xb089b0)\n" + " (declare (in ) float y@0xb08ac0)\n" " )\n" " (\n" " ))\n" @@ -12980,63 +22530,63 @@ static const char *prototypes_for_120_frag = "(function clamp\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8c6630)\n" - " (declare (in ) float minVal@0x8c6740)\n" - " (declare (in ) float maxVal@0x8c6850)\n" + " (declare (in ) float x@0xb08ca0)\n" + " (declare (in ) float minVal@0xb08db0)\n" + " (declare (in ) float maxVal@0xb08ec0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c6c00)\n" - " (declare (in ) vec2 minVal@0x8c6d10)\n" - " (declare (in ) vec2 maxVal@0x8c6e20)\n" + " (declare (in ) vec2 x@0xb09240)\n" + " (declare (in ) vec2 minVal@0xb09350)\n" + " (declare (in ) vec2 maxVal@0xb09460)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c7000)\n" - " (declare (in ) vec3 minVal@0x8c7110)\n" - " (declare (in ) vec3 maxVal@0x8c7220)\n" + " (declare (in ) vec3 x@0xb09640)\n" + " (declare (in ) vec3 minVal@0xb09750)\n" + " (declare (in ) vec3 maxVal@0xb09860)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c7400)\n" - " (declare (in ) vec4 minVal@0x8c7510)\n" - " (declare (in ) vec4 maxVal@0x8c7620)\n" + " (declare (in ) vec4 x@0xb09a40)\n" + " (declare (in ) vec4 minVal@0xb09b50)\n" + " (declare (in ) vec4 maxVal@0xb09c60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c7800)\n" - " (declare (in ) float minVal@0x8c7910)\n" - " (declare (in ) float maxVal@0x8c7a20)\n" + " (declare (in ) vec2 x@0xb09e40)\n" + " (declare (in ) float minVal@0xb09f50)\n" + " (declare (in ) float maxVal@0xb0a060)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c7c00)\n" - " (declare (in ) float minVal@0x8c7d10)\n" - " (declare (in ) float maxVal@0x8c7e20)\n" + " (declare (in ) vec3 x@0xb0a240)\n" + " (declare (in ) float minVal@0xb0a350)\n" + " (declare (in ) float maxVal@0xb0a460)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c8000)\n" - " (declare (in ) float minVal@0x8c8110)\n" - " (declare (in ) float maxVal@0x8c8220)\n" + " (declare (in ) vec4 x@0xb0a640)\n" + " (declare (in ) float minVal@0xb0a750)\n" + " (declare (in ) float maxVal@0xb0a860)\n" " )\n" " (\n" " ))\n" @@ -13046,63 +22596,63 @@ static const char *prototypes_for_120_frag = "(function mix\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8c8400)\n" - " (declare (in ) float y@0x8c8510)\n" - " (declare (in ) float a@0x8c8620)\n" + " (declare (in ) float x@0xb0aa40)\n" + " (declare (in ) float y@0xb0ab50)\n" + " (declare (in ) float a@0xb0ac60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c89d0)\n" - " (declare (in ) vec2 y@0x8c8ae0)\n" - " (declare (in ) vec2 a@0x8c8bf0)\n" + " (declare (in ) vec2 x@0xb0afe0)\n" + " (declare (in ) vec2 y@0xb0b0f0)\n" + " (declare (in ) vec2 a@0xb0b200)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c8dd0)\n" - " (declare (in ) vec3 y@0x8c8ee0)\n" - " (declare (in ) vec3 a@0x8c8ff0)\n" + " (declare (in ) vec3 x@0xb0b3e0)\n" + " (declare (in ) vec3 y@0xb0b4f0)\n" + " (declare (in ) vec3 a@0xb0b600)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c91d0)\n" - " (declare (in ) vec4 y@0x8c92e0)\n" - " (declare (in ) vec4 a@0x8c93f0)\n" + " (declare (in ) vec4 x@0xb0b7e0)\n" + " (declare (in ) vec4 y@0xb0b8f0)\n" + " (declare (in ) vec4 a@0xb0ba00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8c95d0)\n" - " (declare (in ) vec2 y@0x8c96e0)\n" - " (declare (in ) float a@0x8c97f0)\n" + " (declare (in ) vec2 x@0xb0bbe0)\n" + " (declare (in ) vec2 y@0xb0bcf0)\n" + " (declare (in ) float a@0xb0be00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8c99d0)\n" - " (declare (in ) vec3 y@0x8c9ae0)\n" - " (declare (in ) float a@0x8c9bf0)\n" + " (declare (in ) vec3 x@0xb0bfe0)\n" + " (declare (in ) vec3 y@0xb0c0f0)\n" + " (declare (in ) float a@0xb0c200)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8c9dd0)\n" - " (declare (in ) vec4 y@0x8c9ee0)\n" - " (declare (in ) float a@0x8c9ff0)\n" + " (declare (in ) vec4 x@0xb0c3e0)\n" + " (declare (in ) vec4 y@0xb0c4f0)\n" + " (declare (in ) float a@0xb0c600)\n" " )\n" " (\n" " ))\n" @@ -13112,56 +22662,56 @@ static const char *prototypes_for_120_frag = "(function step\n" " (signature float\n" " (parameters\n" - " (declare (in ) float edge@0x8ca1d0)\n" - " (declare (in ) float x@0x8ca2e0)\n" + " (declare (in ) float edge@0xb0c7e0)\n" + " (declare (in ) float x@0xb0c8f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 edge@0x8ca690)\n" - " (declare (in ) vec2 x@0x8ca7a0)\n" + " (declare (in ) vec2 edge@0xb0cc70)\n" + " (declare (in ) vec2 x@0xb0cd80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 edge@0x8ca980)\n" - " (declare (in ) vec3 x@0x8caa90)\n" + " (declare (in ) vec3 edge@0xb0cf60)\n" + " (declare (in ) vec3 x@0xb0d070)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 edge@0x8cac70)\n" - " (declare (in ) vec4 x@0x8cad80)\n" + " (declare (in ) vec4 edge@0xb0d250)\n" + " (declare (in ) vec4 x@0xb0d360)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float edge@0x8caf60)\n" - " (declare (in ) vec2 x@0x8cb070)\n" + " (declare (in ) float edge@0xb0d540)\n" + " (declare (in ) vec2 x@0xb0d650)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float edge@0x8cb250)\n" - " (declare (in ) vec3 x@0x8cb360)\n" + " (declare (in ) float edge@0xb0d830)\n" + " (declare (in ) vec3 x@0xb0d940)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float edge@0x8cb540)\n" - " (declare (in ) vec4 x@0x8cb650)\n" + " (declare (in ) float edge@0xb0db20)\n" + " (declare (in ) vec4 x@0xb0dc30)\n" " )\n" " (\n" " ))\n" @@ -13171,63 +22721,63 @@ static const char *prototypes_for_120_frag = "(function smoothstep\n" " (signature float\n" " (parameters\n" - " (declare (in ) float edge0@0x8cb830)\n" - " (declare (in ) float edge1@0x8cb940)\n" - " (declare (in ) float x@0x8cba50)\n" + " (declare (in ) float edge0@0xb0de10)\n" + " (declare (in ) float edge1@0xb0df20)\n" + " (declare (in ) float x@0xb0e030)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 edge0@0x8cbe10)\n" - " (declare (in ) vec2 edge1@0x8cbf20)\n" - " (declare (in ) vec2 x@0x8cc030)\n" + " (declare (in ) vec2 edge0@0xb0e3c0)\n" + " (declare (in ) vec2 edge1@0xb0e4d0)\n" + " (declare (in ) vec2 x@0xb0e5e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 edge0@0x8cc210)\n" - " (declare (in ) vec3 edge1@0x8cc320)\n" - " (declare (in ) vec3 x@0x8cc430)\n" + " (declare (in ) vec3 edge0@0xb0e7c0)\n" + " (declare (in ) vec3 edge1@0xb0e8d0)\n" + " (declare (in ) vec3 x@0xb0e9e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 edge0@0x8cc610)\n" - " (declare (in ) vec4 edge1@0x8cc720)\n" - " (declare (in ) vec4 x@0x8cc830)\n" + " (declare (in ) vec4 edge0@0xb0ebc0)\n" + " (declare (in ) vec4 edge1@0xb0ecd0)\n" + " (declare (in ) vec4 x@0xb0ede0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float edge0@0x8cca10)\n" - " (declare (in ) float edge1@0x8ccb20)\n" - " (declare (in ) vec2 x@0x8ccc30)\n" + " (declare (in ) float edge0@0xb0efc0)\n" + " (declare (in ) float edge1@0xb0f0d0)\n" + " (declare (in ) vec2 x@0xb0f1e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float edge0@0x8cce10)\n" - " (declare (in ) float edge1@0x8ccf20)\n" - " (declare (in ) vec3 x@0x8cd030)\n" + " (declare (in ) float edge0@0xb0f3c0)\n" + " (declare (in ) float edge1@0xb0f4d0)\n" + " (declare (in ) vec3 x@0xb0f5e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float edge0@0x8cd210)\n" - " (declare (in ) float edge1@0x8cd320)\n" - " (declare (in ) vec4 x@0x8cd430)\n" + " (declare (in ) float edge0@0xb0f7c0)\n" + " (declare (in ) float edge1@0xb0f8d0)\n" + " (declare (in ) vec4 x@0xb0f9e0)\n" " )\n" " (\n" " ))\n" @@ -13237,28 +22787,28 @@ static const char *prototypes_for_120_frag = "(function length\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8cd610)\n" + " (declare (in ) float x@0xb0fbc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x8cd9c0)\n" + " (declare (in ) vec2 x@0xb0ff40)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x8cdba0)\n" + " (declare (in ) vec3 x@0xb10120)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x8cdd80)\n" + " (declare (in ) vec4 x@0xb10300)\n" " )\n" " (\n" " ))\n" @@ -13268,32 +22818,32 @@ static const char *prototypes_for_120_frag = "(function distance\n" " (signature float\n" " (parameters\n" - " (declare (in ) float p0@0x8cdf60)\n" - " (declare (in ) float p1@0x8ce070)\n" + " (declare (in ) float p0@0xb104e0)\n" + " (declare (in ) float p1@0xb105f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 p0@0x8ce430)\n" - " (declare (in ) vec2 p1@0x8ce540)\n" + " (declare (in ) vec2 p0@0xb10980)\n" + " (declare (in ) vec2 p1@0xb10a90)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 p0@0x8ce720)\n" - " (declare (in ) vec3 p1@0x8ce830)\n" + " (declare (in ) vec3 p0@0xb10c70)\n" + " (declare (in ) vec3 p1@0xb10d80)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 p0@0x8cea10)\n" - " (declare (in ) vec4 p1@0x8ceb20)\n" + " (declare (in ) vec4 p0@0xb10f60)\n" + " (declare (in ) vec4 p1@0xb11070)\n" " )\n" " (\n" " ))\n" @@ -13303,32 +22853,32 @@ static const char *prototypes_for_120_frag = "(function dot\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8ced00)\n" - " (declare (in ) float y@0x8cee10)\n" + " (declare (in ) float x@0xb11250)\n" + " (declare (in ) float y@0xb11360)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x8cf1c0)\n" - " (declare (in ) vec2 y@0x8cf2d0)\n" + " (declare (in ) vec2 x@0xb116e0)\n" + " (declare (in ) vec2 y@0xb117f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x8cf4b0)\n" - " (declare (in ) vec3 y@0x8cf5c0)\n" + " (declare (in ) vec3 x@0xb119d0)\n" + " (declare (in ) vec3 y@0xb11ae0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x8cf7a0)\n" - " (declare (in ) vec4 y@0x8cf8b0)\n" + " (declare (in ) vec4 x@0xb11cc0)\n" + " (declare (in ) vec4 y@0xb11dd0)\n" " )\n" " (\n" " ))\n" @@ -13338,8 +22888,8 @@ static const char *prototypes_for_120_frag = "(function cross\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8cfa90)\n" - " (declare (in ) vec3 y@0x8cfba0)\n" + " (declare (in ) vec3 x@0xb11fb0)\n" + " (declare (in ) vec3 y@0xb120c0)\n" " )\n" " (\n" " ))\n" @@ -13349,28 +22899,28 @@ static const char *prototypes_for_120_frag = "(function normalize\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8cff50)\n" + " (declare (in ) float x@0xb12440)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8d0310)\n" + " (declare (in ) vec2 x@0xb127d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8d04f0)\n" + " (declare (in ) vec3 x@0xb129b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8d06d0)\n" + " (declare (in ) vec4 x@0xb12b90)\n" " )\n" " (\n" " ))\n" @@ -13380,36 +22930,36 @@ static const char *prototypes_for_120_frag = "(function faceforward\n" " (signature float\n" " (parameters\n" - " (declare (in ) float N@0x8d08b0)\n" - " (declare (in ) float I@0x8d09c0)\n" - " (declare (in ) float Nref@0x8d0ad0)\n" + " (declare (in ) float N@0xb12d70)\n" + " (declare (in ) float I@0xb12e80)\n" + " (declare (in ) float Nref@0xb12f90)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 N@0x8d0e90)\n" - " (declare (in ) vec2 I@0x8d0fa0)\n" - " (declare (in ) vec2 Nref@0x8d10b0)\n" + " (declare (in ) vec2 N@0xb13320)\n" + " (declare (in ) vec2 I@0xb13430)\n" + " (declare (in ) vec2 Nref@0xb13540)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 N@0x8d1290)\n" - " (declare (in ) vec3 I@0x8d13a0)\n" - " (declare (in ) vec3 Nref@0x8d14b0)\n" + " (declare (in ) vec3 N@0xb13720)\n" + " (declare (in ) vec3 I@0xb13830)\n" + " (declare (in ) vec3 Nref@0xb13940)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 N@0x8d1690)\n" - " (declare (in ) vec4 I@0x8d17a0)\n" - " (declare (in ) vec4 Nref@0x8d18b0)\n" + " (declare (in ) vec4 N@0xb13b20)\n" + " (declare (in ) vec4 I@0xb13c30)\n" + " (declare (in ) vec4 Nref@0xb13d40)\n" " )\n" " (\n" " ))\n" @@ -13419,32 +22969,32 @@ static const char *prototypes_for_120_frag = "(function reflect\n" " (signature float\n" " (parameters\n" - " (declare (in ) float I@0x8d1a90)\n" - " (declare (in ) float N@0x8d1ba0)\n" + " (declare (in ) float I@0xb13f20)\n" + " (declare (in ) float N@0xb14030)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 I@0x8d1f60)\n" - " (declare (in ) vec2 N@0x8d2070)\n" + " (declare (in ) vec2 I@0xb143b0)\n" + " (declare (in ) vec2 N@0xb144c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 I@0x8d2250)\n" - " (declare (in ) vec3 N@0x8d2360)\n" + " (declare (in ) vec3 I@0xb146a0)\n" + " (declare (in ) vec3 N@0xb147b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 I@0x8d2540)\n" - " (declare (in ) vec4 N@0x8d2650)\n" + " (declare (in ) vec4 I@0xb14990)\n" + " (declare (in ) vec4 N@0xb14aa0)\n" " )\n" " (\n" " ))\n" @@ -13454,36 +23004,36 @@ static const char *prototypes_for_120_frag = "(function refract\n" " (signature float\n" " (parameters\n" - " (declare (in ) float I@0x8d2830)\n" - " (declare (in ) float N@0x8d2940)\n" - " (declare (in ) float eta@0x8d2a50)\n" + " (declare (in ) float I@0xb14c80)\n" + " (declare (in ) float N@0xb14d90)\n" + " (declare (in ) float eta@0xb14ea0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 I@0x8d2e10)\n" - " (declare (in ) vec2 N@0x8d2f20)\n" - " (declare (in ) float eta@0x8d3030)\n" + " (declare (in ) vec2 I@0xb15220)\n" + " (declare (in ) vec2 N@0xb15330)\n" + " (declare (in ) float eta@0xb15440)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 I@0x8d3210)\n" - " (declare (in ) vec3 N@0x8d3320)\n" - " (declare (in ) float eta@0x8d3430)\n" + " (declare (in ) vec3 I@0xb15620)\n" + " (declare (in ) vec3 N@0xb15730)\n" + " (declare (in ) float eta@0xb15840)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 I@0x8d3610)\n" - " (declare (in ) vec4 N@0x8d3720)\n" - " (declare (in ) float eta@0x8d3830)\n" + " (declare (in ) vec4 I@0xb15a20)\n" + " (declare (in ) vec4 N@0xb15b30)\n" + " (declare (in ) float eta@0xb15c40)\n" " )\n" " (\n" " ))\n" @@ -13493,72 +23043,72 @@ static const char *prototypes_for_120_frag = "(function matrixCompMult\n" " (signature mat2\n" " (parameters\n" - " (declare (in ) mat2 x@0x8d3a10)\n" - " (declare (in ) mat2 y@0x8d3b20)\n" + " (declare (in ) mat2 x@0xb15e20)\n" + " (declare (in ) mat2 y@0xb15f30)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3\n" " (parameters\n" - " (declare (in ) mat3 x@0x8d3ee0)\n" - " (declare (in ) mat3 y@0x8d3ff0)\n" + " (declare (in ) mat3 x@0xb162c0)\n" + " (declare (in ) mat3 y@0xb163d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4\n" " (parameters\n" - " (declare (in ) mat4 x@0x8d41d0)\n" - " (declare (in ) mat4 y@0x8d42e0)\n" + " (declare (in ) mat4 x@0xb165b0)\n" + " (declare (in ) mat4 y@0xb166c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x3\n" " (parameters\n" - " (declare (in ) mat2x3 x@0x8d44c0)\n" - " (declare (in ) mat2x3 y@0x8d45d0)\n" + " (declare (in ) mat2x3 x@0xb168a0)\n" + " (declare (in ) mat2x3 y@0xb169b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x4\n" " (parameters\n" - " (declare (in ) mat2x4 x@0x8d47b0)\n" - " (declare (in ) mat2x4 y@0x8d48c0)\n" + " (declare (in ) mat2x4 x@0xb16b90)\n" + " (declare (in ) mat2x4 y@0xb16ca0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x2\n" " (parameters\n" - " (declare (in ) mat3x2 x@0x8d4aa0)\n" - " (declare (in ) mat3x2 y@0x8d4bb0)\n" + " (declare (in ) mat3x2 x@0xb16e80)\n" + " (declare (in ) mat3x2 y@0xb16f90)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x4\n" " (parameters\n" - " (declare (in ) mat3x4 x@0x8d4d90)\n" - " (declare (in ) mat3x4 y@0x8d4ea0)\n" + " (declare (in ) mat3x4 x@0xb17170)\n" + " (declare (in ) mat3x4 y@0xb17280)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x2\n" " (parameters\n" - " (declare (in ) mat4x2 x@0x8d5080)\n" - " (declare (in ) mat4x2 y@0x8d5190)\n" + " (declare (in ) mat4x2 x@0xb17460)\n" + " (declare (in ) mat4x2 y@0xb17570)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x3\n" " (parameters\n" - " (declare (in ) mat4x3 x@0x8d5370)\n" - " (declare (in ) mat4x3 y@0x8d5480)\n" + " (declare (in ) mat4x3 x@0xb17750)\n" + " (declare (in ) mat4x3 y@0xb17860)\n" " )\n" " (\n" " ))\n" @@ -13568,72 +23118,72 @@ static const char *prototypes_for_120_frag = "(function outerProduct\n" " (signature mat2\n" " (parameters\n" - " (declare (in ) vec2 c@0x8d5660)\n" - " (declare (in ) vec2 r@0x8d5770)\n" + " (declare (in ) vec2 c@0xb17a40)\n" + " (declare (in ) vec2 r@0xb17b50)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3\n" " (parameters\n" - " (declare (in ) vec3 c@0x8d5b30)\n" - " (declare (in ) vec3 r@0x8d5c40)\n" + " (declare (in ) vec3 c@0xb17ee0)\n" + " (declare (in ) vec3 r@0xb17ff0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4\n" " (parameters\n" - " (declare (in ) vec4 c@0x8d5e20)\n" - " (declare (in ) vec4 r@0x8d5f30)\n" + " (declare (in ) vec4 c@0xb181d0)\n" + " (declare (in ) vec4 r@0xb182e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x3\n" " (parameters\n" - " (declare (in ) vec3 c@0x8d6110)\n" - " (declare (in ) vec2 r@0x8d6220)\n" + " (declare (in ) vec3 c@0xb184c0)\n" + " (declare (in ) vec2 r@0xb185d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x2\n" " (parameters\n" - " (declare (in ) vec2 c@0x8d6400)\n" - " (declare (in ) vec3 r@0x8d6510)\n" + " (declare (in ) vec2 c@0xb187b0)\n" + " (declare (in ) vec3 r@0xb188c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x4\n" " (parameters\n" - " (declare (in ) vec4 c@0x8d66f0)\n" - " (declare (in ) vec2 r@0x8d6800)\n" + " (declare (in ) vec4 c@0xb18aa0)\n" + " (declare (in ) vec2 r@0xb18bb0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x2\n" " (parameters\n" - " (declare (in ) vec2 c@0x8d69e0)\n" - " (declare (in ) vec4 r@0x8d6af0)\n" + " (declare (in ) vec2 c@0xb18d90)\n" + " (declare (in ) vec4 r@0xb18ea0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x4\n" " (parameters\n" - " (declare (in ) vec4 c@0x8d6cd0)\n" - " (declare (in ) vec3 r@0x8d6de0)\n" + " (declare (in ) vec4 c@0xb19080)\n" + " (declare (in ) vec3 r@0xb19190)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x3\n" " (parameters\n" - " (declare (in ) vec3 c@0x8d6fc0)\n" - " (declare (in ) vec4 r@0x8d70d0)\n" + " (declare (in ) vec3 c@0xb19370)\n" + " (declare (in ) vec4 r@0xb19480)\n" " )\n" " (\n" " ))\n" @@ -13643,63 +23193,63 @@ static const char *prototypes_for_120_frag = "(function transpose\n" " (signature mat2\n" " (parameters\n" - " (declare (in ) mat2 m@0x8d72b0)\n" + " (declare (in ) mat2 m@0xb19660)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3\n" " (parameters\n" - " (declare (in ) mat3 m@0x8d7670)\n" + " (declare (in ) mat3 m@0xb199f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4\n" " (parameters\n" - " (declare (in ) mat4 m@0x8d7850)\n" + " (declare (in ) mat4 m@0xb19bd0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x3\n" " (parameters\n" - " (declare (in ) mat3x2 m@0x8d7a30)\n" + " (declare (in ) mat3x2 m@0xb19db0)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x2\n" " (parameters\n" - " (declare (in ) mat2x3 m@0x8d7c10)\n" + " (declare (in ) mat2x3 m@0xb19f90)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat2x4\n" " (parameters\n" - " (declare (in ) mat4x2 m@0x8d7df0)\n" + " (declare (in ) mat4x2 m@0xb1a170)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x2\n" " (parameters\n" - " (declare (in ) mat2x4 m@0x8d7fd0)\n" + " (declare (in ) mat2x4 m@0xb1a350)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat3x4\n" " (parameters\n" - " (declare (in ) mat4x3 m@0x8d81b0)\n" + " (declare (in ) mat4x3 m@0xb1a530)\n" " )\n" " (\n" " ))\n" "\n" " (signature mat4x3\n" " (parameters\n" - " (declare (in ) mat3x4 m@0x8d8390)\n" + " (declare (in ) mat3x4 m@0xb1a710)\n" " )\n" " (\n" " ))\n" @@ -13709,48 +23259,48 @@ static const char *prototypes_for_120_frag = "(function lessThan\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8d8570)\n" - " (declare (in ) vec2 y@0x8d8680)\n" + " (declare (in ) vec2 x@0xb1a8f0)\n" + " (declare (in ) vec2 y@0xb1aa00)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8d8a40)\n" - " (declare (in ) vec3 y@0x8d8b50)\n" + " (declare (in ) vec3 x@0xb1ad90)\n" + " (declare (in ) vec3 y@0xb1aea0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8d8d30)\n" - " (declare (in ) vec4 y@0x8d8e40)\n" + " (declare (in ) vec4 x@0xb1b080)\n" + " (declare (in ) vec4 y@0xb1b190)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x8d9020)\n" - " (declare (in ) ivec2 y@0x8d9130)\n" + " (declare (in ) ivec2 x@0xb1b370)\n" + " (declare (in ) ivec2 y@0xb1b480)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x8d9310)\n" - " (declare (in ) ivec3 y@0x8d9420)\n" + " (declare (in ) ivec3 x@0xb1b660)\n" + " (declare (in ) ivec3 y@0xb1b770)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x8d9600)\n" - " (declare (in ) ivec4 y@0x8d9710)\n" + " (declare (in ) ivec4 x@0xb1b950)\n" + " (declare (in ) ivec4 y@0xb1ba60)\n" " )\n" " (\n" " ))\n" @@ -13760,48 +23310,48 @@ static const char *prototypes_for_120_frag = "(function lessThanEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8d98f0)\n" - " (declare (in ) vec2 y@0x8d9a00)\n" + " (declare (in ) vec2 x@0xb1bc40)\n" + " (declare (in ) vec2 y@0xb1bd50)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8d9dc0)\n" - " (declare (in ) vec3 y@0x8d9ed0)\n" + " (declare (in ) vec3 x@0xb1c0e0)\n" + " (declare (in ) vec3 y@0xb1c1f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8da0b0)\n" - " (declare (in ) vec4 y@0x8da1c0)\n" + " (declare (in ) vec4 x@0xb1c3d0)\n" + " (declare (in ) vec4 y@0xb1c4e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x8da3a0)\n" - " (declare (in ) ivec2 y@0x8da4b0)\n" + " (declare (in ) ivec2 x@0xb1c6c0)\n" + " (declare (in ) ivec2 y@0xb1c7d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x8da690)\n" - " (declare (in ) ivec3 y@0x8da7a0)\n" + " (declare (in ) ivec3 x@0xb1c9b0)\n" + " (declare (in ) ivec3 y@0xb1cac0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x8da980)\n" - " (declare (in ) ivec4 y@0x8daa90)\n" + " (declare (in ) ivec4 x@0xb1cca0)\n" + " (declare (in ) ivec4 y@0xb1cdb0)\n" " )\n" " (\n" " ))\n" @@ -13811,48 +23361,48 @@ static const char *prototypes_for_120_frag = "(function greaterThan\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8dac70)\n" - " (declare (in ) vec2 y@0x8dad80)\n" + " (declare (in ) vec2 x@0xb1cf90)\n" + " (declare (in ) vec2 y@0xb1d0a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8db140)\n" - " (declare (in ) vec3 y@0x8db250)\n" + " (declare (in ) vec3 x@0xb1d430)\n" + " (declare (in ) vec3 y@0xb1d540)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8db430)\n" - " (declare (in ) vec4 y@0x8db540)\n" + " (declare (in ) vec4 x@0xb1d720)\n" + " (declare (in ) vec4 y@0xb1d830)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x8db720)\n" - " (declare (in ) ivec2 y@0x8db830)\n" + " (declare (in ) ivec2 x@0xb1da10)\n" + " (declare (in ) ivec2 y@0xb1db20)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x8dba10)\n" - " (declare (in ) ivec3 y@0x8dbb20)\n" + " (declare (in ) ivec3 x@0xb1dd00)\n" + " (declare (in ) ivec3 y@0xb1de10)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x8dbd00)\n" - " (declare (in ) ivec4 y@0x8dbe10)\n" + " (declare (in ) ivec4 x@0xb1dff0)\n" + " (declare (in ) ivec4 y@0xb1e100)\n" " )\n" " (\n" " ))\n" @@ -13862,48 +23412,48 @@ static const char *prototypes_for_120_frag = "(function greaterThanEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8dbff0)\n" - " (declare (in ) vec2 y@0x8dc100)\n" + " (declare (in ) vec2 x@0xb1e2e0)\n" + " (declare (in ) vec2 y@0xb1e3f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8dc4c0)\n" - " (declare (in ) vec3 y@0x8dc5d0)\n" + " (declare (in ) vec3 x@0xb1e780)\n" + " (declare (in ) vec3 y@0xb1e890)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8dc7b0)\n" - " (declare (in ) vec4 y@0x8dc8c0)\n" + " (declare (in ) vec4 x@0xb1ea70)\n" + " (declare (in ) vec4 y@0xb1eb80)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x8dcaa0)\n" - " (declare (in ) ivec2 y@0x8dcbb0)\n" + " (declare (in ) ivec2 x@0xb1ed60)\n" + " (declare (in ) ivec2 y@0xb1ee70)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x8dcd90)\n" - " (declare (in ) ivec3 y@0x8dcea0)\n" + " (declare (in ) ivec3 x@0xb1f050)\n" + " (declare (in ) ivec3 y@0xb1f160)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x8dd080)\n" - " (declare (in ) ivec4 y@0x8dd190)\n" + " (declare (in ) ivec4 x@0xb1f340)\n" + " (declare (in ) ivec4 y@0xb1f450)\n" " )\n" " (\n" " ))\n" @@ -13913,72 +23463,72 @@ static const char *prototypes_for_120_frag = "(function equal\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8dd370)\n" - " (declare (in ) vec2 y@0x8dd480)\n" + " (declare (in ) vec2 x@0xb1f630)\n" + " (declare (in ) vec2 y@0xb1f740)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8dd830)\n" - " (declare (in ) vec3 y@0x8dd940)\n" + " (declare (in ) vec3 x@0xb1fac0)\n" + " (declare (in ) vec3 y@0xb1fbd0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8ddb20)\n" - " (declare (in ) vec4 y@0x8ddc30)\n" + " (declare (in ) vec4 x@0xb1fdb0)\n" + " (declare (in ) vec4 y@0xb1fec0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x8dde10)\n" - " (declare (in ) ivec2 y@0x8ddf20)\n" + " (declare (in ) ivec2 x@0xb200a0)\n" + " (declare (in ) ivec2 y@0xb201b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x8de100)\n" - " (declare (in ) ivec3 y@0x8de210)\n" + " (declare (in ) ivec3 x@0xb20390)\n" + " (declare (in ) ivec3 y@0xb204a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x8de3f0)\n" - " (declare (in ) ivec4 y@0x8de500)\n" + " (declare (in ) ivec4 x@0xb20680)\n" + " (declare (in ) ivec4 y@0xb20790)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0x8de6e0)\n" - " (declare (in ) bvec2 y@0x8de7f0)\n" + " (declare (in ) bvec2 x@0xb20970)\n" + " (declare (in ) bvec2 y@0xb20a80)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0x8de9d0)\n" - " (declare (in ) bvec3 y@0x8deae0)\n" + " (declare (in ) bvec3 x@0xb20c60)\n" + " (declare (in ) bvec3 y@0xb20d70)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0x8decc0)\n" - " (declare (in ) bvec4 y@0x8dedd0)\n" + " (declare (in ) bvec4 x@0xb20f50)\n" + " (declare (in ) bvec4 y@0xb21060)\n" " )\n" " (\n" " ))\n" @@ -13988,72 +23538,72 @@ static const char *prototypes_for_120_frag = "(function notEqual\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8defb0)\n" - " (declare (in ) vec2 y@0x8df0c0)\n" + " (declare (in ) vec2 x@0xb21240)\n" + " (declare (in ) vec2 y@0xb21350)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8df480)\n" - " (declare (in ) vec3 y@0x8df590)\n" + " (declare (in ) vec3 x@0xb216e0)\n" + " (declare (in ) vec3 y@0xb217f0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8df770)\n" - " (declare (in ) vec4 y@0x8df880)\n" + " (declare (in ) vec4 x@0xb219d0)\n" + " (declare (in ) vec4 y@0xb21ae0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) ivec2 x@0x8dfa60)\n" - " (declare (in ) ivec2 y@0x8dfb70)\n" + " (declare (in ) ivec2 x@0xb21cc0)\n" + " (declare (in ) ivec2 y@0xb21dd0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) ivec3 x@0x8dfd50)\n" - " (declare (in ) ivec3 y@0x8dfe60)\n" + " (declare (in ) ivec3 x@0xb21fb0)\n" + " (declare (in ) ivec3 y@0xb220c0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) ivec4 x@0x8e0040)\n" - " (declare (in ) ivec4 y@0x8e0150)\n" + " (declare (in ) ivec4 x@0xb222a0)\n" + " (declare (in ) ivec4 y@0xb223b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0x8e0330)\n" - " (declare (in ) bvec2 y@0x8e0440)\n" + " (declare (in ) bvec2 x@0xb22590)\n" + " (declare (in ) bvec2 y@0xb226a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0x8e0620)\n" - " (declare (in ) bvec3 y@0x8e0730)\n" + " (declare (in ) bvec3 x@0xb22880)\n" + " (declare (in ) bvec3 y@0xb22990)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0x8e0910)\n" - " (declare (in ) bvec4 y@0x8e0a20)\n" + " (declare (in ) bvec4 x@0xb22b70)\n" + " (declare (in ) bvec4 y@0xb22c80)\n" " )\n" " (\n" " ))\n" @@ -14063,21 +23613,21 @@ static const char *prototypes_for_120_frag = "(function any\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec2 x@0x8e0c00)\n" + " (declare (in ) bvec2 x@0xb22e60)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec3 x@0x8e0fb0)\n" + " (declare (in ) bvec3 x@0xb231e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec4 x@0x8e1190)\n" + " (declare (in ) bvec4 x@0xb233c0)\n" " )\n" " (\n" " ))\n" @@ -14087,21 +23637,21 @@ static const char *prototypes_for_120_frag = "(function all\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec2 x@0x8e1370)\n" + " (declare (in ) bvec2 x@0xb235a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec3 x@0x8e1720)\n" + " (declare (in ) bvec3 x@0xb23920)\n" " )\n" " (\n" " ))\n" "\n" " (signature bool\n" " (parameters\n" - " (declare (in ) bvec4 x@0x8e1900)\n" + " (declare (in ) bvec4 x@0xb23b00)\n" " )\n" " (\n" " ))\n" @@ -14111,21 +23661,21 @@ static const char *prototypes_for_120_frag = "(function not\n" " (signature bvec2\n" " (parameters\n" - " (declare (in ) bvec2 x@0x8e1ae0)\n" + " (declare (in ) bvec2 x@0xb23ce0)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec3\n" " (parameters\n" - " (declare (in ) bvec3 x@0x8e1e90)\n" + " (declare (in ) bvec3 x@0xb24060)\n" " )\n" " (\n" " ))\n" "\n" " (signature bvec4\n" " (parameters\n" - " (declare (in ) bvec4 x@0x8e2070)\n" + " (declare (in ) bvec4 x@0xb24240)\n" " )\n" " (\n" " ))\n" @@ -14135,17 +23685,17 @@ static const char *prototypes_for_120_frag = "(function texture1D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x8e2250)\n" - " (declare (in ) float coord@0x8e2370)\n" + " (declare (in ) sampler1D sampler@0xb24420)\n" + " (declare (in ) float coord@0xb24530)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x8e2f10)\n" - " (declare (in ) float coord@0x8e3030)\n" - " (declare (in ) float bias@0x8e3140)\n" + " (declare (in ) sampler1D sampler@0xb25050)\n" + " (declare (in ) float coord@0xb25160)\n" + " (declare (in ) float bias@0xb25270)\n" " )\n" " (\n" " ))\n" @@ -14155,34 +23705,34 @@ static const char *prototypes_for_120_frag = "(function texture1DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x8e2730)\n" - " (declare (in ) vec2 coord@0x8e2850)\n" + " (declare (in ) sampler1D sampler@0xb248c0)\n" + " (declare (in ) vec2 coord@0xb249d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x8e2c10)\n" - " (declare (in ) vec4 coord@0x8e2d30)\n" + " (declare (in ) sampler1D sampler@0xb24d60)\n" + " (declare (in ) vec4 coord@0xb24e70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x8e3320)\n" - " (declare (in ) vec2 coord@0x8e3440)\n" - " (declare (in ) float bias@0x8e3550)\n" + " (declare (in ) sampler1D sampler@0xb25450)\n" + " (declare (in ) vec2 coord@0xb25560)\n" + " (declare (in ) float bias@0xb25670)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1D sampler@0x8e3730)\n" - " (declare (in ) vec4 coord@0x8e3850)\n" - " (declare (in ) float bias@0x8e3960)\n" + " (declare (in ) sampler1D sampler@0xb25850)\n" + " (declare (in ) vec4 coord@0xb25960)\n" + " (declare (in ) float bias@0xb25a70)\n" " )\n" " (\n" " ))\n" @@ -14192,17 +23742,17 @@ static const char *prototypes_for_120_frag = "(function texture2D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x8e3b40)\n" - " (declare (in ) vec2 coord@0x8e3c60)\n" + " (declare (in ) sampler2D sampler@0xb25c50)\n" + " (declare (in ) vec2 coord@0xb25d60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x8e4800)\n" - " (declare (in ) vec2 coord@0x8e4920)\n" - " (declare (in ) float bias@0x8e4a30)\n" + " (declare (in ) sampler2D sampler@0xb26880)\n" + " (declare (in ) vec2 coord@0xb26990)\n" + " (declare (in ) float bias@0xb26aa0)\n" " )\n" " (\n" " ))\n" @@ -14212,34 +23762,34 @@ static const char *prototypes_for_120_frag = "(function texture2DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x8e4020)\n" - " (declare (in ) vec3 coord@0x8e4140)\n" + " (declare (in ) sampler2D sampler@0xb260f0)\n" + " (declare (in ) vec3 coord@0xb26200)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x8e4500)\n" - " (declare (in ) vec4 coord@0x8e4620)\n" + " (declare (in ) sampler2D sampler@0xb26590)\n" + " (declare (in ) vec4 coord@0xb266a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x8e4c10)\n" - " (declare (in ) vec3 coord@0x8e4d30)\n" - " (declare (in ) float bias@0x8e4e40)\n" + " (declare (in ) sampler2D sampler@0xb26c80)\n" + " (declare (in ) vec3 coord@0xb26d90)\n" + " (declare (in ) float bias@0xb26ea0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2D sampler@0x8e5020)\n" - " (declare (in ) vec4 coord@0x8e5140)\n" - " (declare (in ) float bias@0x8e5250)\n" + " (declare (in ) sampler2D sampler@0xb27080)\n" + " (declare (in ) vec4 coord@0xb27190)\n" + " (declare (in ) float bias@0xb272a0)\n" " )\n" " (\n" " ))\n" @@ -14249,17 +23799,17 @@ static const char *prototypes_for_120_frag = "(function texture3D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x8e5430)\n" - " (declare (in ) vec3 coord@0x8e5550)\n" + " (declare (in ) sampler3D sampler@0xb27480)\n" + " (declare (in ) vec3 coord@0xb27590)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x8e5df0)\n" - " (declare (in ) vec3 coord@0x8e5f10)\n" - " (declare (in ) float bias@0x8e6020)\n" + " (declare (in ) sampler3D sampler@0xb27dc0)\n" + " (declare (in ) vec3 coord@0xb27ed0)\n" + " (declare (in ) float bias@0xb27fe0)\n" " )\n" " (\n" " ))\n" @@ -14269,17 +23819,17 @@ static const char *prototypes_for_120_frag = "(function texture3DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x8e5910)\n" - " (declare (in ) vec4 coord@0x8e5a30)\n" + " (declare (in ) sampler3D sampler@0xb27920)\n" + " (declare (in ) vec4 coord@0xb27a30)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler3D sampler@0x8e6200)\n" - " (declare (in ) vec4 coord@0x8e6320)\n" - " (declare (in ) float bias@0x8e6430)\n" + " (declare (in ) sampler3D sampler@0xb281c0)\n" + " (declare (in ) vec4 coord@0xb282d0)\n" + " (declare (in ) float bias@0xb283e0)\n" " )\n" " (\n" " ))\n" @@ -14289,17 +23839,17 @@ static const char *prototypes_for_120_frag = "(function textureCube\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) samplerCube sampler@0x8e6610)\n" - " (declare (in ) vec3 coord@0x8e6730)\n" + " (declare (in ) samplerCube sampler@0xb285c0)\n" + " (declare (in ) vec3 coord@0xb286d0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) samplerCube sampler@0x8e6af0)\n" - " (declare (in ) vec3 coord@0x8e6c10)\n" - " (declare (in ) float bias@0x8e6d20)\n" + " (declare (in ) samplerCube sampler@0xb28a60)\n" + " (declare (in ) vec3 coord@0xb28b70)\n" + " (declare (in ) float bias@0xb28c80)\n" " )\n" " (\n" " ))\n" @@ -14309,17 +23859,17 @@ static const char *prototypes_for_120_frag = "(function shadow1D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x8e6f00)\n" - " (declare (in ) vec3 coord@0x8e7020)\n" + " (declare (in ) sampler1DShadow sampler@0xb28e60)\n" + " (declare (in ) vec3 coord@0xb28f70)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x8e8280)\n" - " (declare (in ) vec3 coord@0x8e83a0)\n" - " (declare (in ) float bias@0x8e84b0)\n" + " (declare (in ) sampler1DShadow sampler@0xb2a0e0)\n" + " (declare (in ) vec3 coord@0xb2a1f0)\n" + " (declare (in ) float bias@0xb2a300)\n" " )\n" " (\n" " ))\n" @@ -14329,17 +23879,17 @@ static const char *prototypes_for_120_frag = "(function shadow2D\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x8e73e0)\n" - " (declare (in ) vec3 coord@0x8e7500)\n" + " (declare (in ) sampler2DShadow sampler@0xb29300)\n" + " (declare (in ) vec3 coord@0xb29410)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x8e8690)\n" - " (declare (in ) vec3 coord@0x8e87b0)\n" - " (declare (in ) float bias@0x8e88c0)\n" + " (declare (in ) sampler2DShadow sampler@0xb2a4e0)\n" + " (declare (in ) vec3 coord@0xb2a5f0)\n" + " (declare (in ) float bias@0xb2a700)\n" " )\n" " (\n" " ))\n" @@ -14349,17 +23899,17 @@ static const char *prototypes_for_120_frag = "(function shadow1DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x8e78c0)\n" - " (declare (in ) vec4 coord@0x8e79e0)\n" + " (declare (in ) sampler1DShadow sampler@0xb297a0)\n" + " (declare (in ) vec4 coord@0xb298b0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler1DShadow sampler@0x8e8aa0)\n" - " (declare (in ) vec4 coord@0x8e8bc0)\n" - " (declare (in ) float bias@0x8e8cd0)\n" + " (declare (in ) sampler1DShadow sampler@0xb2a8e0)\n" + " (declare (in ) vec4 coord@0xb2a9f0)\n" + " (declare (in ) float bias@0xb2ab00)\n" " )\n" " (\n" " ))\n" @@ -14369,17 +23919,17 @@ static const char *prototypes_for_120_frag = "(function shadow2DProj\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x8e7da0)\n" - " (declare (in ) vec4 coord@0x8e7ec0)\n" + " (declare (in ) sampler2DShadow sampler@0xb29c40)\n" + " (declare (in ) vec4 coord@0xb29d50)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) sampler2DShadow sampler@0x8e8eb0)\n" - " (declare (in ) vec4 coord@0x8e8fd0)\n" - " (declare (in ) float bias@0x8e90e0)\n" + " (declare (in ) sampler2DShadow sampler@0xb2ace0)\n" + " (declare (in ) vec4 coord@0xb2adf0)\n" + " (declare (in ) float bias@0xb2af00)\n" " )\n" " (\n" " ))\n" @@ -14389,28 +23939,28 @@ static const char *prototypes_for_120_frag = "(function dFdx\n" " (signature float\n" " (parameters\n" - " (declare (in ) float p@0x8e92c0)\n" + " (declare (in ) float p@0xb2b0e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 p@0x8e9670)\n" + " (declare (in ) vec2 p@0xb2b460)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 p@0x8e9850)\n" + " (declare (in ) vec3 p@0xb2b640)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 p@0x8e9a30)\n" + " (declare (in ) vec4 p@0xb2b820)\n" " )\n" " (\n" " ))\n" @@ -14420,28 +23970,28 @@ static const char *prototypes_for_120_frag = "(function dFdy\n" " (signature float\n" " (parameters\n" - " (declare (in ) float p@0x8e9c10)\n" + " (declare (in ) float p@0xb2ba00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 p@0x8e9fc0)\n" + " (declare (in ) vec2 p@0xb2bd80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 p@0x8ea1a0)\n" + " (declare (in ) vec3 p@0xb2bf60)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 p@0x8ea380)\n" + " (declare (in ) vec4 p@0xb2c140)\n" " )\n" " (\n" " ))\n" @@ -14451,28 +24001,28 @@ static const char *prototypes_for_120_frag = "(function fwidth\n" " (signature float\n" " (parameters\n" - " (declare (in ) float p@0x8ea560)\n" + " (declare (in ) float p@0xb2c320)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 p@0x8ea910)\n" + " (declare (in ) vec2 p@0xb2c6a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 p@0x8eaaf0)\n" + " (declare (in ) vec3 p@0xb2c880)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 p@0x8eacd0)\n" + " (declare (in ) vec4 p@0xb2ca60)\n" " )\n" " (\n" " ))\n" @@ -14482,28 +24032,28 @@ static const char *prototypes_for_120_frag = "(function noise1\n" " (signature float\n" " (parameters\n" - " (declare (in ) float x@0x8eaeb0)\n" + " (declare (in ) float x@0xb2cc40)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec2 x@0x8eb260)\n" + " (declare (in ) vec2 x@0xb2cfc0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec3 x@0x8eb440)\n" + " (declare (in ) vec3 x@0xb2d1a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature float\n" " (parameters\n" - " (declare (in ) vec4 x@0x8eb620)\n" + " (declare (in ) vec4 x@0xb2d380)\n" " )\n" " (\n" " ))\n" @@ -14513,28 +24063,28 @@ static const char *prototypes_for_120_frag = "(function noise2\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) float x@0x8eb800)\n" + " (declare (in ) float x@0xb2d560)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec2 x@0x8ebbb0)\n" + " (declare (in ) vec2 x@0xb2d8e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec3 x@0x8ebd90)\n" + " (declare (in ) vec3 x@0xb2dac0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec2\n" " (parameters\n" - " (declare (in ) vec4 x@0x8ebf70)\n" + " (declare (in ) vec4 x@0xb2dca0)\n" " )\n" " (\n" " ))\n" @@ -14544,28 +24094,28 @@ static const char *prototypes_for_120_frag = "(function noise3\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) float x@0x8ec150)\n" + " (declare (in ) float x@0xb2de80)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec2 x@0x8ec500)\n" + " (declare (in ) vec2 x@0xb2e200)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec3 x@0x8ec6e0)\n" + " (declare (in ) vec3 x@0xb2e3e0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec3\n" " (parameters\n" - " (declare (in ) vec4 x@0x8ec8c0)\n" + " (declare (in ) vec4 x@0xb2e5c0)\n" " )\n" " (\n" " ))\n" @@ -14575,28 +24125,28 @@ static const char *prototypes_for_120_frag = "(function noise4\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) float x@0x8ecaa0)\n" + " (declare (in ) float x@0xb2e7a0)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec2 x@0x8ece50)\n" + " (declare (in ) vec2 x@0xb2eb20)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec3 x@0x8ed030)\n" + " (declare (in ) vec3 x@0xb2ed00)\n" " )\n" " (\n" " ))\n" "\n" " (signature vec4\n" " (parameters\n" - " (declare (in ) vec4 x@0x8ed210)\n" + " (declare (in ) vec4 x@0xb2eee0)\n" " )\n" " (\n" " ))\n" @@ -14771,6 +24321,22 @@ _mesa_glsl_initialize_functions(exec_list *instructions, state->num_builtins_to_link++; } + if (state->target == fragment_shader && state->language_version == 130) { + static gl_shader *sh = NULL; + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, + prototypes_for_130_frag, + functions_for_130_frag, + Elements(functions_for_130_frag )); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, + state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } + if (state->target == vertex_shader && state->ARB_texture_rectangle_enable) { static gl_shader *sh = NULL; if (sh == NULL) { @@ -14787,6 +24353,22 @@ _mesa_glsl_initialize_functions(exec_list *instructions, state->num_builtins_to_link++; } + if (state->target == vertex_shader && state->language_version == 130) { + static gl_shader *sh = NULL; + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, + prototypes_for_130_vert, + functions_for_130_vert, + Elements(functions_for_130_vert )); + talloc_steal(builtin_mem_ctx, sh); + } + + import_prototypes(sh->ir, instructions, state->symbols, + state); + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; + } + if (state->target == fragment_shader && state->ARB_texture_rectangle_enable) { static gl_shader *sh = NULL; if (sh == NULL) { -- cgit v1.2.3